本文整理汇总了PHP中Links::count_for_anchor方法的典型用法代码示例。如果您正苦于以下问题:PHP Links::count_for_anchor方法的具体用法?PHP Links::count_for_anchor怎么用?PHP Links::count_for_anchor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Links
的用法示例。
在下文中一共展示了Links::count_for_anchor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: one
/**
* format just one item
*
* @param array attributes of one item
* @return array of ($url => array($prefix, $label, $suffix, ...))
*
* @see articles/edit.php
**/
function one(&$item)
{
global $context;
// initialize variables
$prefix = $suffix = $icon = '';
// flag sections that are 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 articles
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// details
$details = array();
// info on related files
if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
// info on related links
if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
}
// info on related comments
if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
}
// append details to the suffix
if (count($details)) {
$suffix .= "\n" . '<span class="details">(' . implode(', ', $details) . ')</span>';
}
// introduction
if ($item['introduction']) {
$suffix .= ' ' . Codes::beautify_introduction($item['introduction']);
}
// add a head list of related links
$subs = array();
// put the actual icon in the left column
if (isset($item['thumbnail_url'])) {
$icon = $item['thumbnail_url'];
}
// url to select this article
$url = 'articles/edit.php?template=' . $item['id'];
// use the title to label the link
$label = Skin::strip($item['title'], 50);
// list all components for this item
$output = array($url => array($prefix, $label, $suffix, 'article', $icon, i18n::s('Select this model')));
return $output;
}
示例2: one
/**
* format just one item
*
* This is used within this script, but also to shape sections assigned
* to the surfer in the web form for new articles.
*
* @param array attributes of one item
* @return array of ($url => array($prefix, $label, $suffix, ...))
*
* @see articles/edit.php
**/
function one(&$item)
{
global $context;
// this function is invoked directly from articles/edit.php
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
// sanity check
if (!isset($this->layout_variant)) {
$this->layout_variant = 'articles/edit.php?anchor=section:';
}
// initialize variables
$prefix = $suffix = $icon = '';
// flag sections that are draft, dead, or created or updated very recently
if ($item['activation_date'] >= $context['now']) {
$prefix .= DRAFT_FLAG;
} elseif ($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;
}
// details
$details = array();
// info on related articles
if ($count = Members::count_articles_for_anchor('section:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
}
// info on related files
if ($count = Files::count_for_anchor('section:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
// info on related links
if ($count = Links::count_for_anchor('section:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
}
// info on related comments
if ($count = Comments::count_for_anchor('section:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
}
// append details to the suffix
if (count($details)) {
$suffix .= "\n" . '<span class="details">(' . implode(', ', $details) . ')</span>';
}
// introduction
if ($item['introduction']) {
$suffix .= ' ' . Codes::beautify_introduction(trim($item['introduction']));
}
// add a head list of related links
$subs = array();
// add sub-sections on index pages
if ($related =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, 2 * YAHOO_LIST_SIZE, 'raw')) {
foreach ($related as $id => $attributes) {
// look for sub-sub-sections
$leaves = array();
if ($children =& Sections::list_by_title_for_anchor('section:' . $id, 0, 50, 'raw')) {
foreach ($children as $child_id => $child_attributes) {
$child_url = $this->layout_variant . $child_id;
$leaves[$child_url] = $child_attributes['title'];
}
}
// link for this sub-section
$url = $this->layout_variant . $id;
// expose sub-sub-sections as well
if (count($leaves) > YAHOO_LIST_SIZE) {
$subs[$url] = array('', $attributes['title'], Skin::build_box(i18n::s('More spaces'), Skin::build_list($leaves, 'compact'), 'folded'));
} elseif (count($leaves)) {
$subs[$url] = array('', $attributes['title'], Skin::build_list($leaves, 'compact'));
} else {
$subs[$url] = $attributes['title'];
}
}
}
// one sub-section per line
if (count($subs)) {
$suffix .= Skin::build_list($subs, 'compact');
}
// put the actual icon in the left column
if (isset($item['thumbnail_url'])) {
$icon = $item['thumbnail_url'];
}
// only associates and editors can post to a locked section
if (isset($item['locked']) && $item['locked'] == 'Y' && !Surfer::is_empowered()) {
//.........这里部分代码省略.........
示例3: array
// details
$details = array();
// info on related sections
if ($count = Sections::count_for_anchor('section:' . $section['id'])) {
$details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
}
// info on related articles
if ($count = Articles::count_for_anchor('section:' . $section['id'])) {
$details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
}
// info on related files
if ($count = Files::count_for_anchor('section:' . $section['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
// info on related links
if ($count = Links::count_for_anchor('section:' . $section['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
}
// the parent link
if (is_object($parent)) {
$details[] = sprintf(i18n::s('in %s'), Skin::build_link($parent->get_url(), ucfirst($parent->get_title()), 'section'));
}
// combine in-line details
if (count($details)) {
$suffix .= ' - <span class="details">' . trim(implode(', ', $details)) . '</span>';
}
// surfer cannot be deselected
if (!strcmp($anchor->get_reference(), 'user:' . $section['owner_id'])) {
$suffix .= ' - <span class="details">' . i18n::s('owner') . '</span>';
} elseif (Surfer::is_associate()) {
$link = $context['script_url'] . '?anchor=' . urlencode($anchor->get_reference()) . '&member=section:' . $section['id'] . '&action=reset';
示例4: layout
/**
* list categories
*
* @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
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// url to read the full category
$url = Categories::get_permalink($item);
// initialize variables
$prefix = $suffix = $icon = '';
// flag categories 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 categories
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// introduction
if ($item['introduction']) {
$suffix .= ' ' . Codes::beautify(trim($item['introduction']));
}
// details
$details = array();
// count related sub-elements
$related_count = 0;
// info on related categories
$stats = Categories::stat_for_anchor('category:' . $item['id']);
if ($stats['count']) {
$details[] = sprintf(i18n::ns('%d category', '%d categories', $stats['count']), $stats['count']);
}
$related_count += $stats['count'];
// info on related sections
if ($count = Members::count_sections_for_anchor('category:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
$related_count += $count;
}
// info on related articles
if ($count = Members::count_articles_for_anchor('category:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
$related_count += $count;
}
// info on related files
if ($count = Files::count_for_anchor('category:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
$related_count += $count;
}
// info on related links
if ($count = Links::count_for_anchor('category:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
$related_count += $count;
}
// info on related comments
if ($count = Comments::count_for_anchor('category:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
$related_count += $stats['count'];
}
// info on related users
if ($count = Members::count_users_for_anchor('category:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d user', '%d users', $count), $count);
}
// append details to the suffix
if (count($details)) {
$suffix .= "\n" . '<span class="details">(' . implode(', ', $details) . ')</span>';
}
// add a head list of related links
$details = array();
// add sub-categories on index pages
if ($related = Categories::list_by_date_for_anchor('category:' . $item['id'], 0, YAHOO_LIST_SIZE, 'compact')) {
foreach ($related as $sub_url => $label) {
$sub_prefix = $sub_suffix = $sub_hover = '';
if (is_array($label)) {
$sub_prefix = $label[0];
$sub_suffix = $label[2];
if (@$label[5]) {
$sub_hover = $label[5];
}
$label = $label[1];
//.........这里部分代码省略.........
示例5: layout
//.........这里部分代码省略.........
$suffix .= ' ' . UPDATED_FLAG;
}
// add details
$details = array();
// the author
if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
if ($item['edit_name'] == $item['create_name']) {
$details[] = sprintf(i18n::s('by %s'), ucfirst($item['create_name']));
} else {
$details[] = sprintf(i18n::s('by %s, %s'), ucfirst($item['create_name']), ucfirst($item['edit_name']));
}
}
// the publish date
$details[] = Skin::build_date($item['publish_date']);
// rating
$rating_label = '';
if ($item['rating_count']) {
$rating_label = Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])) . ' ' . sprintf(i18n::ns('%d rating', '%d ratings', $item['rating_count']), $item['rating_count']) . ' ';
}
// add a link to let surfer rate this item
if (is_object($anchor) && !$anchor->has_option('without_rating')) {
if (!$item['rating_count']) {
$rating_label .= i18n::s('Rate this page');
}
$rating_label = Skin::build_link(Articles::get_url($item['id'], 'like'), $rating_label, 'basic', i18n::s('Rate this page'));
}
// display current rating, and allow for rating
$details[] = $rating_label;
// details
if (count($details)) {
$content .= '<p class="details">' . ucfirst(implode(', ', $details)) . '</p>';
}
// the full introductory text
if ($item['introduction']) {
$content .= Codes::beautify($item['introduction'], $item['options']);
} elseif (!is_object($overlay)) {
include_once $context['path_to_root'] . 'articles/article.php';
$article = new Article();
$article->load_by_content($item);
$content .= $article->get_teaser('teaser');
}
// insert overlay data, if any
if (is_object($overlay)) {
$content .= $overlay->get_text('list', $item);
}
// an array of links
$menu = array();
// rate the article
$menu = array_merge($menu, array(Articles::get_url($item['id'], 'like') => i18n::s('Rate this page')));
// read the article
$menu = array_merge($menu, array($url => i18n::s('Read more')));
// 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
if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
$link = Comments::get_url('article:' . $item['id'], 'list');
$menu = array_merge($menu, array($link => sprintf(i18n::ns('%d comment', '%d comments', $count), $count)));
}
// discuss
if (Comments::allow_creation($item, $anchor)) {
$menu = array_merge($menu, array(Comments::get_url('article:' . $item['id'], 'comment') => i18n::s('Discuss')));
}
// info on related links
if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
$menu = array_merge($menu, array($url . '#_attachments' => sprintf(i18n::ns('%d link', '%d links', $count), $count)));
}
// trackback
if (Links::allow_trackback()) {
$menu = array_merge($menu, array('links/trackback.php?anchor=' . urlencode('article:' . $item['id']) => i18n::s('Reference this page')));
}
// link to the anchor page
if (is_object($anchor)) {
$menu = array_merge($menu, array($anchor->get_url() => $anchor->get_title()));
}
// list up to three categories by title, if any
if ($items = Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 3, 'raw')) {
foreach ($items as $id => $attributes) {
$menu = array_merge($menu, array(Categories::get_permalink($attributes) => $attributes['title']));
}
}
// append a menu
$content .= Skin::build_list($menu, 'menu_bar');
// insert a complete box
$text .= Skin::build_box($icon . $prefix . Codes::beautify_title($item['title']) . $suffix, $content, 'header1', 'article_' . $item['id']);
// section closing
if ($item_count == 1) {
$text .= '</div>' . "\n";
}
}
// end of processing
SQL::free($result);
// add links to archives
$anchor = Categories::get(i18n::c('monthly'));
if (isset($anchor['id']) && ($items = Categories::list_by_date_for_anchor('category:' . $anchor['id'], 0, COMPACT_LIST_SIZE, 'compact'))) {
$text .= Skin::build_box(i18n::s('Previous pages'), Skin::build_list($items, 'menu_bar'));
}
return $text;
}
示例6: layout
/**
* list categories
*
* @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
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// url to read the full category
$url = Categories::get_permalink($item);
// initialize variables
$prefix = $suffix = $icon = '';
// flag categories 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 categories
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// use the title to label the link
$label = Skin::strip($item['title'], 10);
// details
$details = array();
// info on related categories
$stats = Categories::stat_for_anchor('category:' . $item['id']);
if ($stats['count']) {
$details[] = sprintf(i18n::ns('%d category', '%d categories', $stats['count']), $stats['count']);
}
// info on related sections
if ($count = Members::count_sections_for_anchor('category:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
}
// info on related articles
if ($count = Members::count_articles_for_anchor('category:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
}
// info on related files
if ($count = Files::count_for_anchor('category:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
// info on related links
if ($count = Links::count_for_anchor('category:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
}
// info on related comments
if ($count = Comments::count_for_anchor('category:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
}
// info on related users
if ($count = Members::count_users_for_anchor('category:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d user', '%d users', $count), $count);
}
// append details to the suffix
if (count($details)) {
$suffix .= "\n" . '<span class="details">(' . implode(', ', $details) . ')</span>';
}
// introduction
if ($item['introduction']) {
$suffix .= ' ' . Codes::beautify(trim($item['introduction']));
}
// put the actual icon in the left column
if (isset($item['thumbnail_url']) && $this->layout_variant != 'sidebar') {
$icon = $item['thumbnail_url'];
}
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, 'category', $icon);
}
// end of processing
SQL::free($result);
return $items;
}
示例7: layout
/**
* list sections
*
* @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
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// 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);
// 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 restricted and private sections
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_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;
}
// info on related comments
if ($count = Comments::count_for_anchor('section:' . $item['id'], TRUE)) {
$suffix .= ' (' . $count . ')';
}
// details
$details = array();
// info on related sections
if ($count = Sections::count_for_anchor('section:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
}
// info on related articles
if ($count = Articles::count_for_anchor('section:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
}
// info on related files
if ($count = Files::count_for_anchor('section:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
// info on related links
if ($count = Links::count_for_anchor('section:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
}
// the main anchor link
if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) {
$details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'section'));
}
// combine in-line details
if (count($details)) {
$suffix .= ' - <span class="details">' . trim(implode(', ', $details)) . '</span>';
}
// list all components for this item
$items[$url] = array($prefix, $title, $suffix, 'section', $icon);
}
// end of processing
SQL::free($result);
return $items;
}
示例8: layout
/**
* list articles as rows in a table
*
* @param resource the SQL result
* @return string the rendered text
**/
function layout($result)
{
global $context;
// we return some text
$text = '';
// empty list
if (!SQL::count($result)) {
return $text;
}
// build a list of articles
$rows = array();
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// get the related overlay
$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);
// reset everything
$title = $abstract = $author = '';
// 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')) {
$title .= DRAFT_FLAG;
}
// signal restricted and private articles
if ($item['active'] == 'N') {
$title .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$title .= RESTRICTED_FLAG;
}
// indicate the id in the hovering popup
$hover = i18n::s('View the page');
if (Surfer::is_member()) {
$hover .= ' [article=' . $item['id'] . ']';
}
// use the title to label the link
if (is_object($overlay)) {
$label = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$label = Codes::beautify_title($item['title']);
}
// use the title as a link to the page
$title .= Skin::build_link($url, $label, 'basic', $hover);
// signal locked articles
if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
$title .= ' ' . LOCKED_FLAG;
}
// flag articles updated recently
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$title .= ' ' . EXPIRED_FLAG;
} elseif ($item['create_date'] >= $context['fresh']) {
$title .= ' ' . NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$title .= ' ' . UPDATED_FLAG;
}
// the icon
if ($item['thumbnail_url']) {
$abstract .= '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $item['thumbnail_url'] . '" class="right_image" alt="" /></a>';
}
// the introductory text
if (is_object($overlay)) {
$abstract .= Codes::beautify_introduction($overlay->get_text('introduction', $item));
} elseif ($item['introduction']) {
$abstract .= Codes::beautify_introduction($item['introduction']);
}
// insert overlay data, if any
if (is_object($overlay)) {
$abstract .= $overlay->get_text('list', $item);
}
// make some abstract out of main text
if (!$item['introduction'] && $context['skins_with_details'] == 'Y') {
$abstract .= Skin::cap(Codes::beautify($item['description'], $item['options']), 50);
}
// attachment details
$details = array();
// info on related files
if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
Skin::define_img('FILES_LIST_IMG', 'files/list.gif');
$details[] = FILES_LIST_IMG . sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
// info on related links
if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
Skin::define_img('LINKS_LIST_IMG', 'links/list.gif');
$details[] = LINKS_LIST_IMG . sprintf(i18n::ns('%d link', '%d links', $count), $count);
}
// comments
if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
Skin::define_img('COMMENTS_LIST_IMG', 'comments/list.gif');
$details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), COMMENTS_LIST_IMG . sprintf(i18n::ns('%d comment', '%d comments', $count), $count));
}
// describe attachments
if (count($details)) {
//.........这里部分代码省略.........
示例9: layout
/**
* list sections
*
* @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 some text
$text = '';
// maximum number of items
if (isset($this->layout_variant) && $this->layout_variant > 3) {
$maximum_items = $this->layout_variant;
} elseif (defined('YAHOO_LIST_SIZE')) {
$maximum_items = YAHOO_LIST_SIZE;
} else {
$maximum_items = 7;
}
// stack of items
$items = array();
// process all items in the list
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
$family = '';
while ($item = SQL::fetch($result)) {
// change the family
if ($item['family'] != $family) {
// flush current stack, if any
if (count($items)) {
$text .= Skin::build_list($items, '2-columns');
}
$items = array();
// show the family
$family = $item['family'];
$text .= '<h2><span>' . $family . ' </span></h2>' . "\n";
}
// the url to view this item
$url = Sections::get_permalink($item);
// initialize variables
$prefix = $label = $suffix = $icon = '';
// signal restricted and private sections
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// flag sections that are draft, dead, or created or updated very recently
if ($item['activation_date'] >= $context['now']) {
$prefix .= DRAFT_FLAG;
} elseif ($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;
}
// details and content
$details = array();
$content = array();
// count related sub-elements
$related_count = 0;
// info on related articles
if ($count = Articles::count_for_anchor('section:' . $item['id'])) {
if ($count > $maximum_items) {
$details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
} elseif (Surfer::is_empowered()) {
$details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
}
$related_count += $count;
// get the overlay for content of this section, if any
$content_overlay = NULL;
if (isset($item['content_overlay'])) {
$content_overlay = Overlay::bind($item['content_overlay']);
}
// no room to list articles
if (count($content) >= $maximum_items) {
} elseif (is_object($content_overlay) && is_callable(array($content_overlay, 'render_list_for_anchor'))) {
if ($related = $content_overlay->render_list_for_anchor('section:' . $item['id'], $maximum_items - count($content))) {
foreach ($related as $sub_url => $label) {
$sub_prefix = $sub_suffix = $sub_hover = '';
if (is_array($label)) {
$sub_prefix = $label[0];
$sub_suffix = $label[2];
if (@$label[5]) {
$sub_hover = $label[5];
}
$label = $label[1];
}
$content[] = $sub_prefix . Skin::build_link($sub_url, $label, 'basic', $sub_hover) . $sub_suffix;
}
}
// regular rendering of related articles
//.........这里部分代码省略.........
示例10: layout
//.........这里部分代码省略.........
// flag articles updated recently
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$box['title'] .= EXPIRED_FLAG;
} elseif ($item['create_date'] >= $context['fresh']) {
$box['title'] .= NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$box['title'] .= UPDATED_FLAG;
}
// what's the date of publication?
if (isset($item['publish_date']) && $item['publish_date'] > NULL_DATE) {
$box['date'] .= Skin::build_date($item['publish_date'], 'publishing');
}
// the icon to put aside - never use anchor images
if ($item['icon_url']) {
$box['content'] .= '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $item['icon_url'] . '" class="left_image" alt="" /></a>';
}
// details
$details = array();
// 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');
}
// show details
if (count($details)) {
$box['content'] .= '<p class="details">' . implode(' ~ ', $details) . '</p>' . "\n";
}
// list categories by title, if any
if ($items = Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) {
$tags = array();
foreach ($items 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>';
}
$tags[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic');
}
$box['content'] .= '<p class="tags">' . implode(' ', $tags) . '</p>';
}
// the introduction text, if any
if (is_object($overlay)) {
$box['content'] .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
} else {
$box['content'] .= Skin::build_block($item['introduction'], 'introduction');
}
// insert overlay data, if any
if (is_object($overlay)) {
$box['content'] .= $overlay->get_text('list', $item);
}
// the description
$box['content'] .= Skin::build_block($item['description'], 'description', '', $item['options']);
// a compact list of attached files
if ($count = Files::count_for_anchor('article:' . $item['id'])) {
// list files by date (default) or by title (option files_by_title)
if (Articles::has_option('files_by', $anchor, $item) == 'title') {
$items = Files::list_by_title_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'compact');
} else {
$items = Files::list_by_date_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'compact');
}
if (is_array($items)) {
$items = Skin::build_list($items, 'compact');
}
if ($items) {
$box['content'] .= Skin::build_box(i18n::s('Files'), $items, 'header2');
}
}
// build a menu
$menu = array();
// read the article
$menu[] = Skin::build_link($url, i18n::s('Permalink'), 'span');
// info on related files
if ($count) {
$menu[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'span');
}
// info on related comments
if ($count = Comments::count_for_anchor('article:' . $item['id'])) {
$menu[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'span');
}
// comment
if (Comments::allow_creation($item, $anchor)) {
$menu[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Discuss'), 'span');
}
// info on related links
if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
$menu[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'span');
}
// trackback
if (Links::allow_trackback()) {
$menu[] = Skin::build_link('links/trackback.php?anchor=' . urlencode('article:' . $item['id']), i18n::s('Reference this page'), 'span');
}
// a menu bar
if (count($menu)) {
$box['content'] .= '<div class="menu_bar" style="clear: left;">' . MENU_PREFIX . implode(MENU_SEPARATOR, $menu) . MENU_SUFFIX . "</div>\n";
}
// build a simple box for this post
$text .= '<div class="post">' . '<div class="date">' . $box['date'] . '</div>' . '<h2><span>' . $box['title'] . '</span></h2>' . '<div class="content">' . $box['content'] . '</div>' . '</div>';
}
// end of processing
SQL::free($result);
return $text;
}
示例11: layout
/**
* list articles as a table of content of a manual
*
* @param resource the SQL result
* @return string the rendered text
**/
function layout($result)
{
global $context;
// we return some text
$text = '';
// empty list
if (!SQL::count($result)) {
return $text;
}
// build a list of articles
include_once $context['path_to_root'] . 'links/links.php';
$text .= '<ul class="manual">';
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
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$suffix .= ' ' . EXPIRED_FLAG;
} elseif ($item['create_date'] >= $context['fresh']) {
$suffix .= ' ' . NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= ' ' . UPDATED_FLAG;
}
// attachment details
$details = array();
// info on related files
if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
Skin::define_img('FILES_LIST_IMG', 'files/list.gif');
$details[] = FILES_LIST_IMG . sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
// info on related links
if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
Skin::define_img('LINKS_LIST_IMG', 'links/list.gif');
$details[] = LINKS_LIST_IMG . sprintf(i18n::ns('%d link', '%d links', $count), $count);
}
// rating
if ($item['rating_count']) {
$details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
}
// describe attachments
if (count($details)) {
$suffix .= ' <span class="details">' . join(', ', $details) . '</span>';
}
// display all tags
if ($item['tags']) {
$suffix .= ' <span class="details">- ' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>';
}
// make a link
$label = $prefix . Skin::build_link($url, $title, 'basic') . $suffix;
// use the title as a link to the page
$text .= '<li>' . $label . "</li>\n";
}
$text .= '</ul>' . "\n";
// end of processing
SQL::free($result);
return $text;
}
示例12: layout
/**
* list categories for search requests
*
* @param resource the SQL result
* @return array of resulting items ($score, $summary), or NULL
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of array($score, $summary)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// process all items in the list
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// one box at a time
$box = '';
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// url to read the full category
$url = Categories::get_permalink($item);
// initialize variables
$prefix = $suffix = $icon = '';
// flag categories 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 categories
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// use the title to label the link
$title = Skin::strip($item['title'], 10);
// details
$details = array();
// info on related categories
$stats = Categories::stat_for_anchor('category:' . $item['id']);
if ($stats['count']) {
$details[] = sprintf(i18n::ns('%d category', '%d categories', $stats['count']), $stats['count']);
}
// info on related sections
if ($count = Members::count_sections_for_anchor('category:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
}
// info on related articles
if ($count = Members::count_articles_for_anchor('category:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
}
// info on related files
if ($count = Files::count_for_anchor('category:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
// info on related links
if ($count = Links::count_for_anchor('category:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
}
// info on related comments
if ($count = Comments::count_for_anchor('category:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
}
// info on related users
if ($count = Members::count_users_for_anchor('category:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d user', '%d users', $count), $count);
}
// the main anchor link
if (is_object($anchor)) {
$details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'category'));
}
// append details to the suffix
if (count($details)) {
$suffix .= "\n" . '<span class="details">(' . implode(', ', $details) . ')</span>';
}
// introduction
if ($item['introduction']) {
$suffix .= ' ' . Codes::beautify(trim($item['introduction']));
}
// item summary
$box .= $prefix . Skin::build_link($url, $title, 'category') . $suffix;
// put the actual icon in the left column
if (isset($item['thumbnail_url']) && $this->layout_variant != 'sidebar') {
$icon = $item['thumbnail_url'];
}
// layout this item
if ($icon) {
// build the complete HTML element
$icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($title)) . '" />';
// make it a clickable link
$icon = Skin::build_link($url, $icon, 'basic');
//.........这里部分代码省略.........
示例13: layout
/**
* list sections
*
* Accept following variants:
* - 'full' - include anchor information -- also the default value
*
* @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 = 'decorated';
}
// process all items in the list
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// 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);
// 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 sections that are draft, dead, or created or updated very recently
if ($item['activation_date'] >= $context['now']) {
$prefix .= DRAFT_FLAG;
} elseif ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$prefix .= EXPIRED_FLAG;
}
if ($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 .= ' - ' . Codes::beautify_introduction($item['introduction']);
}
// details and content
$details = array();
$content = array();
// count related sub-elements
$related_count = 0;
// info on related articles
if ($count = Articles::count_for_anchor('section:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
$related_count += $count;
// add related articles if necessary
if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
$order = $matches[1];
} else {
$order = 'edition';
}
if (count($details) < YAHOO_LIST_SIZE && ($related =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, YAHOO_LIST_SIZE - count($details), 'compact'))) {
foreach ($related as $link => $label) {
$sub_prefix = $sub_suffix = $sub_hover = '';
if (is_array($label)) {
$sub_prefix = $label[0];
$sub_suffix = $label[2];
if (@$label[5]) {
$sub_hover = $label[5];
}
$label = $label[1];
}
$content[$link] = array($sub_prefix, $label, $sub_suffix, 'basic', '', $sub_hover);
}
}
}
// info on related files
if ($count = Files::count_for_anchor('section:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
$related_count += $count;
// add related files if necessary
if (count($details) < YAHOO_LIST_SIZE && ($related = Files::list_by_date_for_anchor('section:' . $item['id'], 0, YAHOO_LIST_SIZE - count($details), 'compact'))) {
foreach ($related as $link => $label) {
//.........这里部分代码省略.........
示例14: layout
//.........这里部分代码省略.........
$prefix .= STICKY_FLAG;
}
// signal articles to be published
if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > $context['now']) {
$prefix .= DRAFT_FLAG;
}
// signal restricted and private articles
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// signal locked articles
if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
$suffix .= ' ' . LOCKED_FLAG;
}
// flag articles updated recently
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$suffix .= ' ' . EXPIRED_FLAG;
} elseif ($item['create_date'] >= $context['fresh']) {
$suffix .= ' ' . NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= ' ' . UPDATED_FLAG;
}
// rating
if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
$suffix .= Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
}
// the full introductory text
if ($item['introduction']) {
$content .= Codes::beautify_introduction($item['introduction']);
} elseif (!is_object($overlay)) {
$article = new Article();
$article->load_by_content($item);
$content .= $article->get_teaser('teaser');
}
// insert overlay data, if any
if (is_object($overlay)) {
$content .= $overlay->get_text('list', $item);
}
// add details
$details = array();
// the author
if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
if ($item['edit_name'] == $item['create_name']) {
$details[] = sprintf(i18n::s('by %s'), ucfirst($item['create_name']));
} else {
$details[] = sprintf(i18n::s('by %s, %s'), ucfirst($item['create_name']), ucfirst($item['edit_name']));
}
}
// the modification date
if ($item['edit_date'] > NULL_DATE) {
$details[] = Skin::build_date($item['edit_date']);
}
// read the article
$details[] = Skin::build_link($url, i18n::s('More'), 'basic');
// 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
if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
$link = Comments::get_url('article:' . $item['id'], 'list');
$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');
}
// list categories by title, if any
if ($items =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) {
foreach ($items 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>';
}
$details[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic');
}
}
// details
if (count($details)) {
$content .= '<div><span class="details">' . ucfirst(implode(' - ', $details)) . '</span></div>';
}
// insert a complete box
$text .= Skin::build_box(Skin::build_link($url, $prefix . $title . $suffix, 'basic', i18n::s('View the page')), $icon . $content, 'header1 ' . $class, 'article_' . $item['id']);
// stack boxes
if ($class == 'even') {
$class = 'odd';
} else {
$class = 'even';
}
}
// end of processing
SQL::free($result);
return $text;
}
示例15: layout
//.........这里部分代码省略.........
} else {
$first = Skin::build_date($item['create_date'], 'plain');
}
// end
$last = Skin::build_date($item['edit_date'], 'plain');
if ($last != $first) {
$last = ' end="' . $last . '"';
} else {
$last = '';
}
// build a title
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$title = Codes::beautify_title($item['title']);
}
// the url to view this item
$url = str_replace('&', '&', Articles::get_permalink($item));
// this is visual
if (isset($item['icon_url']) && $item['icon_url']) {
$image = $item['icon_url'];
} elseif (isset($item['thumbnail_url']) && $item['thumbnail_url']) {
$image = $item['thumbnail_url'];
} else {
$image = '';
}
// fix relative path
if ($image && !preg_match('/^(\\/|http:|https:|ftp:)/', $image)) {
$image = $context['url_to_root'] . $image;
}
if ($image) {
$image = ' image="' . $image . '"';
}
// introduction
$introduction = '';
if (is_object($overlay)) {
$introduction = $overlay->get_text('introduction', $item);
} else {
$introduction = $item['introduction'];
}
// insert overlay data, if any
if (is_object($overlay) && ($data = $overlay->get_text('list', $item))) {
if ($introduction) {
$introduction .= BR;
}
$introduction .= $data;
}
// ampersands kill SIMILE Timeline
if ($introduction) {
$introduction = encode_field(str_replace(array(' ', '&'), ' ', Codes::beautify($introduction)));
}
// details
$details = array();
// info on related comments
if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
}
// info on related files
if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
// info on related links
if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
}
// combine in-line details
if (count($details)) {
if ($introduction) {
$introduction .= BR;
}
$introduction .= '<span class="details">' . trim(implode(', ', $details)) . '</span>';
}
// escape the introduction, if any
if ($introduction) {
$introduction = str_replace(array('<', '&'), array('<', '&'), $introduction);
}
// add to the list
$content .= ' <event start="' . $first . '"' . $last . ' title="' . encode_field(str_replace(array(" ", '"'), ' ', $title)) . '" link="' . $url . '"' . $image . '>' . "\n" . ' ' . $introduction . "\n" . ' </event>' . "\n";
}
// finalize slideshow content
$content .= '</data>';
// put in cache
Safe::file_put_contents($cache_id, $content);
}
// allow multiple instances
static $count;
if (!isset($count)) {
$count = 1;
} else {
$count++;
}
// 1 week ago
$now = gmdate('M d Y H:i:s', time() - 7 * 24 * 60 * 60);
// load the right file
$text = '<div id="articles_as_simile_' . $count . '" style="height: 300px; border: 1px solid #aaa; font-size: 10px"></div>' . "\n";
Page::insert_script('var simile_handle_' . $count . ';' . "\n" . 'function onLoad' . $count . '() {' . "\n" . ' var eventSource = new Timeline.DefaultEventSource();' . "\n" . ' var bandInfos = [' . "\n" . ' Timeline.createBandInfo({' . "\n" . ' eventSource: eventSource,' . "\n" . ' date: "' . $now . '",' . "\n" . ' width: "80%",' . "\n" . ' intervalUnit: Timeline.DateTime.WEEK,' . "\n" . ' intervalPixels: 200' . "\n" . ' }),' . "\n" . ' Timeline.createBandInfo({' . "\n" . ' showEventText: false,' . "\n" . ' trackHeight: 0.5,' . "\n" . ' trackGap: 0.2,' . "\n" . ' eventSource: eventSource,' . "\n" . ' date: "' . $now . '",' . "\n" . ' width: "20%",' . "\n" . ' intervalUnit: Timeline.DateTime.MONTH,' . "\n" . ' intervalPixels: 50' . "\n" . ' })' . "\n" . ' ];' . "\n" . ' bandInfos[1].syncWith = 0;' . "\n" . ' bandInfos[1].highlight = true;' . "\n" . ' bandInfos[1].eventPainter.setLayout(bandInfos[0].eventPainter.getLayout());' . "\n" . ' simile_handle_' . $count . ' = Timeline.create(document.getElementById("articles_as_simile_' . $count . '"), bandInfos);' . "\n" . ' Timeline.loadXML("' . $context['url_to_home'] . $context['url_to_root'] . $cache_id . '", function(xml, url) { eventSource.loadXML(xml, url); });' . "\n" . '}' . "\n" . "\n" . 'var resizeTimerID' . $count . ' = null;' . "\n" . 'function onResize' . $count . '() {' . "\n" . ' if (resizeTimerID' . $count . ' == null) {' . "\n" . ' resizeTimerID' . $count . ' = window.setTimeout(function() {' . "\n" . ' resizeTimerID' . $count . ' = null;' . "\n" . ' simile_handle_' . $count . '.layout();' . "\n" . ' }, 500);' . "\n" . ' }' . "\n" . '}' . "\n" . "\n" . '// observe page major events' . "\n" . '$(document).ready( onLoad' . $count . ');' . "\n" . '$(window).resize(onResize' . $count . ');' . "\n");
// end of processing
SQL::free($result);
return $text;
}