Advanced meta tags

@param array   $metaTags          MetaTags
@param array   $pageRecord        TSFE Page
@param integer $sysLanguageId     Sys Language ID
@param array   $customMetaTagList Custom Meta Tag list
323912
protected function advMetaTags(array &$metaTags, array $pageRecord, $sysLanguageId, array $customMetaTagList)
    {
        $pageRecordId = $pageRecord['uid'];
        $storeMeta = $this->getStoreMeta();
        $advMetaTagCondition = array();

        // #################
        // External Og tags (from connector)
        // #################
        if ($this->isAvailableExternalOgTags()) {
            // External OpenGraph support
            $advMetaTagCondition[] = 'tag_name NOT LIKE \'og:%\'';
            if (!empty($storeMeta['meta:og'])) { //overwrite known og tags
                $externalOgTags = $storeMeta['meta:og'];
                foreach ($externalOgTags as $tagName => $tagValue) {
                    if (array_key_exists('og.' . $tagName, $metaTags)) { //_only_ known og tags
                        $metaTags['og.' . $tagName] = array(
                            'tag'        => 'meta',
                            'attributes' => array(
                                'property'  => 'og:' . $tagName,
                                'content'   => $tagValue,
                            ),
                        );
                    }
                }
            }
        }
        if ($this->isAvailableExternalOgCustomTags()) {
            $ogTagKeys = array();
            if (!empty($storeMeta['custom:og'])) {
                $externalCustomOgTags = $storeMeta['custom:og'];
                foreach ($externalCustomOgTags as $tagName => $tagValue) { //take all tags
                    $metaTags['og.' . $tagName] = array(
                        'tag'        => 'meta',
                        'attributes' => array(
                            'property'  => 'og:' . $tagName,
                            'content'   => $tagValue,
                        ),
                    );
                    $ogTagKeys[] = 'og:' . $tagName;
                }
            }
            $advMetaTagCondition[] = DatabaseUtility::conditionNotIn('tag_name', $ogTagKeys, true);
        }

        // #################
        // Adv meta tags (from editor)
        // #################

        if (!empty($advMetaTagCondition)) {
            $advMetaTagCondition = '( ' . implode(') AND (', $advMetaTagCondition) . ' )';
        } else {
            $advMetaTagCondition = '1=1';
        }

        // Fetch list of meta tags from database
        $query          = 'SELECT tag_name,
                                  tag_value
                             FROM tx_metaseo_metatag
                            WHERE pid = ' . (int)$pageRecordId . '
                              AND sys_language_uid = ' . (int)$sysLanguageId . '
                              AND ' . $advMetaTagCondition;
        $advMetaTagList = DatabaseUtility::getList($query);

        // Add metadata to tag list
        foreach ($advMetaTagList as $tagName => $tagValue) {
            if (substr($tagName, 0, 3) === 'og:') {
                $metaTags['og.' . $tagName] = array(
                    'tag'        => 'meta',
                    'attributes' => array(
                        'property'  => $tagName,
                        'content'   => $tagValue,
                    ),
                );
            } else {
                $metaTags['adv.' . $tagName] = array(
                    'tag'        => 'meta',
                    'attributes' => array(
                        'rel'  => $tagName, //see https://github.com/webdevops/TYPO3-metaseo/issues/464
                        'href' => $tagValue,
                    ),
                );
            }
        }

        // #################
        // Custom meta tags (from connector)
        // #################
        foreach ($customMetaTagList as $tagName => $tagValue) {
            $metaTags['adv.' . $tagName] = array(
                'tag'        => 'meta',
                'attributes' => array(
                    'rel'  => $tagName, //see https://github.com/webdevops/TYPO3-metaseo/issues/464
                    'href' => $tagValue,
                ),
            );
        }
    }
430866
public function setMetaTags($keywords = null, $description = null)
    {
        if (empty($keywords)) {
            $keywords = $this->module->podiumConfig->get('meta_keywords');
        }
        if ($keywords) {
            $this->getView()->registerMetaTag([
                'name' => 'keywords',
                'content' => $keywords
            ]);
        }
        if (empty($description)) {
            $description = $this->module->podiumConfig->get('meta_description');
        }
        if ($description) {
            $this->getView()->registerMetaTag([
                'name' => 'description',
                'content' => $description
            ]);
        }
    }
