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


PHP FileHandler::moveFile方法代码示例

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


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

示例1: testFileMethods

 public function testFileMethods()
 {
     $mock = dirname(__FILE__) . '/mock.txt';
     $mock2 = dirname(__FILE__) . '/mock2.txt';
     touch($mock);
     // copy file
     $this->assertTrue(is_readable($mock));
     FileHandler::copyFile($mock, $mock2);
     $this->assertTrue(is_readable($mock2));
     // remove file
     $this->assertTrue(FileHandler::removeFile($mock2));
     $this->assertFalse(is_readable($mock2));
     $this->assertFalse(FileHandler::removeFile($mock2));
     // rename file
     $this->assertTrue(FileHandler::rename($mock, $mock2));
     $this->assertFalse(is_readable($mock));
     $this->assertTrue(is_readable($mock2));
     $this->assertFalse(FileHandler::rename($mock, $mock2));
     // move file
     $this->assertTrue(FileHandler::rename($mock2, $mock));
     $this->assertTrue(is_readable($mock));
     $this->assertFalse(is_readable($mock2));
     $this->assertTrue(touch($mock2) && is_readable($mock2));
     $this->assertTrue(FileHandler::moveFile($mock, $mock2));
     $this->assertFalse(is_readable($mock));
     $this->assertTrue(is_readable($mock2));
     // remove file
     $this->assertFalse(FileHandler::removeFile($mock));
     $this->assertTrue(FileHandler::removeFile($mock2));
     $this->assertFalse(is_readable($mock));
     $this->assertFalse(is_readable($mock2));
 }
开发者ID:relip,项目名称:xe-core,代码行数:32,代码来源:FileHandlerTest.php

示例2: loadLangSelected

 /**
  * Find selected languages to serve in the site
  *
  * @return array Selected languages
  */
 public static function loadLangSelected()
 {
     static $lang_selected = null;
     if (!$lang_selected) {
         $selected_lang_file = _XE_PATH_ . 'files/config/lang_selected.info';
         if (!FileHandler::hasContent($selected_lang_file)) {
             $old_selected_lang_file = _XE_PATH_ . 'files/cache/lang_selected.info';
             FileHandler::moveFile($old_selected_lang_file, $selected_lang_file);
         }
         if (!FileHandler::hasContent($selected_lang_file)) {
             $lang_selected = Rhymix\Framework\Lang::getSupportedList();
             $buff = '';
             foreach ($lang_selected as $key => $val) {
                 $buff .= "{$key},{$val}\n";
             }
             FileHandler::writeFile($selected_lang_file, $buff);
         } else {
             $langs = file($selected_lang_file);
             foreach ($langs as $val) {
                 list($lang_prefix, $lang_text) = explode(',', $val);
                 if ($lang_prefix === 'jp') {
                     $lang_prefix = 'ja';
                 }
                 $lang_text = trim($lang_text);
                 $lang_selected[$lang_prefix] = $lang_text;
             }
         }
     }
     return $lang_selected;
 }
开发者ID:1Sam,项目名称:rhymix,代码行数:35,代码来源:Context.class.php

