本文整理汇总了PHP中Comments::stat_for_anchor方法的典型用法代码示例。如果您正苦于以下问题:PHP Comments::stat_for_anchor方法的具体用法?PHP Comments::stat_for_anchor怎么用?PHP Comments::stat_for_anchor使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Comments
的用法示例。
在下文中一共展示了Comments::stat_for_anchor方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: gmstrftime
$fields['introduction'] = i18n::c('Sample support request');
$fields['publish_date'] = gmstrftime('%Y-%m-%d %H:%M:%S');
$overlay = Overlay::bind('issue');
$fields['overlay'] = $overlay->save();
$fields['overlay_id'] = $overlay->get_id();
if (Articles::post($fields)) {
$text .= sprintf(i18n::s('A page "%s" has been created.'), $fields['nick_name']) . BR . "\n";
$overlay->remember('insert', $fields, 'article:' . $fields['id']);
} else {
$text .= Logger::error_pop() . BR . "\n";
}
}
// add sample comments to 'bugzilla_page'
if ($anchor = Articles::lookup('bugzilla_page')) {
// add a bunch of comments
$stats = Comments::stat_for_anchor($anchor);
if ($stats['count'] < 50) {
for ($index = 1; $index <= 10; $index++) {
$fields = array();
$fields['anchor'] = $anchor;
$fields['description'] = sprintf(i18n::c('Comment #%d'), $index);
$fields['edit_name'] = $names[rand(0, 2)];
if (!Comments::post($fields)) {
$text .= Logger::error_pop() . BR . "\n";
break;
}
}
if ($index > 1) {
$text .= sprintf(i18n::s('Comments have been added to "%s".'), 'bugzilla_page') . BR . "\n";
}
}
示例2: layout
//.........这里部分代码省略.........
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']);
// the number of hits
if (Surfer::is_logged() && $item['hits'] > 1) {
$details[] = Skin::build_number($item['hits'], i18n::s('hits'));
}
// info on related files
$stats = Files::stat_for_anchor('article:' . $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('article:' . $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('article:' . $item['id']);
if ($stats['count']) {
$details[] = sprintf(i18n::ns('%d comment', '%d comments', $stats['count']), $stats['count']);
}
// rating
if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
$details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
}
// combine in-line details
if (count($details)) {
$suffix .= ucfirst(trim(implode(', ', $details)));
}
// list up to three categories by title, if any
$anchors = array();
if ($members =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) {
foreach ($members as $id => $attributes) {
// add background color to distinguish this category against others
if (isset($attributes['background_color']) && $attributes['background_color']) {
$attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>';
}
$anchors[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic');
}
}
if (count($anchors)) {
$suffix .= BR . sprintf(i18n::s('In %s'), implode(' / ', $anchors));
}
// end of details
$suffix .= '</span>';
// strip empty details
$suffix = str_replace(BR . '<span class="details"></span>', '', $suffix);
$suffix = str_replace('<span class="details"></span>', '', $suffix);
// the icon to put in the left column
if ($item['thumbnail_url']) {
$icon = $item['thumbnail_url'];
}
// commands
$commands = array(Skin::build_link(Articles::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic'), Skin::build_link(Articles::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic'));
// link to this page
$cells[] = $prefix . Skin::build_link($url, $title, 'article') . ' - ' . Skin::finalize_list($commands, 'menu') . $suffix;
// ranking
$cells[] = '<input type="text" size="5" name="article_rank_' . $item['id'] . '" value="' . $item['rank'] . '" onfocus="$(\'#article_selector_' . $count . '\').attr(\'checked\', \'checked\');" onchange="$(\'#act_on_articles\').prop(\'selectedIndex\', 9);" />';
// append the row
$text .= Skin::table_row($cells, $count++);
}
// select all rows
$cells = array('<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />', i18n::s('Select all/none'), '');
$text .= Skin::table_row($cells, $count++);
// table suffix
$text .= Skin::table_suffix();
// end of processing
SQL::free($result);
return $text;
}
示例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';
//.........这里部分代码省略.........