$context['page_tools'][] = Skin::build_link('help/populate.php', i18n::s('Content Assistant')); $context['page_tools'][] = Skin::build_link('sections/check.php', i18n::s('Maintenance')); } // display extra information $cache_id = 'sections/index.php#extra'; if (!($text = Cache::get($cache_id))) { // see also $lines = array(); $lines[] = Skin::build_link('categories/', i18n::s('Categories')); $lines[] = Skin::build_link('search.php', i18n::s('Search')); $lines[] = Skin::build_link('help/', i18n::s('Help index')); $lines[] = Skin::build_link('query.php', i18n::s('Contact')); $text .= Skin::build_box(i18n::s('See also'), Skin::finalize_list($lines, 'compact'), 'boxes'); // list monthly publications in an extra box $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($anchor['title'], Skin::build_list($items, 'compact'), 'boxes') . "\n"; } // side boxes for related categories, if any if ($categories = Categories::list_by_date_for_display('section:index', 0, 7, 'raw')) { foreach ($categories as $id => $attributes) { // link to the category page from the box title $label =& Skin::build_box_title(Skin::strip($attributes['title']), Categories::get_permalink($attributes), i18n::s('View the category')); // box content if ($items =& Members::list_articles_by_date_for_anchor('category:' . $id, 0, COMPACT_LIST_SIZE, 'compact')) { $text .= Skin::build_box($label, Skin::build_list($items, 'compact'), 'boxes') . "\n"; } } } // save, whatever change, for 5 minutes Cache::put($cache_id, $text, 'stable', 300);
/** * list categories * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // we return an array of ($url => $attributes) $items = array(); // process all items in the list include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // url to read the full category $url = Categories::get_permalink($item); // initialize variables $prefix = $suffix = $icon = ''; // flag categories that are dead, or created or updated very recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $prefix .= EXPIRED_FLAG; } elseif ($item['create_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= UPDATED_FLAG; } // signal restricted and private categories if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // introduction if ($item['introduction']) { $suffix .= ' ' . Codes::beautify(trim($item['introduction'])); } // details $details = array(); // count related sub-elements $related_count = 0; // info on related categories $stats = Categories::stat_for_anchor('category:' . $item['id']); if ($stats['count']) { $details[] = sprintf(i18n::ns('%d category', '%d categories', $stats['count']), $stats['count']); } $related_count += $stats['count']; // info on related sections if ($count = Members::count_sections_for_anchor('category:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count); $related_count += $count; } // info on related articles if ($count = Members::count_articles_for_anchor('category:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count); $related_count += $count; } // info on related files if ($count = Files::count_for_anchor('category:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count); $related_count += $count; } // info on related links if ($count = Links::count_for_anchor('category:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count); $related_count += $count; } // info on related comments if ($count = Comments::count_for_anchor('category:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count); $related_count += $stats['count']; } // info on related users if ($count = Members::count_users_for_anchor('category:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d user', '%d users', $count), $count); } // append details to the suffix if (count($details)) { $suffix .= "\n" . '<span class="details">(' . implode(', ', $details) . ')</span>'; } // add a head list of related links $details = array(); // add sub-categories on index pages if ($related = Categories::list_by_date_for_anchor('category:' . $item['id'], 0, YAHOO_LIST_SIZE, 'compact')) { foreach ($related as $sub_url => $label) { $sub_prefix = $sub_suffix = $sub_hover = ''; if (is_array($label)) { $sub_prefix = $label[0]; $sub_suffix = $label[2]; if (@$label[5]) { $sub_hover = $label[5]; } $label = $label[1]; } $details[] = $sub_prefix . Skin::build_link($sub_url, $label, 'basic', $sub_hover) . $sub_suffix; } } // add related sections if necessary if (count($details) < YAHOO_LIST_SIZE && ($related =& Members::list_sections_by_title_for_anchor('category:' . $item['id'], 0, YAHOO_LIST_SIZE - count($details), 'compact'))) { foreach ($related as $sub_url => $label) { $sub_prefix = $sub_suffix = $sub_hover = ''; if (is_array($label)) { $sub_prefix = $label[0]; $sub_suffix = $label[2]; if (@$label[5]) { $sub_hover = $label[5]; } $label = $label[1]; } $details[] = $sub_prefix . Skin::build_link($sub_url, $label, 'basic', $sub_hover) . $sub_suffix; } } // add related articles if necessary if (count($details) < YAHOO_LIST_SIZE && ($related =& Members::list_articles_by_date_for_anchor('category:' . $item['id'], 0, YAHOO_LIST_SIZE - count($details), 'compact'))) { foreach ($related as $sub_url => $label) { $sub_prefix = $sub_suffix = $sub_hover = ''; if (is_array($label)) { $sub_prefix = $label[0]; $sub_suffix = $label[2]; if (@$label[5]) { $sub_hover = $label[5]; } $label = $label[1]; } $details[] = $sub_prefix . Skin::build_link($sub_url, $label, 'basic', $sub_hover) . $sub_suffix; } } // give me more if (count($details) && $related_count > YAHOO_LIST_SIZE) { $details[] = Skin::build_link(Categories::get_permalink($item), i18n::s('More') . MORE_IMG, 'more', i18n::s('View the category')); } // layout details if (count($details)) { $suffix .= BR . "\n» " . '<span class="details">' . implode(', ', $details) . "</span>\n"; } // put the actual icon in the left column if (isset($item['thumbnail_url'])) { $icon = $item['thumbnail_url']; } // use the title to label the link $label = Skin::strip($item['title'], 50); // some hovering title for this category $hover = i18n::s('View the category'); // list all components for this item $items[$url] = array($prefix, $label, $suffix, 'category', $icon, $hover); } // end of processing SQL::free($result); $output = Skin::build_list($items, '2-columns'); return $output; }
/** * 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; }
// the introduction text $context['text'] .= Skin::build_block($item['introduction'], 'introduction'); // the beautified description, which is the actual page body $context['text'] .= Skin::build_block($item['description'], 'description'); // // date of last update // $context['text'] .= i18n::s('Last update').' '.Skin::build_date($item['edit_date']); // // the section of sub-categories // // title $section = Skin::build_block(i18n::s('Related categories'), 'title'); // list items by date (default) or by title (option :categories_by_title:) if (preg_match('/\\bcategories_by_title\\b/i', $item['options'])) { $items = Categories::list_by_title_for_anchor('category:' . $item['id'], 0, 50); } else { $items = Categories::list_by_date_for_anchor('category:' . $item['id'], 0, 50); } // actually render the html for the section if ($items) { $context['text'] .= $section . Skin::build_list($items, 'decorated'); } // // the section of linked articles // // title $section = Skin::build_block(i18n::s('Pages'), 'title'); // list items by date (default) or by title (option articles_by_title) if (preg_match('/\\barticles_by_title\\b/i', $item['options'])) { $items =& Members::list_articles_by_title_for_anchor('category:' . $item['id'], 0, 50); } else { $items =& Members::list_articles_by_date_for_anchor('category:' . $item['id'], 0, 50);
// loads feeding parameters Safe::load('parameters/feeds.include.php'); // set channel information $values = array(); $values['channel'] = array(); $values['channel']['title'] = $item['title']; $values['channel']['link'] = Categories::get_permalink($item); $values['channel']['description'] = $item['introduction']; // the image for this channel if (isset($context['powered_by_image']) && $context['powered_by_image']) { $values['channel']['image'] = $context['url_to_home'] . $context['url_to_root'] . $context['powered_by_image']; } // the list of newest pages // $values['items'] =& Members::list_articles_by_date_for_anchor('category:'.$item['id'], 0, 20, 'feed'); // the list of newest subcategories $values['items'] = Categories::list_by_date_for_anchor('category:' . $item['id'], 0, 20, 'feed'); // make a text include_once '../services/codec.php'; include_once '../services/rss_codec.php'; $result = rss_Codec::encode($values); $text = @$result[1]; // save in cache for the next request Cache::put($cache_id, $text, 'articles'); } // // transfer to the user agent // // handle the output correctly render_raw('text/xml; charset=' . $context['charset']); // suggest a name on download if (!headers_sent()) {
/** * list categories * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // we return plain text $text = ''; // process all items in the list while ($item = SQL::fetch($result)) { // one box per category $box['title'] = ''; $box['text'] = ''; // use the title to label the link $box['title'] = Skin::strip($item['title'], 50); // list related categories, if any if ($items = Categories::list_by_date_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE, 'compact')) { foreach ($items as $url => $label) { if (is_array($label)) { $label = $label[1]; } $box['text'] .= '<li>' . Skin::build_link($url, $label, 'category') . '</li>' . "\n"; } } // info on related sections $items =& Members::list_sections_by_title_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE); if ($items) { foreach ($items as $url => $label) { if (is_array($label)) { $label = $label[1]; } $box['text'] .= '<li>' . Skin::build_link($url, $label, 'section') . '</li>' . "\n"; } } // info on related articles if (isset($item['options']) && preg_match('/\\barticles_by_title\\b/i', $item['options'])) { $items =& Members::list_articles_by_title_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE); } else { $items =& Members::list_articles_by_date_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE); } if ($items) { foreach ($items as $url => $label) { if (is_array($label)) { $label = $label[1]; } $box['text'] .= '<li>' . Skin::build_link($url, $label, 'article') . '</li>' . "\n"; } } // info on related files if (isset($item['options']) && preg_match('/\\bfiles_by_title\\b/i', $item['options'])) { $items = Files::list_by_title_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE, 'category:' . $item['id']); } else { $items = Files::list_by_date_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE, 'category:' . $item['id']); } if ($items) { foreach ($items as $url => $label) { if (is_array($label)) { $label = $label[1]; } $box['text'] .= '<li>' . Skin::build_link($url, $label, 'file') . '</li>' . "\n"; } } // info on related comments include_once $context['path_to_root'] . 'comments/comments.php'; if ($items = Comments::list_by_date_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE, 'compact')) { foreach ($items as $url => $label) { if (is_array($label)) { $label = $label[1]; } $box['text'] .= '<li>' . Skin::build_link($url, $label, 'comment') . '</li>' . "\n"; } } // info on related links include_once $context['path_to_root'] . 'links/links.php'; if (isset($item['options']) && preg_match('/\\blinks_by_title\\b/i', $item['options'])) { $items = Links::list_by_title_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE); } else { $items = Links::list_by_date_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE); } if ($items) { foreach ($items as $url => $label) { if (is_array($label)) { $label = $label[1]; } $box['text'] .= '<li>' . Skin::build_link($url, $label) . '</li>' . "\n"; } } // add a direct link to the category if (Surfer::is_associate()) { $box['title'] .= ' ' . Skin::build_link(Categories::get_permalink($item), MORE_IMG, 'basic'); } // make a full list if ($box['text']) { $box['text'] = '<ul>' . $box['text'] . '</ul>' . "\n"; } // always make a box, to let associates visit the category $text .= Skin::build_box($box['title'], $box['text']); } // end of processing SQL::free($result); return $text; }
// the maximum number of categories per page if (is_object($layout)) { $items_per_page = $layout->items_per_page(); } else { $items_per_page = CATEGORIES_PER_PAGE; } // count the number of subcategories $stats = Categories::stat_for_anchor('category:' . $item['id']); // if($stats['count']) // $box['bar'] += array('_count' => sprintf(i18n::ns('%d category', '%d categories', $stats['count']), $stats['count'])); // list items by date (default) or by title (option 'categories_by_title') $offset = ($zoom_index - 1) * $items_per_page; if (preg_match('/\\bcategories_by_title\\b/i', $item['options'])) { $items = Categories::list_by_title_for_anchor('category:' . $item['id'], $offset, $items_per_page, $layout); } else { $items = Categories::list_by_date_for_anchor('category:' . $item['id'], $offset, $items_per_page, $layout); } // navigation commands for categories $home = Categories::get_permalink($item); $prefix = Categories::get_url($item['id'], 'navigate', 'categories'); $box['bar'] = array_merge($box['bar'], Skin::navigate($home, $prefix, $stats['count'], $items_per_page, $zoom_index)); // the command to post a new category if ($stats['count'] && $this_cat->allow_creation()) { $url = 'categories/edit.php?anchor=' . urlencode('category:' . $item['id']); $box['bar'] += array($url => i18n::s('Add a category')); } // actually render the html for the section if (is_array($items)) { $box['text'] .= Skin::build_list($items, 'decorated'); } elseif (is_string($items)) { $box['text'] .= $items;