Render an Article content

@author Vincent Chalamon <vincentchalamon@gmail.com>

@param Article $article Article object
@param string  $name    Contents name

@return null|string
776715
public function renderContents(Article $article, $name)
    {
        $content = $article->getContent($name);

        return $content ? $content->getContents() : null;
    }
990614
public function replaceBy($name)
    {
        $content = $this->get($name);
        if ($content === self::NO_SECTION_RENDER) {
            ob_end_clean();

            return; // do not render anything.
        } elseif ($content) {
            ob_end_clean();
            echo $content;
        } else {
            echo ob_get_clean();
        }
    }
534005
private function generateArticleReplacement(ArticleModel $article)
    {
        /** @var Article $adapter */
        $adapter = $this->framework->getAdapter(ContentElement::class);
        return $adapter->getArticle($article);
    }
844831
public function renderPageContainer($name = '')
    {
        $name = $this->prepareContainerName($name);

        /** @var \Zend\View\Renderer\PhpRenderer $view */
        $view = $this->getView();

        return $this->getPageContainerHtmlByName($view->page, $name);
    }
138682
public function createNewContent($name)
    {
        $this->getSession()->visit('/admin/content');
        $contentTypes = $this->getSession()->getPage()->findAll('xpath', '//div[@class="megamenu-content"]//li');

        if (is_array($contentTypes) && count($contentTypes)) {
            // Put the content type here
            $_element = null;

            // Iterate the content types in the list
            foreach ($contentTypes as $element) {
                /** @var \Behat\Mink\Element\NodeElement $element */
                if (false !== strpos($element->getText(), $name)) {
                    $_element = $element;
                }
            }

            if (null === $_element) {
                throw new ExpectationException(
                    sprintf('Content type %s not found under "Create new". do you have the correct rights?', $name),
                    $this->getSession()->getDriver()
                );
            }

            $_element->clickLink($name);
        } else {
            // No navigation found
            throw new ExpectationException(
                'No content items found under "Create new", are you sure you are loggedin?',
                $this->getSession()->getDriver()
            );
        }
    }
911488
function attribute( $name )
    {
        if ( $name === 'is_editor_enabled' )
            $attr = self::isEditorEnabled();
        else if ( $name === 'can_disable' )
            $attr = $this->currentUserHasAccess( 'disable_editor' );
        else if ( $name === 'editor_layout_settings' )
            $attr = $this->getEditorLayoutSettings();
        else if ( $name === 'browser_supports_dhtml_type' )
            $attr = self::browserSupportsDHTMLType();
        else if ( $name === 'is_compatible_version' )
            $attr = $this->isCompatibleVersion();
        else if ( $name === 'version' )
            $attr = self::version();
        else if ( $name === 'ezpublish_version' )
            $attr = $this->eZPublishVersion;
        else if ( $name === 'xml_tag_alias' )
            $attr =  self::getXmlTagAliasList();
        else if ( $name === 'json_xml_tag_alias' )
            $attr =  json_encode( self::getXmlTagAliasList() );
        else
            $attr = parent::attribute( $name );
        return $attr;
    }
