Пример #1
0
 public function value()
 {
     $value = parent::value();
     if (empty($value)) {
         return '';
     }
     $value = (string) CMS::lang($value);
     return $value;
 }
Пример #2
0
 public function form_fields($form, $name, $parms)
 {
     $items = isset($parms['__items']) ? $parms['__items'] : CMS::items_for_select($parms['items']);
     $iobjects = array();
     foreach ($items as $id => $title) {
         $iobjects[] = (object) array('id' => $id, 'title' => CMS::lang($title));
     }
     $form->object_multi_select($name, $iobjects);
 }
Пример #3
0
 public function view_value($value, $name, $data)
 {
     $path = is_string($value) ? $value : $value[$name];
     $path = trim($path);
     if ($path == '') {
         return '';
     }
     $caption = CMS::lang()->_common->ta_download;
     $url = $this->uploaded_url($path);
     return "<a href='{$url}'>{$caption}</a>";
 }
Пример #4
0
 public function form_validator($form, $name, $data)
 {
     $message = CMS::lang()->_common->captcha_error;
     if (isset($data['error_message'])) {
         $message = $data['error_message'];
     }
     if (isset($data['validate_error_message'])) {
         $message = $data['validate_error_message'];
     }
     $this->validator($form)->validate_digital_protect($name, $message);
 }
Пример #5
0
 static function lang_select_items($with_all = true)
 {
     $out = array();
     if ($with_all) {
         $out['all'] = CMS::lang()->_common->all_languages;
     }
     foreach (self::langs() as $lang => $data) {
         if (is_string($data)) {
             $data = array('caption' => $data);
         }
         $out[$lang] = $data['caption'];
     }
     return $out;
 }
Пример #6
0
 public function read_item($title, $item)
 {
     $title = CMS::lang($title);
     if (is_string($item)) {
         $item = array('url' => trim($item));
     }
     if (isset($item['title'])) {
         $title = trim($item['title']);
     }
     if (isset($item['navigation_id'])) {
         $item['id'] = trim($item['navigation_id']);
     }
     $url = $item['url'];
     $url1 = $item['url'];
     Events::call('cms.navigation.add', $title, $item, $url);
     if ($url1 != $url) {
         $item['url'] = $url;
     }
     return parent::read_item($title, $item);
 }
Пример #7
0
 public function title()
 {
     return CMS::lang()->_vars->file;
 }
Пример #8
0
 public function add($title, $item)
 {
     if (!Core_Types::is_iterable($item)) {
         $item = array('uri' => $item, 'url' => $item);
     }
     if (isset($item['title'])) {
         $title = $item['title'];
     }
     $title = CMS::lang($title);
     //Events::dispatch('cms.navigation.add', $ev = Events::Event(array('title' => $title, 'data' => $item, 'url' => $item['url'])));
     //$title = $ev['title'];
     //$item = $ev['data'];
     //$item['url'] = $ev['url'];
     $url = $item['url'];
     Events::call('cms.navigation.add', $title, $item, $url);
     $item['url'] = $url;
     $access = isset($item['access']) ? trim($item['access']) : '';
     if ($access != '' && !CMS::check_globals_or($access)) {
         return $this;
     }
     if (isset($item['disabled'])) {
         if (CMS::check_yes($item['disabled'])) {
             return $this;
         }
     }
     $uri = '';
     if (isset($item['uri'])) {
         $uri = $item['uri'];
     }
     if (isset($item['url'])) {
         $uri = $item['url'];
     }
     $id = isset($item['id']) ? $item['id'] : md5($title . $uri);
     if (isset($item['navigation_id'])) {
         $id = trim($item['navigation_id']);
     }
     $selected = false;
     $disabled = false;
     if (isset($item['match'])) {
         if (preg_match($item['match'], CMS_Navigation3::$uri)) {
             $selected = true;
         }
     }
     if (isset($item['flag'])) {
         if (CMS::$navigation->is_flag($item['flag'])) {
             $selected = true;
         }
     }
     if ($uri == CMS_Navigation3::$uri) {
         $selected = true;
     }
     $item['selected'] = $selected;
     $item['disabled'] = $disabled;
     $sub = isset($item['sub']) ? $item['sub'] : null;
     if (is_string($sub)) {
         $sub = trim($sub);
         $_component = $sub;
         $_parms = $uri;
         if ($m = Core_Regexps::match_with_results('{^([^\\s]+)\\s+(.+)$}', $sub)) {
             $_component = trim($m[1]);
             $_parms = trim($m[2]);
         }
         if (CMS::component_exists($_component)) {
             $_class = CMS::$component_names[$_component];
             $_classref = Core_Types::reflection_for($_class);
             $sub = $_classref->hasMethod('navigation_tree') ? $_classref->getMethod('navigation_tree')->invokeArgs(NULL, array($_parms, $item)) : false;
         }
     }
     if (Core_Types::is_iterable($sub)) {
         $set = new CMS_Navigation3_LinkSet();
         $set->level_num = $this->level_num + 1;
         $set->process($sub);
         $this->link($id, $uri, $title, $item, $set);
     } else {
         $this->link($id, $uri, $title, $item);
     }
     return $this;
 }
