b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (0.9.x) [ class tree: evoskins ] [ index: evoskins ] [ all elements ]

Source for file _categories.php

Documentation is available at _categories.php

  1. <?php
  2.     /**
  3.      * This is the template that displays (recursive) list of (sub)categories
  4.      *
  5.      * This file is not meant to be called directly.
  6.      * It is meant to be called by an include in the _main.php template.
  7.      *
  8.      * b2evolution - {@link http://b2evolution.net/}
  9.      * Released under GNU GPL License - {@link http://b2evolution.net/about/license.html}
  10.      * @copyright (c)2003-2005 by Francois PLANQUE - {@link http://fplanque.net/}
  11.      *
  12.      * @package evoskins
  13.      */
  14.     if!defined('DB_USER') ) die'Please, do not access this page directly.' );
  15.  
  16.     # You can customize the following as you wish:
  17.     if(!isset($cat_all)) $cat_all /* TRANS: All categories, skin's categories list */ T_('All');    // Set to empty to hide
  18.     # global category list delimiters:
  19.     if(!isset($cat_main_start)) $cat_main_start '';
  20.     if(!isset($cat_main_end)) $cat_main_end '';
  21.     # Category delimiters:
  22.     if(!isset($cat_line_start)) $cat_line_start '<li>';
  23.     if(!isset($cat_line_end)) $cat_line_end '</li>';
  24.     if(!isset($cat_line_checkbox)) $cat_line_checkbox true;
  25.     # Category group delimiters:
  26.     if(!isset($cat_group_start)) $cat_group_start '<ul>';
  27.     if(!isset($cat_group_end)) $cat_group_end '</ul>';
  28.     # When multiple blogs are listed on same page:
  29.     if(!isset($cat_blog_start)) $cat_blog_start '<h4>';
  30.     if(!isset($cat_blog_end)) $cat_blog_end '</h4>';
  31.  
  32.     /*
  33.      * WARNING: the category list is displayed recursively.
  34.      * This is a little tricky. Don't modify below unless you really know what you're doing!
  35.      */
  36.     
  37.     // ----------------- START RECURSIVE CAT LIST ----------------
  38.     cat_query();    // make sure the caches are loaded
  39.     ifisset$cat_array ) ) $cat_array array();
  40.     
  41.     /**
  42.      * callback to start sublist
  43.      */
  44.     function cat_list_before_first$parent_cat_ID$level )
  45.     {    // callback to start sublist
  46.         global $cat_group_start;
  47.         if$level echo "\n",$cat_group_start,"\n";
  48.     }
  49.     
  50.     /**
  51.      * callback to display sublist element
  52.      */
  53.     function cat_list_before_each$cat_ID$level )
  54.     {    // callback to display sublist element
  55.         global $blogfilename$cat_array$cat_line_start$cat_line_checkbox;
  56.         $cat get_the_category_by_ID$cat_ID );
  57.         echo $cat_line_start;
  58.         if$cat_line_checkbox )
  59.         {
  60.             echo '<label><input type="checkbox" name="catsel[]" value="'.$cat_ID.'"';
  61.             ifin_array$cat_ID$cat_array ) )
  62.             {    // This category is in the current selection
  63.                 echo ' checked="checked"';
  64.             }
  65.             echo ' />';
  66.         }
  67.         echo '<a href="'.url_add_paramget_bloginfo('blogurl')'cat='.$cat_ID ).'">'.format_to_output($cat['cat_name']'htmlbody').'</a> <span class="dimmed">('.$cat['cat_postcount'].')</span>';
  68.         ifin_array$cat_ID$cat_array ) )
  69.         {    // This category is in the current selection
  70.             echo "*";
  71.         }
  72.         if$cat_line_checkbox )
  73.         {
  74.             echo '</label>';
  75.         }
  76.     }
  77.     
  78.     /**
  79.      * callback to display sublist element
  80.      */
  81.     function cat_list_after_each$cat_ID$level )
  82.     {    // callback to display sublist element
  83.         global $cat_line_end;
  84.         echo $cat_line_end,"\n";
  85.     }
  86.     
  87.     /**
  88.      * callback to end sublist
  89.      */
  90.     function cat_list_after_last$parent_cat_ID$level )
  91.     {    // callback to end sublist
  92.         global  $cat_group_end;
  93.         if$level echo $cat_group_end,"\n";
  94.     }
  95.     
  96.     // Start global list:
  97.     echo $cat_main_start;
  98.     if$blog )
  99.     {    // We want to display cats for one blog
  100.         echo "\n",$cat_group_start,"\n";
  101.  
  102.         if!empty$cat_all ) )
  103.         {    // We want to display a link to all cats:
  104.             echo $cat_line_start,"\n";
  105.             echo '<a href="',get_bloginfo('blogurl'),'">',$cat_all,'</a>';
  106.             echo $cat_line_end,"\n";
  107.         }
  108.  
  109.         cat_children$cache_categories$blogNULL'cat_list_before_first''cat_list_before_each''cat_list_after_each''cat_list_after_last');
  110.  
  111.         echo "\n",$cat_group_end,"\n";
  112.     }
  113.     else
  114.     {    // We want to display cats for all blogs
  115.         for$curr_blog_ID=blog_list_start('stub')
  116.                     $curr_blog_ID!=false
  117.                  $curr_blog_ID=blog_list_next('stub') ) 
  118.         # by uncommenting the following lines you can hide some blogs
  119.             // if( $curr_blog_ID == 2 ) continue; // Hide blog 2...
  120.  
  121.             if( ($curr_blog_ID == 1&& empty$cat_all ) ) continue// Hide blog 1 if requested
  122.  
  123.             echo $cat_blog_start;
  124.             ?><a href="<?php blog_list_iteminfo('blogurl''raw'?>"><?php blog_list_iteminfo('name''htmlbody'?></a>
  125.             <?php
  126.             echo $cat_blog_end;
  127.     
  128.             // run recursively through the cats
  129.             cat_children$cache_categories$curr_blog_IDNULL'cat_list_before_first''cat_list_before_each''cat_list_after_each''cat_list_after_last');
  130.         }
  131.     }
  132.     
  133.     // End global list:
  134.     echo $cat_main_end;
  135.  
  136.     // ----------------- END RECURSIVE CAT LIST ----------------
  137.  
  138. ?>

Documentation generated on Tue, 20 May 2008 01:52:26 +0200 by phpDocumentor 1.4.2