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


PHP Varien_Io_File::mv方法代码示例

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


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

示例1: moveFileFromTmp

 /**
  * Move file from tmp path to base path
  *
  * @param string $baseTmpPath
  * @param string $basePath
  * @param string $file
  * @return string
  */
 public function moveFileFromTmp($baseTmpPath, $basePath, $file)
 {
     $ioObject = new Varien_Io_File();
     $destDirectory = dirname($this->getFilePath($basePath, $file));
     try {
         $ioObject->open(array('path' => $destDirectory));
     } catch (Exception $e) {
         $ioObject->mkdir($destDirectory, 0777, true);
         $ioObject->open(array('path' => $destDirectory));
     }
     if (strrpos($file, '.tmp') == strlen($file) - 4) {
         $file = substr($file, 0, strlen($file) - 4);
     }
     $destFile = dirname($file) . $ioObject->dirsep() . Varien_File_Uploader::getNewFileName($this->getFilePath($basePath, $file));
     $result = $ioObject->mv($this->getFilePath($baseTmpPath, $file), $this->getFilePath($basePath, $file));
     return str_replace($ioObject->dirsep(), '/', $destFile);
 }
开发者ID:HelioFreitas,项目名称:magento-pt_br,代码行数:25,代码来源:File.php

示例2: moveImageFromTmp

 public function moveImageFromTmp($file)
 {
     $ioObject = new Varien_Io_File();
     $destDirectory = Mage::getBaseDir('media') . '/option_image';
     try {
         $ioObject->open(array('path' => $destDirectory));
     } catch (Exception $e) {
         $ioObject->mkdir($destDirectory, 0777, true);
         $ioObject->open(array('path' => $destDirectory));
     }
     if (strrpos($file, '.tmp') == strlen($file) - 4) {
         $file = substr($file, 0, strlen($file) - 4);
     }
     $destFile = Varien_File_Uploader::getNewFileName($file);
     $dest = $destDirectory . '/' . $destFile;
     $ioObject->mv($this->_getMadiaConfig()->getTmpMediaPath($file), $dest);
     return $destFile;
 }
开发者ID:vstorm83,项目名称:ausport,代码行数:18,代码来源:Observer.php

示例3: _moveFileFromTmp

 protected function _moveFileFromTmp($baseTmpPath, $basePath, $file)
 {
     $ioObject = new Varien_Io_File();
     $destDirectory = dirname($this->getFilePath($basePath, $file));
     try {
         $ioObject->open(array('path' => $destDirectory));
     } catch (Exception $e) {
         $ioObject->mkdir($destDirectory, 0777, true);
         $ioObject->open(array('path' => $destDirectory));
     }
     if (strrpos($file, '.tmp') == strlen($file) - 4) {
         $file = substr($file, 0, strlen($file) - 4);
     }
     // DO NOT rename file if it exists. Overwrite it. Custumer request in ticket#2012120510000418 — Magento is losing connection to files
     $destFile = $file;
     //$destFile = dirname($file) . $ioObject->dirsep()
     //          . Mage_Core_Model_File_Uploader::getNewFileName($this->getFilePath($basePath, $file));
     //die ("destFile: $destFile<br>file: $file<br>basePath: $basePath<br>dirname: ".dirname($file));
     Mage::helper('core/file_storage_database')->copyFile($this->getFilePath($baseTmpPath, $file), $this->getFilePath($basePath, $destFile));
     $result = $ioObject->mv($this->getFilePath($baseTmpPath, $file), $this->getFilePath($basePath, $destFile));
     return str_replace($ioObject->dirsep(), '/', $destFile);
 }
开发者ID:ankita-parashar,项目名称:magento,代码行数:22,代码来源:ICC_Downloadable_Helper_File.php

示例4: generateFile


