Ejemplo n.º 1
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;
 }
Ejemplo n.º 2
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;
 }
 /**
  * layout the newest articles
  *
  * caution: this function also updates page title directly, and this makes its call non-cacheable
  *
  * @param array the article
  * @return string the rendered text
  **/
 function layout_newest($item)
 {
     global $context;
     // get the related overlay, if any
     $overlay = Overlay::load($item, 'article:' . $item['id']);
     // get the anchor
     $anchor = Anchors::get($item['anchor']);
     // the url to view this item
     $url = Articles::get_permalink($item);
     // reset the rendering engine between items
     Codes::initialize($url);
     // build a title
     if (is_object($overlay)) {
         $title = Codes::beautify_title($overlay->get_text('title', $item));
     } else {
         $title = Codes::beautify_title($item['title']);
     }
     // title prefix & suffix
     $text = $prefix = $suffix = '';
     // flag articles updated recently
     if ($context['site_revisit_after'] < 1) {
         $context['site_revisit_after'] = 2;
     }
     $context['fresh'] = gmstrftime('%Y-%m-%d %H:%M:%S', mktime(0, 0, 0, date("m"), date("d") - $context['site_revisit_after'], date("Y")));
     // link to permalink
     if (Surfer::is_empowered()) {
         $title = Skin::build_box_title($title, $url, i18n::s('Permalink'));
     }
     // signal articles to be published
     if ($item['publish_date'] <= NULL_DATE) {
         $prefix .= DRAFT_FLAG;
     } else {
         if ($item['publish_date'] > NULL_DATE && $item['publish_date'] > $context['now']) {
             $prefix .= DRAFT_FLAG;
         }
     }
     // signal restricted and private articles
     if ($item['active'] == 'N') {
         $prefix .= PRIVATE_FLAG . ' ';
     } elseif ($item['active'] == 'R') {
         $prefix .= RESTRICTED_FLAG . ' ';
     }
     // signal locked articles
     if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
         $suffix .= LOCKED_FLAG;
     }
     // flag expired article
     if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
         $suffix .= EXPIRED_FLAG;
     }
     // update page title directly
     $text .= Skin::build_block($prefix . $title . $suffix, 'title');
     // if this article has a specific icon, use it
     if ($item['icon_url']) {
         $icon = $item['icon_url'];
     } elseif ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) {
         $icon = $anchor->get_icon_url();
     }
     // if we have a valid image
     if (preg_match('/(.gif|.jpg|.jpeg|.png)$/i', $icon)) {
         // fix relative path
         if (!preg_match('/^(\\/|http:|https:|ftp:)/', $icon)) {
             $icon = $context['url_to_root'] . $icon;
         }
         // flush the image on the right
         $text .= '<img src="' . $icon . '" class="right_image" alt="" />';
     }
     // article rating, if the anchor allows for it
     if (!is_object($anchor) || !$anchor->has_option('without_rating')) {
         // report on current rating
         $label = '';
         if ($item['rating_count']) {
             $label = Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])) . ' ';
         }
         $label .= i18n::s('Rate this page');
         // allow for rating
         $text .= Skin::build_link(Articles::get_url($item['id'], 'like'), $label, 'basic');
     }
     // the introduction text, if any
     if (is_object($overlay)) {
         $text .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
     } else {
         $text .= Skin::build_block($item['introduction'], 'introduction');
     }
     // insert overlay data, if any
     if (is_object($overlay)) {
         $text .= $overlay->get_text('view', $item);
     }
     // the beautified description, which is the actual page body
     if ($item['description']) {
         // use adequate label
         if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
             $text .= Skin::build_block($label, 'title');
         }
         $text .= Skin::build_block($item['description'], 'description', '', $item['options']);
     }
     //
     // list related files
     //
     // if this surfer is an editor of this article, show hidden files as well
     if (Articles::is_assigned($item['id']) || is_object($anchor) && $anchor->is_assigned()) {
         Surfer::empower();
     }
     // build a complete box
     $box['bar'] = array();
     $box['text'] = '';
     // count the number of files in this article
     if ($count = Files::count_for_anchor('article:' . $item['id'])) {
         if ($count > 20) {
             $box['bar'] += array('_count' => sprintf(i18n::ns('%d file', '%d files', $count), $count));
         }
         // list files by date (default) or by title (option files_by_title)
         if (Articles::has_option('files_by', $anchor, $item) == 'title') {
             $items = Files::list_by_title_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'article:' . $item['id']);
         } else {
             $items = Files::list_by_date_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'article:' . $item['id']);
         }
         if (is_array($items)) {
             $box['text'] .= Skin::build_list($items, 'decorated');
         }
         // navigation commands for files
         $prefix = Articles::get_url($item['id'], 'navigate', 'files');
         $box['bar'] += Skin::navigate($url, $prefix, $count, FILES_PER_PAGE, 0);
         // the command to post a new file, if allowed
         if (Files::allow_creation($item, $anchor, 'article')) {
             $link = 'files/edit.php?anchor=' . urlencode('article:' . $item['id']);
             $box['bar'] += array($link => i18n::s('Add a file'));
         }
         if (is_array($box['bar'])) {
             $box['text'] .= Skin::build_list($box['bar'], 'menu_bar');
         }
     }
     // actually render the html for this box
     if ($box['text']) {
         $text .= Skin::build_box(i18n::s('Files'), $box['text'], 'header1', 'files');
     }
     //
     // bottom page menu
     //
     // discuss this page, if the index page can be commented, and comments are accepted at the article level
     if (Comments::allow_creation($item, $anchor)) {
         $this->menu[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Post a comment'), 'span');
     }
     // info on related comments
     if ($count = Comments::count_for_anchor('article:' . $item['id'])) {
         $this->menu[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'span');
     }
     // new links are accepted at the index page and at the article level
     if (Links::allow_trackback()) {
         $this->menu[] = Skin::build_link('links/trackback.php?anchor=' . urlencode('article:' . $item['id']), i18n::s('Reference this page'), 'span');
     }
     // info on related links
     if ($count = Links::count_for_anchor('article:' . $item['id'])) {
         $this->menu[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'span');
     }
     // new files are accepted at the index page and at the article level
     if (is_object($anchor) && $anchor->has_option('with_files') && !($anchor->has_option('no_files') || preg_match('/\\bno_files\\b/i', $item['options']))) {
         // add a file
         if (Files::allow_creation($item, $anchor, 'article')) {
             if ($context['with_friendly_urls'] == 'Y') {
                 $link = 'files/edit.php/article/' . $item['id'];
             } else {
                 $link = 'files/edit.php?anchor=' . urlencode('article:' . $item['id']);
             }
             $this->menu[] = Skin::build_link($link, i18n::s('Add a file'), 'span');
         }
     }
     // modify this page
     if (Surfer::is_empowered()) {
         $this->menu[] = Skin::build_link(Articles::get_url($item['id'], 'edit'), i18n::s('Edit'), 'span');
     }
     // view permalink
     if (Surfer::is_empowered()) {
         $this->menu[] = Skin::build_link($url, i18n::s('Permalink'), 'span');
     }
     // insert overlay data, if any
     if (is_object($overlay)) {
         $text .= $overlay->get_text('trailer', $item);
     }
     // add trailer information from this item, if any
     if (isset($item['trailer']) && trim($item['trailer'])) {
         $text .= Codes::beautify($item['trailer']);
     }
     // returned the formatted content
     return $text;
 }
