Skip to content

Commit

Permalink
Adds a watched status to the current page information.
Browse files Browse the repository at this point in the history
  • Loading branch information
Jim Safley committed Jun 6, 2011
1 parent 1ba62e1 commit 7a62ff4
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion lib/Scripto/Document.php
Expand Up @@ -534,6 +534,33 @@ public function isProtectedTalkPage()
return $this->_isProtectedPage($this->_talkPageInfo['protections']); return $this->_isProtectedPage($this->_talkPageInfo['protections']);
} }


/**
* Determine whether the current user is watching the current transcription
* page.
*
* @return bool
*/
public function isWatchedTranscriptionPage()
{
if (is_null($this->_pageId)) {
throw new Scripto_Exception('The document page must be set before determining whether the current user is watching the transcription page.');
}
return $this->_transcriptionPageInfo['watched'];
}

/**
* Determine whether the current user is watching the current talk page.
*
* @return bool
*/
public function isWatchedTalkPage()
{
if (is_null($this->_pageId)) {
throw new Scripto_Exception('The document page must be set before determining whether the current user is watching the talk page.');
}
return $this->_talkPageInfo['watched'];
}

/** /**
* Determine whether all of this document's transcription pages were already * Determine whether all of this document's transcription pages were already
* exported to the external system. * exported to the external system.
Expand Down Expand Up @@ -756,7 +783,7 @@ protected function _unwatchPage($title)
*/ */
protected function _getPageInfo($title) protected function _getPageInfo($title)
{ {
$params = array('inprop' => 'protection|talkid|subjectid|url', $params = array('inprop' => 'protection|talkid|subjectid|url|watched',
'intoken' => 'edit|move|delete|protect'); 'intoken' => 'edit|move|delete|protect');
$response = $this->_mediawiki->getInfo($title, $params); $response = $this->_mediawiki->getInfo($title, $params);
$page = current($response['query']['pages']); $page = current($response['query']['pages']);
Expand All @@ -775,6 +802,7 @@ protected function _getPageInfo($title)
'talk_id' => $page['talkid'], 'talk_id' => $page['talkid'],
'mediawiki_full_url' => $page['fullurl'], 'mediawiki_full_url' => $page['fullurl'],
'mediawiki_edit_url' => $page['editurl'], 'mediawiki_edit_url' => $page['editurl'],
'watched' => isset($page['watched']) ? true: false,
'redirect' => isset($page['redirect']) ? true: false, 'redirect' => isset($page['redirect']) ? true: false,
'new' => isset($page['new']) ? true: false); 'new' => isset($page['new']) ? true: false);
return $pageInfo; return $pageInfo;
Expand Down

0 comments on commit 7a62ff4

Please sign in to comment.