Changeset View
Changeset View
Standalone View
Standalone View
core/units/helpers/page_helper.php
Show All 37 Lines | |||||
WHERE (' . implode(') AND (', $where_clause) . ')'; | WHERE (' . implode(') AND (', $where_clause) . ')'; | ||||
$users = $this->Conn->GetCol($sql); | $users = $this->Conn->GetCol($sql); | ||||
$page_revisions = Array (); | $page_revisions = Array (); | ||||
if ( $history_permission ) { | if ( $history_permission ) { | ||||
$tag_params = Array ('per_page' => -1, 'skip_parent_filter' => 1, 'requery' => 1, 'page_id' => $page_id); | $tag_params = Array ('per_page' => -1, 'skip_parent_filter' => 1, 'requery' => 1, 'page_id' => $page_id); | ||||
/** @var kDBList $revisions */ | |||||
$revisions = $this->Application->recallObject('page-revision.list', 'page-revision_List', $tag_params); | $revisions = $this->Application->recallObject('page-revision.list', 'page-revision_List', $tag_params); | ||||
/* @var $revisions kDBList */ | |||||
$revisions->Query(); | $revisions->Query(); | ||||
$revisions->GoFirst(); | $revisions->GoFirst(); | ||||
$status_options = $revisions->GetFieldOptions('Status'); | $status_options = $revisions->GetFieldOptions('Status'); | ||||
$draft_label = $this->Application->Phrase('la_Draft', false, true); | $draft_label = $this->Application->Phrase('la_Draft', false, true); | ||||
$title_label = $this->Application->Phrase('la_RevisionNumber', false, true); | $title_label = $this->Application->Phrase('la_RevisionNumber', false, true); | ||||
$by_label = $this->Application->Phrase('la_By', false, true); | $by_label = $this->Application->Phrase('la_By', false, true); | ||||
Show All 10 Lines | |||||
'author' => $by_label . ': ' . $revisions->GetField('CreatedById'), | 'author' => $by_label . ': ' . $revisions->GetField('CreatedById'), | ||||
'draft' => (int)$revisions->GetDBField('IsDraft'), | 'draft' => (int)$revisions->GetDBField('IsDraft'), | ||||
); | ); | ||||
$revisions->GoNext(); | $revisions->GoNext(); | ||||
} | } | ||||
} | } | ||||
/** @var kDBItem $current_revision */ | |||||
$current_revision = $this->Application->recallObject('page-revision.current'); | $current_revision = $this->Application->recallObject('page-revision.current'); | ||||
/* @var $current_revision kDBItem */ | |||||
$revision_status = $current_revision->GetDBField('Status'); | $revision_status = $current_revision->GetDBField('Status'); | ||||
$status_options = $current_revision->GetFieldOptions('Status'); | $status_options = $current_revision->GetFieldOptions('Status'); | ||||
$status_label = $this->Application->Phrase($status_options['options'][$revision_status], false, true); | $status_label = $this->Application->Phrase($status_options['options'][$revision_status], false, true); | ||||
$revision_phase = $current_revision->GetDBField('IsDraft') ? 'la_title_EditingDraft' : 'la_title_ViewingRevision'; | $revision_phase = $current_revision->GetDBField('IsDraft') ? 'la_title_EditingDraft' : 'la_title_ViewingRevision'; | ||||
$revision_title = sprintf($this->Application->Phrase($revision_phase, false, true), $current_revision->GetDBField('RevisionNumber'), mb_strtolower($status_label)); | $revision_title = sprintf($this->Application->Phrase($revision_phase, false, true), $current_revision->GetDBField('RevisionNumber'), mb_strtolower($status_label)); | ||||
$current_revision_info = Array ('title' => $revision_title, 'status' => $revision_status, 'saved' => ''); | $current_revision_info = Array ('title' => $revision_title, 'status' => $revision_status, 'saved' => ''); | ||||
$autosave_time = $current_revision->GetDBField('AutoSavedOn'); | $autosave_time = $current_revision->GetDBField('AutoSavedOn'); | ||||
if ( $autosave_time ) { | if ( $autosave_time ) { | ||||
$phrase = $this->Application->Phrase($current_revision->GetDBField('IsDraft') ? 'la_DraftSavedAt' : 'la_SavedAt', false, true); | $phrase = $this->Application->Phrase($current_revision->GetDBField('IsDraft') ? 'la_DraftSavedAt' : 'la_SavedAt', false, true); | ||||
$current_revision_info['saved'] = sprintf($phrase, $current_revision->GetField('AutoSavedOn_time') . ' (' . $this->getAgoTime($autosave_time) . ')'); | $current_revision_info['saved'] = sprintf($phrase, $current_revision->GetField('AutoSavedOn_time') . ' (' . $this->getAgoTime($autosave_time) . ')'); | ||||
} | } | ||||
/** @var kMultiLanguageHelper $ml_helper */ | |||||
$ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); | $ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); | ||||
/* @var $ml_helper kMultiLanguageHelper */ | |||||
$currently_editing = $ml_helper->getPluralPhrase( | $currently_editing = $ml_helper->getPluralPhrase( | ||||
count($users), | count($users), | ||||
Array ( | Array ( | ||||
'phrase1' => 'la_PageCurrentlyEditing1', | 'phrase1' => 'la_PageCurrentlyEditing1', | ||||
'phrase2' => 'la_PageCurrentlyEditing2', | 'phrase2' => 'la_PageCurrentlyEditing2', | ||||
'phrase5' => 'la_PageCurrentlyEditing5', | 'phrase5' => 'la_PageCurrentlyEditing5', | ||||
), | ), | ||||
▲ Show 20 Lines • Show All 109 Lines • ▼ Show 20 Line(s) | |||||
{ | { | ||||
$sql = 'SELECT pc.PageContentId, pr.RevisionId | $sql = 'SELECT pc.PageContentId, pr.RevisionId | ||||
FROM ' . TABLE_PREFIX . 'PageRevisions pr | FROM ' . TABLE_PREFIX . 'PageRevisions pr | ||||
LEFT JOIN ' . TABLE_PREFIX . 'PageContent pc ON pc.RevisionId = pr.RevisionId AND pc.ContentNum = ' . $num . ' | LEFT JOIN ' . TABLE_PREFIX . 'PageContent pc ON pc.RevisionId = pr.RevisionId AND pc.ContentNum = ' . $num . ' | ||||
WHERE pr.PageId = ' . $page_id; | WHERE pr.PageId = ' . $page_id; | ||||
$revisions = $this->Conn->GetCol($sql, 'RevisionId'); | $revisions = $this->Conn->GetCol($sql, 'RevisionId'); | ||||
if ( !$revisions ) { | if ( !$revisions ) { | ||||
// no revisions for a page -> create a live revision | // no revisions for a page -> create a live revision | ||||
Lint: CodingStandard.Commenting.InlineComment.InvalidEndChar: Inline comments must end in full-stops, exclamation marks, or question marks | |||||
Inline comments must start with a capital letter Lint: CodingStandard.Commenting.InlineComment.NotCapital: Inline comments must start with a capital letter | |||||
/** @var kDBItem $revision */ | |||||
$revision = $this->Application->recallObject('page-revision.live', null, Array ('skip_autoload' => true)); | $revision = $this->Application->recallObject('page-revision.live', null, Array ('skip_autoload' => true)); | ||||
There must be no space between the Array keyword and the opening parenthesis Lint: CodingStandard.Array.Array.SpaceAfterKeyword: There must be no space between the Array keyword and the opening parenthesis | |||||
PHP keywords must be lowercase; expected "array" but found "Array" Lint: Generic.PHP.LowerCaseKeyword.Found: PHP keywords must be lowercase; expected "array" but found "Array" | |||||
/* @var $revision kDBItem */ | |||||
$revision->SetDBField('PageId', $page_id); | $revision->SetDBField('PageId', $page_id); | ||||
$revision->SetDBField('RevisionNumber', 1); | $revision->SetDBField('RevisionNumber', 1); | ||||
$revision->SetDBField('Status', STATUS_ACTIVE); | $revision->SetDBField('Status', STATUS_ACTIVE); | ||||
$revision->Create(); | $revision->Create(); | ||||
$revisions[ $revision->GetID() ] = NULL; | $revisions[ $revision->GetID() ] = NULL; | ||||
} | } | ||||
/** @var kDBItem $content_block */ | |||||
$content_block = $this->Application->recallObject('content.new', null, Array ('skip_autoload' => true)); | $content_block = $this->Application->recallObject('content.new', null, Array ('skip_autoload' => true)); | ||||
PHP keywords must be lowercase; expected "array" but found "Array" Lint: Generic.PHP.LowerCaseKeyword.Found: PHP keywords must be lowercase; expected "array" but found "Array" | |||||
There must be no space between the Array keyword and the opening parenthesis Lint: CodingStandard.Array.Array.SpaceAfterKeyword: There must be no space between the Array keyword and the opening parenthesis | |||||
/* @var $content_block kDBItem */ | |||||
$content_block->SetDBField('PageId', $page_id); | $content_block->SetDBField('PageId', $page_id); | ||||
$content_block->SetDBField('ContentNum', $num); | $content_block->SetDBField('ContentNum', $num); | ||||
foreach ($revisions as $revision_id => $content_block_id) { | foreach ($revisions as $revision_id => $content_block_id) { | ||||
if ( is_numeric($content_block_id) ) { | if ( is_numeric($content_block_id) ) { | ||||
continue; | continue; | ||||
} | } | ||||
Show All 37 Lines |
Inline comments must end in full-stops, exclamation marks, or question marks