Exemplo n.º 1
0
 /**
  * display content below main panel
  *
  * Everything is in a separate panel
  *
  * @param array the hosting record, if any
  * @return some HTML to be inserted into the resulting page
  */
 function &get_trailer_text($host = NULL)
 {
     $text = '';
     // display the following only if at least one comment has been attached to this page
     if (is_object($this->anchor) && !Comments::count_for_anchor($this->anchor->get_reference())) {
         return $text;
     }
     // ask the surfer if he has not answered yet, and if the page has not been locked
     $ask = TRUE;
     if (isset($_COOKIE['rating_' . $host['id']])) {
         $ask = FALSE;
     } elseif (isset($host['locked']) && $host['locked'] == 'Y') {
         $ask = FALSE;
     }
     // ask the surfer
     if ($ask) {
         $text = '<p style="line-height: 2.5em;">' . i18n::s('Has this page been useful to you?') . ' ' . Skin::build_link(Articles::get_url($host['id'], 'like'), i18n::s('Yes'), 'button') . ' ' . Skin::build_link(Articles::get_url($host['id'], 'dislike'), i18n::s('No'), 'button') . '</p>';
         // or report on results
     } elseif ($host['rating_count']) {
         $text = '<p>' . Skin::build_rating_img((int) round($host['rating_sum'] / $host['rating_count'])) . ' ' . sprintf(i18n::ns('%d rating', '%d ratings', $host['rating_count']), $host['rating_count']) . '</p>';
     }
     // add a title
     if ($text) {
         $text = Skin::build_box(i18n::s('Feed-back'), $text);
     }
     // done
     return $text;
 }
Exemplo n.º 2
0
 /**
  * format just one item
  *
  * @param array attributes of one item
  * @return array of ($url => array($prefix, $label, $suffix, ...))
  *
  * @see articles/edit.php
  **/
 function one(&$item)
 {
     global $context;
     // initialize variables
     $prefix = $suffix = $icon = '';
     // flag sections that are created or updated very recently
     if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
         $prefix .= EXPIRED_FLAG;
     } elseif ($item['create_date'] >= $context['fresh']) {
         $suffix .= NEW_FLAG;
     } elseif ($item['edit_date'] >= $context['fresh']) {
         $suffix .= UPDATED_FLAG;
     }
     // signal restricted and private articles
     if ($item['active'] == 'N') {
         $prefix .= PRIVATE_FLAG;
     } elseif ($item['active'] == 'R') {
         $prefix .= RESTRICTED_FLAG;
     }
     // details
     $details = array();
     // info on related files
     if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
         $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
     }
     // info on related links
     if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
         $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
     }
     // info on related comments
     if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
         $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
     }
     // append details to the suffix
     if (count($details)) {
         $suffix .= "\n" . '<span class="details">(' . implode(', ', $details) . ')</span>';
     }
     // introduction
     if ($item['introduction']) {
         $suffix .= ' ' . Codes::beautify_introduction($item['introduction']);
     }
     // add a head list of related links
     $subs = array();
     // put the actual icon in the left column
     if (isset($item['thumbnail_url'])) {
         $icon = $item['thumbnail_url'];
     }
     // url to select this article
     $url = 'articles/edit.php?template=' . $item['id'];
     // use the title to label the link
     $label = Skin::strip($item['title'], 50);
     // list all components for this item
     $output = array($url => array($prefix, $label, $suffix, 'article', $icon, i18n::s('Select this model')));
     return $output;
 }
