/** * 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 sections * * @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; } // process all items in the list while ($item = SQL::fetch($result)) { // get the related overlay $overlay = Overlay::load($item, 'section:' . $item['id']); // more text $text .= Sections::to_xml($item, $overlay); } // end of processing SQL::free($result); return $text; }
} elseif (isset($context['arguments'][0])) { $id = $context['arguments'][0]; } $id = strip_tags($id); // get the item from the database $item = Articles::get($id); // get the related anchor, if any $anchor = NULL; if (isset($item['anchor']) && $item['anchor']) { $anchor = Anchors::get($item['anchor']); } // get poll data include_once '../overlay.php'; $overlay = NULL; if (isset($item['overlay'])) { $overlay = Overlay::load($item, 'article:' . $item['id']); } // look for the vote $vote = ''; if (isset($_REQUEST['vote'])) { $vote = $_REQUEST['vote']; } if (isset($context['arguments'][1])) { $vote = $context['arguments'][1]; } $vote = strip_tags($vote); // next url $next = ''; if (isset($_REQUEST['next'])) { $next = $_REQUEST['next']; }
/** * 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 users * * @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 (!($count = SQL::count($result))) { return $text; } // allow for several lists in the same page static $serial; if (isset($serial)) { $serial++; } else { $serial = 1; } // don't blast too many people if ($count > 100) { $checked = ''; } elseif (isset($this->layout_variant) && $this->layout_variant == 'unchecked') { $checked = ''; } else { $checked = ' checked="checked"'; } // div prefix $text .= '<div id="users_as_mail_panel_' . $serial . '">'; // allow to select/deslect multiple rows at once $text .= '<input type="checkbox" class="row_selector" onclick="check_user_as_mail_panel_' . $serial . '(\'div#users_as_mail_panel_' . $serial . '\', this);"' . $checked . ' /> ' . i18n::s('Select all/none') . BR; // process all items in the list $count = 0; while ($item = SQL::fetch($result)) { // we need some address if (!$item['email']) { continue; } // do not write to myself if ($item['id'] == Surfer::get_id()) { continue; } // get the related overlay, if any $overlay = Overlay::load($item, 'user:'******'id']); // column to select the row $text .= '<input type="checkbox" name="selected_users[]" class="row_selector" value="' . encode_field($item['email']) . '"' . $checked . ' />'; // signal restricted and private users if ($item['active'] == 'N') { $text .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $text .= RESTRICTED_FLAG; } // the url to view this item $url = Users::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['full_name']); } // sanity check if (!$title) { $title = $item['nick_name']; } // link to this page $text .= Skin::build_link($url, $title, 'user'); // the introductory text if ($item['introduction']) { $text .= '<span class="tiny"> - ' . Codes::beautify_introduction($item['introduction']) . '</span>'; } // insert overlay data, if any if (is_object($overlay)) { $text .= $overlay->get_text('list', $item); } // display all tags if ($item['tags']) { $text .= ' <span class="tags">' . Skin::build_tags($item['tags'], 'user:'******'id']) . '</span>'; } // append the row $text .= BR; $count++; } // the script used to check all items at once Page::insert_script('function check_user_as_mail_panel_' . $serial . '(scope, handle) {' . "\n" . ' $(scope + " input[type=\'checkbox\'].row_selector").each(' . "\n" . ' function() { $(this).attr("checked", $(handle).is(":checked"));}' . "\n" . ' );' . "\n" . '}' . "\n"); // div suffix $text .= '</div>'; // no valid account has been found if (!$count) { $text = ''; } // end of processing SQL::free($result); 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 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; }
$id = $_REQUEST['id']; } elseif (isset($context['arguments'][0])) { $id = $context['arguments'][0]; } $id = strip_tags($id); // get the item from the database $item = Categories::get($id); // get the related anchor, if any $anchor = NULL; if (isset($item['anchor']) && $item['anchor']) { $anchor = Anchors::get($item['anchor']); } // get the related overlay, if any $overlay = NULL; if (isset($item['overlay'])) { $overlay = Overlay::load($item, 'category:' . $item['id']); } // associates and authenticated editors can do what they want if (Surfer::is_associate() || Surfer::is_member() && is_object($anchor) && $anchor->is_assigned()) { $permitted = TRUE; } else { $permitted = FALSE; } // load the skin load_skin('categories'); // the path to this page if (is_object($anchor) && $anchor->is_viewable()) { $context['path_bar'] = $anchor->get_path_bar(); } else { $context['path_bar'] = array('categories/' => i18n::s('Categories')); }
/** * delete one section * * @param int the id of the section to delete * @return boolean TRUE on success, FALSE otherwise * * @see sections/delete.php */ public static function delete($id) { global $context; // load the row $item = Sections::get($id); if (!$item['id']) { Logger::error(i18n::s('No item has the provided id.')); return FALSE; } // delete related items Anchors::delete_related_to('section:' . $item['id']); // delete the record in the database $query = "DELETE FROM " . SQL::table_name('sections') . " WHERE id = " . SQL::escape($item['id']); if (SQL::query($query) === FALSE) { return FALSE; } // remember overlay deletion if (isset($item['overlay']) && ($overlay = Overlay::load($item, 'section:' . $item['id']))) { $overlay->remember('delete', $item, 'section:' . $item['id']); } // job done return TRUE; }
/** * 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 sections * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // we return an array of ($url => $attributes) $items = array(); // process all items in the list while ($item = SQL::fetch($result)) { // get the related overlay, if any $overlay = Overlay::load($item, 'section:' . $item['id']); // the url to view this item $url = Sections::get_permalink($item); // initialize variables $prefix = $label = $suffix = ''; // flag sections that are draft or dead if ($item['activation_date'] >= $context['now']) { $prefix .= DRAFT_FLAG; } elseif ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $prefix .= EXPIRED_FLAG; } // signal restricted and private sections if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // flag items updated recently if ($item['create_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= UPDATED_FLAG; } // // start the label with family, if any // if($item['family']) // $label = ucfirst(Skin::strip($item['family'], 30)).' - '; // use the title to label the link if (is_object($overlay)) { $label = ucfirst(Codes::beautify_title($overlay->get_text('title', $item))); } else { $label .= ucfirst(Skin::strip($item['index_title'], 30)); } // 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 section'); } // help members to reference this page if (Surfer::is_member()) { $hover .= ' [section=' . $item['id'] . ']'; } // list all components for this item $items[$url] = array($prefix, $label, $suffix, 'basic', NULL, $hover); } // end of processing SQL::free($result); return $items; }
/** * get some introductory text from a section * * This function is used to introduce comments, or any sub-item related to an anchor. * Compared to the standard anchor implementation, this one adds the ability to handle overlay data. * * If there is some introductory text, it is used. Else the description text is used instead. * The number of words is capped in both cases. * * Also, the number of remaining words is provided. * * Following variants may be selected to adapt to various situations: * - 'basic' - strip every tag, we want almost plain ASCII - maybe this will be send in a mail message * - 'hover' - some text to be displayed while hovering a link * - 'quote' - transform YACS codes, then strip most HTML tags * - 'teaser' - limit the number of words, tranform YACS codes, and link to permalink * * @see shared/anchor.php * * @param string an optional variant * @return NULL, of some text */ function &get_teaser($variant = 'basic') { global $context; // nothing to do if (!isset($this->item['id'])) { $text = NULL; return $text; } // the text to be returned $text = ''; // use the introduction field, if any if ($this->item['introduction']) { $text = trim($this->item['introduction']); // may be rendered as an empty strings if ($variant != 'hover') { // remove toc and toq codes $text = preg_replace(FORBIDDEN_IN_TEASERS, '', $text); // render all codes if (is_callable(array('Codes', 'beautify'))) { $text =& Codes::beautify($text, $this->item['options']); } } // remove most html if ($variant != 'teaser') { $text = xml::strip_visible_tags($text); } // combine with description if ($variant == 'quote') { $text .= BR . BR; } } // use overlay data, if any if (!$text) { $overlay = Overlay::load($this->item, 'section:' . $this->item['id']); if (is_object($overlay)) { $text .= $overlay->get_text('list', $this->item); } } // use the description field, if any $in_description = FALSE; if (!$text && $variant != 'hover' || $variant == 'quote') { $text .= trim($this->item['description']); $in_description = TRUE; // remove toc and toq codes $text = preg_replace(FORBIDDEN_IN_TEASERS, '', $text); // render all codes if (is_callable(array('Codes', 'beautify'))) { $text =& Codes::beautify($text, $this->item['options']); } // remove most html $text = xml::strip_visible_tags($text); } // turn html entities to unicode entities $text =& utf8::transcode($text); // now we have to process the provided text switch ($variant) { // strip everything case 'basic': default: // remove most html $text = xml::strip_visible_tags($text); // limit the number of words $text =& Skin::cap($text, 70); // done return $text; // some text for pop-up panels // some text for pop-up panels case 'hover': // remove most html $text = xml::strip_visible_tags($text); // limit the number of words $text =& Skin::strip($text, 70); // ensure we have some text if (!$text) { $text = i18n::s('View the page'); } // mention shortcut to section if (Surfer::is_associate()) { $text .= ' [section=' . $this->item['id'] . ']'; } // done return $text; // quote this // quote this case 'quote': // remove most html $text = xml::strip_visible_tags($text); // limit the number of words $text =& Skin::cap($text, 300); // done return $text; // preserve as much as possible // preserve as much as possible case 'teaser': // limit the number of words $text =& Skin::cap($text, 12, $this->get_url()); // 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; }
// the title of the page $context['page_title'] = i18n::s('Change named overlays'); // this is reserved to associates if (!Surfer::is_associate()) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // update targeted overlays } elseif (isset($_REQUEST['id']) && $_REQUEST['id']) { // change all named overlays $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>';
/** * list articles * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // the script used to check all pages at once Page::insert_script('function cascade_selection_to_all_article_rows(handle) {' . "\n" . ' $("div#articles_panel input[type=\'checkbox\'].row_selector").each(' . "\n" . ' function() { $(this).attr("checked", $(handle).is(":checked"));}' . "\n" . ' );' . "\n" . '}' . "\n"); // table prefix $text .= Skin::table_prefix('yc-grid'); // table headers $main = '<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />'; $cells = array($main, i18n::s('Page'), i18n::s('Rank')); $text .= Skin::table_row($cells, 'header'); // process all items in the list include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; $count = 0; while ($item = SQL::fetch($result)) { $cells = array(); // get the related overlay, if any $overlay = Overlay::load($item, 'article:' . $item['id']); // get the main anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Articles::get_permalink($item); // column to select the row $cells[] = '<input type="checkbox" name="selected_articles[]" id="article_selector_' . $count . '" class="row_selector" value="' . $item['id'] . '" />'; // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // initialize variables $prefix = $suffix = $icon = ''; // flag sticky pages if ($item['rank'] < 10000) { $prefix .= STICKY_FLAG; } // signal locked articles if (isset($item['locked']) && $item['locked'] == 'Y') { $suffix .= ' ' . LOCKED_FLAG; } // flag articles that are dead, or created or updated very recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $prefix .= EXPIRED_FLAG; } elseif ($item['create_date'] >= $context['fresh']) { $suffix .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= ' ' . UPDATED_FLAG; } // signal articles to be published if ($item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) { $prefix .= DRAFT_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // the introductory text if (is_object($overlay)) { $introduction = $overlay->get_text('introduction', $item); } else { $introduction = $item['introduction']; } if ($introduction) { $suffix .= BR . Codes::beautify_introduction($introduction); } // insert overlay data, if any if (is_object($overlay)) { $suffix .= $overlay->get_text('list', $item); } // append details to the suffix $suffix .= BR . '<span class="details">'; // details $details = array(); // the author if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { if ($item['create_name'] != $item['edit_name']) { $details[] = sprintf(i18n::s('by %s, %s'), $item['create_name'], $item['edit_name']); } else { $details[] = sprintf(i18n::s('by %s'), $item['create_name']); } } // the last action $details[] = Anchors::get_action_label($item['edit_action']) . ' ' . Skin::build_date($item['edit_date']); // the number of hits if (Surfer::is_logged() && $item['hits'] > 1) { $details[] = Skin::build_number($item['hits'], i18n::s('hits')); } // info on related files $stats = Files::stat_for_anchor('article:' . $item['id']); if ($stats['count']) { $details[] = sprintf(i18n::ns('%d file', '%d files', $stats['count']), $stats['count']); } // info on related links $stats = Links::stat_for_anchor('article:' . $item['id']); if ($stats['count']) { $details[] = sprintf(i18n::ns('%d link', '%d links', $stats['count']), $stats['count']); } // info on related comments $stats = Comments::stat_for_anchor('article:' . $item['id']); if ($stats['count']) { $details[] = sprintf(i18n::ns('%d comment', '%d comments', $stats['count']), $stats['count']); } // rating if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) { $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // combine in-line details if (count($details)) { $suffix .= ucfirst(trim(implode(', ', $details))); } // list up to three categories by title, if any $anchors = array(); if ($members =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) { foreach ($members as $id => $attributes) { // add background color to distinguish this category against others if (isset($attributes['background_color']) && $attributes['background_color']) { $attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>'; } $anchors[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic'); } } if (count($anchors)) { $suffix .= BR . sprintf(i18n::s('In %s'), implode(' / ', $anchors)); } // end of details $suffix .= '</span>'; // strip empty details $suffix = str_replace(BR . '<span class="details"></span>', '', $suffix); $suffix = str_replace('<span class="details"></span>', '', $suffix); // the icon to put in the left column if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } // commands $commands = array(Skin::build_link(Articles::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic'), Skin::build_link(Articles::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic')); // link to this page $cells[] = $prefix . Skin::build_link($url, $title, 'article') . ' - ' . Skin::finalize_list($commands, 'menu') . $suffix; // ranking $cells[] = '<input type="text" size="5" name="article_rank_' . $item['id'] . '" value="' . $item['rank'] . '" onfocus="$(\'#article_selector_' . $count . '\').attr(\'checked\', \'checked\');" onchange="$(\'#act_on_articles\').prop(\'selectedIndex\', 9);" />'; // append the row $text .= Skin::table_row($cells, $count++); } // select all rows $cells = array('<input type="checkbox" class="row_selector" onclick="cascade_selection_to_all_article_rows(this);" />', i18n::s('Select all/none'), ''); $text .= Skin::table_row($cells, $count++); // table suffix $text .= Skin::table_suffix(); // end of processing SQL::free($result); return $text; }
/** * list articles * * @param resource the SQL result * @return array * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($url => $attributes) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // process all items in the list while ($item = SQL::fetch($result)) { // get the related overlay, if any $overlay = Overlay::load($item, 'category:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // provide an absolute link $url = Categories::get_permalink($item); // build a title if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // time of last update $time = SQL::strtotime($item['edit_date']); // the section $root = ''; if ($item['anchor'] && ($anchor = Anchors::get($item['anchor']))) { $root = ucfirst(trim(strip_tags(Codes::beautify_title($anchor->get_title())))); } // the icon to use $icon = ''; if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } elseif ($item['anchor'] && ($anchor = Anchors::get($item['anchor'])) && is_callable($anchor, 'get_bullet_url')) { $icon = $anchor->get_bullet_url(); } if ($icon) { $icon = $context['url_to_home'] . $context['url_to_root'] . $icon; } // the author(s) is an e-mail address, according to rss 2.0 spec $author = ''; if (isset($item['create_address'])) { $author .= $item['create_address']; } if (isset($item['create_name']) && trim($item['create_name'])) { $author .= ' (' . $item['create_name'] . ')'; } if (isset($item['edit_address']) && trim($item['edit_address']) && $item['create_address'] != $item['edit_address']) { if ($author) { $author .= ', '; } $author .= $item['edit_address']; if (isset($item['edit_name']) && trim($item['edit_name'])) { $author .= ' (' . $item['edit_name'] . ')'; } } // list all components for this item $items[$url] = array($time, $title, $author, $root, $icon, '', '', ''); } // end of processing SQL::free($result); return $items; }
/** * list articles as rows in a table * * @param resource the SQL result * @return string the rendered text **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // build a list of articles $rows = array(); include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // get the related overlay $overlay = Overlay::load($item, 'article:' . $item['id']); // get the anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Articles::get_permalink($item); // reset everything $title = $abstract = $author = ''; // signal articles to be published if (!isset($item['publish_date']) || $item['publish_date'] <= NULL_DATE || $item['publish_date'] > gmstrftime('%Y-%m-%d %H:%M:%S')) { $title .= DRAFT_FLAG; } // signal restricted and private articles if ($item['active'] == 'N') { $title .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $title .= RESTRICTED_FLAG; } // indicate the id in the hovering popup $hover = i18n::s('View the page'); if (Surfer::is_member()) { $hover .= ' [article=' . $item['id'] . ']'; } // use the title to label the link if (is_object($overlay)) { $label = Codes::beautify_title($overlay->get_text('title', $item)); } else { $label = Codes::beautify_title($item['title']); } // use the title as a link to the page $title .= Skin::build_link($url, $label, 'basic', $hover); // signal locked articles if (isset($item['locked']) && $item['locked'] == 'Y' && Articles::is_owned($item, $anchor)) { $title .= ' ' . LOCKED_FLAG; } // flag articles updated recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $title .= ' ' . EXPIRED_FLAG; } elseif ($item['create_date'] >= $context['fresh']) { $title .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $title .= ' ' . UPDATED_FLAG; } // the icon if ($item['thumbnail_url']) { $abstract .= '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $item['thumbnail_url'] . '" class="right_image" alt="" /></a>'; } // the introductory text if (is_object($overlay)) { $abstract .= Codes::beautify_introduction($overlay->get_text('introduction', $item)); } elseif ($item['introduction']) { $abstract .= Codes::beautify_introduction($item['introduction']); } // insert overlay data, if any if (is_object($overlay)) { $abstract .= $overlay->get_text('list', $item); } // make some abstract out of main text if (!$item['introduction'] && $context['skins_with_details'] == 'Y') { $abstract .= Skin::cap(Codes::beautify($item['description'], $item['options']), 50); } // attachment details $details = array(); // info on related files if ($count = Files::count_for_anchor('article:' . $item['id'], TRUE)) { Skin::define_img('FILES_LIST_IMG', 'files/list.gif'); $details[] = FILES_LIST_IMG . sprintf(i18n::ns('%d file', '%d files', $count), $count); } // info on related links if ($count = Links::count_for_anchor('article:' . $item['id'], TRUE)) { Skin::define_img('LINKS_LIST_IMG', 'links/list.gif'); $details[] = LINKS_LIST_IMG . sprintf(i18n::ns('%d link', '%d links', $count), $count); } // comments if ($count = Comments::count_for_anchor('article:' . $item['id'], TRUE)) { Skin::define_img('COMMENTS_LIST_IMG', 'comments/list.gif'); $details[] = Skin::build_link(Comments::get_url('article:' . $item['id'], 'list'), COMMENTS_LIST_IMG . sprintf(i18n::ns('%d comment', '%d comments', $count), $count)); } // describe attachments if (count($details)) { $abstract .= '<p style="margin: 3px 0;">' . join(', ', $details) . '</p>'; } // anchors $anchors = array(); if ($members =& Members::list_categories_by_title_for_member('article:' . $item['id'], 0, 7, 'raw')) { foreach ($members as $category_id => $attributes) { // add background color to distinguish this category against others if (isset($attributes['background_color']) && $attributes['background_color']) { $attributes['title'] = '<span style="background-color: ' . $attributes['background_color'] . '; padding: 0 3px 0 3px;">' . $attributes['title'] . '</span>'; } $anchors[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'basic'); } } if (@count($anchors)) { $abstract .= '<p class="tags" style="margin: 3px 0">' . implode(' ', $anchors) . '</p>'; } // poster name if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { if ($item['create_name']) { $author = Users::get_link($item['create_name'], $item['create_address'], $item['create_id']); } else { $author = Users::get_link($item['edit_name'], $item['edit_address'], $item['edit_id']); } } // more details $details =& Articles::build_dates($anchor, $item); // rating if ($item['rating_count'] && !(is_object($anchor) && $anchor->has_option('without_rating'))) { $details[] = Skin::build_link(Articles::get_url($item['id'], 'like'), Skin::build_rating_img((int) round($item['rating_sum'] / $item['rating_count'])), 'basic'); } // page details if (count($details)) { $details = '<p class="details">' . join(', ', $details) . '</p>'; } // this is another row of the output -- title, abstract, (author,) details if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { $cells = array($title, $abstract, $author, $details); } else { $cells = array($title, $abstract, $details); } // append this row $rows[] = $cells; } // end of processing SQL::free($result); // headers if (isset($context['with_author_information']) && $context['with_author_information'] == 'Y') { $headers = array(i18n::s('Topic'), i18n::s('Abstract'), i18n::s('Poster'), i18n::s('Details')); } else { $headers = array(i18n::s('Topic'), i18n::s('Abstract'), i18n::s('Details')); } // return a sortable table $text .= Skin::table($headers, $rows, 'grid'); return $text; }
/** * list articles * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // 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 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; }
$id = NULL; if (isset($_REQUEST['id'])) { $id = $_REQUEST['id']; } elseif (isset($context['arguments'][0]) && isset($context['arguments'][1])) { $id = $context['arguments'][0] . ':' . $context['arguments'][1]; } $id = strip_tags($id); // get the anchor $anchor = Anchors::get($id); // get the related overlay, if any $overlay = NULL; if (is_object($anchor)) { $fields = array(); $fields['id'] = $anchor->get_value('id'); $fields['overlay'] = $anchor->get_value('overlay'); $overlay = Overlay::load($fields, $anchor->get_reference()); } // load the skin, maybe with a variant load_skin('articles', $anchor); // stop crawlers if (Surfer::is_crawler()) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // not found } elseif (!is_object($anchor)) { include '../../error.php'; // permission denied } elseif (!$anchor->is_owned()) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // no overlay
/** * list sections * * @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; } // 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, 'section:' . $item['id']); // get the main anchor $anchor = Anchors::get($item['anchor']); // 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']); } // initialize variables $prefix = $suffix = $icon = ''; // flag sticky pages if ($item['rank'] < 10000) { $prefix .= STICKY_FLAG; } // signal restricted and private sections if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // flag sections 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; } // info on related comments if ($count = Comments::count_for_anchor('section:' . $item['id'], TRUE)) { $suffix .= ' (' . $count . ')'; } // details $details = array(); // info on related sections if ($count = Sections::count_for_anchor('section:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count); } // info on related articles if ($count = Articles::count_for_anchor('section:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count); } // info on related files if ($count = Files::count_for_anchor('section:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count); } // info on related links if ($count = Links::count_for_anchor('section:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count); } // 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 .= ' - <span class="details">' . trim(implode(', ', $details)) . '</span>'; } // list all components for this item $items[$url] = array($prefix, $title, $suffix, 'section', $icon); } // end of processing SQL::free($result); return $items; }
/** * 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; }
$id = $_REQUEST['id']; } elseif (isset($context['arguments'][0])) { $id = $context['arguments'][0]; } $id = strip_tags($id); // get the item from the database $item = Files::get($id); // get the related anchor, if any $anchor = NULL; if (isset($item['anchor']) && $item['anchor']) { $anchor = Anchors::get($item['anchor']); } // get the related overlay, if any $overlay = NULL; if (isset($item['overlay'])) { $overlay = Overlay::load($item, 'file:' . $item['id']); } // the surfer can proceed if (Files::allow_deletion($item, $anchor)) { Surfer::empower(); $permitted = TRUE; // the default is to deny access } else { $permitted = FALSE; } // load the skin, maybe with a variant load_skin('files', $anchor); // clear the tab we are in, if any if (is_object($anchor)) { $context['current_focus'] = $anchor->get_focus(); }
/** * 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; }
/** * remember the last action for this article * * This function is called by related items. What does it do? * - On image creation, the adequate code is added to the description field to let the image be displayed inline * - On icon selection, the icon field is updated * - On thumbnail image selection, the thumbnail image field is updated * - On location creation, some code is inserted in the description field to display location name inline * - On table creation, some code is inserted in the description field to display the table inline * * @see articles/article.php * @see articles/edit.php * @see shared/anchor.php * * @param string one of the pre-defined action code * @param string the id of the item related to this update * @param boolean TRUE to not change the edit date of this anchor, default is FALSE */ function touch($action, $origin = NULL, $silently = FALSE) { global $context; // we make extensive use of comments below include_once $context['path_to_root'] . 'comments/comments.php'; // don't go further on import if (preg_match('/import$/i', $action)) { return; } // no article bound if (!isset($this->item['id'])) { return; } // delegate to overlay if (is_object($this->overlay) && $this->overlay->touch($action, $origin, $silently) === false) { return; // stop on false } // clear floating objects if ($action == 'clear') { $this->item['description'] .= ' [clear]'; $query = "UPDATE " . SQL::table_name('articles') . " SET description='" . SQL::escape($this->item['description']) . "'" . " WHERE id = " . SQL::escape($this->item['id']); SQL::query($query); return; } // get the related overlay, if any if (!isset($this->overlay)) { $this->overlay = NULL; if (isset($this->item['overlay'])) { $this->overlay = Overlay::load($this->item, 'article:' . $this->item['id']); } } // components of the query $query = array(); // a new comment has been posted if ($action == 'comment:create') { // purge oldest comments Comments::purge_for_anchor('article:' . $this->item['id']); // file upload } elseif ($action == 'file:create' || $action == 'file:upload') { // actually, several files have been added $label = ''; if (!$origin) { // only when comments are allowed if (!Articles::has_option('no_comments', $this->anchor, $this->item)) { // remember this as an automatic notification $fields = array(); $fields['anchor'] = 'article:' . $this->item['id']; $fields['description'] = i18n::s('Several files have been added'); $fields['type'] = 'notification'; Comments::post($fields); } // one file has been added } elseif (!Codes::check_embedded($this->item['description'], 'embed', $origin) && ($item = Files::get($origin, TRUE))) { // this file is eligible for being embedded in the page if (isset($item['file_name']) && Files::is_embeddable($item['file_name'])) { // the overlay may prevent embedding if (is_object($this->overlay) && !$this->overlay->should_embed_files()) { } else { $label = '[embed=' . $origin . ']'; } // else add a comment to take note of the upload } else { // only when comments are allowed if (!Articles::has_option('no_comments', $this->anchor, $this->item)) { // remember this as an automatic notification $fields = array(); $fields['anchor'] = 'article:' . $this->item['id']; if ($action == 'file:create') { $fields['description'] = '[file=' . $item['id'] . ',' . $item['file_name'] . ']'; } else { $fields['description'] = '[download=' . $item['id'] . ',' . $item['file_name'] . ']'; } Comments::post($fields); } } } // we are in some interactive thread if ($origin && $this->has_option('view_as_chat')) { // default is to download the file if (!$label) { $label = '[download=' . $origin . ']'; } // this is the first contribution to the thread if (!($comment = Comments::get_newest_for_anchor('article:' . $this->item['id']))) { $fields = array(); $fields['anchor'] = 'article:' . $this->item['id']; $fields['description'] = $label; // this is a continuated contribution from this authenticated surfer } elseif ($comment['type'] != 'notification' && Surfer::get_id() && (isset($comment['create_id']) && Surfer::get_id() == $comment['create_id'])) { $comment['description'] .= BR . $label; $fields = $comment; // else process the contribution as a new comment } else { $fields = array(); $fields['anchor'] = 'article:' . $this->item['id']; $fields['description'] = $label; } // only when comments are allowed if (!Articles::has_option('no_comments', $this->anchor, $this->item)) { Comments::post($fields); } // include flash videos in a regular page } elseif ($origin && $label) { $query[] = "description = '" . SQL::escape($this->item['description'] . ' ' . $label) . "'"; } // suppress references to a deleted file } elseif ($action == 'file:delete' && $origin) { // suppress reference in main description field $text = Codes::delete_embedded($this->item['description'], 'download', $origin); $text = Codes::delete_embedded($text, 'embed', $origin); $text = Codes::delete_embedded($text, 'file', $origin); // save changes $query[] = "description = '" . SQL::escape($text) . "'"; // append a reference to a new image to the description } elseif ($action == 'image:create' && $origin) { if (!Codes::check_embedded($this->item['description'], 'image', $origin)) { // the overlay may prevent embedding if (is_object($this->overlay) && !$this->overlay->should_embed_files()) { } else { // list has already started if (preg_match('/\\[image=[^\\]]+?\\]\\s*$/', $this->item['description'])) { $this->item['description'] .= ' [image=' . $origin . ']'; } else { $this->item['description'] .= "\n\n" . '[image=' . $origin . ']'; } $query[] = "description = '" . SQL::escape($this->item['description']) . "'"; } } // also use it as thumnail if none has been defined yet if (!isset($this->item['thumbnail_url']) || !trim($this->item['thumbnail_url'])) { include_once $context['path_to_root'] . 'images/images.php'; if (($image = Images::get($origin)) && ($url = Images::get_thumbnail_href($image))) { $query[] = "thumbnail_url = '" . SQL::escape($url) . "'"; } } // refresh stamp only if image update occurs within 6 hours after last edition if (SQL::strtotime($this->item['edit_date']) + 6 * 60 * 60 < time()) { $silently = TRUE; } // suppress a reference to an image that has been deleted } elseif ($action == 'image:delete' && $origin) { // suppress reference in main description field $query[] = "description = '" . SQL::escape(Codes::delete_embedded($this->item['description'], 'image', $origin)) . "'"; // suppress references as icon and thumbnail as well include_once $context['path_to_root'] . 'images/images.php'; if ($image = Images::get($origin)) { if ($url = Images::get_icon_href($image)) { if ($this->item['icon_url'] == $url) { $query[] = "icon_url = ''"; } if ($this->item['thumbnail_url'] == $url) { $query[] = "thumbnail_url = ''"; } } if ($url = Images::get_thumbnail_href($image)) { if ($this->item['icon_url'] == $url) { $query[] = "icon_url = ''"; } if ($this->item['thumbnail_url'] == $url) { $query[] = "thumbnail_url = ''"; } } } // set an existing image as the article icon } elseif ($action == 'image:set_as_icon' && $origin) { include_once $context['path_to_root'] . 'images/images.php'; if ($image = Images::get($origin)) { if ($url = Images::get_icon_href($image)) { $query[] = "icon_url = '" . SQL::escape($url) . "'"; } // also use it as thumnail if none has been defined yet if (!(isset($this->item['thumbnail_url']) && trim($this->item['thumbnail_url'])) && ($url = Images::get_thumbnail_href($image))) { $query[] = "thumbnail_url = '" . SQL::escape($url) . "'"; } } // set an existing image as the article thumbnail } elseif ($action == 'image:set_as_thumbnail' && $origin) { include_once $context['path_to_root'] . 'images/images.php'; if ($image = Images::get($origin)) { // use the thumbnail for large files, or the image itself for smaller files if ($image['image_size'] > $context['thumbnail_threshold']) { $url = Images::get_thumbnail_href($image); } else { $url = Images::get_icon_href($image); } $query[] = "thumbnail_url = '" . SQL::escape($url) . "'"; } elseif ($origin) { $query[] = "thumbnail_url = '" . SQL::escape($origin) . "'"; } // do not remember minor changes $silently = TRUE; // append a new image, and set it as the article thumbnail } elseif ($action == 'image:set_as_both' && $origin) { if (!Codes::check_embedded($this->item['description'], 'image', $origin)) { $query[] = "description = '" . SQL::escape($this->item['description'] . ' [image=' . $origin . ']') . "'"; } include_once $context['path_to_root'] . 'images/images.php'; if ($image = Images::get($origin)) { // use the thumbnail for large files, or the image itself for smaller files if ($image['image_size'] > $context['thumbnail_threshold']) { $url = Images::get_thumbnail_href($image); } else { $url = Images::get_icon_href($image); } $query[] = "thumbnail_url = '" . SQL::escape($url) . "'"; } elseif ($origin) { $query[] = "thumbnail_url = '" . SQL::escape($origin) . "'"; } // do not remember minor changes $silently = TRUE; // add a reference to a location in the article description } elseif ($action == 'location:create' && $origin) { if (!Codes::check_embedded($this->item['description'], 'location', $origin)) { $query[] = "description = '" . SQL::escape($this->item['description'] . ' [location=' . $origin . ']') . "'"; } // suppress a reference to a location that has been deleted } elseif ($action == 'location:delete' && $origin) { $query[] = "description = '" . SQL::escape(Codes::delete_embedded($this->item['description'], 'location', $origin)) . "'"; // add a reference to a new table in the article description } elseif ($action == 'table:create' && $origin) { if (!Codes::check_embedded($this->item['description'], 'table', $origin)) { $query[] = "description = '" . SQL::escape($this->item['description'] . "\n" . '[table=' . $origin . ']' . "\n") . "'"; } // suppress a reference to a table that has been deleted } elseif ($action == 'table:delete' && $origin) { $query[] = "description = '" . SQL::escape(Codes::delete_embedded($this->item['description'], 'table', $origin)) . "'"; } // stamp the update if (!$silently) { $query[] = "edit_name='" . SQL::escape(Surfer::get_name()) . "'," . "edit_id=" . SQL::escape(Surfer::get_id()) . "," . "edit_address='" . SQL::escape(Surfer::get_email_address()) . "'," . "edit_action='" . SQL::escape($action) . "'," . "edit_date='" . gmstrftime('%Y-%m-%d %H:%M:%S') . "'"; } // update the database if (count($query)) { $query = "UPDATE " . SQL::table_name('articles') . " SET " . implode(', ', $query) . " WHERE id = " . SQL::escape($this->item['id']); SQL::query($query); } // add this page to the watch list of the contributor, on any action if (Surfer::get_id()) { Members::assign('article:' . $this->item['id'], 'user:'******'article:' . $this->item['id'], $this->item['active']); // always clear the cache, even on no update Articles::clear($this->item); // get the parent if (!$this->anchor) { $this->anchor = Anchors::get($this->item['anchor']); } // propagate the touch upwards if (is_object($this->anchor)) { $this->anchor->touch('article:update', $this->item['id'], TRUE); } }
$context['text'] .= $anchor->get_prefix(); } // the current list of linked sections $sections =& Members::list_sections_by_title_for_anchor($anchor->get_reference(), 0, SECTIONS_LIST_SIZE, 'raw'); // the form to link additional sections if (!is_array($sections) || count($sections) < SECTIONS_LIST_SIZE) { $context['text'] .= '<form method="post" action="' . $context['script_url'] . '"><p>' . i18n::s('To assign a section, look in the content tree below and assign one section at a time') . BR . '<select name="member">' . Sections::get_options(NULL, $sections) . '</select>' . ' ' . Skin::build_submit_button(' >> ') . '<input type="hidden" name="anchor" value="' . encode_field($anchor->get_reference()) . '">' . '<input type="hidden" name="action" value="set">' . '</p></form>' . "\n"; } // splash $context['text'] .= '<p style="margin-top: 2em;">' . sprintf(i18n::s('This is the list of sections assigned to %s'), $anchor->get_title()) . '</p>'; // layout assigned sections if ($sections) { // browse the list foreach ($sections as $id => $section) { // get the related overlay, if any $overlay = Overlay::load($section, 'section:' . $id); // get parent anchor $parent = Anchors::get($section['anchor']); // the url to view this item $url = Sections::get_permalink($section); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $section)); } else { $title = Codes::beautify_title($section['title']); } // initialize variables $prefix = $suffix = $icon = ''; // flag sticky pages if ($section['rank'] < 10000) { $prefix .= STICKY_FLAG;
$id = $_REQUEST['id']; } elseif (isset($context['arguments'][0])) { $id = $context['arguments'][0]; } $id = strip_tags($id); // get the item from the database $item = Sections::get($id); // get the related anchor, if any $anchor = NULL; if (isset($item['anchor'])) { $anchor = Anchors::get($item['anchor']); } // get the related overlay, if any $overlay = NULL; if (isset($item['overlay'])) { $overlay = Overlay::load($item, 'section:' . $item['id']); } // owners can do what they want if (Sections::is_owned($item, $anchor, TRUE)) { Surfer::empower(); } // associates and editors can do what they want if (Sections::is_owned($item, $anchor, TRUE)) { $permitted = TRUE; } elseif (isset($item['active']) && $item['active'] == 'Y') { $permitted = TRUE; } else { $permitted = FALSE; } // load the skin, maybe with a variant load_skin('articles', $anchor, isset($item['options']) ? $item['options'] : '');
/** * 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); }
/** * load the related item * * This function is useful to create an object from an array of values * * @param array attributes to set this instance * @param array attributes of the anchor, if any */ function load_by_content($item, $anchor = NULL) { global $context; // save attributes of this instance $this->item = $item; // save attributes of the anchor if ($anchor) { $this->anchor = $anchor; } // get the related overlay, if any $this->overlay = NULL; if (isset($this->item['overlay'])) { $this->overlay = Overlay::load($this); } }