ActionAdmin

Package actions
Inheritance class ActionAdmin » Action » LsObject
Since 1.0
Source Code /classes/actions/ActionAdmin.class.php
Экшен обработки УРЛа вида /admin/

Protected Properties

Hide inherited properties

PropertyTypeDescriptionDefined By
aParams array Список параметров из URL Action
aParamsEventMatch array Список совпадений по регулярному выражению для евента Action
aRegisterEvent array Список зарегистрированных евентов Action
oEngine Engine|null Объект ядра Action
oUserCurrent ModuleUser_EntityUser|null Текущий пользователь ActionAdmin
sActionTemplate string|null Шаблон экшена Action
sCurrentAction null|string Текущий экшен Action
sCurrentEvent string|null Текущий евент Action
sCurrentEventName string|null Имя текущий евента Action
sDefaultEvent string|null Дефолтный евент Action
sMenuHeadItemSelect string Главное меню ActionAdmin

Public Methods

Hide inherited methods

MethodDescriptionDefined By
EventShutdown() Выполняется при завершении работы экшена ActionAdmin
ExecEvent() Запускает евент на выполнение Action
GetActionClass() Получить каталог с шаблонами экшена(совпадает с именем класса) Action
GetCurrentEventName() Возвращает имя евента Action
GetDefaultEvent() Получает евент по умолчанию Action
GetParam() Получает параметр из URL по его номеру, если его нет то null Action
GetParams() Получает список параметров из УРЛ Action
GetTemplate() Получить шаблон Action
Init() Инициализация ActionAdmin
SetDefaultEvent() Устанавливает евент по умолчанию Action
SetParam() Установить значение параметра(эмуляция параметра в URL). Action
__call() Ставим хук на вызов неизвестного метода и считаем что хотели вызвать метод какого либо модуля Action
__construct() Конструктор Action
checkUserField() Проверка поля пользователя на корректность из реквеста ActionAdmin

Protected Methods

Hide inherited methods

MethodDescriptionDefined By
AddEvent() Добавляет евент в экшен Action
AddEventPreg() Добавляет евент в экшен, используя регулярное вырожение для евента и параметров Action
EventIndex() Отображение главной страницы админки ActionAdmin
EventNotFound() Вызывается в том случаи если не найден евент который запросили через URL Action
EventPlugins() Страница со списком плагинов ActionAdmin
EventRecalculateFavourite() Пересчет счетчика избранных ActionAdmin
EventRecalculateTopic() Пересчет количества топиков в блогах ActionAdmin
EventRecalculateVote() Пересчет счетчика голосований ActionAdmin
EventRestoreComment() Перестроение дерева комментариев, актуально при $config['module']['comment']['use_nested'] = true; ActionAdmin
EventUserFields() Управление полями пользователя ActionAdmin
GetEventMatch() Возвращает элементы совпадения по регулярному выражению для евента Action
GetParamEventMatch() Возвращает элементы совпадения по регулярному выражению для параметров евента Action
RegisterEvent() Регистрация евентов ActionAdmin
SetTemplate() Устанавливает какой шаблон выводить Action
SetTemplateAction() Устанавливает какой шаблон выводить Action
SubmitManagePlugin() Активация\деактивация плагина ActionAdmin

Property Details

oUserCurrent property
protected ModuleUser_EntityUser|null $oUserCurrent;

Текущий пользователь

sMenuHeadItemSelect property
protected string $sMenuHeadItemSelect;

Главное меню

Method Details

EventIndex() method
protected void EventIndex()
Source Code: /classes/actions/ActionAdmin.class.php#77 (show)
protected function EventIndex() {

}

Отображение главной страницы админки Нет никакой логики, просто отображение дефолтного шаблона евента index.tpl

EventPlugins() method
protected void EventPlugins()
Source Code: /classes/actions/ActionAdmin.class.php#135 (show)
protected function EventPlugins() {
    
$this->sMenuHeadItemSelect='plugins';
    
/**
     * Обработка удаления плагинов
     */
    
if (isPost('submit_plugins_del')) {
        
$this->Security_ValidateSendForm();

        
$aPluginsDelete=getRequest('plugin_del');
        if (
is_array($aPluginsDelete)) {
            
$this->Plugin_Delete(array_keys($aPluginsDelete));
        }
    }
    
/**
     * Получаем название плагина и действие
     */
    
if($sPlugin=getRequest('plugin',null,'get') and $sAction=getRequest('action',null,'get')) {
        return 
$this->SubmitManagePlugin($sPlugin,$sAction);
    }
    
/**
     * Получаем список блогов
     */
    
$aPlugins=$this->Plugin_GetList(array('order'=>'name'));
    
/**
     * Загружаем переменные в шаблон
     */
    
$this->Viewer_Assign("aPlugins",$aPlugins);
    
$this->Viewer_AddHtmlTitle($this->Lang_Get('plugins_administartion_title'));
    
/**
     * Устанавливаем шаблон вывода
     */
    
$this->SetTemplateAction('plugins');
}

