本文整理汇总了PHP中Sections::list_by_title_for_anchor方法的典型用法代码示例。如果您正苦于以下问题:PHP Sections::list_by_title_for_anchor方法的具体用法?PHP Sections::list_by_title_for_anchor怎么用?PHP Sections::list_by_title_for_anchor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sections
的用法示例。
在下文中一共展示了Sections::list_by_title_for_anchor方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_childs
/**
* list childs of this anchor, with or without type filters
*
* @param string set of desired childs (articles, sections...) separted by comma, or "all" keyword
* @param int offset to start listing
* @param int the maximum of items returned per type
* @param mixed string or object the layout to use
* @return an array of array with raw items sorted by type
*/
function get_childs($filter = 'all', $offset = 0, $max = 50, $layout = 'raw')
{
// we return a array
$childs = array();
// sub sections
if ($filter == 'all' || preg_match('/\\bsections?\\b/i', $filter)) {
$childs['section'] = Sections::list_by_title_for_anchor($this->get_reference(), $offset, $max, $layout);
}
// sub articles
if ($filter == 'all' || preg_match('/\\barticles?\\b/i', $filter)) {
$childs['article'] = Articles::list_for_anchor_by('title', $this->get_reference(), $offset, $max, $layout);
}
// files
if ($filter == 'all' || preg_match('/\\bfiles?\\b/i', $filter)) {
$childs['file'] = Files::list_by_title_for_anchor($this->get_reference(), $offset, $max, $layout);
}
return $childs;
}
示例2: array
// the maximum number of sections per page
if (is_object($layout)) {
$items_per_page = $layout->items_per_page();
} else {
$items_per_page = SECTIONS_PER_PAGE;
}
// build a complete box
$box = array('top_bar' => array(), 'text' => '', 'bottom_bar' => array());
// the command to add a new section
if (Sections::allow_creation($item, $anchor)) {
Skin::define_img('SECTIONS_ADD_IMG', 'sections/add.gif');
$box['top_bar'] += array('sections/edit.php?anchor=' . urlencode('section:' . $item['id']) => SECTIONS_ADD_IMG . i18n::s('Add a section'));
}
// list items by title
$offset = ($zoom_index - 1) * $items_per_page;
$items = Sections::list_by_title_for_anchor('section:' . $item['id'], $offset, $items_per_page, $layout);
// top menu
if ($box['top_bar']) {
$box['text'] .= Skin::build_list($box['top_bar'], 'menu_bar');
}
// actually render the html for the section
if (is_array($items) && is_string($item['sections_layout']) && $item['sections_layout'] == 'compact') {
$box['text'] .= Skin::build_list($items, 'compact');
} elseif (is_array($items)) {
$box['text'] .= Skin::build_list($items, 'decorated');
} elseif (is_string($items)) {
$box['text'] .= $items;
}
// count the number of subsections
if ($count = Sections::count_for_anchor('section:' . $item['id'])) {
if ($count > 20) {
示例3: tabs
/**
* show site tabs
*
* Tabs are derived by top-level sections of the server.
*
* Prefix and suffix tabs can be provided as links packaged in arrays of ( $url => array($label_prefix, $label, $label_suffix, $link_class) )
*
* @param boolean TRUE to add a tab to the front page, FALSE otherwise
* @param boolean TRUE to reverse order of tabs, FALSE otherwise
* @param array of links to be used as tabs before the regular set
* @param array of links to be used as tabs after the regular set
* @param string layout name to use for listing sub-sections (horizontal drop down menu)
*/
public static function tabs($with_home = TRUE, $with_reverse = FALSE, $prefix = NULL, $suffix = NULL, $layout_subsections = NULL)
{
global $context;
// only for live servers Or Associate
if (!file_exists($context['path_to_root'] . 'parameters/switch.on') && !Surfer::is_associate()) {
return;
}
// we have no database back-end
if (!is_callable(array('sql', 'query'))) {
return;
}
// limit listing for drop-down menu
if (!defined('TABS_DROP_LIST_SIZE')) {
define('TABS_DROP_LIST_SIZE', 5);
}
// cache this across requests
$cache_id = 'skins/page.php#tabs';
if (!($text = Cache::get($cache_id))) {
// an array of tabs
$site_bar = array();
// prefix tabs, if any
if (is_array($prefix) && count($prefix)) {
$site_bar = array_merge($site_bar, $prefix);
}
// the first tab links to the front page
if ($with_home && is_callable(array('i18n', 's'))) {
$site_bar = array_merge($site_bar, array($context['url_to_root'] => array('', i18n::s('Home'), '', 'home')));
}
// default number of sections to list
if (!isset($context['root_sections_count_at_home']) || $context['root_sections_count_at_home'] < 1) {
$context['root_sections_count_at_home'] = 5;
}
// query the database to get dynamic tabs
if (is_callable(array('Sections', 'list_by_title_for_anchor')) && ($items = Sections::list_by_title_for_anchor(NULL, 0, $context['root_sections_count_at_home'], 'main_tabs'))) {
if (count($items)) {
//query subsections if layout is provided
if ($layout_subsections) {
//Parse mother-sections previously selected to get sub-sections
foreach ($items as $url => $item) {
//get id of mother section
$mother_id = str_replace('_', ':', $item[3]);
//get subsections list
$subsections = '';
$subsections = Sections::list_by_title_for_anchor($mother_id, 0, TABS_DROP_LIST_SIZE, $layout_subsections);
//transform list into string if necessary (depend layout output)
if (is_array($subsections)) {
$subsections = Skin::build_list($subsections, $layout_subsections);
}
//get real number of subsections
$nb_subsections = Sections::count_for_anchor($mother_id);
//hint unlisted subsections if any
$hint = '<p class="details" id="dropcount">';
if ($nb_subsections > TABS_DROP_LIST_SIZE) {
$hint .= '( ';
$hint .= sprintf(i18n::ns('%d section', '%d sections', $nb_subsections), $nb_subsections);
$hint .= ' )</p>';
} else {
// provide empty <p> to preserve alignment
$hint .= ' </p>';
}
$subsections = $hint . $subsections;
//store sub-sections list into "suffix" of this tab's label
if ($subsections) {
$items[$url][2] = "\n<div class=dropmenu>" . $subsections . '</div>';
}
}
}
$site_bar = array_merge($site_bar, $items);
}
}
// suffix tabs, if any
if (is_array($suffix) && count($suffix)) {
$site_bar = array_merge($site_bar, $suffix);
}
// the skin will reverse the order
if ($with_reverse) {
$site_bar = array_reverse($site_bar);
}
// shape tabs
$text = Skin::build_list($site_bar, 'tabs') . "\n";
// cache result
Cache::put($cache_id, $text, 'sections');
}
echo $text;
}
示例4: get_options_for_anchor
/**
* get options recursively
*
* This function is called internally by Sections::get_options(), above.
*
* @param string the current anchor to an existing section (e.g., 'section:12')
* @param string spaces to prepend before section name -- to reflect depth
* @param string the reference of the default section
* @param array list of sections made of $id => $attributes
* @return the HTML to insert in the page
*
*/
public static function get_options_for_anchor($anchor, $spaces, $default, $to_avoid)
{
global $context;
// add to text
$text = '';
// list sections at this level
if ($sections = Sections::list_by_title_for_anchor($anchor, 0, 1000, 'raw')) {
foreach ($sections as $id => $attributes) {
if (Sections::match($id, $to_avoid)) {
continue;
}
// this section
$reference = 'section:' . $id;
$text .= '<option value="' . $reference . '"';
// the section is locked
if (isset($attributes['locked']) && $attributes['locked'] == 'Y' && !Surfer::is_associate()) {
$text .= ' style="font-style: italic;" disabled="disabled"';
}
// currently selected
if ($default && $default == $reference) {
$text .= ' selected="selected"';
}
$text .= '>' . $spaces . Skin::strip($attributes['title']) . "</option>\n";
// depending sections, if any
if ($to_avoid == 'no_subsections') {
} elseif ($depending = Sections::get_options_for_anchor($reference, $spaces . ' ', $default, $to_avoid)) {
$text .= $depending;
}
}
}
// associates can also access inactive sections at this level
if ($anchor && Surfer::is_associate()) {
if ($sections = Sections::list_inactive_by_title_for_anchor($anchor, 0, 100, 'raw')) {
foreach ($sections as $id => $attributes) {
if (Sections::match($id, $to_avoid)) {
continue;
}
// this section
$reference = 'section:' . $id;
$text .= '<option value="' . $reference . '"';
if ($default && $default == $reference) {
$text .= ' selected="selected"';
}
$text .= '>' . $spaces . Skin::strip($attributes['title']) . "</option>\n";
// depending sections, if any
if ($depending = Sections::get_options_for_anchor($reference, $spaces . ' ', $default, $to_avoid)) {
$text .= $depending;
}
}
}
}
// end of job
return $text;
}
示例5: render_sections
/**
* render a list of sections
*
* The provided anchor can reference:
* - a section 'section:123'
* - a user 'user:789'
* - 'self'
* - nothing
*
* @param string the anchor (e.g. 'section:123')
* @param string layout to use
* @return string the rendered text
**/
public static function render_sections($layout = 'simple', $anchor = '')
{
global $context;
// we return some text;
$text = '';
// number of items to display
$count = YAHOO_LIST_SIZE;
if (($position = strpos($anchor, ',')) !== FALSE) {
$count = (int) trim(substr($anchor, $position + 1));
if (!$count) {
$count = YAHOO_LIST_SIZE;
}
$anchor = trim(substr($anchor, 0, $position));
}
// scope is limited to current surfer
if ($anchor == 'self' && Surfer::get_id()) {
$anchor = 'user:' . Surfer::get_id();
// refresh on every page load
Cache::poison();
}
// scope is limited to one section
if (strpos($anchor, 'section:') === 0) {
$text = Sections::list_by_title_for_anchor($anchor, 0, $count, $layout);
} elseif (strpos($anchor, 'user:') === 0) {
$text = Members::list_sections_by_title_for_anchor($anchor, 0, $count, $layout);
} else {
$text = Sections::list_by_title_for_anchor(NULL, 0, $count, $layout);
}
// we have an array to format
if (is_array($text)) {
$text = Skin::build_list($text, $layout);
}
// job done
return $text;
}
示例6: layout
//.........这里部分代码省略.........
if ($count = Links::count_for_anchor('section:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
$related_count += $count;
// add related links if necessary
if (count($content) < $maximum_items && ($related = Links::list_by_date_for_anchor('section:' . $item['id'], 0, $maximum_items - count($content), 'compact'))) {
foreach ($related as $sub_url => $label) {
$sub_prefix = $sub_suffix = $sub_hover = '';
if (is_array($label)) {
$sub_prefix = $label[0];
$sub_suffix = $label[2];
if (@$label[5]) {
$sub_hover = $label[5];
}
$label = $label[1];
}
$content[] = $sub_prefix . $label . $sub_suffix;
}
}
}
// info on related comments
if ($count = Comments::count_for_anchor('section:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
$related_count += $count;
}
// info on related sections
if ($count = Sections::count_for_anchor('section:' . $item['id'])) {
if ($count > $maximum_items) {
$details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
} elseif (Surfer::is_empowered()) {
$details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
}
$related_count += $count;
// add sub-sections
if ($related =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, $maximum_items - count($content), 'compact')) {
foreach ($related as $sub_url => $label) {
$sub_prefix = $sub_suffix = $sub_hover = '';
if (is_array($label)) {
$sub_prefix = $label[0];
$sub_suffix = $label[2];
if (@$label[5]) {
$sub_hover = $label[5];
}
$label = $label[1];
}
$content[] = $sub_prefix . $label . $sub_suffix;
}
}
}
// give me more
if (count($content) && $related_count > $maximum_items) {
$content[] = '...' . MORE_IMG;
}
// layout details
if (count($content)) {
$hover .= '<ul><li>' . implode('</li><li>', $content) . '</li></ul>';
}
// add a link to the main page
if (!$hover) {
$hover = i18n::s('View the section');
}
// use the title to label the link
$title = Skin::strip($item['title'], 50);
// new or updated flag
if ($suffix) {
$details[] = $suffix;
}
示例7: layout
/**
* list sections
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// the maximum number of items per section
if (!defined('MAXIMUM_ITEMS_PER_SECTION')) {
define('MAXIMUM_ITEMS_PER_SECTION', 100);
}
// we return plain text
$text = '';
// process all items in the list
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
$family = '';
while ($item = SQL::fetch($result)) {
// change the family
if ($item['family'] != $family) {
$family = $item['family'];
// show the family
$text .= '<h2><span>' . $family . ' </span></h2>' . "\n";
}
// get the related overlay, if any
$overlay = Overlay::load($item, 'section:' . $item['id']);
// get the main anchor
$anchor = Anchors::get($item['anchor']);
// one box per section
$box = array('title' => '', 'text' => '');
// box content
$elements = array();
// use the title to label the link
if (is_object($overlay)) {
$box['title'] .= Codes::beautify_title($overlay->get_text('title', $item));
} else {
$box['title'] .= Codes::beautify_title($item['title']);
}
$details = array();
// info on related articles
if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
$order = $matches[1];
} else {
$order = 'edition';
}
$items =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact');
if (@count($items)) {
// mention the number of items in folded title
$details[] = sprintf(i18n::ns('%d page', '%d pages', 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, 'article') . $suffix;
}
}
// info on related files
if (Sections::has_option('files_by', $anchor, $item) == 'title') {
$items = Files::list_by_title_for_anchor('section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact');
} else {
$items = Files::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 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];
}
//.........这里部分代码省略.........
示例8: layout
//.........这里部分代码省略.........
$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']);
// last editor
$action = '';
if ($article['edit_date']) {
// label the action
if (isset($article['edit_action'])) {
$action = Anchors::get_action_label($article['edit_action']);
} else {
$action = i18n::s('edited');
}
$action = '<span class="details">' . $action . ' ' . Skin::build_date($article['edit_date']) . '</span>';
}
// this is another row of the output
$text .= '<tr class="' . $class_detail . '"><td>' . $title . $flag . '</td><td>' . $poster . '</td><td style="text-align: center;">' . $comments . '</td><td>' . $action . '</td></tr>' . "\n";
}
}
// more details
$details = array();
// board introduction
if ($item['introduction']) {
$details[] = Codes::beautify_introduction($item['introduction']);
}
// indicate the total number of threads here
if (($count = Articles::count_for_anchor('section:' . $item['id'])) && $count >= 5) {
$details[] = sprintf(i18n::s('%d threads'), $count) . ' »';
}
// link to the section index page
if ($details) {
$details = Skin::build_link(Sections::get_permalink($item), join(' - ', $details), 'basic');
} else {
$details = '';
}
// add a command for new post
$poster = '';
if (Surfer::is_empowered()) {
$poster = Skin::build_link('articles/edit.php?anchor=' . urlencode('section:' . $item['id']), i18n::s('Add a page') . ' »', 'basic');
}
// insert details in a separate row
if ($details || $poster) {
$text .= '<tr class="' . $class_detail . '"><td colspan="3">' . $details . '</td><td>' . $poster . '</td></tr>' . "\n";
}
// more 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, 'compact')) {
$more[] = sprintf(i18n::ns('Child board: %s', 'Child boards: %s', count($children)), Skin::build_list($children, 'comma'));
}
// as a compact list
if (count($more)) {
$content = '<ul class="compact">';
foreach ($more as $list_item) {
$content .= '<li>' . $list_item . '</li>' . "\n";
}
$content .= '</ul>' . "\n";
// insert details in a separate row
$text .= '<tr class="' . $class_detail . '"><td colspan="4">' . $content . '</td></tr>' . "\n";
}
}
// end of processing
SQL::free($result);
$text .= Skin::table_suffix();
return $text;
}
示例9: layout
//.........这里部分代码省略.........
$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) {
$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 links
if ($count = Links::count_for_anchor('section:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
$related_count += $count;
// add related links if necessary
if (count($details) < YAHOO_LIST_SIZE && ($related = Links::list_by_date_for_anchor('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 comments
if ($count = Comments::count_for_anchor('section:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
}
// info on related sections
if ($count = Sections::count_for_anchor('section:' . $item['id'])) {
$details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
$related_count += $count;
// add sub-sections
if ($related =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, YAHOO_LIST_SIZE, '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);
}
}
}
// give me more
if (count($details) && $related_count > YAHOO_LIST_SIZE) {
$content[Sections::get_permalink($item)] = array('', i18n::s('More') . MORE_IMG, '', 'more', '', i18n::s('View the section'));
}
// append details to the suffix
if (count($details)) {
$suffix .= ' <span class="details">(' . implode(', ', $details) . ')</span>';
}
// the main anchor link
if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) {
$suffix .= ' <span class="details">' . sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'section')) . "</span>\n";
}
// not if decorated
if ($this->layout_variant != 'decorated' && $this->layout_variant != 'references') {
// one line per related item
if (count($content)) {
$suffix .= '<div class="details">' . Skin::build_list($content, 'compact') . "</div>\n";
}
}
// the icon to put in the left column
if ($item['thumbnail_url']) {
$icon = $item['thumbnail_url'];
}
// some hovering title for this section
$hover = i18n::s('View the section');
// list all components for this item
$items[$url] = array($prefix, $title, $suffix, 'section', $icon, $hover);
}
// end of processing
SQL::free($result);
return $items;
}
示例10: layout
/**
* list pages
*
* @param resource the SQL result
* @return string the rendered text
*
* @see layouts/layout.php
**/
function layout($result)
{
global $context;
// allow for multiple calls
static $accordion_id;
if (!isset($accordion_id)) {
$accordion_id = 1;
} else {
$accordion_id++;
}
// empty list
if (!SQL::count($result)) {
$output = array();
return $output;
}
// the maximum number of items per article
if (!defined('MAXIMUM_ITEMS_PER_ACCORDION')) {
define('MAXIMUM_ITEMS_PER_ACCORDION', 100);
}
// we return plain text
$text = '';
// type of listed object
$items_type = $this->listed_type;
// process all items in the list
include_once $context['path_to_root'] . 'comments/comments.php';
include_once $context['path_to_root'] . 'links/links.php';
$family = '';
while ($item = SQL::fetch($result)) {
// get the object interface, this may load parent and overlay
$entity = new $items_type($item);
// change the family (layout of sections)
if (isset($item['family']) && $item['family'] != $family) {
$family = $item['family'];
// show the family
$text .= '<h2><span>' . $family . ' </span></h2>' . "\n";
}
// one box per page
$box = array('title' => '', 'text' => '');
// signal entity to be published
if (isset($item['publish_date']) && ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S'))) {
$box['title'] .= DRAFT_FLAG;
}
// signal entity to be activated
if (isset($item['activation_date']) && $item['activation_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
$box['title'] .= DRAFT_FLAG;
}
// signal restricted and private entity
if ($item['active'] == 'N') {
$box['title'] .= PRIVATE_FLAG;
} elseif ($item['active'] == 'R') {
$box['title'] .= RESTRICTED_FLAG;
}
// use the title to label the link
if (is_object($entity->overlay)) {
$box['title'] .= Codes::beautify_title($entity->overlay->get_text('title', $item));
} else {
$box['title'] .= Codes::beautify_title($item['title']);
}
// box content
$elements = array();
// complement the title with interesting details
$details = array();
// info on related article, only for sections
if ($items_type == 'section') {
if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
$order = $matches[1];
} else {
$order = 'edition';
}
$items =& Articles::list_for_anchor_by($order, $entity->get_reference(), 0, MAXIMUM_ITEMS_PER_ACCORDION + 1, 'compact');
if (@count($items)) {
// mention the number of items in folded title
$details[] = sprintf(i18n::ns('%d page', '%d pages', 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, 'article') . $suffix;
}
}
}
// info on related files
if ($entity->has_option('files_by') == 'title') {
$items = Files::list_by_title_for_anchor($entity->get_reference(), 0, MAXIMUM_ITEMS_PER_ACCORDION + 1, 'compact');
} else {
$items = Files::list_by_date_for_anchor($entity->get_reference(), 0, MAXIMUM_ITEMS_PER_ACCORDION + 1, 'compact');
}
if ($items) {
//.........这里部分代码省略.........
示例11: 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()) {
//.........这里部分代码省略.........
示例12: encode_field
// the head
$text .= '<head>' . "\n";
// the title
$text .= ' <title>' . encode_field(strip_tags($context['channel_title'])) . "</title>\n";
// the body
$text .= '</head>' . "\n" . '<body>' . "\n";
// the main rss feed of this site
$text .= ' <outline type="rss" text="' . encode_field($context['channel_title']) . '" xmlUrl="' . $context['url_to_home'] . $context['url_to_root'] . Feeds::get_url('rss') . '"' . " />\n";
// full articles
$text .= ' <outline type="rss" text="' . encode_field(i18n::c('Pages with full content') . $suffix) . '" xmlUrl="' . $context['url_to_home'] . $context['url_to_root'] . Feeds::get_url('articles') . '"' . " />\n";
// newest comments
$text .= ' <outline type="rss" text="' . encode_field(i18n::c('Comments') . $suffix) . '" xmlUrl="' . $context['url_to_home'] . $context['url_to_root'] . Feeds::get_url('comments') . '"' . " />\n";
// the file rss feed for podcasting, etc.
$text .= ' <outline type="rss" text="' . encode_field(i18n::c('Files and podcasts') . $suffix) . '" xmlUrl="' . $context['url_to_home'] . $context['url_to_root'] . Feeds::get_url('files') . '"' . " />\n";
// one feed per section
if ($items = Sections::list_by_title_for_anchor(NULL, 0, COMPACT_LIST_SIZE, 'raw')) {
foreach ($items as $id => $attributes) {
$text .= ' <outline type="rss" text="' . encode_field(strip_tags($attributes['title']) . $suffix) . '" xmlUrl="' . $context['url_to_home'] . $context['url_to_root'] . Sections::get_url($id, 'feed') . '"' . " />\n";
}
}
// one feed per category
if ($items = Categories::list_by_date(0, COMPACT_LIST_SIZE, 'raw')) {
foreach ($items as $id => $attributes) {
$text .= ' <outline type="rss" text="' . encode_field(strip_tags($attributes['title']) . $suffix) . '" xmlUrl="' . $context['url_to_home'] . $context['url_to_root'] . Categories::get_url($id, 'feed') . '"' . " />\n";
}
}
// one feed per user
if ($items = Users::list_by_posts(0, COMPACT_LIST_SIZE, 'raw')) {
foreach ($items as $id => $attributes) {
$text .= ' <outline type="rss" text="' . encode_field(strip_tags($attributes['nick_name']) . $suffix) . '" xmlUrl="' . $context['url_to_home'] . $context['url_to_root'] . Users::get_url($id, 'feed') . '"' . " />\n";
}
示例13: layout
//.........这里部分代码省略.........
if ($count = Articles::count_for_anchor('section:' . $item['id'])) {
if ($count > 20) {
$box['bottom_bar'] += array('_count' => sprintf(i18n::ns('%d page', '%d pages', $count), $count));
}
// navigation commands for articles
$home = Sections::get_permalink($item);
$prefix = Sections::get_url($item['id'], 'navigate', 'articles');
$box['bottom_bar'] += Skin::navigate($home, $prefix, $count, $items_per_page, 1);
}
}
// bottom menu
if ($box['bottom_bar']) {
$box['text'] .= Skin::build_list($box['bottom_bar'], 'menu_bar');
}
// there is some box content
if ($box['text']) {
$text .= $box['text'];
}
}
// layout sub-sections
if (!isset($item['sections_layout']) || $item['sections_layout'] != 'none') {
// select a layout
if (!isset($item['sections_layout']) || !$item['sections_layout']) {
include_once 'layout_sections.php';
$layout = new Layout_sections();
} else {
$layout = Layouts::new_($item['sections_layout'], 'section');
}
// the maximum number of sections per page
if (is_object($layout)) {
$items_per_page = $layout->items_per_page();
} else {
$items_per_page = SECTIONS_PER_PAGE;
}
// build a complete box
$box = array('top_bar' => array(), 'text' => '', 'bottom_bar' => array());
// the command to add a new section
//if(Sections::allow_creation($item, $anchor)) {
if ($anchor->allows('creation', 'section')) {
Skin::define_img('SECTIONS_ADD_IMG', 'sections/add.gif');
$box['top_bar'] += array('sections/edit.php?anchor=' . urlencode('section:' . $item['id']) => SECTIONS_ADD_IMG . i18n::s('Add a section'));
}
// top menu
if ($box['top_bar']) {
$box['text'] .= Skin::build_list($box['top_bar'], 'menu_bar');
}
// list items by family then title
$offset = 0 * $items_per_page;
$items = Sections::list_by_title_for_anchor('section:' . $item['id'], $offset, $items_per_page, $layout, TRUE);
// actually render the html for the section
if (is_array($items) && is_string($item['sections_layout']) && $item['sections_layout'] == 'compact') {
$box['text'] .= Skin::build_list($items, 'compact');
} elseif (is_array($items)) {
$box['text'] .= Skin::build_list($items, 'decorated');
} elseif (is_string($items)) {
$box['text'] .= $items;
}
// count the number of subsections
if ($count = Sections::count_for_anchor('section:' . $item['id'])) {
if ($count > 20) {
$box['bottom_bar'] = array('_count' => sprintf(i18n::ns('%d section', '%d sections', $count), $count));
}
// navigation commands for sections
$home = Sections::get_permalink($item);
$prefix = Sections::get_url($item['id'], 'navigate', 'sections');
$box['bottom_bar'] += Skin::navigate($home, $prefix, $count, $items_per_page, 1);
}
// bottom menu
if ($box['bottom_bar']) {
$box['text'] .= Skin::build_list($box['bottom_bar'], 'menu_bar');
}
// there is some box content
if ($box['text']) {
$text .= $box['text'];
}
}
// ensure that the surfer can change content
if (Sections::allow_modification($item, $anchor)) {
// view or modify this section
$menu = array();
$menu[] = Skin::build_link(Sections::get_permalink($item), i18n::s('View the sub-section'), 'span');
if (!is_object($overlay) || !($label = $overlay->get_label('edit_command', 'sections'))) {
$label = i18n::s('Edit this sub-section');
}
$menu[] = Skin::build_link(Sections::get_url($item['id'], 'edit'), $label, 'span');
$text .= Skin::finalize_list($menu, 'menu_bar');
}
// assemble the full panel
$panels[] = array('stt' . $item['id'], ucfirst(Skin::strip($item['title'], 30)), 'stc' . $item['id'], $text);
}
// format tabs
if ($this->has_variant('as_array')) {
$text = $panels;
} else {
$text = Skin::build_tabs($panels);
}
// end of processing
SQL::free($result);
return $text;
}
示例14: 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']) {
//.........这里部分代码省略.........
示例15: layout
//.........这里部分代码省略.........
foreach ($related as $sub_url => $label) {
$sub_prefix = $sub_suffix = $sub_hover = '';
if (is_array($label)) {
$sub_prefix = $label[0];
$sub_suffix = $label[2];
if (@$label[5]) {
$sub_hover = $label[5];
}
$label = $label[1];
}
$content[] = $sub_prefix . Skin::build_link($sub_url, $label, 'file', $sub_hover) . $sub_suffix;
}
}
}
// info on related links
if ($count = Links::count_for_anchor('section:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
$related_count += $count;
// add related links if necessary
if (count($content) < $maximum_items && ($related = Links::list_by_date_for_anchor('section:' . $item['id'], 0, $maximum_items - count($content), 'compact'))) {
foreach ($related as $sub_url => $label) {
$sub_prefix = $sub_suffix = $sub_hover = '';
if (is_array($label)) {
$sub_prefix = $label[0];
$sub_suffix = $label[2];
if (@$label[5]) {
$sub_hover = $label[5];
}
$label = $label[1];
}
$content[] = $sub_prefix . Skin::build_link($sub_url, $label, 'link', $sub_hover) . $sub_suffix;
}
}
}
// info on related comments
if ($count = Comments::count_for_anchor('section:' . $item['id'], TRUE)) {
$details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
$related_count += $count;
}
// info on related sections
if ($count = Sections::count_for_anchor('section:' . $item['id'])) {
if ($count > $maximum_items) {
$details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
} elseif (Surfer::is_empowered()) {
$details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
}
$related_count += $count;
// add sub-sections
if ($related =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, $maximum_items, 'compact')) {
foreach ($related as $sub_url => $label) {
$sub_prefix = $sub_suffix = $sub_hover = '';
if (is_array($label)) {
$sub_prefix = $label[0];
$sub_suffix = $label[2];
if (@$label[5]) {
$sub_hover = $label[5];
}
$label = $label[1];
}
$content[] = $sub_prefix . Skin::build_link($sub_url, $label, 'section', $sub_hover) . $sub_suffix;
}
}
}
// introduction
if ($item['introduction']) {
$suffix .= ' ' . Codes::beautify_introduction($item['introduction']);
}
// append details to the suffix
if (count($details)) {
$suffix .= ' <span class="details">(' . implode(', ', $details) . ')</span>';
}
// give me more
if (count($content) && $related_count > $maximum_items) {
$content[] = Skin::build_link(Sections::get_permalink($item), i18n::s('More') . MORE_IMG, 'more', i18n::s('View the section'));
}
// layout details
if (count($content)) {
foreach ($content as $line) {
$suffix .= '<div>' . YAHOO_ITEM_PREFIX . $line . YAHOO_ITEM_SUFFIX . '</div>';
}
}
// use the title to label the link
$label = Skin::strip($item['title'], 50);
// put the actual icon in the left column
if (isset($item['thumbnail_url'])) {
$icon = $item['thumbnail_url'];
}
// some hovering title for this section
$hover = i18n::s('View the section');
// list all components for this item --use basic link style to avoid prefix or suffix images, if any
$items[$url] = array($prefix, $label, $suffix, 'basic', $icon, $hover);
}
// flush the stack
if (count($items)) {
$text .= Skin::build_list($items, '2-columns');
}
// end of processing
SQL::free($result);
return $text;
}