MDL-56103 wiki: Return version in get_page_contents

This commit is contained in:
Dani Palou
2016-09-27 16:19:23 +02:00
parent 26162efe4a
commit 7f98de7d9d
3 changed files with 13 additions and 3 deletions
+8 -1
View File
@@ -635,6 +635,12 @@ class mod_wiki_external extends external_api {
$page->cachedcontent, FORMAT_HTML, $context->id, 'mod_wiki', 'attachments', $subwiki->id);
$returnedpage['caneditpage'] = wiki_user_can_edit($subwiki);
// Get page version.
$version = wiki_get_current_version($page->id);
if (!empty($version)) {
$returnedpage['version'] = $version->version;
}
$result = array();
$result['page'] = $returnedpage;
$result['warnings'] = $warnings;
@@ -660,7 +666,8 @@ class mod_wiki_external extends external_api {
'title' => new external_value(PARAM_RAW, 'Page title.'),
'cachedcontent' => new external_value(PARAM_RAW, 'Page contents.'),
'contentformat' => new external_format_value('cachedcontent', VALUE_OPTIONAL),
'caneditpage' => new external_value(PARAM_BOOL, 'True if user can edit the page.')
'caneditpage' => new external_value(PARAM_BOOL, 'True if user can edit the page.'),
'version' => new external_value(PARAM_INT, 'Latest version of the page.', VALUE_OPTIONAL),
), 'Page'
),
'warnings' => new external_warnings()
+4 -2
View File
@@ -976,7 +976,8 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase {
'title' => $this->firstpage->title,
'cachedcontent' => $this->firstpage->cachedcontent,
'contentformat' => 1,
'caneditpage' => true
'caneditpage' => true,
'version' => 1
);
$result = mod_wiki_external::get_page_contents($this->firstpage->id);
@@ -1016,7 +1017,8 @@ class mod_wiki_external_testcase extends externallib_advanced_testcase {
'title' => $this->fpsepg1indstu->title,
'cachedcontent' => $this->fpsepg1indstu->cachedcontent,
'contentformat' => 1,
'caneditpage' => true
'caneditpage' => true,
'version' => 1
);
$result = mod_wiki_external::get_page_contents($this->fpsepg1indstu->id);
+1
View File
@@ -5,6 +5,7 @@ information provided here is intended especially for developers.
* External functions that were returning file information now return the following file fields:
filename, filepath, mimetype, filesize, timemodified and fileurl.
Those fields are now marked as VALUE_OPTIONAL for backwards compatibility.
* External function get_page_contents now returns the page version. This new field is marked as VALUE_OPTIONAL for backwards compatibility.
=== 3.1 ===
* Added a new param $sort to wiki_get_page_list function. Default value behaves exactly like before (sort by title ASC).