static function changeNum($uid, $num) { $p = self::childByUID($uid); if (!$p) { return array('status' => 'error', 'msg' => l::get('pages.errors.notfound')); } if ($num == $p->num()) { return array('status' => 'success', 'msg' => l::get('nochanges')); } $dirname = dirname($p->root()) . '/' . $num . '-' . $p->uid(); if (!dir::move($p->root(), $dirname)) { return array('status' => 'error', 'msg' => l::get('pages.errors.move')); } return array('status' => 'success', 'msg' => l::get('pages.moved')); }
/** * Moves the directory to a new location * * @param string $to * @return boolean */ public function move($to) { if (!dir::move($this->root, $to)) { return false; } else { $this->root = true; return true; } }
/** * Make the page invisible by removing the prepended number */ public function hide() { if ($this->isInvisible()) { return true; } $root = dirname($this->root()) . DS . $this->uid(); if (!dir::move($this->root(), $root)) { throw new Exception('The directory could not be moved'); } $this->dirname = $this->uid(); $this->num = null; $this->root = $root; $this->kirby->cache()->flush(); $this->reset(); return true; }
public function testMove() { $this->assertTrue(dir::move($this->tmpDir, $this->movedDir)); }
protected function relocate() { if ($this->old['created'] == $this->data['created']) { return; } $old = clone $this; $old->created = $this->old['created']; if (!$old->exists()) { return; } if (!dir::make($this->root())) { throw new Exception('The new directory could not be created'); } if (!dir::move($old->root(), $this->root())) { throw new Exception('The directory could not be moved'); } $this->library->clean($old->root('day')); }
/** * 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>'); }