Source for file _categories.plugin.php
Documentation is available at _categories.plugin.php
* This file implements the Categories plugin.
* Displays a list of categories (chapters and subchapters) for the blog.
* This file is part of the b2evolution project - {@link http://b2evolution.net/}
* @copyright (c)2003-2006 by Francois PLANQUE - {@link http://fplanque.net/}
* Parts of this file are copyright (c)2004-2006 by Daniel HAHLER - {@link http://thequod.de/contact}.
* {@internal License choice
* - If you have received this file as part of a package, please find the license.txt file in
* the same folder or the closest folder above for complete license terms.
* - If you have received this file individually (e-g: from http://cvs.sourceforge.net/viewcvs.py/evocms/)
* then you must choose one of the following licenses before using the file:
* - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php
* - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php
* {@internal Below is a list of authors who have contributed to design/coding of this file: }}
* @author fplanque: Francois PLANQUE - {@link http://fplanque.net/}
* @version $Id: _categories.plugin.php,v 1.24.2.4 2006/12/26 03:18:50 fplanque Exp $
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
* This plugin displays a list of categories (chapters and subchapters) for the blog.
* Variables below MUST be overriden by plugin implementations,
* either in the subclass declaration or in the subclass constructor.
var $name =
'Categories Skin Tag';
$this->short_desc =
T_('This skin tag displays the list of available categories for the blog.');
$this->long_desc =
T_('Categories are indeed chapters and sub-chapters in the blog.');
$this->dbtable =
'T_posts';
$this->dbprefix =
'post_';
$this->dbIDname =
'post_ID';
* @param array Associative array of parameters. Valid keys are:
* - 'block_start' : (Default: '<div class="bSideItem">')
* - 'block_end' : (Default: '</div>')
* - 'title' : (Default: '<h3>'.T_('Categories').'</h3>')
* - 'link_type' : 'canonic'|'context' (default: canonic)
* - 'context_isolation' : what params need override when changing date/range (Default: 'm,w,p,title,unit,dstart' )
* - 'form' : true|false (default: false)
* - 'list_start' : (Default '<ul>'), does not get displayed for empty lists
* - 'list_end' : (Default '</ul>'), does not get displayed for empty lists
* - 'line_start' : (Default '<li>')
* - 'line_end' : (Default '</li>')
* - 'group_start' : (Default '<ul>') - (for BLOG 1 Categories)
* - 'group_end' : (Default "</ul>\n") - (for BLOG 1 Categories)
* - 'collist_start' : (Default '') - (for BLOG 1 Categories)
* - 'collist_end' : (Default "\n") - (for BLOG 1 Categories)
* - 'coll_start' : (Default '<h4>') - (for BLOG 1 Categories)
* - 'coll_end' : (Default "</h4>\n") - (for BLOG 1 Categories)
* - 'option_all' : (Default T_('All'))
* @return boolean did we display?
global $cache_categories;
* @todo get rid of these globals:
global $blog, $cat_modifier;
// This is what will enclose the block in the skin:
if(!isset
($params['block_start'])) $params['block_start'] =
'<div class="bSideItem">';
if(!isset
($params['block_end'])) $params['block_end'] =
"</div>\n";
if(!isset
($params['title']))
$params['title'] =
'<h3>'.
T_('Categories').
'</h3>';
if(!isset
($params['link_type'])) $params['link_type'] =
'canonic';
// if(!isset($params['context_isolation'])) $params['context_isolation'] = 'm,w,p,title,unit,dstart';
if(!isset
($params['form'])) $params['form'] =
false;
// This is what will enclose the category list:
if(!isset
($params['list_start'])) $params['list_start'] =
'<ul>';
if(!isset
($params['list_end'])) $params['list_end'] =
"</ul>\n";
// This is what will separate the category links:
if(!isset
($params['line_start'])) $params['line_start'] =
'<li>';
if(!isset
($params['line_end'])) $params['line_end'] =
"</li>\n";
// This is what will enclose the sub chapter lists:
if(!isset
($params['group_start'])) $params['group_start'] =
'<ul>';
if(!isset
($params['group_end'])) $params['group_end'] =
"</ul>\n";
// This is what will enclose the global list if several blogs are listed on the same page:
if(!isset
($params['collist_start'])) $params['collist_start'] =
'';
if(!isset
($params['collist_end'])) $params['collist_end'] =
"\n";
// This is what will separate blogs/collections when several of them are listed on the same page:
if(!isset
($params['coll_start'])) $params['coll_start'] =
'<h4>';
if(!isset
($params['coll_end'])) $params['coll_end'] =
"</h4>\n";
if(!isset
($params['option_all'])) $params['option_all'] =
T_('All');
// Save params for others functions:
// make sure the caches are loaded:
cat_query( $params['link_type'], $this->dbtable, $this->dbprefix, $this->dbIDname );
echo
$params['block_start'];
{ // We want to display cats for one blog
if( $params['option_all'] )
{ // We want to display a link to all cats:
$tmp_disp .=
$this->params['line_start'].
'<a href="';
if( $this->params['link_type'] ==
'context' )
{ // We want to preserve current browsing context:
$tmp_disp .=
'">'.
$params['option_all'].
'</a>';
$tmp_disp .=
$this->params['line_end'];
array( $this, 'callback_before_first' ), array( $this, 'callback_before_each' ),
array( $this, 'callback_after_each' ), array( $this, 'callback_after_last' ), 0 );
echo
$params['list_start'];
echo
$params['list_end'];
{ // We want to display cats for all blogs
echo
$params['collist_start'];
{ // Skip Blogs that should not get displayed in public blog list
// run recursively through the cats
$cat_list =
cat_children( $cache_categories, $curr_blog_ID, NULL,
array( $this, 'callback_before_first' ), array( $this, 'callback_before_each' ),
array( $this, 'callback_after_each' ), array( $this, 'callback_after_last' ), 0 );
/* Make this a param with default to OFF (NO Skip) because even if there are no cats, the blog name is a clickable root category itself
{ // Skip Blogs that have no categories!
echo
$params['coll_start'];
if( $this->params['link_type'] ==
'context' )
{ // We want to preserve current browsing context:
echo
$params['coll_end'];
echo
$params['list_start'];
echo
$params['list_end'];
echo
$params['collist_end'];
{ // We want to add form fields:
<span class="line">
<?php /* blueyed>> using div.line here makes them "blocks" in Konqueror/Safari(?) */ ?>
<input type="radio" name="cat" value="" id="catANY" class="radio"
<?php if( $cat_modifier !=
'-' &&
$cat_modifier !=
'*' ) echo
'checked="checked" '?> />
<label for="catANY">
<?php echo
T_('ANY') ?></label>
<input type="radio" name="cat" value="-" id="catANYBUT" class="radio"
<?php if( $cat_modifier ==
'-' ) echo
'checked="checked" '?> />
<label for="catANYBUT">
<?php echo
T_('ANY BUT') ?></label>
<input type="radio" name="cat" value="*" id="catALL" class="radio"
<?php if( $cat_modifier ==
'*' ) echo
'checked="checked" '?> />
<label for="catALL">
<?php echo
T_('ALL') ?></label>
echo
$params['block_end'];
{ // callback to start sublist
if( $level >
0 ) $r .=
$this->params['group_start'];
{ // callback to display sublist element
global $tab, $blog, $cat_array;
$r =
$this->params['line_start'];
if( $this->params['form'] )
{ // We want to add form fields:
$r .=
'<label><input type="checkbox" name="catsel[]" value="'.
$cat_ID.
'" class="checkbox"';
{ // This category is in the current selection
$r .=
' checked="checked"';
if( $this->params['link_type'] ==
'context' )
{ // We want to preserve current browsing context:
$r .=
'">'.
format_to_output($cat['cat_name'], 'htmlbody').
'</a> <span class="notes">('.
$cat['cat_postcount'].
')</span>';
{ // This category is in the current selection
if( $this->params['form'] )
{ // We want to add form fields:
{ // callback to display sublist element
return $this->params['line_end'];
{ // callback to end sublist
if( $level >
0 ) $r .=
$this->params['group_end'];
* $Log: _categories.plugin.php,v $
* Revision 1.24.2.4 2006/12/26 03:18:50 fplanque
* assigned a few significant plugin groups
* Revision 1.24.2.3 2006/12/05 12:44:43 blueyed
* Link categories with the corresponding blog URL. Fixes "serious google problem". See http://forums.b2evolution.net//viewtopic.php?p=47815#47815
* Revision 1.24.2.2 2006/11/04 19:55:11 fplanque
* Reinjected old Log blocks. Removing them from CVS was a bad idea -- especially since Daniel has decided branch 1.9 was his HEAD...
* Revision 1.24 2006/07/10 20:19:30 blueyed
* Fixed PluginInit behaviour. It now gets called on both installed and non-installed Plugins, but with the "is_installed" param appropriately set.
* Revision 1.23 2006/07/07 21:26:49 blueyed
* Revision 1.22 2006/06/16 21:30:57 fplanque
* Started clean numbering of plugin versions (feel free do add dots...)
* Revision 1.21 2006/05/30 19:39:55 fplanque
* Revision 1.20 2006/04/19 20:14:03 fplanque
* do not restrict to :// (does not catch subdomains, not even www.)
* Revision 1.19 2006/04/11 21:22:26 fplanque