Inheritance: extends Spot\Entity
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;
 }
Example #2
0
 /**
  * @param Entity_Type $type
  * @return bool
  */
 private function deleteFromFileSystem(&$type)
 {
     $r1 = unlink(ENTITY . '/' . $type->getName() . '.php');
     $r2 = unlink(DAO . '/interface/' . $type->getName() . '.php');
     $r3 = unlink(DAO . '/types/' . $type->getName() . '.php');
     $r4 = unlink(ADMIN . '/views/types/' . $type->getName() . '.tpl');
     $r5 = unlink(ADMIN . '/models/types/' . $type->getName() . '.php');
     $r6 = unlink(ADMIN . '/controllers/types/' . $type->getName() . '.php');
     return $r1 && $r2 && $r3 && $r4 && $r5 && $r6;
 }