Страница со списком плагинов

EventRecalculateFavourite() method
protected void EventRecalculateFavourite()
Source Code: /classes/actions/ActionAdmin.class.php#97 (show)
protected function EventRecalculateFavourite() {
    
$this->Security_ValidateSendForm();
    
set_time_limit(0);
    
$this->Comment_RecalculateFavourite();
    
$this->Topic_RecalculateFavourite();
    
$this->Cache_Clean();

    
$this->Message_AddNotice($this->Lang_Get('admin_favourites_recalculated'),$this->Lang_Get('attention'));
    
$this->SetTemplateAction('index');
}

Пересчет счетчика избранных

EventRecalculateTopic() method
protected void EventRecalculateTopic()
Source Code: /classes/actions/ActionAdmin.class.php#122 (show)
protected function EventRecalculateTopic() {
    
$this->Security_ValidateSendForm();
    
set_time_limit(0);
    
$this->Blog_RecalculateCountTopic();
    
$this->Cache_Clean();

    
$this->Message_AddNotice($this->Lang_Get('admin_topics_recalculated'),$this->Lang_Get('attention'));
    
$this->SetTemplateAction('index');
}

Пересчет количества топиков в блогах

EventRecalculateVote() method
protected void EventRecalculateVote()
Source Code: /classes/actions/ActionAdmin.class.php#110 (show)
protected function EventRecalculateVote() {
    
$this->Security_ValidateSendForm();
    
set_time_limit(0);
    
$this->Topic_RecalculateVote();
    
$this->Cache_Clean();

    
$this->Message_AddNotice($this->Lang_Get('admin_votes_recalculated'),$this->Lang_Get('attention'));
    
$this->SetTemplateAction('index');
}

Пересчет счетчика голосований

EventRestoreComment() method
protected void EventRestoreComment()
Source Code: /classes/actions/ActionAdmin.class.php#84 (show)
protected function EventRestoreComment() {
    
$this->Security_ValidateSendForm();
    
set_time_limit(0);
    
$this->Comment_RestoreTree();
    
$this->Cache_Clean();

    
$this->Message_AddNotice($this->Lang_Get('admin_comment_restore_tree'),$this->Lang_Get('attention'));
    
$this->SetTemplateAction('index');
}

Перестроение дерева комментариев, актуально при $config['module']['comment']['use_nested'] = true;

EventShutdown() method
public void EventShutdown()
Source Code: /classes/actions/ActionAdmin.class.php#329 (show)
public function EventShutdown() {
    
/**
     * Загружаем в шаблон необходимые переменные
     */
    
$this->Viewer_Assign('sMenuHeadItemSelect',$this->sMenuHeadItemSelect);
}

Выполняется при завершении работы экшена

EventUserFields() method
protected void EventUserFields()
Source Code: /classes/actions/ActionAdmin.class.php#172 (show)
protected function EventUserFields()
{
    switch(
getRequest('action')) {
        
/**
         * Создание нового поля
         */
        
case 'add':
            
/**
             * Обрабатываем как ajax запрос (json)
             */
            
$this->Viewer_SetResponseAjax('json');
            if (!
$this->checkUserField()) {
                return;
            }
            
$oField Engine::GetEntity('User_Field');
            
$oField->setName(getRequest('name'));
            
$oField->setTitle(getRequest('title'));
            
$oField->setPattern(getRequest('pattern'));
            if (
in_array(getRequest('type'),$this->User_GetUserFieldTypes())) {
                
$oField->setType(getRequest('type'));
            } else {
                
$oField->setType('');
            }

            
$iId $this->User_addUserField($oField);
            if(!
$iId) {
                
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
                return;
            }
            
/**
             * Прогружаем переменные в ajax ответ
             */
            
$this->Viewer_AssignAjax('id'$iId);
            
$this->Viewer_AssignAjax('lang_delete'$this->Lang_Get('user_field_delete'));
            
$this->Viewer_AssignAjax('lang_edit'$this->Lang_Get('user_field_update'));
            
$this->Message_AddNotice($this->Lang_Get('user_field_added'),$this->Lang_Get('attention'));
            break;
        
/**
         * Удаление поля
         */
        
case 'delete':
            
/**
             * Обрабатываем как ajax запрос (json)
             */
            
$this->Viewer_SetResponseAjax('json');
            if (!
getRequest('id')) {
                
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
                return;
            }
            
$this->User_deleteUserField(getRequest('id'));
            
$this->Message_AddNotice($this->Lang_Get('user_field_deleted'),$this->Lang_Get('attention'));
            break;
        
/**
         * Изменение поля
         */
        
case 'update':
            
/**
             * Обрабатываем как ajax запрос (json)
             */
            
$this->Viewer_SetResponseAjax('json');
            if (!
getRequest('id')) {
                
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
                return;
            }
            if (!
$this->User_userFieldExistsById(getRequest('id'))) {
                
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
                return 
false;
            }
            if (!
$this->checkUserField()) {
                return;
            }
            
$oField Engine::GetEntity('User_Field');
            
$oField->setId(getRequest('id'));
            
$oField->setName(getRequest('name'));
            
$oField->setTitle(getRequest('title'));
            
$oField->setPattern(getRequest('pattern'));
            if (
in_array(getRequest('type'),$this->User_GetUserFieldTypes())) {
                
$oField->setType(getRequest('type'));
            } else {
                
$oField->setType('');
            }

            if (
$this->User_updateUserField($oField)) {
                
$this->Message_AddError($this->Lang_Get('system_error'),$this->Lang_Get('error'));
                return;
            }
            
$this->Message_AddNotice($this->Lang_Get('user_field_updated'),$this->Lang_Get('attention'));
            break;
        
/**
         * Показываем страницу со списком полей
         */
        
default:
            
/**
             * Загружаем в шаблон JS текстовки
             */
            
$this->Lang_AddLangJs(array('user_field_delete_confirm'));
            
/**
             * Получаем список всех полей
             */
            
$this->Viewer_Assign('aUserFields',$this->User_getUserFields());
            
$this->Viewer_Assign('aUserFieldTypes',$this->User_GetUserFieldTypes());
            
$this->SetTemplateAction('user_fields');
    }
}

