diff --git a/action.php b/action.php index f5a0b7aed5a92fdafae16e168b46507b011da00e..39ac2a76bb0eff229c18eef808312bb728384483 100644 --- a/action.php +++ b/action.php @@ -30,6 +30,10 @@ * @authors Rabea de Groot, Anna Heynkes, Friederike Schwager * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + +use mod_pdfannotator\output\comment; +use mod_pdfannotator\output\printview; + require_once('../../config.php'); require_once('model/annotation.class.php'); require_once('model/comment.class.php'); @@ -325,7 +329,6 @@ if ($action === 'addComment') { require_capability('mod/pdfannotator:create', $context); - require_once($CFG->dirroot . '/mod/pdfannotator/classes/output/comment.php'); // Get the annotation to be commented. $annotationid = required_param('annotationId', PARAM_INT); $PAGE->set_context($context); @@ -359,7 +362,6 @@ if ($action === 'addComment') { if ($action === 'getInformation') { // This concerns only textbox and drawing. - require_once($CFG->dirroot . '/mod/pdfannotator/classes/output/comment.php'); $annotationid = required_param('annotationId', PARAM_INT); $comment = pdfannotator_annotation::get_information($annotationid); @@ -384,7 +386,8 @@ if ($action === 'getComments') { $comments = pdfannotator_comment::read($documentid, $annotationid, $context); - require_once($CFG->dirroot . '/mod/pdfannotator/classes/output/comment.php'); + // require_once($CFG->dirroot . '/mod/pdfannotator/classes/output/comment.php'); + $myrenderer = $PAGE->get_renderer('mod_pdfannotator'); $templatable = new comment($comments, $cm, $context); @@ -604,8 +607,6 @@ if ($action === 'getCommentsToPrint') { return; } - require_once($CFG->dirroot.'/mod/pdfannotator/classes/output/printview.php'); - global $DB; // The model retrieves and selects data. diff --git a/classes/output/answermenu.php b/classes/output/answermenu.php index b84d9e1b46db2463c0c74d61adb49f5e7255ec36..5a599740f563c32cb1460f4796005cddc293a6a8 100644 --- a/classes/output/answermenu.php +++ b/classes/output/answermenu.php @@ -22,6 +22,10 @@ * @author Friederike Schwager * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + +namespace mod_pdfannotator\output; +use moodle_url; + defined('MOODLE_INTERNAL') || die(); class answermenu implements \renderable, \templatable { diff --git a/classes/output/comment.php b/classes/output/comment.php index 26bb275673e28db94c18973d24543dc8361b0dd8..b5ba9dfcf0c7845fb7e1b20752b822af75440995 100644 --- a/classes/output/comment.php +++ b/classes/output/comment.php @@ -14,6 +14,9 @@ // You should have received a copy of the GNU General Public License // along with Moodle. If not, see <http://www.gnu.org/licenses/>. +namespace mod_pdfannotator\output; +use moodle_url; + /** * Renderable for comments. * diff --git a/classes/output/index.php b/classes/output/index.php index fc391ca0c111a32294f6acb247813dffdde203c9..c288c58e3816ac8a6874404dfb69bac426177a23 100644 --- a/classes/output/index.php +++ b/classes/output/index.php @@ -28,9 +28,14 @@ * * @author degroot */ + +namespace mod_pdfannotator\output; + +use stdClass; + defined('MOODLE_INTERNAL') || die(); -class index implements renderable, templatable { // Class should be placed elsewhere. +class index implements \renderable, \templatable { // Class should be placed elsewhere. private $usestudenttextbox; private $usestudentdrawing; @@ -61,7 +66,7 @@ class index implements renderable, templatable { // Class should be placed elsew } - public function export_for_template(renderer_base $output) { + public function export_for_template(\renderer_base $output) { global $OUTPUT, $PAGE; $url = $PAGE->url; $data = new stdClass(); diff --git a/classes/output/printview.php b/classes/output/printview.php index 350c628019b54e686fc300323afd74543bb88ba2..5fa9b3f1055914a4d2b8292cecf833d7c940fdde 100644 --- a/classes/output/printview.php +++ b/classes/output/printview.php @@ -25,6 +25,9 @@ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later * */ + +namespace mod_pdfannotator\output; + defined('MOODLE_INTERNAL') || die(); class printview implements \renderable, \templatable { diff --git a/classes/output/questionmenu.php b/classes/output/questionmenu.php index 69691721756d8ec1ec60c1cfc2d1f659deb89014..a43d1d0607816bc0de25dd60edf0eee62a425472 100644 --- a/classes/output/questionmenu.php +++ b/classes/output/questionmenu.php @@ -22,6 +22,10 @@ * @author Friederike Schwager * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + +namespace mod_pdfannotator\output; +use moodle_url; + defined('MOODLE_INTERNAL') || die(); class questionmenu implements \renderable, \templatable { diff --git a/classes/output/reportmenu.php b/classes/output/reportmenu.php index d23b75970e247cfffe4b8f918b6eea5d519cd123..246d599c1a6a7f80a592351363fdb24edeac9d00 100644 --- a/classes/output/reportmenu.php +++ b/classes/output/reportmenu.php @@ -22,6 +22,10 @@ * @author Friederike Schwager * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + +namespace mod_pdfannotator\output; +use moodle_url; + defined('MOODLE_INTERNAL') || die(); class reportmenu implements \renderable, \templatable { diff --git a/classes/output/statistics.php b/classes/output/statistics.php index d8b9983f3fa823e3bfdcf35623d16d5d312082e3..1689c3c68742f4166de5844d86cc4b27b8f0376d 100644 --- a/classes/output/statistics.php +++ b/classes/output/statistics.php @@ -24,6 +24,11 @@ * @author Friederike Schwager * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + +namespace mod_pdfannotator\output; + +use pdfannotator_statistics; + defined('MOODLE_INTERNAL') || die(); /** diff --git a/controller.php b/controller.php index 4cbd5ea5ca24c11d9e30d990aee93957b7be8605..96b2d41ee59f42552c02111a21ee49ff906bfdbf 100644 --- a/controller.php +++ b/controller.php @@ -20,6 +20,9 @@ * @authors Anna Heynkes, Friederike Schwager * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + +use mod_pdfannotator\output\statistics; + defined('MOODLE_INTERNAL') || die(); $action = optional_param('action', 'view', PARAM_ALPHA); // The default action is 'view'. @@ -435,7 +438,6 @@ if ($action === 'statistic') { require_capability('mod/pdfannotator:viewstatistics', $context); require_once($CFG->dirroot . '/mod/pdfannotator/model/statistics.class.php'); - require_once($CFG->dirroot . '/mod/pdfannotator/classes/output/statistics.php'); echo $myrenderer->pdfannotator_render_tabs($taburl, $action, $pdfannotator->name, $context); $PAGE->set_title("statisticview"); diff --git a/locallib.php b/locallib.php index f1d628c47bd691df82a23822ac11cf25831baa8d..0c85ccc850ae998b555f1f23ff40acb22cb5d465 100644 --- a/locallib.php +++ b/locallib.php @@ -19,6 +19,12 @@ * @authors Rabea de Groot, Anna Heynkes, Friederike Schwager * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ + +use mod_pdfannotator\output\answermenu; +use mod_pdfannotator\output\questionmenu; +use mod_pdfannotator\output\reportmenu; +use mod_pdfannotator\output\index; + defined('MOODLE_INTERNAL') || die; require_once("$CFG->libdir/filelib.php"); @@ -35,7 +41,6 @@ require_once("$CFG->dirroot/mod/pdfannotator/lib.php"); */ function pdfannotator_display_embed($pdfannotator, $cm, $course, $file, $page = 1, $annoid = null, $commid = null) { global $CFG, $PAGE, $OUTPUT, $USER; - require_once($CFG->dirroot . '/mod/pdfannotator/classes/output/index.php'); // The revision attribute's existance is demanded by moodle for versioning and could be saved in the pdfannotator table in the future. // Note, however, that we forbid file replacement in order to prevent a change of meaning in other people's comments. @@ -1575,7 +1580,6 @@ function pdfannotator_questionstable_add_row($thiscourse, $table, $question, $ur $data = array($content, $author . '<br>' . $time, $question->votes, $question->answercount, $lastanswered, $pdfannotatorname); if ($showdropdown) { - require_once($CFG->dirroot . '/mod/pdfannotator/classes/output/questionmenu.php'); $myrenderer = $PAGE->get_renderer('mod_pdfannotator'); $dropdown = $myrenderer->render_dropdownmenu(new questionmenu($question->commentid, $urlparams)); $data[] = $dropdown; @@ -1627,7 +1631,6 @@ function pdfannotator_answerstable_add_row($thiscourse, $table, $answer, $cmid, $classname = 'dimmed_text'; } - require_once($CFG->dirroot . '/mod/pdfannotator/classes/output/answermenu.php'); $myrenderer = $PAGE->get_renderer('mod_pdfannotator'); $dropdown = $myrenderer->render_dropdownmenu(new answermenu($answer->annoid, $issubscribed, $cmid, $currentpage, $itemsperpage, $answerfilter)); @@ -1684,7 +1687,6 @@ function pdfannotator_reportstable_add_row($thiscourse, $table, $report, $cmid, } // Create action dropdown menu. - require_once($CFG->dirroot . '/mod/pdfannotator/classes/output/reportmenu.php'); $myrenderer = $PAGE->get_renderer('mod_pdfannotator'); $dropdown = $myrenderer->render_dropdownmenu(new reportmenu($report, $cmid, $currentpage, $itemsperpage, $reportfilter));