Amiro.CMS API Reference
Amiro.Ru / Manual
Loading search...

Source for file AmiClean_AmiSample_Table.php

Documentation is available at AmiClean_AmiSample_Table.php

  • <?php
  • /**
  •  * AmiClean/AmiSample configuration.
  •  *
  •  * @copyright  Amiro.CMS. All rights reserved.
  •  * @category   Module
  •  * @package    Config_AmiClean_AmiSample
  •  * @version    $Id: AmiClean_AmiSample_Table.php 61273 2013-08-07 10:47:54Z Leontiev Anton $
  •  * @since      5.14.4
  •  * @filesource
  •  */
  •  
  • /**
  •  * AmiClean/AmiSample configuration table model.
  •  *
  •  * See {@link AMI_ModTable::getAvailableFields()} for common fields description.
  •  *
  •  * @package    Config_AmiClean_AmiSample
  •  * @subpackage Model
  •  * @resource   {$modId}/table/model <code>AMI::getResourceModel('{$modId}/table')*</code>
  •  * @since      5.14.4
  •  */
  •     /**
  •      * Initializing table data.
  •      *
  •      * @param array $aAttributes  Attributes of table model
  •      */
  •     public function __construct(array $aAttributes array()){
  •         $this->tableName = 'cms_' $this->getModId();
  •  
  •         parent::__construct($aAttributes);
  •  
  •         $aRemap array(
  •             'id'               => 'id',
  •             'public'           => 'public',
  •             'birth'            => 'birth',
  •             'sublink'          => 'sublink',
  •             // 'lang'         => 'lang',
  •         );
  •         $this->addFieldsRemap($aRemap);
  •     }
  •  
  • }
  •  
  • /**
  •  * AmiClean/AmiSample configuration table item model.
  •  *
  •  * @package    Config_AmiClean_AmiSample
  •  * @subpackage Model
  •  * @resource   {$modId}/table/model/item <code>AMI::getResourceModel('{$modId}/table')->getItem()*</code>
  •  * @since      5.14.4
  •  */
  •     /**
  •      * Initializing table item data.
  •      *
  •      * @param AMI_ModTable $oTable  Module table model
  •      * @param DB_Query     $oQuery  Required for load or save operations
  •      */
  •     public function __construct(AMI_ModTable $oTableDB_Query $oQuery null){
  •         parent::__construct($oTable$oQuery);
  •  
  •         // Add field validators
  •         $this->oTable->addValidators(
  •             array(
  •                 'nickname' => array('filled'),
  •                 'birth'    => array('filled'),
  •                 'email'    => array('required''email')
  •             )
  •         );
  •  
  •         // Add virtual field callback
  •         $this->setFieldCallback('age'array($this'fcbAge'));
  •  
  •         // Append origin field
  •         $this->setOriginFields(array('nickname'));
  •  
  •         $this->setFieldType(
  •             'file',
  •             'file',
  •             array(
  •                 'path'     => '_mod_files/_upload/',
  •                 'aMapping' => array(
  •                     'file_name' => 'realName',
  •                     'file_path' => 'name'
  •                 )
  •             )
  •         );
  •     }
  •  
  •     /**
  •      * Virtual 'age' field callback.
  •      *
  •      * @param  array $aData  Field data
  •      * @return array 
  •      */
  •     protected function fcbAge(array $aData){
  •         if($aData['action'=== 'get'){
  •             // Sample age calculation
  •             if(isset($this->aData['birth'])){
  •                 list($y$m$dexplode('-'$this->aData['birth']);
  •                 $aData['value'date('Y'$y - (int)(date('md'($m $d));
  •             }
  •         }else{
  •             $aData['_skip'true;
  •         }
  •         return $aData;
  •     }
  • }
  •  
  • /**
  •  * AmiClean/AmiSample configuration table list model.
  •  *
  •  * @package    Config_AmiClean_AmiSample
  •  * @subpackage Model
  •  * @resource   {$modId}/table/model/list <code>AMI::getResourceModel('{$modId}/table')->getList()*</code>
  •  * @since      5.14.4
  •  */
  • }