//.........这里部分代码省略.........
                     $x51 = $this->x142($x51, $x7c, $x7d);
                 } else {
                     $x51 = $this->x142($x51, $x7c, $x7d);
                 }
             } elseif ($x78 != 1) {
                 if (!$this->_display) {
                     $x51 = $this->x145($x51, $x5e, $x5f, $x60);
                     $x51 = $this->x143($x51);
                 } else {
                     $x51 = $this->x144($x51, false);
                 }
             }
             $x51 = $x116(array("__LOWERTHAN__", "__HIGHERTHAN__", "__QUOTES__", "__BACKSLASH__"), array("<", ">", '"', '\\'), $x51);
             if (!empty($x51)) {
                 if ($x78 == 1) {
                     $x8c .= $x51 . "";
                 } else {
                     $x8c .= $x51 . "";
                 }
                 if ($this->_display) {
                     $x8d .= $x8c;
                     $x8c = '';
                 } else {
                     if ($xd1 % Mage::getStoreConfig("datafeedmanager/system/buffer") == 0) {
                         $x43->streamWrite($x8c);
                         unset($x8c);
                         $x8c = '';
                         if ($this->_log) {
                             Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" . $xdd . "/" . $this->_counter . " items added", null, $this->getFilename('.log'));
                         }
                     }
                 }
                 if ($this->_limit && $xd1 >= $this->_limit) {
                     break 2;
                 }
                 $xd1++;
                 $xdd++;
             }
         }
     }
     if (!$this->_display) {
         $x43->streamWrite($x8c);
         if ($x121($x120($x77)) > 1) {
             $x43->streamWrite($x77 . "\n");
         }
         if ($this->_log) {
             Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " . ($xdd - 1) . "/" . $this->_counter . " items added", null, $this->getFilename('.log'));
         }
     } else {
         $x8d .= $x8c;
         $x8d .= $x77 . "\n";
         if ($x78 > 1) {
             $x8d .= "</table>";
         }
         if ($this->_log) {
             Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " . $xdd . "/" . $this->_counter . " items added", null, $this->getFilename('.log'));
         }
     }
     unset($xbf);
     if ($this->_log) {
         Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Footer template added", null, $this->getFilename('.log'));
     }
     if ($this->_display && !$this->_debug) {
         $x78 == 1 && !Mage::app()->getRequest()->getParam("real_time_preview") ? $x10a = "<textarea id='CodeMirror' class='CodeMirror'>" . $x8d . "</textarea>" : ($x10a = $x8d);
         if (!Mage::app()->getRequest()->getParam("real_time_preview")) {
             return "\r\n    <html>\r\n   \t <head>\r     \t\t<title>" . $this->getFeedName() . "</title>                 <link rel='stylesheet' href='" . $x70 . "skin/adminhtml/default/default/CodeMirror2/lib/codemirror.css'> \n           <link rel='stylesheet' href='" . $x70 . "skin/adminhtml/default/default/CodeMirror2/theme/default.css'>\r\n         \r\n              <script type='text/javascript' src='" . $x70 . "skin/adminhtml/default/default/CodeMirror2/lib/codemirror.js'></script>\r\n               <script type='text/javascript' src='" . $x70 . "skin/adminhtml/default/default/CodeMirror2/mode/xml/xml.js'></script> \n       \r\n               \n             </head>\r                <body>\r\n                " . $x10a . " \n              <script language='javascript'> \n                  sHtml=document.getElementById('CodeMirror');\r\n              if(typeof sHtml != 'undefined'){\r\n                      var myCodeMirror = CodeMirror(function(elt) { \n                         sHtml.parentNode.replaceChild(elt, sHtml)}, {\r                         value: sHtml.value,                         mode:  'xml',\r\n                            readOnly: true\r\n \n                  })\r\n                  } \n               \n               </script>                 </body>\r\n              </html>";
         } else {
             return $x10a;
         }
     } elseif ($this->_debug) {
         echo "<br><br>------------ XML OUTPUT ----------------<br>";
         $x10a = "<pre>" . $x122($x8d) . "</pre>";
         return $x10a;
     } else {
         $x43->streamClose();
         $x43->mv($this->getFilename(), $this->getFilename(false));
         $x43->rm($this->getFilename());
         $this->setFeedUpdatedAt(Mage::getSingleton('core/date')->gmtDate('Y-m-d H:i:s'));
         $this->save();
         if ($this->_log) {
             Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Temp file closed and moved to " . $this->getFilename(false), null, $this->getFilename('.log'));
         }
         if ($x80) {
             $x111 = $x13a($x81);
             $x112 = $x13b($x111, $x82, $x83);
             $x13c($x111, true);
             if (!$x111 || !$x112) {
                 Mage::getSingleton("adminhtml/session")->addError(Mage::helper("datafeedmanager")->__("Unable to connect the ftp server, please check your credentials."));
             }
             $x113 = $x13d($x111, $x84 . $this->getFilename(false), $this->getPath() . $this->getFilename(false), FTP_BINARY);
             if (!$x113) {
                 Mage::getSingleton("adminhtml/session")->addError(Mage::helper("datafeedmanager")->__("Unable to upload the file to the FTP directory."));
             } else {
                 Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("datafeedmanager")->__("File successfully uploaded on {$x81}."));
             }
             $x13e($x111);
         }
     }
     return $this;
 }
