Exemplo n.º 1
0
 public function testGetViewFile()
 {
     $expected = '%s/frontend/package/custom_theme/Fixture_Module/fixture_script.js';
     $params = array('package' => 'package', 'theme' => 'custom_theme');
     $actual = $this->_model->getViewFile('Fixture_Module::fixture_script.js', $params);
     $this->_testExpectedVersusActualFilename($expected, $actual);
 }
Exemplo n.º 2
0
 /**
  * Test for the theme files fallback
  *
  * @param string $themeFile
  * @param array $designParams
  * @param string|null $expectedFilename
  *
  * @dataProvider getThemeFileFallbackDataProvider
  */
 public function testThemeFileFallback($themeFile, array $designParams, $expectedFilename)
 {
     $expectedFilename = str_replace('/', DIRECTORY_SEPARATOR, $expectedFilename);
     $actualFilename = $this->_model->getFilename($themeFile, $designParams);
     if ($expectedFilename) {
         //$this->assertStringMatchesFormat($expectedFilename, $actualFilename);
         $this->assertFileExists($actualFilename);
     } else {
         $this->assertFileNotExists($actualFilename);
     }
 }
Exemplo n.º 3
0
 public function testGetViewFile()
 {
     $params = array('area' => 'some_area', 'package' => 'some_package', 'theme' => 'some_theme', 'locale' => 'some_locale');
     $file = 'Some_Module::some_file.ext';
     $expectedParams = $params + array('module' => 'Some_Module');
     $expected = 'path/to/some_file.ext';
     $this->_model->expects($this->once())->method('_getFallback')->with($expectedParams)->will($this->returnValue($this->_fallback));
     $this->_fallback->expects($this->once())->method('getViewFile')->with('some_file.ext', 'Some_Module')->will($this->returnValue($expected));
     $actual = $this->_model->getViewFile($file, $params);
     $this->assertEquals($expected, $actual);
 }
Exemplo n.º 4
0
 /**
  * @magentoDataFixture Mage/Core/_files/layout_update.php
  */
 public function testMakeTemporaryLayoutUpdatesPermanent()
 {
     /** @var $coreLayoutUpdate Mage_Core_Model_Resource_Layout_Update */
     $coreLayoutUpdate = $this->_objectManager->create('Mage_Core_Model_Resource_Layout_Update');
     $resultBefore = $coreLayoutUpdate->fetchUpdatesByHandle('test_handle');
     $this->assertEquals('not_temporary', $resultBefore);
     /** @var $vdeLayoutUpdate Mage_DesignEditor_Model_Resource_Layout_Update */
     $vdeLayoutUpdate = $this->_objectManager->create('Mage_DesignEditor_Model_Resource_Layout_Update');
     $vdeLayoutUpdate->makeTemporaryLayoutUpdatesPermanent($this->_design->getDesignTheme()->getThemeId(), array(Mage_Core_Model_App::ADMIN_STORE_ID));
     $resultAfter = $coreLayoutUpdate->fetchUpdatesByHandle('test_handle');
     $this->assertEquals('not_temporarytemporary', $resultAfter);
 }
