From 2c49daf7897b942c52cfb09cb88d74556e6eec3f Mon Sep 17 00:00:00 2001 From: Petr Skoda Date: Thu, 15 Jul 2010 15:45:20 +0000 Subject: [PATCH] MDL-21249 + MDL-16089 finalizing the mod/page module --- .../moodle2/backup_page_activity_task.class.php | 10 ++++++---- .../backup/moodle2/backup_page_stepslib.php | 10 ++++++---- mod/page/db/access.php | 9 ++++++--- mod/page/db/install.php | 9 ++++++--- mod/page/db/upgrade.php | 9 ++++++--- mod/page/db/upgradelib.php | 9 ++++++--- mod/page/index.php | 7 ++++--- mod/page/lib.php | 17 ++++++++++------- mod/page/locallib.php | 12 ++++++++---- mod/page/mod_form.php | 15 +++++++-------- mod/page/readme.txt | 1 - mod/page/settings.php | 7 ++++--- mod/page/version.php | 9 ++++++--- mod/page/view.php | 7 ++++--- 14 files changed, 79 insertions(+), 52 deletions(-) diff --git a/mod/page/backup/moodle2/backup_page_activity_task.class.php b/mod/page/backup/moodle2/backup_page_activity_task.class.php index 29de836b938..16637b61268 100644 --- a/mod/page/backup/moodle2/backup_page_activity_task.class.php +++ b/mod/page/backup/moodle2/backup_page_activity_task.class.php @@ -16,12 +16,14 @@ // along with Moodle. If not, see . /** - * @package moodlecore - * @subpackage backup-moodle2 - * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod + * @subpackage page + * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die; + require_once($CFG->dirroot . '/mod/page/backup/moodle2/backup_page_stepslib.php'); // Because it exists (must) /** diff --git a/mod/page/backup/moodle2/backup_page_stepslib.php b/mod/page/backup/moodle2/backup_page_stepslib.php index f6d01314faf..56576bd8e4e 100644 --- a/mod/page/backup/moodle2/backup_page_stepslib.php +++ b/mod/page/backup/moodle2/backup_page_stepslib.php @@ -16,12 +16,14 @@ // along with Moodle. If not, see . /** - * @package moodlecore - * @subpackage backup-moodle2 - * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod + * @subpackage page + * @copyright 2010 onwards Eloy Lafuente (stronk7) {@link http://stronk7.com} + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die; + /** * Define all the backup steps that will be used by the backup_page_activity_task */ diff --git a/mod/page/db/access.php b/mod/page/db/access.php index e6f22561c1a..6c773e662e4 100644 --- a/mod/page/db/access.php +++ b/mod/page/db/access.php @@ -18,11 +18,14 @@ /** * Page module capability definition * - * @package mod-page - * @copyright 2009 Petr Skoda (http://skodak.org) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod + * @subpackage page + * @copyright 2009 Petr Skoda (http://skodak.org) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die; + $capabilities = array( /* TODO: review public portfolio API first! 'mod/page:portfolioexport' => array( diff --git a/mod/page/db/install.php b/mod/page/db/install.php index 15a37f932e6..08b70331b6d 100644 --- a/mod/page/db/install.php +++ b/mod/page/db/install.php @@ -23,11 +23,14 @@ * - lib.php/modulename_install() post installation hook * - partially defaults.php * - * @package mod-page - * @copyright 2009 Petr Skoda (http://skodak.org) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod + * @subpackage page + * @copyright 2009 Petr Skoda (http://skodak.org) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die; + function xmldb_page_install() { global $CFG; diff --git a/mod/page/db/upgrade.php b/mod/page/db/upgrade.php index e99c3174985..8a9eb0b374d 100644 --- a/mod/page/db/upgrade.php +++ b/mod/page/db/upgrade.php @@ -38,11 +38,14 @@ * Please do not forget to use upgrade_set_timeout() * before any action that may take longer time to finish. * - * @package mod-page - * @copyright 2009 Petr Skoda (http://skodak.org) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod + * @subpackage page + * @copyright 2009 Petr Skoda (http://skodak.org) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die; + function xmldb_page_upgrade($oldversion) { global $CFG, $DB; require_once("$CFG->dirroot/mod/page/db/upgradelib.php"); diff --git a/mod/page/db/upgradelib.php b/mod/page/db/upgradelib.php index 8a8dbcadf5e..2d410302543 100644 --- a/mod/page/db/upgradelib.php +++ b/mod/page/db/upgradelib.php @@ -18,11 +18,14 @@ /** * Folder module upgrade related helper functions * - * @package mod-page - * @copyright 2009 Petr Skoda (http://skodak.org) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod + * @subpackage page + * @copyright 2009 Petr Skoda (http://skodak.org) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die; + /** * Migrate page module data from 1.9 resource_old table to new page table * @return void diff --git a/mod/page/index.php b/mod/page/index.php index df24f84aa5a..8ea91657171 100644 --- a/mod/page/index.php +++ b/mod/page/index.php @@ -18,9 +18,10 @@ /** * List of all pages in course * - * @package mod-page - * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod + * @subpackage page + * @copyright 1999 onwards Martin Dougiamas (http://dougiamas.com) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require('../../config.php'); diff --git a/mod/page/lib.php b/mod/page/lib.php index 86b80e825b0..7522904d9f3 100644 --- a/mod/page/lib.php +++ b/mod/page/lib.php @@ -16,11 +16,14 @@ // along with Moodle. If not, see . /** - * @package mod-page - * @copyright 2009 Petr Skoda (http://skodak.org) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod + * @subpackage page + * @copyright 2009 Petr Skoda (http://skodak.org) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die; + /** * List of features supported in Page module * @param string $feature FEATURE_xx constant for requested feature @@ -285,7 +288,7 @@ function page_get_file_areas($course, $cm, $context) { } /** - * File browsing support for page module ontent area. + * File browsing support for page module content area. * @param object $browser * @param object $areas * @param object $course @@ -337,7 +340,7 @@ function page_get_file_info($browser, $areas, $course, $cm, $context, $filearea, * @param string $filearea * @param array $args * @param bool $forcedownload - * @return bool false if file not found, does not return if found - justsend the file + * @return bool false if file not found, does not return if found - just send the file */ function page_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) { global $CFG, $DB; @@ -378,7 +381,7 @@ function page_pluginfile($course, $cm, $context, $filearea, $args, $forcedownloa /** - * This function extends the global navigaiton for the site. + * This function extends the global navigation for the site. * It is important to note that you should not rely on PAGE objects within this * body of code as there is no guarantee that during an AJAX request they are * available @@ -386,7 +389,7 @@ function page_pluginfile($course, $cm, $context, $filearea, $args, $forcedownloa * @param navigation_node $navigation The page node within the global navigation * @param stdClass $course The course object returned from the DB * @param stdClass $module The module object returned from the DB - * @param stdClass $cm The course module isntance returned from the DB + * @param stdClass $cm The course module instance returned from the DB */ function page_extend_navigation($navigation, $course, $module, $cm) { /** diff --git a/mod/page/locallib.php b/mod/page/locallib.php index bbca137e11f..5eb4d0fb679 100644 --- a/mod/page/locallib.php +++ b/mod/page/locallib.php @@ -18,11 +18,14 @@ /** * Private page module utility functions * - * @package mod-page - * @copyright 2009 Petr Skoda (http://skodak.org) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod + * @subpackage page + * @copyright 2009 Petr Skoda (http://skodak.org) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die; + require_once("$CFG->libdir/filelib.php"); require_once("$CFG->libdir/resourcelib.php"); require_once("$CFG->dirroot/mod/page/lib.php"); @@ -47,5 +50,6 @@ class page_content_file_info extends file_info_stored { } function page_get_editor_options($context) { - return array('subdirs'=>1, 'maxbytes'=>0, 'maxfiles'=>-1, 'changeformat'=>1, 'context'=>$context, 'noclean'=>1, 'trusttext'=>0); + global $CFG; + return array('subdirs'=>1, 'maxbytes'=>$CFG->maxbytes, 'maxfiles'=>-1, 'changeformat'=>1, 'context'=>$context, 'noclean'=>1, 'trusttext'=>0); } \ No newline at end of file diff --git a/mod/page/mod_form.php b/mod/page/mod_form.php index 9adef17bbb3..ca5260ae7a7 100644 --- a/mod/page/mod_form.php +++ b/mod/page/mod_form.php @@ -18,14 +18,13 @@ /** * Page configuration form * - * @package mod-page - * @copyright 2009 Petr Skoda (http://skodak.org) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod + * @subpackage page + * @copyright 2009 Petr Skoda (http://skodak.org) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ -if (!defined('MOODLE_INTERNAL')) { - die('Direct access to this script is forbidden.'); /// It must be included from a Moodle page -} +defined('MOODLE_INTERNAL') || die; require_once($CFG->dirroot.'/course/moodleform_mod.php'); require_once($CFG->dirroot.'/mod/page/locallib.php'); @@ -34,7 +33,8 @@ require_once($CFG->libdir.'/filelib.php'); class mod_page_mod_form extends moodleform_mod { function definition() { global $CFG, $DB; - $mform =& $this->_form; + + $mform = $this->_form; $config = get_config('page'); @@ -52,7 +52,6 @@ class mod_page_mod_form extends moodleform_mod { //------------------------------------------------------- $mform->addElement('header', 'contentsection', get_string('contentheader', 'page')); $mform->addElement('editor', 'page', get_string('content', 'page'), null, page_get_editor_options($this->context)); - $mform->addElement('static', 'note', '', '(TODO: The format switching is not implemented yet, sorry...)'); //------------------------------------------------------- $mform->addElement('header', 'optionssection', get_string('optionsheader', 'page')); diff --git a/mod/page/readme.txt b/mod/page/readme.txt index 45763f272a9..47cd7f4923b 100644 --- a/mod/page/readme.txt +++ b/mod/page/readme.txt @@ -26,4 +26,3 @@ Page module is a successor to original 'html' and 'text' type plugins of Resourc TODO: * implement portfolio support (MDL-20076) * new backup/restore and old restore migration (MDL-20077) - * implement format switching in formslib editor element (MDL-20078) diff --git a/mod/page/settings.php b/mod/page/settings.php index f3ee893cb00..3c10b23e46a 100644 --- a/mod/page/settings.php +++ b/mod/page/settings.php @@ -18,9 +18,10 @@ /** * Page module admin settings and defaults * - * @package mod-page - * @copyright 2009 Petr Skoda (http://skodak.org) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod + * @subpackage page + * @copyright 2009 Petr Skoda (http://skodak.org) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die; diff --git a/mod/page/version.php b/mod/page/version.php index ea02913f48d..fecb77309dd 100644 --- a/mod/page/version.php +++ b/mod/page/version.php @@ -18,11 +18,14 @@ /** * Page module version information * - * @package mod-page - * @copyright 2009 Petr Skoda (http://skodak.org) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod + * @subpackage page + * @copyright 2009 Petr Skoda (http://skodak.org) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ +defined('MOODLE_INTERNAL') || die; + $module->version = 2009080500; $module->requires = 2009073101; // Requires this Moodle version $module->cron = 0; diff --git a/mod/page/view.php b/mod/page/view.php index 0e6df797c0f..d5a00416596 100644 --- a/mod/page/view.php +++ b/mod/page/view.php @@ -18,9 +18,10 @@ /** * Page module version information * - * @package mod-page - * @copyright 2009 Petr Skoda (http://skodak.org) - * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later + * @package mod + * @subpackage page + * @copyright 2009 Petr Skoda (http://skodak.org) + * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ require('../../config.php');