当前位置: 首页>>代码示例>>PHP>>正文


PHP Folder::move方法代码示例

本文整理汇总了PHP中Folder::move方法的典型用法代码示例。如果您正苦于以下问题:PHP Folder::move方法的具体用法?PHP Folder::move怎么用?PHP Folder::move使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Folder的用法示例。


在下文中一共展示了Folder::move方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: rename

 /**
  * Rename $oldPath to $newPath
  *
  * @param string $oldPath Old filename/directory
  * @param string $newPath New filename/directory
  * @return bool True if rename was successful
  */
 public function rename($oldPath, $newPath)
 {
     if (is_dir($oldPath)) {
         $Folder = new Folder($oldPath);
         return $Folder->move(array('from' => $oldPath, 'to' => $newPath));
     } else {
         return rename($oldPath, $newPath);
     }
 }
开发者ID:saydulk,项目名称:croogo,代码行数:16,代码来源:FileManager.php

示例2: testSaveOnRename

 /**
  * 保存
  */
 public function testSaveOnRename()
 {
     $path = WWW_ROOT . 'theme' . DS;
     $data = array('Theme' => array('old_name' => 'nada-icons', 'name' => 'new-nada-icons'));
     $this->Theme->save($data);
     $this->assertFileExists($path . 'new-nada-icons', 'ファイル名を変更できません');
     $Folder = new Folder($path . 'new-nada-icons');
     $Folder->move(['to' => $path . 'nada-icons']);
 }
开发者ID:baserproject,项目名称:basercms,代码行数:12,代码来源:ThemeTest.php

示例3: rollback

function rollback($movers)
{
    foreach ($movers as $m) {
        $path = ROOT . DS . $m;
        $to = $path . '.off';
        if (is_dir($to)) {
            if (is_dir($path)) {
                $fr = new Folder($path);
                $fr->delete();
            }
            $f = new Folder($to);
            $f->move($path);
        } else {
            if (file_exists($to)) {
                if (file_exists($path)) {
                    unlink($path);
                }
                rename($to, $path);
            }
        }
    }
}
开发者ID:phototech,项目名称:sailvenice,代码行数:22,代码来源:updater.php

示例4: locations

 /**
  * Move files and folders to their new homes
  *
  * Moves folders containing files which cannot necessarily be autodetected (libs and templates)
  * and then looks for all php files except vendors, and moves them to where Cake 2.0 expects
  * to find them.
  *
  * @return void
  */
 public function locations()
 {
     $cwd = getcwd();
     if (is_dir('plugins')) {
         $Folder = new Folder('plugins');
         list($plugins) = $Folder->read();
         foreach ($plugins as $plugin) {
             chdir($cwd . DS . 'plugins' . DS . $plugin);
             $this->locations();
         }
         $this->_files = array();
         chdir($cwd);
     }
     $moves = array('libs' => 'Lib', 'vendors' . DS . 'shells' . DS . 'templates' => 'Console' . DS . 'Templates');
     foreach ($moves as $old => $new) {
         if (is_dir($old)) {
             $this->out("Moving {$old} to {$new}");
             if (!$this->params['dry-run']) {
                 $Folder = new Folder($old);
                 $Folder->move($new);
             }
             if ($this->params['git']) {
                 exec('git mv -f ' . escapeshellarg($old) . ' ' . escapeshellarg($new));
             }
         }
     }
     $sourceDirs = array('.' => array('recursive' => false), 'Console', 'Controller', 'controllers', 'Lib' => array('checkFolder' => false), 'Model', 'models', 'tests', 'View', 'views', 'vendors/shells');
     $defaultOptions = array('recursive' => true, 'checkFolder' => true);
     foreach ($sourceDirs as $dir => $options) {
         if (is_numeric($dir)) {
             $dir = $options;
             $options = array();
         }
         $options = array_merge($defaultOptions, $options);
         $this->_movePhpFiles($dir, $options);
     }
 }
开发者ID:Nervie,项目名称:Beta,代码行数:46,代码来源:UpgradeShell.php

示例5: update

 function update($plugin, $url = null)
 {
     App::import('Folder');
     $this->formattedOut(String::insert(__d('plugin', "Atualizando [fg=green]:plugin[/fg]...", true), array('plugin' => $plugin)), false);
     if (empty($url)) {
         $url = $this->_url($plugin);
     }
     if (empty($url)) {
         $this->formattedOut(__d('plugin', "[fg=black][bg=red] ERRO [/bg][/fg]", true));
         $this->formattedOut(__d('plugin', "  -> O plugin nao existe ou nao possui uma url para atualizacao.", true));
         $this->_stop();
     }
     $this->out("\n", false);
     $pluginFolder = new Folder();
     $pluginFolder->move(array('from' => $this->params['working'] . DS . 'plugins/' . $plugin, 'to' => $this->params['working'] . DS . 'plugins/' . $plugin . '-old'));
     $status = $this->Installer->install($url, $plugin);
     if ($status) {
         $pluginFolder->delete($this->params['working'] . DS . 'plugins/' . $plugin . '-old');
     } else {
         $this->formattedOut(__d('plugin', "[fg=black][bg=red] ERRO [/bg][/fg]", true));
         $this->formattedOut(__d('plugin', "  -> Nao foi possivel atualizar o plugin.", true));
         $pluginFolder->move(array('from' => $this->params['working'] . DS . 'plugins/' . $plugin . '-old', 'to' => $this->params['working'] . DS . 'plugins/' . $plugin));
     }
 }
开发者ID:rodrigorm,项目名称:plugin_manager,代码行数:24,代码来源:plugins.php

示例6: update

 function update()
 {
     if (!PRODUCTION) {
         // Don't want to ever run this in development
         die('good');
     }
     App::import('Vendor', 'bradleyboy/updater');
     $old_mask = umask(0);
     // Move these to off position in case we need to rollback
     $movers = array('app', 'm', 'cron.php', 'images.php', 'index.php', 'p.php', 'popup.php');
     foreach ($movers as $m) {
         $path = ROOT . DS . $m;
         $to = $path . '.off';
         if (is_dir($path)) {
             $f = new Folder($path);
             $f->move($to);
             if (is_dir($path)) {
                 umask($old_mask);
                 rollback($movers);
                 die('permfail');
             }
         } else {
             if (file_exists($path)) {
                 rename($path, $to);
                 if (file_exists($path)) {
                     umask($old_mask);
                     rollback($movers);
                     die('permfail');
                 }
             }
         }
     }
     $version = trim($this->Pigeon->version(true));
     if ((strpos($version, 'b') !== false || strpos($version, 'a') !== false) && BETA_TEST) {
         $core = 'http://www.sspdirector.com/zips/upgrade_beta.zip';
     } else {
         $core = 'http://www.sspdirector.com/zips/upgrade.zip';
     }
     $zip_helper = 'http://www.sspdirector.com/zips/pclzip.lib.txt';
     $local_core = ROOT . DS . 'core.zip';
     $local_helper = ROOT . DS . 'pclzip.lib.php';
     if (download_file($core, $local_core) && download_file($zip_helper, $local_helper)) {
         require $local_helper;
         $archive = new PclZip('core.zip');
         $archive->extract(PCLZIP_CB_POST_EXTRACT, 'extract_callback');
     } else {
         umask($old_mask);
         rollback($movers);
         die('permfail');
     }
     foreach ($movers as $m) {
         $path = ROOT . DS . $m;
         $to = $path . '.off';
         if (is_dir($to)) {
             $f = new Folder($path);
             $f->delete($to);
         } else {
             if (file_exists($to)) {
                 unlink($to);
             }
         }
     }
     unlink($local_core);
     unlink($local_helper);
     umask($old_mask);
     die('good');
 }
开发者ID:phototech,项目名称:sailvenice,代码行数:67,代码来源:install_controller.php

示例7: _move

 /**
  * Move file with 2 step process to avoid collisions on case insensitive systems
  *
  * @return void
  */
 protected function _move($from, $to, $folder = true)
 {
     $tmp = '_tmp';
     if ($this->params['git']) {
         exec('git mv -f ' . escapeshellarg($from) . ' ' . escapeshellarg($from . $tmp));
         exec('git mv -f ' . escapeshellarg($from . $tmp) . ' ' . escapeshellarg($to));
     } elseif ($this->params['tgit']) {
         exec('tgit mv -f ' . escapeshellarg($from) . ' ' . escapeshellarg($from . $tmp));
         exec('tgit mv -f ' . escapeshellarg($from . $tmp) . ' ' . escapeshellarg($to));
     } elseif ($this->params['svn']) {
         exec('"' . $this->params['svn'] . '" move --force ' . escapeshellarg($from) . ' ' . escapeshellarg($from . $tmp));
         exec('"' . $this->params['svn'] . '" move --force ' . escapeshellarg($from . $tmp) . ' ' . escapeshellarg($to));
     } elseif ($folder) {
         $Folder = new Folder($from);
         $Folder->move($to . $tmp);
         $Folder = new Folder($to . $tmp);
         $Folder->move($to);
     } else {
         rename($from, $to);
     }
 }
开发者ID:edukondaluetg,项目名称:cakephp-upgrade,代码行数:26,代码来源:UpgradeShell.php

示例8: testMove

 /**
  * testMove method
  *
  * Verify that directories and files are moved recursively
  * even if the destination directory already exists.
  * Subdirectories existing in both destination and source directory
  * are skipped and not merged or overwritten.
  *
  * @return void
  */
 public function testMove()
 {
     $path = TMP . 'folder_test';
     $folder1 = $path . DS . 'folder1';
     $folder2 = $folder1 . DS . 'folder2';
     $folder3 = $path . DS . 'folder3';
     $file1 = $folder1 . DS . 'file1.php';
     $file2 = $folder2 . DS . 'file2.php';
     new Folder($path, true);
     new Folder($folder1, true);
     new Folder($folder2, true);
     new Folder($folder3, true);
     touch($file1);
     touch($file2);
     $Folder = new Folder($folder1);
     $result = $Folder->move($folder3);
     $this->assertTrue($result);
     $this->assertTrue(file_exists($folder3 . DS . 'file1.php'));
     $this->assertTrue(is_dir($folder3 . DS . 'folder2'));
     $this->assertTrue(file_exists($folder3 . DS . 'folder2' . DS . 'file2.php'));
     $this->assertFalse(file_exists($file1));
     $this->assertFalse(file_exists($folder2));
     $this->assertFalse(file_exists($file2));
     $Folder = new Folder($folder3);
     $Folder->delete();
     new Folder($folder1, true);
     new Folder($folder2, true);
     touch($file1);
     touch($file2);
     $Folder = new Folder($folder1);
     $result = $Folder->move($folder3);
     $this->assertTrue($result);
     $this->assertTrue(file_exists($folder3 . DS . 'file1.php'));
     $this->assertTrue(is_dir($folder3 . DS . 'folder2'));
     $this->assertTrue(file_exists($folder3 . DS . 'folder2' . DS . 'file2.php'));
     $this->assertFalse(file_exists($file1));
     $this->assertFalse(file_exists($folder2));
     $this->assertFalse(file_exists($file2));
     $Folder = new Folder($folder3);
     $Folder->delete();
     new Folder($folder1, true);
     new Folder($folder2, true);
     new Folder($folder3, true);
     new Folder($folder3 . DS . 'folder2', true);
     touch($file1);
     touch($file2);
     file_put_contents($folder3 . DS . 'folder2' . DS . 'file2.php', 'untouched');
     $Folder = new Folder($folder1);
     $result = $Folder->move($folder3);
     $this->assertTrue($result);
     $this->assertTrue(file_exists($folder3 . DS . 'file1.php'));
     $this->assertEquals(file_get_contents($folder3 . DS . 'folder2' . DS . 'file2.php'), 'untouched');
     $this->assertFalse(file_exists($file1));
     $this->assertFalse(file_exists($folder2));
     $this->assertFalse(file_exists($file2));
     $Folder = new Folder($path);
     $Folder->delete();
 }