Exemplo n.º 3
0
Arquivo: list.php Projeto: rair/yacs
     $layout->set_focus($anchor->get_reference());
 }
 // the maximum number of files per page
 if (is_object($layout)) {
     $items_per_page = $layout->items_per_page();
 } else {
     $items_per_page = FILES_PER_PAGE;
 }
 // the first file to list
 $offset = ($page - 1) * $items_per_page;
 if (is_object($layout) && method_exists($layout, 'set_offset')) {
     $layout->set_offset($offset);
 }
 // a navigation bar for these files
 if ($count = Files::count_for_anchor($anchor->get_reference())) {
     $context['page_menu'] += array('_count' => sprintf(i18n::ns('%d file', '%d files', $count), $count));
     // navigation commands for files
     $prefix = Files::get_url($anchor->get_reference(), 'navigate');
     $context['page_menu'] += Skin::navigate($anchor->get_url('files'), $prefix, $count, $items_per_page, $page, FALSE);
     // list files by date or by title
     if ($anchor->has_option('files_by') == 'title') {
         $items = Files::list_by_title_for_anchor($anchor->get_reference(), $offset, $items_per_page, $anchor->get_reference());
     } else {
         $items = Files::list_by_date_for_anchor($anchor->get_reference(), $offset, $items_per_page, $anchor->get_reference());
     }
     // actually render the html
     if (is_array($items)) {
         $context['text'] .= Skin::build_list($items, 'decorated');
     } elseif (is_string($items)) {
         $context['text'] .= $items;
     }
Exemplo n.º 4
0
 /**
  * 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;
 }
Exemplo n.º 5
0
         if (isset($rows[$user_id])) {
             $rows[$user_id][1] = CHECKED_IMG;
         } else {
             $owner = '';
             if ($user_id == $item['owner_id']) {
                 $owner = CHECKED_IMG;
             }
             $editor = '';
             $watcher = CHECKED_IMG;
             $rows[$user_id] = array($user_label, $watcher, $editor, $owner);
         }
     }
 }
 // count
 if ($users_count) {
     $box['bar'] += array('_count' => sprintf(i18n::ns('%d participant', '%d participants', $users_count), $users_count));
 }
 // add to the watch list -- $in_watch_list is set in sections/view.php
 if (Surfer::get_id() && $in_watch_list == 'N') {
     Skin::define_img('TOOLS_WATCH_IMG', 'tools/watch.gif');
     $box['bar'] += array(Users::get_url('section:' . $item['id'], 'track') => TOOLS_WATCH_IMG . i18n::s('Watch this section'));
 }
 // invite participants, for owners
 if (Sections::is_owned($item, $anchor, TRUE) && isset($context['with_email']) && $context['with_email'] == 'Y') {
     Skin::define_img('SECTIONS_INVITE_IMG', 'sections/invite.gif');
     $box['bar'] += array(Sections::get_url($item['id'], 'invite') => SECTIONS_INVITE_IMG . i18n::s('Invite participants'));
 }
 // notify participants
 if ($count > 1 && Sections::allow_message($item, $anchor) && isset($context['with_email']) && $context['with_email'] == 'Y') {
     Skin::define_img('SECTIONS_EMAIL_IMG', 'sections/email.gif');
     $box['bar'] += array(Sections::get_url($item['id'], 'mail') => SECTIONS_EMAIL_IMG . i18n::s('Notify participants'));
Exemplo n.º 6
0
 /**
  * list articles for search requests
  *
  * @param resource the SQL result
  * @return array of resulting items ($score, $summary), or NULL
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of array($score, $summary)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // process all items in the list
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // one box at a time
         $box = '';
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // initialize variables
         $prefix = $suffix = $icon = '';
         // flag sticky pages
         if ($item['rank'] < 10000) {
             $prefix .= STICKY_FLAG;
         }
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
             $suffix .= ' ' . LOCKED_FLAG;
         }
         // flag articles that are dead, or created or updated very recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= ' ' . UPDATED_FLAG;
         }
         // signal articles to be published
         if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
             $prefix .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // introduction
         $introduction = '';
         if (is_object($overlay)) {
             $introduction = $overlay->get_text('introduction', $item);
         } else {
             $introduction = $item['introduction'];
         }
         // the introductory text
         if ($introduction) {
             $suffix .= ' -&nbsp;' . Codes::beautify_introduction($introduction);
             // link to description, if any
             if ($item['description']) {
                 $suffix .= ' ' . Skin::build_link($url, MORE_IMG, 'more', i18n::s('View the page')) . ' ';
             }
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $suffix .= $overlay->get_text('list', $item);
         }
         // details
         $details = array();
         // the author
         if ($item['create_name'] != $item['edit_name']) {
             $details[] = sprintf(i18n::s('by %s, %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']));
         } else {
             $details[] = sprintf(i18n::s('by %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']));
         }
         // the last action
         $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']);
         // the number of hits
         if (Surfer::is_logged() && $item['hits'] > 1) {
             $details[] = Skin::build_number($item['hits'], i18n::s('hits'));
         }
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
         }
         // rating
         if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
             $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
         }
         // the main anchor link
         if (is_object($anchor)) {
             $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'section'));
         }
         // display all tags
         if ($item['tags']) {
             $details[] = '<span class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>';
         }
         // combine in-line details
         if (count($details)) {
             $suffix .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>';
         }
         // insert a suffix separator
         if (trim($suffix)) {
             $suffix = ' ' . $suffix;
         }
         // item summary
         $box .= $prefix . Skin::build_link($url, $title, 'article') . $suffix;
         // the icon to put in the left column
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } elseif (is_callable(array($anchor, 'get_bullet_url'))) {
             $icon = $anchor->get_bullet_url();
         }
         // build the complete HTML element
         if ($icon) {
             $icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($title)) . '" />';
             // make it a clickable link
             $icon = Skin::build_link($url, $icon, 'basic');
             // default icon
         } else {
             $icon = DECORATED_IMG;
         }
         // layout this item
         $list = array(array($box, $icon));
         $items[] = array($item['score'], Skin::finalize_list($list, 'decorated'));
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Exemplo n.º 7
0
 /**
  * list articles
  *
  * Accept following variants:
  * - 'hits', compact plus the number of hits
  * - 'no_author', for articles in the user page
  * - 'category:xxx', if the list is displayed at categories/view.php
  * - 'section:xxx', if the list is displayed at sections/view.php
  *
  * @param resource the SQL result
  * @return array of resulting items, or NULL
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return an array of ($url => $attributes)
     $items = array();
     // empty list
     if (!SQL::count($result)) {
         return $items;
     }
     // sanity check
     if (!isset($this->layout_variant)) {
         $this->layout_variant = 'decorated';
     }
     // process all items in the list
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // initialize variables
         $prefix = $suffix = $icon = '';
         // flag sticky pages
         if ($item['rank'] < 10000) {
             $prefix .= STICKY_FLAG;
         }
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
             $suffix .= ' ' . LOCKED_FLAG;
         }
         // flag articles that are dead, or created or updated very recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= ' ' . UPDATED_FLAG;
         }
         // signal articles to be published
         if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
             $prefix .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // the compact version
         if ($this->layout_variant == 'compact') {
             $items[$url] = array($prefix, Skin::strip($title, 30), $suffix, 'basic', NULL);
             continue;
         }
         // with hits
         if ($this->layout_variant == 'hits') {
             if ($item['hits'] > 1) {
                 $suffix = ' <span class="details">- ' . Skin::build_number($item['hits'], i18n::s('hits')) . '</span>';
             }
             $items[$url] = array($prefix, Skin::strip($title, 30), $suffix, 'basic', NULL);
             continue;
         }
         // introduction
         $introduction = '';
         if (is_object($overlay)) {
             $introduction = $overlay->get_text('introduction', $item);
         } else {
             $introduction = $item['introduction'];
         }
         // the introductory text
         if ($introduction) {
             $suffix .= ' -&nbsp;' . Codes::beautify_introduction($introduction);
             // link to description, if any
             if ($item['description']) {
                 $suffix .= ' ' . Skin::build_link($url, MORE_IMG, 'more', i18n::s('View the page')) . ' ';
             }
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $suffix .= $overlay->get_text('list', $item);
         }
         // next line, except if we already are at the beginning of a line
         if ($suffix && !preg_match('/<br\\s*\\/>$/', rtrim($suffix))) {
             $suffix .= BR;
         }
         // append details to the suffix
         $suffix .= '<span class="details">';
         // details
         $details = array();
         // display details only at the main index page, and also at anchor pages
         if (isset($this->focus) && $item['anchor'] != $this->focus) {
             // the author
             if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
                 if ($item['create_name'] != $item['edit_name']) {
                     $details[] = sprintf(i18n::s('by %s, %s'), $item['create_name'], $item['edit_name']);
                 } else {
                     $details[] = sprintf(i18n::s('by %s'), $item['create_name']);
                 }
             }
             // the last action
             $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']);
             // the number of hits
             if (Surfer::is_logged() && $item['hits'] > 1) {
                 $details[] = Skin::build_number($item['hits'], i18n::s('hits'));
             }
             // info on related files
             if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
                 $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
             }
             // info on related links
             if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
                 $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
             }
             // info on related comments
             if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
                 $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
             }
             // rating
             if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
                 $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
             }
             // unusual ranks are signaled to associates and owners
             if ($item['rank'] != 10000 && Articles::is_owned($item, $anchor)) {
                 $details[] = '{' . $item['rank'] . '}';
             }
         }
         // at the user page
         if ($this->layout_variant == 'no_author' && Surfer::get_id()) {
             if (Members::check('article:' . $item['id'], 'user:'******'Stop notifications');
             } else {
                 $label = i18n::s('Watch this page');
             }
             $menu = array('users/track.php?anchor=' . urlencode('article:' . $item['id']) => $label);
             $details[] = Skin::build_list($menu, 'menu');
         }
         // 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 .= ucfirst(trim(implode(', ', $details)));
         }
         // end of details
         $suffix .= '</span>';
         // display all tags
         if ($item['tags']) {
             $suffix .= ' <span class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>';
         }
         // strip empty details
         $suffix = str_replace(BR . '<span class="details"></span>', '', $suffix);
         $suffix = str_replace('<span class="details"></span>', '', $suffix);
         // insert a suffix separator
         if (trim($suffix)) {
             $suffix = ' ' . $suffix;
         }
         // the icon to put in the left column
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } elseif (is_callable(array($anchor, 'get_bullet_url'))) {
             $icon = $anchor->get_bullet_url();
         }
         // list all components for this item
         $items[$url] = array($prefix, $title, $suffix, 'article', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Exemplo n.º 8
0
 /**
  * list articles as digg do
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $label = i18n::s('No page to display.');
         if (Surfer::is_associate()) {
             $label .= ' ' . sprintf(i18n::s('Use the %s to populate this server.'), Skin::build_link('help/populate.php', i18n::s('Content Assistant'), 'shortcut'));
         }
         $output = '<p>' . $label . '</p>';
         return $output;
     }
     // build a list of articles
     $text = '';
     $item_count = 0;
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // permalink
         $url = Articles::get_permalink($item);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // next item
         $item_count += 1;
         // section opening
         if ($item_count == 1) {
             $text .= '<div class="newest">' . "\n";
         }
         // reset everything
         $content = $prefix = $label = $suffix = $icon = '';
         // the icon to put aside
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } elseif (is_callable(array($anchor, 'get_bullet_url'))) {
             $icon = $anchor->get_bullet_url();
         }
         if ($icon) {
             $icon = '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $icon . '" class="right_image" alt="' . encode_field(i18n::s('View the page')) . '" title="' . encode_field(i18n::s('View the page')) . '" /></a>';
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // flag articles updated recently
         if ($item['create_date'] >= $context['fresh']) {
             $suffix .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= ' ' . UPDATED_FLAG;
         }
         // add details
         $details = array();
         // the author
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             if ($item['edit_name'] == $item['create_name']) {
                 $details[] = sprintf(i18n::s('by %s'), ucfirst($item['create_name']));
             } else {
                 $details[] = sprintf(i18n::s('by %s, %s'), ucfirst($item['create_name']), ucfirst($item['edit_name']));
             }
         }
         // the publish date
         $details[] = Skin::build_date($item['publish_date']);
         // rating
         $rating_label = '';
         if ($item['rating_count']) {
             $rating_label = Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])) . ' ' . sprintf(i18n::ns('%d rating', '%d ratings', $item['rating_count']), $item['rating_count']) . ' ';
         }
         // add a link to let surfer rate this item
         if (is_object($anchor) && !$anchor->has_option('without_rating')) {
             if (!$item['rating_count']) {
                 $rating_label .= i18n::s('Rate this page');
             }
             $rating_label = Skin::build_link(Articles::get_url($item['id'], 'like'), $rating_label, 'basic', i18n::s('Rate this page'));
         }
         // display current rating, and allow for rating
         $details[] = $rating_label;
         // details
         if (count($details)) {
             $content .= '<p class="details">' . ucfirst(implode(', ', $details)) . '</p>';
         }
         // the full introductory text
         if ($item['introduction']) {
             $content .= Codes::beautify($item['introduction'], $item['options']);
         } elseif (!is_object($overlay)) {
             include_once $context['path_to_root'] . 'articles/article.php';
             $article = new Article();
             $article->load_by_content($item);
             $content .= $article->get_teaser('teaser');
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $content .= $overlay->get_text('list', $item);
         }
         // an array of links
         $menu = array();
         // rate the article
         $menu = array_merge($menu, array(Articles::get_url($item['id'], 'like') => i18n::s('Rate this page')));
         // read the article
         $menu = array_merge($menu, array($url => i18n::s('Read more')));
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
             $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'basic');
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
             $link = Comments::get_url('article:' . $item['id'], 'list');
             $menu = array_merge($menu, array($link => sprintf(i18n::ns('%d comment', '%d comments', $count), $count)));
         }
         // discuss
         if (Comments::allow_creation($item, $anchor)) {
             $menu = array_merge($menu, array(Comments::get_url('article:' . $item['id'], 'comment') => i18n::s('Discuss')));
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             $menu = array_merge($menu, array($url . '#_attachments' => sprintf(i18n::ns('%d link', '%d links', $count), $count)));
         }
         // trackback
         if (Links::allow_trackback()) {
             $menu = array_merge($menu, array('links/trackback.php?anchor=' . urlencode('article:' . $item['id']) => i18n::s('Reference this page')));
         }
         // link to the anchor page
         if (is_object($anchor)) {
             $menu = array_merge($menu, array($anchor->get_url() => $anchor->get_title()));
         }
         // list up to three categories by title, if any
         if ($items = Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 3, 'raw')) {
             foreach ($items as $id => $attributes) {
                 $menu = array_merge($menu, array(Categories::get_permalink($attributes) => $attributes['title']));
             }
         }
         // append a menu
         $content .= Skin::build_list($menu, 'menu_bar');
         // insert a complete box
         $text .= Skin::build_box($icon . $prefix . Codes::beautify_title($item['title']) . $suffix, $content, 'header1', 'article_' . $item['id']);
         // section closing
         if ($item_count == 1) {
             $text .= '</div>' . "\n";
         }
     }
     // end of processing
     SQL::free($result);
     // add links to archives
     $anchor = Categories::get(i18n::c('monthly'));
     if (isset($anchor['id']) && ($items = Categories::list_by_date_for_anchor('category:' . $anchor['id'], 0, COMPACT_LIST_SIZE, 'compact'))) {
         $text .= Skin::build_box(i18n::s('Previous pages'), Skin::build_list($items, 'menu_bar'));
     }
     return $text;
 }
Exemplo n.º 9
0
 /**
  * list sections as topics in a forum
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $output = array();
         return $output;
     }
     // layout in a table
     $text = Skin::table_prefix('wide');
     // 'even' is used for title rows, 'odd' for detail rows
     $class_title = 'odd';
     $class_detail = 'even';
     // build a list of sections
     $family = '';
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // change the family
         if ($item['family'] != $family) {
             $family = $item['family'];
             // show the family
             $text .= Skin::table_suffix() . '<h2><span>' . $family . '&nbsp;</span></h2>' . "\n" . Skin::table_prefix('wide');
         }
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'section:' . $item['id']);
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // reset everything
         $prefix = $label = $suffix = $icon = '';
         // signal restricted and private sections
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // indicate the id in the hovering popup
         $hover = i18n::s('View the section');
         if (Surfer::is_member()) {
             $hover .= ' [section=' . $item['id'] . ']';
         }
         // the url to view this item
         $url = Sections::get_permalink($item);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // use the title as a link to the page
         $title =& Skin::build_link($url, $title, 'basic', $hover);
         // flag sections updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $suffix = EXPIRED_FLAG . ' ';
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix = NEW_FLAG . ' ';
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix = UPDATED_FLAG . ' ';
         }
         // this is another row of the output
         $text .= '<tr class="' . $class_title . '"><th>' . $prefix . $title . $suffix . '</th><th>' . i18n::s('Poster') . '</th><th>' . i18n::s('Messages') . '</th><th>' . i18n::s('Last active') . '</th></tr>' . "\n";
         $count = 1;
         // get last posts for this board --avoid sticky pages
         if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) {
             $order = $matches[1];
         } else {
             $order = 'edition';
         }
         if ($articles =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, 5, 'raw', TRUE)) {
             foreach ($articles as $id => $article) {
                 // get the related overlay, if any
                 $article_overlay = Overlay::load($article, 'article:' . $id);
                 // flag articles updated recently
                 if ($article['expiry_date'] > NULL_DATE && $article['expiry_date'] <= $context['now']) {
                     $flag = EXPIRED_FLAG . ' ';
                 } elseif ($article['create_date'] >= $context['fresh']) {
                     $flag = NEW_FLAG . ' ';
                 } elseif ($article['edit_date'] >= $context['fresh']) {
                     $flag = UPDATED_FLAG . ' ';
                 } else {
                     $flag = '';
                 }
                 // use the title to label the link
                 if (is_object($article_overlay)) {
                     $title = Codes::beautify_title($article_overlay->get_text('title', $article));
                 } else {
                     $title = Codes::beautify_title($article['title']);
                 }
                 // title
                 $title = Skin::build_link(Articles::get_permalink($article), $title, 'article');
                 // poster
                 $poster = Users::get_link($article['create_name'], $article['create_address'], $article['create_id']);
                 // comments
                 $comments = Comments::count_for_anchor('article:' . $article['id']);
                 // 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) . '&nbsp;&raquo;';
         }
         // link to the section index page
         if ($details) {
             $details = Skin::build_link(Sections::get_permalink($item), join(' -&nbsp;', $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') . '&nbsp;&raquo;', '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;
 }
Exemplo n.º 10
0
Arquivo: index.php Projeto: rair/yacs
         $cells = array();
         $cells[] = Skin::build_link('http://www.mysql.com/', 'MySQL');
         $cells[] = $version;
         $box .= Skin::table_row($cells, $lines++);
     }
     // Apache version
     if (is_callable('apache_get_version')) {
         $cells = array();
         $cells[] = Skin::build_link('http://www.apache.org/', 'Apache');
         $cells[] = apache_get_version();
         $box .= Skin::table_row($cells, $lines++);
     }
     // time shift
     $cells = array();
     $cells[] = i18n::s('Server time zone');
     $cells[] = sprintf('UTC %s%s %s', $context['gmt_offset'] > 0 ? '+' : '', $context['gmt_offset'], i18n::ns('hour', 'hours', abs($context['gmt_offset'])));
     $box .= Skin::table_row($cells, $lines++);
     // memory usage
     if (is_callable('memory_get_usage')) {
         $cells = array();
         $cells[] = i18n::s('Memory');
         $cells[] = memory_get_usage();
         $box .= Skin::table_row($cells, $lines++);
     }
     // end of the table
     $box .= Skin::table_suffix();
     // make a nice box out of it
     $text .= Skin::build_box(i18n::s('System overview'), $box);
 }
 // available commands for system management
 $commands = array();
Exemplo n.º 11
0
 /**
  * list articles 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;
     }
     // build a list of articles
     $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, 'article:' . $item['id']);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // reset everything
         $title = $abstract = $author = '';
         // signal articles to be published
         if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
             $title .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $title .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $title .= RESTRICTED_FLAG;
         }
         // indicate the id in the hovering popup
         $hover = i18n::s('View the page');
         if (Surfer::is_member()) {
             $hover .= ' [article=' . $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
         $title .= Skin::build_link($url, $label, 'basic', $hover);
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
             $title .= ' ' . LOCKED_FLAG;
         }
         // flag articles updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $title .= ' ' . EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $title .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $title .= ' ' . UPDATED_FLAG;
         }
         // the icon
         if ($item['thumbnail_url']) {
             $abstract .= '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $item['thumbnail_url'] . '" class="right_image" alt="" /></a>';
         }
         // the introductory text
         if (is_object($overlay)) {
             $abstract .= Codes::beautify_introduction($overlay->get_text('introduction', $item));
         } elseif ($item['introduction']) {
             $abstract .= Codes::beautify_introduction($item['introduction']);
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $abstract .= $overlay->get_text('list', $item);
         }
         // make some abstract out of main text
         if (!$item['introduction'] && $context['skins_with_details'] == 'Y') {
             $abstract .= Skin::cap(Codes::beautify($item['description'], $item['options']), 50);
         }
         // attachment details
         $details = array();
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
             Skin::define_img('FILES_LIST_IMG', 'files/list.gif');
             $details[] = FILES_LIST_IMG . sprintf(i18n::ns('%d file', '%d files', $count), $count);
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             Skin::define_img('LINKS_LIST_IMG', 'links/list.gif');
             $details[] = LINKS_LIST_IMG . sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
             Skin::define_img('COMMENTS_LIST_IMG', 'comments/list.gif');
             $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), COMMENTS_LIST_IMG . sprintf(i18n::ns('%d comment', '%d comments', $count), $count));
         }
         // describe attachments
         if (count($details)) {
             $abstract .= '<p style="margin: 3px 0;">' . join(', ', $details) . '</p>';
         }
         // anchors
         $anchors = array();
         if ($members =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) {
             foreach ($members as $category_id => $attributes) {
                 // add background color to distinguish this category against others
                 if (isset($attributes['background_color']) && $attributes['background_color']) {
                     $attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>';
                 }
                 $anchors[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic');
             }
         }
         if (@count($anchors)) {
             $abstract .= '<p class="tags" style="margin: 3px 0">' . implode(' ', $anchors) . '</p>';
         }
         // poster name
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             if ($item['create_name']) {
                 $author = Users::get_link($item['create_name'], $item['create_address'], $item['create_id']);
             } else {
                 $author = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']);
             }
         }
         // more details
         $details =& Articles::build_dates($anchor, $item);
         // rating
         if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
             $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
         }
         // page details
         if (count($details)) {
             $details = '<p class="details">' . join(', ', $details) . '</p>';
         }
         // this is another row of the output -- title, abstract, (author,) details
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             $cells = array($title, $abstract, $author, $details);
         } else {
             $cells = array($title, $abstract, $details);
         }
         // append this row
         $rows[] = $cells;
     }
     // end of processing
     SQL::free($result);
     // headers
     if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
         $headers = array(i18n::s('Topic'), i18n::s('Abstract'), i18n::s('Poster'), i18n::s('Details'));
     } else {
         $headers = array(i18n::s('Topic'), i18n::s('Abstract'), i18n::s('Details'));
     }
     // return a sortable table
     $text .= Skin::table($headers, $rows, 'grid');
     return $text;
 }
Exemplo n.º 12
0
Arquivo: index.php Projeto: rair/yacs
// the maximum number of locations per page
if (!defined('LOCATIONS_PER_PAGE')) {
    define('LOCATIONS_PER_PAGE', 20);
}
// the title of the page
$context['page_title'] = i18n::s('Locations');
// this page is really only for associates
if (!Surfer::is_associate()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
    // display the index
} else {
    // count locations in the database
    $stats = Locations::stat();
    if ($stats['count']) {
        $context['page_menu'] += array('_count' => sprintf(i18n::ns('%d location', '%d locations', $stats['count']), $stats['count']));
    }
    // navigation commands for locations, if necessary
    if ($stats['count'] > LOCATIONS_PER_PAGE) {
        $home = 'locations/';
        if ($context['with_friendly_urls'] == 'Y') {
            $prefix = $home . 'index.php/';
        } elseif ($context['with_friendly_urls'] == 'R') {
            $prefix = $home;
        } else {
            $prefix = $home . '?page=';
        }
        $context['page_menu'] += Skin::navigate($home, $prefix, $stats['count'], LOCATIONS_PER_PAGE, $page);
    }
    // page main content
    $cache_id = 'locations/index.php#text#' . $page;
Exemplo n.º 13
0
Arquivo: view.php Projeto: rair/yacs
         $canvas['files'] = Skin::build_content('files', i18n::s('Files'), $box['text'], $box['bar']);
     }
     $canvas['files_count'] = $count;
 }
 //
 // links attached to this article
 //
 // the list of related links if not at another follow-up page
 if (!$zoom_type || $zoom_type == 'links') {
     // build a complete box
     $box = array('bar' => array(), 'text' => '');
     // a navigation bar for these links
     if ($count = Links::count_for_anchor('article:' . $item['id'])) {
         $attachments_count += $count;
         if ($count > 20) {
             $box['bar'] += array('_count' => sprintf(i18n::ns('%d link', '%d links', $count), $count));
         }
         // list links by date (default) or by title (option links_by_title)
         $offset = ($zoom_index - 1) * LINKS_PER_PAGE;
         if (Articles::has_option('links_by_title', $anchor, $item)) {
             $items = Links::list_by_title_for_anchor('article:' . $item['id'], $offset, LINKS_PER_PAGE);
         } else {
             $items = Links::list_by_date_for_anchor('article:' . $item['id'], $offset, LINKS_PER_PAGE);
         }
         // actually render the html
         if (is_array($items)) {
             $box['text'] .= Skin::build_list($items, 'decorated');
         } elseif (is_string($items)) {
             $box['text'] .= $items;
         }
         // navigation commands for links
Exemplo n.º 14
0
Arquivo: view.php Projeto: rair/yacs
 //			.JS_SUFFIX."\n";
 //	}
 //
 // link to download the file
 //
 // download description
 $description = '';
 // the list of people who have fetched this file, for owners and associates
 if (Files::allow_modification($item, $anchor) && ($users = Activities::list_users_at('file:' . $item['id'], 'fetch', 30, 'comma'))) {
     $count = Activities::count_users_at('file:' . $item['id'], 'fetch');
     if ($count > 30) {
         $more = ' ...';
     } else {
         $more = '';
     }
     $description .= '<p>' . Skin::build_number($item['hits'], i18n::ns('download', 'downloads', $item['hits'])) . sprintf(i18n::ns(', including %d authenticated person: %s', ', including %d authenticated persons: %s', $count), $count, $users) . "</p>\n";
 }
 // add some help depending on the file type
 $extension = strtolower(@array_pop(@explode('.', @basename($item['file_name']))));
 switch ($extension) {
     case '3gp':
         // video/3gpp
         $description .= '<p>' . sprintf(i18n::s('You are about to download a small video. To take the most of it we recommend you to use %s (open source).'), Skin::build_link(i18n::s('http://www.videolan.org/vlc/'), i18n::s('VLC media player'), 'external')) . '</p>';
         break;
     case 'ai':
     case 'eps':
     case 'ps':
         $description .= '<p>' . sprintf(i18n::s('You are about to download a Postscript file. %s is a popular rendering platform (free for non-commercial use).'), Skin::build_link(i18n::s('http://www.cs.wisc.edu/~ghost/'), i18n::s('Ghostscript, Ghostview and GSview'), 'external')) . '</p>';
         break;
     case 'ace':
     case 'arj':
Exemplo n.º 15
0
 /**
  * list articles as topics in a forum
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // allow for complete styling
     $text = '<div class="last_articles">';
     // build a list of articles
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // get the related overlay
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // build a title
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // reset everything
         $prefix = $label = $suffix = $icon = '';
         // signal articles to be published
         if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
             $prefix .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // flag expired articles
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG . ' ';
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
             $suffix .= ' ' . LOCKED_FLAG;
         }
         // rating
         if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
             $suffix .= ' ' . Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
         }
         // indicate the id in the hovering popup
         $hover = i18n::s('View the page');
         if (Surfer::is_member()) {
             $hover .= ' [article=' . $item['id'] . ']';
         }
         // one box per update
         $text .= '<div class="last_article" >';
         // use the title as a link to the page
         $text .= Skin::build_block($prefix . ucfirst($title) . $suffix, 'header1');
         // some details about this page
         $details = array();
         // page starter and date
         if ($item['create_name']) {
             $details[] = sprintf(i18n::s('Started by %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id'])) . ' ' . Skin::build_date($item['create_date']);
         }
         // page last modification
         if ($item['edit_date'] && $item['edit_action'] == 'article:update' && $item['edit_name']) {
             $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . sprintf(i18n::s('by %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id'])) . ' ' . Skin::build_date($item['edit_date']);
         }
         // friends
         if ($friends =& Members::list_users_by_posts_for_anchor('article:' . $item['id'], 0, USERS_LIST_SIZE, 'comma5', $item['create_id'])) {
             $details[] = sprintf(i18n::s('with %s'), $friends);
         }
         // people details
         if ($details) {
             $text .= '<p class="details">' . join(', ', $details) . "</p>\n";
         }
         // the introductory text
         $introduction = '';
         if (is_object($overlay)) {
             $introduction = $overlay->get_text('introduction', $item);
         } elseif ($item['introduction']) {
             $introduction = $item['introduction'];
         }
         if ($introduction) {
             $text .= '<div style="margin: 1em 0;">' . Codes::beautify_introduction($introduction) . '</div>';
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $text .= $overlay->get_text('list', $item);
         }
         // info on related comments
         if (($count = Comments::count_for_anchor('article:' . $item['id'])) > 1) {
             $text .= '<div style="margin-top: 1em;"><p class="details">' . sprintf(i18n::s('%d contributions, including:'), $count) . '</p></div>';
         }
         // avoid first file if mentioned in last contribution
         $file_offset = 0;
         // get last contribution for this page
         if ($comment = Comments::get_newest_for_anchor('article:' . $item['id'])) {
             if (preg_match('/\\[(download|file)=/', $comment['description'])) {
                 $file_offset++;
             }
             // bars around the last contribution
             $bottom_menu = array();
             // last contributor
             $contributor = Users::get_link($comment['create_name'], $comment['create_address'], $comment['create_id']);
             $flag = '';
             if ($comment['create_date'] >= $context['fresh']) {
                 $flag = NEW_FLAG;
             } elseif ($comment['edit_date'] >= $context['fresh']) {
                 $flag = UPDATED_FLAG;
             }
             $bottom_menu[] = sprintf(i18n::s('By %s'), $contributor) . ' ' . Skin::build_date($comment['create_date']) . $flag;
             // offer to reply
             if (Comments::allow_creation($item, $anchor)) {
                 $link = Comments::get_url($comment['id'], 'reply');
                 $bottom_menu[] = Skin::build_link($link, i18n::s('Reply'), 'basic');
             }
             // gather pieces
             $pieces = array();
             // last contribution, and user signature
             $pieces[] = ucfirst(trim($comment['description'])) . Users::get_signature($comment['create_id']);
             // bottom
             if ($bottom_menu) {
                 $pieces[] = '<div style="margin-top: 1em;">' . ucfirst(trim(Skin::finalize_list($bottom_menu, 'menu'))) . '</div>';
             }
             // put all pieces together
             $text .= '<div class="last_comment">' . "\n" . join("\n", $pieces) . '</div>' . "\n";
         }
         // list more recent files
         if ($items = Files::list_by_date_for_anchor('article:' . $item['id'], $file_offset, 3, 'dates')) {
             // more files than listed
             $more = '';
             if (($count = Files::count_for_anchor('article:' . $item['id'])) > 3) {
                 $more = '<span class="details">' . sprintf(i18n::s('%d files, including:'), $count) . '</span>';
             }
             if (is_array($items)) {
                 $items = Skin::build_list($items, 'compact');
             }
             $text .= '<div style="margin: 1em 0;">' . $more . $items . '</div>';
         }
         // display all tags
         if ($item['tags']) {
             $text .= ' <p class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</p>';
         }
         // navigation links
         $menu = array();
         // permalink
         $menu[] = Skin::build_link($url, i18n::s('View the page'), 'span');
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             $menu[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // the main anchor link
         if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) {
             $menu[] = Skin::build_link($anchor->get_url(), sprintf(i18n::s('in %s'), ucfirst($anchor->get_title())), 'span', i18n::s('View the section'));
         }
         // actually insert details
         $text .= Skin::finalize_list($menu, 'menu_bar');
         // bottom of the box
         $text .= '</div>';
     }
     // close the list of articles
     $text .= '</div>';
     // beautify everything at once
     $text = Codes::beautify($text);
     // end of processing
     SQL::free($result);
     // done
     return $text;
 }
Exemplo n.º 16
0
Arquivo: edit.php Projeto: rair/yacs
                // save content of the overlay in the page
                $item['overlay'] = $overlay->save();
                $item['overlay_id'] = $overlay->get_id();
                // store in the database
                if (Articles::put($item)) {
                    $context['text'] .= sprintf(i18n::s('%s has been changed'), Skin::build_link(Articles::get_permalink($item), $item['title']));
                }
            }
        }
        // no page has been found
    } else {
        $context['text'] .= '<p>' . i18n::s('No item has the provided id.') . '</p>';
    }
    // report on results
    if ($count) {
        $context['text'] .= '<p>' . sprintf(i18n::ns('%d page has been processed.', '%d pages have been processed.', $count), $count) . '</p>';
    }
    // bottom commands
    $menu = array();
    $menu[] = Skin::build_link('overlays/mutables/edit.php', i18n::s('Change named overlays'), 'basic');
    $context['text'] .= Skin::finalize_list($menu, 'assistant_bar');
    // the form
} else {
    // splash
    $context['text'] .= '<p>' . i18n::s('You will change some attributes of a named overlay.') . '</p>';
    // the form to send a query
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" onsubmit="return validateDocumentPost(this)" id="main_form"><div>';
    // overlay id
    $label = i18n::s('Overlay identifier') . ' *';
    $input = '<input type="text" name="id" size="45" value="" maxlength="255" />';
    $fields[] = array($label, $input);
Exemplo n.º 17
0
 /**
  * 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 . '&nbsp;</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']) {
             // 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 = '';
             }
             // title
             $last_post = Skin::build_link(Articles::get_permalink($article), Codes::beautify_title($article['title']), 'article');
             // last editor
             if ($article['edit_date']) {
                 // find a name, if any
                 if ($article['edit_name']) {
                     // label the action
                     if (isset($article['edit_action'])) {
                         $action = Anchors::get_action_label($article['edit_action']);
                     } else {
                         $action = i18n::s('edited');
                     }
                     // name of last editor
                     $user = sprintf(i18n::s('%s by %s'), $action, Users::get_link($article['edit_name'], $article['edit_address'], $article['edit_id']));
                 }
                 $last_post .= $flag . BR . '<span class="tiny">' . $user . ' ' . Skin::build_date($article['edit_date']) . '</span>';
             }
         }
         // this is another row of the output
         $text .= Skin::table_row(array($prefix . $title . $suffix . $details, 'center=' . $count, $last_post));
     }
     // end of processing
     SQL::free($result);
     $text .= Skin::table_suffix();
     return $text;
 }
Exemplo n.º 18
0
 /**
  * list articles as topics in a forum
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // start a table
     $text .= Skin::table_prefix('jive');
     // headers
     $text .= Skin::table_row(array(i18n::s('Topic'), i18n::s('Content')), 'header');
     // build a list of articles
     $odd = FALSE;
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // one row per article
         $text .= '<tr class="' . ($odd ? 'odd' : 'even') . '"><td>';
         $odd = !$odd;
         // signal articles to be published
         if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
             $text .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $text .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $text .= RESTRICTED_FLAG;
         }
         // use the title as a link to the page
         $text .= Skin::build_link($url, '<strong>' . $title . '</strong>', 'basic');
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
             $text .= ' ' . LOCKED_FLAG;
         }
         // flag articles updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $text .= ' ' . EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $text .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $text .= ' ' . UPDATED_FLAG;
         }
         // add details, if any
         $details = array();
         // poster name
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             if ($item['create_name']) {
                 $details[] = sprintf(i18n::s('posted by %s %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']), Skin::build_date($item['create_date']));
             }
         }
         // last update
         $details[] = sprintf(i18n::s('Updated %s'), Skin::build_date($item['edit_date']));
         // add details to the title
         if (count($details)) {
             $text .= '<p class="details" style="margin: 3px 0">' . join(', ', $details) . '</p>';
         }
         // display all tags
         if ($item['tags']) {
             $text .= '<p class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</p>';
         }
         // next cell for the content
         $text .= '</td><td width="70%">';
         // the content to be displayed
         $content = '';
         // rating
         if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
             $content .= Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
         }
         // the introductory text
         if (is_object($overlay)) {
             $content .= Codes::beautify_introduction($overlay->get_text('introduction', $item));
         } else {
             $content .= Codes::beautify_introduction($item['introduction']);
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $content .= $overlay->get_text('list', $item);
         }
         // the description
         $content .= Skin::build_block($item['description'], 'description', '', $item['options']);
         // attachment details
         $details = array();
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'])) {
             Skin::define_img('FILES_LIST_IMG', 'files/list.gif');
             $details[] = Skin::build_link($url . '#_attachments', FILES_LIST_IMG . sprintf(i18n::ns('%d file', '%d files', $count), $count), 'span');
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             Skin::define_img('LINKS_LIST_IMG', 'links/list.gif');
             $details[] = LINKS_LIST_IMG . sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // count replies
         if ($count = Comments::count_for_anchor('article:' . $item['id'])) {
             $details[] = Skin::build_link($url . '#_discussion', sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'span');
         }
         // the command to reply
         if (Comments::allow_creation($item, $anchor)) {
             Skin::define_img('COMMENTS_ADD_IMG', 'comments/add.gif');
             $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), COMMENTS_ADD_IMG . i18n::s('Post a comment'), 'span');
         }
         // describe attachments
         $content .= Skin::finalize_list($details, 'menu_bar');
         // end the row
         $text .= $content . '</td></tr>';
     }
     // end of processing
     SQL::free($result);
     // return the table
     $text .= Skin::table_suffix();
     return $text;
 }
Exemplo n.º 19
0
 /**
  * list articles
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // the script used to check all pages at once
     Page::insert_script('function cascade_selection_to_all_article_rows(handle) {' . "\n" . '	$("div#articles_panel input[type=\'checkbox\'].row_selector").each(' . "\n" . '		function() { $(this).attr("checked", $(handle).is(":checked"));}' . "\n" . '	);' . "\n" . '}' . "\n");
     // table prefix
     $text .= Skin::table_prefix('yc-grid');
     // table headers
     $main = '<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />';
     $cells = array($main, i18n::s('Page'), i18n::s('Rank'));
     $text .= Skin::table_row($cells, 'header');
     // process all items in the list
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     $count = 0;
     while ($item = SQL::fetch($result)) {
         $cells = array();
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // column to select the row
         $cells[] = '<input type="checkbox" name="selected_articles[]" id="article_selector_' . $count . '" class="row_selector" value="' . $item['id'] . '" />';
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // initialize variables
         $prefix = $suffix = $icon = '';
         // flag sticky pages
         if ($item['rank'] < 10000) {
             $prefix .= STICKY_FLAG;
         }
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y') {
             $suffix .= ' ' . LOCKED_FLAG;
         }
         // flag articles that are dead, or created or updated very recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= ' ' . UPDATED_FLAG;
         }
         // signal articles to be published
         if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) {
             $prefix .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // the introductory text
         if (is_object($overlay)) {
             $introduction = $overlay->get_text('introduction', $item);
         } else {
             $introduction = $item['introduction'];
         }
         if ($introduction) {
             $suffix .= BR . Codes::beautify_introduction($introduction);
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $suffix .= $overlay->get_text('list', $item);
         }
         // append details to the suffix
         $suffix .= BR . '<span class="details">';
         // details
         $details = array();
         // the author
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             if ($item['create_name'] != $item['edit_name']) {
                 $details[] = sprintf(i18n::s('by %s, %s'), $item['create_name'], $item['edit_name']);
             } else {
                 $details[] = sprintf(i18n::s('by %s'), $item['create_name']);
             }
         }
         // the last action
         $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']);
         // the number of hits
         if (Surfer::is_logged() && $item['hits'] > 1) {
             $details[] = Skin::build_number($item['hits'], i18n::s('hits'));
         }
         // info on related files
         $stats = Files::stat_for_anchor('article:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $stats['count']), $stats['count']);
         }
         // info on related links
         $stats = Links::stat_for_anchor('article:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $stats['count']), $stats['count']);
         }
         // info on related comments
         $stats = Comments::stat_for_anchor('article:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $stats['count']), $stats['count']);
         }
         // rating
         if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
             $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
         }
         // combine in-line details
         if (count($details)) {
             $suffix .= ucfirst(trim(implode(', ', $details)));
         }
         // list up to three categories by title, if any
         $anchors = array();
         if ($members =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) {
             foreach ($members as $id => $attributes) {
                 // add background color to distinguish this category against others
                 if (isset($attributes['background_color']) && $attributes['background_color']) {
                     $attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>';
                 }
                 $anchors[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic');
             }
         }
         if (count($anchors)) {
             $suffix .= BR . sprintf(i18n::s('In %s'), implode(' / ', $anchors));
         }
         // end of details
         $suffix .= '</span>';
         // strip empty details
         $suffix = str_replace(BR . '<span class="details"></span>', '', $suffix);
         $suffix = str_replace('<span class="details"></span>', '', $suffix);
         // the icon to put in the left column
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         }
         // commands
         $commands = array(Skin::build_link(Articles::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic'), Skin::build_link(Articles::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic'));
         // link to this page
         $cells[] = $prefix . Skin::build_link($url, $title, 'article') . ' - ' . Skin::finalize_list($commands, 'menu') . $suffix;
         // ranking
         $cells[] = '<input type="text" size="5" name="article_rank_' . $item['id'] . '" value="' . $item['rank'] . '" onfocus="$(\'#article_selector_' . $count . '\').attr(\'checked\', \'checked\');" onchange="$(\'#act_on_articles\').prop(\'selectedIndex\', 9);" />';
         // append the row
         $text .= Skin::table_row($cells, $count++);
     }
     // select all rows
     $cells = array('<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />', i18n::s('Select all/none'), '');
     $text .= Skin::table_row($cells, $count++);
     // table suffix
     $text .= Skin::table_suffix();
     // end of processing
     SQL::free($result);
     return $text;
 }
Exemplo n.º 20
0
 /**
  * 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;
 }
Exemplo n.º 21
0
Arquivo: stage.php Projeto: rair/yacs
            }
            // errors have been encountered
            if ($errors) {
                $context['text'] .= i18n::s('Errors have been encountered, and you cannot proceed with the network update.') . "</p>\n";
                // forward to the index page
                $menu = array('scripts/' => i18n::s('Server software'));
                $context['text'] .= Skin::build_list($menu, 'menu_bar');
                // server is up to date
            } elseif (!$staging_files) {
                $context['text'] .= i18n::s('No file has been staged. Scripts on your server are exact copies of the reference set.') . "</p>\n";
                // forward to the index page
                $menu = array('scripts/' => i18n::s('Server software'));
                $context['text'] .= Skin::build_list($menu, 'menu_bar');
                // scripts are ready for update
            } else {
                $context['text'] .= sprintf(i18n::ns('%d file has been downloaded from the reference server.', '%d files have been downloaded from the reference server.', $staging_files), $staging_files) . "</p>\n";
                // forward to the update script
                $context['text'] .= '<form method="get" action="' . $context['url_to_root'] . 'scripts/update.php">' . "\n" . '<p>' . Skin::build_submit_button(i18n::s('Review staged scripts before the update')) . '</p>' . "\n" . '</form>' . "\n";
            }
        }
    }
    // ask for something to process, except on error
} elseif (!count($context['error'])) {
    // the splash message
    $context['text'] .= '<p>' . i18n::s('This script allows you to stage new scripts that will then be used to update your YACS server.') . "</p>\n";
    // warning if safe mode of limited time
    if (Safe::ini_get('safe_mode') || !is_callable('set_time_limit')) {
        Logger::error(sprintf(i18n::s('Extended processing time is not allowed on this server. In case of trouble, please upload individual files manually to the <code>scripts/staging</code> directory, using your preferred FTP tool or equivalent. When this is completed, jump to %s to complete the software update.'), Skin::build_link('scripts/update.php', i18n::s('the update script'), 'basic')));
    }
    // option #1 - in-band upload
    $context['text'] .= Skin::build_block(i18n::s('Direct upload'), 'title');
Exemplo n.º 22
0
 /**
  * list articles
  *
  * @param resource the SQL result
  * @return string
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // sanity check
     if (!isset($this->focus)) {
         $this->focus = NULL;
     }
     // process all items in the list
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     $odd = TRUE;
     while ($item = SQL::fetch($result)) {
         // get the related overlay
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // build a title
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // initialize variables
         $prefix = $suffix = $icon = '';
         // flag articles that are dead, or created or updated very recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG;
         }
         // signal articles to be published
         if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > $context['now']) {
             $prefix .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // some details
         $details = array();
         // info on related files --optional
         if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
         }
         // info on related comments --mandatory
         if ($count = Comments::count_for_anchor('article:' . $item['id'], FALSE)) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
         }
         // info on related links --optional
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // details
         if (count($details)) {
             $suffix .= ' <span class="details">(' . ucfirst(implode(', ', $details)) . ')</span>';
         }
         // flag popular pages
         if ($item['hits'] > 300) {
             $suffix .= POPULAR_FLAG;
         }
         // last contribution
         if ($item['edit_action']) {
             $action = Anchors::get_action_label($item['edit_action']) . ' ';
         } else {
             $action = i18n::s('edited');
         }
         if ($item['edit_name']) {
             $suffix .= '<br /><span class="details">' . sprintf(i18n::s('%s by %s %s'), $action, Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date'])) . '</span>';
         } else {
             $suffix .= '<br /><span class="details">' . $action . ' ' . Skin::build_date($item['edit_date']) . '</span>';
         }
         // flag articles updated recently
         if ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $suffix .= $overlay->get_text('list', $item, $this->focus);
         }
         // the hovering title
         if ($item['introduction'] && $context['skins_with_details'] == 'Y') {
             $hover = strip_tags(Codes::beautify_introduction($item['introduction']));
         } else {
             $hover = i18n::s('View the page');
         }
         // help members to reference this page
         if (Surfer::is_member()) {
             $hover .= ' [article=' . $item['id'] . ']';
         }
         // add an image if available
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } elseif (is_callable(array($anchor, 'get_bullet_url'))) {
             $icon = $anchor->get_bullet_url();
         }
         // format the image
         if ($icon) {
             $icon = Skin::build_link($url, '<img src="' . $icon . '" />', 'basic', $hover);
         }
         // list all components for this item
         if ($odd = !$odd) {
             $class = ' class="odd"';
         } else {
             $class = ' class="even"';
         }
         // use a table to layout the image properly
         if ($icon) {
             $text .= '<div' . $class . '><table class="decorated"><tr><td class="image" style="text-align: center">' . $icon . '</td><td class="content">' . $prefix . Skin::build_link($url, Skin::strip($title, 30), 'basic', $hover) . $suffix . '</td></tr></table></div>';
         } else {
             $text .= '<div' . $class . '>' . $prefix . Skin::build_link($url, Skin::strip($title, 30), 'basic', $hover) . $suffix . '</div>';
         }
     }
     // end of processing
     SQL::free($result);
     return $text;
 }
Exemplo n.º 23
0
/**
 * dynamically generate the page
 *
 * @see skins/index.php
 */
function send_body()
{
    global $context, $local;
    // $local is required to localize included scripts
    // include every script that has to be run once
    global $scripts, $scripts_count;
    if (@count($scripts)) {
        // the alphabetical order may be used to control script execution order
        sort($scripts);
        reset($scripts);
        // process each script one by one
        foreach ($scripts as $item) {
            // do not execute on first installation
            if (file_exists('../parameters/switch.on') || file_exists('../parameters/switch.off')) {
                // ensure we have a valid database resource
                if (!$context['connection']) {
                    break;
                }
                // remember this as an event
                Logger::remember('scripts/run_once.php: ' . sprintf(i18n::c('script %s has been executed'), $item));
                // where scripts actually are
                $actual_item = str_replace('//', '/', $context['path_to_root'] . 'scripts/run_once/' . $item);
                // include the script to execute it
                $scripts_count++;
                echo Skin::build_block($item, 'subtitle');
                include $actual_item;
                echo "\n";
            }
            // ensure enough overall execution time
            Safe::set_time_limit(30);
            // stamp the file to remember execution time
            Safe::touch($actual_item);
            // rename the script to avoid further execution
            Safe::unlink($actual_item . '.done');
            Safe::rename($actual_item, $actual_item . '.done');
        }
        // refresh javascript libraries
        Cache::purge('js');
    }
    // report on actual execution
    if ($scripts_count) {
        echo '<p>&nbsp;</p><p>' . sprintf(i18n::ns('%d script has been executed', '%d scripts have been executed', $scripts_count), $scripts_count) . "</p>\n";
    } else {
        echo '<p>' . i18n::s('No script has been executed') . "</p>\n";
    }
    // display the total execution time
    $time = round(get_micro_time() - $context['start_time'], 2);
    if ($time > 30) {
        echo '<p>' . sprintf(i18n::s('Script terminated in %.2f seconds.'), $time) . '</p>';
    }
    // if the server has been switched off, go back to the control panel
    if (file_exists('../parameters/switch.off')) {
        echo '<form method="get" action="' . $context['url_to_root'] . 'control/">' . "\n" . '<p class="assistant_bar">' . Skin::build_submit_button(i18n::s('Control Panel')) . '</p>' . "\n" . '</form>' . "\n";
        // else back to the control panel as well, but without a button
    } else {
        $menu = array('control/' => i18n::s('Control Panel'));
        echo Skin::build_list($menu, 'menu_bar');
    }
    // purge the cache, since it is likely that we have modified some data
    Cache::clear();
}
Exemplo n.º 24
0
Arquivo: index.php Projeto: rair/yacs
if (isset($_REQUEST['page'])) {
    $page = $_REQUEST['page'];
} elseif (isset($context['arguments'][0])) {
    $page = $context['arguments'][0];
} else {
    $page = 1;
}
$page = max(1, intval($page));
// load the skin
load_skin('comments');
// the title of the page
$context['page_title'] = i18n::s('Threads');
// count comments in the database
$stats = Comments::stat_threads();
if ($stats['count']) {
    $context['page_menu'] += array('_count' => sprintf(i18n::ns('%d thread', '%d threads', $stats['count']), $stats['count']));
}
// stop hackers
if ($page > 1 && ($page - 1) * THREADS_PER_PAGE > $stats['count']) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    Logger::error(i18n::s('You are not allowed to perform this operation.'));
} else {
    // navigation commands for comments, if necessary
    if ($stats['count'] > THREADS_PER_PAGE) {
        $home = 'comments/';
        if ($context['with_friendly_urls'] == 'Y') {
            $prefix = $home . 'index.php/';
        } elseif ($context['with_friendly_urls'] == 'R') {
            $prefix = $home;
        } else {
            $prefix = $home . '?page=';
Exemplo n.º 25
0
 /**
  * list categories
  *
  * @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 an array of ($url => $attributes)
     $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';
     while ($item = SQL::fetch($result)) {
         // url to read the full category
         $url = Categories::get_permalink($item);
         // initialize variables
         $prefix = $suffix = $icon = '';
         // flag categories that are dead, or created or updated very recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         // signal restricted and private categories
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // introduction
         if ($item['introduction']) {
             $suffix .= ' ' . Codes::beautify(trim($item['introduction']));
         }
         // details
         $details = array();
         // count related sub-elements
         $related_count = 0;
         // info on related categories
         $stats = Categories::stat_for_anchor('category:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d category', '%d categories', $stats['count']), $stats['count']);
         }
         $related_count += $stats['count'];
         // info on related sections
         if ($count = Members::count_sections_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
             $related_count += $count;
         }
         // info on related articles
         if ($count = Members::count_articles_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
             $related_count += $count;
         }
         // info on related files
         if ($count = Files::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
             $related_count += $count;
         }
         // info on related links
         if ($count = Links::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
             $related_count += $count;
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
             $related_count += $stats['count'];
         }
         // info on related users
         if ($count = Members::count_users_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d user', '%d users', $count), $count);
         }
         // append details to the suffix
         if (count($details)) {
             $suffix .= "\n" . '<span class="details">(' . implode(', ', $details) . ')</span>';
         }
         // add a head list of related links
         $details = array();
         // add sub-categories on index pages
         if ($related = Categories::list_by_date_for_anchor('category:' . $item['id'], 0, YAHOO_LIST_SIZE, '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];
                 }
                 $details[] = $sub_prefix . Skin::build_link($sub_url, $label, 'basic', $sub_hover) . $sub_suffix;
             }
         }
         // add related sections if necessary
         if (count($details) < YAHOO_LIST_SIZE && ($related =& Members::list_sections_by_title_for_anchor('category:' . $item['id'], 0, YAHOO_LIST_SIZE - count($details), '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];
                 }
                 $details[] = $sub_prefix . Skin::build_link($sub_url, $label, 'basic', $sub_hover) . $sub_suffix;
             }
         }
         // add related articles if necessary
         if (count($details) < YAHOO_LIST_SIZE && ($related =& Members::list_articles_by_date_for_anchor('category:' . $item['id'], 0, YAHOO_LIST_SIZE - count($details), '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];
                 }
                 $details[] = $sub_prefix . Skin::build_link($sub_url, $label, 'basic', $sub_hover) . $sub_suffix;
             }
         }
         // give me more
         if (count($details) && $related_count > YAHOO_LIST_SIZE) {
             $details[] = Skin::build_link(Categories::get_permalink($item), i18n::s('More') . MORE_IMG, 'more', i18n::s('View the category'));
         }
         // layout details
         if (count($details)) {
             $suffix .= BR . "\n&raquo;&nbsp;" . '<span class="details">' . implode(', ', $details) . "</span>\n";
         }
         // put the actual icon in the left column
         if (isset($item['thumbnail_url'])) {
             $icon = $item['thumbnail_url'];
         }
         // use the title to label the link
         $label = Skin::strip($item['title'], 50);
         // some hovering title for this category
         $hover = i18n::s('View the category');
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'category', $icon, $hover);
     }
     // end of processing
     SQL::free($result);
     $output = Skin::build_list($items, '2-columns');
     return $output;
 }
 /**
  * layout the newest articles
  *
  * caution: this function also updates page title directly, and this makes its call non-cacheable
  *
  * @param array the article
  * @return string the rendered text
  **/
 function layout_newest($item)
 {
     global $context;
     // get the related overlay, if any
     $overlay = Overlay::load($item, 'article:' . $item['id']);
     // get the anchor
     $anchor = Anchors::get($item['anchor']);
     // the url to view this item
     $url = Articles::get_permalink($item);
     // reset the rendering engine between items
     Codes::initialize($url);
     // build a title
     if (is_object($overlay)) {
         $title = Codes::beautify_title($overlay->get_text('title', $item));
     } else {
         $title = Codes::beautify_title($item['title']);
     }
     // title prefix & suffix
     $text = $prefix = $suffix = '';
     // flag articles updated recently
     if ($context['site_revisit_after'] < 1) {
         $context['site_revisit_after'] = 2;
     }
     $context['fresh'] = gmstrftime('%Y-%m-%d %H:%M:%S', mktime(0, 0, 0, date("m"), date("d") - $context['site_revisit_after'], date("Y")));
     // link to permalink
     if (Surfer::is_empowered()) {
         $title = Skin::build_box_title($title, $url, i18n::s('Permalink'));
     }
     // signal articles to be published
     if ($item['publish_date'] <= NULL_DATE) {
         $prefix .= DRAFT_FLAG;
     } else {
         if ($item['publish_date'] > NULL_DATE && $item['publish_date'] > $context['now']) {
             $prefix .= DRAFT_FLAG;
         }
     }
     // signal restricted and private articles
     if ($item['active'] == 'N') {
         $prefix .= PRIVATE_FLAG . ' ';
     } elseif ($item['active'] == 'R') {
         $prefix .= RESTRICTED_FLAG . ' ';
     }
     // signal locked articles
     if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
         $suffix .= LOCKED_FLAG;
     }
     // flag expired article
     if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
         $suffix .= EXPIRED_FLAG;
     }
     // update page title directly
     $text .= Skin::build_block($prefix . $title . $suffix, 'title');
     // if this article has a specific icon, use it
     if ($item['icon_url']) {
         $icon = $item['icon_url'];
     } elseif ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
         $icon = $anchor->get_icon_url();
     }
     // if we have a valid image
     if (preg_match('/(.gif|.jpg|.jpeg|.png)$/i', $icon)) {
         // fix relative path
         if (!preg_match('/^(\\/|http:|https:|ftp:)/', $icon)) {
             $icon = $context['url_to_root'] . $icon;
         }
         // flush the image on the right
         $text .= '<img src="' . $icon . '" class="right_image" alt="" />';
     }
     // article rating, if the anchor allows for it
     if (!is_object($anchor) || !$anchor->has_option('without_rating')) {
         // report on current rating
         $label = '';
         if ($item['rating_count']) {
             $label = Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])) . ' ';
         }
         $label .= i18n::s('Rate this page');
         // allow for rating
         $text .= Skin::build_link(Articles::get_url($item['id'], 'like'), $label, 'basic');
     }
     // the introduction text, if any
     if (is_object($overlay)) {
         $text .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
     } else {
         $text .= Skin::build_block($item['introduction'], 'introduction');
     }
     // insert overlay data, if any
     if (is_object($overlay)) {
         $text .= $overlay->get_text('view', $item);
     }
     // the beautified description, which is the actual page body
     if ($item['description']) {
         // use adequate label
         if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
             $text .= Skin::build_block($label, 'title');
         }
         $text .= Skin::build_block($item['description'], 'description', '', $item['options']);
     }
     //
     // list related files
     //
     // if this surfer is an editor of this article, show hidden files as well
     if (Articles::is_assigned($item['id']) || is_object($anchor) && $anchor->is_assigned()) {
         Surfer::empower();
     }
     // build a complete box
     $box['bar'] = array();
     $box['text'] = '';
     // count the number of files in this article
     if ($count = Files::count_for_anchor('article:' . $item['id'])) {
         if ($count > 20) {
             $box['bar'] += array('_count' => sprintf(i18n::ns('%d file', '%d files', $count), $count));
         }
         // list files by date (default) or by title (option files_by_title)
         if (Articles::has_option('files_by', $anchor, $item) == 'title') {
             $items = Files::list_by_title_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'article:' . $item['id']);
         } else {
             $items = Files::list_by_date_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'article:' . $item['id']);
         }
         if (is_array($items)) {
             $box['text'] .= Skin::build_list($items, 'decorated');
         }
         // navigation commands for files
         $prefix = Articles::get_url($item['id'], 'navigate', 'files');
         $box['bar'] += Skin::navigate($url, $prefix, $count, FILES_PER_PAGE, 0);
         // the command to post a new file, if allowed
         if (Files::allow_creation($item, $anchor, 'article')) {
             $link = 'files/edit.php?anchor=' . urlencode('article:' . $item['id']);
             $box['bar'] += array($link => i18n::s('Add a file'));
         }
         if (is_array($box['bar'])) {
             $box['text'] .= Skin::build_list($box['bar'], 'menu_bar');
         }
     }
     // actually render the html for this box
     if ($box['text']) {
         $text .= Skin::build_box(i18n::s('Files'), $box['text'], 'header1', 'files');
     }
     //
     // bottom page menu
     //
     // discuss this page, if the index page can be commented, and comments are accepted at the article level
     if (Comments::allow_creation($item, $anchor)) {
         $this->menu[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Post a comment'), 'span');
     }
     // info on related comments
     if ($count = Comments::count_for_anchor('article:' . $item['id'])) {
         $this->menu[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'span');
     }
     // new links are accepted at the index page and at the article level
     if (Links::allow_trackback()) {
         $this->menu[] = Skin::build_link('links/trackback.php?anchor=' . urlencode('article:' . $item['id']), i18n::s('Reference this page'), 'span');
     }
     // info on related links
     if ($count = Links::count_for_anchor('article:' . $item['id'])) {
         $this->menu[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'span');
     }
     // new files are accepted at the index page and at the article level
     if (is_object($anchor) && $anchor->has_option('with_files') && !($anchor->has_option('no_files') || preg_match('/\\bno_files\\b/i', $item['options']))) {
         // add a file
         if (Files::allow_creation($item, $anchor, 'article')) {
             if ($context['with_friendly_urls'] == 'Y') {
                 $link = 'files/edit.php/article/' . $item['id'];
             } else {
                 $link = 'files/edit.php?anchor=' . urlencode('article:' . $item['id']);
             }
             $this->menu[] = Skin::build_link($link, i18n::s('Add a file'), 'span');
         }
     }
     // modify this page
     if (Surfer::is_empowered()) {
         $this->menu[] = Skin::build_link(Articles::get_url($item['id'], 'edit'), i18n::s('Edit'), 'span');
     }
     // view permalink
     if (Surfer::is_empowered()) {
         $this->menu[] = Skin::build_link($url, i18n::s('Permalink'), 'span');
     }
     // insert overlay data, if any
     if (is_object($overlay)) {
         $text .= $overlay->get_text('trailer', $item);
     }
     // add trailer information from this item, if any
     if (isset($item['trailer']) && trim($item['trailer'])) {
         $text .= Codes::beautify($item['trailer']);
     }
     // returned the formatted content
     return $text;
 }
