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


PHP Mage::getBaseDir方法代码示例

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


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

示例1: toOptionArray

 public function toOptionArray($key)
 {
     $key = str_replace("/", DS, $key);
     $importDir = Mage::getBaseDir('skin') . DS . 'frontend' . DS . $key . DS . 'import' . DS;
     $fileType = '.json';
     $files = glob($importDir . '*' . $fileType);
     $outputs = array();
     $outputs[] = array('label' => '-- Please Select --', 'value' => '');
     foreach ($files as $k => $v) {
         $labelFile = str_replace($importDir, "", $v);
         $file_content = file_get_contents($v);
         $file_content = Mage::helper('core')->jsonDecode($file_content);
         $created_at = $comment = '';
         if (isset($file_content['created_at']) && $file_content['created_at'] != '') {
             $created_at = ' - ' . $file_content['created_at'];
         }
         if (isset($file_content['comment']) && $file_content['comment'] != '') {
             $comment = ' - ' . $file_content['comment'];
         }
         $labelFile = $labelFile . ' ' . $created_at . ' ' . $comment;
         $outputs[] = array('label' => $labelFile, 'value' => $v);
     }
     $outputs[] = array('value' => 'data_import_file', 'label' => Mage::helper('themesettings')->__('Upload custom file...'));
     return $outputs;
 }
开发者ID:adrienManikon,项目名称:iPong,代码行数:25,代码来源:ImportFiles.php

示例2: getImages

 /**
  * Extracting available images
  *
  * @param string $thumbSize dimensions of thumbnail image (either number of width pixels or {width]x{height}
  * @param string $imageSize dimensions of detail image (either number of width pixels or {width]x{height}
  * @return unknown
  */
 public function getImages($thumbSize = null, $imageSize = null)
 {
     if (!($faq = $this->getFaq())) {
         return false;
     }
     // read images from dataset
     $images = $faq->getImage();
     $result = array();
     // if we have found images - process them
     if (is_array($images) && !empty($images)) {
         // get media model
         $mediaConfig = Mage::getSingleton('faq/faq_media_config');
         $mediaModel = Mage::getSingleton('media/image')->setConfig($mediaConfig);
         // iterate through images
         foreach ($images as $image) {
             // only go on if the image can be found
             if (file_exists(Mage::getBaseDir('media') . DS . 'faq' . DS . $image)) {
                 // gather needed information
                 $newImage = array('original' => $image, 'galleryUrl' => $this->getGalleryUrl($image));
                 if ($thumbSize) {
                     $newImage['src'] = $mediaModel->getSpecialLink($image, $thumbSize);
                 }
                 if ($imageSize) {
                     $newImage['href'] = $mediaModel->getSpecialLink($image, $imageSize);
                     $newImage['width'] = intval($imageSize);
                 } else {
                     $newImage['href'] = Mage::getBaseUrl('media') . '/faq/' . $image;
                     $newImage['width'] = $mediaModel->setFileName($image)->getDimensions()->getWidth();
                 }
                 $result[] = $newImage;
             }
         }
     }
     return $result;
 }
开发者ID:ravitechrlabs,项目名称:em,代码行数:42,代码来源:Detail.php

示例3: _construct

 /**
  * (non-PHPdoc)
  * @see lib/Varien/Varien_Object#_construct()
  */
 public function _construct()
 {
     // Note that the channel_id refers to the key field in your database table.
     $this->_init('manager/channel', 'channel_id');
     // initialize the PEAR service implementation
     $this->_service = Faett_Core_Factory::get(Mage::getBaseDir());
 }
开发者ID:BGCX067,项目名称:faett-manager-svn-to-git,代码行数:11,代码来源:Channel.php

