/** * 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; }
$context['text'] .= '</div></form>'; // the script used for form handling at the browser Page::insert_script('func' . 'tion validateDocumentPost(container) {' . "\n" . ' if(!container.letter_title.value) {' . "\n" . ' alert("' . i18n::s('No title has been provided.') . '");' . "\n" . ' Yacs.stopWorking();' . "\n" . ' return false;' . "\n" . ' }' . "\n" . ' return true;' . "\n" . '}' . "\n" . '// set the focus on first form field' . "\n" . 'document.main_form.letter_title.focus();' . "\n"); // list featured pages } elseif (isset($action) && $action == 'featured') { // the letter prefix if ($context['letter_prefix']) { $context['letter_body'] .= '<div>' . $context['letter_prefix'] . '</div>'; } // re-use parameter for featured pages at the front page if (!isset($context['root_featured_count']) || $context['root_featured_count'] < 1) { $context['root_featured_count'] = 7; } // the category used to assign featured pages $anchor = Categories::get(i18n::c('featured')); if (isset($anchor['id']) && ($items =& Members::list_articles_by_date_for_anchor('category:' . $anchor['id'], 0, $context['root_featured_count'], 'digest'))) { // scan each article foreach ($items as $url => $label) { // text for this article $context['letter_body'] .= "\n"; // split $label as array($time, $label, $author, $section, $icon, $introduction) $time = $author = $section = $icon = $introduction = NULL; $sublevel = FALSE; if (is_array($label)) { $time = $label[0]; $author = $label[2]; $section = $label[3]; $icon = $label[4]; $introduction = $label[5]; $label = $label[1]; }
$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); } // actually render the html for the section if ($items) { $context['text'] .= $section . Skin::build_list($items, 'decorated'); } // // the files section // // title $section = Skin::build_block(i18n::s('Files'), 'title'); // list files by date (default) or by title (option :files_by_title:) if (preg_match('/\\bfiles_by_title\\b/i', $item['options'])) { $items = Files::list_by_title_for_anchor('category:' . $item['id'], 0, 300, 'category:' . $item['id']); } else { $items = Files::list_by_date_for_anchor('category:' . $item['id'], 0, 300, 'category:' . $item['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); } $context['components']['boxes'] = $text; // referrals, if any $context['components']['referrals'] = Skin::build_referrals('sections/index.php'); // render the skin render_skin();
if (($section = Sections::get('navigation_boxes')) && isset($section['id'])) { $context['page_tools'][] = Skin::build_link(Sections::get_permalink($section), i18n::s('Navigation boxes'), 'basic'); } } // save some database requests $cache_id = 'index.php#extra_news'; if (!($text = Cache::get($cache_id))) { // show featured articles -- set in configure.php if (isset($context['root_featured_layout']) && $context['root_featured_layout'] != 'none') { // set in configure.php if (!isset($context['root_featured_count']) || $context['root_featured_count'] < 1) { $context['root_featured_count'] = 7; } // the category used to assign featured pages $anchor = Categories::get(i18n::c('featured')); if ($anchor['id'] && ($items =& Members::list_articles_by_date_for_anchor('category:' . $anchor['id'], 0, $context['root_featured_count'] + 1, 'news'))) { // link to the category page from the box title $title =& Skin::build_box_title($anchor['title'], Categories::get_permalink($anchor), i18n::s('Featured pages')); // limit to seven links only if (@count($items) > $context['root_featured_count']) { @array_splice($items, $context['root_featured_count']); // link to the category page $url = Categories::get_permalink($anchor); $items[$url] = i18n::s('Featured pages') . MORE_IMG; } // render html if (is_array($items)) { $items =& Skin::build_list($items, 'news'); } // we do have something to display if ($items) {
/** * 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; }
$cache_id = 'categories/feed.php?id=' . $item['id'] . '#channel'; if (!($text = Cache::get($cache_id))) { // 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'); // 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()) {
/** * render a compact list of recent modifications * * The provided anchor can reference: * - a section 'section:123' * - a category 'category:456' * - a user 'user:789' * - 'self' * - nothing * * @param string the anchor (e.g. 'section:123') * @param string layout to use * @return string the rendered text **/ public static function render_updated($layout = 'simple', $anchor = '') { global $context; // we return some text; $text = ''; // number of items to display $count = COMPACT_LIST_SIZE; if (($position = strpos($anchor, ',')) !== FALSE) { $count = (int) trim(substr($anchor, $position + 1)); if (!$count) { $count = COMPACT_LIST_SIZE; } $anchor = trim(substr($anchor, 0, $position)); } // scope is limited to current surfer if ($anchor == 'self' && Surfer::get_id()) { $anchor = 'user:'******'section:') === 0) { // look at this branch of the content tree $anchors = Sections::get_branch_at_anchor($anchor); // query the database and layout that stuff $text = Articles::list_for_anchor_by('edition', $anchors, 0, $count, $layout); // scope is limited to one category } elseif (strpos($anchor, 'category:') === 0) { // first level of depth $anchors = array(); // get sections linked to this category if ($topics = Members::list_sections_by_title_for_anchor($anchor, 0, 50, 'raw')) { foreach ($topics as $id => $not_used) { $anchors = array_merge($anchors, array('section:' . $id)); } } // second level of depth if (count($topics) && count($anchors) < 2000) { $topics = Sections::get_children_of_anchor($anchors); $anchors = array_merge($anchors, $topics); } // third level of depth if (count($topics) && count($anchors) < 2000) { $topics = Sections::get_children_of_anchor($anchors); $anchors = array_merge($anchors, $topics); } // fourth level of depth if (count($topics) && count($anchors) < 2000) { $topics = Sections::get_children_of_anchor($anchors); $anchors = array_merge($anchors, $topics); } // fifth level of depth if (count($topics) && count($anchors) < 2000) { $topics = Sections::get_children_of_anchor($anchors); $anchors = array_merge($anchors, $topics); } // the category itself is an anchor $anchors[] = $anchor; // ensure anchors are referenced only once $anchors = array_unique($anchors); // query the database and layout that stuff $text = Members::list_articles_by_date_for_anchor($anchors, 0, $count, $layout); // scope is limited to pages of one surfer } elseif (strpos($anchor, 'user:'******'edition', substr($anchor, 5), 0, $count, $layout); } else { $text = Articles::list_by('edition', 0, $count, $layout); } // we have an array to format if (is_array($text)) { $text = Skin::build_list($text, $layout); } // job done return $text; }
$count = Members::count_articles_for_anchor('category:' . $item['id'], $this_cat->get_listed_lang()); if ($count) { $box['bar'] = array('_count' => sprintf(i18n::ns('%d page', '%d pages', $count), $count)); } // navigation commands for articles $home = Categories::get_permalink($item); $prefix = Categories::get_url($item['id'], 'navigate', 'articles'); $box['bar'] = array_merge($box['bar'], Skin::navigate($home, $prefix, $count, ARTICLES_PER_PAGE, $zoom_index)); // list items by date (default) or by title (option 'articles_by_title') or by rating_sum (option article_by_rating) $offset = ($zoom_index - 1) * ARTICLES_PER_PAGE; if (isset($order) && preg_match('/\\barticles_by_rating\\b/i', $order)) { $items =& Members::list_articles_by_rating_for_anchor('category:' . $item['id'], $offset, ARTICLES_PER_PAGE, $layout_articles, $this_cat->get_listed_lang()); } elseif (isset($item['options']) && preg_match('/\\barticles_by_title\\b/i', $item['options'])) { $items =& Members::list_articles_by_title_for_anchor('category:' . $item['id'], $offset, ARTICLES_PER_PAGE, $layout_articles, $this_cat->get_listed_lang()); } else { $items =& Members::list_articles_by_date_for_anchor('category:' . $item['id'], $offset, ARTICLES_PER_PAGE, $layout_articles, $this_cat->get_listed_lang()); } // 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; } if ($box['bar']) { $box['text'] .= Skin::build_list($box['bar'], 'menu_bar'); } // in a separate panel if ($box['text']) { $panels[] = array('articles', i18n::s('Pages'), 'articles_panel', $box['text']); } }