Exemplo n.º 27
0
Arquivo: select.php Projeto: rair/yacs
 $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
 if (is_object($parent)) {
     $details[] = sprintf(i18n::s('in %s'), Skin::build_link($parent->get_url(), ucfirst($parent->get_title()), 'section'));
 }
 // combine in-line details
 if (count($details)) {
     $suffix .= ' - <span class="details">' . trim(implode(', ', $details)) . '</span>';
 }
 // surfer cannot be deselected
 if (!strcmp($anchor->get_reference(), 'user:'******'owner_id'])) {
     $suffix .= ' - <span class="details">' . i18n::s('owner') . '</span>';
 } elseif (Surfer::is_associate()) {
     $link = $context['script_url'] . '?anchor=' . urlencode($anchor->get_reference()) . '&amp;member=section:' . $section['id'] . '&amp;action=reset';
     $suffix .= ' - <span class="details">' . Skin::build_link($link, i18n::s('unassign'), 'basic') . '</span>';
Exemplo n.º 28
0
Arquivo: page.php Projeto: rair/yacs
 /**
  * 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;
 }
Exemplo n.º 29
0
 /**
  * layout one recent article
  *
  * @param array the article
  * @return an array ($prefix, $label, $suffix)
  **/
 function layout_recent($item)
 {
     global $context;
     // permalink
     $url = Articles::get_permalink($item);
     // get the related overlay, if any
     $overlay = Overlay::load($item, 'article:' . $item['id']);
     // get the anchor
     $anchor = Anchors::get($item['anchor']);
     // use the title to label the link
     if (is_object($overlay)) {
         $title = Codes::beautify_title($overlay->get_text('title', $item));
     } else {
         $title = Codes::beautify_title($item['title']);
     }
     // reset everything
     $prefix = $suffix = '';
     // signal restricted and private articles
     if ($item['active'] == 'N') {
         $prefix .= PRIVATE_FLAG;
     } elseif ($item['active'] == 'R') {
         $prefix .= RESTRICTED_FLAG;
     }
     // rating
     if ($item['rating_count']) {
         $suffix .= Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
     }
     // the introductory text
     $introduction = '';
     if (is_object($overlay)) {
         $introduction = $overlay->get_text('introduction', $item);
     } elseif ($item['introduction']) {
         $introduction = $item['introduction'];
     }
     if ($introduction) {
         $suffix .= ' -&nbsp;' . Codes::beautify_introduction($introduction);
     }
     // other details
     $details = array();
     // the author
     $author = '';
     if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
         $author = sprintf(i18n::s('by %s'), $item['create_name']) . ' ';
     }
     // date
     $details[] = $author . Skin::build_date($item['publish_date']);
     // info on related files
     if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
         $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'basic');
     }
     // info on related comments
     $link = Comments::get_url('article:' . $item['id'], 'list');
     if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
         $details[] = Skin::build_link($link, sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'basic');
     }
     // discuss
     if (Comments::allow_creation($item, $anchor)) {
         $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Discuss'), 'basic');
     }
     // info on related links
     if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
         $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'basic');
     }
     // append a menu
     $suffix .= Skin::finalize_list($details, 'menu');
     // display all tags
     if ($item['tags']) {
         $suffix .= ' <p class="tags" style="margin-top: 3px;">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</p>';
     }
     // insert an array of links
     return array($prefix, $title, $suffix);
 }
