Source for file _coll_category_list.widget.php
Documentation is available at _coll_category_list.widget.php
* This file implements the xyz Widget class.
* This file is part of the evoCore framework - {@link http://evocore.net/}
* See also {@link http://sourceforge.net/projects/evocms/}.
* @copyright (c)2003-2010 by Francois PLANQUE - {@link http://fplanque.net/}
* Parts of this file are copyright (c)2008 by Daniel HAHLER - {@link http://daniel.hahler.de/}.
* {@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://evocms.cvs.sourceforge.net/)
* 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 blueyed: Daniel HAHLER
* @author fplanque: Francois PLANQUE.
* @version $Id: _coll_category_list.widget.php,v 1.26 2010/02/26 02:05:09 sam2kb Exp $
if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
load_class( 'widgets/model/_widget.class.php', 'ComponentWidget' );
* A ComponentWidget is a displayable entity that can be placed into a Container on a web page.
// Call parent constructor:
return T_('Category list');
* Get a very short desc. Used in the widget list.
return T_('List of all categories; click filters blog on selected category.');
* Get definitions for editable params
* @see Plugin::GetDefaultSettings()
* @param array local params
* - 'title': block title (string, default "Categories")
* - 'option_all': "All categories" link title, empty to disable (string, default "All")
* - 'use_form': Add a form with checkboxes to allow selection of multiple categories (boolean)
* - 'disp_names_for_coll_list': Display blog names, if this is an aggregated blog? (boolean)
* - 'display_checkboxes': Add checkboxes (but not a complete form) to allow selection of multiple categories (boolean)
'label' =>
T_('Block title'),
'defaultvalue' =>
T_('Categories'),
'label' =>
T_('Option "All"'),
'defaultvalue' =>
T_('All'),
'note' =>
T_('The "All categories" link allows to reset the filter. Leave blank if you want no such option.'),
'label' =>
T_('Use form'),
'note' =>
T_('Add checkboxes to allow selection of multiple categories.'),
'disp_names_for_coll_list' =>
array(
'label' =>
T_('Display blog names'),
'defaultvalue' =>
1, /* previous behaviour */
'note' =>
T_('Display blog names, if this is an aggregated blog.'),
// Hidden, used by the item list sidebar in the backoffice.
'display_checkboxes' =>
array(
'label' =>
'Internal: Display checkboxes', // This key is required
* @param array MUST contain at least the basic display params
'line' =>
array( $this, 'cat_line' ),
'no_children' =>
array( $this, 'cat_no_children' ),
'before_level' =>
array( $this, 'cat_before_level' ),
'after_level' =>
array( $this, 'cat_after_level' )
// Display title if requested
{ // We want a complete form:
echo
'<form method="get" action="'.
$Blog->gen_blogurl().
'">';
$aggregate_coll_IDs =
$Blog->get_setting('aggregate_coll_IDs');
if( empty($aggregate_coll_IDs) )
{ // ____________________ We want to display cats for ONE blog ____________________
{ // We want to display a link to all cats:
$tmp_disp .=
$this->disp_params['item_start'].
'<a href="';
{ // We want to preserve current browsing context:
$tmp_disp .=
$Blog->gen_blogurl();
$tmp_disp .=
'">'.
$this->disp_params['option_all'].
'</a>';
$r =
$tmp_disp .
$ChapterCache->recurse( $callbacks, $Blog->ID );
{ // ____________________ We want to display cats for SEVERAL blogs ____________________
// Make sure everything is loaded at once (vs multiple queries)
$ChapterCache->load_all();
if( $aggregate_coll_IDs ==
'*' )
$coll_ID_array =
$BlogCache->get_ID_array();
foreach( $coll_ID_array as $curr_blog_ID )
$loop_Blog =
& $BlogCache->get_by_ID( $curr_blog_ID, false );
{ // That one doesn't exist (any more?)
// Display blog title, if requested:
{ // We want to preserve current browsing context:
$loop_Blog->disp('url','raw');
$loop_Blog->disp('name');
$r =
$ChapterCache->recurse( $callbacks, $curr_blog_ID );
{ // We want to add form fields:
<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>
{ // We want a complete form:
<input type="submit" value="
<?php echo
T_( 'Filter categories' ); ?>" />
* Callback: Generate category line when it has children
* @param Chapter generic category we want to display
* @param int level of the category in the recursive tree
if( in_array( $Chapter->ID, $cat_array ) )
{ // This category is in the current selection
{ // We want to add form fields:
$r .=
'<label><input type="checkbox" name="catsel[]" value="'.
$Chapter->ID.
'" class="checkbox"';
if( in_array( $Chapter->ID, $cat_array ) )
{ // This category is in the current selection
$r .=
' checked="checked"';
{ // We want to preserve current browsing context:
$r .=
$Chapter->get_permanent_url();
$r .=
'">'.
$Chapter->dget('name').
'</a>';
{ // We want to add form fields:
// Do not end line here because we need to include children first!
// $r .= $this->disp_params['item_end'];
* Callback: Generate category line when it has no children
* @param Chapter generic category we want to display
* @param int level of the category in the recursive tree
* Callback: Generate code when entering a new level
* @param int level of the category in the recursive tree
{ // If this is not the root:
* Callback: Generate code when exiting from a level
* @param int level of the category in the recursive tree
{ // If this is not the root:
// End current (parent) line:
* $Log: _coll_category_list.widget.php,v $
* Revision 1.26 2010/02/26 02:05:09 sam2kb
* Sanitize aggregate_coll_IDs array
* Revision 1.25 2010/02/08 17:54:47 efy-yury
* Revision 1.24 2009/09/26 12:00:44 tblue246
* Revision 1.23 2009/09/25 07:33:31 efy-cantor
* replace get_cache to get_*cache
* Revision 1.22 2009/09/14 13:54:13 efy-arrin
* Included the ClassName in load_class() call with proper UpperCase
* Revision 1.21 2009/09/12 11:03:12 efy-arrin
* Included the ClassName in the loadclass() with proper UpperCase
* Revision 1.20 2009/03/13 02:32:07 fplanque
* Removed stupid widget_name param.
* Revision 1.19 2009/03/10 13:53:04 tblue246
* Fixing the "Category list" widget again, now hopefully without making the backoffice sidebar look ugly...
* Revision 1.18 2009/03/08 23:57:46 fplanque
* Revision 1.17 2009/03/08 23:08:35 fplanque
* rollback: NOT A BUG (this "fix" ads an unwanted button to admin)
* There should probably be no public setting for the form mode.
* (Or there should be an option for "standalone form".)
* Revision 1.16 2009/03/07 23:14:34 tblue246
* Revision 1.15 2009/03/07 22:41:13 tblue246
* Display submit button on category widget when requested (fixes https://bugs.launchpad.net/b2evolution/+bug/194849 ).
* Revision 1.14 2009/01/23 00:06:25 blueyed
* Support '*' for aggregate_coll_IDs in coll_category_list.widget, too.
* Revision 1.13 2008/05/30 19:57:37 blueyed
* Revision 1.12 2008/05/30 16:39:06 blueyed
* Revision 1.11 2008/05/06 23:35:47 fplanque
* The correct way to add linebreaks to widgets is to add them to $disp_params when the container is called, right after the array_merge with defaults.
* Revision 1.9 2008/01/21 09:35:37 fplanque
* Revision 1.8 2008/01/06 17:52:50 fplanque
* Revision 1.7 2008/01/06 15:35:34 blueyed
* - added "disp_names_for_coll_list" param
* Revision 1.6 2007/12/23 16:16:18 fplanque
* Revision 1.5 2007/12/23 14:14:25 fplanque
* Enhanced widget name display
* Revision 1.4 2007/12/22 19:54:59 yabs
* cleanup from adding core params
* Revision 1.3 2007/11/27 10:01:05 yabs
* Revision 1.2 2007/07/01 15:12:28 fplanque
* Revision 1.1 2007/07/01 03:55:04 fplanque
* category plugin replaced by widget