Changeset View
Changeset View
Standalone View
Standalone View
branches/5.2.x/core/units/helpers/page_helper.php
Show All 38 Lines | |||||
/** | /** | ||||
* Returns current admin user id (even, when called from front-end) and it's revision history view permission | * Returns current admin user id (even, when called from front-end) and it's revision history view permission | ||||
* | * | ||||
* @param int $page_id | * @param int $page_id | ||||
* @return Array | * @return Array | ||||
*/ | */ | ||||
protected function getHistoryPermissionAndUser($page_id) | protected function getHistoryPermissionAndUser($page_id) | ||||
{ | { | ||||
/** @var kPermissionsHelper $perm_helper */ | |||||
$perm_helper = $this->Application->recallObject('PermissionsHelper'); | $perm_helper = $this->Application->recallObject('PermissionsHelper'); | ||||
/* @var $perm_helper kPermissionsHelper */ | |||||
$user_id = (int)$this->Application->RecallVar($this->Application->isAdmin ? 'user_id' : 'admin_user_id'); | $user_id = (int)$this->Application->RecallVar($this->Application->isAdmin ? 'user_id' : 'admin_user_id'); | ||||
$history_permission = $perm_helper->CheckUserPermission($user_id, 'CATEGORY.REVISION.HISTORY.VIEW', 0, $page_id); | $history_permission = $perm_helper->CheckUserPermission($user_id, 'CATEGORY.REVISION.HISTORY.VIEW', 0, $page_id); | ||||
return Array ($user_id, $history_permission); | return Array ($user_id, $history_permission); | ||||
} | } | ||||
/** | /** | ||||
Show All 22 Lines | |||||
/** | /** | ||||
* Returns information about current revision. | * Returns information about current revision. | ||||
* | * | ||||
* @return array | * @return array | ||||
*/ | */ | ||||
protected function getCurrentRevisionInfo() | protected function getCurrentRevisionInfo() | ||||
{ | { | ||||
/** @var kDBItem $revision */ | |||||
$revision = $this->Application->recallObject('page-revision.current'); | $revision = $this->Application->recallObject('page-revision.current'); | ||||
/* @var $revision kDBItem */ | |||||
$status_label = $this->getRevisionStatusText($revision); | $status_label = $this->getRevisionStatusText($revision); | ||||
$draft = $revision->GetDBField('IsDraft'); | $draft = $revision->GetDBField('IsDraft'); | ||||
$title = $this->getAdminPhrase($draft ? 'la_title_EditingDraft' : 'la_title_ViewingRevision'); | $title = $this->getAdminPhrase($draft ? 'la_title_EditingDraft' : 'la_title_ViewingRevision'); | ||||
$current_revision_info = array( | $current_revision_info = array( | ||||
'title' => sprintf($title, $revision->GetDBField('RevisionNumber'), $status_label), | 'title' => sprintf($title, $revision->GetDBField('RevisionNumber'), $status_label), | ||||
▲ Show 20 Lines • Show All 71 Lines • ▼ Show 20 Line(s) | |||||
* Returns warning to be shown in case of parallel editing attempts. | * Returns warning to be shown in case of parallel editing attempts. | ||||
* | * | ||||
* @param array $users Users, that are editing a page. | * @param array $users Users, that are editing a page. | ||||
* | * | ||||
* @return string | * @return string | ||||
*/ | */ | ||||
protected function getEditorsWarning(array $users) | protected function getEditorsWarning(array $users) | ||||
{ | { | ||||
/** @var kMultiLanguageHelper $ml_helper */ | |||||
$ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); | $ml_helper = $this->Application->recallObject('kMultiLanguageHelper'); | ||||
/* @var $ml_helper kMultiLanguageHelper */ | |||||
$ret = $ml_helper->getPluralPhrase( | $ret = $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 All 11 Lines | |||||
* @return array | * @return array | ||||
*/ | */ | ||||
protected function getPageRevisions($page_id) | protected function getPageRevisions($page_id) | ||||
{ | { | ||||
$ret = Array (); | $ret = Array (); | ||||
$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(); | ||||
while ( !$revisions->EOL() ) { | while ( !$revisions->EOL() ) { | ||||
$ret[ 'r' . $revisions->GetDBField('RevisionNumber') ] = array( | $ret[ 'r' . $revisions->GetDBField('RevisionNumber') ] = array( | ||||
'title' => $this->getRevisionTitle($revisions), | 'title' => $this->getRevisionTitle($revisions), | ||||
'status' => $revisions->GetDBField('Status'), | 'status' => $revisions->GetDBField('Status'), | ||||
▲ Show 20 Lines • Show All 161 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 | ||||
/** @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)); | ||||
/* @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)); | ||||
/* @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 |