public function testConditionalScriptWidthIndentation() { $this->helper->headScript()->appendFile('/js/foo.js', 'text/javascript', array('conditional' => 'lt IE 7')); $this->helper->headScript()->setIndent(4); $test = $this->helper->headScript()->toString(); $this->assertContains(' <!--[if lt IE 7]>', $test); }
/** * Returns CKEditor form field * @param string $name Name used for generated field * @param string $value Content for CKEditor * @param array $attr Attributes for textarea */ function rte($name, $value = null, $attr = array()) { $baseUrl = str_replace('/index.php', '', str_replace('/dev.php', '', Zend_Controller_Front::getInstance()->getBaseUrl())); $headLink = new Zend_View_Helper_HeadLink(); $headScript = new Zend_View_Helper_HeadScript(); $headScript->headScript()->appendFile($baseUrl . '/js/ckeditor/ckeditor.js'); $placeholder = new Zend_View_Helper_Placeholder(); $placeholder->placeholder('jQuery')->captureStart(); echo "CKEDITOR.replace( '" . $name . "' );"; $placeholder->placeholder('jQuery')->captureEnd(); return $this->view->formTextarea($name, $value, $attr); }
public function testCannotNestCaptures() { $this->helper->headScript()->captureStart(); echo "this is something captured"; try { $this->helper->headScript()->captureStart(); $this->helper->headScript()->captureEnd(); $this->fail('Should not be able to nest captures'); } catch (Zend_View_Exception $e) { $this->helper->headScript()->captureEnd(); $this->assertContains('Cannot nest', $e->getMessage()); } $this->helper->headScript()->captureEnd(); }
public function testToStringRendersValidHtml() { $this->helper->headScript('FILE', 'foo', 'set') ->headScript('SCRIPT', 'bar', 'prepend') ->headScript('SCRIPT', 'baz', 'append'); $string = $this->helper->toString(); $scripts = substr_count($string, '<script '); $this->assertEquals(3, $scripts); $scripts = substr_count($string, '</script>'); $this->assertEquals(3, $scripts); $scripts = substr_count($string, 'src="'); $this->assertEquals(1, $scripts); $scripts = substr_count($string, '><'); $this->assertEquals(1, $scripts); $this->assertContains('src="foo"', $string); $this->assertContains('bar', $string); $this->assertContains('baz', $string); $doc = new DOMDocument; $dom = $doc->loadHtml($string); $this->assertTrue($dom !== false); }
private function addToHead($config, $stylesheet_dir = '', $js_dir = '', $head, $baseUrl, $yui_dir = '') { // Add CSS if (isset($config->style->screen->stylesheet) && $config->style->screen->stylesheet != '') { $css = explode(',', $config->style->screen->stylesheet); foreach ($css as $s) { if (@substr_compare(trim($s), 'http', 0, 4) == 0) { $head->headLink()->appendStylesheet(trim($s), 'screen'); } else { $head->headLink()->appendStylesheet($baseUrl . DIRECTORY_SEPARATOR . $stylesheet_dir . DIRECTORY_SEPARATOR . trim($s), 'screen'); } } } // IE stylesheet if (isset($config->ie->screen->stylesheet) && $config->ie->screen->stylesheet != '') { $css = explode(',', $config->ie->screen->stylesheet); foreach ($css as $s) { if (@substr_compare(trim($s), 'http', 0, 4) == 0) { $head->headLink()->appendStylesheet(trim($s), 'screen', 'IE'); } else { $head->headLink()->appendStylesheet(str_replace('//', '/', $this->baseUrl . DIRECTORY_SEPARATOR . $stylesheet_dir . DIRECTORY_SEPARATOR . trim($s)), 'screen', 'IE'); } } } if (isset($config->style->print->stylesheet) && $config->style->print->stylesheet != '') { $css = explode(',', $config->style->print->stylesheet); foreach ($css as $s) { if (@substr_compare(trim($s), 'http', 0, 4) == 0) { $head->headLink()->appendStylesheet(trim($s), 'print'); } else { $head->headLink()->appendStylesheet($baseUrl . DIRECTORY_SEPARATOR . $stylesheet_dir . DIRECTORY_SEPARATOR . trim($s), 'print'); } } } // yui if (isset($config->yui->css) && $config->yui->css != '') { $css = explode(',', $config->yui->css); foreach ($css as $s) { if (@substr_compare(trim($s), 'http', 0, 4) == 0) { $head->headLink()->appendStylesheet(trim($s), 'screen'); } else { $head->headLink()->appendStylesheet($baseUrl . DIRECTORY_SEPARATOR . $yui_dir . DIRECTORY_SEPARATOR . trim($s), 'screen'); } } } // Add JS $headScript = new Zend_View_Helper_HeadScript(); if (isset($config->js->js) && $config->js->js != '') { $js = explode(',', $config->js->js); foreach ($js as $j) { if (@substr_compare(trim($j), 'http', 0, 4) == 0) { $headScript->headScript()->appendFile(trim($j)); } else { $headScript->headScript()->appendFile($baseUrl . DIRECTORY_SEPARATOR . $js_dir . DIRECTORY_SEPARATOR . trim($j)); } } } if (isset($config->js->prepend) && $config->js->prepend != '') { $js = array_reverse(explode(',', $config->js->prepend)); foreach ($js as $j) { if (@substr_compare(trim($j), 'http', 0, 4) == 0) { $headScript->headScript()->prependFile(trim($j)); } else { $headScript->headScript()->prependFile($baseUrl . DIRECTORY_SEPARATOR . $js_dir . DIRECTORY_SEPARATOR . trim($j)); } } } // yui if (isset($config->yui->js) && $config->yui->js != '') { $js = explode(',', $config->yui->js); foreach ($js as $j) { if (@substr_compare(trim($j), 'http', 0, 4) == 0) { $headScript->headScript()->appendFile(trim($j)); } else { $headScript->headScript()->appendFile($baseUrl . DIRECTORY_SEPARATOR . $yui_dir . DIRECTORY_SEPARATOR . trim($j)); } } } }
/** * Return headScript object * * Returns headScript helper object; optionally, allows specifying a script * or script file to include. * * @param string $mode Script or file * @param string $spec Script/url * @param string $placement Append, prepend, or set * @param array $attrs Array of script attributes * @param string $type Script type and/or array of script attributes * @return Zend_View_Helper_HeadScript */ public function bottomScript($mode = Zend_View_Helper_HeadScript::FILE, $spec = null, $placement = 'APPEND', array $attrs = array(), $type = 'text/javascript') { return parent::headScript($mode, $spec, $placement, $attrs, $type); }
/** * Proxies to Zend_View_Helper_HeadScript::headScript() * * @return BundlePhu_View_Helper_BundleScript */ public function bundleScript() { return parent::headScript(); }
/** * Return headScript object * * Returns headScript helper object; optionally, allows specifying a script * or script file to include. * * @param string $mode Script or file * @param string $spec Script/url * @param string $placement Append, prepend, or set * @param array $attributes Array of script attributes * @param string $type Script type and/or array of script attributes * @return Zend_View_Helper_HeadScript */ public function headScript($mode = Zend_View_Helper_HeadScript::FILE, $spec = null, $placement = 'APPEND', array $attributes = array(), $type = 'text/javascript') { $this->_proxy = null; return parent::headScript($mode, $spec, $placement, $attributes, $type); }