示例#1
0
 public function setTemplate($template)
 {
     if (!Mage::helper('magenotification')->checkLicenseKey('Membership')) {
         return $this;
     }
     return parent::setTemplate($template);
 }
 public function manejandobloquesAction()
 {
     $block_1 = new Mage_Core_Block_Text();
     $block_1->setText('Original Text');
     $block_2 = new Mage_Core_Block_Text();
     $block_2->setText('The second sentence.');
     $main_block = new Mage_Core_Block_Template();
     $main_block->setTemplate('nofrills/manejandobloques.phtml');
     $main_block->setChild('the_first', $block_1);
     $main_block->setChild('the_second', $block_2);
     $block_1->setText('Wait , I want this text instead .');
     echo $main_block->toHtml();
 }
 public function searchConfigAction()
 {
     if ($this->getRequest()->isPost()) {
         $result['error'] = 0;
         $query = $this->getRequest()->getPost('query');
         if (!empty($query)) {
             $configs = Mage::app()->getConfig()->getNode($query);
             $items = array();
             Magneto_Debug_Block_Config::xml2array($configs, $items, $query);
             $block = new Mage_Core_Block_Template();
             //Is this the correct way?
             $block->setTemplate('debug/configsearch.phtml');
             $block->assign('items', $items);
             echo $block->toHtml();
         } else {
             $result['error'] = 1;
             $result['message'] = 'Search query cannot be empty.';
         }
     }
 }
 /**
  * Return last 100 lines of log file
  *
  * @return string
  */
 public function viewLogAction()
 {
     $file = $this->getRequest()->getParam('file');
     if (!empty($file)) {
         $result = Mage::helper('debug')->getLastRows(Mage::getBaseDir() . '/var/log/' . $file, 10);
         if (!is_array($result)) {
             $result = array($result);
         }
         $block = new Mage_Core_Block_Template();
         //Is this the correct way?
         $block->setTemplate('debug/logdetails.phtml');
         $block->assign('title', 'Log details : ' . $file);
         $block->assign('items', $result);
         echo $block->toHtml();
     }
 }
示例#5
0
文件: Rating.php 项目: rcclaudrey/dev
 /**
  * @param int $countStars
  *
  * @return string
  */
 protected function getLabelHtml($countStars)
 {
     if ($countStars == 6) {
         return Mage::helper('amshopby')->__(self::NOT_RATED_LABEL);
     }
     $block = new Mage_Core_Block_Template();
     $block->setStar($countStars);
     $html = $block->setTemplate('amasty/amshopby/rating.phtml')->toHtml();
     return $html;
 }
示例#6
0
 /**
  * @covers Mage_Core_Block_Template::_toHtml
  * @covers Mage_Core_Block_Abstract::toHtml
  * @see testAssign()
  */
 public function testToHtml()
 {
     $this->assertEmpty($this->_block->toHtml());
     $this->_block->setTemplate(uniqid('invalid_filename.phtml'));
     $this->assertEmpty($this->_block->toHtml());
 }
示例#7
0
 /**
  * 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;
 }
 /**
  * @param int $countStars
  *
  * @return string
  */
 protected function getLabelHtml($countStars)
 {
     $block = new Mage_Core_Block_Template();
     $block->setStar($countStars);
     $html = $block->setTemplate('amasty/amshopby/rating.phtml')->toHtml();
     return $html;
 }
 /**
  * @param Mage_Core_Block_Template
  * @param string
  * @return string
  */
 protected function getBlockContent(Mage_Core_Block_Template $block, $template)
 {
     $block->setLayout(Mage::app()->getLayout());
     return $block->setTemplate($template)->toHtml();
 }