protected function uninstall($plugin, $output) { $root = $this->kirby()->roots()->plugins() . DS . $plugin; dir::remove($root); $output->writeln('<comment>The "' . $plugin . '" plugin has been removed!</comment>'); $output->writeln(''); }
public function testSize() { dir::make($this->tmpDir); f::write($this->tmpDir . DS . 'testfile-1.txt', str::random(5)); f::write($this->tmpDir . DS . 'testfile-2.txt', str::random(5)); f::write($this->tmpDir . DS . 'testfile-3.txt', str::random(5)); $this->assertEquals(15, dir::size($this->tmpDir)); $this->assertEquals('15 b', dir::niceSize($this->tmpDir)); dir::remove($this->tmpDir); }
protected function execute(InputInterface $input, OutputInterface $output) { if ($this->isInstalled() === false) { throw new RuntimeException('Invalid Kirby installation'); } $helper = $this->getHelper('question'); $question = new ConfirmationQuestion('<info>Do you really want to uninstall the Panel? (y/n)</info>' . PHP_EOL . 'leave blank to cancel: ', false); if ($helper->ask($input, $output, $question)) { // load kirby $this->bootstrap(); // remove the panel folder dir::remove($this->dir() . DS . 'panel'); $output->writeln('<comment>The panel has been uninstalled!</comment>'); $output->writeln(''); } }
protected function execute(InputInterface $input, OutputInterface $output) { if ($this->isInstalled() === false) { throw new RuntimeException('Invalid Kirby installation'); } $helper = $this->getHelper('question'); $question = new ConfirmationQuestion('<info>Do you really want to uninstall Kirby? (y/n)</info>' . PHP_EOL . 'leave blank to cancel: ', false); if ($helper->ask($input, $output, $question)) { // load kirby $this->bootstrap(); f::remove($this->dir() . DS . 'index.php'); f::remove($this->dir() . DS . '.htaccess'); f::remove($this->dir() . DS . '.gitignore'); f::remove($this->dir() . DS . 'license.md'); f::remove($this->dir() . DS . 'readme.md'); dir::remove($this->dir() . DS . 'kirby'); dir::remove($this->dir() . DS . 'panel'); dir::remove($this->dir() . DS . 'thumbs'); $output->writeln('<comment>Kirby has been uninstalled!</comment>'); $output->writeln(''); } }
/** * Deletes the page * * @param boolean $force Forces the page to be deleted even if there are subpages */ public function delete($force = false) { if (!$this->isDeletable()) { throw new Exception('The page cannot be deleted'); } if ($force === false and $this->children()->count()) { throw new Exception('This page has subpages'); } $parent = $this->parent(); if (!dir::remove($this->root())) { throw new Exception('The page could not be deleted'); } $this->kirby->cache()->flush(); $parent->reset(); return true; }
function resizeOnDemandDeleteDir($pageId) { $path = str_replace('/', DS, $pageId); $root = kirby()->roots()->index() . DS . 'thumbs' . DS . $path; // delete directory with resized images if (f::exists($root)) { dir::remove($root, false); } }
protected function tearDown() { dir::remove($this->root); }
/** * Clean the thumbs folder for the page * */ public function removeThumbs() { return dir::remove($this->kirby()->roots()->thumbs() . DS . $this->id()); }
static function deleteDir() { $delete = self::childByUID(get('uid')); if (!$delete) { return array('status' => 'error', 'msg' => l::get('pages.errors.notfound')); } if ($delete->isHomePage()) { return array('status' => 'error', 'msg' => l::get('pages.delete.errors.homepage')); } if ($delete->isErrorPage()) { return array('status' => 'error', 'msg' => l::get('pages.delete.errors.errorpage')); } if ($delete->hasChildren()) { return array('status' => 'error', 'msg' => l::get('pages.delete.errors.subpages')); } if (!dir::remove($delete->root())) { return array('status' => 'error', 'msg' => l::get('pages.delete.errors.permissions')); } self::killCache(); return array('status' => 'success', 'msg' => l::get('pages.delete.success')); }
public function delete() { // get this before the item is killed $dayroot = $this->root('day'); if (!dir::remove($this->root())) { throw new Exception('The item directory could not be removed'); } if (!$this->library->database->query('delete from items where id = :id', array('id' => $this->id))) { throw new Exception('The delete query failed'); } // make sure to clean up the directory attic $this->library->clean($dayroot); }
/** * Overload delete to include assets * when the object is deleted. */ public function delete($id = NULL) { if ($id === NULL and $this->loaded) { # delete testimonial survey questions ORM::factory('question')->where(array('owner_id' => $id))->delete_all(); echo 'survey questions deleted<br/>'; # delete testimonial tags/categories ORM::factory('tag')->where(array('owner_id' => $id))->delete_all(); echo 'testimonial tags deleted<br/>'; # delete tconfigs ORM::factory('tconfig')->where(array('owner_id' => $id))->delete_all(); echo 'tconfig settings deleted<br/>'; # delete all testimonials ORM::factory('testimonial')->where(array('owner_id' => $id))->delete_all(); echo 'testimonials deleted<br/>'; # delete owner data folder. $folder = t_paths::data($this->apikey); if (dir::remove($folder)) { echo "data directory {$folder} deleted<br/>"; } } return parent::delete($id); }
/** * Move the source to the final destination */ protected function move() { $exists = $this->pluginExists(); $error = $exists ? 'The plugin could not be updated' : 'The plugin could not be installed'; $success = $exists ? 'The plugin has been updated to version:' : 'The plugin has been installed at version:'; if ($exists) { $this->output->writeln('<info>Updating plugin...</info>'); } else { $this->output->writeln('<info>Installing plugin...</info>'); } $this->output->writeln('<info></info>'); $this->prepare(); $src = $this->source(); $dest = $this->destination(); // overwriting means having to clean the plugin first if (is_dir($dest)) { if (!dir::remove($dest)) { throw new RuntimeException('The old plugin could not be removed before the update'); } } if (is_file($src)) { if (!f::move($src, $dest)) { throw new RuntimeException($error); } } else { if (is_dir($src)) { if (!dir::move($src, $dest)) { throw new RuntimeException($error); } } else { throw new RuntimeException('Invalid source'); } } $this->output->writeln('<comment>' . $success . ' "' . $this->version() . '"</comment>'); }
public function clean($root) { if (!is_dir($root)) { throw new Exception('The given directory does not exist'); } if (!str::startsWith($root, $this->root)) { throw new Exception('Invalid directory. Must be within the library'); } while ($root != $this->root) { $files = dir::read($root); if (count($files) === 0) { dir::remove($root); } else { break; } $root = dirname($root); } }
protected function delete($name, $output) { dir::remove($this->root() . DS . $name); $output->writeln('<comment>The "' . $name . '" plugin has been deleted!</comment>'); $output->writeln(''); }