/** * Delete a folder or file */ public function action_delete() { Kohana::$log->add(Kohana::DEBUG, 'Executing Controller_Admin_Asset::action_delete'); $dir = $this->request->param('path'); $obj = new Model_Resource_File($dir); if (isset($_POST['no'])) { Request::instance()->redirect(Route::get('admin/resource')->uri(array('path' => $obj->parent))); } $this->template->content = View::factory('cms/files/delete')->bind('resource', $resource)->bind('legend', $legend); if (is_dir($obj->path)) { $resource = new Model_Resource_Folder($dir); $legend = __('Delete :name folder?', array(':name' => $dir)); if (isset($_POST['yes'])) { try { $resource->delete(); Message::instance()->info('The folder, :name, has been deleted.', array(':name' => $resource)); if (!$this->_internal) { $this->request->redirect($this->request->uri(array('action' => 'read', 'path' => $resource->parent))); } } catch (Resource_Exception $e) { Message::instance()->error('The folder, :name, could not be deleted.', array(':name' => $resource)); if (!$this->_internal) { $this->request->redirect($this->request->uri(array('action' => 'read', 'path' => $resource->parent))); } } } } else { $resource = new Model_Resource_File($dir); $legend = __('Delete :name file?', array(':name' => $dir)); if (isset($_POST['yes'])) { try { $resource->delete(); Message::instance()->info('The file, :name, has been deleted.', array(':name' => $resource)); if (!$this->_internal) { $this->request->redirect($this->request->uri(array('action' => 'read', 'path' => $resource->parent))); } } catch (Resource_Exception $e) { Message::instance()->error('The file, :name, could not be deleted.', array(':name' => $resource)); if (!$this->_internal) { $this->request->redirect($this->request->uri(array('action' => 'read', 'path' => $resource->parent))); } } } } }