/** * display content below main panel * * Everything is in a separate panel * * @param array the hosting record, if any * @return some HTML to be inserted into the resulting page */ function &get_trailer_text($host = NULL) { $text = ''; // display the following only if at least one comment has been attached to this page if (is_object($this->anchor) && !Comments::count_for_anchor($this->anchor->get_reference())) { return $text; } // ask the surfer if he has not answered yet, and if the page has not been locked $ask = TRUE; if (isset($_COOKIE['rating_' . $host['id']])) { $ask = FALSE; } elseif (isset($host['locked']) && $host['locked'] == 'Y') { $ask = FALSE; } // ask the surfer if ($ask) { $text = '<p style="line-height: 2.5em;">' . i18n::s('Has this page been useful to you?') . ' ' . Skin::build_link(Articles::get_url($host['id'], 'like'), i18n::s('Yes'), 'button') . ' ' . Skin::build_link(Articles::get_url($host['id'], 'dislike'), i18n::s('No'), 'button') . '</p>'; // or report on results } elseif ($host['rating_count']) { $text = '<p>' . Skin::build_rating_img((int) round($host['rating_sum'] / $host['rating_count'])) . ' ' . sprintf(i18n::ns('%d rating', '%d ratings', $host['rating_count']), $host['rating_count']) . '</p>'; } // add a title if ($text) { $text = Skin::build_box(i18n::s('Feed-back'), $text); } // done return $text; }
/** * extend the page menu * * @param string script name * @param string target anchor, if any * @param array current menu * @return array updated menu */ function add_commands($script, $anchor, $menu = array()) { global $context; // limit the scope of our check to viewed pages if (!preg_match('/articles\\/view/', $script)) { return $menu; } // surfer has to be authenticated if (!Surfer::is_logged()) { return $menu; } // sanity checks if (!$anchor) { Logger::error(i18n::s('No anchor has been found.')); } elseif (!($target = Anchors::get($anchor))) { Logger::error(i18n::s('No anchor has been found.')); } elseif (!$this->parameters) { Logger::error(sprintf(i18n::s('No parameter has been provided to %s'), 'behaviors/move_on_article_access')); } else { // look at parent container if possible if (!($origin = Anchors::get($target->get_parent()))) { $origin = $target; } // only container editors can proceed if ($origin->is_assigned() || Surfer::is_associate()) { // load target section $tokens = explode(' ', $this->parameters, 2); if ($section = Anchors::get('section:' . $tokens[0])) { // make a label if (count($tokens) < 2) { $tokens[1] = sprintf(i18n::s('Move to %s'), $section->get_title()); } // the target link to move the page $link = Articles::get_url(str_replace('article:', '', $anchor), 'move', str_replace('section:', '', $section->get_reference())); // make a sub-menu $menu = array_merge(array($link => array('', $tokens[1], '', 'button')), $menu); } } } return $menu; }
} // lock command provided to container and page owners if ($cur_article->allows('locking')) { if (!isset($item['locked']) || $item['locked'] == 'N') { Skin::define_img('ARTICLES_LOCK_IMG', 'articles/lock.gif'); $context['page_tools'][] = Skin::build_link(Articles::get_url($item['id'], 'lock'), ARTICLES_LOCK_IMG . i18n::s('Lock')); } else { Skin::define_img('ARTICLES_UNLOCK_IMG', 'articles/unlock.gif'); $context['page_tools'][] = Skin::build_link(Articles::get_url($item['id'], 'lock'), ARTICLES_UNLOCK_IMG . i18n::s('Unlock')); } } // delete command if ($cur_article->allows('deletion')) { Skin::define_img('ARTICLES_DELETE_IMG', 'articles/delete.gif'); if (!is_object($overlay) || !($label = $overlay->get_label('delete_command', 'articles'))) { $label = i18n::s('Delete this page'); } $context['page_tools'][] = Skin::build_link(Articles::get_url($item['id'], 'delete'), ARTICLES_DELETE_IMG . $label); } // duplicate command provided to container owners if ($cur_article->allows('duplicate')) { Skin::define_img('ARTICLES_DUPLICATE_IMG', 'articles/duplicate.gif'); if (!is_object($overlay) || !($label = $overlay->get_label('duplicate_command', 'articles'))) { $label = i18n::s('Duplicate this page'); } $context['page_tools'][] = Skin::build_link(Articles::get_url($item['id'], 'duplicate'), ARTICLES_DUPLICATE_IMG . $label); } } } // render the skin render_skin();
$menu = array(); // the submit button $menu[] = Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's'); // cancel button if (isset($item['id'])) { $menu[] = Skin::build_link(Users::get_permalink($item), i18n::s('Cancel'), 'span'); } // several options to check $suffix = array(); // associates may decide to not stamp changes -- complex command if (isset($item['id']) && Surfer::is_associate() && Surfer::has_all()) { $suffix[] = '<input type="checkbox" name="silent" value="Y" />' . ' ' . i18n::s('Do not change modification date.'); } // link to privacy statement if (!isset($item['id']) && !Surfer::is_associate()) { $suffix[] = '<span>' . sprintf(i18n::s('By clicking submit, you agree to the terms and conditions outlined in the %s.'), Skin::build_link(Articles::get_url('privacy'), i18n::s('privacy statement'), 'basic')) . '</span>'; } // validate page content if (Surfer::is_associate()) { $suffix[] = '<input type="checkbox" name="option_validate" value="Y" checked="checked" /> ' . i18n::s('Ensure this post is valid XHTML.'); } // an assistant-like rendering at page bottom $context['text'] .= Skin::build_assistant_bottom('', $menu, $suffix, isset($item['tags']) ? $item['tags'] : ''); // transmit the id as a hidden field if (isset($item['id']) && $item['id']) { $context['text'] .= '<input type="hidden" name="id" value="' . $item['id'] . '" />'; } // transmit the link to use after registration if (!isset($item['id']) && isset($_REQUEST['forward']) && $_REQUEST['forward']) { $context['text'] .= '<input type="hidden" name="forward" value="' . encode_field($_REQUEST['forward']) . '" />'; }
/** * 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; }
/** * 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; } // page size for comments include_once $context['path_to_root'] . 'comments/layout_comments_as_updates.php'; $layout = new Layout_comments_as_updates(); // build a list of articles $rows = array(); include_once $context['path_to_root'] . 'comments/comments.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 $text = $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, and 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'); } // select an icon for this thread $item['comments_count'] = Comments::count_for_anchor('article:' . $item['id']); if (is_object($overlay) && $overlay->attributes['overlay_type'] == 'poll') { Skin::define_img('POLL_IMG', 'articles/poll.gif'); $icon = POLL_IMG; } elseif ($item['rank'] < 10000) { Skin::define_img('STICKY_THREAD_IMG', 'articles/sticky_thread.gif'); $icon = STICKY_THREAD_IMG; } elseif (isset($item['comments_count']) && $item['comments_count'] >= 20) { Skin::define_img('VERY_HOT_THREAD_IMG', 'articles/very_hot_thread.gif'); $icon = VERY_HOT_THREAD_IMG; } elseif (isset($item['comments_count']) && $item['comments_count'] >= 10) { $icon = HOT_THREAD_IMG; } else { $icon = THREAD_IMG; } // indicate the id in the hovering popup $hover = i18n::s('View the page'); if (Surfer::is_member()) { $hover .= ' [article=' . $item['id'] . ']'; } // use the title as a link to the page $title = $prefix . Skin::build_link($url, ucfirst($title), 'basic', $hover) . $suffix; $suffix = ''; // the introductory text $introduction = ''; if (is_object($overlay)) { $introduction = $overlay->get_text('introduction', $item); } elseif ($item['introduction']) { $introduction = $item['introduction']; } if ($introduction) { $suffix .= BR . Codes::beautify_introduction($introduction); } // insert overlay data, if any if (is_object($overlay)) { $suffix .= $overlay->get_text('list', $item); } // shortcuts to comments pages if (isset($item['comments_count']) && ($pages = (int) ceil($item['comments_count'] / $layout->items_per_page())) && $pages > 1) { $suffix .= '<p class="details">Pages '; for ($index = 1; $index <= $pages; $index++) { $suffix .= Skin::build_link('comments/list.php?id=article:' . $item['id'] . '&page=' . $index, $index, 'basic', i18n::s('One page of comments')) . ' '; } $suffix .= Skin::build_link('comments/list.php?id=article:' . $item['id'] . '&page=' . $pages, MORE_IMG, 'basic', i18n::s('Most recent comments')) . '</p>'; } // links to sections and categories $anchors = array(); // the main anchor link if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) { $anchors[] = Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'basic', i18n::s('In this section')); } // list categories by title, if any if ($members =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) { foreach ($members as $category_id => $attributes) { // add background color to distinguish this category against others if (isset($attributes['background_color']) && $attributes['background_color']) { $attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>'; } if (!isset($this->focus) || $this->focus != 'category:' . $category_id) { $anchors[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic', i18n::s('Related topics')); } } } // list section and categories in the suffix if (@count($anchors)) { $suffix .= '<p class="tags">' . implode(' ', $anchors) . '</p>'; } // the creator of this article $starter = ''; if ($item['create_name']) { $starter = '<span class="details">' . Users::get_link($item['create_name'], $item['create_address'], $item['create_id']) . '</span>'; } // the last editor $details = ''; if ($item['edit_date']) { // find a name, if any $user = ''; if ($item['edit_name']) { // label the action if (isset($item['edit_action'])) { $user .= Anchors::get_action_label($item['edit_action']) . ' '; } // name of last editor $user .= sprintf(i18n::s('by %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id'])); } $details .= $user . ' ' . Skin::build_date($item['edit_date']); } // signal locked articles if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) { $details .= ', ' . LOCKED_FLAG; } // poster details if ($details) { $details = '<p class="details">' . $details . "</p>\n"; } if (!isset($item['comments_count'])) { $item['comments_count'] = 0; } // this is another row of the output $cells = array($title . $suffix, 'center=' . $starter, 'center=' . $item['comments_count'], 'center=' . Skin::build_number($item['hits']), $details); if (THREAD_IMG) { $cells = array_merge(array($icon), $cells); } $rows[] = $cells; } // end of processing SQL::free($result); // headers $headers = array(i18n::s('Topic'), 'center=' . i18n::s('Poster'), 'center=' . i18n::s('Replies'), 'center=' . i18n::s('Views'), i18n::s('Last post')); if (THREAD_IMG) { $headers = array_merge(array(''), $headers); } // make a sortable table $output = Skin::table($headers, $rows, 'yabb'); return $output; }
/** * list articles for search requests * * @param resource the SQL result * @return array of resulting items ($score, $summary), or NULL * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of array($score, $summary) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // process all items in the list include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // one box at a time $box = ''; // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the main anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Articles::get_permalink($item); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // initialize variables $prefix = $suffix = $icon = ''; // flag sticky pages if ($item['rank'] < 10000) { $prefix .= STICKY_FLAG; } // signal locked articles if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) { $suffix .= ' ' . LOCKED_FLAG; } // flag articles that are dead, or created or updated very recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $prefix .= EXPIRED_FLAG; } elseif ($item['create_date'] >= $context['fresh']) { $suffix .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= ' ' . UPDATED_FLAG; } // signal articles to be published if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) { $prefix .= DRAFT_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // introduction $introduction = ''; if (is_object($overlay)) { $introduction = $overlay->get_text('introduction', $item); } else { $introduction = $item['introduction']; } // the introductory text if ($introduction) { $suffix .= ' - ' . Codes::beautify_introduction($introduction); // link to description, if any if ($item['description']) { $suffix .= ' ' . Skin::build_link($url, MORE_IMG, 'more', i18n::s('View the page')) . ' '; } } // insert overlay data, if any if (is_object($overlay)) { $suffix .= $overlay->get_text('list', $item); } // details $details = array(); // the author if ($item['create_name'] != $item['edit_name']) { $details[] = sprintf(i18n::s('by %s, %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id'])); } else { $details[] = sprintf(i18n::s('by %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id'])); } // the last action $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']); // the number of hits if (Surfer::is_logged() && $item['hits'] > 1) { $details[] = Skin::build_number($item['hits'], i18n::s('hits')); } // info on related files if ($count = Files::count_for_anchor('article:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count); } // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count); } // info on related comments if ($count = Comments::count_for_anchor('article:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count); } // rating if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) { $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // the main anchor link if (is_object($anchor)) { $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'section')); } // display all tags if ($item['tags']) { $details[] = '<span class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>'; } // combine in-line details if (count($details)) { $suffix .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>'; } // insert a suffix separator if (trim($suffix)) { $suffix = ' ' . $suffix; } // item summary $box .= $prefix . Skin::build_link($url, $title, 'article') . $suffix; // the icon to put in the left column if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } elseif (is_callable(array($anchor, 'get_bullet_url'))) { $icon = $anchor->get_bullet_url(); } // build the complete HTML element if ($icon) { $icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($title)) . '" />'; // make it a clickable link $icon = Skin::build_link($url, $icon, 'basic'); // default icon } else { $icon = DECORATED_IMG; } // layout this item $list = array(array($box, $icon)); $items[] = array($item['score'], Skin::finalize_list($list, 'decorated')); } // end of processing SQL::free($result); return $items; }
/** * 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; }
/** * get the url to display the main page for this anchor * * @see shared/anchor.php * * @param string the targeted action ('view', 'print', 'edit', 'delete', ...) * @return an anchor to the viewing script, or NULL on error */ function get_url($action = 'view') { // sanity check if (!isset($this->item['id'])) { return NULL; } switch ($action) { // view comments case 'comments': // variants that start at the article page if ($this->has_option('view_as_chat')) { return $this->get_url() . '#comments'; } // start threads on a separate page if ($this->has_layout('alistapart')) { return Comments::get_url($this->get_reference(), 'list'); } // layouts that start at the article page --assume we have at least one comment, on a tab return Articles::get_permalink($this->item) . '#_discussion'; // list of files // list of files case 'files': return $this->get_url() . '#_attachments'; // list of links // list of links case 'links': return $this->get_url() . '#_attachments'; // jump to parent page // jump to parent page case 'parent': if (!isset($this->anchor)) { $this->anchor = Anchors::get($this->item['anchor']); } return $this->anchor->get_url(); // the permalink page // the permalink page case 'view': return Articles::get_permalink($this->item); // another action // another action default: return Articles::get_url($this->item['id'], $action, $this->item['title'], $this->item['nick_name']); } }
/** * get permanent address * * @param array page attributes * @return string the permanent web address to this item, relative to the installation path */ public static function get_permalink($item) { global $context; // sanity check if (!isset($item['id'])) { return null; } // get host to this page $vhost = Sections::get_vhost($item['anchor']); // absolute link return $vhost . Articles::get_url($item['id'], 'view', $item['title'], isset($item['nick_name']) ? $item['nick_name'] : ''); }
if (Surfer::is_crawler()) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // an error has occured } elseif (count($context['error'])) { } elseif (!isset($item['id'])) { include '../error.php'; // a destination anchor is mandatory } elseif (!is_object($destination)) { Safe::header('Status: 404 Not Found', TRUE, 404); Logger::error(i18n::s('No anchor has been found.')); // permission denied } elseif (!Articles::is_owned($item, $anchor)) { // anonymous users are invited to log in or to register if (!Surfer::is_logged()) { $link = Articles::get_url($item['id'], 'move', $destination->get_reference()); Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode($link)); } // permission denied to authenticated user Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // maybe this article cannot be modified anymore } elseif (isset($item['locked']) && $item['locked'] == 'Y' && !Surfer::is_empowered()) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('This page has been locked.')); // do the job } else { // attributes to change $fields = array(); $fields['id'] = $item['id']; $fields['anchor'] = $destination->get_reference();
if (!isset($context['site_email']) || !$context['site_email']) { $context['site_email'] = '*****@*****.**'; } $label = i18n::s('Contact mail address'); $input = '<input type="text" name="site_email" size="40" value="' . encode_field($context['site_email']) . '" maxlength="255" />'; $hint = sprintf(i18n::s('May be subject to spam attacks; featured in the %s page and in RSS feeds, at least'), Skin::build_link(Articles::get_url('about'), i18n::s('about'), 'shortcut')); $fields[] = array($label, $input, $hint); // copyright $label = i18n::s('Copyright'); $input = '<input type="text" name="site_copyright" size="50" value="' . encode_field(isset($context['site_copyright']) ? $context['site_copyright'] : '') . '" maxlength="255" />'; $hint = i18n::s('Example: "2002-2008, Acme incorporated"; inserted in the "copyright" meta field'); $fields[] = array($label, $input, $hint); // site owner $label = i18n::s('Site owner'); $input = '<input type="text" name="site_owner" size="50" value="' . encode_field(isset($context['site_owner']) ? $context['site_owner'] : '') . '" maxlength="255" />'; $hint = sprintf(i18n::s('The name of the site owner, e.g. "ACME and company"; Featured in the %s page and in ATOM feeds, at least'), Skin::build_link(Articles::get_url('about'), i18n::s('about'), 'shortcut')); $fields[] = array($label, $input, $hint); // revisit after if (!isset($context['site_revisit_after']) || !$context['site_revisit_after']) { $context['site_revisit_after'] = 7; } $label = i18n::s('Usual delay between updates'); $input = '<input type="text" name="site_revisit_after" size="4" value="' . encode_field($context['site_revisit_after']) . '" maxlength="4" /> ' . i18n::s('days'); $hint = i18n::s('Please be realistic here. Used to flag new and updated items. Also featured in "revisit-after" meta field.'); $fields[] = array($label, $input, $hint); // position $label = i18n::s('Geographical position'); $input = '<input type="text" name="site_position" size="40" value="' . encode_field(isset($context['site_position']) ? $context['site_position'] : '') . '" maxlength="255" />'; $hint = sprintf(i18n::s('Latitude and longitude, separated by a comma, for example: 47.98481,-71.42124, featured as meta fields "geo.position" and "ICBM" at the front page. See %s or %s'), Skin::build_link('http://geotags.com/', i18n::s('GeoTags Search Engine'), 'external'), Skin::build_link('http://www.travelgis.com/geocode/Default.aspx', i18n::s('Geocoding Service'), 'external')); $fields[] = array($label, $input, $hint); // head
// surfer name and execution time, if known if (is_callable(array('Surfer', 'get_name')) && is_callable(array('i18n', 's'))) { $execution_time = round(get_micro_time() - $context['start_time'], 2); echo sprintf(i18n::s('Page prepared in %.2f seconds for %s'), $execution_time, ucwords(Surfer::get_name())) . ' '; } // site copyright if (isset($context['site_copyright'])) { echo '<br />Copyright © ' . $context['site_copyright'] . "\n"; } // a command to authenticate if (is_callable(array('Surfer', 'is_logged')) && !Surfer::is_logged() && is_callable(array('i18n', 's'))) { echo ' - ' . Skin::build_link('users/login.php', i18n::s('login'), 'basic') . ' '; } // about this site if (is_callable(array('i18n', 's')) && is_callable(array('Articles', 'get_url'))) { echo ' - ' . Skin::build_link(Articles::get_url('about'), i18n::s('about this site'), 'basic') . ' '; } // privacy statement if (is_callable(array('i18n', 's')) && is_callable(array('Articles', 'get_url'))) { echo ' - ' . Skin::build_link(Articles::get_url('privacy'), i18n::s('privacy statement'), 'basic') . ' '; } // a reference to YACS if (is_callable(array('i18n', 's'))) { echo BR . sprintf(i18n::s('Powered by %s'), Skin::build_link(i18n::s('http://www.yacs.fr/'), 'Yacs', 'external')); } // end of the footer panel echo '</div>' . "\n"; // insert the footer echo $context['page_footer']; // end of page echo '</body>' . "\n" . '</html>';
/** * 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; }
/** * list articles as a table of content of a manual * * @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'] . 'links/links.php'; $text .= '<ul class="manual">'; 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']); } // reset everything $prefix = $label = $suffix = $icon = $details = ''; // 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 (isset($item['active']) && $item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif (isset($item['active']) && $item['active'] == 'R') { $prefix .= RESTRICTED_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; } // attachment details $details = array(); // info on related files if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) { Skin::define_img('FILES_LIST_IMG', 'files/list.gif'); $details[] = FILES_LIST_IMG . sprintf(i18n::ns('%d file', '%d files', $count), $count); } // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { Skin::define_img('LINKS_LIST_IMG', 'links/list.gif'); $details[] = LINKS_LIST_IMG . sprintf(i18n::ns('%d link', '%d links', $count), $count); } // rating if ($item['rating_count']) { $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // describe attachments if (count($details)) { $suffix .= ' <span class="details">' . join(', ', $details) . '</span>'; } // display all tags if ($item['tags']) { $suffix .= ' <span class="details">- ' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>'; } // make a link $label = $prefix . Skin::build_link($url, $title, 'basic') . $suffix; // use the title as a link to the page $text .= '<li>' . $label . "</li>\n"; } $text .= '</ul>' . "\n"; // end of processing SQL::free($result); return $text; }
} // delete command if (Articles::allow_deletion($item, $anchor)) { Skin::define_img('ARTICLES_DELETE_IMG', 'articles/delete.gif'); $context['page_tools'][] = Skin::build_link(Articles::get_url($item['id'], 'delete'), ARTICLES_DELETE_IMG . i18n::s('Delete this page')); } // several extra boxes in a row // $text = ''; // participants // // advertise this thread $invite = ''; if (isset($context['with_email']) && $context['with_email'] == 'Y') { Skin::define_img('ARTICLES_INVITE_IMG', 'articles/invite.gif'); $invite = Skin::build_link(Articles::get_url($item['id'], 'invite'), ARTICLES_INVITE_IMG . i18n::s('Invite participants'), 'basic', i18n::s('Spread the word')); } // thread participants if (!isset($item['locked']) || $item['locked'] != 'Y') { $text .= Skin::build_box(i18n::s('Participants'), '<div id="thread_roster_panel"></div>' . $invite, 'boxes', 'roster'); } // files // // the command to post a new file -- do that in this window, since the surfer will be driven back here $invite = ''; if (Files::allow_creation($item, $anchor, 'article')) { Skin::define_img('FILES_UPLOAD_IMG', 'files/upload.gif'); $link = 'files/edit.php?anchor=' . urlencode('article:' . $item['id']); $invite = Skin::build_link($link, FILES_UPLOAD_IMG . i18n::s('Add a file'), 'basic') . BR; } // list files by date (default) or by title (option files_by_title)
} // content assistant if (Surfer::is_associate()) { $commands[] = sprintf(i18n::s('%s - create blogs, wikis, forums, and more'), Skin::build_link('help/populate.php', i18n::s('Content Assistant'), 'basic')); } // site map if (Surfer::is_associate()) { $commands[] = sprintf(i18n::s('%s - you may enhance %s of some sections'), Skin::build_link('sections/', i18n::s('Site map')), '<a href="../behaviors/">' . i18n::s('behaviors') . '</a>'); } // template pages if (Surfer::is_associate()) { $commands[] = sprintf(i18n::s('%s - some have %s'), Skin::build_link(Sections::get_url('templates'), i18n::s('Template pages')), '<a href="../overlays/">' . i18n::s('overlays') . '</a>'); } // global pages if (Surfer::is_associate()) { $commands[] = sprintf(i18n::s('%s, including: %s, %s, %s and %s'), Skin::build_link(Sections::get_url('global'), i18n::s('Global pages')), Skin::build_link(Articles::get_url('cover'), i18n::s('the cover page')), Skin::build_link(Articles::get_url('menu'), i18n::s('Menu')), Skin::build_link(Articles::get_url('about'), i18n::s('About this site')), Skin::build_link(Articles::get_url('privacy'), i18n::s('Privacy statement'))); } // import some content if (Surfer::is_associate()) { $commands[] = sprintf(i18n::s('%s - exported from another server'), Skin::build_link('control/import.php', i18n::s('Import XML content'), 'basic')); } // upload some CSV if (Surfer::is_associate()) { $commands[] = sprintf(i18n::s('%s - update the database'), Skin::build_link('tables/import.php', i18n::s('Upload a .CSV file'), 'basic')); } // available feeds $commands[] = sprintf(i18n::s('%s - all feeds available (RSS, ATOM)'), Skin::build_link('feeds/', i18n::s('Information channels'), 'basic')); // web services $commands[] = sprintf(i18n::s('%s - connect remote computers through XML-RPC or REST'), Skin::build_link('services/', i18n::s('Web services'), 'basic')); // codes $commands[] = sprintf(i18n::s('%s - codes you can use to beautify your pages'), Skin::build_link('codes/', i18n::s('Codes'), 'basic'));
/** * 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 if (isset($item['introduction']) && $item['introduction']) { $suffix .= ' - ' . Codes::beautify_introduction($item['introduction']); } elseif (isset($item['decription']) && $item['decription']) { $suffix .= ' - ' . Skin::cap(Codes::beautify($item['description'], $item['options']), 25); } // the author $author = ''; if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { $author = sprintf(i18n::s('by %s'), $item['create_name']) . ' '; } // date $suffix .= '<span class="details"> - ' . $author . Skin::build_date($item['publish_date']); // count comments if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) { $suffix .= ' - ' . sprintf(i18n::ns('%d comment', '%d comments', $count), $count); } // end of details $suffix .= '</span>'; // insert an array of links return array($prefix, $title, $suffix); }
/** * list articles as rows in a table * * @param resource the SQL result * @return string the rendered text **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // build a list of articles $rows = array(); include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // get the related overlay $overlay = Overlay::load($item, 'article:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Articles::get_permalink($item); // reset everything $title = $abstract = $author = ''; // signal articles to be published if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) { $title .= DRAFT_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $title .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $title .= RESTRICTED_FLAG; } // indicate the id in the hovering popup $hover = i18n::s('View the page'); if (Surfer::is_member()) { $hover .= ' [article=' . $item['id'] . ']'; } // use the title to label the link if (is_object($overlay)) { $label = Codes::beautify_title($overlay->get_text('title', $item)); } else { $label = Codes::beautify_title($item['title']); } // use the title as a link to the page $title .= Skin::build_link($url, $label, 'basic', $hover); // signal locked articles if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) { $title .= ' ' . LOCKED_FLAG; } // flag articles updated recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $title .= ' ' . EXPIRED_FLAG; } elseif ($item['create_date'] >= $context['fresh']) { $title .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $title .= ' ' . UPDATED_FLAG; } // the icon if ($item['thumbnail_url']) { $abstract .= '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $item['thumbnail_url'] . '" class="right_image" alt="" /></a>'; } // the introductory text if (is_object($overlay)) { $abstract .= Codes::beautify_introduction($overlay->get_text('introduction', $item)); } elseif ($item['introduction']) { $abstract .= Codes::beautify_introduction($item['introduction']); } // insert overlay data, if any if (is_object($overlay)) { $abstract .= $overlay->get_text('list', $item); } // make some abstract out of main text if (!$item['introduction'] && $context['skins_with_details'] == 'Y') { $abstract .= Skin::cap(Codes::beautify($item['description'], $item['options']), 50); } // attachment details $details = array(); // info on related files if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) { Skin::define_img('FILES_LIST_IMG', 'files/list.gif'); $details[] = FILES_LIST_IMG . sprintf(i18n::ns('%d file', '%d files', $count), $count); } // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { Skin::define_img('LINKS_LIST_IMG', 'links/list.gif'); $details[] = LINKS_LIST_IMG . sprintf(i18n::ns('%d link', '%d links', $count), $count); } // comments if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) { Skin::define_img('COMMENTS_LIST_IMG', 'comments/list.gif'); $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), COMMENTS_LIST_IMG . sprintf(i18n::ns('%d comment', '%d comments', $count), $count)); } // describe attachments if (count($details)) { $abstract .= '<p style="margin: 3px 0;">' . join(', ', $details) . '</p>'; } // anchors $anchors = array(); if ($members =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) { foreach ($members as $category_id => $attributes) { // add background color to distinguish this category against others if (isset($attributes['background_color']) && $attributes['background_color']) { $attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>'; } $anchors[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic'); } } if (@count($anchors)) { $abstract .= '<p class="tags" style="margin: 3px 0">' . implode(' ', $anchors) . '</p>'; } // poster name if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { if ($item['create_name']) { $author = Users::get_link($item['create_name'], $item['create_address'], $item['create_id']); } else { $author = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']); } } // more details $details =& Articles::build_dates($anchor, $item); // rating if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) { $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // page details if (count($details)) { $details = '<p class="details">' . join(', ', $details) . '</p>'; } // this is another row of the output -- title, abstract, (author,) details if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { $cells = array($title, $abstract, $author, $details); } else { $cells = array($title, $abstract, $details); } // append this row $rows[] = $cells; } // end of processing SQL::free($result); // headers if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { $headers = array(i18n::s('Topic'), i18n::s('Abstract'), i18n::s('Poster'), i18n::s('Details')); } else { $headers = array(i18n::s('Topic'), i18n::s('Abstract'), i18n::s('Details')); } // return a sortable table $text .= Skin::table($headers, $rows, 'grid'); return $text; }
$permitted = FALSE; } // load the skin, maybe with a variant load_skin('articles', $anchor, isset($item['options']) ? $item['options'] : ''); // stop crawlers if (Surfer::is_crawler()) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // not found } elseif (!isset($item['id'])) { include '../error.php'; // publication is restricted } elseif (!$permitted) { // anonymous users are invited to log in if (!Surfer::is_logged()) { Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Articles::get_url($item['id'], 'unpublish'))); } // permission denied to authenticated user Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // update the database } elseif ($error = Articles::unpublish($item['id'])) { $context['text'] .= $error; } else { // clear the cache Articles::clear($item); // display the updated page Safe::redirect(Articles::get_permalink($item)); } // clear the tab we are in, if any if (is_object($anchor)) {
/** * echo the standard footer * * Note that this one does not echo $context['page_footer'], and you have * to do it yourself. * * @param string footer prefix, if any * @param string footer suffix, if any */ public static function footer($prefix = '', $suffix = '') { global $context; // the last paragraph echo '<p>'; // add footer prefix echo $prefix; $details = array(); // execution time and surfer name, for logged user only (not for indexing robots!) if (is_callable(array('Surfer', 'get_name')) && is_callable(array('i18n', 's'))) { $execution_time = round(get_micro_time() - $context['start_time'], 2); $details[] = sprintf(i18n::s('page prepared in %.2f seconds for %s'), $execution_time, ucwords(Surfer::get_name())); } // site copyright if (isset($context['site_copyright']) && $context['site_copyright']) { $details[] = '© ' . $context['site_copyright'] . "\n"; } // a command to authenticate if (is_callable(array('Surfer', 'is_logged')) && !Surfer::is_logged() && is_callable(array('i18n', 's'))) { $details[] = Skin::build_link('users/login.php', i18n::s('login'), 'basic'); } // about this site if (is_callable(array('i18n', 's')) && is_callable(array('Articles', 'get_url'))) { $details[] = Skin::build_link(Articles::get_url('about'), i18n::s('about this site'), 'basic'); } // privacy statement if (is_callable(array('i18n', 's')) && is_callable(array('Articles', 'get_url'))) { $details[] = Skin::build_link(Articles::get_url('privacy'), i18n::s('privacy statement'), 'basic'); } // a reference to YACS if (is_callable(array('i18n', 's')) && $context['host_name'] != 'www.yacs.fr') { $details[] = sprintf(i18n::s('powered by %s'), Skin::build_link(i18n::s('http://www.yacs.fr/'), 'Yacs', 'external')); } // all our feeds if (is_callable(array('i18n', 's'))) { $details[] = Skin::build_link('feeds/', i18n::s('information channels'), 'basic'); } echo join(' - ', $details); // add footer suffix echo $suffix; // end of the last paragraph echo '</p>' . "\n"; }
/** * list articles * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // the script used to check all pages at once Page::insert_script('function cascade_selection_to_all_article_rows(handle) {' . "\n" . ' $("div#articles_panel input[type=\'checkbox\'].row_selector").each(' . "\n" . ' function() { $(this).attr("checked", $(handle).is(":checked"));}' . "\n" . ' );' . "\n" . '}' . "\n"); // table prefix $text .= Skin::table_prefix('yc-grid'); // table headers $main = '<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />'; $cells = array($main, i18n::s('Page'), i18n::s('Rank')); $text .= Skin::table_row($cells, 'header'); // process all items in the list include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; $count = 0; while ($item = SQL::fetch($result)) { $cells = array(); // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the main anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Articles::get_permalink($item); // column to select the row $cells[] = '<input type="checkbox" name="selected_articles[]" id="article_selector_' . $count . '" class="row_selector" value="' . $item['id'] . '" />'; // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // initialize variables $prefix = $suffix = $icon = ''; // flag sticky pages if ($item['rank'] < 10000) { $prefix .= STICKY_FLAG; } // signal locked articles if (isset($item['locked']) && $item['locked'] == 'Y') { $suffix .= ' ' . LOCKED_FLAG; } // flag articles that are dead, or created or updated very recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $prefix .= EXPIRED_FLAG; } elseif ($item['create_date'] >= $context['fresh']) { $suffix .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= ' ' . UPDATED_FLAG; } // signal articles to be published if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) { $prefix .= DRAFT_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // the introductory text if (is_object($overlay)) { $introduction = $overlay->get_text('introduction', $item); } else { $introduction = $item['introduction']; } if ($introduction) { $suffix .= BR . Codes::beautify_introduction($introduction); } // insert overlay data, if any if (is_object($overlay)) { $suffix .= $overlay->get_text('list', $item); } // append details to the suffix $suffix .= BR . '<span class="details">'; // details $details = array(); // the author if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { if ($item['create_name'] != $item['edit_name']) { $details[] = sprintf(i18n::s('by %s, %s'), $item['create_name'], $item['edit_name']); } else { $details[] = sprintf(i18n::s('by %s'), $item['create_name']); } } // the last action $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']); // the number of hits if (Surfer::is_logged() && $item['hits'] > 1) { $details[] = Skin::build_number($item['hits'], i18n::s('hits')); } // info on related files $stats = Files::stat_for_anchor('article:' . $item['id']); if ($stats['count']) { $details[] = sprintf(i18n::ns('%d file', '%d files', $stats['count']), $stats['count']); } // info on related links $stats = Links::stat_for_anchor('article:' . $item['id']); if ($stats['count']) { $details[] = sprintf(i18n::ns('%d link', '%d links', $stats['count']), $stats['count']); } // info on related comments $stats = Comments::stat_for_anchor('article:' . $item['id']); if ($stats['count']) { $details[] = sprintf(i18n::ns('%d comment', '%d comments', $stats['count']), $stats['count']); } // rating if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) { $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // combine in-line details if (count($details)) { $suffix .= ucfirst(trim(implode(', ', $details))); } // list up to three categories by title, if any $anchors = array(); if ($members =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) { foreach ($members as $id => $attributes) { // add background color to distinguish this category against others if (isset($attributes['background_color']) && $attributes['background_color']) { $attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>'; } $anchors[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic'); } } if (count($anchors)) { $suffix .= BR . sprintf(i18n::s('In %s'), implode(' / ', $anchors)); } // end of details $suffix .= '</span>'; // strip empty details $suffix = str_replace(BR . '<span class="details"></span>', '', $suffix); $suffix = str_replace('<span class="details"></span>', '', $suffix); // the icon to put in the left column if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } // commands $commands = array(Skin::build_link(Articles::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic'), Skin::build_link(Articles::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic')); // link to this page $cells[] = $prefix . Skin::build_link($url, $title, 'article') . ' - ' . Skin::finalize_list($commands, 'menu') . $suffix; // ranking $cells[] = '<input type="text" size="5" name="article_rank_' . $item['id'] . '" value="' . $item['rank'] . '" onfocus="$(\'#article_selector_' . $count . '\').attr(\'checked\', \'checked\');" onchange="$(\'#act_on_articles\').prop(\'selectedIndex\', 9);" />'; // append the row $text .= Skin::table_row($cells, $count++); } // select all rows $cells = array('<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />', i18n::s('Select all/none'), ''); $text .= Skin::table_row($cells, $count++); // table suffix $text .= Skin::table_suffix(); // end of processing SQL::free($result); return $text; }
/** * 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; }
/** * 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; }
// the default value if (!isset($item['rank'])) { $item['rank'] = 10000; } $label = i18n::s('Rank'); $input = '<input type="text" name="rank" id="rank" size="10" value="' . encode_field($item['rank']) . '" maxlength="255" />'; $hint = sprintf(i18n::s('For %s pages; regular pages are ranked at %s.'), '<a href="#" onclick="$(\'#rank\').value=10; return false;">' . i18n::s('sticky') . '</a>', '<a href="#" onclick="$(\'#rank\').value=10000; return false;">' . i18n::s('10000') . '</a>'); $fields[] = array($label, $input, $hint); } // the publication date $label = i18n::s('Publication date'); if (isset($item['publish_date']) && $item['publish_date'] > NULL_DATE) { $input = Surfer::from_GMT($item['publish_date']); } elseif (isset($item['id']) && (Surfer::is_associate() || Surfer::is_member() && is_object($anchor) && $anchor->is_assigned())) { Skin::define_img('ARTICLES_PUBLISH_IMG', 'articles/publish.gif'); $input = Skin::build_link(Articles::get_url($item['id'], 'publish'), ARTICLES_PUBLISH_IMG . i18n::s('Publish'), 'basic'); } else { Skin::define_img('ARTICLES_UNPUBLISH_IMG', 'articles/unpublish.gif'); $input = ARTICLES_UNPUBLISH_IMG . i18n::s('not published'); } $fields[] = array($label, $input); // the expiry date $label = i18n::s('Expiry date'); if (isset($item['expiry_date']) && $item['expiry_date'] > NULL_DATE) { $input = Surfer::from_GMT($item['expiry_date']); } else { $input = i18n::s('never'); } $fields[] = array($label, $input); // the parent section if (is_object($anchor)) {
// the title of the page if (isset($item['title'])) { $context['page_title'] = utf8::to_unicode($item['title']); } // stop crawlers if (Surfer::is_crawler()) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // not found } elseif (!isset($item['id'])) { include '../error.php'; // permission denied } elseif (!Articles::allow_access($item, $anchor)) { // anonymous users are invited to log in or to register if (!Surfer::is_logged()) { Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Articles::get_url($item['id'], 'fetch_as_msword'))); } // permission denied to authenticated user Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // display the article } else { // always use the iso-8859-15 charset, else word will get garbage chars... $context['charset'] = 'iso-8859-15'; // details $details =& Articles::build_dates($anchor, $item); // all details if ($details) { $context['text'] .= ucfirst(implode(', ', $details)) . BR . "\n"; } // display the source, if any
/** * 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; }
/** * 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; }
/** * 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 .= ' - ' . 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); }
/** * list articles * * Accept following variants: * - 'hits', compact plus the number of hits * - 'no_author', for articles in the user page * - 'category:xxx', if the list is displayed at categories/view.php * - 'section:xxx', if the list is displayed at sections/view.php * * @param resource the SQL result * @return array of resulting items, or NULL * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($url => $attributes) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // sanity check if (!isset($this->layout_variant)) { $this->layout_variant = 'decorated'; } // process all items in the list include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the main anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Articles::get_permalink($item); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // initialize variables $prefix = $suffix = $icon = ''; // flag sticky pages if ($item['rank'] < 10000) { $prefix .= STICKY_FLAG; } // signal locked articles if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) { $suffix .= ' ' . LOCKED_FLAG; } // flag articles that are dead, or created or updated very recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $prefix .= EXPIRED_FLAG; } elseif ($item['create_date'] >= $context['fresh']) { $suffix .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= ' ' . UPDATED_FLAG; } // signal articles to be published if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) { $prefix .= DRAFT_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // the compact version if ($this->layout_variant == 'compact') { $items[$url] = array($prefix, Skin::strip($title, 30), $suffix, 'basic', NULL); continue; } // with hits if ($this->layout_variant == 'hits') { if ($item['hits'] > 1) { $suffix = ' <span class="details">- ' . Skin::build_number($item['hits'], i18n::s('hits')) . '</span>'; } $items[$url] = array($prefix, Skin::strip($title, 30), $suffix, 'basic', NULL); continue; } // introduction $introduction = ''; if (is_object($overlay)) { $introduction = $overlay->get_text('introduction', $item); } else { $introduction = $item['introduction']; } // the introductory text if ($introduction) { $suffix .= ' - ' . Codes::beautify_introduction($introduction); // link to description, if any if ($item['description']) { $suffix .= ' ' . Skin::build_link($url, MORE_IMG, 'more', i18n::s('View the page')) . ' '; } } // insert overlay data, if any if (is_object($overlay)) { $suffix .= $overlay->get_text('list', $item); } // next line, except if we already are at the beginning of a line if ($suffix && !preg_match('/<br\\s*\\/>$/', rtrim($suffix))) { $suffix .= BR; } // append details to the suffix $suffix .= '<span class="details">'; // details $details = array(); // display details only at the main index page, and also at anchor pages if (isset($this->focus) && $item['anchor'] != $this->focus) { // the author if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { if ($item['create_name'] != $item['edit_name']) { $details[] = sprintf(i18n::s('by %s, %s'), $item['create_name'], $item['edit_name']); } else { $details[] = sprintf(i18n::s('by %s'), $item['create_name']); } } // the last action $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']); // the number of hits if (Surfer::is_logged() && $item['hits'] > 1) { $details[] = Skin::build_number($item['hits'], i18n::s('hits')); } // info on related files if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count); } // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count); } // info on related comments if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count); } // rating if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) { $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // unusual ranks are signaled to associates and owners if ($item['rank'] != 10000 && Articles::is_owned($item, $anchor)) { $details[] = '{' . $item['rank'] . '}'; } } // at the user page if ($this->layout_variant == 'no_author' && Surfer::get_id()) { if (Members::check('article:' . $item['id'], 'user:'******'Stop notifications'); } else { $label = i18n::s('Watch this page'); } $menu = array('users/track.php?anchor=' . urlencode('article:' . $item['id']) => $label); $details[] = Skin::build_list($menu, 'menu'); } // the main anchor link if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) { $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'section')); } // combine in-line details if (count($details)) { $suffix .= ucfirst(trim(implode(', ', $details))); } // end of details $suffix .= '</span>'; // display all tags if ($item['tags']) { $suffix .= ' <span class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>'; } // strip empty details $suffix = str_replace(BR . '<span class="details"></span>', '', $suffix); $suffix = str_replace('<span class="details"></span>', '', $suffix); // insert a suffix separator if (trim($suffix)) { $suffix = ' ' . $suffix; } // the icon to put in the left column if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } elseif (is_callable(array($anchor, 'get_bullet_url'))) { $icon = $anchor->get_bullet_url(); } // list all components for this item $items[$url] = array($prefix, $title, $suffix, 'article', $icon); } // end of processing SQL::free($result); return $items; }