public function uploadPostAction() { try { if (!isset($_FILES['template'])) { throw new Mage_Exception($this->__("No template file selected")); } $file = $_FILES['template']; if ($file['error']['file'] !== UPLOAD_ERR_OK) { throw new Mage_Exception($this->__("Error when uploading template (#%s)", $file['error']['file'])); } $template = $this->_initTemplate(); $template->loadFromFile($file['tmp_name']['file']); $template->save(); if (version_compare($template->getVersion(), Mage::helper('mzax_emarketing')->getVersion()) < 0) { $this->_getSession()->addWarning($this->__("The template you just uploaded was made with version %s, you only have version %s of Mzax Emarketing. This might cause an issue.")); } $this->_getSession()->addSuccess($this->__("Template successfully uploaded.")); $this->_redirect('*/*/edit', array('id' => $template->getId())); return; } catch (Mage_Exception $e) { $this->_getSession()->addError($e->getMessage()); } catch (Exception $e) { if (Mage::getIsDeveloperMode()) { throw $e; } Mage::logException($e); $this->_getSession()->addError($this->__("There was an error uploading the template.")); } $this->_redirect('*/*/index'); }
/** * Initializes the aspect kernel. * * @return void */ public function initializeAspectKernel() { $cacheTypes = Mage::app()->useCache(); $aspectKernel = Danslo_Aop_Aspect_Kernel::getInstance(); $aspectKernel->init(array('debug' => Mage::getIsDeveloperMode() || empty($cacheTypes[self::AOP_CACHE_TYPE]), 'cacheDir' => $this->_getCacheDir())); self::$initialized = true; }
public function dispatch($action) { try { $this->getRequest()->isGet() && !$this->getRequest()->isPost() && !$this->getRequest()->isXmlHttpRequest() && $this->updateDomainBackup(); Mage::helper('M2ePro/Exception')->setFatalErrorHandler(); return parent::dispatch($action); } catch (Exception $exception) { if ($this->getRequest()->getControllerName() == 'adminhtml_support') { exit($exception->getMessage()); } else { if (Mage::getIsDeveloperMode()) { throw $exception; } else { try { Mage::helper('M2ePro/Exception')->process($exception, true); } catch (Exception $exceptionTemp) { } if (($this->getRequest()->isGet() || $this->getRequest()->isPost()) && !$this->getRequest()->isXmlHttpRequest()) { $this->_getSession()->addError(Mage::helper('M2ePro/Exception')->getUserMessage($exception)); $this->_redirect('*/adminhtml_support/index'); } else { exit($exception->getMessage()); } } } } }
protected function _addData($data, $scope, $forceReload = false, $translationSource = null) { foreach ($data as $key => $value) { if ($key === $value) { continue; } $key = $this->_prepareDataString($key); $value = $this->_prepareDataString($value); if ($scope && isset($this->_dataScope[$key]) && !$forceReload) { /** * Checking previos value */ $scopeKey = $this->_dataScope[$key] . self::SCOPE_SEPARATOR . $key; if (!isset($this->_data[$scopeKey])) { if (isset($this->_data[$key])) { $this->_data[$scopeKey] = $this->_data[$key]; /** * Not allow use translation not related to module */ if (Mage::getIsDeveloperMode()) { unset($this->_data[$key]); } } } $scopeKey = $scope . self::SCOPE_SEPARATOR . $key; $this->_data[$scopeKey] = $value; } else { $this->_data[$key] = $value; $this->_dataScope[$key] = $scope; } } return $this; }
protected function _prepareColumns() { $this->addColumn('product_id', array('header' => Mage::helper('M2ePro')->__('Product ID'), 'align' => 'right', 'width' => '100px', 'type' => 'number', 'index' => 'product_id', 'filter_index' => 'main_table.product_id', 'frame_callback' => array($this, 'callbackColumnProductId'))); $this->addColumn('name', array('header' => Mage::helper('M2ePro')->__('Product Title / SKU'), 'align' => 'left', 'type' => 'text', 'index' => 'value', 'filter_index' => 'cpev.value', 'frame_callback' => array($this, 'callbackColumnProductTitle'), 'filter_condition_callback' => array($this, 'callbackFilterTitle'))); $this->addColumn('stock_availability', array('header' => Mage::helper('M2ePro')->__('Stock Availability'), 'width' => '100px', 'index' => 'is_in_stock', 'filter_index' => 'cisi.is_in_stock', 'type' => 'options', 'sortable' => false, 'options' => array(1 => Mage::helper('M2ePro')->__('In Stock'), 0 => Mage::helper('M2ePro')->__('Out of Stock')), 'frame_callback' => array($this, 'callbackColumnStockAvailability'))); $this->addColumn('ebay_item_id', array('header' => Mage::helper('M2ePro')->__('eBay Item ID'), 'align' => 'left', 'width' => '100px', 'type' => 'text', 'index' => 'item_id', 'filter_index' => 'ebit.item_id', 'frame_callback' => array($this, 'callbackColumnEbayItemId'))); $this->addColumn('ebay_available_qty', array('header' => Mage::helper('M2ePro')->__('eBay Available QTY'), 'align' => 'right', 'width' => '50px', 'type' => 'number', 'index' => 'ebay_qty_sold', 'filter' => false, 'sortable' => false, 'filter_index' => 'main_table.ebay_qty_sold', 'frame_callback' => array($this, 'callbackColumnEbayAvailableQty'))); $this->addColumn('ebay_qty_sold', array('header' => Mage::helper('M2ePro')->__('eBay Sold QTY'), 'align' => 'right', 'width' => '50px', 'type' => 'number', 'index' => 'ebay_qty_sold', 'filter_index' => 'main_table.ebay_qty_sold', 'frame_callback' => array($this, 'callbackColumnEbayQtySold'))); if ($this->sellingFormatTemplate->isListingTypeAuction() || $this->sellingFormatTemplate->isListingTypeAttribute()) { $this->addColumn('ebay_start_price', array('header' => Mage::helper('M2ePro')->__('"Start" Price'), 'align' => 'right', 'width' => '50px', 'type' => 'number', 'index' => 'ebay_start_price', 'filter_index' => 'main_table.ebay_start_price', 'frame_callback' => array($this, 'callbackColumnStartPrice'))); /*$this->addColumn('ebay_reserve_price', array( 'header' => Mage::helper('M2ePro')->__('"Reserve" Price'), 'align' =>'right', 'width' => '50px', 'type' => 'number', 'index' => 'ebay_reserve_price', 'filter_index' => 'main_table.ebay_reserve_price', 'frame_callback' => array($this, 'callbackColumnReservePrice') ));*/ } $this->addColumn('ebay_buyitnow_price', array('header' => Mage::helper('M2ePro')->__('"Buy It Now" Price'), 'align' => 'right', 'width' => '50px', 'type' => 'number', 'index' => 'ebay_buyitnow_price', 'filter_index' => 'main_table.ebay_buyitnow_price', 'frame_callback' => array($this, 'callbackColumnBuyItNowPrice'))); $this->addColumn('status', array('header' => Mage::helper('M2ePro')->__('Status'), 'width' => '100px', 'index' => 'status', 'filter_index' => 'main_table.status', 'type' => 'options', 'sortable' => false, 'options' => array(Ess_M2ePro_Model_ListingsProducts::STATUS_NOT_LISTED => Mage::helper('M2ePro')->__('Not Listed'), Ess_M2ePro_Model_ListingsProducts::STATUS_LISTED => Mage::helper('M2ePro')->__('Listed'), Ess_M2ePro_Model_ListingsProducts::STATUS_SOLD => Mage::helper('M2ePro')->__('Sold'), Ess_M2ePro_Model_ListingsProducts::STATUS_STOPPED => Mage::helper('M2ePro')->__('Stopped'), Ess_M2ePro_Model_ListingsProducts::STATUS_FINISHED => Mage::helper('M2ePro')->__('Finished')), 'frame_callback' => array($this, 'callbackColumnStatus'))); $this->addColumn('ebay_end_date', array('header' => Mage::helper('M2ePro')->__('eBay End Date'), 'align' => 'right', 'width' => '130px', 'type' => 'datetime', 'format' => Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM), 'index' => 'ebay_end_date', 'filter_index' => 'main_table.ebay_end_date', 'frame_callback' => array($this, 'callbackColumnEbayEndTime'))); if (Mage::getIsDeveloperMode()) { $this->addColumn('developer_action', array('header' => Mage::helper('M2ePro')->__('Actions'), 'align' => 'left', 'width' => '100px', 'type' => 'text', 'index' => 'value', 'filter' => false, 'sortable' => false, 'filter_index' => 'cpev.value', 'frame_callback' => array($this, 'callbackColumnDeveloperAction'))); } return parent::_prepareColumns(); }
/** * @param Varien_Event_Observer $observer */ public function detect(Varien_Event_Observer $observer) { $stores = $this->getHelper()->getStoreUrlOptionsAsArray(); if ($lastUrl = $this->getSession()->getData('last_url')) { $parsedUrl = $this->getCoreUrl()->parseUrl($lastUrl); $scheme = $parsedUrl->getData('scheme'); $host = $parsedUrl->getData('host'); $currentUrl = $scheme . '://' . $host; /** * if in developer mode, we will concatenate the url by two parts of the url path * the url will be the developer ${scheme+host} + ${storeCode} if magento * runs on a virtual host, and ${scheme+host} + ${magentoRoot}+ ${storeCode} if otherwise. */ if (Mage::getIsDeveloperMode()) { $pathParts = explode('/', ltrim($parsedUrl->getData('path'), '/')); if ($this->getHelper()->isVirtualHost()) { $currentUrl .= "/{$pathParts[0]}"; } else { $currentUrl .= "/{$pathParts[0]}/{$pathParts[1]}"; } } $storeCode = ''; foreach ($stores as $store) { if (rtrim($currentUrl, '/') == rtrim($store['store_url'], '/')) { $storeCode = $store['store_code']; break; } } $this->getSession()->setData('old_store', $storeCode); } }
/** * Logging for Feed exporter * @param string $message * @param int $level ZEND_LOG log level * @param boolean $bDeveloperModeOnly True to log only in Developer mode */ public function log($message, $level = Zend_Log::INFO, $bDeveloperModeOnly = false) { if ($bDeveloperModeOnly == false || $bDeveloperModeOnly == true && Mage::getIsDeveloperMode()) { Mage::log($message, $level, self::LOG_FILE); } return $this; }
/** * Render placeholder tags around the block if needed * * Modified to not save JS to container cache. * Rely on the fact that JS is being moved to the end of the page * and that the JS is not changed after initial generation. * * @param Varien_Event_Observer $observer * * @return Enterprise_PageCache_Model_Observer */ public function renderBlockPlaceholder(Varien_Event_Observer $observer) { if (!$this->_isEnabled) { return $this; } $block = $observer->getEvent()->getBlock(); $transport = $observer->getEvent()->getTransport(); $placeholder = $this->_config->getBlockPlaceholder($block); if ($transport && $placeholder && !$block->getSkipRenderTag()) { $blockHtml = $transport->getHtml(); $request = Mage::app()->getFrontController()->getRequest(); /** @var $processor Enterprise_PageCache_Model_Processor_Default */ $processor = $this->_processor->getRequestProcessor($request); if ($processor && $processor->allowCache($request)) { $container = $placeholder->getContainerClass(); if ($container && !Mage::getIsDeveloperMode()) { $container = new $container($placeholder); $container->setProcessor(Mage::getSingleton('enterprise_pagecache/processor')); $container->setPlaceholderBlock($block); // Modify to not save block with JS in it as JS is being moved to the end of the page. $footerJs = Mage::helper('meanbee_footerjs'); $container->saveCache($footerJs->removeJs($blockHtml)); } } $blockHtml = $placeholder->getStartTag() . $blockHtml . $placeholder->getEndTag(); $transport->setHtml($blockHtml); } return $this; }
/** * Send all messages in a queue * * @return Mage_Core_Model_Email_Queue */ public function send() { /** @var $collection Mage_Core_Model_Resource_Email_Queue_Collection */ $collection = Mage::getModel('core/email_queue')->getCollection()->addOnlyForSendingFilter()->setPageSize(self::MESSAGES_LIMIT_PER_CRON_RUN)->setCurPage(1)->load(); ini_set('SMTP', Mage::getStoreConfig('system/smtp/host')); ini_set('smtp_port', Mage::getStoreConfig('system/smtp/port')); /** @var $message Mage_Core_Model_Email_Queue */ foreach ($collection as $message) { if ($message->getId()) { $parameters = new Varien_Object($message->getMessageParameters()); if ($parameters->getReturnPathEmail() !== null) { $mailTransport = new Zend_Mail_Transport_Sendmail("-f" . $parameters->getReturnPathEmail()); Zend_Mail::setDefaultTransport($mailTransport); } $mailer = new Zend_Mail('utf-8'); foreach ($message->getRecipients() as $recipient) { list($email, $name, $type) = $recipient; switch ($type) { case self::EMAIL_TYPE_BCC: $mailer->addBcc($email, '=?utf-8?B?' . base64_encode($name) . '?='); break; case self::EMAIL_TYPE_TO: case self::EMAIL_TYPE_CC: default: $mailer->addTo($email, '=?utf-8?B?' . base64_encode($name) . '?='); break; } } if ($parameters->getIsPlain()) { $mailer->setBodyText($message->getMessageBody()); } else { $mailer->setBodyHTML($message->getMessageBody()); } $mailer->setSubject('=?utf-8?B?' . base64_encode($parameters->getSubject()) . '?='); $mailer->setFrom($parameters->getFromEmail(), $parameters->getFromName()); if ($parameters->getReplyTo() !== null) { $mailer->setReplyTo($parameters->getReplyTo()); } if ($parameters->getReturnTo() !== null) { $mailer->setReturnPath($parameters->getReturnTo()); } try { //$mailer->send(); $mailer->send(Mage::helper('smtp')->getTransport()); unset($mailer); $message->setProcessedAt(Varien_Date::formatDate(true)); $message->save(); } catch (Exception $e) { unset($mailer); $oldDevMode = Mage::getIsDeveloperMode(); Mage::setIsDeveloperMode(true); Mage::logException($e); Mage::setIsDeveloperMode($oldDevMode); return false; } } } return $this; }
protected function setUp() { parent::setUp(); $this->_block = new Mage_Downloadable_Block_Adminhtml_Catalog_Product_Edit_Tab_Downloadable_Samples(); $this->_oldDisplayErrors = ini_get('display_errors'); $this->_oldErrorLevel = error_reporting(); $this->_oldIsDeveloperMode = Mage::getIsDeveloperMode(); }
/** * Ensure dev mode for manual feed generation. */ public function preDispatch() { parent::preDispatch(); if (!Mage::getIsDeveloperMode()) { $this->norouteAction(); $this->setFlag('', 'no-dispatch', true); } }
/** * @return bool */ public function isDebug() { if ($this->isAppInited()) { return Mage::getStoreConfigFlag(self::XML_PATH_DEBUG); } else { return Mage::getIsDeveloperMode(); } }
protected function setUp() { parent::setUp(); $this->_object = new Stub_UnitTest_Mage_Catalog_Model_Resource_Product_Option_Value(); $this->_oldDisplayErrors = ini_get('display_errors'); $this->_oldErrorLevel = error_reporting(); $this->_oldIsDeveloperMode = Mage::getIsDeveloperMode(); }
protected function setUp() { parent::setUp(); $this->_object = new Stub_UnitTest_Mage_ImportExport_Model_Export_Entity_Product(); $this->_oldDisplayErrors = ini_get('display_errors'); $this->_oldErrorLevel = error_reporting(); $this->_oldIsDeveloperMode = Mage::getIsDeveloperMode(); }
public static function setUpBeforeClass() { $fixtureDir = dirname(__DIR__) . DIRECTORY_SEPARATOR . '_files'; Mage::app()->getConfig()->getOptions()->setDesignDir($fixtureDir . DIRECTORY_SEPARATOR . 'design'); Varien_Io_File::rmdirRecursive(Mage::app()->getConfig()->getOptions()->getMediaDir() . '/skin'); $ioAdapter = new Varien_Io_File(); $ioAdapter->cp(Mage::app()->getConfig()->getOptions()->getJsDir() . '/prototype/prototype.js', Mage::app()->getConfig()->getOptions()->getJsDir() . '/prototype/prototype.min.js'); self::$_developerMode = Mage::getIsDeveloperMode(); }
/** * Logging for import interface * @param string $message * @param int $level ZEND_LOG log level * @param boolean $bDeveloperModeOnly True to log only in Developer mode */ public function log($message, $level = Zend_Log::INFO, $bDeveloperModeOnly = false) { if ($bDeveloperModeOnly == false || $bDeveloperModeOnly == true && Mage::getIsDeveloperMode()) { Mage::log($message, $level, $this->getLogPath()); } if ($level <= $this->_iEmailLogLevel) { $this->_aEmailMessages[] = $this->_oFormatter->format(array('timestamp' => date('c'), 'message' => $message, 'priority' => $level, 'priorityName' => $this->_getNameForLevel($level))); } }
public static function setUpBeforeClass() { $mediaDir = Mage::app()->getConfig()->getOptions()->getMediaDir(); $filesystem = Mage::getObjectManager()->create('Magento_Filesystem'); $filesystem->delete($mediaDir . '/theme/frontend'); $filesystem->delete($mediaDir . '/theme/_merged'); $ioAdapter = new Varien_Io_File(); $ioAdapter->cp(Mage::app()->getConfig()->getOptions()->getJsDir() . '/prototype/prototype.js', Mage::app()->getConfig()->getOptions()->getJsDir() . '/prototype/prototype.min.js'); self::$_developerMode = Mage::getIsDeveloperMode(); }
/** * Initializes the aspect kernel. * * @return void */ public static function initializeAspectKernel() { if (self::$initialized) { return; } $cacheTypes = Mage::app()->useCache(); $aspectKernel = Danslo_Aop_Aspect_Kernel::getInstance(); $aspectKernel->init(array('debug' => Mage::getIsDeveloperMode() || empty($cacheTypes[self::AOP_CACHE_TYPE]), 'cacheDir' => self::_getCacheDir(), 'excludePaths' => [Mage::getBaseDir() . DS . 'vendor' . DS . 'phpunit', Mage::getBaseDir() . DS . 'app'])); self::$initialized = true; }
public function merge($observer) { try { $this->getModel()->deleteByQuoteId($observer->getSource()->getID()); } catch (Exception $e) { if (Mage::getIsDeveloperMode()) { echo $e->getMessage(); } Mage::logException($e); } }
public function preDispatch() { parent::preDispatch(); if (!Mage::getIsDeveloperMode()) { $this->setFlag('', self::FLAG_NO_DISPATCH, true); $this->_redirect('/'); return; } header("Content-Type: text/plain; charset=utf8"); ini_set('html_errors', false); ob_implicit_flush(true); }
public function printDebugData() { if (!Mage::getIsDeveloperMode()) { return; } parent::printDebugData(); if (count($this->parsedResponseData) > 0) { echo '<h1>Parsed Response:</h1>', '<pre>'; var_dump($this->parsedResponseData); echo '</pre>'; } }
public function fetchView($fileName) { // This is so we do not need to keep templates // outside of the extension code. $class_parts = explode("_", __CLASS__); $dev_template_path = Mage::getModuleDir('', $class_parts[0] . "_" . $class_parts[1]) . DS . "templates"; if (Mage::getIsDeveloperMode() && file_exists($dev_template_path . DS . $fileName)) { Mage::log("NOTE: Loading template from development path - not the design directory"); $this->setScriptPath($dev_template_path); } else { $this->setScriptPath(Mage::getBaseDir('design')); } return parent::fetchView($fileName); }
protected function _beforeToHtml() { try { $this->_prepareToRender(); $this->setIsValid(true); } catch (Exception $e) { $this->setIsValid(false); $this->setInvalidStateMessage($e->getMessage()); if (Mage::getIsDeveloperMode()) { Mage::logException($e); } else { throw $e; } } }
public function setUp() { parent::setUp(); $this->setBrowser('firefox'); $this->setBrowserUrl(Mage::getBaseUrl()); $this->setUpSessionStrategy(null); // Default Browser-Size $this->prepareSession()->currentWindow()->size(array('width' => 1280, 'height' => 1024)); self::initFrontend(1); if (Mage::getIsDeveloperMode()) { self::$_defaultSleep = 7; } $this->disableCaches(); $this->setConfigMagento(); $this->setMundipaggConfig(); $this->createSimpleProduct(); }
/** * Returns a string of problems that occured after any installation scripts were run through this helper * @return string message to display to the user */ public function getProblemsString() { $msg = $this->__("The following errors occured while trying to install the module."); $msg .= "\n<br>"; foreach ($this->ex_stack as $ex_i => $ex) { $msg .= "<b>#{$ex_i}: </b>"; if (Mage::getIsDeveloperMode()) { $msg .= nl2br($ex); } else { $msg .= $ex->getMessage(); } $msg .= "\n<br>"; } $msg .= "\n<br>"; $msg .= $this->__("If any of these problems were unexpected, I recommend that you contact the module support team to avoid problems in the future."); return $msg; }
public function parse($all = false) { $lock = Mage::helper('mzax_emarketing')->lock('parse_user_agent'); if (!$lock) { return; } $adapter = $this->_getWriteAdapter(); $select = $adapter->select(); $select->from($this->getMainTable(), array('useragent_id', 'useragent')); if (!$all) { $select->where('parsed = 0'); } $useragents = $adapter->fetchPairs($select); $regexFile = Mage::getModuleDir('data', 'Mzax_Emarketing') . DS . 'useragent_regexes.php'; if (!file_exists($regexFile)) { throw new Exception("Regex file for UAParser not found ({$regexFile})"); } $parser = UAParser_Parser::create($regexFile); foreach ($useragents as $id => $ua) { try { $result = $parser->parse($ua); $bind = array('ua' => $result->ua->family, 'ua_version' => $result->ua->major, 'os' => $result->os->family, 'os_version' => $result->os->major, 'device' => $result->device->family, 'device_brand' => $result->device->brand, 'device_type' => 'Unknown', 'parsed' => 1); foreach ($this->_deviceTypes as $key => $types) { foreach ($types as $type => $regex) { if (isset($bind[$key])) { if (preg_match($regex, $bind[$key])) { $bind['device_type'] = $type; break 2; } } } } $adapter->update($this->getMainTable(), $bind, $adapter->quoteInto('useragent_id = ?', $id)); $lock->touch(); } catch (Exception $e) { Mage::logException($e); if (Mage::getIsDeveloperMode()) { $lock->unlock(); throw $e; } } } $lock->unlock(); return $this; }
public function collectInformation($observer) { if (!$this->_isOn($observer)) { return; } $collection = $this->getCollector(); $system_info = new stdClass(); $system_info->ajax_path = $this->getUrl(); if (!$this->getShim()->isMage2() && Mage::getIsDeveloperMode()) { Moeroas_Commercebug_Model_Crossareaajax::validateControllers(); } $system_info->ajax_paths = new stdClass(); $system_info->form_key = $this->getShim()->getSingleton('core/session')->getFormKey(); foreach (Moeroas_Commercebug_Model_Crossareaajax::getAjaxActionNames() as $action) { $system_info->ajax_paths->{$action} = $this->createAjaxUrl($action); } $this->_items['system_info'] = $system_info; }
/** * Block Factory * * @param string $type * @param string $blockName * @param array $attributes * @return Mage_Core_Block_Abstract */ public function createBlock($type, $name = '', array $attributes = array()) { try { $block = $this->_getBlockInstance($type, $attributes); $module = Mage::app()->getRequest()->getRequestedRouteName(); $controller = Mage::app()->getRequest()->getRequestedControllerName(); $action = Mage::app()->getRequest()->getRequestedActionName(); $exceptionblocks = ''; $exceptionblocks = Mage::app()->getConfig()->getNode(self::XML_PATH_CED_REWRITES . "/" . $module . "/" . $controller . "/" . $action); if (strlen($exceptionblocks) == 0) { $action = "all"; $exceptionblocks = Mage::app()->getConfig()->getNode(self::XML_PATH_CED_REWRITES . "/" . $module . "/" . $controller . "/" . $action); } if (strlen($exceptionblocks) > 0) { $exceptionblocks = explode(",", $exceptionblocks); if (count($exceptionblocks) > 0) { foreach ($exceptionblocks as $exceptionblock) { if (strpos(get_class($block), $exceptionblock) !== false) { $block->setArea('adminhtml'); } } } } } catch (Exception $e) { Mage::logException($e); return false; } if (empty($name) || '.' === $name[0]) { $block->setIsAnonymous(true); if (!empty($name)) { $block->setAnonSuffix(substr($name, 1)); } $name = 'ANONYMOUS_' . sizeof($this->_blocks); } elseif (isset($this->_blocks[$name]) && Mage::getIsDeveloperMode()) { //Mage::throwException(Mage::helper('core')->__('Block with name "%s" already exists', $name)); } $block->setType($type); $block->setNameInLayout($name); $block->addData($attributes); $block->setLayout($this); $this->_blocks[$name] = $block; Mage::dispatchEvent('core_layout_block_create_after', array('block' => $block)); return $this->_blocks[$name]; }
/** * Create a new css file based on sass file * @param string $sourceFilePath * @param string $targetFilenamePath * @throws Exception */ public function createNewCss($sourceFilePath, $targetFilenamePath, $importFallback = null) { $config = $this->_getConfig(); $targetDir = dirname($targetFilenamePath); $this->_createDir($targetDir); $this->_createDir($config['cache_dir']); if ($config['use_ruby']) { $options = '--cache-location ' . $config['cache_dir'] . ' --style ' . $config['output_style']; if ($config['debug']) { $options .= ' --debug-info --line-numbers'; } $command = $config['sass_command'] . ' ' . $options . ' ' . $sourceFilePath . ':' . $targetFilenamePath; $execResult = exec($command, $output); if ($execResult != '') { throw new Exception("Error while processing sass file with command '{$command}':\n" . implode("\n", $output)); } } else { /** @var \Leafo\ScssPhp\Compiler $compiler */ $compiler = new \Leafo\ScssPhp\Compiler(); switch ($config['output_style']) { case Laurent_Sass_Model_Config_Style::STYLE_COMPACT: default: $formatter = \Leafo\ScssPhp\Formatter\Compact::class; break; case Laurent_Sass_Model_Config_Style::STYLE_NESTED: $formatter = \Leafo\ScssPhp\Formatter\Nested::class; break; case Laurent_Sass_Model_Config_Style::STYLE_COMPRESSED: $formatter = \Leafo\ScssPhp\Formatter\Compressed::class; break; case Laurent_Sass_Model_Config_Style::STYLE_EXPANDED: $formatter = \Leafo\ScssPhp\Formatter\Expanded::class; break; } if (Mage::getIsDeveloperMode()) { $compiler->setLineNumberStyle(Leafo\ScssPhp\Compiler::LINE_COMMENTS); } $compiler->setFormatter($formatter); $compiler->setImportPaths(array(dirname($sourceFilePath), Mage::getBaseDir('lib') . '/scssphp/stylesheets', $importFallback)); file_put_contents($targetFilenamePath, $compiler->compile(sprintf('@import "%s"', basename($sourceFilePath)))); } }
/** * Checks if the current request is allowed. * * @param Zend_Controller_Request_Http $request * @return bool */ public function isAllowedToViewPage(Zend_Controller_Request_Http $request) { // Is developermode is enabled? if (Mage::getIsDeveloperMode()) { return true; } $transport = new Varien_Object(); $transport->setData('is_allowed', true); Mage::dispatchEvent('ho_offlinemaintenance_is_allowed', array('transport' => $transport)); if (!$transport->getData('is_allowed')) { return false; } if (!Mage::helper('ho_offlinemaintenance')->isOffline()) { return true; } // Is the ip allowed by the client restriction? /** @var $coreHelper Mage_Core_Helper_Data */ $coreHelper = Mage::helper('core/data'); if (Mage::getStoreConfig(Mage_Core_Helper_Data::XML_PATH_DEV_ALLOW_IPS, $request->getStoreCodeFromPath()) && $coreHelper->isDevAllowed()) { return true; } // Is the path always allowed? $excludePaths = Mage::helper('ho_offlinemaintenance/arrayfield_exclude')->getConfigValue(); $currentPath = Mage::app()->getRequest()->getPathInfo(); $excluded = false; foreach ($excludePaths as $excludePath) { if (strpos($currentPath, $excludePath['url_path']) === 0) { $excluded = true; } } if ($excluded) { return true; } // Is user logged into the admin panel? Mage::getSingleton('core/session', array('name' => 'adminhtml')); /** @var $adminSession Mage_Admin_Model_Session */ $adminSession = Mage::getSingleton('admin/session'); if ($adminSession->isLoggedIn()) { return true; } return false; }