Merge branch 'wip-mdl-23520' of git://github.com/rajeshtaneja/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2011-09-06 01:25:05 +02:00
commit c35fba98da
7 changed files with 639 additions and 1 deletions

106
mod/wiki/admin.php Normal file
View File

@ -0,0 +1,106 @@
<?php
// This file is part of Moodle - http://moodle.org/
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Delete wiki pages or versions
*
* This will show options for deleting wiki pages or purging page versions
* If user have wiki:managewiki ability then only this page will show delete
* options
*
* @package mod-wiki-2.0
* @copyright 2011 Rajesh Taneja
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
require_once('../../config.php');
require_once($CFG->dirroot . '/mod/wiki/lib.php');
require_once($CFG->dirroot . '/mod/wiki/locallib.php');
require_once($CFG->dirroot . '/mod/wiki/pagelib.php');
$pageid = required_param('pageid', PARAM_INT); // Page ID
$delete = optional_param('delete', 0, PARAM_INT); // ID of the page to be deleted.
$option = optional_param('option', 1, PARAM_INT); // Option ID
$listall = optional_param('listall', 0, PARAM_INT); // list all pages
$toversion = optional_param('toversion', 0, PARAM_INT); // max version to be deleted
$fromversion = optional_param('fromversion', 0, PARAM_INT); // min version to be deleted
if (!$page = wiki_get_page($pageid)) {
print_error('incorrectpageid', 'wiki');
}
if (!$subwiki = wiki_get_subwiki($page->subwikiid)) {
print_error('incorrectsubwikiid', 'wiki');
}
if (!$cm = get_coursemodule_from_instance("wiki", $subwiki->wikiid)) {
print_error('invalidcoursemodule');
}
$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
if (!$wiki = wiki_get_wiki($subwiki->wikiid)) {
print_error('incorrectwikiid', 'wiki');
}
require_login($course->id, true, $cm);
$context = get_context_instance(CONTEXT_MODULE, $cm->id);
require_capability('mod/wiki:managewiki', $context);
add_to_log($course->id, "wiki", "admin", "admin.php?id=$cm->id", "$wiki->id");
//Delete page if a page ID to delete was supplied
if (!empty($delete) && confirm_sesskey()) {
wiki_delete_pages($context, $delete, $page->subwikiid);
//when current wiki page is deleted, then redirect user to create that page, as
//current pageid is invalid after deletion.
if ($pageid == $delete) {
$params = array('swid' => $page->subwikiid, 'title' => $page->title);
$url = new moodle_url('/mod/wiki/create.php', $params);
redirect($url);
}
}
//delete version if toversion and fromversion are set.
if (!empty($toversion) && !empty($fromversion) && confirm_sesskey()) {
//make sure all versions should not be deleted...
$versioncount = wiki_count_wiki_page_versions($pageid);
$versioncount -= 1; //ignore version 0
$totalversionstodelete = $toversion - $fromversion;
$totalversionstodelete += 1; //added 1 as toversion should be included
if (($totalversionstodelete >= $versioncount) || ($versioncount <= 1)) {
print_error('incorrectdeleteversions', 'wiki');
} else {
$versions = array();
for ($i = $fromversion; $i <= $toversion; $i++) {
//Add all version to deletion list which exist
if (wiki_get_wiki_page_version($pageid, $i)) {
array_push($versions, $i);
}
}
$purgeversions[$pageid] = $versions;
wiki_delete_page_versions($purgeversions);
}
}
//show actual page
$wikipage = new page_wiki_admin($wiki, $subwiki, $cm);
$wikipage->set_page($page);
$wikipage->print_header();
$wikipage->set_view($option, empty($listall)?true:false);
$wikipage->print_content();
$wikipage->print_footer();

View File