Exemplo n.º 5
0
 protected function _mergeFiles(array $srcFiles, $targetFile = false, $mustMerge = false, $beforeMergeCallback = null, $extensionsFilter = array(), $mimeType = null)
 {
     if (!Mage::helper('magefm_cdn')->isEnabled()) {
         return parent::_mergeFiles($srcFiles, $targetFile, $mustMerge, $beforeMergeCallback, $extensionsFilter);
     }
     return Mage::helper('core')->mergeFiles($srcFiles, $targetFile, $mustMerge, $beforeMergeCallback, $extensionsFilter, $mimeType);
 }
 public function getHtml()
 {
     $htmlId = $this->_getHtmlId() . microtime(true);
     $format = $this->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
     $html = '<div class="range"><div class="range-line date">
         <span class="label">' . AO::helper('adminhtml')->__('From') . ':</span>
         <input type="text" name="' . $this->_getHtmlName() . '[from]" id="' . $htmlId . '_from" value="' . $this->getEscapedValue('from') . '" class="input-text no-changes"/>
         <img src="' . Mage_Core_Model_Design_Package::getDesign()->getSkinUrl('images/grid-cal.gif') . '" alt="" class="v-middle" id="' . $htmlId . '_from_trig" title="' . $this->htmlEscape(AO::helper('adminhtml')->__('Date selector')) . '"/>
         </div>';
     $html .= '<div class="range-line date">
         <span class="label">' . AO::helper('adminhtml')->__('To') . ' :</span>
         <input type="text" name="' . $this->_getHtmlName() . '[to]" id="' . $htmlId . '_to" value="' . $this->getEscapedValue('to') . '" class="input-text no-changes"/>
         <img src="' . Mage_Core_Model_Design_Package::getDesign()->getSkinUrl('images/grid-cal.gif') . '" alt="" class="v-middle" id="' . $htmlId . '_to_trig" title="' . $this->htmlEscape(AO::helper('adminhtml')->__('Date selector')) . '"/>
         </div></div>';
     $html .= '<input type="hidden" name="' . $this->_getHtmlName() . '[locale]" value="' . $this->getLocale()->getLocaleCode() . '"/>';
     $html .= '<script type="text/javascript">
         Calendar.setup({
             inputField : "' . $htmlId . '_from",
             ifFormat : "' . $format . '",
             button : "' . $htmlId . '_from_trig",
             align : "Bl",
             singleClick : true
         });
         Calendar.setup({
             inputField : "' . $htmlId . '_to",
             ifFormat : "' . $format . '",
             button : "' . $htmlId . '_to_trig",
             align : "Bl",
             singleClick : true
         });
     </script>';
     return $html;
 }
 /**
  * JS Calendar html
  *
  * @return string Formatted Html
  */
 public function getCalendarDateHtml()
 {
     // $require = $this->getOption()->getIsRequire() ? ' required-entry' : '';
     $require = '';
     $calendar = $this->getLayout()->createBlock('core/html_date')->setId('options_' . $this->getOption()->getId() . '_date')->setName('options[' . $this->getOption()->getId() . '][date]')->setClass('product-custom-option datetime-picker input-text' . $require)->setImage(Mage_Core_Model_Design_Package::getDesign()->getSkinUrl('images/grid-cal.gif'))->setExtraParams('onchange="opConfig.reloadPrice()"')->setFormat(AO::app()->getLocale()->getDateStrFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT));
     return $calendar->getHtml();
 }
 public function __construct()
 {
     if (method_exists('Mage_Core_Model_Design_Package', '__construct')) {
         parent::__construct();
     }
     foreach (explode(',', Mage::getStoreConfig('dev/js/speedster_minify_blacklist')) as $jsBlacklist) {
         $jsBlacklist = Mage::helper('speedsterAdvanced')->normaliseUrl($jsBlacklist);
         if ($jsBlacklist) {
             $this->_speedsterBlacklists['js']['minify'][$jsBlacklist] = true;
         }
     }
     foreach (explode(',', Mage::getStoreConfig('dev/css/speedster_minify_blacklist')) as $cssBlacklist) {
         $cssBlacklist = Mage::helper('speedsterAdvanced')->normaliseUrl($cssBlacklist);
         if ($cssBlacklist) {
             $this->_speedsterBlacklists['css']['minify'][$cssBlacklist] = true;
         }
     }
     foreach (explode(',', Mage::getStoreConfig('dev/css/speedster_minify_blacklist_secure')) as $cssBlacklist) {
         $cssBlacklist = Mage::helper('speedsterAdvanced')->normaliseUrl($cssBlacklist);
         if ($cssBlacklist) {
             $this->_speedsterBlacklists['css_secure']['minify'][$cssBlacklist] = true;
         }
     }
     if (method_exists($this, '_mergeFiles')) {
         $this->_speedsterMergeFilesMethod = array($this, '_mergeFiles');
     } else {
         $this->_speedsterMergeFilesMethod = array(Mage::helper('core'), 'mergeFiles');
     }
 }
