示例#1
0
 /**
  * @return string
  */
 protected function makeControl()
 {
     $tpl = new Mtpl($this->theme_location . '/html/form/controls/radio.html');
     if (!empty($this->options)) {
         foreach ($this->options as $key => $name) {
             $attributes = array("value=\"{$key}\"");
             if ($this->checked !== null) {
                 if (is_array($this->checked) && in_array($key, $this->checked)) {
                     $attributes[] = 'checked="checked"';
                 } elseif ($this->checked === $key) {
                     $attributes[] = 'checked="checked"';
                 }
             }
             if (!empty($this->attributes)) {
                 foreach ($this->attributes as $attr_name => $value) {
                     if (trim($attr_name) != 'value') {
                         $attributes[] = "{$attr_name}=\"{$value}\"";
                     }
                 }
             }
             if ($this->required) {
                 $attributes[] = 'required="required"';
                 if ($this->required_message) {
                     $attributes[] = "data-required-message=\"{$this->required_message}\"";
                 }
             }
             // TODO сделать валидаторы
             if (!empty($this->validators)) {
                 foreach ($this->validators as $validator) {
                 }
             }
             $tpl->radio->assign('[ATTRIBUTES]', implode(' ', $attributes));
             $tpl->radio->assign('[NAME]', $name);
             $tpl->radio->reassign();
         }
     }
     return $tpl->render();
 }
示例#2
0
 /**
  * @return string
  */
 protected function makeControl()
 {
     $tpl = new Mtpl(__DIR__ . '/tpl/control.html');
     $attributes = array();
     $attributes_raw['type'] = isset($attributes_raw['type']) ? $attributes_raw['type'] : 'text';
     $attributes_raw['class'] = isset($attributes_raw['class']) ? $attributes_raw['class'] : 'form-control';
     if (!empty($attributes_raw)) {
         foreach ($attributes_raw as $attr_name => $value) {
             $attributes[] = "{$attr_name}=\"{$value}\"";
         }
     }
     if (isset($options['required']) && $options['required']) {
         $attributes[] = 'required="required"';
         $tpl->assign('[REQUIRED]', '<span class="combine-req-star">*</span> ');
         if (!empty($options['required_message'])) {
             $attributes[] = "data-required-message=\"{$options['required_message']}\"";
         }
     }
     if (!empty($options['validators'])) {
         foreach ($options['validators'] as $validator) {
             // TODO сделать валидаторы
         }
     }
     if (!empty($attributes_raw['id'])) {
         $attr_id = $attributes_raw['id'];
     } elseif (!empty($attributes_raw['name'])) {
         $attr_id = $attributes_raw['name'];
     } else {
         $attr_id = '';
     }
     $tpl->assign('[ID]', $attr_id);
     $tpl->assign('[LABEL]', $label);
     $tpl->assign('[ATTRIBUTES]', implode(' ', $attributes));
     if (!empty($options['out'])) {
         $tpl->assign('[OUT]', $options['out']);
     }
     return $tpl->render();
 }
示例#3
0
 /**
  * @return string
  */
 protected function makeControl()
 {
     $tpl = new Mtpl($this->theme_location . '/html/form/controls/upload2.html');
     if (!empty($this->files)) {
         foreach ($this->files as $file) {
             $file_type = strpos($file['name'], '.') !== false ? substr($file['name'], strrpos($file['name'], '.')) : '';
             $file_id = uniqid();
             $tpl->file->assign('[ID]', $file_id);
             $tpl->file->assign('[NAME]', $file['name']);
             $tpl->file->assign('[SIZE]', $file['size']);
             $tpl->file->assign('[SIZE_FORMAT]', $this->formatSizeUnits($file['size']));
             $tpl->file->assign('[TYPE]', $file_type);
             $tpl->file->reassign();
             if (empty($this->attributes['value'])) {
                 $this->attributes['value'] = "{$file['name']}:{$file['size']}:{$file_type}";
             } else {
                 $this->attributes['value'] .= "|{$file['name']}:{$file['size']}:{$file_type}";
             }
         }
     }
     $id = uniqid();
     $attributes = array("id=\"control-{$id}\"");
     if (!empty($this->attributes)) {
         foreach ($this->attributes as $attr_name => $value) {
             if (trim($attr_name) != 'id') {
                 $attributes[] = "{$attr_name}=\"{$value}\"";
             }
         }
     }
     if ($this->required) {
         $attributes[] = 'required="required"';
         if ($this->required_message) {
             $attributes[] = "data-required-message=\"{$this->required_message}\"";
         }
     }
     $tpl->assign('[ATTRIBUTES]', implode(' ', $attributes));
     $tpl->assign('[THEME_SRC]', $this->theme_src);
     $tpl->assign('[ID]', $id);
     $tpl->assign('[RESOURCE]', $this->resource);
     return $tpl->render();
 }
