Changeset View
Changeset View
Standalone View
Standalone View
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 string | |||||
*/ | |||||
public function getRevisionContent($page_revision_id) | |||||
{ | |||||
/** @var kMultiLanguageHelper $ml_helper */ | |||||
$ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); | |||||
$field_sql = array(); | |||||
foreach ( $ml_helper->getLanguages() as $lang_id ) { | |||||
$content = 'l' . $lang_id . '_Content'; | |||||
$field_sql[] = 'GROUP_CONCAT(COALESCE(' . $content . ', "") SEPARATOR " ") | |||||
AS l' . $lang_id . '_PageContent'; | |||||
} | |||||
$sql = 'SELECT ' . implode(', ', $field_sql) . ' | |||||
FROM ' . TABLE_PREFIX . 'PageContent | |||||
WHERE RevisionId = ' . $page_revision_id; | |||||
$content = $this->Conn->GetRow($sql); | |||||
alex: Instead of selecting single row, where content block data is merged per-language we need to:
#… | |||||
return array_map(array($this, 'makeSearchable'), $content); | |||||
} | |||||
/** | |||||
* Unescapes and removes tags | |||||
* | |||||
* @param string $content Content. | |||||
* | |||||
* @return string | |||||
*/ | |||||
protected function makeSearchable($content) | |||||
{ | |||||
return strip_tags(html_entity_decode($content, ENT_QUOTES)); | |||||
} | |||||
} | } |
Instead of selecting single row, where content block data is merged per-language we need to:
The GROUP_CONCAT function truncates result to 1024 bytes (see https://dev.mysql.com/doc/refman/8.0/en/group-by-functions.html#function_group-concat) making resulting string only 1KB long. This prevents searching pages with more than 1KB long.