Changeset View
Changeset View
Standalone View
Standalone View
core/units/page_revisions/page_revision_eh.php
Show First 20 Lines • Show All 217 Lines • ▼ Show 20 Line(s) | |||||
if ( $status != $object->GetOriginalField('Status') && $status == STATUS_ACTIVE ) { | if ( $status != $object->GetOriginalField('Status') && $status == STATUS_ACTIVE ) { | ||||
/** @var kDBItem $page */ | /** @var kDBItem $page */ | ||||
$page = $this->Application->recallObject('c.revision', null, Array ('skip_autoload' => true)); | $page = $this->Application->recallObject('c.revision', null, Array ('skip_autoload' => true)); | ||||
$page->Load($object->GetDBField('PageId')); | $page->Load($object->GetDBField('PageId')); | ||||
$page->SetDBField('LiveRevisionNumber', $object->GetDBField('RevisionNumber')); | $page->SetDBField('LiveRevisionNumber', $object->GetDBField('RevisionNumber')); | ||||
$page->Update(); | $page->Update(); | ||||
} | } | ||||
$this->syncPageContent($object->GetDBField('RevisionId')); | |||||
} | |||||
alex: remove page filter
---
the RevisionId is unique to a page, it's RevisionNumber that isn't | |||||
/** | |||||
Not Done Replyinline there only 1 condition left alex: inline
---
there only 1 condition left | |||||
* Update searchable content of the page. | |||||
* | |||||
* @param integer $revision_id Revision Id. | |||||
* | |||||
* @return void | |||||
Not Done Replyperform this SQL directly in the syncPageContent method alex: perform this SQL directly in the `syncPageContent` method | |||||
*/ | |||||
protected function syncPageContent($revision_id) | |||||
{ | |||||
$sql = 'SELECT * | |||||
FROM ' . TABLE_PREFIX . 'PageContent | |||||
WHERE RevisionId = ' . $revision_id; | |||||
$blocks = $this->Conn->Query($sql); | |||||
if ( !$blocks ) { | |||||
return; | |||||
} | |||||
/** @var kMultiLanguageHelper $ml_helper */ | |||||
$ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); | |||||
Not Done Replyspecify $revision_id instead of $blocks alex: specify `$revision_id` instead of `$blocks` | |||||
$fields_hash = array(); | |||||
foreach ( $ml_helper->getLanguages() as $language_id ) { | |||||
$page_content = array(); | |||||
Not Done Replyplease inline variable used only once alex: please inline
---
variable used only once | |||||
foreach ( $blocks as $block ) { | |||||
if ( $block['l' . $language_id . '_Content'] ) { | |||||
$page_content[] = $block['l' . $language_id . '_Content']; | |||||
} | |||||
} | |||||
if ( $page_content ) { | |||||
$page_content = strip_tags(kUtil::unescape(implode(' ', $page_content), kUtil::ESCAPE_HTML)); | |||||
$fields_hash['l' . $language_id . '_ContentBlockContent'] = $page_content; | |||||
} | |||||
} | |||||
if ( $fields_hash ) { | |||||
$this->Conn->doUpdate( | |||||
$fields_hash, | |||||
TABLE_PREFIX . 'PageRevisions', | |||||
'RevisionId = ' . $revision_id | |||||
Not Done ReplyUse revision ID given to the method. alex: Use revision ID given to the method. | |||||
); | |||||
Not Done Replyinline alex: inline | |||||
} | |||||
Not Done Replyformat as multi-line function call alex: format as multi-line function call | |||||
} | } | ||||
/** | /** | ||||
* Returns user, who are editing current page right now | * Returns user, who are editing current page right now | ||||
* | * | ||||
* @param kEvent $event | * @param kEvent $event | ||||
*/ | */ | ||||
function OnGetInfo($event) | function OnGetInfo($event) | ||||
▲ Show 20 Lines • Show All 144 Lines • Show Last 20 Lines |
remove page filter
the RevisionId is unique to a page, it's RevisionNumber that isn't