本文整理汇总了PHP中Articles::get_permalink方法的典型用法代码示例。如果您正苦于以下问题:PHP Articles::get_permalink方法的具体用法?PHP Articles::get_permalink怎么用?PHP Articles::get_permalink使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Articles
的用法示例。
在下文中一共展示了Articles::get_permalink方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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;
}
// clear flows
$text .= '<br style="clear: left" />';
// process all items in the list
while ($item = SQL::fetch($result)) {
// get the related overlay
$overlay = Overlay::load($item, 'article:' . $item['id']);
// 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']);
}
// the hovering title
if ($item['introduction'] && $context['skins_with_details'] == 'Y') {
$hover = strip_tags(Codes::beautify_introduction($item['introduction']));
} else {
$hover = i18n::s('View the page');
}
// title is a link to the target article
$title =& Skin::build_link($url, $title, 'basic', $hover);
// use the thumbnail for this article
if ($icon = trim($item['thumbnail_url'])) {
// fix relative path
if (!preg_match('/^(\\/|http:|https:|ftp:)/', $icon)) {
$icon = $context['url_to_root'] . $icon;
}
// use parameter of the control panel for this one
$options = '';
if (isset($context['classes_for_thumbnail_images'])) {
$options = 'class="' . $context['classes_for_thumbnail_images'] . '" ';
}
// build the complete HTML element
$icon = '<img src="' . $icon . '" alt="" title="' . encode_field($hover) . '" ' . $options . ' />';
// use default icon if nothing to display
} else {
$icon = MAP_IMG;
}
// use the image as a link to the target page
$icon =& Skin::build_link($url, $icon, 'basic', $hover);
// add a floating box
$text .= Skin::build_box($title, $icon, 'floating');
}
// clear flows
$text .= '<br style="clear: left" />';
// end of processing
SQL::free($result);
return $text;
}
示例2: layout
/**
* list dates
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// build the calendar
$text = 'BEGIN:VCALENDAR' . CRLF . 'VERSION:2.0' . CRLF . 'PRODID:YACS' . CRLF . 'METHOD:PUBLISH' . CRLF;
// organization, if any
if (isset($context['site_name']) && $context['site_name']) {
$text .= 'X-WR-CALNAME:' . $context['site_name'] . CRLF;
}
// process all items in the list
while ($item = SQL::fetch($result)) {
// one event at a time
$text .= 'BEGIN:VEVENT' . CRLF;
// the event spans limited time
if (isset($item['duration']) && $item['duration']) {
$text .= 'DTSTART:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['date_stamp'])) . CRLF;
$text .= 'DTEND:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['date_stamp']) + $item['duration'] * 60) . CRLF;
// a full-day event
} else {
$text .= 'DTSTART;VALUE=DATE:' . date('Ymd', SQL::strtotime($item['date_stamp'])) . CRLF;
$text .= 'DTEND;VALUE=DATE:' . date('Ymd', SQL::strtotime($item['date_stamp']) + 86400) . CRLF;
}
// url to view the date
$text .= 'URL:' . Articles::get_permalink($item) . CRLF;
// organization, if any
if (isset($item['introduction']) && $item['introduction']) {
$text .= 'DESCRIPTION:' . str_replace(array("\n", "\r"), ' ', strip_tags($item['introduction'])) . CRLF;
}
// build a valid title
if (isset($item['title']) && $item['title']) {
$text .= 'SUMMARY:' . Codes::beautify_title($item['title']) . CRLF;
}
// required by Outlook 2003
if (isset($item['id']) && $item['id']) {
$text .= 'UID:' . $item['id'] . CRLF;
}
// date of creation
if (isset($item['create_date']) && $item['create_date']) {
$text .= 'CREATED:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['create_date'])) . CRLF;
}
// date of last modification
if (isset($item['edit_date']) && $item['edit_date']) {
$text .= 'DTSTAMP:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['edit_date'])) . CRLF;
}
// next event
$text .= 'SEQUENCE:0' . CRLF . 'END:VEVENT' . CRLF;
}
// date of last update
$text .= 'END:VCALENDAR' . CRLF;
// end of processing
SQL::free($result);
return $text;
}
示例3: layout
/**
* list dates
*
* @param resource the SQL result
* @return string the rendered text
*
* @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)) {
// the url to use
$url = Articles::get_permalink($item);
// initialize variables
$prefix = $suffix = $icon = '';
// signal restricted and private dates/articles
if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE) {
$prefix .= DRAFT_FLAG;
}
// signal restricted and private dates/articles
if (!isset($item['active'])) {
} elseif ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// flag new dates/articles
if ($item['edit_date'] >= $context['fresh']) {
$suffix .= NEW_FLAG;
}
// build a valid label
if (isset($item['title'])) {
$label = Codes::beautify_title($item['title']);
if (isset($item['date_stamp'])) {
$label .= ' [' . Skin::build_date($item['date_stamp'], 'day') . ']';
}
} else {
$label = Skin::build_date($item['date_stamp'], 'day');
}
// may have variant overlay for links
$link_type = $this->has_variant('overlaid') ? 'overlaid' : 'basic';
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, $link_type, NULL, $item['date_stamp']);
}
// end of processing
SQL::free($result);
return $items;
}
示例4: transform_reference
/**
* reference another page at this site
*
* The function transforms a local reference (e.g;, [code][user=2][/code])
* to an actual link relative to the YACS directory (e.g., [code]users/view.php/2[/code]),
* adds a title and, sometimes, set a description as well.
*
* @param string any string, maybe with a local reference in it
* @return an array($url, $title, $description) or NULL
*
* @see images/view.php
* @see links/edit.php
* @see shared/codes.php
*/
public static function transform_reference($text)
{
global $context;
// translate this reference to an internal link
if (preg_match("/^\\[(article|section|file|image|category|user)=(.+?)\\]/i", $text, $matches)) {
switch ($matches[1]) {
// article link
case 'article':
if ($item = Articles::get($matches[2])) {
return array(Articles::get_permalink($item), $item['title'], $item['introduction']);
}
return array('', $text, '');
// section link
// section link
case 'section':
if ($item = Sections::get($matches[2])) {
return array(Sections::get_permalink($item), $item['title'], $item['introduction']);
}
return array('', $text, '');
// file link
// file link
case 'file':
if ($item = Files::get($matches[2])) {
return array(Files::get_url($matches[2]), $item['title'] ? $item['title'] : str_replace('_', ' ', ucfirst($item['file_name'])));
}
return array('', $text, '');
// image link
// image link
case 'image':
include_once $context['path_to_root'] . 'images/images.php';
if ($item = Images::get($matches[2])) {
return array(Images::get_url($matches[2]), $item['title'] ? $item['title'] : str_replace('_', ' ', ucfirst($item['image_name'])));
}
return array('', $text, '');
// category link
// category link
case 'category':
if ($item = Categories::get($matches[2])) {
return array(Categories::get_permalink($item), $item['title'], $item['introduction']);
}
return array('', $text, '');
// user link
// user link
case 'user':
if ($item = Users::get($matches[2])) {
return array(Users::get_permalink($item), $item['full_name'] ? $item['full_name'] : $item['nick_name']);
}
return array('', $text, '');
}
}
return array('', $text, '');
}
示例5: layout
/**
* list articles
*
* @param resource the SQL result
* @return string
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return some text
$text = '';
// empty list
if (!SQL::count($result)) {
return $text;
}
// sanity check
if (!isset($this->focus)) {
$this->focus = NULL;
}
// process all items in the list
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
$odd = TRUE;
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);
// build a title
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 articles that are dead, or created or updated very recently
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$prefix .= EXPIRED_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;
}
// some details
$details = array();
// info on related files --optional
if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
// info on related comments --mandatory
if ($count = Comments::count_for_anchor('article:' . $item['id'], FALSE)) {
$details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
}
// info on related links --optional
if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
}
// details
if (count($details)) {
$suffix .= ' <span class="details">(' . ucfirst(implode(', ', $details)) . ')</span>';
}
// flag popular pages
if ($item['hits'] > 300) {
$suffix .= POPULAR_FLAG;
}
// last contribution
if ($item['edit_action']) {
$action = Anchors::get_action_label($item['edit_action']) . ' ';
} else {
$action = i18n::s('edited');
}
if ($item['edit_name']) {
$suffix .= '<br /><span class="details">' . sprintf(i18n::s('%s by %s %s'), $action, Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date'])) . '</span>';
} else {
$suffix .= '<br /><span class="details">' . $action . ' ' . Skin::build_date($item['edit_date']) . '</span>';
}
// flag articles updated recently
if ($item['create_date'] >= $context['fresh']) {
$suffix .= NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= UPDATED_FLAG;
}
// insert overlay data, if any
if (is_object($overlay)) {
$suffix .= $overlay->get_text('list', $item, $this->focus);
}
// the hovering title
if ($item['introduction'] && $context['skins_with_details'] == 'Y') {
$hover = strip_tags(Codes::beautify_introduction($item['introduction']));
//.........这里部分代码省略.........
示例6: layout
/**
* list articles 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 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);
// 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' && Articles::is_owned($item, $anchor)) {
$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;
}
// introduction
$introduction = '';
if (is_object($overlay)) {
$introduction = $overlay->get_text('introduction', $item);
} else {
$introduction = $item['introduction'];
}
// the introductory text
if ($introduction) {
$suffix .= ' - ' . Codes::beautify_introduction($introduction);
// link to description, if any
if ($item['description']) {
$suffix .= ' ' . Skin::build_link($url, MORE_IMG, 'more', i18n::s('View the page')) . ' ';
}
}
// insert overlay data, if any
if (is_object($overlay)) {
$suffix .= $overlay->get_text('list', $item);
}
// details
$details = array();
// the author
if ($item['create_name'] != $item['edit_name']) {
$details[] = sprintf(i18n::s('by %s, %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']));
} else {
$details[] = sprintf(i18n::s('by %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']));
}
// 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
if ($count = Files::count_for_anchor('article:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
}
//.........这里部分代码省略.........
示例7: layout
/**
* list sections as topics in a forum
*
* @param resource the SQL result
* @return string the rendered text
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// layout in a table
$text = Skin::table_prefix('wide');
// 'even' is used for title rows, 'odd' for detail rows
$class_title = 'odd';
$class_detail = 'even';
// build a list of sections
$family = '';
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// change the family
if ($item['family'] != $family) {
$family = $item['family'];
// show the family
$text .= Skin::table_suffix() . '<h2><span>' . $family . ' </span></h2>' . "\n" . Skin::table_prefix('wide');
}
// get the related overlay, if any
$overlay = Overlay::load($item, 'section:' . $item['id']);
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// reset everything
$prefix = $label = $suffix = $icon = '';
// signal restricted and private sections
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// indicate the id in the hovering popup
$hover = i18n::s('View the section');
if (Surfer::is_member()) {
$hover .= ' [section=' . $item['id'] . ']';
}
// 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']);
}
// use the title as a link to the page
$title =& Skin::build_link($url, $title, 'basic', $hover);
// flag sections 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 . ' ';
}
// this is another row of the output
$text .= '<tr class="' . $class_title . '"><th>' . $prefix . $title . $suffix . '</th><th>' . i18n::s('Poster') . '</th><th>' . i18n::s('Messages') . '</th><th>' . i18n::s('Last active') . '</th></tr>' . "\n";
$count = 1;
// get last posts for this board --avoid sticky pages
if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
$order = $matches[1];
} else {
$order = 'edition';
}
if ($articles =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, 5, 'raw', TRUE)) {
foreach ($articles as $id => $article) {
// get the related overlay, if any
$article_overlay = Overlay::load($article, 'article:' . $id);
// flag articles updated recently
if ($article['expiry_date'] > NULL_DATE && $article['expiry_date'] <= $context['now']) {
$flag = EXPIRED_FLAG . ' ';
} elseif ($article['create_date'] >= $context['fresh']) {
$flag = NEW_FLAG . ' ';
} elseif ($article['edit_date'] >= $context['fresh']) {
$flag = UPDATED_FLAG . ' ';
} else {
$flag = '';
}
// use the title to label the link
if (is_object($article_overlay)) {
$title = Codes::beautify_title($article_overlay->get_text('title', $article));
} else {
$title = Codes::beautify_title($article['title']);
}
// title
$title = Skin::build_link(Articles::get_permalink($article), $title, 'article');
// poster
$poster = Users::get_link($article['create_name'], $article['create_address'], $article['create_id']);
// comments
$comments = Comments::count_for_anchor('article:' . $article['id']);
//.........这里部分代码省略.........
示例8: layout
/**
* list articles as digg do
*
* @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)) {
$label = i18n::s('No page to display.');
if (Surfer::is_associate()) {
$label .= ' ' . sprintf(i18n::s('Use the %s to populate this server.'), Skin::build_link('help/populate.php', i18n::s('Content Assistant'), 'shortcut'));
}
$output = '<p>' . $label . '</p>';
return $output;
}
// build a list of articles
$text = '';
$item_count = 0;
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
while ($item = SQL::fetch($result)) {
// permalink
$url = Articles::get_permalink($item);
// get the anchor
$anchor = Anchors::get($item['anchor']);
// get the related overlay, if any
$overlay = Overlay::load($item, 'article:' . $item['id']);
// next item
$item_count += 1;
// section opening
if ($item_count == 1) {
$text .= '<div class="newest">' . "\n";
}
// reset everything
$content = $prefix = $label = $suffix = $icon = '';
// the icon to put aside
if ($item['thumbnail_url']) {
$icon = $item['thumbnail_url'];
} elseif (is_callable(array($anchor, 'get_bullet_url'))) {
$icon = $anchor->get_bullet_url();
}
if ($icon) {
$icon = '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $icon . '" class="right_image" alt="' . encode_field(i18n::s('View the page')) . '" title="' . encode_field(i18n::s('View the page')) . '" /></a>';
}
// signal restricted and private articles
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// flag articles updated recently
if ($item['create_date'] >= $context['fresh']) {
$suffix .= ' ' . NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$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');
}
//.........这里部分代码省略.........
示例9: 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']);
//.........这里部分代码省略.........
示例10: layout
/**
* list articles as topics in a forum
*
* @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;
}
// allow for complete styling
$text = '<div class="last_articles">';
// build a list of articles
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);
// build a title
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 = '';
// 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 ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// flag expired articles
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 locked articles
if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
$suffix .= ' ' . LOCKED_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');
}
// indicate the id in the hovering popup
$hover = i18n::s('View the page');
if (Surfer::is_member()) {
$hover .= ' [article=' . $item['id'] . ']';
}
// one box per update
$text .= '<div class="last_article" >';
// use the title as a link to the page
$text .= Skin::build_block($prefix . ucfirst($title) . $suffix, 'header1');
// some details about this page
$details = array();
// page starter and date
if ($item['create_name']) {
$details[] = sprintf(i18n::s('Started by %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id'])) . ' ' . Skin::build_date($item['create_date']);
}
// page last modification
if ($item['edit_date'] && $item['edit_action'] == 'article:update' && $item['edit_name']) {
$details[] = Anchors::get_action_label($item['edit_action']) . ' ' . sprintf(i18n::s('by %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id'])) . ' ' . Skin::build_date($item['edit_date']);
}
// friends
if ($friends =& Members::list_users_by_posts_for_anchor('article:' . $item['id'], 0, USERS_LIST_SIZE, 'comma5', $item['create_id'])) {
$details[] = sprintf(i18n::s('with %s'), $friends);
}
// people details
if ($details) {
$text .= '<p class="details">' . join(', ', $details) . "</p>\n";
}
// the introductory text
$introduction = '';
if (is_object($overlay)) {
$introduction = $overlay->get_text('introduction', $item);
} elseif ($item['introduction']) {
$introduction = $item['introduction'];
}
if ($introduction) {
$text .= '<div style="margin: 1em 0;">' . Codes::beautify_introduction($introduction) . '</div>';
}
// insert overlay data, if any
if (is_object($overlay)) {
//.........这里部分代码省略.........
示例11: 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'] . 'comments/comments.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);
// build a title
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$title = Codes::beautify_title($item['title']);
}
// initialize variables
$prefix = $suffix = '';
// 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;
}
// 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;
}
// count related comments, if any
if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
$suffix .= ' (' . $count . ')';
}
// flag articles updated recently
if ($item['create_date'] >= $context['fresh']) {
$suffix .= NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= UPDATED_FLAG;
}
// the hovering title
if ($item['introduction'] && $context['skins_with_details'] == 'Y') {
$hover = strip_tags(Codes::beautify_introduction($item['introduction']));
} else {
$hover = i18n::s('View the page');
}
// help members to reference this page
if (Surfer::is_member()) {
$hover .= ' [article=' . $item['id'] . ']';
}
// list all components for this item
$items[$url] = array($prefix, Skin::strip($title, 30), $suffix, 'basic', NULL, $hover);
}
// end of processing
SQL::free($result);
return $items;
}
示例12: sprintf
$count = 0;
if ($ids = Articles::get_ids_for_overlay($_REQUEST['id'])) {
$context['text'] .= sprintf(i18n::s('Changing all overlays with name %s'), $_REQUEST['id']) . BR;
// one page at a time
foreach ($ids as $id) {
// load the page and bind the related overlay
if (($item = Articles::get($id)) && ($overlay = Overlay::load($item, 'article:' . $item['id'])) && is_callable(array($overlay, 'update'))) {
$count++;
// update provided attributes
$overlay->update($_REQUEST);
// save content of the overlay in the page
$item['overlay'] = $overlay->save();
$item['overlay_id'] = $overlay->get_id();
// store in the database
if (Articles::put($item)) {
$context['text'] .= sprintf(i18n::s('%s has been changed'), Skin::build_link(Articles::get_permalink($item), $item['title']));
}
}
}
// no page has been found
} else {
$context['text'] .= '<p>' . i18n::s('No item has the provided id.') . '</p>';
}
// report on results
if ($count) {
$context['text'] .= '<p>' . sprintf(i18n::ns('%d page has been processed.', '%d pages have been processed.', $count), $count) . '</p>';
}
// bottom commands
$menu = array();
$menu[] = Skin::build_link('overlays/mutables/edit.php', i18n::s('Change named overlays'), 'basic');
$context['text'] .= Skin::finalize_list($menu, 'assistant_bar');
示例13: layout
/**
* list articles
*
* Accept following variants:
* - 'hits', compact plus the number of hits
* - 'no_author', for articles in the user page
* - 'category:xxx', if the list is displayed at categories/view.php
* - 'section:xxx', if the list is displayed at sections/view.php
*
* @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, 'article:' . $item['id']);
// get the main 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']);
}
// 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' && Articles::is_owned($item, $anchor)) {
$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 compact version
if ($this->layout_variant == 'compact') {
$items[$url] = array($prefix, Skin::strip($title, 30), $suffix, 'basic', NULL);
continue;
}
// with hits
if ($this->layout_variant == 'hits') {
if ($item['hits'] > 1) {
$suffix = ' <span class="details">- ' . Skin::build_number($item['hits'], i18n::s('hits')) . '</span>';
}
$items[$url] = array($prefix, Skin::strip($title, 30), $suffix, 'basic', NULL);
continue;
}
// introduction
$introduction = '';
if (is_object($overlay)) {
$introduction = $overlay->get_text('introduction', $item);
} else {
$introduction = $item['introduction'];
}
// the introductory text
if ($introduction) {
$suffix .= ' - ' . Codes::beautify_introduction($introduction);
// link to description, if any
if ($item['description']) {
$suffix .= ' ' . Skin::build_link($url, MORE_IMG, 'more', i18n::s('View the page')) . ' ';
}
}
// insert overlay data, if any
//.........这里部分代码省略.........
示例14: layout_newest
/**
* layout the newest articles
*
* caution: this function also updates page title directly, and this makes its call non-cacheable
*
* @param array the article
* @return string the rendered text
**/
function layout_newest($item)
{
global $context;
// 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);
// reset the rendering engine between items
Codes::initialize($url);
// build a title
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$title = Codes::beautify_title($item['title']);
}
// title prefix & suffix
$text = $prefix = $suffix = '';
// flag articles updated recently
if ($context['site_revisit_after'] < 1) {
$context['site_revisit_after'] = 2;
}
$context['fresh'] = gmstrftime('%Y-%m-%d %H:%M:%S', mktime(0, 0, 0, date("m"), date("d") - $context['site_revisit_after'], date("Y")));
// link to permalink
if (Surfer::is_empowered()) {
$title = Skin::build_box_title($title, $url, i18n::s('Permalink'));
}
// signal articles to be published
if ($item['publish_date'] <= NULL_DATE) {
$prefix .= DRAFT_FLAG;
} else {
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 expired article
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$suffix .= EXPIRED_FLAG;
}
// update page title directly
$text .= Skin::build_block($prefix . $title . $suffix, 'title');
// if this article has a specific icon, use it
if ($item['icon_url']) {
$icon = $item['icon_url'];
} elseif ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
$icon = $anchor->get_icon_url();
}
// if we have a valid image
if (preg_match('/(.gif|.jpg|.jpeg|.png)$/i', $icon)) {
// fix relative path
if (!preg_match('/^(\\/|http:|https:|ftp:)/', $icon)) {
$icon = $context['url_to_root'] . $icon;
}
// flush the image on the right
$text .= '<img src="' . $icon . '" class="right_image" alt="" />';
}
// article rating, if the anchor allows for it
if (!is_object($anchor) || !$anchor->has_option('without_rating')) {
// report on current rating
$label = '';
if ($item['rating_count']) {
$label = Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])) . ' ';
}
$label .= i18n::s('Rate this page');
// allow for rating
$text .= Skin::build_link(Articles::get_url($item['id'], 'like'), $label, 'basic');
}
// the introduction text, if any
if (is_object($overlay)) {
$text .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
} else {
$text .= Skin::build_block($item['introduction'], 'introduction');
}
// insert overlay data, if any
if (is_object($overlay)) {
$text .= $overlay->get_text('view', $item);
}
// the beautified description, which is the actual page body
if ($item['description']) {
// use adequate label
if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
//.........这里部分代码省略.........
示例15: array
// list links by date (default) or by title (option :links_by_title:)
$items = array();
if (Articles::has_option('links_by_title', $anchor, $item)) {
$items = Links::list_by_title_for_anchor('article:' . $item['id'], 0, 50, 'compact');
} else {
$items = Links::list_by_date_for_anchor('article:' . $item['id'], 0, 50, 'compact');
}
// actually list items
if (count($items)) {
$context['text'] .= Skin::build_box(i18n::s('See also'), utf8::to_unicode(Skin::build_list($items, 'compact')));
}
//
// page suffix
//
// link to the original page
$context['text'] .= '<p>' . sprintf(i18n::s('The original page is located at %s'), Skin::build_link(Articles::get_permalink($item), Articles::get_permalink($item))) . "</p>\n";
// insert anchor suffix
if (is_object($anchor)) {
$context['text'] .= $anchor->get_suffix();
}
//
// special rendering if everything is ok
//
$text = '<html><body>' . "\n";
// display the title
if (isset($context['page_title']) && $context['page_title']) {
$text .= Skin::build_block($context['page_title'], 'page_title');
}
// display error messages, if any
$text .= Skin::build_error_block();
// render and display the content, if any