• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP Varien_Io_File类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: getPatchefiles

 public function getPatchefiles()
 {
     /* Mage::getBaseDir('etc') . DS . 'applied.patches.list'; */
     $path = BP . DS . "app" . DS . "etc" . DS;
     $filename = 'applied.patches.list';
     $filepath = $path . $filename;
     if (!file_exists($filepath)) {
         return "No Patch file found.";
     }
     if (!is_readable($filepath)) {
         return "Patch file is not readable.";
     }
     $flocal = new Varien_Io_File();
     $flocal->open(array('path' => dirname($filepath)));
     $flocal->streamOpen($filepath, 'r');
     $patch_install_version = array();
     $patch_uninstall_version = array();
     $patch_version = array();
     while (false !== ($patchFileLines = $flocal->streamReadCsv())) {
         if (strpos($patchFileLines[0], 'SUPEE') !== false) {
             $patch_name = explode('|', $patchFileLines[0]);
             $patch_install_version[] = str_replace("SUPEE-", '', $patch_name[1]);
         }
         if (strpos($patchFileLines[0], 'REVERTED') !== false) {
             $patch_name = explode('|', $patchFileLines[0]);
             $patch_uninstall_version[] = str_replace("SUPEE-", '', $patch_name[1]);
         }
     }
     $patch_install_version = array_unique($patch_install_version);
     $patch_uninstall_version = array_unique($patch_uninstall_version);
     $patch_version = array_diff($patch_install_version, $patch_uninstall_version);
     return implode(",", $patch_version);
 }
开发者ID:vijays91,项目名称:Magento-Security-Patches,代码行数:33,代码来源:Data.php


示例2: regenerate

 /**
  * regenerate theme css based on appearance settings
  */
 public function regenerate()
 {
     $websites = Mage::app()->getWebsites();
     foreach ($websites as $_website) {
         $_website_code = $_website->getCode();
         foreach ($_website->getStores() as $_store) {
             if (!Mage::app()->getStore($_store)->getIsActive()) {
                 continue;
             }
             ob_start();
             require $this->_css_template_path;
             $css = ob_get_clean();
             $filename = str_replace(array('%WEBSITE%', '%STORE%'), array($_website_code, $_store->getCode()), $this->_css_file);
             try {
                 $file = new Varien_Io_File();
                 $file->setAllowCreateFolders(true)->open(array('path' => $this->_css_path));
                 $file->streamOpen($filename, 'w+');
                 $file->streamWrite($css);
                 $file->streamClose();
             } catch (Exception $e) {
                 Mage::getSingleton('adminhtml/session')->addError(Mage::helper('athlete')->__('Css generation error: %s', $this->_css_path . $filename) . '<br/>' . $e->getMessage());
                 Mage::logException($e);
             }
         }
     }
 }
开发者ID:bigtailbear14,项目名称:rosstheme,代码行数:29,代码来源:Css.php


示例3: uninstall

 final function uninstall(Varien_Event_Observer $observer)
 {
     $module = $observer->getEvent()->getModule();
     if (0 !== strpos(get_class($this), $module)) {
         return false;
     }
     $this->run();
     $manifestPath = str_replace('_', '/', $module) . '/etc/manifest.xml';
     foreach (explode(PS, get_include_path()) as $includePath) {
         if (file_exists($includePath . DS . $manifestPath)) {
             $manifestPath = $includePath . DS . $manifestPath;
             break;
         }
     }
     if (!file_exists($manifestPath)) {
         throw new Exception('Manifest path "' . $manifestPath . '" does not exist');
     }
     $manifestXml = new SimpleXMLElement($manifestPath, null, true);
     $paths = $manifestXml->xpath('/manifest/' . $module . '/paths/path');
     $file = new Varien_Io_File();
     foreach ($paths as $path) {
         $path = BP . DS . $path;
         if (file_exists($path)) {
             if (is_dir($path)) {
                 $file->rmdir($path, true);
             } else {
                 $file->rm($path);
             }
         }
     }
     $this->_removeResources($module);
 }
开发者ID:Jonathonbyrd,项目名称:Optimized-Magento-1.9.x,代码行数:32,代码来源:Abstract.php