Exemplo n.º 9
0
 protected function _construct()
 {
     parent::_construct();
     Mage_Core_Model_Design_Package::getDesign()->setArea('install')->setPackageName('default')->setTheme('default');
     $this->getLayout()->setArea('install');
     $this->setFlag('', self::FLAG_NO_CHECK_INSTALLATION, true);
 }
Exemplo n.º 10
0
 /**
  * Check for files existence by specified scheme
  *
  * @param string $file
  * @param array &$params
  * @param array $fallbackScheme
  * @return string
  */
 protected function _fallback($file, array &$params, array $fallbackScheme = array(array()))
 {
     if ($params['_area'] !== 'frontend') {
         return parent::_fallback($file, $params, $fallbackScheme);
     } else {
         return parent::_fallback($file, $params, $this->getFallbackScheme($params));
     }
 }
Exemplo n.º 11
0
 /**
  * Utilizes theme fallback to improve the compiler scss imports
  *
  * @param $file
  *
  * @return string
  */
 public function importFallbackFunction($file)
 {
     //@TODO make directory dynamic in some way
     $filepath = parent::getFilename('scss' . DS . $file . '.scss', array('_type' => 'skin'));
     if (!$filepath) {
         $filepath = parent::getFilename('scss' . DS . '_' . $file . '.scss', array('_type' => 'skin'));
     }
     return $filepath;
 }
Exemplo n.º 12
0
 /**
  * Test to get valid html code for 'image' with placeholder
  */
 public function testImagePlaceholder()
 {
     $urlPath = 'http://example.com/pub/images/image-placeholder.png';
     $this->_model->setValue(null);
     $this->_design->expects($this->once())->method('getViewFileUrl')->will($this->returnValue($urlPath));
     $this->_helperData->expects($this->any())->method('escapeHtml')->will($this->returnArgument(0));
     $html = $this->_createHtmlCode('', $urlPath);
     $this->assertXmlStringEqualsXmlString("<test>{$html}</test>", "<test>{$this->_model->getElementHtml()}</test>", 'Another BaseImage html code is expected');
 }
Exemplo n.º 13
0
 /**
  * @param string $themePath
  * @param null $area
  * @return Mage_Core_Utility_Theme
  */
 public function setDesignTheme($themePath, $area = null)
 {
     if (empty($area)) {
         $area = $this->_design->getArea();
     }
     $theme = $this->getThemeByParams($themePath, $area);
     $this->_design->setDesignTheme($theme, $area);
     return $this;
 }
Exemplo n.º 14
0
 /**
  * Replace missing skin images with a placeholder.
  * 
  * @param string $file   The file path.
  * @param array  $params Path resolution parameters.
  * 
  * @return string
  */
 public function validateFile($file, array $params)
 {
     return parent::validateFile($file, $params);
     $filename = parent::validateFile($file, $params);
     if (!$filename && $this->isImage($file)) {
         return Mage::getStoreConfig('imagefill/general/placeholder_url');
     }
     return $filename;
 }
Exemplo n.º 15
0
 /**
  * Add css customization
  *
  * @param Mage_Core_Model_Layout $layout
  * @return Mage_Core_Model_Theme_Service
  */
 protected function _addCssCustomization($layout)
 {
     /** @var $theme Mage_Core_Model_Theme_Files */
     $customCssFile = $this->_design->getDesignTheme()->getCustomCssFile();
     if ($customCssFile->getContent()) {
         $layout->getBlock('head')->addCss($customCssFile->getFilePath());
     }
     return $this;
 }
 protected function _beforeSave()
 {
     $value = $this->getValue();
     if (empty($value)) {
         throw new Exception('package name is empty.');
     }
     if (!Mage_Core_Model_Design_Package::getDesign()->designPackageExists($value)) {
         throw new Exception('package with this name does not exist and cannot be set.');
     }
 }
