/** * 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; } // process all items in the list $items = array(); $total = 0; $minimum = 10000; $maximum = 0; while ($item = SQL::fetch($result)) { // this will be sorted alphabetically $items[$item['title']] = array('importance' => (int) $item['importance'], 'href' => Categories::get_permalink($item)); // assess the scope if ($minimum > (int) $item['importance']) { $minimum = (int) $item['importance']; } if ($maximum < (int) $item['importance']) { $maximum = (int) $item['importance']; } } // end of processing SQL::free($result); // sort the array alphabetically ksort($items); // scale items $text = ''; foreach ($items as $title => $item) { switch ((string) ceil((1 + $item['importance'] - $minimum) * 6 / (1 + $maximum - $minimum))) { default: case 1: $item['style'] = 'font-size: 0.8em'; break; case 2: $item['style'] = 'font-size: 0.9em'; break; case 3: $item['style'] = 'font-size: 1.3em'; break; case 4: $item['style'] = 'font-size: 1.5em'; break; case 5: $item['style'] = 'font-size: 1.7em'; break; case 6: $item['style'] = 'font-size: 2em'; break; } $text .= '<span style="' . $item['style'] . '">' . Skin::build_link($item['href'], $title, 'basic') . '</span> '; } // final packaging $text = '<p class="cloud">' . rtrim($text) . '</p>'; // return by reference return $text; }
/** * 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 while ($item = SQL::fetch($result)) { // url to view the comment $url = Categories::get_permalink($item); // use the title to label the link $label = ucfirst(Skin::strip($item['title'], 20)); // number of items for this category $count = 0; // count sections for this category if ($scount = Members::count_sections_for_anchor('category:' . $item['id'])) { $count += $scount; } // count articles for this category if ($acount = Members::count_articles_for_anchor('category:' . $item['id'])) { $count += $acount; } // format total count of items if ($count) { $count = ' (' . $count . ')'; } else { $count = ''; } // list all components for this item $items[$url] = array('', $label, $count, 'basic', NULL); } // end of processing SQL::free($result); return $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 an array of ($url => $attributes) $items = array(); // process all items in the list while ($item = SQL::fetch($result)) { // url to view the comment $url = Categories::get_permalink($item); // use the title to label the link $label = ucfirst(Skin::strip($item['title'], 20)); // list all components for this item $items[$url] = array('', $label, NULL, 'basic', NULL); } // end of processing SQL::free($result); return $items; }
/** * list categories * * @param resource the SQL result * @return an array of $url => (NULL, $title, NULL, 'section_123', NULL, 'visit this section') * * @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; } // no hovering label $href_title = ''; // process all items in the list while ($item = SQL::fetch($result)) { // the url to view this item $url = Categories::get_permalink($item); // initialize variables $prefix = $suffix = ''; // list all components for this item $items[$url] = array($prefix, ucfirst(Skin::strip($item['title'], 30)), $suffix, 'category_' . $item['id'], NULL, $href_title); } // end of processing SQL::free($result); return $items; }
if (!isset($item['id'])) { include '../error.php'; // permission denied } elseif (!$permitted) { // give anonymous surfers a chance for HTTP authentication if (!Surfer::is_logged()) { Safe::header('WWW-Authenticate: Basic realm="' . utf8::to_iso8859($context['site_name']) . '"'); Safe::header('Status: 401 Unauthorized', TRUE, 401); } // permission denied to authenticated user Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // describe the category } else { // compute the url for this category $url = Categories::get_permalink($item); // get a description if ($item['introduction']) { $description = Codes::beautify($item['introduction']); } else { $description = Skin::cap(Codes::beautify($item['description']), 50); } // prepare the response $text = '<?xml version="1.0" encoding="' . $context['charset'] . '"?>' . "\n" . '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">' . "\n" . ' <rdf:Description rdf:about="' . $url . '">' . "\n" . ' <dc:title>' . encode_field($item['title']) . '</dc:title>' . "\n" . ' <dc:description>' . encode_field(Skin::strip($description)) . '</dc:description>' . "\n" . ' <dc:date>' . gmdate('Y-m-d') . '</dc:date>' . "\n" . ' <dc:format>text/html</dc:format>' . "\n" . ' <dc:language>' . $context['preferred_language'] . '</dc:language>' . "\n" . ' </rdf:Description>' . "\n" . '</rdf:RDF>'; // // 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 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; }
/** * 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; } // use the title to label the link $label = Skin::strip($item['title'], 10); // details $details = array(); // 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']); } // info on related sections if ($count = Members::count_sections_for_anchor('category:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d section', '%d sections', $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); } // info on related files if ($count = Files::count_for_anchor('category:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d file', '%d files', $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); } // info on related comments if ($count = Comments::count_for_anchor('category:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $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>'; } // introduction if ($item['introduction']) { $suffix .= ' ' . Codes::beautify(trim($item['introduction'])); } // put the actual icon in the left column if (isset($item['thumbnail_url']) && $this->layout_variant != 'sidebar') { $icon = $item['thumbnail_url']; } // list all components for this item $items[$url] = array($prefix, $label, $suffix, 'category', $icon); } // end of processing SQL::free($result); return $items; }
/** * list categories 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 main anchor $anchor = Anchors::get($item['anchor']); // 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; } // use the title to label the link $title = Skin::strip($item['title'], 10); // details $details = array(); // 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']); } // info on related sections if ($count = Members::count_sections_for_anchor('category:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d section', '%d sections', $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); } // info on related files if ($count = Files::count_for_anchor('category:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d file', '%d files', $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); } // info on related comments if ($count = Comments::count_for_anchor('category:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $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); } // the main anchor link if (is_object($anchor)) { $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'category')); } // append details to the suffix if (count($details)) { $suffix .= "\n" . '<span class="details">(' . implode(', ', $details) . ')</span>'; } // introduction if ($item['introduction']) { $suffix .= ' ' . Codes::beautify(trim($item['introduction'])); } // item summary $box .= $prefix . Skin::build_link($url, $title, 'category') . $suffix; // put the actual icon in the left column if (isset($item['thumbnail_url']) && $this->layout_variant != 'sidebar') { $icon = $item['thumbnail_url']; } // layout this item if ($icon) { // build the complete HTML element $icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($title)) . '" />'; // make it a clickable link $icon = Skin::build_link($url, $icon, 'basic'); $list = array(array($box, $icon)); $items[] = array($item['score'], Skin::finalize_list($list, 'decorated')); // put the item in a division } else { $items[] = array($item['score'], '<div style="margin: 0 0 1em 0">' . $box . '</div>'); } } // end of processing SQL::free($result); return $items; }
/** * 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; }
/** * 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; }
/** * get permalink to item */ function get_permalink() { if (!isset($this->item['id'])) { return NULL; } $link = Categories::get_permalink($this->item); return $link; }
// the front page $text .= ' <url>' . "\n" . ' <loc>' . $context['url_to_home'] . $context['url_to_root'] . '</loc>' . "\n" . ' <changefreq>weekly</changefreq>' . "\n" . ' <priority>1.0</priority>' . "\n" . ' </url>' . "\n\n"; // the site map $text .= ' <url>' . "\n" . ' <loc>' . $context['url_to_home'] . $context['url_to_root'] . 'sections/</loc>' . "\n" . ' <changefreq>weekly</changefreq>' . "\n" . ' <priority>1.0</priority>' . "\n" . ' </url>' . "\n\n"; // main sections if ($items = Sections::list_by_title_for_anchor(NULL, 0, 25, 'raw')) { foreach ($items as $id => $item) { $text .= ' <url>' . "\n" . ' <loc>' . encode_link(Sections::get_permalink($item)) . '</loc>' . "\n" . ' <changefreq>weekly</changefreq>' . "\n" . ' </url>' . "\n\n"; } } // the categories tree $text .= ' <url>' . "\n" . ' <loc>' . $context['url_to_home'] . $context['url_to_root'] . 'categories/</loc>' . "\n" . ' <changefreq>weekly</changefreq>' . "\n" . ' <priority>0.7</priority>' . "\n" . ' </url>' . "\n\n"; // main categories if ($items = Categories::list_by_date(0, 25, 'raw')) { foreach ($items as $id => $item) { $text .= ' <url>' . "\n" . ' <loc>' . encode_link(Categories::get_permalink($item)) . '</loc>' . "\n" . ' <changefreq>weekly</changefreq>' . "\n" . ' </url>' . "\n\n"; } } // members $text .= ' <url>' . "\n" . ' <loc>' . $context['url_to_home'] . $context['url_to_root'] . 'users/</loc>' . "\n" . ' <changefreq>weekly</changefreq>' . "\n" . ' <priority>0.7</priority>' . "\n" . ' </url>' . "\n\n"; // the OPML feed $text .= ' <url>' . "\n" . ' <loc>' . $context['url_to_home'] . $context['url_to_root'] . 'feeds/describe.php</loc>' . "\n" . ' <changefreq>weekly</changefreq>' . "\n" . ' </url>' . "\n\n"; // the postamble $text .= '</urlset>' . "\n"; // put in cache Safe::file_put_contents($cache_id, $text); } // // transfer to the user agent // // handle the output correctly
/** * list categories as an index * * @param resource the SQL result * @return string the rendered text **/ function layout($result) { global $context; // we return some text $text = ''; // referenced items $letters = array(); // empty list if (!SQL::count($result)) { return $text; } // build a list of categories include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // get the related overlay, if any $overlay = Overlay::load($item, 'category:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Categories::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 restricted and private categories if (isset($item['active']) && $item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif (isset($item['active']) && $item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // flag categories updated recently if ($item['create_date'] >= $context['fresh']) { $suffix .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= ' ' . UPDATED_FLAG; } // make a link $label = $prefix . Skin::build_link($url, $title, 'basic') . $suffix; // the associated letter $letter = strtoupper(ltrim($title[0])); if ($letter < 'A' || $letter > 'Z') { $letter = '#'; } // a new entry for this letter if (!isset($letters[$letter])) { $letters[$letter] = array(); } $letters[$letter][] = $label; } // mention all letters at the top $bar = array(); // all potential letters, in expected order $all = '#ABCDEFGHIJKLMNOPQRSTUVWXYZ'; for ($index = 0; $index < strlen($all); $index++) { $letter = $all[$index]; // some content for this letter if (isset($letters[$letter])) { // internal link to the right place $bar[] = Skin::build_link('#letter' . $letter, $letter, 'span'); // actual content for this letter $content = '<ul class="index"><li>' . join('</li><li>', $letters[$letter]) . '</li></ul>'; // content displayed in the page $text .= Skin::build_header_box($letter, $content, 'letter' . $letter); // no content for this letter } else { $bar[] = $letter; } } // insert local links at the top $text = Skin::finalize_list($bar, 'menu_bar') . $text; // end of processing SQL::free($result); return $text; }
/** * list articles as slashdot do * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // layout in a table $text = Skin::table_prefix('wide'); // 'even' is used for title rows, 'odd' for detail rows $class_title = 'odd'; $class_detail = 'even'; // build a list of sections $family = ''; include_once $context['path_to_root'] . 'articles/article.php'; include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // change the family if ($item['family'] != $family) { $family = $item['family']; // show the family $text .= Skin::table_suffix() . '<h2><span>' . $family . ' </span></h2>' . "\n" . Skin::table_prefix('wide'); } // document this section $content = $prefix = $title = $suffix = $icon = ''; $menu = array(); // permalink $url = Sections::get_permalink($item); // get the anchor $anchor = Anchors::get($item['anchor']); // get the related overlay, if any $overlay = Overlay::load($item, 'section:' . $item['id']); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // signal restricted and private sections if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // this is another row of the output $text .= '<tr class="' . $class_title . '"><th>' . $prefix . Skin::build_link($url, $title, 'basic', i18n::s('View the section')) . $suffix . '</th></tr>' . "\n"; // document most recent page here $content = $prefix = $title = $suffix = $icon = ''; $menu = array(); // branches of this tree $anchors = Sections::get_branch_at_anchor('section:' . $item['id']); // get last post $article =& Articles::get_newest_for_anchor($anchors, TRUE); if ($article['id']) { // permalink $url = Articles::get_permalink($article); // get the anchor $anchor = Anchors::get($article['anchor']); // get the related overlay, if any $overlay = Overlay::load($item, 'section:' . $item['id']); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $article)); } else { $title = Codes::beautify_title($article['title']); } // signal restricted and private articles if ($article['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($article['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // the icon to put aside if ($article['thumbnail_url']) { $icon = $article['thumbnail_url']; } // the icon to put aside if (!$icon && is_callable(array($anchor, 'get_bullet_url'))) { $icon = $anchor->get_bullet_url(); } if ($icon) { $icon = '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $icon . '" class="right_image" alt="" title="' . encode_field(i18n::s('View the page')) . '" /></a>'; } // the introductory text if ($article['introduction']) { $content .= Codes::beautify_introduction($article['introduction']); } elseif (!is_object($overlay)) { $handle = new Article(); $handle->load_by_content($article); $content .= $handle->get_teaser('teaser'); } // insert overlay data, if any if (is_object($overlay)) { $content .= $overlay->get_text('list', $article); } // link to description, if any if (trim($article['description'])) { $menu[] = Skin::build_link($url, i18n::s('Read more') . MORE_IMG, 'span', i18n::s('View the page')); } // info on related files if ($count = Files::count_for_anchor('article:' . $article['id'])) { $menu[] = sprintf(i18n::ns('%d file', '%d files', $count), $count); } // info on related comments if ($count = Comments::count_for_anchor('article:' . $article['id'])) { $menu[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count); } // discuss if (Comments::allow_creation($article, $anchor)) { $menu[] = Skin::build_link(Comments::get_url('article:' . $article['id'], 'comment'), i18n::s('Discuss'), 'span'); } // the main anchor link if (is_object($anchor) && (!isset($this->focus) || $article['anchor'] != $this->focus)) { $menu[] = Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'span', i18n::s('View the section')); } // list up to three categories by title, if any if ($items =& Members::list_categories_by_title_for_member('article:' . $article['id'], 0, 3, 'raw')) { foreach ($items as $id => $attributes) { $menu[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'span'); } } // append a menu $content .= '<p>' . Skin::finalize_list($menu, 'menu') . '</p>'; // this is another row of the output $text .= '<tr class="' . $class_detail . '"><td>' . '<h3 class="top"><span>' . Skin::build_link($url, $prefix . $title . $suffix, 'basic', i18n::s('View the page')) . '</span></h3>' . '<div class="content">' . $icon . $content . '</div>' . '</td></tr>' . "\n"; } } // end of processing SQL::free($result); $text .= Skin::table_suffix(); return $text; }
/** * build linked tags * * @param string the full list of tags * @return string HTML tags to be put in the resulting page */ public static function &build_tags($tags) { global $context; $text = ''; // list existing tags $tags = explode(',', $tags); foreach ($tags as $tag) { if (!($tag = trim($tag))) { continue; } if ($category = Categories::get_by_keyword($tag)) { // get category visibility and check surfer rights $active = $category['active']; if ($active == 'Y' || $active == 'R' && Surfer::is_member() || $active == 'N' && Surfer::is_associate()) { // add background color to distinguish this category against others if (isset($category['background_color']) && $category['background_color']) { $tag = '<span style="background-color: ' . $category['background_color'] . '; padding: 0 3px 0 3px;">' . $tag . '</span>'; } $text .= Skin::build_link(Categories::get_permalink($category), $tag, 'basic') . ' '; } else { // do not show the tag for this category $text .= ''; } } else { $text .= $tag . ' '; } } $text = rtrim($text, ' '); // a link to add a tag return $text; }
} elseif (!($articles = Articles::search($search, 1.0, 50, 'raw'))) { Logger::error(i18n::s('No item has been found.')); // create a category for this keyword if none exists yet } elseif (!($category =& Categories::get_by_keyword($search))) { $fields = array(); $fields['keywords'] = $search; $fields['anchor'] = $root_category; $fields['title'] = ucfirst($search); if ($fields['id'] = Categories::post($fields)) { Categories::clear($fields); $category = Categories::get($fields['id']); } } // ensure we have a valid category for found articles if (isset($articles) && (!isset($category) || !$category)) { Logger::error(i18n::s('No item has been found.')); } elseif (isset($articles) && is_array($articles)) { foreach ($articles as $id => $not_used) { if (!Members::assign('category:' . $category['id'], 'article:' . $id)) { break; } } // redirect to the updated category, if no error has happened if (!count($context['error'])) { Safe::redirect(Categories::get_permalink($category)); } } // failed operation $context['text'] .= '<p>' . i18n::s('Impossible to update the item.') . '</p>'; // render the skin render_skin();
// scan up to 10000 categories $count = 0; if ($items = Categories::list_by_date(0, 10000, 'raw')) { // retrieve the id and all attributes $errors_count = 0; foreach ($items as $id => $item) { // animate user screen and take care of time $count++; if (!($count % 100)) { $context['text'] .= sprintf(i18n::s('%d records have been processed'), $count) . BR . "\n"; // ensure enough execution time Safe::set_time_limit(30); } // check that the anchor exists, if any if ($item['anchor'] && !Anchors::get($item['anchor'])) { $context['text'] .= sprintf(i18n::s('Orphan: %s'), 'category ' . Skin::build_link(Categories::get_permalink($item), $id . ' ' . $label, 'category')) . BR . "\n"; if (++$errors_count >= 5) { $context['text'] .= i18n::s('Too many successive errors. Aborted') . BR . "\n"; break; } } else { $errors_count = 0; } } } // ending message $context['text'] .= sprintf(i18n::s('%d records have been processed'), $count) . BR . "\n"; // scan members $context['text'] .= Skin::build_block(sprintf(i18n::s('Analyzing table %s...'), SQL::table_name('members')), 'title'); // scan up to 50000 members $count = 0;
/** * list articles as a daily weblog do * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { if (Surfer::is_associate()) { $text .= '<p>' . sprintf(i18n::s('Use the %s to populate this server.'), Skin::build_link('help/populate.php', i18n::s('Content Assistant'), 'shortcut')) . '</p>'; } return $text; } // build a list of articles include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // three components per box $box = array(); $box['date'] = ''; $box['title'] = ''; $box['content'] = ''; // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // permalink $url = Articles::get_permalink($item); // make a live title if (is_object($overlay)) { $box['title'] .= Codes::beautify_title($overlay->get_text('title', $item)); } else { $box['title'] .= Codes::beautify_title($item['title']); } // make a clickable title $box['title'] = Skin::build_link($url, $box['title'], 'basic'); // signal restricted and private articles if ($item['active'] == 'N') { $box['title'] = PRIVATE_FLAG . $box['title']; } elseif ($item['active'] == 'R') { $box['title'] = RESTRICTED_FLAG . $box['title']; } // flag articles updated recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $box['title'] .= EXPIRED_FLAG; } elseif ($item['create_date'] >= $context['fresh']) { $box['title'] .= NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $box['title'] .= UPDATED_FLAG; } // what's the date of publication? if (isset($item['publish_date']) && $item['publish_date'] > NULL_DATE) { $box['date'] .= Skin::build_date($item['publish_date'], 'publishing'); } // the icon to put aside - never use anchor images if ($item['icon_url']) { $box['content'] .= '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $item['icon_url'] . '" class="left_image" alt="" /></a>'; } // details $details = array(); // rating if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) { $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // show details if (count($details)) { $box['content'] .= '<p class="details">' . implode(' ~ ', $details) . '</p>' . "\n"; } // list categories by title, if any if ($items = Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) { $tags = array(); foreach ($items as $id => $attributes) { // add background color to distinguish this category against others if (isset($attributes['background_color']) && $attributes['background_color']) { $attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>'; } $tags[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic'); } $box['content'] .= '<p class="tags">' . implode(' ', $tags) . '</p>'; } // the introduction text, if any if (is_object($overlay)) { $box['content'] .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction'); } else { $box['content'] .= Skin::build_block($item['introduction'], 'introduction'); } // insert overlay data, if any if (is_object($overlay)) { $box['content'] .= $overlay->get_text('list', $item); } // the description $box['content'] .= Skin::build_block($item['description'], 'description', '', $item['options']); // a compact list of attached files if ($count = Files::count_for_anchor('article:' . $item['id'])) { // list files by date (default) or by title (option files_by_title) if (Articles::has_option('files_by', $anchor, $item) == 'title') { $items = Files::list_by_title_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'compact'); } else { $items = Files::list_by_date_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'compact'); } if (is_array($items)) { $items = Skin::build_list($items, 'compact'); } if ($items) { $box['content'] .= Skin::build_box(i18n::s('Files'), $items, 'header2'); } } // build a menu $menu = array(); // read the article $menu[] = Skin::build_link($url, i18n::s('Permalink'), 'span'); // info on related files if ($count) { $menu[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'span'); } // info on related comments if ($count = Comments::count_for_anchor('article:' . $item['id'])) { $menu[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'span'); } // comment if (Comments::allow_creation($item, $anchor)) { $menu[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Discuss'), 'span'); } // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { $menu[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'span'); } // trackback if (Links::allow_trackback()) { $menu[] = Skin::build_link('links/trackback.php?anchor=' . urlencode('article:' . $item['id']), i18n::s('Reference this page'), 'span'); } // a menu bar if (count($menu)) { $box['content'] .= '<div class="menu_bar" style="clear: left;">' . MENU_PREFIX . implode(MENU_SEPARATOR, $menu) . MENU_SUFFIX . "</div>\n"; } // build a simple box for this post $text .= '<div class="post">' . '<div class="date">' . $box['date'] . '</div>' . '<h2><span>' . $box['title'] . '</span></h2>' . '<div class="content">' . $box['content'] . '</div>' . '</div>'; } // end of processing SQL::free($result); return $text; }
} // 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 category } else { // get the list from the cache, if possible $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'); // 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
// 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();
// 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) { // animate the text if required to do so if ($context['root_featured_layout'] == 'scroll') { $items = Skin::scroll($items); $box_id = 'scrolling_featured'; } elseif ($context['root_featured_layout'] == 'rotate') { $items = Skin::rotate($items); $box_id = 'rotating_featured';
/** * reference another page at this site * * The function transforms a local reference (e.g;, [code][user=2][/code]) * to an actual link relative to the YACS directory (e.g., [code]users/view.php/2[/code]), * adds a title and, sometimes, set a description as well. * * @param string any string, maybe with a local reference in it * @return an array($url, $title, $description) or NULL * * @see images/view.php * @see links/edit.php * @see shared/codes.php */ public static function transform_reference($text) { global $context; // translate this reference to an internal link if (preg_match("/^\\[(article|section|file|image|category|user)=(.+?)\\]/i", $text, $matches)) { switch ($matches[1]) { // article link case 'article': if ($item = Articles::get($matches[2])) { return array(Articles::get_permalink($item), $item['title'], $item['introduction']); } return array('', $text, ''); // section link // section link case 'section': if ($item = Sections::get($matches[2])) { return array(Sections::get_permalink($item), $item['title'], $item['introduction']); } return array('', $text, ''); // file link // file link case 'file': if ($item = Files::get($matches[2])) { return array(Files::get_url($matches[2]), $item['title'] ? $item['title'] : str_replace('_', ' ', ucfirst($item['file_name']))); } return array('', $text, ''); // image link // image link case 'image': include_once $context['path_to_root'] . 'images/images.php'; if ($item = Images::get($matches[2])) { return array(Images::get_url($matches[2]), $item['title'] ? $item['title'] : str_replace('_', ' ', ucfirst($item['image_name']))); } return array('', $text, ''); // category link // category link case 'category': if ($item = Categories::get($matches[2])) { return array(Categories::get_permalink($item), $item['title'], $item['introduction']); } return array('', $text, ''); // user link // user link case 'user': if ($item = Users::get($matches[2])) { return array(Users::get_permalink($item), $item['full_name'] ? $item['full_name'] : $item['nick_name']); } return array('', $text, ''); } } return array('', $text, ''); }
/** * list articles * * @param resource the SQL result * @return array * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($url => $attributes) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // process all items in the list while ($item = SQL::fetch($result)) { // get the related overlay, if any $overlay = Overlay::load($item, 'category:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // provide an absolute link $url = Categories::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']); } // time of last update $time = SQL::strtotime($item['edit_date']); // the section $root = ''; if ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) { $root = ucfirst(trim(strip_tags(Codes::beautify_title($anchor->get_title())))); } // the icon to use $icon = ''; if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } elseif ($item['anchor'] && ($anchor = Anchors::get($item['anchor'])) && is_callable($anchor, 'get_bullet_url')) { $icon = $anchor->get_bullet_url(); } if ($icon) { $icon = $context['url_to_home'] . $context['url_to_root'] . $icon; } // the author(s) is an e-mail address, according to rss 2.0 spec $author = ''; if (isset($item['create_address'])) { $author .= $item['create_address']; } if (isset($item['create_name']) && trim($item['create_name'])) { $author .= ' (' . $item['create_name'] . ')'; } if (isset($item['edit_address']) && trim($item['edit_address']) && $item['create_address'] != $item['edit_address']) { if ($author) { $author .= ', '; } $author .= $item['edit_address']; if (isset($item['edit_name']) && trim($item['edit_name'])) { $author .= ' (' . $item['edit_name'] . ')'; } } // list all components for this item $items[$url] = array($time, $title, $author, $root, $icon, '', '', ''); } // end of processing SQL::free($result); return $items; }
} elseif (!strncmp($id, 's~', 2) && ($item = Sections::get(restore_number(substr($id, 2))))) { Safe::redirect(Sections::get_permalink($item)); // look in sections } elseif ($items =& Sections::list_for_name($id, NULL, 'full')) { // only one section has this name if (count($items) == 1) { list($url, $attributes) = each($items); Safe::redirect($url); } // splash $context['text'] .= '<p>' . i18n::s('Select below among available sections.') . '</p>'; // several pages $context['text'] .= Skin::build_list($items, 'decorated'); // look in categories } elseif (($item = Categories::get($id)) || ($item =& Categories::get_by_keyword($id))) { Safe::redirect(Categories::get_permalink($item)); // look in articles } elseif ($items =& Articles::list_for_name($id, NULL, 'full')) { // only one page has this name if (count($items) == 1) { list($url, $attributes) = each($items); Safe::redirect($url); } // splash $context['text'] .= '<p>' . i18n::s('Select below among available pages.') . '</p>'; // several pages $context['text'] .= Skin::build_list($items, 'decorated'); // look in user profiles } elseif ($item = Users::get($id)) { Safe::redirect(Users::get_permalink($item)); // not found
/** * 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; }
/** * 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 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 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 current list of linked categories $categories =& Members::list_categories_by_title_for_member($member, 0, CATEGORIES_LIST_SIZE, 'raw'); // the form to link additional categories if (!is_array($categories) || count($categories) < CATEGORIES_LIST_SIZE) { $context['text'] .= '<form method="post" action="' . $context['script_url'] . '"><div style="margin-bottom: 2em;">' . i18n::s('Select a category') . ' <select name="anchor">' . Categories::get_options($categories) . '</select>' . ' ' . Skin::build_submit_button(i18n::s('Categorize')) . '<input type="hidden" name="member" value="' . encode_field($member) . '">' . '</div></form>' . "\n"; } // the current list of linked categories if (count($categories)) { // display attached categories with unlink buttons $context['text'] .= '<p>' . i18n::s('All categories that have been associated to this page:') . '</p>'; // browse the list foreach ($categories as $category_id => $attributes) { // make an url $url = Categories::get_permalink($attributes); // gather information on this category $prefix = $suffix = $type = $icon = ''; $label = Skin::strip($attributes['title']); // add background color to distinguish this category against others if (isset($attributes['background_color']) && $attributes['background_color']) { $label = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $label . '</span>'; } // build a unlink button for this category if (Surfer::is_associate()) { $suffix .= BR . '<form method="post" action="' . $context['script_url'] . '"><div>' . '<input type="hidden" name="anchor" value="category:' . $category_id . '" />' . '<input type="hidden" name="member" value="' . encode_field($member) . '" />' . Skin::build_submit_button(i18n::s('Unlink')) . '</div></form>'; } // a button to change the thumbnail of the anchored page if ($icon) { $suffix .= ' <form method="post" action="' . $context['url_to_root'] . 'categories/set_as_thumbnail.php"><div>' . '<input type="hidden" name="anchor" value="' . encode_field($member) . '" />' . '<input type="hidden" name="id" value="' . $category_id . '" />' . Skin::build_submit_button(i18n::s('Use this thumbnail as the thumbnail of the page')) . '</div></form>'; }
// back to the anchor page or to the index page if (is_object($anchor)) { Safe::redirect($anchor->get_url()); } else { Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'categories/'); } } // deletion has to be confirmed } elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') { Logger::error(i18n::s('The action has not been confirmed.')); } else { // commands $menu = array(); $menu[] = Skin::build_submit_button(i18n::s('Yes, I want to delete this category'), NULL, NULL, 'confirmed'); if (isset($item['id'])) { $menu[] = Skin::build_link(Categories::get_permalink($item), i18n::s('Cancel'), 'span'); } // the submit button $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . "\n" . Skin::finalize_list($menu, 'menu_bar') . '<input type="hidden" name="id" value="' . $item['id'] . '" />' . "\n" . '<input type="hidden" name="confirm" value="yes" />' . "\n" . '</p></form>' . "\n"; // set the focus Page::insert_script('$("#confirmed").focus();'); // the title of the category if ($item['title']) { $context['text'] .= Skin::build_block($item['title'], 'title'); } // the introduction text, if any $context['text'] .= '<div style="margin: 1em 0;">' . Codes::beautify($item['introduction']) . '</div>' . "\n"; // get text related to the overlay, if any if (is_object($overlay)) { $context['text'] .= $overlay->get_text('view', $item); }