if ($context['root_articles_layout'] == 'alistapart') { $input .= ' checked="checked"'; } $input .= '/>alistapart - ' . i18n::s('Display only the most recent published page. Previous articles may be accessed through a menu. This layout is suitable for sites with a low number of heavy publications.') . ' ' . Skin::build_link('skins/layout_home_articles_as_alistapart.jpg', i18n::s('Preview'), 'open') . BR; // custom $input .= '<input type="radio" name="root_articles_layout" value="custom" id="custom_articles_layout"'; if ($context['root_articles_layout'] == 'custom') { $input .= ' checked="checked"'; } $input .= '/> ' . sprintf(i18n::s('Use the customized layout %s'), '<input type="text" name="home_custom_layout" value="' . encode_field($custom_layout) . '" size="32" onfocus="$(\'#custom_articles_layout\').attr(\'checked\', \'checked\')" />') . BR; // no article $input .= '<p><input type="radio" name="root_articles_layout" value="no_articles"'; if ($context['root_articles_layout'] == 'no_articles') { $input .= ' checked="checked"'; } $input .= '/>' . sprintf(i18n::s('Do not list recent pages. The layout of the front page is solely based on a %s, on %s, plus %s.'), Skin::build_link(Sections::get_url('covers'), i18n::s('cover article'), 'shortcut'), Skin::build_link('sections/', i18n::s('the site map'), 'shortcut'), Skin::build_link(Sections::get_url('gadget_boxes'), i18n::s('gadget boxes'), 'shortcut')) . '</p>'; // number of entries at the front page if (!isset($context['root_articles_count_at_home'])) { $context['root_articles_count_at_home'] = ''; } $input .= '<p>' . sprintf(i18n::s('Display %s articles at the front page. Put a number if you wish to override the default value for the selected layout.'), '<input type="text" name="root_articles_count_at_home" size="2" value="' . encode_field($context['root_articles_count_at_home']) . '" maxlength="4" />') . '</p>'; $fields[] = array($label, $input); // build the form $main .= Skin::build_form($fields); $fields = array(); // the extra panel // $extra = ''; // featured articles can be either a static or an animated list $label = i18n::s('Featured'); if (!isset($context['root_featured_count']) || $context['root_featured_count'] < 1 || $context['root_featured_count'] > 7) {
} else { $context['text'] .= '<p>' . i18n::s('No message has been sent') . '</p>'; } // back to the section page $menu = array(); $menu[] = Skin::build_link(Sections::get_permalink($item), i18n::s('Done'), 'button'); $context['text'] .= Skin::finalize_list($menu, 'assistant_bar'); // a form to send an invitation to several people } else { // the form to send a message $context['text'] .= '<form method="post" action="' . $context['script_url'] . '" onsubmit="return validateDocumentPost(this)" id="main_form"><div>'; $fields = array(); // additional fields for anonymous surfers if (!Surfer::is_logged()) { // splash $login_url = $context['url_to_root'] . 'users/login.php?url=' . urlencode(Sections::get_url($item['id'], 'invite')); $context['text'] .= '<p>' . sprintf(i18n::s('If you have previously registered to this site, please %s. Then the server will automatically put your name and address in following fields.'), Skin::build_link($login_url, i18n::s('authenticate'))) . "</p>\n"; // the name, if any $label = i18n::s('Your name'); $input = '<input type="text" name="edit_name" size="45" maxlength="128" accesskey="n" value="' . encode_field(Surfer::get_name(' ')) . '" />'; $hint = i18n::s('Let us a chance to know who you are'); $fields[] = array($label, $input, $hint); // the address, if any $label = i18n::s('Your e-mail address'); $input = '<input type="text" name="edit_address" size="45" maxlength="128" accesskey="a" value="' . encode_field(Surfer::get_email_address()) . '" />'; $hint = i18n::s('Put your e-mail address to receive feed-back'); $fields[] = array($label, $input, $hint); // stop robots if ($field = Surfer::get_robot_stopper()) { $fields[] = $field; }
// access previous versions, if any if ($has_versions) { Skin::define_img('SECTIONS_VERSIONS_IMG', 'sections/versions.gif'); $context['page_tools'][] = Skin::build_link(Versions::get_url('section:' . $item['id'], 'list'), SECTIONS_VERSIONS_IMG . i18n::s('Versions'), 'basic', i18n::s('Restore a previous version if necessary')); } // lock the page if (!isset($item['locked']) || $item['locked'] == 'N') { Skin::define_img('SECTIONS_LOCK_IMG', 'sections/lock.gif'); $context['page_tools'][] = Skin::build_link(Sections::get_url($item['id'], 'lock'), SECTIONS_LOCK_IMG . i18n::s('Lock'), 'basic'); } else { Skin::define_img('SECTIONS_UNLOCK_IMG', 'sections/unlock.gif'); $context['page_tools'][] = Skin::build_link(Sections::get_url($item['id'], 'lock'), SECTIONS_UNLOCK_IMG . i18n::s('Unlock'), 'basic'); } // delete the page Skin::define_img('SECTIONS_DELETE_IMG', 'sections/delete.gif'); $context['page_tools'][] = Skin::build_link(Sections::get_url($item['id'], 'delete'), SECTIONS_DELETE_IMG . i18n::s('Delete this section'), 'basic'); // manage content if ($has_content) { Skin::define_img('SECTIONS_MANAGE_IMG', 'sections/manage.gif'); $context['page_tools'][] = Skin::build_link(Sections::get_url($item['id'], 'manage'), SECTIONS_MANAGE_IMG . i18n::s('Manage content'), 'basic', i18n::s('Bulk operations')); } // duplicate command provided to container owners Skin::define_img('SECTIONS_DUPLICATE_IMG', 'sections/duplicate.gif'); $context['page_tools'][] = Skin::build_link(Sections::get_url($item['id'], 'duplicate'), SECTIONS_DUPLICATE_IMG . i18n::s('Duplicate this section')); } // use date of last modification into etag computation if (isset($item['edit_date'])) { $context['page_date'] = $item['edit_date']; } // render the skin render_skin();
/** * get permanent address * * @param array page attributes * @return string the permanent web address to this item, relative to the installation path */ public static function get_permalink($item) { global $context; // sanity check if (!isset($item['id'])) { throw new Exception('bad input parameter'); } // get host to this page $vhost = Sections::get_vhost('section:' . $item['id']); // if top-level section with bounded vhost, provide a root link if ((!isset($item['anchor']) || !$item['anchor']) && file_exists($context['path_to_root'] . 'parameters/virtual_' . $item['nick_name'] . '.include.php')) { return $vhost; } // absolute link return $vhost . Sections::get_url($item['id'], 'view', $item['title'], isset($item['nick_name']) ? $item['nick_name'] : ''); }
} // content assistant if (Surfer::is_associate()) { $commands[] = sprintf(i18n::s('%s - create blogs, wikis, forums, and more'), Skin::build_link('help/populate.php', i18n::s('Content Assistant'), 'basic')); } // site map if (Surfer::is_associate()) { $commands[] = sprintf(i18n::s('%s - you may enhance %s of some sections'), Skin::build_link('sections/', i18n::s('Site map')), '<a href="../behaviors/">' . i18n::s('behaviors') . '</a>'); } // template pages if (Surfer::is_associate()) { $commands[] = sprintf(i18n::s('%s - some have %s'), Skin::build_link(Sections::get_url('templates'), i18n::s('Template pages')), '<a href="../overlays/">' . i18n::s('overlays') . '</a>'); } // global pages if (Surfer::is_associate()) { $commands[] = sprintf(i18n::s('%s, including: %s, %s, %s and %s'), Skin::build_link(Sections::get_url('global'), i18n::s('Global pages')), Skin::build_link(Articles::get_url('cover'), i18n::s('the cover page')), Skin::build_link(Articles::get_url('menu'), i18n::s('Menu')), Skin::build_link(Articles::get_url('about'), i18n::s('About this site')), Skin::build_link(Articles::get_url('privacy'), i18n::s('Privacy statement'))); } // import some content if (Surfer::is_associate()) { $commands[] = sprintf(i18n::s('%s - exported from another server'), Skin::build_link('control/import.php', i18n::s('Import XML content'), 'basic')); } // upload some CSV if (Surfer::is_associate()) { $commands[] = sprintf(i18n::s('%s - update the database'), Skin::build_link('tables/import.php', i18n::s('Upload a .CSV file'), 'basic')); } // available feeds $commands[] = sprintf(i18n::s('%s - all feeds available (RSS, ATOM)'), Skin::build_link('feeds/', i18n::s('Information channels'), 'basic')); // web services $commands[] = sprintf(i18n::s('%s - connect remote computers through XML-RPC or REST'), Skin::build_link('services/', i18n::s('Web services'), 'basic')); // codes $commands[] = sprintf(i18n::s('%s - codes you can use to beautify your pages'), Skin::build_link('codes/', i18n::s('Codes'), 'basic'));
/** * 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; }
/** * get the url to display the main page for this anchor * * @see shared/anchor.php * * @param string the targeted action ('view', 'print', 'edit', 'delete', ...) * @return an anchor to the viewing script */ function get_url($action = 'view') { // sanity check if (!isset($this->item['id'])) { return NULL; } switch ($action) { // view comments case 'comments': if ($this->has_option('view_as_tabs', FALSE)) { return $this->get_url() . '#_discussion'; } return Sections::get_url($this->item['id'], 'view', $this->item['title'], $this->item['nick_name']) . '#comments'; // list of files // list of files case 'files': return $this->get_url() . '#_attachments'; // list of links // list of links case 'links': return $this->get_url() . '#_attachments'; // another action // another action default: return Sections::get_url($this->item['id'], $action, $this->item['title'], $this->item['nick_name']); } }
/** * 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; }
} else { Skin::define_img('SECTIONS_UNLOCK_IMG', 'sections/unlock.gif'); $context['page_tools'][] = Skin::build_link(Sections::get_url($item['id'], 'lock'), SECTIONS_UNLOCK_IMG . i18n::s('Unlock'), 'basic'); } // delete the page if ($cur_section->allows('deletion')) { Skin::define_img('SECTIONS_DELETE_IMG', 'sections/delete.gif'); if (!is_object($overlay) || !($label = $overlay->get_label('delete_command', 'sections'))) { $label = i18n::s('Delete this section'); } $context['page_tools'][] = Skin::build_link(Sections::get_url($item['id'], 'delete'), SECTIONS_DELETE_IMG . $label, 'basic'); } // manage content if ($has_content) { Skin::define_img('SECTIONS_MANAGE_IMG', 'sections/manage.gif'); $context['page_tools'][] = Skin::build_link(Sections::get_url($item['id'], 'manage'), SECTIONS_MANAGE_IMG . i18n::s('Manage content'), 'basic', i18n::s('Bulk operations')); } // duplicate command provided to container owners if (Sections::is_owned(NULL, $anchor) || Surfer::is_associate()) { Skin::define_img('SECTIONS_DUPLICATE_IMG', 'sections/duplicate.gif'); $context['page_tools'][] = Skin::build_link(Sections::get_url($item['id'], 'duplicate'), SECTIONS_DUPLICATE_IMG . i18n::s('Duplicate this section')); } } // commands for associates if (Surfer::is_associate()) { Skin::define_img('SECTIONS_DUPLICATE_IMG', 'sections/duplicate.gif'); $context['page_tools'][] = Skin::build_link(Sections::get_url($item['id'], 'export'), SECTIONS_DUPLICATE_IMG . i18n::s('Export this section')); } } // render the skin render_skin();
// options tab // $text = ''; // provide information to section owner, and to editors of parent section if (Sections::is_owned($item, $anchor) || Surfer::is_associate()) { // owner if (isset($item['owner_id'])) { $label = i18n::s('Owner'); if ($owner = Users::get($item['owner_id'])) { $input = Users::get_link($owner['full_name'], $owner['email'], $owner['id']); } else { $input = i18n::s('No owner has been found.'); } // only real owner can delegate to another person if (Sections::is_owned($item, $anchor, TRUE) || Surfer::is_associate()) { $input .= ' <span class="details">' . Skin::build_link(Sections::get_url($item['id'], 'own'), i18n::s('Change'), 'button') . '</span>'; } $fields[] = array($label, $input); } } // the active flag: Yes/public, Restricted/logged, No/associates --we don't care about inheritance, to enable security changes afterwards $label = i18n::s('Access'); $input = Skin::build_active_set_input($item); $hint = Skin::build_active_set_hint($anchor); $fields[] = array($label, $input, $hint); // locked: Yes / No $label = i18n::s('Locker'); $input = '<input type="radio" name="locked" value="N"'; if (!isset($item['locked']) || $item['locked'] != 'Y') { $input .= ' checked="checked"'; }
// page title if (isset($item['title'])) { $context['page_title'] = sprintf(i18n::s('Owner of %s'), $item['title']); } // 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 (!$permitted) { // 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'], 'own'))); } // permission denied to authenticated user Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // 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);
// all commands $menu = array(); $menu[] = $options; // back to section $menu[] = Skin::build_link(Sections::get_permalink($item), i18n::s('Cancel'), 'span'); // finalize the menu $text .= Skin::finalize_list($menu, 'menu_bar'); // count the number of articles in this section $menu = array(); if ($count = Sections::count_for_anchor('section:' . $item['id'])) { if ($count > min(5, $items_per_page)) { $menu = array_merge($menu, array('_count' => sprintf(i18n::ns('%d section', '%d sections', $count), $count))); } // navigation commands for sections $home = Sections::get_url($item['id'], 'manage'); $prefix = Sections::get_url($item['id'], 'manage', 'sections'); $menu = array_merge($menu, Skin::navigate($home, $prefix, $count, $items_per_page, $zoom_index)); } if (count($menu)) { $text .= Skin::build_list($menu, 'menu_bar'); } } // display in a separate panel if (trim($text)) { $panels[] = array('sections', i18n::s('Sections'), 'sections_panel', $text); } // assemble all tabs // if (count($panels)) { $context['text'] .= Skin::build_tabs($panels); } else {
// the title $text .= ' <title>' . encode_field(strip_tags($context['channel_title'])) . "</title>\n"; // the body $text .= '</head>' . "\n" . '<body>' . "\n"; // the main rss feed of this site $text .= ' <outline type="rss" text="' . encode_field($context['channel_title']) . '" xmlUrl="' . $context['url_to_home'] . $context['url_to_root'] . Feeds::get_url('rss') . '"' . " />\n"; // full articles $text .= ' <outline type="rss" text="' . encode_field(i18n::c('Pages with full content') . $suffix) . '" xmlUrl="' . $context['url_to_home'] . $context['url_to_root'] . Feeds::get_url('articles') . '"' . " />\n"; // newest comments $text .= ' <outline type="rss" text="' . encode_field(i18n::c('Comments') . $suffix) . '" xmlUrl="' . $context['url_to_home'] . $context['url_to_root'] . Feeds::get_url('comments') . '"' . " />\n"; // the file rss feed for podcasting, etc. $text .= ' <outline type="rss" text="' . encode_field(i18n::c('Files and podcasts') . $suffix) . '" xmlUrl="' . $context['url_to_home'] . $context['url_to_root'] . Feeds::get_url('files') . '"' . " />\n"; // one feed per section if ($items = Sections::list_by_title_for_anchor(NULL, 0, COMPACT_LIST_SIZE, 'raw')) { foreach ($items as $id => $attributes) { $text .= ' <outline type="rss" text="' . encode_field(strip_tags($attributes['title']) . $suffix) . '" xmlUrl="' . $context['url_to_home'] . $context['url_to_root'] . Sections::get_url($id, 'feed') . '"' . " />\n"; } } // one feed per category if ($items = Categories::list_by_date(0, COMPACT_LIST_SIZE, 'raw')) { foreach ($items as $id => $attributes) { $text .= ' <outline type="rss" text="' . encode_field(strip_tags($attributes['title']) . $suffix) . '" xmlUrl="' . $context['url_to_home'] . $context['url_to_root'] . Categories::get_url($id, 'feed') . '"' . " />\n"; } } // one feed per user if ($items = Users::list_by_posts(0, COMPACT_LIST_SIZE, 'raw')) { foreach ($items as $id => $attributes) { $text .= ' <outline type="rss" text="' . encode_field(strip_tags($attributes['nick_name']) . $suffix) . '" xmlUrl="' . $context['url_to_home'] . $context['url_to_root'] . Users::get_url($id, 'feed') . '"' . " />\n"; } } // the postamble
/** * list sections * * @param resource the SQL result * @return a string to be displayed * * @see layouts/layout.php **/ function layout($result) { global $context; // we return some text $text = ''; // empty list if (!SQL::count($result)) { return $text; } // no hovering label $href_title = ''; // we build an array for the skin::build_tabs() function $panels = array(); // process all items in the list while ($item = SQL::fetch($result)) { // get the main anchor $anchor = Anchors::get($item['anchor']); // get the related overlay, if any $overlay = Overlay::load($item, 'section:' . $item['id']); // 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']); } // panel content $text = ''; // insert anchor prefix if (is_object($anchor)) { $text .= $anchor->get_prefix(); } // the introduction text, if any if (is_object($overlay)) { $text .= Skin::build_block($overlay->get_text('introduction', $item), 'introduction'); } elseif (isset($item['introduction']) && trim($item['introduction'])) { $text .= Skin::build_block($item['introduction'], 'introduction'); } // get text related to the overlay, if any if (is_object($overlay)) { $text .= $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'))) { $text .= Skin::build_block($label, 'title'); } // beautify the target page $text .= Skin::build_block($description, 'description', '', $item['options']); } // delegate rendering to the overlay, where applicable if (is_object($content_overlay) && ($overlaid = $content_overlay->render('articles', 'section:' . $item['id'], 1))) { $text .= $overlaid; // regular rendering } elseif (!isset($item['articles_layout']) || $item['articles_layout'] != 'none') { // select a layout if (!isset($item['articles_layout']) || !$item['articles_layout']) { include_once '../articles/layout_articles.php'; $layout = new Layout_articles(); } else { $layout = Layouts::new_($item['articles_layout'], 'article'); } // avoid links to this page if (is_object($layout) && is_callable(array($layout, 'set_variant'))) { $layout->set_focus('section:' . $item['id']); } // the maximum number of articles per page if (is_object($layout)) { $items_per_page = $layout->items_per_page(); } else { $items_per_page = ARTICLES_PER_PAGE; } // sort and list articles $offset = 0; if (preg_match('/\\barticles_by_([a-z_]+)\\b/i', $item['options'], $matches)) { $order = $matches[1]; } elseif (is_callable(array($layout, 'items_order'))) { $order = $layout->items_order(); } else { $order = 'edition'; } // create a box $box = array('top_bar' => array(), 'text' => '', 'bottom_bar' => array()); // the command to post a new page //if(Articles::allow_creation($item, $anchor)) { if ($anchor->allows('creation', 'article')) { Skin::define_img('ARTICLES_ADD_IMG', 'articles/add.gif'); $url = 'articles/edit.php?anchor=' . urlencode('section:' . $item['id']); if (is_object($content_overlay) && ($label = $content_overlay->get_label('new_command', 'articles'))) { } else { $label = ARTICLES_ADD_IMG . i18n::s('Add a page'); } $box['top_bar'] += array($url => $label); } // list pages under preparation $this_section = new section(); $this_section->load_by_content($item, $anchor); if ($this_section->is_assigned()) { if ($order == 'publication' && ($items =& Articles::list_for_anchor_by('draft', 'section:' . $item['id'], 0, 20, 'compact'))) { if (is_array($items)) { $items = Skin::build_list($items, 'compact'); } $box['top_bar'] += array('_draft' => Skin::build_sliding_box(i18n::s('Draft pages'), $items)); } } // top menu if ($box['top_bar']) { $box['text'] .= Skin::build_list($box['top_bar'], 'menu_bar'); } // get pages $items =& Articles::list_for_anchor_by($order, 'section:' . $item['id'], $offset, $items_per_page, $layout); // items in the middle if (is_array($items) && isset($item['articles_layout']) && $item['articles_layout'] == 'compact') { $box['text'] .= Skin::build_list($items, 'compact'); } elseif (is_array($items)) { $box['text'] .= Skin::build_list($items, 'decorated'); } elseif (is_string($items)) { $box['text'] .= $items; } // no navigation bar with alistapart if (!isset($item['articles_layout']) || $item['articles_layout'] != 'alistapart') { // count the number of articles in this section if ($count = Articles::count_for_anchor('section:' . $item['id'])) { if ($count > 20) { $box['bottom_bar'] += array('_count' => sprintf(i18n::ns('%d page', '%d pages', $count), $count)); } // navigation commands for articles $home = Sections::get_permalink($item); $prefix = Sections::get_url($item['id'], 'navigate', 'articles'); $box['bottom_bar'] += Skin::navigate($home, $prefix, $count, $items_per_page, 1); } } // bottom menu if ($box['bottom_bar']) { $box['text'] .= Skin::build_list($box['bottom_bar'], 'menu_bar'); } // there is some box content if ($box['text']) { $text .= $box['text']; } } // layout sub-sections if (!isset($item['sections_layout']) || $item['sections_layout'] != 'none') { // select a layout if (!isset($item['sections_layout']) || !$item['sections_layout']) { include_once 'layout_sections.php'; $layout = new Layout_sections(); } else { $layout = Layouts::new_($item['sections_layout'], 'section'); } // the maximum number of sections per page if (is_object($layout)) { $items_per_page = $layout->items_per_page(); } else { $items_per_page = SECTIONS_PER_PAGE; } // build a complete box $box = array('top_bar' => array(), 'text' => '', 'bottom_bar' => array()); // the command to add a new section //if(Sections::allow_creation($item, $anchor)) { if ($anchor->allows('creation', 'section')) { Skin::define_img('SECTIONS_ADD_IMG', 'sections/add.gif'); $box['top_bar'] += array('sections/edit.php?anchor=' . urlencode('section:' . $item['id']) => SECTIONS_ADD_IMG . i18n::s('Add a section')); } // top menu if ($box['top_bar']) { $box['text'] .= Skin::build_list($box['top_bar'], 'menu_bar'); } // list items by family then title $offset = 0 * $items_per_page; $items = Sections::list_by_title_for_anchor('section:' . $item['id'], $offset, $items_per_page, $layout, TRUE); // actually render the html for the section if (is_array($items) && is_string($item['sections_layout']) && $item['sections_layout'] == 'compact') { $box['text'] .= Skin::build_list($items, 'compact'); } elseif (is_array($items)) { $box['text'] .= Skin::build_list($items, 'decorated'); } elseif (is_string($items)) { $box['text'] .= $items; } // count the number of subsections if ($count = Sections::count_for_anchor('section:' . $item['id'])) { if ($count > 20) { $box['bottom_bar'] = array('_count' => sprintf(i18n::ns('%d section', '%d sections', $count), $count)); } // navigation commands for sections $home = Sections::get_permalink($item); $prefix = Sections::get_url($item['id'], 'navigate', 'sections'); $box['bottom_bar'] += Skin::navigate($home, $prefix, $count, $items_per_page, 1); } // bottom menu if ($box['bottom_bar']) { $box['text'] .= Skin::build_list($box['bottom_bar'], 'menu_bar'); } // there is some box content if ($box['text']) { $text .= $box['text']; } } // ensure that the surfer can change content if (Sections::allow_modification($item, $anchor)) { // view or modify this section $menu = array(); $menu[] = Skin::build_link(Sections::get_permalink($item), i18n::s('View the sub-section'), 'span'); if (!is_object($overlay) || !($label = $overlay->get_label('edit_command', 'sections'))) { $label = i18n::s('Edit this sub-section'); } $menu[] = Skin::build_link(Sections::get_url($item['id'], 'edit'), $label, 'span'); $text .= Skin::finalize_list($menu, 'menu_bar'); } // assemble the full panel $panels[] = array('stt' . $item['id'], ucfirst(Skin::strip($item['title'], 30)), 'stc' . $item['id'], $text); } // format tabs if ($this->has_variant('as_array')) { $text = $panels; } else { $text = Skin::build_tabs($panels); } // end of processing SQL::free($result); return $text; }