@ -10,6 +10,8 @@
* @package wiki
*/
$string['addcomment'] = 'Add comment';
$string['admin'] = 'Administration';
$string['adminmenu'] = 'Admin menu';
$string['attachmentattach'] = 'Add as attachment';
$string['attachmentimage'] = 'Add as image';
$string['attachmentlink'] = 'Add as link';
@ -43,6 +45,7 @@ $string['deletecomment'] = 'Deleting comment';
$string['deleteupload'] = 'Delete';
$string['deletedbegins'] = 'Deleted begins';
$string['deletedends'] = 'Deleted ends';
$string['deleteversions'] = 'Delete page versions';
$string['addedbegins'] = 'added begins';
$string['addedends'] = 'added ends';
$string['diff'] = 'Diff';
@ -82,6 +85,7 @@ $string['formatnwiki_link'] = 'mod/wiki/nwiki';
$string['history'] = 'History';
$string['history_help'] = 'The history lists links to previous versions of the page.';
$string['html'] = 'HTML';
$string['incorrectdeleteversions'] = "Page versions provided for deletion are incorrect.";
$string['insertcomment'] = 'Insert comment';
$string['insertimage'] = 'Insert an image...';
$string['insertimage_help'] = 'This drop-down list will insert an image to the wiki editor. If you need to add more images to the wiki, please use "Files" tab.';
@ -93,6 +97,8 @@ $string['javascriptdisabledlocks'] = 'Javascript is disabled on your browser and
$string['lockingajaxtimeout'] = 'Edit page locking refresh time';
$string['lockingtimeout'] = 'Locking timeout';
$string['links'] = 'Links';
$string['listall'] = 'List all';
$string['listorphan'] = 'List orphan';
$string['map'] = 'Map';
$string['mapmenu'] = 'Map menu';
$string['migrationfinished'] = 'Migration finished successfully';
@ -160,6 +166,7 @@ $string['reparsetimeout'] = 'Reparsing default timeout';
$string['repeatedsection'] = 'Wiki error: Section name cannot be repeated \'{$a}\'';
$string['restore'] = 'Restore';
$string['removeallwikitags'] = 'Remove all wiki tags';
$string['removepages'] = 'Remove pages';
$string['restoreconfirm'] = 'Are you sure you want to restore version #{$a}?';
$string['restoreerror'] = 'Version #{$a} could not be restored';
$string['restorethis'] = 'Restore this version';

View File

