本文整理汇总了PHP中Sections::stat_for_anchor方法的典型用法代码示例。如果您正苦于以下问题:PHP Sections::stat_for_anchor方法的具体用法?PHP Sections::stat_for_anchor怎么用?PHP Sections::stat_for_anchor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sections
的用法示例。
在下文中一共展示了Sections::stat_for_anchor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: layout
/**
* list sections
*
* @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_section_rows(handle) {' . "\n" . ' $("div#sections_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_section_rows(this);" />';
$cells = array($main, i18n::s('Section'), 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, 'section:' . $item['id']);
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// the url to view this item
$url = Sections::get_permalink($item);
// column to select the row
$cells[] = '<input type="checkbox" name="selected_sections[]" id="section_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($item['title']);
}
// initialize variables
$prefix = $suffix = $icon = '';
// flag sticky pages
if ($item['rank'] < 10000) {
$prefix .= STICKY_FLAG;
}
// signal locked sections
if (isset($item['locked']) && $item['locked'] == 'Y') {
$suffix .= ' ' . LOCKED_FLAG;
}
// flag sections 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 restricted and private sections
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// the introductory text
if ($item['introduction']) {
$suffix .= BR . Codes::beautify_introduction($item['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();
// info on related pages
$stats = Articles::stat_for_anchor('section:' . $item['id']);
if ($stats['count']) {
$details[] = sprintf(i18n::ns('%d page', '%d pages', $stats['count']), $stats['count']);
}
// info on related files
$stats = Files::stat_for_anchor('section:' . $item['id']);
if ($stats['count']) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $stats['count']), $stats['count']);
}
// info on related links
$stats = Links::stat_for_anchor('section:' . $item['id']);
if ($stats['count']) {
$details[] = sprintf(i18n::ns('%d link', '%d links', $stats['count']), $stats['count']);
}
// info on related comments
$stats = Comments::stat_for_anchor('section:' . $item['id']);
if ($stats['count']) {
$details[] = sprintf(i18n::ns('%d comment', '%d comments', $stats['count']), $stats['count']);
//.........这里部分代码省略.........
示例2: elseif
Cache::clear();
// back to the anchor page or to the index page
if (is_object($overlay) && ($back_url = $overlay->get_url_after_deleting())) {
Safe::redirect($back_url);
} elseif (is_object($anchor)) {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . $anchor->get_url());
} else {
Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'sections/');
}
}
// deletion has to be confirmed
} elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') {
Logger::error(i18n::s('The action has not been confirmed.'));
} else {
// all sub-sections have not been deleted
if (($stats = Sections::stat_for_anchor('section:' . $item['id'])) && $stats['count']) {
Logger::error(i18n::s('Warning: related content will be deleted as well.'));
}
// all articles have not been deleted
if ($count = Articles::count_for_anchor('section:' . $item['id'])) {
Logger::error(i18n::s('Warning: related content will be deleted as well.'));
}
// commands
$menu = array();
$menu[] = Skin::build_submit_button(i18n::s('Yes, I want to delete this section'), NULL, NULL, 'confirmed');
if (isset($item['id'])) {
$menu[] = Skin::build_link(Sections::get_permalink($item), i18n::s('Cancel'), 'span');
}
// the submit button
$context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . "\n" . Skin::finalize_list($menu, 'menu_bar') . '<input type="hidden" name="id" value="' . $item['id'] . '" />' . "\n" . '<input type="hidden" name="confirm" value="yes" />' . "\n" . '</p></form>' . "\n";
// set the focus
示例3: stat_related_to
/**
* count related items
*
* This function draws a nice table to show how many items are related to
* the anchor that has the focus.
*
* @param string the target reference
* @param string the label to use, if any
* @return string some XHTML snippet to send to the browser
*/
public static function stat_related_to($anchor, $label = NULL)
{
global $context;
// describe related content
$related = '';
$lines = 2;
// stats for related categories, but only within categories
if (strpos($anchor, 'category:') === 0) {
if (($stats = Categories::stat_for_anchor($anchor)) && $stats['count']) {
$cells = array();
$cells[] = i18n::s('Categories');
$cells[] = 'center=' . $stats['count'];
$cells[] = 'center=' . Skin::build_date($stats['oldest_date']);
$cells[] = 'center=' . Skin::build_date($stats['newest_date']);
$related .= Skin::table_row($cells, $lines++);
}
}
// stats for related sections, but only within sections
if (strpos($anchor, 'section:') === 0) {
if (($stats = Sections::stat_for_anchor($anchor)) && $stats['count']) {
$cells = array();
$cells[] = i18n::s('Sections');
$cells[] = 'center=' . $stats['count'];
$cells[] = 'center=' . Skin::build_date($stats['oldest_date']);
$cells[] = 'center=' . Skin::build_date($stats['newest_date']);
$related .= Skin::table_row($cells, $lines++);
}
}
// stats for related articles, but only within sections
if (strpos($anchor, 'section:') === 0) {
if (($stats = Articles::stat_for_anchor($anchor)) && $stats['count']) {
$cells = array();
$cells[] = i18n::s('Pages');
$cells[] = 'center=' . $stats['count'];
$cells[] = 'center=' . Skin::build_date($stats['oldest_date']);
$cells[] = 'center=' . Skin::build_date($stats['newest_date']);
$related .= Skin::table_row($cells, $lines++);
}
}
// stats for related images
include_once $context['path_to_root'] . 'images/images.php';
if (($stats = Images::stat_for_anchor($anchor)) && $stats['count']) {
$cells = array();
$cells[] = i18n::s('Images');
$cells[] = 'center=' . $stats['count'];
$cells[] = 'center=' . Skin::build_date($stats['oldest_date']);
$cells[] = 'center=' . Skin::build_date($stats['newest_date']);
$related .= Skin::table_row($cells, $lines++);
}
// stats for related locations
include_once $context['path_to_root'] . 'locations/locations.php';
if (($stats = Locations::stat_for_anchor($anchor)) && $stats['count']) {
$cells = array();
$cells[] = i18n::s('Locations');
$cells[] = 'center=' . $stats['count'];
$cells[] = 'center=' . Skin::build_date($stats['oldest_date']);
$cells[] = 'center=' . Skin::build_date($stats['newest_date']);
$related .= Skin::table_row($cells, $lines++);
}
// stats for related tables
include_once $context['path_to_root'] . 'tables/tables.php';
if (($stats = Tables::stat_for_anchor($anchor)) && $stats['count']) {
$cells = array();
$cells[] = i18n::s('Tables');
$cells[] = 'center=' . $stats['count'];
$cells[] = 'center=' . Skin::build_date($stats['oldest_date']);
$cells[] = 'center=' . Skin::build_date($stats['newest_date']);
$related .= Skin::table_row($cells, $lines++);
}
// stats for related files
if (($stats = Files::stat_for_anchor($anchor)) && $stats['count']) {
$cells = array();
$cells[] = i18n::s('Files');
$cells[] = 'center=' . $stats['count'];
$cells[] = 'center=' . Skin::build_date($stats['oldest_date']);
$cells[] = 'center=' . Skin::build_date($stats['newest_date']);
$related .= Skin::table_row($cells, $lines++);
}
// stats for related dates
include_once $context['path_to_root'] . 'dates/dates.php';
if (($stats = Dates::stat_for_anchor($anchor)) && $stats['count']) {
$cells = array();
$cells[] = i18n::s('Dates');
$cells[] = 'center=' . $stats['count'];
$cells[] = 'center=' . Skin::build_date($stats['oldest_date']);
$cells[] = 'center=' . Skin::build_date($stats['newest_date']);
$related .= Skin::table_row($cells, $lines++);
}
// stats for related comments
include_once $context['path_to_root'] . 'comments/comments.php';
//.........这里部分代码省略.........