Beispiel #1
0
 /**
  * Container data setter
  * @param  string $name   meta name
  * @param  string $value  meta value
  * @param  array  $attr   Extra attributes
  */
 public static function set($name, $value, array $attr = array())
 {
     $_name = self::key($name);
     $attrs['property'] = 'og:' . preg_replace('/\\Aog:/i', '', $name);
     $attrs['content'] = $value;
     $data = self::data($_name, $attrs);
     HeadsContainer::set('ogp', $data);
 }
Beispiel #2
0
 /**
  * Container data setter
  * @param  string $name   meta name
  * @param  string $value  meta value
  * @param  array  $attr   Extra attributes
  */
 public static function set($name, $value, array $attr = array())
 {
     $attrs['rel'] = $name;
     $attrs['href'] = $value;
     if (is_string($attrs)) {
         $attrs['title'] = $attr;
     }
     $data = self::data($name, $attrs);
     HeadsContainer::set('link', $data);
 }
Beispiel #3
0
 /**
  * http Content-Type
  * @param  string $value  meta value
  * @param  mixed  $attr   Extra attributes
  * @return array          Tag data
  */
 protected static function _contentType($value, $attrs = array())
 {
     if (false === strpos($value, 'charset')) {
         if ($data = HeadsContainer::get('meta', '_charset')) {
             $value = trim($value, ' ;') . '; charset=' . $data[0]['attrs']['charset'];
         }
     }
     $attrs['http-equiv'] = 'Content-Type';
     $attrs['content'] = $value;
     return self::data(__FUNCTION__, $attrs);
 }
Beispiel #4
0
 /**
  * Container data setter
  * @param  string $name   meta name
  * @param  string $value  meta value
  * @param  array  $attr   Extra attributes
  */
 public static function set($name, $value, array $attr = array())
 {
     $_name = self::key($name);
     if (false !== array_search($_name, self::$availables)) {
         $attrs['property'] = 'fb:' . preg_replace('/\\Afb:/i', '', $name);
         $attrs['content'] = $value;
         $data = self::data($_name, $attrs);
         HeadsContainer::set('facebook', $data);
     } else {
         HeadsMain::ogp('og:' . preg_replace('/\\Afb:/i', '', $name), $value, $attr);
     }
 }
Beispiel #5
0
 /**
  * Get duplicate value
  * @param  string $category  Container category name
  * @param  string $key       Container key name
  * @param  array $attr       Extra attributes
  * @param  mixed $value      If array to string
  * @return array
  */
 protected static function duplicate($category, $key, $attr, $value)
 {
     $key = self::key($key);
     if (is_string($value)) {
         $value = str_replace(array(' ,', ', '), ',', $value);
         $value = explode(',', $value);
     }
     if ($datas = HeadsContainer::get($category, $key)) {
         $current = $datas[0]['attrs'][$attr];
         $current = explode(',', $current);
         $value = array_merge($current, $value);
     }
     $value = array_filter($value);
     $value = array_unique($value);
     $value = implode(',', $value);
     return $value;
 }
Beispiel #6
0
 /**
  * Get Open Graph Namespaces
  * @return string  prefix HTML attribute
  */
 public static function namespace()
 {
     $datas = HeadsContainer::datas();
     if (empty($datas) || empty(self::$options['namespace'])) {
         return;
     }
     $options = self::$options['namespace'];
     $prefixes = array();
     foreach ($datas as $type => $values) {
         foreach ($values as $key => $rows) {
             foreach ($rows as $row) {
                 if (empty($row['attrs']['property'])) {
                     continue;
                 }
                 $prop = $row['attrs']['property'];
                 $ns = substr($prop, 0, strpos($prop, ':'));
                 if (!empty($options[$ns])) {
                     $prefixes[$ns] = $ns . ': ' . $options[$ns] . '#';
                 }
                 if ('og:type' === $prop && !empty($row['attrs']['content'])) {
                     $ns = $row['attrs']['content'];
                     if (!empty($options[$ns])) {
                         $prefixes[$ns] = $ns . ': ' . $options[$ns] . '#';
                     }
                 }
             }
         }
     }
     if (empty($prefixes)) {
         return;
     }
     return $prefixes;
 }