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


PHP Mage::getRoot方法代码示例

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


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

示例1: _checkPath

 /**
  * Check file system path
  *
  * @param   string $path
  * @param   bool $recursive
  * @param   bool $existence
  * @param   string $mode
  * @return  bool
  */
 protected function _checkPath($path, $recursive, $existence, $mode)
 {
     $res = true;
     $fullPath = dirname(Mage::getRoot()) . $path;
     if ($mode == self::MODE_WRITE) {
         $setError = false;
         if ($existence) {
             if (is_dir($fullPath) && !is_dir_writeable($fullPath) || !is_writable($fullPath)) {
                 $setError = true;
             }
         } else {
             if (file_exists($fullPath) && !is_writable($fullPath)) {
                 $setError = true;
             }
         }
         if ($setError) {
             $this->_getInstaller()->getDataModel()->addError(Mage::helper('install')->__('Path "%s" must be writable.', $fullPath));
             $res = false;
         }
     }
     if ($recursive && is_dir($fullPath)) {
         foreach (new DirectoryIterator($fullPath) as $file) {
             if (!$file->isDot() && $file->getFilename() != '.svn' && $file->getFilename() != '.htaccess') {
                 $res = $res && $this->_checkPath($path . DS . $file->getFilename(), $recursive, $existence, $mode);
             }
         }
     }
     return $res;
 }
开发者ID:jpbender,项目名称:mage_virtual,代码行数:38,代码来源:Filesystem.php

示例2: testReset

 /**
  * @magentoAppIsolation enabled
  */
 public function testReset()
 {
     Mage::setRoot(dirname(__FILE__));
     $this->assertNotNull(Mage::getRoot());
     Mage::reset();
     $this->assertNull(Mage::getRoot());
 }
开发者ID:nemphys,项目名称:magento2,代码行数:10,代码来源:MageTest.php

示例3: __construct

 /**
  * Initialize default values of the options
  *
  * @param array $data
  */
 public function __construct(array $data = array())
 {
     $this->_io = isset($data['io']) ? $data['io'] : new Varien_Io_File();
     unset($data['io']);
     parent::__construct($data);
     $appRoot = isset($data['app_dir']) ? $data['app_dir'] : Mage::getRoot();
     $root = dirname($appRoot);
     $this->_data['app_dir'] = $appRoot;
     $this->_data['base_dir'] = $root;
     $this->_data['code_dir'] = $appRoot . DIRECTORY_SEPARATOR . 'code';
     $this->_data['design_dir'] = $appRoot . DIRECTORY_SEPARATOR . 'design';
     $this->_data['etc_dir'] = $appRoot . DIRECTORY_SEPARATOR . 'etc';
     $this->_data['lib_dir'] = $root . DIRECTORY_SEPARATOR . 'lib';
     $this->_data['locale_dir'] = $appRoot . DIRECTORY_SEPARATOR . 'locale';
     $this->_data['pub_dir'] = $root . DIRECTORY_SEPARATOR . 'pub';
     $this->_data['js_dir'] = $this->_data['pub_dir'] . DIRECTORY_SEPARATOR . 'lib';
     $this->_data['media_dir'] = isset($data['media_dir']) ? $data['media_dir'] : $this->_data['pub_dir'] . DIRECTORY_SEPARATOR . 'media';
     $this->_data['var_dir'] = $this->getVarDir();
     $this->_data['tmp_dir'] = $this->_data['var_dir'] . DIRECTORY_SEPARATOR . 'tmp';
     $this->_data['cache_dir'] = $this->_data['var_dir'] . DIRECTORY_SEPARATOR . 'cache';
     $this->_data['log_dir'] = $this->_data['var_dir'] . DIRECTORY_SEPARATOR . 'log';
     $this->_data['session_dir'] = $this->_data['var_dir'] . DIRECTORY_SEPARATOR . 'session';
     $this->_data['upload_dir'] = $this->_data['media_dir'] . DIRECTORY_SEPARATOR . 'upload';
     $this->_data['export_dir'] = $this->_data['var_dir'] . DIRECTORY_SEPARATOR . 'export';
 }
开发者ID:natxetee,项目名称:magento2,代码行数:30,代码来源:Options.php

