Returns page-title for node.

@param ArticleInterface $document

@return string
502070
private function getPageTitle(ArticleInterface $document)
    {
        $pageTitleProperty = $this->getPageTitleProperty($document);
        if (!$pageTitleProperty) {
            return;
        }

        $stagedData = $document->getStructure()->getStagedData();
        if (array_key_exists($pageTitleProperty->getName(), $stagedData)) {
            return $stagedData[$pageTitleProperty->getName()];
        }

        if (!$document->getStructure()->hasProperty($pageTitleProperty->getName())) {
            return;
        }

        return $document->getStructure()->getProperty($pageTitleProperty->getName())->getValue();
    }
653506
public function fetchHead(&$document)
	{
		// Trigger the onBeforeCompileHead event (skip for installation, since it causes an error)
		\Event::trigger('onBeforeCompileHead');

		// Get line endings
		$lnEnd  = $document->_getLineEnd();
		$tab    = $document->_getTab();
		$tagEnd = ' />';
		$buffer = array();

		// Generate base tag (need to happen first)
		$base = $document->getBase();
		if (!empty($base))
		{
			$buffer[] = $tab . '<base href="' . $document->getBase() . '" />';
		}

		// Generate META tags (needs to happen as early as possible in the head)
		foreach ($document->_metaTags as $type => $tag)
		{
			foreach ($tag as $name => $content)
			{
				if ($type == 'http-equiv')
				{
					$content .= '; charset=' . $document->getCharset();
					$buffer[] = $tab . '<meta http-equiv="' . $name . '" content="' . htmlspecialchars($content) . '" />';
				}
				elseif ($type == 'standard' && !empty($content) && isset($content['content']))
				{
					$buffer[] = $tab . '<meta name="' . $content['name'] . '" content="' . htmlspecialchars($content['content']) . '" />';
				}
			}
		}

		// Don't add empty descriptions
		if ($description = $document->getDescription())
		{
			$buffer[] = $tab . '<meta name="description" content="' . htmlspecialchars($description) . '" />';
		}

		// Don't add empty generators
		if ($generator = $document->getGenerator())
		{
			$buffer[] = $tab . '<meta name="generator" content="' . htmlspecialchars($generator) . '" />';
		}

		$buffer[] = $tab . '<title>' . htmlspecialchars($document->getTitle(), ENT_COMPAT, 'UTF-8') . '</title>';

		// Generate link declarations
		foreach ($document->_links as $link => $linkAtrr)
		{
			$line = $tab . '<link href="' . $link . '" ' . $linkAtrr['relType'] . '="' . $linkAtrr['relation'] . '"';
			if ($temp = Arr::toString($linkAtrr['attribs']))
			{
				$line .= ' ' . $temp;
			}
			$line .= ' />';

			$buffer[] = $line;
		}

		// Generate stylesheet links
		foreach ($document->_styleSheets as $strSrc => $strAttr)
		{
			$line = $tab . '<link rel="stylesheet" href="' . $strSrc . '" type="' . $strAttr['mime'] . '"';
			if (!is_null($strAttr['media']))
			{
				$line .= ' media="' . $strAttr['media'] . '" ';
			}
			if ($temp = Arr::toString($strAttr['attribs']))
			{
				$line .= ' ' . $temp;
			}

			$buffer[] = $line . $tagEnd;
		}

		// Generate stylesheet declarations
		foreach ($document->_style as $type => $content)
		{
			$buffer[] = $tab . '<style type="' . $type . '">';

			// This is for full XHTML support.
			if ($document->_mime != 'text/html')
			{
				$buffer[] = $tab . $tab . '<![CDATA[';
			}

			$buffer[] = $content;

			// See above note
			if ($document->_mime != 'text/html')
			{
				$buffer[] = $tab . $tab . ']]>';
			}
			$buffer[] = $tab . '</style>';
		}

		// Generate script file links
		foreach ($document->_scripts as $strSrc => $strAttr)
		{
			$line = $tab . '<script src="' . $strSrc . '"';
			if (!is_null($strAttr['mime']))
			{
				$line .= ' type="' . $strAttr['mime'] . '"';
			}
			if ($strAttr['defer'])
			{
				$line .= ' defer="defer"';
			}
			if ($strAttr['async'])
			{
				$line .= ' async="async"';
			}
			$line .= '></script>';

			$buffer[] = $line;
		}

		// Generate script declarations
		foreach ($document->_script as $type => $content)
		{
			$buffer[] = $tab . '<script type="' . $type . '">';

			// This is for full XHTML support.
			if ($document->_mime != 'text/html')
			{
				$buffer[] = $tab . $tab . '<![CDATA[';
			}

			if (is_array($content))
			{
				foreach ($content as $c)
				{
					$buffer[] = $c;
				}
			}
			else
			{
				$buffer[] = $content;
			}

			// See above note
			if ($document->_mime != 'text/html')
			{
				$buffer[] = $tab . $tab . ']]>';
			}
			$buffer[] = $tab . '</script>';
		}

		// Generate script language declarations.
		if (count(\Lang::script()))
		{
			$buffer[] = $tab . '<script type="text/javascript">';
			$buffer[] = $tab . $tab . '(function() {';
			$buffer[] = $tab . $tab . $tab . 'var strings = ' . json_encode(\Lang::script()) . ';';
			$buffer[] = $tab . $tab . $tab . 'if (typeof Hubzero == \'undefined\') {';
			$buffer[] = $tab . $tab . $tab . $tab . 'Hubzero = {};';
			$buffer[] = $tab . $tab . $tab . $tab . 'Hubzero.Lang = strings;';
			$buffer[] = $tab . $tab . $tab . '} else {';
			$buffer[] = $tab . $tab . $tab . $tab . 'Hubzero.Lang.load(strings);';
			$buffer[] = $tab . $tab . $tab . '}';
			$buffer[] = $tab . $tab . '})();';
			$buffer[] = $tab . '</script>';
		}

		foreach ($document->_custom as $custom)
		{
			$buffer[] = $tab . $custom;
		}

		return implode($lnEnd, $buffer);
	}
202198
private function mapPages(ArticleDocument $document, ArticleViewDocumentInterface $article)
    {
        $pages = [];
        /** @var ArticlePageDocument $child */
        foreach ($document->getChildren() as $child) {
            if (!$child instanceof ArticlePageDocument) {
                continue;
            }

            /** @var ArticlePageViewObject $page */
            $pages[] = $page = $this->documentFactory->create('article_page');
            $page->uuid = $child->getUuid();
            $page->pageNumber = $child->getPageNumber();
            $page->title = $child->getPageTitle();
            $page->routePath = $child->getRoutePath();
            $page->contentData = json_encode($child->getStructure()->toArray());
        }

        $article->setPages(new Collection($pages));
    }
638825
public function getNodeLocalCanonical(NodeInterface $node) : ?string
    {
        if ($this->isNodeBlacklisted($node)) {
            return 'node/' . $node->id();
        }

        if ($this->siteManager->hasContext()) {
            return $this->aliasManager->getPathAlias($node->id(), $this->siteManager->getContext()->getId());
        }
    }
1312319
private function getTitle(): string {
        $openGraph = $this->article()->getOpenGraph();

        // Rely on OpenGraph in case we have the data
        if (isset($openGraph['title'])) {
            return $this->cleanTitle($openGraph['title']);
        }

        $nodes = $this->getNodesByLowercasePropertyValue($this->article()->getDoc(), 'meta', 'name', 'headline');
        if ($nodes->count()) {
            return $this->cleanTitle($nodes->first()->attr('content'));
        }

        $nodes = $this->article()->getDoc()->find('html > head > title');
        if ($nodes->count()) {
            return $this->cleanTitle(Helper::textNormalise($nodes->first()->text()));
        }

        return '';
    }
