本文整理汇总了PHP中Article::load_by_content方法的典型用法代码示例。如果您正苦于以下问题:PHP Article::load_by_content方法的具体用法?PHP Article::load_by_content怎么用?PHP Article::load_by_content使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Article
的用法示例。
在下文中一共展示了Article::load_by_content方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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');
}
//.........这里部分代码省略.........
示例2: layout
/**
* list articles
*
* @param resource the SQL result
* @return array
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($url => $attributes)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// process all items in the list
include_once $context['path_to_root'] . 'articles/article.php';
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'locations/locations.php';
while ($item = SQL::fetch($result)) {
// get the related overlay, if any
$overlay = Overlay::load($item, 'article:' . $item['id']);
// get the anchor
$anchor = Anchors::get($item['anchor']);
// provide an absolute link
$url = Articles::get_permalink($item);
// build a title
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$title = Codes::beautify_title($item['title']);
}
// time of last update
$time = SQL::strtotime($item['edit_date']);
// the section
$section = '';
if ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
$section = ucfirst(trim(strip_tags(Codes::beautify_title($anchor->get_title()))));
}
// the icon to use
$icon = '';
if ($item['thumbnail_url']) {
$icon = $item['thumbnail_url'];
} elseif ($item['anchor'] && ($anchor = Anchors::get($item['anchor'])) && is_callable($anchor, 'get_bullet_url')) {
$icon = $anchor->get_bullet_url();
}
if ($icon) {
$icon = $context['url_to_home'] . $context['url_to_root'] . $icon;
}
// the author(s) is an e-mail address, according to rss 2.0 spec
$author = '';
if (isset($item['create_address'])) {
$author .= $item['create_address'];
}
if (isset($item['create_name']) && trim($item['create_name'])) {
$author .= ' (' . $item['create_name'] . ')';
}
if (isset($item['edit_address']) && trim($item['edit_address']) && $item['create_address'] != $item['edit_address']) {
if ($author) {
$author .= ', ';
}
$author .= $item['edit_address'];
if (isset($item['edit_name']) && trim($item['edit_name'])) {
$author .= ' (' . $item['edit_name'] . ')';
}
}
// some introductory text for this article
$article = new Article();
$article->load_by_content($item);
$introduction = $article->get_teaser('teaser');
// warns on restricted access
if (isset($item['active']) && $item['active'] != 'Y') {
$introduction = '[' . i18n::c('Restricted to members') . '] ' . $introduction;
}
// fix references
$introduction = preg_replace('/"\\//', '"' . $context['url_to_home'] . '/', $introduction);
// the article content
$description = '';
// other rss fields
$extensions = array();
// the geolocation for this page, if any
if ($location = Locations::locate_anchor('article:' . $item['id'])) {
$extensions[] = '<georss:point>' . str_replace(',', ' ', $location) . '</georss:point>';
}
// url for comments
if (is_object($anchor)) {
$extensions[] = '<comments>' . encode_link($context['url_to_home'] . $context['url_to_root'] . $anchor->get_url('comments')) . '</comments>';
}
// count comments
$comment_count = Comments::count_for_anchor('article:' . $item['id']);
$extensions[] = '<slash:comments>' . $comment_count . "</slash:comments>";
// the comment post url
$extensions[] = '<wfw:comment>' . encode_link($context['url_to_home'] . $context['url_to_root'] . Comments::get_url('article:' . $item['id'], 'service.comment')) . "</wfw:comment>";
// the comment Rss url
$extensions[] = '<wfw:commentRss>' . encode_link($context['url_to_home'] . $context['url_to_root'] . Comments::get_url('article:' . $item['id'], 'feed')) . "</wfw:commentRss>";
// the trackback url
$extensions[] = '<trackback:ping>' . encode_link($context['url_to_home'] . $context['url_to_root'] . 'links/trackback.php?anchor=' . urlencode('article:' . $item['id'])) . "</trackback:ping>";
// no trackback:about;
//.........这里部分代码省略.........
示例3: layout
/**
* list articles
*
* @param resource the SQL result
* @return array
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($url => $attributes)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// process all items in the list
include_once $context['path_to_root'] . 'articles/article.php';
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);
// build a title
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$title = Codes::beautify_title($item['title']);
}
// time of publication
if (isset($item['publish_date']) && $item['publish_date'] > NULL_DATE) {
$time = $item['publish_date'];
} else {
$time = NULL_DATE;
}
// the section
$section = '';
if ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
$section = ucfirst(trim(strip_tags(Codes::beautify_title($anchor->get_title()))));
}
// the icon to use
$icon = '';
if ($item['thumbnail_url']) {
$icon = $item['thumbnail_url'];
} elseif ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
$icon = $anchor->get_thumbnail_url();
}
if ($icon) {
$icon = $context['url_to_home'] . $context['url_to_root'] . $icon;
}
// the author(s) is an e-mail address, according to rss 2.0 spec
$author = '';
if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
if (isset($item['create_address'])) {
$author .= $item['create_address'];
}
if (isset($item['create_name']) && trim($item['create_name'])) {
$author .= ' (' . $item['create_name'] . ')';
}
}
// some introductory text for this article
$article = new Article();
$article->load_by_content($item);
$introduction = $article->get_teaser('basic');
// warns on restricted access
if (isset($item['active']) && $item['active'] != 'Y') {
$introduction = '[' . i18n::c('Restricted to members') . '] ' . $introduction;
}
// fix references
$introduction = preg_replace('/"\\//', '"' . $context['url_to_home'] . '/', $introduction);
// list all components for this item
$items[$url] = array($time, $title, $author, $section, $icon, $introduction);
}
// end of processing
SQL::free($result);
return $items;
}
示例4: layout
/**
* list articles as news
*
* @param resource the SQL result
* @return array
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($url => $attributes)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// process all items in the list
include_once $context['path_to_root'] . 'articles/article.php';
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . '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);
// reset the rendering engine between items
Codes::initialize($url);
// 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 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;
}
// go to a new line
$suffix .= BR;
// get introduction from overlay
if (is_object($overlay)) {
$suffix .= Codes::beautify_introduction($overlay->get_text('introduction', $item));
// add a link to the main page
$suffix .= BR . Skin::build_link($url, i18n::s('More') . MORE_IMG, 'basic', i18n::s('View the page'));
// use introduction
} elseif ($item['introduction']) {
$suffix .= Codes::beautify_introduction($item['introduction']);
// add a link to the main page
$suffix .= BR . Skin::build_link($url, i18n::s('More') . MORE_IMG, 'basic', i18n::s('View the page'));
// else use a teaser, if no overlay
} elseif (!is_object($overlay)) {
$article = new Article();
$article->load_by_content($item);
$suffix .= $article->get_teaser('teaser');
}
// insert overlay data, if any
if (is_object($overlay)) {
$suffix .= $overlay->get_text('list', $item);
}
// the icon to put in the left column
if ($item['thumbnail_url']) {
$suffix .= BR . Skin::build_link($url, '<img src="' . $item['thumbnail_url'] . '" alt="" title="' . encode_field($title) . '" />', 'basic');
}
// details
$details = array();
// info on related files
if ($count = Files::count_for_anchor('article:' . $item['id'])) {
$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);
}
// actually insert details
if ($details) {
$suffix .= '<p class="details">' . ucfirst(trim(implode(', ', $details))) . '</p>';
}
//.........这里部分代码省略.........
示例5: layout
/**
* list articles as slashdot do
*
* @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;
}
// 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'] . 'articles/article.php';
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');
}
// document this section
$content = $prefix = $title = $suffix = $icon = '';
$menu = array();
// permalink
$url = Sections::get_permalink($item);
// get the anchor
$anchor = Anchors::get($item['anchor']);
// get the related overlay, if any
$overlay = Overlay::load($item, 'section:' . $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']);
}
// signal restricted and private sections
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// this is another row of the output
$text .= '<tr class="' . $class_title . '"><th>' . $prefix . Skin::build_link($url, $title, 'basic', i18n::s('View the section')) . $suffix . '</th></tr>' . "\n";
// document most recent page here
$content = $prefix = $title = $suffix = $icon = '';
$menu = array();
// branches of this tree
$anchors = Sections::get_branch_at_anchor('section:' . $item['id']);
// get last post
$article =& Articles::get_newest_for_anchor($anchors, TRUE);
if ($article['id']) {
// permalink
$url = Articles::get_permalink($article);
// get the anchor
$anchor = Anchors::get($article['anchor']);
// get the related overlay, if any
$overlay = Overlay::load($item, 'section:' . $item['id']);
// use the title to label the link
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $article));
} else {
$title = Codes::beautify_title($article['title']);
}
// signal restricted and private articles
if ($article['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($article['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// the icon to put aside
if ($article['thumbnail_url']) {
$icon = $article['thumbnail_url'];
}
// the icon to put aside
if (!$icon && 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="" title="' . encode_field(i18n::s('View the page')) . '" /></a>';
}
// the introductory text
if ($article['introduction']) {
$content .= Codes::beautify_introduction($article['introduction']);
} elseif (!is_object($overlay)) {
$handle = new Article();
$handle->load_by_content($article);
//.........这里部分代码省略.........
示例6: finalize_update
/**
* do whatever is necessary when a page has been updated
*
* This function:
* - logs the update
* - sends notification to watchers and to followers
* - "touches" the container of the page,
* - ping referred pages remotely (via the pingback protocol)
* - ping selected servers, if any
* - and triggers the hook 'update'.
*
* The first parameter provides the watching context to consider. If call is related
* to the creation of a published page, the context is the section that hosts the new
* page. If call is related to a draft page that has been published, then the context
* is the page itself.
*
* This function is also able to notify followers of the surfer who has initiated the
* action.
*
* @param object the watching context
* @param array attributes of the published page
* @param object page overlay, if any
* @param boolean TRUE if dates should be left unchanged, FALSE otherwise
* @param boolean TRUE if watchers should be notified, FALSE otherwise
* @param boolean TRUE if followers should be notified, FALSE otherwise
*/
public static function finalize_update($anchor, $item, $overlay = NULL, $silently = FALSE, $with_watchers = TRUE, $with_followers = FALSE)
{
global $context;
// proceed only if the page has been published
if (isset($item['publish_date']) && $item['publish_date'] > NULL_DATE) {
// notification to send by e-mail
$mail = array();
$mail['subject'] = sprintf(i18n::c('%s: %s'), i18n::c('Update'), strip_tags($item['title']));
$mail['notification'] = Articles::build_notification('update', $item);
$mail['headers'] = Mailer::set_thread('article:' . $item['id']);
// allow the overlay to prevent notifications of watcherss
if (is_object($overlay) && !$overlay->should_notify_watchers($mail)) {
$with_watchers = FALSE;
}
// send to watchers of this page, and to watchers upwards
if ($with_watchers && ($handle = new Article())) {
$handle->load_by_content($item, $anchor);
$handle->alert_watchers($mail, 'article:update', $item['active'] == 'N');
}
// never notify followers on private pages
if (isset($item['active']) && $item['active'] == 'N') {
$with_followers = FALSE;
}
// allow the overlay to prevent notifications of followers
if (is_object($overlay) && !$overlay->should_notify_followers()) {
$with_followers = FALSE;
}
// send to followers of this user
if ($with_followers && Surfer::get_id()) {
$mail['message'] = Mailer::build_notification($mail['notification'], 2);
Users::alert_watchers('user:' . Surfer::get_id(), $mail);
}
// update anchors
$anchor->touch('article:update', $item['id'], $silently);
// advertise public pages
if (isset($item['active']) && $item['active'] == 'Y') {
// expose links within the page
$raw = '';
if (isset($item['introduction'])) {
$raw .= $item['introduction'];
}
if (isset($item['source'])) {
$raw .= ' ' . $item['source'];
}
if (isset($item['description'])) {
$raw .= ' ' . $item['description'];
}
// pingback to referred links, if any
include_once $context['path_to_root'] . 'links/links.php';
Links::ping($raw, 'article:' . $item['id']);
// ping servers, if any
Servers::notify($anchor->get_url());
}
}
// 'update' hook
if (is_callable(array('Hooks', 'include_scripts'))) {
Hooks::include_scripts('update', $item['id']);
}
// log page update
$label = sprintf(i18n::c('Update: %s'), strip_tags($item['title']));
$poster = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']);
$description = sprintf(i18n::c('Updated by %s in %s'), $poster, $anchor->get_title());
$description .= "\n\n" . '<a href="' . Articles::get_permalink($item) . '">' . $item['title'] . '</a>';
Logger::notify('articles/articles.php: ' . $label, $description);
}
示例7: elseif
// publication is confirmed
} elseif (isset($_REQUEST['publish_date']) && $_REQUEST['publish_date'] > NULL_DATE) {
// convert dates from surfer time zone to UTC time zone
$_REQUEST['publish_date'] = Surfer::to_GMT($_REQUEST['publish_date']);
if (isset($_REQUEST['expiry_date']) && $_REQUEST['expiry_date'] > NULL_DATE) {
$_REQUEST['expiry_date'] = Surfer::to_GMT($_REQUEST['expiry_date']);
}
// update the database
if ($error = Articles::stamp($item['id'], $_REQUEST['publish_date'], isset($_REQUEST['expiry_date']) ? $_REQUEST['expiry_date'] : NULL_DATE)) {
Logger::error($error);
} else {
// reflect in memory what has been saved in database
$item['publish_date'] = $_REQUEST['publish_date'];
// send to watchers of this page, and to watchers upwards
$watching_context = new Article();
$watching_context->load_by_content($item, $anchor);
// do whatever is necessary on page publication
Articles::finalize_publication($watching_context, $item, $overlay, isset($_REQUEST['silent']) && $_REQUEST['silent'] == 'Y', isset($_REQUEST['notify_followers']) && $_REQUEST['notify_followers'] == 'Y');
// splash messages
$context['text'] .= '<p>' . i18n::s('The page has been successfully published.') . "</p>\n";
// list persons that have been notified
$context['text'] .= Mailer::build_recipients('article:' . $item['id']);
// clear the cache
Articles::clear($item);
// follow-up commands
$follow_up = i18n::s('Where do you want to go now?');
$menu = array();
$menu = array_merge($menu, array(Articles::get_permalink($item) => i18n::s('Back to main page')));
if (Surfer::is_associate()) {
$menu = array_merge($menu, array('articles/review.php' => i18n::s('Review queue')));
}
示例8: layout
/**
* list articles as slashdot do
*
* @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'] . 'articles/article.php';
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
$class = 'even';
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);
// 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
$content = $prefix = $label = $suffix = $icon = '';
// the icon to put aside
if ($item['thumbnail_url']) {
$icon = $item['thumbnail_url'];
}
if ($icon) {
$icon = '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $icon . '" class="right_image" alt="" title="' . encode_field(i18n::s('More')) . '" /></a>';
}
// flag sticky pages
if ($item['rank'] < 10000) {
$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');
//.........这里部分代码省略.........
示例9: layout
/**
* list articles
*
* @param resource the SQL result
* @return array( $title => $content )
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return an array of ($url => $attributes)
$items = array();
// empty list
if (!SQL::count($result)) {
return $items;
}
// process all items in the list
include_once $context['path_to_root'] . 'articles/article.php';
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']);
}
// shortcut for associates
if (Surfer::is_associate()) {
$title =& Skin::build_box_title($title, $url, i18n::s('View the page'));
}
// title prefix
$prefix = '';
// 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;
}
// prefix the title
$title = $prefix . $title;
// what has to be displayed in this box
$parts = array();
// if the page is publicly available, show introduction and link to full content
$article = new Article();
$article->load_by_content($item, Anchors::get($item['anchor']));
if ($article->is_public()) {
// get introduction from overlay, if any
if (is_object($overlay)) {
$parts[] = Codes::beautify_introduction($overlay->get_text('introduction', $item));
// add a link to the main page
$parts[] = Skin::build_link($url, i18n::s('More') . MORE_IMG, 'basic', i18n::s('View the page'));
// use the introduction, if any
} elseif ($item['introduction']) {
// the content of this box
$parts[] = Codes::beautify_introduction($item['introduction']);
// add a link to the main page
$parts[] = Skin::build_link($url, i18n::s('More') . MORE_IMG, 'basic', i18n::s('View the page'));
// no introduction, display article full content
} else {
// insert overlay data, if any
if (is_object($overlay)) {
$parts[] = $overlay->get_text('box', $item);
}
// the content of this box
$parts[] = Codes::beautify($item['description'], $item['options']);
}
// else display full box content
} else {
// use the introduction, if any
if ($item['introduction']) {
$parts[] = Codes::beautify_introduction($item['introduction']);
}
// get the related overlay, if any
$overlay = Overlay::load($item, 'article:' . $item['id']);
// insert overlay data, if any
if (is_object($overlay)) {
$parts[] = $overlay->get_text('box', $item);
}
// the content of this box
if ($item['description']) {
$parts[] = Codes::beautify($item['description'], $item['options']);
}
}
// use nick name as box id
$id = '';
if (isset($item['nick_name'])) {
$id = trim($item['nick_name']);
}
// append to the list
$items[$title] = array('content' => implode(BR, $parts), 'id' => $id);
}
// end of processing
//.........这里部分代码省略.........
示例10: layout
//.........这里部分代码省略.........
}
// 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 introductory text
if ($item['introduction']) {
$suffix .= ' - ' . Codes::beautify_introduction($item['introduction']);
// link to description, if any
if ($item['description']) {
$suffix .= ' ' . Skin::build_link($url, MORE_IMG, 'more', i18n::s('View the page')) . ' ';
}
// else use a teaser, if no overlay
} elseif (!is_object($overlay)) {
$article = new Article();
$article->load_by_content($item);
if ($teaser = $article->get_teaser('teaser')) {
$suffix .= ' - ' . $teaser;
}
}
// insert overlay data, if any
if (is_object($overlay)) {
$suffix .= $overlay->get_text('list', $item);
}
// next line, except if we already are at the beginning of a line
if ($suffix && !preg_match('/<br\\s*\\/>$/', rtrim($suffix))) {
$suffix .= BR;
}
// append details to the suffix
$suffix .= '<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
if ($count = Files::count_for_anchor('article:' . $item['id'])) {
示例11: 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;
// we return some text
$text = '';
// empty list
if (!SQL::count($result)) {
return $text;
}
// build a list of articles
$text = '';
$item_count = 0;
include_once $context['path_to_root'] . 'articles/article.php';
include_once $context['path_to_root'] . 'comments/comments.php';
while ($item = SQL::fetch($result)) {
// get the related overlay, if any
$overlay = Overlay::load($item, 'article:' . $item['id']);
// get the anchor
$anchor = Anchors::get($item['anchor']);
// the url to view this item
$url = Articles::get_permalink($item);
// make a live title
if (is_object($overlay)) {
$title = Codes::beautify_title($overlay->get_text('title', $item));
} else {
$title = Codes::beautify_title($item['title']);
}
// 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="" title="' . encode_field(i18n::s('View the page')) . '" /></a>';
}
// rating
if ($item['rating_count']) {
$rating_label = sprintf(i18n::ns('%s vote', '%s votes', $item['rating_count']), '<span class="big">' . $item['rating_count'] . '</span>' . BR);
} else {
$rating_label = i18n::s('No vote');
}
// present results
$digg = '<div class="digg"><div class="votes">' . $rating_label . '</div>';
// a rating has already been registered
if (isset($_COOKIE['rating_' . $item['id']])) {
Cache::poison();
} else {
$digg .= '<div class="rate">' . Skin::build_link(Articles::get_url($item['id'], 'like'), i18n::s('Rate it'), 'basic') . '</div>';
}
// close digg-like area
$digg .= '</div>';
// 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;
}
// 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;
}
// the full introductory text
if (is_object($overlay)) {
$content .= Codes::beautify_introduction($overlay->get_text('introduction', $item));
}
if ($item['introduction']) {
$content .= Codes::beautify_introduction($item['introduction']);
} else {
$article = new Article();
$article->load_by_content($item);
$content .= $article->get_teaser('teaser');
//.........这里部分代码省略.........