示例4: getAllOptions

 /**
  * Retrieve all options array
  *
  * @return array
  */
 public function getAllOptions()
 {
     $taxonomyPath = Mage::getBaseDir() . self::TAXONOMY_FILE_PATH;
     $lang = Mage::getStoreConfig('general/locale/code', Mage::app()->getRequest()->getParam('store', 0));
     $taxonomyFile = $taxonomyPath . "taxonomy-with-ids." . $lang . ".txt";
     if (!file_exists($taxonomyFile)) {
         $taxonomyFile = $taxonomyPath . "taxonomy-with-ids.en_US.txt";
     }
     if (is_null($this->_options)) {
         $this->_options = array();
         $this->_options[0] = array('value' => 0, 'label' => "0 Other");
         if (($fh = fopen($taxonomyFile, "r")) !== false) {
             $line = 0;
             while (($category = fgets($fh)) !== false) {
                 $line++;
                 if ($line === 1) {
                     continue;
                 }
                 // skip first line
                 $option = explode(' - ', $category);
                 $this->_options[] = array('value' => $option[0], 'label' => $category);
             }
         }
     }
     return $this->_options;
 }
开发者ID:portchris,项目名称:NaturalRemedyCompany,代码行数:31,代码来源:GoogleShoppingCategories.php

示例5: scheduledBackup

 /**
  * Create Backup
  *
  * @return Mage_Log_Model_Cron
  */
 public function scheduledBackup()
 {
     if (!Mage::getStoreConfigFlag(self::XML_PATH_BACKUP_ENABLED)) {
         return $this;
     }
     if (Mage::getStoreConfigFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE)) {
         Mage::helper('backup')->turnOnMaintenanceMode();
     }
     $type = Mage::getStoreConfig(self::XML_PATH_BACKUP_TYPE);
     $this->_errors = array();
     try {
         $backupManager = Mage_Backup::getBackupInstance($type)->setBackupExtension(Mage::helper('backup')->getExtensionByType($type))->setTime(time())->setBackupsDir(Mage::helper('backup')->getBackupsDir());
         Mage::register('backup_manager', $backupManager);
         if ($type != Mage_Backup_Helper_Data::TYPE_DB) {
             $backupManager->setRootDir(Mage::getBaseDir())->addIgnorePaths(Mage::helper('backup')->getBackupIgnorePaths());
         }
         $backupManager->create();
         Mage::log(Mage::helper('backup')->getCreateSuccessMessageByType($type));
     } catch (Exception $e) {
         $this->_errors[] = $e->getMessage();
         $this->_errors[] = $e->getTrace();
         Mage::log($e->getMessage(), Zend_Log::ERR);
         Mage::logException($e);
     }
     if (Mage::getStoreConfigFlag(self::XML_PATH_BACKUP_MAINTENANCE_MODE)) {
         Mage::helper('backup')->turnOffMaintenanceMode();
     }
     return $this;
 }
开发者ID:chucky515,项目名称:Magento-CE-Mirror,代码行数:34,代码来源:Observer.php

示例6: testExecutionTimeAction

    /**
     * @title "Execution Time Test"
     * @description "Execution Time Test"
     * @new_line
     */
    public function testExecutionTimeAction()
    {
        ini_set('display_errors', 1);
        $seconds = (int) $this->getRequest()->getParam('seconds', null);
        $logDir = Mage::getBaseDir('var') . DS . 'log' . DS;
        $fileName = 'm2epro_execution_time.log';
        $isLogFileExists = is_file($logDir . $fileName);
        if ($seconds) {
            $isLogFileExists && unlink($logDir . $fileName);
            $i = 0;
            while ($i < $seconds) {
                sleep(1);
                ++$i % 10 == 0 && Mage::log("{$i} seconds passed", null, $fileName, 1);
            }
            echo "<div>{$seconds} seconds passed successfully!</div><br/>";
        }
        if ($isLogFileExists) {
            $contentsRows = explode("\n", file_get_contents($logDir . $fileName));
            if (count($contentsRows) >= 2) {
                $lastRecord = trim($contentsRows[count($contentsRows) - 2], "\r\n");
                echo "<button onclick=\"alert('{$lastRecord}')\">show prev. log</button>";
            }
        }
        $url = Mage::helper('adminhtml')->getUrl('*/*/*');
        return print <<<HTML
<form action="{$url}" method="get">
    <input type="text" name="seconds" class="input-text" value="180" style="text-align: right; width: 100px" />
    <button type="submit">Test</button>
</form>
HTML;
    }
开发者ID:ReeceCrossland,项目名称:essua-m2epro,代码行数:36,代码来源:AdditionalController.php

示例7: is_writable

 function is_writable($is_use_session = true)
 {
     $dir = Mage::getBaseDir('var') . DS;
     $msg = false;
     if (is_writable($dir)) {
         $dir .= 'ThememanagerExport' . DS;
         if (file_exists($dir)) {
             if (!is_dir($dir)) {
                 $msg = Mage::helper('thememanager')->__('"%s" is not a dir', $dir);
             }
         } else {
             mkdir($dir, 0777);
         }
         if (!is_writable($dir)) {
             $msg = Mage::helper('thememanager')->__('"%s" is not writable', $dir);
         }
     } else {
         $msg = Mage::helper('thememanager')->__('"%s" is not writable', $dir);
     }
     if ($msg) {
         $this->error_msg[] = $msg;
         if ($is_use_session) {
             Mage::getSingleton('core/session')->addError($msg);
         }
         return false;
     } else {
         $this->files_dir = $dir . date('U') . DS;
         mkdir($this->files_dir, 0777);
         return $this->files_dir;
     }
 }
开发者ID:kiutisuperking,项目名称:eatsmartboxdev,代码行数:31,代码来源:Meigee_Thememanager_Model_ExportImport.php

示例8: 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

示例9: __construct

 public function __construct()
 {
     $this->localFolder = Mage::getBaseDir('var') . DS . 'lecom';
     $this->localInbound = $this->localFolder . DS . 'inbound';
     $this->localInboundOrdship = $this->localInbound . DS . 'ordshipment' . DS;
     $this->localInboundOrdshipArcv = $this->localInbound . DS . 'ordshipment_arcv' . DS;
     $this->localInboundOrdshipErr = $this->localInbound . DS . 'ordshipment_err' . DS;
     $remoteInboundOrdship = Mage::getStoreConfig('orders/paths/otfshipment');
     $this->remoteInboundOrdship = trim($remoteInboundOrdship);
     Mage::getModel('logger/logger')->saveLogger("order_shipment", "Information", __FILE__, "DB Inbound Path:" . $this->remoteInboundOrdship);
     if (empty($this->remoteInboundOrdship)) {
         $this->remoteInboundOrdship = '/mnt/lecomotf/inbound/ordshipment/';
     }
     if (!is_dir($this->localFolder)) {
         mkdir($this->localFolder, 0777);
         chmod($this->localFolder, 0777);
     }
     if (!is_dir($this->localInbound)) {
         mkdir($this->localInbound, 0777);
         chmod($this->localInbound, 0777);
     }
     if (!is_dir($this->localInboundOrdship)) {
         mkdir($this->localInboundOrdship, 0777);
         chmod($this->localInboundOrdship, 0777);
     }
     if (!is_dir($this->localInboundOrdshipArcv)) {
         mkdir($this->localInboundOrdshipArcv, 0777);
         chmod($this->localInboundOrdshipArcv, 0777);
     }
     if (!is_dir($this->localInboundOrdshipErr)) {
         mkdir($this->localInboundOrdshipErr, 0777);
         chmod($this->localInboundOrdshipErr, 0777);
     }
 }
开发者ID:sagmahajan,项目名称:aswan_release,代码行数:34,代码来源:Shipment.php

示例10: resize

 public function resize($width, $height)
 {
     if (!($imageUrl = $this->getImageUrl())) {
         return '';
     }
     $dir = Mage::getBaseDir('media') . DS . "testimonials" . DS . "pictures" . DS . "resized";
     if (!file_exists($dir)) {
         mkdir($dir, 0777);
     }
     $imageName = substr(strrchr($imageUrl, "/"), 1);
     $imageName = $width . '_' . $height . '_' . $imageName;
     $imageResized = $dir . DS . $imageName;
     $imagePath = str_replace(Mage::getBaseUrl('media'), 'media/', $imageUrl);
     $imagePath = Mage::getBaseDir() . DS . str_replace("/", DS, $imagePath);
     if (!file_exists($imageResized) && file_exists($imagePath)) {
         $imageObj = new Varien_Image($imagePath);
         $imageObj->constrainOnly(true);
         $imageObj->keepAspectRatio(true);
         $imageObj->keepFrame(false);
         $imageObj->keepTransparency(true);
         $imageObj->resize($width, $height);
         $imageObj->save($imageResized);
     }
     $imageUrl = Mage::getBaseUrl('media') . "testimonials/pictures/resized/" . $imageName;
     return $imageUrl;
 }
开发者ID:masterdef,项目名称:testimonials,代码行数:26,代码来源:Image.php

示例11: getShortImageSize

 public function getShortImageSize($item)
 {
     $width_max = Mage::getStoreConfig('clnews/news/shortdescr_image_max_width');
     $height_max = Mage::getStoreConfig('clnews/news/shortdescr_image_max_height');
     if (Mage::getStoreConfig('clnews/news/resize_to_max') == 1) {
         $width = $width_max;
         $height = $height_max;
     } else {
         $imageObj = new Varien_Image(Mage::getBaseDir('media') . DS . $item->getImageShortContent());
         $original_width = $imageObj->getOriginalWidth();
         $original_height = $imageObj->getOriginalHeight();
         if ($original_width > $width_max) {
             $width = $width_max;
         } else {
             $width = $original_width;
         }
         if ($original_height > $height_max) {
             $height = $height_max;
         } else {
             $height = $original_height;
         }
     }
     if ($item->getShortWidthResize()) {
         $width = $item->getShortWidthResize();
     } else {
         $width;
     }
     if ($item->getShortHeightResize()) {
         $height = $item->getShortHeightResize();
     } else {
         $height;
     }
     return array('width' => $width, 'height' => $height);
 }
开发者ID:zloadmin,项目名称:modnyashka,代码行数:34,代码来源:News.php

示例12: getPostImage

 public function getPostImage($width = false, $height = false)
 {
     $img = $this->getData('post_image');
     if (empty($img)) {
         return false;
     }
     $imgDir = dirname($img);
     $imgFile = basename($img);
     if (!$width) {
         return $img;
     }
     //if(!$height) $height = $width;
     $imageUrl = Mage::getBaseDir('media') . DS . $img;
     if (!is_file($imageUrl)) {
         return false;
     }
     $imageResized = Mage::getBaseDir('media') . DS . $imgDir . "/resized/" . $width . "x" . $height . DS . $imgFile;
     if (file_exists($imageResized)) {
         return $imgDir . "/resized/" . $width . "x" . $height . DS . $imgFile;
     }
     $imageObj = new Varien_Image($imageUrl);
     $imageObj->constrainOnly(TRUE);
     $imageObj->keepAspectRatio(TRUE);
     $imageObj->keepFrame(FALSE);
     $imageObj->quality(100);
     $imageObj->resize($width, $height);
     $imageObj->save($imageResized);
     return $imgDir . "/resized/" . $width . "x" . $height . DS . $imgFile;
 }
开发者ID:xiaoguizhidao,项目名称:storebaby.it,代码行数:29,代码来源:Post.php

