本文整理汇总了PHP中Codes::beautify_introduction方法的典型用法代码示例。如果您正苦于以下问题:PHP Codes::beautify_introduction方法的具体用法?PHP Codes::beautify_introduction怎么用?PHP Codes::beautify_introduction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Codes
的用法示例。
在下文中一共展示了Codes::beautify_introduction方法的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 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
//.........这里部分代码省略.........
示例3: 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']));
//.........这里部分代码省略.........
示例4: 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);
}
//.........这里部分代码省略.........
示例5: layout
/**
* list sections
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// we return some text
$text = '';
// empty list
if (!($delta = SQL::count($result))) {
return $text;
}
// process all items in the list
$count = 0;
$items = array();
while ($item = SQL::fetch($result)) {
// the url to view this item
$url = Sections::get_permalink($item);
// initialize variables
$prefix = $label = $suffix = '';
// flag sections that are draft or dead
if ($item['activation_date'] >= $context['now']) {
$prefix .= DRAFT_FLAG;
} elseif ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$prefix .= EXPIRED_FLAG;
}
// signal restricted and private sections
if ($item['active'] == 'N') {
$prefix .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$prefix .= RESTRICTED_FLAG;
}
// flag items updated recently
if ($item['create_date'] >= $context['fresh']) {
$suffix .= NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$suffix .= UPDATED_FLAG;
}
// // start the label with family, if any
// if($item['family'])
// $label = ucfirst(Skin::strip($item['family'], 30)).' - ';
// use the title to label the link
$label .= ucfirst(Skin::strip($item['title'], 30));
// 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 section');
}
// help members to reference this page
if (Surfer::is_member()) {
$hover .= ' [section=' . $item['id'] . ']';
}
// list all components for this item
$items[$url] = array($prefix, $label, $suffix, 'basic', NULL, $hover);
// limit to one page of results
if (++$count >= COMPACT_LIST_SIZE - 1) {
break;
}
}
// end of processing
SQL::free($result);
// turn this to some text
$text .= Skin::build_list($items, 'comma');
// some indications on the number of connections
if (($delta -= $count) > 0) {
$text .= ', ...';
}
return $text;
}
示例6: 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;
}
// output as a string
$text = '';
// build a list of sections
$family = '';
$first = TRUE;
while ($item = SQL::fetch($result)) {
// change the family
if ($item['family'] != $family) {
$family = $item['family'];
// close last table only if a section has been already listed
if (!$first) {
$text .= Skin::table_suffix();
}
// show the family
$text .= '<h2><span>' . $family . ' </span></h2>' . "\n" . Skin::table_prefix('yabb') . Skin::table_row(array(i18n::s('Board'), 'center=' . i18n::s('Topics'), i18n::s('Last post')), 'header');
} elseif ($first) {
$text .= Skin::table_prefix('yabb');
$text .= Skin::table_row(array(i18n::s('Board'), 'center=' . i18n::s('Topics'), i18n::s('Last post')), 'header');
}
// done with this case
$first = FALSE;
// 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 as a link to the page
$title =& Skin::build_link($url, Codes::beautify_title($item['title']), 'basic', $hover);
// also use a clickable thumbnail, if any
if ($item['thumbnail_url']) {
$prefix = Skin::build_link($url, '<img src="' . $item['thumbnail_url'] . '" alt="" title="' . encode_field($hover) . '" class="left_image" />', 'basic', $hover) . $prefix;
}
// 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 . ' ';
}
// board introduction
if ($item['introduction']) {
$suffix .= '<br style="clear: none;" />' . Codes::beautify_introduction($item['introduction']);
}
// more details
$details = '';
$more = array();
// board moderators
if ($moderators = Sections::list_editors_by_name($item, 0, 7, 'comma5')) {
$more[] = sprintf(i18n::ns('Moderator: %s', 'Moderators: %s', count($moderators)), $moderators);
}
// children boards
if ($children =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, COMPACT_LIST_SIZE, 'comma')) {
$more[] = sprintf(i18n::ns('Child board: %s', 'Child boards: %s', count($children)), Skin::build_list($children, 'comma'));
}
// as a compact list
if (count($more)) {
$details .= '<ul class="compact">';
foreach ($more as $list_item) {
$details .= '<li>' . $list_item . '</li>' . "\n";
}
$details .= '</ul>' . "\n";
}
// all details
if ($details) {
$details = BR . '<span class="details">' . $details . "</span>\n";
}
// count posts here, and in children sections
$anchors = Sections::get_branch_at_anchor('section:' . $item['id']);
if (!($count = Articles::count_for_anchor($anchors))) {
$count = 0;
}
// get last post
$last_post = '--';
$article =& Articles::get_newest_for_anchor($anchors, TRUE);
if ($article['id']) {
//.........这里部分代码省略.........
示例7: 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;
}
// start a table
$text .= Skin::table_prefix('jive');
// headers
$text .= Skin::table_row(array(i18n::s('Topic'), i18n::s('Content')), 'header');
// build a list of articles
$odd = FALSE;
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 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']);
}
// one row per article
$text .= '<tr class="' . ($odd ? 'odd' : 'even') . '"><td>';
$odd = !$odd;
// 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')) {
$text .= DRAFT_FLAG;
}
// signal restricted and private articles
if ($item['active'] == 'N') {
$text .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$text .= RESTRICTED_FLAG;
}
// use the title as a link to the page
$text .= Skin::build_link($url, '<strong>' . $title . '</strong>', 'basic');
// signal locked articles
if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
$text .= ' ' . LOCKED_FLAG;
}
// flag articles updated recently
if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
$text .= ' ' . EXPIRED_FLAG;
} elseif ($item['create_date'] >= $context['fresh']) {
$text .= ' ' . NEW_FLAG;
} elseif ($item['edit_date'] >= $context['fresh']) {
$text .= ' ' . UPDATED_FLAG;
}
// add details, if any
$details = array();
// poster name
if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
if ($item['create_name']) {
$details[] = sprintf(i18n::s('posted by %s %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']), Skin::build_date($item['create_date']));
}
}
// last update
$details[] = sprintf(i18n::s('Updated %s'), Skin::build_date($item['edit_date']));
// add details to the title
if (count($details)) {
$text .= '<p class="details" style="margin: 3px 0">' . join(', ', $details) . '</p>';
}
// display all tags
if ($item['tags']) {
$text .= '<p class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</p>';
}
// next cell for the content
$text .= '</td><td width="70%">';
// the content to be displayed
$content = '';
// rating
if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
$content .= Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
}
// the introductory text
if (is_object($overlay)) {
$content .= Codes::beautify_introduction($overlay->get_text('introduction', $item));
} else {
$content .= Codes::beautify_introduction($item['introduction']);
}
// insert overlay data, if any
if (is_object($overlay)) {
$content .= $overlay->get_text('list', $item);
}
// the description
//.........这里部分代码省略.........
示例8: array
$context['page_header'] .= "\n" . '<link rel="meta" href="' . $context['url_to_home'] . $context['url_to_root'] . Articles::get_url($item['id'], 'describe') . '" title="Meta Information" type="application/rdf+xml" />';
// implement the trackback interface
$permanent_link = Articles::get_permalink($item);
$trackback_link = $context['url_to_home'] . $context['url_to_root'] . 'links/trackback.php?anchor=article:' . $item['id'];
$context['page_header'] .= "\n" . '<!--' . "\n" . '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"' . "\n" . ' xmlns:dc="http://purl.org/dc/elements/1.1/"' . "\n" . ' xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">' . "\n" . '<rdf:Description' . "\n" . ' trackback:ping="' . $trackback_link . '"' . "\n" . ' dc:identifier="' . $permanent_link . '"' . "\n" . ' rdf:about="' . $permanent_link . '" />' . "\n" . '</rdf:RDF>' . "\n" . '-->';
// implement the pingback interface
$context['page_header'] .= "\n" . '<link rel="pingback" href="' . $context['url_to_root'] . 'services/ping.php" title="Pingback Interface" />';
// implement the Comment API interface
$context['page_header'] .= "\n" . '<link rel="service.comment" href="' . $context['url_to_root'] . Comments::get_url('article:' . $item['id'], 'service.comment') . '" title="Comment Interface" type="text/xml" />';
// set specific headers
if (is_object($overlay) && is_callable(array($overlay, 'get_meta_introduction_text')) && ($more = $overlay->get_text('meta_introduction', $item))) {
$order = array("\r\n", "\n", "\r");
$replace = ' ';
$context['page_meta'] = str_replace($order, $replace, strip_tags(Codes::beautify_introduction($more)));
} elseif (isset($item['introduction']) && $item['introduction']) {
$context['page_meta'] = strip_tags(Codes::beautify_introduction($item['introduction']));
}
if (isset($item['create_name']) && $item['create_name']) {
$context['page_author'] = $item['create_name'];
}
if (isset($item['edit_date']) && $item['edit_date']) {
$context['page_date'] = $item['edit_date'];
}
if (isset($item['publish_name']) && $item['publish_name']) {
$context['page_publisher'] = $item['publish_name'];
}
}
//
// set page details -- $context['page_details']
//
$text = '';
示例9: layout
function layout($result)
{
global $context;
// load skin for ajax request
load_skin();
// we return some text
$text = '';
// empty list
if (!SQL::count($result)) {
return $text;
}
// infinite scroll is a option
$infinite = $this->has_variant('infinite');
// column grid width may have been setted thru variant
if (!($grid_width = $this->has_variant('grid'))) {
$grid_width = MC_GRID_DEFAULT;
}
// wrappers
if ($infinite) {
$text .= '<div class="mc-infinite">';
}
$text .= '<div class="mc-wrap" >' . "\n";
while ($item = SQL::fetch($result)) {
// get the object interface, this may load parent and overlay
$entity = new $this->listed_type($item);
// link
$url = $entity->get_permalink();
// title
$title = $entity->get_title();
// intro
$intro = Codes::beautify_introduction($entity->get_introduction());
if ($intro) {
$intro = BR . $intro;
}
// image
$thumb = '';
if (!$this->has_variant('no_thumb')) {
if ($thumb = trim($entity->get_thumbnail_url())) {
// 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
$thumb = '<img src="' . $thumb . '" alt="" title="' . encode_field($title) . '" ' . $options . ' />' . "\n";
} else {
$thumb = MAP_IMG;
}
}
// use the image as a link to the target page
if ($thumb) {
$thumb = Skin::build_link($url, $thumb, 'basic', $title);
}
// use list text of overlay if any
$list = '';
if (is_object($entity->overlay)) {
$list = $entity->overlay->get_text('list');
}
// list articles, if any
$childs = $entity->get_childs('articles', 0, 5, 'alistapart');
// content
$content = $thumb . $intro . $list;
if (isset($childs['article'])) {
$content .= $childs['article'];
}
// add a block, guess the html tag from context
if (isset($context['SKIN_HTML5'])) {
switch ($this->listed_type) {
case 'article':
$tag = 'article';
break;
case 'section':
case 'category':
$tag = 'section';
break;
case 'user':
default:
$tag = 'div';
}
} else {
$tag = 'div';
}
$text .= '<' . $tag . ' class="mc-block">' . '<h3>' . $title . '</h3>' . $content . '</' . $tag . '>' . "\n";
}
// end wrappers
if ($infinite) {
$text .= '</div>';
}
$text .= '</div>' . "\n";
if (!isset($context['AJAX_REQUEST']) || $context['AJAX_REQUEST'] == false) {
// we have bound styles and scripts
$this->load_scripts_n_styles();
// initialize js
Page::insert_script('Mosaic.init(' . $grid_width . ')');
// infinite scroll js lib
if ($infinite) {
Page::defer_script('layouts/layout_as_mosaic/jquery.infinitescroll.min.js');
Page::insert_script('Mosaic.infiniteScroll()');
}
} else {
//.........这里部分代码省略.........
示例10: layout
/**
* list users
*
* @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 (!($count = SQL::count($result))) {
return $text;
}
$text = '<div>';
// process all items in the list
$count = 0;
$checked = ' checked="checked"';
while ($item = SQL::fetch($result)) {
// we need some address
if (!$item['email']) {
continue;
}
// do not write to myself
if ($item['id'] == Surfer::get_id()) {
continue;
}
// get the related overlay, if any
$overlay = Overlay::load($item, 'user:' . $item['id']);
// one radio button per person
$text .= '<input type="radio" name="requested" value="' . encode_field($item['id']) . '"' . $checked . ' />';
// signal restricted and private users
if ($item['active'] == 'N') {
$text .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$text .= RESTRICTED_FLAG;
}
// the url to view this item
$url = Users::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['full_name']);
}
// sanity check
if (!$title) {
$title = $item['nick_name'];
}
// link to this page
$text .= Skin::build_link($url, $title, 'user');
// the introductory text
if ($item['introduction']) {
$text .= '<span class="tiny"> - ' . Codes::beautify_introduction($item['introduction']) . '</span>';
}
// insert overlay data, if any
if (is_object($overlay)) {
$text .= $overlay->get_text('list', $item);
}
// append the row
$text .= BR;
$count++;
$checked = '';
}
// div suffix
$text .= '</div>';
// no valid account has been found
if (!$count) {
$text = '';
}
// end of processing
SQL::free($result);
return $text;
}
示例11: 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;
}
// page size for comments
include_once $context['path_to_root'] . 'comments/layout_comments_as_updates.php';
$layout = new Layout_comments_as_updates();
// build a list of articles
$rows = array();
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']);
}
// reset everything
$text = $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, and 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');
}
// select an icon for this thread
$item['comments_count'] = Comments::count_for_anchor('article:' . $item['id']);
if (is_object($overlay) && $overlay->attributes['overlay_type'] == 'poll') {
Skin::define_img('POLL_IMG', 'articles/poll.gif');
$icon = POLL_IMG;
} elseif ($item['rank'] < 10000) {
Skin::define_img('STICKY_THREAD_IMG', 'articles/sticky_thread.gif');
$icon = STICKY_THREAD_IMG;
} elseif (isset($item['comments_count']) && $item['comments_count'] >= 20) {
Skin::define_img('VERY_HOT_THREAD_IMG', 'articles/very_hot_thread.gif');
$icon = VERY_HOT_THREAD_IMG;
} elseif (isset($item['comments_count']) && $item['comments_count'] >= 10) {
$icon = HOT_THREAD_IMG;
} else {
$icon = THREAD_IMG;
}
// indicate the id in the hovering popup
$hover = i18n::s('View the page');
if (Surfer::is_member()) {
$hover .= ' [article=' . $item['id'] . ']';
}
// use the title as a link to the page
$title = $prefix . Skin::build_link($url, ucfirst($title), 'basic', $hover) . $suffix;
$suffix = '';
// the introductory text
$introduction = '';
if (is_object($overlay)) {
$introduction = $overlay->get_text('introduction', $item);
} elseif ($item['introduction']) {
$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);
}
// shortcuts to comments pages
if (isset($item['comments_count']) && ($pages = (int) ceil($item['comments_count'] / $layout->items_per_page())) && $pages > 1) {
$suffix .= '<p class="details">Pages ';
for ($index = 1; $index <= $pages; $index++) {
//.........这里部分代码省略.........
示例12: layout
//.........这里部分代码省略.........
$details[] = sprintf(i18n::ns('%d file', '%d files', count($items)), count($items));
// add one link per item
foreach ($items as $url => $label) {
if (is_array($label)) {
$prefix = $label[0];
$suffix = $label[2];
$label = $label[1];
}
$elements[] = $prefix . Skin::build_link($url, $label, 'file') . $suffix;
}
}
// info on related comments
if ($items = Comments::list_by_date_for_anchor('section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact', TRUE)) {
// mention the number of sections in folded title
$details[] = sprintf(i18n::ns('%d comment', '%d comments', count($items)), count($items));
// add one link per item
foreach ($items as $url => $label) {
$prefix = $suffix = '';
if (is_array($label)) {
$prefix = $label[0];
$suffix = $label[2];
$label = $label[1];
}
$elements[] = $prefix . Skin::build_link($url, $label, 'comment') . $suffix;
}
}
// info on related links
if (Sections::has_option('links_by_title', $anchor, $item)) {
$items = Links::list_by_title_for_anchor('section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact');
} else {
$items = Links::list_by_date_for_anchor('section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact');
}
if ($items) {
// mention the number of sections in folded title
$details[] = sprintf(i18n::ns('%d link', '%d links', count($items)), count($items));
// add one link per item
foreach ($items as $url => $label) {
$prefix = $suffix = '';
if (is_array($label)) {
$prefix = $label[0];
$suffix = $label[2];
$label = $label[1];
}
$elements[] = $prefix . Skin::build_link($url, $label) . $suffix;
}
}
// list related sections, if any
if ($items =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact')) {
// mention the number of sections in folded title
$details[] = sprintf(i18n::ns('%d section', '%d sections', count($items)), count($items));
// add one link per item
foreach ($items as $url => $label) {
$prefix = $suffix = '';
if (is_array($label)) {
$prefix = $label[0];
$suffix = $label[2];
$label = $label[1];
}
$elements[] = $prefix . Skin::build_link($url, $label, 'section') . $suffix;
}
}
// signal continuing sections
if (count($elements) > MAXIMUM_ITEMS_PER_SECTION) {
$elements[] = Skin::build_link(Sections::get_permalink($item), i18n::s('More pages') . MORE_IMG, 'basic');
} else {
$elements[] = Skin::build_link(Sections::get_permalink($item), i18n::s('View the section'), 'shortcut');
}
// complement title
if (count($details)) {
$box['title'] .= ' <span class="details">(' . join(', ', $details) . ')</span>';
}
// insert introduction, if any
if ($item['introduction']) {
$box['text'] .= Codes::beautify_introduction($item['introduction']);
}
// make a full list
if (count($elements)) {
$box['text'] .= '<ul><li>' . implode('</li>' . "\n" . '<li>', $elements) . '</li></ul>' . "\n";
}
// if we have an icon for this section, use it
if (isset($item['thumbnail_url']) && $item['thumbnail_url']) {
// adjust the class
$class = '';
if (isset($context['classes_for_thumbnail_images'])) {
$class = 'class="' . $context['classes_for_thumbnail_images'] . '" ';
}
// build the complete HTML element
$icon = '<img src="' . $item['thumbnail_url'] . '" alt="" title="' . encode_field(Codes::beautify_title($item['title'])) . '" ' . $class . '/>';
// make it clickable
$link = Skin::build_link(Sections::get_permalink($item), $icon, 'basic');
// put this aside
$box['text'] = '<table class="decorated"><tr>' . '<td class="image">' . $link . '</td>' . '<td class="content">' . $box['text'] . '</td>' . '</tr></table>';
}
// always make a box
$text .= Skin::build_box($box['title'], $box['text'], 'folded');
}
// end of processing
SQL::free($result);
return $text;
}
示例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
/**
* 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');
//.........这里部分代码省略.........
示例15: 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()) {
//.........这里部分代码省略.........