示例4: checkFolderPermissionsErrors

 /**
  * Check is folders exist and have writable permissions
  *
  * @return string Error message if exist
  */
 public function checkFolderPermissionsErrors()
 {
     $arrFolders = array('image_dir' => Mage::getConfig()->getOptions()->getMediaDir() . DS . Mage::helper('nwdrevslider/images')->getImageDir(), 'thumb_dir' => Mage::getConfig()->getOptions()->getMediaDir() . DS . Mage::helper('nwdrevslider/images')->getImageThumbDir(), 'admin_css_dir' => Mage::getBaseDir() . Mage::helper('nwdrevslider/css')->getAdminCssDir(), 'front_css_dir' => Mage::getBaseDir() . Mage::helper('nwdrevslider/css')->getFrontCssDir());
     $ioFile = new Varien_Io_File();
     $arrErrors = array();
     foreach ($arrFolders as $_folder) {
         try {
             if (!($ioFile->checkandcreatefolder($_folder) && $ioFile->isWriteable($_folder))) {
                 $arrErrors[] = $_folder;
             }
         } catch (Exception $e) {
             $arrErrors[] = $_folder;
             Mage::logException($e);
         }
     }
     if (!(in_array($arrFolders['admin_css_dir'], $arrErrors) || in_array($arrFolders['front_css_dir'], $arrErrors))) {
         if (!file_exists($arrFolders['admin_css_dir'] . 'statics.css')) {
             Mage::helper('nwdrevslider/css')->putStaticCss();
         }
         if (!file_exists($arrFolders['admin_css_dir'] . 'dynamic.css')) {
             Mage::helper('nwdrevslider/css')->putDynamicCss();
         }
     }
     $strError = $arrErrors ? Mage::helper('nwdrevslider')->__('Following directories not found or not writable, please change permissions to: ') . implode(' , ', $arrErrors) : '';
     return $strError;
 }
开发者ID:perseusl,项目名称:kingdavid,代码行数:31,代码来源:Masterview.php