示例4: saveMenuCache

 public function saveMenuCache()
 {
     try {
         //$defaultStoreId = Mage::app()->getWebsite()->getDefaultGroup()->getDefaultStoreId();
         //Mage::app()->setCurrentStore($defaultStoreId);
         //Mage::getSingleton('core/session', array('name'=>'frontend'));
         //$_layout  = Mage::getSingleton('core/layout');
         //$_block  =	$_layout->createBlock('page/html_topmenu')/*->setTemplate('page/html/topmenu.phtml')*/;
         //$html=$_block->getHtml();
         Mage::app()->loadArea('frontend');
         $layout = Mage::getSingleton('core/layout');
         //load default xml layout handle and generate blocks
         $layout->getUpdate()->load('default');
         $layout->generateXml()->generateBlocks();
         //get the loaded head and header blocks and output
         $headerBlock = $layout->getBlock('header');
         $html = $headerBlock->toHtml();
         $filename = dirname(Mage::getRoot()) . DS . 'media' . DS . 'wp' . DS . 'topmenu';
         file_put_contents($filename, $html);
         //Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
         //Mage::getSingleton('core/session', array('name'=>'admintml'));
     } catch (Exception $e) {
         Mage:
         log($e->getMessage(), null, 'wp_menu_error.log');
     }
 }
开发者ID:buttasg,项目名称:cowgirlk,代码行数:26,代码来源:Wpmenu000.php

示例5: themeConfigFileDataProvider

 /**
  * @return array
  */
 public function themeConfigFileDataProvider()
 {
     $result = array();
     foreach (glob(Mage::getRoot() . '/design/*/*/*/theme.xml') as $file) {
         $result[] = array($file);
     }
     return $result;
 }
开发者ID:relue,项目名称:magento2,代码行数:11,代码来源:XmlFilesTest.php

示例6: _config

 protected function _config()
 {
     if (is_null($this->_localConfig)) {
         $path = Mage::getRoot() . '/etc/local.xml';
         if (file_exists($path)) {
             $this->_localConfig = new Zend_Config_Xml($path);
         }
     }
     return $this->_localConfig;
 }
开发者ID:rajarshc,项目名称:Rooja,代码行数:10,代码来源:Database.php

示例7: __construct

 public function __construct()
 {
     $this->_etcDir = Mage::getRoot() . '/etc/';
     $this->_codeDir = Mage::getRoot() . '/code/';
     $this->_rewriteDir = dirname(Mage::getRoot()) . self::REWRITE_CACHE_DIR;
     $this->_checkClassDir[] = $this->_codeDir . 'local/';
     $this->_checkClassDir[] = $this->_codeDir . 'community/';
     $this->_checkClassDir[] = $this->_codeDir . 'core/';
     if (!file_exists($this->_rewriteDir)) {
         $this->tool()->filesystem()->mkDir($this->_rewriteDir);
     }
 }
开发者ID:sagmahajan,项目名称:aswan_release,代码行数:12,代码来源:Abstract.php

示例8: processFile

 /**
  * Process file
  * 
  * @param string $filename Filename
  * 
  * @return boolean|void
  */
 public function processFile($filename)
 {
     $file = $this->getFilePath($filename);
     if ('' == $filename || !file_exists($file)) {
         return false;
     }
     $filename = basename($file);
     $this->saveProgress($filename);
     $suffix = '> /dev/null 2>/dev/null &';
     $script = Mage::getRoot() . "/../shell/nedisimport.php --file '{$filename}'";
     exec('php ' . $script . ' ' . $suffix);
 }
开发者ID:vecbralis,项目名称:magento-nedis-import,代码行数:19,代码来源:Catalog.php

示例9: wpMenuCache

 public function wpMenuCache()
 {
     try {
         $filename = dirname(Mage::getRoot()) . DS . 'media' . DS . 'wp' . DS . 'topmenu';
         if (file_exists($filename)) {
             @unlink($filename);
         }
         $url = "http://" . $_SERVER['HTTP_HOST'] . "/mg2wp/index.php/?block=topmenu";
         $html = @file_get_contents($url);
         //Mage::log($html,null,'wp_menu.log');
     } catch (Exception $e) {
         Mage::log($e->getMessage(), null, 'wp_menu_error.log');
     }
 }
开发者ID:buttasg,项目名称:cowgirlk,代码行数:14,代码来源:Wpmenu.php

示例10: __construct

 public function __construct($options = array(), $dbSettings = array())
 {
     $this->_defaultBackendOptions['cache_dir'] = dirname(Mage::getRoot()) . DS . 'var' . DS . 'cache';
     // Initialize id prefix
     $this->_idPrefix = isset($options['id_prefix']) ? $options['id_prefix'] : '';
     if (!$this->_idPrefix && isset($options['prefix'])) {
         $this->_idPrefix = $options['prefix'];
     }
     if (empty($this->_idPrefix)) {
         $etcDir = Mage::getRoot() . DS . 'etc';
         $this->_idPrefix = substr(md5($etcDir), 0, 3) . '_';
     }
     // init database resource
     $this->_resource = new Aitoc_Aitsys_Model_Core_Cache_Resource($dbSettings);
     // collect cache options
     $backend = $this->_getBackendOptions($options);
     $frontend = $this->_getFrontendOptions($options);
     $this->_frontend = Zend_Cache::factory('Varien_Cache_Core', $backend['type'], $frontend, $backend['options'], true, true, true);
 }
开发者ID:CherylMuniz,项目名称:fashion,代码行数:19,代码来源:Cache.php

示例11: _construct

 /**
  * Initialize default values of the options
  */
 protected function _construct()
 {
     $appRoot = Mage::getRoot();
     $root = dirname($appRoot);
     $this->_data['app_dir'] = $appRoot;
     $this->_data['base_dir'] = $root;
     $this->_data['code_dir'] = $appRoot . DS . 'code';
     $this->_data['design_dir'] = $appRoot . DS . 'design';
     $this->_data['etc_dir'] = $appRoot . DS . 'etc';
     $this->_data['lib_dir'] = $root . DS . 'lib';
     $this->_data['locale_dir'] = $appRoot . DS . 'locale';
     $this->_data['media_dir'] = $root . DS . 'media';
     $this->_data['skin_dir'] = $root . DS . 'skin';
     $this->_data['var_dir'] = $this->getVarDir();
     $this->_data['tmp_dir'] = $this->_data['var_dir'] . DS . 'tmp';
     $this->_data['cache_dir'] = $this->_data['var_dir'] . DS . 'cache';
     $this->_data['log_dir'] = $this->_data['var_dir'] . DS . 'log';
     $this->_data['session_dir'] = $this->_data['var_dir'] . DS . 'session';
     $this->_data['upload_dir'] = $this->_data['media_dir'] . DS . 'upload';
     $this->_data['export_dir'] = $this->_data['var_dir'] . DS . 'export';
 }
开发者ID:Airmal,项目名称:Magento-Em,代码行数:24,代码来源:Options.php

示例12: __construct

 public function __construct($options = array())
 {
     if (!isset($options['prefix'])) {
         $this->_idPrefix = md5(dirname(Mage::getRoot()));
     } else {
         $this->_idPrefix = $options['prefix'];
     }
     $backend = '';
     if (isset($options['backend'])) {
         $backend = strtolower($options['backend']);
     }
     $backendType = '';
     if (extension_loaded('apc') && ini_get('apc.enabled') && $backend == 'apc') {
         $backendType = 'Apc';
         $backendAttributes = array('cache_prefix' => $this->_idPrefix);
     } elseif (extension_loaded('eaccelerator') && ini_get('eaccelerator.enable') && $backend == 'eaccelerator') {
         $backendType = 'Eaccelerator';
         $backendAttributes = array('cache_prefix' => $this->_idPrefix);
     } elseif ('memcached' == $backend && extension_loaded('memcache')) {
         $backendType = 'Memcached';
         $memcachedConfig = $options['memcached'];
         $backendAttributes = array('compression' => isset($memcachedConfig['compression']) ? $memcachedConfig['compression'] : false, 'cache_dir' => isset($memcachedConfig['cache_dir']) ? $memcachedConfig['cache_dir'] : '', 'hashed_directory_level' => isset($memcachedConfig['hashed_directory_level']) ? $memcachedConfig['hashed_directory_level'] : '', 'hashed_directory_umask' => isset($memcachedConfig['hashed_directory_umask']) ? $memcachedConfig['hashed_directory_umask'] : '', 'file_name_prefix' => isset($memcachedConfig['file_name_prefix']) ? $memcachedConfig['file_name_prefix'] : '', 'servers' => array());
         foreach ($memcachedConfig['servers'] as $serverConfig) {
             $backendAttributes['servers'][] = array('host' => $serverConfig['host'], 'port' => $serverConfig['port'], 'persistent' => $serverConfig['persistent']);
         }
     }
     if (!$backendType) {
         $backendType = $this->_defaultBackend;
         $backendAttributes = $this->_defaultBackendOptions;
         $backendAttributes['cache_dir'] = dirname(Mage::getRoot()) . DS . 'var' . DS . 'cache';
     }
     if (isset($options['lifetime'])) {
         $lifetime = (int) $options['lifetime'];
     } else {
         $lifetime = self::DEFAULT_LIFETIME;
     }
     $this->_frontend = Zend_Cache::factory('Core', $backendType, array('caching' => true, 'lifetime' => $lifetime, 'automatic_cleaning_factor' => 0), $backendAttributes, false, false, true);
 }
