From 81658f5dfb054e0957a46c996897fb2ef47b7115 Mon Sep 17 00:00:00 2001
From: Friederike Schwager <friederike.schwager@rwth-aachen.de>
Date: Mon, 31 May 2021 11:09:17 +0200
Subject: [PATCH] add namespace for classes in classes/output
---
action.php | 11 ++++++-----
classes/output/answermenu.php | 4 ++++
classes/output/comment.php | 3 +++
classes/output/index.php | 9 +++++++--
classes/output/printview.php | 3 +++
classes/output/questionmenu.php | 4 ++++
classes/output/reportmenu.php | 4 ++++
classes/output/statistics.php | 5 +++++
controller.php | 4 +++-
locallib.php | 10 ++++++----
10 files changed, 45 insertions(+), 12 deletions(-)
diff --git a/action.php b/action.php
index f5a0b7a..39ac2a7 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 b84d9e1..5a59974 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 26bb275..b5ba9df 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 fc391ca..c288c58 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 350c628..5fa9b3f 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 6969172..a43d1d0 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 d23b759..246d599 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 d8b9983..1689c3c 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 4cbd5ea..96b2d41 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 f1d628c..0c85ccc 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));
--
GitLab