Ejemplo n.º 1
0
 public function init()
 {
     $self = $this;
     Events::add_listener('ws.response', function ($resp) use($self) {
         $self->dump($resp);
     });
 }
Ejemplo n.º 2
0
Archivo: Core.php Proyecto: techart/tao
 protected static function init_module_cache()
 {
     if (Core::option('modules_cache')) {
         Core::load('Events');
         $modules = array();
         if (is_file(self::option('modules_cache_path')) && ($inc = (include_once self::option('modules_cache_path'))) && is_array($inc)) {
             self::$cached_modules = $inc;
         } else {
             self::$cached_modules = Core::find_all_modules();
             self::$flush_modules_cahce = true;
         }
         Events::add_listener('ws.response', array('Core', 'flush_modules_cache'));
     }
 }
Ejemplo n.º 3
0
Archivo: CMS.php Proyecto: techart/tao
 /**
  * Добавляет комманду в очередь
  *
  * @param string $chapter
  * @param string $command
  */
 static function add_command()
 {
     $args = func_get_args();
     $chapter = trim($args[0]);
     $method = trim($args[1]);
     array_splice($args, 0, 2);
     if (!isset(self::$commands[$chapter])) {
         self::$commands[$chapter] = array();
     }
     self::$commands[$chapter][] = array('method' => $method, 'args' => $args);
     Events::add_listener(self::event_name_for_command($chapter, $method), $args[0]);
 }
Ejemplo n.º 4
0
 protected function process_component_config($config_name = 'component')
 {
     $config = $this->config($config_name);
     // TODO: split to methods
     if (isset($config->admin_menu)) {
         $menu = (object) $config->admin_menu;
         CMS_Admin::menu($menu->caption, $menu->path, $menu->items, $menu->icon);
     }
     if (isset($config->templates)) {
         $helpers = $config->templates['helpers'];
         Templates_HTML::use_helpers($helpers);
     }
     if (isset($config->field_types)) {
         $types = $config->field_types;
         foreach ($types as $name => $class) {
             CMS::field_type($name, $class);
         }
     }
     if (isset($config->commands)) {
         $commands = $config->commands;
         foreach ($commands as $chapter => $data) {
             $args = array_merge(array($chapter, $data['name'], $data['callback']), isset($data['args']) ? $data['args'] : array());
             call_user_func_array(array('CMS', 'add_command'), $args);
         }
     }
     if (isset($config->insertions)) {
         $insertions = $config->insertions;
         foreach ($insertions as $ins) {
             $args = array_merge(array($ins['class']), $ins['names']);
             call_user_func_array(array('CMS', 'register_insertions'), $args);
         }
     }
     if (isset($config->events)) {
         $events = $config->events;
         foreach ($events as $name => $callback) {
             Events::add_listener($name, $callback);
         }
     }
     if (isset($config->orm)) {
         $orm = $config->orm;
         foreach ($orm as $name => $class) {
             CMS::orm()->submapper($name, $class);
         }
     }
 }
Ejemplo n.º 5
0
 protected function form_fields($action)
 {
     $fields = array();
     if ($action == 'list') {
     } elseif ($action == 'add') {
         $fields = array();
         if ($this->is_admin()) {
             $fields['_name'] = array('type' => 'input', 'style' => 'width: 200px;', 'tab' => 'config', 'caption' => CMS::lang('%LANG{en}Name%LANG{ru}Мнемокод'));
             if (isset($_GET['chapter'])) {
                 $pchapter = trim($_GET['chapter']);
                 if ($pchapter != '') {
                     $pchapter .= '.';
                 }
                 $fields['_name']['obligatory_prefix'] = $pchapter;
                 $fields['_type'] = array('type' => 'select', 'items' => CMS::vars()->types_list(), 'caption' => CMS::lang('%LANG{en}Type%LANG{ru}Тип'), 'tab' => 'config');
             }
         }
     } else {
         $var = $this->edit_item;
         if (!$var->is_dir()) {
             $fields = array('vname' => array('type' => 'subheader', 'tab' => 'default', 'caption' => $var->id() . ': ' . $var->title()));
             $fields += $var->fields($var);
         }
     }
     if ($this->is_admin()) {
         $fields['_title'] = array('type' => 'input', 'style' => 'width: 100%;', 'tab' => 'config', 'caption' => CMS::lang('%LANG{en}Title%LANG{ru}Название'));
         $fields['_access'] = array('type' => 'input', 'style' => 'width: 200px;', 'tab' => 'config', 'caption' => CMS::lang('%LANG{en}Access%LANG{ru}Доступ'));
         $fields['_delsubheader'] = array('type' => 'subheader', 'style' => 'width: 200px;', 'tab' => 'config', 'caption' => CMS::lang(' '));
         static $ev = false;
         if (!$ev) {
             Events::add_listener('cms.fields.admin.mainform._delsubheader.after', function ($parms) {
                 $var = $parms['item'];
                 $url = WS::env()->urls->adminvars->delete_url($var->name());
                 if ($url == '#') {
                     return;
                 }
                 $title = 'Удалить';
                 $confirm = 'Вы уверены?';
                 print "<a href='{$url}' onClick='return confirm(\"{$confirm}\")' class='icon-button'><em style='background-image: url(/tao/images/del.png);'>{$title}</em></a>";
             });
             $ev = true;
         }
     }
     return $fields;
 }