Improves to get the content

This commit is contained in:
Diego Najar 2017-09-29 19:06:18 +02:00
parent cfe4fb79a2
commit 341858ce02
1 changed files with 17 additions and 8 deletions

View File

@ -40,8 +40,15 @@ class Page {
// Check if the current line start the content of the page // Check if the current line start the content of the page
// We have two breakers, the word content or 3 dash --- // We have two breakers, the word content or 3 dash ---
if( ($field==='content') || ($field==='---') ) { if ($field==='content') {
$tmp = $lineNumber; $tmp = $lineNumber;
$styleTypeUsed = 'Content:';
break;
}
if ($field==='---') {
$tmp = $lineNumber;
$styleTypeUsed = '---';
break; break;
} }
@ -68,12 +75,14 @@ class Page {
// Process the content // Process the content
if ($tmp!==0) { if ($tmp!==0) {
// Next line after "Content:" or "---" // Get all lines starting from "Content:" or "---"
$tmp++;
// Get all lines after "Content:" or "---"
$content = array_slice($file, $tmp); $content = array_slice($file, $tmp);
// Remove "Content:" or "---" and keep next characters if there are
$content[0] = substr($content[0], strpos($content[0], $styleTypeUsed) + strlen($styleTypeUsed));
$content[0] = trim($content[0]);
// Join lines in one variable, this is RAW content from file // Join lines in one variable, this is RAW content from file
$this->vars['contentRaw'] = implode($content); $this->vars['contentRaw'] = implode($content);
} }
@ -84,7 +93,7 @@ class Page {
// Returns TRUE if the content is loaded correctly, FALSE otherwise // Returns TRUE if the content is loaded correctly, FALSE otherwise
public function isValid() public function isValid()
{ {
return($this->vars!==false); return $this->vars!==false;
} }
// DEPRACTED // DEPRACTED