示例5: __construct

 /**
  * Set base dir
  */
 public function __construct()
 {
     $this->_baseDir = Mage::getBaseDir('var') . DS . 'connect';
     $io = new Varien_Io_File();
     $io->setAllowCreateFolders(true)->createDestinationDir($this->_baseDir);
     $this->addTargetDir($this->_baseDir);
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:10,代码来源:Collection.php


示例6: createModule

 public function createModule($data)
 {
     $namespace = $this->_cleanString($data['namespace']);
     $module = $this->_cleanString($data['module']);
     $pool = $data['pool'];
     $version = $this->_cleanString($data['version']);
     $dependencies = array();
     if (isset($data['depends'])) {
         foreach ($data['depends'] as $dependency) {
             $dependencies[] = sprintf('%s<%s />', str_repeat(' ', 4 * 4), $dependency);
         }
     }
     $replacements = array('{{Namespace}}' => $namespace, '{{namespace}}' => strtolower($namespace), '{{Module}}' => $module, '{{module}}' => strtolower($module), '{{pool}}' => $pool, '{{version}}' => $version, '{{depends}}' => implode(PHP_EOL, $dependencies));
     $io = new Varien_Io_File();
     $tplDir = $this->getTemplateDir();
     $tmpDir = $this->getTmpModuleDir($namespace . '_' . $module);
     $io->checkAndCreateFolder($tmpDir);
     if (!$io->isWriteable($tmpDir)) {
         Mage::throwException('Module temp dir is not writeable');
     }
     @shell_exec("cp -r {$tplDir} {$tmpDir}");
     $files = $this->_getTemplateFiles($tmpDir);
     if (empty($files)) {
         Mage::throwException('Could not copy templates files to module temp dir');
     }
     $this->_replaceVars($tmpDir, $replacements);
     $dest = Mage::getBaseDir();
     if (!$io->isWriteable($dest)) {
         Mage::throwException(sprintf('Could not move module files to Magento tree. However, module structure is available in %s', $tmpDir));
     }
     @shell_exec("cp -r {$tmpDir} {$dest}");
     return true;
 }
开发者ID:piotr0beschel,项目名称:magento-module-factory,代码行数:33,代码来源:Data.php


示例7: cleanImageCache

 /**
  * Flush the media/slider/resized folder, when the catalog image cache is flushed
  *
  * @param Varien_Event_Observer $observer
  * @return Soon_Image_Model_Observer
  */
 public function cleanImageCache(Varien_Event_Observer $observer)
 {
     $directory = Mage::getBaseDir('media') . DS . 'slider' . DS . 'resized' . DS;
     $io = new Varien_Io_File();
     $io->rmdir($directory, true);
     return $this;
 }
开发者ID:christinecardoso,项目名称:AntoineK_Slider,代码行数:13,代码来源:Observer.php


示例8: save

 public function save($destination = null, $newName = null)
 {
     $fileName = !isset($destination) ? $this->_fileName : $destination;
     if (isset($destination) && isset($newName)) {
         $fileName = $destination . "/" . $fileName;
     } elseif (isset($destination) && !isset($newName)) {
         $info = pathinfo($destination);
         $fileName = $destination;
         $destination = $info['dirname'];
     } elseif (!isset($destination) && isset($newName)) {
         $fileName = $this->_fileSrcPath . "/" . $newName;
     } else {
         $fileName = $this->_fileSrcPath . $this->_fileSrcName;
     }
     $destinationDir = isset($destination) ? $destination : $this->_fileSrcPath;
     if (!is_writable($destinationDir)) {
         try {
             $io = new Varien_Io_File();
             $io->mkdir($destination);
         } catch (Exception $e) {
             throw new Exception("Unable to write file into directory '{$destinationDir}'. Access forbidden.");
         }
     }
     // keep alpha transparency
     $isAlpha = false;
     $this->_getTransparency($this->_imageHandler, $this->_fileType, $isAlpha);
     if ($isAlpha) {
         $this->_fillBackgroundColor($this->_imageHandler);
     }
     call_user_func($this->_getCallback('output'), $this->_imageHandler, $fileName);
 }
开发者ID:ronseigel,项目名称:agent-ohm,代码行数:31,代码来源:Gd2.php


示例9: getCSVFile

 public function getCSVFile()
 {
     $data = $this->dataExport;
     if ($this->isVersion13) {
         $content = '';
         foreach ($data as $val) {
             $content .= implode(',', $val) . "\r\n";
         }
         return $content;
     } else {
         $io = new Varien_Io_File();
         $path = Mage::getBaseDir('var') . DS . 'export' . DS;
         $name = md5(microtime());
         $file = $path . DS . $name . '.csv';
         $io->setAllowCreateFolders(true);
         $io->open(array('path' => $path));
         $io->streamOpen($file, 'w+');
         $io->streamLock(true);
         // $this->dataExport[0] == csvHeader
         $io->streamWriteCsv($data[0]);
         unset($data[0]);
         //$delimiter = Mage::getSingleton('core/session')->getExportSeperator();
         foreach ($data as $val) {
             $io->streamWriteCsv($val);
         }
         return array('type' => 'filename', 'value' => $file, 'rm' => false);
     }
 }
开发者ID:xiaoguizhidao,项目名称:storebaby.it,代码行数:28,代码来源:Export.php


示例10: writeSampleDataFile

 /**
  * Write Sample Data to File. Store in folder: "skin/frontend/default/ves theme name/import/"
  */
 public function writeSampleDataFile($importDir, $file_name, $content = "")
 {
     $file = new Varien_Io_File();
     //Create import_ready folder
     $error = false;
     if (!file_exists($importDir)) {
         $importReadyDirResult = $file->mkdir($importDir);
         $error = false;
         if (!$importReadyDirResult) {
             //Handle error
             $error = true;
             Mage::getSingleton('adminhtml/session')->addError(Mage::helper('ves_tempcp')->__('Can not create folder "%s".', $importDir));
         }
     } else {
         $file->open(array('path' => $importDir));
     }
     if (!$file->write($importDir . $file_name, $content)) {
         //Handle error
         $error = true;
         Mage::getSingleton('adminhtml/session')->addError(Mage::helper('ves_tempcp')->__('Can not save import sample file "%s".', $file_name));
     }
     if (!$error) {
         Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('cms')->__('Successfully, Stored sample data file "%s".', $file_name));
     }
     return !$error;
 }
开发者ID:quanghuynt93,项目名称:VesSmartshop,代码行数:29,代码来源:ExportSample.php


