/** * @magentoAppIsolation enabled */ public function testGetTemplateFile() { Mage::app()->getConfig()->getOptions()->setDesignDir(__DIR__ . DIRECTORY_SEPARATOR . '_files'); // with template $template = 'dummy.phtml'; $this->_block->setTemplate($template); $file = $this->_block->getTemplateFile(); $this->assertContains('frontend', $file); $this->assertStringEndsWith($template, $file); // change area $this->_block->setArea('adminhtml'); $file = $this->_block->getTemplateFile(); $this->assertContains('adminhtml', $file); $this->assertStringEndsWith($template, $file); }
/** * Get absolute path to template * * Load template from adminhtml/default area flag is_simple is set * * @return string */ public function getTemplateFile() { if (!$this->getIsSimple()) { return parent::getTemplateFile(); } //load base template from admin area $params = array('_relative' => true, '_area' => 'adminhtml', '_package' => 'default'); return Mage::getDesign()->getTemplateFilename($this->getTemplate(), $params); }
/** * convert each string which linking to some class or template to ajax link * * @param string $xml * @return string */ public function xmlEncodeAndAddHovers($xml) { $xml = preg_replace(['/<template>(.*?)<\\/template>/ium', '/template="(.*?)"/ium', '/helper="(.*?)"/ium', '/(<.+?type=")(.*?)("[^>]*>)/ium'], ['<template>{{template=$1}}</template>', 'template="{{template=$1}}"', 'helper="{{helper=$1}}"', '$1{{block=$2}}$3'], $xml); $xml = htmlspecialchars($xml); if (Mage::app()->getStore()->isAdmin()) { $routeBase = 'debug/admin_index'; } else { $routeBase = 'debug/index'; } $pattern = '/{{(.*?)}}/ium'; $xml = preg_replace_callback($pattern, function ($matches) use($routeBase) { list($key, $val) = explode('=', $matches[1]); switch ($key) { case 'block': $url = Mage::getUrl($routeBase . '/viewBlock', ['block' => Mage::app()->getConfig()->getBlockClassName($val), '_secure' => Mage::app()->getStore()->isCurrentlySecure()]); $result = '<a class="remoteCall" href="' . $url . '">' . $val . '</a>'; break; case 'helper': $url = Mage::getUrl($routeBase . '/viewBlock', ['block' => Mage::app()->getConfig()->getHelperClassName(preg_replace('/\\/[^\\/]*$/', '', $val)), '_secure' => Mage::app()->getStore()->isCurrentlySecure()]); $result = '<a class="remoteCall" href="' . $url . '">' . $val . '</a>'; break; case 'template': $block = new Mage_Core_Block_Template(); $block->setTemplate($val); $url = Mage::getUrl($routeBase . '/viewTemplate', ['_query' => ['template' => $block->getTemplateFile()], '_secure' => Mage::app()->getStore()->isCurrentlySecure()]); $result = '<a class="remoteCall" href="' . $url . '">' . $val . '</a>'; break; } return $result; }, $xml); return $xml; }