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

Source for file AmiSample_FormAdm.php

Documentation is available at AmiSample_FormAdm.php

  • <?php
  • /**
  •  * @copyright  Amiro.CMS. All rights reserved.
  •  * @category   AMI
  •  * @package    Module_Sample
  •  * @since      5.12.0
  •  * @filesource
  •  * @version    $Id: AmiSample_FormAdm.php 61273 2013-08-07 10:47:54Z Leontiev Anton $
  •  */
  •  
  • /**
  •  * Sample module admin form component action controller.
  •  *
  •  * @package    Module_Sample
  •  * @subpackage Controller
  •  * @resource   ami_sample/form/controller/adm <code>AMI::getResource('ami_sample/form/controller/adm')</code>
  •  * @since      5.12.0
  •  */
  •     /**
  •      * Save action dispatcher.
  •      *
  •      * @param  array &$aEvent  Event data
  •      * @return void 
  •      */
  •     protected function _save(array &$aEvent){
  •         parent::_save($aEvent);
  •         if(is_object($this->oItem)){
  •             AMI::getSingleton('response')->addStatusMessage('origin_data'array('data' => d::getDumpAsString($this->oItem->getOriginData())));
  •             AMI::getSingleton('response')->addStatusMessage('difference_from_origin'array('data' => d::getDumpAsString($this->oItem->getDiffFromOrigin())));
  •         }
  •     }
  • }
  •  
  • /**
  •  * Sample module form component view.
  •  *
  •  * @package    Module_Sample
  •  * @subpackage View
  •  * @resource   ami_sample/form/view/adm <code>AMI::getResource('ami_sample/form/view/adm')</code>
  •  * @since      5.12.0
  •  */
  •     /**
  •      * Constructor.
  •      */
  •     public function __construct(){
  •         parent::__construct();
  •     }
  •  
  •     /**
  •      * Fields init.
  •      *
  •      */
  •     public function init(){
  •  
  •         // Add custom sets for the fields
  •         $this->addTemplate($this->getModTemplatePath('fields.tpl');
  •  
  •         // Common form fields {
  •  
  •         // Item id
  •         $this->addField(array('name' => 'id''type' => 'hidden'));
  •         // Form save action
  •         $this->addField(array('name' => 'mod_action''value' => 'form_save''type' => 'hidden'));
  •  
  •         // } Common form fields
  •  
  •         $this->addField(array('name' => 'public''type' => 'checkbox''default_checked' => true));
  •         $this->addField(array('name' => 'nickname'));
  •         $this->addField(array('name' => 'birth''type' => 'date''validate' => array('custom''stop_on_error')));
  •         $this->addField(array('name' => 'email'));
  •  
  •         // Add tabs
  •         $this->addTabContainer('tabset');
  •         $this->addTab('info''tabset'self::TAB_STATE_ACTIVE);
  •         $this->addTab('contacts''tabset',self::TAB_STATE_COMMON,''array('edit','show'));
  •  
  •         // Add fields on tabs
  •         $this->addField(array('name' => 'about''type' => 'htmleditor''cols' => 80'rows' => 10'position' => 'info.end''modes' => array('editor''bb')));
  •         $this->addField(array('name' => 'phone''position' => 'contacts.end'));
  •         $this->addField(array('name' => 'homepage''position' => 'contacts.end''validate' => array('domain')));
  •  
  •         $this->addField(array('name' => 'file''type' => 'file''position' => 'email.after''validate' => array('required')));
  •  
  •         // Add custom script
  •         $this->addScriptFile('_local/plugins_distr/' $this->getModId(.  '/templates/form.adm.js');
  •  
  •         $this->putPlaceholder('special''birth.begin'true);
  •         $this->addTemplate($this->getModTemplatePath('fields_custom.tpl''special');
  •         $this->addField(array('name' => 'views''position' => 'special.begin' ,'display_by_action' => array('edit''show')));
  •  
  •         return parent::init();
  •     }
  •  
  •     /**
  •      * Returns module specific locale path.
  •      *
  •      * @return string 
  •      */
  •     protected function getModLocalePath(){
  •         return $this->getModTemplatePath('form.lng';
  •     }
  •  
  •     /**
  •      * Returns module specific template path.
  •      *
  •      * @return string 
  •      */
  •     protected function getModTemplatePath(){
  •         return '_local/plugins_distr/' $this->getModId(.  '/templates/';
  •     }
  • }