@ -557,6 +557,11 @@ function wiki_extend_navigation(navigation_node $navref, $course, $module, $cm)
$link = new moodle_url('/mod/wiki/files.php', array('pageid' => $pageid));
$node = $navref->add(get_string('files', 'wiki'), $link, navigation_node::TYPE_SETTING);
}
if (has_capability('mod/wiki:managewiki', $context)) {
$link = new moodle_url('/mod/wiki/admin.php', array('pageid' => $pageid));
$node = $navref->add(get_string('admin', 'wiki'), $link, navigation_node::TYPE_SETTING);
}
}
}
/**

View File

@ -1018,6 +1018,136 @@ function wiki_delete_old_locks() {
$DB->delete_records_select('wiki_locks', "lockedat < ?", array(time() - 3600));
}
/**
* Deletes wiki_links. It can be sepecific link or links attached in subwiki
*
* @global mixed $DB database object
* @param int $linkid id of the link to be deleted
* @param int $topageid links to the specific page
* @param int $frompageid links from specific page
* @param int $subwikiid links to subwiki
*/
function wiki_delete_links($linkid = null, $topageid = null, $frompageid = null, $subwikiid = null) {
global $DB;
$params = array();
// if link id is givien then don't check for anything else
if (!empty($linkid)) {
$params['id'] = $linkid;
} else {
if (!empty($topageid)) {
$params['topageid'] = $topageid;
}
if (!empty($frompageid)) {
$params['frompageid'] = $frompageid;
}
if (!empty($subwikiid)) {
$params['subwikiid'] = $subwikiid;
}
}
//Delete links if any params are passed, else nothing to delete.
if (!empty($params)) {
$DB->delete_records('wiki_links', $params);
}
}
/**
* Delete wiki synonyms related to subwikiid or page
*
* @param int $subwikiid id of sunbwiki
* @param int $pageid id of page
*/
function wiki_delete_synonym($subwikiid, $pageid = null) {
global $DB;
$params = array('subwikiid' => $subwikiid);
if (!is_null($pageid)) {
$params['pageid'] = $pageid;
}
$DB->delete_records('wiki_synonyms', $params, IGNORE_MISSING);
}
/**
* Delete pages and all related data
*
* @param mixed $context context in which page needs to be deleted.
* @param mixed $pageids id's of pages to be deleted
* @param int $subwikiid id of the subwiki for which all pages should be deleted
*/
function wiki_delete_pages($context, $pageids = null, $subwikiid = null) {
global $DB;
if (!empty($pageids) && is_int($pageids)) {
$pageids = array($pageids);
} else if (!empty($subwikiid)) {
$pageids = wiki_get_page_list($subwikiid);
}
//If there is no pageid then return as we can't delete anything.
if (empty($pageids)) {
return;
}
/// Delete page and all it's relevent data
foreach ($pageids as $pageid) {
if (is_object($pageid)) {
$pageid = $pageid->id;
}
//Delete page comments
$comments = wiki_get_comments($context->id, $pageid);
foreach ($comments as $commentid => $commentvalue) {
wiki_delete_comment($commentid, $context, $pageid);
}
//Delete page tags
$tags = tag_get_tags_array('wiki_pages', $pageid);
foreach ($tags as $tagid => $tagvalue) {
tag_delete_instance('wiki_pages', $pageid, $tagid);
}
//Delete Synonym
wiki_delete_synonym($subwikiid, $pageid);
//Delete all page versions
wiki_delete_page_versions(array($pageid=>array(0)));
//Delete all page locks
wiki_delete_locks($pageid);
//Delete all page links
wiki_delete_links(null, $pageid);
//Delete page
$params = array('id' => $pageid);
$DB->delete_records('wiki_pages', $params);
}
}
/**
* Delete specificed versions of a page or versions created by users
* if version is 0 then it will remove all versions of the page
*
* @param array $deleteversions delete versions for a page
*/
function wiki_delete_page_versions($deleteversions) {
global $DB;
/// delete page-versions
foreach ($deleteversions as $id => $versions) {
foreach ($versions as $version) {
$params = array('pageid' => $id);
//If version = 0, then remove all versions of this page, else remove
//specified version
if ($version != 0) {
$params['version'] = $version;
}
$DB->delete_records('wiki_versions', $params, IGNORE_MISSING);
}
}
}
function wiki_get_comment($commentid){
global $DB;
return $DB->get_record('comments', array('id' => $commentid));

View File

@ -77,6 +77,42 @@ M.mod_wiki.history = function(Y, args) {
}
}
M.mod_wiki.deleteversion = function(Y, args) {
var fromversion = false;
var toversion = false;
var radio = document.getElementsByName('fromversion');
var radio2 = document.getElementsByName('toversion');
var length = radio.length;
//version to should be more then version from
for (var i = 0; i < radio.length; i++) {
//if from-version is selected then disable all to-version options after that.
if (fromversion) {
radio2[i].disabled = true;
} else {
radio2[i].disabled = false;
}
//check when to-version option is selected
if (radio2[i].checked) {
toversion = true;
}
//make sure to-version should be >= from-version
if (radio[i].checked) {
fromversion = true;
if (!toversion) {
radio2[i].checked = true;
}
}
}
//avoid selecting first and last version
if (radio[0].checked && radio2[length-1].checked) {
radio2[length - 2].checked = true;
} else if(radio[length - 1].checked && radio2[0].checked) {
radio2[1].checked = true;
radio2[0].disabled = true;
toversion = true;
}
}
M.mod_wiki.init_tree = function(Y, expand_all, htmlid) {
Y.use('yui2-treeview', function(Y) {
var tree = new YAHOO.widget.TreeView(htmlid);

View File

@ -76,7 +76,8 @@ abstract class page_wiki {
* @var array The tabs set used in wiki module
*/
protected $tabs = array('view' => 'view', 'edit' => 'edit', 'comments' => 'comments',
'history' => 'history', 'map' => 'map', 'files' => 'files');
'history' => 'history', 'map' => 'map', 'files' => 'files',
'admin' => 'admin');
/**
* @var array tabs options
*/
@ -2269,3 +2270,338 @@ class page_wiki_overridelocks extends page_wiki_edit {
}
}
/**
* This class will let user to delete wiki pages and page versions
*
*/
class page_wiki_admin extends page_wiki {
public $view, $action;
public $listorphan = false;
/**
* Constructor
*
* @global object $PAGE
* @param mixed $wiki instance of wiki
* @param mixed $subwiki instance of subwiki
* @param stdClass $cm course module
*/
function __construct($wiki, $subwiki, $cm) {
global $PAGE;
parent::__construct($wiki, $subwiki, $cm);
$PAGE->requires->js_init_call('M.mod_wiki.deleteversion', null, true);
}
/**
* Prints header for wiki page
*/
function print_header() {
parent::print_header();
$this->print_pagetitle();
}
/**
* This function will display administration view to users with managewiki capability
*/
function print_content() {
//make sure anyone trying to access this page has managewiki capabilities
require_capability('mod/wiki:managewiki', $this->modcontext, NULL, true, 'noviewpagepermission', 'wiki');
//update wiki cache if timedout
$page = $this->page;
if ($page->timerendered + WIKI_REFRESH_CACHE_TIME < time()) {
$fresh = wiki_refresh_cachedcontent($page);
$page = $fresh['page'];
}
//dispaly admin menu
echo $this->wikioutput->menu_admin($this->page->id, $this->view);
//Display appropriate admin view
switch ($this->view) {
case 1: //delete page view
$this->print_delete_content($this->listorphan);
break;
case 2: //delete version view
$this->print_delete_version();
break;
default: //default is delete view
$this->print_delete_content($this->listorphan);
break;
}
}
/**
* Sets admin view option
*
* @param int $view page view id
* @param bool $listorphan is only valid for view 1.
*/
public function set_view($view, $listorphan = true) {
$this->view = $view;
$this->listorphan = $listorphan;
}
/**
* Sets page url
*
* @global object $PAGE
* @global object $CFG
*/
function set_url() {
global $PAGE, $CFG;
$PAGE->set_url($CFG->wwwroot . '/mod/wiki/admin.php', array('pageid' => $this->page->id));
}
/**
* sets navigation bar for the page
*
* @global object $PAGE
*/
protected function create_navbar() {
global $PAGE;
parent::create_navbar();
$PAGE->navbar->add(get_string('admin', 'wiki'));
}
/**
* Show wiki page delete options
*
* @param bool $showorphan
*/
protected function print_delete_content($showorphan = true) {
$contents = array();
$table = new html_table();
$table->head = array('','Page name');
$table->attributes['class'] = 'generaltable mdl-align';
$swid = $this->subwiki->id;
if ($showorphan) {
if ($orphanedpages = wiki_get_orphaned_pages($swid)) {
$this->add_page_delete_options($orphanedpages, $swid, $table);
} else {
$table->data[] = array('', get_string('noorphanedpages', 'wiki'));
}
} else {
if ($pages = wiki_get_page_list($swid)) {
$this->add_page_delete_options($pages, $swid, $table);
} else {
$table->data[] = array('', get_string('nopages', 'wiki'));
}
}
///Print the form
echo html_writer::start_tag('form', array(
'action' => new moodle_url('/mod/wiki/admin.php'),
'method' => 'post'));
echo html_writer::tag('div', html_writer::empty_tag('input', array(
'type' => 'hidden',
'name' => 'pageid',
'value' => $this->page->id)));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'option', 'value' => $this->view));
echo html_writer::table($table);
echo html_writer::start_tag('div', array('class' => 'mdl-align'));
if (!$showorphan) {
echo html_writer::empty_tag('input', array(
'type' => 'submit',
'class' => 'wiki_form-button',
'value' => get_string('listorphan', 'wiki'),
'sesskey' => sesskey()));
} else {
echo html_writer::empty_tag('input', array('type'=>'hidden', 'name'=>'listall', 'value'=>'1'));
echo html_writer::empty_tag('input', array(
'type' => 'submit',
'class' => 'wiki_form-button',
'value' => get_string('listall', 'wiki'),
'sesskey' => sesskey()));
}
echo html_writer::end_tag('div');
echo html_writer::end_tag('form');
}
/**
* helper function for print_delete_content. This will add data to the table.
*
* @global object $OUTPUT
* @param array $pages objects of wiki pages in subwiki
* @param int $swid id of subwiki
* @param object $table reference to the table in which data needs to be added
*/
protected function add_page_delete_options($pages, $swid, &$table) {
global $OUTPUT;
foreach ($pages as $page) {
$link = wiki_parser_link($page->title, array('swid' => $swid));
$class = ($link['new']) ? 'class="wiki_newentry"' : '';
$pagelink = '<a href="' . $link['url'] . '"' . $class . '>' . format_string($link['content']) . '</a>';
$urledit = new moodle_url('/mod/wiki/edit.php', array('pageid' => $page->id, 'sesskey' => sesskey()));
$urldelete = new moodle_url('/mod/wiki/admin.php', array(
'pageid' => $this->page->id,
'delete' => $page->id,
'option' => $this->view,
'listall' => !$this->listorphan?'1': '',
'sesskey' => sesskey()));
$editlinks = $OUTPUT->action_icon($urledit, new pix_icon('t/edit', get_string('edit')));
$editlinks .= $OUTPUT->action_icon($urldelete, new pix_icon('t/delete', get_string('delete')));
$table->data[] = array($editlinks, $pagelink);
}
}
/**
* Prints lists of versions which can be deleted
*
* @global object $OUTPUT
*/
private function print_delete_version() {
global $OUTPUT;
$pageid = $this->page->id;
// versioncount is the latest version
$versioncount = wiki_count_wiki_page_versions($pageid) - 1;
$versions = wiki_get_wiki_page_versions($pageid, 0, $versioncount);
// We don't want version 0 to be displayed
// version 0 is blank page
if (end($versions)->version == 0) {
array_pop($versions);
}
$contents = array();
$version0page = wiki_get_wiki_page_version($this->page->id, 0);
$creator = wiki_get_user_info($version0page->userid);
$a = new stdClass();
$a->date = userdate($this->page->timecreated, get_string('strftimedaydatetime', 'langconfig'));
$a->username = $creator->username;
echo $OUTPUT->heading(get_string('createddate', 'wiki', $a), 4, 'wiki_headingtime');
if ($versioncount > 0) {
/// If there is only one version, we don't need radios nor forms
if (count($versions) == 1) {
$row = array_shift($versions);
$username = wiki_get_user_info($row->userid);
$picture = $OUTPUT->user_picture($username);
$date = userdate($row->timecreated, get_string('strftimedate', 'langconfig'));
$time = userdate($row->timecreated, get_string('strftimetime', 'langconfig'));
$versionid = wiki_get_version($row->id);
$versionlink = new moodle_url('/mod/wiki/viewversion.php', array('pageid' => $pageid, 'versionid' => $versionid->id));
$userlink = new moodle_url('/user/view.php', array('id' => $username->id));
$picturelink = $picture . html_writer::link($userlink->out(false), fullname($username));
$historydate = $OUTPUT->container($date, 'wiki_histdate');
$contents[] = array('', html_writer::link($versionlink->out(false), $row->version), $picturelink, $time, $historydate);
//Show current version
$table = new html_table();
$table->head = array('', get_string('version'), get_string('user'), get_string('modified'), '');
$table->data = $contents;
$table->attributes['class'] = 'mdl-align';
echo html_writer::table($table);
} else {
$lastdate = '';
$rowclass = array();
foreach ($versions as $version) {
$user = wiki_get_user_info($version->userid);
$picture = $OUTPUT->user_picture($user, array('popup' => true));
$date = userdate($version->timecreated, get_string('strftimedate'));
if ($date == $lastdate) {
$date = '';
$rowclass[] = '';
} else {
$lastdate = $date;
$rowclass[] = 'wiki_histnewdate';
}
$time = userdate($version->timecreated, get_string('strftimetime', 'langconfig'));
$versionid = wiki_get_version($version->id);
if ($versionid) {
$url = new moodle_url('/mod/wiki/viewversion.php', array('pageid' => $pageid, 'versionid' => $versionid->id));
$viewlink = html_writer::link($url->out(false), $version->version);
} else {
$viewlink = $version->version;
}
$userlink = new moodle_url('/user/view.php', array('id' => $version->userid));
$picturelink = $picture . html_writer::link($userlink->out(false), fullname($user));
$historydate = $OUTPUT->container($date, 'wiki_histdate');
$radiofromelement = $this->choose_from_radio(array($version->version => null), 'fromversion', 'M.mod_wiki.deleteversion()', $versioncount, true);
$radiotoelement = $this->choose_from_radio(array($version->version => null), 'toversion', 'M.mod_wiki.deleteversion()', $versioncount, true);
$contents[] = array( $radiofromelement . $radiotoelement, $viewlink, $picturelink, $time, $historydate);
}
$table = new html_table();
$table->head = array(get_string('deleteversions', 'wiki'), get_string('version'), get_string('user'), get_string('modified'), '');
$table->data = $contents;
$table->attributes['class'] = 'generaltable mdl-align';
$table->rowclasses = $rowclass;
///Print the form
echo html_writer::start_tag('form', array('action'=>new moodle_url('/mod/wiki/admin.php'), 'method' => 'post'));
echo html_writer::tag('div', html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'pageid', 'value' => $pageid)));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'option', 'value' => $this->view));
echo html_writer::empty_tag('input', array('type' => 'hidden', 'name' => 'sesskey', 'value' => sesskey()));
echo html_writer::table($table);
echo html_writer::start_tag('div', array('class' => 'mdl-align'));
echo html_writer::empty_tag('input', array('type' => 'submit', 'class' => 'wiki_form-button', 'value' => get_string('deleteversions', 'wiki')));
echo html_writer::end_tag('div');
echo html_writer::end_tag('form');
}
} else {
print_string('nohistory', 'wiki');
}
}
/**
* Given an array of values, creates a group of radio buttons to be part of a form
* helper function for print_delete_version
*
* @param array $options An array of value-label pairs for the radio group (values as keys).
* @param string $name Name of the radiogroup (unique in the form).
* @param string $onclick Function to be executed when the radios are clicked.
* @param string $checked The value that is already checked.
* @param bool $return If true, return the HTML as a string, otherwise print it.
*
* @return mixed If $return is false, returns nothing, otherwise returns a string of HTML.
*/
private function choose_from_radio($options, $name, $onclick = '', $checked = '', $return = false) {
static $idcounter = 0;
if (!$name) {
$name = 'unnamed';
}
$output = '<span class="radiogroup ' . $name . "\">\n";
if (!empty($options)) {
$currentradio = 0;
foreach ($options as $value => $label) {
$htmlid = 'auto-rb' . sprintf('%04d', ++$idcounter);
$output .= ' <span class="radioelement ' . $name . ' rb' . $currentradio . "\">";
$output .= '<input name="' . $name . '" id="' . $htmlid . '" type="radio" value="' . $value . '"';
if ($value == $checked) {
$output .= ' checked="checked"';
}
if ($onclick) {
$output .= ' onclick="' . $onclick . '"';
}
if ($label === '') {
$output .= ' /> <label for="' . $htmlid . '">' . $value . '</label></span>' . "\n";
} else {
$output .= ' /> <label for="' . $htmlid . '">' . $label . '</label></span>' . "\n";
}
$currentradio = ($currentradio + 1) % 2;
}
}
$output .= '</span>' . "\n";
if ($return) {
return $output;
} else {
echo $output;
}
}
}