示例#4
0
 /**
  * Создание элементов дерева
  * @param  array    $elements
  * @param  string   $element_tpl
  * @param  int|null $parent_id
  *
  * @return string
  */
 protected function buildElements($elements, $element_tpl, $parent_id = null)
 {
     $tpl = new Mtpl();
     $tpl->setTemplate($element_tpl);
     foreach ($elements as $node) {
         if ($node['parent_id'] === $parent_id) {
             $tpl->assign('[URL]', $node['url']);
             $tpl->assign('[TITLE]', $node['title']);
             $tpl->assign('[ELEMENT_OPTIONS]', !empty($node['options']) ? json_encode($node['options']) : '');
             $sub_elements = $this->buildElements($elements, $element_tpl, $node['id']);
             $tpl->assign('[SUB_ELEMENTS]', $sub_elements !== $element_tpl ? '<ul>' . $sub_elements . '</ul>' : '');
             $tpl->reassign();
         }
     }
     return $tpl->render();
 }
示例#5
0
 /**
  * Создание таблицы
  * @return void
  */
 protected function make()
 {
     $tpl = new Mtpl($this->theme_location . '/html/table.html');
     $tpl->assign('[TPL_DIR]', $this->theme_src);
     if (!empty($this->search)) {
         $search_value = !empty($this->sessData['search']) ? $this->sessData['search'] : array();
         if (!empty($search_value) && count($search_value)) {
             $tpl->search->clear->assign('[RESOURCE]', $this->resource);
             $tpl->search->clear->assign('[TPL_DIR]', $this->theme_src);
         }
         $tpl->search->assign('[RESOURCE]', $this->resource);
         $tpl->search->assign('[TPL_DIR]', $this->theme_src);
         foreach ($this->search as $key => $search) {
             if ($search instanceof Search) {
                 $control_value = isset($search_value[$key]) ? $search_value[$key] : '';
                 switch ($search->getType()) {
                     case 'text':
                         $tpl->search->field->text->assign("[ID]", "search-{$this->resource}-{$key}");
                         $tpl->search->field->text->assign("[NAME]", "search[{$key}]");
                         $tpl->search->field->text->assign("[VALUE]", $control_value);
                         $tpl->search->field->text->assign("[IN_TEXT]", $search->getIn());
                         break;
                     case 'radio':
                         $data = $search->getData();
                         if (!empty($data)) {
                             $data = array('' => $this->getLocution('All')) + $data;
                             foreach ($data as $radio_value => $radio_title) {
                                 $tpl->search->field->radio->assign("[ID]", "search-{$this->resource}-{$key}");
                                 $tpl->search->field->radio->assign("[NAME]", "search[{$key}]");
                                 $tpl->search->field->radio->assign("[VALUE]", $radio_value);
                                 $tpl->search->field->radio->assign("[TITLE]", $radio_title);
                                 $tpl->search->field->radio->assign("[IN_TEXT]", $search->getIn());
                                 $is_checked = $control_value == $radio_value ? 'checked="checked"' : '';
                                 $tpl->search->field->radio->assign("[IS_CHECKED]", $is_checked);
                                 $tpl->search->field->radio->reassign();
                             }
                         }
                         break;
                     case 'checkbox':
                         $data = $search->getData();
                         if (!empty($data)) {
                             foreach ($data as $checkbox_value => $checkbox_title) {
                                 $tpl->search->field->checkbox->assign("[ID]", "search-{$this->resource}-{$key}");
                                 $tpl->search->field->checkbox->assign("[NAME]", "search[{$key}][]");
                                 $tpl->search->field->checkbox->assign("[VALUE]", $checkbox_value);
                                 $tpl->search->field->checkbox->assign("[TITLE]", $checkbox_title);
                                 $tpl->search->field->checkbox->assign("[IN_TEXT]", $search->getIn());
                                 $is_checked = is_array($control_value) && in_array($checkbox_value, $control_value) ? 'checked="checked"' : '';
                                 $tpl->search->field->checkbox->assign("[IS_CHECKED]", $is_checked);
                                 $tpl->search->field->checkbox->reassign();
                             }
                         }
                         break;
                     case 'date':
                         $tpl->search->field->date->assign("[ID]", "search-{$this->resource}-{$key}");
                         $tpl->search->field->date->assign("[NAME_FROM]", "search[{$key}][0]");
                         $tpl->search->field->date->assign("[NAME_TO]", "search[{$key}][1]");
                         $tpl->search->field->date->assign("[VALUE_FROM]", isset($control_value[0]) ? $control_value[0] : '');
                         $tpl->search->field->date->assign("[VALUE_TO]", isset($control_value[1]) ? $control_value[1] : '');
                         $tpl->search->field->date->assign("[IN_TEXT]", $search->getIn());
                         break;
                     case 'datetime':
                         $tpl->search->field->datetime->assign("[ID]", "search-{$this->resource}-{$key}");
                         $tpl->search->field->datetime->assign("[NAME_FROM]", "search[{$key}][0]");
                         $tpl->search->field->datetime->assign("[NAME_TO]", "search[{$key}][1]");
                         $tpl->search->field->datetime->assign("[VALUE_FROM]", isset($control_value[0]) ? $control_value[0] : '');
                         $tpl->search->field->datetime->assign("[VALUE_TO]", isset($control_value[1]) ? $control_value[1] : '');
                         $tpl->search->field->datetime->assign("[IN_TEXT]", $search->getIn());
                         break;
                     case 'select':
                         $data = $search->getData();
                         $options = array('' => '') + $data;
                         $tpl->search->field->select->assign("[ID]", "search-{$this->resource}-{$key}");
                         $tpl->search->field->select->assign("[NAME]", "search[{$key}]");
                         $tpl->search->field->select->assign("[IN_TEXT]", $search->getIn());
                         $tpl->search->field->select->fillDropDown("[ID]", $options, $control_value);
                         break;
                     case 'multiselect':
                         $data = $search->getData();
                         $tpl->search->field->multiselect->assign("[ID]", "search-{$this->resource}-{$key}");
                         $tpl->search->field->multiselect->assign("[NAME]", "search[{$key}][]");
                         $tpl->search->field->multiselect->assign("[IN_TEXT]", $search->getIn());
                         $tpl->search->field->multiselect->fillDropDown("[ID]", $data, $control_value);
                         break;
                 }
                 $tpl->search->field->assign("[#]", $key);
                 $tpl->search->field->assign("[OUT_TEXT]", $search->getOut());
                 $tpl->search->field->assign('[CAPTION]', $search->getCaption());
                 $tpl->search->field->reassign();
             }
         }
     }
     if ($this->add_url) {
         $tpl->add_button->assign('[URL]', $this->add_url);
     }
     if ($this->show_delete && $this->delete_url != '') {
         $delete_msg = $this->getLocution('Are you sure you want to delete this post?');
         $no_select_msg = $this->getLocution('You must select at least one record');
         $tpl->del_button->assign('[DELETE_ACTION]', "combine.table.del('{$this->resource}', '{$delete_msg}',  '{$no_select_msg}', '{$this->delete_url}')");
     }
     $token = sha1(uniqid());
     $this->session->table->__csrf_token = $token;
     $tpl->assign('[TOKEN]', $token);
     $tpl->assign('[RESOURCE]', $this->resource);
     $tpl->assign('[BUTTONS]', implode('', $this->buttons));
     foreach ($this->columns as $key => $column) {
         if ($column instanceof Column) {
             if ($column->isSorting()) {
                 if (isset($this->sessData['order']) && $this->sessData['order'] == $key + 1) {
                     if ($this->sessData['order_type'] == "ASC") {
                         $tpl->header->cell->sort->order_asc->assign('[SRC]', $this->theme_src . '/img/asc.gif');
                     } elseif ($this->sessData['order_type'] == "DESC") {
                         $tpl->header->cell->sort->order_desc->assign('[SRC]', $this->theme_src . '/img/desc.gif');
                     }
                 }
                 $width = $column->getAttr('width');
                 if ($width) {
                     $tpl->header->cell->sort->assign('<th', "<th width=\"{$width}\"");
                 }
                 $tpl->header->cell->sort->assign('[COLUMN_NUMBER]', $key + 1);
                 $tpl->header->cell->sort->assign('[CAPTION]', $column->getTitle());
             } else {
                 $width = $column->getAttr('width');
                 if ($width) {
                     $tpl->header->cell->no_sort->assign('<th', "<th width=\"{$width}\"");
                 }
                 $tpl->header->cell->no_sort->assign('[CAPTION]', $column->getTitle());
             }
             $tpl->header->cell->reassign();
         }
     }
     if ($this->show_checkboxes == true) {
         $tpl->header->touchBlock('checkboxes');
     }
     $this->fetchData();
     $tpl->assign('[TOTAL_RECORDS]', ($this->round_record_count ? '~' : '') . $this->record_count);
     if (!empty($this->data)) {
         $row_index = 1;
         $row_number = $this->current_page > 1 ? ($this->current_page - 1) * $this->records_per_page + 1 : 1;
         foreach ($this->data as $row) {
             if (!$row instanceof Row) {
                 $row = new Row($row);
             }
             $tpl->row->assign('[ID]', $row->id);
             $tpl->row->assign('[#]', $row_number);
             if ($this->edit_url) {
                 $edit_url = $this->replaceTCOL($row, $this->edit_url);
                 $row->setAppendAttr('class', 'edit-row');
                 if (strpos($edit_url, 'javascript:') === 0) {
                     $row->setAppendAttr('onclick', substr($edit_url, 11));
                 } else {
                     $row->setAppendAttr('onclick', "combine.table.load('{$edit_url}');");
                 }
             }
             foreach ($this->columns as $column) {
                 if ($column instanceof Column) {
                     $cell = $row->{$column->getField()};
                     $value = $cell->getValue();
                     switch ($column->getType()) {
                         case 'text':
                             $tpl->row->col->assign('[VALUE]', htmlspecialchars($value));
                             break;
                         case 'number':
                             $value = strrev($value);
                             $value = (string) preg_replace('/(\\d{3})(?=\\d)(?!\\d*\\.)/', '$1;psbn&', $value);
                             $value = strrev($value);
                             $tpl->row->col->assign('[VALUE]', $value);
                             break;
                         case 'html':
                             $tpl->row->col->assign('[VALUE]', htmlspecialchars_decode($value));
                             break;
                         case 'date':
                             $date = $value ? date($this->date_mask, strtotime($value)) : '';
                             $tpl->row->col->assign('[VALUE]', $date);
                             break;
                         case 'datetime':
                             $date = $value ? date($this->datetime_mask, strtotime($value)) : '';
                             $tpl->row->col->assign('[VALUE]', $date);
                             break;
                         case 'status':
                             if ($value == 'Y' || $value == 1) {
                                 $img = "<img src=\"{$this->theme_src}/img/lightbulb_on.png\" alt=\"[#on#]\" title=\"[#on#]/[#off#]\" data-value=\"{$value}\"/>";
                             } else {
                                 $img = "<img src=\"{$this->theme_src}/img/lightbulb_off.png\" alt=\"[#off#]\" title=\"[#on#]/[#off#]\" data-value=\"{$value}\"/>";
                             }
                             $tpl->row->col->assign('[VALUE]', $img);
                             break;
                     }
                     // Атрибуты ячейки
                     $column_attributes = $cell->getAttribs();
                     $attributes = array();
                     foreach ($column_attributes as $attr => $value) {
                         $attributes[] = "{$attr}=\"{$value}\"";
                     }
                     $implode_attributes = implode(' ', $attributes);
                     $implode_attributes = $implode_attributes ? ' ' . $implode_attributes : '';
                     $tpl->row->col->assign('<td>', "<td{$implode_attributes}>");
                     if (end($this->columns) != $column) {
                         $tpl->row->col->reassign();
                     }
                 }
             }
             $attribs = $row->getAttribs();
             if (!empty($attribs)) {
                 $attribs_string = '';
                 foreach ($attribs as $name => $attr) {
                     $attribs_string .= " {$name}=\"{$attr}\"";
                 }
                 $tpl->row->assign('<tr', '<tr ' . $attribs_string);
             }
             if ($this->show_checkboxes) {
                 $tpl->row->checkboxes->assign('[ID]', $row->id);
                 $tpl->row->checkboxes->assign('[RESOURCE]', $this->resource);
                 $tpl->row->checkboxes->assign('[#]', $row_index);
                 $row_index++;
             }
             $row_number++;
             $tpl->row->reassign();
         }
     } else {
         $tpl->touchBlock('no_rows');
     }
     // Pagination
     $count_pages = ceil($this->record_count / $this->records_per_page);
     $tpl->pages->assign('[CURRENT_PAGE]', $this->current_page);
     $tpl->pages->assign('[COUNT_PAGES]', $count_pages);
     if ($count_pages > 1 || $this->records_per_page > 25) {
         $tpl->pages->touchBlock('gotopage');
         $tpl->pages->touchBlock('per_page');
         if ($this->current_page > 1) {
             $tpl->pages->prev->assign('[PREV_PAGE]', $this->current_page - 1);
         }
         if ($this->current_page < $count_pages) {
             $tpl->pages->next->assign('[NEXT_PAGE]', $this->current_page + 1);
         }
     }
     $tpl->pages->fillDropDown('records-per-page-[RESOURCE]', array('25' => '25', '50' => '50', '100' => '100', '0' => $this->getLocution('All')), $this->records_per_page == 1000000000 ? 0 : $this->records_per_page);
     // Перевод
     if (!empty($this->locutions[$this->lang])) {
         foreach ($this->locutions[$this->lang] as $locution => $translate) {
             $tpl->assign("[#{$locution}#]", $translate);
         }
     }
     $this->HTML .= $tpl->render();
 }
