Example #1
0
 /**
  * list servers
  *
  * @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
     while ($item = SQL::fetch($result)) {
         // initialize variables
         $prefix = $suffix = $icon = '';
         // the url to view this item
         $url = Servers::get_url($item['id']);
         // use the title as a label
         $label = Skin::strip($item['title'], 10);
         // flag files uploaded recently
         if ($item['edit_date'] >= $context['fresh']) {
             $prefix = NEW_FLAG . $prefix;
         }
         // description
         if ($item['description']) {
             $suffix .= ' ' . ucfirst(trim($item['description']));
         }
         // the menu bar for associates and poster
         if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
             $menu = array(Servers::get_url($item['id'], 'edit') => i18n::s('Edit'), Servers::get_url($item['id'], 'delete') => i18n::s('Delete'));
             $suffix .= ' ' . Skin::build_list($menu, 'menu');
         }
         // add a separator
         if ($suffix) {
             $suffix = ' - ' . $suffix;
         }
         // append details to the suffix
         $suffix .= BR . '<span class="details">';
         // details
         $details = array();
         // item poster
         if ($item['edit_name']) {
             $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
         }
         // the edition date
         $details[] = Skin::build_date($item['edit_date']);
         // all details
         if (count($details)) {
             $suffix .= ucfirst(implode(', ', $details)) . "\n";
         }
         // end of details
         $suffix .= '</span>';
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'server', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #2
0
 /**
  * list comments as successive notes in a thread
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // we return formatted text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // build a list of comments
     while ($item = SQL::fetch($result)) {
         // automatic notification
         if ($item['type'] == 'notification') {
             $text = '<dd class="thread_other" style="font-style: italic;">' . ucfirst(trim($item['description'])) . '</dd>' . $text;
         } else {
             // link to user profile -- open links in separate window to enable side browsing of participant profiles
             if ($item['create_id']) {
                 if ($user = Users::get($item['create_id']) && $user['full_name']) {
                     $hover = $user['full_name'];
                 } else {
                     $hover = NULL;
                 }
                 $author = Users::get_link($item['create_name'], $item['create_address'], $item['create_id'], TRUE, $hover);
             } else {
                 $author = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id'], TRUE);
             }
             // differentiate my posts from others
             if (Surfer::get_id() && $item['create_id'] == Surfer::get_id()) {
                 $style = ' class="thread_me"';
             } else {
                 $style = ' class="thread_other"';
             }
             // a clickable label
             $stamp = '#';
             // flag old items on same day
             if (!strncmp($item['edit_date'], gmstrftime('%Y-%m-%d %H:%M:%S', time()), 10)) {
                 $stamp = Skin::build_time($item['edit_date']);
             } else {
                 $stamp = Skin::build_date($item['edit_date']);
             }
             // append this at the end of the comment
             $stamp = ' <div style="float: right; font-size: x-small">' . Skin::build_link(Comments::get_url($item['id']), $stamp, 'basic', i18n::s('Edit')) . '</div>';
             // package everything --change order to get oldest first
             $text = '<dt' . $style . '>' . $author . '</dt><dd' . $style . '>' . $stamp . ucfirst(trim($item['description'])) . '</dd>' . $text;
         }
     }
     // end of processing
     SQL::free($result);
     // finalize the returned definition list
     if ($text) {
         $text = '<dl>' . $text . '</dl>';
     }
     // process yacs codes
     $text = Codes::beautify($text);
     return $text;
 }
Example #3
0
 /**
  * list files
  *
  * @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
     while ($item = SQL::fetch($result)) {
         // download the file directly
         $url = Files::get_url($item['id'], 'fetch', $item['file_name']);
         // file title or file name
         $label = Codes::beautify_title($item['title']);
         if (!$label) {
             $label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name']));
         }
         // initialize variables
         $prefix = $suffix = '';
         $contributor = Users::get_link($item['create_name'], $item['create_address'], $item['create_id']);
         $flag = '';
         if ($item['create_date'] >= $context['fresh']) {
             $flag = NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $flag = UPDATED_FLAG;
         }
         $suffix .= '<span class="details"> - ' . sprintf(i18n::s('By %s'), $contributor) . ' ' . Skin::build_date($item['create_date']) . $flag . '</span>';
         // signal restricted and private files
         if ($item['active'] == 'N' && defined('PRIVATE_FLAG')) {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R' && defined('RESTRICTED_FLAG')) {
             $prefix .= RESTRICTED_FLAG;
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'file', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #4
0
 /**
  * list comments
  *
  * @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;
     }
     // sanity check
     if (!isset($this->layout_variant)) {
         $this->layout_variant = 'full';
     }
     // we return an array of ($url => $attributes)
     $items = array();
     // process all items in the list
     include_once $context['path_to_root'] . 'comments/comments.php';
     while ($item = SQL::fetch($result)) {
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // initialize variables
         $prefix = $suffix = '';
         // there is no zoom page for comments
         $label = '_';
         // the icon is a link to comment permalink
         $suffix .= Skin::build_link(Comments::get_url($item['id']), Comments::get_img($item['type']), 'basic', i18n::s('View this comment'));
         // a link to the user profile
         if ($item['create_name']) {
             $suffix .= ' ' . Users::get_link($item['create_name'], $item['create_address'], $item['create_id']);
         } else {
             $suffix .= ' ' . Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']);
         }
         $menu = array();
         // the edition date
         if ($item['create_date']) {
             $menu[] = Skin::build_date($item['create_date']);
         } else {
             $menu[] = Skin::build_date($item['edit_date']);
         }
         // the menu bar for associates, editors and poster
         if (Comments::allow_modification($anchor, $item)) {
             $menu[] = Skin::build_link(Comments::get_url($item['id'], 'edit'), i18n::s('edit'), 'span');
             $menu[] = Skin::build_link(Comments::get_url($item['id'], 'delete'), i18n::s('delete'), 'span');
         }
         if ($menu) {
             $suffix .= ' -' . Skin::finalize_list($menu, 'menu');
         }
         // new line
         $suffix .= BR;
         // description
         if ($description = ucfirst(trim(Codes::beautify($item['description'] . Users::get_signature($item['create_id']))))) {
             $suffix .= ' ' . $description;
         }
         // url to view the comment
         $url = Comments::get_url($item['id']);
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'comment', NULL);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
 /**
  * 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;
 }
Example #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;
 }
Example #7
0
 /**
  * list files
  *
  * Recognize following variants:
  * - 'section:123' to list items attached to one particular anchor
  * - 'no_author' to list items attached to one user profile
  *
  * @param resource the SQL result
  * @return string HTML text to be displayed, or NULL
  *
  * @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 = '';
     }
     // process all items in the list
     $items = array();
     while ($item = SQL::fetch($result)) {
         // one box at a time
         $box = '';
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // we feature only the head of the list, if we are at the origin page
         if (!count($items) && $anchor && is_string($this->focus) && $this->focus == $anchor->get_reference()) {
             $box .= Codes::render_object('file', $item['id']);
             // no side icon
             $icon = '';
             // we are listing various files from various places
         } else {
             $prefix = $suffix = '';
             // stream the file
             if (Files::is_stream($item['file_name'])) {
                 $url = Files::get_url($item['id'], 'stream', $item['file_name']);
             } else {
                 $url = Files::get_url($item['id'], 'fetch', $item['file_name']);
             }
             // absolute url
             $url = $context['url_to_home'] . $context['url_to_root'] . $url;
             // signal restricted and private files
             if ($item['active'] == 'N') {
                 $prefix .= PRIVATE_FLAG;
             } elseif ($item['active'] == 'R') {
                 $prefix .= RESTRICTED_FLAG;
             }
             // file title or file name
             $label = Codes::beautify_title($item['title']);
             if (!$label) {
                 $label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name']));
             }
             // show a reference to the file for members
             $hover = i18n::s('Get the file');
             if (Surfer::is_member()) {
                 $hover .= ' [file=' . $item['id'] . ']';
             }
             // flag files uploaded recently
             if ($item['create_date'] >= $context['fresh']) {
                 $suffix .= NEW_FLAG;
             } elseif ($item['edit_date'] >= $context['fresh']) {
                 $suffix .= UPDATED_FLAG;
             }
             // one line of text
             $box .= $prefix . Skin::build_link($url, $label, 'basic', $hover) . $suffix;
             // side icon
             if ($item['thumbnail_url']) {
                 $icon = $item['thumbnail_url'];
             } else {
                 $icon = $context['url_to_root'] . Files::get_icon_url($item['file_name']);
             }
             // build the complete HTML element
             $icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($label)) . '" />';
             // make it a clickable link
             $icon = Skin::build_link($url, $icon, 'basic');
         }
         // first line of details
         $details = array();
         // file poster and last action
         if ($this->layout_variant != 'no_author') {
             $details[] = sprintf(i18n::s('shared by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
         } else {
             $details[] = Skin::build_date($item['edit_date']);
         }
         // downloads
         if ($item['hits'] > 1) {
             $details[] = Skin::build_number($item['hits'], i18n::s('downloads'));
         }
         // file size
         if ($item['file_size'] > 1) {
             $details[] = Skin::build_number($item['file_size'], i18n::s('bytes'));
         }
         // anchor link
         if ($anchor && is_string($this->focus) && $this->focus != $anchor->get_reference()) {
             $anchor_url = $anchor->get_url();
             $anchor_label = ucfirst($anchor->get_title());
             $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor_url, $anchor_label, 'article'));
         }
         $box .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>';
         // append details
         $details = array();
         // view the file
         $details[] = Skin::build_link(Files::get_permalink($item), i18n::s('details'), 'basic');
         // file has been detached
         if (isset($item['assign_id']) && $item['assign_id']) {
             // who has been assigned?
             if (Surfer::is($item['assign_id'])) {
                 $details[] = DRAFT_FLAG . sprintf(i18n::s('reserved by you %s'), Skin::build_date($item['assign_date']));
             } else {
                 $details[] = DRAFT_FLAG . sprintf(i18n::s('reserved by %s %s'), Users::get_link($item['assign_name'], $item['assign_address'], $item['assign_id']), Skin::build_date($item['assign_date']));
             }
         }
         // detach or edit the file
         if (Files::allow_modification($item, $anchor)) {
             if (!isset($item['assign_id']) || !$item['assign_id']) {
                 $details[] = Skin::build_link(Files::get_url($item['id'], 'reserve'), i18n::s('reserve'), 'basic', i18n::s('Prevent other persons from changing this file until you update it'));
             }
             // release reservation
             if (isset($item['assign_id']) && $item['assign_id'] && (Surfer::is($item['assign_id']) || is_object($anchor) && $anchor->is_owned())) {
                 $details[] = Skin::build_link(Files::get_url($item['id'], 'release'), i18n::s('release reservation'), 'basic', i18n::s('Allow other persons to update this file'));
             }
             if (!isset($item['assign_id']) || !$item['assign_id'] || Surfer::is($item['assign_id']) || is_object($anchor) && $anchor->is_owned()) {
                 $details[] = Skin::build_link(Files::get_url($item['id'], 'edit'), i18n::s('update'), 'basic', i18n::s('Share a new version of this file, or change details'));
             }
         }
         // delete the file
         if (Files::allow_deletion($item, $anchor)) {
             $details[] = Skin::build_link(Files::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic');
         }
         // append details
         if (count($details)) {
             $box .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>';
         }
         // insert item icon
         if ($icon) {
             $list = array(array($box, $icon));
             $items[] = Skin::finalize_list($list, 'decorated');
             // put the item in a division
         } else {
             $items[] = '<div style="margin: 0 0 1em 0">' . $box . '</div>';
         }
     }
     // stack all items in a single column
     $text = Skin::finalize_list($items, 'rows');
     // end of processing
     SQL::free($result);
     return $text;
 }
Example #8
0
 if ($text) {
     $panels[] = array('resources', i18n::s('Resources'), 'resources_panel', $text);
 }
 //
 // options tab is visible only to site associates
 //
 if (Surfer::is_associate()) {
     $text = '';
     // provide information to section owner
     if (isset($item['id'])) {
         // owner
         $label = i18n::s('Owner');
         $input = '';
         if (isset($item['owner_id'])) {
             if ($owner = Users::get($item['owner_id'])) {
                 $input = Users::get_link($owner['full_name'], $owner['email'], $owner['id']);
             } else {
                 $input = i18n::s('No owner has been found.');
             }
         }
         // change the owner
         if (Articles::is_owned($item, $anchor) || Surfer::is_associate()) {
             $input .= ' <span class="details">' . Skin::build_link(Articles::get_url($item['id'], 'own'), i18n::s('Change'), 'button') . '</span>';
         }
         $fields[] = array($label, $input);
     }
     // the active flag: Yes/public, Restricted/logged, No/associates --we don't care about inheritance, to enable security changes afterwards
     if ($cur_article->is_owned() || Surfer::is_associate()) {
         $label = i18n::s('Access');
         $input = Skin::build_active_set_input($item);
         $hint = Skin::build_active_set_hint($anchor);
Example #9
0
File: fetch.php Project: rair/yacs
    $context['page_title'] = sprintf(i18n::s('%s: %s'), i18n::s('Reserve'), $context['page_title']);
    // assign the file to this surfer
    $user = array('nick_name' => Surfer::get_name(), 'id' => Surfer::get_id(), 'email' => Surfer::get_email_address());
    if (Files::assign($item['id'], $user)) {
        // inform surfer
        $context['text'] .= '<p>' . sprintf(i18n::s('You have reserved this file, and you are encouraged to %s as soon as possible, or to %s.'), Skin::build_link(Files::get_url($item['id'], 'edit'), i18n::s('upload an updated version'), 'basic'), Skin::build_link(Files::get_url($item['id'], 'fetch', 'release'), i18n::s('release reservation'), 'basic')) . '</p>';
        // help the surfer
    } else {
        Logger::error(i18n::s('Operation has failed.'));
    }
    // follow-up commands
    $context['text'] .= Skin::build_block(Skin::build_link($anchor->get_url('files'), i18n::s('Done'), 'button'), 'bottom');
    // file has been reserved, and surfer is not owner
} elseif ($action != 'confirm' && isset($item['assign_id']) && $item['assign_id'] && !Surfer::is($item['assign_id'])) {
    // inform surfer
    $context['text'] .= Skin::build_block(sprintf(i18n::s('This file has been assigned to %s %s, and it is likely that an updated version will be made available soon.'), Users::get_link($item['assign_name'], $item['assign_address'], $item['assign_id']), Skin::build_date($item['assign_date'])), 'caution');
    // commands
    $menu = array();
    $menu[] = Skin::build_submit_button(i18n::s('Download this file'), NULL, NULL, 'confirmed', 'no_spin_on_click');
    $menu[] = Skin::build_link($anchor->get_url('files'), i18n::s('Cancel'), 'span');
    // to get the actual file
    $target_href = $context['url_to_home'] . $context['url_to_root'] . Files::get_url($item['id'], 'fetch', $item['file_name']);
    // render commands
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><div>' . "\n" . Skin::finalize_list($menu, 'assistant_bar') . '<input type="hidden" name="id" value="' . $item['id'] . '" />' . "\n" . '<input type="hidden" name="action" value="confirm" />' . "\n" . '</div></form>' . "\n";
    // set the focus
    Page::insert_script('$("#confirmed").focus();');
    //actual transfer
} elseif ($item['id'] && $item['anchor']) {
    // increment the count of downloads
    if (!Surfer::is_crawler()) {
        Files::increment_hits($item['id']);
Example #10
0
File: surfer.php Project: rair/yacs
 /**
  * build a pretty link to the profile page of this surfer
  *
  * This function is a proxy for Users::get_link(), limited to current surfer.
  *
  * @return string some text describing this surfer, with a link to get more information
  *
  * @see users/users.php
  */
 public static function get_link()
 {
     global $context;
     return Users::get_link(Surfer::get_name(), Surfer::get_email_address(), Surfer::get_id());
 }