示例11: save

 /**
  * Write file to file system.
  *
  * @param null $destination
  * @param null $newName
  * @throws Exception
  */
 public function save($destination = null, $newName = null)
 {
     Varien_Profiler::start(__METHOD__);
     if (isset($destination) && isset($newName)) {
         $fileName = $destination . "/" . $newName;
     } elseif (isset($destination) && !isset($newName)) {
         $info = pathinfo($destination);
         $fileName = $destination;
         $destination = $info['dirname'];
     } elseif (!isset($destination) && isset($newName)) {
         $fileName = $this->_fileSrcPath . "/" . $newName;
     } else {
         $fileName = $this->_fileSrcPath . $this->_fileSrcName;
     }
     $destinationDir = isset($destination) ? $destination : $this->_fileSrcPath;
     if (!is_writable($destinationDir)) {
         try {
             $io = new Varien_Io_File();
             $io->mkdir($destination);
         } catch (Exception $e) {
             Varien_Profiler::stop(__METHOD__);
             throw new Exception("Unable to write into directory '{$destinationDir}'.");
         }
     }
     //set compression quality
     $this->getImageMagick()->setImageCompressionQuality($this->getQuality());
     //remove all underlying information
     $this->getImageMagick()->stripImage();
     //write to file system
     $this->getImageMagick()->writeImage($fileName);
     //clear data and free resources
     $this->getImageMagick()->clear();
     $this->getImageMagick()->destroy();
     Varien_Profiler::stop(__METHOD__);
 }
开发者ID:erlisdhima,项目名称:Perfect_Watermarks,代码行数:42,代码来源:Imagemagic.php


示例12: loadFile

 /**
  * @param $filename
  * @return bool|string
  */
 public function loadFile($filename)
 {
     $varienFile = new Varien_Io_File();
     $varienFile->open();
     $path = $this->getFilePath($filename);
     return $varienFile->read($path . DS . $filename);
 }
开发者ID:AleksNesh,项目名称:pandora,代码行数:11,代码来源:Pdf.php


示例13: resizeImg

 /**
  * Resize image
  *
  * @param string $fileName
  * @param int $width
  * @param int $height
  * @return string Resized image url
  */
 public function resizeImg($fileName, $width, $height = '')
 {
     if (!$height) {
         $height = $width;
     }
     $thumbDir = self::IMAGE_THUMB_DIR;
     $resizeDir = $thumbDir . "/resized_{$width}x{$height}";
     $ioFile = new Varien_Io_File();
     $ioFile->checkandcreatefolder(Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . $resizeDir);
     $imageParts = explode('/', $fileName);
     $imageFile = end($imageParts);
     $folderURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
     $imageURL = $folderURL . $fileName;
     $basePath = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . $fileName;
     $newPath = Mage::getBaseDir(Mage_Core_Model_Store::URL_TYPE_MEDIA) . DS . $resizeDir . DS . $imageFile;
     if ($width != '') {
         if (file_exists($basePath) && is_file($basePath) && !file_exists($newPath)) {
             $imageObj = new Varien_Image($basePath);
             $imageObj->constrainOnly(TRUE);
             $imageObj->keepAspectRatio(TRUE);
             $imageObj->keepFrame(FALSE);
             $imageObj->keepTransparency(TRUE);
             //$imageObj->backgroundColor(array(255,255,255));
             $imageObj->resize($width, $height);
             $imageObj->save($newPath);
         }
         $resizedURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA) . $resizeDir . '/' . $imageFile;
     } else {
         $resizedURL = $imageURL;
     }
     return $resizedURL;
 }
开发者ID:perseusl,项目名称:kingdavid,代码行数:40,代码来源:Images.php


示例14: import

 /**
  * @$forceCreation true overwrites existing entities with the new values
  */
 public function import($forceCreation = false)
 {
     if (is_null($this->_entity)) {
         throw Mage::exception('Please specify a valid entity.');
     }
     if (!file_exists($this->_importFile)) {
         throw Mage::exception('Please specify a valid csv file.');
     }
     if (is_null($this->_storeId)) {
         throw Mage::exception('Please specify a valid store.');
     }
     $io = new Varien_Io_File();
     $io->streamOpen($this->_importFile, 'r');
     $io->streamLock(true);
     $firstLine = true;
     while (false !== ($line = $io->streamReadCsv())) {
         if ($firstLine) {
             $firstLine = false;
             $this->_headerColumns = $line;
             continue;
         }
         $data = array();
         foreach ($this->_headerColumns as $key => $val) {
             $data[$val] = $line[$key];
         }
         $this->_importEntity($data, $forceCreation);
     }
 }