开发者ID:rafaelferreiraxd,项目名称:modulos-magento,代码行数:101,代码来源:Configurations.php

示例5: saveUploadedFile

 /**
  * Saves uploaded by Mage_Core_Model_File_Uploader file to DB with existence tests
  *
  * param $result should be result from Mage_Core_Model_File_Uploader::save() method
  * Checks in DB, whether uploaded file exists ($result['file'])
  * If yes, renames file on FS (!!!!!)
  * Saves file with unique name into DB
  * If passed file exists returns new name, file was renamed to (in the same context)
  * Otherwise returns $result['file']
  *
  * @param array $result
  * @return string
  */
 public function saveUploadedFile($result = array())
 {
     if ($this->checkDbUsage()) {
         $path = rtrim(str_replace(array('\\', '/'), DS, $result['path']), DS);
         $file = '/' . ltrim($result['file'], '\\/');
         $uniqueResultFile = $this->getUniqueFilename($path, $file);
         if ($uniqueResultFile !== $file) {
             $ioFile = new Varien_Io_File();
             $ioFile->open(array('path' => $path));
             $ioFile->mv($path . $file, $path . $uniqueResultFile);
         }
         $this->saveFile($path . $uniqueResultFile);
         return $uniqueResultFile;
     } else {
         return $result['file'];
     }
 }
开发者ID:hirentricore,项目名称:devmagento,代码行数:30,代码来源:Database.php

示例6: _moveImageFromTmp

 /**
  * Move image from temporary directory to normal
  *
  * @param string $file
  * @return string
  */
 protected function _moveImageFromTmp($file)
 {
     $ioObject = new Varien_Io_File();
     $destDirectory = dirname($this->_getConfig()->getMediaPath($file));
     try {
         $ioObject->open(array('path' => $destDirectory));
     } catch (Exception $e) {
         $ioObject->mkdir($destDirectory, 0777, true);
         $ioObject->open(array('path' => $destDirectory));
     }
     if (strrpos($file, '.tmp') == strlen($file) - 4) {
         $file = substr($file, 0, strlen($file) - 4);
     }
     $destFile = $this->_getUniqueFileName($file, $ioObject->dirsep());
     /** @var $storageHelper Mage_Core_Helper_File_Storage_Database */
     $storageHelper = Mage::helper('core/file_storage_database');
     if ($storageHelper->checkDbUsage()) {
         $storageHelper->renameFile($this->_getConfig()->getTmpMediaShortUrl($file), $this->_getConfig()->getMediaShortUrl($destFile));
         $ioObject->rm($this->_getConfig()->getTmpMediaPath($file));
         $ioObject->rm($this->_getConfig()->getMediaPath($destFile));
     } else {
         $ioObject->mv($this->_getConfig()->getTmpMediaPath($file), $this->_getConfig()->getMediaPath($destFile));
     }
     return str_replace($ioObject->dirsep(), '/', $destFile);
 }
