Example #1
0
 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;
 }