예제 #1
0
파일: TreeSelect.php 프로젝트: techart/tao
 protected function preprocess($template, $name, $data)
 {
     $t = parent::preprocess($template, $name, $data);
     $items = isset($data['__items']) ? $data['__items'] : CMS::items_for_select($data['items']);
     $empty_value = isset($data['empty_value']) ? $data['empty_value'] : null;
     $outs = $this->process_items($items, $data);
     $t->with(array('wrap' => $wrap = !isset($data['text-wrap']) ? 'none' : $data['text-wrap'], 'node_wrap_class' => "text-wrap_" . $wrap . "_node", 'caption_wrap_class' => "text-wrap_" . $wrap . "_caption", 'selectioner_wrap_class' => "text-wrap_" . $wrap . "_selectioner", 'container_style' => isset($data['container_style']) ? $data['container_style'] : null, 'level_up' => !isset($data['level_up']) ? 1 : $data['level_up'], 'empty_value' => $empty_value));
     return $t->with('flat_items', $outs[1], 'items', $outs[0]);
 }
예제 #2
0
파일: Select.php 프로젝트: techart/tao
 protected function get_items($name, $data)
 {
     $items = array();
     if (isset($data['__items'])) {
         $items = $data['__items'];
     } else {
         $items = CMS::items_for_select($data['items']);
     }
     return $items;
 }
예제 #3
0
 public function render()
 {
     if (!$this->type->access($this->name, $this->data, 'container_render', $this->item, $this)) {
         return '';
     }
     $value = '';
     $values = $this->as_array();
     $items = CMS::items_for_select($this->data['items']);
     foreach ($values as $v) {
         $value .= ($value ? ', ' : '') . $items[$v];
     }
     return $value;
 }
예제 #4
0
파일: AdminTable.php 프로젝트: techart/tao
 public function items_for_select($s)
 {
     if (is_string($s) && ($m = Core_Regexps::match_with_results('/^:(.+)$/', $s))) {
         $method = trim($m[1]);
         if ($m = Core_Regexps::match_with_results('/^(.+)\\((.*)\\)$/', $method)) {
             $method = trim($m[1]);
             $parms = explode(',', trim($m[2]));
             foreach ($parms as $k => $v) {
                 $v = trim($v);
                 $parms[$k] = $v;
             }
             return call_user_func_array(array($this, $method), $parms);
         }
         return $this->{$method}();
     }
     return CMS::items_for_select($s);
 }
예제 #5
0
 public function action($name, $data, $action, $item = false, $fields = array())
 {
     $args = func_get_args();
     $res = Net_HTTP::Response();
     $res->content_type('application/json');
     $query = WS::env()->request['query'];
     $ents = CMS::items_for_select(Core::invoke($data['search'], array($query)));
     $values = array();
     $empty = $this->get_empty($data);
     if ($empty && empty($query)) {
         $values[] = $empty;
     }
     foreach ($ents as $k => $e) {
         $values[] = array('id' => (int) $k, 'title' => (string) $e);
     }
     $res->body(json_encode(array('data' => $values)));
     return $res;
 }
예제 #6
0
파일: Tags.php 프로젝트: 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();
         }
     }
 }
예제 #7
0
 public function assign_to_object($object, Forms_Form $form, $name, $parms)
 {
     $values = array();
     $items = CMS::items_for_select($parms['items']);
     foreach ($items as $key => $data) {
         $fname = $name . $key;
         if ($form[$fname]) {
             $values[] = $key;
         }
     }
     $object->{$name} = implode(',', $values);
 }
예제 #8
0
파일: Checkboxes.php 프로젝트: techart/tao
 protected function preprocess($template, $name, $data)
 {
     $t = parent::preprocess($template, $name, $data);
     return $t->with('items', isset($data['__items']) ? $data['__items'] : CMS::items_for_select($data['items']));
 }
예제 #9
0
파일: Fields.php 프로젝트: techart/tao
 protected function items_for_select($items)
 {
     return CMS::items_for_select($items);
 }