b2evolution PHP Cross Reference Blogging Systems

Source: /inc/generic/model/_genericcategory.class.php - 140 lines - 3608 bytes - Summary - Text - Print

Description: This file implements the GenericCategory class. This file is part of the evoCore framework - {@link http://evocore.net/} See also {@link http://sourceforge.net/projects/evocms/}.

   1  <?php
   2  /**
   3   * This file implements the GenericCategory 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-2014 by Francois Planque - {@link http://fplanque.com/}
   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   * @author fplanque: Francois PLANQUE.
  29   * @author mbruneau: Marc BRUNEAU / PROGIDISTRI
  30   *
  31   * @version $Id: _genericcategory.class.php 6136 2014-03-08 07:59:48Z manuel $
  32   */
  33  if( !defined('EVO_MAIN_INIT') ) die( 'Please, do not access this page directly.' );
  34  
  35  
  36  load_class('generic/model/_genericelement.class.php', 'GenericElement');
  37  
  38  
  39  /**
  40   * GenericCategory Class
  41   *
  42   * @package evocore
  43   */
  44  class GenericCategory extends GenericElement
  45  {
  46      var $parent_ID;
  47      /**
  48       * To display parent name in form
  49       */
  50      var $parent_name;
  51  
  52      /**
  53       * Category children list
  54       */
  55      var $children = array();
  56  
  57      /**
  58       * Constructor
  59       *
  60       * @param string Table name
  61       * @param string
  62       * @param string DB ID name
  63       * @param array|NULL Database row
  64       */
  65  	function GenericCategory( $tablename, $prefix = '', $dbIDname = 'ID', $db_row = NULL )
  66      {
  67          global $Debuglog;
  68  
  69          // Call parent constructor:
  70          parent::GenericElement( $tablename, $prefix, $dbIDname, $db_row );
  71  
  72          if( $db_row != NULL )
  73          {
  74              $parentIDfield = $prefix.'parent_ID';
  75              $this->parent_ID = $db_row->$parentIDfield;
  76          }
  77      }
  78  
  79  
  80      /**
  81       * Load data from Request form fields.
  82       *
  83       * @todo fp> check that we are not creating a loop!
  84       *
  85       * @return boolean true if loaded data seems valid.
  86       */
  87  	function load_from_request()
  88      {
  89          parent::load_from_Request();
  90  
  91          if( param( $this->dbprefix.'parent_ID', 'integer', -1 ) !== -1 )
  92          {
  93              $this->set_from_Request( 'parent_ID' );
  94          }
  95  
  96          return ! param_errors_detected();
  97      }
  98  
  99  
 100      /**
 101       * Set param value
 102       *
 103       * By default, all values will be considered strings
 104       *
 105       * @param string parameter name
 106       * @param mixed parameter value
 107       * @param boolean true to set to NULL if empty value
 108       * @return boolean true, if a value has been set; false if it has not changed
 109       */
 110  	function set( $parname, $parvalue, $make_null = false )
 111      {
 112          switch( $parname )
 113          {
 114               case 'parent_ID':
 115                  return $this->set_param( $parname, 'string', $parvalue, true );
 116  
 117              case 'name':
 118              case 'urlname':
 119              case 'description':
 120              default:
 121                  return $this->set_param( $parname, 'string', $parvalue, $make_null );
 122          }
 123      }
 124  
 125  
 126      /**
 127       * Add a child
 128       * @param GenericCategory
 129       */
 130  	function add_child_category( & $GenericCategory )
 131      {
 132          if( !isset( $this->children[$GenericCategory->ID] ) )
 133          { // Add only if it was not added yet
 134              $this->children[$GenericCategory->ID] = & $GenericCategory;
 135          }
 136      }
 137  
 138  }
 139  
 140  ?>

title

Description

title

Description

title

Description

title

title

Body