Exemplo n.º 17
0
 /**
  * Return file path in file system
  *
  * @param bool $fullPath
  * @return string|bool
  */
 public function getFilePath($fullPath = false)
 {
     if (!$this->getId()) {
         return false;
     }
     $filePath = $this->getThemeId() . DIRECTORY_SEPARATOR . $this->getFileName();
     if ($fullPath) {
         $filePath = $this->_design->getCustomizationDir() . DIRECTORY_SEPARATOR . $filePath;
     }
     return $filePath;
 }
Exemplo n.º 18
0
 /**
  * Return a singleton of Design_Package
  */
 public static function getDesign()
 {
     //namespace
     $_s = Mage_Core_Model_Design_Package::$_singleton;
     if ($_s === null) {
         $_s = AO::getModel('core/design_package');
         $_s->setStore(AO::app()->getStore());
     }
     Mage_Core_Model_Design_Package::$_singleton = $_s;
     return Mage_Core_Model_Design_Package::$_singleton;
 }
Exemplo n.º 19
0
 public function getInclude($template, array $variables)
 {
     $filename = Mage_Core_Model_Design_Package::getDesign()->getTemplateFilename($template);
     if (!$filename) {
         return '';
     }
     extract($variables);
     ob_start();
     include $filename;
     return ob_get_clean();
 }
Exemplo n.º 20
0
 /**
  * @param string $file
  * @param string $result
  * @covers Mage_Core_Model_Design_Package::getSkinUrl
  * @dataProvider getSkinUrlDataProvider
  * @magentoConfigFixture current_store dev/static/sign 1
  */
 public function testGetSkinUrlSigned($devMode, $file, $result)
 {
     Mage::setIsDeveloperMode($devMode);
     $url = $this->_model->getSkinUrl($file);
     $this->assertEquals(strpos($url, $result), 0);
     $lastModified = array();
     preg_match('/.*\\?(.*)$/i', $url, $lastModified);
     $this->assertArrayHasKey(1, $lastModified);
     $this->assertEquals(10, strlen($lastModified[1]));
     $this->assertLessThanOrEqual(time(), $lastModified[1]);
     $this->assertGreaterThan(1970, date('Y', $lastModified[1]));
 }
Exemplo n.º 21
0
 /**
  * Get full url for image
  *
  * @param string $imagePath
  *
  * @return string
  */
 protected function _getImageUrl($imagePath)
 {
     if (!in_array($imagePath, array(null, 'no_selection', '/'))) {
         if (pathinfo($imagePath, PATHINFO_EXTENSION) == 'tmp') {
             $imageUrl = $this->_mediaConfig->getTmpMediaUrl(substr($imagePath, 0, -4));
         } else {
             $imageUrl = $this->_mediaConfig->getMediaUrl($imagePath);
         }
     } else {
         $imageUrl = $this->_design->getViewFileUrl('Mage_Adminhtml::images/image-placeholder.png');
     }
     return $imageUrl;
 }
Exemplo n.º 22
0
 /**
  * Changing path for patched layouts
  */
 public function getLayoutFilename($file, array $params = array())
 {
     $filename = parent::getLayoutFilename($file, $params);
     $filenameNew = str_replace(Mage::getBaseDir('app'), Mage::getBaseDir('var') . DS . 'ait_patch', $filename);
     if (file_exists($filenameNew)) {
         $filename = $filenameNew;
     } else {
         $filenameNew = str_replace(DS . 'base' . DS, DS . 'default' . DS, $filenameNew);
         if (file_exists($filenameNew)) {
             $filename = $filenameNew;
         }
     }
     return $filename;
 }
Exemplo n.º 23
0
 public function translateAction()
 {
     if ($translate = $this->getRequest()->getPost('translate')) {
         try {
             if ($area = $this->getRequest()->getPost('area')) {
                 Mage_Core_Model_Design_Package::getDesign()->setArea($area);
             }
             AO::getModel('core/translate_inline')->processAjaxPost($translate);
             echo "{success:true}";
         } catch (Exception $e) {
             echo "{error:true,message:'" . $e->getMessage() . "'}";
         }
     }
     exit;
 }
