/** * 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 some text $text = ''; // process all items in the list while ($item = SQL::fetch($result)) { // we want to make it visual if (!$item['thumbnail_url']) { continue; } // a title for the image --do not force a title if (isset($item['title'])) { $title = $item['title']; } else { $title = ''; } // the url to view this item $url = Sections::get_permalink($item); // use the skin to shape it $text .= Skin::build_image('thumbnail', $item['thumbnail_url'], $title, $url); } // end of processing SQL::free($result); return $text; }
/** * list sections * * @param resource the SQL result * @return an array of $url => (NULL, $title, NULL, 'section_123', NULL, 'visit this section') * * @see layouts/layout.php **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // no hovering label $href_title = ''; // we return an array of ($url => $attributes) $items = array(); // process all items in the list while ($item = SQL::fetch($result)) { // the url to view this item $url = Sections::get_permalink($item); // initialize variables $prefix = $suffix = ''; // list all components for this item $items[$url] = array($prefix, ucfirst(Skin::strip($item['index_title'], 30)), $suffix, 'section_' . $item['id'], NULL, $href_title); } // end of processing SQL::free($result); return $items; }
/** * list sections 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 sections while ($item = SQL::fetch($result)) { // get the related overlay, if any $overlay = Overlay::load($item, 'section:' . $item['id']); // get the 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']); } // reset everything $prefix = $label = $suffix = $icon = $details = ''; // signal restricted and private sections if (isset($item['active']) && $item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif (isset($item['active']) && $item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // flag sections updated recently if ($item['create_date'] >= $context['fresh']) { $suffix .= ' ' . NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= ' ' . UPDATED_FLAG; } // make a link $label = $prefix . Skin::build_link($url, $title, 'basic') . $suffix; // the associated letter $letter = strtoupper(ltrim($title[0])); if ($letter < 'A' || $letter > 'Z') { $letter = '#'; } // a new entry for this letter if (!isset($letters[$letter])) { $letters[$letter] = array(); } $letters[$letter][] = $label; } // mention all letters at the top $bar = array(); // all potential letters, in expected order $all = '#ABCDEFGHIJKLMNOPQRSTUVWXYZ'; for ($index = 0; $index < strlen($all); $index++) { $letter = $all[$index]; // some content for this letter if (isset($letters[$letter])) { // internal link to the right place $bar[] = Skin::build_link('#letter' . $letter, $letter, 'span'); // actual content for this letter $content = '<ul class="index"><li>' . join('</li><li>', $letters[$letter]) . '</li></ul>'; // content displayed in the page $text .= Skin::build_header_box($letter, $content, 'letter' . $letter); // no content for this letter } else { $bar[] = $letter; } } // insert local links at the top $text = Skin::finalize_list($bar, 'menu_bar') . $text; // end of processing SQL::free($result); return $text; }
// 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; } // signal restricted and private sections if ($section['active'] == 'N') { $prefix .= PRIVATE_FLAG;
/** * 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; }
// // page tools // if (Surfer::is_associate()) { $context['page_tools'][] = Skin::build_link('configure.php', i18n::s('Configure')); if (isset($cover_page['id'])) { $context['page_tools'][] = Skin::build_link(Articles::get_permalink($cover_page), i18n::s('Cover page'), 'basic'); } if (($section = Sections::get('gadget_boxes')) && isset($section['id'])) { $context['page_tools'][] = Skin::build_link(Sections::get_permalink($section), i18n::s('Gadget boxes'), 'basic'); } if (($section = Sections::get('extra_boxes')) && isset($section['id'])) { $context['page_tools'][] = Skin::build_link(Sections::get_permalink($section), i18n::s('Extra boxes'), 'basic'); } if (($section = Sections::get('navigation_boxes')) && isset($section['id'])) { $context['page_tools'][] = Skin::build_link(Sections::get_permalink($section), i18n::s('Navigation boxes'), 'basic'); } } // save some database requests $cache_id = 'index.php#extra_news'; if (!($text = Cache::get($cache_id))) { // show featured articles -- set in configure.php if (isset($context['root_featured_layout']) && $context['root_featured_layout'] != 'none') { // set in configure.php if (!isset($context['root_featured_count']) || $context['root_featured_count'] < 1) { $context['root_featured_count'] = 7; } // the category used to assign featured pages $anchor = Categories::get(i18n::c('featured')); if ($anchor['id'] && ($items =& Members::list_articles_by_date_for_anchor('category:' . $anchor['id'], 0, $context['root_featured_count'] + 1, 'news'))) { // link to the category page from the box title
Sections::post($fields); } } // increment the post counter of the surfer Users::increment_posts(Surfer::get_id()); // reward the poster $context['page_title'] = i18n::s('Congratulation, you have successfully added a new web space'); // follow-up commands $follow_up = i18n::s('What do you want to do now?'); $menu = array(); if ($_REQUEST['space_type'] == 'blog') { $menu = array_merge($menu, array(Sections::get_permalink($_REQUEST) => i18n::s('View the new blog'))); } elseif ($_REQUEST['space_type'] == 'project') { $menu = array_merge($menu, array(Sections::get_permalink($_REQUEST) => i18n::s('View the new project'))); } else { $menu = array_merge($menu, array(Sections::get_permalink($_REQUEST) => i18n::s('View the new group'))); } if (Surfer::may_upload()) { $menu = array_merge($menu, array('images/edit.php?anchor=' . urlencode('section:' . $_REQUEST['id']) => i18n::s('Add an image'))); } if (preg_match('/\\bwith_files\\b/i', $section->item['options']) && Surfer::may_upload()) { $menu = array_merge($menu, array('files/edit.php?anchor=' . urlencode('section:' . $_REQUEST['id']) => i18n::s('Add a file'))); } if (preg_match('/\\bwith_links\\b/i', $section->item['options'])) { $menu = array_merge($menu, array('links/edit.php?anchor=' . urlencode('section:' . $_REQUEST['id']) => i18n::s('Add a link'))); } $follow_up .= Skin::build_list($menu, 'menu_bar'); $context['text'] .= $follow_up; } // display the form on GET } else {
// feed-back on contributor scope switch ($_REQUEST['contribution']) { case 'Y': $context['text'] .= '<p>' . i18n::s('Any surfer is allowed to contribute anonymously to this wiki. Internet robots are prevented to submit new posts, however you should continuously review content to avoid unappropriate material.') . '</p>'; break; case 'R': $context['text'] .= '<p>' . i18n::s('Any authenticated member of the community is allowed to contribute to this wiki. You should control community membership to avoid unappropriate material.') . '</p>'; break; case 'N': $context['text'] .= '<p>' . i18n::s('You have selected to implement a private wiki. Assign individual members as editors of this wiki to enable contributions beyond associates.') . '</p>'; break; } // follow-up commands $follow_up = i18n::s('What do you want to do now?'); $menu = array(); $menu = array_merge($menu, array(Sections::get_permalink($fields) => i18n::s('Access the new wiki'))); if (Surfer::may_upload()) { $menu = array_merge($menu, array('images/edit.php?anchor=' . urlencode('section:' . $fields['id']) => i18n::s('Add an image'))); } $menu = array_merge($menu, array('help/populate.php' => i18n::s('Launch the Content Assistant again'))); $menu = array_merge($menu, array('control/' => i18n::s('Control Panel'))); $follow_up .= Skin::build_list($menu, 'menu_bar'); $context['text'] .= Skin::build_block($follow_up, 'bottom'); // new content has been created Logger::remember('help/populate.php: content assistant has created new content'); } } // make the user select an option } else { // the splash message $context['text'] .= '<p>' . i18n::s('This script will help to structure content for your server. Please select below the action you would like to perform.Depending on your choice, the assistant may ask for additional parameters on successive panels.') . '</p>';
load_skin('sitemap'); // get the list from the cache, if possible $cache_id = Cache::hash('sitemap') . '.xml'; // save for 5 minutes if (!file_exists($context['path_to_root'] . $cache_id) || filemtime($context['path_to_root'] . $cache_id) + 300 < time() || !($text = Safe::file_get_contents($context['path_to_root'] . $cache_id))) { $text = ''; // the preamble $text = '<?xml version="1.0" encoding="' . $context['charset'] . '"?>' . "\n" . '<urlset xmlns="http://www.google.com/schemas/sitemap/0.84">' . "\n"; // the front page $text .= ' <url>' . "\n" . ' <loc>' . $context['url_to_home'] . $context['url_to_root'] . '</loc>' . "\n" . ' <changefreq>weekly</changefreq>' . "\n" . ' <priority>1.0</priority>' . "\n" . ' </url>' . "\n\n"; // the site map $text .= ' <url>' . "\n" . ' <loc>' . $context['url_to_home'] . $context['url_to_root'] . 'sections/</loc>' . "\n" . ' <changefreq>weekly</changefreq>' . "\n" . ' <priority>1.0</priority>' . "\n" . ' </url>' . "\n\n"; // main sections if ($items = Sections::list_by_title_for_anchor(NULL, 0, 25, 'raw')) { foreach ($items as $id => $item) { $text .= ' <url>' . "\n" . ' <loc>' . encode_link(Sections::get_permalink($item)) . '</loc>' . "\n" . ' <changefreq>weekly</changefreq>' . "\n" . ' </url>' . "\n\n"; } } // the categories tree $text .= ' <url>' . "\n" . ' <loc>' . $context['url_to_home'] . $context['url_to_root'] . 'categories/</loc>' . "\n" . ' <changefreq>weekly</changefreq>' . "\n" . ' <priority>0.7</priority>' . "\n" . ' </url>' . "\n\n"; // main categories if ($items = Categories::list_by_date(0, 25, 'raw')) { foreach ($items as $id => $item) { $text .= ' <url>' . "\n" . ' <loc>' . encode_link(Categories::get_permalink($item)) . '</loc>' . "\n" . ' <changefreq>weekly</changefreq>' . "\n" . ' </url>' . "\n\n"; } } // members $text .= ' <url>' . "\n" . ' <loc>' . $context['url_to_home'] . $context['url_to_root'] . 'users/</loc>' . "\n" . ' <changefreq>weekly</changefreq>' . "\n" . ' <priority>0.7</priority>' . "\n" . ' </url>' . "\n\n"; // the OPML feed $text .= ' <url>' . "\n" . ' <loc>' . $context['url_to_home'] . $context['url_to_root'] . 'feeds/describe.php</loc>' . "\n" . ' <changefreq>weekly</changefreq>' . "\n" . ' </url>' . "\n\n"; // the postamble
// do the job } elseif (!count($context['error'])) { // look for the user through his nick name if (isset($_REQUEST['assigned_name']) && ($user = Users::get($_REQUEST['assigned_name']))) { $_REQUEST['anchor'] = 'user:'******'id']; } // transfer ownership if (isset($_REQUEST['action']) && $_REQUEST['action'] == 'set' && isset($_REQUEST['anchor'])) { // assign a user, and also update his watch list $attributes = array('id' => $item['id'], 'owner_id' => $user['id']); Sections::put_attributes($attributes); Members::assign($_REQUEST['anchor'], 'section:' . $item['id']); Members::assign('section:' . $item['id'], $_REQUEST['anchor']); $context['text'] .= '<p>' . sprintf(i18n::s('Current owner is %s'), Users::get_link($user['full_name'], $user['email'], $user['id'])) . '</p>'; // name current owner } elseif (isset($item['owner_id']) && ($owner = Users::get($item['owner_id']))) { $context['text'] .= '<p>' . sprintf(i18n::s('Current owner is %s'), Users::get_link($owner['full_name'], $owner['email'], $owner['id'])) . '</p>'; } // delegate to another person $context['text'] .= '<p style="margin-top: 2em;">' . i18n::s('To transfer ownership to another person, type some letters of the name you are looking for.') . '</p>'; // the form to link additional users $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" id="main_form"><p>' . '<input type="text" name="assigned_name" id="assigned_name" size="45" maxlength="255" />' . '<input type="hidden" name="id" value="' . encode_field($item['id']) . '" />' . '<input type="hidden" name="action" value="set" />' . ' <input type="submit" id="submit_button" value="' . i18n::s('Submit') . '" style="display: none;" />' . '</p></form>' . "\n"; // enable autocompletion Page::insert_script('$(function() {' . "\n" . ' $("#name").focus();' . "\n" . ' Yacs.autocomplete_names("assigned_name",true, "", function(data) { $("#submit_button").show().click(); });' . "\n" . '});' . "\n"); // back to the anchor page $links = array(); $links[] = Skin::build_link(Sections::get_permalink($item) . '#_users', i18n::s('Done'), 'button'); $context['text'] .= Skin::finalize_list($links, 'assistant_bar'); } // render the skin render_skin();
/** * 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 some text $text = ''; // maximum number of items if (isset($this->layout_variant) && $this->layout_variant > 3) { $maximum_items = $this->layout_variant; } elseif (defined('YAHOO_LIST_SIZE')) { $maximum_items = YAHOO_LIST_SIZE; } else { $maximum_items = 7; } // stack of items $items = array(); // process all items in the list include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; $family = ''; while ($item = SQL::fetch($result)) { // change the family if ($item['family'] != $family) { // flush current stack, if any if (count($items)) { $text .= Skin::build_list($items, '2-columns'); } $items = array(); // show the family $family = $item['family']; $text .= '<h2><span>' . $family . ' </span></h2>' . "\n"; } // the url to view this item $url = Sections::get_permalink($item); // initialize variables $prefix = $label = $suffix = $icon = ''; // signal restricted and private sections if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // flag sections that are draft, dead, or created or updated very recently if ($item['activation_date'] >= $context['now']) { $prefix .= DRAFT_FLAG; } elseif ($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; } // details and content $details = array(); $content = array(); // count related sub-elements $related_count = 0; // info on related articles if ($count = Articles::count_for_anchor('section:' . $item['id'])) { if ($count > $maximum_items) { $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count); } elseif (Surfer::is_empowered()) { $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count); } $related_count += $count; // get the overlay for content of this section, if any $content_overlay = NULL; if (isset($item['content_overlay'])) { $content_overlay = Overlay::bind($item['content_overlay']); } // no room to list articles if (count($content) >= $maximum_items) { } elseif (is_object($content_overlay) && is_callable(array($content_overlay, 'render_list_for_anchor'))) { if ($related = $content_overlay->render_list_for_anchor('section:' . $item['id'], $maximum_items - count($content))) { foreach ($related as $sub_url => $label) { $sub_prefix = $sub_suffix = $sub_hover = ''; if (is_array($label)) { $sub_prefix = $label[0]; $sub_suffix = $label[2]; if (@$label[5]) { $sub_hover = $label[5]; } $label = $label[1]; } $content[] = $sub_prefix . Skin::build_link($sub_url, $label, 'basic', $sub_hover) . $sub_suffix; } } // regular rendering of related articles } else { if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) { $order = $matches[1]; } else { $order = 'edition'; } if ($related =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, $maximum_items - count($content), 'compact')) { foreach ($related as $sub_url => $label) { $sub_prefix = $sub_suffix = $sub_hover = ''; if (is_array($label)) { $sub_prefix = $label[0]; $sub_suffix = $label[2]; if (@$label[5]) { $sub_hover = $label[5]; } $label = $label[1]; } $content[] = $sub_prefix . Skin::build_link($sub_url, $label, 'article', $sub_hover) . $sub_suffix; } } } } // info on related files if ($count = Files::count_for_anchor('section:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count); $related_count += $count; // add related files if necessary if (count($content) < $maximum_items && ($related = Files::list_by_date_for_anchor('section:' . $item['id'], 0, $maximum_items - count($content), 'compact'))) { foreach ($related as $sub_url => $label) { $sub_prefix = $sub_suffix = $sub_hover = ''; if (is_array($label)) { $sub_prefix = $label[0]; $sub_suffix = $label[2]; if (@$label[5]) { $sub_hover = $label[5]; } $label = $label[1]; } $content[] = $sub_prefix . Skin::build_link($sub_url, $label, 'file', $sub_hover) . $sub_suffix; } } } // info on related links if ($count = Links::count_for_anchor('section:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count); $related_count += $count; // add related links if necessary if (count($content) < $maximum_items && ($related = Links::list_by_date_for_anchor('section:' . $item['id'], 0, $maximum_items - count($content), 'compact'))) { foreach ($related as $sub_url => $label) { $sub_prefix = $sub_suffix = $sub_hover = ''; if (is_array($label)) { $sub_prefix = $label[0]; $sub_suffix = $label[2]; if (@$label[5]) { $sub_hover = $label[5]; } $label = $label[1]; } $content[] = $sub_prefix . Skin::build_link($sub_url, $label, 'link', $sub_hover) . $sub_suffix; } } } // info on related comments if ($count = Comments::count_for_anchor('section:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count); $related_count += $count; } // info on related sections if ($count = Sections::count_for_anchor('section:' . $item['id'])) { if ($count > $maximum_items) { $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count); } elseif (Surfer::is_empowered()) { $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count); } $related_count += $count; // add sub-sections if ($related =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, $maximum_items, 'compact')) { foreach ($related as $sub_url => $label) { $sub_prefix = $sub_suffix = $sub_hover = ''; if (is_array($label)) { $sub_prefix = $label[0]; $sub_suffix = $label[2]; if (@$label[5]) { $sub_hover = $label[5]; } $label = $label[1]; } $content[] = $sub_prefix . Skin::build_link($sub_url, $label, 'section', $sub_hover) . $sub_suffix; } } } // introduction if ($item['introduction']) { $suffix .= ' ' . Codes::beautify_introduction($item['introduction']); } // append details to the suffix if (count($details)) { $suffix .= ' <span class="details">(' . implode(', ', $details) . ')</span>'; } // give me more if (count($content) && $related_count > $maximum_items) { $content[] = Skin::build_link(Sections::get_permalink($item), i18n::s('More') . MORE_IMG, 'more', i18n::s('View the section')); } // layout details if (count($content)) { foreach ($content as $line) { $suffix .= '<div>' . YAHOO_ITEM_PREFIX . $line . YAHOO_ITEM_SUFFIX . '</div>'; } } // use the title to label the link $label = Skin::strip($item['title'], 50); // put the actual icon in the left column if (isset($item['thumbnail_url'])) { $icon = $item['thumbnail_url']; } // some hovering title for this section $hover = i18n::s('View the section'); // list all components for this item --use basic link style to avoid prefix or suffix images, if any $items[$url] = array($prefix, $label, $suffix, 'basic', $icon, $hover); } // flush the stack if (count($items)) { $text .= Skin::build_list($items, '2-columns'); } // end of processing SQL::free($result); return $text; }
/** * list articles as slashdot do * * @param resource the SQL result * @return string the rendered text * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // layout in a table $text = Skin::table_prefix('wide'); // 'even' is used for title rows, 'odd' for detail rows $class_title = 'odd'; $class_detail = 'even'; // build a list of sections $family = ''; include_once $context['path_to_root'] . 'articles/article.php'; include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // change the family if ($item['family'] != $family) { $family = $item['family']; // show the family $text .= Skin::table_suffix() . '<h2><span>' . $family . ' </span></h2>' . "\n" . Skin::table_prefix('wide'); } // document this section $content = $prefix = $title = $suffix = $icon = ''; $menu = array(); // permalink $url = Sections::get_permalink($item); // get the anchor $anchor = Anchors::get($item['anchor']); // get the related overlay, if any $overlay = Overlay::load($item, 'section:' . $item['id']); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // signal restricted and private sections if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // this is another row of the output $text .= '<tr class="' . $class_title . '"><th>' . $prefix . Skin::build_link($url, $title, 'basic', i18n::s('View the section')) . $suffix . '</th></tr>' . "\n"; // document most recent page here $content = $prefix = $title = $suffix = $icon = ''; $menu = array(); // branches of this tree $anchors = Sections::get_branch_at_anchor('section:' . $item['id']); // get last post $article =& Articles::get_newest_for_anchor($anchors, TRUE); if ($article['id']) { // permalink $url = Articles::get_permalink($article); // get the anchor $anchor = Anchors::get($article['anchor']); // get the related overlay, if any $overlay = Overlay::load($item, 'section:' . $item['id']); // use the title to label the link if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $article)); } else { $title = Codes::beautify_title($article['title']); } // signal restricted and private articles if ($article['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($article['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // the icon to put aside if ($article['thumbnail_url']) { $icon = $article['thumbnail_url']; } // the icon to put aside if (!$icon && is_callable(array($anchor, 'get_bullet_url'))) { $icon = $anchor->get_bullet_url(); } if ($icon) { $icon = '<a href="' . $context['url_to_root'] . $url . '"><img src="' . $icon . '" class="right_image" alt="" title="' . encode_field(i18n::s('View the page')) . '" /></a>'; } // the introductory text if ($article['introduction']) { $content .= Codes::beautify_introduction($article['introduction']); } elseif (!is_object($overlay)) { $handle = new Article(); $handle->load_by_content($article); $content .= $handle->get_teaser('teaser'); } // insert overlay data, if any if (is_object($overlay)) { $content .= $overlay->get_text('list', $article); } // link to description, if any if (trim($article['description'])) { $menu[] = Skin::build_link($url, i18n::s('Read more') . MORE_IMG, 'span', i18n::s('View the page')); } // info on related files if ($count = Files::count_for_anchor('article:' . $article['id'])) { $menu[] = sprintf(i18n::ns('%d file', '%d files', $count), $count); } // info on related comments if ($count = Comments::count_for_anchor('article:' . $article['id'])) { $menu[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count); } // discuss if (Comments::allow_creation($article, $anchor)) { $menu[] = Skin::build_link(Comments::get_url('article:' . $article['id'], 'comment'), i18n::s('Discuss'), 'span'); } // the main anchor link if (is_object($anchor) && (!isset($this->focus) || $article['anchor'] != $this->focus)) { $menu[] = Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'span', i18n::s('View the section')); } // list up to three categories by title, if any if ($items =& Members::list_categories_by_title_for_member('article:' . $article['id'], 0, 3, 'raw')) { foreach ($items as $id => $attributes) { $menu[] = Skin::build_link(Categories::get_permalink($attributes), $attributes['title'], 'span'); } } // append a menu $content .= '<p>' . Skin::finalize_list($menu, 'menu') . '</p>'; // this is another row of the output $text .= '<tr class="' . $class_detail . '"><td>' . '<h3 class="top"><span>' . Skin::build_link($url, $prefix . $title . $suffix, 'basic', i18n::s('View the page')) . '</span></h3>' . '<div class="content">' . $icon . $content . '</div>' . '</td></tr>' . "\n"; } } // end of processing SQL::free($result); $text .= Skin::table_suffix(); return $text; }
/** * 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; } // the maximum number of items per section if (!defined('MAXIMUM_ITEMS_PER_SECTION')) { define('MAXIMUM_ITEMS_PER_SECTION', 100); } // we return plain text $text = ''; // process all items in the list include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; $family = ''; while ($item = SQL::fetch($result)) { // change the family if ($item['family'] != $family) { $family = $item['family']; // show the family $text .= '<h2><span>' . $family . ' </span></h2>' . "\n"; } // get the related overlay, if any $overlay = Overlay::load($item, 'section:' . $item['id']); // get the main anchor $anchor = Anchors::get($item['anchor']); // one box per section $box = array('title' => '', 'text' => ''); // box content $elements = array(); // use the title to label the link if (is_object($overlay)) { $box['title'] .= Codes::beautify_title($overlay->get_text('title', $item)); } else { $box['title'] .= Codes::beautify_title($item['title']); } $details = array(); // info on related articles if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) { $order = $matches[1]; } else { $order = 'edition'; } $items =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact'); if (@count($items)) { // mention the number of items in folded title $details[] = sprintf(i18n::ns('%d page', '%d pages', count($items)), count($items)); // add one link per item foreach ($items as $url => $label) { $prefix = $suffix = ''; if (is_array($label)) { $prefix = $label[0]; $suffix = $label[2]; $label = $label[1]; } $elements[] = $prefix . Skin::build_link($url, $label, 'article') . $suffix; } } // info on related files if (Sections::has_option('files_by', $anchor, $item) == 'title') { $items = Files::list_by_title_for_anchor('section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact'); } else { $items = Files::list_by_date_for_anchor('section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact'); } if ($items) { // mention the number of sections in folded title $details[] = sprintf(i18n::ns('%d file', '%d files', count($items)), count($items)); // add one link per item foreach ($items as $url => $label) { if (is_array($label)) { $prefix = $label[0]; $suffix = $label[2]; $label = $label[1]; } $elements[] = $prefix . Skin::build_link($url, $label, 'file') . $suffix; } } // info on related comments if ($items = Comments::list_by_date_for_anchor('section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact', TRUE)) { // mention the number of sections in folded title $details[] = sprintf(i18n::ns('%d comment', '%d comments', count($items)), count($items)); // add one link per item foreach ($items as $url => $label) { $prefix = $suffix = ''; if (is_array($label)) { $prefix = $label[0]; $suffix = $label[2]; $label = $label[1]; } $elements[] = $prefix . Skin::build_link($url, $label, 'comment') . $suffix; } } // info on related links if (Sections::has_option('links_by_title', $anchor, $item)) { $items = Links::list_by_title_for_anchor('section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact'); } else { $items = Links::list_by_date_for_anchor('section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact'); } if ($items) { // mention the number of sections in folded title $details[] = sprintf(i18n::ns('%d link', '%d links', count($items)), count($items)); // add one link per item foreach ($items as $url => $label) { $prefix = $suffix = ''; if (is_array($label)) { $prefix = $label[0]; $suffix = $label[2]; $label = $label[1]; } $elements[] = $prefix . Skin::build_link($url, $label) . $suffix; } } // list related sections, if any if ($items =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, MAXIMUM_ITEMS_PER_SECTION + 1, 'compact')) { // mention the number of sections in folded title $details[] = sprintf(i18n::ns('%d section', '%d sections', count($items)), count($items)); // add one link per item foreach ($items as $url => $label) { $prefix = $suffix = ''; if (is_array($label)) { $prefix = $label[0]; $suffix = $label[2]; $label = $label[1]; } $elements[] = $prefix . Skin::build_link($url, $label, 'section') . $suffix; } } // signal continuing sections if (count($elements) > MAXIMUM_ITEMS_PER_SECTION) { $elements[] = Skin::build_link(Sections::get_permalink($item), i18n::s('More pages') . MORE_IMG, 'basic'); } else { $elements[] = Skin::build_link(Sections::get_permalink($item), i18n::s('View the section'), 'shortcut'); } // complement title if (count($details)) { $box['title'] .= ' <span class="details">(' . join(', ', $details) . ')</span>'; } // insert introduction, if any if ($item['introduction']) { $box['text'] .= Codes::beautify_introduction($item['introduction']); } // make a full list if (count($elements)) { $box['text'] .= '<ul><li>' . implode('</li>' . "\n" . '<li>', $elements) . '</li></ul>' . "\n"; } // if we have an icon for this section, use it if (isset($item['thumbnail_url']) && $item['thumbnail_url']) { // adjust the class $class = ''; if (isset($context['classes_for_thumbnail_images'])) { $class = 'class="' . $context['classes_for_thumbnail_images'] . '" '; } // build the complete HTML element $icon = '<img src="' . $item['thumbnail_url'] . '" alt="" title="' . encode_field(Codes::beautify_title($item['title'])) . '" ' . $class . '/>'; // make it clickable $link = Skin::build_link(Sections::get_permalink($item), $icon, 'basic'); // put this aside $box['text'] = '<table class="decorated"><tr>' . '<td class="image">' . $link . '</td>' . '<td class="content">' . $box['text'] . '</td>' . '</tr></table>'; } // always make a box $text .= Skin::build_box($box['title'], $box['text'], 'folded'); } // end of processing SQL::free($result); return $text; }
/** * list sections * * Accept following variants: * - 'full' - include anchor information -- also the default value * * @param resource the SQL result * @return array of resulting items, or NULL * * @see layouts/layout.php **/ function layout($result) { global $context; // we return an array of ($url => $attributes) $items = array(); // empty list if (!SQL::count($result)) { return $items; } // sanity check if (!isset($this->layout_variant)) { $this->layout_variant = 'decorated'; } // process all items in the list include_once $context['path_to_root'] . 'comments/comments.php'; include_once $context['path_to_root'] . 'links/links.php'; while ($item = SQL::fetch($result)) { // get the related overlay, if any $overlay = Overlay::load($item, '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 sections that are draft, dead, or created or updated very recently if ($item['activation_date'] >= $context['now']) { $prefix .= DRAFT_FLAG; } elseif ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $prefix .= EXPIRED_FLAG; } if ($item['create_date'] >= $context['fresh']) { $suffix .= NEW_FLAG; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix .= UPDATED_FLAG; } // signal restricted and private sections if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // the introductory text if ($item['introduction']) { $suffix .= ' - ' . Codes::beautify_introduction($item['introduction']); } // details and content $details = array(); $content = array(); // count related sub-elements $related_count = 0; // info on related articles if ($count = Articles::count_for_anchor('section:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count); $related_count += $count; // add related articles if necessary if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) { $order = $matches[1]; } else { $order = 'edition'; } if (count($details) < YAHOO_LIST_SIZE && ($related =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, YAHOO_LIST_SIZE - count($details), 'compact'))) { foreach ($related as $link => $label) { $sub_prefix = $sub_suffix = $sub_hover = ''; if (is_array($label)) { $sub_prefix = $label[0]; $sub_suffix = $label[2]; if (@$label[5]) { $sub_hover = $label[5]; } $label = $label[1]; } $content[$link] = array($sub_prefix, $label, $sub_suffix, 'basic', '', $sub_hover); } } } // info on related files if ($count = Files::count_for_anchor('section:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count); $related_count += $count; // add related files if necessary if (count($details) < YAHOO_LIST_SIZE && ($related = Files::list_by_date_for_anchor('section:' . $item['id'], 0, YAHOO_LIST_SIZE - count($details), 'compact'))) { foreach ($related as $link => $label) { $sub_prefix = $sub_suffix = $sub_hover = ''; if (is_array($label)) { $sub_prefix = $label[0]; $sub_suffix = $label[2]; if (@$label[5]) { $sub_hover = $label[5]; } $label = $label[1]; } $content[$link] = array($sub_prefix, $label, $sub_suffix, 'basic', '', $sub_hover); } } } // info on related links if ($count = Links::count_for_anchor('section:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count); $related_count += $count; // add related links if necessary if (count($details) < YAHOO_LIST_SIZE && ($related = Links::list_by_date_for_anchor('section:' . $item['id'], 0, YAHOO_LIST_SIZE - count($details), 'compact'))) { foreach ($related as $link => $label) { $sub_prefix = $sub_suffix = $sub_hover = ''; if (is_array($label)) { $sub_prefix = $label[0]; $sub_suffix = $label[2]; if (@$label[5]) { $sub_hover = $label[5]; } $label = $label[1]; } $content[$link] = array($sub_prefix, $label, $sub_suffix, 'basic', '', $sub_hover); } } } // info on related comments if ($count = Comments::count_for_anchor('section:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count); } // info on related sections if ($count = Sections::count_for_anchor('section:' . $item['id'])) { $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count); $related_count += $count; // add sub-sections if ($related =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, YAHOO_LIST_SIZE, 'compact')) { foreach ($related as $link => $label) { $sub_prefix = $sub_suffix = $sub_hover = ''; if (is_array($label)) { $sub_prefix = $label[0]; $sub_suffix = $label[2]; if (@$label[5]) { $sub_hover = $label[5]; } $label = $label[1]; } $content[$link] = array($sub_prefix, $label, $sub_suffix, 'basic', '', $sub_hover); } } } // give me more if (count($details) && $related_count > YAHOO_LIST_SIZE) { $content[Sections::get_permalink($item)] = array('', i18n::s('More') . MORE_IMG, '', 'more', '', i18n::s('View the section')); } // append details to the suffix if (count($details)) { $suffix .= ' <span class="details">(' . implode(', ', $details) . ')</span>'; } // the main anchor link if (is_object($anchor) && (!isset($this->focus) || $item['anchor'] != $this->focus)) { $suffix .= ' <span class="details">' . sprintf(i18n::s('in %s'), Skin::build_link($anchor->get_url(), ucfirst($anchor->get_title()), 'section')) . "</span>\n"; } // not if decorated if ($this->layout_variant != 'decorated' && $this->layout_variant != 'references') { // one line per related item if (count($content)) { $suffix .= '<div class="details">' . Skin::build_list($content, 'compact') . "</div>\n"; } } // the icon to put in the left column if ($item['thumbnail_url']) { $icon = $item['thumbnail_url']; } // some hovering title for this section $hover = i18n::s('View the section'); // list all components for this item $items[$url] = array($prefix, $title, $suffix, 'section', $icon, $hover); } // end of processing SQL::free($result); return $items; }
/** * 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 dates at some anchor * * @param string type of replaced items (e.g., 'articles') * @param string the anchor to consider (e.g., 'section:123') * @param int page index * @return string to be inserted in resulting web page, or NULL */ function render($type, $anchor, $page = 1) { global $context; // instead of articles if ($type != 'articles') { return NULL; } // get the containing page $container = Anchors::get($anchor); // handle dates include_once $context['path_to_root'] . 'dates/dates.php'; // the maximum number of articles per page if (!defined('DATES_PER_PAGE')) { define('DATES_PER_PAGE', 50); } // where we are $offset = ($page - 1) * DATES_PER_PAGE; // should we display all dates, or not? $with_past_dates = FALSE; if (preg_match('/\\bwith_past_dates\\b/i', $this->attributes['overlay_parameters'])) { $with_past_dates = TRUE; } // menu to be displayed at the top $menu = array(); // empowered users can contribute if (Articles::allow_creation(NULL, $container)) { Skin::define_img('ARTICLES_ADD_IMG', 'articles/add.gif'); $menu[] = '<div style="display: inline">' . Skin::build_link('articles/edit.php?anchor=' . urlencode($anchor), ARTICLES_ADD_IMG . i18n::s('Add an event'), 'span') . '</div>'; } // ensure access to past dates if (!$with_past_dates && ($items = Dates::list_past_for_anchor($anchor, $offset, DATES_PER_PAGE, 'compact'))) { // turn an array to a string if (is_array($items)) { $items =& Skin::build_list($items, 'compact'); } // navigation bar $bar = array(); // count the number of dates in this section $stats = Dates::stat_past_for_anchor($anchor); if ($stats['count'] > DATES_PER_PAGE) { $bar = array_merge($bar, array('_count' => sprintf(i18n::ns('%d date', '%d dates', $stats['count']), $stats['count']))); } // navigation commands for dates if ($section = Sections::get(str_replace('section:', '', $anchor))) { $home = Sections::get_permalink($section); $prefix = Sections::get_url($section['id'], 'navigate', 'articles'); $bar = array_merge($bar, Skin::navigate($home, $prefix, $stats['count'], DATES_PER_PAGE, $page)); } // display the bar if (is_array($bar)) { $items = Skin::build_list($bar, 'menu_bar') . $items; } // in a separate box $menu[] = Skin::build_sliding_box(i18n::s('Past dates'), $items, 'past_dates', TRUE); } // menu displayed towards the top of the page $text = Skin::finalize_list($menu, 'menu_bar'); // build a list of events if (preg_match('/\\blayout_as_list\\b/i', $this->attributes['overlay_parameters'])) { // list all dates if ($with_past_dates) { // navigation bar $bar = array(); // count the number of dates in this section $stats = Dates::stat_for_anchor($anchor); if ($stats['count'] > DATES_PER_PAGE) { $bar = array_merge($bar, array('_count' => sprintf(i18n::ns('%d date', '%d dates', $stats['count']), $stats['count']))); } // navigation commands for dates $section = Sections::get($anchor); $home = Sections::get_permalink($section); $prefix = Sections::get_url($section['id'], 'navigate', 'articles'); $bar = array_merge($bar, Skin::navigate($home, $prefix, $stats['count'], DATES_PER_PAGE, $page)); // display the bar if (count($bar)) { $text .= Skin::build_list($bar, 'menu_bar'); } // list one page of dates if ($items = Dates::list_for_anchor($anchor, $offset, DATES_PER_PAGE, 'family')) { $text .= $items; } // display only future dates to regular surfers } else { // show future dates on first page if ($page == 1 && ($items = Dates::list_future_for_anchor($anchor, 0, 500, 'family', TRUE))) { $text .= $items; } } // deliver a calendar view for current month, plus months around } else { // show past dates as well if ($with_past_dates) { $items = Dates::list_for_anchor($anchor, 0, 500, 'links'); } else { $items = Dates::list_future_for_anchor($anchor, 0, 500, 'links', TRUE); } // layout all these dates if ($items) { $text .= Dates::build_months($items); } } // integrate this into the page return $text; }
} // the message $label = i18n::s('Message content'); $input = Surfer::get_editor('message', $content); $fields[] = array($label, $input); // build the form $context['text'] .= Skin::build_form($fields); // // bottom commands // $menu = array(); // the submit button $menu[] = Skin::build_submit_button(i18n::s('Submit'), i18n::s('Press [s] to submit data'), 's'); // cancel button if (isset($item['id'])) { $menu[] = Skin::build_link(Sections::get_permalink($item), i18n::s('Cancel'), 'span'); } // insert the menu in the page $context['text'] .= Skin::finalize_list($menu, 'assistant_bar'); // get a copy of the sent message $context['text'] .= '<p><input type="checkbox" name="self_copy" value="Y" checked="checked" /> ' . i18n::s('Send me a copy of this message.') . '</p>'; // transmit the id as a hidden field $context['text'] .= '<input type="hidden" name="id" value="' . $item['id'] . '" />'; // end of the form $context['text'] .= '</div></form>'; // append the script used for data checking on the browser Page::insert_script('func' . 'tion validateDocumentPost(container) {' . "\n" . ' if(!container.subject.value) {' . "\n" . ' alert("' . i18n::s('Please provide a meaningful title.') . '");' . "\n" . ' Yacs.stopWorking();' . "\n" . ' return false;' . "\n" . ' }' . "\n" . ' if(!container.message.value) {' . "\n" . ' alert("' . i18n::s('Message content can not be empty.') . '");' . "\n" . ' Yacs.stopWorking();' . "\n" . ' return false;' . "\n" . ' }' . "\n" . ' return true;' . "\n" . '}' . "\n" . '$(function() {' . "\n" . ' $("#names").focus();' . "\n" . ' Yacs.autocomplete_names("names");' . "\n" . '}); ' . "\n"); // help message $help = '<p>' . i18n::s('New e-mail addresses are converted to new user profiles. Because of this, you should not use e-mail addresses that have multiple recipients.') . '</p>'; $context['components']['boxes'] = Skin::build_box(i18n::s('Help'), $help, 'boxes', 'help'); }
/** * 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; } // the script used to check all pages at once Page::insert_script('function cascade_selection_to_all_section_rows(handle) {' . "\n" . ' $("div#sections_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_section_rows(this);" />'; $cells = array($main, i18n::s('Section'), 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, 'section:' . $item['id']); // get the main anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Sections::get_permalink($item); // column to select the row $cells[] = '<input type="checkbox" name="selected_sections[]" id="section_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($item['title']); } // initialize variables $prefix = $suffix = $icon = ''; // flag sticky pages if ($item['rank'] < 10000) { $prefix .= STICKY_FLAG; } // signal locked sections if (isset($item['locked']) && $item['locked'] == 'Y') { $suffix .= ' ' . LOCKED_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; } // signal restricted and private sections if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // the introductory text if ($item['introduction']) { $suffix .= BR . Codes::beautify_introduction($item['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(); // info on related pages $stats = Articles::stat_for_anchor('section:' . $item['id']); if ($stats['count']) { $details[] = sprintf(i18n::ns('%d page', '%d pages', $stats['count']), $stats['count']); } // info on related files $stats = Files::stat_for_anchor('section:' . $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('section:' . $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('section:' . $item['id']); if ($stats['count']) { $details[] = sprintf(i18n::ns('%d comment', '%d comments', $stats['count']), $stats['count']); } // info on related sections $stats = Sections::stat_for_anchor('section:' . $item['id']); if ($stats['count']) { $details[] = sprintf(i18n::ns('%d section', '%d sections', $stats['count']), $stats['count']); } // combine in-line details if (count($details)) { $suffix .= ucfirst(trim(implode(', ', $details))) . BR; } // list up to three categories by title, if any $anchors = array(); if ($members =& Members::list_categories_by_title_for_member('section:' . $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 .= sprintf(i18n::s('In %s'), implode(' | ', $anchors)) . BR; } // 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')); } // combine in-line details if (count($details)) { $suffix .= ucfirst(trim(implode(', ', $details))); } // 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(Sections::get_url($item['id'], 'edit'), i18n::s('edit'), 'basic'), Skin::build_link(Sections::get_url($item['id'], 'delete'), i18n::s('delete'), 'basic')); // link to this page $cells[] = $prefix . Skin::build_link($url, $title, 'section') . ' - ' . Skin::finalize_list($commands, 'menu') . $suffix; // ranking $cells[] = '<input type="text" size="5" name="section_rank_' . $item['id'] . '" value="' . $item['rank'] . '" onfocus="$(\'#section_selector_' . $count . '\').attr(\'checked\', \'checked\');" onchange="$(\'#act_on_sections\').prop(\'selectedIndex\', 6);" />'; // 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_section_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; }
$query = "SELECT id, anchor, title FROM " . SQL::table_name('sections') . " ORDER BY anchor LIMIT 0, 10000"; // parse the whole list if ($result = SQL::query($query)) { // retrieve the id and a printable label $errors_count = 0; while ($row = SQL::fetch($result)) { // animate user screen and take care of time $count++; if (!($count % 100)) { $context['text'] .= sprintf(i18n::s('%d records have been processed'), $count) . BR . "\n"; // ensure enough execution time Safe::set_time_limit(30); } // check that the anchor exists, if any if ($row['anchor'] && !Anchors::get($row['anchor'])) { $context['text'] .= sprintf(i18n::s('Orphan: %s'), 'section ' . Skin::build_link(Sections::get_permalink($row), $row['id'] . ' ' . $row['title'], 'section')) . BR . "\n"; if (++$errors_count >= 5) { $context['text'] .= i18n::s('Too many successive errors. Aborted') . BR . "\n"; break; } } else { $errors_count = 0; } } } // ending message $context['text'] .= sprintf(i18n::s('%d records have been processed'), $count) . BR . "\n"; // display the execution time $time = round(get_micro_time() - $context['start_time'], 2); $context['text'] .= '<p>' . sprintf(i18n::s('Script terminated in %.2f seconds.'), $time) . '</p>'; // forward to the index page
/** * 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; } // maximum number of items if (isset($this->layout_variant) && $this->layout_variant > 3) { $maximum_items = $this->layout_variant; } elseif (defined('YAHOO_LIST_SIZE')) { $maximum_items = YAHOO_LIST_SIZE; } else { $maximum_items = 7; } // clear flows $text .= '<br style="clear: left" />'; // process all items in the list $family = ''; while ($item = SQL::fetch($result)) { // change the family if ($item['family'] != $family) { $family = $item['family']; $text .= '<h2><span>' . $family . ' </span></h2>' . "\n"; } // get the anchor $anchor = Anchors::get($item['anchor']); // the url to view this item $url = Sections::get_permalink($item); // initialize variables $prefix = $label = $suffix = $icon = $hover = ''; // signal restricted and private sections if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // flag sections that are draft, dead, or created or updated very recently if ($item['activation_date'] >= $context['now']) { $prefix .= DRAFT_FLAG; } elseif ($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; } // display introduction field on hovering if ($item['introduction']) { $hover .= strip_tags(Codes::beautify_introduction($item['introduction'])); } // details and content $details = array(); $content = array(); // count related sub-elements $related_count = 0; // info on related articles if ($count = Articles::count_for_anchor('section:' . $item['id'])) { if ($count > $maximum_items) { $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count); } elseif (Surfer::is_empowered()) { $details[] = sprintf(i18n::ns('%d page', '%d pages', $count), $count); } $related_count += $count; // get the overlay for content of this section, if any $content_overlay = NULL; if (isset($item['content_overlay'])) { $content_overlay = Overlay::bind($item['content_overlay']); } // no room to list articles if (count($content) >= $maximum_items) { } elseif (is_object($content_overlay) && is_callable(array($content_overlay, 'render_list_for_anchor'))) { if ($related = $content_overlay->render_list_for_anchor('section:' . $item['id'], $maximum_items - count($content))) { foreach ($related as $sub_url => $label) { $sub_prefix = $sub_suffix = $sub_hover = ''; if (is_array($label)) { $sub_prefix = $label[0]; $sub_suffix = $label[2]; if (@$label[5]) { $sub_hover = $label[5]; } $label = $label[1]; } $content[] = $sub_prefix . $label . $sub_suffix; } } // regular rendering of related articles } else { if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) { $order = $matches[1]; } else { $order = 'edition'; } if ($related =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], 0, $maximum_items - count($content), 'compact')) { foreach ($related as $sub_url => $label) { $sub_prefix = $sub_suffix = $sub_hover = ''; if (is_array($label)) { $sub_prefix = $label[0]; $sub_suffix = $label[2]; if (@$label[5]) { $sub_hover = $label[5]; } $label = $label[1]; } $content[] = $sub_prefix . $label . $sub_suffix; } } } } // info on related files if ($count = Files::count_for_anchor('section:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d file', '%d files', $count), $count); $related_count += $count; // add related files if necessary if (count($content) < $maximum_items && ($related = Files::list_by_date_for_anchor('section:' . $item['id'], 0, $maximum_items - count($content), 'compact'))) { foreach ($related as $sub_url => $label) { $sub_prefix = $sub_suffix = $sub_hover = ''; if (is_array($label)) { $sub_prefix = $label[0]; $sub_suffix = $label[2]; if (@$label[5]) { $sub_hover = $label[5]; } $label = $label[1]; } $content[] = $sub_prefix . $label . $sub_suffix; } } } // info on related links if ($count = Links::count_for_anchor('section:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d link', '%d links', $count), $count); $related_count += $count; // add related links if necessary if (count($content) < $maximum_items && ($related = Links::list_by_date_for_anchor('section:' . $item['id'], 0, $maximum_items - count($content), 'compact'))) { foreach ($related as $sub_url => $label) { $sub_prefix = $sub_suffix = $sub_hover = ''; if (is_array($label)) { $sub_prefix = $label[0]; $sub_suffix = $label[2]; if (@$label[5]) { $sub_hover = $label[5]; } $label = $label[1]; } $content[] = $sub_prefix . $label . $sub_suffix; } } } // info on related comments if ($count = Comments::count_for_anchor('section:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::ns('%d comment', '%d comments', $count), $count); $related_count += $count; } // info on related sections if ($count = Sections::count_for_anchor('section:' . $item['id'])) { if ($count > $maximum_items) { $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count); } elseif (Surfer::is_empowered()) { $details[] = sprintf(i18n::ns('%d section', '%d sections', $count), $count); } $related_count += $count; // add sub-sections if ($related =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, $maximum_items - count($content), 'compact')) { foreach ($related as $sub_url => $label) { $sub_prefix = $sub_suffix = $sub_hover = ''; if (is_array($label)) { $sub_prefix = $label[0]; $sub_suffix = $label[2]; if (@$label[5]) { $sub_hover = $label[5]; } $label = $label[1]; } $content[] = $sub_prefix . $label . $sub_suffix; } } } // give me more if (count($content) && $related_count > $maximum_items) { $content[] = '...' . MORE_IMG; } // layout details if (count($content)) { $hover .= '<ul><li>' . implode('</li><li>', $content) . '</li></ul>'; } // add a link to the main page if (!$hover) { $hover = i18n::s('View the section'); } // use the title to label the link $title = Skin::strip($item['title'], 50); // new or updated flag if ($suffix) { $details[] = $suffix; } // append details if (count($details)) { $title .= BR . '<span class="details">' . implode(', ', $details) . '</span>'; } // look for an image $icon = ''; if (isset($item['thumbnail_url']) && $item['thumbnail_url']) { $icon = $item['thumbnail_url']; } elseif (is_callable(array($anchor, 'get_bullet_url'))) { $icon = $anchor->get_bullet_url(); } // use the thumbnail for this section if ($icon) { // 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="" ' . $options . ' />'; // use default icon if nothing to display } else { $icon = MAP_IMG; } // use tipsy on hover $content = '<a href="' . $url . '" id="titles_' . $item['id'] . '">' . $icon . BR . $prefix . $title . '</a>'; Page::insert_script('$(function() {' . "\n" . ' $("a#titles_' . $item['id'] . '").each(function() {' . "\n" . ' $(this).tipsy({fallback: \'<div style="text-align: left;">' . str_replace(array("'", "\n"), array('"', '<br />'), $hover) . '</div>\',' . "\n" . ' html: true,' . "\n" . ' gravity: $.fn.tipsy.autoWE,' . "\n" . ' fade: true,' . "\n" . ' offset: 8,' . "\n" . ' opacity: 1.0});' . "\n" . ' });' . "\n" . '});' . "\n"); // add a floating box $text .= Skin::build_box(NULL, $content, 'floating'); } // clear flows $text .= '<br style="clear: left" />'; // end of processing SQL::free($result); return $text; }
} // list links by date (default) or by title (option 'links_by_title') $offset = ($zoom_index - 1) * LINKS_PER_PAGE; if (preg_match('/\\blinks_by_title\\b/i', $item['options'])) { $items = Links::list_by_title_for_anchor('section:' . $item['id'], $offset, LINKS_PER_PAGE, 'no_anchor'); } else { $items = Links::list_by_date_for_anchor('section:' . $item['id'], $offset, LINKS_PER_PAGE, 'no_anchor'); } // actually render the html if (is_array($items)) { $box['text'] .= Skin::build_list($items, 'rows'); } elseif (is_string($items)) { $box['text'] .= $items; } // navigation commands for links $home = Sections::get_permalink($item); $prefix = Sections::get_url($item['id'], 'navigate', 'links'); $box['bar'] = array_merge($box['bar'], Skin::navigate($home, $prefix, $count, LINKS_PER_PAGE, $zoom_index)); } // new links are allowed -- check option 'with_links' if (Links::allow_creation($item, $anchor, 'section')) { Skin::define_img('LINKS_ADD_IMG', 'links/add.gif'); $box['bar'] += array('links/edit.php?anchor=' . urlencode('section:' . $item['id']) => LINKS_ADD_IMG . i18n::s('Add a link')); } // integrate commands if (count($box['bar'])) { $box['text'] = Skin::build_list($box['bar'], 'menu_bar') . $box['text']; } // there is some box content if (trim($box['text'])) { $attachments .= Skin::build_box(i18n::s('Links'), $box['text'], 'header1', 'links');
/** * get permalink to item */ function get_permalink() { if (!isset($this->item['id'])) { return NULL; } $link = Sections::get_permalink($this->item); return $link; }
/** * list sections as topics in a forum * * @param resource the SQL result * @return string the rendered text **/ function layout($result) { global $context; // empty list if (!SQL::count($result)) { $output = array(); return $output; } // output as a string $text = ''; // build a list of sections $family = ''; $first = TRUE; while ($item = SQL::fetch($result)) { // change the family if ($item['family'] != $family) { $family = $item['family']; // close last table only if a section has been already listed if (!$first) { $text .= Skin::table_suffix(); } // show the family $text .= '<h2><span>' . $family . ' </span></h2>' . "\n" . Skin::table_prefix('yabb') . Skin::table_row(array(i18n::s('Board'), 'center=' . i18n::s('Topics'), i18n::s('Last post')), 'header'); } elseif ($first) { $text .= Skin::table_prefix('yabb'); $text .= Skin::table_row(array(i18n::s('Board'), 'center=' . i18n::s('Topics'), i18n::s('Last post')), 'header'); } // done with this case $first = FALSE; // reset everything $prefix = $label = $suffix = $icon = ''; // signal restricted and private sections if ($item['active'] == 'N') { $prefix .= PRIVATE_FLAG; } elseif ($item['active'] == 'R') { $prefix .= RESTRICTED_FLAG; } // indicate the id in the hovering popup $hover = i18n::s('View the section'); if (Surfer::is_member()) { $hover .= ' [section=' . $item['id'] . ']'; } // the url to view this item $url = Sections::get_permalink($item); // use the title as a link to the page $title =& Skin::build_link($url, Codes::beautify_title($item['title']), 'basic', $hover); // also use a clickable thumbnail, if any if ($item['thumbnail_url']) { $prefix = Skin::build_link($url, '<img src="' . $item['thumbnail_url'] . '" alt="" title="' . encode_field($hover) . '" class="left_image" />', 'basic', $hover) . $prefix; } // flag sections updated recently if ($item['expiry_date'] > NULL_DATE && $item['expiry_date'] <= $context['now']) { $suffix = EXPIRED_FLAG . ' '; } elseif ($item['create_date'] >= $context['fresh']) { $suffix = NEW_FLAG . ' '; } elseif ($item['edit_date'] >= $context['fresh']) { $suffix = UPDATED_FLAG . ' '; } // board introduction if ($item['introduction']) { $suffix .= '<br style="clear: none;" />' . Codes::beautify_introduction($item['introduction']); } // more details $details = ''; $more = array(); // board moderators if ($moderators = Sections::list_editors_by_name($item, 0, 7, 'comma5')) { $more[] = sprintf(i18n::ns('Moderator: %s', 'Moderators: %s', count($moderators)), $moderators); } // children boards if ($children =& Sections::list_by_title_for_anchor('section:' . $item['id'], 0, COMPACT_LIST_SIZE, 'comma')) { $more[] = sprintf(i18n::ns('Child board: %s', 'Child boards: %s', count($children)), Skin::build_list($children, 'comma')); } // as a compact list if (count($more)) { $details .= '<ul class="compact">'; foreach ($more as $list_item) { $details .= '<li>' . $list_item . '</li>' . "\n"; } $details .= '</ul>' . "\n"; } // all details if ($details) { $details = BR . '<span class="details">' . $details . "</span>\n"; } // count posts here, and in children sections $anchors = Sections::get_branch_at_anchor('section:' . $item['id']); if (!($count = Articles::count_for_anchor($anchors))) { $count = 0; } // get last post $last_post = '--'; $article =& Articles::get_newest_for_anchor($anchors, TRUE); if ($article['id']) { // flag articles updated recently if ($article['expiry_date'] > NULL_DATE && $article['expiry_date'] <= $context['now']) { $flag = EXPIRED_FLAG . ' '; } elseif ($article['create_date'] >= $context['fresh']) { $flag = NEW_FLAG . ' '; } elseif ($article['edit_date'] >= $context['fresh']) { $flag = UPDATED_FLAG . ' '; } else { $flag = ''; } // title $last_post = Skin::build_link(Articles::get_permalink($article), Codes::beautify_title($article['title']), 'article'); // last editor if ($article['edit_date']) { // find a name, if any if ($article['edit_name']) { // label the action if (isset($article['edit_action'])) { $action = Anchors::get_action_label($article['edit_action']); } else { $action = i18n::s('edited'); } // name of last editor $user = sprintf(i18n::s('%s by %s'), $action, Users::get_link($article['edit_name'], $article['edit_address'], $article['edit_id'])); } $last_post .= $flag . BR . '<span class="tiny">' . $user . ' ' . Skin::build_date($article['edit_date']) . '</span>'; } } // this is another row of the output $text .= Skin::table_row(array($prefix . $title . $suffix . $details, 'center=' . $count, $last_post)); } // end of processing SQL::free($result); $text .= Skin::table_suffix(); return $text; }
/** * 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; }
/** * 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 (!($delta = SQL::count($result))) { return $text; } // process all items in the list $count = 0; $items = array(); while ($item = SQL::fetch($result)) { // 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 $label .= ucfirst(Skin::strip($item['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); // limit to one page of results if (++$count >= COMPACT_LIST_SIZE - 1) { break; } } // end of processing SQL::free($result); // turn this to some text $text .= Skin::build_list($items, 'comma'); // some indications on the number of connections if (($delta -= $count) > 0) { $text .= ', ...'; } 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; } // sanity check if (!isset($this->focus)) { $this->focus = 'map'; } // put in cache $cache_id = Cache::hash('sections/layout_sections_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, 'section:' . $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_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 = Sections::get_permalink($item); // add to the list $content .= ' <photo>' . "\n" . ' <title>' . $title . '</title>' . "\n" . ' <src>' . $context['url_to_home'] . $image . '</src>' . "\n" . ' <href>' . $context['url_to_home'] . $context['url_to_root'] . $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="sections_as_carrousel_' . $count . '"></div>' . "\n"; Page::insert_script('swfobject.embedSWF("' . $context['url_to_home'] . $context['url_to_root'] . 'included/browser/carrousel.swf",' . "\n" . '"sections_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; }
if (!$item['id']) { include '../error.php'; // access denied } elseif (!Sections::allow_access($item, $anchor)) { // give anonymous surfers a chance for HTTP authentication if (!Surfer::is_logged()) { Safe::header('WWW-Authenticate: Basic realm="' . utf8::to_iso8859($context['site_name']) . '"'); Safe::header('Status: 401 Unauthorized', TRUE, 401); } // permission denied to authenticated user Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // describe the section } else { // compute the url for this section $url = Sections::get_permalink($item); // get a description if ($item['introduction']) { $description = Codes::beautify($item['introduction']); } else { $description = Skin::strip(Codes::beautify($item['description']), 50); } // prepare the response $text = '<?xml version="1.0" encoding="' . $context['charset'] . '"?>' . "\n" . '<rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:dc="http://purl.org/dc/elements/1.1/">' . "\n" . ' <rdf:Description rdf:about="' . $url . '">' . "\n" . ' <dc:title>' . encode_field($item['title']) . '</dc:title>' . "\n" . ' <dc:description>' . encode_field(Skin::strip($description)) . '</dc:description>' . "\n" . ' <dc:date>' . gmdate('Y-m-d') . '</dc:date>' . "\n" . ' <dc:format>text/html</dc:format>' . "\n"; if (isset($item['language']) && $item['language'] && $item['language'] != 'none') { $text .= ' <dc:language>' . $item['language'] . '</dc:language>' . "\n"; } $text .= ' </rdf:Description>' . "\n" . '</rdf:RDF>'; // // transfer to the user agent //
/** * build a notification related to a section * * This function builds a mail message that displays: * - an image of the contributor (if possible) * - a headline mentioning the contribution * - the full content of the section * - a button linked to the section * - a link to the containing section, if any * * Note: this function returns legacy HTML, not modern XHTML, because this is what most * e-mail client software can afford. * * @param string either 'apply', 'create' or 'update' * @param array attributes of the item * @param object overlay of the item, if any * @return string text to be send by e-mail */ public static function build_notification($action, $item, $overlay = NULL) { global $context; // get the main anchor $anchor = Anchors::get($item['anchor']); // compute page title if (is_object($overlay)) { $title = Codes::beautify_title($overlay->get_text('title', $item)); } else { $title = Codes::beautify_title($item['title']); } // headline template switch ($action) { case 'apply': $template = i18n::c('%s is requesting access to %s'); break; case 'create': $template = i18n::c('%s has created section %s'); break; case 'update': $template = i18n::c('%s has updated section %s'); break; } // headline $headline = sprintf($template, Surfer::get_link(), '<a href="' . Sections::get_permalink($item) . '">' . $title . '</a>'); // panel content $content = ''; // signal restricted and private articles if ($item['active'] == 'N') { $title = PRIVATE_FLAG . $title; } elseif ($item['active'] == 'R') { $title = RESTRICTED_FLAG . $title; } // insert page title $content .= '<h3><span>' . $title . '</span></h3>'; // insert anchor prefix if (is_object($anchor)) { $content .= $anchor->get_prefix(); } // the introduction text, if any if (is_object($overlay)) { $content .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction'); } elseif (isset($item['introduction']) && trim($item['introduction'])) { $content .= Skin::build_block($item['introduction'], 'introduction'); } // get text related to the overlay, if any if (is_object($overlay)) { $content .= $overlay->get_text('view', $item); } // filter description, if necessary if (is_object($overlay)) { $description = $overlay->get_text('description', $item); } else { $description = $item['description']; } // the beautified description, which is the actual page body if ($description) { // use adequate label if (is_object($overlay) && ($label = $overlay->get_label('description'))) { $content .= Skin::build_block($label, 'title'); } // beautify the target page $content .= Skin::build_block($description, 'description', '', $item['options']); } // attachment details $details = array(); // info on related sections if ($count = Sections::count_for_anchor('section:' . $item['id'])) { $details[] = sprintf(i18n::nc('%d section', '%d sections', $count), $count); } // info on related articles if ($count = Articles::count_for_anchor('section:' . $item['id'])) { $details[] = sprintf(i18n::nc('%d page', '%d pages', $count), $count); } // info on related files if ($count = Files::count_for_anchor('section:' . $item['id'], TRUE)) { // the actual list of files attached to this section if (preg_match('/\\bfiles_by_title\\b/i', $item['options'])) { $items = Files::list_by_title_for_anchor('section:' . $item['id'], 0, 300, 'compact'); } else { $items = Files::list_by_date_for_anchor('section:' . $item['id'], 0, 300, 'compact'); } // wrap it with some header if (is_array($items)) { $items = Skin::build_list($items); } if ($items) { $content .= '<h3><span>' . i18n::s('Files') . '</span></h3>' . $items; } // details to be displayed at page bottom $details[] = sprintf(i18n::nc('%d file', '%d files', $count), $count); } // info on related links include_once $context['path_to_root'] . 'links/links.php'; if ($count = Links::count_for_anchor('section:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::nc('%d link', '%d links', $count), $count); } // comments include_once $context['path_to_root'] . 'comments/comments.php'; if ($count = Comments::count_for_anchor('section:' . $item['id'], TRUE)) { $details[] = sprintf(i18n::nc('%d comment', '%d comments', $count), $count); } // describe attachments if (count($details)) { $content .= '<hr align="left" size=1" width="150">' . '<p style="margin: 3px 0;">' . sprintf(i18n::c('This section has %s'), join(', ', $details)) . '</p>'; } // assemble main content of this message $text = Skin::build_mail_content($headline, $content); // a set of links $menu = array(); // request access to the item if ($action == 'apply') { // call for action $link = $context['url_to_home'] . $context['url_to_root'] . Sections::get_url($item['id'], 'invite', Surfer::get_id()); $label = sprintf(i18n::c('Invite %s to participate'), Surfer::get_name()); $menu[] = Skin::build_mail_button($link, $label, TRUE); // link to user profile $link = Surfer::get_permalink(); $label = sprintf(i18n::c('View the profile of %s'), Surfer::get_name()); $menu[] = Skin::build_mail_button($link, $label, FALSE); // invite to visit the item } else { // call for action $link = Sections::get_permalink($item); if (!is_object($overlay) || !($label = $overlay->get_label('permalink_command', 'sections', FALSE))) { $label = i18n::c('View the section'); } $menu[] = Skin::build_mail_button($link, $label, TRUE); // link to the container if (is_object($anchor)) { $link = $context['url_to_home'] . $context['url_to_root'] . $anchor->get_url(); $menu[] = Skin::build_mail_button($link, $anchor->get_title(), FALSE); } } // finalize links $text .= Skin::build_mail_menu($menu); // the full message return $text; }
/** * reference another page at this site * * The function transforms a local reference (e.g;, [code][user=2][/code]) * to an actual link relative to the YACS directory (e.g., [code]users/view.php/2[/code]), * adds a title and, sometimes, set a description as well. * * @param string any string, maybe with a local reference in it * @return an array($url, $title, $description) or NULL * * @see images/view.php * @see links/edit.php * @see shared/codes.php */ public static function transform_reference($text) { global $context; // translate this reference to an internal link if (preg_match("/^\\[(article|section|file|image|category|user)=(.+?)\\]/i", $text, $matches)) { switch ($matches[1]) { // article link case 'article': if ($item = Articles::get($matches[2])) { return array(Articles::get_permalink($item), $item['title'], $item['introduction']); } return array('', $text, ''); // section link // section link case 'section': if ($item = Sections::get($matches[2])) { return array(Sections::get_permalink($item), $item['title'], $item['introduction']); } return array('', $text, ''); // file link // file link case 'file': if ($item = Files::get($matches[2])) { return array(Files::get_url($matches[2]), $item['title'] ? $item['title'] : str_replace('_', ' ', ucfirst($item['file_name']))); } return array('', $text, ''); // image link // image link case 'image': include_once $context['path_to_root'] . 'images/images.php'; if ($item = Images::get($matches[2])) { return array(Images::get_url($matches[2]), $item['title'] ? $item['title'] : str_replace('_', ' ', ucfirst($item['image_name']))); } return array('', $text, ''); // category link // category link case 'category': if ($item = Categories::get($matches[2])) { return array(Categories::get_permalink($item), $item['title'], $item['introduction']); } return array('', $text, ''); // user link // user link case 'user': if ($item = Users::get($matches[2])) { return array(Users::get_permalink($item), $item['full_name'] ? $item['full_name'] : $item['nick_name']); } return array('', $text, ''); } } return array('', $text, ''); }
// the title of the page $context['page_title'] = i18n::s('Lock'); // 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 (!isset($item['id'])) { include '../error.php'; // permission denied } elseif (!Sections::is_owned($item, $anchor) && !Surfer::is_associate()) { // anonymous users are invited to log in or to register if (!Surfer::is_logged()) { Safe::redirect($context['url_to_home'] . $context['url_to_root'] . 'users/login.php?url=' . urlencode(Sections::get_url($item['id'], 'lock'))); } // permission denied to authenticated user Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // an error occured } elseif (count($context['error'])) { } elseif (Sections::lock($item['id'], $item['locked'])) { // clear the cache Sections::clear($item); // redirect to the page Safe::redirect(Sections::get_permalink($item)); // failed operation } else { $context['text'] .= '<p>' . i18n::s('Operation has failed.') . '</p>'; } // render the skin render_skin();