Esempio n. 1
0
 public function setup()
 {
     if (CMS::vars()->storage_type() == 'orm') {
         $this->orm_name = 'vars';
     }
     if (CMS::vars()->storage_type() == 'storage') {
         $this->storage_name = 'vars';
     }
     $this->merge_options();
     Templates_HTML::add_scripts_settings(array('adminvars' => $this->js_config));
     $this->auth_realm = CMS::$admin_realm;
     if (isset(CMS::$cfg->vars->use_tinymce)) {
         $s = trim(CMS::$cfg->vars->use_tinymce);
         if ($s == '' || $s == '0') {
             $this->use_tinymce = false;
         }
     }
     $this->use_views_from(CMS::views_path('admin/vars'))->use_views_from(CMS::views_path('admin/vars2'));
     if (CMS::vars()->storage_type() == 'orm') {
         $types = WS::env()->orm->vars->types();
         $this->form_fields = $types->fields;
         $types->end();
     }
     if (CMS::vars()->storage_type() == 'storage') {
         $this->form_fields = $this->storage()->make_entity()->fields();
         // var_dump($this->form_fields);
     }
     $this->component = WS::env()->adminvars->component;
     //TODO: configure fields
     if (empty($this->tree_fields)) {
         $this->tree_fields = array('title' => array('caption' => 'Комментарий', 'flex' => 1), 'var_description' => array('caption' => 'Тип', 'flex' => 1), 'full_code' => array('caption' => 'Идентификатор', 'width' => 200));
     }
     return parent::setup();
 }
Esempio n. 2
0
    protected function layout_preprocess($l, $name, $data)
    {
        $item = $this->get_item($name, $data);
        $l->use_styles(CMS::stdfile_url('styles/SlickGrid/slick.grid.css'), CMS::stdfile_url('styles/SlickGrid/slick-default-theme.css'), CMS::stdfile_url('styles/SlickGrid/slick.css'), CMS::stdfile_url('styles/jquery/ui.css'), CMS::stdfile_url('styles/fields/documents-grid.css'));
        $l->use_scripts(CMS::stdfile_url('scripts/tao/data.js'), CMS::stdfile_url('scripts/tao/oop.js'), CMS::stdfile_url('scripts/fields/documents-grid.js'), CMS::stdfile_url('scripts/jquery/ui.js'), CMS::stdfile_url('scripts/jquery/event.drag.js'), CMS::stdfile_url('scripts/jquery/event.drop.js'), CMS::stdfile_url('scripts/SlickGrid/slick.core.js'), CMS::stdfile_url('scripts/SlickGrid/slick.formatters.js'), CMS::stdfile_url('scripts/SlickGrid/slick.editors.js'), CMS::stdfile_url('scripts/SlickGrid/slick.grid.js'), CMS::stdfile_url('scripts/SlickGrid/slick.table.js'), CMS::stdfile_url('scripts/SlickGrid/plugins/slick.rowmovemanager.js'), CMS::stdfile_url('scripts/SlickGrid/plugins/slick.rowselectionmodel.js'), CMS::stdfile_url('scripts/tao/data.js'));
        $id = $this->url_class();
        $l->with('url_class', $id);
        if ($item && !$item->is_phantom()) {
            $code = <<<JS
\t\t\$(window).load(function () { \$('.{$id}.field-{$name}').each(function() {TAO.fields.documents_grid.process(\$(this))}) })
JS;
            $l->append_to('js', $code);
        }
        Templates_HTML::add_scripts_settings(array('fields' => array($name => array('fields' => $this->get_fields($name, $data), 'api' => array('read' => CMS::$current_controller->field_action_url($name, 'load', $data['__item']), 'update' => CMS::$current_controller->field_action_url($name, 'update', $data['__item']), 'destroy' => CMS::$current_controller->field_action_url($name, 'delete', $data['__item']), 'save' => CMS::$current_controller->field_action_url($name, 'save', $data['__item']))))));
        return parent::layout_preprocess($l, $name, $data);
    }
Esempio n. 3
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);
    }
Esempio n. 4
0
 protected function setup_settings()
 {
     $this->state_expanded_name = !empty($this->state_expanded_name) ? $this->state_expanded_name : str_replace('.', '_', $this->name) . '_expanded';
     Templates_HTML::add_scripts_settings(array('tree' => array('expanded_state_name' => $this->state_expanded_name)));
     Templates_HTML::add_scripts_settings(array('tree' => array('edit_icon' => '/files/_assets/images/edit.gif', 'delete_icon' => '/files/_assets/images/del.gif', 'fields' => $this->tree_fields())));
 }
Esempio n. 5
0
    protected function layout_preprocess($l, $name, $data)
    {
        $l->use_styles(CMS::stdfile_url('styles/fields/documents.css'), CMS::stdfile_url('styles/jquery/dform.css'));
        $l->use_scripts(CMS::stdfile_url('scripts/jquery/dform.js'), CMS::stdfile_url('scripts/tao/popup.js'), CMS::stdfile_url('scripts/fields/documents.js'), CMS::stdfile_url('scripts/jquery/json.js'), CMS::stdfile_url('scripts/jquery/tablednd.js'));
        $doc_fields = $this->get_doc_fields($name, $data);
        foreach ($doc_fields as $dname => $ddata) {
            if ($ddata['xtype'] == 'datefield' || $ddata['type'] == 'date') {
                $l->use_script(CMS::stdfile_url('scripts/jquery/ui.js'), array('weight' => -1));
                $l->use_style(CMS::stdfile_url('styles/jquery/ui.css'));
            }
        }
        $id = $this->url_class();
        $code = <<<JS
\t\t\$(function () { \$('.{$id}.field-{$name}').each(function() {TAO.fields.documents.process(\$(this))}) })
JS;
        $item = $this->get_item($name, $data);
        if ($item && method_exists($item, 'is_phantom') && !$item->is_phantom()) {
            $l->append_to('js', $code);
        }
        $l->with('url_class', $id);
        Templates_HTML::add_scripts_settings(array('fields' => array($name => array('fields' => $doc_fields, 'autoedit_on_upload' => isset($data['autoedit_on_upload']) ? $data['autoedit_on_upload'] : $this->autoedit_on_upload))));
        return parent::layout_preprocess($l, $name, $data);
    }
Esempio n. 6
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);
 }
Esempio n. 7
0
 /**
  * Инициализации редактора
  *
  * Дополнительно можно указать jquery селектор textarea для автоматического подключения редактора
  *
  * @param  mixed  $t        объект шаблона
  * @param  string $selector jquery селектор
  *
  * @return self
  */
 public function process_template($t, $selector = '')
 {
     if (!$this->validate_instalation($t)) {
         return $this;
     }
     $this->add_files_to($t);
     Templates_HTML::add_scripts_settings(array('editor' => array($this->name => $this->settings())), true);
     if (!empty($selector)) {
         $this->attach_to($t, $selector);
     }
     return $this;
 }