示例#6
0
 /**
  * Создание контейнера
  * @return string
  * @throws Exception
  */
 protected function make()
 {
     $tpl = new Mtpl($this->theme_location . '/html/tabs.html');
     $tpl->assign('[RESOURCE]', $this->resource);
     if ($this->position == self::POSITION_BOTTOM) {
         $tpl->content_top->assign('[CONTENT]', $this->content);
     } else {
         $tpl->content_bottom->assign('[CONTENT]', $this->content);
     }
     if (!empty($this->tabs)) {
         switch ($this->type) {
             case self::TYPE_TABS:
                 $type_name = 'tabs';
                 break;
             case self::TYPE_PILLS:
                 $type_name = 'pills';
                 break;
             default:
                 throw new Exception('Invalid type');
                 break;
         }
         $tpl->tabs->assign('[TYPE]', $type_name);
         switch ($this->position) {
             case self::POSITION_TOP:
                 $position_name = 'top';
                 break;
             case self::POSITION_LEFT:
                 $position_name = 'left';
                 break;
             case self::POSITION_RIGHT:
                 $position_name = 'right';
                 break;
             case self::POSITION_BOTTOM:
                 $position_name = 'bottom';
                 break;
             default:
                 throw new Exception('Invalid position');
                 break;
         }
         $tpl->tabs->assign('[POSITION]', $position_name);
         foreach ($this->tabs as $key => $tab) {
             if ($tab instanceof ComboTab) {
                 $combo_tab_class = '';
                 $combo_tab_class_toggle = 'dropdown-toggle';
                 if (!$tab->isDisabled()) {
                     $elements = $tab->getElements();
                     if (!empty($elements)) {
                         foreach ($elements as $element) {
                             if ($element['type'] == $tab::ELEMENT_BREAK) {
                                 $tpl->tabs->elements->combo_tab->elements2->touchBlock('break');
                             } elseif ($element['type'] == $tab::ELEMENT_ITEM) {
                                 $url = $this->url . '&' . $this->resource . '=' . $element['id'];
                                 if ($element['disabled']) {
                                     $class = 'disabled';
                                     $url = 'javascript:void(0);';
                                 } elseif ($this->active_tab == $element['id']) {
                                     $class = 'active';
                                     $combo_tab_class = 'active';
                                 } else {
                                     $class = '';
                                 }
                                 $tpl->tabs->elements->combo_tab->elements2->element->assign('[CLASS]', $class);
                                 $tpl->tabs->elements->combo_tab->elements2->element->assign('[TITLE]', $element['title']);
                                 $tpl->tabs->elements->combo_tab->elements2->element->assign('[URL]', $url);
                             }
                             $tpl->tabs->elements->combo_tab->elements2->reassign();
                         }
                     }
                 } else {
                     $combo_tab_class = 'disabled';
                     $combo_tab_class_toggle = '';
                 }
                 $tpl->tabs->elements->combo_tab->assign('[TITLE]', $tab->getTitle());
                 $tpl->tabs->elements->combo_tab->assign('[CLASS]', $combo_tab_class);
                 $tpl->tabs->elements->combo_tab->assign('[CLASS_TOGGLE]', $combo_tab_class_toggle);
             } else {
                 $url = $this->url . '&' . $this->resource . '=' . $tab['id'];
                 if ($tab['disabled']) {
                     $class = 'disabled';
                     $url = 'javascript:void(0);';
                 } elseif ($this->active_tab == $tab['id']) {
                     $class = 'active';
                 } else {
                     $class = '';
                 }
                 $tpl->tabs->elements->tab->assign('[CLASS]', $class);
                 $tpl->tabs->elements->tab->assign('[TITLE]', $tab['title']);
                 $tpl->tabs->elements->tab->assign('[URL]', $url);
             }
             $tpl->tabs->elements->reassign();
         }
     }
     return $tpl->render();
 }
