|
Source for file AmiClean_AmiSample_Adm.php
Documentation is available at AmiClean_AmiSample_Adm.php
* AmiClean/AmiSample configuration.
* @copyright Amiro.CMS. All rights reserved.
* @package Config_AmiClean_AmiSample
* @version $Id: AmiClean_AmiSample_Adm.php 61273 2013-08-07 10:47:54Z Leontiev Anton $
* AmiClean/AmiSample configuration admin action controller.
* @package Config_AmiClean_AmiSample
* @resource {$modId}/module/controller/adm <code>AMI::getResource('{$modId}/module/controller/adm')*</code>
* @param AMI_Request $oRequest Request object
* @param AMI_Response $oResponse Response object
public function __construct(AMI_Request $oRequest, AMI_Response $oResponse){
parent::__construct($oRequest, $oResponse);
// Load plugin status messages
$oResponse->loadStatusMessages(AMI_iTemplate::LOCAL_LNG_MOD_PATH . '/' . $this->getModId() . '_messages.lng');
// Add handler on adding status messages
* Replaces the status message with a new one.
* @param string $name Event name
* @param array $aEvent Event data
* @param string $handlerModId Handler module id
* @param string $srcModId Source module id
if($aEvent['key'] == 'status_add'){
$aEvent['key'] = 'status_name_add';
$aEvent['aParams'] = array('name' => $this->getRequestParam('nickname'));
* AmiClean/AmiSample configuration model.
* @package Config_AmiClean_AmiSample
* @resource {$modId}/module/model <code>AMI::getResourceModel('{$modId}/module')*</code>
* AmiClean/AmiSample configuration admin filter component action controller.
* @package Config_AmiClean_AmiSample
* @resource {$modId}/filter/controller/adm <code>AMI::getResource('{$modId}/filter/controller/adm')*</code>
* AmiClean/AmiSample configuration item list component filter model.
* @package Config_AmiClean_AmiSample
* @resource {$modId}/filter/model/adm <code>AMI::getResource('{$modId}/filter/model/adm')*</code>
'flt_condition' => 'like',
'flt_column' => 'nickname'
* AmiClean/AmiSample configuration admin filter component view.
* @package Config_AmiClean_AmiSample
* @resource {$modId}/filter/view/adm <code>AMI::getResource('{$modId}/filter/view/adm')*</code>
// Add admin filter form placeholder for 'nickname' before 'datefrom' filter field
* AmiClean/AmiSample configuration admin form component action controller.
* @package Config_AmiClean_AmiSample
* @resource {$modId}/form/controller/adm <code>AMI::getResource('{$modId}/form/controller/adm')*</code>
* Save action dispatcher.
* @param array &$aEvent Event data
protected function _save(array &$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())));
* Returns module file storage path.
return '_mod_files/_upload/';
* AmiClean/AmiSample configuration form component view.
* @package Config_AmiClean_AmiSample
* @resource {$modId}/form/view/adm <code>AMI::getResource('{$modId}/form/view/adm')*</code>
// Add custom sets for the fields
$this->addField(array('name' => 'id', 'type' => 'hidden'));
$this->addField(array('name' => 'mod_action', 'value' => 'form_save', 'type' => 'hidden'));
$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'));
$this->addTab('info', 'tabset', self::TAB_STATE_ACTIVE);
$this->addTab('contacts', 'tabset',self::TAB_STATE_COMMON,'', array('edit','show'));
$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')));
$this->dropPlaceholders(array('sublink', 'ext_image'));
$this->addField(array('name' => 'sublink', 'position' => 'file.after'));
$this->addField(array('name' => 'views', 'position' => 'special.begin' ,'display_by_action' => array('edit', 'show')));
* AmiClean/AmiSample configuration admin list component action controller.
* @package Config_AmiClean_AmiSample
* @resource {$modId}/list/controller/adm <code>AMI::getResource('{$modId}/list/controller/adm')*</code>
* @return AmiSample_ListAdm
// 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
// Add action inside existing column
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'),
* AmiClean/AmiSample configuration admin list component view.
* @package Config_AmiClean_AmiSample
* @resource {$modId}/list/view/adm <code>AMI::getResource('{$modId}/list/view/adm')*</code>
->addColumnType('age', 'int')
->setColumnTensility('nickname')
// place 'rename' action column before 'nickname' column
// Truncate 'nickname' column by 50 symbols
array($this, 'fmtTruncate'),
// Format 'birth' column as date
array($this, 'fmtDateTime'),
// Use custom formatter on 'value' column
array($this, 'fmtCustom')
* Custom column formatter.
* @param mixed $value Value to format
* @param array $aArgs Arguments
* @see AMI_ModListView::formatColumn()
protected function fmtCustom($value, array $aArgs){
return '~ ' . $value . ' ~';
* AmiClean/AmiSample configuration admin list actions controller.
* @package Config_AmiClean_AmiSample
* @resource {$modId}/list_actions/controller/adm <code>AMI::getResource('{$modId}_cat/list_actions/controller/adm')*</code>
class AmiClean_AmiSample_ListActionsAdm extends Hyper_AmiClean_ListActionsAdm{
* @see AMI_Event::addHandler()
* @see AMI_ModListAdm::addActions()
* @see AMI_ModListAdm::addColActions()
* Dispatches 'delete' action.
* Overridden item deletion. Denies deletion of item having id == 1.
* @param string $name Event name
* @param array $aEvent Event data
* @param string $handlerModId Handler module id
* @param string $srcModId Source module id
public function dispatchDelete($name, array $aEvent, $handlerModId, $srcModId){
$oItem = $this->getItem($this->getRequestId());
if($oItem->getId() == 1){
$aEvent['oResponse']->addStatusMessage('status_del_forbidden', array(), AMI_Response::STATUS_MESSAGE_ERROR);
parent::dispatchDelete($name, $aEvent, $handlerModId, $srcModId);
* Dispatches 'inner' action.
* Displays three messages.
* @param string $name Event name
* @param array $aEvent Event data
* @param string $handlerModId Handler module id
* @param string $srcModId Source module id
public function dispatchInner($name, array $aEvent, $handlerModId, $srcModId){
->addStatusMessage('status_inner_note')
->addStatusMessage('status_inner_warning', array(), AMI_Response::STATUS_MESSAGE_WARNING)
->addStatusMessage('status_inner_error', array(), AMI_Response::STATUS_MESSAGE_ERROR);
* Dispatches 'rename' action.
* Renames 'nickname' field to "[{$nickname}]".
* @param string $name Event name
* @param array $aEvent Event data
* @param string $handlerModId Handler module id
* @param string $srcModId Source module id
public function dispatchRename($name, array $aEvent, $handlerModId, $srcModId){
$oItem = $this->getItem($this->getRequestId());
$nickname = $oItem->nickname;
$oItem->nickname = '[' . $nickname . ']';
$aEvent['oResponse']->addStatusMessage(
'destination' => $oItem->nickname
* Dispatches 'copy' action.
* Copies item and prepends '- ' string to the new 'nickname' field.
* @param string $name Event name
* @param array $aEvent Event data
* @param string $handlerModId Handler module id
* @param string $srcModId Source module id
public function dispatchCopy($name, array $aEvent, $handlerModId, $srcModId){
$oItem = $this->getItem($this->getRequestId());
$nickname = $oItem->nickname;
$newNickname = '- ' . $nickname;
$oItem->nickname = $newNickname;
$aEvent['oResponse']->addStatusMessage(
'destination' => $newNickname
* AmiClean/AmiSample configuration admin list group actions controller.
* @package Config_AmiClean_AmiSample
* @resource {$modId}/list_group_actions/controller/adm <code>AMI::getResource('{$modId}_cat/list_group_actions/controller/adm')*</code>
* @see AMI_Event::addHandler()
* @see AMI_ModListAdm::addGroupActions()
* Dispatches 'delete' group action.
* @param string $name Event name
* @param array $aEvent Event data
* @param string $handlerModId Handler module id
* @param string $srcModId Source module id
return parent::dispatchGrpDelete($name, $aEvent, $handlerModId, $srcModId);
* Dispatches 'rename' group action.
* Renames 'nickname' field to "[{$nickname}]".
* @param string $name Event name
* @param array $aEvent Event data
* @param string $handlerModId Handler module id
* @param string $srcModId Source module id
$oListActionsAdm = AMI::getResource($handlerModId . '/list_actions/controller/adm');
foreach($aRequestIds as $id){
$aEvent['oRequest']->set('mod_action_id', $id);
$oListActionsAdm->setActionData($name, $aEvent, $handlerModId, $srcModId);
$oListActionsAdm->dispatchRename($name, $aEvent, $handlerModId, $srcModId);
$aEvent['oResponse']->resetStatusMessages();
$aEvent['oResponse']->addStatusMessage('status_grp_rename', array('num_items' => sizeof($aRequestIds)));
|