开发者ID:sagmahajan,项目名称:aswan_release,代码行数:38,代码来源:Legacy.php

示例13: __construct

 /**
  * Initialize default values of the options
  */
 public function __construct()
 {
     parent::__construct();
     $appRoot = Mage::getRoot();
     $root = dirname($appRoot);
     $this->_data['app_dir'] = $appRoot;
     $this->_data['base_dir'] = $root;
     $this->_data['code_dir'] = $appRoot . DIRECTORY_SEPARATOR . 'code';
     $this->_data['design_dir'] = $appRoot . DIRECTORY_SEPARATOR . 'design';
     $this->_data['etc_dir'] = $appRoot . DIRECTORY_SEPARATOR . 'etc';
     $this->_data['lib_dir'] = $root . DIRECTORY_SEPARATOR . 'lib';
     $this->_data['locale_dir'] = $appRoot . DIRECTORY_SEPARATOR . 'locale';
     $this->_data['pub_dir'] = $root . DIRECTORY_SEPARATOR . 'pub';
     $this->_data['js_dir'] = $this->_data['pub_dir'] . DIRECTORY_SEPARATOR . 'js';
     $this->_data['media_dir'] = $this->_data['pub_dir'] . DIRECTORY_SEPARATOR . 'media';
     $this->_data['var_dir'] = $this->getVarDir();
     $this->_data['tmp_dir'] = $this->_data['var_dir'] . DIRECTORY_SEPARATOR . 'tmp';
     $this->_data['cache_dir'] = $this->_data['var_dir'] . DIRECTORY_SEPARATOR . 'cache';
     $this->_data['log_dir'] = $this->_data['var_dir'] . DIRECTORY_SEPARATOR . 'log';
     $this->_data['session_dir'] = $this->_data['var_dir'] . DIRECTORY_SEPARATOR . 'session';
     $this->_data['upload_dir'] = $this->_data['media_dir'] . DIRECTORY_SEPARATOR . 'upload';
     $this->_data['export_dir'] = $this->_data['var_dir'] . DIRECTORY_SEPARATOR . 'export';
 }
开发者ID:relue,项目名称:magento2,代码行数:26,代码来源:Options.php

示例14: __construct

 private function __construct()
 {
     $moduleFiles = glob(Mage::getRoot() . '/etc/modules/*.xml');
     $unsortedConfig = new Varien_Simplexml_Config();
     $unsortedConfig->loadString('<config/>');
     $fileConfig = new Varien_Simplexml_Config();
     foreach ($moduleFiles as $filePath) {
         $fileConfig->loadFile($filePath);
         $unsortedConfig->extend($fileConfig);
     }
     // create sorted config [only active modules]
     #$sortedConfig = new Varien_Simplexml_Config();
     #$sortedConfig->loadString('<config><modules/></config>');
     $fileConfig = new Varien_Simplexml_Config();
     foreach ($unsortedConfig->getNode('modules')->children() as $moduleName => $moduleNode) {
         if ('true' === (string) $moduleNode->active) {
             $codePool = (string) $moduleNode->codePool;
             $configPath = Mage::getRoot() . '/code/' . $codePool . '/' . uc_words($moduleName, '/') . '/etc/config.xml';
             $fileConfig->loadFile($configPath);
             $unsortedConfig->extend($fileConfig);
         }
     }
     $this->_config = $unsortedConfig;
 }
开发者ID:sagmahajan,项目名称:aswan_release,代码行数:24,代码来源:MageConfig.php

