diff options
| -rw-r--r-- | Pigeonholes.php | 79 | ||||
| -rw-r--r-- | admin/admin_pigeonholes_inc.php | 19 | ||||
| -rw-r--r-- | assign_non_members.php | 13 | ||||
| -rw-r--r-- | edit_pigeonholes.php | 17 | ||||
| -rw-r--r-- | edit_structure.php | 5 | ||||
| -rw-r--r-- | list.php | 5 | ||||
| -rw-r--r-- | lookup_pigeonholes_inc.php | 5 | ||||
| -rw-r--r-- | modules/mod_last_changes.php | 4 | ||||
| -rw-r--r-- | modules/mod_whats_related.php | 6 | ||||
| -rw-r--r-- | servicefunctions_inc.php | 12 | ||||
| -rw-r--r-- | templates/admin_pigeonholes.tpl | 10 | ||||
| -rw-r--r-- | templates/edit_pigeonholes.tpl | 72 | ||||
| -rw-r--r-- | templates/edit_pigeonholes_inc.tpl | 63 | ||||
| -rw-r--r-- | templates/edit_structure.tpl | 2 | ||||
| -rw-r--r-- | templates/list.tpl | 2 | ||||
| -rw-r--r-- | templates/section_inc.tpl | 149 | ||||
| -rw-r--r-- | templates/view_structure_inc.tpl | 13 | ||||
| -rw-r--r-- | view.php | 9 |
18 files changed, 342 insertions, 143 deletions
diff --git a/Pigeonholes.php b/Pigeonholes.php index 7e2ac2f..5f10ef2 100644 --- a/Pigeonholes.php +++ b/Pigeonholes.php @@ -1,6 +1,6 @@ <?php /** - * @version $Header: /cvsroot/bitweaver/_bit_pigeonholes/Pigeonholes.php,v 1.14 2006/01/10 21:16:02 squareing Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_pigeonholes/Pigeonholes.php,v 1.15 2006/01/14 19:55:17 squareing Exp $ * * +----------------------------------------------------------------------+ * | Copyright ( c ) 2004, bitweaver.org @@ -17,7 +17,7 @@ * Pigeonholes class * * @author xing <xing@synapse.plus.com> - * @version $Revision: 1.14 $ + * @version $Revision: 1.15 $ * @package pigeonholes */ @@ -42,7 +42,7 @@ class Pigeonholes extends LibertyAttachable { * @return none * @access public **/ - function Pigeonholes( $pStructureId=NULL, $pContentId=NULL, $pAutoLoad=TRUE, $pExtras=FALSE ) { + function Pigeonholes( $pStructureId=NULL, $pContentId=NULL ) { LibertyAttachable::LibertyAttachable(); $this->registerContentType( PIGEONHOLES_CONTENT_TYPE_GUID, array( 'content_type_guid' => PIGEONHOLES_CONTENT_TYPE_GUID, @@ -55,9 +55,6 @@ class Pigeonholes extends LibertyAttachable { $this->mContentId = $pContentId; $this->mStructureId = $pStructureId; $this->mContentTypeGuid = PIGEONHOLES_CONTENT_TYPE_GUID; - if( $pAutoLoad ) { - $this->load( $pExtras ); - } } /** @@ -333,9 +330,13 @@ class Pigeonholes extends LibertyAttachable { * @return array of pigeonholes in 'data' and count of pigeonholes in 'cant' * @access public **/ - function getList( $pListHash=NULL, $pOnlyGetRoot=FALSE, $pExtras=FALSE ) { + function getList( $pListHash = NULL ) { + global $gBitSystem; + LibertyContent::prepGetList( $pListHash ); + $bindVars = array(); $where = ''; + if( !empty( $pListHash['find'] ) ) { $where .= " WHERE UPPER( tc.`title` ) LIKE ? "; $bindVars[] = '%'.strtoupper( $pListHash['find'] ).'%'; @@ -347,7 +348,7 @@ class Pigeonholes extends LibertyAttachable { $bindVars[] = $pListHash['root_structure_id']; } - if( $pOnlyGetRoot ) { + if( !empty( $pListHash['load_only_root'] ) ) { $where .= empty( $where ) ? ' WHERE ' : ' AND '; $where .= " ts.`structure_id`=ts.`root_structure_id` "; } @@ -369,11 +370,7 @@ class Pigeonholes extends LibertyAttachable { INNER JOIN `".BIT_DB_PREFIX."tiki_structures` ts ON ( ts.`structure_id` = bp.`structure_id` ) $where"; - if( isset( $pListHash['max_rows'] ) && is_numeric( $pListHash['max_rows'] ) && isset( $pListHash['offset'] ) && is_numeric( $pListHash['offset'] ) ) { - $result = $this->mDb->query( $query, $bindVars, $pListHash['max_rows'], $pListHash['offset'] ); - } else { - $result = $this->mDb->query( $query, $bindVars ); - } + $result = $this->mDb->query( $query, $bindVars, $pListHash['max_records'], $pListHash['offset'] ); while( !$result->EOF ) { $aux = $result->fields; @@ -381,11 +378,19 @@ class Pigeonholes extends LibertyAttachable { $aux['editor'] = ( isset( $result->fields['modifier_real_name'] ) ? $result->fields['modifier_real_name'] : $result->fields['modifier_user'] ); $aux['display_link'] = Pigeonholes::getDisplayLink( $aux['title'], $aux ); - if( $pExtras ) { + if( !empty( $pListHash['force_extras'] ) || + ( !empty( $pListHash['load_extras'] ) && $gBitSystem->getPreference( 'pigeonholes_list_style' ) != 'table' ) || + ( !empty( $pListHash['load_extras'] ) && $aux['structure_id'] == @$pListHash['structure_id'] && $gBitSystem->getPreference( 'pigeonholes_list_style' ) == 'table' ) + ) { $aux['path'] = $this->getPigeonholePath( $aux['structure_id'] ); $aux['display_path'] = $this->getDisplayPath( $aux['path'] ); $aux['members'] = $this->getMemberList( array( 'content_id' => $aux['content_id'] ) ); $aux['members_count'] = count( $aux['members'] ); + if( $gBitSystem->getPreference( 'pigeonholes_list_style' ) == 'table' ) { + $this->alphabetiseMembers( $aux['members'] ); + } + } else { +// $aux['members_count'] = $this->mDb->getOne( "SELECT COUNT(*) FROM `".BIT_DB_PREFIX."bit_pigeonhole_members` WHERE `parent_id`=?", array( $aux['content_id'] ) ); } $ret['data'][] = $aux; @@ -401,6 +406,22 @@ class Pigeonholes extends LibertyAttachable { return $ret; } + function alphabetiseMembers( &$pParamHash ) { + if( !empty( $pParamHash ) ) { + usort( $pParamHash, "pigeonholes_alphabetiser" ); + $per_column = ceil( count( $pParamHash ) / 3 ); + $i = 1; + $j = 1; + foreach( $pParamHash as $member ) { + $column = ( $i++ % $per_column == 0 ) ? $j++ : $j; + $index = strtoupper( substr( $member['title'], 0, 1 ) ); + $ret[$column][$index][] = $member; + } + $pParamHash = $ret; + unset( $ret ); + } + } + /** * Store pigeonhole data * @param $pParamHash contains all data to store the pigeonholes @@ -799,34 +820,45 @@ class Pigeonholes extends LibertyAttachable { * @return bool TRUE on success, FALSE if store could not occur. * @access public **/ - function expunge() { + function expunge( $pStructureId = NULL ) { $ret = FALSE; + // if we have a custom structure id we want to remove, load it + if( @BitBase::verifyId( $pStructureId ) ) { + $this->mStructureId = $pStructureId; + $this->load(); + } + if( $this->isValid() ) { $this->mDb->StartTrans(); // get all items that are part of the sub tree require_once( LIBERTY_PKG_PATH.'LibertyStructure.php' ); $struct = new LibertyStructure(); + // include the current structure id as well + $structureIds[] = $this->mStructureId; $tree = $struct->getSubTree( $this->mStructureId ); foreach( $tree as $node ) { $structureIds[] = $node['structure_id']; } $structureIds = array_unique( $structureIds ); + $where = ''; foreach( $structureIds as $structureId ) { - $contentIds[] = $this->mDb->getOne( "SELECT `content_id` FROM `".BIT_DB_PREFIX."tiki_structures` WHERE `structure_id`=?", array( $structureId ) ); + $where .= ( empty( $where ) ? " WHERE " : " OR ")."`structure_id`=?"; } + $result = $this->mDb->query( "SELECT `content_id` FROM `".BIT_DB_PREFIX."tiki_structures` $where", $structureIds ); + $contentIds = $result->getRows(); - foreach( $contentIds as $contentId ) { + foreach( $contentIds as $id ) { // now we have the content ids - let the nuking begin $query = "DELETE FROM `".BIT_DB_PREFIX."bit_pigeonholes` WHERE `content_id` = ?"; - $result = $this->mDb->query( $query, array( $contentId ) ); + $result = $this->mDb->query( $query, array( $id['content_id'] ) ); $query = "DELETE FROM `".BIT_DB_PREFIX."bit_pigeonhole_members` WHERE `parent_id` = ?"; - $result = $this->mDb->query( $query, array( $contentId ) ); - $this->expungePigeonholeSettings( $contentId ); + $result = $this->mDb->query( $query, array( $id['content_id'] ) ); + $this->expungePigeonholeSettings( $id['content_id'] ); // remove all entries from content tables - $this->mContentId = $contentId; + $this->mContentId = $id['content_id']; if( LibertyAttachable::expunge() ) { $ret = TRUE; $this->mDb->CompleteTrans(); @@ -893,4 +925,9 @@ class Pigeonholes extends LibertyAttachable { return $ret; } } + +function pigeonholes_alphabetiser($a, $b) { + return strcasecmp( $a["title"], $b["title"] ); +} + ?> diff --git a/admin/admin_pigeonholes_inc.php b/admin/admin_pigeonholes_inc.php index 616547f..45e17dd 100644 --- a/admin/admin_pigeonholes_inc.php +++ b/admin/admin_pigeonholes_inc.php @@ -1,11 +1,7 @@ <?php -// $Header: /cvsroot/bitweaver/_bit_pigeonholes/admin/admin_pigeonholes_inc.php,v 1.1 2005/08/21 16:22:48 squareing Exp $ +// $Header: /cvsroot/bitweaver/_bit_pigeonholes/admin/admin_pigeonholes_inc.php,v 1.2 2006/01/14 19:55:19 squareing Exp $ $pigeonholeSettings = array( - 'custom_member_sorting' => array( - 'label' => 'Custom Sorting', - 'note' => 'This will change the way category members are displayed. It allows you to sort the members manually.', - ), 'display_pigeonhole_path' => array( 'label' => 'Display Path', 'note' => 'Display category paths above the page leading to the object.', @@ -18,11 +14,21 @@ $pigeonholeSettings = array( 'label' => 'Display Description', 'note' => 'When showing the category members, you can display the category description as well.', ), + 'custom_member_sorting' => array( + 'label' => 'Custom Sorting', + 'note' => 'This will change the way category members are displayed. It allows you to sort the members manually.', + ), ); $gBitSmarty->assign( 'pigeonholeSettings', $pigeonholeSettings ); +$listStyles = array( + 'dynamic' => tra( 'Dynamic list' ), + 'table' => tra( 'Table based list' ), +); +$gBitSmarty->assign( 'listStyles', $listStyles ); + $memberLimit = array( - '9999' => 'Unlimited', + '9999' => tra( 'Unlimited' ), '10' => 10, '20' => 20, '30' => 30, @@ -37,5 +43,6 @@ if( !empty( $_REQUEST['pigeonhole_settings'] ) ) { } simple_set_value( 'limit_member_number', PIGEONHOLES_PKG_NAME ); + simple_set_value( 'pigeonholes_list_style', PIGEONHOLES_PKG_NAME ); } ?> diff --git a/assign_non_members.php b/assign_non_members.php index 44957f0..947dca1 100644 --- a/assign_non_members.php +++ b/assign_non_members.php @@ -1,6 +1,6 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_pigeonholes/Attic/assign_non_members.php,v 1.3 2005/10/23 08:28:55 squareing Exp $ + * $Header: /cvsroot/bitweaver/_bit_pigeonholes/Attic/assign_non_members.php,v 1.4 2006/01/14 19:55:18 squareing Exp $ * * Copyright ( c ) 2004 bitweaver.org * Copyright ( c ) 2003 tikwiki.org @@ -8,7 +8,7 @@ * All Rights Reserved. See copyright.txt for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details * - * $Id: assign_non_members.php,v 1.3 2005/10/23 08:28:55 squareing Exp $ + * $Id: assign_non_members.php,v 1.4 2006/01/14 19:55:18 squareing Exp $ * @package pigeonholes * @subpackage functions */ @@ -38,7 +38,6 @@ $listHash = array( 'sort_mode' => empty( $_REQUEST['sort_mode'] ) ? NULL : $_REQUEST['sort_mode'], 'max_rows' => ( !empty( $_REQUEST['max_rows'] ) && is_numeric( $_REQUEST['max_rows'] ) ) ? $_REQUEST['max_rows'] : 10, ); - $nonMembers = $gPigeonholes->getNonPigeonholeMembers( $listHash, $contentSelect, ( !empty( $_REQUEST['include'] ) && $_REQUEST['include'] == 'members' ) ? $_REQUEST['include'] : FALSE ); if( !empty( $_REQUEST['insert_content'] ) && isset( $_REQUEST['pigeonhole'] ) ) { @@ -74,14 +73,18 @@ if( !empty( $_REQUEST['insert_content'] ) && isset( $_REQUEST['pigeonhole'] ) ) $nonMembers = $gPigeonholes->getNonPigeonholeMembers( $listHash, $contentSelect, ( !empty( $_REQUEST['include'] ) && $_REQUEST['include'] == 'members' ) ? $_REQUEST['include'] : FALSE ); } -$pigeonRootData = $gPigeonholes->getList( NULL, TRUE, FALSE ); +$pigeonRootData = $gPigeonholes->getList( array( 'only_get_root' => TRUE ) ); $pigeonRoots[0] = 'All'; foreach( $pigeonRootData['data'] as $root ) { $pigeonRoots[$root['root_structure_id']] = $root['title']; } $gBitSmarty->assign( 'pigeonRoots', !empty( $pigeonRoots ) ? $pigeonRoots : NULL ); -$pigeonList = $gPigeonholes->getList( array( 'root_structure_id' => !empty( $_REQUEST['root_structure_id'] ) ? $_REQUEST['root_structure_id'] : NULL ) , FALSE, TRUE ); +$listHash = array( + 'root_structure_id' => ( !empty( $_REQUEST['root_structure_id'] ) ? $_REQUEST['root_structure_id'] : NULL ), + 'force_extras' => TRUE +); +$pigeonList = $gPigeonholes->getList( $listHash ); $gBitSmarty->assign( 'pigeonList', !empty( $pigeonList['data'] ) ? $pigeonList['data'] : NULL ); $gBitSmarty->assign( 'nonMembers', $nonMembers ); $gBitSmarty->assign( 'contentCount', count( $nonMembers ) ); diff --git a/edit_pigeonholes.php b/edit_pigeonholes.php index 68d44df..eda6aa1 100644 --- a/edit_pigeonholes.php +++ b/edit_pigeonholes.php @@ -1,6 +1,6 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_pigeonholes/edit_pigeonholes.php,v 1.4 2005/10/18 11:06:19 squareing Exp $ + * $Header: /cvsroot/bitweaver/_bit_pigeonholes/edit_pigeonholes.php,v 1.5 2006/01/14 19:55:18 squareing Exp $ * * Copyright ( c ) 2004 bitweaver.org * Copyright ( c ) 2003 tikwiki.org @@ -8,7 +8,7 @@ * All Rights Reserved. See copyright.txt for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details * - * $Id: edit_pigeonholes.php,v 1.4 2005/10/18 11:06:19 squareing Exp $ + * $Id: edit_pigeonholes.php,v 1.5 2006/01/14 19:55:18 squareing Exp $ * @package pigeonholes * @subpackage functions */ @@ -25,6 +25,11 @@ include_once( LIBERTY_PKG_PATH.'LibertyStructure.php' ); include_once( THEMES_PKG_PATH.'theme_control_lib.php' ); include_once( PIGEONHOLES_PKG_PATH.'lookup_pigeonholes_inc.php' ); +if( !empty( $_REQUEST['pigeonhole_store_and_create'] ) ) { + $_REQUEST['pigeonhole_store'] = TRUE; + $_REQUEST['action'] = 'create'; +} + // include edit structure file only when structure_id is known if( !empty( $_REQUEST["structure_id"] ) && ( empty( $_REQUEST['action'] ) || $_REQUEST['action'] != 'remove' ) ) { $verifyStructurePermission = 'bit_p_edit_pigeonholes'; @@ -38,7 +43,6 @@ if( !empty( $_REQUEST["structure_id"] ) && ( empty( $_REQUEST['action'] ) || $_R } global $gStructure; - // store the form if we need to if( !empty( $_REQUEST['pigeonhole_store'] ) ) { if( ( empty( $_REQUEST['pigeonhole']['title'] ) ) ) { @@ -54,7 +58,7 @@ if( !empty( $_REQUEST['pigeonhole_store'] ) ) { $pigeonStore->mContentId = !empty( $_REQUEST['content_id'] ) ? $_REQUEST['content_id'] : NULL; $pigeonStore->load(); if( $pigeonStore->store( $_REQUEST['pigeonhole'] ) ) { - header( "Location: ".$_SERVER['PHP_SELF'].'?structure_id='.$pigeonStore->mStructureId ); + header( "Location: ".$_SERVER['PHP_SELF'].'?structure_id='.$pigeonStore->mStructureId.( !empty( $_REQUEST['action'] ) ? '&action='.$_REQUEST['action'] : '' ) ); } else { vd( $gPigeonholes->mErrors ); $gBitSmarty->assign( 'msg', tra( "There was a problem trying to store the pigeonhole." ) ); @@ -100,7 +104,7 @@ if( !empty( $_REQUEST['search_objects'] ) ) { header( "Location: ".$_SERVER['PHP_SELF'].'?structure_id='.$gPigeonholes->mInfo["parent_id"] ); die; } else { - vd( $gPigeonhole->mErrors ); + vd( $gPigeonholes->mErrors ); } } $gBitSystem->setBrowserTitle( 'Confirm removal of '.$gPigeonholes->mInfo['title'] ); @@ -136,7 +140,8 @@ $gBitSmarty->assign( 'contentSelect', $contentSelect ); $gBitSmarty->assign( 'contentTypes', $contentTypes ); $listHash['root_structure_id'] = $gPigeonholes->mInfo['root_structure_id']; -$pigeonList = $gPigeonholes->getList( $listHash, FALSE, TRUE ); +$listHash['force_extras'] = TRUE; +$pigeonList = $gPigeonholes->getList( $listHash ); $gBitSmarty->assign( 'pigeonList', empty( $pigeonList['data'] ) ? NULL : $pigeonList['data'] ); $gBitSmarty->assign( 'feedback', !empty( $feedback ) ? $feedback : NULL ); diff --git a/edit_structure.php b/edit_structure.php index 51f9101..5f89686 100644 --- a/edit_structure.php +++ b/edit_structure.php @@ -1,6 +1,6 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_pigeonholes/edit_structure.php,v 1.1 2005/08/21 16:22:44 squareing Exp $ + * $Header: /cvsroot/bitweaver/_bit_pigeonholes/edit_structure.php,v 1.2 2006/01/14 19:55:18 squareing Exp $ * * Copyright ( c ) 2004 bitweaver.org * Copyright ( c ) 2003 tikwiki.org @@ -8,7 +8,7 @@ * All Rights Reserved. See copyright.txt for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details * - * $Id: edit_structure.php,v 1.1 2005/08/21 16:22:44 squareing Exp $ + * $Id: edit_structure.php,v 1.2 2006/01/14 19:55:18 squareing Exp $ * @package pigeonholes * @subpackage functions */ @@ -21,6 +21,7 @@ require_once( '../bit_setup_inc.php' ); $gBitSystem->verifyPackage( 'pigeonholes' ); $gBitSystem->verifyPermission( 'bit_p_edit_pigeonholes' ); +$gBitSmarty->assign( 'loadDynamicTree', TRUE ); include_once( PIGEONHOLES_PKG_PATH.'lookup_pigeonholes_inc.php' ); $verifyStructurePermission = 'bit_p_edit_pigeonholes'; @@ -3,7 +3,7 @@ * $Header * * @author xing <xing@synapse.plus.com> - * @version $Revision: 1.3 $ + * @version $Revision: 1.4 $ * @package pigeonholes * @subpackage functions */ @@ -29,9 +29,10 @@ $listHash = array( 'max_rows' => $gBitSystem->mPrefs['maxRecords'], 'offset' => ( $page - 1 ) * $gBitSystem->mPrefs['maxRecords'], 'find' => !empty( $_REQUEST['find'] ) ? $_REQUEST['find'] : NULL, + 'load_only_root' => TRUE, ); -$pigeonList = $gPigeonholes->getList( $listHash, TRUE, FALSE ); +$pigeonList = $gPigeonholes->getList( $listHash ); // set up structure related stuff if( !empty( $pigeonList['data'] ) ) { diff --git a/lookup_pigeonholes_inc.php b/lookup_pigeonholes_inc.php index 2e14224..e3cc4a8 100644 --- a/lookup_pigeonholes_inc.php +++ b/lookup_pigeonholes_inc.php @@ -4,7 +4,7 @@ * * @package pigeonholes * @subpackage functions - * @version $Header: /cvsroot/bitweaver/_bit_pigeonholes/lookup_pigeonholes_inc.php,v 1.1 2005/08/21 16:22:44 squareing Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_pigeonholes/lookup_pigeonholes_inc.php,v 1.2 2006/01/14 19:55:18 squareing Exp $ * * Copyright ( c ) 2005 bitweaver.org * All Rights Reserved. See copyright.txt for details and a complete list of authors. @@ -16,6 +16,7 @@ */ require_once( PIGEONHOLES_PKG_PATH.'/Pigeonholes.php' ); -$gPigeonholes = new Pigeonholes( ( !empty( $_REQUEST['structure_id'] ) ? $_REQUEST['structure_id'] : NULL ), ( !empty( $_REQUEST['content_id'] ) ? $_REQUEST['content_id'] : NULL ), TRUE, TRUE ); +$gPigeonholes = new Pigeonholes( ( !empty( $_REQUEST['structure_id'] ) ? $_REQUEST['structure_id'] : NULL ), ( !empty( $_REQUEST['content_id'] ) ? $_REQUEST['content_id'] : NULL ) ); +$gPigeonholes->load( TRUE ); $gBitSmarty->assign( 'gPigeonholes', $gPigeonholes ); ?> diff --git a/modules/mod_last_changes.php b/modules/mod_last_changes.php index c58be34..ba2dce5 100644 --- a/modules/mod_last_changes.php +++ b/modules/mod_last_changes.php @@ -1,6 +1,6 @@ <?php /** - * @version $Header: /cvsroot/bitweaver/_bit_pigeonholes/modules/Attic/mod_last_changes.php,v 1.3 2005/10/30 21:03:50 lsces Exp $ + * @version $Header: /cvsroot/bitweaver/_bit_pigeonholes/modules/Attic/mod_last_changes.php,v 1.4 2006/01/14 19:55:19 squareing Exp $ * @package liberty * @subpackage modules * Params: @@ -15,7 +15,7 @@ global $gBitUser, $module_rows, $module_params, $gLibertySystem, $module_title; if( $gBitUser->hasPermission( 'bit_p_view_pigeonholes' ) ) { require_once( PIGEONHOLES_PKG_PATH.'Pigeonholes.php' ); - $pigeonholes = new Pigeonholes( NULL, NULL, FALSE ); + $pigeonholes = new Pigeonholes(); $listHash = array( 'title' => !empty( $module_params['category'] ) ? $module_params['category'] : NULL, diff --git a/modules/mod_whats_related.php b/modules/mod_whats_related.php index 515cc63..8fff3bc 100644 --- a/modules/mod_whats_related.php +++ b/modules/mod_whats_related.php @@ -1,6 +1,6 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_pigeonholes/modules/mod_whats_related.php,v 1.2 2005/10/26 17:46:45 squareing Exp $ + * $Header: /cvsroot/bitweaver/_bit_pigeonholes/modules/mod_whats_related.php,v 1.3 2006/01/14 19:55:19 squareing Exp $ * * Copyright (c) 2004 bitweaver.org * Copyright (c) 2003 tikwiki.org @@ -8,7 +8,7 @@ * All Rights Reserved. See copyright.txt for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details * - * $Id: mod_whats_related.php,v 1.2 2005/10/26 17:46:45 squareing Exp $ + * $Id: mod_whats_related.php,v 1.3 2006/01/14 19:55:19 squareing Exp $ * @package categories * @subpackage modules */ @@ -21,7 +21,7 @@ global $gContent; if( isset( $gContent ) ) { if( $gBitUser->hasPermission( 'bit_p_view_pigeonholes' ) ) { require_once( PIGEONHOLES_PKG_PATH.'Pigeonholes.php' ); - $pigeonholes = new Pigeonholes( NULL, NULL, FALSE ); + $pigeonholes = new Pigeonholes(); if( $pigeons = $pigeonholes->getPigeonholesFromContentId( $gContent->mContentId ) ) { foreach( $pigeons as $pigeon ) { diff --git a/servicefunctions_inc.php b/servicefunctions_inc.php index a61d2b6..5798233 100644 --- a/servicefunctions_inc.php +++ b/servicefunctions_inc.php @@ -1,6 +1,6 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_pigeonholes/Attic/servicefunctions_inc.php,v 1.4 2005/10/18 11:31:07 squareing Exp $ + * $Header: /cvsroot/bitweaver/_bit_pigeonholes/Attic/servicefunctions_inc.php,v 1.5 2006/01/14 19:55:18 squareing Exp $ * * Copyright ( c ) 2004 bitweaver.org * All Rights Reserved. See copyright.txt for details and a complete list of authors. @@ -16,7 +16,7 @@ function display_pigeonholes( &$pObject ) { global $gBitSmarty, $gBitUser, $gPreviewStyle; require_once( PIGEONHOLES_PKG_PATH.'Pigeonholes.php' ); - $pigeonholes = new Pigeonholes( NULL, NULL, FALSE ); + $pigeonholes = new Pigeonholes(); $settings = $pigeonholes->getPigeonholeSettings( NULL, $pObject->mContentId ); if( !empty( $settings['style'] ) ) { @@ -44,7 +44,7 @@ function pigeonholes_input_content( $pObject=NULL ) { if( $gBitUser->hasPermission( 'bit_p_insert_pigeonhole_member' ) ) { require_once( PIGEONHOLES_PKG_PATH.'Pigeonholes.php' ); - $pigeonholes = new Pigeonholes( NULL, NULL, FALSE ); + $pigeonholes = new Pigeonholes(); // get pigeonholes path list if( $pigeonPathList = $pigeonholes->getPigeonholesPathList( !empty( $pObject->mContentId ) ? $pObject->mContentId : NULL ) ) { @@ -58,7 +58,7 @@ function pigeonholes_input_content( $pObject=NULL ) { */ function pigeonholes_expunge_member( $pObject=NULL ) { require_once( PIGEONHOLES_PKG_PATH.'Pigeonholes.php' ); - $pigeonholes = new Pigeonholes( NULL, NULL, FALSE ); + $pigeonholes = new Pigeonholes(); $pigeonholes->expungePigeonholeMember( NULL, $pObject->mContentId ); } @@ -72,7 +72,7 @@ function pigeonholes_preview_content() { if( $gBitUser->hasPermission( 'bit_p_insert_pigeonhole_member' ) ) { require_once( PIGEONHOLES_PKG_PATH.'Pigeonholes.php' ); - $pigeonholes = new Pigeonholes( NULL, NULL, FALSE ); + $pigeonholes = new Pigeonholes(); // get pigeonholes path list if( $pigeonPathList = $pigeonholes->getPigeonholesPathList() ) { @@ -102,7 +102,7 @@ function pigeonholes_store_member( $pObject, $pParamHash ) { $pParamHash['content_id'] = $pObject->mContentId; } - $pigeonholes = new Pigeonholes( NULL, NULL, FALSE ); + $pigeonholes = new Pigeonholes(); $pigeonPathList = $pigeonholes->getPigeonholesPathList( $pParamHash['content_id'] ); // here we need to work out if we need to save at all diff --git a/templates/admin_pigeonholes.tpl b/templates/admin_pigeonholes.tpl index b80dfcb..a871232 100644 --- a/templates/admin_pigeonholes.tpl +++ b/templates/admin_pigeonholes.tpl @@ -1,4 +1,4 @@ -{* $Header: /cvsroot/bitweaver/_bit_pigeonholes/templates/admin_pigeonholes.tpl,v 1.1 2005/08/21 16:22:47 squareing Exp $ *} +{* $Header: /cvsroot/bitweaver/_bit_pigeonholes/templates/admin_pigeonholes.tpl,v 1.2 2006/01/14 19:55:19 squareing Exp $ *} {strip} {form} {legend legend="Category Settings"} @@ -14,6 +14,14 @@ {/foreach} <div class="row"> + {formlabel label="List style" for="pigeonholes_list_style"} + {forminput} + {html_options name="pigeonholes_list_style" options=$listStyles values=$listStyles selected=`$gBitSystemPrefs.pigeonholes_list_style` id=pigeonholes_list_style} + {formhelp note="Select the display method. Table listing is better suited for large categories.<br />Custom sorting only works with the dynamic list method."} + {/forminput} + </div> + + <div class="row"> {formlabel label="Number of Members" for="member_number"} {forminput} {html_options name="limit_member_number" options=$memberLimit values=$memberLimit selected=`$gBitSystemPrefs.limit_member_number` id=member_number} diff --git a/templates/edit_pigeonholes.tpl b/templates/edit_pigeonholes.tpl index ed2f2a2..df30670 100644 --- a/templates/edit_pigeonholes.tpl +++ b/templates/edit_pigeonholes.tpl @@ -7,13 +7,71 @@ <div class="body"> {formfeedback hash=$feedback} - {if $gBitUser->hasPermission( 'bit_p_edit_pigeonholes' ) and ( $smarty.request.action eq 'create' or $smarty.request.action eq 'edit' or !$gPigeonholes->mContentId )} - {include file="bitpackage:pigeonholes/edit_pigeonholes_inc.tpl"} - {elseif $gBitUser->hasPermission( 'bit_p_edit_pigeonholes' )} - {smartlink ititle="Insert new Category" ifile="edit_pigeonholes.php" structure_id=`$gPigeonholes->mStructureId` action=create} - <br /> - {/if} + {form legend="Create / Edit Category"} + {if $gPigeonholes->mStructureId} + <input type="hidden" name="structure_id" value="{$gPigeonholes->mStructureId}" /> + <input type="hidden" name="content_id" value="{$pigeonInfo.content_id}" /> + <input type="hidden" name="action" value="{$smarty.request.action}" /> - {include file="bitpackage:pigeonholes/view_structure_inc.tpl" edit=true} + <div class="row"> + {formlabel label="Parent" for="pigeonhole-parent"} + {forminput} + {* we need to disable dropdown when editing since it might confus users when nothing happens *} + {if $pigeonInfo.content_id} + {html_options id="pigeonhole-parent" name="pigeonhole[parent_id]" values=$pigeonStructure options=$pigeonStructure selected=$pigeonInfo.parent_id disabled=disabled} + {else} + {html_options id="pigeonhole-parent" name="pigeonhole[parent_id]" values=$pigeonStructure options=$pigeonStructure selected=$pigeonInfo.parent_id} + {/if} + {formhelp note="Pick where you would like to create a new sub-category. To change the hierarchy of the categories, please visit the change structure page."} + {/forminput} + </div> + {/if} + + <div class="row"> + {formlabel label="Title" for="pigeonhole-title"} + {forminput} + <input type="text" size="50" id="pigeonhole-title" name="pigeonhole[title]" value="{$pigeonInfo.title}" /> + {/forminput} + </div> + + <div class="row"> + {formlabel label="Description" for="pigeonhole-desc"} + {forminput} + <textarea id="pigeonhole-desc" name="pigeonhole[edit]" rows="3" cols="50">{$pigeonInfo.data|escape}</textarea> + {formhelp note="A description of the category. This will be visible when users view this particular category."} + {/forminput} + </div> + + <div class="row"> + {formlabel label="Theme" for="pigeonhole-style"} + {forminput} + {html_options id="pigeonhole-style" name="pigeonhole[settings][style]" output=$styles values=$styles selected=$pigeonInfo.settings.style} + {formhelp note="This theme will be applied when viewing any page belonging to this category."} + {/forminput} + </div> + + <div class="row"> + {formlabel label="Content" for="pigeonhole-content"} + {forminput} + {html_options values=$contentTypes options=$contentTypes name=content_type_guid selected=$contentSelect} + {/forminput} + + {forminput} + {html_options multiple="multiple" size="12" name="pigeonhole[members][]" id="pigeonhole-content" values=$contentList options=$contentList selected=$pigeonInfo.selected_members} + {/forminput} + + {forminput} + <input type="text" size="30" name="find_objects" value="{$smarty.request.find_objects}" /> + <input type="submit" value="{tr}Apply filter{/tr}" name="search_objects" /> + {/forminput} + </div> + + <div class="row submit"> + <input type="submit" name="pigeonhole_store" value="{tr}Save Category{/tr}" /> + <input type="submit" name="pigeonhole_store_and_create" value="{tr}Save and Insert a new Category{/tr}" /> + </div> + {/form} + + {include file="bitpackage:pigeonholes/view_structure_inc.tpl"} </div><!-- end .body --> </div><!-- end .edit --> diff --git a/templates/edit_pigeonholes_inc.tpl b/templates/edit_pigeonholes_inc.tpl deleted file mode 100644 index c378925..0000000 --- a/templates/edit_pigeonholes_inc.tpl +++ /dev/null @@ -1,63 +0,0 @@ -{form legend="Create / Edit Category"} - {if $gPigeonholes->mStructureId} - <input type="hidden" name="structure_id" value="{$gPigeonholes->mStructureId}" /> - <input type="hidden" name="content_id" value="{$pigeonInfo.content_id}" /> - <input type="hidden" name="action" value="{$smarty.request.action}" /> - - <div class="row"> - {formlabel label="Parent" for="pigeonhole-parent"} - {forminput} - {* we need to disable dropdown when editing since it might confus users when nothing happens *} - {if $pigeonInfo.content_id} - {html_options id="pigeonhole-parent" name="pigeonhole[parent_id]" values=$pigeonStructure options=$pigeonStructure selected=$pigeonInfo.parent_id disabled=disabled} - {else} - {html_options id="pigeonhole-parent" name="pigeonhole[parent_id]" values=$pigeonStructure options=$pigeonStructure selected=$pigeonInfo.parent_id} - {/if} - {formhelp note="Pick where you would like to create a new sub-category. To change the hierarchy of the categories, please visit the change structure page."} - {/forminput} - </div> - {/if} - - <div class="row"> - {formlabel label="Title" for="pigeonhole-title"} - {forminput} - <input type="text" size="50" id="pigeonhole-title" name="pigeonhole[title]" value="{$pigeonInfo.title}" /> - {/forminput} - </div> - - <div class="row"> - {formlabel label="Description" for="pigeonhole-desc"} - {forminput} - <textarea id="pigeonhole-desc" name="pigeonhole[edit]" rows="3" cols="50">{$pigeonInfo.data|escape}</textarea> - {formhelp note="A description of the category. This will be visible when users view this particular category."} - {/forminput} - </div> - - <div class="row"> - {formlabel label="Theme" for="pigeonhole-style"} - {forminput} - {html_options id="pigeonhole-style" name="pigeonhole[settings][style]" output=$styles values=$styles selected=$pigeonInfo.settings.style} - {formhelp note="This theme will be applied when viewing any page belonging to this category."} - {/forminput} - </div> - - <div class="row"> - {formlabel label="Content" for="pigeonhole-content"} - {forminput} - {html_options values=$contentTypes options=$contentTypes name=content_type_guid selected=$contentSelect} - {/forminput} - - {forminput} - {html_options multiple="multiple" size="12" name="pigeonhole[members][]" id="pigeonhole-content" values=$contentList options=$contentList selected=$pigeonInfo.selected_members} - {/forminput} - - {forminput} - <input type="text" size="30" name="find_objects" value="{$smarty.request.find_objects}" /> - <input type="submit" value="{tr}Apply filter{/tr}" name="search_objects" /> - {/forminput} - </div> - - <div class="row submit"> - <input type="submit" name="pigeonhole_store" value="{tr}Save Category{/tr}" /> - </div> -{/form} diff --git a/templates/edit_structure.tpl b/templates/edit_structure.tpl index 196637f..50cf64c 100644 --- a/templates/edit_structure.tpl +++ b/templates/edit_structure.tpl @@ -6,6 +6,6 @@ </div> <div class="body"> - {include file="bitpackage:liberty/edit_structure_inc.tpl" hide_extended=TRUE} + {include file="bitpackage:liberty/edit_structure_inc.tpl" no_delete=TRUE} </div><!-- end .body --> </div><!-- end .edit --> diff --git a/templates/list.tpl b/templates/list.tpl index 57365e3..dbb2d0c 100644 --- a/templates/list.tpl +++ b/templates/list.tpl @@ -32,7 +32,7 @@ <h2>{$item.display_link}</h2> {$item.data} </td> - <td style="white-space:nowrap">{include file="bitpackage:pigeonholes/view_structure_inc.tpl" plain=true subtree=$item.subtree}</td> + <td style="white-space:nowrap">{include file="bitpackage:pigeonholes/view_structure_inc.tpl" no_edit=TRUE subtree=$item.subtree}</td> {if $gBitUser->hasPermission( 'bit_p_edit_pigeonholes' )} <td class="actionicon"> {smartlink ititle="Insert new Category" ifile="edit_pigeonholes.php" ibiticon="liberty/new" structure_id=`$item.structure_id` action=create} diff --git a/templates/section_inc.tpl b/templates/section_inc.tpl new file mode 100644 index 0000000..ba61ae1 --- /dev/null +++ b/templates/section_inc.tpl @@ -0,0 +1,149 @@ +{strip} +{if $list_style == "table"} + + {* ======= this display method requires "alphabetisation" ======= *} + <h3><a href="{$smarty.const.PIGEONHOLES_PKG_URL}view.php?structure_id={$subtree[ix].structure_id}">{$subtree[ix].title}</a></h3> + + {foreach from=$pigeonList item=pigeonItem} + {if $pigeonItem.structure_id eq $subtree[ix].structure_id && $pigeonItem.members} + {$pigeonItem.data|escape} + <table class="data"><tr> + {*use a fixed number here for now, we can change this eventually with a preference*} + {math equation="100 / x" x=3 assign=width format="%u"} + {foreach from=$pigeonItem.members item=pigeonColumn} + <td style="vertical-align:top; width:{$width}%;"> + {foreach from=$pigeonColumn item=members key=index} + <h2>{$index}</h2> + <ul> + {foreach from=$members item=member} + <li> + <a href="{$smarty.const.BIT_ROOT_URL}index.php?content_id={$member.content_id}">{$member.title}</a> + <br /> + <small>{$member.content_type_description}</small> + </li> + {/foreach} + </ul> + {/foreach} + </td> + {/foreach} + </tr></table> + {/if} + {/foreach} + +{elseif $list_style == "dynamic"} + + {* ======= crazy display for only few category memebers - only display method that allows custom sorting ======= *} + {if $gPigeonholes->mStructureId eq $subtree[ix].structure_id or $smarty.request.expand_all} + {assign var=iname value=Expanded} + {else} + {assign var=iname value=Collapsed} + {/if} + + <div class="highlight"> + {if $edit} + <div class="floaticon"> + {smartlink ititle="Edit Category" ibiticon="liberty/edit" ifile="edit_pigeonholes.php" structure_id=$subtree[ix].structure_id action=edit} + {smartlink ititle="Remove Category" ibiticon="liberty/delete" ifile="edit_pigeonholes.php" structure_id=$subtree[ix].structure_id action=remove} + </div> + {/if} + + <a href="javascript:icntoggle('sid{$subtree[ix].structure_id}');"> + {biticon ipackage=liberty iname=$iname id=sid`$subtree[ix].structure_id`img"} {$subtree[ix].title} + </a> + + <script type="text/javascript"> + setfoldericonstate('sid{$subtree[ix].structure_id}'); + </script> + + {foreach from=$pigeonList item=pigeonItem} + {if $pigeonItem.structure_id eq $subtree[ix].structure_id} + <small> {tr}{$pigeonItem.members_count} Item(s){/tr} </small> + {/if} + {/foreach} + + <noscript> + <div style="padding-left:18px;" class="small"><a href="{$smarty.const.PIGEONHOLES_PKG_URL}{if $edit}edit_pigeonholes{else}index{/if}.php?structure_id={$subtree[ix].structure_id}">{tr}Expand{/tr}</a></div> + </noscript> + </div> + + {foreach from=$pigeonList item=pigeonItem} + {if $pigeonItem.structure_id eq $subtree[ix].structure_id} + <small>{$pigeonItem.data|escape}</small> + + {if $pigeonItem.members} + <ul id="sid{$subtree[ix].structure_id}" style="display:{if $gPigeonholes->mStructureId eq $subtree[ix].structure_id or $smarty.request.expand_all}block{else}none{/if};" class="data"> + {foreach from=$pigeonItem.members item=pigeonMember} + {if $gBitSystem->isFeatureActive( 'custom_member_sorting' )} + <li> + {if $edit && $gBitSystem->isFeatureActive( 'custom_member_sorting' )} + {if $pigeonMember.pos ne 1} + {smartlink ititle="Move item up" ibiticon="liberty/nav_up" expand_all=$smarty.request.expand_all ifile="edit_pigeonholes.php" action=move orientation=north structure_id=$pigeonItem.structure_id parent_id=$pigeonItem.content_id member_id=$pigeonMember.content_id} + {else} + {biticon ipackage="liberty" iname="spacer"} + {/if} + + {if $pigeonMember.pos ne $pigeonItem.members_count} + {smartlink ititle="Move item down" ibiticon="liberty/nav_down" expand_all=$smarty.request.expand_all ifile="edit_pigeonholes.php" action=move orientation=south structure_id=$pigeonItem.structure_id parent_id=$pigeonItem.content_id member_id=$pigeonMember.content_id} + {else} + {biticon ipackage="liberty" iname="spacer"} + {/if} + {/if} + <a href="{$smarty.const.BIT_ROOT_URL}index.php?content_id={$pigeonMember.content_id}">{$pigeonMember.title}</a> + {if $edit} + {smartlink ititle="Remove Item" ibiticon="liberty/delete_small" expand_all=$smarty.request.expand_all ifile="edit_pigeonholes.php" action=demember structure_id=$pigeonItem.structure_id parent_id=$pigeonMember.content_id content_id=$pigeonItem.content_id} + {/if} + </li> + {else} + {assign var=ctg1 value=$pigeonMember.content_type_guid} + + {* close off the content type <ul> *} + {if $ctg1 ne $ctg2 and $ctg2} + </ul> + </li> + {/if} + + {* open the content type <ul> *} + {if $ctg1 ne $ctg2} + <li>{$gLibertySystem->mContentTypes.$ctg1.content_description} + <ul> + {/if} + + <li> + <a href="{$smarty.const.BIT_ROOT_URL}index.php?content_id={$pigeonMember.content_id}">{$pigeonMember.title}</a> + {if $edit} + {smartlink ititle="Remove Item" ibiticon="liberty/delete_small" expand_all=$smarty.request.expand_all ifile="edit_pigeonholes.php" action=demember structure_id=$pigeonItem.structure_id parent_id=$pigeonMember.content_id content_id=$pigeonItem.content_id} + {/if} + </li> + + {assign var=ctg2 value=$pigeonMember.content_type_guid} + {/if} + {/foreach} + + {if !$gBitSystem->isFeatureActive( 'custom_member_sorting' )} + </ul> + </li> + {/if} + </ul> + {/if} + {/if} + {/foreach} + +{else} + + {* ======= very basic display of the pigoenhole structure ======= *} + {if !$no_edit} + <div class="floaticon"> + {smartlink ititle="Edit Category" ibiticon="liberty/edit" ifile="edit_pigeonholes.php" structure_id=$subtree[ix].structure_id action=edit} + {smartlink ititle="Remove Category" ibiticon="liberty/delete" ifile="edit_pigeonholes.php" structure_id=$subtree[ix].structure_id action=remove} + </div> + {/if} + + <h3><a href="{$smarty.const.PIGEONHOLES_PKG_URL}view.php?structure_id={$subtree[ix].structure_id}">{$subtree[ix].title}</a></h3> + + {foreach from=$pigeonList item=pigeonItem} + {if $pigeonItem.structure_id eq $subtree[ix].structure_id and $pigeonItem.members_count} + {tr}{$pigeonItem.members_count} Item(s){/tr} + {/if} + {/foreach} +{/if} +{/strip} diff --git a/templates/view_structure_inc.tpl b/templates/view_structure_inc.tpl index 164685a..e8b3a88 100644 --- a/templates/view_structure_inc.tpl +++ b/templates/view_structure_inc.tpl @@ -4,20 +4,11 @@ {section name=ix loop=$subtree} {assign var=structId value=$subtree[ix].structure_id} {if $subtree[ix].pos eq ''} - {if $plain} - {$subtree[ix].title} - {else} - {include file="bitpackage:pigeonholes/structure_section_inc.tpl"} - {/if} + {include file="bitpackage:pigeonholes/section_inc.tpl"} {else} {if $subtree[ix].first}<ul>{else}</li>{/if} {if $subtree[ix].last}</ul>{else} - <li> - {if $plain} - {$subtree[ix].title} - {else} - {include file="bitpackage:pigeonholes/structure_section_inc.tpl"} - {/if} + <li>{include file="bitpackage:pigeonholes/section_inc.tpl"} {/if} {/if} {/section} @@ -1,6 +1,6 @@ <?php /** - * $Header: /cvsroot/bitweaver/_bit_pigeonholes/view.php,v 1.1 2005/08/21 16:22:45 squareing Exp $ + * $Header: /cvsroot/bitweaver/_bit_pigeonholes/view.php,v 1.2 2006/01/14 19:55:19 squareing Exp $ * * Copyright ( c ) 2004 bitweaver.org * Copyright ( c ) 2003 tikwiki.org @@ -8,7 +8,7 @@ * All Rights Reserved. See copyright.txt for details and a complete list of authors. * Licensed under the GNU LESSER GENERAL PUBLIC LICENSE. See license.txt for details * - * $Id: view.php,v 1.1 2005/08/21 16:22:45 squareing Exp $ + * $Id: view.php,v 1.2 2006/01/14 19:55:19 squareing Exp $ * @package pigeonholes * @subpackage functions */ @@ -37,9 +37,10 @@ $gBitSmarty->assign_by_ref( 'gStructure', $gStructure ); $gBitSmarty->assign( 'structureInfo', $gStructure->mInfo ); $gBitSmarty->assign( 'subtree', $gStructure->getSubTree( $gStructure->mStructureId ) ); -$listHash = array( 'root_structure_id' => $gPigeonholes->mInfo['root_structure_id'] ); -$pigeonList = $gPigeonholes->getList( $listHash, FALSE, TRUE ); +$listHash = array( 'root_structure_id' => $gPigeonholes->mInfo['root_structure_id'], 'structure_id' => $gPigeonholes->mInfo['structure_id'], 'load_extras' => TRUE ); +$pigeonList = $gPigeonholes->getList( $listHash ); $gBitSmarty->assign( 'pigeonList', $pigeonList['data'] ); +$gBitSmarty->assign( 'list_style', $gBitSystem->getPreference( 'pigeonholes_list_style', 'dynamic' ) ); // Display the template $gBitSystem->display( 'bitpackage:pigeonholes/view_structure.tpl', tra( 'View Pigeonhole' ) ); |