开发者ID:hirentricore,项目名称:devmagento,代码行数:31,代码来源:Media.php

示例7: _moveFileFromTmp

 /**
  * Move file from tmp path to base path
  *
  * @param string $baseTmpPath
  * @param string $basePath
  * @param string $file
  * @return string
  */
 protected function _moveFileFromTmp($baseTmpPath, $basePath, $file)
 {
     $ioObject = new Varien_Io_File();
     $destDirectory = dirname($this->getFilePath($basePath, $file));
     try {
         $ioObject->open(array('path' => $destDirectory));
     } catch (Exception $e) {
         $ioObject->mkdir($destDirectory, 0777, true);
         $ioObject->open(array('path' => $destDirectory));
     }
     if (strrpos($file, '.tmp') == strlen($file) - 4) {
         $file = substr($file, 0, strlen($file) - 4);
     }
     $destFile = dirname($file) . $ioObject->dirsep() . Mage_Core_Model_File_Uploader::getNewFileName($this->getFilePath($basePath, $file));
     Mage::helper('Mage_Core_Helper_File_Storage_Database')->copyFile($this->getFilePath($baseTmpPath, $file), $this->getFilePath($basePath, $destFile));
     $result = $ioObject->mv($this->getFilePath($baseTmpPath, $file), $this->getFilePath($basePath, $destFile));
     return str_replace($ioObject->dirsep(), '/', $destFile);
 }
开发者ID:natxetee,项目名称:magento2,代码行数:26,代码来源:File.php

示例8: addImage

 /**
  * Add image to media gallery and return new filename
  *
  * @param Mage_Catalog_Model_Product $product
  * @param string                     $file              file path of image in file system
  * @param string|array               $mediaAttribute    code of attribute with type 'media_image',
  *                                                      leave blank if image should be only in gallery
  * @param boolean                    $move              if true, it will move source file
  * @param boolean                    $exclude           mark image as disabled in product page view
  * @return string
  */
 public function addImage(Mage_Catalog_Model_Product $product, $file, $mediaAttribute = null, $move = false, $exclude = true)
 {
     $file = realpath($file);
     if (!$file || !file_exists($file)) {
         Mage::throwException(Mage::helper('catalog')->__('Image does not exist.'));
     }
     Mage::dispatchEvent('catalog_product_media_add_image', array('product' => $product, 'image' => $file));
     $pathinfo = pathinfo($file);
     $imgExtensions = array('jpg', 'jpeg', 'gif', 'png');
     if (!isset($pathinfo['extension']) || !in_array(strtolower($pathinfo['extension']), $imgExtensions)) {
         Mage::throwException(Mage::helper('catalog')->__('Invalid image file type.'));
     }
     $fileName = Mage_Core_Model_File_Uploader::getCorrectFileName($pathinfo['basename']);
     $dispretionPath = Mage_Core_Model_File_Uploader::getDispretionPath($fileName);
     $fileName = $dispretionPath . DS . $fileName;
     $fileName = $this->_getNotDuplicatedFilename($fileName, $dispretionPath);
     $ioAdapter = new Varien_Io_File();
     $ioAdapter->setAllowCreateFolders(true);
     $distanationDirectory = dirname($this->_getConfig()->getTmpMediaPath($fileName));
     try {
         $ioAdapter->open(array('path' => $distanationDirectory));
         /** @var $storageHelper Mage_Core_Helper_File_Storage_Database */
         $storageHelper = Mage::helper('core/file_storage_database');
         if ($move) {
             $ioAdapter->mv($file, $this->_getConfig()->getTmpMediaPath($fileName));
             //If this is used, filesystem should be configured properly
             $storageHelper->saveFile($this->_getConfig()->getTmpMediaShortUrl($fileName));
         } else {
             $ioAdapter->cp($file, $this->_getConfig()->getTmpMediaPath($fileName));
             $storageHelper->saveFile($this->_getConfig()->getTmpMediaShortUrl($fileName));
             $ioAdapter->chmod($this->_getConfig()->getTmpMediaPath($fileName), 0777);
         }
     } catch (Exception $e) {
         Mage::throwException(Mage::helper('catalog')->__('Failed to move file: %s', $e->getMessage()));
     }
     $fileName = str_replace(DS, '/', $fileName);
     $attrCode = $this->getAttribute()->getAttributeCode();
     $mediaGalleryData = $product->getData($attrCode);
     $position = 0;
     if (!is_array($mediaGalleryData)) {
         $mediaGalleryData = array('images' => array());
     }
     foreach ($mediaGalleryData['images'] as &$image) {
         if (isset($image['position']) && $image['position'] > $position) {
             $position = $image['position'];
         }
     }
     $position++;
     $mediaGalleryData['images'][] = array('file' => $fileName, 'position' => $position, 'label' => '', 'disabled' => (int) $exclude, 'defaultimg' => (int) $exclude);
     $product->setData($attrCode, $mediaGalleryData);
     if (!is_null($mediaAttribute)) {
         $this->setMediaAttribute($product, $mediaAttribute, $fileName);
     }
     return $fileName;
 }
