Beispiel #1
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);
 }
Beispiel #2
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());
 }
Beispiel #3
0
 /**
  * Append data
  * @param string $append
  * @return \RtHeadtitle\Controller\Plugin\HeadTitle 
  */
 public function append($append)
 {
     $this->container->append($append);
     return $this;
 }