/** * list selected files * * If variant is provided as a string, the functions looks for a script featuring this name. * E.g., for variant 'compact', the file 'files/layout_files_as_compact.php' is loaded. * If no file matches then the default 'files/layout_files.php' script is loaded. * * @param resource result of database query * @param string 'full', etc or object, i.e., an instance of Layout_Interface * @param string '?' or 'A', to support editors and to impersonate associates, where applicable * @return an array of $url => ($prefix, $label, $suffix, $icon) * * @see skins/skin_skeleton.php * @see files/fetch_all.php */ public static function &list_selected($result, $variant = 'compact') { global $context; // no result if (!$result) { $output = NULL; return $output; } // special layout if (is_object($variant)) { $output = $variant->layout($result); return $output; } // instanciate the provided name $layout = Layouts::new_($variant, 'file', false, true); // do the job $output = $layout->layout($result); return $output; }
$box['text'] .= Skin::build_list($box['bar'], 'menu_bar'); } // there is some box content if (trim($box['text'])) { $text .= Skin::build_box($title_label, $box['text'], 'header1', '_discussion'); } // if not at another follow-up page if (!$zoom_type || $zoom_type == 'sections') { // 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 $context['path_to_root'] . 'sections/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)) { 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')); } // list items by title
if ($context['with_friendly_urls'] == 'Y') { $prefix = $home . 'index.php/'; } elseif ($context['with_friendly_urls'] == 'R') { $prefix = $home; } else { $prefix = $home . '?page='; } $context['page_menu'] += Skin::navigate($home, $prefix, $stats['count'], THREADS_PER_PAGE, $page); } // page main content $cache_id = 'comments/index.php#text#' . $page; if (!($text = Cache::get($cache_id))) { // the first comment to list $offset = ($page - 1) * THREADS_PER_PAGE; // load the layout to use $layout = Layouts::new_('yabb', 'article'); // query the database and layout that stuff if (!($text = Comments::list_threads_by_date($offset, THREADS_PER_PAGE, $layout))) { $context['text'] .= '<p>' . i18n::s('No comment has been transmitted.') . '</p>'; } // we have an array to format if (is_array($text)) { $text =& Skin::build_list($text, 'rows'); } // cache, whatever changes, for 1 minute Cache::put($cache_id, $text, 'stable', 60); } $context['text'] .= $text; } // page tools if (Surfer::is_associate()) {
$prefix = $home; } else { $prefix = $home . '?page='; } $menu = array_merge($menu, Skin::navigate($home, $prefix, $count, $items_per_page, $page)); // add a menu at the bottom $text .= Skin::build_list($menu, 'menu_bar'); } // make a box if ($items) { $text .= Skin::build_box('', $items, 'header1', 'sections'); } // associates may list specific sections as well if ($page == 1 && Surfer::is_associate()) { // load the layout to use $layout = Layouts::new_('yahoo', 'section'); $layout->set_variant(20); // show more elements at the site map // query the database and layout that stuff if ($items = Sections::list_inactive_by_title_for_anchor(NULL, 0, 50, $layout)) { // we have an array to format if (is_array($items)) { $items = Skin::build_list($items, '2-columns'); } // displayed as another page section $text .= Skin::build_box(i18n::s('Other sections'), $items, 'header1', 'other_sections'); } } // cache this to speed subsequent queries Cache::put($cache_id, $text, 'sections'); }
// 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('files/list.php?id=' . $anchor->get_reference())); } // permission denied to authenticated user Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // stop hackers } elseif ($page > 10) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); // display the index } else { // insert anchor prefix and suffix, plus any available icon $context['prefix'] .= $anchor->get_prefix(); $layout = Layouts::new_('decorated', 'file'); // provide anthor information to layout if (is_object($layout)) { $layout->set_focus($anchor->get_reference()); } // the maximum number of files per page if (is_object($layout)) { $items_per_page = $layout->items_per_page(); } else { $items_per_page = FILES_PER_PAGE; } // the first file to list $offset = ($page - 1) * $items_per_page; if (is_object($layout) && method_exists($layout, 'set_offset')) { $layout->set_offset($offset); }
// load the skin load_skin('site_taxonomy'); // the title of the page $context['page_title'] = i18n::s('Categories'); // count categories in the database $stats = Categories::stat_for_anchor(NULL); // stop hackers if ($page > 1 && ($page - 1) * CATEGORIES_PER_PAGE > $stats['count']) { Safe::header('Status: 401 Unauthorized', TRUE, 401); Logger::error(i18n::s('You are not allowed to perform this operation.')); } else { // page main content $cache_id = 'categories/index.php#text#' . $page; if (!($text = Cache::get($cache_id))) { // do it the Yahoo! style $layout = Layouts::new_('yahoo', 'category'); // the list of active categories $offset = ($page - 1) * CATEGORIES_PER_PAGE; if (!($text = Categories::list_by_title_for_anchor(NULL, $offset, CATEGORIES_PER_PAGE, $layout))) { $text = '<p>' . i18n::s('No category has been created yet.') . '</p>'; } // we have an array to format if (is_array($text)) { $text =& Skin::build_list($text, '2-columns'); } // navigation commands for categories, if necessary if ($stats['count'] > CATEGORIES_PER_PAGE) { $menu = array('_count' => Skin::build_number($stats['count'], i18n::s('categories'))); $home = 'categories/'; if ($context['with_friendly_urls'] == 'Y') { $prefix = $home . 'index.php/';
$fields[] = $field; } } // recipients $label = i18n::s('Invite participants'); $input = ''; if (Sections::is_owned($item, $anchor, TRUE)) { // roles are defined as per invitation settings if (is_callable(array($overlay, 'get_invite_roles'))) { $input .= $overlay->get_invite_roles(); } elseif ($item['active'] != 'N') { $input .= '<p><input type="radio" name="provide_credentials" value="N" checked="checked" /> ' . i18n::s('to review public content (watchers)') . BR . '<input type="radio" name="provide_credentials" value="Y" /> ' . i18n::s('to manage public and private content (editors)') . '</p>' . '<hr/>'; } } // get a customized layout $layout = Layouts::new_('mail', 'user'); // avoid links to this page if (is_object($layout) && is_callable(array($layout, 'set_variant'))) { $layout->set_variant('unchecked'); } // pre-invite someone $invited = ''; if (isset($_REQUEST['invited']) && ($user = Users::get($_REQUEST['invited']))) { $invited = $user['nick_name']; } else { $handle = $item['anchor']; while ($handle && ($parent = Anchors::get($handle))) { $handle = $parent->get_parent(); // invitation to a private page should be limited to editors if ($item['active'] == 'N') { if ($editors = Members::list_editors_for_member($parent->get_reference(), 0, 1000, $layout)) {
/** * list selected sections * * If variant is provided as a string, the functions looks for a script featuring this name. * E.g., for variant 'compact', the file 'sections/layout_sections_as_compact.php' is loaded. * If no file matches then the default 'sections/layout_sections.php' script is loaded. * * @param resource result of database query * @param string 'full', etc or object, i.e., an instance of Layout_Interface * @return NULL on error, else an ordered array with $url => ($prefix, $label, $suffix, $icon) * */ public static function &list_selected($result, $variant = 'full') { global $context; // no result if (!$result) { $output = NULL; return $output; } // special layouts if (is_object($variant)) { $output = $variant->layout($result); return $output; } // get a layout $layout = Layouts::new_($variant, 'section', false, true); // do the job $output = $layout->layout($result); return $output; }
if ($cur_article->allows('modification')) { $embedded = NULL; } else { $embedded = Codes::list_embedded($item['description']); } // build a complete box $box = array('bar' => array(), 'text' => ''); // count the number of files in this article if ($count = Files::count_for_anchor('article:' . $item['id'], FALSE, $embedded)) { $attachments_count += $count; if ($count > 20) { $box['bar'] += array('_count' => sprintf(i18n::ns('%d file', '%d files', $count), $count)); } // compact list of files if ($compact = Articles::has_option('files_as_compact', $anchor, $item)) { $layout = Layouts::new_('compact', 'file'); $layout->set_focus('article:' . $item['id']); // standard list of files } else { $layout = 'article:' . $item['id']; } // list files by date (default) or by title (option files_by_title) $offset = ($zoom_index - 1) * FILES_PER_PAGE; if ($cur_article->has_option('files_by') == 'title') { $items = Files::list_by_title_for_anchor('article:' . $item['id'], 0, 300, $layout, $embedded); } else { $items = Files::list_by_date_for_anchor('article:' . $item['id'], 0, 300, $layout, $embedded); } // actually render the html if (is_array($items)) { $box['text'] .= Skin::build_list($items, $compact ? 'compact' : 'decorated');
if ($count) { $box['bottom'] += array('_count' => sprintf(i18n::ns('%d section', '%d sections', $count), $count)); } // navigation commands for articles $home = Users::get_permalink($item); $prefix = Users::get_url($item['id'], 'navigate', 'sections'); $box['bottom'] = array_merge($box['bottom'], Skin::navigate($home, $prefix, $count, SECTIONS_PER_PAGE, $zoom_index)); // append a menu bar before the list $box['top'] = array_merge($box['top'], $box['bottom']); if (count($box['top'])) { $box['text'] .= Skin::build_list($box['top'], 'menu_bar'); } // compute offset from list beginning $offset = ($zoom_index - 1) * SECTIONS_PER_PAGE; // list assigned by title $layout = Layouts::new_('rights', 'section'); $layout->set_focus($item['id']); $items =& Sections::list_by_date_for_user($item['id'], $offset, SECTIONS_PER_PAGE, $layout); if (is_array($items)) { $box['text'] .= Skin::build_list($items, 'compact'); } elseif ($items) { $box['text'] .= $items; } // append a menu bar below the list if (count($box['bottom']) > 1) { $box['text'] .= Skin::build_list($box['bottom'], 'menu_bar'); } // one box if ($box['text']) { $sections .= $box['text']; }
} elseif (is_array($items)) { $box['text'] .= Skin::build_list($items, '2-columns'); } elseif (is_string($items)) { $box['text'] .= $items; } if ($box['text']) { $context['text'] .= Skin::build_box('', $box['text']); } // // the articles section // // select a layout if (!isset($item['articles_layout'])) { $layout = NULL; } else { $layout = Layouts::new_($item['articles_layout'], 'article'); } // 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; } // list articles by date (default) or by title (option 'articles_by_title') 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'); // actually render the html
/** * 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; }
$panels[] = array('categories', i18n::s('Categories'), 'categories_panel', $box['text']); } } // // users associated to this category // // the list of related users if not at another follow-up page if ((!$zoom_type || $zoom_type == 'users') && (!isset($item['users_layout']) || $item['users_layout'] != 'none')) { // build a complete box $box = array('bar' => array(), 'text' => ''); // select a layout if (!isset($item['users_layout']) || !$item['users_layout']) { include_once '../users/layout_users.php'; $layout = new Layout_users(); } else { $layout = Layouts::new_($item['users_layout'], 'user'); } // count the number of users in this category $count = Members::count_users_for_anchor('category:' . $item['id']); // notify members if ($count > 1 && Surfer::is_associate()) { Skin::define_img('CATEGORIES_EMAIL_IMG', 'categories/email.gif'); $box['bar'] += array(Categories::get_url($item['id'], 'mail') => CATEGORIES_EMAIL_IMG . i18n::s('Notify members')); } // spread the list over several pages if ($count > USERS_LIST_SIZE) { $box['bar'] += array('_count' => sprintf(i18n::ns('%d user', '%d users', $count), $count)); } // navigation commands for users $home = Categories::get_permalink($item); $prefix = Categories::get_url($item['id'], 'navigate', 'users');
// the main hook if (is_callable(array('Hooks', 'include_scripts'))) { $context['text'] .= Hooks::include_scripts('index.php'); } // the list of most recent articles switch ($context['root_articles_layout']) { case 'compact': case 'decorated': $layout = Layouts::new_($context['root_articles_layout'], 'article'); break; case 'no_articles': $layout = NULL; break; default: // load layout, if one exists, for the home page $layout = Layouts::new_($context['root_articles_layout'], 'article', true); /*if(is_readable($context['path_to_root'].'skins/layout_home_articles_as_'.$context['root_articles_layout'].'.php')) { $name = 'layout_home_articles_as_'.$context['root_articles_layout']; include_once $context['path_to_root'].'skins/'.$name.'.php'; $layout = new $name; // no layout to use } else { // useful warning for associates if(Surfer::is_associate()) Logger::error(sprintf(i18n::s('Warning: No script exists for the customized layout %s'), $context['root_articles_layout'])); // load default layout include_once $context['path_to_root'].'skins/layout_home_articles_as_daily.php'; $layout = new Layout_home_articles_as_daily();
$output['success'] = 'false'; break; } // check surfer's rights if (is_object($anchor) && !$anchor->allows('creation') || $anchor_id == 'index' && !Surfer::is_associate()) { $output['success'] = 'false'; break; } // create obj interface $newitem = new $type(); // try to post if ($output['success'] = $newitem->post($_REQUEST['anchor'], $_REQUEST['title'])) { $output['title'] = $newitem->get_title(); $output['ref'] = $newitem->get_reference(); // ask menu rendering for this new entry $l = Layouts::new_('tree_manager', $type); if (isset($_REQUEST['variant'])) { $l->set_variant($_REQUEST['variant']); } $output['menu'] = $l->get_interactive_menu(); } break; // delete the anchor with the given reference // delete the anchor with the given reference case 'delete': // reference to anchor is mandatory if (!isset($_REQUEST['anchor']) || !$_REQUEST['anchor']) { die_on_invalid(); } // get obj interface if (!($to_delete = Anchors::get($_REQUEST['anchor']))) {
$prefix = Sections::get_url($item['id'], 'manage', 'articles'); $menu = array_merge($menu, Skin::navigate($home, $prefix, $count, $items_per_page, $zoom_index)); } if (count($menu)) { $text .= Skin::build_list($menu, 'menu_bar'); } } // diplay in a separate panel if (trim($text)) { $panels[] = array('articles', i18n::s('Pages'), 'articles_panel', $text); } // one tab for sections // $text = ''; // managed sections $layout = Layouts::new_('manage', 'section'); // 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 = SECTIONS_PER_PAGE; } // list content $offset = ($zoom_index - 1) * $items_per_page; if ($items =& Sections::list_by_title_for_anchor('section:' . $item['id'], $offset, $items_per_page, $layout)) { // splash $text .= Skin::build_block(i18n::s('Select items you want to manage, and click some button at the bottom of the page.'), 'introduction');