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

Source for file AmiSample_ListAdm.php

Documentation is available at AmiSample_ListAdm.php

  • <?php
  • /**
  •  * @copyright  Amiro.CMS. All rights reserved.
  •  * @category   AMI
  •  * @package    Module_Sample
  •  * @since      5.12.0
  •  * @filesource
  •  * @version    $Id: AmiSample_ListAdm.php 61273 2013-08-07 10:47:54Z Leontiev Anton $
  •  */
  •  
  • /**
  •  * Sample module admin list component action controller.
  •  *
  •  * @package    Module_Sample
  •  * @subpackage Controller
  •  * @resource   ami_sample/list/controller/adm <code>AMI::getResource('ami_sample/list/controller/adm')</code>
  •  * @since      5.12.0
  •  */
  •     /**
  •      * List actions controller resource id
  •      *
  •      * @var string 
  •      */
  •     protected $listActionsResId = 'ami_sample/list_actions/controller/adm';
  •  
  •     /**
  •      * List group actions controller resource id
  •      *
  •      * @var string 
  •      */
  •     protected $listGrpActionsResId = 'ami_sample/list_group_actions/controller/adm';
  •  
  •     /**
  •      * Initialization.
  •      *
  •      * @return AmiSample_ListAdm 
  •      */
  •     public function init(){
  •         // AMI_ModListAdm::addActions() must be called before parent::init()!
  •  
  •         // Add actions to "actions" column
  •         $this->addActions(array(self::REQUIRE_FULL_ENV 'edit'self::REQUIRE_FULL_ENV 'delete'self::REQUIRE_FULL_ENV 'copy''show'));
  •  
  •         // Add separate column action
  •         $this->addColActions(array(self::REQUIRE_FULL_ENV 'public')true);
  •  
  •         // Add separate column action
  •         $this->addColActions(array(self::REQUIRE_FULL_ENV 'rename'));
  •  
  •         // Add action inside existing column
  •         $this->addActions(array('inner')'nickname');
  •  
  •         // Add group actions
  •         $this->addGroupActions(
  •             array(
  •                 array(self::REQUIRE_FULL_ENV 'public',   'public_section'),
  •                 array(self::REQUIRE_FULL_ENV 'unpublic''public_section'),
  •                 array(self::REQUIRE_FULL_ENV 'rename',   'rename_section'),
  •                 array(self::REQUIRE_FULL_ENV 'delete',   'delete_section'),
  •             )
  •         );
  •  
  •         parent::init();
  •         return $this;
  •     }
  • }
  •  
  • /**
  •  * Sample module admin list component view.
  •  *
  •  * @package    Module_Sample
  •  * @subpackage View
  •  * @resource   ami_sample/list/view/adm <code>AMI::getResource('ami_sample/list/view/adm')</code>
  •  * @since      5.12.0
  •  */
  •     /**
  •      * Order column
  •      *
  •      * @var string 
  •      */
  •     protected $orderColumn = 'nickname';
  •  
  •     /**
  •      * Order column direction
  •      *
  •      * @var bool 
  •      */
  •     protected $orderDirection = 'asc';
  •  
  •     /**
  •      * Constructor.
  •      */
  •     public function __construct(){
  •         $this->tplFileName = '_local/plugins_distr/' $this->getModId('/templates/list.tpl';
  •         parent::__construct();
  •  
  •         // Init columns
  •         $this
  •             ->addColumnType('id''hidden')
  •             ->addColumn('nickname')
  •             ->addColumn('birth')
  •             ->addColumnType('age''int')
  •             ->setColumnTensility('nickname')
  •             ->addSortColumns(
  •                 array(
  •                     'public',
  •                     'nickname',
  •                     'birth'
  •                 )
  •             );
  •  
  •         // place 'rename' action column before 'nickname' column
  •         $this->putPlaceholder('rename''nickname.before');
  •  
  •         // Truncate 'nickname' column by 50 symbols
  •         $this->formatColumn(
  •             'nickname',
  •             array($this'fmtTruncate'),
  •             array(
  •                 'length' => 50
  •             )
  •         );
  •  
  •         // Format 'birth' column as date
  •         $this->formatColumn(
  •             'birth',
  •             array($this'fmtDateTime'),
  •             array(
  •                 'format' => AMI_Lib_Date::FMT_DATE
  •             )
  •         );
  •  
  •         // Use custom formatter on 'value' column
  •         $this->formatColumn(
  •             'birth',
  •             array($this'fmtCustom')
  •         );
  •  
  •         // Add custom script
  •         $this->addScriptFile('_local/plugins_distr/' $this->getModId(.  '/templates/list.adm.js');
  •     }
  •  
  •     /**
  •      * Returns module specific locale path.
  •      *
  •      * @return string 
  •      */
  •     protected function getModLocalePath(){
  •         return '_local/plugins_distr/' $this->getModId(.  '/templates/list.lng';
  •     }
  •  
  •     /**
  •      * Custom column formatter.
  •      *
  •      * @param  mixed $value  Value to format
  •      * @param  array $aArgs  Arguments
  •      * @return mixed 
  •      * @see    AMI_ModListView::formatColumn()
  •      */
  •     protected function fmtCustom($valuearray $aArgs){
  •         return '~ ' $value ' ~';
  •     }
  • }