示例#7
0
 /**
  * @return string
  */
 protected function makeWrapper()
 {
     $tpl = new Mtpl($this->theme_location . '/html/form/wrappers/control.html');
     if (!empty($this->attributes['id'])) {
         $label_for = ' for="' . $this->attributes['id'] . '"';
     } else {
         $label_for = '';
     }
     $name = !empty($this->attributes['name']) ? $this->attributes['name'] : '';
     $tpl->assign('[RESOURCE]', $this->resource);
     $tpl->assign('[NAME]', $name);
     $tpl->assign('[LABEL_FOR]', $label_for);
     $tpl->assign('[LABEL]', $this->label);
     if ($this->required) {
         $tpl->touchBlock('req');
     }
     if (!empty($this->out)) {
         $tpl->out->assign('[OUT]', $this->out);
     }
     return $tpl->render();
 }
示例#8
0
 /**
  * @return string
  */
 protected function makeControl()
 {
     $tpl = new Mtpl($this->theme_location . '/html/form/controls/upload.html');
     if (!empty($this->files)) {
         foreach ($this->files as $file) {
             if (!empty($file['download_url'])) {
                 $tpl->file->link->assign('[DOWNLOAD_URL]', $file['download_url']);
                 $tpl->file->link->assign('[NAME]', $file['name']);
                 if (!empty($file['size'])) {
                     $tpl->file->link->size->assign('[SIZE_HUMAN]', $this->formatSizeHuman($file['size']));
                 }
             } else {
                 $tpl->file->text->assign('[NAME]', $file['name']);
                 if (!empty($file['size'])) {
                     $tpl->file->text->size->assign('[SIZE_HUMAN]', $this->formatSizeHuman($file['size']));
                 }
             }
             if ($file['preview_url']) {
                 $tpl->file->img->assign('[PREVIEW_URL]', $file['preview_url']);
                 $tpl->file->img->assign('[ALT]', $file['name']);
             }
             $file_type = !empty($file['type']) && strpos($file['type'], 'image') !== false ? 'image' : 'doc';
             $tpl->file->assign('[ID]', $file['id']);
             $tpl->file->assign('[KEY]', uniqid());
             $tpl->file->assign('[TYPE]', $file_type);
             $tpl->file->reassign();
         }
     }
     if (!isset($this->attributes['id'])) {
         $this->attributes['id'] = "control-" . uniqid();
     }
     if ($this->required) {
         $this->attributes['required'] = 'required';
         if ($this->required_message) {
             $this->attributes['data-required-message'] = $this->required_message;
         }
     }
     $attributes = array();
     if (!empty($this->attributes)) {
         foreach ($this->attributes as $attr_name => $value) {
             $attributes[] = "{$attr_name}=\"{$value}\"";
         }
     }
     $is_multiple = $this->file_limit == 0 || $this->file_limit > 1;
     if ($this->size_limit == 0) {
         $this->size_limit = $this->getMaxFileSize();
     }
     if ($is_multiple) {
         $tpl->touchBlock('control_buttons');
     }
     $tpl->assign('[ATTRIBUTES]', implode(' ', $attributes));
     $tpl->assign('[THEME_SRC]', $this->theme_src);
     $tpl->assign('[ID]', $this->attributes['id']);
     $tpl->assign('[NAME]', $this->attributes['name']);
     $tpl->assign('[LANG]', $this->lang);
     $tpl->assign('[ACCEPT]', $this->accept);
     $tpl->assign('[SIZE_LIMIT]', $this->size_limit);
     $tpl->assign('[FILE_LIMIT]', $this->file_limit);
     $tpl->assign('[AUTOSTART]', $this->autostart ? 'true' : 'false');
     $tpl->assign('[MULTIPLE]', $is_multiple ? 'multiple' : '');
     // Перевод
     if (!empty($this->locutions[$this->lang])) {
         foreach ($this->locutions[$this->lang] as $locution => $translate) {
             $tpl->assign("[#{$locution}#]", $translate);
         }
     }
     return $tpl->render();
 }
