/** * @covers Mage_Core_Model_Layout::addBlock * @covers Mage_Core_Model_Layout::addOutputBlock * @covers Mage_Core_Model_Layout::getOutput * @covers Mage_Core_Model_Layout::removeOutputBlock */ public function testGetOutput() { $blockName = 'block_' . __METHOD__; $expectedText = "some_text_for_{$blockName}"; $block = new Mage_Core_Block_Text(); $block->setText($expectedText); $this->_model->addBlock($block, $blockName); $this->_model->addOutputBlock($blockName); $this->assertEquals($expectedText, $this->_model->getOutput()); $this->_model->removeOutputBlock($blockName); $this->assertEmpty($this->_model->getOutput()); }
/** * @covers Mage_Core_Model_Layout::addOutputElement * @covers Mage_Core_Model_Layout::getOutput * @covers Mage_Core_Model_Layout::removeOutputElement */ public function testGetOutput() { $blockName = 'block_' . __METHOD__; $expectedText = "some_text_for_{$blockName}"; $block = $this->_layout->addBlock('Mage_Core_Block_Text', $blockName); $block->setText($expectedText); //$this->_layout->addOutputElement($blockName); // add the same element twice should not produce output duplicate //$this->_layout->addOutputElement($blockName); $this->assertEquals($expectedText, $this->_layout->getOutput()); $this->_layout->removeOutputElement($blockName); $this->assertEmpty($this->_layout->getOutput()); }
/** * Get all blocks marked for output * * @return string */ public function getOutput() { if (!Mage::getSingleton('Flagbit_Typo3connect/Core')->isEnabled()) { return parent::getOutput(); } $out = ''; foreach ($this->_blocks as $key => $block) { Mage::getSingleton('Flagbit_Typo3connect/Core')->setBlock($key, $block); } //return parent::getOutput(); if (!empty($this->_output)) { foreach ($this->_output as $callback) { $out .= $this->getBlock($callback[0])->{$callback}[1](); } } return $out; }
/** * Records that layout was rendered * (non-PHPdoc) * @see Mage_Core_Model_Layout::getOutput() */ public function getOutput() { $this->record(self::ACTION_RENDER, 'layout'); return parent::getOutput(); }
/** * Replace all inline JavaScript * * @return string */ public function getOutput() { $output = parent::getOutput(); if (preg_match('/<body\\s*[^>]*>.*<\\/body>/is', $output, $body)) { $oldBody = $body[0]; // Replace script tags $newBody = preg_replace('/<script\\s*[^>]*>.*?<\\/script>/is', '', $oldBody); // Replace JS events foreach ($this->_jsEvents as $event) { $newBody = preg_replace("/(<[^>]+){$event}\\s*=\\s*(['\"])/is", "\$1{$event}-vde=\$2", $newBody); } // Replace href JS $newBody = preg_replace('/(<[^>]+)href\\s*=\\s*([\'"])javascript:/is', '$1href-vde=$2', $newBody); $output = str_replace($oldBody, $newBody, $output); } return $output; }