b2evolution

Multilingual multiuser multiblog engine

b2evolution Technical Documentation (CVS HEAD) [ class tree: evocore ] [ index: evocore ] [ all elements ]

Source for file _genericorderedcache.class.php

Documentation is available at _genericorderedcache.class.php

  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-2010 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.6 2010/02/08 17:53:03 efy-yury 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''GenericCache' );
  37.  
  38. /**
  39.  * GenericOrderedCache Class
  40.  * @package evocore
  41.  */
  42. {
  43.     /**
  44.      * Constructor
  45.      */
  46.     function GenericOrderedCache$objtype$load_all$tablename$prefix ''$dbIDname 'ID'$name_field NULL )
  47.     {
  48.         parent::GenericCache$objtype$load_all$tablename$prefix$dbIDname$name_field );
  49.     }
  50.  
  51.  
  52.     /**
  53.      * Move up the element order in database
  54.      *
  55.      * @param integer id element
  56.      * @return unknown 
  57.      */
  58.     function move_up_by_ID$id )
  59.     {
  60.         global $DB$Messages$result_fadeout;
  61.  
  62.         $DB->begin();
  63.  
  64.         if( ($obj_sup $this->get_by_ID$id )) === false )
  65.         {
  66.         $Messages->addsprintfT_('Requested &laquo;%s&raquo; object does not exist any longer.')T_('Entry') )'error' );
  67.             $DB->commit();
  68.             return false;
  69.         }
  70.         $order $obj_sup->order;
  71.  
  72.         // Get the ID of the inferior element which his order is the nearest
  73.         $rows $DB->get_results'SELECT '.$this->dbIDname
  74.                                                              .' FROM '.$this->dbtablename
  75.                                                          .' WHERE '.$this->dbprefix.'order < '.$order
  76.                                                     .' ORDER BY '.$this->dbprefix.'order DESC
  77.                                                                  LIMIT 0,1' );
  78.  
  79.         ifcount$rows ) )
  80.         {
  81.             // instantiate the inferior element
  82.             $obj_inf $this->get_by_ID$rows[0]->{$this->dbIDname);
  83.  
  84.             // Update element order
  85.             $obj_sup->set'order'$obj_inf->order );
  86.             $obj_sup->dbupdate();
  87.  
  88.             // Update inferior element order
  89.             $obj_inf->set'order'$order );
  90.             $obj_inf->dbupdate();
  91.  
  92.             // EXPERIMENTAL FOR FADEOUT RESULT
  93.             $result_fadeout[$this->dbIDname][$id;
  94.             $result_fadeout[$this->dbIDname][$obj_inf->ID;
  95.         }
  96.         else
  97.         {
  98.             $Messages->addT_('This element is already at the top.')'error' );
  99.         }
  100.         $DB->commit();
  101.     }
  102.  
  103.  
  104.     /**
  105.      * Move down the element order in database
  106.      *
  107.      * @param integer id element
  108.      * @return unknown 
  109.      */
  110.     function move_down_by_ID$id )
  111.     {
  112.         global $DB$Messages$result_fadeout;
  113.  
  114.         $DB->begin();
  115.  
  116.         if( ($obj_inf $this->get_by_ID$id )) === false )
  117.         {
  118.             $Messages->addsprintfT_('Requested &laquo;%s&raquo; object does not exist any longer.')T_('Entry') )'error' );
  119.             $DB->commit();
  120.             return false;
  121.         }
  122.         $order $obj_inf->order;
  123.  
  124.         // Get the ID of the inferior element which his order is the nearest
  125.         $rows $DB->get_results'SELECT '.$this->dbIDname
  126.                                                              .' FROM '.$this->dbtablename
  127.                                                          .' WHERE '.$this->dbprefix.'order > '.$order
  128.                                                     .' ORDER BY '.$this->dbprefix.'order ASC
  129.                                                                  LIMIT 0,1' );
  130.  
  131.         ifcount$rows ) )
  132.         {
  133.             // instantiate the inferior element
  134.             $obj_sup $this->get_by_ID$rows[0]->{$this->dbIDname);
  135.  
  136.             //  Update element order
  137.             $obj_inf->set'order'$obj_sup->order );
  138.             $obj_inf->dbupdate();
  139.  
  140.             // Update inferior element order
  141.             $obj_sup->set'order'$order );
  142.             $obj_sup->dbupdate();
  143.  
  144.             // EXPERIMENTAL FOR FADEOUT RESULT
  145.             $result_fadeout[$this->dbIDname][$id;
  146.             $result_fadeout[$this->dbIDname][$obj_sup->ID;
  147.         }
  148.         else
  149.         {
  150.             $Messages->addT_('This element is already at the bottom.')'error' );
  151.         }
  152.         $DB->commit();
  153.     }
  154.  
  155. }
  156.  
  157. /*
  158.  * $Log: _genericorderedcache.class.php,v $
  159.  * Revision 1.6  2010/02/08 17:53:03  efy-yury
  160.  * copyright 2009 -> 2010
  161.  *
  162.  * Revision 1.5  2009/09/14 13:11:37  efy-arrin
  163.  * Included the ClassName in load_class() call with proper UpperCase
  164.  *
  165.  * Revision 1.4  2009/08/30 19:54:25  fplanque
  166.  * less translation messgaes for infrequent errors
  167.  *
  168.  * Revision 1.3  2009/03/08 23:57:43  fplanque
  169.  * 2009
  170.  *
  171.  * Revision 1.2  2008/01/21 09:35:30  fplanque
  172.  * (c) 2008
  173.  *
  174.  * Revision 1.1  2007/06/25 11:00:18  fplanque
  175.  * MODULES (refactored MVC)
  176.  *
  177.  * Revision 1.7  2007/06/11 22:01:53  blueyed
  178.  * doc fixes
  179.  *
  180.  * Revision 1.6  2007/04/26 00:11:11  fplanque
  181.  * (c) 2007
  182.  *
  183.  * Revision 1.5  2006/11/26 01:42:09  fplanque
  184.  * doc
  185.  */
  186. ?>

Documentation generated on Sat, 06 Mar 2010 04:11:51 +0100 by phpDocumentor 1.4.2. This site is hosted and maintained by Daniel HAHLER (Contact).