1: <?php
  2: /**
  3:  * This file contains the container configuration collection and item class.
  4:  *
  5:  * @package Core
  6:  * @subpackage GenericDB_Model
  7:  * @version SVN Revision $Rev:$
  8:  *
  9:  * @author Timo Hummel
 10:  * @copyright four for business AG <www.4fb.de>
 11:  * @license http://www.contenido.org/license/LIZENZ.txt
 12:  * @link http://www.4fb.de
 13:  * @link http://www.contenido.org
 14:  */
 15: 
 16: defined('CON_FRAMEWORK') || die('Illegal call: Missing framework initialization - request aborted.');
 17: 
 18: /**
 19:  * Container configuration collection
 20:  *
 21:  * @package Core
 22:  * @subpackage GenericDB_Model
 23:  */
 24: class cApiContainerConfigurationCollection extends ItemCollection {
 25: 
 26:     /**
 27:      * Create a new collection of items.
 28:      *
 29:      * @param string $select where clause to use for selection (see
 30:      *            ItemCollection::select())
 31:      */
 32:     public function __construct($select = false) {
 33:         global $cfg;
 34:         parent::__construct($cfg['tab']['container_conf'], 'idcontainerc');
 35:         $this->_setItemClass('cApiContainerConfiguration');
 36: 
 37:         // set the join partners so that joins can be used via link() method
 38:         $this->_setJoinPartner('cApiTemplateConfigurationCollection');
 39: 
 40:         if ($select !== false) {
 41:             $this->select($select);
 42:         }
 43:     }
 44: 
 45:     /**
 46:      *
 47:      * @param int $idtplcfg
 48:      * @param int $number
 49:      * @param string $container
 50:      */
 51:     public function create($idtplcfg, $number, $container) {
 52:         $item = parent::createNewItem();
 53:         $item->set('idtplcfg', $idtplcfg);
 54:         $item->set('number', $number);
 55:         $item->set('container', $container);
 56:         $item->store();
 57:     }
 58: }
 59: 
 60: /**
 61:  * Container configuration item
 62:  *
 63:  * @package Core
 64:  * @subpackage GenericDB_Model
 65:  */
 66: class cApiContainerConfiguration extends Item {
 67: 
 68:     /**
 69:      * Constructor Function
 70:      *
 71:      * @param mixed $mId Specifies the ID of item to load
 72:      */
 73:     public function __construct($mId = false) {
 74:         global $cfg;
 75:         parent::__construct($cfg['tab']['container_conf'], 'idcontainerc');
 76:         $this->setFilters(array(), array());
 77:         if ($mId !== false) {
 78:             $this->loadByPrimaryKey($mId);
 79:         }
 80:     }
 81: 
 82:     /**
 83:      * Userdefined setter for container config fields.
 84:      *
 85:      * @param string $name
 86:      * @param mixed $value
 87:      * @param bool $bSafe Flag to run defined inFilter on passed value
 88:      * @todo should return return value of overloaded method
 89:      */
 90:     public function setField($name, $value, $bSafe = true) {
 91:         switch ($name) {
 92:             case 'idtplcfg':
 93:             case 'number':
 94:                 $value = (int) $value;
 95:                 break;
 96:         }
 97: 
 98:         parent::setField($name, $value, $bSafe);
 99:     }
100: }
101: