本文整理汇总了PHP中Varien_Io_File::cd方法的典型用法代码示例。如果您正苦于以下问题:PHP Varien_Io_File::cd方法的具体用法?PHP Varien_Io_File::cd怎么用?PHP Varien_Io_File::cd使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Varien_Io_File
的用法示例。
在下文中一共展示了Varien_Io_File::cd方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toOptionArray
public function toOptionArray($exclude = true)
{
$result = array();
$result['Magento'] = array('label' => 'Magento');
$path = Mage::getModuleDir('', 'Mirasvit_SearchIndex') . DS . 'Model' . DS . 'Index';
$io = new Varien_Io_File();
$io->open();
$io->cd($path);
foreach ($io->ls(Varien_Io_File::GREP_DIRS) as $space) {
$io->cd($space['id']);
foreach ($io->ls(Varien_Io_File::GREP_DIRS) as $module) {
$io->cd($module['id']);
foreach ($io->ls(Varien_Io_File::GREP_DIRS) as $entity) {
if ($io->fileExists($entity['id'] . DS . 'Index.php', true)) {
$indexCode = $space['text'] . '_' . $module['text'] . '_' . $entity['text'];
$index = Mage::helper('searchindex/index')->getIndexModel($indexCode);
if (is_object($index)) {
if ($index->canUse()) {
if (!isset($result[$index->getBaseGroup()])) {
$result[$index->getBaseGroup()] = array('label' => $index->getBaseGroup(), 'value' => array());
}
$result[$index->getBaseGroup()]['value'][] = array('value' => $index->getCode(), 'label' => $index->getBaseTitle());
}
} else {
Mage::throwException('Wrong model for index ' . $indexCode);
}
}
}
}
}
return $result;
}
示例2: prepareFeed
/**
* Prepare the feed file and returns its path
*
* @param array $productsData
* @param int $storeId
* @return string
*/
public function prepareFeed(array $productsData, $storeId)
{
$mId = $this->getVendorConfig('merchant_id', $storeId);
if (!$mId) {
Mage::throwException(Mage::helper('productfeed')->__('Rakuten Seller ID must be set.'));
}
$filename = 'rakuten_product_' . Mage::getModel('core/date')->date('Ymd') . '.txt';
$filepath = $this->getFeedStorageDir() . $filename;
try {
$ioAdapter = new Varien_Io_File();
$ioAdapter->setAllowCreateFolders(true);
$ioAdapter->createDestinationDir($this->getFeedStorageDir());
$ioAdapter->cd($this->getFeedStorageDir());
$ioAdapter->streamOpen($filename);
$ioAdapter->streamWrite(implode(self::DELIMITER, $this->getHeaders()) . "\n");
foreach ($productsData as $productId => $row) {
array_unshift($row, $mId);
$this->prepareRow($row, $productId);
$ioAdapter->streamWrite(implode(self::DELIMITER, $row) . "\n");
// because a CSV enclosure is not supported
}
return $filepath;
} catch (Exception $e) {
Mage::throwException(Mage::helper('productfeed')->__('Could not write feed file to path: %s, %s', $filepath, $e->getMessage()));
}
}
示例3: prepareFeed
/**
* Prepare the feed file and returns its path
*
* @param array $productsData
* @param int $storeId
* @return string
*/
public function prepareFeed(array $productsData, $storeId)
{
$mId = $this->getVendorConfig('merchant_id', $storeId);
$company = $this->getVendorConfig('company', $storeId);
if (!$mId || !$company) {
Mage::throwException(Mage::helper('productfeed')->__('LinkShare Merchant ID and Company Name must be set.'));
}
Varien_Profiler::start('productfeed_' . $this->getVendorCode() . '::' . __FUNCTION__);
$content = implode(self::DELIMITER, array('HDR', $mId, $company, Mage::getModel('core/date')->date('Y-m-d/H:i:s'))) . self::EOL;
foreach ($productsData as $row) {
$content .= $row . self::EOL;
}
$filename = $mId . '_nmerchandis' . Mage::getModel('core/date')->date('Ymd') . '.txt';
$filepath = $this->getFeedStorageDir() . $filename;
try {
$ioAdapter = new Varien_Io_File();
$ioAdapter->setAllowCreateFolders(true);
$ioAdapter->createDestinationDir($this->getFeedStorageDir());
$ioAdapter->cd($this->getFeedStorageDir());
$ioAdapter->streamOpen($filename);
$ioAdapter->streamWrite($content);
Varien_Profiler::stop('productfeed_' . $this->getVendorCode() . '::' . __FUNCTION__);
return $filepath;
} catch (Exception $e) {
Varien_Profiler::stop('productfeed_' . $this->getVendorCode() . '::' . __FUNCTION__);
Mage::throwException(Mage::helper('productfeed')->__('Could not write feed file to path: %s, %s', $filepath, $e->getMessage()));
}
}
示例4: writeRewriteFile
function writeRewriteFile()
{
$adapter = Mage::getModel('freelunchlabs_cloudfront/refreshadapters_apache');
$base_dir = Mage::getBaseDir() . DS;
$file = new Varien_Io_File();
try {
if ($file->cd($base_dir) && $file->checkAndCreateFolder($this->cdn_rewrite_directory, 0755)) {
if ($file->cd($base_dir . $this->cdn_rewrite_directory)) {
if (!$file->write($adapter->filename, $adapter->buildFileContents(), 0644)) {
throw new Exception("Could not write .htaccess to: " . $file->pwd());
}
}
}
} catch (Exception $e) {
Mage::getSingleton('core/session')->addWarning('Configuration saved but there was an error creating the .htaccess file: ' . $e->getMessage());
}
}
示例5: toOptionArray
public function toOptionArray()
{
$io = new Varien_Io_File();
$io->cd(Mage::getBaseDir() . DS . 'js' . DS . 'codemirror' . DS . 'theme');
$files = $io->ls(Varien_Io_File::GREP_FILES);
$options = array(array('value' => 'default', 'label' => 'default'));
foreach ($files as $file) {
$theme = pathinfo($file['text'], PATHINFO_FILENAME);
$options[] = array('value' => $theme, 'label' => $theme);
}
return $options;
}
示例6: getFilesOlderThan
/**
* Get all files which are older than X days and containing a pattern.
*
* @param int $days Days
* @param string $dir Directory
* @param string $filename Filename
* @return array
*/
public function getFilesOlderThan($days, $dir, $filename)
{
$date = Mage::getModel('core/date')->gmtTimestamp() - 60 * 60 * 24 * $days;
$oldFiles = array();
$scanDir = new Varien_Io_File();
$scanDir->cd($dir);
foreach ($scanDir->ls(Varien_Io_File::GREP_FILES) as $oldFile) {
if (stripos($oldFile['text'], $filename) != false && strtotime($oldFile['mod_date']) < $date) {
$oldFiles[] = $oldFile;
}
}
return $oldFiles;
}
示例7: _rewriteGrid
protected function _rewriteGrid($blcgClass, $originalClass, $gridType)
{
$classParts = explode('_', str_replace($this->_getBlcgClassPrefix(), '', $blcgClass));
$fileName = array_pop($classParts) . '.php';
$rewriteDir = dirname(__FILE__) . '/../../../Block/Rewrite/' . implode('/', $classParts);
$ioFile = new Varien_Io_File();
$ioFile->setAllowCreateFolders(true);
$ioFile->checkAndCreateFolder($rewriteDir);
$ioFile->cd($rewriteDir);
// Use open() to initialize Varien_Io_File::$_iwd
// Prevents a warning when chdir() is used without error control in Varien_Io_File::read()
if ($ioFile->fileExists($fileName, true) && $ioFile->open()) {
if ($content = $ioFile->read($fileName)) {
$lines = preg_split('#\\R#', $content, 3);
$isUpToDate = false;
if (isset($lines[0]) && isset($lines[1]) && $lines[0] == '<?php' && preg_match('#^// BLCG_REWRITE_CODE_VERSION\\=([0-9]+)$#', $lines[1], $matches)) {
if ($matches[1] === strval(self::REWRITE_CODE_VERSION)) {
$isUpToDate = true;
}
}
}
$ioFile->close();
if ($isUpToDate) {
return $this;
}
}
$content = '<?php
// BLCG_REWRITE_CODE_VERSION=' . self::REWRITE_CODE_VERSION . '
// This file was generated automatically. Do not alter its content.
/**
* NOTICE OF LICENSE
*
* This source file is subject to the Open Software License (OSL 3.0)
* that is bundled with this package in the file LICENSE.txt.
* It is also available through the world-wide-web at this URL:
* http://opensource.org/licenses/osl-3.0.php
*
* @category BL
* @package BL_CustomGrid
* @copyright Copyright (c) ' . date('Y') . ' Benoît Leulliette <benoit.leulliette@gmail.com>
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
*/
';
$content .= $this->_getRewriteCode($blcgClass, $originalClass, $gridType);
if (!$ioFile->write($fileName, $content)) {
Mage::throwException();
}
return $this;
}
示例8: cleanCache
public function cleanCache(Varien_Event_Observer $observer)
{
/** @var Mage_Catalog_Model_Product_Media_Config $mediaConfig */
$mediaConfig = Mage::getSingleton('catalog/product_media_config');
$baseCacheDir = realpath($mediaConfig->getMediaPath(Aoe_LazyCatalogImages_Helper_Catalog_Image::TOKEN_PREFIX));
$io = new Varien_Io_File();
$io->cd($baseCacheDir);
foreach ($io->ls(Varien_Io_File::GREP_DIRS) as $info) {
$dir = $info['id'];
if (strpos($dir, $baseCacheDir) === 0) {
$io->rmdir($dir, true);
}
}
}
示例9: toArray
public static function toArray()
{
$result = array();
$path = Mage::getModuleDir('', 'Mirasvit_Email') . DS . 'Model' . DS . 'Event';
$io = new Varien_Io_File();
$io->open();
$io->cd($path);
foreach ($io->ls(Varien_Io_File::GREP_DIRS) as $entity) {
$io->cd($entity['id']);
foreach ($io->ls(Varien_Io_File::GREP_FILES) as $event) {
if ($event['filetype'] != 'php') {
continue;
}
$info = pathinfo($event['text']);
$eventCode = strtolower($entity['text'] . '_' . $info['filename']);
$event = Mage::helper('email/event')->getEventModel($eventCode);
foreach ($event->getEvents() as $code => $name) {
$result[$event->getEventsGroup()][$code] = $name;
}
}
}
return $result;
}
示例10: processDailyRefunds
/**
* Submit refunds back to LinkShare for reimbursement.
*
* @param int $storeId
* @return Grommet_ProductFeed_Model_Vendor_LinkShare_Refund
*/
public function processDailyRefunds($storeId)
{
$rows = array();
$ordersProcessed = array();
// add credit memos to the feed
$creditmemos = $this->_getCreditMemos($storeId);
if (count($creditmemos)) {
foreach ($creditmemos as $creditmemo) {
$rows = array_merge($rows, $this->creditmemoToFeed($creditmemo));
$ordersProcessed[] = $creditmemo->getOrderId();
}
}
// add cancelations to the feed
$orders = $this->_getOrders($storeId, $ordersProcessed);
if (count($orders)) {
foreach ($orders as $order) {
$rows = array_merge($rows, $this->orderToFeed($order));
}
}
if (count($rows)) {
$mId = $this->getVendorConfig('merchant_id', $storeId);
if (!$mId) {
Mage::throwException(Mage::helper('productfeed')->__('LinkShare Merchant ID must be set.'));
}
$content = '';
foreach ($rows as $row) {
$content .= implode(self::DELIMITER, array_values($row)) . self::EOL;
}
$filename = $mId . '_trans' . Mage::getModel('core/date')->date('Ymd') . '.txt';
$filepath = $this->getFeedStorageDir() . $filename;
try {
$ioAdapter = new Varien_Io_File();
$ioAdapter->setAllowCreateFolders(true);
$ioAdapter->createDestinationDir($this->getFeedStorageDir());
$ioAdapter->cd($this->getFeedStorageDir());
$ioAdapter->streamOpen($filename);
$ioAdapter->streamWrite($content);
} catch (Exception $e) {
Mage::throwException(Mage::helper('productfeed')->__('Could not write refund file to path: %s, %s', $filepath, $e->getMessage()));
}
$publisher = $this->getPublisher();
$publisher->publish($filepath, $this->getPublishParams($storeId));
}
return $this;
}
示例11: _getRuleClasses
protected function _getRuleClasses()
{
$classes = array();
$rulesDir = Mage::getModuleDir('', 'Mirasvit_Email') . DS . 'Model' . DS . 'Rule' . DS . 'Condition';
$io = new Varien_Io_File();
$io->open();
$io->cd($rulesDir);
foreach ($io->ls(Varien_Io_File::GREP_FILES) as $event) {
if ($event['filetype'] != 'php') {
continue;
}
$info = pathinfo($event['text']);
$class = strtolower($info['filename']);
$classes[$class] = 'email/rule_condition_' . strtolower($class);
}
$io->close();
return $classes;
}
示例12: prepareFeed
/**
* Prepare the feed file and returns its path
*
* @param array $productsData
* @param int $storeId
* @return string
*/
public function prepareFeed(array $productsData, $storeId)
{
$filename = 'mediaforge_' . Mage::getModel('core/date')->date('Ymd') . '.csv';
$filepath = $this->getFeedStorageDir() . $filename;
try {
$ioAdapter = new Varien_Io_File();
$ioAdapter->setAllowCreateFolders(true);
$ioAdapter->createDestinationDir($this->getFeedStorageDir());
$ioAdapter->cd($this->getFeedStorageDir());
$ioAdapter->streamOpen($filename);
$ioAdapter->streamWriteCsv($this->_fields, self::DELIMITER);
foreach ($productsData as $row) {
$ioAdapter->streamWriteCsv($row, self::DELIMITER);
}
return $filepath;
} catch (Exception $e) {
Mage::throwException(Mage::helper('productfeed')->__('Could not write feed file to path: %s, %s', $filepath, $e->getMessage()));
}
}
示例13: getVariablesHelpers
public function getVariablesHelpers()
{
$result = array();
$pathes = array('email' => Mage::getModuleDir('', 'Mirasvit_Email') . DS . 'Helper' . DS . 'Variables', 'emaildesign' => Mage::getModuleDir('', 'Mirasvit_EmailDesign') . DS . 'Helper' . DS . 'Variables');
$io = new Varien_Io_File();
$io->open();
foreach ($pathes as $pathKey => $path) {
$io->cd($path);
foreach ($io->ls(Varien_Io_File::GREP_FILES) as $event) {
if ($event['filetype'] != 'php') {
continue;
}
$info = pathinfo($event['text']);
$result[] = $pathKey . '/variables_' . strtolower($info['filename']);
}
}
$io->close();
return $result;
}
示例14: prepareFeed
/**
* Prepare the feed file and returns its path
*
* @param array $productsData
* @param int $storeId
* @return string
*/
public function prepareFeed(array $productsData, $storeId)
{
Varien_Profiler::start('productfeed_' . $this->getVendorCode() . '::' . __FUNCTION__);
$filename = $this->getVendorCode() . '_' . Mage::getModel('core/date')->date('Ymd') . '.json';
$filepath = $this->getFeedStorageDir() . $filename;
try {
$ioAdapter = new Varien_Io_File();
$ioAdapter->setAllowCreateFolders(true);
$ioAdapter->createDestinationDir($this->getFeedStorageDir());
$ioAdapter->cd($this->getFeedStorageDir());
$ioAdapter->streamOpen($filename);
$ioAdapter->streamWrite(json_encode($productsData));
Varien_Profiler::stop('productfeed_' . $this->getVendorCode() . '::' . __FUNCTION__);
return $filepath;
} catch (Exception $e) {
Varien_Profiler::stop('productfeed_' . $this->getVendorCode() . '::' . __FUNCTION__);
Mage::throwException(Mage::helper('productfeed')->__('Could not write feed file to path: %s, %s', $filepath, $e->getMessage()));
}
}
示例15: _processDatabaseFile
/**
* Check file in database storage if needed and place it on file system
*
* @param string $filePath
* @return bool
*/
protected function _processDatabaseFile($filePath)
{
if (!Mage::helper('core/file_storage_database')->checkDbUsage()) {
return false;
}
$relativePath = Mage::helper('core/file_storage_database')->getMediaRelativePath($filePath);
$file = Mage::getModel('core/file_storage_database')->loadByFilename($relativePath);
if (!$file->getId()) {
return false;
}
$directory = dirname($filePath);
@mkdir($directory, 0777, true);
$io = new Varien_Io_File();
$io->cd($directory);
$io->streamOpen($filePath);
$io->streamLock(true);
$io->streamWrite($file->getContent());
$io->streamUnlock();
$io->streamClose();
return true;
}