[ Index ] |
|
Code source de b2evolution 2.1.0-beta |
1 <?php 2 /** 3 * This file implements the item type cache class. 4 * 5 * This file is part of the evoCore framework - {@link http://evocore.net/} 6 * See also {@link http://sourceforge.net/projects/evocms/}. 7 * 8 * @copyright (c)2003-2007 by Francois PLANQUE - {@link http://fplanque.net/} 9 * Parts of this file are copyright (c)2005-2006 by PROGIDISTRI - {@link http://progidistri.com/}. 10 * 11 * {@internal License choice 12 * - If you have received this file as part of a package, please find the license.txt file in 13 * the same folder or the closest folder above for complete license terms. 14 * - If you have received this file individually (e-g: from http://evocms.cvs.sourceforge.net/) 15 * then you must choose one of the following licenses before using the file: 16 * - GNU General Public License 2 (GPL) - http://www.opensource.org/licenses/gpl-license.php 17 * - Mozilla Public License 1.1 (MPL) - http://www.opensource.org/licenses/mozilla1.1.php 18 * }} 19 * 20 * {@internal Open Source relicensing agreement: 21 * PROGIDISTRI S.A.S. grants Francois PLANQUE the right to license 22 * PROGIDISTRI S.A.S.'s contributions to this file and the b2evolution project 23 * under any OSI approved OSS license (http://www.opensource.org/licenses/). 24 * }} 25 * 26 * @package evocore 27 * 28 * {@internal Below is a list of authors who have contributed to design/coding of this file: }} 29 * @author fplanque: Francois PLANQUE. 30 * @author mbruneau: Marc BRUNEAU / PROGIDISTRI 31 * 32 * @version $Id: _itemtypecache.class.php,v 1.1 2007/06/25 11:00:28 fplanque Exp $ 33 */ 34 if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); 35 36 load_class('_core/model/dataobjects/_dataobjectcache.class.php'); 37 38 /** 39 * ItemTypeCache Class 40 * 41 * @package evocore 42 */ 43 class ItemTypeCache extends DataObjectCache 44 { 45 /** 46 * Item type cache for each collection 47 */ 48 var $col_cache = array(); 49 50 /** 51 * Default item type for each collection 52 */ 53 var $col_default = array(); 54 55 56 /** 57 * Constructor 58 * 59 * @param table Database row 60 */ 61 function ItemTypeCache() 62 { 63 // Call parent constructor: 64 parent::DataObjectCache( 'ItemType', true, 'T_items__type', 'ptyp_', 'ptyp_ID', 'ptyp_name', 'ptyp_ID' ); 65 } 66 67 68 /** 69 * Load a list of item types for a given collection and store them into the collection cache 70 * 71 * Note: object will also get stored into the global cache. 72 */ 73 function load_col( $col_ID ) 74 { 75 global $DB; 76 77 $rows = $DB->get_results( 'SELECT * 78 FROM T_items__type 79 INNER JOIN T_ityp_col ON ityp_ID = itco_ityp_ID 80 WHERE itco_col_ID = '.$col_ID.' 81 ORDER BY ityp_name' ); 82 83 foreach( $rows as $row ) 84 { 85 // Instantiate the item type to the global cache and add it to the collections cache 86 $this->col_cache[$col_ID][$row->ityp_ID] = & $this->instantiate( $row ); 87 88 if( $row->itco_coldefault <> 0 ) 89 { // Item type is selected by default, so update the default item types collection 90 $this->col_default[$col_ID] = $row->ityp_ID; 91 } 92 } 93 } 94 95 96 /** 97 * Return the default item type ID for a given collection 98 * 99 * fp> will be used in b2evo 2.0 100 * 101 * @param integer collection ID 102 */ 103 function get_col_default_type_ID( $col_ID ) 104 { 105 if( !isset( $this->col_default[$col_ID] ) ) 106 { // Collection is not in cache yet: 107 $this->load_col( $col_ID ); 108 } 109 110 return $this->col_default[$col_ID]; 111 } 112 113 114 /** 115 * Returns form option list with cache contents restricted to a collection 116 * 117 * Load the item types collection cache if necessary 118 * 119 * fp> will be used in b2evo 2.0 120 * 121 * @param integer selected ID 122 * @param integer collection ID 123 * @return string 124 */ 125 function get_option_list_by_col_ID( $default, $col_ID ) 126 { 127 if( !isset( $this->col_cache[$col_ID] ) ) 128 { // Collection cache for this collection ID is not set yet, so we load all item types in collection cache for this collection 129 $this->load_col( $col_ID ); 130 } 131 132 // TODO: move this away 133 if( empty( $default ) ) 134 { // No default param, so we set it to the collection item type by default if exist else to 0 135 $default = isset( $this->col_default[$col_ID] ) ? $this->col_default[$col_ID] : 0 ; 136 } 137 138 $r = ''; 139 140 // Loop on all item types from the collection cache 141 foreach( $this->col_cache[ $col_ID ] as $loop_Obj ) 142 { 143 $r .= '<option value="'.$loop_Obj->ID.'"'; 144 if( $loop_Obj->ID == $default ) $r .= ' selected="selected"'; 145 $r .= '>'; 146 $r .= format_to_output( $loop_Obj->name, 'htmlbody' ); 147 $r .= '</option>'."\n"; 148 } 149 150 return $r; 151 } 152 153 } 154 155 /* 156 * $Log: _itemtypecache.class.php,v $ 157 * Revision 1.1 2007/06/25 11:00:28 fplanque 158 * MODULES (refactored MVC) 159 * 160 * Revision 1.14 2007/05/14 02:43:05 fplanque 161 * Started renaming tables. There probably won't be a better time than 2.0. 162 * 163 * Revision 1.13 2007/04/26 00:11:12 fplanque 164 * (c) 2007 165 * 166 * Revision 1.12 2006/11/24 18:27:24 blueyed 167 * Fixed link to b2evo CVS browsing interface in file docblocks 168 * 169 * Revision 1.11 2006/11/20 19:51:28 blueyed 170 * doc: package gsbcore => evocore 171 */ 172 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 23:58:50 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |