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


PHP Filesystem::copyDirectory方法代码示例

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


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

示例1: make

 /**
  * Make template
  *
  * @return  void
  **/
 protected function make()
 {
     if (count($this->templateFiles) > 0) {
         foreach ($this->templateFiles as $template) {
             if (is_dir($template['path'])) {
                 if (!Filesystem::copyDirectory($template['path'], $template['destination'])) {
                     $this->output->error("Error: an problem occured copying {$template['path']} to {$template['destination']}.");
                 }
                 // Get folder contents
                 $this->scanFolder($template['destination']);
             } elseif (is_file($template['path'])) {
                 if (!copy($template['path'], $template['destination'])) {
                     $this->output->error("Error: an problem occured copying {$template['path']} to {$template['destination']}.");
                 }
                 // Get template contents
                 $contents = file_get_contents($template['destination']);
                 $contents = $this->doReplacements($contents);
                 // Write file
                 $this->putContents($template['destination'], $contents);
             }
         }
     }
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:28,代码来源:Scaffolding.php

示例2: copy

 /**
  * Method to check if new template name already exists
  *
  * @return	boolean   true if name is not used, false otherwise
  * @since	2.5
  */
 public function copy()
 {
     if ($template = $this->getTemplate()) {
         $client = JApplicationHelper::getClientInfo($template->client_id);
         $fromPath = Filesystem::cleanPath($client->path . '/templates/' . $template->element . '/');
         // Delete new folder if it exists
         $toPath = $this->getState('to_path');
         if (Filesystem::exists($toPath)) {
             if (!Filesystem::deleteDirectory($toPath)) {
                 Notify::warning(Lang::txt('COM_TEMPLATES_ERROR_COULD_NOT_WRITE'));
                 return false;
             }
         }
         // Copy all files from $fromName template to $newName folder
         if (!Filesystem::copyDirectory($fromPath, $toPath) || !$this->fixTemplateName()) {
             return false;
         }
         return true;
     } else {
         Notify::warning(Lang::txt('COM_TEMPLATES_ERROR_INVALID_FROM_NAME'));
         return false;
     }
 }
开发者ID:sumudinie,项目名称:hubzero-cms,代码行数:29,代码来源:template.php

示例3: copy

 /**
  * Copy existing form and data to new form
  *
  * @return mixed
  **/
 public function copy()
 {
     $title = $this->getTitle();
     $questions = $this->getPageLayout();
     $oldId = $this->getId();
     // Save new
     $this->id = null;
     $id = $this->getId();
     $this->setTitle($title);
     $base = $this->base . $oldId;
     // Copy actual files
     if (is_dir($base)) {
         // Scan for versions
         $versions = array();
         $dirs = scandir($base);
         foreach ($dirs as $dir) {
             if (is_numeric($dir) && is_dir($base . DS . $dir) && $dir != '.' && $dir != '..') {
                 $versions[] = $dir;
             }
         }
         if (!empty($versions)) {
             $base .= DS . max($versions);
         }
         \Filesystem::copyDirectory($base, $this->base . $id);
     }
     // Copy questions
     $this->setPageLayout($questions);
     // Copy deployment (only most recent)
     try {
         $dep = PdfFormDeployment::latestFromFormId($oldId);
         $dep->setId(null);
         $dep->setFormId($id);
         $dep->genNewCrumb();
         $dep->save();
         // Return the deployment crumb
         return $dep->getCrumb();
     } catch (\Hubzero\Error\Exception\RuntimeException $e) {
         // Just return the form id
         return $id;
     }
 }
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:46,代码来源:form.php

示例4: transfer

 /**
  * Transfer files from one version to another
  *
  * @param      string  $sourceid Source version ID
  * @param      string  $destid   Destination version ID
  * @param      integer $rid      Resource ID
  * @return     boolean False if errors, True on success
  */
 public function transfer($sourceid, $destid, $rid)
 {
     Log::debug(__FUNCTION__ . '()');
     // Get resource information
     $resource = new \Components\Resources\Tables\Resource($this->database);
     $resource->load($rid);
     // Get screenshot information
     $ss = new \Components\Resources\Tables\Screenshot($this->database);
     $shots = $ss->getFiles($rid, $sourceid);
     // Build the path
     include_once PATH_CORE . DS . 'components' . DS . 'com_resources' . DS . 'helpers' . DS . 'html.php';
     $listdir = \Components\Resources\Helpers\Html::build_path($resource->created, $rid, '');
     $srcdir = $listdir . DS . $sourceid;
     $destdir = $listdir . DS . $destid;
     $src = $this->_buildUploadPath($srcdir, '');
     $dest = $this->_buildUploadPath($destdir, '');
     // Make sure the path exist
     if (!is_dir($src)) {
         if (!Filesystem::makeDirectory($src)) {
             $this->setError(Lang::txt('COM_TOOLS_UNABLE_TO_CREATE_UPLOAD_PATH'));
             return false;
         }
     }
     Log::debug(__FUNCTION__ . "() {$src}");
     // do we have files to transfer?
     $files = Filesystem::files($src, '.', false, true, array());
     Log::debug(__FUNCTION__ . "() " . implode(',', $files));
     if (!empty($files)) {
         // Copy directory
         Log::debug(__FUNCTION__ . "() copying {$src} to {$dest}");
         if (!Filesystem::copyDirectory($src, $dest, '', true)) {
             return false;
         } else {
             // Update screenshot information for this resource
             $ss->updateFiles($rid, $sourceid, $destid, $copy = 1);
             Log::debug(__FUNCTION__ . '() updated files');
             return true;
         }
     }
     Log::debug(__FUNCTION__ . '() done');
     return true;
 }
开发者ID:kevinwojo,项目名称:hubzero-cms,代码行数:50,代码来源:screenshots.php

示例5: _prepDir

 /**
  * Prep file directory (provisioned project)
  *
  * @param      boolean		$force
  *
  * @return     boolean
  */
 protected function _prepDir($force = true)
 {
     if (!$this->model->exists()) {
         $this->setError(Lang::txt('UNABLE_TO_CREATE_UPLOAD_PATH'));
         return;
     }
     // Get member files path
     $memberPath = $this->_getMemberPath();
     // Create and initialize local repo
     if (!$this->model->repo()->iniLocal()) {
         $this->setError(Lang::txt('UNABLE_TO_CREATE_UPLOAD_PATH'));
         return;
     }
     // Copy files from member directory
     if (!Filesystem::copyDirectory($memberPath, $this->model->repo()->get('path'))) {
         $this->setError(Lang::txt('COM_PROJECTS_FAILED_TO_COPY_FILES'));
         return false;
     }
     // Read copied files
     $get = Filesystem::files($this->model->repo()->get('path'));
     $num = count($get);
     $checkedin = 0;
     // Check-in copied files
     if ($get) {
         foreach ($get as $file) {
             $file = str_replace($this->model->repo()->get('path') . DS, '', $file);
             if (is_file($this->model->repo()->get('path') . DS . $file)) {
                 // Checkin into repo
                 $this->model->repo()->call('checkin', array('file' => $this->model->repo()->getMetadata($file, 'file', array())));
                 $checkedin++;
             }
         }
     }
     if ($num == $checkedin) {
         // Clean up member files
         Filesystem::deleteDirectory($memberPath);
         return true;
     }
     return false;
 }
开发者ID:sumudinie,项目名称:hubzero-cms,代码行数:47,代码来源:publications.php

示例6: activateTask

 /**
  * Activate provisioned project
  *
  * @return     void
  */
 public function activateTask()
 {
     // Cannot proceed without project id/alias
     if (!$this->model->exists()) {
         throw new Exception(Lang::txt('COM_PROJECTS_PROJECT_NOT_FOUND'), 404);
         return;
     }
     // Must be project creator
     if (!$this->model->access('owner')) {
         throw new Exception(Lang::txt('ALERTNOTAUTH'), 403);
         return;
     }
     // Must be a provisioned project to be activated
     if (!$this->model->isProvisioned()) {
         // Redirect to project page
         App::redirect(Route::url($this->model->link()));
         return;
     }
     // Redirect to setup if activation not complete
     if ($this->model->inSetup()) {
         App::redirect(Route::url($this->model->link('setup')));
         return;
     }
     // Get publication of a provisioned project
     $pub = $this->model->getPublication();
     if (empty($pub)) {
         throw new Exception(Lang::txt('COM_PROJECTS_PROJECT_NOT_FOUND'), 404);
         return;
     }
     // Incoming
     $name = trim(Request::getVar('new-alias', '', 'post'));
     $title = trim(Request::getVar('title', '', 'post'));
     $confirm = trim(Request::getInt('confirm', 0, 'post'));
     $name = preg_replace('/ /', '', $name);
     $name = strtolower($name);
     // Check incoming data
     $verified = $this->model->check($name, $this->model->get('id'));
     if ($confirm && !$verified) {
         $error = $this->model->getError() ? $this->model->getError() : Lang::txt('COM_PROJECTS_ERROR_NAME_INVALID_OR_EMPTY');
         $this->setError($error);
     } elseif ($confirm && ($title == '' || strlen($title) < 3)) {
         $this->setError(Lang::txt('COM_PROJECTS_ERROR_TITLE_SHORT_OR_EMPTY'));
     }
     // Set the pathway
     $this->_buildPathway();
     // Set the page title
     $this->_buildTitle();
     // Display page
     if (!$confirm || $this->getError()) {
         $this->view->setLayout('provisioned');
         $this->view->model = $this->model;
         $this->view->team = $this->model->_tblOwner->getOwnerNames($this->model->get('alias'));
         // Output HTML
         $this->view->pub = isset($pub) ? $pub : '';
         $this->view->suggested = $name;
         $this->view->verified = $verified;
         $this->view->suggested = $verified ? $this->view->suggested : '';
         $this->view->title = $this->title;
         $this->view->active = $this->active;
         $this->view->task = $this->_task;
         $this->view->authorized = 1;
         $this->view->option = $this->_option;
         $this->view->msg = $this->_getNotifications('success');
         if ($this->getError()) {
             $this->view->setError($this->getError());
         }
         $this->view->display();
         return;
     }
     // Save new alias & title
     if (!$this->getError()) {
         $this->model->set('title', \Hubzero\Utility\String::truncate($title, 250));
         $this->model->set('alias', $name);
         $state = $this->_setupComplete == 3 ? 0 : 1;
         $this->model->set('state', $state);
         $this->model->set('setup_stage', 2);
         $this->model->set('provisioned', 0);
         $this->model->set('modified', Date::toSql());
         $this->model->set('modified_by', User::get('id'));
         // Save changes
         if (!$this->model->store()) {
             $this->setError($this->model->getError());
         }
     }
     // Get project parent directory
     $path = Helpers\Html::getProjectRepoPath($this->model->get('alias'));
     $newpath = Helpers\Html::getProjectRepoPath($name, 'files', true);
     // Rename project parent directory
     if ($path && is_dir($path)) {
         if (!Filesystem::copyDirectory($path, $newpath)) {
             $this->setError(Lang::txt('COM_PROJECTS_FAILED_TO_COPY_FILES'));
         } else {
             // Correct permissions to 0755
             Filesystem::setPermissions($newpath);
             // Delete original repo
//.........这里部分代码省略.........
开发者ID:mined-gatech,项目名称:hubzero-cms,代码行数:101,代码来源:projects.php


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