Ejemplo n.º 4
0
 /**
  * remember the last action for this section
  *
  * @see articles/article.php
  * @see shared/anchor.php
  *
  * @param string the description of the last action
  * @param string the id of the item related to this update
  * @param boolean TRUE to not change the edit date of this anchor, default is FALSE
  */
 function touch($action, $origin = NULL, $silently = FALSE)
 {
     global $context;
     // we make extensive use of comments below
     include_once $context['path_to_root'] . 'comments/comments.php';
     // don't go further on import
     if (preg_match('/import$/i', $action)) {
         return;
     }
     // no section bound
     if (!isset($this->item['id'])) {
         return;
     }
     // delegate to overlay
     if (is_object($this->overlay) && $this->overlay->touch($action, $origin, $silently) === false) {
         return;
         // stop on false
     }
     // sanity check
     if (!$origin) {
         logger::remember('sections/section.php: unexpected NULL origin at touch()');
         return;
     }
     // components of the query
     $query = array();
     // a new page has been added to the section
     if ($action == 'article:publish' || $action == 'article:submit') {
         // limit the number of items attached to this section
         if (isset($this->item['maximum_items']) && $this->item['maximum_items'] > 10) {
             Articles::purge_for_anchor('section:' . $this->item['id'], $this->item['maximum_items']);
         }
         // a new comment has been posted
     } elseif ($action == 'comment:create') {
         // purge oldest comments
         Comments::purge_for_anchor('section:' . $this->item['id']);
         // file upload
     } elseif ($action == 'file:create' || $action == 'file:upload') {
         // actually, several files have been added
         $label = '';
         if (!$origin) {
             $fields = array();
             $fields['anchor'] = 'section:' . $this->item['id'];
             $fields['description'] = i18n::s('Several files have been added');
             $fields['type'] = 'notification';
             Comments::post($fields);
             // one file has been added
         } elseif (!Codes::check_embedded($this->item['description'], 'embed', $origin) && ($item = Files::get($origin, TRUE))) {
             // this file is eligible for being embedded in the page
             if (isset($item['file_name']) && Files::is_embeddable($item['file_name'])) {
                 // the overlay may prevent embedding
                 if (is_object($this->overlay) && !$this->overlay->should_embed_files()) {
                 } else {
                     $label = '[embed=' . $origin . ']';
                 }
                 // else add a comment to take note of the upload
             } elseif (Comments::allow_creation($this->item, null, 'section')) {
                 $fields = array();
                 $fields['anchor'] = 'section:' . $this->item['id'];
                 if ($action == 'file:create') {
                     $fields['description'] = '[file=' . $item['id'] . ',' . $item['file_name'] . ']';
                 } else {
                     $fields['description'] = '[download=' . $item['id'] . ',' . $item['file_name'] . ']';
                 }
                 Comments::post($fields);
             }
         }
         // include flash videos in a regular page
         if ($label) {
             $query[] = "description = '" . SQL::escape($this->item['description'] . ' ' . $label) . "'";
         }
         // suppress references to a deleted file
     } elseif ($action == 'file:delete') {
         // suppress reference in main description field
         $text = Codes::delete_embedded($this->item['description'], 'download', $origin);
         $text = Codes::delete_embedded($text, 'embed', $origin);
         $text = Codes::delete_embedded($text, 'file', $origin);
         // save changes
         $query[] = "description = '" . SQL::escape($text) . "'";
         // append a reference to a new image to the description
     } elseif ($action == 'image:create') {
         if (!Codes::check_embedded($this->item['description'], 'image', $origin)) {
             // the overlay may prevent embedding
             if (is_object($this->overlay) && !$this->overlay->should_embed_files()) {
             } else {
                 // list has already started
                 if (preg_match('/\\[image=[^\\]]+?\\]\\s*$/', $this->item['description'])) {
                     $query[] = "description = '" . SQL::escape($this->item['description'] . ' [image=' . $origin . ']') . "'";
                 } else {
                     $query[] = "description = '" . SQL::escape($this->item['description'] . "\n\n" . '[image=' . $origin . ']') . "'";
                 }
             }
         }
         // also use it as thumnail if none has been defined yet
         if (!isset($this->item['thumbnail_url']) || !trim($this->item['thumbnail_url'])) {
             include_once $context['path_to_root'] . 'images/images.php';
             if (($image = Images::get($origin)) && ($url = Images::get_thumbnail_href($image))) {
                 $query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
             }
         }
         // refresh stamp only if image update occurs within 6 hours after last edition
         if (SQL::strtotime($this->item['edit_date']) + 6 * 60 * 60 < time()) {
             $silently = TRUE;
         }
         // suppress a reference to an image that has been deleted
     } elseif ($action == 'image:delete') {
         // suppress reference in main description field
         $query[] = "description = '" . SQL::escape(Codes::delete_embedded($this->item['description'], 'image', $origin)) . "'";
         // suppress references as icon and thumbnail as well
         include_once $context['path_to_root'] . 'images/images.php';
         if ($image = Images::get($origin)) {
             if ($url = Images::get_icon_href($image)) {
                 if ($this->item['icon_url'] == $url) {
                     $query[] = "icon_url = ''";
                 }
                 if ($this->item['thumbnail_url'] == $url) {
                     $query[] = "thumbnail_url = ''";
                 }
             }
             if ($url = Images::get_thumbnail_href($image)) {
                 if ($this->item['icon_url'] == $url) {
                     $query[] = "icon_url = ''";
                 }
                 if ($this->item['thumbnail_url'] == $url) {
                     $query[] = "thumbnail_url = ''";
                 }
             }
         }
         // set an existing image as the section icon
     } elseif ($action == 'image:set_as_icon') {
         include_once $context['path_to_root'] . 'images/images.php';
         if ($image = Images::get($origin)) {
             if ($url = Images::get_icon_href($image)) {
                 $query[] = "icon_url = '" . SQL::escape($url) . "'";
             }
             // also use it as thumnail if none has been defined yet
             if (!(isset($this->item['thumbnail_url']) && trim($this->item['thumbnail_url'])) && ($url = Images::get_thumbnail_href($image))) {
                 $query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
             }
         } elseif ($origin) {
             $query[] = "icon_url = '" . SQL::escape($origin) . "'";
         }
         $silently = TRUE;
         // set an existing image as the section thumbnail
     } elseif ($action == 'image:set_as_thumbnail') {
         include_once $context['path_to_root'] . 'images/images.php';
         if ($image = Images::get($origin)) {
             // use the thumbnail for large files, or the image itself for smaller files
             if ($image['image_size'] > $context['thumbnail_threshold']) {
                 $url = Images::get_thumbnail_href($image);
             } else {
                 $url = Images::get_icon_href($image);
             }
             $query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
         } elseif ($origin) {
             $query[] = "thumbnail_url = '" . SQL::escape($origin) . "'";
         }
         $silently = TRUE;
         // append a new image, and set it as the article thumbnail
     } elseif ($action == 'image:set_as_both') {
         if (!Codes::check_embedded($this->item['description'], 'image', $origin)) {
             $query[] = "description = '" . SQL::escape($this->item['description'] . ' [image=' . $origin . ']') . "'";
         }
         include_once $context['path_to_root'] . 'images/images.php';
         if ($image = Images::get($origin)) {
             // use the thumbnail for large files, or the image itself for smaller files
             if ($image['image_size'] > $context['thumbnail_threshold']) {
                 $url = Images::get_thumbnail_href($image);
             } else {
                 $url = Images::get_icon_href($image);
             }
             $query[] = "thumbnail_url = '" . SQL::escape($url) . "'";
         } elseif ($origin) {
             $query[] = "thumbnail_url = '" . SQL::escape($origin) . "'";
         }
         // do not remember minor changes
         $silently = TRUE;
         // add a reference to a new table in the section description
     } elseif ($action == 'table:create') {
         if (!Codes::check_embedded($this->item['description'], 'table', $origin)) {
             $query[] = "description = '" . SQL::escape($this->item['description'] . ' [table=' . $origin . ']') . "'";
         }
         // suppress a reference to a table that has been deleted
     } elseif ($action == 'table:delete') {
         $query[] = "description = '" . SQL::escape(Codes::delete_embedded($this->item['description'], 'table', $origin)) . "'";
     }
     // stamp the update
     if (!$silently) {
         $query[] = "edit_name='" . SQL::escape(Surfer::get_name()) . "'," . "edit_id=" . SQL::escape(Surfer::get_id()) . "," . "edit_address='" . SQL::escape(Surfer::get_email_address()) . "'," . "edit_action='{$action}'," . "edit_date='" . SQL::escape(gmstrftime('%Y-%m-%d %H:%M:%S')) . "'";
     }
     // update the database
     if (@count($query)) {
         $query = "UPDATE " . SQL::table_name('sections') . " SET " . implode(', ', $query) . " WHERE id = " . SQL::escape($this->item['id']);
         SQL::query($query);
     }
     // always clear the cache, even on no update
     Sections::clear($this->item);
     // get the parent
     if (!$this->anchor) {
         $this->anchor = Anchors::get($this->item['anchor']);
     }
     // propagate the touch upwards silently -- we only want to purge the cache
     if (is_object($this->anchor)) {
         $this->anchor->touch('section:touch', $this->item['id'], TRUE);
     }
 }
Ejemplo n.º 5
0
Archivo: view.php Proyecto: rair/yacs
 if ($this_cat->allow_creation()) {
     Skin::define_img('CATEGORIES_ADD_IMG', 'categories/add.gif');
     $context['page_tools'][] = Skin::build_link('categories/edit.php?anchor=' . urlencode('category:' . $item['id']), CATEGORIES_ADD_IMG . i18n::s('Add a category'), 'basic');
 }
 // post an image, if upload is allowed
 if (Images::allow_creation($item, $anchor, 'category')) {
     Skin::define_img('IMAGES_ADD_IMG', 'images/add.gif');
     $context['page_tools'][] = Skin::build_link('images/edit.php?anchor=' . urlencode('category:' . $item['id']), IMAGES_ADD_IMG . i18n::s('Add an image'), 'basic', i18n::s('You can upload a camera shot, a drawing, or another image file.'));
 }
 // add a file, if upload is allowed
 if (Files::allow_creation($item, $anchor, 'category')) {
     Skin::define_img('FILES_UPLOAD_IMG', 'files/upload.gif');
     $context['page_tools'][] = Skin::build_link('files/edit.php?anchor=' . urlencode('category:' . $item['id']), FILES_UPLOAD_IMG . i18n::s('Add a file'), 'basic', i18n::s('Attach related files.'));
 }
 // comment this page if anchor does not prevent it
 if (Comments::allow_creation($item, $anchor, 'category')) {
     Skin::define_img('COMMENTS_ADD_IMG', 'comments/add.gif');
     $context['page_tools'][] = Skin::build_link(Comments::get_url('category:' . $item['id'], 'comment'), COMMENTS_ADD_IMG . i18n::s('Post a comment'), 'basic', i18n::s('Express yourself, and say what you think.'));
 }
 // add a link
 if (Links::allow_creation($item, $anchor, 'category')) {
     Skin::define_img('LINKS_ADD_IMG', 'links/add.gif');
     $context['page_tools'][] = Skin::build_link('links/edit.php?anchor=' . urlencode('category:' . $item['id']), LINKS_ADD_IMG . i18n::s('Add a link'), 'basic', i18n::s('Contribute to the web and link to relevant pages.'));
 }
 // modify this item
 Skin::define_img('CATEGORIES_EDIT_IMG', 'categories/edit.gif');
 $context['page_tools'][] = Skin::build_link(Categories::get_url($item['id'], 'edit'), CATEGORIES_EDIT_IMG . i18n::s('Edit this category'), 'basic', i18n::s('Press [e] to edit'), FALSE, 'e');
 // delete this item
 Skin::define_img('CATEGORIES_DELETE_IMG', 'categories/delete.gif');
 $context['page_tools'][] = Skin::build_link(Categories::get_url($item['id'], 'delete'), CATEGORIES_DELETE_IMG . i18n::s('Delete this category'));
 // manage persons assigned to this category