Exemplo n.º 24
0
 /**
  * Merges files into one and saves it into DB (if DB file storage is on)
  *
  * @see Mage_Core_Helper_Data::mergeFiles()
  * @param array $srcFiles
  * @param string|bool $targetFile - file path to be written
  * @param bool $mustMerge
  * @param callback $beforeMergeCallback
  * @param array|string $extensionsFilter
  * @return bool|string
  */
 protected function _mergeFiles(array $srcFiles, $targetFile = false, $mustMerge = false, $beforeMergeCallback = null, $extensionsFilter = array())
 {
     if (!Mage::helper('uaudio_storage')->isEnabled()) {
         return parent::_mergeFiles($srcFiles, $targetFile, $mustMerge, $beforeMergeCallback, $extensionsFilter);
     }
     $storageModel = Mage::getSingleton('core/file_storage')->getStorageModel();
     if ($storageModel->fileExists($targetFile) && !$mustMerge) {
         return true;
     }
     $result = Mage::helper('core')->mergeFiles($srcFiles, $targetFile, $mustMerge, $beforeMergeCallback, $extensionsFilter);
     if ($result) {
         $storageModel->moveFile($targetFile, $targetFile);
     }
     return $result;
 }
Exemplo n.º 25
0
 /**
  * @magentoConfigFixture current_store dev/js/merge_files 1
  * @magentoAppIsolation enabled
  */
 public function testCleanMergedJsCss()
 {
     $this->assertFileNotExists($this->_pubMerged);
     $this->_model->getOptimalJsUrls(array('calendar/calendar.js', 'scripts.js'));
     $this->assertFileExists($this->_pubMerged);
     $filesFound = false;
     foreach (new RecursiveDirectoryIterator($this->_pubMerged) as $fileInfo) {
         if ($fileInfo->isFile()) {
             $filesFound = true;
         }
     }
     $this->assertTrue($filesFound, 'No files found in the merged directory.');
     $this->_model->cleanMergedJsCss();
     $this->assertFileNotExists($this->_pubMerged);
 }
Exemplo n.º 26
0
 /**
  * Tests what happens when CSS file and its resources are changed - whether they are re-published or not
  *
  * @param bool $expectedPublished
  */
 protected function _testPublishChangedResourcesWhenUnchangedCss($expectedPublished)
 {
     $fixtureSkinPath = self::$_fixtureTmpDir . '/frontend/test/default/skin/default/';
     $publishedPath = self::$_skinPublicDir . '/frontend/test/default/default/en_US/';
     // Prepare temporary fixture directory and publish files from it
     $this->_copyFixtureSkinToTmpDir($fixtureSkinPath);
     $this->_model->getSkinUrl('style.css');
     // Change referenced files
     copy($fixtureSkinPath . 'images/rectangle.gif', $fixtureSkinPath . 'images/square.gif');
     touch($fixtureSkinPath . 'images/square.gif');
     file_put_contents($fixtureSkinPath . 'sub.css', '.sub2 {border: 1px solid magenta}', FILE_APPEND);
     $this->_model->getSkinUrl('style.css');
     $assertFileComparison = $expectedPublished ? 'assertFileEquals' : 'assertFileNotEquals';
     $this->{$assertFileComparison}($fixtureSkinPath . 'sub.css', $publishedPath . 'sub.css');
     $this->{$assertFileComparison}($fixtureSkinPath . 'images/rectangle.gif', $publishedPath . 'images/square.gif');
 }
Exemplo n.º 27
0
 public function getAllOptions($withEmpty = true)
 {
     if (is_null($this->_options)) {
         $design = Mage_Core_Model_Design_Package::getDesign()->getThemeList();
         $options = array();
         foreach ($design as $package => $themes) {
             $packageOption = array('label' => $package);
             $themeOptions = array();
             foreach ($themes as $theme) {
                 $themeOptions[] = array('label' => $theme, 'value' => $package . '/' . $theme);
             }
             $packageOption['value'] = $themeOptions;
             $options[] = $packageOption;
         }
         $this->_options = $options;
     }
     $options = $this->_options;
     if ($withEmpty) {
         array_unshift($options, array('value' => '', 'label' => AO::helper('core')->__('-- Please Select --')));
     }
     return $options;
 }