示例15: suvenirparseAction

 public function suvenirparseAction()
 {
     set_time_limit(0);
     ini_set('memory_limit', '1024M');
     $skus = array();
     $qtys = array();
     $prices = array();
     $attrSetName = 'suvenir';
     $attributeSetId = Mage::getModel('eav/entity_attribute_set')->load($attrSetName, 'attribute_set_name')->getAttributeSetId();
     $products = Mage::getModel('catalog/product')->getCollection()->joinField('qty', 'cataloginventory/stock_item', 'qty', 'product_id=entity_id', '{{table}}.stock_id=1', 'left')->addAttributeToSelect('price')->addFieldToFilter('attribute_set_id', $attributeSetId);
     foreach ($products as $p) {
         $skus[] = $p->getData('sku');
         $qtys[] = $p->getQty();
         $prices[] = $p->getPrice();
     }
     $sku = '';
     $appRoot = Mage::getRoot();
     $root = dirname($appRoot);
     error_reporting(E_ALL ^ E_NOTICE);
     require_once $root . DS . 'lib' . DS . 'ExcelReader' . DS . 'excelreader.php';
     $data = new Spreadsheet_Excel_Reader();
     $data->read($_FILES['filesuvenir']['tmp_name']);
     $found = '0';
     $csv = array();
     $sku = array();
     for ($i = 2; $i < $data->rowcount() + 1; $i++) {
         $price = str_replace(" ", "", $data->val($i, D));
         $csv[$i - 2][] = "''";
         //articul
         $csv[$i - 2][] = "'" . trim($data->val($i, B)) . "'";
         //sku
         $csv[$i - 2][] = "'" . str_replace(',', '.', $price) . "'";
         //price
         $csv[$i - 2][] = "'" . trim($data->val($i, E)) . "'";
         //qty
         $csv[$i - 2][] = "'Каталог, поиск'";
         //visibility
         $csv[$i - 2][] = "'simple'";
         //type
         $csv[$i - 2][] = "'suvenir'";
         //attribute_set
         $csv[$i - 2][] = "'base'";
         //websites
         $csv[$i - 2][] = "'1'";
         //is in stock
         $find_sku = '0';
         if (in_array($data->val($i, B), $skus)) {
             $find_sku = '1';
             $index = array_search($data->val($i, B), $skus);
             if ($index != false or (int) $index == 0) {
                 // echo $data->val($data->val($i,B))."<br/>";
                 unset($skus[(int) $index]);
                 unset($qtys[(int) $index]);
                 unset($prices[(int) $index]);
             }
         }
         if ($find_sku == '0') {
             $csv[$i - 2][] = "'Отключено'";
             //status
             $csv[$i - 2][] = "'Да'";
             //new
         } else {
             $csv[$i - 2][] = "'Включено'";
             //status
             $csv[$i - 2][] = "'Нет'";
         }
     }
     //get old products to invisible
     foreach ($skus as $key => $value) {
         $i++;
         $csv[$i - 2][] = "''";
         //articul
         $csv[$i - 2][] = "'" . $value . "'";
         //sku
         $csv[$i - 2][] = "'" . $prices[(int) $key] . "'";
         //price
         $csv[$i - 2][] = "'" . $qtys[(int) $key] . "'";
         //qty
         $csv[$i - 2][] = "'Каталог, Поиск'";
         //visibility
         $csv[$i - 2][] = "'simple'";
         //type
         $csv[$i - 2][] = "'suvenir'";
         //attribute_set
         $csv[$i - 2][] = "'base'";
         //websites
         $csv[$i - 2][] = "'1'";
         //is in stock
         $csv[$i - 2][] = "'Отключено'";
         //status
         $csv[$i - 2][] = "'Нет'";
         //status
     }
     $file = fopen($root . DS . 'var' . DS . 'import' . DS . 'update_suvenir.csv', 'w');
     foreach ($csv as $line) {
         fputcsv($file, $line, "~");
     }
     fclose($file);
     $data = file_get_contents($root . DS . 'var' . DS . 'import' . DS . 'update_suvenir.csv');
     $data = str_replace('"', "", $data);
//.........这里部分代码省略.........
开发者ID:xiaoguizhidao,项目名称:ortodon,代码行数:101,代码来源:UpdateController.php


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