Ejemplo n.º 6
0
 /**
  * list articles
  *
  * @param resource the SQL result
  * @return a string to be displayed
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // no hovering label
     $href_title = '';
     // we build an array for the skin::build_tabs() function
     $panels = array();
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // get the main anchor
         $anchor = Anchors::get($item['anchor']);
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // panel content
         $text = '';
         // insert anchor prefix
         if (is_object($anchor)) {
             $text .= $anchor->get_prefix();
         }
         // the introduction text, if any
         if (is_object($overlay)) {
             $text .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
         } elseif (isset($item['introduction']) && trim($item['introduction'])) {
             $text .= Skin::build_block($item['introduction'], 'introduction');
         }
         // get text related to the overlay, if any
         if (is_object($overlay)) {
             $text .= $overlay->get_text('view', $item);
         }
         // filter description, if necessary
         if (is_object($overlay)) {
             $description = $overlay->get_text('description', $item);
         } else {
             $description = $item['description'];
         }
         // the beautified description, which is the actual page body
         if ($description) {
             // use adequate label
             if (is_object($overlay) && ($label = $overlay->get_label('description'))) {
                 $text .= Skin::build_block($label, 'title');
             }
             // beautify the target page
             $text .= Skin::build_block($description, 'description', '', $item['options']);
         }
         // list files only to people able to change the page
         if (Articles::allow_modification($item, $anchor)) {
             $embedded = NULL;
         } else {
             $embedded = Codes::list_embedded($item['description']);
         }
         // build a complete box
         $box = array('bar' => array(), 'text' => '');
         // count the number of files in this article
         if ($count = Files::count_for_anchor('article:' . $item['id'], FALSE, $embedded)) {
             if ($count > 20) {
                 $box['bar'] += array('_count' => sprintf(i18n::ns('%d file', '%d files', $count), $count));
             }
             // list files by date (default) or by title (option files_by_title)
             $offset = ($zoom_index - 1) * FILES_PER_PAGE;
             if (Articles::has_option('files_by', $anchor, $item) == 'title') {
                 $items = Files::list_by_title_for_anchor('article:' . $item['id'], 0, 300, 'article:' . $item['id'], $embedded);
             } else {
                 $items = Files::list_by_date_for_anchor('article:' . $item['id'], 0, 300, 'article:' . $item['id'], $embedded);
             }
             // actually render the html
             if (is_array($items)) {
                 $box['text'] .= Skin::build_list($items, 'decorated');
             } elseif (is_string($items)) {
                 $box['text'] .= $items;
             }
             // the command to post a new file
             if (Files::allow_creation($item, $anchor, 'article')) {
                 Skin::define_img('FILES_UPLOAD_IMG', 'files/upload.gif');
                 $box['bar'] += array('files/edit.php?anchor=' . urlencode('article:' . $item['id']) => FILES_UPLOAD_IMG . i18n::s('Add a file'));
             }
         }
         // some files have been attached to this page
         if ($page == 1 && $count > 1) {
             // the command to download all files
             $link = 'files/fetch_all.php?anchor=' . urlencode('article:' . $item['id']);
             if ($count > 20) {
                 $label = i18n::s('Zip 20 first files');
             } else {
                 $label = i18n::s('Zip all files');
             }
             $box['bar'] += array($link => $label);
         }
         // there is some box content
         if ($box['text']) {
             $text .= Skin::build_content('files', i18n::s('Files'), $box['text'], $box['bar']);
         }
         // list of comments
         $title_label = '';
         if (is_object($anchor)) {
             $title_label = ucfirst($overlay->get_label('list_title', 'comments'));
         }
         if (!$title_label) {
             $title_label = i18n::s('Comments');
         }
         // no layout yet
         $layout = NULL;
         // label to create a comment
         $add_label = '';
         if (is_object($overlay)) {
             $add_label = $overlay->get_label('new_command', 'comments');
         }
         if (!$add_label) {
             $add_label = i18n::s('Post a comment');
         }
         // get a layout from anchor
         $layout =& Comments::get_layout($anchor, $item);
         // provide author information to layout
         if (is_object($layout) && isset($item['create_id']) && $item['create_id']) {
             $layout->set_focus('user:'******'create_id']);
         }
         // the maximum number of comments per page
         if (is_object($layout)) {
             $items_per_page = $layout->items_per_page();
         } else {
             $items_per_page = COMMENTS_PER_PAGE;
         }
         // the first comment to list
         $offset = 0;
         if (is_object($layout) && method_exists($layout, 'set_offset')) {
             $layout->set_offset($offset);
         }
         // build a complete box
         $box = array('bar' => array(), 'prefix_bar' => array(), 'text' => '');
         // feed the wall
         if (Comments::allow_creation($item, $anchor)) {
             $box['text'] .= Comments::get_form('article:' . $item['id']);
         }
         // a navigation bar for these comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'])) {
             if ($count > 20) {
                 $box['bar'] += array('_count' => sprintf(i18n::ns('%d comment', '%d comments', $count), $count));
             }
             // list comments by date
             $items = Comments::list_by_date_for_anchor('article:' . $item['id'], $offset, $items_per_page, $layout, TRUE);
             // actually render the html
             if (is_array($items)) {
                 $box['text'] .= Skin::build_list($items, 'rows');
             } elseif (is_string($items)) {
                 $box['text'] .= $items;
             }
             // navigation commands for comments
             $prefix = Comments::get_url('article:' . $item['id'], 'navigate');
             $box['bar'] = array_merge($box['bar'], Skin::navigate(NULL, $prefix, $count, $items_per_page, $zoom_index));
         }
         // ensure that the surfer can change content
         if (Articles::allow_modification($item, $anchor)) {
             // view or modify this section
             $menu = array();
             $box['bar'] += array(Articles::get_permalink($item) => i18n::s('View the page'));
             if (!is_object($overlay) || !($label = $overlay->get_label('edit_command', 'articles'))) {
                 $label = i18n::s('Edit this page');
             }
             $box['bar'] += array(Articles::get_url($item['id'], 'edit') => $label);
         }
         // show commands
         if (count($box['bar'])) {
             // commands before the box
             $box['text'] = Skin::build_list($box['prefix_bar'], 'menu_bar') . $box['text'];
             // append the menu bar at the end
             $box['text'] .= Skin::build_list($box['bar'], 'menu_bar');
         }
         // build a box
         if ($box['text']) {
             // put a title if there are other titles or if more than 2048 chars
             $title = '';
             if (preg_match('/(<h1|<h2|<h3|<table|\\[title|\\[subtitle)/i', $context['text'] . $text) || strlen($context['text'] . $text) > 2048) {
                 $title = $title_label;
             }
             // insert a full box
             $text .= Skin::build_box($title, $box['text'], 'header1', 'comments');
         }
         // assemble the full panel
         $panels[] = array('att' . $item['id'], ucfirst(Skin::strip($item['title'], 30)), 'atc' . $item['id'], $text);
     }
     // there is some box content
     if (trim($box['text'])) {
         $text .= $box['text'];
     }
     // format tabs
     $text = Skin::build_tabs($panels);
     // end of processing
     SQL::free($result);
     return $text;
 }
Ejemplo n.º 7
0
 /**
  * list articles as a daily weblog do
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         if (Surfer::is_associate()) {
             $text .= '<p>' . sprintf(i18n::s('Use the %s to populate this server.'), Skin::build_link('help/populate.php', i18n::s('Content Assistant'), 'shortcut')) . '</p>';
         }
         return $text;
     }
     // 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)) {
         // three components per box
         $box = array();
         $box['date'] = '';
         $box['title'] = '';
         $box['content'] = '';
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // permalink
         $url = Articles::get_permalink($item);
         // make a live title
         if (is_object($overlay)) {
             $box['title'] .= Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $box['title'] .= Codes::beautify_title($item['title']);
         }
         // make a clickable title
         $box['title'] = Skin::build_link($url, $box['title'], 'basic');
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $box['title'] = PRIVATE_FLAG . $box['title'];
         } elseif ($item['active'] == 'R') {
             $box['title'] = RESTRICTED_FLAG . $box['title'];
         }
         // flag articles updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $box['title'] .= EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $box['title'] .= NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $box['title'] .= UPDATED_FLAG;
         }
         // what's the date of publication?
         if (isset($item['publish_date']) && $item['publish_date'] > NULL_DATE) {
             $box['date'] .= Skin::build_date($item['publish_date'], 'publishing');
         }
         // the icon to put aside - never use anchor images
         if ($item['icon_url']) {
             $box['content'] .= '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $item['icon_url'] . '" class="left_image" alt="" /></a>';
         }
         // details
         $details = array();
         // 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');
         }
         // show details
         if (count($details)) {
             $box['content'] .= '<p class="details">' . implode(' ~ ', $details) . '</p>' . "\n";
         }
         // list categories by title, if any
         if ($items = Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) {
             $tags = array();
             foreach ($items as $id => $attributes) {
                 // add background color to distinguish this category against others
                 if (isset($attributes['background_color']) && $attributes['background_color']) {
                     $attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>';
                 }
                 $tags[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic');
             }
             $box['content'] .= '<p class="tags">' . implode(' ', $tags) . '</p>';
         }
         // the introduction text, if any
         if (is_object($overlay)) {
             $box['content'] .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction');
         } else {
             $box['content'] .= Skin::build_block($item['introduction'], 'introduction');
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $box['content'] .= $overlay->get_text('list', $item);
         }
         // the description
         $box['content'] .= Skin::build_block($item['description'], 'description', '', $item['options']);
         // a compact list of attached files
         if ($count = Files::count_for_anchor('article:' . $item['id'])) {
             // list files by date (default) or by title (option files_by_title)
             if (Articles::has_option('files_by', $anchor, $item) == 'title') {
                 $items = Files::list_by_title_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'compact');
             } else {
                 $items = Files::list_by_date_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'compact');
             }
             if (is_array($items)) {
                 $items = Skin::build_list($items, 'compact');
             }
             if ($items) {
                 $box['content'] .= Skin::build_box(i18n::s('Files'), $items, 'header2');
             }
         }
         // build a menu
         $menu = array();
         // read the article
         $menu[] = Skin::build_link($url, i18n::s('Permalink'), 'span');
         // info on related files
         if ($count) {
             $menu[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'span');
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'])) {
             $menu[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'span');
         }
         // comment
         if (Comments::allow_creation($item, $anchor)) {
             $menu[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Discuss'), 'span');
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             $menu[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'span');
         }
         // trackback
         if (Links::allow_trackback()) {
             $menu[] = Skin::build_link('links/trackback.php?anchor=' . urlencode('article:' . $item['id']), i18n::s('Reference this page'), 'span');
         }
         // a menu bar
         if (count($menu)) {
             $box['content'] .= '<div class="menu_bar" style="clear: left;">' . MENU_PREFIX . implode(MENU_SEPARATOR, $menu) . MENU_SUFFIX . "</div>\n";
         }
         // build a simple box for this post
         $text .= '<div class="post">' . '<div class="date">' . $box['date'] . '</div>' . '<h2><span>' . $box['title'] . '</span></h2>' . '<div class="content">' . $box['content'] . '</div>' . '</div>';
     }
     // end of processing
     SQL::free($result);
     return $text;
 }
Ejemplo n.º 8
0
 /**
  * list articles as digg do
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // empty list
     if (!SQL::count($result)) {
         $label = i18n::s('No page to display.');
         if (Surfer::is_associate()) {
             $label .= ' ' . sprintf(i18n::s('Use the %s to populate this server.'), Skin::build_link('help/populate.php', i18n::s('Content Assistant'), 'shortcut'));
         }
         $output = '<p>' . $label . '</p>';
         return $output;
     }
     // build a list of articles
     $text = '';
     $item_count = 0;
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     while ($item = SQL::fetch($result)) {
         // permalink
         $url = Articles::get_permalink($item);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // next item
         $item_count += 1;
         // section opening
         if ($item_count == 1) {
             $text .= '<div class="newest">' . "\n";
         }
         // reset everything
         $content = $prefix = $label = $suffix = $icon = '';
         // the icon to put aside
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } elseif (is_callable(array($anchor, 'get_bullet_url'))) {
             $icon = $anchor->get_bullet_url();
         }
         if ($icon) {
             $icon = '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $icon . '" class="right_image" alt="' . encode_field(i18n::s('View the page')) . '" title="' . encode_field(i18n::s('View the page')) . '" /></a>';
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // flag articles updated recently
         if ($item['create_date'] >= $context['fresh']) {
             $suffix .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= ' ' . UPDATED_FLAG;
         }
         // add details
         $details = array();
         // the author
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             if ($item['edit_name'] == $item['create_name']) {
                 $details[] = sprintf(i18n::s('by %s'), ucfirst($item['create_name']));
             } else {
                 $details[] = sprintf(i18n::s('by %s, %s'), ucfirst($item['create_name']), ucfirst($item['edit_name']));
             }
         }
         // the publish date
         $details[] = Skin::build_date($item['publish_date']);
         // rating
         $rating_label = '';
         if ($item['rating_count']) {
             $rating_label = Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])) . ' ' . sprintf(i18n::ns('%d rating', '%d ratings', $item['rating_count']), $item['rating_count']) . ' ';
         }
         // add a link to let surfer rate this item
         if (is_object($anchor) && !$anchor->has_option('without_rating')) {
             if (!$item['rating_count']) {
                 $rating_label .= i18n::s('Rate this page');
             }
             $rating_label = Skin::build_link(Articles::get_url($item['id'], 'like'), $rating_label, 'basic', i18n::s('Rate this page'));
         }
         // display current rating, and allow for rating
         $details[] = $rating_label;
         // details
         if (count($details)) {
             $content .= '<p class="details">' . ucfirst(implode(', ', $details)) . '</p>';
         }
         // the full introductory text
         if ($item['introduction']) {
             $content .= Codes::beautify($item['introduction'], $item['options']);
         } elseif (!is_object($overlay)) {
             include_once $context['path_to_root'] . 'articles/article.php';
             $article = new Article();
             $article->load_by_content($item);
             $content .= $article->get_teaser('teaser');
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $content .= $overlay->get_text('list', $item);
         }
         // an array of links
         $menu = array();
         // rate the article
         $menu = array_merge($menu, array(Articles::get_url($item['id'], 'like') => i18n::s('Rate this page')));
         // read the article
         $menu = array_merge($menu, array($url => i18n::s('Read more')));
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
             $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'basic');
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
             $link = Comments::get_url('article:' . $item['id'], 'list');
             $menu = array_merge($menu, array($link => sprintf(i18n::ns('%d comment', '%d comments', $count), $count)));
         }
         // discuss
         if (Comments::allow_creation($item, $anchor)) {
             $menu = array_merge($menu, array(Comments::get_url('article:' . $item['id'], 'comment') => i18n::s('Discuss')));
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             $menu = array_merge($menu, array($url . '#_attachments' => sprintf(i18n::ns('%d link', '%d links', $count), $count)));
         }
         // trackback
         if (Links::allow_trackback()) {
             $menu = array_merge($menu, array('links/trackback.php?anchor=' . urlencode('article:' . $item['id']) => i18n::s('Reference this page')));
         }
         // link to the anchor page
         if (is_object($anchor)) {
             $menu = array_merge($menu, array($anchor->get_url() => $anchor->get_title()));
         }
         // list up to three categories by title, if any
         if ($items = Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 3, 'raw')) {
             foreach ($items as $id => $attributes) {
                 $menu = array_merge($menu, array(Categories::get_permalink($attributes) => $attributes['title']));
             }
         }
         // append a menu
         $content .= Skin::build_list($menu, 'menu_bar');
         // insert a complete box
         $text .= Skin::build_box($icon . $prefix . Codes::beautify_title($item['title']) . $suffix, $content, 'header1', 'article_' . $item['id']);
         // section closing
         if ($item_count == 1) {
             $text .= '</div>' . "\n";
         }
     }
     // end of processing
     SQL::free($result);
     // add links to archives
     $anchor = Categories::get(i18n::c('monthly'));
     if (isset($anchor['id']) && ($items = Categories::list_by_date_for_anchor('category:' . $anchor['id'], 0, COMPACT_LIST_SIZE, 'compact'))) {
         $text .= Skin::build_box(i18n::s('Previous pages'), Skin::build_list($items, 'menu_bar'));
     }
     return $text;
 }
Ejemplo n.º 9
0
Archivo: list.php Proyecto: rair/yacs
         $box['bar'] += array('_count' => $count . ' ' . strtolower($label));
     }
     // navigation commands for comments
     $prefix = Comments::get_url($anchor->get_reference(), 'navigate');
     $box['bar'] = array_merge($box['bar'], Skin::navigate($anchor->get_url('comments'), $prefix, $count, $items_per_page, $page, FALSE));
     // list comments by date
     $items = Comments::list_by_date_for_anchor($anchor->get_reference(), $offset, $items_per_page, $layout, TRUE);
     // actually render the html
     if (is_array($items)) {
         $box['text'] .= Skin::build_list($items, 'rows');
     } elseif (is_string($items)) {
         $box['text'] .= $items;
     }
 }
 // the command to post a new comment, if this is allowed
 if (Comments::allow_creation($anchor)) {
     Skin::define_img('COMMENTS_ADD_IMG', 'comments/add.gif');
     $label = '';
     if (is_object($anchor->overlay)) {
         $label = $anchor->overlay->get_label('new_command', 'comments');
     }
     if (!$label) {
         $label = i18n::s('Add a comment');
     }
     $box['bar'] = array_merge($box['bar'], array(Comments::get_url($anchor->get_reference(), 'comment') => COMMENTS_ADD_IMG . $label));
 }
 // show commands
 if (@count($box['bar'])) {
     // append the menu bar at the end
     if (strlen($box['text']) > 10 && $count) {
         $box['text'] .= Skin::build_list($box['bar'], 'menu_bar');
Ejemplo n.º 10
0
            }
            // the submit button
            $menu[] = Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's', 'submit');
            // go to smileys
            //		$menu[] = Skin::build_link('smileys/', i18n::s('Smileys'), 'open');
            // display all commands
            $context['text'] .= Skin::finalize_list($menu, 'menu_bar');
            // end the form
            $context['text'] .= '</form>' . "\n";
        }
        // end of the wrapper
        $context['text'] .= '</div>' . "\n";
        // the AJAX part
        $js_script = 'var Comments = {' . "\n" . "\n" . '	url: "' . $context['url_to_home'] . $context['url_to_root'] . Comments::get_url($item['id'], 'thread') . '",' . "\n" . '	timestamp: 0,' . "\n" . "\n" . '	initialize: function() { },' . "\n" . "\n" . '	contribute: function() {' . "\n" . '		Yacs.startWorking();' . "\n" . '		$("#upload_frame").load(Comments.contributed);' . "\n" . '		return true;' . "\n" . '	},' . "\n" . "\n" . '	contributed: function() {' . "\n" . '		$("#upload_frame").unbind("load");' . "\n" . '		$("#comment_upload").slideUp(600);' . "\n" . '		$("#upload_option").slideUp();' . "\n" . '		$("#upload").replaceWith(\'<input type="file" id="upload" name="upload" size="30" />\');' . "\n" . '		$("#description").val("").trigger("change").focus();' . "\n" . '		setTimeout(function() {Comments.subscribe(); Yacs.stopWorking();}, 500);' . "\n" . '		if((typeof OpenTok == "object") && OpenTok.session)' . "\n" . '			OpenTok.signal();' . "\n" . '	},' . "\n" . "\n" . '	keypress: function(event) {' . "\n" . '		if(event.which == 13) {' . "\n" . '			$("#submit").trigger("click");' . "\n" . '			return false;' . "\n" . '		}' . "\n" . '	},' . "\n" . "\n" . '	showMore: function() {' . "\n" . '		var options = {};' . "\n" . '		var newHeight = $("#thread_text_panel").clientHeight + 200;' . "\n" . '		options.height =  newHeight + "px";' . "\n" . '		options.maxHeight =  newHeight + "px";' . "\n" . '		$("#thread_text_panel").css(options);' . "\n" . '	},' . "\n" . "\n" . '	subscribe: function() {' . "\n" . '		$.ajax(Comments.url, {' . "\n" . '			type: "get",' . "\n" . '			dataType: "json",' . "\n" . '			data: { "timestamp" : Comments.timestamp },' . "\n" . '			success: Comments.updateOnSuccess' . "\n" . '		});' . "\n" . "\n" . '	},' . "\n" . "\n" . '	subscribeToExtraUpdates: function() {' . "\n" . '		$.ajax("' . $context['url_to_home'] . $context['url_to_root'] . Users::get_url($item['id'], 'visit') . '", {' . "\n" . '			type: "get",' . "\n" . '			dataType: "html",' . "\n" . '			success: function(data) { $("#thread_roster_panel").html(data); }' . "\n" . '		});' . "\n" . "\n" . '		$.ajax("' . $context['url_to_home'] . $context['url_to_root'] . Files::get_url($item['id'], 'thread') . '", {' . "\n" . '			type: "get",' . "\n" . '			dataType: "html",' . "\n" . '			success: function(data) { $("#thread_files_panel").html(data); }' . "\n" . '		});' . "\n" . "\n" . '	},' . "\n" . "\n" . '	updateOnSuccess: function(response) {' . "\n" . '		if(!response) return;' . "\n" . '		if(response["status"] != "started")' . "\n" . '			window.location.reload(true);' . "\n" . '		$("#thread_text_panel").html("<div>" + response["items"] + "</div>");' . "\n" . '		var div = $("#thread_text_panel")[0];' . "\n" . '		var scrollHeight = Math.max(div.scrollHeight, div.clientHeight);' . "\n" . '		div.scrollTop = scrollHeight - div.clientHeight;' . "\n" . '		if(typeof Comments.windowOriginalTitle != "string")' . "\n" . '			Comments.windowOriginalTitle = document.title;' . "\n" . '		document.title = "[" + response["name"] + "] " + Comments.windowOriginalTitle;' . "\n" . '		Comments.timestamp = response["timestamp"];' . "\n" . '	}' . "\n" . "\n" . '}' . "\n" . "\n" . '// wait for new comments and for other updates' . "\n" . 'Comments.subscribeTimer = setInterval("Comments.subscribe()", 5000);' . "\n" . 'Comments.subscribeTimer = setInterval("Comments.subscribeToExtraUpdates()", 59999);' . "\n" . "\n" . '// load past contributions asynchronously' . "\n" . '$(function() {' . 'Comments.subscribe();' . 'location.hash="#thread_text_panel";' . '$("#description").tipsy({gravity: "s", fade: true, title: function () {return "' . i18n::s('Contribute here') . '";}, trigger: "manual"});' . '$("#description").tipsy("show");' . 'setTimeout("$(\'#description\').tipsy(\'hide\');", 10000);' . '$("textarea#description").autogrow();' . '});' . "\n";
        // only authenticated surfers can contribute
        if (Surfer::is_logged() && Comments::allow_creation($item, $anchor)) {
            $js_script .= '$(function() {' . '$("#description").focus();' . '});' . "\n" . '$(\'#description\').keypress( Comments.keypress );' . "\n";
        }
        break;
        Page::insert_script($js_script);
    case 'excluded':
        // surfer is not
        $context['text'] .= Skin::build_block(i18n::s('You have not been enrolled into this interactive chat.'), 'caution');
        break;
}
//
// trailer information
//
// add trailer information from the overlay, if any --opentok videos come from here
if (is_object($overlay)) {
    $context['text'] .= $overlay->get_text('trailer', $item);
Ejemplo n.º 11
0
 /**
  * list articles as slashdot do
  *
  * @param resource the SQL result
  * @return string the rendered text
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // build a list of articles
     include_once $context['path_to_root'] . 'articles/article.php';
     include_once $context['path_to_root'] . 'comments/comments.php';
     include_once $context['path_to_root'] . 'links/links.php';
     $class = 'even';
     while ($item = SQL::fetch($result)) {
         // get the related overlay
         $overlay = Overlay::load($item, 'article:' . $item['id']);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // the url to view this item
         $url = Articles::get_permalink($item);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // reset everything
         $content = $prefix = $label = $suffix = $icon = '';
         // the icon to put aside
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         }
         if ($icon) {
             $icon = '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $icon . '" class="right_image" alt="" title="' . encode_field(i18n::s('More')) . '" /></a>';
         }
         // flag sticky pages
         if ($item['rank'] < 10000) {
             $prefix .= STICKY_FLAG;
         }
         // signal articles to be published
         if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > $context['now']) {
             $prefix .= DRAFT_FLAG;
         }
         // signal restricted and private articles
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
             $suffix .= ' ' . LOCKED_FLAG;
         }
         // flag articles updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $suffix .= ' ' . EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= ' ' . UPDATED_FLAG;
         }
         // rating
         if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
             $suffix .= Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
         }
         // the full introductory text
         if ($item['introduction']) {
             $content .= Codes::beautify_introduction($item['introduction']);
         } elseif (!is_object($overlay)) {
             $article = new Article();
             $article->load_by_content($item);
             $content .= $article->get_teaser('teaser');
         }
         // insert overlay data, if any
         if (is_object($overlay)) {
             $content .= $overlay->get_text('list', $item);
         }
         // add details
         $details = array();
         // the author
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             if ($item['edit_name'] == $item['create_name']) {
                 $details[] = sprintf(i18n::s('by %s'), ucfirst($item['create_name']));
             } else {
                 $details[] = sprintf(i18n::s('by %s, %s'), ucfirst($item['create_name']), ucfirst($item['edit_name']));
             }
         }
         // the modification date
         if ($item['edit_date'] > NULL_DATE) {
             $details[] = Skin::build_date($item['edit_date']);
         }
         // read the article
         $details[] = Skin::build_link($url, i18n::s('More'), 'basic');
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
             $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'basic');
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
             $link = Comments::get_url('article:' . $item['id'], 'list');
             $details[] = Skin::build_link($link, sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'basic');
         }
         // discuss
         if (Comments::allow_creation($item, $anchor)) {
             $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Discuss'), 'basic');
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'basic');
         }
         // list categories by title, if any
         if ($items =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) {
             foreach ($items as $id => $attributes) {
                 // add background color to distinguish this category against others
                 if (isset($attributes['background_color']) && $attributes['background_color']) {
                     $attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>';
                 }
                 $details[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic');
             }
         }
         // details
         if (count($details)) {
             $content .= '<div><span class="details">' . ucfirst(implode(' - ', $details)) . '</span></div>';
         }
         // insert a complete box
         $text .= Skin::build_box(Skin::build_link($url, $prefix . $title . $suffix, 'basic', i18n::s('View the page')), $icon . $content, 'header1 ' . $class, 'article_' . $item['id']);
         // stack boxes
         if ($class == 'even') {
             $class = 'odd';
         } else {
             $class = 'even';
         }
     }
     // end of processing
     SQL::free($result);
     return $text;
 }
Ejemplo n.º 12
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 some text
     $output = '';
     // empty list
     if (!SQL::count($result)) {
         return $output;
     }
     // build a list of comments
     $rows = array();
     include_once $context['path_to_root'] . 'comments/comments.php';
     while ($item = SQL::fetch($result)) {
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // get poster information
         $poster = array();
         if ($item['create_name']) {
             if (!($poster = Users::get($item['create_id']))) {
                 $poster['id'] = 0;
                 $poster['full_name'] = $item['create_name'];
                 $poster['email'] = $item['create_address'];
             }
         } else {
             if (!($poster = Users::get($item['edit_id']))) {
                 $poster['id'] = 0;
                 $poster['full_name'] = $item['edit_name'];
                 $poster['email'] = $item['edit_address'];
             }
         }
         // author description
         $author = '';
         // avatar, but not for notifications
         if ($item['type'] != 'notification' && isset($poster['avatar_url']) && $poster['avatar_url']) {
             $author .= '<img src="' . $poster['avatar_url'] . '" alt="" title="avatar" class="avatar" />' . BR;
         }
         // link to poster, if possible
         if (isset($poster['id'])) {
             $author .= Users::get_link($poster['full_name'], $poster['email'], $poster['id']);
         }
         // commands to handle this comment
         $menu = array();
         // get an icon for this comment
         $icon = Comments::get_img($item['type']);
         // link to comment permalink
         $label = Skin::build_link(Comments::get_url($item['id']), $icon, 'basic', i18n::s('View this comment')) . ' ';
         // the creation date
         if ($item['create_date']) {
             $label .= Skin::build_date($item['create_date'], 'with_hour');
         } else {
             $label .= Skin::build_date($item['edit_date'], 'with_hour');
         }
         // flag new comments
         if ($item['create_date'] >= $context['fresh']) {
             $label .= NEW_FLAG;
         }
         $menu[] = $label;
         // an approval -- can be modified, but not deleted
         if ($item['type'] == 'approval') {
             // additional commands for associates and poster and editor
             if ($anchor->is_owned()) {
                 Skin::define_img('COMMENTS_EDIT_IMG', 'comments/edit.gif');
                 $menu[] = Skin::build_link(Comments::get_url($item['id'], 'edit'), COMMENTS_EDIT_IMG . i18n::s('Edit'), 'basic');
             }
             // an automatic notification -- can be deleted, but not modified
         } elseif ($item['type'] == 'notification') {
             // additional commands for associates and poster and editor
             if ($anchor->is_owned()) {
                 Skin::define_img('COMMENTS_DELETE_IMG', 'comments/delete.gif');
                 $menu[] = Skin::build_link(Comments::get_url($item['id'], 'delete'), COMMENTS_DELETE_IMG . i18n::s('Delete'), 'basic');
             }
             // regular case
         } else {
             // additional commands for associates and poster and editor
             if (Comments::allow_modification($anchor, $item)) {
                 Skin::define_img('COMMENTS_EDIT_IMG', 'comments/edit.gif');
                 $menu[] = Skin::build_link(Comments::get_url($item['id'], 'edit'), COMMENTS_EDIT_IMG . i18n::s('Edit'), 'basic');
                 Skin::define_img('COMMENTS_DELETE_IMG', 'comments/delete.gif');
                 $menu[] = Skin::build_link(Comments::get_url($item['id'], 'delete'), COMMENTS_DELETE_IMG . i18n::s('Delete'), 'basic');
             }
         }
         // comment main text
         $text = '';
         // state clearly that this is an approval
         if ($item['type'] == 'approval' && isset($poster['id'])) {
             $text .= '<p>' . sprintf(i18n::s('%s has provided his approval'), Users::get_link($poster['full_name'], $poster['email'], $poster['id'])) . '</p>';
         }
         // display comment main text
         $text .= $item['description'];
         // display signature, but not for notifications
         if ($item['type'] != 'notification') {
             $text .= Users::get_signature($item['create_id']);
         }
         // format and display
         $text = ucfirst(trim($text));
         // float the menu on the right
         if (count($menu)) {
             $text = '<div style="text-align: right">' . Skin::finalize_list($menu, 'menu') . '</div>' . $text;
         }
         // comment has been modified
         if ($item['create_name'] && $item['edit_name'] != $item['create_name']) {
             $text .= '<p class="details">' . ucfirst(sprintf(i18n::s('edited by %s %s'), $item['edit_name'], Skin::build_date($item['edit_date']))) . '</p>';
         }
         // potential replies to this comment
         if ($item['type'] != 'notification') {
             // look for replies
             if ($replies = Comments::list_next($item['id'], 'replies')) {
                 if (is_array($replies)) {
                     $replies = Skin::build_list($replies, 'compact');
                 }
                 $text .= '<div>' . $replies . '</div>';
             }
             // allow to reply to this comment
             if (Comments::allow_creation($anchor)) {
                 // the form to edit a comment
                 $text .= '<form method="post" action="' . $context['url_to_root'] . Comments::get_url($item['id'], 'reply') . '" onsubmit="return validateDocumentPost(this)" enctype="multipart/form-data"><div style="margin-top: 1em;">';
                 // reference the anchor page
                 $text .= '<input type="hidden" name="anchor" value="' . $item['anchor'] . '" />';
                 // remember the id of the replied comment
                 $text .= '<input type="hidden" name="previous_id" value="' . $item['id'] . '" />';
                 // notify watchers
                 $text .= '<input type="hidden" name="notify_watchers" value="Y" />';
                 // ensure id uniqueness
                 static $fuse_id;
                 if (!isset($fuse_id)) {
                     $fuse_id = 1;
                 } else {
                     $fuse_id++;
                 }
                 // a textarea that grow on focus
                 Page::insert_script('var reply' . $fuse_id . '=1;');
                 $text .= '<textarea name="description" id="reply' . $fuse_id . '"' . ' rows="1" cols="50"' . ' onfocus="if(reply' . $fuse_id . '){$(\'div#submit' . $fuse_id . '\').slideDown(600);reply' . $fuse_id . '=0;}">' . '</textarea>' . "\n";
                 // fix number of rows in firefox
                 Page::insert_script('$(function(){' . '$("textarea#reply' . $fuse_id . '")' . '.each(function(){' . 'var lineHeight = parseFloat($(this).css("line-height"));' . 'var lines = $(this).attr("rows")*1 || $(this).prop("rows")*1;' . '$(this).css("height", lines*lineHeight);' . '})' . '.autogrow();' . '});' . "\n");
                 // the submit button
                 $text .= '<div class="menu_bar" style="display: none;" id="submit' . $fuse_id . '">' . Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's') . '</div>';
                 // end of the form
                 $text .= '</div></form>';
             }
         }
         // the main part of the comment, with an id
         $text = '<td class="comment ' . $item['type'] . '" id="comment_' . $item['id'] . '">' . $text . '</td>';
         // this is another row of the output
         $rows[] = '<td class="author ' . $item['type'] . '">' . $author . '</td>' . $text;
     }
     // end of processing
     SQL::free($result);
     // sanity check
     if (!count($rows)) {
         return '';
     }
     // return a table
     $output = Skin::table_prefix('yabb');
     $count = 1;
     foreach ($rows as $row) {
         if ($count % 2) {
             $output .= '<tr class="odd">' . $row . '</tr>';
         } else {
             $output .= '<tr class="even">' . $row . '</tr>';
         }
         $count++;
     }
     $output .= '</table>';
     // process yacs codes
     $output = Codes::beautify($output);
     return $output;
 }
Ejemplo n.º 13
0
Archivo: edit.php Proyecto: rair/yacs
    $login_hook = 'anchor=' . $target_anchor;
}
// fight hackers
$id = strip_tags($id);
$target_anchor = strip_tags($target_anchor);
// get the item from the database
$item = Comments::get($id);
// get the related anchor, if any
$anchor = NULL;
if (isset($item['anchor']) && $item['anchor']) {
    $anchor = Anchors::get($item['anchor']);
} elseif ($target_anchor) {
    $anchor = Anchors::get($target_anchor);
}
// associates and authenticated editors can modify any comment
if ($action != 'edit' && Comments::allow_creation($anchor)) {
    $permitted = TRUE;
} elseif ($action == 'edit' && Comments::allow_modification($anchor, $item)) {
    $permitted = TRUE;
} else {
    $permitted = FALSE;
}
// do not always show the edition form
$with_form = FALSE;
// load the skin, maybe with a variant
load_skin('comments', $anchor);
// clear the tab we are in, if any
if (is_object($anchor)) {
    $context['current_focus'] = $anchor->get_focus();
}
// the path to this page
Ejemplo n.º 14
0
Archivo: thread.php Proyecto: rair/yacs
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    die(i18n::s('You are not allowed to perform this operation.'));
    // an anchor is mandatory
} elseif (!is_object($anchor)) {
    Safe::header('Status: 404 Not Found', TRUE, 404);
    die(i18n::s('No anchor has been found.'));
    // the anchor has to be viewable by this surfer
} elseif (!$anchor->is_viewable()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    die(i18n::s('You are not allowed to perform this operation.'));
    // robots cannot contribute
} elseif (isset($_REQUEST['message']) && Surfer::may_be_a_robot()) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    die(i18n::s('You are not allowed to perform this operation.'));
    // this anchor does not accept contributions
} elseif (isset($_REQUEST['message']) && is_object($anchor) && !Comments::allow_creation($anchor)) {
    Safe::header('Status: 401 Unauthorized', TRUE, 401);
    die(i18n::s('You are not allowed to perform this operation.'));
    // a new contribution has been submitted
} elseif (isset($_REQUEST['message']) && trim($_REQUEST['message'])) {
    // sanitize the message
    $_REQUEST['message'] = str_replace(array("\r\n", "\r"), "\n", trim($_REQUEST['message']));
    // protect from hackers
    if (isset($_REQUEST['edit_name'])) {
        $_REQUEST['edit_name'] = preg_replace(FORBIDDEN_IN_NAMES, '_', $_REQUEST['edit_name']);
    }
    if (isset($_REQUEST['edit_address'])) {
        $_REQUEST['edit_address'] = encode_link($_REQUEST['edit_address']);
    }
    // append to previous comment during 10 minutes
    $continuity_limit = gmstrftime('%Y-%m-%d %H:%M:%S', time() - 600);
Ejemplo n.º 15
0
 /**
  * list articles as slashdot do
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // 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'] . 'articles/article.php';
     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');
         }
         // document this section
         $content = $prefix = $title = $suffix = $icon = '';
         $menu = array();
         // permalink
         $url = Sections::get_permalink($item);
         // get the anchor
         $anchor = Anchors::get($item['anchor']);
         // get the related overlay, if any
         $overlay = Overlay::load($item, 'section:' . $item['id']);
         // use the title to label the link
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // signal restricted and private sections
         if ($item['active'] == 'N') {
             $prefix .= PRIVATE_FLAG;
         } elseif ($item['active'] == 'R') {
             $prefix .= RESTRICTED_FLAG;
         }
         // this is another row of the output
         $text .= '<tr class="' . $class_title . '"><th>' . $prefix . Skin::build_link($url, $title, 'basic', i18n::s('View the section')) . $suffix . '</th></tr>' . "\n";
         // document most recent page here
         $content = $prefix = $title = $suffix = $icon = '';
         $menu = array();
         // branches of this tree
         $anchors = Sections::get_branch_at_anchor('section:' . $item['id']);
         // get last post
         $article =& Articles::get_newest_for_anchor($anchors, TRUE);
         if ($article['id']) {
             // permalink
             $url = Articles::get_permalink($article);
             // get the anchor
             $anchor = Anchors::get($article['anchor']);
             // get the related overlay, if any
             $overlay = Overlay::load($item, 'section:' . $item['id']);
             // use the title to label the link
             if (is_object($overlay)) {
                 $title = Codes::beautify_title($overlay->get_text('title', $article));
             } else {
                 $title = Codes::beautify_title($article['title']);
             }
             // signal restricted and private articles
             if ($article['active'] == 'N') {
                 $prefix .= PRIVATE_FLAG;
             } elseif ($article['active'] == 'R') {
                 $prefix .= RESTRICTED_FLAG;
             }
             // the icon to put aside
             if ($article['thumbnail_url']) {
                 $icon = $article['thumbnail_url'];
             }
             // the icon to put aside
             if (!$icon && is_callable(array($anchor, 'get_bullet_url'))) {
                 $icon = $anchor->get_bullet_url();
             }
             if ($icon) {
                 $icon = '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $icon . '" class="right_image" alt="" title="' . encode_field(i18n::s('View the page')) . '" /></a>';
             }
             // the introductory text
             if ($article['introduction']) {
                 $content .= Codes::beautify_introduction($article['introduction']);
             } elseif (!is_object($overlay)) {
                 $handle = new Article();
                 $handle->load_by_content($article);
                 $content .= $handle->get_teaser('teaser');
             }
             // insert overlay data, if any
             if (is_object($overlay)) {
                 $content .= $overlay->get_text('list', $article);
             }
             // link to description, if any
             if (trim($article['description'])) {
                 $menu[] = Skin::build_link($url, i18n::s('Read more') . MORE_IMG, 'span', i18n::s('View the page'));
             }
             // info on related files
             if ($count = Files::count_for_anchor('article:' . $article['id'])) {
                 $menu[] = sprintf(i18n::ns('%d file', '%d files', $count), $count);
             }
             // info on related comments
             if ($count = Comments::count_for_anchor('article:' . $article['id'])) {
                 $menu[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count);
             }
             // discuss
             if (Comments::allow_creation($article, $anchor)) {
                 $menu[] = Skin::build_link(Comments::get_url('article:' . $article['id'], 'comment'), i18n::s('Discuss'), 'span');
             }
             // the main anchor link
             if (is_object($anchor) && (!isset($this->focus) || $article['anchor'] != $this->focus)) {
                 $menu[] = Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'span', i18n::s('View the section'));
             }
             // list up to three categories by title, if any
             if ($items =& Members::list_categories_by_title_for_member('article:' . $article['id'], 0, 3, 'raw')) {
                 foreach ($items as $id => $attributes) {
                     $menu[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'span');
                 }
             }
             // append a menu
             $content .= '<p>' . Skin::finalize_list($menu, 'menu') . '</p>';
             // this is another row of the output
             $text .= '<tr class="' . $class_detail . '"><td>' . '<h3 class="top"><span>' . Skin::build_link($url, $prefix . $title . $suffix, 'basic', i18n::s('View the page')) . '</span></h3>' . '<div class="content">' . $icon . $content . '</div>' . '</td></tr>' . "\n";
         }
     }
     // end of processing
     SQL::free($result);
     $text .= Skin::table_suffix();
     return $text;
 }
Ejemplo n.º 16
0
    }
    $context['page_tools'][] = Skin::build_link($url, ARTICLES_ADD_IMG . $label, 'basic', i18n::s('Add new content to this section'));
    // the command to create a new poll, if no overlay nor template has been defined for content of this section
    if ((!isset($item['content_overlay']) || !trim($item['content_overlay'])) && (!isset($item['articles_templates']) || !trim($item['articles_templates'])) && (!is_object($anchor) || !$anchor->get_templates_for('article'))) {
        Skin::define_img('ARTICLES_POLL_IMG', 'articles/poll.gif');
        $url = 'articles/edit.php?anchor=' . urlencode('section:' . $item['id']) . '&amp;variant=poll';
        $context['page_tools'][] = Skin::build_link($url, ARTICLES_POLL_IMG . i18n::s('Add a poll'), 'basic', i18n::s('Add new content to this section'));
    }
}
// add a section
if (Sections::allow_creation($item, $anchor)) {
    Skin::define_img('SECTIONS_ADD_IMG', 'sections/add.gif');
    $context['page_tools'][] = Skin::build_link('sections/edit.php?anchor=' . urlencode('section:' . $item['id']), SECTIONS_ADD_IMG . i18n::s('Add a section'), 'basic', i18n::s('Add a section'));
}
// comment this page if anchor does not prevent it
if (Comments::allow_creation($item, $anchor, 'section')) {
    Skin::define_img('COMMENTS_ADD_IMG', 'comments/add.gif');
    $context['page_tools'][] = Skin::build_link(Comments::get_url('section:' . $item['id'], 'comment'), COMMENTS_ADD_IMG . i18n::s('Post a comment'), 'basic', i18n::s('Express yourself, and say what you think.'));
}
// add a file, if upload is allowed
if (Files::allow_creation($item, $anchor, 'section')) {
    Skin::define_img('FILES_UPLOAD_IMG', 'files/upload.gif');
    $context['page_tools'][] = Skin::build_link('files/edit.php?anchor=' . urlencode('section:' . $item['id']), FILES_UPLOAD_IMG . i18n::s('Add a file'), 'basic', i18n::s('Attach related files.'));
}
// add a link
if (Links::allow_creation($item, $anchor, 'section')) {
    Skin::define_img('LINKS_ADD_IMG', 'links/add.gif');
    $context['page_tools'][] = Skin::build_link('links/edit.php?anchor=' . urlencode('section:' . $item['id']), LINKS_ADD_IMG . i18n::s('Add a link'), 'basic', i18n::s('Contribute to the web and link to relevant pages.'));
}
// post an image, if upload is allowed
if (Images::allow_creation($item, $anchor, 'section')) {
Ejemplo n.º 17
0
 /**
  * layout one of the newest articles
  *
  * @param array the article
  * @return string the rendered text
  */
 function layout_newest($item)
 {
     global $context;
     // permalink
     $url = Articles::get_permalink($item);
     // get the related overlay, if any
     $overlay = Overlay::load($item, 'article:' . $item['id']);
     // get the anchor
     $anchor = Anchors::get($item['anchor']);
     // the icon to put aside
     $icon = '';
     if ($item['thumbnail_url']) {
         $icon = $item['thumbnail_url'];
     } elseif (is_callable(array($anchor, 'get_bullet_url'))) {
         $icon = $anchor->get_bullet_url();
     }
     if ($icon) {
         $icon = '<img src="' . $icon . '" class="left_image" alt="" />';
     }
     // 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']);
     }
     // rating
     if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) {
         $title .= ' ' . Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
     }
     // pack in a block
     $text = '<h3>' . Skin::build_link($url, $icon . $title, 'basic') . '</h3>';
     // the introduction
     $text .= '<p style="margin-top: 0;">';
     // signal restricted and private articles
     if ($item['active'] == 'N') {
         $text .= PRIVATE_FLAG;
     } elseif ($item['active'] == 'R') {
         $text .= RESTRICTED_FLAG;
     }
     // the author
     $author = '';
     if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
         $author = sprintf(i18n::s('by %s'), $item['create_name']) . ' ';
     }
     // date
     $text .= '<span class="details">' . $author . Skin::build_date($item['publish_date']) . '</span>';
     // the introductory text
     if ($item['introduction']) {
         $text .= ' - ' . Codes::beautify_introduction($item['introduction']);
     } elseif (!is_object($overlay) && $item['description']) {
         $text .= ' - ' . Skin::cap(Codes::beautify($item['description'], $item['options']), 25, $url);
     }
     // end of the introduction
     $text .= '</p>' . "\n";
     // insert overlay data, if any
     if (is_object($overlay)) {
         $text .= $overlay->get_text('list', $item);
     }
     // read this article
     $text .= '<p class="details right">' . Skin::build_link($url, i18n::s('View the page'), 'basic');
     // discuss
     if (Comments::allow_creation($item, $anchor)) {
         $text .= BR . Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Discuss'), 'basic');
     }
     // info on related comments
     if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
         $link = Comments::get_url('article:' . $item['id'], 'list');
         $text .= ' - ' . Skin::build_link($link, sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'basic');
     }
     // info on related links
     if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
         $text .= ' - ' . Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'basic');
     }
     // end of details
     $text .= '</p>';
     return $text;
 }