Example #11
0
File: edit.php Project: rair/yacs
}
// display the form
if ($with_form) {
    // reference the anchor page
    if (is_object($anchor) && $anchor->is_viewable()) {
        $context['text'] .= '<p>' . sprintf(i18n::s('In: %s'), Skin::build_link($anchor->get_url(), $anchor->get_title())) . "</p>\n";
    }
    // the form to edit an table
    $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" onsubmit="return validateDocumentPost(this)" id="main_form"><div>';
    // encode fields
    $fields = array();
    // display info on current version
    if (isset($item['id'])) {
        // the last poster
        if (isset($item['edit_id'])) {
            $text = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']) . ' ' . Skin::build_date($item['edit_date']);
            $fields[] = array(i18n::s('Posted by'), $text);
        }
    }
    // the title
    $label = i18n::s('Title');
    $input = '<textarea name="title" id="title" rows="2" cols="50">' . encode_field(isset($item['title']) ? $item['title'] : '') . '</textarea>';
    $hint = i18n::s('Please provide a meaningful title.');
    $fields[] = array($label, $input, $hint);
    // the query
    $label = i18n::s('SQL Query');
    $input = '<textarea name="query" rows="15" cols="50">' . encode_field(isset($item['query']) ? $item['query'] : '') . '</textarea>';
    $hint = i18n::s('The SELECT command submitted to the database');
    $fields[] = array($label, $input, $hint);
    // is the first row an url to the zoom page?
    $label = i18n::s('First column');
Example #12
0
File: event.php Project: rair/yacs
 /**
  * display the content of one instance
  *
  * @see overlays/overlay.php
  *
  * @param array the hosting record
  * @return some HTML to be inserted into the resulting page
  */
 function &get_view_text($host = NULL)
 {
     global $context;
     // we may look at enrolments
     include_once $context['path_to_root'] . 'shared/enrolments.php';
     // minutes to go
     if (isset($this->attributes['date_stamp']) && $this->attributes['date_stamp'] > NULL_DATE) {
         $this->minutes_before_start = (sql::strtotime($this->attributes['date_stamp']) - time()) / 60;
     } else {
         $this->minutes_before_start = 120;
     }
     // prevent automatic start
     // minutes since the end of the event
     if (isset($this->attributes['duration']) && $this->attributes['duration']) {
         $this->minutes_since_stop = -($this->attributes['duration'] + $this->minutes_before_start);
     } else {
         $this->minutes_since_stop = -120;
     }
     // prevent automatic stop
     // tabular information
     $rows = array();
     // initialize feed-back to end-user
     $this->feed_back = array('message' => '', 'status' => array(), 'menu' => array(), 'commands' => array(), 'reload_this_page' => FALSE);
     // maybe a bare instance
     if (!isset($this->attributes['status'])) {
         $this->attributes['status'] = 'created';
     }
     // step 5 - end of the event
     if ($this->attributes['status'] == 'stopped') {
         // list enrolment for this meeting
         $query = "SELECT * FROM " . SQL::table_name('enrolments') . " WHERE anchor LIKE '" . SQL::escape($this->anchor->get_reference()) . "'";
         if ($result = SQL::query($query)) {
             // browse the list
             $items = array();
             while ($item = SQL::fetch($result)) {
                 // a user registered on this server
                 if ($item['user_id'] && ($user = Users::get($item['user_id']))) {
                     // make an url
                     $url = Users::get_permalink($user);
                     // gather information on this user
                     if (isset($user['full_name']) && $user['full_name']) {
                         $label = $user['full_name'] . ' (' . $user['nick_name'] . ')';
                     } else {
                         $label = $user['nick_name'];
                     }
                     $items[] = Skin::build_link($url, $label, 'user');
                     // we only have some e-mail address
                 } else {
                     $items[] = $item['user_email'];
                 }
             }
             // shape a compact list
             if (count($items)) {
                 $this->feed_back['status'][] = Skin::build_folded_box(i18n::s('Enrolment') . ' (' . count($items) . ')', Skin::finalize_list($items, 'compact'));
             }
         }
         // signal that the event is over
         $this->feed_back['status'][] = i18n::s('Event is over');
         // display the follow-up message
         if (isset($this->attributes['follow_up_message']) && $this->attributes['follow_up_message']) {
             $this->feed_back['message'] .= Codes::render($this->attributes['follow_up_message']);
         }
         // possible transition to state 'stopped'
     } else {
         $this->transition_to_stopped();
     }
     // step 4 - event has started
     if ($this->attributes['status'] == 'started') {
         // display the welcome message
         if (isset($this->attributes['welcome_message'])) {
             $this->feed_back['message'] .= Codes::render($this->attributes['welcome_message']);
         }
         // possible transition to state 'started'
     } else {
         $this->transition_to_started();
     }
     // step 3 - waiting for event start
     if ($this->attributes['status'] == 'lobby') {
         // display the lobby message
         if (isset($this->attributes['lobby_message'])) {
             $this->feed_back['message'] .= Codes::render($this->attributes['lobby_message']);
         }
         // possible transition to state 'lobby'
     } else {
         $this->transition_to_lobby();
     }
     // step 2 - enrolment has been opened
     if ($this->attributes['status'] == 'open') {
         // display the induction message
         if (isset($this->attributes['induction_message'])) {
             $this->feed_back['message'] .= Codes::render($this->attributes['induction_message']);
         }
         // possible transition to state 'open'
     } else {
         $this->transition_to_open();
     }
     // step 1 - at the very beginning of the workflow
     if (!isset($this->attributes['status']) || $this->attributes['status'] == 'created') {
         // display the induction message
         if (isset($this->attributes['induction_message'])) {
             $this->feed_back['message'] .= Codes::render($this->attributes['induction_message']);
         }
         // possible transition to state 'created'
     } else {
         $this->transition_to_created();
     }
     // event details
     if ($details = $this->get_event_details_text()) {
         $rows[] = array($this->get_event_details_label(), $details);
     }
     // meeting date
     if (isset($this->attributes['date_stamp']) && $this->attributes['date_stamp']) {
         // offer to update the calendar
         $button = '';
         if ($this->attributes['status'] == 'stopped') {
         } elseif (enrolments::get_record($this->anchor->get_reference())) {
             $button = ' ' . Skin::build_link($this->get_url('fetch_ics'), '<img src="' . $context['url_to_root'] . 'included/jscalendar/img.gif" style="border: none; cursor: pointer;" title="' . i18n::s('Update my calendar') . '" onmouseover="this.style.background=\'red\';" onmouseout="this.style.background=\'\'" alt="' . i18n::s('Update my calendar') . '" />', 'basic');
         }
         $rows[] = array(i18n::s('Date'), Skin::build_date($this->attributes['date_stamp'], 'full') . $button);
     }
     // meeting duration
     if (isset($this->attributes['duration']) && $this->attributes['duration'] && $this->attributes['duration'] < 1440) {
         switch ($this->attributes['duration']) {
             case 60:
                 $duration = i18n::s('one hour');
                 break;
             case 120:
                 $duration = i18n::s('two hours');
                 break;
             default:
                 $duration = sprintf(i18n::s('%d minutes'), $this->attributes['duration']);
                 break;
         }
         $rows[] = array(i18n::s('Duration'), $duration);
     }
     // build a link to the owner page, if any
     if (isset($this->attributes['chairman']) && $this->attributes['chairman']) {
         if ($user = Users::get($this->attributes['chairman'])) {
             $label = Users::get_link($user['full_name'], NULL, $user['id']);
         } else {
             $label = $this->attributes['chairman'];
         }
         $rows[] = array(i18n::s('Chairman'), $label);
     }
     // finalize status
     if (is_callable(array($this, 'finalize_status'))) {
         $this->feed_back['status'] = $this->finalize_status($this->feed_back['status']);
     }
     // finalize menu
     if (is_callable(array($this, 'finalize_menu'))) {
         $this->feed_back['menu'] = $this->finalize_menu($this->feed_back['menu']);
     }
     // we have to refresh the page
     if ($this->feed_back['reload_this_page']) {
         $reload_through_javascript = '<img alt="*" src="' . $context['url_to_home'] . $context['url_to_root'] . 'skins/_reference/ajax/ajax_spinner.gif" style="vertical-align:-3px" /> ';
         Page::insert_script('window.location.reload(true);');
         $rows[] = array(i18n::s('Status'), $reload_through_javascript);
         // display the status line and/or buttons
     } elseif (count($this->feed_back['status']) || count($this->feed_back['menu'])) {
         $status = '';
         // embed status line
         if (count($this->feed_back['status'])) {
             $status .= implode(BR, $this->feed_back['status']);
         }
         // embed menu bar
         if (count($this->feed_back['menu'])) {
             $status .= Skin::finalize_list($this->feed_back['menu'], 'menu_bar');
         }
         $rows[] = array(i18n::s('Status'), $status);
     }
     // display commands to page owner
     if (count($this->feed_back['commands'])) {
         $rows[] = array('', Skin::finalize_list($this->feed_back['commands'], 'menu_bar'));
     }
     // format text in a table
     $text = Skin::table(NULL, $rows, 'grid');
     // finalize feed-back
     if ($this->feed_back['message']) {
         $text .= Skin::build_box($this->get_message_label(), $this->feed_back['message']);
     }
     // allow for extensions
     if (is_callable(array($this, 'get_view_text_extension'))) {
         $text .= $this->get_view_text_extension();
     }
     // job done
     return $text;
 }
Example #13
0
 /**
  * do whatever is necessary when a page has been updated
  *
  * This function:
  * - logs the update
  * - sends notification to watchers and to followers
  * - "touches" the container of the page,
  * - ping referred pages remotely (via the pingback protocol)
  * - ping selected servers, if any
  * - and triggers the hook 'update'.
  *
  * The first parameter provides the watching context to consider. If call is related
  * to the creation of a published page, the context is the section that hosts the new
  * page. If call is related to a draft page that has been published, then the context
  * is the page itself.
  *
  * This function is also able to notify followers of the surfer who has initiated the
  * action.
  *
  * @param object the watching context
  * @param array attributes of the published page
  * @param object page overlay, if any
  * @param boolean TRUE if dates should be left unchanged, FALSE otherwise
  * @param boolean TRUE if watchers should be notified, FALSE otherwise
  * @param boolean TRUE if followers should be notified, FALSE otherwise
  */
 public static function finalize_update($anchor, $item, $overlay = NULL, $silently = FALSE, $with_watchers = TRUE, $with_followers = FALSE)
 {
     global $context;
     // proceed only if the page has been published
     if (isset($item['publish_date']) && $item['publish_date'] > NULL_DATE) {
         // notification to send by e-mail
         $mail = array();
         $mail['subject'] = sprintf(i18n::c('%s: %s'), i18n::c('Update'), strip_tags($item['title']));
         $mail['notification'] = Articles::build_notification('update', $item);
         $mail['headers'] = Mailer::set_thread('article:' . $item['id']);
         // allow the overlay to prevent notifications of watcherss
         if (is_object($overlay) && !$overlay->should_notify_watchers($mail)) {
             $with_watchers = FALSE;
         }
         // send to watchers of this page, and to watchers upwards
         if ($with_watchers && ($handle = new Article())) {
             $handle->load_by_content($item, $anchor);
             $handle->alert_watchers($mail, 'article:update', $item['active'] == 'N');
         }
         // never notify followers on private pages
         if (isset($item['active']) && $item['active'] == 'N') {
             $with_followers = FALSE;
         }
         // allow the overlay to prevent notifications of followers
         if (is_object($overlay) && !$overlay->should_notify_followers()) {
             $with_followers = FALSE;
         }
         // send to followers of this user
         if ($with_followers && Surfer::get_id()) {
             $mail['message'] = Mailer::build_notification($mail['notification'], 2);
             Users::alert_watchers('user:'******'article:update', $item['id'], $silently);
         // advertise public pages
         if (isset($item['active']) && $item['active'] == 'Y') {
             // expose links within the page
             $raw = '';
             if (isset($item['introduction'])) {
                 $raw .= $item['introduction'];
             }
             if (isset($item['source'])) {
                 $raw .= ' ' . $item['source'];
             }
             if (isset($item['description'])) {
                 $raw .= ' ' . $item['description'];
             }
             // pingback to referred links, if any
             include_once $context['path_to_root'] . 'links/links.php';
             Links::ping($raw, 'article:' . $item['id']);
             // ping servers, if any
             Servers::notify($anchor->get_url());
         }
     }
     // 'update' hook
     if (is_callable(array('Hooks', 'include_scripts'))) {
         Hooks::include_scripts('update', $item['id']);
     }
     // log page update
     $label = sprintf(i18n::c('Update: %s'), strip_tags($item['title']));
     $poster = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']);
     $description = sprintf(i18n::c('Updated by %s in %s'), $poster, $anchor->get_title());
     $description .= "\n\n" . '<a href="' . Articles::get_permalink($item) . '">' . $item['title'] . '</a>';
     Logger::notify('articles/articles.php: ' . $label, $description);
 }
Example #14
0
File: issue.php Project: rair/yacs
 /**
  * display content of 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_view_text($host = NULL)
 {
     $text = '';
     $rows = array();
     // this page has an explicit owner
     if (isset($host['owner_id']) && ($user = Users::get($host['owner_id']))) {
         // allow for click-to-call
         $click_to_call = Users::get_click_to_call($user);
         // display information on the owner
         $rows[] = array(i18n::s('Owner'), Users::get_link($user['full_name'], NULL, $user['id']) . ' ' . $click_to_call);
     }
     // show progress
     $rows[] = array(i18n::s('Progress'), $this->get_progress_value());
     // type
     $rows[] = array(i18n::s('Workflow'), self::get_type_value());
     // the status and history
     $history = self::get_history();
     $rows[] = array(i18n::s('Status'), self::get_status_label($this->attributes['status']) . $history);
     $text = Skin::table(NULL, $rows, 'grid');
     return $text;
 }
Example #15
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;
 }
Example #16
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;
 }
Example #17
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;
 }
Example #18
0
File: view.php Project: rair/yacs
 if (isset($item['assign_id']) && $item['assign_id']) {
     if (Surfer::is($item['assign_id'])) {
         $label = i18n::s('you');
     } else {
         $label = $item['assign_name'];
     }
     $history .= DRAFT_FLAG . sprintf(i18n::s('reserved by %s %s'), Users::get_link($label, $item['assign_address'], $item['assign_id']), Skin::build_date($item['assign_date'])) . BR;
 }
 // file uploader
 if (isset($item['create_name'])) {
     if (Surfer::is($item['create_id'])) {
         $label = i18n::s('you');
     } else {
         $label = $item['create_name'];
     }
     $history .= sprintf(i18n::s('shared by %s %s'), Users::get_link($label, $item['create_address'], $item['create_id']), Skin::build_date($item['create_date']));
 }
 // display the full text
 if ($item['description']) {
     $history .= Skin::build_box(i18n::s('More information'), $item['description'], 'folded');
 }
 // past of this file
 if ($history) {
     $rows[] = array(i18n::s('History'), $history);
 }
 // display the source
 if ($item['source']) {
     if (preg_match('/http:\\/\\/([^\\s]+)/', $item['source'], $matches)) {
         $item['source'] = Skin::build_link($matches[0], $matches[0], 'external');
     } else {
         if ($attributes = Links::transform_reference($item['source'])) {
Example #19
0
 /**
  * list comments as successive reader notes
  *
  * @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;
     }
     // return some formatted text
     $text = '<dl class="wiki_comments">';
     // build a list of comments
     $index = 0;
     include_once $context['path_to_root'] . 'comments/comments.php';
     while ($item = SQL::fetch($result)) {
         // odd or even
         $index++;
         if ($index % 2) {
             $class = 'odd';
         } else {
             $class = 'even';
         }
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // include a link to comment permalink
         $text .= '<dt class="' . $class . ' details">';
         // a link to the user profile
         $text .= Users::get_link($item['create_name'], $item['create_address'], $item['create_id']);
         $menu = array();
         // the creation date
         $label = Skin::build_date($item['create_date']);
         // flag new comments
         if ($item['create_date'] >= $context['fresh']) {
             $label .= NEW_FLAG;
         }
         $menu[] = $label;
         // the menu bar for associates and poster
         if (Comments::allow_modification($anchor, $item)) {
             $menu[] = Skin::build_link(Comments::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic');
             $menu[] = Skin::build_link(Comments::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic');
         }
         $text .= ' - ' . Skin::finalize_list($menu, 'menu');
         $text .= '</dt>';
         // each comment has an id
         $text .= '<dd class="' . $class . '" id="comment_' . $item['id'] . '">';
         // the comment itself
         $text .= ucfirst(trim($item['description'] . Users::get_signature($item['create_id'])));
         // comment has been modified
         if ($item['create_name'] && $item['edit_name'] != $item['create_name']) {
             $text .= BR . '<span class="details">(' . sprintf(i18n::s('modified by %s'), $item['edit_name']) . ')</span>';
         }
         // end of this note
         $text .= '</dd>';
     }
     // end of the list
     $text .= '</dl>';
     // process yacs codes
     $text = Codes::beautify($text);
     // end of processing
     SQL::free($result);
     return $text;
 }
Example #20
0
 /**
  * list locations
  *
  * Recognize following variants:
  * - 'no_anchor' to list items attached to one particular anchor
  * - 'no_author' to list items attached to one user prolocation
  *
  * @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
     while ($item = SQL::fetch($result)) {
         // initialize variables
         $prefix = $suffix = $icon = '';
         // the url to view this item
         $url = Locations::get_url($item['id']);
         // build a valid label
         if ($item['geo_place_name']) {
             $label = Skin::strip($item['geo_place_name'], 10);
         } else {
             $label = $item['latitude'] . ', ' . $item['longitude'];
         }
         // description
         if ($item['description']) {
             $suffix .= ' ' . ucfirst(trim($item['description']));
         }
         // the menu bar for associates and poster
         if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
             $menu = array(Locations::get_url($item['id'], 'edit') => i18n::s('Edit'), Locations::get_url($item['id'], 'delete') => i18n::s('Delete'));
             $suffix .= ' ' . Skin::build_list($menu, 'menu');
         }
         // add a separator
         if ($suffix) {
             $suffix = ' - ' . $suffix;
         }
         // append details to the suffix
         $suffix .= BR . '<span class="details">';
         // details
         $details = array();
         // item poster
         if (isset($this->layout_variant) && $this->layout_variant != 'no_author') {
             if ($item['edit_name']) {
                 $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
             }
         } else {
             $details[] = Anchors::get_action_label($item['edit_action']);
         }
         // show an anchor location
         if (isset($this->layout_variant) && $this->layout_variant != 'no_anchor' && $item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
             $anchor_url = $anchor->get_url();
             $anchor_label = ucfirst($anchor->get_title());
             $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor_url, $anchor_label, 'article'));
         }
         // all details
         if (count($details)) {
             $suffix .= ucfirst(implode(', ', $details)) . "\n";
         }
         // end of details
         $suffix .= '</span>';
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'location', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #21
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;
 }
Example #22
0
 /**
  * list files
  *
  * @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 = '';
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // initialize variables
         $prefix = $suffix = $icon = '';
         // more details
         $url = Files::get_permalink($item);
         // codes
         $codes = array();
         // files that can be embedded
         if (preg_match('/\\.(3gp|flv|gan|m4v|mm|mov|mp4|swf)$/i', $item['file_name'])) {
             $codes[] = '[embed=' . $item['id'] . ']';
         }
         // link for direct download
         $codes[] = '[file=' . $item['id'] . ']';
         $codes[] = '[download=' . $item['id'] . ']';
         // integrate codes
         if (!isset($_SESSION['surfer_editor']) || $_SESSION['surfer_editor'] == 'yacs') {
             foreach ($codes as $code) {
                 $suffix .= '<a onclick="edit_insert(\'\', \' ' . $code . '\');return false;" title="insert" tabindex="2000">' . $code . '</a> ';
             }
         } else {
             $suffix .= join(' ', $codes);
         }
         $suffix .= BR . '<span class="details">';
         // signal restricted and private files
         if ($item['active'] == 'N') {
             $suffix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $suffix .= RESTRICTED_FLAG;
         }
         // file title or file name
         $label = Codes::beautify_title($item['title']);
         if (!$label) {
             $label = ucfirst(str_replace(array('%20', '-', '_'), ' ', $item['file_name']));
         }
         $suffix .= $label;
         // flag files uploaded recently
         if ($item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         $suffix .= '</span>';
         // details
         $details = array();
         if (Surfer::is_logged() && $item['edit_name']) {
             $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
         }
         // the menu bar for associates and poster
         if (Surfer::is_empowered()) {
             $details[] = Skin::build_link($url, i18n::s('details'), 'basic');
             $details[] = Skin::build_link(Files::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic');
             $details[] = Skin::build_link(Files::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic');
         }
         // append details
         if (count($details)) {
             $suffix .= BR . Skin::finalize_list($details, 'menu');
         }
         // explicit icon
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } else {
             $icon = $context['url_to_root'] . Files::get_icon_url($item['file_name']);
         }
         // list all components for this item
         $items[$url] = array($prefix, '_', $suffix, 'file', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #23
0
 /**
  * list links
  *
  * Recognize following variants:
  * - 'no_anchor' to list items attached to one particular anchor
  * - 'no_author' to list items attached to one user prolink
  *
  * @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 = 'no_anchor';
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // initialize variables
         $prefix = $suffix = $icon = '';
         // make a label
         $label = Links::clean($item['title'], $item['link_url']);
         // flag links uploaded recently
         if ($item['edit_date'] >= $context['fresh']) {
             $prefix = NEW_FLAG . $prefix;
         }
         // the number of clicks
         if ($item['hits'] > 1) {
             $suffix .= ' (' . Skin::build_number($item['hits'], i18n::s('clicks')) . ') ';
         }
         // add a separator
         if ($suffix) {
             $suffix = ' - ' . $suffix;
         }
         // details
         $details = array();
         // item poster
         if ($item['edit_name'] && $this->layout_variant != 'no_author') {
             if (Surfer::is_member() || (!isset($context['content_without_details']) || $context['content_without_details'] != 'Y') || is_object($anchor) && $anchor->has_option('with_details')) {
                 $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
             }
         }
         // show an anchor link
         if ($this->layout_variant != 'no_anchor' && $this->layout_variant != 'no_author' && $item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
             $anchor_url = $anchor->get_url();
             $anchor_label = ucfirst($anchor->get_title());
             $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor_url, $anchor_label, 'article'));
         }
         // the menu bar for associates and poster
         if (Surfer::is_empowered() || Surfer::is($item['edit_id'])) {
             $details[] = Skin::build_link('links/edit.php?id=' . $item['id'], i18n::s('edit'), 'span');
             $details[] = Skin::build_link('links/delete.php?id=' . $item['id'], i18n::s('delete'), 'span');
         }
         // append details to the suffix
         if (count($details)) {
             $suffix .= BR . Skin::finalize_list($details, 'menu');
         }
         // description
         if ($item['description']) {
             $suffix .= BR . Codes::beautify($item['description']);
         }
         // build the actual link to check it
         if ($this->layout_variant == 'review') {
             $icon = $item['link_url'];
         }
         // url is the link itself -- hack for xhtml compliance
         $url = str_replace('&', '&amp;', $item['link_url']);
         // let the rendering engine guess the type of link
         $link_type = NULL;
         // except if we want to stay within this window
         if (isset($item['link_target']) && $item['link_target'] != 'I') {
             $link_type = 'external';
         }
         // hovering title
         $link_title = NULL;
         if (isset($item['link_title']) && $item['link_title']) {
             $link_title = $item['link_title'];
         }
         // pack everything
         $items[$url] = array($prefix, $label, $suffix, $link_type, $icon, $link_title);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }
Example #24
0
File: view.php Project: rair/yacs
     // 			$context['text'] .= Skin::table(NULL, $rows);
 }
 // back to the anchor page
 $links = array();
 if (is_object($anchor) && (Surfer::is_associate() || $anchor->is_assigned())) {
     $links[] = Skin::build_link(Versions::get_url($anchor->get_reference(), 'list'), i18n::s('Versions'), 'button');
 }
 if ($item['id'] && (Surfer::is_associate() || Surfer::is_member() && is_object($anchor) && $anchor->is_assigned())) {
     $links[] = Skin::build_link(Versions::get_url($item['id'], 'restore'), i18n::s('Restore this version'), 'span', i18n::s('Caution: restoration can not be reversed!'));
 }
 $context['text'] .= Skin::finalize_list($links, 'assistant_bar');
 // page help
 $help = '';
 // information to members
 if (Surfer::is_member()) {
     $help .= '<p>' . sprintf(i18n::s('This has been posted by %s %s.'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date'])) . "</p>\n";
 }
 $help .= '<p><ins>' . i18n::s('Text inserted since that version.') . '</ins></p>' . '<p><del>' . i18n::s('Text suppressed from this version.') . '</del></p>' . '<p>' . i18n::s('Caution: restoration can not be reversed!') . '</p>';
 $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help');
 //
 // the navigation sidebar
 //
 $text = '';
 // buttons to display previous and next pages, if any
 if (is_object($anchor)) {
     $neighbours = $anchor->get_neighbours('version', $item);
     $text .= Skin::neighbours($neighbours, 'sidebar');
 }
 // build a nice sidebar box
 if ($text) {
     $text =& Skin::build_box(i18n::s('Navigation'), $text, 'neighbours', 'neighbours');
Example #25
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;
 }
Example #26
0
File: view.php Project: rair/yacs
 }
 // restricted to logged members
 if ($item['active'] == 'R') {
     $details[] = RESTRICTED_FLAG . i18n::s('Community - Access is granted to any identified surfer');
 } elseif ($item['active'] == 'N') {
     $details[] = PRIVATE_FLAG . i18n::s('Private - Access is restricted to selected persons');
 }
 // expired article
 if ((Surfer::is_associate() || $cur_article->is_assigned()) && $item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
     $details[] = EXPIRED_FLAG . ' ' . sprintf(i18n::s('Page has expired %s'), Skin::build_date($item['expiry_date']));
 }
 // provide more details to authenticated surfers
 if (Surfer::is_logged()) {
     // page owner
     if (isset($item['owner_id']) && ($owner = Users::get($item['owner_id']))) {
         $details[] = sprintf(i18n::s('%s: %s'), i18n::s('Owner'), Users::get_link($owner['full_name'], $owner['email'], $owner['id']));
     }
     // page editors
     if ($items = Articles::list_editors_by_name($item, 0, 7, 'comma5')) {
         $details[] = sprintf(i18n::s('%s: %s'), Skin::build_link(Users::get_url('article:' . $item['id'], 'select'), i18n::s('Editors')), $items);
     }
     // page watchers
     if ($items = Articles::list_watchers_by_posts($item, 0, 7, 'comma5')) {
         $details[] = sprintf(i18n::s('%s: %s'), Skin::build_link(Users::get_url('article:' . $item['id'], 'watch'), i18n::s('Watchers')), $items);
     }
 }
 // display details, if any
 if (count($details)) {
     $text .= ucfirst(implode(BR . "\n", $details)) . BR . "\n";
 }
 // other details
Example #27
0
File: day.php Project: rair/yacs
 /**
  * get invitation default message
  *
  * This is put in the invitation form.
  *
  * @see articles/invite.php
  *
  * @param string 'PUBLISH' or 'CANCEL'
  * @return string to be put in the web form
  */
 function get_invite_default_message($method = 'PUBLISH')
 {
     global $context;
     // to be displayed into the web form for this invitation
     $text = '';
     if ($value = $this->anchor->get_title()) {
         $text .= sprintf(i18n::c('%s: %s'), i18n::c('Topic'), Skin::build_link($context['url_to_home'] . $context['url_to_root'] . $this->anchor->get_url(), Codes::beautify_title($value))) . BR;
     }
     // dates
     if (isset($this->attributes['date_stamp']) && $this->attributes['date_stamp']) {
         $text .= sprintf(i18n::c('%s: %s'), i18n::c('Date'), Skin::build_date($this->attributes['date_stamp'], 'day')) . BR;
     }
     // build a link to the chairman page, if any
     if (isset($this->attributes['chairman']) && ($user = Users::get($this->attributes['chairman']))) {
         $text .= sprintf(i18n::c('%s: %s'), i18n::c('Chairman'), Users::get_link($user['full_name'], NULL, $user['id'])) . BR;
     }
     // event has been cancelled
     if ($method == 'CANCEL') {
         $text .= '<div><p>' . i18n::c('Event has been cancelled.') . '</p></div>';
     } else {
         // copy content of the introduction field, if any
         if ($value = $this->anchor->get_value('introduction')) {
             $text .= '<div>' . Codes::beautify('<p>' . $value . '</p>') . '</div>';
         }
         // copy the induction message, if any
         if (isset($this->attributes['induction_message'])) {
             $text .= '<div>' . Codes::render($this->attributes['induction_message']) . '</div>';
         }
     }
     // done
     return $text;
 }
Example #28
0
 /**
  * document modification dates for this item
  *
  * @param object anchor of the section
  * @param array the section to be documented
  * @return array strings detailed labels
  */
 public static function &build_dates($anchor, $item)
 {
     global $context;
     // we return an array of strings
     $details = array();
     // we do want details for this page
     if (strpos($item['options'], 'with_details') !== FALSE) {
     } elseif (isset($context['content_without_details']) && $context['content_without_details'] == 'Y' && !Sections::is_owned($item, $anchor)) {
         return $details;
     }
     // last modification
     if ($item['edit_action']) {
         $action = Anchors::get_action_label($item['edit_action']) . ' ';
     } else {
         $action = i18n::s('edited');
     }
     if ($item['edit_name']) {
         $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']));
     } else {
         $details[] = $action . ' ' . Skin::build_date($item['edit_date']);
     }
     // post date and author
     if ($item['create_date']) {
         // creation and last modification happen on same day by the same person
         if (!strcmp(substr($item['create_date'], 0, 10), substr($item['edit_date'], 0, 10)) && $item['create_id'] == $item['edit_id']) {
         } elseif ($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']));
         } else {
             $details[] = Skin::build_date($item['create_date']);
         }
     }
     // job done
     return $details;
 }
Example #29
0
File: view.php Project: rair/yacs
} elseif ($context['self_url'] && ($canonical = $context['url_to_home'] . $context['url_to_root'] . Servers::get_url($item['id'])) && strncmp($context['self_url'], $canonical, strlen($canonical))) {
    Safe::header('Status: 301 Moved Permanently', TRUE, 301);
    Safe::header('Location: ' . $canonical);
    Logger::error(Skin::build_link($canonical));
    // display the server profile
} else {
    $text = '';
    // initialize the rendering engine
    Codes::initialize(Servers::get_url($item['id']));
    // the nick name
    if ($item['host_name'] && Surfer::is_associate()) {
        $details[] = '"' . $item['host_name'] . '"';
    }
    // information on last update
    if ($item['edit_name']) {
        $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
    }
    // restricted to logged members
    if ($item['active'] == 'R') {
        $details[] = RESTRICTED_FLAG . i18n::s('Community - Access is granted to any identified surfer') . BR . "\n";
    } elseif ($item['active'] == 'N') {
        $details[] = PRIVATE_FLAG . i18n::s('Private - Access is restricted to selected persons') . BR . "\n";
    }
    // all details
    if (@count($details)) {
        $context['page_details'] .= '<p class="details">' . ucfirst(implode(', ', $details)) . "</p>\n";
    }
    // insert anchor prefix
    if (is_object($anchor)) {
        $text .= $anchor->get_prefix();
    }
Example #30
0
 /**
  * list tables
  *
  * Recognize following variants:
  * - 'no_anchor' to list items attached to one particular anchor
  *
  * @param resource the SQL result
  * @return array one item per image
  *
  * @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;
     }
     if (!isset($this->layout_variant)) {
         $this->layout_variant = 'no_anchor';
     }
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // initialize variables
         $prefix = $suffix = $icon = '';
         // the url to view this item
         $url = Tables::get_url($item['id']);
         // codes to embed this image
         if ($anchor && $this->focus == $anchor->get_reference()) {
             // codes
             $codes = array();
             $codes[] = '[table=' . $item['id'] . ']';
             $codes[] = '[table.filter=' . $item['id'] . ']';
             $codes[] = '[table.chart=' . $item['id'] . ']';
             $codes[] = '[table.bars=' . $item['id'] . ']';
             $codes[] = '[table.line=' . $item['id'] . ']';
             // integrate codes
             if (!isset($_SESSION['surfer_editor']) || $_SESSION['surfer_editor'] == 'yacs') {
                 foreach ($codes as $code) {
                     $suffix .= '<a onclick="edit_insert(\'\', \' ' . $code . '\');return false;" title="insert" tabindex="2000">' . $code . '</a> ';
                 }
             } else {
                 $suffix .= join(' ', $codes);
             }
             $suffix .= BR;
         }
         // we are listing tables attached to an chor
         if ($anchor && $this->focus == $anchor->get_reference()) {
             $label = '_';
             // the title
             if ($item['title']) {
                 $suffix .= Skin::strip($item['title'], 10);
             }
             // an index of tables
         } else {
             // the title
             if ($item['title']) {
                 $label = Skin::strip($item['title'], 10);
             }
         }
         // flag tables created or updated very recently
         if (isset($item['create_date']) && $item['create_date'] >= $context['fresh']) {
             $suffix .= NEW_FLAG;
         } elseif (isset($item['edit_date']) && $item['edit_date'] >= $context['fresh']) {
             $suffix .= UPDATED_FLAG;
         }
         // details
         $details = array();
         if (Surfer::is_associate() && $item['nick_name']) {
             $details[] = '"' . $item['nick_name'] . '"';
         }
         if (Surfer::is_logged() && $item['edit_name']) {
             $details[] = sprintf(i18n::s('edited by %s %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date']));
         }
         // the menu bar for associates and poster
         if (Surfer::is_empowered()) {
             $details[] = Skin::build_link(Tables::get_url($item['id'], 'view'), i18n::s('details'), 'basic');
             $details[] = Skin::build_link(Tables::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic');
             $details[] = Skin::build_link(Tables::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic');
         }
         // append details
         if (count($details)) {
             $suffix .= BR . Skin::finalize_list($details, 'menu');
         }
         // list all components for this item
         $items[$url] = array($prefix, $label, $suffix, 'table', $icon);
     }
     // end of processing
     SQL::free($result);
     return $items;
 }