Exemple #1
0
 /**
  * @return Container
  */
 protected function script()
 {
     if (null === $this->script) {
         $this->script = new Container();
         $this->script->setSeparator(PHP_EOL);
     }
     return $this->script;
 }
Exemple #2
0
 public function testIndentationIsHonored()
 {
     $this->container->setIndent(4)->setPrefix("<ul>\n    <li>")->setSeparator("</li>\n    <li>")->setPostfix("</li>\n</ul>");
     $this->container->append('foo');
     $this->container->append('bar');
     $this->container->append('baz');
     $string = $this->container->toString();
     $lis = substr_count($string, "\n        <li>");
     $this->assertEquals(3, $lis);
     $this->assertTrue(strstr($string, "    <ul>\n") ? true : false, $string);
     $this->assertTrue(strstr($string, "\n    </ul>") ? true : false);
 }
Exemple #3
0
 /**
  * Assign one or more layout variables
  *
  * @param  mixed $spec Assoc array or string key; if assoc array, sets each
  * key as a layout variable
  * @param  mixed $value Value if $spec is a key
  * @return \Zend\Layout\Layout
  * @throws \Zend\Layout\Exception if non-array/string value passed to $spec
  */
 public function assign($spec, $value = null)
 {
     if (is_array($spec)) {
         $orig = $this->_container->getArrayCopy();
         $merged = array_merge($orig, $spec);
         $this->_container->exchangeArray($merged);
         return $this;
     }
     if (is_string($spec)) {
         $this->_container[$spec] = $value;
         return $this;
     }
     throw new Exception('Invalid values passed to assign()');
 }
Exemple #4
0
 /**
  * This function will generate all meta tags needed for SEO optimisation.
  *
  * @param array $content
  */
 public function __invoke(array $content = [])
 {
     $description = !empty($content['description']) ? $content['description'] : $this->settings->__invoke('general', 'site_description');
     $keywords = !empty($content['keywords']) ? $content['keywords'] : $this->settings->__invoke('general', 'site_keywords');
     $text = !empty($content['text']) ? $content['text'] : $this->settings->__invoke('general', 'site_text');
     $preview = !empty($content['preview']) ? $content['preview'] : '';
     $title = !empty($content['title']) ? $content['title'] : $this->settings->__invoke('general', 'site_name');
     $this->placeholder->append("\r\n<meta itemprop='name' content='" . $this->settings->__invoke('general', 'site_name') . "'>\r\n");
     // must be set from db
     $this->placeholder->append("<meta itemprop='description' content='" . substr(strip_tags($text), 0, 150) . "'>\r\n");
     $this->placeholder->append("<meta itemprop='title' content='" . $title . "'>\r\n");
     $this->placeholder->append("<meta itemprop='image' content='" . $preview . "'>\r\n");
     $this->headMeta->appendName('keywords', $keywords);
     $this->headMeta->appendName('description', $description);
     $this->headMeta->appendName('viewport', 'width=device-width, initial-scale=1.0');
     $this->headMeta->appendName('generator', $this->settings->__invoke('general', 'site_name'));
     $this->headMeta->appendName('apple-mobile-web-app-capable', 'yes');
     $this->headMeta->appendName('application-name', $this->settings->__invoke('general', 'site_name'));
     $this->headMeta->appendName('mobile-web-app-capable', 'yes');
     $this->headMeta->appendName('HandheldFriendly', 'True');
     $this->headMeta->appendName('MobileOptimized', '320');
     $this->headMeta->appendName('apple-mobile-web-app-status-bar-style', 'black-translucent');
     $this->headMeta->appendName('author', 'Stanimir Dimitrov - stanimirdim92@gmail.com');
     $this->headMeta->appendName('twitter:card', 'summary');
     $this->headMeta->appendName('twitter:site', '@' . $this->settings->__invoke('general', 'site_name'));
     $this->headMeta->appendName('twitter:title', substr(strip_tags($title), 0, 70));
     // max 70 chars
     $this->headMeta->appendName('twitter:description', substr(strip_tags($text), 0, 200));
     $this->headMeta->appendName('twitter:image', $preview);
     // max 1MB
     $this->headMeta->appendProperty('og:image', $preview);
     $this->headMeta->appendProperty('og:title', $title);
     $this->headMeta->appendProperty('og:description', $description);
     $this->headMeta->appendProperty('og:type', 'article');
     $this->headMeta->appendProperty('og:url', $this->request->getUri()->getHost() . $this->request->getRequestUri());
 }
Exemple #5
0
 /**
  * Get title data
  * @return string 
  */
 public function getTitle()
 {
     return $this->container->toString();
 }