Пример #1
0
 /**
  * list childs of this anchor, with or without type filters
  * 
  * @param string set of desired childs (articles, sections...) separted by comma, or "all" keyword
  * @param int offset to start listing
  * @param int the maximum of items returned per type
  * @param mixed string or object the layout to use
  * @return an array of array with raw items sorted by type
  */
 function get_childs($filter = 'all', $offset = 0, $max = 50, $layout = 'raw')
 {
     // we return a array
     $childs = array();
     // sub-categories
     if ($filter == 'all' || preg_match('/\\bcategor(y|ies)\\b/i', $filter)) {
         $childs['category'] = Categories::list_by_title_for_anchor($this, $offset, $max, $layout);
     }
     // related articles
     if ($filter == 'all' || preg_match('/\\barticles?\\b/i', $filter)) {
         $childs['article'] = Members::list_articles_by_title_for_anchor($this->get_reference(), $offset, $max, $layout);
     }
     // related sections
     if ($filter == 'all' || preg_match('/\\bsections?\\b/i', $filter)) {
         $childs['section'] = Members::list_sections_by_title_for_anchor($this->get_reference(), $offset, $max, $layout);
     }
     // related users
     if ($filter == 'all' || preg_match('/\\busers?\\b/i', $filter)) {
         $childs['user'] = Members::list_users_by_name_for_anchor($this->get_reference(), $offset, $max, $layout);
     }
     // files
     if ($filter == 'all' || preg_match('/\\bfiles?\\b/i', $filter)) {
         $childs['file'] = Files::list_by_title_for_anchor($this->get_reference(), $offset, $max, $layout);
     }
     return $childs;
 }
Пример #2
0
     $items = Categories::list_by_title_for_anchor('category:' . $item['id'], 0, 50);
 } else {
     $items = Categories::list_by_date_for_anchor('category:' . $item['id'], 0, 50);
 }
 // actually render the html for the section
 if ($items) {
     $context['text'] .= $section . Skin::build_list($items, 'decorated');
 }
 //
 // the section of linked articles
 //
 // title
 $section = Skin::build_block(i18n::s('Pages'), 'title');
 // list items by date (default) or by title (option articles_by_title)
 if (preg_match('/\\barticles_by_title\\b/i', $item['options'])) {
     $items =& Members::list_articles_by_title_for_anchor('category:' . $item['id'], 0, 50);
 } else {
     $items =& Members::list_articles_by_date_for_anchor('category:' . $item['id'], 0, 50);
 }
 // actually render the html for the section
 if ($items) {
     $context['text'] .= $section . Skin::build_list($items, 'decorated');
 }
 //
 // the files section
 //
 // title
 $section = Skin::build_block(i18n::s('Files'), 'title');
 // list files by date (default) or by title (option :files_by_title:)
 if (preg_match('/\\bfiles_by_title\\b/i', $item['options'])) {
     $items = Files::list_by_title_for_anchor('category:' . $item['id'], 0, 300, 'category:' . $item['id']);
Пример #3
0
 /**
  * list categories
  *
  * @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 plain text
     $text = '';
     // process all items in the list
     while ($item = SQL::fetch($result)) {
         // one box per category
         $box['title'] = '';
         $box['text'] = '';
         // use the title to label the link
         $box['title'] = Skin::strip($item['title'], 50);
         // list related categories, if any
         if ($items = Categories::list_by_date_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE, 'compact')) {
             foreach ($items as $url => $label) {
                 if (is_array($label)) {
                     $label = $label[1];
                 }
                 $box['text'] .= '<li>' . Skin::build_link($url, $label, 'category') . '</li>' . "\n";
             }
         }
         // info on related sections
         $items =& Members::list_sections_by_title_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE);
         if ($items) {
             foreach ($items as $url => $label) {
                 if (is_array($label)) {
                     $label = $label[1];
                 }
                 $box['text'] .= '<li>' . Skin::build_link($url, $label, 'section') . '</li>' . "\n";
             }
         }
         // info on related articles
         if (isset($item['options']) && preg_match('/\\barticles_by_title\\b/i', $item['options'])) {
             $items =& Members::list_articles_by_title_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE);
         } else {
             $items =& Members::list_articles_by_date_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE);
         }
         if ($items) {
             foreach ($items as $url => $label) {
                 if (is_array($label)) {
                     $label = $label[1];
                 }
                 $box['text'] .= '<li>' . Skin::build_link($url, $label, 'article') . '</li>' . "\n";
             }
         }
         // info on related files
         if (isset($item['options']) && preg_match('/\\bfiles_by_title\\b/i', $item['options'])) {
             $items = Files::list_by_title_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE, 'category:' . $item['id']);
         } else {
             $items = Files::list_by_date_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE, 'category:' . $item['id']);
         }
         if ($items) {
             foreach ($items as $url => $label) {
                 if (is_array($label)) {
                     $label = $label[1];
                 }
                 $box['text'] .= '<li>' . Skin::build_link($url, $label, 'file') . '</li>' . "\n";
             }
         }
         // info on related comments
         include_once $context['path_to_root'] . 'comments/comments.php';
         if ($items = Comments::list_by_date_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE, 'compact')) {
             foreach ($items as $url => $label) {
                 if (is_array($label)) {
                     $label = $label[1];
                 }
                 $box['text'] .= '<li>' . Skin::build_link($url, $label, 'comment') . '</li>' . "\n";
             }
         }
         // info on related links
         include_once $context['path_to_root'] . 'links/links.php';
         if (isset($item['options']) && preg_match('/\\blinks_by_title\\b/i', $item['options'])) {
             $items = Links::list_by_title_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE);
         } else {
             $items = Links::list_by_date_for_anchor('category:' . $item['id'], 0, COMPACT_LIST_SIZE);
         }
         if ($items) {
             foreach ($items as $url => $label) {
                 if (is_array($label)) {
                     $label = $label[1];
                 }
                 $box['text'] .= '<li>' . Skin::build_link($url, $label) . '</li>' . "\n";
             }
         }
         // add a direct link to the category
         if (Surfer::is_associate()) {
             $box['title'] .= '&nbsp;' . Skin::build_link(Categories::get_permalink($item), MORE_IMG, 'basic');
         }
         // make a full list
         if ($box['text']) {
             $box['text'] = '<ul>' . $box['text'] . '</ul>' . "\n";
         }
         // always make a box, to let associates visit the category
         $text .= Skin::build_box($box['title'], $box['text']);
     }
     // end of processing
     SQL::free($result);
     return $text;
 }
Пример #4
0
Файл: view.php Проект: rair/yacs
 $layout_articles->set_focus('category:' . $item['id']);
 // count the number of articles in this category
 $count = Members::count_articles_for_anchor('category:' . $item['id'], $this_cat->get_listed_lang());
 if ($count) {
     $box['bar'] = array('_count' => sprintf(i18n::ns('%d page', '%d pages', $count), $count));
 }
 // navigation commands for articles
 $home = Categories::get_permalink($item);
 $prefix = Categories::get_url($item['id'], 'navigate', 'articles');
 $box['bar'] = array_merge($box['bar'], Skin::navigate($home, $prefix, $count, ARTICLES_PER_PAGE, $zoom_index));
 // list items by date (default) or by title (option 'articles_by_title') or by rating_sum (option article_by_rating)
 $offset = ($zoom_index - 1) * ARTICLES_PER_PAGE;
 if (isset($order) && preg_match('/\\barticles_by_rating\\b/i', $order)) {
     $items =& Members::list_articles_by_rating_for_anchor('category:' . $item['id'], $offset, ARTICLES_PER_PAGE, $layout_articles, $this_cat->get_listed_lang());
 } elseif (isset($item['options']) && preg_match('/\\barticles_by_title\\b/i', $item['options'])) {
     $items =& Members::list_articles_by_title_for_anchor('category:' . $item['id'], $offset, ARTICLES_PER_PAGE, $layout_articles, $this_cat->get_listed_lang());
 } else {
     $items =& Members::list_articles_by_date_for_anchor('category:' . $item['id'], $offset, ARTICLES_PER_PAGE, $layout_articles, $this_cat->get_listed_lang());
 }
 // actually render the html for the section
 if (is_array($items)) {
     $box['text'] .= Skin::build_list($items, 'decorated');
 } elseif (is_string($items)) {
     $box['text'] .= $items;
 }
 if ($box['bar']) {
     $box['text'] .= Skin::build_list($box['bar'], 'menu_bar');
 }
 // in a separate panel
 if ($box['text']) {
     $panels[] = array('articles', i18n::s('Pages'), 'articles_panel', $box['text']);