Пример #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
    // display the category
} else {
    // the introduction text
    $context['text'] .= Skin::build_block($item['introduction'], 'introduction');
    // the beautified description, which is the actual page body
    $context['text'] .= Skin::build_block($item['description'], 'description');
    //	// date of last update
    //	$context['text'] .= i18n::s('Last update').' '.Skin::build_date($item['edit_date']);
    //
    // the section of sub-categories
    //
    // title
    $section = Skin::build_block(i18n::s('Related categories'), 'title');
    // list items by date (default) or by title (option :categories_by_title:)
    if (preg_match('/\\bcategories_by_title\\b/i', $item['options'])) {
        $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);
Пример #3
0
 /**
  * render a list of categories
  *
  * The provided anchor can reference:
  * - a section 'category:123'
  * - a user 'user:789'
  * - 'self'
  * - nothing
  *
  * @param string the anchor (e.g. 'section:123')
  * @param string layout to use
  * @return string the rendered text
  **/
 public static function render_categories($layout = 'compact', $anchor = '')
 {
     global $context;
     // we return some text;
     $text = '';
     // number of items to display
     $count = YAHOO_LIST_SIZE;
     if (($position = strpos($anchor, ',')) !== FALSE) {
         $count = (int) trim(substr($anchor, $position + 1));
         if (!$count) {
             $count = YAHOO_LIST_SIZE;
         }
         $anchor = trim(substr($anchor, 0, $position));
     }
     // scope is limited to current surfer
     if ($anchor == 'self' && Surfer::get_id()) {
         $anchor = 'user:'******'category:') === 0) {
         $text = Categories::list_by_title_for_anchor($anchor, 0, $count, $layout);
     } elseif (strpos($anchor, 'user:') === 0) {
         $text = Members::list_categories_by_title_for_member($anchor, 0, $count, $layout);
     }
     // consider all pages
     if (!$text) {
         $text = Categories::list_by_title_for_anchor(NULL, 0, $count, $layout);
     }
     // we have an array to format
     if (is_array($text)) {
         $text = Skin::build_list($text, $layout);
     }
     // job done
     return $text;
 }
Пример #4
0
$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/';
            } elseif ($context['with_friendly_urls'] == 'R') {
                $prefix = $home;
            } else {
Пример #5
0
Файл: view.php Проект: rair/yacs
     $layout = Layouts::new_($item['categories_layout'], 'category');
 }
 // the maximum number of categories per page
 if (is_object($layout)) {
     $items_per_page = $layout->items_per_page();
 } else {
     $items_per_page = CATEGORIES_PER_PAGE;
 }
 // count the number of subcategories
 $stats = Categories::stat_for_anchor('category:' . $item['id']);
 // 		if($stats['count'])
 // 			$box['bar'] += array('_count' => sprintf(i18n::ns('%d category', '%d categories', $stats['count']), $stats['count']));
 // list items by date (default) or by title (option 'categories_by_title')
 $offset = ($zoom_index - 1) * $items_per_page;
 if (preg_match('/\\bcategories_by_title\\b/i', $item['options'])) {
     $items = Categories::list_by_title_for_anchor('category:' . $item['id'], $offset, $items_per_page, $layout);
 } else {
     $items = Categories::list_by_date_for_anchor('category:' . $item['id'], $offset, $items_per_page, $layout);
 }
 // navigation commands for categories
 $home = Categories::get_permalink($item);
 $prefix = Categories::get_url($item['id'], 'navigate', 'categories');
 $box['bar'] = array_merge($box['bar'], Skin::navigate($home, $prefix, $stats['count'], $items_per_page, $zoom_index));
 // the command to post a new category
 if ($stats['count'] && $this_cat->allow_creation()) {
     $url = 'categories/edit.php?anchor=' . urlencode('category:' . $item['id']);
     $box['bar'] += array($url => i18n::s('Add a category'));
 }
 // actually render the html for the section
 if (is_array($items)) {
     $box['text'] .= Skin::build_list($items, 'decorated');