View File

@ -278,6 +278,9 @@ class mod_wiki_renderer extends plugin_renderer_base {
if (($tab == 'view' || $tab == 'map' || $tab == 'history') && !has_capability('mod/wiki:viewpage', $context)) {
continue;
}
if ($tab == 'admin' && !has_capability('mod/wiki:managewiki', $context)) {
continue;
}
$link = $baseurl . $tab . '.php?pageid=' . $pageid;
if ($linked == $tab) {
$tabs[] = new tabobject($tab, $link, get_string($tab, 'wiki'), '', true);
@ -494,6 +497,21 @@ class mod_wiki_renderer extends plugin_renderer_base {
return $html;
}
function menu_admin($pageid, $currentselect) {
$options = array('removepages', 'deleteversions');
$items = array();
foreach ($options as $opt) {
$items[] = get_string($opt, 'wiki');
}
$selectoptions = array();
foreach ($items as $key => $item) {
$selectoptions[$key + 1] = $item;
}
$select = new single_select(new moodle_url('/mod/wiki/admin.php', array('pageid' => $pageid)), 'option', $selectoptions, $currentselect);
$select->label = get_string('adminmenu', 'wiki') . ': ';
return $this->output->container($this->output->render($select), 'midpad');
}
/**
* Internal function - creates htmls structure suitable for YUI tree.
*/