示例#1
0
    public function _initialize(KConfig $config)
    {
        $sluggable = KDatabaseBehavior::factory('sluggable', array('columns' => array('name')));
        $orderable = $this->getBehavior('com://admin/categories.database.behavior.orderable', array('parent_column' => 'catid'));

        $config->append(array(
            'identity_column'    => 'bid',
            'base'               => 'banner',
            'name'               => 'banner',
            'behaviors'		     => array('creatable', 'lockable', $sluggable, $orderable, 'hittable'),
            'column_map'         => array(
                'enabled'    => 'showBanner',
                'created_on' => 'date',
                'locked_on'  => 'checked_out_time',
                'locked_by'  => 'checked_out',
                'slug' 		 => 'alias',
                'hits'       => 'clicks'
            ),
            'filters' => array(
                'custombannercode' => array('html', 'tidy'),
                'params'           => 'ini'
            )
        ));
        
        parent::_initialize($config);
    }
示例#2
0
	public function _initialize(KConfig $config)
	{
		$config->identity_column = 'id';
		
		$sluggable = KDatabaseBehavior::factory('sluggable', array('columns' => array('name')));

        $config->append(array(
            'name'      => 'contact_details',
            'behaviors' => array('orderable', 'lockable', $sluggable),
            'column_map'=> array(
                'enabled' 	=> 'published',
				'locked_on' => 'checked_out_time',
				'locked_by'	=> 'checked_out',
				'slug'		=> 'alias',
                'category'  => 'catid',
            ),
             'filters' => array(
                'params'    => 'ini'
            )
        ));
        
		parent::_initialize($config);
	}
示例#3
0
 /**
  * Add one or more behaviors to the table
  *
  * @param   array   Array of one or more behaviors to add.
  * @return  KDatabaseTableAbstract
  */
 public function addBehaviors($behaviors)
 {
     foreach ($behaviors as $behavior) {
         if (!$behavior instanceof KDatabaseBehaviorInterface) {
             $identifier = (string) $behavior;
             $behavior = KDatabaseBehavior::factory($behavior);
         } else {
             $identifier = (string) $behavior->getIdentifier();
         }
         //Set the behaviors in the database schema
         $this->getInfo()->behaviors[$identifier] = $behavior;
         //Enqueue the behavior in the command chain
         $this->getCommandChain()->enqueue($behavior);
     }
     return $this;
 }
示例#4
0
	/**
     * Get a behavior by identifier
     *
     * @param  
     * @return KControllerBehaviorAbstract
     */
    public function getBehavior($behavior, $config = array())
    {
       if(!($behavior instanceof KIdentifier))
       {
            //Create the complete identifier if a partial identifier was passed
           if(is_string($behavior) && strpos($behavior, '.') === false )
           {
               $identifier = clone $this->_identifier;
               $identifier->path = array('database', 'behavior');
               $identifier->name = $behavior;
           }
           else $identifier = KFactory::identify($behavior);
       }
       
       if(!isset($this->getSchema()->behaviors[$identifier->name])) {
           $behavior = KDatabaseBehavior::factory($identifier, array_merge($config, array('mixer' => $this)));
       } else {
           $behavior = $this->getSchema()->behaviors[$identifier->name];
       }
       
       return $behavior;
    }