示例3: procLayoutAdminUpdate

 /**
  * Update layout information
  * Apply a title of the new layout and extra vars
  * @return Object
  */
 function procLayoutAdminUpdate()
 {
     // Consider the rest of items as extra vars, except module, act, layout_srl, layout, and title  .. Some gurida ..
     $extra_vars = Context::getRequestVars();
     unset($extra_vars->module);
     unset($extra_vars->act);
     unset($extra_vars->layout_srl);
     unset($extra_vars->layout);
     unset($extra_vars->title);
     unset($extra_vars->apply_layout);
     unset($extra_vars->apply_mobile_view);
     $is_sitemap = $extra_vars->is_sitemap;
     unset($extra_vars->is_sitemap);
     $args = Context::gets('layout_srl', 'title');
     // Get layout information
     $oLayoutModel = getModel('layout');
     $oMenuAdminModel = getAdminModel('menu');
     $layout_info = $oLayoutModel->getLayout($args->layout_srl);
     if ($layout_info->menu) {
         $menus = get_object_vars($layout_info->menu);
     }
     if (count($menus)) {
         foreach ($menus as $menu_id => $val) {
             $menu_srl = Context::get($menu_id);
             if (!$menu_srl) {
                 continue;
             }
             // if menu is -1, get default menu in site
             if ($menu_srl == -1) {
                 $oModuleModel = getModel('module');
                 $start_module = $oModuleModel->getSiteInfo(0, $columnList);
                 $tmpArgs->url = $start_module->mid;
                 $tmpArgs->site_srl = 0;
                 $output = executeQuery('menu.getMenuItemByUrl', $tmpArgs);
                 if (!$output->toBool()) {
                     return new Object(-1, 'fail_to_update');
                 }
                 $menu_srl = $output->data->menu_srl;
             }
             $output = $oMenuAdminModel->getMenu($menu_srl);
             $menu_srl_list[] = $menu_srl;
             $menu_name_list[$menu_srl] = $output->title;
             $apply_layout = Context::get('apply_layout');
             $apply_mobile_view = Context::get('apply_mobile_view');
             if ($apply_layout == 'Y' || $apply_mobile_view == 'Y') {
                 $menu_args = new stdClass();
                 $menu_args->menu_srl = $menu_srl;
                 $menu_args->site_srl = $layout_info->site_srl;
                 $output = executeQueryArray('layout.getLayoutModules', $menu_args);
                 if ($output->data) {
                     $modules = array();
                     for ($i = 0; $i < count($output->data); $i++) {
                         $modules[] = $output->data[$i]->module_srl;
                     }
                     if (count($modules)) {
                         $update_args = new stdClass();
                         $update_args->module_srls = implode(',', $modules);
                         if ($apply_layout == "Y") {
                             $update_args->layout_srl = $args->layout_srl;
                         }
                         if ($layout_info->layout_type == "M") {
                             if (Context::get('apply_mobile_view') == "Y") {
                                 $update_args->use_mobile = "Y";
                             }
                             $output = executeQuery('layout.updateModuleMLayout', $update_args);
                         } else {
                             $output = executeQuery('layout.updateModuleLayout', $update_args);
                         }
                         $oCacheHandler = CacheHandler::getInstance('object', null, true);
                         if ($oCacheHandler->isSupport()) {
                             $oCacheHandler->invalidateGroupKey('site_and_module');
                         }
                     }
                 }
             }
         }
     }
     $tmpDir = sprintf('./files/attach/images/%s/tmp', $args->layout_srl);
     // Separately handle if a type of extra_vars is an image
     if ($layout_info->extra_var) {
         foreach ($layout_info->extra_var as $name => $vars) {
             if ($vars->type != 'image') {
                 continue;
             }
             $fileName = $extra_vars->{$name};
             if ($vars->value == $fileName) {
                 continue;
             }
             FileHandler::removeFile($vars->value);
             if (!$fileName) {
                 continue;
             }
             $pathInfo = pathinfo($fileName);
             $tmpFileName = sprintf('%s/tmp/%s', $pathInfo['dirname'], $pathInfo['basename']);
             if (!FileHandler::moveFile($tmpFileName, $fileName)) {
//.........这里部分代码省略.........
开发者ID:ddmshu,项目名称:xe-core,代码行数:101,代码来源:layout.admin.controller.php

示例4: loadLangSelected

 /**
  * Find selected languages to serve in the site
  *
  * @return array Selected languages
  */
 function loadLangSelected()
 {
     static $lang_selected = null;
     if (!$lang_selected) {
         $orig_lang_file = _XE_PATH_ . 'common/lang/lang.info';
         $selected_lang_file = _XE_PATH_ . 'files/config/lang_selected.info';
         if (!FileHandler::hasContent($selected_lang_file)) {
             $old_selected_lang_file = _XE_PATH_ . 'files/cache/lang_selected.info';
             FileHandler::moveFile($old_selected_lang_file, $selected_lang_file);
         }
         if (!FileHandler::hasContent($selected_lang_file)) {
             $buff = FileHandler::readFile($orig_lang_file);
             FileHandler::writeFile($selected_lang_file, $buff);
             $lang_selected = self::loadLangSupported();
         } else {
             $langs = file($selected_lang_file);
             foreach ($langs as $val) {
                 list($lang_prefix, $lang_text) = explode(',', $val);
                 $lang_text = trim($lang_text);
                 $lang_selected[$lang_prefix] = $lang_text;
             }
         }
     }
     return $lang_selected;
 }
开发者ID:nontoxice,项目名称:xe-core,代码行数:30,代码来源:Context.class.php

示例5: updateIcon

 private function updateIcon($iconname, $deleteIcon = false)
 {
     $image_filepath = _XE_PATH_ . 'files/attach/xeicon/';
     if ($deleteIcon) {
         FileHandler::removeFile($image_filepath . $iconname);
         return;
     }
     $tmpicon_filepath = $image_filepath . 'tmp/' . $iconname;
     $icon_filepath = $image_filepath . $iconname;
     if (file_exists($tmpicon_filepath)) {
         FileHandler::moveFile($tmpicon_filepath, $icon_filepath);
     }
     FileHandler::removeFile($tmpicon_filepath);
 }
开发者ID:umjinsun12,项目名称:dngshin,代码行数:14,代码来源:install.admin.controller.php

示例6: _saveFavicon

 private function _saveFavicon($iconname, $deleteIcon = false)
 {
     $site_info = Context::get('site_module_info');
     $virtual_site = '';
     if ($site_info->site_srl) {
         $virtual_site = $site_info->site_srl . '/';
     }
     $image_filepath = RX_BASEDIR . 'files/attach/xeicon/' . $virtual_site;
     if ($deleteIcon) {
         FileHandler::removeFile($image_filepath . $iconname);
         return;
     }
     $tmpicon_filepath = $image_filepath . 'tmp/' . $iconname;
     $icon_filepath = $image_filepath . $iconname;
     if (file_exists($tmpicon_filepath)) {
         FileHandler::moveFile($tmpicon_filepath, $icon_filepath);
     }
     FileHandler::removeFile($tmpicon_filepath);
 }
开发者ID:kkkyyy03,项目名称:coffeemix,代码行数:19,代码来源:admin.admin.controller.php

示例7: procPurplebookFilePicker

 /**
  * image file handling
  */
 function procPurplebookFilePicker()
 {
     $oPurplebookModel =& getModel('purplebook');
     //$this->setTemplatePath($this->module_path.'tpl');
     if (!$this->module_info->skin) {
         $this->module_info->skin = 'default';
     }
     $this->setTemplatePath($this->module_path . "skins/{$this->module_info->skin}");
     $this->setLayoutFile('default_layout');
     $this->setTemplateFile('filepicker');
     $logged_info = Context::get('logged_info');
     if (!$logged_info) {
         Context::set('message', Context::getLang('msg_login_required'));
         return;
     }
     $vars = Context::gets('addfile', 'filter');
     $source_file = $vars->addfile['tmp_name'];
     if (!is_uploaded_file($source_file)) {
         Context::set('message', Context::getLang('msg_invalid_request'));
         return;
     }
     // check file format, size
     $ext = strtolower(substr(strrchr($vars->addfile['name'], '.'), 1));
     if ($vars->filter) {
         $filter = explode(',', $vars->filter);
     } else {
         $filter = array('jpg', 'jpeg', 'gif', 'png');
     }
     if (!in_array($ext, $filter)) {
         Context::set('message', Context::getLang('msg_invalid_file_format'));
         return;
     }
     // 파일 정보 구함
     list($width, $height, $type, $attrs) = @getimagesize($source_file);
     switch ($type) {
         case '1':
             $type = 'gif';
             break;
         case '2':
             $type = 'jpg';
             break;
         case '3':
             $type = 'png';
             break;
         case '6':
             $type = 'bmp';
             break;
         default:
             return;
             break;
     }
     $file_srl = getNextSequence();
     $path = $oPurplebookModel->getFilePickerPath($file_srl);
     $save_filename = sprintf('%s%s.%s', $path, $file_srl, $type);
     // create directory
     if (!is_dir($path)) {
         FileHandler::makeDir($path);
     }
     if (!FileHandler::moveFile($source_file, $save_filename)) {
         Context::set('message', Context::getLang('msg_error_occured'));
         return;
     }
     $output = $this->insertFile($save_filename, $file_srl);
     if (!$output->toBool()) {
         Context::set('message', $output->getMessage());
         return;
     }
     Context::set('filename', $save_filename);
     Context::set('purplebook_file_srl', $file_srl);
     $this->setLayoutFile('default_layout');
     $this->setTemplateFile('filepicker_selected');
 }
开发者ID:seoeun,项目名称:xe-module-purplebook,代码行数:75,代码来源:purplebook.controller.php


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