Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Fixes #21, adds methods in Scripto_Document that return MediaWiki URL…

… for a specified page.
  • Loading branch information...
commit 17789c483e379405f2e0e61ab2efbd96a90540c3 1 parent aa033e5
@jimsafley jimsafley authored
Showing with 40 additions and 0 deletions.
  1. +40 −0 lib/Scripto/Document.php
View
40 lib/Scripto/Document.php
@@ -263,6 +263,32 @@ public function getPageFileUrl()
}
/**
+ * 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.
*
* @uses Scripto_Service_MediaWiki::getLatestRevisionWikitext()
@@ -739,6 +765,20 @@ protected function _unprotectPage($title, $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.
*
* @uses Scripto_Service_MediaWiki::getInfo()

0 comments on commit 17789c4

Please sign in to comment.
Something went wrong with that request. Please try again.