/** * 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; } // clear flows $text .= '<br style="clear: left" />'; // process all items in the list while ($item = SQL::fetch($result)) { // get the related overlay $overlay = Overlay::load($item, 'article:' . $item['id']); // 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']); } // the hovering title if ($item['introduction'] && $context['skins_with_details'] == 'Y') { $hover = strip_tags(Codes::beautify_introduction($item['introduction'])); } else { $hover = i18n::s('View the page'); } // title is a link to the target article $title =& Skin::build_link($url, $title, 'basic', $hover); // use the thumbnail for this article if ($icon = trim($item['thumbnail_url'])) { // fix relative path if (!preg_match('/^(\\/|http:|https:|ftp:)/', $icon)) { $icon = $context['url_to_root'] . $icon; } // use parameter of the control panel for this one $options = ''; if (isset($context['classes_for_thumbnail_images'])) { $options = 'class="' . $context['classes_for_thumbnail_images'] . '" '; } // build the complete HTML element $icon = '<img src="' . $icon . '" alt="" title="' . encode_field($hover) . '" ' . $options . ' />'; // use default icon if nothing to display } else { $icon = MAP_IMG; } // use the image as a link to the target page $icon =& Skin::build_link($url, $icon, 'basic', $hover); // add a floating box $text .= Skin::build_box($title, $icon, 'floating'); } // clear flows $text .= '<br style="clear: left" />'; // end of processing SQL::free($result); return $text; }
/** * list dates * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // build the calendar $text = 'BEGIN:VCALENDAR' . CRLF . 'VERSION:2.0' . CRLF . 'PRODID:YACS' . CRLF . 'METHOD:PUBLISH' . CRLF; // organization, if any if (isset($context['site_name']) && $context['site_name']) { $text .= 'X-WR-CALNAME:' . $context['site_name'] . CRLF; } // process all items in the list while ($item = SQL::fetch($result)) { // one event at a time $text .= 'BEGIN:VEVENT' . CRLF; // the event spans limited time if (isset($item['duration']) && $item['duration']) { $text .= 'DTSTART:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['date_stamp'])) . CRLF; $text .= 'DTEND:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['date_stamp']) + $item['duration'] * 60) . CRLF; // a full-day event } else { $text .= 'DTSTART;VALUE=DATE:' . date('Ymd', SQL::strtotime($item['date_stamp'])) . CRLF; $text .= 'DTEND;VALUE=DATE:' . date('Ymd', SQL::strtotime($item['date_stamp']) + 86400) . CRLF; } // url to view the date $text .= 'URL:' . Articles::get_permalink($item) . CRLF; // organization, if any if (isset($item['introduction']) && $item['introduction']) { $text .= 'DESCRIPTION:' . str_replace(array("\n", "\r"), ' ', strip_tags($item['introduction'])) . CRLF; } // build a valid title if (isset($item['title']) && $item['title']) { $text .= 'SUMMARY:' . Codes::beautify_title($item['title']) . CRLF; } // required by Outlook 2003 if (isset($item['id']) && $item['id']) { $text .= 'UID:' . $item['id'] . CRLF; } // date of creation if (isset($item['create_date']) && $item['create_date']) { $text .= 'CREATED:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['create_date'])) . CRLF; } // date of last modification if (isset($item['edit_date']) && $item['edit_date']) { $text .= 'DTSTAMP:' . gmdate('Ymd\\THis\\Z', SQL::strtotime($item['edit_date'])) . CRLF; } // next event $text .= 'SEQUENCE:0' . CRLF . 'END:VEVENT' . CRLF; } // date of last update $text .= 'END:VCALENDAR' . CRLF; // end of processing SQL::free($result); return $text; }
/** * list dates * * @param resource the SQL result * @return string the rendered text * * @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)) { // the url to use $url = Articles::get_permalink($item); // initialize variables $prefix = $suffix = $icon = ''; // signal restricted and private dates/articles if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE) { $prefix .= DRAFT_FLAG; } // signal restricted and private dates/articles if (!isset($item['active'])) { } elseif ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // flag new dates/articles if ($item['edit_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } // build a valid label if (isset($item['title'])) { $label = Codes::beautify_title($item['title']); if (isset($item['date_stamp'])) { $label .= ' [' . Skin::build_date($item['date_stamp'], 'day') . ']'; } } else { $label = Skin::build_date($item['date_stamp'], 'day'); } // may have variant overlay for links $link_type = $this->has_variant('overlaid') ? 'overlaid' : 'basic'; // list all components for this item $items[$url] = array($prefix, $label, $suffix, $link_type, NULL, $item['date_stamp']); } // end of processing SQL::free($result); return $items; }
/** * 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 string * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // sanity check if (!isset($this->focus)) { $this->focus = NULL; } // process all items in the list include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; $odd = TRUE; 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']); } // initialize variables $prefix = $suffix = $icon = ''; // 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; } // 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; } // some details $details = array(); // info on related files --optional if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count); } // info on related comments --mandatory if ($count = Comments::count_for_anchor('article:' . $item['id'], FALSE)) { $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count); } // info on related links --optional if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count); } // details if (count($details)) { $suffix .= ' <span class="details">(' . ucfirst(implode(', ', $details)) . ')</span>'; } // flag popular pages if ($item['hits'] > 300) { $suffix .= POPULAR_FLAG; } // last contribution if ($item['edit_action']) { $action = Anchors::get_action_label($item['edit_action']) . ' '; } else { $action = i18n::s('edited'); } if ($item['edit_name']) { $suffix .= '<br /><span class="details">' . sprintf(i18n::s('%s by %s %s'), $action, Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']), Skin::build_date($item['edit_date'])) . '</span>'; } else { $suffix .= '<br /><span class="details">' . $action . ' ' . Skin::build_date($item['edit_date']) . '</span>'; } // flag articles updated recently if ($item['create_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= UPDATED_FLAG; } // insert overlay data, if any if (is_object($overlay)) { $suffix .= $overlay->get_text('list', $item, $this->focus); } // the hovering title if ($item['introduction'] && $context['skins_with_details'] == 'Y') { $hover = strip_tags(Codes::beautify_introduction($item['introduction'])); } else { $hover = i18n::s('View the page'); } // help members to reference this page if (Surfer::is_member()) { $hover .= ' [article=' . $item['id'] . ']'; } // add an image if available if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } elseif (is_callable(array($anchor, 'get_bullet_url'))) { $icon = $anchor->get_bullet_url(); } // format the image if ($icon) { $icon = Skin::build_link($url, '<img src="' . $icon . '" />', 'basic', $hover); } // list all components for this item if ($odd = !$odd) { $class = ' class="odd"'; } else { $class = ' class="even"'; } // use a table to layout the image properly if ($icon) { $text .= '<div' . $class . '><table class="decorated"><tr><td class="image" style="text-align: center">' . $icon . '</td><td class="content">' . $prefix . Skin::build_link($url, Skin::strip($title, 30), 'basic', $hover) . $suffix . '</td></tr></table></div>'; } else { $text .= '<div' . $class . '>' . $prefix . Skin::build_link($url, Skin::strip($title, 30), 'basic', $hover) . $suffix . '</div>'; } } // end of processing SQL::free($result); return $text; }
/** * list articles for search requests * * @param resource the SQL result * @return array of resulting items ($score, $summary), or NULL * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of array($score, $summary) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // process all items in the list include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // one box at a time $box = ''; // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the main anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Articles::get_permalink($item); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // initialize variables $prefix = $suffix = $icon = ''; // flag sticky pages if ($item['rank'] < 10000) { $prefix .= STICKY_FLAG; } // signal locked articles if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) { $suffix .= ' ' . LOCKED_FLAG; } // flag articles that are dead, or created or updated very recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $prefix .= EXPIRED_FLAG; } elseif ($item['create_date'] >= $context['fresh']) { $suffix .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= ' ' . UPDATED_FLAG; } // signal articles to be published if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) { $prefix .= DRAFT_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // introduction $introduction = ''; if (is_object($overlay)) { $introduction = $overlay->get_text('introduction', $item); } else { $introduction = $item['introduction']; } // the introductory text if ($introduction) { $suffix .= ' - ' . Codes::beautify_introduction($introduction); // link to description, if any if ($item['description']) { $suffix .= ' ' . Skin::build_link($url, MORE_IMG, 'more', i18n::s('View the page')) . ' '; } } // insert overlay data, if any if (is_object($overlay)) { $suffix .= $overlay->get_text('list', $item); } // details $details = array(); // the author if ($item['create_name'] != $item['edit_name']) { $details[] = sprintf(i18n::s('by %s, %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id'])); } else { $details[] = sprintf(i18n::s('by %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id'])); } // the last action $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']); // the number of hits if (Surfer::is_logged() && $item['hits'] > 1) { $details[] = Skin::build_number($item['hits'], i18n::s('hits')); } // info on related files if ($count = Files::count_for_anchor('article:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count); } // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count); } // info on related comments if ($count = Comments::count_for_anchor('article:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count); } // rating if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) { $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // the main anchor link if (is_object($anchor)) { $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'section')); } // display all tags if ($item['tags']) { $details[] = '<span class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>'; } // combine in-line details if (count($details)) { $suffix .= '<p class="details">' . Skin::finalize_list($details, 'menu') . '</p>'; } // insert a suffix separator if (trim($suffix)) { $suffix = ' ' . $suffix; } // item summary $box .= $prefix . Skin::build_link($url, $title, 'article') . $suffix; // the icon to put in the left column if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } elseif (is_callable(array($anchor, 'get_bullet_url'))) { $icon = $anchor->get_bullet_url(); } // build the complete HTML element if ($icon) { $icon = '<img src="' . $icon . '" alt="" title="' . encode_field(strip_tags($title)) . '" />'; // make it a clickable link $icon = Skin::build_link($url, $icon, 'basic'); // default icon } else { $icon = DECORATED_IMG; } // layout this item $list = array(array($box, $icon)); $items[] = array($item['score'], Skin::finalize_list($list, 'decorated')); } // end of processing SQL::free($result); return $items; }
/** * list sections as topics in a forum * * @param resource the SQL result * @return string the rendered text **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // 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'] . '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'); } // get the related overlay, if any $overlay = Overlay::load($item, 'section:' . $item['id']); // get the main anchor $anchor = Anchors::get($item['anchor']); // reset everything $prefix = $label = $suffix = $icon = ''; // signal restricted and private sections if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // indicate the id in the hovering popup $hover = i18n::s('View the section'); if (Surfer::is_member()) { $hover .= ' [section=' . $item['id'] . ']'; } // the url to view this item $url = Sections::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']); } // use the title as a link to the page $title =& Skin::build_link($url, $title, 'basic', $hover); // flag sections 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 . ' '; } // this is another row of the output $text .= '<tr class="' . $class_title . '"><th>' . $prefix . $title . $suffix . '</th><th>' . i18n::s('Poster') . '</th><th>' . i18n::s('Messages') . '</th><th>' . i18n::s('Last active') . '</th></tr>' . "\n"; $count = 1; // get last posts for this board --avoid sticky pages if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) { $order = $matches[1]; } else { $order = 'edition'; } if ($articles =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, 5, 'raw', TRUE)) { foreach ($articles as $id => $article) { // get the related overlay, if any $article_overlay = Overlay::load($article, 'article:' . $id); // flag articles updated recently if ($article['expiry_date'] > NULL_DATE && $article['expiry_date'] <= $context['now']) { $flag = EXPIRED_FLAG . ' '; } elseif ($article['create_date'] >= $context['fresh']) { $flag = NEW_FLAG . ' '; } elseif ($article['edit_date'] >= $context['fresh']) { $flag = UPDATED_FLAG . ' '; } else { $flag = ''; } // use the title to label the link if (is_object($article_overlay)) { $title = Codes::beautify_title($article_overlay->get_text('title', $article)); } else { $title = Codes::beautify_title($article['title']); } // title $title = Skin::build_link(Articles::get_permalink($article), $title, 'article'); // poster $poster = Users::get_link($article['create_name'], $article['create_address'], $article['create_id']); // comments $comments = Comments::count_for_anchor('article:' . $article['id']); // last editor $action = ''; if ($article['edit_date']) { // label the action if (isset($article['edit_action'])) { $action = Anchors::get_action_label($article['edit_action']); } else { $action = i18n::s('edited'); } $action = '<span class="details">' . $action . ' ' . Skin::build_date($article['edit_date']) . '</span>'; } // this is another row of the output $text .= '<tr class="' . $class_detail . '"><td>' . $title . $flag . '</td><td>' . $poster . '</td><td style="text-align: center;">' . $comments . '</td><td>' . $action . '</td></tr>' . "\n"; } } // more details $details = array(); // board introduction if ($item['introduction']) { $details[] = Codes::beautify_introduction($item['introduction']); } // indicate the total number of threads here if (($count = Articles::count_for_anchor('section:' . $item['id'])) && $count >= 5) { $details[] = sprintf(i18n::s('%d threads'), $count) . ' »'; } // link to the section index page if ($details) { $details = Skin::build_link(Sections::get_permalink($item), join(' - ', $details), 'basic'); } else { $details = ''; } // add a command for new post $poster = ''; if (Surfer::is_empowered()) { $poster = Skin::build_link('articles/edit.php?anchor=' . urlencode('section:' . $item['id']), i18n::s('Add a page') . ' »', 'basic'); } // insert details in a separate row if ($details || $poster) { $text .= '<tr class="' . $class_detail . '"><td colspan="3">' . $details . '</td><td>' . $poster . '</td></tr>' . "\n"; } // more details $more = array(); // board moderators if ($moderators = Sections::list_editors_by_name($item, 0, 7, 'comma5')) { $more[] = sprintf(i18n::ns('Moderator: %s', 'Moderators: %s', count($moderators)), $moderators); } // children boards if ($children =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, COMPACT_LIST_SIZE, 'compact')) { $more[] = sprintf(i18n::ns('Child board: %s', 'Child boards: %s', count($children)), Skin::build_list($children, 'comma')); } // as a compact list if (count($more)) { $content = '<ul class="compact">'; foreach ($more as $list_item) { $content .= '<li>' . $list_item . '</li>' . "\n"; } $content .= '</ul>' . "\n"; // insert details in a separate row $text .= '<tr class="' . $class_detail . '"><td colspan="4">' . $content . '</td></tr>' . "\n"; } } // end of processing SQL::free($result); $text .= Skin::table_suffix(); return $text; }
/** * 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 * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // the script used to check all pages at once Page::insert_script('function cascade_selection_to_all_article_rows(handle) {' . "\n" . ' $("div#articles_panel input[type=\'checkbox\'].row_selector").each(' . "\n" . ' function() { $(this).attr("checked", $(handle).is(":checked"));}' . "\n" . ' );' . "\n" . '}' . "\n"); // table prefix $text .= Skin::table_prefix('yc-grid'); // table headers $main = '<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />'; $cells = array($main, i18n::s('Page'), i18n::s('Rank')); $text .= Skin::table_row($cells, 'header'); // process all items in the list include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; $count = 0; while ($item = SQL::fetch($result)) { $cells = array(); // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the main anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Articles::get_permalink($item); // column to select the row $cells[] = '<input type="checkbox" name="selected_articles[]" id="article_selector_' . $count . '" class="row_selector" value="' . $item['id'] . '" />'; // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // initialize variables $prefix = $suffix = $icon = ''; // flag sticky pages if ($item['rank'] < 10000) { $prefix .= STICKY_FLAG; } // signal locked articles if (isset($item['locked']) && $item['locked'] == 'Y') { $suffix .= ' ' . LOCKED_FLAG; } // flag articles that are dead, or created or updated very recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $prefix .= EXPIRED_FLAG; } elseif ($item['create_date'] >= $context['fresh']) { $suffix .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= ' ' . UPDATED_FLAG; } // signal articles to be published if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) { $prefix .= DRAFT_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // the introductory text if (is_object($overlay)) { $introduction = $overlay->get_text('introduction', $item); } else { $introduction = $item['introduction']; } if ($introduction) { $suffix .= BR . Codes::beautify_introduction($introduction); } // insert overlay data, if any if (is_object($overlay)) { $suffix .= $overlay->get_text('list', $item); } // append details to the suffix $suffix .= BR . '<span class="details">'; // details $details = array(); // the author if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { if ($item['create_name'] != $item['edit_name']) { $details[] = sprintf(i18n::s('by %s, %s'), $item['create_name'], $item['edit_name']); } else { $details[] = sprintf(i18n::s('by %s'), $item['create_name']); } } // the last action $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']); // the number of hits if (Surfer::is_logged() && $item['hits'] > 1) { $details[] = Skin::build_number($item['hits'], i18n::s('hits')); } // info on related files $stats = Files::stat_for_anchor('article:' . $item['id']); if ($stats['count']) { $details[] = sprintf(i18n::ns('%d file', '%d files', $stats['count']), $stats['count']); } // info on related links $stats = Links::stat_for_anchor('article:' . $item['id']); if ($stats['count']) { $details[] = sprintf(i18n::ns('%d link', '%d links', $stats['count']), $stats['count']); } // info on related comments $stats = Comments::stat_for_anchor('article:' . $item['id']); if ($stats['count']) { $details[] = sprintf(i18n::ns('%d comment', '%d comments', $stats['count']), $stats['count']); } // rating if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) { $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // combine in-line details if (count($details)) { $suffix .= ucfirst(trim(implode(', ', $details))); } // list up to three categories by title, if any $anchors = array(); if ($members =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) { foreach ($members as $id => $attributes) { // add background color to distinguish this category against others if (isset($attributes['background_color']) && $attributes['background_color']) { $attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>'; } $anchors[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic'); } } if (count($anchors)) { $suffix .= BR . sprintf(i18n::s('In %s'), implode(' / ', $anchors)); } // end of details $suffix .= '</span>'; // strip empty details $suffix = str_replace(BR . '<span class="details"></span>', '', $suffix); $suffix = str_replace('<span class="details"></span>', '', $suffix); // the icon to put in the left column if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } // commands $commands = array(Skin::build_link(Articles::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic'), Skin::build_link(Articles::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic')); // link to this page $cells[] = $prefix . Skin::build_link($url, $title, 'article') . ' - ' . Skin::finalize_list($commands, 'menu') . $suffix; // ranking $cells[] = '<input type="text" size="5" name="article_rank_' . $item['id'] . '" value="' . $item['rank'] . '" onfocus="$(\'#article_selector_' . $count . '\').attr(\'checked\', \'checked\');" onchange="$(\'#act_on_articles\').prop(\'selectedIndex\', 9);" />'; // append the row $text .= Skin::table_row($cells, $count++); } // select all rows $cells = array('<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />', i18n::s('Select all/none'), ''); $text .= Skin::table_row($cells, $count++); // table suffix $text .= Skin::table_suffix(); // end of processing SQL::free($result); return $text; }
/** * list articles as topics in a forum * * @param resource the SQL result * @return string the rendered text **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // allow for complete styling $text = '<div class="last_articles">'; // build a list of articles include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // get the related overlay $overlay = Overlay::load($item, 'article:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Articles::get_permalink($item); // build a title if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // reset everything $prefix = $label = $suffix = $icon = ''; // signal articles to be published if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) { $prefix .= DRAFT_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // flag expired articles if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $prefix .= EXPIRED_FLAG . ' '; } elseif ($item['create_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= UPDATED_FLAG; } // signal locked articles if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) { $suffix .= ' ' . LOCKED_FLAG; } // rating if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) { $suffix .= ' ' . Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // indicate the id in the hovering popup $hover = i18n::s('View the page'); if (Surfer::is_member()) { $hover .= ' [article=' . $item['id'] . ']'; } // one box per update $text .= '<div class="last_article" >'; // use the title as a link to the page $text .= Skin::build_block($prefix . ucfirst($title) . $suffix, 'header1'); // some details about this page $details = array(); // page starter and date if ($item['create_name']) { $details[] = sprintf(i18n::s('Started by %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id'])) . ' ' . Skin::build_date($item['create_date']); } // page last modification if ($item['edit_date'] && $item['edit_action'] == 'article:update' && $item['edit_name']) { $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . sprintf(i18n::s('by %s'), Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id'])) . ' ' . Skin::build_date($item['edit_date']); } // friends if ($friends =& Members::list_users_by_posts_for_anchor('article:' . $item['id'], 0, USERS_LIST_SIZE, 'comma5', $item['create_id'])) { $details[] = sprintf(i18n::s('with %s'), $friends); } // people details if ($details) { $text .= '<p class="details">' . join(', ', $details) . "</p>\n"; } // the introductory text $introduction = ''; if (is_object($overlay)) { $introduction = $overlay->get_text('introduction', $item); } elseif ($item['introduction']) { $introduction = $item['introduction']; } if ($introduction) { $text .= '<div style="margin: 1em 0;">' . Codes::beautify_introduction($introduction) . '</div>'; } // insert overlay data, if any if (is_object($overlay)) { $text .= $overlay->get_text('list', $item); } // info on related comments if (($count = Comments::count_for_anchor('article:' . $item['id'])) > 1) { $text .= '<div style="margin-top: 1em;"><p class="details">' . sprintf(i18n::s('%d contributions, including:'), $count) . '</p></div>'; } // avoid first file if mentioned in last contribution $file_offset = 0; // get last contribution for this page if ($comment = Comments::get_newest_for_anchor('article:' . $item['id'])) { if (preg_match('/\\[(download|file)=/', $comment['description'])) { $file_offset++; } // bars around the last contribution $bottom_menu = array(); // last contributor $contributor = Users::get_link($comment['create_name'], $comment['create_address'], $comment['create_id']); $flag = ''; if ($comment['create_date'] >= $context['fresh']) { $flag = NEW_FLAG; } elseif ($comment['edit_date'] >= $context['fresh']) { $flag = UPDATED_FLAG; } $bottom_menu[] = sprintf(i18n::s('By %s'), $contributor) . ' ' . Skin::build_date($comment['create_date']) . $flag; // offer to reply if (Comments::allow_creation($item, $anchor)) { $link = Comments::get_url($comment['id'], 'reply'); $bottom_menu[] = Skin::build_link($link, i18n::s('Reply'), 'basic'); } // gather pieces $pieces = array(); // last contribution, and user signature $pieces[] = ucfirst(trim($comment['description'])) . Users::get_signature($comment['create_id']); // bottom if ($bottom_menu) { $pieces[] = '<div style="margin-top: 1em;">' . ucfirst(trim(Skin::finalize_list($bottom_menu, 'menu'))) . '</div>'; } // put all pieces together $text .= '<div class="last_comment">' . "\n" . join("\n", $pieces) . '</div>' . "\n"; } // list more recent files if ($items = Files::list_by_date_for_anchor('article:' . $item['id'], $file_offset, 3, 'dates')) { // more files than listed $more = ''; if (($count = Files::count_for_anchor('article:' . $item['id'])) > 3) { $more = '<span class="details">' . sprintf(i18n::s('%d files, including:'), $count) . '</span>'; } if (is_array($items)) { $items = Skin::build_list($items, 'compact'); } $text .= '<div style="margin: 1em 0;">' . $more . $items . '</div>'; } // display all tags if ($item['tags']) { $text .= ' <p class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</p>'; } // navigation links $menu = array(); // permalink $menu[] = Skin::build_link($url, i18n::s('View the page'), 'span'); // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { $menu[] = sprintf(i18n::ns('%d link', '%d links', $count), $count); } // the main anchor link if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) { $menu[] = Skin::build_link($anchor->get_url(), sprintf(i18n::s('in %s'), ucfirst($anchor->get_title())), 'span', i18n::s('View the section')); } // actually insert details $text .= Skin::finalize_list($menu, 'menu_bar'); // bottom of the box $text .= '</div>'; } // close the list of articles $text .= '</div>'; // beautify everything at once $text = Codes::beautify($text); // end of processing SQL::free($result); // done return $text; }
/** * list articles * * @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 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']); } // initialize variables $prefix = $suffix = ''; // 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; } // 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; } // count related comments, if any if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) { $suffix .= ' (' . $count . ')'; } // flag articles updated recently if ($item['create_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= UPDATED_FLAG; } // the hovering title if ($item['introduction'] && $context['skins_with_details'] == 'Y') { $hover = strip_tags(Codes::beautify_introduction($item['introduction'])); } else { $hover = i18n::s('View the page'); } // help members to reference this page if (Surfer::is_member()) { $hover .= ' [article=' . $item['id'] . ']'; } // list all components for this item $items[$url] = array($prefix, Skin::strip($title, 30), $suffix, 'basic', NULL, $hover); } // end of processing SQL::free($result); return $items; }
$count = 0; if ($ids = Articles::get_ids_for_overlay($_REQUEST['id'])) { $context['text'] .= sprintf(i18n::s('Changing all overlays with name %s'), $_REQUEST['id']) . BR; // one page at a time foreach ($ids as $id) { // load the page and bind the related overlay if (($item = Articles::get($id)) && ($overlay = Overlay::load($item, 'article:' . $item['id'])) && is_callable(array($overlay, 'update'))) { $count++; // update provided attributes $overlay->update($_REQUEST); // save content of the overlay in the page $item['overlay'] = $overlay->save(); $item['overlay_id'] = $overlay->get_id(); // store in the database if (Articles::put($item)) { $context['text'] .= sprintf(i18n::s('%s has been changed'), Skin::build_link(Articles::get_permalink($item), $item['title'])); } } } // no page has been found } else { $context['text'] .= '<p>' . i18n::s('No item has the provided id.') . '</p>'; } // report on results if ($count) { $context['text'] .= '<p>' . sprintf(i18n::ns('%d page has been processed.', '%d pages have been processed.', $count), $count) . '</p>'; } // bottom commands $menu = array(); $menu[] = Skin::build_link('overlays/mutables/edit.php', i18n::s('Change named overlays'), 'basic'); $context['text'] .= Skin::finalize_list($menu, 'assistant_bar');
/** * list articles * * Accept following variants: * - 'hits', compact plus the number of hits * - 'no_author', for articles in the user page * - 'category:xxx', if the list is displayed at categories/view.php * - 'section:xxx', if the list is displayed at sections/view.php * * @param resource the SQL result * @return array of resulting items, or NULL * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($url => $attributes) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // sanity check if (!isset($this->layout_variant)) { $this->layout_variant = 'decorated'; } // process all items in the list include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the main anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Articles::get_permalink($item); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // initialize variables $prefix = $suffix = $icon = ''; // flag sticky pages if ($item['rank'] < 10000) { $prefix .= STICKY_FLAG; } // signal locked articles if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) { $suffix .= ' ' . LOCKED_FLAG; } // flag articles that are dead, or created or updated very recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $prefix .= EXPIRED_FLAG; } elseif ($item['create_date'] >= $context['fresh']) { $suffix .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= ' ' . UPDATED_FLAG; } // signal articles to be published if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) { $prefix .= DRAFT_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // the compact version if ($this->layout_variant == 'compact') { $items[$url] = array($prefix, Skin::strip($title, 30), $suffix, 'basic', NULL); continue; } // with hits if ($this->layout_variant == 'hits') { if ($item['hits'] > 1) { $suffix = ' <span class="details">- ' . Skin::build_number($item['hits'], i18n::s('hits')) . '</span>'; } $items[$url] = array($prefix, Skin::strip($title, 30), $suffix, 'basic', NULL); continue; } // introduction $introduction = ''; if (is_object($overlay)) { $introduction = $overlay->get_text('introduction', $item); } else { $introduction = $item['introduction']; } // the introductory text if ($introduction) { $suffix .= ' - ' . Codes::beautify_introduction($introduction); // link to description, if any if ($item['description']) { $suffix .= ' ' . Skin::build_link($url, MORE_IMG, 'more', i18n::s('View the page')) . ' '; } } // insert overlay data, if any if (is_object($overlay)) { $suffix .= $overlay->get_text('list', $item); } // next line, except if we already are at the beginning of a line if ($suffix && !preg_match('/<br\\s*\\/>$/', rtrim($suffix))) { $suffix .= BR; } // append details to the suffix $suffix .= '<span class="details">'; // details $details = array(); // display details only at the main index page, and also at anchor pages if (isset($this->focus) && $item['anchor'] != $this->focus) { // the author if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { if ($item['create_name'] != $item['edit_name']) { $details[] = sprintf(i18n::s('by %s, %s'), $item['create_name'], $item['edit_name']); } else { $details[] = sprintf(i18n::s('by %s'), $item['create_name']); } } // the last action $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']); // the number of hits if (Surfer::is_logged() && $item['hits'] > 1) { $details[] = Skin::build_number($item['hits'], i18n::s('hits')); } // info on related files if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count); } // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count); } // info on related comments if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count); } // rating if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) { $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // unusual ranks are signaled to associates and owners if ($item['rank'] != 10000 && Articles::is_owned($item, $anchor)) { $details[] = '{' . $item['rank'] . '}'; } } // at the user page if ($this->layout_variant == 'no_author' && Surfer::get_id()) { if (Members::check('article:' . $item['id'], 'user:'******'Stop notifications'); } else { $label = i18n::s('Watch this page'); } $menu = array('users/track.php?anchor=' . urlencode('article:' . $item['id']) => $label); $details[] = Skin::build_list($menu, 'menu'); } // the main anchor link if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) { $details[] = sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'section')); } // combine in-line details if (count($details)) { $suffix .= ucfirst(trim(implode(', ', $details))); } // end of details $suffix .= '</span>'; // display all tags if ($item['tags']) { $suffix .= ' <span class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</span>'; } // strip empty details $suffix = str_replace(BR . '<span class="details"></span>', '', $suffix); $suffix = str_replace('<span class="details"></span>', '', $suffix); // insert a suffix separator if (trim($suffix)) { $suffix = ' ' . $suffix; } // the icon to put in the left column if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } elseif (is_callable(array($anchor, 'get_bullet_url'))) { $icon = $anchor->get_bullet_url(); } // list all components for this item $items[$url] = array($prefix, $title, $suffix, 'article', $icon); } // end of processing SQL::free($result); return $items; }
/** * layout the newest articles * * caution: this function also updates page title directly, and this makes its call non-cacheable * * @param array the article * @return string the rendered text **/ function layout_newest($item) { global $context; // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Articles::get_permalink($item); // reset the rendering engine between items Codes::initialize($url); // build a title if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // title prefix & suffix $text = $prefix = $suffix = ''; // flag articles updated recently if ($context['site_revisit_after'] < 1) { $context['site_revisit_after'] = 2; } $context['fresh'] = gmstrftime('%Y-%m-%d %H:%M:%S', mktime(0, 0, 0, date("m"), date("d") - $context['site_revisit_after'], date("Y"))); // link to permalink if (Surfer::is_empowered()) { $title = Skin::build_box_title($title, $url, i18n::s('Permalink')); } // signal articles to be published if ($item['publish_date'] <= NULL_DATE) { $prefix .= DRAFT_FLAG; } else { if ($item['publish_date'] > NULL_DATE && $item['publish_date'] > $context['now']) { $prefix .= DRAFT_FLAG; } } // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG . ' '; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG . ' '; } // signal locked articles if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) { $suffix .= LOCKED_FLAG; } // flag expired article if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $suffix .= EXPIRED_FLAG; } // update page title directly $text .= Skin::build_block($prefix . $title . $suffix, 'title'); // if this article has a specific icon, use it if ($item['icon_url']) { $icon = $item['icon_url']; } elseif ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) { $icon = $anchor->get_icon_url(); } // if we have a valid image if (preg_match('/(.gif|.jpg|.jpeg|.png)$/i', $icon)) { // fix relative path if (!preg_match('/^(\\/|http:|https:|ftp:)/', $icon)) { $icon = $context['url_to_root'] . $icon; } // flush the image on the right $text .= '<img src="' . $icon . '" class="right_image" alt="" />'; } // article rating, if the anchor allows for it if (!is_object($anchor) || !$anchor->has_option('without_rating')) { // report on current rating $label = ''; if ($item['rating_count']) { $label = Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])) . ' '; } $label .= i18n::s('Rate this page'); // allow for rating $text .= Skin::build_link(Articles::get_url($item['id'], 'like'), $label, 'basic'); } // the introduction text, if any if (is_object($overlay)) { $text .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction'); } else { $text .= Skin::build_block($item['introduction'], 'introduction'); } // insert overlay data, if any if (is_object($overlay)) { $text .= $overlay->get_text('view', $item); } // the beautified description, which is the actual page body if ($item['description']) { // use adequate label if (is_object($overlay) && ($label = $overlay->get_label('description'))) { $text .= Skin::build_block($label, 'title'); } $text .= Skin::build_block($item['description'], 'description', '', $item['options']); } // // list related files // // if this surfer is an editor of this article, show hidden files as well if (Articles::is_assigned($item['id']) || is_object($anchor) && $anchor->is_assigned()) { Surfer::empower(); } // build a complete box $box['bar'] = array(); $box['text'] = ''; // count the number of files in this article if ($count = Files::count_for_anchor('article:' . $item['id'])) { if ($count > 20) { $box['bar'] += array('_count' => sprintf(i18n::ns('%d file', '%d files', $count), $count)); } // list files by date (default) or by title (option files_by_title) if (Articles::has_option('files_by', $anchor, $item) == 'title') { $items = Files::list_by_title_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'article:' . $item['id']); } else { $items = Files::list_by_date_for_anchor('article:' . $item['id'], 0, FILES_PER_PAGE, 'article:' . $item['id']); } if (is_array($items)) { $box['text'] .= Skin::build_list($items, 'decorated'); } // navigation commands for files $prefix = Articles::get_url($item['id'], 'navigate', 'files'); $box['bar'] += Skin::navigate($url, $prefix, $count, FILES_PER_PAGE, 0); // the command to post a new file, if allowed if (Files::allow_creation($item, $anchor, 'article')) { $link = 'files/edit.php?anchor=' . urlencode('article:' . $item['id']); $box['bar'] += array($link => i18n::s('Add a file')); } if (is_array($box['bar'])) { $box['text'] .= Skin::build_list($box['bar'], 'menu_bar'); } } // actually render the html for this box if ($box['text']) { $text .= Skin::build_box(i18n::s('Files'), $box['text'], 'header1', 'files'); } // // bottom page menu // // discuss this page, if the index page can be commented, and comments are accepted at the article level if (Comments::allow_creation($item, $anchor)) { $this->menu[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Post a comment'), 'span'); } // info on related comments if ($count = Comments::count_for_anchor('article:' . $item['id'])) { $this->menu[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'span'); } // new links are accepted at the index page and at the article level if (Links::allow_trackback()) { $this->menu[] = Skin::build_link('links/trackback.php?anchor=' . urlencode('article:' . $item['id']), i18n::s('Reference this page'), 'span'); } // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'])) { $this->menu[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'span'); } // new files are accepted at the index page and at the article level if (is_object($anchor) && $anchor->has_option('with_files') && !($anchor->has_option('no_files') || preg_match('/\\bno_files\\b/i', $item['options']))) { // add a file if (Files::allow_creation($item, $anchor, 'article')) { if ($context['with_friendly_urls'] == 'Y') { $link = 'files/edit.php/article/' . $item['id']; } else { $link = 'files/edit.php?anchor=' . urlencode('article:' . $item['id']); } $this->menu[] = Skin::build_link($link, i18n::s('Add a file'), 'span'); } } // modify this page if (Surfer::is_empowered()) { $this->menu[] = Skin::build_link(Articles::get_url($item['id'], 'edit'), i18n::s('Edit'), 'span'); } // view permalink if (Surfer::is_empowered()) { $this->menu[] = Skin::build_link($url, i18n::s('Permalink'), 'span'); } // insert overlay data, if any if (is_object($overlay)) { $text .= $overlay->get_text('trailer', $item); } // add trailer information from this item, if any if (isset($item['trailer']) && trim($item['trailer'])) { $text .= Codes::beautify($item['trailer']); } // returned the formatted content return $text; }
// list links by date (default) or by title (option :links_by_title:) $items = array(); if (Articles::has_option('links_by_title', $anchor, $item)) { $items = Links::list_by_title_for_anchor('article:' . $item['id'], 0, 50, 'compact'); } else { $items = Links::list_by_date_for_anchor('article:' . $item['id'], 0, 50, 'compact'); } // actually list items if (count($items)) { $context['text'] .= Skin::build_box(i18n::s('See also'), utf8::to_unicode(Skin::build_list($items, 'compact'))); } // // page suffix // // link to the original page $context['text'] .= '<p>' . sprintf(i18n::s('The original page is located at %s'), Skin::build_link(Articles::get_permalink($item), Articles::get_permalink($item))) . "</p>\n"; // insert anchor suffix if (is_object($anchor)) { $context['text'] .= $anchor->get_suffix(); } // // special rendering if everything is ok // $text = '<html><body>' . "\n"; // display the title if (isset($context['page_title']) && $context['page_title']) { $text .= Skin::build_block($context['page_title'], 'page_title'); } // display error messages, if any $text .= Skin::build_error_block(); // render and display the content, if any
// the trail of the cover article if (!isset($context['root_cover_at_home']) || $context['root_cover_at_home'] != 'none') { // may be changed in skin.php if necessary if (isset($cover_page['trailer'])) { $context['text'] .= Codes::beautify($cover_page['trailer']); } } // // compute extra information -- $context['extra'] // // page tools // if (Surfer::is_associate()) { $context['page_tools'][] = Skin::build_link('configure.php', i18n::s('Configure')); if (isset($cover_page['id'])) { $context['page_tools'][] = Skin::build_link(Articles::get_permalink($cover_page), i18n::s('Cover page'), 'basic'); } if (($section = Sections::get('gadget_boxes')) && isset($section['id'])) { $context['page_tools'][] = Skin::build_link(Sections::get_permalink($section), i18n::s('Gadget boxes'), 'basic'); } if (($section = Sections::get('extra_boxes')) && isset($section['id'])) { $context['page_tools'][] = Skin::build_link(Sections::get_permalink($section), i18n::s('Extra boxes'), 'basic'); } 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
// cascade changes on access rights if ($_REQUEST['active'] != $item['active']) { Anchors::cascade('article:' . $item['id'], $_REQUEST['active']); } // the page has been modified $context['text'] .= '<p>' . i18n::s('The page has been successfully updated.') . '</p>'; // display the updated page if (!($recipients = Mailer::build_recipients('article:' . $item['id']))) { Safe::redirect(Articles::get_permalink($item)); } // list persons that have been notified $context['text'] .= $recipients; // follow-up commands $follow_up = i18n::s('What do you want to do now?'); $menu = array(); $menu = array_merge($menu, array(Articles::get_permalink($_REQUEST) => i18n::s('View the page'))); if (Surfer::may_upload()) { $menu = array_merge($menu, array('files/edit.php?anchor=' . urlencode('article:' . $item['id']) => i18n::s('Add a file'))); } if ((!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE) && Surfer::is_empowered()) { $menu = array_merge($menu, array(Articles::get_url($item['id'], 'publish') => i18n::s('Publish the page'))); } $follow_up .= Skin::build_list($menu, 'menu_bar'); $context['text'] .= Skin::build_block($follow_up, 'bottom'); } // create a new page } elseif (!($_REQUEST['id'] = Articles::post($_REQUEST))) { $item = $_REQUEST; $with_form = TRUE; // successful post } else {
} // action has to be confirmed } elseif (isset($_SERVER['REQUEST_METHOD']) && $_SERVER['REQUEST_METHOD'] == 'POST') { Logger::error(i18n::s('The action has not been confirmed.')); // please confirm } else { // the article or the anchor icon, if any $context['page_image'] = $item['icon_url']; if (!$context['page_image'] && is_object($anchor)) { $context['page_image'] = $anchor->get_icon_url(); } // commands $menu = array(); $menu[] = Skin::build_submit_button(i18n::s('Yes, I want to duplicate this page'), NULL, NULL, 'confirmed'); if (isset($item['id'])) { $menu[] = Skin::build_link(Articles::get_permalink($item), i18n::s('Cancel'), 'span'); } // render commands $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="action" value="duplicate" />' . "\n" . '</p></form>' . "\n"; // set the focus Page::insert_script('$("#confirmed").focus();'); // the title of the action $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); } // details $details = array();
// permission denied } elseif (!Articles::allow_access($item, $anchor)) { // 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 article } else { // initialize the rendering engine Codes::initialize(Articles::get_permalink($item)); // compute the url for this article $permanent_link = Articles::get_permalink($item); // the trackback link $trackback_link = $context['url_to_home'] . $context['url_to_root'] . 'links/trackback.php?anchor=article:' . $item['id']; // get a description -- render codes if (isset($item['introduction']) && $item['introduction']) { $description = Codes::beautify($item['introduction'], $item['options']); } else { $description = Skin::cap(Codes::beautify($item['description'], $item['options']), 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#"' . "\n" . ' xmlns:dc="http://purl.org/dc/elements/1.1/"' . "\n" . ' xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/">' . "\n" . ' <rdf:Description' . "\n" . ' trackback:ping="' . $trackback_link . '"' . "\n" . ' dc:identifier="' . $permanent_link . '"' . "\n" . ' rdf:about="' . $permanent_link . '">' . "\n" . ' <dc:title>' . encode_field($item['title']) . '</dc:title>' . "\n" . ' <dc:description>' . encode_field(Skin::strip($description)) . '</dc:description>' . "\n" . ' <dc:creator>' . $item['create_name'] . '</dc:creator>' . "\n" . ' <dc:date>' . gmdate('Y-m-d') . '</dc:date>' . "\n" . ' <dc:format>text/html</dc:format>' . "\n"; if (isset($item['language']) && $item['language'] && $item['language'] != 'none') { $text .= ' <dc:language>' . $item['language'] . '</dc:language>' . "\n"; } if (is_object($anchor)) { $text .= ' <dc:subject>' . encode_field($anchor->get_title()) . '</dc:subject>' . "\n";
} // list links by date (default) or by title (option links_by_title) $offset = ($zoom_index - 1) * LINKS_PER_PAGE; if (Articles::has_option('links_by_title', $anchor, $item)) { $items = Links::list_by_title_for_anchor('article:' . $item['id'], $offset, LINKS_PER_PAGE); } else { $items = Links::list_by_date_for_anchor('article:' . $item['id'], $offset, LINKS_PER_PAGE); } // actually render the html if (is_array($items)) { $box['text'] .= Skin::build_list($items, 'decorated'); } elseif (is_string($items)) { $box['text'] .= $items; } // navigation commands for links $home = Articles::get_permalink($item); $prefix = Articles::get_url($item['id'], 'navigate', 'links'); $box['bar'] += Skin::navigate($home, $prefix, $count, LINKS_PER_PAGE, $zoom_index); // new links are allowed if ($cur_article->allows('creation', 'link')) { Skin::define_img('LINKS_ADD_IMG', 'links/add.gif'); $box['bar'] += array('links/edit.php?anchor=' . urlencode('article:' . $item['id']) => LINKS_ADD_IMG . i18n::s('Add a link')); } } // there is some box content if ($box['text']) { $canvas['links'] = Skin::build_content('links', i18n::s('Links'), $box['text'], $box['bar']); } $canvas['links_count'] = $count; } //
/** * 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; } // sanity check if (!isset($this->focus)) { $this->focus = 'map'; } // put in cache $cache_id = Cache::hash('articles/layout_articles_as_carrousel:' . $this->focus) . '.xml'; // save for one minute if (!file_exists($context['path_to_root'] . $cache_id) || filemtime($context['path_to_root'] . $cache_id) + 60 < time()) { // content of the slideshow $content = '<?xml version="1.0" encoding="utf-8"?><!-- fhShow Carousel 2.0 configuration file Please visit http://www.flshow.net/ -->' . "\n" . '<slide_show>' . "\n" . ' <options>' . "\n" . ' <debug>false</debug> <!-- true, false -->' . "\n" . ' <background>transparent</background> <!-- #RRGGBB, transparent -->' . "\n" . ' <friction>5</friction> <!-- [1,100] -->' . "\n" . ' <fullscreen>false</fullscreen> <!-- true, false -->' . "\n" . ' <margins>' . "\n" . ' <top>0</top> <!-- [-1000,1000] pixels -->' . "\n" . ' <left>0</left> <!-- [-1000,1000] pixels -->' . "\n" . ' <bottom>0</bottom> <!-- [-1000,1000] pixels -->' . "\n" . ' <right>0</right> <!-- [-1000,1000] pixels -->' . "\n" . ' <horizontal_ratio>20%</horizontal_ratio> <!-- [1,50] a photo may occupy at most horizontalRatio percent of the Carousel width -->' . "\n" . ' <vertical_ratio>90%</vertical_ratio> <!-- [1,100] a photo may occupy at most verticalRatio percent of the Carousel height -->' . "\n" . ' </margins>' . "\n" . ' <interaction>' . "\n" . ' <rotation>mouse</rotation> <!-- auto, mouse, keyboard -->' . "\n" . ' <view_point>none</view_point> <!-- none, mouse, keyboard -->' . "\n" . ' <speed>15</speed> <!-- [-360,360] degrees per second -->' . "\n" . ' <default_speed>15</default_speed> <!-- [-360,360] degrees per second -->' . "\n" . ' <default_view_point>20%</default_view_point> <!-- [0,100] percentage -->' . "\n" . ' <reset_delay>20</reset_delay> <!-- [0,600] seconds, 0 means never reset -->' . "\n" . ' </interaction>' . "\n" . ' <far_photos>' . "\n" . ' <size>50%</size> <!-- [0,100] percentage -->' . "\n" . ' <amount>50%</amount> <!-- [0,100] percentage -->' . "\n" . ' <blur>10</blur> <!-- [0,100] amount -->' . "\n" . ' <blur_quality>3</blur_quality> <!-- [1,3] 1=low - 3=high -->' . "\n" . ' </far_photos>' . "\n" . ' <reflection>' . "\n" . ' <amount>25</amount> <!-- [0,1000] pixels -->' . "\n" . ' <blur>2</blur> <!-- [0,100] blur amount -->' . "\n" . ' <distance>0</distance> <!-- [-1000,1000] pixels -->' . "\n" . ' <alpha>40%</alpha> <!-- [0,100] percentage -->' . "\n" . ' </reflection>' . "\n" . ' <titles>' . "\n" . ' <style>font-size: 14px; font-family: Verdana, _serif; color: #000000;</style>' . "\n" . ' <position>above center</position> <!-- [above, below] [left,center,right]-->' . "\n" . ' <background>' . $context['url_to_home'] . $context['url_to_root'] . 'skins/_reference/layouts/carrousel_bubble.png</background> <!-- image url -->' . "\n" . ' <scale9>35 35 35 35</scale9> <!-- [0,1000] pixels -->' . "\n" . ' <padding>8 15 10 15</padding> <!-- [-1000,1000] pixels -->' . "\n" . ' </titles>' . "\n" . ' </options>' . "\n"; // get a default image if (Safe::GetImageSize($context['path_to_root'] . $context['skin'] . '/layouts/map.gif')) { $default_href = $context['url_to_root'] . $context['skin'] . '/layouts/map.gif'; } elseif ($size = Safe::GetImageSize($context['path_to_root'] . 'skins/_reference/layouts/map.gif')) { $default_href = $context['url_to_root'] . 'skins/_reference/layouts/map.gif'; } else { $default_href = NULL; } // process all items in the list while ($item = SQL::fetch($result)) { // get the related overlay $overlay = Overlay::load($item, 'article:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // this is visual if (isset($item['icon_url']) && $item['icon_url']) { $image = $item['icon_url']; } elseif (isset($item['thumbnail_url']) && $item['thumbnail_url']) { $image = $item['thumbnail_url']; } elseif (is_callable(array($anchor, 'get_bullet_url')) && ($image = $anchor->get_bullet_url())) { } elseif ($default_href) { $image = $default_href; } else { continue; } // fix relative path if (!preg_match('/^(\\/|http:|https:|ftp:)/', $image)) { $image = $context['url_to_home'] . $context['url_to_root'] . $image; } // build a title if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // the url to view this item $url = Articles::get_permalink($item); // add to the list $content .= ' <photo>' . "\n" . ' <title>' . $title . '</title>' . "\n" . ' <src>' . $image . '</src>' . "\n" . ' <href>' . $url . '</href>' . "\n" . ' <target>_self</target>' . "\n" . ' </photo>' . "\n"; } // finalize slideshow content $content .= '</slide_show>'; // put in cache Safe::file_put_contents($cache_id, $content); } // allow multiple instances static $count; if (!isset($count)) { $count = 1; } else { $count++; } // load the right file $text = '<div id="articles_as_carrousel_' . $count . '"></div>' . "\n"; Page::insert_script('swfobject.embedSWF("' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/carrousel.swf",' . "\n" . '"articles_as_carrousel_' . $count . '",' . "\n" . '"100%",' . "\n" . '"150",' . "\n" . '"9.0.0",' . "\n" . 'false,' . "\n" . '{xmlfile:"' . $context['url_to_home'] . $context['url_to_root'] . $cache_id . '", loaderColor:"0x666666"},' . "\n" . '{wmode: "transparent"},' . "\n" . '{});' . "\n"); // end of processing SQL::free($result); return $text; }
/** * 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 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 articles include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Articles::get_permalink($item); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // reset everything $prefix = $label = $suffix = $icon = $details = ''; // signal articles to be published if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) { $prefix .= DRAFT_FLAG; } // signal restricted and private articles if (isset($item['active']) && $item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif (isset($item['active']) && $item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // flag articles updated recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $suffix .= ' ' . EXPIRED_FLAG; } elseif ($item['create_date'] >= $context['fresh']) { $suffix .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= ' ' . UPDATED_FLAG; } // 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 topics in a forum * * @param resource the SQL result * @return string the rendered text **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // start a table $text .= Skin::table_prefix('jive'); // headers $text .= Skin::table_row(array(i18n::s('Topic'), i18n::s('Content')), 'header'); // build a list of articles $odd = FALSE; include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Articles::get_permalink($item); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // one row per article $text .= '<tr class="' . ($odd ? 'odd' : 'even') . '"><td>'; $odd = !$odd; // signal articles to be published if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) { $text .= DRAFT_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $text .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $text .= RESTRICTED_FLAG; } // use the title as a link to the page $text .= Skin::build_link($url, '<strong>' . $title . '</strong>', 'basic'); // signal locked articles if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) { $text .= ' ' . LOCKED_FLAG; } // flag articles updated recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $text .= ' ' . EXPIRED_FLAG; } elseif ($item['create_date'] >= $context['fresh']) { $text .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $text .= ' ' . UPDATED_FLAG; } // add details, if any $details = array(); // poster name if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { if ($item['create_name']) { $details[] = sprintf(i18n::s('posted by %s %s'), Users::get_link($item['create_name'], $item['create_address'], $item['create_id']), Skin::build_date($item['create_date'])); } } // last update $details[] = sprintf(i18n::s('Updated %s'), Skin::build_date($item['edit_date'])); // add details to the title if (count($details)) { $text .= '<p class="details" style="margin: 3px 0">' . join(', ', $details) . '</p>'; } // display all tags if ($item['tags']) { $text .= '<p class="tags">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</p>'; } // next cell for the content $text .= '</td><td width="70%">'; // the content to be displayed $content = ''; // rating if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) { $content .= Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // the introductory text if (is_object($overlay)) { $content .= Codes::beautify_introduction($overlay->get_text('introduction', $item)); } else { $content .= Codes::beautify_introduction($item['introduction']); } // insert overlay data, if any if (is_object($overlay)) { $content .= $overlay->get_text('list', $item); } // the description $content .= Skin::build_block($item['description'], 'description', '', $item['options']); // attachment details $details = array(); // info on related files if ($count = Files::count_for_anchor('article:' . $item['id'])) { Skin::define_img('FILES_LIST_IMG', 'files/list.gif'); $details[] = Skin::build_link($url . '#_attachments', FILES_LIST_IMG . sprintf(i18n::ns('%d file', '%d files', $count), $count), 'span'); } // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { Skin::define_img('LINKS_LIST_IMG', 'links/list.gif'); $details[] = LINKS_LIST_IMG . sprintf(i18n::ns('%d link', '%d links', $count), $count); } // count replies if ($count = Comments::count_for_anchor('article:' . $item['id'])) { $details[] = Skin::build_link($url . '#_discussion', sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'span'); } // the command to reply if (Comments::allow_creation($item, $anchor)) { Skin::define_img('COMMENTS_ADD_IMG', 'comments/add.gif'); $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), COMMENTS_ADD_IMG . i18n::s('Post a comment'), 'span'); } // describe attachments $content .= Skin::finalize_list($details, 'menu_bar'); // end the row $text .= $content . '</td></tr>'; } // end of processing SQL::free($result); // return the table $text .= Skin::table_suffix(); return $text; }
/** * 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 include_once $context['path_to_root'] . 'articles/article.php'; include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'locations/locations.php'; while ($item = SQL::fetch($result)) { // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // provide an absolute link $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']); } // time of last update $time = SQL::strtotime($item['edit_date']); // the section $section = ''; if ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) { $section = 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'] . ')'; } } // some introductory text for this article $article = new Article(); $article->load_by_content($item); $introduction = $article->get_teaser('teaser'); // warns on restricted access if (isset($item['active']) && $item['active'] != 'Y') { $introduction = '[' . i18n::c('Restricted to members') . '] ' . $introduction; } // fix references $introduction = preg_replace('/"\\//', '"' . $context['url_to_home'] . '/', $introduction); // the article content $description = ''; // other rss fields $extensions = array(); // the geolocation for this page, if any if ($location = Locations::locate_anchor('article:' . $item['id'])) { $extensions[] = '<georss:point>' . str_replace(',', ' ', $location) . '</georss:point>'; } // url for comments if (is_object($anchor)) { $extensions[] = '<comments>' . encode_link($context['url_to_home'] . $context['url_to_root'] . $anchor->get_url('comments')) . '</comments>'; } // count comments $comment_count = Comments::count_for_anchor('article:' . $item['id']); $extensions[] = '<slash:comments>' . $comment_count . "</slash:comments>"; // the comment post url $extensions[] = '<wfw:comment>' . encode_link($context['url_to_home'] . $context['url_to_root'] . Comments::get_url('article:' . $item['id'], 'service.comment')) . "</wfw:comment>"; // the comment Rss url $extensions[] = '<wfw:commentRss>' . encode_link($context['url_to_home'] . $context['url_to_root'] . Comments::get_url('article:' . $item['id'], 'feed')) . "</wfw:commentRss>"; // the trackback url $extensions[] = '<trackback:ping>' . encode_link($context['url_to_home'] . $context['url_to_root'] . 'links/trackback.php?anchor=' . urlencode('article:' . $item['id'])) . "</trackback:ping>"; // no trackback:about; // list all components for this item $items[$url] = array($time, $title, $author, $section, $icon, $introduction, $description, $extensions); } // end of processing SQL::free($result); return $items; }
/** * get the url to display the main page for this anchor * * @see shared/anchor.php * * @param string the targeted action ('view', 'print', 'edit', 'delete', ...) * @return an anchor to the viewing script, or NULL on error */ function get_url($action = 'view') { // sanity check if (!isset($this->item['id'])) { return NULL; } switch ($action) { // view comments case 'comments': // variants that start at the article page if ($this->has_option('view_as_chat')) { return $this->get_url() . '#comments'; } // start threads on a separate page if ($this->has_layout('alistapart')) { return Comments::get_url($this->get_reference(), 'list'); } // layouts that start at the article page --assume we have at least one comment, on a tab return Articles::get_permalink($this->item) . '#_discussion'; // list of files // list of files case 'files': return $this->get_url() . '#_attachments'; // list of links // list of links case 'links': return $this->get_url() . '#_attachments'; // jump to parent page // jump to parent page case 'parent': if (!isset($this->anchor)) { $this->anchor = Anchors::get($this->item['anchor']); } return $this->anchor->get_url(); // the permalink page // the permalink page case 'view': return Articles::get_permalink($this->item); // another action // another action default: return Articles::get_url($this->item['id'], $action, $this->item['title'], $this->item['nick_name']); } }
$overlay->attributes[$name][$sub_name] = str_replace('\\', '\\\\', $sub_value); } } else { $overlay->attributes[$name] = str_replace('\\', '\\\\', $value); } } // update the record $item['overlay'] = serialize($overlay->attributes); // touch the related anchor if ($article = Anchors::get('article:' . $item['id'])) { $article->touch('vote', $item['id'], isset($_REQUEST['silent']) && $_REQUEST['silent'] == 'Y'); } // update the database if (!Articles::put($item)) { } elseif ($next && !headers_sent()) { Safe::redirect($next); // ask for manual click } else { $context['text'] .= '<p>' . i18n::s('Thank you for your contribution') . "</p>\n"; // link to the poll, depending on access rights $menu = array(); if ($permitted) { $menu = array_merge($menu, array(Articles::get_permalink($item) => i18n::s('View poll results'))); } // back to the front page $menu = array_merge($menu, array($context['url_to_root'] => i18n::s('Front page'))); $context['text'] .= Skin::build_list($menu, 'menu_bar'); } } // render the skin render_skin();
/** * list sections as topics in a forum * * @param resource the SQL result * @return string the rendered text **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // output as a string $text = ''; // build a list of sections $family = ''; $first = TRUE; while ($item = SQL::fetch($result)) { // change the family if ($item['family'] != $family) { $family = $item['family']; // close last table only if a section has been already listed if (!$first) { $text .= Skin::table_suffix(); } // show the family $text .= '<h2><span>' . $family . ' </span></h2>' . "\n" . Skin::table_prefix('yabb') . Skin::table_row(array(i18n::s('Board'), 'center=' . i18n::s('Topics'), i18n::s('Last post')), 'header'); } elseif ($first) { $text .= Skin::table_prefix('yabb'); $text .= Skin::table_row(array(i18n::s('Board'), 'center=' . i18n::s('Topics'), i18n::s('Last post')), 'header'); } // done with this case $first = FALSE; // reset everything $prefix = $label = $suffix = $icon = ''; // signal restricted and private sections if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // indicate the id in the hovering popup $hover = i18n::s('View the section'); if (Surfer::is_member()) { $hover .= ' [section=' . $item['id'] . ']'; } // the url to view this item $url = Sections::get_permalink($item); // use the title as a link to the page $title =& Skin::build_link($url, Codes::beautify_title($item['title']), 'basic', $hover); // also use a clickable thumbnail, if any if ($item['thumbnail_url']) { $prefix = Skin::build_link($url, '<img src="' . $item['thumbnail_url'] . '" alt="" title="' . encode_field($hover) . '" class="left_image" />', 'basic', $hover) . $prefix; } // flag sections 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 . ' '; } // board introduction if ($item['introduction']) { $suffix .= '<br style="clear: none;" />' . Codes::beautify_introduction($item['introduction']); } // more details $details = ''; $more = array(); // board moderators if ($moderators = Sections::list_editors_by_name($item, 0, 7, 'comma5')) { $more[] = sprintf(i18n::ns('Moderator: %s', 'Moderators: %s', count($moderators)), $moderators); } // children boards if ($children =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, COMPACT_LIST_SIZE, 'comma')) { $more[] = sprintf(i18n::ns('Child board: %s', 'Child boards: %s', count($children)), Skin::build_list($children, 'comma')); } // as a compact list if (count($more)) { $details .= '<ul class="compact">'; foreach ($more as $list_item) { $details .= '<li>' . $list_item . '</li>' . "\n"; } $details .= '</ul>' . "\n"; } // all details if ($details) { $details = BR . '<span class="details">' . $details . "</span>\n"; } // count posts here, and in children sections $anchors = Sections::get_branch_at_anchor('section:' . $item['id']); if (!($count = Articles::count_for_anchor($anchors))) { $count = 0; } // get last post $last_post = '--'; $article =& Articles::get_newest_for_anchor($anchors, TRUE); if ($article['id']) { // flag articles updated recently if ($article['expiry_date'] > NULL_DATE && $article['expiry_date'] <= $context['now']) { $flag = EXPIRED_FLAG . ' '; } elseif ($article['create_date'] >= $context['fresh']) { $flag = NEW_FLAG . ' '; } elseif ($article['edit_date'] >= $context['fresh']) { $flag = UPDATED_FLAG . ' '; } else { $flag = ''; } // title $last_post = Skin::build_link(Articles::get_permalink($article), Codes::beautify_title($article['title']), 'article'); // last editor if ($article['edit_date']) { // find a name, if any if ($article['edit_name']) { // label the action if (isset($article['edit_action'])) { $action = Anchors::get_action_label($article['edit_action']); } else { $action = i18n::s('edited'); } // name of last editor $user = sprintf(i18n::s('%s by %s'), $action, Users::get_link($article['edit_name'], $article['edit_address'], $article['edit_id'])); } $last_post .= $flag . BR . '<span class="tiny">' . $user . ' ' . Skin::build_date($article['edit_date']) . '</span>'; } } // this is another row of the output $text .= Skin::table_row(array($prefix . $title . $suffix . $details, 'center=' . $count, $last_post)); } // end of processing SQL::free($result); $text .= Skin::table_suffix(); return $text; }
/** * layout one recent article * * @param array the article * @return an array ($prefix, $label, $suffix) **/ function layout_recent($item) { global $context; // permalink $url = Articles::get_permalink($item); // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // reset everything $prefix = $suffix = ''; // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // rating if ($item['rating_count']) { $suffix .= Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // the introductory text $introduction = ''; if (is_object($overlay)) { $introduction = $overlay->get_text('introduction', $item); } elseif ($item['introduction']) { $introduction = $item['introduction']; } if ($introduction) { $suffix .= ' - ' . Codes::beautify_introduction($introduction); } // other details $details = array(); // the author $author = ''; if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { $author = sprintf(i18n::s('by %s'), $item['create_name']) . ' '; } // date $details[] = $author . Skin::build_date($item['publish_date']); // info on related files if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d file', '%d files', $count), $count), 'basic'); } // info on related comments $link = Comments::get_url('article:' . $item['id'], 'list'); if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = Skin::build_link($link, sprintf(i18n::ns('%d comment', '%d comments', $count), $count), 'basic'); } // discuss if (Comments::allow_creation($item, $anchor)) { $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'comment'), i18n::s('Discuss'), 'basic'); } // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { $details[] = Skin::build_link($url . '#_attachments', sprintf(i18n::ns('%d link', '%d links', $count), $count), 'basic'); } // append a menu $suffix .= Skin::finalize_list($details, 'menu'); // display all tags if ($item['tags']) { $suffix .= ' <p class="tags" style="margin-top: 3px;">' . Skin::build_tags($item['tags'], 'article:' . $item['id']) . '</p>'; } // insert an array of links return array($prefix, $title, $suffix); }
// not found } elseif (!isset($item['id'])) { include '../error.php'; // publication is restricted } elseif (!$permitted) { // anonymous users are invited to log in if (!Surfer::is_logged()) { Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Articles::get_url($item['id'], 'unpublish'))); } // permission denied to authenticated user Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // update the database } elseif ($error = Articles::unpublish($item['id'])) { $context['text'] .= $error; } else { // clear the cache Articles::clear($item); // display the updated page Safe::redirect(Articles::get_permalink($item)); } // clear the tab we are in, if any if (is_object($anchor)) { $context['current_focus'] = $anchor->get_focus(); } // path to this page $context['path_bar'] = Surfer::get_path_bar($anchor); // page title $context['page_title'] = i18n::s('Draft'); // render the skin render_skin();