Exemple #1
0
 // flag sections that are dead, or created or updated very recently
 if ($section['expiry_date'] > NULL_DATE && $section['expiry_date'] <= $context['now']) {
     $prefix .= EXPIRED_FLAG;
 } elseif ($section['create_date'] >= $context['fresh']) {
     $suffix .= NEW_FLAG;
 } elseif ($section['edit_date'] >= $context['fresh']) {
     $suffix .= UPDATED_FLAG;
 }
 // info on related comments
 if ($count = Comments::count_for_anchor('section:' . $section['id'], TRUE)) {
     $suffix .= ' (' . $count . ')';
 }
 // details
 $details = array();
 // info on related sections
 if ($count = Sections::count_for_anchor('section:' . $section['id'])) {
     $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
 }
 // info on related articles
 if ($count = Articles::count_for_anchor('section:' . $section['id'])) {
     $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
 }
 // info on related files
 if ($count = Files::count_for_anchor('section:' . $section['id'], TRUE)) {
     $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
 }
 // info on related links
 if ($count = Links::count_for_anchor('section:' . $section['id'], TRUE)) {
     $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
 }
 // the parent link
Exemple #2
0
 /**
  * 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 .= '&nbsp;</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;
 }
Exemple #3
0
} else {
    $page = 1;
}
$page = max(1, intval($page));
// sanity check
if ($page < 1) {
    $page = 1;
}
// load the skin
load_skin('site_map');
// page size
$items_per_page = 50;
// the title of the page
$context['page_title'] = i18n::s('Site map');
// count public root sections in the database
$count = Sections::count_for_anchor(NULL);
// a meta link to our blogging interface
$context['page_header'] .= "\n" . '<link rel="EditURI" href="' . $context['url_to_home'] . $context['url_to_root'] . 'services/describe.php" title="RSD" type="application/rsd+xml" />';
// the prefix hook for the site map page
if (is_callable(array('Hooks', 'include_scripts'))) {
    $context['text'] .= Hooks::include_scripts('sections/index.php#prefix');
}
// stop hackers
if ($page > 10) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
} else {
    // page main content
    $cache_id = 'sections/index.php#text#' . $page;
    if (!($text = Cache::get($cache_id))) {
        // load the layout to use
Exemple #4
0
 /**
  * build a notification related to a section
  *
  * This function builds a mail message that displays:
  * - an image of the contributor (if possible)
  * - a headline mentioning the contribution
  * - the full content of the section
  * - a button linked to the section
  * - a link to the containing section, if any
  *
  * Note: this function returns legacy HTML, not modern XHTML, because this is what most
  * e-mail client software can afford.
  *
  * @param string either 'apply', 'create' or 'update'
  * @param array attributes of the item
  * @param object overlay of the item, if any
  * @return string text to be send by e-mail
  */
 public static function build_notification($action, $item, $overlay = NULL)
 {
     global $context;
     // get the main anchor
     $anchor = Anchors::get($item['anchor']);
     // compute page title
     if (is_object($overlay)) {
         $title = Codes::beautify_title($overlay->get_text('title', $item));
     } else {
         $title = Codes::beautify_title($item['title']);
     }
     // headline template
     switch ($action) {
         case 'apply':
             $template = i18n::c('%s is requesting access to %s');
             break;
         case 'create':
             $template = i18n::c('%s has created section %s');
             break;
         case 'update':
             $template = i18n::c('%s has updated section %s');
             break;
     }
     // headline
     $headline = sprintf($template, Surfer::get_link(), '<a href="' . Sections::get_permalink($item) . '">' . $title . '</a>');
     // panel content
     $content = '';
     // signal restricted and private articles
     if ($item['active'] == 'N') {
         $title = PRIVATE_FLAG . $title;
     } elseif ($item['active'] == 'R') {
         $title = RESTRICTED_FLAG . $title;
     }
     // insert page title
     $content .= '<h3><span>' . $title . '</span></h3>';
     // insert anchor prefix
     if (is_object($anchor)) {
         $content .= $anchor->get_prefix();
     }
     // the introduction text, if any
     if (is_object($overlay)) {
         $content .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
     } elseif (isset($item['introduction']) && trim($item['introduction'])) {
         $content .= Skin::build_block($item['introduction'], 'introduction');
     }
     // get text related to the overlay, if any
     if (is_object($overlay)) {
         $content .= $overlay->get_text('view', $item);
     }
     // filter description, if necessary
     if (is_object($overlay)) {
         $description = $overlay->get_text('description', $item);
     } else {
         $description = $item['description'];
     }
     // the beautified description, which is the actual page body
     if ($description) {
         // use adequate label
         if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
             $content .= Skin::build_block($label, 'title');
         }
         // beautify the target page
         $content .= Skin::build_block($description, 'description', '', $item['options']);
     }
     // attachment details
     $details = array();
     // info on related sections
     if ($count = Sections::count_for_anchor('section:' . $item['id'])) {
         $details[] = sprintf(i18n::nc('%d section', '%d sections', $count), $count);
     }
     // info on related articles
     if ($count = Articles::count_for_anchor('section:' . $item['id'])) {
         $details[] = sprintf(i18n::nc('%d page', '%d pages', $count), $count);
     }
     // info on related files
     if ($count = Files::count_for_anchor('section:' . $item['id'], TRUE)) {
         // the actual list of files attached to this section
         if (preg_match('/\\bfiles_by_title\\b/i', $item['options'])) {
             $items = Files::list_by_title_for_anchor('section:' . $item['id'], 0, 300, 'compact');
         } else {
             $items = Files::list_by_date_for_anchor('section:' . $item['id'], 0, 300, 'compact');
         }
         // wrap it with some header
         if (is_array($items)) {
             $items = Skin::build_list($items);
         }
         if ($items) {
             $content .= '<h3><span>' . i18n::s('Files') . '</span></h3>' . $items;
         }
         // details to be displayed at page bottom
         $details[] = sprintf(i18n::nc('%d file', '%d files', $count), $count);
     }
     // info on related links
     include_once $context['path_to_root'] . 'links/links.php';
     if ($count = Links::count_for_anchor('section:' . $item['id'], TRUE)) {
         $details[] = sprintf(i18n::nc('%d link', '%d links', $count), $count);
     }
     // comments
     include_once $context['path_to_root'] . 'comments/comments.php';
     if ($count = Comments::count_for_anchor('section:' . $item['id'], TRUE)) {
         $details[] = sprintf(i18n::nc('%d comment', '%d comments', $count), $count);
     }
     // describe attachments
     if (count($details)) {
         $content .= '<hr align="left" size=1" width="150">' . '<p style="margin: 3px 0;">' . sprintf(i18n::c('This section has %s'), join(', ', $details)) . '</p>';
     }
     // assemble main content of this message
     $text = Skin::build_mail_content($headline, $content);
     // a set of links
     $menu = array();
     // request access to the item
     if ($action == 'apply') {
         // call for action
         $link = $context['url_to_home'] . $context['url_to_root'] . Sections::get_url($item['id'], 'invite', Surfer::get_id());
         $label = sprintf(i18n::c('Invite %s to participate'), Surfer::get_name());
         $menu[] = Skin::build_mail_button($link, $label, TRUE);
         // link to user profile
         $link = Surfer::get_permalink();
         $label = sprintf(i18n::c('View the profile of %s'), Surfer::get_name());
         $menu[] = Skin::build_mail_button($link, $label, FALSE);
         // invite to visit the item
     } else {
         // call for action
         $link = Sections::get_permalink($item);
         if (!is_object($overlay) || !($label = $overlay->get_label('permalink_command', 'sections', FALSE))) {
             $label = i18n::c('View the section');
         }
         $menu[] = Skin::build_mail_button($link, $label, TRUE);
         // link to the container
         if (is_object($anchor)) {
             $link = $context['url_to_home'] . $context['url_to_root'] . $anchor->get_url();
             $menu[] = Skin::build_mail_button($link, $anchor->get_title(), FALSE);
         }
     }
     // finalize links
     $text .= Skin::build_mail_menu($menu);
     // the full message
     return $text;
 }
 /**
  * list sections
  *
  * @param resource the SQL result
  * @return array of resulting items, or NULL
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of ($url => $attributes)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // process all items in the list
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'section:' . $item['id']);
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Sections::get_permalink($item);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // initialize variables
         $prefix = $suffix = $icon = '';
         // flag sticky pages
         if ($item['rank'] < 10000) {
             $prefix .= STICKY_FLAG;
         }
         // signal restricted and private sections
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // flag sections that are dead, or created or updated very recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('section:' . $item['id'], TRUE)) {
             $suffix .= ' (' . $count . ')';
         }
         // details
         $details = array();
         // info on related sections
         if ($count = Sections::count_for_anchor('section:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
         }
         // info on related articles
         if ($count = Articles::count_for_anchor('section:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
         }
         // info on related files
         if ($count = Files::count_for_anchor('section:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
         }
         // info on related links
         if ($count = Links::count_for_anchor('section:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // the main anchor link
         if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) {
             $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'section'));
         }
         // combine in-line details
         if (count($details)) {
             $suffix .= ' - <span class="details">' . trim(implode(', ', $details)) . '</span>';
         }
         // list all components for this item
         $items[$url] = array($prefix, $title, $suffix, 'section', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
 /**
  * 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 (!SQL::count($result)) {
         return $text;
     }
     // maximum number of items
     if (isset($this->layout_variant) && $this->layout_variant > 3) {
         $maximum_items = $this->layout_variant;
     } elseif (defined('YAHOO_LIST_SIZE')) {
         $maximum_items = YAHOO_LIST_SIZE;
     } else {
         $maximum_items = 7;
     }
     // clear flows
     $text .= '<br style="clear: left" />';
     // process all items in the list
     $family = '';
     while ($item = SQL::fetch($result)) {
         // change the family
         if ($item['family'] != $family) {
             $family = $item['family'];
             $text .= '<h2><span>' . $family . '&nbsp;</span></h2>' . "\n";
         }
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Sections::get_permalink($item);
         // initialize variables
         $prefix = $label = $suffix = $icon = $hover = '';
         // signal restricted and private sections
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // flag sections that are draft, dead, or created or updated very recently
         if ($item['activation_date'] >= $context['now']) {
             $prefix .= DRAFT_FLAG;
         } elseif ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         // display introduction field on hovering
         if ($item['introduction']) {
             $hover .= strip_tags(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'])) {
             if ($count > $maximum_items) {
                 $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
             } elseif (Surfer::is_empowered()) {
                 $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
             }
             $related_count += $count;
             // get the overlay for content of this section, if any
             $content_overlay = NULL;
             if (isset($item['content_overlay'])) {
                 $content_overlay = Overlay::bind($item['content_overlay']);
             }
             // no room to list articles
             if (count($content) >= $maximum_items) {
             } elseif (is_object($content_overlay) && is_callable(array($content_overlay, 'render_list_for_anchor'))) {
                 if ($related = $content_overlay->render_list_for_anchor('section:' . $item['id'], $maximum_items - count($content))) {
                     foreach ($related as $sub_url => $label) {
                         $sub_prefix = $sub_suffix = $sub_hover = '';
                         if (is_array($label)) {
                             $sub_prefix = $label[0];
                             $sub_suffix = $label[2];
                             if (@$label[5]) {
                                 $sub_hover = $label[5];
                             }
                             $label = $label[1];
                         }
                         $content[] = $sub_prefix . $label . $sub_suffix;
                     }
                 }
                 // regular rendering of related articles
             } else {
                 if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
                     $order = $matches[1];
                 } else {
                     $order = 'edition';
                 }
                 if ($related =& Articles::list_for_anchor_by($order, '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 files
         if ($count = Files::count_for_anchor('section:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
             $related_count += $count;
             // add related files if necessary
             if (count($content) < $maximum_items && ($related = Files::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 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 . $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;
         }
         // append details
         if (count($details)) {
             $title .= BR . '<span class="details">' . implode(', ', $details) . '</span>';
         }
         // look for an image
         $icon = '';
         if (isset($item['thumbnail_url']) && $item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } elseif (is_callable(array($anchor, 'get_bullet_url'))) {
             $icon = $anchor->get_bullet_url();
         }
         // use the thumbnail for this section
         if ($icon) {
             // 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="" ' . $options . ' />';
             // use default icon if nothing to display
         } else {
             $icon = MAP_IMG;
         }
         // use tipsy on hover
         $content = '<a href="' . $url . '" id="titles_' . $item['id'] . '">' . $icon . BR . $prefix . $title . '</a>';
         Page::insert_script('$(function() {' . "\n" . '	$("a#titles_' . $item['id'] . '").each(function() {' . "\n" . '		$(this).tipsy({fallback: \'<div style="text-align: left;">' . str_replace(array("'", "\n"), array('"', '<br />'), $hover) . '</div>\',' . "\n" . '		 html: true,' . "\n" . '		 gravity: $.fn.tipsy.autoWE,' . "\n" . '		 fade: true,' . "\n" . '		 offset: 8,' . "\n" . '		 opacity: 1.0});' . "\n" . '	});' . "\n" . '});' . "\n");
         // add a floating box
         $text .= Skin::build_box(NULL, $content, 'floating');
     }
     // clear flows
     $text .= '<br style="clear: left" />';
     // end of processing
     SQL::free($result);
     return $text;
 }
 /**
  * list sections
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // we return some text
     $text = '';
     // maximum number of items
     if (isset($this->layout_variant) && $this->layout_variant > 3) {
         $maximum_items = $this->layout_variant;
     } elseif (defined('YAHOO_LIST_SIZE')) {
         $maximum_items = YAHOO_LIST_SIZE;
     } else {
         $maximum_items = 7;
     }
     // stack of items
     $items = array();
     // process all items in the list
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     $family = '';
     while ($item = SQL::fetch($result)) {
         // change the family
         if ($item['family'] != $family) {
             // flush current stack, if any
             if (count($items)) {
                 $text .= Skin::build_list($items, '2-columns');
             }
             $items = array();
             // show the family
             $family = $item['family'];
             $text .= '<h2><span>' . $family . '&nbsp;</span></h2>' . "\n";
         }
         // the url to view this item
         $url = Sections::get_permalink($item);
         // initialize variables
         $prefix = $label = $suffix = $icon = '';
         // signal restricted and private sections
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // flag sections that are draft, dead, or created or updated very recently
         if ($item['activation_date'] >= $context['now']) {
             $prefix .= DRAFT_FLAG;
         } elseif ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         // details and content
         $details = array();
         $content = array();
         // count related sub-elements
         $related_count = 0;
         // info on related articles
         if ($count = Articles::count_for_anchor('section:' . $item['id'])) {
             if ($count > $maximum_items) {
                 $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
             } elseif (Surfer::is_empowered()) {
                 $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
             }
             $related_count += $count;
             // get the overlay for content of this section, if any
             $content_overlay = NULL;
             if (isset($item['content_overlay'])) {
                 $content_overlay = Overlay::bind($item['content_overlay']);
             }
             // no room to list articles
             if (count($content) >= $maximum_items) {
             } elseif (is_object($content_overlay) && is_callable(array($content_overlay, 'render_list_for_anchor'))) {
                 if ($related = $content_overlay->render_list_for_anchor('section:' . $item['id'], $maximum_items - count($content))) {
                     foreach ($related as $sub_url => $label) {
                         $sub_prefix = $sub_suffix = $sub_hover = '';
                         if (is_array($label)) {
                             $sub_prefix = $label[0];
                             $sub_suffix = $label[2];
                             if (@$label[5]) {
                                 $sub_hover = $label[5];
                             }
                             $label = $label[1];
                         }
                         $content[] = $sub_prefix . Skin::build_link($sub_url, $label, 'basic', $sub_hover) . $sub_suffix;
                     }
                 }
                 // regular rendering of related articles
             } else {
                 if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
                     $order = $matches[1];
                 } else {
                     $order = 'edition';
                 }
                 if ($related =& Articles::list_for_anchor_by($order, '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, 'article', $sub_hover) . $sub_suffix;
                     }
                 }
             }
         }
         // info on related files
         if ($count = Files::count_for_anchor('section:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
             $related_count += $count;
             // add related files if necessary
             if (count($content) < $maximum_items && ($related = Files::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, '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;
 }
Exemple #8
0
 /**
  * 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 .= ' -&nbsp;' . 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) {
                     $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;
 }
 /**
  * list sections
  *
  * @param resource the SQL result
  * @return a string to be displayed
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // no hovering label
     $href_title = '';
     // we build an array for the skin::build_tabs() function
     $panels = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'section:' . $item['id']);
         // get the overlay for content of this section, if any
         $content_overlay = NULL;
         if (isset($item['content_overlay'])) {
             $content_overlay = Overlay::bind($item['content_overlay']);
         }
         // panel content
         $text = '';
         // insert anchor prefix
         if (is_object($anchor)) {
             $text .= $anchor->get_prefix();
         }
         // the introduction text, if any
         if (is_object($overlay)) {
             $text .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
         } elseif (isset($item['introduction']) && trim($item['introduction'])) {
             $text .= Skin::build_block($item['introduction'], 'introduction');
         }
         // get text related to the overlay, if any
         if (is_object($overlay)) {
             $text .= $overlay->get_text('view', $item);
         }
         // filter description, if necessary
         if (is_object($overlay)) {
             $description = $overlay->get_text('description', $item);
         } else {
             $description = $item['description'];
         }
         // the beautified description, which is the actual page body
         if ($description) {
             // use adequate label
             if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
                 $text .= Skin::build_block($label, 'title');
             }
             // beautify the target page
             $text .= Skin::build_block($description, 'description', '', $item['options']);
         }
         // delegate rendering to the overlay, where applicable
         if (is_object($content_overlay) && ($overlaid = $content_overlay->render('articles', 'section:' . $item['id'], 1))) {
             $text .= $overlaid;
             // regular rendering
         } elseif (!isset($item['articles_layout']) || $item['articles_layout'] != 'none') {
             // select a layout
             if (!isset($item['articles_layout']) || !$item['articles_layout']) {
                 include_once '../articles/layout_articles.php';
                 $layout = new Layout_articles();
             } else {
                 $layout = Layouts::new_($item['articles_layout'], 'article');
             }
             // avoid links to this page
             if (is_object($layout) && is_callable(array($layout, 'set_variant'))) {
                 $layout->set_focus('section:' . $item['id']);
             }
             // the maximum number of articles per page
             if (is_object($layout)) {
                 $items_per_page = $layout->items_per_page();
             } else {
                 $items_per_page = ARTICLES_PER_PAGE;
             }
             // sort and list articles
             $offset = 0;
             if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
                 $order = $matches[1];
             } elseif (is_callable(array($layout, 'items_order'))) {
                 $order = $layout->items_order();
             } else {
                 $order = 'edition';
             }
             // create a box
             $box = array('top_bar' => array(), 'text' => '', 'bottom_bar' => array());
             // the command to post a new page
             //if(Articles::allow_creation($item, $anchor)) {
             if ($anchor->allows('creation', 'article')) {
                 Skin::define_img('ARTICLES_ADD_IMG', 'articles/add.gif');
                 $url = 'articles/edit.php?anchor=' . urlencode('section:' . $item['id']);
                 if (is_object($content_overlay) && ($label = $content_overlay->get_label('new_command', 'articles'))) {
                 } else {
                     $label = ARTICLES_ADD_IMG . i18n::s('Add a page');
                 }
                 $box['top_bar'] += array($url => $label);
             }
             // list pages under preparation
             $this_section = new section();
             $this_section->load_by_content($item, $anchor);
             if ($this_section->is_assigned()) {
                 if ($order == 'publication' && ($items =& Articles::list_for_anchor_by('draft', 'section:' . $item['id'], 0, 20, 'compact'))) {
                     if (is_array($items)) {
                         $items = Skin::build_list($items, 'compact');
                     }
                     $box['top_bar'] += array('_draft' => Skin::build_sliding_box(i18n::s('Draft pages'), $items));
                 }
             }
             // top menu
             if ($box['top_bar']) {
                 $box['text'] .= Skin::build_list($box['top_bar'], 'menu_bar');
             }
             // get pages
             $items =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], $offset, $items_per_page, $layout);
             // items in the middle
             if (is_array($items) && isset($item['articles_layout']) && $item['articles_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;
             }
             // no navigation bar with alistapart
             if (!isset($item['articles_layout']) || $item['articles_layout'] != 'alistapart') {
                 // count the number of articles in this section
                 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;
 }
 /**
  * list sections as rows in a table
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // we list pages for one surfer
     // sanity check
     if (!isset($this->focus)) {
         $this->focus = Surfer::get_id();
     }
     // build a list of sections
     Skin::define_img('CHECKED_IMG', 'ajax/accept.png', '*');
     $rows = array();
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // get the related overlay
         $overlay = Overlay::load($item, 'section:' . $item['id']);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = sections::get_permalink($item);
         // reset everything
         $summary = $update = $owner = $editor = $watcher = '';
         if ($item['activation_date'] >= $context['now']) {
             $summary .= DRAFT_FLAG;
         } elseif ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $summary .= EXPIRED_FLAG;
         }
         // signal restricted and private sections
         if ($item['active'] == 'N') {
             $summary .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $summary .= RESTRICTED_FLAG;
         }
         // indicate the id in the hovering popup
         $hover = i18n::s('View the page');
         if (Surfer::is_member()) {
             $hover .= ' [section=' . $item['id'] . ']';
         }
         // use the title to label the link
         if (is_object($overlay)) {
             $label = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $label = Codes::beautify_title($item['title']);
         }
         // use the title as a link to the page
         $summary .= Skin::build_link($url, $label, 'basic', $hover);
         // signal locked sections
         if (isset($item['locked']) && $item['locked'] == 'Y' && Sections::is_owned($item, $anchor)) {
             $summary .= ' ' . LOCKED_FLAG;
         }
         // flag sections updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $summary .= ' ' . EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $summary .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $summary .= ' ' . UPDATED_FLAG;
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $summary .= $overlay->get_text('list', $item);
         }
         // attachment details
         $details = array();
         // info on related sections
         if ($count = Sections::count_for_anchor('section:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
         }
         // info on related articles
         if ($count = Articles::count_for_anchor('section:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
         }
         // info on related files
         if ($count = Files::count_for_anchor('section:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
         }
         // info on related links
         if ($count = Links::count_for_anchor('section:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // comments
         if ($count = Comments::count_for_anchor('section:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
         }
         // the main anchor link
         if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) {
             $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'basic'));
         }
         // combine in-line details
         if (count($details)) {
             $summary .= BR . '<span class="details">' . trim(implode(' &middot; ', $details)) . '</span>';
         }
         // display all tags
         if ($item['tags']) {
             $summary .= BR . '<span class="tags">' . Skin::build_tags($item['tags'], 'section:' . $item['id']) . '</span>';
         }
         // watcher
         if (Sections::is_watched($item['id'], $this->focus)) {
             $watcher = CHECKED_IMG;
         }
         // editor
         if (Sections::is_editable($anchor, $item, $this->focus, TRUE)) {
             $editor = CHECKED_IMG;
         }
         // owner
         if (Sections::is_owned($item, NULL, TRUE, $this->focus)) {
             $owner = CHECKED_IMG;
         }
         // this is another row of the output
         $cells = array($summary, $watcher, $editor, $owner);
         // append this row
         $rows[] = $cells;
     }
     // end of processing
     SQL::free($result);
     // headers
     $headers = array(i18n::s('Section'), i18n::s('Watcher'), i18n::s('Editor'), i18n::s('Owner'));
     // return a sortable table
     $text .= Skin::table($headers, $rows, 'yc-grid');
     return $text;
 }