From cf6b7dec97e1d95a7a7c93a49202bcbd1fb713a5 Mon Sep 17 00:00:00 2001 From: Max Kremmel Date: Thu, 23 Aug 2007 07:31:27 +0000 Subject: add service function and template to add category filter on list pages. list services still need to be implemented in various packages. --- Pigeonholes.php | 47 +++++++++++++++++++++++++++-------------- admin/admin_pigeonholes_inc.php | 6 +++++- bit_setup_inc.php | 17 +++++++++------ 3 files changed, 47 insertions(+), 23 deletions(-) diff --git a/Pigeonholes.php b/Pigeonholes.php index 8e36763..553f68d 100644 --- a/Pigeonholes.php +++ b/Pigeonholes.php @@ -1,6 +1,6 @@ - * @version $Revision: 1.95 $ + * @version $Revision: 1.96 $ * @package pigeonholes */ @@ -1069,6 +1069,26 @@ function pigeonholes_content_store( $pObject, $pParamHash ) { } } +/** + * When the list function is called and the template, a filter option will appear based on categories + * + * @param array $pObject Current object + * @param array $pParamHash Parameter hash - only works if $_REQUEST[pigeonholes][filter] is passed back to the list sql funciton + * @access public + * @return void + */ +function pigeonholes_content_list( &$pObject, $pParamHash = NULL ) { + global $gBitSystem, $gBitSmarty; + if( $gBitSystem->isFeatureActive( 'pigeonholes_list_filter' )) { + $pigeonholes = new Pigeonholes(); + $pigeonList = $pigeonholes->getPigeonholesPathList(); + foreach( $pigeonList as $content_id => $path ) { + $list[$content_id] = $pigeonholes->getDisplayPath( $path ); + } + $gBitSmarty->assign( 'pigeonList', $list ); + } +} + /** * filter the search with pigeonholes * @param $pParamHash['pigeonholes']['filter'] - a pigeonhole or an array of pigeonhole content_id @@ -1076,27 +1096,22 @@ function pigeonholes_content_store( $pObject, $pParamHash ) { function pigeonholes_content_list_sql( &$pObject, $pParamHash = NULL ) { global $gBitSystem; $ret = array(); - if( /*$gBitSystem->isFeatureActive( 'pigeonholes_categorize_'.$pObject->getContentType() ) && */ !empty( $pParamHash['pigeonholes']['filter'] ) ) { - if ( is_array( $pParamHash['pigeonholes']['filter'] ) ) { - $ret['join_sql'] = "LEFT JOIN `".BIT_DB_PREFIX."pigeonhole_members` pm ON (lc .`content_id`= pm.`content_id`)"; - $ret['where_sql'] = ' AND pm.`parent_id` in ('.implode( ',', array_fill(0, count( $pParamHash['pigeonholes']['filter'] ), '?' ) ).')'; - $ret['bind_vars'] = $pParamHash['pigeonholes']['filter']; - } else { - $ret['join_sql'] = "LEFT JOIN `".BIT_DB_PREFIX."pigeonhole_members` pm ON (lc .`content_id`= pm.`content_id`)"; - $ret['where_sql'] = " AND pm.`parent_id`=? "; - $ret['bind_vars'][] = $pParamHash['pigeonholes']['filter']; - } + + if( !empty( $pParamHash['pigeonholes']['filter'] )) { + $pParamHash['liberty_categories'] = $pParamHash['pigeonholes']['filter']; } - if( !empty( $pParamHash['liberty_categories'] ) ) { - $ret['join_sql'] = "LEFT JOIN `".BIT_DB_PREFIX."pigeonhole_members` pm ON (lc .`content_id`= pm.`content_id`)"; - if ( is_array( $pParamHash['liberty_categories'] ) ) { - $ret['where_sql'] = ' AND pm.`parent_id` in ('.implode( ',', array_fill(0, count( $pParamHash['liberty_categories'] ), '?' ) ).')'; + + if( !empty( $pParamHash['liberty_categories'] )) { + $ret['join_sql'] = "LEFT JOIN `".BIT_DB_PREFIX."pigeonhole_members` pm ON (lc .`content_id`= pm.`content_id`)"; + if( is_array( $pParamHash['liberty_categories'] )) { + $ret['where_sql'] = ' AND pm.`parent_id` in ('.implode( ',', array_fill( 0, count( $pParamHash['liberty_categories'] ), '?' )).')'; $ret['bind_vars'] = $pParamHash['liberty_categories']; } else { $ret['where_sql'] = " AND pm.`parent_id`=? "; $ret['bind_vars'][] = $pParamHash['liberty_categories']; } } + return $ret; } ?> diff --git a/admin/admin_pigeonholes_inc.php b/admin/admin_pigeonholes_inc.php index d73aded..be06a61 100644 --- a/admin/admin_pigeonholes_inc.php +++ b/admin/admin_pigeonholes_inc.php @@ -1,5 +1,5 @@ array( @@ -18,6 +18,10 @@ $pigeonholeDisplaySettings = array( 'label' => 'Display Subtree', 'note' => 'When viewing the category list, you can display the subcategories as well.', ), + 'pigeonholes_list_filter' => array( + 'label' => 'Listing Filter', + 'note' => 'When viewing a listing of content items, users can limit the listing based on category.', + ), 'pigeonholes_themes' => array( 'label' => 'Theme selection', 'note' => 'Allow the selection of a different theme to use for a category.', diff --git a/bit_setup_inc.php b/bit_setup_inc.php index 490e305..596cb7f 100644 --- a/bit_setup_inc.php +++ b/bit_setup_inc.php @@ -1,7 +1,7 @@ - * @version $Revision: 1.16 $ + * @version $Revision: 1.17 $ * @package Pigeonholes * @subpackage functions */ @@ -16,24 +16,29 @@ $gBitSystem->registerPackage( $registerHash ); define( 'PIGEONHOLES_CONTENT_TYPE_GUID', 'pigeonholes' ); -if( $gBitSystem->isPackageActive( 'pigeonholes' ) ) { +if( $gBitSystem->isPackageActive( 'pigeonholes' )) { // include service functions require_once( PIGEONHOLES_PKG_PATH.'Pigeonholes.php' ); $tpl = $gBitSystem->isFeatureActive( 'pigeonholes_use_jstab' ) ? 'tab' : 'mini'; $gLibertySystem->registerService( LIBERTY_SERVICE_CATEGORIZATION, PIGEONHOLES_PKG_NAME, array( + // functions 'content_display_function' => 'pigeonholes_content_display', 'content_preview_function' => 'pigeonholes_content_preview', 'content_edit_function' => 'pigeonholes_content_edit', 'content_store_function' => 'pigeonholes_content_store', 'content_expunge_function' => 'pigeonholes_content_expunge', - 'content_view_tpl' => 'bitpackage:pigeonholes/service_view_members_inc.tpl', - 'content_nav_tpl' => 'bitpackage:pigeonholes/service_nav_path_inc.tpl', + 'content_list_function' => 'pigeonholes_content_list', 'content_list_sql_function' => 'pigeonholes_content_list_sql', + + // templates 'content_edit_'.$tpl.'_tpl' => 'bitpackage:pigeonholes/service_edit_'.$tpl.'_inc.tpl', - ) ); + 'content_view_tpl' => 'bitpackage:pigeonholes/service_view_members_inc.tpl', + 'content_nav_tpl' => 'bitpackage:pigeonholes/service_nav_path_inc.tpl', + 'content_list_tpl' => 'bitpackage:pigeonholes/service_list_inc.tpl', + )); - if( $gBitUser->hasPermission( 'p_pigeonholes_view' ) ) { + if( $gBitUser->hasPermission( 'p_pigeonholes_view' )) { $menuHash = array( 'package_name' => PIGEONHOLES_PKG_NAME, 'index_url' => PIGEONHOLES_PKG_URL.'index.php', -- cgit v1.3