开发者ID:ronaldsalazar23,项目名称:ComercialChiriguano,代码行数:68,代码来源:FolderTest.php

示例9: admin_edit_folder

 /**
  * フォルダ編集
  *
  * @return void
  * @access public
  */
 public function admin_edit_folder()
 {
     $args = $this->_parseArgs(func_get_args());
     extract($args);
     if (!isset($this->_tempalteTypes[$type])) {
         $this->notFound();
     }
     if (!$this->request->data) {
         $this->request->data['ThemeFolder']['name'] = basename($path);
         $this->request->data['ThemeFolder']['parent'] = dirname($fullpath);
         $this->request->data['ThemeFolder']['pastname'] = basename($path);
     } else {
         $newPath = dirname($fullpath) . DS . $this->request->data['ThemeFolder']['name'] . DS;
         $folder = new Folder();
         $this->ThemeFolder->set($this->request->data);
         if ($this->ThemeFolder->validates()) {
             if ($fullpath != $newPath) {
                 if ($folder->move(array('from' => $fullpath, 'to' => $newPath, 'chmod' => 0777, 'skip' => array('_notes')))) {
                     $this->setMessage('フォルダ名を ' . $this->request->data['ThemeFolder']['name'] . ' に変更しました。');
                     $this->redirect(array_merge(array('action' => 'index', $theme, $type), explode('/', dirname($path))));
                 } else {
                     $this->setMessage('フォルダ名の変更に失敗しました。', true);
                 }
             } else {
                 $this->setMessage('フォルダ名に変更はありませんでした。', true);
                 $this->redirect(array_merge(array('action' => 'index', $theme, $type), explode('/', dirname($path))));
             }
         } else {
             $this->setMessage('フォルダ名の変更に失敗しました。', true);
         }
     }
     $pageTitle = $theme;
     $this->pageTitle = '[' . $pageTitle . '] フォルダ表示: ' . basename($path);
     $this->crumbs[] = array('name' => $this->_tempalteTypes[$type], 'url' => array('controller' => 'theme_files', 'action' => 'index', $theme, $type));
     $this->subMenuElements = array('theme_files');
     $this->set('currentPath', str_replace(ROOT, '', dirname($fullpath)) . '/');
     $this->set('theme', $theme);
     $this->set('plugin', $plugin);
     $this->set('type', $type);
     $this->set('path', $path);
     $this->help = 'theme_files_form_folder';
     $this->render('form_folder');
 }
开发者ID:naow9y,项目名称:basercms,代码行数:49,代码来源:ThemeFilesController.php