Exemplo n.º 30
0
 /**
  * list categories
  *
  * @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 an array of ($url => $attributes)
     $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';
     while ($item = SQL::fetch($result)) {
         // url to read the full category
         $url = Categories::get_permalink($item);
         // initialize variables
         $prefix = $suffix = $icon = '';
         // flag categories that are dead, or created or updated very recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $prefix .= EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         // signal restricted and private categories
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // use the title to label the link
         $label = Skin::strip($item['title'], 10);
         // details
         $details = array();
         // info on related categories
         $stats = Categories::stat_for_anchor('category:' . $item['id']);
         if ($stats['count']) {
             $details[] = sprintf(i18n::ns('%d category', '%d categories', $stats['count']), $stats['count']);
         }
         // info on related sections
         if ($count = Members::count_sections_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count);
         }
         // info on related articles
         if ($count = Members::count_articles_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count);
         }
         // info on related files
         if ($count = Files::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
         }
         // info on related links
         if ($count = Links::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count);
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('category:' . $item['id'], TRUE)) {
             $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
         }
         // info on related users
         if ($count = Members::count_users_for_anchor('category:' . $item['id'])) {
             $details[] = sprintf(i18n::ns('%d user', '%d users', $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(trim($item['introduction']));
         }
         // put the actual icon in the left column
         if (isset($item['thumbnail_url']) && $this->layout_variant != 'sidebar') {
             $icon = $item['thumbnail_url'];
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'category', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }