public function getType($id = null) { $id = $this->isAjax() ? intval($_POST['id']) : $id; $entity = $this->typeModel->getType($id); if (!$entity) { $entity = new Entity_Type(); } $toReplace = array('{action}', '{option}', '{delete}', '{id_value}', '{title_value}', '{name_value}', '{seo_value}', '{fields}', '{fields-count}'); $fields = json_decode($entity->getJson(), true); $fieldsHTML = $this->typeModel->genFields($fields); $option = $this->typeModel->getAllTypesOption('id', $id); $replace = array(empty($id) ? 'add' : 'update', $option, empty($id) ? '' : '<i class="fa fa-times del delete-type"></i>', $entity->getId(), $entity->getTitle(), $entity->getName(), $entity->getSeo() == 1 ? 'checked="checked"' : '', $fieldsHTML, count($fields)); $file = file_get_contents(ADMIN . '/views/type.tpl'); $result = str_replace($toReplace, $replace, $file); if ($this->isAjax()) { $this->putAjax($result); } return $result; }
public function getAddLeafForm() { $tpl = $this->getTPL('tree/add_leaf'); $toReplace = array('{pid}', '{id}', '{title}', '{name}', '{option}'); $option = '<option value="">Выбрать</option>'; $typeModel = new Admin_Models_Type(); $option .= $typeModel->getAllTypesOption(); $replace = array(intval($_POST['pid']), 'select-type-leaf', 'Выберите тип элемента', '', $option); $result = str_replace($toReplace, $replace, $tpl); $this->putAjax($result); }