开发者ID:aayushKhandpur,项目名称:aayush-renting,代码行数:31,代码来源:Import.php


示例15: fileUploadAction

 /**
  * @todo better subdirectories
  *       saves a file in the dir: media/wysiwyg/markdown/....
  *
  * @return $this
  */
 public function fileUploadAction()
 {
     $return = array('err' => TRUE, 'msg' => 'An error occurred.', 'fileUrl' => '');
     $binaryData = base64_decode($this->getRequest()->getParam('binaryData', ''));
     $file = json_decode($this->getRequest()->getParam('file', '[]'), TRUE);
     if (!(isset($file['extra']['nameNoExtension']) && isset($file['extra']['extension'])) || empty($binaryData)) {
         $return['msg'] = 'Either fileName or binaryData or file is empty ...';
         return $this->_setReturn($return, TRUE);
     }
     $fileName = $file['extra']['nameNoExtension'] . '.' . $file['extra']['extension'];
     if (strpos(strtolower($fileName), 'clipboard') !== FALSE) {
         $fileName = 'clipboard_' . date('Ymd-His') . '_' . str_replace('clipboard', '', strtolower($fileName));
     }
     $fileName = preg_replace('~[^\\w\\.]+~i', '_', $fileName);
     $savePath = $this->_getStorageRoot() . $this->_getStorageSubDirectory();
     $io = new Varien_Io_File();
     if ($io->checkAndCreateFolder($savePath)) {
         $result = (int) file_put_contents($savePath . $fileName, $binaryData);
         // io->write will not work :-(
         if ($result > 10) {
             $return['err'] = FALSE;
             $return['msg'] = '';
             $return['fileUrl'] = Mage::helper('markdown')->getTemplateMediaUrl($this->_getStorageSubDirectory() . $fileName);
         }
     }
     $this->_setReturn($return, TRUE);
 }
开发者ID:ho-nl-fork,项目名称:magento1-SchumacherFM_Markdown,代码行数:33,代码来源:MarkdownController.php


示例16: getCsvFileEnhanced

 public function getCsvFileEnhanced()
 {
     $collectionData = $this->getCollection()->getData();
     $this->_isExport = true;
     $io = new Varien_Io_File();
     $path = Mage::getBaseDir('var') . DS . 'export' . DS;
     $name = md5(microtime());
     $file = $path . DS . $name . '.csv';
     while (file_exists($file)) {
         sleep(1);
         $name = md5(microtime());
         $file = $path . DS . $name . '.csv';
     }
     $io->setAllowCreateFolders(true);
     $io->open(array('path' => $path));
     $io->streamOpen($file, 'w+');
     $io->streamLock(true);
     if ($this->_columns) {
         $io->streamWriteCsv($this->_columns);
     }
     foreach ($collectionData as $item) {
         if ($this->_removeIndexes && is_array($this->_removeIndexes)) {
             foreach ($this->_removeIndexes as $index) {
                 unset($item[$index]);
             }
         }
         $io->streamWriteCsv($item);
     }
     $io->streamUnlock();
     $io->streamClose();
     return array('type' => 'filename', 'value' => $file, 'rm' => true);
 }
开发者ID:programmerrahul,项目名称:vastecom,代码行数:32,代码来源:Abstract.php


示例17: importAction

 public function importAction()
 {
     try {
         $productId = $this->getRequest()->getParam('id');
         $fileName = $this->getRequest()->getParam('Filename');
         $path = Mage::getBaseDir('var') . DS . 'import' . DS;
         $uploader = new Mage_Core_Model_File_Uploader('file');
         $uploader->setAllowedExtensions(array('csv'));
         $uploader->setAllowRenameFiles(false);
         $uploader->setFilesDispersion(false);
         $result = $uploader->save($path, $fileName);
         $io = new Varien_Io_File();
         $io->open(array('path' => $path));
         $io->streamOpen($path . $fileName, 'r');
         $io->streamLock(true);
         while ($data = $io->streamReadCsv(';', '"')) {
             if ($data[0]) {
                 $model = Mage::getModel('giftcards/pregenerated')->load($data[0], 'card_code');
                 if ($model->getId()) {
                     continue;
                 }
                 $model->setCardCode($data[0]);
                 $model->setCardStatus(1);
                 $model->setProductId($productId);
                 $model->save();
             } else {
                 continue;
             }
         }
     } catch (Exception $e) {
         $result = array('error' => $e->getMessage(), 'errorcode' => $e->getCode());
     }
     $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
 }
