Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/helpers/page_helper.php
Show First 20 Lines • Show All 432 Lines • ▼ Show 20 Line(s) | |||||
WHERE (' . $content_block->TableName . '.PageId = ' . $page_id . ') AND (' . $content_block->TableName . '.ContentNum = ' . $num . ') AND (' . $revision_clause . ') | WHERE (' . $content_block->TableName . '.PageId = ' . $page_id . ') AND (' . $content_block->TableName . '.ContentNum = ' . $num . ') AND (' . $revision_clause . ') | ||||
ORDER BY pr.IsDraft DESC, pr.RevisionNumber DESC'; | ORDER BY pr.IsDraft DESC, pr.RevisionNumber DESC'; | ||||
$content_data = $this->Conn->GetRow($sql); | $content_data = $this->Conn->GetRow($sql); | ||||
$content_block->LoadFromHash($content_data); | $content_block->LoadFromHash($content_data); | ||||
return $content_block->isLoaded(); | return $content_block->isLoaded(); | ||||
} | } | ||||
/** | |||||
* Returns revision content | |||||
* | |||||
* @param integer $page_revision_id Page revision Id. | |||||
* | |||||
* @return array | |||||
*/ | |||||
public function getRevisionContent($page_revision_id) | |||||
{ | |||||
$sql = 'SELECT * | |||||
FROM ' . TABLE_PREFIX . 'PageContent | |||||
WHERE RevisionId = ' . $page_revision_id; | |||||
$blocks = $this->Conn->GetIterator($sql); | |||||
/** @var kMultiLanguageHelper $ml_helper */ | |||||
$ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); | |||||
$content = array(); | |||||
foreach ( $ml_helper->getLanguages() as $lang_id ) { | |||||
$parts = array(); | |||||
foreach ( $blocks as $block_data ) { | |||||
if ( (string)$block_data['l' . $lang_id . '_Content'] !== '' ) { | |||||
$parts[] = $this->makeSearchable($block_data['l' . $lang_id . '_Content']); | |||||
} | |||||
} | |||||
$content['l' . $lang_id . '_PageContent'] = implode(' ', $parts); | |||||
} | |||||
return $content; | |||||
} | |||||
/** | |||||
* Unescapes and removes tags | |||||
* | |||||
* @param string $content Content. | |||||
* | |||||
* @return string | |||||
*/ | |||||
protected function makeSearchable($content) | |||||
{ | |||||
return trim(strip_tags(html_entity_decode($content, ENT_QUOTES, 'UTF-8'))); | |||||
} | |||||
} | } |