开发者ID:Madhurabhat,项目名称:test,代码行数:66,代码来源:Media.php

示例9: _moveImageFromTmp

 /**
  * Move image from temporary directory to normal
  *
  * @param string $file
  * @return string
  */
 protected function _moveImageFromTmp($file)
 {
     $ioObject = new Varien_Io_File();
     $destDirectory = dirname($this->_getConfig()->getMediaPath($file));
     try {
         $ioObject->open(array('path' => $destDirectory));
     } catch (Exception $e) {
         $ioObject->mkdir($destDirectory, 0777, true);
         $ioObject->open(array('path' => $destDirectory));
     }
     if (strrpos($file, '.tmp') == strlen($file) - 4) {
         $file = substr($file, 0, strlen($file) - 4);
     }
     $destFile = dirname($file) . $ioObject->dirsep() . Varien_File_Uploader::getNewFileName($this->_getConfig()->getMediaPath($file));
     $ioObject->mv($this->_getConfig()->getTmpMediaPath($file), $this->_getConfig()->getMediaPath($destFile));
     return str_replace($ioObject->dirsep(), '/', $destFile);
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:23,代码来源:Media.php

示例10: generateXml


//.........这里部分代码省略.........
                                         $x136 = true;
                                     } else {
                                         $x136 = false;
                                     }
                                     break;
                             }
                         }
                     }
                 } else {
                     $x136 = true;
                 }
                 if ($x136 == true && !$x156($x135['label'], $x134)) {
                     $x134[] = $x135['label'];
                     if ($x135['required'] && empty($xd9->{$x135}['tag'])) {
                         $this->x16c($x135['label'], 'required', $xd9->{"g_id"});
                     } elseif ($x135['recommended'] && empty($xd9->{$x135}['tag'])) {
                         $this->x16c($x135['label'], 'recommended', $xd9->{"g_id"}, null);
                     } elseif ((int) $x135['occurrence'] < count($xd9->{$x135}['tag'])) {
                         $this->x16c($x135['label'], 'toomany', $xd9->{"id"});
                     } else {
                         if (isset($x135['length']) && strlen($xd9->{$x135}['tag']) > $x135['length']) {
                             $this->x16c($x135['label'], 'toolong', $xd9->{"g_id"}, $x135['length']);
                         }
                         if (isset($x135['type']) && $x135['type'] == "RegExp" && !empty($xd9->{$x135}['tag']) && !$x14a("/^" . $x135['regexp'] . "\$/i", $xd9->{$x135}['tag'])) {
                             $this->x16c($x135['label'], 'invalid', $xd9->{"g_id"}, $x135['say']);
                         } elseif (isset($x135['type']) && ($x135['type'] == "GoogleProductCategory" || $x135['type'] == "Text")) {
                         } elseif (isset($x135['type']) && !empty($xd9->{$x135}['tag']) && $x135['type'] != "RegExp") {
                             switch ($x135['type']) {
                                 case "Boolean":
                                     $x13a = "/^true|false\$/i";
                                     break;
                                 case "Alphanumeric":
                                     $x13a = "/^[\\wc73\\-]+\$/";
                                     break;
                                     break;
                                 case "Url":
                                     $x13a = "/^http(s)?:\\/\\/.+\$/";
                                     break;
                                 case "Price":
                                     $x13a = '/^([0-9]+\\.[0-9]{2})\\s?[A-Z]{3}$/';
                                     break;
                             }
                             if (!$x14a($x13a, $xd9->{$x135}['tag'], $x13b)) {
                                 $this->x16c($x135['label'], 'invalid', $xd9->{"g_id"}, $x135['type']);
                             } elseif ($x135['type'] == "Price" && (double) $x13b[1] < 0.01) {
                                 $this->x16c($x135['label'], 'invalid', $xd9->{"g_id"}, $x135['type']);
                             }
                         }
                     }
                 }
             }
             if ($this->_display) {
                 $x74 .= $x73;
                 $x73 = '';
             } else {
                 if ($xc3 % Mage::getStoreConfig("simplegoogleshopping/system/buffer") == 0) {
                     $x3a->streamWrite($x73);
                     unset($x73);
                     $x73 = '';
                     Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>" . $xd4 . "/" . $this->_counter . " items added", null, $this->x165('.log'));
                     $x13c = time(true);
                     $x13d = (int) $x13c - (int) $xd5;
                     $this->_time += $x13d;
                     $this->x16a($x4f, $x53, "PROCESSING; {$xd4}; " . $this->_counter . ";" . $x13d);
                     $xd5 = time(true);
                 }
             }
             if ($this->_limit && $xd4 > $this->_limit) {
                 break 2;
             }
         }
     }
     $x73 .= '</channel>' . "\n";
     $x73 .= '</rss>';
     if (!$this->_display) {
         $x3a->streamWrite($x73);
         $this->x16a($x4f, $x53, "SUCCEED;ˆ0;ˆ0; 0");
     }
     Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> " . ($xd4 - 1) . "/" . $this->_counter . " items added", null, $this->x165('.log'));
     unset($xab);
     $x74 .= $x73;
     if ($this->_display && !$this->_debug) {
         return $x74;
     } elseif ($this->_debug) {
         echo "<br><br>------------ XML OUTPUT ----------------<br>";
         $x51 = "<pre>" . htmlentities($x74) . "</pre>";
         return $x51;
     } else {
         $x3a->streamClose();
         $x3a->mv($this->x165(), $this->x165(false));
         $x3a->rm($this->x165());
         $this->setSimplegoogleshopping_time(Mage::getSingleton('core/date')->gmtDate('Y-m-d H:i:s'));
         $this->_errorReport['stats'] = array($xd4 - 1, $this->_time);
         $this->setSimplegoogleshopping_report(serialize($this->_errorReport));
         $this->save();
         Mage::log("\n>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> Temp file closed and moved to " . $this->x165(false), null, $this->x165('.log'));
     }
     Mage::app()->setCurrentStore(0);
     return $this;
 }