Управление полями пользователя

Init() method
public string Init()
{return} string
Source Code: /classes/actions/ActionAdmin.class.php#43 (show)
public function Init() {
    
/**
     * Если нет прав доступа - перекидываем на 404 страницу
     */
    
if(!$this->User_IsAuthorization() or !$oUserCurrent=$this->User_GetUserCurrent() or !$oUserCurrent->isAdministrator()) {
        return 
parent::EventNotFound();
    }
    
$this->SetDefaultEvent('index');

    
$this->oUserCurrent=$oUserCurrent;
}

Инициализация

RegisterEvent() method
protected void RegisterEvent()
Source Code: /classes/actions/ActionAdmin.class.php#57 (show)
protected function RegisterEvent() {
    
$this->AddEvent('index','EventIndex');
    
$this->AddEvent('plugins','EventPlugins');
    
$this->AddEvent('restorecomment','EventRestoreComment');
    
$this->AddEvent('userfields','EventUserfields');
    
$this->AddEvent('recalcfavourite','EventRecalculateFavourite');
    
$this->AddEvent('recalcvote','EventRecalculateVote');
    
$this->AddEvent('recalctopic','EventRecalculateTopic');
}

Регистрация евентов

SubmitManagePlugin() method
protected void SubmitManagePlugin(string $sPlugin, string $sAction)
$sPlugin string Имя плагина
$sAction string Действие
Source Code: /classes/actions/ActionAdmin.class.php#306 (show)
protected function SubmitManagePlugin($sPlugin,$sAction) {
    
$this->Security_ValidateSendForm();
    if(!
in_array($sAction,array('activate','deactivate'))) {
        
$this->Message_AddError($this->Lang_Get('plugins_unknown_action'),$this->Lang_Get('error'),true);
        
Router::Location(Router::GetPath('plugins'));
    }
    
/**
     * Активируем\деактивируем плагин
     */
    
if($bResult=$this->Plugin_Toggle($sPlugin,$sAction)) {
        
$this->Message_AddNotice($this->Lang_Get('plugins_action_ok'),$this->Lang_Get('attention'),true);
    } else {
        if(!(
$aMessages=$this->Message_GetErrorSession()) or !count($aMessages)) $this->Message_AddErrorSingle($this->Lang_Get('system_error'),$this->Lang_Get('error'),true);
    }
    
/**
     * Возвращаем на страницу управления плагинами
     */
    
Router::Location(Router::GetPath('admin').'plugins/');
}

Активация\деактивация плагина

checkUserField() method
public bool checkUserField()
{return} bool
Source Code: /classes/actions/ActionAdmin.class.php#281 (show)
public function checkUserField()
{
    if (!
getRequest('title')) {
        
$this->Message_AddError($this->Lang_Get('user_field_error_add_no_title'),$this->Lang_Get('error'));
        return 
false;
    }
    if (!
getRequest('name')) {
        
$this->Message_AddError($this->Lang_Get('user_field_error_add_no_name'),$this->Lang_Get('error'));
        return 
false;
    }
    
/**
     * Не допускаем дубликатов по имени
     */
    
if ($this->User_userFieldExistsByName(getRequest('name'), getRequest('id'))) {
        
$this->Message_AddError($this->Lang_Get('user_field_error_name_exists'),$this->Lang_Get('error'));
        return 
false;
    }
    return 
true;
}

Проверка поля пользователя на корректность из реквеста