Moodle  2.2.1
http://www.collinsharper.com
C:/xampp/htdocs/moodle/mod/wiki/create_form.php
Go to the documentation of this file.
00001 <?php
00002 
00003 // This file is part of Moodle - http://moodle.org/
00004 //
00005 // Moodle is free software: you can redistribute it and/or modify
00006 // it under the terms of the GNU General Public License as published by
00007 // the Free Software Foundation, either version 3 of the License, or
00008 // (at your option) any later version.
00009 //
00010 // Moodle is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00013 // GNU General Public License for more details.
00014 //
00015 // You should have received a copy of the GNU General Public License
00016 // along with Moodle. If not, see <http://www.gnu.org/licenses/>.
00017 
00027 require_once($CFG->libdir.'/formslib.php');
00028 
00029 class mod_wiki_create_form extends moodleform {
00030 
00031     protected function definition() {
00032         global $CFG;
00033         $mform =& $this->_form;
00034 
00035         $formats = $this->_customdata['formats'];
00036         $defaultformat = $this->_customdata['defaultformat'];
00037         $forceformat = $this->_customdata['forceformat'];
00038 
00039         $mform->addElement('header', 'general', get_string('createpage', 'wiki'));
00040 
00041         $textoptions = array();
00042         if (!empty($this->_customdata['disable_pagetitle'])) {
00043             $textoptions = array('readonly'=>'readonly');
00044         }
00045         $mform->addElement('text', 'pagetitle', get_string('newpagetitle', 'wiki'), $textoptions);
00046 
00047         if ($forceformat) {
00048             $mform->addElement('hidden', 'pageformat', $defaultformat);
00049         } else {
00050             $mform->addElement('static', 'format', get_string('format', 'wiki'));
00051             $mform->addHelpButton('format', 'format', 'wiki');
00052             foreach ($formats as $format) {
00053                 if ($format == $defaultformat) {
00054                     $attr = array('checked'=>'checked');
00055                 }else if (!empty($forceformat)){
00056                     $attr = array('disabled'=>'disabled');
00057                 } else {
00058                     $attr = array();
00059                 }
00060                 $mform->addElement('radio', 'pageformat', '', get_string('format'.$format, 'wiki'), $format, $attr);
00061             }
00062         }
00063 
00064         //hiddens
00065         $mform->addElement('hidden', 'action');
00066         $mform->setDefault('action', 'create');
00067 
00068         $this->add_action_buttons(false, get_string('createpage', 'wiki'));
00069     }
00070 }
 All Data Structures Namespaces Files Functions Variables Enumerations