Ejemplo n.º 18
0
 /**
  * layout one recent article
  *
  * @param array the article
  * @return an array ($prefix, $label, $suffix)
  **/
 function layout_recent($item)
 {
     global $context;
     // permalink
     $url = Articles::get_permalink($item);
     // get the related overlay, if any
     $overlay = Overlay::load($item, 'article:' . $item['id']);
     // get the anchor
     $anchor = Anchors::get($item['anchor']);
     // use the title to label the link
     if (is_object($overlay)) {
         $title = Codes::beautify_title($overlay->get_text('title', $item));
     } else {
         $title = Codes::beautify_title($item['title']);
     }
     // reset everything
     $prefix = $suffix = '';
     // signal restricted and private articles
     if ($item['active'] == 'N') {
         $prefix .= PRIVATE_FLAG;
     } elseif ($item['active'] == 'R') {
         $prefix .= RESTRICTED_FLAG;
     }
     // rating
     if ($item['rating_count']) {
         $suffix .= Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic');
     }
     // the introductory text
     $introduction = '';
     if (is_object($overlay)) {
         $introduction = $overlay->get_text('introduction', $item);
     } elseif ($item['introduction']) {
         $introduction = $item['introduction'];
     }
     if ($introduction) {
         $suffix .= ' -&nbsp;' . Codes::beautify_introduction($introduction);
     }
     // other details
     $details = array();
     // the author
     $author = '';
     if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
         $author = sprintf(i18n::s('by %s'), $item['create_name']) . ' ';
     }
     // date
     $details[] = $author . Skin::build_date($item['publish_date']);
     // info on related files
     if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
         $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'basic');
     }
     // info on related comments
     $link = Comments::get_url('article:' . $item['id'], 'list');
     if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
         $details[] = Skin::build_link($link, sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'basic');
     }
     // discuss
     if (Comments::allow_creation($item, $anchor)) {
         $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Discuss'), 'basic');
     }
     // info on related links
     if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
         $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'basic');
     }
     // append a menu
     $suffix .= Skin::finalize_list($details, 'menu');
     // display all tags
     if ($item['tags']) {
         $suffix .= ' <p class="tags" style="margin-top: 3px;">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</p>';
     }
     // insert an array of links
     return array($prefix, $title, $suffix);
 }
