Ejemplo n.º 1
0
 protected function orm_mapper()
 {
     if (!$this->orm_name) {
         return false;
     }
     $name = $this->orm_name;
     if (is_string($name)) {
         return CMS::orm()->{$name};
     }
     return false;
 }
Ejemplo n.º 2
0
Archivo: Tags.php Proyecto: techart/tao
 public function tie($tags)
 {
     $id = (int) $this->item->id();
     if ($id == 0) {
         return;
     }
     if (!is_array($tags)) {
         $tags = array($tags);
     }
     $items = isset($this->data['items']) ? CMS::items_for_select($this->data['items']) : false;
     $table = $this->item->mapper->options['table'][0];
     $table_rels = CMS_Fields_Types_Tags::table_rels($table, $this->name);
     $table_tags = CMS_Fields_Types_Tags::table_tags($table, $this->name);
     foreach ($tags as $tag_id) {
         $tag_id = (int) $tag_id;
         if ($tag_id > 0) {
             if ($items && isset($items[$tag_id])) {
                 CMS_Fields_Types_Tags::check_tag_title($tag_id, $items[$tag_id], $table_tags);
             }
             CMS::orm()->connection->prepare("INSERT INTO {$table_rels} SET item_id=:item_id, tag_id=:tag_id")->bind(array('item_id' => $id, 'tag_id' => $tag_id))->execute();
         }
     }
 }
Ejemplo n.º 3
0
 public function get($var)
 {
     $this->deserialize($var);
     $m = CMS::orm()->vars->spawn();
     $m->types()->build($this->fields)->end();
     $var->set_mapper($m);
     return $var;
 }
Ejemplo n.º 4
0
 protected function dbc()
 {
     return CMS::orm()->connection();
 }
Ejemplo n.º 5
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.º 6
0
Archivo: Base.php Proyecto: techart/tao
 static function db()
 {
     return CMS::orm();
 }
Ejemplo n.º 7
0
Archivo: CLI.php Proyecto: techart/tao
 static function set_call_time($name)
 {
     CMS::orm()->connection->prepare('DELETE FROM tao_cli_calls WHERE name=:name')->bind(array('name' => $name))->execute();
     CMS::orm()->connection->prepare('INSERT INTO tao_cli_calls SET name=:name, time=:time')->bind(array('name' => $name, 'time' => time()))->execute();
 }