Skip to content

Commit

Permalink
Fixes #21, adds methods in Scripto_Document that return MediaWiki URL…
Browse files Browse the repository at this point in the history
… for a specified page.
  • Loading branch information
jimsafley committed Jun 15, 2011
1 parent aa033e5 commit 17789c4
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions lib/Scripto/Document.php
Expand Up @@ -262,6 +262,32 @@ public function getPageFileUrl()
return $this->_adapter->getDocumentPageFileUrl($this->_id, $this->_pageId);
}

/**
* Get the MediaWiki URL for the current transcription page.
*
* @return string
*/
public function getTranscriptionPageMediawikiUrl()
{
if (is_null($this->_pageId)) {
throw new Scripto_Exception('The document page must be set before getting the transcription page MediaWiki URL.');
}
return $this->_getPageMediawikiUrl($this->_baseTitle);
}

/**
* Get the MediaWiki URL for the current talk page.
*
* @return string
*/
public function getTalkPageMediawikiUrl()
{
if (is_null($this->_pageId)) {
throw new Scripto_Exception('The document page must be set before getting the talk page MediaWiki URL.');
}
return $this->_getPageMediawikiUrl('Talk:' . $this->_baseTitle);
}

/**
* Get the MediaWiki transcription page wikitext for the current page.
*
Expand Down Expand Up @@ -738,6 +764,20 @@ protected function _unprotectPage($title, $protectToken)
$this->_mediawiki->protect($title, $protections, $protectToken);
}

/**
* Get the MediaWiki URL for the specified page.
*
* @uses Scripto_Service_MediaWiki::getSiteInfo()
* @param string $title
* @return string
*/
protected function _getPageMediawikiUrl($title)
{
$siteInfo = $this->_mediawiki->getSiteInfo();
return $siteInfo['query']['general']['server']
. str_replace('$1', $title, $siteInfo['query']['general']['articlepath']);
}

/**
* Get information for the specified page.
*
Expand Down

0 comments on commit 17789c4

Please sign in to comment.