示例13: __construct

 /**
  * Assemble themes inheritance config
  *
  */
 public function __construct(array $params = array())
 {
     if (isset($params['designRoot'])) {
         if (!is_dir($params['designRoot'])) {
             throw new Mage_Core_Exception("Design root '{$params['designRoot']}' isn't a directory.");
         }
         $this->_designRoot = $params['designRoot'];
     } else {
         $this->_designRoot = Mage::getBaseDir('design');
     }
     $this->_cacheChecksum = null;
     $this->setCacheId('config_theme');
     $this->setCache(Mage::app()->getCache());
     if (!$this->loadCache()) {
         $this->loadString('<theme />');
         $path = str_replace('/', DS, $this->_designRoot . '/*/*/*/etc/theme.xml');
         $files = glob($path);
         foreach ($files as $file) {
             $config = new Varien_Simplexml_Config();
             $config->loadFile($file);
             list($area, $package, $theme) = $this->_getThemePathSegments($file);
             $this->setNode($area . '/' . $package . '/' . $theme, null);
             $this->getNode($area . '/' . $package . '/' . $theme)->extend($config->getNode());
         }
         $this->saveCache();
     }
 }
开发者ID:barneydesmond,项目名称:propitious-octo-tribble,代码行数:31,代码来源:Config.php

示例14: process

 public function process(array $csvData, $cid, $imageDir)
 {
     $cnt = count($csvData);
     $importDir = Mage::getBaseDir() . DS . 'media' . DS . 'marketplace' . DS . $cid . DS . $imageDir . DS;
     if ($cnt > 1) {
         for ($i = 1; $i < $cnt; $i++) {
             try {
                 $sku = $csvData[$i][0];
                 $product = Mage::getModel('catalog/product')->loadByAttribute('sku', $sku);
                 $fileName = trim($csvData[$i][11]);
                 $filePath = $importDir . $fileName;
                 if (file_exists($filePath) && $fileName != '') {
                     $types = array('image', 'small_image', 'thumbnail');
                     foreach ($types as $type) {
                         $product->addImageToMediaGallery($filePath, array($type), false);
                     }
                     $mediaGallery = $product->getMediaGallery();
                     if (isset($mediaGallery['images'])) {
                         foreach ($mediaGallery['images'] as $key => $image) {
                             Mage::getSingleton('catalog/product_action')->updateAttributes(array($product->getId()), array($types[$key] => $image['file']), 0);
                         }
                     }
                     $product->save();
                     unlink($filePath);
                 } else {
                     $message = 'Image does not exist for sku ' . $sku;
                     Mage::log($message, null, 'sellerimages_debug.log', true);
                 }
             } catch (Exception $e) {
                 Mage::logException($e);
             }
         }
     }
     return true;
 }
开发者ID:DeveshKumarThakur,项目名称:cosmetics,代码行数:35,代码来源:Image.php

示例15: importImages

 /**
  * import images
  *
  * @access public
  * @param $product, $image, $sku
  * @return void
  * 
  */
 private function importImages($product, $image, $sku)
 {
     $image_url = $image['img'];
     $image_url = str_replace("https://", "http://", $image_url);
     $image_type = substr(strrchr($image_url, "."), 1);
     $split = explode("?", $image_type);
     $image_type = $split[0];
     $imgName = basename($image_url);
     $imgName = str_replace('.' . $image_type, "", $imgName);
     $filename = md5($imgName . $sku) . '.' . $image_type;
     $dirPath = Mage::getBaseDir('media') . DS . 'import';
     if (!file_exists($dirPath)) {
         mkdir($dirPath, 0777, true);
     }
     $filepath = $dirPath . DS . $filename;
     $curl_handle = curl_init();
     curl_setopt($curl_handle, CURLOPT_URL, $image_url);
     curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
     curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Cirkel');
     $query = curl_exec($curl_handle);
     curl_close($curl_handle);
     file_put_contents($filepath, $query);
     if (file_exists($filepath)) {
         $attrIMG = array();
         if (array_key_exists('main', $image)) {
             if ($image['main'] == true) {
                 $attrIMG = array('image', 'thumbnail', 'small_image');
             }
         }
         $productMG = Mage::getModel('catalog/product')->loadByAttribute('sku', $product->getSku());
         $productMG->addImageToMediaGallery($filepath, $attrIMG, false, false);
         $productMG->save();
     }
 }
开发者ID:novapc,项目名称:magento,代码行数:43,代码来源:Productgenerator.php


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