开发者ID:GaynorH,项目名称:prestigedrinks,代码行数:101,代码来源:Simplegoogleshopping.php

示例11: saveUploadedFile

 /**
  * Saves uploaded by Varien_File_Uploader file to DB with existence tests
  *
  * param $result should be result from Varien_File_Uploader::save() method
  * Checks in DB, whether uploaded file exists ($result['file'])
  * If yes, renames file on FS (!!!!!)
  * Saves file with unique name into DB
  * If passed file exists returns new name, file was renamed to (in the same context)
  * Otherwise returns $result['file']
  *
  * @param array $result
  * @return string
  */
 public function saveUploadedFile($result = array())
 {
     if ($this->checkDbUsage()) {
         $path = str_replace('/', DS, $result['path']);
         if (!in_array(substr($result['file'], 0, 1), array('/', DS)) && !in_array(substr($result['path'], -1), array('/', DS))) {
             $path = $path . '/';
         }
         $uniqueResultFile = $this->getUniqueFilename($path, $result['file']);
         if ($uniqueResultFile !== $result['file']) {
             $ioObject = new Varien_Io_File();
             $ioObject->open(array('path' => $path));
             $ioObject->mv($path . $result['file'], $path . $uniqueResultFile);
         }
         $this->saveFile($path . $uniqueResultFile);
         return $uniqueResultFile;
     } else {
         return $result['file'];
     }
 }