示例#9
0
 /**
  * Создание контейнера
  * @return string
  */
 protected function make()
 {
     $tpl = new Mtpl($this->theme_location . '/html/panel.html');
     $tpl->assign('[ID]', $this->resource);
     $tpl->assign('[CONTENT]', $this->content);
     if (!empty($this->title)) {
         $tpl->title->assign('[TITLE]', $this->title);
     }
     if (!empty($this->tabs)) {
         foreach ($this->tabs as $tab) {
             if ($tab instanceof ComboTab) {
                 $elements = $tab->getElements();
                 if (!empty($elements)) {
                     $combo_tab_class = '';
                     foreach ($elements as $element) {
                         if ($element['type'] == $tab::ELEMENT_BREAK) {
                             $tpl->tabs->elements->combo_tab->elements2->touchBlock('break');
                         } else {
                             $url = $this->url . '&' . $this->resource . '=' . $element['id'];
                             if ($element['disabled']) {
                                 $class = 'disabled';
                                 $url = 'javascript:void(0);';
                             } elseif ($this->active_tab == $element['id']) {
                                 $class = 'active';
                                 $combo_tab_class = 'active';
                             } else {
                                 $class = '';
                             }
                             $tpl->tabs->elements->combo_tab->elements2->element->assign('[CLASS]', $class);
                             $tpl->tabs->elements->combo_tab->elements2->element->assign('[TITLE]', $element['title']);
                             $tpl->tabs->elements->combo_tab->elements2->element->assign('[URL]', $url);
                         }
                         $tpl->tabs->elements->combo_tab->elements2->reassign();
                     }
                     $tpl->tabs->elements->combo_tab->assign('[TITLE]', $tab->getTitle());
                     $tpl->tabs->elements->combo_tab->assign('[CLASS]', $combo_tab_class);
                 }
             } else {
                 $url = $this->url . '&' . $this->resource . '=' . $tab['id'];
                 if ($tab['disabled']) {
                     $class = 'disabled';
                     $url = 'javascript:void(0);';
                 } elseif ($this->active_tab == $tab['id']) {
                     $class = 'active';
                 } else {
                     $class = '';
                 }
                 $tpl->tabs->elements->tab->assign('[CLASS]', $class);
                 $tpl->tabs->elements->tab->assign('[TITLE]', $tab['title']);
                 $tpl->tabs->elements->tab->assign('[URL]', $url);
             }
             $tpl->tabs->elements->reassign();
         }
     }
     return $tpl->render();
 }