Example #1
0
 public function create_one($params = [])
 {
     Session::permit_admin();
     $class = Filter::controller_model(get_called_class());
     $item = $class::create(Record::allow($params, ['name', 'title']));
     Render::json($class::read(['*'], $item['id']));
 }
Example #2
0
 public static function update($model, $id, $update_lit = '')
 {
     Session::permit_admin();
     $success = parent::update(Record::allow($model, ['title', 'name', 'type']), $id, $update_lit);
     if (isset($model['content'])) {
         $success = DocContent::create(['doc_id' => $id, 'content' => $model['content']]);
     }
     if (isset($model['routes'])) {
         DocRoute::destroy_all($id);
         if ($model['routes']) {
             $routes = [];
             foreach (explode(',', $model['routes']) as $route_def) {
                 $parts = explode('=>', $route_def);
                 $route = trim($parts[0]);
                 if (strlen($route) == 0 || $route[0] != '/') {
                     $route = '/' . $route;
                 }
                 $handler = count($parts) > 1 ? trim($parts[1]) : null;
                 $routes[] = ['doc_id' => $id, 'route' => $route, 'handler' => $handler ? $handler : null];
             }
             DocRoute::create_all($routes);
         }
     }
     return $success;
 }
Example #3
0
 public function upload($params = [])
 {
     Session::permit_admin();
     foreach ($_FILES['file']['tmp_name'] as $idx => $tmp_name) {
         $name = $_FILES['file']['name'][$idx];
         move_uploaded_file($tmp_name, IMAGES . $name);
     }
     header('Location: ' . $_POST['loc']);
 }
Example #4
0
 public function create_one($params)
 {
     Session::permit_admin();
     global $_PST;
     Render::json(User::create($_PST));
 }
 public function create_one($params = [])
 {
     Session::permit_admin();
     return DocContent::create($params);
 }
Example #6
0
 public function routes($params = [])
 {
     Session::permit_admin();
     SiteStructure::set_page_title('Routes');
     Render::php(ADMIN . 'routes.php');
 }