开发者ID:votanlean,项目名称:Magento-Pruebas,代码行数:32,代码来源:Database.php

示例12: moveImageFromTemp

 /**
  *
  * Move option image from Temp directory to Media directory
  *
  * @param string $fileName
  * @param int $attributeId
  * @param int $optionId
  * @return string
  */
 public function moveImageFromTemp($fileName, $attributeId, $optionId)
 {
     $ioObject = new Varien_Io_File();
     $targetDirectory = $this->_optionImageBasePath . $attributeId . DS . $optionId;
     try {
         $ioObject->rmdir($targetDirectory, true);
         $ioObject->mkdir($targetDirectory, 0777, true);
         $ioObject->open(array('path' => $targetDirectory));
     } catch (Exception $e) {
         return false;
     }
     $fileName = trim($fileName, '.tmp');
     $targetFile = Varien_File_Uploader::getNewFileName($fileName);
     $path = $targetDirectory . DS . $targetFile;
     $ioObject->mv(Mage::getSingleton('catalog/product_media_config')->getTmpMediaPath($fileName), $path);
     return $targetFile;
 }
开发者ID:xiaoguizhidao,项目名称:devfashion,代码行数:26,代码来源:Data.php

示例13: _moveImageFromTmp

 /**
  * Move image from temporary directory to normal
  *
  * @param string $file
  * @return string
  */
 protected function _moveImageFromTmp($file)
 {
     $ioObject = new Varien_Io_File();
     $destDirectory = dirname($this->_getConfig()->getMediaPath($file));
     try {
         $ioObject->open(array('path' => $destDirectory));
     } catch (Exception $e) {
         $ioObject->mkdir($destDirectory, 0777, true);
         $ioObject->open(array('path' => $destDirectory));
     }
     $destFile = dirname($file) . $ioObject->dirsep() . Varien_File_Uploader::getNewFileName($this->_getConfig()->getMediaPath($file));
     $ioObject->mv($this->_getConfig()->getTmpMediaPath($file), $this->_getConfig()->getMediaPath($destFile));
     return $destFile;
 }
开发者ID:arslbbt,项目名称:mangentovies,代码行数:20,代码来源:Media.php

