Example #1
0
 /**
  * @return HeadMeta
  */
 public function headMeta()
 {
     $this->__initialized__ && $this->__initialized__->__invoke();
     if (null === $this->headMeta) {
         $this->headMeta = new HeadMeta();
         $this->headMeta->setView($this->view);
     }
     return $this->headMeta;
 }
Example #2
0
 public function testConditionalNoIEWidthSpace()
 {
     $html = $this->helper->appendHttpEquiv('foo', 'bar', array('conditional' => '! IE'))->toString();
     $this->assertContains('<!--[if ! IE]><!--><', $html);
     $this->assertContains('<!--<![endif]-->', $html);
 }
Example #3
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());
 }
Example #4
0
 /**
  * Retrieve object instance; optionally add meta tag
  *
  * @param  string $content
  * @param  string $keyValue
  * @param  string $keyType
  * @param  array  $modifiers
  * @param  string $placement
  *
  * @return HeadMeta
  */
 public function __invoke($content = null, $keyValue = null, $keyType = 'name', $modifiers = array(), $placement = AbstractContainer::APPEND)
 {
     $this->setRcmDefaultMeta();
     return parent::__invoke($content, $keyValue, $keyType, $modifiers, $placement);
 }
Example #5
0
 /**
  * Prepend an element
  *
  * @param \stdClass $value
  * @return void
  */
 public function prepend($value)
 {
     if ('name' == $value->type) {
         $container = $this->getContainer();
         $content = '';
         foreach ($container->getArrayCopy() as $index => $item) {
             if ($item->name == $value->name) {
                 $content = $item->content;
                 $this->offsetUnset($index);
             }
         }
         if ($content) {
             $separator = 'description' == $value->name ? ' ' : ', ';
             $value->content = $value->content . $separator . $content;
         }
     }
     return parent::prepend($value);
 }
Example #6
0
 /**
  * If a keywords meta already exsists, extends it with $value->content,
  * else creates a new keywords meta.
  * @param \stdClass $value
  * @param string $position
  */
 public function updateKeywords(\stdClass $value, $position = AbstractContainer::SET)
 {
     $keywordsExists = false;
     foreach ($this->getContainer() as $item) {
         if (empty($value->content)) {
             return false;
         }
         if ($this->isKeywords($item)) {
             switch ($position) {
                 case AbstractContainer::APPEND:
                     $keywordsString = implode(', ', array($item->content, $value->content));
                     break;
                 case AbstractContainer::PREPEND:
                     $keywordsString = implode(', ', array($value->content, $item->content));
                     break;
                 case AbstractContainer::SET:
                 default:
                     $keywordsString = $value->content;
                     break;
             }
             $item->content = $keywordsString;
             $keywordsExists = true;
         }
     }
     if (!$keywordsExists) {
         parent::append($value);
     }
 }