/**
  * Позволяет тонко сконфигурировать грид перед самой отрисовкой
  *
  * @param BeforeGridEvent $event
  */
 public function onBeforeGrid(BeforeGridEvent $event)
 {
     if (isset(Yii::app()->controller->buttons)) {
         foreach (Yii::app()->controller->buttons as $key => $buttonConfig) {
             if (isset($buttonConfig['code']) && $buttonConfig['code'] == 'create') {
                 // Модули - типы создаваемого экземпляра
                 $addButtonData = null;
                 $phpScripts = PhpScript::model()->findAllByAttributes(array('id_php_script_interface' => PhpScript::ID_PHP_SCRIPT_INTERFACE_MODULE));
                 if (count($phpScripts) > 0) {
                     $addButtonData = '<button class="btn navbar-btn btn-success dropdown-toggle" data-toggle="dropdown"><span class="caret"></span></button>';
                     $addButtonData .= '<ul class="dropdown-menu">' . "\n";
                     foreach ($phpScripts as $phpScript) {
                         /**
                          * @var $phpScript PhpScript
                          */
                         $linkModule = ObjectUrlRule::createUrlFromCurrent(BackendModule::ROUTE_INSTANCE_LIST, array(ObjectUrlRule::PARAM_OBJECT_INSTANCE => -1, ObjectUrlRule::PARAM_SYSTEM_MODULE => $phpScript->id_php_script_type));
                         $addButtonData .= "<li><a href='" . $linkModule . "'>" . $phpScript->description . "</a></li>";
                     }
                     $addButtonData .= '</ul>' . "\n";
                 }
                 $buttonConfig['addButtonData'] = $addButtonData;
                 Yii::app()->controller->buttons[$key] = $buttonConfig;
                 break;
             }
         }
     }
 }
Example #2
0
 public function deactivatePhpScript($idPhpScriptType)
 {
     $phpScriptType = PhpScript::model()->resetScope()->findByPk($idPhpScriptType);
     if ($phpScriptType == null) {
         throw new Exception('Не удалось загрузить пхп-скрипт. ИД=' . $idPhpScriptType);
     }
     $phpScriptType->active = 0;
     $phpScriptType->save();
 }