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


PHP Varien_Io_File::dirname方法代码示例

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


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

示例1: uploadFile

 /**
  * Upload file to CDN async
  */
 public function uploadFile()
 {
     $adapter = Mage::getModel('mycdn/adapter');
     if (!$adapter) {
         return;
     }
     $ioObject = new Varien_Io_File();
     $ioObject->setAllowCreateFolders(true);
     $ioObject->open(array('path' => $ioObject->dirname($this->getData('filename'))));
     if (!$ioObject->fileExists($this->getData('filename'), true)) {
         Mage::helper('mycdn')->addLog('[CRON] No file ' . $this->getData('filename'));
         $this->delete();
         return;
     }
     //Mage::helper('mycdn')->addLog('[CRON] processing id = ' . $this->getId());
     //Mage::helper('mycdn')->addLog($this->getData());
     $result = $adapter->uploadFile($this->getData('filename'), $this->getData('uploadname'), $this->getData('content_type'));
     if ($result && $this->getData('delete')) {
         $ioObject->rm($this->getData('filename'));
         Mage::helper('mycdn')->addLog('[DELETE] CRON delete for ' . $this->getData('filename'));
     }
     if ($result) {
         Mage::helper('mycdn')->addLog('[JOB] CRON delete job for ' . $this->getData('filename') . "\n");
         $this->delete();
     }
 }
开发者ID:mygento,项目名称:cdn,代码行数:29,代码来源:Job.php

示例2: isFileExists

 public function isFileExists($fileName)
 {
     $ioObject = new Varien_Io_File();
     $ioObject->setAllowCreateFolders(true);
     $ioObject->open(array('path' => $ioObject->dirname($fileName)));
     if ($ioObject->fileExists($fileName, true)) {
         return true;
     }
     return false;
 }
开发者ID:mygento,项目名称:cdn,代码行数:10,代码来源:Data.php

示例3: _debugWriteToFile

 protected function _debugWriteToFile($str)
 {
     if (!$this->_debugIoAdapter) {
         $this->_debugIoAdapter = new Varien_Io_File();
         $dir = $this->_debugIoAdapter->dirname($this->_debugFile);
         $this->_debugIoAdapter->checkAndCreateFolder($dir);
         $this->_debugIoAdapter->open(array('path' => $dir));
         $this->_debugFile = basename($this->_debugFile);
     }
     $this->_debugIoAdapter->streamOpen($this->_debugFile, 'a');
     $this->_debugIoAdapter->streamLock();
     $this->_debugIoAdapter->streamWrite($str);
     $this->_debugIoAdapter->streamUnlock();
     $this->_debugIoAdapter->streamClose();
 }
开发者ID:HelioFreitas,项目名称:magento-pt_br,代码行数:15,代码来源:Mysql.php

示例4: _loadPatchFile

 /**
  * Use to load the patches array with applied patches.
  *
  * @return void
  */
 protected function _loadPatchFile()
 {
     $ioAdapter = new Varien_Io_File();
     if (!$ioAdapter->fileExists($this->patchFile)) {
         return;
     }
     $ioAdapter->open(array('path' => $ioAdapter->dirname($this->patchFile)));
     $ioAdapter->streamOpen($this->patchFile, 'r');
     while ($buffer = $ioAdapter->streamRead()) {
         if (stristr($buffer, '|')) {
             list($date, $patch) = array_map('trim', explode('|', $buffer));
             $this->appliedPatches[] = $patch;
         }
     }
     $ioAdapter->streamClose();
 }
开发者ID:brentwpeterson,项目名称:Philwinkle_AppliedPatches,代码行数:21,代码来源:Patches.php

示例5: _prepareDownloadResponse

 /**
  * Declare headers and content file in response for file download
  *
  * @param string $fileName
  * @param string|array $content set to null to avoid starting output, $contentLength should be set explicitly in
  *                              that case
  * @param string $contentType
  * @param int $contentLength    explicit content length, if strlen($content) isn't applicable
  * @return Mage_Core_Controller_Varien_Action
  */
 protected function _prepareDownloadResponse($fileName, $content, $contentType = 'application/octet-stream', $contentLength = null)
 {
     $session = Mage::getSingleton('admin/session');
     if ($session->isFirstPageAfterLogin()) {
         $this->_redirect($session->getUser()->getStartupPageUrl());
         return $this;
     }
     $isFile = false;
     $file = null;
     if (is_array($content)) {
         if (!isset($content['type']) || !isset($content['value'])) {
             return $this;
         }
         if ($content['type'] == 'filename') {
             $isFile = true;
             $file = $content['value'];
             $contentLength = filesize($file);
         }
     }
     $this->getResponse()->setHttpResponseCode(200)->setHeader('Pragma', 'public', true)->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)->setHeader('Content-type', $contentType, true)->setHeader('Content-Length', is_null($contentLength) ? strlen($content) : $contentLength, true)->setHeader('Content-Disposition', 'attachment; filename="' . $fileName . '"', true)->setHeader('Last-Modified', date('r'), true);
     if (!is_null($content)) {
         if ($isFile) {
             $this->getResponse()->clearBody();
             $this->getResponse()->sendHeaders();
             $ioAdapter = new Varien_Io_File();
             $ioAdapter->open(array('path' => $ioAdapter->dirname($file)));
             $ioAdapter->streamOpen($file, 'r');
             while ($buffer = $ioAdapter->streamRead()) {
                 print $buffer;
             }
             $ioAdapter->streamClose();
             if (!empty($content['rm'])) {
                 $ioAdapter->rm($file);
             }
             exit(0);
         } else {
             $this->getResponse()->setBody($content);
         }
     }
     return $this;
 }
开发者ID:pankajsinghjarial,项目名称:SYLC,代码行数:51,代码来源:Action.php

示例6: _debugWriteToFile

 /**
  * Debug write to file process
  *
  * @param string $str
  */
 protected function _debugWriteToFile($str)
 {
     $str = '## ' . date('Y-m-d H:i:s') . "\r\n" . $str;
     if (!$this->_debugIoAdapter) {
         $this->_debugIoAdapter = new Varien_Io_File();
         $dir = Mage::getBaseDir() . DS . $this->_debugIoAdapter->dirname($this->_debugFile);
         $this->_debugIoAdapter->checkAndCreateFolder($dir);
         $this->_debugIoAdapter->open(array('path' => $dir));
         $this->_debugFile = basename($this->_debugFile);
     }
     $this->_debugIoAdapter->streamOpen($this->_debugFile, 'a');
     $this->_debugIoAdapter->streamLock();
     $this->_debugIoAdapter->streamWrite($str);
     $this->_debugIoAdapter->streamUnlock();
     $this->_debugIoAdapter->streamClose();
 }
开发者ID:z4kko,项目名称:smartdevs-indexer,代码行数:21,代码来源:Mysql.php

示例7: _getFileContainerContent

 /**
  * Retrieve file content from file container array
  *
  * @param array $fileData
  * @return string
  */
 protected function _getFileContainerContent(array $fileData)
 {
     $io = new Varien_Io_File();
     $path = $io->dirname($fileData['value']);
     $io->open(array('path' => $path));
     return $io->read($fileData['value']);
 }
开发者ID:nja78,项目名称:Magento-Pre-Patched-Files,代码行数:13,代码来源:Grid.php

示例8: _applyEntityRedirectParentDirectory

 /**
  * Redirect customer to parent directory of current request.
  *
  * If the current redirect is to the top level (matches the base URL), don't do a redirect.
  *
  * @param $targetRouteSetting
  * @return bool Redirect was applied
  */
 protected function _applyEntityRedirectParentDirectory($targetRouteSetting)
 {
     $currectUrl = $this->_getCurrentUrl();
     $baseUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB, Mage::app()->getStore()->isCurrentlySecure());
     // Cut off query string at the end if present
     if (($pos = strpos($currectUrl, '?')) !== false) {
         $currectUrl = substr($currectUrl, 0, $pos);
     }
     // Paranoid check - _getCurrentUrl() should always be within the current base URL ;)
     if (strpos($currectUrl, $baseUrl) === 0) {
         // Remove base URL from beginning
         $path = substr($currectUrl, strlen($baseUrl));
         if (strlen($path) > 0) {
             // Only apply dirname() if there is a parent directory
             $io = new Varien_Io_File();
             if (($path = $io->dirname($path)) === '.') {
                 $path = '';
             }
             // Append configured category file suffix if this still isn't a top level request
             if (strlen($path) > 0) {
                 $path .= Mage::helper('catalog/category')->getCategoryUrlSuffix();
             }
             $targetUrl = $baseUrl . $path;
             if ($targetUrl != $currectUrl) {
                 $this->_sendRedirectHeaders($targetUrl, false);
                 return true;
             }
         }
     }
     // Don't display configured message if we already are requesting the target (top level) url.
     $this->_addMessage = false;
     return false;
 }
开发者ID:gewaechshaus,项目名称:groupscatalog2,代码行数:41,代码来源:Hidden.php

示例9: _prepareDownloadResponse

 /**
  * Declare headers and content file in response for file download
  *
  * @param string $fileName
  * @param string|array $content set to null to avoid starting output, $contentLength should be set explicitly in
  *                              that case
  * @param string $contentType
  * @param int $contentLength    explicit content length, if strlen($content) isn't applicable
  * @return Mage_Core_Controller_Varien_Action
  */
 protected function _prepareDownloadResponse($fileName, $content, $contentType = 'application/octet-stream', $contentLength = null)
 {
     $isFile = false;
     $file = null;
     if (is_array($content)) {
         if (!isset($content['type']) || !isset($content['value'])) {
             return $this;
         }
         if ($content['type'] == 'filename') {
             $isFile = true;
             $file = $content['value'];
             $contentLength = filesize($file);
         }
     }
     $this->getResponse()->setHttpResponseCode(200)->setHeader('Pragma', 'public', true)->setHeader('Cache-Control', 'must-revalidate, post-check=0, pre-check=0', true)->setHeader('Content-type', $contentType, true)->setHeader('Content-Length', is_null($contentLength) ? strlen($content) : $contentLength, true)->setHeader('Content-Disposition', 'attachment; filename="' . $fileName . '"', true)->setHeader('Last-Modified', date('r'), true);
     if (!is_null($content)) {
         if ($isFile) {
             $this->getResponse()->clearBody();
             $this->getResponse()->sendHeaders();
             $ioAdapter = new Varien_Io_File();
             if (!$ioAdapter->fileExists($file)) {
                 Mage::throwException(Mage::helper('Mage_Core_Helper_Data')->__('File not found'));
             }
             $ioAdapter->open(array('path' => $ioAdapter->dirname($file)));
             $ioAdapter->streamOpen($file, 'r');
             while ($buffer = $ioAdapter->streamRead()) {
                 print $buffer;
             }
             $ioAdapter->streamClose();
             if (!empty($content['rm'])) {
                 $ioAdapter->rm($file);
             }
             exit(0);
         } else {
             $this->getResponse()->setBody($content);
         }
     }
     return $this;
 }
开发者ID:nemphys,项目名称:magento2,代码行数:49,代码来源:Action.php


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