示例14: buildFeeds

 public function buildFeeds($storeId, $type, $page)
 {
     $store = Mage::app()->getStore($storeId);
     if (Mage::getStoreConfig('clerk/settings/active', $store->getId())) {
         $feedData = array();
         if ($type == 'products') {
             $feedData[$type] = $this->__getFeedProductData($store->getId(), $page);
         }
         if ($type == 'categories') {
             $feedData[$type] = $this->__getFeedCategoryData($store->getId(), $page);
         }
         if ($type == 'sales') {
             $feedData[$type] = $this->__getFeedSalesData($store->getId(), $page);
         }
         if ($type != 'done') {
             $filename_tmp = Mage::helper('clerk')->getFileName($store, $tmp = true);
             $path = Mage::getBaseDir('media') . "/clerk/feeds/";
             $file = new Varien_Io_File();
             $file->checkAndCreateFolder($path);
             $file->open(array('path' => $path));
             if (file_exists($path . $filename_tmp)) {
                 $content = $file->read($filename_tmp);
                 $json = json_decode($content, true);
                 if (isset($json[$type])) {
                     if ($type == 'products') {
                         $add = true;
                         foreach ($json[$type] as $item_added) {
                             if ($item_added['id'] == $feedData[$type][0]['id']) {
                                 $add = false;
                                 break;
                             }
                         }
                         if ($add) {
                             $json[$type] = array_merge($json[$type], $feedData[$type]);
                         }
                     } else {
                         $json[$type] = array_merge($json[$type], $feedData[$type]);
                     }
                 } else {
                     $json[$type] = $feedData[$type];
                 }
                 $json['created'] = (int) time();
                 $file->write($filename_tmp, json_encode($json, JSON_HEX_QUOT));
             } else {
                 $feedData['created'] = (int) time();
                 $file->write($filename_tmp, json_encode($feedData, JSON_HEX_QUOT));
             }
         } else {
             $filename_tmp = Mage::helper('clerk')->getFileName($store, $tmp = true);
             $filename = Mage::helper('clerk')->getFileName($store, $tmp = false);
             $path = Mage::getBaseDir('media') . "/clerk/feeds/";
             $file = new Varien_Io_File();
             $file->checkAndCreateFolder($path);
             $file->open(array('path' => $path));
             $file->mv($filename_tmp, $filename);
             Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('clerk')->__("Done building feed. Data stored in %s", $filename));
             Mage::getModel('clerk/communicator')->startImportOfFeed($storeId);
         }
     }
     return true;
 }
开发者ID:KingIsulgard,项目名称:clerk-magento,代码行数:61,代码来源:FeedAjax.php

示例15: moveImages

 /**
  * Move images (Step 3)
  *
  * @param Pimgento_Core_Model_Task $task
  *
  * @return bool
  */
 public function moveImages($task)
 {
     $resource = $this->getResource();
     $adapter = $this->getAdapter();
     /* @var $helper Pimgento_Image_Helper_Data */
     $helper = Mage::helper('pimgento_image');
     $directory = $helper->getImageDir();
     $images = $helper->getFiles($directory);
     if (count($images) === 0) {
         $task->nextStep();
         $task->nextStep();
         $task->setMessage($helper->__('No image found'));
         return false;
     }
     /** @var $storageHelper Mage_Core_Helper_File_Storage_Database */
     $storageHelper = Mage::helper('core/file_storage_database');
     $ioAdapter = new Varien_Io_File();
     $ioAdapter->setAllowCreateFolders(true);
     $destination = $helper->getBaseMediaPath();
     foreach ($images as $sku => $pictures) {
         $exists = $adapter->fetchOne($adapter->select()->from($resource->getTable('catalog/product'), array($this->_zde(1)))->where('sku = ?', $sku)->limit(1));
         if (!$exists) {
             continue;
         }
         $data = array('code' => $sku);
         $gallery = array();
         $key = 0;
         foreach ($pictures as $picture) {
             $ioAdapter->open(array('path' => dirname($destination . $picture['name'])));
             if (Mage::getStoreConfig('pimdata/image/delete')) {
                 $ioAdapter->mv($picture['directory'] . $picture['file'], $destination . $picture['name']);
             } else {
                 $ioAdapter->cp($picture['directory'] . $picture['file'], $destination . $picture['name']);
             }
             $storageHelper->saveFile($destination . $picture['name']);
             if ($key === 0) {
                 $data['image'] = $picture['name'];
                 $data['small_image'] = $picture['name'];
                 $data['thumbnail'] = $picture['name'];
             }
             $gallery[] = $picture['name'];
             $key++;
         }
         $data['gallery'] = join(',', $gallery);
         $adapter->insert($this->getTable(), $data);
     }
     return true;
 }
开发者ID:techpub,项目名称:PIMGento,代码行数:55,代码来源:Import.php


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