1344824
public function getDocumentationFromNode($node)
    {
        // Any NamespaceDefinition comments likely apply to the file, not the declaration itself.
        if ($node instanceof Node\Statement\NamespaceDefinition) {
            return null;
        }

        // For properties and constants, set the node to the declaration node, rather than the individual property.
        // This is because they get defined as part of a list.
        $constOrPropertyDeclaration = ParserHelpers\tryGetPropertyDeclaration($node) ?? ParserHelpers\tryGetConstOrClassConstDeclaration($node);
        if ($constOrPropertyDeclaration !== null) {
            $node = $constOrPropertyDeclaration;
        }

        // For parameters, parse the function-like declaration to get documentation for a parameter
        if ($node instanceof Node\Parameter) {
            $variableName = $node->getName();

            $functionLikeDeclaration = ParserHelpers\getFunctionLikeDeclarationFromParameter($node);
            $docBlock = $this->getDocBlock($functionLikeDeclaration);

            $parameterDocBlockTag = $this->tryGetDocBlockTagForParameter($docBlock, $variableName);
            return $parameterDocBlockTag !== null ? $parameterDocBlockTag->getDescription()->render() : null;
        }

        // For everything else, get the doc block summary corresponding to the current node.
        $docBlock = $this->getDocBlock($node);
        if ($docBlock !== null) {
            // check whether we have a description, when true, add a new paragraph
            // with the description
            $description = $docBlock->getDescription()->render();

            if (empty($description)) {
                return $docBlock->getSummary();
            }

            return $docBlock->getSummary() . "\n\n" . $description;
        }
        return null;
    }
924920
public function documentTitle()
    {
        $siteName  = $this->siteName();
        $pageTitle = strip_tags($this->title());

        if ($pageTitle) {
            if ($pageTitle === $siteName) {
                return sprintf('%1$s &#8212; Charcoal', $pageTitle);
            } else {
                return sprintf('%1$s &lsaquo; %2$s &#8212; Charcoal', $pageTitle, $siteName);
            }
        }

        return $siteName;
    }
13073
public function getTitle()
    {
        $node = $this->html->findFirstTag('title');

        return $node ? trim($node->nodeValue) : null;
    }
825713
private static function getDocumentClass(DocumentInterface $document): string
    {
        return $document instanceof ProxyInterface ? $document->getRealClass() : get_class($document);
    }
132039
public function getSubscriptionName(DocumentNode $document): string
    {
        return $document->definitions[0]->selectionSet->selections[0]->name->value;
    }
1267626
public function processContent(string $content): string
    {
        return Strings::replace($content, self::HEADLINE_PATTERN, function (array $result): string {
            $titleWithoutTags = strip_tags($result['title']);
            $headlineId = Strings::webalize($titleWithoutTags);
            $titleWithLink = Strings::match($result['title'], self::LINK_PATTERN);
            $titleHasLink = is_array($titleWithLink) ? count($titleWithLink) > 0 : false;

            // Title contains <a> element
            if ($result['title'] !== $titleWithoutTags && $titleHasLink) {
                return sprintf(
                    '<h%s id="%s">%s</h%s>',
                    $result['level'],
                    $headlineId,
                    $result['title'],
                    $result['level']
                );
            }

            return sprintf(
                '<h%s id="%s"><a href="#%s" class="heading-anchor">%s</a></h%s>',
                $result['level'],
                $headlineId,
                $headlineId,
                $result['title'],
                $result['level']
            );
        });
    }
447701
public function getContentTypePageUrl(ContentTypePage $page, ContentInterface $document)
    {
        return $this->router->generate(
            $this->getRouteName($page),
            $this->getRoutingParamaters($page, $document)
        );
    }
184822
public function getTitleText()
    {
        if ($this->UseLevelTitle && ($page = $this->getCurrentPage(Page::class))) {
            return $page->MenuTitle;
        }
        
        return parent::getTitleText();
    }
512224
public function getNodeForDocument($document)
    {
        $oid = $this->getObjectIdentifier($document);
        $this->assertDocumentExists($document);

        return $this->nodeMap[$this->documentNodeMap[$oid]];
    }
679022
public function nodeToDslText(NodeInterface $node)
    {
        switch ($node->getNodeType()) {
            case Node::TYPE_USE_CASE:
                return $this->useCaseNodeToDslText($node);
                break;
            default:
                throw new \InvalidArgumentException('Unknown node type "' . $node->getNodeType() . '"');
                break;
        }
    }
268182
public function getParent($document)
    {
        $parentNode = $this->getNode($document)->getParent();

        if (!$parentNode) {
            return;
        }

        return $this->proxyFactory->createProxyForNode($document, $parentNode);
    }
826740
private function getArticleForPage(ArticleDocument $article, $pageNumber)
    {
        $children = $article->getChildren();
        if (null === $children || 1 === $pageNumber) {
            return $article;
        }

        foreach ($children as $child) {
            if ($child instanceof ArticlePageDocument && $child->getPageNumber() === $pageNumber) {
                return $child;
            }
        }

        return $article;
    }