Add getPureContent to Page to be able to get content without template

Cette révision appartient à :
Stéphane Goetz 2016-03-13 21:51:15 +01:00
Parent d8f7a6e238
révision 55ef0b982b
7 fichiers modifiés avec 38 ajouts et 5 suppressions

Voir le fichier

@ -15,4 +15,9 @@ abstract class ComputedRawPage implements Page
{
return $this->raw->getContent();
}
public function getPureContent()
{
return $this->raw->getContent();
}
}

Voir le fichier

@ -21,6 +21,8 @@ abstract class ContentPage extends SimplePage
*/
protected $contentType;
protected $generatedContent;
public function __construct($title, $content)
{
$this->initializePage($title, $content);
@ -49,14 +51,18 @@ abstract class ContentPage extends SimplePage
$this->contentType = $contentType;
}
protected function convertPage($content)
public function getPureContent()
{
return $this->contentType->convert($content, $this->getFile());
if (!$this->generatedContent) {
$this->generatedContent = $this->contentType->convert($this->content, $this->getFile());
}
return $this->generatedContent;
}
protected function generatePage()
{
return $this->convertPage($this->content);
return $this->getPureContent();
}
public static function fromFile(Content $file, $params, ContentType $contentType)

Voir le fichier

@ -2,5 +2,17 @@
interface Page
{
/**
* Get the converted content, without any template
*
* @return string
*/
public function getPureContent();
/**
* Get the full content
*
* @return mixed
*/
public function getContent();
}

Voir le fichier

@ -16,6 +16,11 @@ abstract class RawPage implements Page
return $this->file;
}
public function getPureContent()
{
throw new Exception("you should not use this method to show a raw content");
}
public function getContent()
{
throw new Exception("you should not use this method to show a raw content");

Voir le fichier

@ -11,6 +11,11 @@ abstract class SimplePage implements Page
$this->initializePage($title, $content);
}
public function getPureContent()
{
return $this->content;
}
public function getContent()
{
if (is_null($this->generated)) {

Voir le fichier

@ -81,7 +81,7 @@ class ContentPage extends \Todaymade\Daux\Format\Base\ContentPage
'modified_time' => filemtime($this->file->getPath()),
'markdown' => $this->content,
'request' => $params['request'],
'content' => $this->convertPage($this->content),
'content' => $this->getPureContent(),
'breadcrumbs' => $params['html']['breadcrumbs'],
'prev' => $this->file->getPrevious(),
'next' => $this->file->getNext(),

Voir le fichier

@ -33,7 +33,7 @@ class ErrorPage extends SimplePage
$params = $this->params;
$page = [
'title' => $this->title,
'content' => $this->content,
'content' => $this->getPureContent(),
'language' => '',
];