Пример #9
0
 public function render()
 {
     if (!$this->type->access($this->name, $this->data, 'container_render', $this->item, $this)) {
         return '';
     }
     $value = $this->value();
     if (is_null($value)) {
         return '';
     }
     if (!is_string($value)) {
         return print_r($value, true);
     }
     if (is_string($value) && $this->type->enable_multilang()) {
         if ($this->forced_lang) {
             $value = CMS::lang($value, $this->forced_lang);
         } else {
             $value = CMS::lang($value);
         }
     }
     return $value;
 }
Пример #10
0
    public function node_template($name, $data, $items, $node_wrap_class, $caption_wrap_class, $level_up, $current_level, $top_caption)
    {
        $i = 0;
        $size = sizeof($items);
        $res = '';
        foreach ($items as $key => $item) {
            $suff = '';
            if ($i == 0) {
                $suff .= 'tree_item_first ';
            }
            if ($i == $size - 1) {
                $suff .= 'tree_item_last ';
            }
            $class_active = $key == $data['__item'][$name] ? 'tree_select_caption_active' : '';
            $disabled = '';
            if (is_array($item) && isset($item['disabled']) && $item['disabled']) {
                $disabled = "tree_select_node_disabled";
            }
            if (is_array($item['childs']) && !empty($item['childs'])) {
                $title = CMS::lang($item['title']);
                $elbow_open_icon = $level_up > $current_level ? 'tree_select_elbow_open_icon' : '';
                $array_open_icon = $level_up > $current_level ? 'tree_select_array_open_icon' : '';
                $sub_display = $level_up > $current_level ? 'block' : 'none';
                print <<<HTML
\t\t\t\t<div class="tree_select_array {$suff}" id="{$key}">
\t\t\t\t\t<div class="tree_select_icon tree_select_elbow_icon {$elbow_open_icon}"></div>
\t\t\t\t\t<div class="tree_select_node {$disabled} tree_select_item {$node_wrap_class}">
 \t\t\t\t\t\t<div class="tree_select_caption tree_select_caption_array {$caption_wrap_class} {$class_active}"> 
\t\t\t\t\t\t\t{$title}
\t\t\t\t\t\t</div>
\t\t\t\t\t</div>
\t\t\t\t\t<div class="tree_select_sub" style="display: {$sub_display}">
HTML;
                print $this->node_template($name, $data, $item['childs'], $node_wrap_class, $caption_wrap_class, $level_up, $current_level + 1, $top_caption);
                print <<<HTML
\t\t\t\t\t</div>
\t\t\t\t</div>
HTML;
            } else {
                if (is_string($item)) {
                    $title = CMS::lang((string) $item);
                } else {
                    $title = CMS::lang($item['title']);
                }
                print <<<HTML
\t\t\t\t<div class="tree_select_one {$suff}" id="{$key}">
\t\t\t\t\t<div class="tree_select_branch"></div>
\t\t\t\t\t<div class="tree_select_node {$disabled} {$node_wrap_class}">
\t\t\t\t\t\t<div class="tree_select_caption tree_select_caption_one {$caption_wrap_class} {$class_active}">{$title}</div>
\t\t\t\t\t</div>
\t\t\t\t</div>
HTML;
            }
            $i++;
        }
        return $res;
    }
Пример #11
0
 public function get()
 {
     return CMS::lang((string) $this['value']);
 }
Пример #12
0
 protected function layout_preprocess($l, $name, $data)
 {
     $item = $this->get_item($name, $data);
     $l->use_scripts(CMS::stdfile_url('scripts/fields/image.js'));
     $l->use_scripts(CMS::stdfile_url('scripts/jquery/block.js'));
     $id = $this->url_class();
     $l->with('url_class', $id);
     if ($item && !$item->is_phantom()) {
         $code = "; \$(function() { \$('.{$id}.field-{$name}').each(function() {\n\t\t \t\t\t\t\tTAO.fields.image.process(\$(this));\n\t\t\t\t\t\t\t}\n\t\t\t)});";
         $l->append_to('js', $code);
     }
     Templates_HTML::add_scripts_settings(array('fields' => array($name => array('confirm' => CMS::lang()->_common->ta_diconfirm))));
     return parent::layout_preprocess($l, $name, $data);
 }
Пример #13
0
 public function as_string()
 {
     return CMS::lang(parent::as_string());
 }
