Ejemplo n.º 1
0
 public function testAppendTagsMoreTagsSpan()
 {
     $styles = array(array('tag' => 'li', 'appendTags' => array(array('tag' => 'span', 'style' => 'margin-left:10px'), array('tag' => 'span', 'style' => 'margin-right:10px'))));
     $html = '<table><tr><td><ul><li>Here</li></ul></td></tr></table>';
     $expected = '<html xmlns="http://www.w3.org/1999/xhtml">';
     $expected .= '<head><title></title></head><table><tr><td><ul><li><span style="margin-left:10px"><span style="margin-right:10px">Here</span></span></li></ul></td></tr></table>';
     $expected .= '</html>';
     $p = new Kwc_Mail_HtmlParser($styles);
     $html = $p->parse($html);
     $this->_assertHtmlEquals($expected, $html);
 }
Ejemplo n.º 2
0
 public function renderComponent($component, &$hasDynamicParts = false)
 {
     static $benchmarkEnabled;
     if (!isset($benchmarkEnabled)) {
         $benchmarkEnabled = Kwf_Benchmark::isEnabled();
     }
     $content = false;
     if ($this->_enableCache && $component->isPage) {
         //use fullPage cache only for pages
         $content = Kwf_Component_Cache::getInstance()->load($component->componentId, $this->_getRendererName(), 'fullPage');
         $this->_minLifetime = null;
     }
     Kwf_Benchmark::checkpoint('load fullPage cache');
     $statType = null;
     if (!$content) {
         $helper = new Kwf_Component_View_Helper_Component();
         $helper->setRenderer($this);
         $content = $helper->component($component);
         $pass1Cacheable = true;
         $content = $this->_renderPass1($content, $pass1Cacheable);
         Kwf_Benchmark::checkpoint('render pass 1');
         if (strpos($content, '<kwc2 ') === false) {
             //if there are no components that need second render cycle start HtmlParser now
             //and cache result in fullPage cache
             if ($this->_renderFormat == self::RENDER_HTML && $this->_htmlStyles) {
                 $p = new Kwc_Mail_HtmlParser($this->_htmlStyles);
                 $content = $p->parse($content);
                 Kwf_Benchmark::checkpoint('html parser (in fullPage)');
             }
         }
         if ($this->_enableCache && $pass1Cacheable && $component->isPage) {
             Kwf_Component_Cache::getInstance()->save($component, $content, $this->_getRendererName(), 'fullPage', '', '', $this->_minLifetime);
         }
     }
     $hasPass2Placeholders = strpos($content, '<kwc2 ') !== false;
     $content = $this->_renderPass2($content);
     Kwf_Benchmark::checkpoint('render pass 2');
     //if there where components that needed second render cycle the HtmlParser wasn't started yet
     //do that now (should be avoided as it's slow)
     if ((!$component->isPage || $hasPass2Placeholders) && $this->_renderFormat == self::RENDER_HTML && $this->_htmlStyles) {
         $p = new Kwc_Mail_HtmlParser($this->_htmlStyles);
         $content = $p->parse($content);
         Kwf_Benchmark::checkpoint('html parser');
     }
     Kwf_Component_Cache::getInstance()->writeBuffer();
     return $content;
 }
Ejemplo n.º 3
0
 public function testSelectorMultipleClasses9()
 {
     $styles = array(array('selector' => '.foo .bar', 'styles' => array('font-size' => '12px')));
     $html = '<p class="foo bar">Lorem Ipsum</p>';
     $html .= '<p class="foo"><span class="bar">Lorem Ipsum</span></p>';
     $html .= '<p class="bar">Lorem Ipsum</p>';
     $expected = '<html xmlns="http://www.w3.org/1999/xhtml">';
     $expected .= '<head><title></title></head>';
     $expected .= '<p class="foo bar">Lorem Ipsum</p>';
     $expected .= '<p class="foo"><span class="bar" style="font-size: 12px; ">Lorem Ipsum</span></p>';
     $expected .= '<p class="bar">Lorem Ipsum</p>';
     $expected .= '</html>';
     $p = new Kwc_Mail_HtmlParser($styles);
     $html = $p->parse($html);
     $this->_assertHtmlEquals($expected, $html);
 }