示例10: Email

         // der entsprechende Ordner konnte nicht angelegt werden
         $gMessage->setForwardUrl($g_root_path . '/adm_program/modules/photos/photos.php');
         $gMessage->show($gL10n->get($error['text'], $error['path'], '<a href="mailto:' . $gPreferences['email_administrator'] . '">', '</a>'));
     }
     if (strlen($error['text']) === 0) {
         // Benachrichtigungs-Email für neue Einträge
         $notification = new Email();
         $message = $gL10n->get('PHO_EMAIL_NOTIFICATION_MESSAGE', $gCurrentOrganization->getValue('org_longname'), $_POST['pho_name'], $gCurrentUser->getValue('FIRST_NAME') . ' ' . $gCurrentUser->getValue('LAST_NAME'), date($gPreferences['system_date'], time()));
         $notification->adminNotfication($gL10n->get('PHO_EMAIL_NOTIFICATION_TITLE'), $message, $gCurrentUser->getValue('FIRST_NAME') . ' ' . $gCurrentUser->getValue('LAST_NAME'), $gCurrentUser->getValue('EMAIL'));
     }
     $getPhotoId = $photo_album->getValue('pho_id');
 } elseif ($getMode === 'change' && $ordner != SERVER_PATH . '/adm_my_files/photos/' . $_POST['pho_begin'] . '_' . $getPhotoId) {
     $newFolder = SERVER_PATH . '/adm_my_files/photos/' . $_POST['pho_begin'] . '_' . $photo_album->getValue('pho_id');
     // das komplette Album in den neuen Ordner kopieren
     $albumFolder = new Folder($ordner);
     $b_return = $albumFolder->move($newFolder);
     // Verschieben war nicht erfolgreich, Schreibrechte vorhanden ?
     if ($b_return == false) {
         $gMessage->setForwardUrl($g_root_path . '/adm_program/modules/photos/photos.php');
         $gMessage->show($gL10n->get('SYS_FOLDER_WRITE_ACCESS', $newFolder, '<a href="mailto:' . $gPreferences['email_administrator'] . '">', '</a>'));
     }
 }
 //if
 /********************Aenderung der Datenbankeinträge***********************************/
 if ($getMode === 'change') {
     // geaenderte Daten in der Datenbank akutalisieren
     $photo_album->save();
 }
 unset($_SESSION['photo_album_request']);
 $gNavigation->deleteLastUrl();
 header('Location: ' . $gNavigation->getUrl());
开发者ID:sistlind,项目名称:admidio,代码行数:31,代码来源:photo_album_function.php

示例11: extractTheme

 /**
  * Extract a theme from a zip file
  *
  * @param string $path Path to extension zip file
  * @param string $theme Optional theme name
  * @return boolean
  * @throws CakeException
  */
 public function extractTheme($path = null, $theme = null)
 {
     if (!file_exists($path)) {
         throw new CakeException(__('Invalid theme file path'));
     }
     if (empty($theme)) {
         $theme = $this->getThemeName($path);
     }
     $themeHome = App::path('View');
     $themeHome = reset($themeHome) . 'Themed' . DS;
     $themePath = $themeHome . $theme . DS;
     if (is_dir($themePath)) {
         throw new CakeException(__('Theme already exists'));
     }
     $Zip = new ZipArchive();
     if ($Zip->open($path) === true) {
         new Folder($themePath, true);
         $Zip->extractTo($themePath);
         if (!empty($this->_rootPath[$path])) {
             $old = $themePath . $this->_rootPath[$path];
             $new = $themePath;
             $Folder = new Folder($old);
             $Folder->move($new);
         }
         $Zip->close();
         return true;
     } else {
         throw new CakeException(__('Failed to extract theme'));
     }
     return false;
 }
开发者ID:ryansnowden,项目名称:croogo,代码行数:39,代码来源:ExtensionsInstaller.php

示例12: Folder

<?php

if (!defined('MIGRATE')) {
    exit;
}
$oldies = $this->_query("SELECT id, path FROM {$atbl} WHERE path NOT LIKE 'album-%' AND path IS NOT NULL LIMIT 1");
if ($this->_rows($oldies) == 1) {
    $row = $this->_array($oldies);
    $old = ALBUMS . DS . $row['path'];
    $path = 'album-' . $row['id'];
    $new = ALBUMS . DS . $path;
    if (is_dir($old)) {
        $f = new Folder($old);
        $f->chmod($old, 0777);
        if ($f->move($new)) {
            $this->_query("UPDATE {$atbl} SET path = '{$path}-old-{$row['path']}' WHERE id = {$row['id']}");
        }
    } else {
        $this->_query("UPDATE {$atbl} SET path = '{$path}-old-{$row['path']}' WHERE id = {$row['id']}");
    }
    die('again');
}
开发者ID:phototech,项目名称:sailvenice,代码行数:22,代码来源:1309.php

示例13: testMoveWithSkip

 /**
  * testMoveWithSkip method
  *
  * Verify that directories and files are moved recursively
  * even if the destination directory already exists.
  * Subdirectories existing in both destination and source directory
  * are skipped and not merged or overwritten.
  *
  * @return void
  */
 public function testMoveWithSkip()
 {
     extract($this->_setupFilesystem());
     $Folder = new Folder($folderOne);
     $result = $Folder->move(array('to' => $folderTwo, 'scheme' => Folder::SKIP));
     $this->assertTrue($result);
     $this->assertTrue(file_exists($folderTwo . DS . 'file1.php'));
     $this->assertTrue(is_dir($folderTwo . DS . 'folderB'));
     $this->assertTrue(file_exists($folderTwoB . DS . 'fileB.php'));
     $this->assertFalse(file_exists($fileOne));
     $this->assertFalse(file_exists($folderOneA));
     $this->assertFalse(file_exists($fileOneA));
     $Folder = new Folder($folderTwo);
     $Folder->delete();
     new Folder($folderOne, true);
     new Folder($folderOneA, true);
     new Folder($folderTwo, true);
     touch($fileOne);
     touch($fileOneA);
     $Folder = new Folder($folderOne);
     $result = $Folder->move(array('to' => $folderTwo, 'scheme' => Folder::SKIP));
     $this->assertTrue($result);
     $this->assertTrue(file_exists($folderTwo . DS . 'file1.php'));
     $this->assertTrue(is_dir($folderTwo . DS . 'folderA'));
     $this->assertTrue(file_exists($folderTwo . DS . 'folderA' . DS . 'fileA.php'));
     $this->assertFalse(file_exists($fileOne));
     $this->assertFalse(file_exists($folderOneA));
     $this->assertFalse(file_exists($fileOneA));
     $Folder = new Folder($folderTwo);
     $Folder->delete();
     new Folder($folderOne, true);
     new Folder($folderOneA, true);
     new Folder($folderTwo, true);
     new Folder($folderTwoB, true);
     touch($fileOne);
     touch($fileOneA);
     file_put_contents($folderTwoB . DS . 'fileB.php', 'untouched');
     $Folder = new Folder($folderOne);
     $result = $Folder->move(array('to' => $folderTwo, 'scheme' => Folder::SKIP));
     $this->assertTrue($result);
     $this->assertTrue(file_exists($folderTwo . DS . 'file1.php'));
     $this->assertEquals('untouched', file_get_contents($folderTwoB . DS . 'fileB.php'));
     $this->assertFalse(file_exists($fileOne));
     $this->assertFalse(file_exists($folderOneA));
     $this->assertFalse(file_exists($fileOneA));
     $Folder = new Folder($path);
     $Folder->delete();
 }
开发者ID:yuuicchan0912,项目名称:sample2,代码行数:58,代码来源:FolderTest.php