703294
public function addTags($methodVars) {
		// Only allow full authed calls
		if ( $this->fullAuth == true ) {
			// Check for required variables
			if ( !empty($methodVars['artist']) && !empty($methodVars['track']) && !empty($methodVars['tags']) ) {
				// If the tags variables is an array build a CS list
				if ( is_array($methodVars['tags']) ) {
					$tags = '';
					foreach ( $methodVars['tags'] as $tag ) {
						$tags .= $tag.',';
					}
					$tags = substr($tags, 0, -1);
				}
				else {
					$tags = $methodVars['tags'];
				}
				$methodVars['tags'] = $tags;

				$vars = array(
					'method' => 'track.addtags',
					'api_key' => $this->auth->apiKey,
					'sk' => $this->auth->sessionKey
				);
				$vars = array_merge($vars, $methodVars);
				$sig = $this->apiSig($this->auth->apiSecret, $vars);
				$vars['api_sig'] = $sig;

				if ( $call = $this->apiPostCall($vars) ) {
					return true;
				}
				else {
					return false;
				}
			}
			else {
				throw new InvalidArgumentException('You must include artist, track and tags varialbes in the call for this method');
			}
		}
		else {
			throw new NotAuthenticatedException('Method requires full auth. Call auth.getSession using lastfmApiAuth class');
		}
	}
597971
protected function get_metadata( $pageInfoArray2 = null ) {
		$pageInfoArray = array(
			'action' => 'query',
			'prop'   => "info"
		);
		$pageInfoArray['inprop'] = 'protection|talkid|watched|watchers|notificationtimestamp|subjectid|url|readable|preload|displaytitle';

		if( $pageInfoArray2 != null ) {
			$pageInfoArray = array_merge( $pageInfoArray, $pageInfoArray2 );
		} else {
			$pageInfoArray['titles'] = $this->title;
		}

		$pageInfoRes = $this->wiki->apiQuery( $pageInfoArray );

		if( isset( $pageInfoRes['warnings']['query']['*'] ) && in_string( 'special pages', $pageInfoRes['warnings']['query']['*'] ) ) {
			pecho( "Special pages are not currently supported by the API.\n\n", PECHO_ERROR );
			$this->exists = false;
			$this->special = true;
		}

		if( isset( $pageInfoRes['query']['redirects'][0] ) ) {
			$this->redirectFollowed = true;
		}

		foreach( $pageInfoRes['query']['pages'] as $key => $info ){
			$this->pageid = $key;
			if( $this->pageid > 0 ) {
				$this->exists = true;
				$this->lastedit = $info['touched'];
				$this->hits = isset( $info['counter'] ) ? $info['counter'] : '';
				$this->length = $info['length'];
			} else {
				$this->pageid = 0;
				$this->lastedit = '';
				$this->hits = '';
				$this->length = '';
				$this->starttimestamp = '';
			}

			if( isset( $info['missing'] ) ) $this->exists = false;

			if( isset( $info['invalid'] ) ) throw new BadTitle( $this->title );

			$this->title = $info['title'];
			$this->namespace_id = $info['ns'];

			if( $this->namespace_id != 0) {
                $title_wo_namespace = explode(':', $this->title, 2);
                $this->title_wo_namespace = $title_wo_namespace[1];
			} else {
				$this->title_wo_namespace = $this->title;
			}

			if( isset( $info['special'] ) ) $this->special = true;

			if( isset( $info['protection'] ) ) $this->protection = $info['protection'];
			if( isset( $info['talkid'] ) ) $this->talkid = $info['talkid'];
			if( isset( $info['watched'] ) ) $this->watched = true;
			if( isset( $info['watchers'] ) ) $this->watchers = $info['watchers'];
			if( isset( $info['notificationtimestamp'] ) ) $this->watchlisttimestamp = $info['notificationtimestamp'];
			if( isset( $info['subjectid'] ) ) $this->subjectid = $info['subjectid'];
			if( isset( $info['fullurl'] ) ) $this->urls['full'] = $info['fullurl'];
			if( isset( $info['editurl'] ) ) $this->urls['edit'] = $info['editurl'];
			if( isset( $info['readable'] ) ) $this->readable = true;
			if( isset( $info['preload'] ) ) $this->preload = $info['preload'];
			if( isset( $info['displaytitle'] ) ) $this->displaytitle = $info['displaytitle'];
		}
	}
401574
public function parseMetadata(array $metaFields): array
    {
        $metadata = [];
        
        foreach ($metaFields as $fieldName => $field) {
            $validatedField = $this->parseField($fieldName, $field);
            if (!is_null($validatedField)) {
                $metadata[$fieldName] = $validatedField;
            }
        }
        
        return $metadata;
    }
123949
protected function metaTagsAfter(AssetInterface $asset, $rawHtml)
    {
        if ($matches = $this->getMatches($rawHtml, '<meta', true, true)) {
            $last = count($matches[0]) - 1;
            $replacement = sprintf("%s\n%s%s", $matches[0][$last], $matches[1][$last], (string) $asset);

            return Str::replaceFirst($rawHtml, $matches[0][$last], $replacement);
        }

        return $this->headTagEnd($asset, $rawHtml);
    }
591793
public function printTags($customView = '', $ulClass ="")
    {
        if($this->hasTags()) {
            $tags = "tags";
            return new HtmlString(
                view()->make(
                    ($customView ? $customView : "vendor.tags.default"), [
                    'tagsList' => $this->$tags,
                    'ulClass' => $ulClass,
                    'postTypeSlug' => $this->getTable()

                    ]
                )->render()
            );
        }
    }
308269
public function MetaTags(&$tags)
    {
        // Only attempt to replace <title> tag if it has been included, as it won't
        // be included if called via $MetaTags(false)
        if (preg_match("/<title>(.+)<\/title>/i", $tags)) {
            $format = Config::inst()->get(static::class, 'title_format');

            $data = ArrayData::create([
                'MetaTitle' => $this->owner->MetaTitle ? $this->owner->obj('MetaTitle') : $this->owner->obj('Title')
            ]);

            $newTitleTag = HTML::createTag('title', [], SSViewer::execute_string($format, $data));
            $tags = preg_replace("/<title>(.+)<\/title>/i", $newTitleTag, $tags);
        }
    }
833518
public function set_metadatas(array $metadatas, $force_readonly = false)
    {
        $databox_descriptionStructure = $this->getDatabox()->get_meta_structure();

        foreach ($metadatas as $param) {
            if (!is_array($param)) {
                throw new Exception_InvalidArgument('Invalid metadatas argument');
            }

            $db_field = $databox_descriptionStructure->get_element($param['meta_struct_id']);

            if ($db_field->is_readonly() === true && !$force_readonly) {
                continue;
            }

            $this->set_metadata($param, $this->getDatabox());
        }

        $xml = new DOMDocument();
        $xml->loadXML($this->app['serializer.caption']->serialize($this->get_caption(), CaptionSerializer::SERIALIZE_XML, true));

        $this->set_xml($xml);
        unset($xml);

        $this->write_metas();
        $this->dispatch(RecordEvents::METADATA_CHANGED, new MetadataChangedEvent($this));

        return $this;
    }
912948
protected LinkedList<ModificationRecord> parseModificationRecords(Tag[] tags) {
		LinkedList<ModificationRecord> result = new LinkedList<ModificationRecord>();
		for (int i = 0; i < tags.length; i++) {
			if ("@author".equalsIgnoreCase(tags[i].name())) {
				ModificationRecord record = new ModificationRecord();
				record.setModifier(tags[i].text());

				if (i + 1 < tags.length) {
					if ("@version".equalsIgnoreCase(tags[i + 1].name())) {
						record.setVersion(tags[i + 1].text());
						if (i + 2 < tags.length && ("@" + WRMemoTaglet.NAME).equalsIgnoreCase(tags[i + 2].name())) {
							record.setMemo(tags[i + 2].text());
						}
					} else if (("@" + WRMemoTaglet.NAME).equalsIgnoreCase(tags[i + 1].name())) {
						record.setMemo(tags[i + 1].text());
					}
				}
				result.add(record);
			}
		}

		return result;
	}
1205161
public function UpdateTags()
    {
        $siteTree = DataObject::getSchema()->tableName(SiteTree::class);
        $taxonomy = DataObject::getSchema()->tableName(TaxonomyTerm::class);

        $tags = TaxonomyTerm::get()
            ->innerJoin('BasePage_Terms', sprintf('"%s"."ID"="BasePage_Terms"."TaxonomyTermID"', $taxonomy))
            ->innerJoin(
                $siteTree,
                sprintf(
                    '"%s"."ID" = "BasePage_Terms"."BasePageID" AND "%s"."ParentID" = \'%d\'',
                    $siteTree,
                    $siteTree,
                    $this->ID
                )
            )
            ->sort('Name');

        return $tags;
    }