551805
public function render($name = '', $params = null, $content = null)
	{
		$now  = new Date('now');
		$data = $this->doc;

		$url = App::get('request')->root();

		$tz = new \DateTimeZone(App::get('config')->get('offset'));

		$syndicationURL = App::get('router')->url('&format=feed&type=atom');

		if (App::get('config')->get('sitename_pagetitles', 0) == 1)
		{
			$data->title = App::get('language')->txt('JPAGETITLE', App::get('config')->get('sitename'), $data->title);
		}
		elseif (App::get('config')->get('sitename_pagetitles', 0) == 2)
		{
			$data->title = App::get('language')->txt('JPAGETITLE', $data->title, App::get('config')->get('sitename'));
		}

		$feed_title = htmlspecialchars($data->title, ENT_COMPAT, 'UTF-8');

		$feed  = "<feed xmlns=\"http://www.w3.org/2005/Atom\" ";
		if ($data->language != "")
		{
			$feed .= " xml:lang=\"" . $data->language . "\"";
		}
		$feed .= ">\n";
		$feed .= "	<title type=\"text\">" . $feed_title . "</title>\n";
		$feed .= "	<subtitle type=\"text\">" . htmlspecialchars($data->description, ENT_COMPAT, 'UTF-8') . "</subtitle>\n";
		if (empty($data->category) === false)
		{
			if (is_array($data->category))
			{
				foreach ($data->category as $cat)
				{
					$feed .= "	<category term=\"" . htmlspecialchars($cat, ENT_COMPAT, 'UTF-8') . "\" />\n";
				}
			}
			else
			{
				$feed .= "	<category term=\"" . htmlspecialchars($data->category, ENT_COMPAT, 'UTF-8') . "\" />\n";
			}
		}
		$feed .= "	<link rel=\"alternate\" type=\"text/html\" href=\"" . $url . "\"/>\n";
		$feed .= "	<id>" . str_replace(' ', '%20', $data->getBase()) . "</id>\n";
		$feed .= "	<updated>" . htmlspecialchars($now->toISO8601(true), ENT_COMPAT, 'UTF-8') . "</updated>\n";
		if ($data->editor != "")
		{
			$feed .= "	<author>\n";
			$feed .= "		<name>" . $data->editor . "</name>\n";
			if ($data->editorEmail != "")
			{
				$feed .= "		<email>" . htmlspecialchars($data->editorEmail, ENT_COMPAT, 'UTF-8') . "</email>\n";
			}
			$feed .= "	</author>\n";
		}
		$feed .= "	<generator uri=\"http://hubzero.org\" version=\"2.5\">" . $data->getGenerator() . "</generator>\n";
		$feed .= '	<link rel="self" type="application/atom+xml" href="' . str_replace(' ', '%20', $url . $syndicationURL) . "\"/>\n";

		for ($i = 0, $count = count($data->items); $i < $count; $i++)
		{
			$feed .= "	<entry>\n";
			$feed .= "		<title>" . htmlspecialchars(strip_tags($data->items[$i]->title), ENT_COMPAT, 'UTF-8') . "</title>\n";
			$feed .= '		<link rel="alternate" type="text/html" href="' . $url . $data->items[$i]->link . "\"/>\n";

			if ($data->items[$i]->date == "")
			{
				$data->items[$i]->date = $now->toUnix();
			}
			$itemDate = new Date($data->items[$i]->date);
			$itemDate->setTimeZone($tz);

			$feed .= "		<published>" . htmlspecialchars($itemDate->toISO8601(true), ENT_COMPAT, 'UTF-8') . "</published>\n";
			$feed .= "		<updated>" . htmlspecialchars($itemDate->toISO8601(true), ENT_COMPAT, 'UTF-8') . "</updated>\n";
			if (empty($data->items[$i]->guid) === true)
			{
				$feed .= "		<id>" . str_replace(' ', '%20', $url . $data->items[$i]->link) . "</id>\n";
			}
			else
			{
				$feed .= "		<id>" . htmlspecialchars($data->items[$i]->guid, ENT_COMPAT, 'UTF-8') . "</id>\n";
			}

			if ($data->items[$i]->author != "")
			{
				$feed .= "		<author>\n";
				$feed .= "			<name>" . htmlspecialchars($data->items[$i]->author, ENT_COMPAT, 'UTF-8') . "</name>\n";
				if ($data->items[$i]->authorEmail != "")
				{
					$feed .= "			<email>" . htmlspecialchars($data->items[$i]->authorEmail, ENT_COMPAT, 'UTF-8') . "</email>\n";
				}
				$feed .= "		</author>\n";
			}
			if ($data->items[$i]->description != "")
			{
				$feed .= "		<summary type=\"html\">" . htmlspecialchars($data->items[$i]->description, ENT_COMPAT, 'UTF-8') . "</summary>\n";
				$feed .= "		<content type=\"html\">" . htmlspecialchars($data->items[$i]->description, ENT_COMPAT, 'UTF-8') . "</content>\n";
			}
			if (empty($data->items[$i]->category) === false)
			{
				if (is_array($data->items[$i]->category))
				{
					foreach ($data->items[$i]->category as $cat)
					{
						$feed .= "		<category term=\"" . htmlspecialchars($cat, ENT_COMPAT, 'UTF-8') . "\" />\n";
					}
				}
				else
				{
					$feed .= "		<category term=\"" . htmlspecialchars($data->items[$i]->category, ENT_COMPAT, 'UTF-8') . "\" />\n";
				}
			}
			if ($data->items[$i]->enclosure != null)
			{
				$feed .= "		<link rel=\"enclosure\" href=\"" . $data->items[$i]->enclosure->url . "\" type=\"" . $data->items[$i]->enclosure->type . "\"  length=\"" . $data->items[$i]->enclosure->length . "\" />\n";
			}
			$feed .= "	</entry>\n";
		}
		$feed .= "</feed>\n";
		return $feed;
	}
1151458
public static function tag($name, $content = NULL, Array $attributes = NULL) {
    $tag = new HTMLTag($name, $content, $attributes);
    return $tag;
  }
32662
protected function article(Article $article = null): ?Article {
        if ($article === null) {
            return $this->article;
        }

        $this->article = $article;

        return $this->article;
    }