Пример #14
0
 public function assign_from_object($form, $object, $name, $data)
 {
     $value = is_object($object) ? $object[$name] : $object;
     if ($langs = $this->data_langs($data)) {
         $lvalues = CMS::lang()->lang_split($value);
         foreach ($langs as $lang => $ldata) {
             $current_format_name = $this->name_lang($name . '_format', $lang);
             $fvalues = $this->format_split($lvalues[$lang]);
             foreach ($fvalues as $code => $fvalue) {
                 $fname = $this->get_format_name($name, $code);
                 $flname = $this->name_lang($fname, $lang);
                 $form[$flname] = $fvalue;
                 $form[$current_format_name] = $code;
             }
             if (empty($form[$current_format_name]) && !empty($current_format_name)) {
                 $form[$current_format_name] = reset(array_keys($this->get_formats($name, $data)));
             }
         }
     } else {
         $fvalues = $this->format_split($value);
         $current_format_name = $name . '_format';
         if (!empty($fvalues)) {
             foreach ($fvalues as $code => $fval) {
                 $form[$this->get_format_name($name, $code)] = $fval;
                 $form[$current_format_name] = $code;
             }
         }
         $form[$name] = $value;
     }
     if (empty($form[$current_format_name]) && !empty($current_format_name)) {
         $form[$current_format_name] = reset(array_keys($this->get_formats($name, $data)));
     }
     //return parent::assign_from_object($form,$object,$name,$data);
 }
Пример #15
0
 protected function process_form($item)
 {
     $errors = parent::process_form($item);
     if (isset($this->form['_name']) && sizeof($errors) == 0) {
         $name = trim($this->form['_name']);
         if (Core_Regexps::match('{^[a-z0-9_-]+$}i', $name)) {
             return array();
         }
         if (Core_Regexps::match('{^[a-z0-9_-]+\\.[a-z0-9_-]+$}i', $name)) {
             return array();
         }
         return array('_name' => CMS::lang('%LANG{en}Invalid name!%LANG{ru}Некорректный мнемокод!'));
     }
     return $errors;
 }
Пример #16
0
 public function add($title, $item)
 {
     if (isset($item['title'])) {
         $title = trim($item['title']);
         $item['title'] = CMS::lang($title);
     }
     $title = CMS::lang($title);
     if (!$this['sub']) {
         $this['sub'] = new ArrayObject();
     }
     if ($item instanceof CMS_Navigation_Node) {
         $this['sub'][$title] = $item;
     } else {
         if (is_string($item)) {
             $item = array('url' => $item);
         }
         $url = $item['url'];
         Events::call('cms.navigation.add', $title, $item, $url);
         $item['url'] = $url;
         if (!isset($item['disabled']) || !$item['disabled'] && CMS::check_no($item['disabled'])) {
             $this['sub'][$title] = new CMS_Navigation_Node($title, $item);
         }
     }
 }
Пример #17
0
 public function dir($id, $component = false)
 {
     $this->component = $component;
     $rows = CMS::vars()->db()->for_id($id, $component);
     foreach ($rows as $key => &$row) {
         $row[':del'] = $this->make_uri('del', $row->id);
         $row[':edit'] = $this->make_uri('dir', $row->id);
         $row[':parms'] = $this->make_uri('parms', $row->id);
         $row->list_value = CMS::vars()->type($row->vartype)->list_value($row);
     }
     $_up = '';
     if ($id == 0) {
         $item = CMS::vars()->db()->make_entity();
         $item->id = 0;
         $item->vartype = 'dir';
         $item->full_code = '';
         $item->title = CMS::lang()->_vars->root_dir;
     } else {
         $item = $this->_item;
         $prefix = CMS::vars()->db()->full_code($id);
         foreach ($rows as $key => &$row) {
             $row->code = $prefix . '.' . $row->code;
         }
         $_up = $this->make_uri('dir', $item->parent_id);
     }
     return $this->render('index', array('title' => $this->get_title($item), 'id' => $id, 'rows' => $rows, 'item' => $item, 'component' => $component, '_up' => $_up, '_add' => $this->make_uri('add', $id)));
 }
Пример #18
0
 public function title()
 {
     return CMS::lang($this->_title);
 }
Пример #19
0
 public function preview()
 {
     return (bool) $this['value'] ? CMS::lang('%LANG{en}Yes%LANG{ru}Да') : CMS::lang('%LANG{en}No%LANG{ru}Нет');
 }
Пример #20
0
 public function get_add_file_text($name, $data)
 {
     return CMS::lang()->_common->ta_addimg;
 }
Пример #21
0
    protected function layout_preprocess($l, $name, $data)
    {
        $l->use_scripts(CMS::stdfile_url('scripts/fields/attaches.js'));
        if ($this->block_on_upload) {
            $l->use_scripts(CMS::stdfile_url('scripts/jquery/block.js'));
        }
        if (!empty($data['__item_id']) || !empty($data['__item']) && !empty($data['__item']->id)) {
            $id = $this->url_class();
            $code = <<<JS

\$(function() {
\$(".{$id}.field-{$name}").each(function() {TAO.fields.attaches.process(\$(this));});
});

JS;
            $l->append_to('js', $code);
            $l->with('url_class', $id);
            Templates_HTML::add_scripts_settings(array('fields' => array($name => array('confirm' => CMS::lang()->_common->ta_dfconfirm, 'block' => $this->block_on_upload))));
        }
        parent::layout_preprocess($l, $name, $data);
    }
Пример #22
0
 public function preview()
 {
     $caption = CMS::lang()->_common->ta_download;
     $url = $this->field('file')->url();
     return "<a href='{$url}'>{$caption}</a>";
 }