本文整理汇总了PHP中f::move方法的典型用法代码示例。如果您正苦于以下问题:PHP f::move方法的具体用法?PHP f::move怎么用?PHP f::move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类f
的用法示例。
在下文中一共展示了f::move方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: rename
/**
* Renames the file and also its meta info txt
*
* @param string $filename
*/
public function rename($name)
{
$filename = f::safeName($name) . '.' . $this->extension();
$root = $this->dir() . DS . $filename;
if ($root == $this->root()) {
return $filename;
}
if (file_exists($root)) {
throw new Exception('A file with that name already exists');
}
if (!f::move($this->root(), $root)) {
throw new Exception('The file could not be renamed');
}
$meta = $this->textfile();
if (file_exists($meta)) {
f::move($meta, $this->page->textfile($filename));
}
cache::flush();
return $filename;
}
示例2: move
/**
* Moves the file to a new location
*
* @param string $to
* @return boolean
*/
public function move($to)
{
if (!f::move($this->root, $to)) {
return false;
} else {
$this->root = $to;
return true;
}
}
示例3: rename
/**
* Renames the file and also its meta info txt
*
* @param string $filename
*/
public function rename($name)
{
$filename = $this->createNewFilename($name);
$root = $this->dir() . DS . $filename;
if (empty($name)) {
throw new Exception('The filename is missing');
}
if ($root == $this->root()) {
return $filename;
}
if (file_exists($root)) {
throw new Exception('A file with that name already exists');
}
if (!f::move($this->root(), $root)) {
throw new Exception('The file could not be renamed');
}
$meta = $this->textfile();
if (file_exists($meta)) {
f::move($meta, $this->page->textfile($filename));
}
// reset the page cache
$this->page->reset();
cache::flush();
return $filename;
}
示例4: rename
/**
* Renames the file and also its meta info txt
*
* @param string $filename
*/
public function rename($name)
{
$filename = f::safeName($name) . '.' . $this->extension();
$root = $this->dir() . DS . $filename;
if (empty($name)) {
throw new Exception('The filename is missing');
}
if ($root == $this->root()) {
return $filename;
}
if (file_exists($root)) {
throw new Exception('A file with that name already exists');
}
if (!f::move($this->root(), $root)) {
throw new Exception('The file could not be renamed');
}
foreach ($this->site->languages() as $lang) {
// rename all meta files
$meta = $this->textfile($lang->code());
if (file_exists($meta)) {
f::move($meta, $this->page->textfile($filename, $lang->code()));
}
}
return $filename;
}
示例5: testMove
public function testMove()
{
$this->assertTrue(f::move($this->tmpFile, TEST_ROOT_TMP . DS . 'moved.txt'));
}
示例6: changeTemplate
public function changeTemplate($newTemplate)
{
$oldTemplate = $this->intendedTemplate();
if ($newTemplate == $oldTemplate) {
return true;
}
if ($this->site()->multilang()) {
foreach ($this->site()->languages() as $lang) {
$old = $this->textfile(null, $lang->code());
$new = $this->textfile($newTemplate, $lang->code());
f::move($old, $new);
$this->reset();
$this->updateForNewTemplate($oldTemplate, $newTemplate, $lang->code());
}
} else {
$old = $this->textfile();
$new = $this->textfile($newTemplate);
f::move($old, $new);
$this->reset();
$this->updateForNewTemplate($oldTemplate, $newTemplate);
}
return true;
}
示例7: editFile
static function editFile()
{
global $page;
$filename = get('filename');
$newname = str::urlify(get('newname'));
$file = $page->files()->find($filename);
if (!$file) {
return array('status' => 'error', 'msg' => l::get('files.edit.errors.notfound'));
}
$newfilename = $newname . '.' . $file->extension();
if ($newfilename == $file->filename()) {
return array('status' => 'success', 'msg' => l::get('nochanges'));
}
$newroot = dirname($file->root()) . '/' . $newfilename;
if (file_exists($newroot)) {
return array('status' => 'error', 'msg' => l::get('files.edit.errors.exists'));
}
if (!f::move($file->root(), $newroot)) {
return array('status' => 'error', 'msg' => l::get('files.edit.errors.permissions'));
}
self::killCache();
return array('status' => 'success', 'msg' => l::get('files.edit.success'));
}
示例8: editFile
static function editFile()
{
global $panel, $page;
$filename = get('filename');
$newname = str::urlify(get('newname'));
$file = $page->files()->find($filename);
if (!$file) {
return array('status' => 'error', 'msg' => l::get('files.edit.errors.notfound'));
}
if (str::length($newname) < 1) {
return array('status' => 'error', 'msg' => l::get('files.edit.errors.filename'));
}
$newfilename = $newname . '.' . $file->extension();
if ($newfilename != $file->filename()) {
$newroot = dirname($file->root()) . '/' . $newfilename;
if (file_exists($newroot)) {
return array('status' => 'error', 'msg' => l::get('files.edit.errors.exists'));
}
if (!f::move($file->root(), $newroot)) {
return array('status' => 'error', 'msg' => l::get('files.edit.errors.permissions'));
}
// delete the old meta file
if (c::get('lang.support')) {
// make sure to remove the meta file without language extension
$invalidfile = dirname($file->root()) . '/' . $file->filename() . '.' . c::get('content.file.extension', 'txt');
f::remove($invalidfile);
// remove the translated meta file
$oldmeta = dirname($file->root()) . '/' . $file->filename() . '.' . c::get('lang.current') . '.' . c::get('content.file.extension', 'txt');
} else {
$oldmeta = dirname($file->root()) . '/' . $file->filename() . '.' . c::get('content.file.extension', 'txt');
}
f::remove($oldmeta);
}
if (c::get('lang.support')) {
// delete the untranslated file
$delete = dirname($file->root()) . '/' . $newfilename . '.' . c::get('content.file.extension', 'txt');
f::remove($delete);
// set the translated file
$destination = dirname($file->root()) . '/' . $newfilename . '.' . c::get('lang.current') . '.' . c::get('content.file.extension', 'txt');
} else {
$destination = dirname($file->root()) . '/' . $newfilename . '.' . c::get('content.file.extension', 'txt');
}
$updateInfo = self::updateFileinfo($file, $destination);
if (error($updateInfo)) {
return $updateInfo;
}
self::killCache();
return array('status' => 'success', 'msg' => l::get('files.edit.success'));
}
示例9: editFile
static function editFile()
{
global $panel, $page;
$filename = get('filename');
$newname = str::urlify(get('newname'));
$file = $page->files()->find($filename);
if (!$file) {
return array('status' => 'error', 'msg' => l::get('files.edit.errors.notfound'));
}
if (str::length($newname) < 1) {
return array('status' => 'error', 'msg' => l::get('files.edit.errors.filename'));
}
$newfilename = $newname . '.' . $file->extension();
if ($newfilename != $file->filename()) {
$newroot = dirname($file->root()) . '/' . $newfilename;
if (file_exists($newroot)) {
return array('status' => 'error', 'msg' => l::get('files.edit.errors.exists'));
}
if (!f::move($file->root(), $newroot)) {
return array('status' => 'error', 'msg' => l::get('files.edit.errors.permissions'));
}
// delete the old meta file
$oldmeta = dirname($file->root()) . '/' . $file->filename() . '.txt';
f::remove($oldmeta);
}
$destination = dirname($file->root()) . '/' . $newfilename . '.txt';
$updateInfo = self::updateFileinfo($file, $destination);
if (error($updateInfo)) {
return $updateInfo;
}
self::killCache();
return array('status' => 'success', 'msg' => l::get('files.edit.success'));
}
示例10: rename
/**
* Renames the file and also its meta info txt
*
* @param string $filename
* @param boolean $safeName
*/
public function rename($name, $safeName = true)
{
$filename = $this->createNewFilename($name, $safeName);
$root = $this->dir() . DS . $filename;
if ($root == $this->root()) {
return $filename;
}
if (file_exists($root)) {
throw new Exception('A file with that name already exists');
}
if (!f::move($this->root(), $root)) {
throw new Exception('The file could not be renamed');
}
foreach ($this->site->languages() as $lang) {
// rename all meta files
$meta = $this->textfile($lang->code());
if (file_exists($meta)) {
f::move($meta, $this->page->textfile($filename, $lang->code()));
}
}
// reset the page cache
$this->page->reset();
// reset the basics
$this->root = $root;
$this->filename = $filename;
$this->name = $name;
$this->cache = array();
cache::flush();
return $filename;
}
示例11: move
/**
* 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>');
}