开发者ID:enjoy2000,项目名称:gemz,代码行数:34,代码来源:ProductController.php


示例18: uploadAndImport

 public function uploadAndImport(Varien_Object $object)
 {
     $hlr = Mage::helper("amacart");
     if (empty($_FILES['groups']['tmp_name']['import']['fields']['blacklist']['value'])) {
         return $this;
     }
     $csvFile = $_FILES['groups']['tmp_name']['import']['fields']['blacklist']['value'];
     $io = new Varien_Io_File();
     $info = pathinfo($csvFile);
     $io->open(array('path' => $info['dirname']));
     $io->streamOpen($info['basename'], 'r');
     $emails = array();
     while (($csvLine = $io->streamReadCsv()) !== FALSE) {
         foreach ($csvLine as $email) {
             if (!Zend_Validate::is($email, 'NotEmpty')) {
             } else {
                 if (!Zend_Validate::is($email, 'EmailAddress')) {
                     $this->_warnings[] = $email . " " . $hlr->__("not valid email");
                 } else {
                     $emails[] = array("email" => $email, 'created_at' => date("Y-m-d H:i:s", time()));
                 }
             }
             if (count($emails) == 100) {
                 $this->saveImportData($emails);
                 $emails = array();
             }
         }
     }
     $this->saveImportData($emails);
     foreach (array_slice($this->_warnings, 0, 10) as $warning) {
         Mage::getSingleton('adminhtml/session')->addWarning($warning);
     }
     Mage::getSingleton('core/session')->addSuccess($hlr->__("Import completed"));
 }
开发者ID:ankita-parashar,项目名称:magento,代码行数:34,代码来源:Amasty_Acart_Model_Mysql4_Blist.php


示例19: generateXml

 /**
  * Generate XML file
  *
  * @return Mage_Sitemap_Model_Sitemap
  */
 public function generateXml()
 {
     $io = new Varien_Io_File();
     $io->setAllowCreateFolders(true);
     $io->open(array('path' => $this->getPath()));
     if ($io->fileExists($this->getSitemapFilename()) && !$io->isWriteable($this->getSitemapFilename())) {
         Mage::throwException(Mage::helper('sitemap')->__('File "%s" cannot be saved. Please, make sure the directory "%s" is writeable by web server.', $this->getSitemapFilename(), $this->getPath()));
     }
     $io->streamOpen($this->getSitemapFilename());
     $io->streamWrite('<?xml version="1.0" encoding="UTF-8"?>' . "\n");
     $io->streamWrite('<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:content="http://www.google.com/schemas/sitemap-content/1.0" xmlns:image="http://www.google.com/schemas/sitemap-image/1.1">' . "\n");
     $storeId = $this->getStoreId();
     $date = Mage::getSingleton('core/date')->gmtDate('Y-m-d');
     $baseUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_LINK);
     // Hans2103 change -> set mediaUrl
     $mediaUrl = Mage::app()->getStore($storeId)->getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA);
     $mediaUrl = preg_replace('/^https/', 'http', $mediaUrl);
     /**
      * Generate categories sitemap
      */
     $changefreq = (string) Mage::getStoreConfig('sitemap/category/changefreq', $storeId);
     $priority = (string) Mage::getStoreConfig('sitemap/category/priority', $storeId);
     $collection = Mage::getResourceModel('sitemap/catalog_category')->getCollection($storeId);
     foreach ($collection as $item) {
         $xml = sprintf('<url><loc>%s</loc><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%.1f</priority></url>' . "\n", htmlspecialchars($baseUrl . $item->getUrl()), $date, $changefreq, $priority);
         $io->streamWrite($xml);
         $this->check_counter($io);
     }
     unset($collection);
     /**
      * Generate products sitemap
      */
     /**
      * override to include images in sitemap
      */
     $changefreq = (string) Mage::getStoreConfig('sitemap/product/changefreq', $storeId);
     $priority = (string) Mage::getStoreConfig('sitemap/product/priority', $storeId);
     $collection = Mage::getResourceModel('sitemap/catalog_product')->getCollection($storeId);
     foreach ($collection as $item) {
         $xml = sprintf('<url><loc>%s</loc><image:image><image:loc>%s</image:loc><image:title>%s</image:title></image:image><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%.1f</priority><PageMap xmlns="http://www.google.com/schemas/sitemap-pagemap/1.0"><DataObject type="thumbnail"><Attribute name="name" value="%s"/><Attribute name="src" value="%s"/></DataObject></PageMap></url>' . "\n", htmlspecialchars($baseUrl . $item->getUrl()), htmlspecialchars($mediaUrl . 'catalog/product' . $item->getMedia()), htmlspecialchars($item->getName()), $date, $changefreq, $priority, htmlspecialchars($item->getName()), htmlspecialchars($mediaUrl . 'catalog/product' . $item->getMedia()));
         $io->streamWrite($xml);
     }
     unset($collection);
     /**
      * Generate cms pages sitemap
      */
     $changefreq = (string) Mage::getStoreConfig('sitemap/page/changefreq', $storeId);
     $priority = (string) Mage::getStoreConfig('sitemap/page/priority', $storeId);
     $collection = Mage::getResourceModel('sitemap/cms_page')->getCollection($storeId);
     foreach ($collection as $item) {
         $xml = sprintf('<url><loc>%s</loc><lastmod>%s</lastmod><changefreq>%s</changefreq><priority>%.1f</priority></url>' . "\n", htmlspecialchars($baseUrl . $item->getUrl()), $date, $changefreq, $priority);
         $io->streamWrite($xml);
     }
     unset($collection);
     $io->streamWrite('</urlset>');
     $io->streamClose();
     $this->setSitemapTime(Mage::getSingleton('core/date')->gmtDate('Y-m-d H:i:s'));
     $this->save();
     return $this;
 }