1315791
public function getImageAltText(string $name, string $default = '') : string
    {
        $contentArea = $this->content->getImage($name);

        return ($contentArea ? $contentArea->altText : null) ?? $default;
    }
1153703
public function textarea($name, $id, $content = '', array $attr = null)
    {
        $basic = $this->merge_attr([ 'id' => $id ], $attr);

        return $this->input($name, [ 'id'      => $id, 'type'    => 'textarea', 'content' => $content,
                'attr'    => $basic ]);
    }
1253594
public function render()
    {
        parent::render();

        $this->_aViewData['edit'] = $article = oxNew(\OxidEsales\Eshop\Application\Model\Article::class);

        $oxId = $this->getEditObjectId();

        $this->_createCategoryTree("artcattree");

        // all categories
        if (isset($oxId) && $oxId != "-1") {
            // load object
            $article->loadInLang($this->_iEditLang, $oxId);

            $article = $this->updateArticle($article);

            // load object in other languages
            $otherLang = $article->getAvailableInLangs();
            if (!isset($otherLang[$this->_iEditLang])) {
                $article->loadInLang(key($otherLang), $oxId);
            }

            foreach ($otherLang as $id => $language) {
                $lang = new stdClass();
                $lang->sLangDesc = $language;
                $lang->selected = ($id == $this->_iEditLang);
                $this->_aViewData["otherlang"][$id] = clone $lang;
            }

            // variant handling
            if ($article->oxarticles__oxparentid->value) {
                $parentArticle = oxNew(\OxidEsales\Eshop\Application\Model\Article::class);
                $parentArticle->load($article->oxarticles__oxparentid->value);
                $this->_aViewData["parentarticle"] = $parentArticle;
                $this->_aViewData["oxparentid"] = $article->oxarticles__oxparentid->value;
            }
        }

        $this->prepareBundledArticlesDataForView($article);

        $iAoc = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("aoc");
        if ($iAoc == 1) {
            $oArticleExtendAjax = oxNew(\OxidEsales\Eshop\Application\Controller\Admin\ArticleExtendAjax::class);
            $this->_aViewData['oxajax'] = $oArticleExtendAjax->getColumns();

            return "popups/article_extend.tpl";
        } elseif ($iAoc == 2) {
            $oArticleBundleAjax = oxNew(\OxidEsales\Eshop\Application\Controller\Admin\ArticleBundleAjax::class);
            $this->_aViewData['oxajax'] = $oArticleBundleAjax->getColumns();

            return "popups/article_bundle.tpl";
        }

        //load media files
        $this->_aViewData['aMediaUrls'] = $article->getMediaUrls();

        return "article_extend.tpl";
    }
718826
private function getArticleFullUrlForRequest($cat, $article)
    {
        $catParameter = array();
        if (null !== $cat) {
            $catParameter = array(TdbShopArticle::CMS_LINKABLE_OBJECT_PARAM_CATEGORY => $cat->id);
        }

        return $article->getLink(false, null, $catParameter);
    }
1163019
public function createBlankArticle(Article &$article)
		{
			$form_data = array(
				'article_name' => $article->getName()
			);
			$data = $this->call('createblankarticle', $form_data);

			$article->setId((int)trim($data[1]));
		}
602171
public function render($name, $content)
    {
        list($data, $content) = (array) Matter::parse($content);

        $data = array_merge($data, (array) $this->data);

        $data['title'] = isset($data['title']) ? $data['title'] : '';

        $output = $this->website->content()->make($content);

        if ($data['title'] === '') {
            preg_match('/<h1>(.*?)<\/h1>/', $output, $matches);

            isset($matches[1]) && $data['title'] = $matches[1];
        }

        $data['content'] = (string) $output;

        return $this->renderer->render($name, $data);
    }
785697
public function getArticle($articleNumber)
    {
        $requestData = new Get\RequestData();
        $requestData->setArticleNumber($articleNumber);

        $request = new Get\Request($requestData);
        $request->setLimit(1);

        /** @var Get\ApiResponse $apiResponse */
        $apiResponse = $this->sendRequest($request, Get\ApiResponse::class);
        $articles = $apiResponse->getResponse()->getArticles();

        return isset($articles[0]) ? $articles[0] : null;
    }
380546
public function render()
    {
        parent::render();

        $oArticle = oxNew(\OxidEsales\Eshop\Application\Model\Article::class);
        $this->_aViewData["edit"] = $oArticle;

        $soxId = $this->getEditObjectId();
        if (isset($soxId) && $soxId != "-1") {
            if ($oArticle->isDerived()) {
                $this->_aViewData['readonly'] = true;
            }

            // load object
            $oArticle->load($soxId);
        }

        return "article_userdef.tpl";
    }