Ejemplo n.º 19
0
 /**
  * list articles as digg do
  *
  * @param resource the SQL result
  * @return string the rendered text
  *
  * @see layouts/layout.php
  **/
 function layout($result)
 {
     global $context;
     // we return some text
     $text = '';
     // empty list
     if (!SQL::count($result)) {
         return $text;
     }
     // build a list of articles
     $text = '';
     $item_count = 0;
     include_once $context['path_to_root'] . 'articles/article.php';
     include_once $context['path_to_root'] . 'comments/comments.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);
         // make a live title
         if (is_object($overlay)) {
             $title = Codes::beautify_title($overlay->get_text('title', $item));
         } else {
             $title = Codes::beautify_title($item['title']);
         }
         // next item
         $item_count += 1;
         // section opening
         if ($item_count == 1) {
             $text .= '<div class="newest">' . "\n";
         }
         // reset everything
         $content = $prefix = $label = $suffix = $icon = '';
         // the icon to put aside
         if ($item['thumbnail_url']) {
             $icon = $item['thumbnail_url'];
         } elseif (is_callable(array($anchor, 'get_bullet_url'))) {
             $icon = $anchor->get_bullet_url();
         }
         if ($icon) {
             $icon = '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $icon . '" class="right_image" alt="" title="' . encode_field(i18n::s('View the page')) . '" /></a>';
         }
         // rating
         if ($item['rating_count']) {
             $rating_label = sprintf(i18n::ns('%s vote', '%s votes', $item['rating_count']), '<span class="big">' . $item['rating_count'] . '</span>' . BR);
         } else {
             $rating_label = i18n::s('No vote');
         }
         // present results
         $digg = '<div class="digg"><div class="votes">' . $rating_label . '</div>';
         // a rating has already been registered
         if (isset($_COOKIE['rating_' . $item['id']])) {
             Cache::poison();
         } else {
             $digg .= '<div class="rate">' . Skin::build_link(Articles::get_url($item['id'], 'like'), i18n::s('Rate it'), 'basic') . '</div>';
         }
         // close digg-like area
         $digg .= '</div>';
         // 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;
         }
         // signal locked articles
         if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) {
             $suffix .= ' ' . LOCKED_FLAG;
         }
         // flag articles updated recently
         if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) {
             $suffix .= ' ' . EXPIRED_FLAG;
         } elseif ($item['create_date'] >= $context['fresh']) {
             $suffix .= ' ' . NEW_FLAG;
         } elseif ($item['edit_date'] >= $context['fresh']) {
             $suffix .= ' ' . UPDATED_FLAG;
         }
         // the full introductory text
         if (is_object($overlay)) {
             $content .= Codes::beautify_introduction($overlay->get_text('introduction', $item));
         }
         if ($item['introduction']) {
             $content .= Codes::beautify_introduction($item['introduction']);
         } else {
             $article = new Article();
             $article->load_by_content($item);
             $content .= $article->get_teaser('teaser');
         }
         // add details
         $details = array();
         // the author
         if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') {
             if ($item['edit_name'] == $item['create_name']) {
                 $details[] = sprintf(i18n::s('by %s'), ucfirst($item['create_name']));
             } else {
                 $details[] = sprintf(i18n::s('by %s, %s'), ucfirst($item['create_name']), ucfirst($item['edit_name']));
             }
         }
         // the publish date
         if (isset($item['publish_date']) && $item['publish_date'] > NULL_DATE) {
             $details[] = Skin::build_date($item['publish_date']);
         }
         // read the article
         $details[] = Skin::build_link($url, i18n::s('View the page'), 'basic');
         // info on related files
         if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) {
             $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'basic');
         }
         // info on related comments
         if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) {
             $link = Comments::get_url('article:' . $item['id'], 'list');
             $details[] = Skin::build_link($link, sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'basic');
         }
         // discuss
         if (Comments::allow_creation($item, $anchor)) {
             $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Discuss'), 'basic');
         }
         // info on related links
         if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) {
             $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'basic');
         }
         // link to the anchor page
         if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) {
             $details[] = Skin::build_link($anchor->get_url(), $anchor->get_title(), 'basic');
         }
         // list categories by title, if any
         if ($items =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) {
             foreach ($items as $id => $attributes) {
                 // add background color to distinguish this category against others
                 if (isset($attributes['background_color']) && $attributes['background_color']) {
                     $attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>';
                 }
                 $details[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic');
             }
         }
         // details
         if (count($details)) {
             $content .= '<p class="details">' . ucfirst(implode(' - ', $details)) . '</p>';
         }
         // manage layout
         $content = '<div class="digg_content">' . $digg . $content . '</div>';
         // insert a complete box
         $text .= Skin::build_box($prefix . $title . $suffix, $icon . $content, 'header1', 'article_' . $item['id']);
         // section closing
         if ($item_count == 1) {
             $text .= '</div>' . "\n";
         }
     }
     // end of processing
     SQL::free($result);
     return $text;
 }