174401
public function generateDefaultMetaTags()
    {
        if ($this->isEmptyMeta($this->metaTitle)) {
            $this->setMetaTitle($this->defaultMetaTitle());
        }
        if ($this->isEmptyMeta($this->metaDescription)) {
            $this->setMetaDescription($this->defaultMetaDescription());
        }
        if ($this->isEmptyMeta($this->metaImage)) {
            $this->setMetaImage($this->defaultMetaImage());
        }
        return $this;
    }
188307
public function MetaTags(&$tags) {

        $siteConfig = SiteConfig::current_site_config();

        // facebook OpenGraph
        /*
        $tags .= '<meta property="og:locale" content="' . i18n::get_locale() . '" />' . "\n";
        $tags .= '<meta property="og:title" content="' . $this->owner->Title . '" />' . "\n";
        $tags .= '<meta property="og:description" content="' . $this->owner->MetaDescription . '" />' . "\n";
        $tags .= '<meta property="og:url" content=" ' . $this->owner->AbsoluteLink() . ' " />' . "\n";
        $tags .= '<meta property="og:site_name" content="' . $siteConfig->Title . '" />' . "\n";
        $tags .= '<meta property="og:type" content="article" />' . "\n";
        */
        //$tags .= '<meta property="og:image" content="" />' . "\n";

        if (Config::inst()->get('SeoObjectExtension', 'use_webmaster_tag')) {
            $tags .= $siteConfig->GoogleWebmasterMetaTag . "\n";
        }
    }
1187210
public function render(array $metaTags = array())
    {
        $html = '';

        foreach ($metaTags as $metaTag) {
            if (!$metaTag instanceof Item) {
                throw new InvalidArgumentException('metaTags', 'Cannot render meta tag, not an instance of \Netgen\Bundle\OpenGraphBundle\MetaTag\Item');
            }

            $tagName = htmlspecialchars($metaTag->getTagName(), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
            $tagValue = htmlspecialchars($metaTag->getTagValue(), ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');

            if (!empty($tagName) && !empty($tagValue)) {
                $html .= "<meta property=\"$tagName\" content=\"$tagValue\" />\n";
            }
        }

        return $html;
    }
1233502
protected function _renderTag($attribs = array(), $content = null, TemplateInterface $template)
    {
        $attribs = $this->buildAttributes($attribs);

        $html = '<meta '.$attribs.' />'."\n";
        return $html;
    }
420183
private function mapTranslatable(ClassMetadata $metadata)
    {
        // In the case A -> B -> TranslatableInterface, B might not have mapping defined as it
        // is probably defined in A, so in that case, we just return.
        if (!isset($this->mappings[$metadata->name])) {
            return;
        }

        $config = $this->mappings[$metadata->name];
        $mapping = $config['translation']['mapping'];

        $metadata->mapManyEmbedded([
            'fieldName' => $mapping['translatable']['translations'],
            'targetDocument' => $config['translation']['model'],
            'strategy' => 'set',
        ]);
    }
516643
def subtags(self):
        
        data = self.data
        subtags = []

        # if tag is grandfathered return no subtags
        if 'record' in data and self.data['record']['Type'] == 'grandfathered':
            return subtags

        codes = data['tag'].split('-')
        # Try and find the language tag.
        for i, code in enumerate(codes):

            # Singletons and anything after are unhandled.
            if len(code) == 1:
                #Stop the loop (stop processing after a singleton).
                break

            # Check for non-existent tag.
            if code not in index:
                continue
            types = index[code]

            # Language subtags may only appear at the beginning of the tag, otherwise the subtag type is indeterminate.
            if 'language' in types and i == 0:
                subtags.append(Subtag(code, 'language'))
                continue

            if len(code) == 2:
                # Should be a region
                if 'region' in types:
                    subtags.append(Subtag(code, 'region'))
                # Error case: language subtag in the wrong place.
                elif 'language' in types:
                    subtags.append(Subtag(code, 'language'))

            elif len(code) == 3:
                # Could be a numeric region code e.g. '001' for 'World'.
                if 'region' in types:
                    subtags.append(Subtag(code, 'region'))
                elif 'extlang' in types:
                    subtags.append(Subtag(code, 'extlang'))
                # Error case: language subtag in the wrong place.
                elif 'language' in types:
                    subtags.append(Subtag(code, 'language'))

            elif len(code) == 4:
                # Could be a numeric variant
                if 'variant' in types:
                    subtags.append(Subtag(code, 'variant'))
                elif 'script' in types:
                    subtags.append(Subtag(code, 'script'))

            else:
                # Should be a variant
                if 'variant' in types:
                    subtags.append(Subtag(code, 'variant'))

        return subtags