Esempio n. 1
0
 public function rest_delete()
 {
     $layout_name = $this->param('name', NULL, TRUE);
     $layout = new Model_File_Layout($layout_name);
     if (!$layout->is_exists()) {
         throw HTTP_API_Exception::factory(API::ERROR_PAGE_NOT_FOUND, 'Layout not found!', array(':name' => $layout_name));
     }
     // find the user to delete
     if (!$layout->is_used()) {
         if ($layout->delete()) {
             $this->response($layout);
         } else {
             throw HTTP_API_Exception::factory(API::ERROR_UNKNOWN, 'Something went wrong!');
         }
     } else {
         throw HTTP_API_Exception::factory(API::ERROR_PERMISSIONS, 'Layout is used! It CAN NOT be deleted!');
     }
 }
Esempio n. 2
0
 public function action_edit()
 {
     $layout_name = $this->request->param('id');
     $layout = new Model_File_Layout($layout_name);
     if (!$layout->is_exists()) {
         if (($found_file = $layout->find_file()) !== FALSE) {
             $layout = new Model_File_Layout($found_file);
         } else {
             Messages::errors(__('Layout not found!'));
             $this->go();
         }
     }
     $this->set_title($layout_name);
     // check if trying to save
     if (Request::current()->method() == Request::POST and ACL::check('layout.edit')) {
         return $this->_edit($layout);
     }
     Assets::package('ace');
     $this->template->content = View::factory('layout/edit', array('action' => 'edit', 'layout' => $layout));
 }
Esempio n. 3
0
 /**
  * 
  * @return Model_File_Layout
  * @throws Kohana_Exception
  */
 public function get_layout_object()
 {
     if ($this->_layout_object === NULL) {
         $layout_name = $this->layout();
         $this->_layout_object = new Model_File_Layout($layout_name);
     }
     if (!$this->_layout_object->is_exists()) {
         if (($found_file = $this->_layout_object->find_file()) !== FALSE) {
             $this->_layout_object = new Model_File_Layout($found_file);
         } else {
             throw new HTTP_Exception_500('Layout file :file not found!', array(':file' => $layout_name));
         }
     }
     return $this->_layout_object;
 }