Exemplo n.º 28
0
 /**
  * Test changed resources, referenced in non-modified CSS file, are re-published
  * @magentoAppIsolation enabled
  */
 public function testPublishChangedResourcesWhenUnchangedCss()
 {
     $fixtureSkinPath = self::$_fixtureTmpDir . '/frontend/test/default/skin/default/';
     $publishedPath = self::$_skinPublicDir . '/frontend/test/default/default/en_US/';
     // Prepare temporary fixture directory and publish files from it
     $this->_copyFixtureSkinToTmpDir($fixtureSkinPath);
     $this->_model->getSkinUrl('style.css');
     // Change referenced files
     copy($fixtureSkinPath . 'images/rectangle.gif', $fixtureSkinPath . 'images/square.gif');
     touch($fixtureSkinPath . 'images/square.gif');
     file_put_contents($fixtureSkinPath . 'sub.css', '.sub2 {border: 1px solid magenta}', FILE_APPEND);
     // Without developer mode nothing must be re-published
     Mage::setIsDeveloperMode(false);
     $this->_model->getSkinUrl('style.css');
     $this->assertFileNotEquals($fixtureSkinPath . 'sub.css', $publishedPath . 'sub.css');
     $this->assertFileNotEquals($fixtureSkinPath . 'images/rectangle.gif', $publishedPath . 'images/square.gif');
     // With developer mode all changed files must be re-published
     Mage::setIsDeveloperMode(true);
     $this->_model->getSkinUrl('style.css');
     $this->assertFileEquals($fixtureSkinPath . 'sub.css', $publishedPath . 'sub.css');
     $this->assertFileEquals($fixtureSkinPath . 'images/rectangle.gif', $publishedPath . 'images/square.gif');
 }
Exemplo n.º 29
0
 /**
  * Filename of css file or compiled css from sass file
  * This method is important for using css merging feature
  *
  * @param string $file
  * @param array $params
  * @return string
  */
 public function getFilename($file, array $params)
 {
     $filename = parent::getFilename($file, $params);
     if ($this->_isSassFile($file)) {
         try {
             if (Mage::app()->useCache('sass')) {
                 $cacheKey = $this->getCacheKey($filename);
                 $compiledFilename = Mage::app()->loadCache($cacheKey);
                 if (!$compiledFilename) {
                     $compiledFilename = $this->convertToCss($filename);
                     Mage::app()->saveCache($compiledFilename, $cacheKey, array('sass'), 86400);
                 }
             } else {
                 $compiledFilename = $this->convertToCss($filename);
             }
             $filename = $compiledFilename;
         } catch (Exception $e) {
             Mage::logException($e);
             $filename = '';
         }
     }
     return $filename;
 }
 public function __construct()
 {
     if (method_exists(get_parent_class($this), '__construct')) {
         parent::__construct();
     }
     foreach (explode(',', Mage::getStoreConfig('dev/js/speedster_minify_blacklist')) as $jsBlacklist) {
         $jsBlacklist = Mage::helper('speedsterAdvanced')->normaliseUrl($jsBlacklist);
         if ($jsBlacklist) {
             $this->_speedsterBlacklists['js']['minify'][$jsBlacklist] = true;
         }
     }
     foreach (explode(',', Mage::getStoreConfig('dev/css/speedster_minify_blacklist')) as $cssBlacklist) {
         $cssBlacklist = Mage::helper('speedsterAdvanced')->normaliseUrl($cssBlacklist);
         if ($cssBlacklist) {
             $this->_speedsterBlacklists['css']['minify'][$cssBlacklist] = true;
         }
     }
     foreach (explode(',', Mage::getStoreConfig('dev/css/speedster_minify_blacklist_secure')) as $cssBlacklist) {
         $cssBlacklist = Mage::helper('speedsterAdvanced')->normaliseUrl($cssBlacklist);
         if ($cssBlacklist) {
             $this->_speedsterBlacklists['css_secure']['minify'][$cssBlacklist] = true;
         }
     }
 }