本文整理汇总了PHP中Anchors类的典型用法代码示例。如果您正苦于以下问题:PHP Anchors类的具体用法?PHP Anchors怎么用?PHP Anchors使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Anchors类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: layout
/**
* list links
*
* @param resource the SQL result
* @return array of resulting items, or NULL
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($url => $attributes)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// process all items in the list
while ($item = SQL::fetch($result)) {
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// url is the link itself -- hack for xhtml compliance
$url = str_replace('&', '&', $item['link_url']);
// initialize variables
$prefix = $suffix = '';
// flag links that are dead, or created or updated very recently
if ($item['edit_date'] >= $context['fresh']) {
$suffix = NEW_FLAG;
}
// make a label
$label = Links::clean($item['title'], $item['link_url']);
// the main anchor link
if (is_object($anchor)) {
$suffix .= ' - <span class="details">' . sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()))) . '</span>';
}
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
}
// end of processing
SQL::free($result);
return $items;
}
开发者ID:rair,项目名称:yacs,代码行数:42,代码来源:layout_links_as_simple.php
示例2: get_comment_notification
public function get_comment_notification($item)
{
global $context;
// build a tease notification for simple members
// sanity check
if (!isset($item['anchor']) || !($anchor = Anchors::get($item['anchor']))) {
throw new Exception('no anchor for this comment');
}
// headline
$headline = sprintf(i18n::c('%s has replied'), Surfer::get_link());
$content = BR;
// shape these
$tease = Skin::build_mail_content($headline, $content);
// a set of links
$menu = array();
// call for action
$link = $context['url_to_home'] . $context['url_to_root'] . Comments::get_url($item['id'], 'view');
$menu[] = Skin::build_mail_button($link, i18n::c('View the reply'), TRUE);
// link to the container
$menu[] = Skin::build_mail_button($anchor->get_url(), $anchor->get_title(), FALSE);
// finalize links
$tease .= Skin::build_mail_menu($menu);
// assemble all parts of the mail
$mail = array();
$mail['subject'] = sprintf(i18n::c('%s: %s'), i18n::c('Reply in the discussion'), strip_tags($anchor->get_title()));
$mail['notification'] = Comments::build_notification($item);
// full notification
$mail['tease'] = Mailer::build_notification($tease, 1);
return $mail;
}
开发者ID:rair,项目名称:yacs,代码行数:30,代码来源:thread.php
示例3: cascade
/**
* cascade to children
*
* @param string referencing of the changed anchor
* @param string rights to be cascaded (e.g., 'Y', 'R' or 'N')
*/
public static function cascade($reference, $active)
{
global $context;
// only sections may have sub-sections
if (strpos($reference, 'section:') === 0) {
// cascade to sub-sections
if ($items = Sections::list_for_anchor($reference, 'raw')) {
// cascade to each section individually
foreach ($items as $id => $item) {
// limit actual rights
$item['active'] = Anchors::ceil_rights($active, $item['active_set']);
$query = "UPDATE " . SQL::table_name('sections') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
SQL::query($query);
// cascade to children
Anchors::cascade('section:' . $item['id'], $item['active']);
}
}
}
// only categories may have sub-categories
if (strpos($reference, 'category:') === 0) {
// cascade to sub-categories
if ($items = Categories::list_for_anchor($reference, 'raw')) {
// cascade to each section individually
foreach ($items as $id => $item) {
// limit actual rights
$item['active'] = Anchors::ceil_rights($active, $item['active_set']);
$query = "UPDATE " . SQL::table_name('categories') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
SQL::query($query);
// cascade to children
Anchors::cascade('category:' . $item['id'], $item['active']);
}
}
}
// only sections may have articles
if (strpos($reference, 'section:') === 0) {
// cascade to articles --up to 3000
if ($items =& Articles::list_for_anchor_by('edition', $reference, 0, 3000, 'raw')) {
// cascade to each section individually
foreach ($items as $id => $item) {
// limit actual rights
$item['active'] = Anchors::ceil_rights($active, $item['active_set']);
$query = "UPDATE " . SQL::table_name('articles') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
SQL::query($query);
// cascade to children
Anchors::cascade('article:' . $item['id'], $item['active']);
}
}
}
// cascade to files --up to 3000
if ($items = Files::list_by_date_for_anchor($reference, 0, 3000, 'raw')) {
// cascade to each section individually
foreach ($items as $id => $item) {
// limit actual rights
$item['active'] = Anchors::ceil_rights($active, $item['active_set']);
$query = "UPDATE " . SQL::table_name('files') . " SET active='" . SQL::escape($item['active']) . "' WHERE id = " . SQL::escape($id);
SQL::query($query);
}
}
}
开发者ID:rair,项目名称:yacs,代码行数:65,代码来源:anchors.php
示例4: layout
/**
* list images
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// we return an array of ($url => $attributes)
$items = array();
// process all items in the list
while ($item = SQL::fetch($result)) {
// get the anchor for this image
if ($item['anchor']) {
$anchor = Anchors::get($item['anchor']);
}
// url to view the image
$url = $context['url_to_home'] . $context['url_to_root'] . Images::get_url($item['id']);
// time of last update
$time = SQL::strtotime($item['edit_date']);
// the title as the label
if ($item['title']) {
$label = ucfirst($item['title']) . ' (' . $item['image_name'] . ')';
} else {
$label = $item['image_name'];
}
// the section
$section = '';
if (is_object($anchor)) {
$section = ucfirst($anchor->get_title());
}
// the author(s) is an e-mail address, according to rss 2.0 spec
$author = $item['create_address'] . ' (' . $item['create_name'] . ')';
if ($item['create_address'] != $item['edit_address']) {
if ($author) {
$author .= ', ';
}
$author .= $item['edit_address'] . ' (' . $item['edit_name'] . ')';
}
// the description
$description = Codes::beautify($item['description']);
// cap the number of words
$description = Skin::cap($description, 300);
// fix image references
$description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description);
$introduction = $description;
// other rss fields
$extensions = array();
// url for enclosure
$type = Files::get_mime_type($item['image_name']);
$extensions[] = '<enclosure url="' . $context['url_to_home'] . $context['url_to_root'] . Files::get_path($item['anchor'], 'images') . '/' . $item['image_name'] . '"' . ' length="' . $item['image_size'] . '"' . ' type="' . $type . '" />';
// list all components for this item
$items[$url] = array($time, $label, $author, $section, NULL, $introduction, $description, $extensions);
}
// end of processing
SQL::free($result);
return $items;
}
开发者ID:rair,项目名称:yacs,代码行数:66,代码来源:layout_images_as_feed.php
示例5: layout
/**
* list files
*
* @param resource the SQL result
* @return array of resulting items, or NULL
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($url => $attributes)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// sanity check
if (!isset($this->layout_variant)) {
$this->layout_variant = 'full';
}
// process all items in the list
while ($item = SQL::fetch($result)) {
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// download the file directly
$url = Files::get_url($item['id'], 'fetch', $item['file_name']);
// initialize variables
$prefix = $suffix = '';
// flag files that are dead, or created or updated very recently
if ($item['create_date'] >= $context['fresh']) {
$suffix .= NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= UPDATED_FLAG;
}
// signal restricted and private files
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// file title or file name
$label = Codes::beautify_title($item['title']);
if (!$label) {
$label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name']));
}
// the main anchor link, except on user profiles
if (is_object($anchor) && $anchor->get_reference() != $this->focus) {
$suffix .= ' - <span class="details">' . sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()))) . '</span>';
}
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, 'basic', NULL);
}
// end of processing
SQL::free($result);
return $items;
}
开发者ID:rair,项目名称:yacs,代码行数:57,代码来源:layout_files_as_simple.php
示例6: layout
/**
* list links
*
* @param resource the SQL result
* @return array of resulting items, or NULL
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($url => $attributes)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// process all items in the list
while ($item = SQL::fetch($result)) {
// get the anchor for this link
if ($item['anchor']) {
$anchor = Anchors::get($item['anchor']);
}
// url is the link itself
$url = $item['link_url'];
// time of last update
$time = SQL::strtotime($item['edit_date']);
// the title as the label
if ($item['title']) {
$label = $item['title'];
} else {
$label = $url;
}
// the section
$section = '';
if (is_object($anchor)) {
$section = ucfirst($anchor->get_title());
}
// the author(s) is an e-mail address, according to rss 2.0 spec
$author = $item['edit_address'] . ' (' . $item['edit_name'] . ')';
// the description
$description = Codes::beautify($item['description']);
// cap the number of words
$description = Skin::cap($description, 300);
// fix image references
$description = preg_replace('#"/([^">]+?)"#', '"' . $context['url_to_home'] . '/$1"', $description);
$introduction = $description;
// other rss fields
$extensions = array();
// list all components for this item
$items[$url] = array($time, $label, $author, $section, NULL, $introduction, $description, $extensions);
}
// end of processing
SQL::free($result);
return $items;
}
开发者ID:rair,项目名称:yacs,代码行数:56,代码来源:layout_links_as_feed.php
示例7: delete
/**
* delete one server in the database
*
* @param int the id of the server to delete
* @return boolean TRUE on success, FALSE otherwise
*
* @see servers/delete.php
*/
public static function delete($id)
{
global $context;
// id cannot be empty
if (!$id || !is_numeric($id)) {
return FALSE;
}
// delete related items
Anchors::delete_related_to('server:' . $id);
// delete the record in the database
$query = "DELETE FROM " . SQL::table_name('servers') . " WHERE id = " . $id;
if (SQL::query($query) === FALSE) {
return FALSE;
}
// job done
return TRUE;
}
开发者ID:rair,项目名称:yacs,代码行数:25,代码来源:servers.php
示例8: add_commands
/**
* extend the page menu
*
* @param string script name
* @param string target anchor, if any
* @param array current menu
* @return array updated menu
*/
function add_commands($script, $anchor, $menu = array())
{
global $context;
// limit the scope of our check to viewed pages
if (!preg_match('/articles\\/view/', $script)) {
return $menu;
}
// surfer has to be authenticated
if (!Surfer::is_logged()) {
return $menu;
}
// sanity checks
if (!$anchor) {
Logger::error(i18n::s('No anchor has been found.'));
} elseif (!($target = Anchors::get($anchor))) {
Logger::error(i18n::s('No anchor has been found.'));
} elseif (!$this->parameters) {
Logger::error(sprintf(i18n::s('No parameter has been provided to %s'), 'behaviors/move_on_article_access'));
} else {
// look at parent container if possible
if (!($origin = Anchors::get($target->get_parent()))) {
$origin = $target;
}
// only container editors can proceed
if ($origin->is_assigned() || Surfer::is_associate()) {
// load target section
$tokens = explode(' ', $this->parameters, 2);
if ($section = Anchors::get('section:' . $tokens[0])) {
// make a label
if (count($tokens) < 2) {
$tokens[1] = sprintf(i18n::s('Move to %s'), $section->get_title());
}
// the target link to move the page
$link = Articles::get_url(str_replace('article:', '', $anchor), 'move', str_replace('section:', '', $section->get_reference()));
// make a sub-menu
$menu = array_merge(array($link => array('', $tokens[1], '', 'button')), $menu);
}
}
}
return $menu;
}
开发者ID:rair,项目名称:yacs,代码行数:49,代码来源:move_on_article_access.php
示例9: layout_recent
/**
* layout one recent article
*
* @param array the article
* @return an array ($prefix, $label, $suffix)
**/
function layout_recent($item)
{
global $context;
// permalink
$url = Articles::get_permalink($item);
// get the related overlay, if any
$overlay = Overlay::load($item, 'article:' . $item['id']);
// get the anchor
$anchor = Anchors::get($item['anchor']);
// use the title to label the link
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$title = Codes::beautify_title($item['title']);
}
// reset everything
$prefix = $suffix = '';
// signal restricted and private articles
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// rating
if ($item['rating_count']) {
$suffix .= Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
}
// the introductory text
$introduction = '';
if (is_object($overlay)) {
$introduction = $overlay->get_text('introduction', $item);
} elseif ($item['introduction']) {
$introduction = $item['introduction'];
}
if ($introduction) {
$suffix .= ' - ' . Codes::beautify_introduction($introduction);
}
// other details
$details = array();
// the author
$author = '';
if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
$author = sprintf(i18n::s('by %s'), $item['create_name']) . ' ';
}
// date
$details[] = $author . Skin::build_date($item['publish_date']);
// info on related files
if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'basic');
}
// info on related comments
$link = Comments::get_url('article:' . $item['id'], 'list');
if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = Skin::build_link($link, sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'basic');
}
// discuss
if (Comments::allow_creation($item, $anchor)) {
$details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Discuss'), 'basic');
}
// info on related links
if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'basic');
}
// append a menu
$suffix .= Skin::finalize_list($details, 'menu');
// display all tags
if ($item['tags']) {
$suffix .= ' <p class="tags" style="margin-top: 3px;">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</p>';
}
// insert an array of links
return array($prefix, $title, $suffix);
}
开发者ID:rair,项目名称:yacs,代码行数:78,代码来源:layout_articles_as_newspaper.php
示例10: layout
/**
* main function to render layout
*
* @param type $result MySQL object
* @return string the rendering
*/
public function layout($result)
{
global $context;
// we return some text
$text = '';
// type of listed object
$items_type = $this->listed_type;
// this level root reference
if (isset($this->focus) && $this->focus) {
$root_ref = $this->focus;
} elseif (isset($context['current_item']) && $context['current_item']) {
$root_ref = $context['current_item'];
} else {
$root_ref = $items_type . ':index';
}
$this->tree_only = $this->has_variant('tree_only');
// drag&drop zone
$text .= '<div class="tm-ddz tm-drop" data-ref="' . $root_ref . '" data-variant="' . $this->layout_variant . '" >' . "\n";
// root create command
$text .= $this->btn_create();
// root ul
$text .= '<ul class="tm-sub_elems tm-root">' . "\n";
while ($item = SQL::fetch($result)) {
// get the object interface, this may load parent and overlay
$entity = new $items_type($item);
// title
$title = '<a class="tm-zoom" href="' . $entity->get_permalink() . '"><span class="tm-folder">' . $entity->get_title() . '</span></a>';
// sub elements of this entity
$sub = $this->get_sub_level($entity);
// command related to this entity
$cmd = $this->get_interactive_menu();
// one <li> per entity of this level of the tree
$text .= '<li class="tm-drag tm-drop" data-ref="' . $entity->get_reference() . '">' . $title . $cmd . $sub . '</li>' . "\n";
}
// this level may have childs that are not folders (exept index)
// do not search in variant tree_only is setted
if (!preg_match('/index$/', $root_ref) && !$this->tree_only) {
$thislevel = Anchors::get($root_ref);
$text .= $this->get_sub_level($thislevel, true);
// do not search for folders
}
// we have bound styles and scripts, but do not provide on ajax requests
if (!isset($context['AJAX_REQUEST']) || !$context['AJAX_REQUEST']) {
$this->load_scripts_n_styles();
// init js depending on user privilege for this level
if (isset($thislevel)) {
// get surfer privilege for this level
$powered = $thislevel->allows('creation');
} else {
$powered = Surfer::is_associate();
}
$powered = $powered ? 'powered' : '';
// cast to string
Page::insert_script('TreeManager.init("' . $powered . '");');
}
// end drag drop zone
$text .= '</ul></div>' . "\n";
// end of processing
SQL::free($result);
return $text;
}
开发者ID:rair,项目名称:yacs,代码行数:67,代码来源:layout_as_tree_manager.php
示例11: elseif
include_once '../shared/global.php';
include_once 'servers.php';
// look for the id
$id = NULL;
if (isset($_REQUEST['id'])) {
$id = $_REQUEST['id'];
} elseif (isset($context['arguments'][0])) {
$id = $context['arguments'][0];
}
$id = strip_tags($id);
// get the item from the database
$item = Servers::get($id);
// get the related anchor, if any
$anchor = NULL;
if (isset($item['anchor']) && $item['anchor']) {
$anchor = Anchors::get($item['anchor']);
}
// associates can do what they want
if (Surfer::is_associate()) {
$permitted = TRUE;
} elseif (is_object($anchor) && !$anchor->is_viewable()) {
$permitted = FALSE;
} elseif ($item['active'] == 'R' && Surfer::is_member()) {
$permitted = TRUE;
} elseif ($item['active'] == 'Y') {
$permitted = TRUE;
} else {
$permitted = FALSE;
}
// load the skin
load_skin('servers');
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:view.php
示例12: encode_field
// the current list of linked sections
$sections =& Members::list_sections_by_title_for_anchor($anchor->get_reference(), 0, SECTIONS_LIST_SIZE, 'raw');
// the form to link additional sections
if (!is_array($sections) || count($sections) < SECTIONS_LIST_SIZE) {
$context['text'] .= '<form method="post" action="' . $context['script_url'] . '"><p>' . i18n::s('To assign a section, look in the content tree below and assign one section at a time') . BR . '<select name="member">' . Sections::get_options(NULL, $sections) . '</select>' . ' ' . Skin::build_submit_button(' >> ') . '<input type="hidden" name="anchor" value="' . encode_field($anchor->get_reference()) . '">' . '<input type="hidden" name="action" value="set">' . '</p></form>' . "\n";
}
// splash
$context['text'] .= '<p style="margin-top: 2em;">' . sprintf(i18n::s('This is the list of sections assigned to %s'), $anchor->get_title()) . '</p>';
// layout assigned sections
if ($sections) {
// browse the list
foreach ($sections as $id => $section) {
// get the related overlay, if any
$overlay = Overlay::load($section, 'section:' . $id);
// get parent anchor
$parent = Anchors::get($section['anchor']);
// the url to view this item
$url = Sections::get_permalink($section);
// use the title to label the link
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $section));
} else {
$title = Codes::beautify_title($section['title']);
}
// initialize variables
$prefix = $suffix = $icon = '';
// flag sticky pages
if ($section['rank'] < 10000) {
$prefix .= STICKY_FLAG;
}
// signal restricted and private sections
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:select.php
示例13: layout
/**
* list articles
*
* @param resource the SQL result
* @return array
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($url => $attributes)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// process all items in the list
include_once $context['path_to_root'] . 'articles/article.php';
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'locations/locations.php';
while ($item = SQL::fetch($result)) {
// get the related overlay, if any
$overlay = Overlay::load($item, 'article:' . $item['id']);
// get the anchor
$anchor = Anchors::get($item['anchor']);
// provide an absolute link
$url = Articles::get_permalink($item);
// build a title
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$title = Codes::beautify_title($item['title']);
}
// time of last update
$time = SQL::strtotime($item['edit_date']);
// the section
$section = '';
if ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
$section = ucfirst(trim(strip_tags(Codes::beautify_title($anchor->get_title()))));
}
// the icon to use
$icon = '';
if ($item['thumbnail_url']) {
$icon = $item['thumbnail_url'];
} elseif ($item['anchor'] && ($anchor = Anchors::get($item['anchor'])) && is_callable($anchor, 'get_bullet_url')) {
$icon = $anchor->get_bullet_url();
}
if ($icon) {
$icon = $context['url_to_home'] . $context['url_to_root'] . $icon;
}
// the author(s) is an e-mail address, according to rss 2.0 spec
$author = '';
if (isset($item['create_address'])) {
$author .= $item['create_address'];
}
if (isset($item['create_name']) && trim($item['create_name'])) {
$author .= ' (' . $item['create_name'] . ')';
}
if (isset($item['edit_address']) && trim($item['edit_address']) && $item['create_address'] != $item['edit_address']) {
if ($author) {
$author .= ', ';
}
$author .= $item['edit_address'];
if (isset($item['edit_name']) && trim($item['edit_name'])) {
$author .= ' (' . $item['edit_name'] . ')';
}
}
// some introductory text for this article
$article = new Article();
$article->load_by_content($item);
$introduction = $article->get_teaser('teaser');
// warns on restricted access
if (isset($item['active']) && $item['active'] != 'Y') {
$introduction = '[' . i18n::c('Restricted to members') . '] ' . $introduction;
}
// fix references
$introduction = preg_replace('/"\\//', '"' . $context['url_to_home'] . '/', $introduction);
// the article content
$description = '';
// other rss fields
$extensions = array();
// the geolocation for this page, if any
if ($location = Locations::locate_anchor('article:' . $item['id'])) {
$extensions[] = '<georss:point>' . str_replace(',', ' ', $location) . '</georss:point>';
}
// url for comments
if (is_object($anchor)) {
$extensions[] = '<comments>' . encode_link($context['url_to_home'] . $context['url_to_root'] . $anchor->get_url('comments')) . '</comments>';
}
// count comments
$comment_count = Comments::count_for_anchor('article:' . $item['id']);
$extensions[] = '<slash:comments>' . $comment_count . "</slash:comments>";
// the comment post url
$extensions[] = '<wfw:comment>' . encode_link($context['url_to_home'] . $context['url_to_root'] . Comments::get_url('article:' . $item['id'], 'service.comment')) . "</wfw:comment>";
// the comment Rss url
$extensions[] = '<wfw:commentRss>' . encode_link($context['url_to_home'] . $context['url_to_root'] . Comments::get_url('article:' . $item['id'], 'feed')) . "</wfw:commentRss>";
// the trackback url
$extensions[] = '<trackback:ping>' . encode_link($context['url_to_home'] . $context['url_to_root'] . 'links/trackback.php?anchor=' . urlencode('article:' . $item['id'])) . "</trackback:ping>";
// no trackback:about;
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:layout_articles_as_feed.php
示例14: while
$query = "SELECT id, anchor FROM " . SQL::table_name('comments') . " ORDER BY anchor LIMIT 0, 100000";
if (!($result = SQL::query($query))) {
return;
} else {
// fetch one anchor and the linked member
$errors_count = 0;
while ($row = SQL::fetch($result)) {
// animate user screen and take care of time
$count++;
if (!($count % 500)) {
$context['text'] .= sprintf(i18n::s('%d records have been processed'), $count) . BR . "\n";
// ensure enough execution time
Safe::set_time_limit(30);
}
// check that the anchor exists, if any
if ($row['anchor'] && !Anchors::get($row['anchor'])) {
$context['text'] .= sprintf(i18n::s('Orphan: %s'), 'comment ' . Skin::build_link(Comments::get_url($row['id']), $row['id'])) . BR . "\n";
if (++$errors_count >= 5) {
$context['text'] .= i18n::s('Too many successive errors. Aborted') . BR . "\n";
break;
}
} else {
$errors_count = 0;
}
}
}
// ending message
$context['text'] .= sprintf(i18n::s('%d records have been processed'), $count) . BR . "\n";
// display the execution time
$time = round(get_micro_time() - $context['start_time'], 2);
$context['text'] .= '<p>' . sprintf(i18n::s('Script terminated in %.2f seconds.'), $time) . '</p>';
开发者ID:rair,项目名称:yacs,代码行数:31,代码来源:check.php
示例15: layout
/**
* list links
*
* Recognize following variants:
* - 'no_anchor' to list items attached to one particular anchor
* - 'no_author' to list items attached to one user prolink
*
* @param resource the SQL result
* @return array of resulting items, or NULL
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($url => $attributes)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// sanity check
if (!isset($this->layout_variant)) {
$this->layout_variant = 'no_anchor';
}
// process all items in the list
while ($item = SQL::fetch($result)) {
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// initialize variables
$prefix = $suffix = $icon = '';
// make a label
$label = Links::clean($item['title'], $item['link_url']);
// flag links uploaded recently
if ($item['edit_date'] >= $context['fresh']) {
$prefix = NEW_FLAG . $prefix;
}
// the number of clicks
if ($item['hits'] > 1) {
$suffix .= ' (' . Skin::build_number($item['hits'], i18n::s('clicks')) . ') ';
}
// add a separator
if ($suffix) {
$suffix = ' - ' . $suffix;
}
// details
$details = array();
// item poster
if ($item['edit_name'] && $this->layout_variant != 'no_author') {
if (Surfer::is_member() || (!isset($context['content_without_details']) || $context['content_without_details'] != 'Y') || is_object($anchor) && $anchor->has_option('with_details')) {
$details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
}
}
// show an anchor link
if ($this->layout_variant != 'no_anchor' && $this->layout_variant != 'no_author' && $item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
$anchor_url = $anchor->get_url();
$anchor_label = ucfirst($anchor->get_title());
$details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor_url, $anchor_label, 'article'));
}
// the menu bar for associates and poster
if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
$details[] = Skin::build_link('links/edit.php?id=' . $item['id'], i18n::s('edit'), 'span');
$details[] = Skin::build_link('links/delete.php?id=' . $item['id'], i18n::s('delete'), 'span');
}
// append details to the suffix
if (count($details)) {
$suffix .= BR . Skin::finalize_list($details, 'menu');
}
// description
if ($item['description']) {
$suffix .= BR . Codes::beautify($item['description']);
}
// build the actual link to check it
if ($this->layout_variant == 'review') {
$icon = $item['link_url'];
}
// url is the link itself -- hack for xhtml compliance
$url = str_replace('&', '&', $item['link_url']);
// let the rendering engine guess the type of link
$link_type = NULL;
// except if we want to stay within this window
if (isset($item['link_target']) && $item['link_target'] != 'I') {
$link_type = 'external';
}
// hovering title
$link_title = NULL;
if (isset($item['link_title']) && $item['link_title']) {
$link_title = $item['link_title'];
}
// pack everything
$items[$url] = array($prefix, $label, $suffix, $link_type, $icon, $link_title);
}
// end of processing
SQL::free($result);
return $items;
}
开发者ID:rair,项目名称:yacs,代码行数:96,代码来源:layout_links.php
示例16: layout
/**
* list articles
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return some text
$text = '';
// empty list
if (!SQL::count($result)) {
return $text;
}
// the script used to check all pages at once
Page::insert_script('function cascade_selection_to_all_article_rows(handle) {' . "\n" . ' $("div#articles_panel input[type=\'checkbox\'].row_selector").each(' . "\n" . ' function() { $(this).attr("checked", $(handle).is(":checked"));}' . "\n" . ' );' . "\n" . '}' . "\n");
// table prefix
$text .= Skin::table_prefix('yc-grid');
// table headers
$main = '<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />';
$cells = array($main, i18n::s('Page'), i18n::s('Rank'));
$text .= Skin::table_row($cells, 'header');
// process all items in the list
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
$count = 0;
while ($item = SQL::fetch($result)) {
$cells = array();
// get the related overlay, if any
$overlay = Overlay::load($item, 'article:' . $item['id']);
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// the url to view this item
$url = Articles::get_permalink($item);
// column to select the row
$cells[] = '<input type="checkbox" name="selected_articles[]" id="article_selector_' . $count . '" class="row_selector" value="' . $item['id'] . '" />';
// use the title to label the link
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$title = Codes::beautify_title($item['title']);
}
// initialize variables
$prefix = $suffix = $icon = '';
// flag sticky pages
if ($item['rank'] < 10000) {
$prefix .= STICKY_FLAG;
}
// signal locked articles
if (isset($item['locked']) && $item['locked'] == 'Y') {
$suffix .= ' ' . LOCKED_FLAG;
}
// flag articles that are dead, or created or updated very recently
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$prefix .= EXPIRED_FLAG;
} elseif ($item['create_date'] >= $context['fresh']) {
$suffix .= ' ' . NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= ' ' . UPDATED_FLAG;
}
// signal articles to be published
if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
$prefix .= DRAFT_FLAG;
}
// signal restricted and private articles
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// the introductory text
if (is_object($overlay)) {
$introduction = $overlay->get_text('introduction', $item);
} else {
$introduction = $item['introduction'];
}
if ($introduction) {
$suffix .= BR . Codes::beautify_introduction($introduction);
}
// insert overlay data, if any
if (is_object($overlay)) {
$suffix .= $overlay->get_text('list', $item);
}
// append details to the suffix
$suffix .= BR . '<span class="details">';
// details
$details = array();
// the author
if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
if ($item['create_name'] != $item['edit_name']) {
$details[] = sprintf(i18n::s('by %s, %s'), $item['create_name'], $item['edit_name']);
} else {
$details[] = sprintf(i18n::s('by %s'), $item['create_name']);
}
}
// the last action
$details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']);
//.........这里部分代码省略.........
开发者ID:rair,项目名称:yacs,代码行数:101,代码来源:layout_articles_as_manage.php
示例17: layout
/**
* list articles as an index
*
* @param resource the SQL result
* @return string the rendered text
**/
function layout($result)
{
global $context;
// we return some text
$text = '';
// referenced items
$letters = array();
// empty list
if (!SQL::count($result)) {
return $text;
}
// build a list of articles
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// get the related overlay, if any
$overlay = Overlay::load($item, 'article:' . $item['id']);
// get the anchor
$anchor = Anchors::get($item['anchor']);
// the url to view this item
$url = Articles::get_permalink($item);
// use the title to label the link
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$title = Codes::beautify_title($item['title']);
}
// reset everything
$prefix = $label = $suffix = $icon = $details = '';
// signal articles to be published
if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
$prefix .= DRAFT_FLAG;
}
// signal restricted and private articles
if (isset($item['active']) && $item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif (isset($item['active']) && $item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// flag articles updated recently
|
请发表评论