Ejemplo n.º 1
0
 public function testLinkRendersAsPlainHtmlIfDoctypeNotXhtml()
 {
     $this->view->doctype('HTML4_STRICT');
     $this->helper->headLink(array('rel' => 'icon', 'src' => '/foo/bar'))->headLink(array('rel' => 'foo', 'href' => '/bar/baz'));
     $test = $this->helper->toString();
     $this->assertNotContains(' />', $test);
 }
Ejemplo n.º 2
0
    public function testCreatingLinkStackViaHeadScriptCreatesAppropriateOutput()
    {
        $links = array(
            'link1' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'foo'),
            'link2' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'bar'),
            'link3' => array('rel' => 'stylesheet', 'type' => 'text/css', 'href' => 'baz'),
        );
        $this->helper->headLink($links['link1'])
                     ->headLink($links['link2'], 'PREPEND')
                     ->headLink($links['link3']);

        $string = $this->helper->toString();
        $lines  = substr_count($string, PHP_EOL);
        $this->assertEquals(2, $lines);
        $lines  = substr_count($string, '<link ');
        $this->assertEquals(3, $lines, $string);

        foreach ($links as $link) {
            $substr = ' href="' . $link['href'] . '"';
            $this->assertContains($substr, $string);
            $substr = ' rel="' . $link['rel'] . '"';
            $this->assertContains($substr, $string);
            $substr = ' type="' . $link['type'] . '"';
            $this->assertContains($substr, $string);
        }

        $order = array();
        foreach ($this->helper as $key => $value) {
            if (isset($value->href)) {
                $order[$key] = $value->href;
            }
        }
        $expected = array('bar', 'foo', 'baz');
        $this->assertSame($expected, $order);
    }
Ejemplo n.º 3
0
 /**
  * @issue ZF-5435
  */
 public function testContainerMaintainsCorrectOrderOfItems()
 {
     $this->helper->headLink()->offsetSetStylesheet(1, '/test1.css');
     $this->helper->headLink()->offsetSetStylesheet(10, '/test2.css');
     $this->helper->headLink()->offsetSetStylesheet(20, '/test3.css');
     $this->helper->headLink()->offsetSetStylesheet(5, '/test4.css');
     $test = $this->helper->toString();
     $expected = '<link href="/test1.css" media="screen" rel="stylesheet" type="text/css" >' . PHP_EOL . '<link href="/test4.css" media="screen" rel="stylesheet" type="text/css" >' . PHP_EOL . '<link href="/test2.css" media="screen" rel="stylesheet" type="text/css" >' . PHP_EOL . '<link href="/test3.css" media="screen" rel="stylesheet" type="text/css" >';
     $this->assertEquals($expected, $test);
 }
Ejemplo n.º 4
0
 public function preDispatch(Zend_Controller_Request_Abstract $request)
 {
     $config = new Zend_Config_Ini(APPLICATION_DIRECTORY . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'assets.ini', 'general');
     $stylesheet_dir = $config->style->stylesheet_dir;
     $js_dir = $config->js->js_dir;
     $yui_dir = '';
     if ($config->yui) {
         $yui_dir = $config->yui->dir;
     }
     $baseUrl = str_replace('index.php', '', str_replace('dev.php', '', Zend_Controller_Front::getInstance()->getBaseUrl()));
     if (substr($baseUrl, -1, 1) == '/') {
         $baseUrl = substr($baseUrl, 0, strlen($baseUrl) - 1);
     }
     require_once 'Zend/View/Helper/HeadLink.php';
     $head = new Zend_View_Helper_HeadLink();
     // favicon
     if (isset($config->favicon) && $config->favicon != '' && $this->favicon == false) {
         $head->headLink(array('rel' => 'shortcut icon', 'href' => $baseUrl . DIRECTORY_SEPARATOR . $config->favicon));
         $this->favicon = true;
     }
     if ($config->style->blueprintcss == true) {
         $head->headLink()->appendStylesheet($baseUrl . DIRECTORY_SEPARATOR . $config->style->blueprintcss_dir . DIRECTORY_SEPARATOR . 'blueprint' . DIRECTORY_SEPARATOR . 'screen.css', 'screen')->appendStylesheet($baseUrl . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'blueprint' . DIRECTORY_SEPARATOR . 'print.css', 'print')->appendStylesheet($baseUrl . DIRECTORY_SEPARATOR . 'css' . DIRECTORY_SEPARATOR . 'blueprint' . DIRECTORY_SEPARATOR . 'ie.css', 'screen print', 'IE');
     }
     // Add general section css & js to head.
     $this->addToHead($config, $stylesheet_dir, $js_dir, $head, $baseUrl, $yui_dir);
     // pull entire config file (error when trying to pull module name sectio & does not exist
     $config = new Zend_Config_Ini(APPLICATION_DIRECTORY . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'assets.ini');
     $req = Zend_Controller_Front::getInstance()->getRequest();
     $mod = $req->getModuleName() . '.' . strtolower($req->getControllerName()) . '.' . $req->getActionName();
     // if module name has extra js or css, add to head
     if (isset($config->{$mod})) {
         if (!empty($config->{$mod})) {
             $this->addToHead($config->{$mod}, $stylesheet_dir, $js_dir, $head, $baseUrl, $yui_dir);
         }
     }
 }
Ejemplo n.º 5
0
 /**
  * @group ZF-11643
  */
 public function testSizesAttributeIsSupported()
 {
     $this->helper->headLink(array('rel' => 'icon', 'href' => 'favicon.png', 'sizes' => '16x16', 'type' => 'image/png'));
     $expected = '<link href="favicon.png" rel="icon" type="image/png" sizes="16x16" >';
     $this->assertEquals($expected, $this->helper->toString());
 }
Ejemplo n.º 6
0
 /**
  * headLink() - View Helper Method
  *
  * Returns current object instance. Optionally, allows passing array of
  * values to build link.
  *
  * @return Zend_View_Helper_HeadLink
  */
 public function headLink(array $attributes = null, $placement = Zend_View_Helper_Placeholder_Container_Abstract::APPEND)
 {
     $this->_proxy = null;
     return parent::headLink($attributes, $placement);
 }
Ejemplo n.º 7
0
 /**
  * Proxies to Zend_View_Helper_HeadLink::headLink()
  *
  * @return BundlePhu_View_Helper_BundleLink
  */
 public function bundleLink()
 {
     return parent::headLink();
 }