[ Index ] |
|
Code source de b2evolution 2.1.0-beta |
1 <?php 2 /** 3 * This file implements the Generic Ordered 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: _genericorderedcache.class.php,v 1.1 2007/06/25 11:00:18 fplanque Exp $ 33 */ 34 if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' ); 35 36 load_class('generic/model/_genericcache.class.php'); 37 38 /** 39 * GenericOrderedCache Class 40 * @package evocore 41 */ 42 class GenericOrderedCache extends GenericCache 43 { 44 /** 45 * Constructor 46 */ 47 function GenericOrderedCache( $objtype, $load_all, $tablename, $prefix = '', $dbIDname = 'ID', $name_field = NULL ) 48 { 49 parent::GenericCache( $objtype, $load_all, $tablename, $prefix, $dbIDname, $name_field ); 50 } 51 52 53 /** 54 * Move up the element order in database 55 * 56 * @param integer id element 57 * @return unknown 58 */ 59 function move_up_by_ID( $id ) 60 { 61 global $DB, $Messages, $result_fadeout; 62 63 $DB->begin(); 64 65 if( ($obj_sup = & $this->get_by_ID( $id )) === false ) 66 { 67 $Messages->head = T_('Cannot edit entry!'); 68 $Messages->add( T_('Requested entry does not exist any longer.'), 'error' ); 69 $DB->commit(); 70 return false; 71 } 72 $order = $obj_sup->order; 73 74 // Get the ID of the inferior element which his order is the nearest 75 $rows = $DB->get_results( 'SELECT '.$this->dbIDname 76 .' FROM '.$this->dbtablename 77 .' WHERE '.$this->dbprefix.'order < '.$order 78 .' ORDER BY '.$this->dbprefix.'order DESC 79 LIMIT 0,1' ); 80 81 if( count( $rows ) ) 82 { 83 // instantiate the inferior element 84 $obj_inf = & $this->get_by_ID( $rows[0]->{$this->dbIDname} ); 85 86 // Update element order 87 $obj_sup->set( 'order', $obj_inf->order ); 88 $obj_sup->dbupdate(); 89 90 // Update inferior element order 91 $obj_inf->set( 'order', $order ); 92 $obj_inf->dbupdate(); 93 94 // EXPERIMENTAL FOR FADEOUT RESULT 95 $result_fadeout[$this->dbIDname][] = $id; 96 $result_fadeout[$this->dbIDname][] = $obj_inf->ID; 97 } 98 else 99 { 100 $Messages->add( T_('This element is already at the top.'), 'error' ); 101 } 102 $DB->commit(); 103 } 104 105 106 /** 107 * Move down the element order in database 108 * 109 * @param integer id element 110 * @return unknown 111 */ 112 function move_down_by_ID( $id ) 113 { 114 global $DB, $Messages, $result_fadeout; 115 116 $DB->begin(); 117 118 if( ($obj_inf = & $this->get_by_ID( $id )) === false ) 119 { 120 $Messages->head = T_('Cannot edit entry!'); 121 $Messages->add( T_('Requested entry does not exist any longer.'), 'error' ); 122 $DB->commit(); 123 return false; 124 } 125 $order = $obj_inf->order; 126 127 // Get the ID of the inferior element which his order is the nearest 128 $rows = $DB->get_results( 'SELECT '.$this->dbIDname 129 .' FROM '.$this->dbtablename 130 .' WHERE '.$this->dbprefix.'order > '.$order 131 .' ORDER BY '.$this->dbprefix.'order ASC 132 LIMIT 0,1' ); 133 134 if( count( $rows ) ) 135 { 136 // instantiate the inferior element 137 $obj_sup = & $this->get_by_ID( $rows[0]->{$this->dbIDname} ); 138 139 // Update element order 140 $obj_inf->set( 'order', $obj_sup->order ); 141 $obj_inf->dbupdate(); 142 143 // Update inferior element order 144 $obj_sup->set( 'order', $order ); 145 $obj_sup->dbupdate(); 146 147 // EXPERIMENTAL FOR FADEOUT RESULT 148 $result_fadeout[$this->dbIDname][] = $id; 149 $result_fadeout[$this->dbIDname][] = $obj_sup->ID; 150 } 151 else 152 { 153 $Messages->add( T_('This element is already at the bottom.'), 'error' ); 154 } 155 $DB->commit(); 156 } 157 158 } 159 160 /* 161 * $Log: _genericorderedcache.class.php,v $ 162 * Revision 1.1 2007/06/25 11:00:18 fplanque 163 * MODULES (refactored MVC) 164 * 165 * Revision 1.7 2007/06/11 22:01:53 blueyed 166 * doc fixes 167 * 168 * Revision 1.6 2007/04/26 00:11:11 fplanque 169 * (c) 2007 170 * 171 * Revision 1.5 2006/11/26 01:42:09 fplanque 172 * doc 173 */ 174 ?>
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 |
![]() |