示例14: extract

 /**
  * フォルダ編集
  *
  * @return void
  * @access public
  */
 function admin_edit_folder()
 {
     $args = $this->_parseArgs(func_get_args());
     extract($args);
     if (!isset($this->_tempalteTypes[$type])) {
         $this->notFound();
     }
     if (!$this->data) {
         $this->data['ThemeFolder']['name'] = basename($path);
         $this->data['ThemeFolder']['parent'] = dirname($fullpath);
         $this->data['ThemeFolder']['pastname'] = basename($path);
     } else {
         $newPath = dirname($fullpath) . DS . $this->data['ThemeFolder']['name'] . DS;
         $folder = new Folder();
         $this->ThemeFolder->set($this->data);
         if ($this->ThemeFolder->validates()) {
             if ($fullpath != $newPath) {
                 if ($folder->move(array('from' => $fullpath, 'to' => $newPath, 'chmod' => 0777, 'skip' => array('_notes')))) {
                     $this->Session->setFlash('フォルダ名を ' . $this->data['ThemeFolder']['name'] . ' に変更しました。');
                     $this->redirect(array('action' => 'index', $theme, $type, dirname($path)));
                 } else {
                     $this->Session->setFlash('フォルダ名の変更に失敗しました。');
                 }
             } else {
                 $this->Session->setFlash('フォルダ名に変更はありませんでした。');
                 $this->redirect(array('action' => 'index', $theme, $type, dirname($path)));
             }
         } else {
             $this->Session->setFlash('フォルダ名の変更に失敗しました。');
         }
     }
     $pageTitle = Inflector::camelize($theme);
     $this->pageTitle = '[' . $pageTitle . '] フォルダ表示: ' . basename($path);
     $this->navis[$this->_tempalteTypes[$type]] = '/admin/theme_files/index/' . $theme . '/' . $type;
     $this->subMenuElements = array('theme_files');
     $this->set('currentPath', str_replace(ROOT, '', dirname($fullpath)) . '/');
     $this->set('theme', $theme);
     $this->set('plugin', $plugin);
     $this->set('type', $type);
     $this->set('path', $path);
     $this->render('form_folder');
 }
开发者ID:nazo,项目名称:phpcondo,代码行数:48,代码来源:theme_files_controller.php

示例15: admin_add

 /**
  * プラグインをアップロードしてインストールする
  *
  * @return void
  */
 public function admin_add()
 {
     $this->pageTitle = 'プラグインアップロード';
     $this->subMenuElements = array('plugins');
     //データなし
     if (empty($this->request->data)) {
         return;
     }
     //アップロード失敗
     if (empty($this->request->data['Plugin']['file']['tmp_name'])) {
         $this->setMessage('ファイルのアップロードに失敗しました。', true);
         return;
     }
     $zippedName = $this->request->data['Plugin']['file']['name'];
     move_uploaded_file($this->request->data['Plugin']['file']['tmp_name'], TMP . $zippedName);
     $format = 'unzip -o ' . TMP . '%s' . ' -d ' . APP . 'Plugin' . DS;
     $command = sprintf($format, escapeshellarg($zippedName));
     exec($command, $return);
     //ZIPファイル展開失敗
     if (empty($return[2])) {
         $msg = 'アップロードしたZIPファイルの展開に失敗しました。';
         exec('unzip 2>&1', $errs);
         $msg .= '<br />' . implode('<br />', $errs);
         $this->setMessage($msg, true);
         $this->redirect(array('action' => 'add'));
         return;
     }
     // 解凍したプラグインフォルダがキャメルケースでない場合にキャメルケースに変換
     $plugin = preg_replace('/^\\s*?(creating|inflating):\\s*' . preg_quote(APP . 'Plugin' . DS, '/') . '/', '', $return[2]);
     $plugin = explode(DS, $plugin);
     $plugin = $plugin[0];
     $srcPluginPath = APP . 'Plugin' . DS . $plugin;
     $Folder = new Folder();
     $Folder->chmod($srcPluginPath, 0777);
     $tgtPluginPath = APP . 'Plugin' . DS . Inflector::camelize($plugin);
     if ($srcPluginPath != $tgtPluginPath) {
         $Folder->move(array('to' => $tgtPluginPath, 'from' => $srcPluginPath, 'mode' => 0777));
     }
     unlink(TMP . $zippedName);
     // プラグインをインストール
     if ($this->BcManager->installPlugin($plugin)) {
         clearAllCache();
         $this->setMessage('新規プラグイン「' . $plugin . '」を baserCMS に登録しました。', false, true);
         $this->Plugin->addFavoriteAdminLink($plugin, $this->BcAuth->user());
         $this->redirect(array('action' => 'index'));
     } else {
         $this->setMessage('プラグインに問題がある為インストールを完了できません。プラグインの開発者に確認してください。', true);
     }
 }
开发者ID:naow9y,项目名称:basercms,代码行数:54,代码来源:PluginsController.php


注:本文中的Folder::move方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。