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


PHP FileUtils::rename方法代码示例

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


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

示例1: publish

 public function publish($id)
 {
     $properties = $this->getProperties($id);
     if ($properties === false) {
         return false;
     }
     $res = true;
     if ($properties['status'] != self::STATUS_PUBLISHED) {
         $published_folder = $this->getPagePublishedFolder($id, $properties);
         $edit_folder = $this->getPageEditFolder($id, $properties);
         if (file_exists($edit_folder)) {
             if (file_exists($published_folder)) {
                 FileUtils::deleteFolder($published_folder);
             }
             FileUtils::rename($edit_folder, $published_folder);
         }
         $new_properties = array('status' => self::STATUS_PUBLISHED, 'last-publish-date' => time());
         $res = $this->setProperties($id, $new_properties);
     }
     $parameters = array('pageId' => $id);
     $data = null;
     Plugins::call(Plugins::PUBLISH_PAGE, $parameters, $data);
     return $res;
 }
开发者ID:pixelproduction,项目名称:PixelManagerCMS,代码行数:24,代码来源:Pages.php

示例2: saveImage

 protected function saveImage($row_id, &$data, $field, $language_id)
 {
     $orig_data = $data;
     $edit_data = null;
     $image_dir = $this->getImageDir($row_id);
     $this->ensureImageDirIsAvailable($row_id);
     if (isset($data['action'])) {
         // ********************************************************************
         // Daten wurden verändert / durch "getData" des Plugins bearbeitet
         // ********************************************************************
         if ($data['action'] == 'none') {
             if (isset($data['overwriteOccured'])) {
                 if ($data['overwriteOccured'] == true) {
                     $data['action'] = 'overwrite';
                 }
             }
         }
         // Wenn Bild gelöscht oder überschrieben werden soll,
         // die alte(n) Datei(en) in die Liste der zu löschenden Dateien aufnehmen
         if ($data['action'] == 'remove' || $data['action'] == 'overwrite') {
             if (isset($data['existingImage'])) {
                 if (trim($data['existingImage']) != '') {
                     if (file_exists($image_dir . $data['existingImage'])) {
                         $this->image_files_to_delete[] = basename($data['existingImage']);
                     }
                 }
             }
             if (isset($data['existingAdditionalSizes'])) {
                 if (is_array($data['existingAdditionalSizes'])) {
                     foreach ($data['existingAdditionalSizes'] as $additional) {
                         $this->image_files_to_delete[] = basename($additional);
                     }
                 }
             }
         }
         // Wenn ein neues Bild eingesetzt werden soll,
         // die neue(n) Datei(en) in den Bilder-Ordner dieses Elements verschieben
         // und in die Liste der zu erhaltenden Dateien aufnehmen
         if ($data['action'] == 'overwrite') {
             if (isset($data['newImage'])) {
                 if (trim($data['newImage']) != '') {
                     $orig_file = APPLICATION_ROOT . $data['newImage'];
                     if (file_exists($orig_file)) {
                         $new_image_name = $this->getRandomFilename($orig_file);
                         FileUtils::rename($orig_file, $image_dir . $new_image_name);
                         $this->image_files_to_keep[] = basename($new_image_name);
                         $edit_data = array('imageRelativePath' => $new_image_name, 'additionalSizes' => null);
                         if (isset($data['originalImage'])) {
                             $edit_data['originalImage'] = $data['originalImage'];
                         }
                         if (isset($data['customSettings'])) {
                             $edit_data['customSettings'] = $data['customSettings'];
                         }
                     }
                     if (isset($data['newAdditionalSizes'])) {
                         if (is_array($data['newAdditionalSizes'])) {
                             $edit_data['additionalSizes'] = array();
                             foreach ($data['newAdditionalSizes'] as $additional_id => $additional) {
                                 $orig_file = APPLICATION_ROOT . $additional;
                                 if (file_exists($orig_file)) {
                                     $new_image_name = $this->getRandomFilename($orig_file);
                                     FileUtils::rename($orig_file, $image_dir . $new_image_name);
                                     $this->image_files_to_keep[] = basename($new_image_name);
                                     $edit_data['additionalSizes'][$additional_id] = $new_image_name;
                                 }
                             }
                         }
                     }
                 }
             }
             // Wenn keine Änderung stattfinden soll,
             // die Datei(en) in die Liste der zu erhaltenden Dateien aufnehmen
         } elseif ($data['action'] == 'none') {
             $this->image_files_to_keep[] = basename($data['existingImage']);
             if (isset($data['existingAdditionalSizes'])) {
                 if (is_array($data['existingAdditionalSizes'])) {
                     foreach ($data['existingAdditionalSizes'] as $additional_id => $additional) {
                         $this->image_files_to_keep[] = basename($additional);
                     }
                 }
             }
             $edit_data = array('imageRelativePath' => $data['existingImage'], 'additionalSizes' => $data['existingAdditionalSizes']);
             if (isset($data['originalImage'])) {
                 $edit_data['originalImage'] = $data['originalImage'];
             }
             if (isset($data['customSettings'])) {
                 $edit_data['customSettings'] = $data['customSettings'];
             }
         }
     } else {
         // ********************************************************************
         // Daten wurden unverändert durchgeschleust
         // ********************************************************************
         if (isset($data['imageRelativePath'])) {
             if (trim($data['imageRelativePath']) != '') {
                 $this->image_files_to_keep[] = basename($data['imageRelativePath']);
                 $edit_data = array('imageRelativePath' => $data['imageRelativePath'], 'additionalSizes' => null);
                 if (isset($data['additionalSizes'])) {
                     if (is_array($data['additionalSizes'])) {
                         foreach ($data['additionalSizes'] as $additional_id => $additional) {
//.........这里部分代码省略.........
开发者ID:pixelproduction,项目名称:PixelManagerCMS,代码行数:101,代码来源:DataTable.php

示例3: onSavePageDataField

 public function onSavePageDataField($parameters, &$data)
 {
     // Nur auf Bilder andwenden
     if ($parameters['fieldType'] == 'image') {
         $orig_data = $data;
         $edit_data = null;
         if (isset($data['action'])) {
             // ********************************************************************
             // Daten wurden verändert / durch "getData" des Plugins bearbeitet
             // ********************************************************************
             if ($data['action'] == 'none') {
                 if (isset($data['overwriteOccured'])) {
                     if ($data['overwriteOccured'] == true) {
                         $data['action'] = 'overwrite';
                     }
                 }
             }
             // Wenn Bild gelöscht oder überschrieben werden soll,
             // die alte(n) Datei(en) in die Liste der zu löschenden Dateien aufnehmen
             if ($data['action'] == 'remove' || $data['action'] == 'overwrite') {
                 if (isset($data['existingImage'])) {
                     if (trim($data['existingImage']) != '') {
                         if (file_exists($parameters['pageFiles'] . $data['existingImage'])) {
                             $this->files_to_delete[] = basename($data['existingImage']);
                         }
                     }
                 }
                 if (isset($data['existingAdditionalSizes'])) {
                     if (is_array($data['existingAdditionalSizes'])) {
                         foreach ($data['existingAdditionalSizes'] as $additional) {
                             $this->files_to_delete[] = basename($additional);
                         }
                     }
                 }
             }
             // Wenn ein neues Bild eingesetzt werden soll,
             // die neue(n) Datei(en) in den "Edit"-Ordner der Seite verschieben
             // und in die Liste der zu erhaltenden Dateien aufnehmen
             if ($data['action'] == 'overwrite') {
                 if (isset($data['newImage'])) {
                     if (trim($data['newImage']) != '') {
                         $orig_file = APPLICATION_ROOT . $data['newImage'];
                         if (file_exists($orig_file)) {
                             $new_image_name = $this->getRandomFilename($orig_file);
                             FileUtils::rename($orig_file, $parameters['pageFiles'] . $new_image_name);
                             $this->files_to_keep[] = basename($new_image_name);
                             $edit_data = array('imageRelativePath' => $new_image_name, 'additionalSizes' => null);
                             if (isset($data['originalImage'])) {
                                 $edit_data['originalImage'] = $data['originalImage'];
                             }
                             if (isset($data['customSettings'])) {
                                 $edit_data['customSettings'] = $data['customSettings'];
                             }
                         }
                         if (isset($data['newAdditionalSizes'])) {
                             if (is_array($data['newAdditionalSizes'])) {
                                 $edit_data['additionalSizes'] = array();
                                 foreach ($data['newAdditionalSizes'] as $additional_id => $additional) {
                                     $orig_file = APPLICATION_ROOT . $additional;
                                     if (file_exists($orig_file)) {
                                         $new_image_name = $this->getRandomFilename($orig_file);
                                         FileUtils::rename($orig_file, $parameters['pageFiles'] . $new_image_name);
                                         $this->files_to_keep[] = basename($new_image_name);
                                         $edit_data['additionalSizes'][$additional_id] = $new_image_name;
                                     }
                                 }
                             }
                         }
                     }
                 }
                 // Wenn keine Änderung stattfinden soll,
                 // die Datei(en) in die Liste der zu erhaltenden Dateien aufnehmen
             } elseif ($data['action'] == 'none') {
                 $this->files_to_keep[] = basename($data['existingImage']);
                 if (isset($data['existingAdditionalSizes'])) {
                     if (is_array($data['existingAdditionalSizes'])) {
                         foreach ($data['existingAdditionalSizes'] as $additional_id => $additional) {
                             $this->files_to_keep[] = basename($additional);
                         }
                     }
                 }
                 $edit_data = array('imageRelativePath' => $data['existingImage'], 'additionalSizes' => $data['existingAdditionalSizes']);
                 if (isset($data['originalImage'])) {
                     $edit_data['originalImage'] = $data['originalImage'];
                 }
                 if (isset($data['customSettings'])) {
                     $edit_data['customSettings'] = $data['customSettings'];
                 }
             }
         } else {
             // ********************************************************************
             // Daten wurden unverändert durchgeschleust
             // ********************************************************************
             if (isset($data['imageRelativePath'])) {
                 if (trim($data['imageRelativePath']) != '') {
                     $this->files_to_keep[] = basename($data['imageRelativePath']);
                     $edit_data = array('imageRelativePath' => $data['imageRelativePath'], 'additionalSizes' => null);
                     if (isset($data['additionalSizes'])) {
                         if (is_array($data['additionalSizes'])) {
                             foreach ($data['additionalSizes'] as $additional_id => $additional) {
//.........这里部分代码省略.........
开发者ID:pixelproduction,项目名称:PixelManagerCMS,代码行数:101,代码来源:DataEditorImageBackend.php


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