开发者ID:evinw,项目名称:project_bloom_magento,代码行数:65,代码来源:Sitemap.php


示例20: _generateStoreCss

 protected function _generateStoreCss($storeCode)
 {
     $store = Mage::app()->getStore($storeCode);
     $store_id = $store->getId();
     $package_name = Mage::getStoreConfig('design/package/name', $store_id);
     $theme = Mage::getStoreConfig('design/theme/defaults', $store_id);
     if ($theme == '') {
         $theme = 'default';
     }
     if (!$store->getIsActive()) {
         return;
     }
     $cssFile = Mage::getBaseDir('skin') . DS . 'frontend' . DS . $package_name . DS . $theme . DS . 'themesettings' . DS . 'css' . DS . 'themesettings_' . $storeCode . '.css';
     $cssTemplate = 'ves/themesettings/themesettings_styles.phtml';
     Mage::register('ves_store', $store);
     try {
         $cssBlockHtml = Mage::app()->getLayout()->createBlock("core/template")->setData('area', 'frontend')->setTemplate($cssTemplate)->toHtml();
         if (empty($cssBlockHtml)) {
             throw new Exception(Mage::helper('themesettings')->__("The system has an issue when create css file"));
         }
         $file = new Varien_Io_File();
         $file->setAllowCreateFolders(true);
         $file->open(array('path' => Mage::getBaseDir('skin') . DS . 'frontend' . DS . $package_name . DS . $theme . DS . 'themesettings' . DS . 'css'));
         $file->streamOpen($cssFile, 'w+', 0777);
         $file->streamLock(true);
         $file->streamWrite($cssBlockHtml);
         $file->streamUnlock();
         $file->streamClose();
     } catch (Exception $e) {
         Mage::getSingleton('adminhtml/session')->addError(Mage::helper('themesettings')->__('The system has an issue when create css file') . '<br/>Message: ' . $e->getMessage());
         Mage::logException($e);
     }
     Mage::unregister('ves_store');
 }
开发者ID:TusharKDonda,项目名称:maruti,代码行数:34,代码来源:Generator.php



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP Varien_Object类代码示例发布时间:2022-05-23
下一篇:
PHP Varien_Image_Adapter类代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap