diff --git a/amd/build/module.min.js b/amd/build/module.min.js
index 9367ee3..9560bc7 100644
--- a/amd/build/module.min.js
+++ b/amd/build/module.min.js
@@ -2,7 +2,7 @@
* *************************************************************************
* * OOHOO - Tab Display **
* *************************************************************************
- * @package mod **
+ * @package
* @subpackage tab **
* @name tab **
* @copyright oohoo.biz **
@@ -10,7 +10,8 @@
* @author Patrick Thibaudeau **
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
- * ************************************************************************ */
-define("mod_tab/module",["jquery"],(function($){var modtabjs={obj:null,init:function(id){modtabjs.obj=$("#"+id),modtabjs.resizeobject(),window.onresize=function(){modtabjs.resizeobject()}},resizeobject:function(){var newwidth=$(".tab-content").width();modtabjs.obj.css("width","0px"),modtabjs.obj.css("height","0px");var newheight=window.visualViewport.height-$("div#page").height()-40;newwidth<600&&(newwidth=600),newheight<400&&(newheight=400),modtabjs.obj.css("width",newwidth+"px"),modtabjs.obj.css("height",newheight+"px")}};return modtabjs}));
+ * ************************************************************************
+ */
+define("mod_tab/module",["jquery"],(function($){let modtabjs={obj:null,init:function(id){modtabjs.obj=$("#"+id),modtabjs.resizeobject(),window.onresize=function(){modtabjs.resizeobject()}},resizeobject:function(){let newwidth=$(".tab-content").width();modtabjs.obj.css("width","0px"),modtabjs.obj.css("height","0px");let newheight=window.visualViewport.height-$("div#page").height()-40;newwidth<600&&(newwidth=600),newheight<400&&(newheight=400),modtabjs.obj.css("width",newwidth+"px"),modtabjs.obj.css("height",newheight+"px")}};return modtabjs}));
//# sourceMappingURL=module.min.js.map
\ No newline at end of file
diff --git a/amd/build/module.min.js.map b/amd/build/module.min.js.map
index 8ef9e41..b0bc591 100644
--- a/amd/build/module.min.js.map
+++ b/amd/build/module.min.js.map
@@ -1 +1 @@
-{"version":3,"file":"module.min.js","sources":["../src/module.js"],"sourcesContent":["/**\n * *************************************************************************\n * * OOHOO - Tab Display **\n * *************************************************************************\n * @package mod **\n * @subpackage tab **\n * @name tab **\n * @copyright oohoo.biz **\n * @link http://oohoo.biz **\n * @author Patrick Thibaudeau **\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **\n * *************************************************************************\n * ************************************************************************ */\ndefine(['jquery'], function($) {\n var modtabjs = {\n obj: null,\n init: function(id) {\n modtabjs.obj = $('#' + id);\n modtabjs.resizeobject();\n window.onresize = function () {\n modtabjs.resizeobject();\n };\n },\n resizeobject: function() {\n var newwidth = $('.tab-content').width();\n\n modtabjs.obj.css('width', '0px');\n modtabjs.obj.css('height', '0px');\n\n var newheight = window.visualViewport.height - $('div#page').height() - 40;\n\n if (newwidth < 600) {\n newwidth = 600;\n }\n if (newheight < 400) {\n newheight = 400;\n }\n modtabjs.obj.css('width', newwidth + 'px');\n modtabjs.obj.css('height', newheight + 'px');\n }\n };\n\n return modtabjs;\n});\n"],"names":["define","$","modtabjs","obj","init","id","resizeobject","window","onresize","newwidth","width","css","newheight","visualViewport","height"],"mappings":";;;;;;;;;;;;;AAaAA,wBAAO,CAAC,WAAW,SAASC,OACpBC,SAAW,CACXC,IAAK,KACLC,KAAM,SAASC,IACXH,SAASC,IAAMF,EAAE,IAAMI,IACvBH,SAASI,eACTC,OAAOC,SAAW,WACdN,SAASI,iBAGjBA,aAAc,eACNG,SAAWR,EAAE,gBAAgBS,QAEjCR,SAASC,IAAIQ,IAAI,QAAS,OAC1BT,SAASC,IAAIQ,IAAI,SAAU,WAEvBC,UAAYL,OAAOM,eAAeC,OAASb,EAAE,YAAYa,SAAW,GAEpEL,SAAW,MACXA,SAAW,KAEXG,UAAY,MACZA,UAAY,KAEhBV,SAASC,IAAIQ,IAAI,QAASF,SAAW,MACrCP,SAASC,IAAIQ,IAAI,SAAUC,UAAY,eAIxCV"}
\ No newline at end of file
+{"version":3,"file":"module.min.js","sources":["../src/module.js"],"sourcesContent":["// This file is part of Moodle - http://moodle.org/\n//\n// Moodle is free software: you can redistribute it and/or modify\n// it under the terms of the GNU General Public License as published by\n// the Free Software Foundation, either version 3 of the License, or\n// (at your option) any later version.\n//\n// Moodle is distributed in the hope that it will be useful,\n// but WITHOUT ANY WARRANTY; without even the implied warranty of\n// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the\n// GNU General Public License for more details.\n//\n// You should have received a copy of the GNU General Public License\n// along with Moodle. If not, see .\n\n/**\n * *************************************************************************\n * * OOHOO - Tab Display **\n * *************************************************************************\n * @package\n * @subpackage tab **\n * @name tab **\n * @copyright oohoo.biz **\n * @link http://oohoo.biz **\n * @author Patrick Thibaudeau **\n * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **\n * *************************************************************************\n * ************************************************************************\n */\n\ndefine(['jquery'], function($) {\n let modtabjs = {\n obj: null,\n init: function(id) {\n modtabjs.obj = $('#' + id);\n modtabjs.resizeobject();\n window.onresize = function() {\n modtabjs.resizeobject();\n };\n },\n resizeobject: function() {\n let newwidth = $('.tab-content').width();\n\n modtabjs.obj.css('width', '0px');\n modtabjs.obj.css('height', '0px');\n\n let newheight = window.visualViewport.height - $('div#page').height() - 40;\n\n if (newwidth < 600) {\n newwidth = 600;\n }\n if (newheight < 400) {\n newheight = 400;\n }\n modtabjs.obj.css('width', newwidth + 'px');\n modtabjs.obj.css('height', newheight + 'px');\n }\n };\n\n return modtabjs;\n});\n"],"names":["define","$","modtabjs","obj","init","id","resizeobject","window","onresize","newwidth","width","css","newheight","visualViewport","height"],"mappings":";;;;;;;;;;;;;;AA8BAA,wBAAO,CAAC,WAAW,SAASC,OACpBC,SAAW,CACXC,IAAK,KACLC,KAAM,SAASC,IACXH,SAASC,IAAMF,EAAE,IAAMI,IACvBH,SAASI,eACTC,OAAOC,SAAW,WACdN,SAASI,iBAGjBA,aAAc,eACNG,SAAWR,EAAE,gBAAgBS,QAEjCR,SAASC,IAAIQ,IAAI,QAAS,OAC1BT,SAASC,IAAIQ,IAAI,SAAU,WAEvBC,UAAYL,OAAOM,eAAeC,OAASb,EAAE,YAAYa,SAAW,GAEpEL,SAAW,MACXA,SAAW,KAEXG,UAAY,MACZA,UAAY,KAEhBV,SAASC,IAAIQ,IAAI,QAASF,SAAW,MACrCP,SAASC,IAAIQ,IAAI,SAAUC,UAAY,eAIxCV"}
\ No newline at end of file
diff --git a/amd/src/module.js b/amd/src/module.js
index ee15bc0..2afa38b 100644
--- a/amd/src/module.js
+++ b/amd/src/module.js
@@ -1,8 +1,23 @@
+// 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 .
+
/**
* *************************************************************************
* * OOHOO - Tab Display **
* *************************************************************************
- * @package mod **
+ * @package
* @subpackage tab **
* @name tab **
* @copyright oohoo.biz **
@@ -10,24 +25,26 @@
* @author Patrick Thibaudeau **
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
- * ************************************************************************ */
+ * ************************************************************************
+ */
+
define(['jquery'], function($) {
- var modtabjs = {
+ let modtabjs = {
obj: null,
init: function(id) {
modtabjs.obj = $('#' + id);
modtabjs.resizeobject();
- window.onresize = function () {
+ window.onresize = function() {
modtabjs.resizeobject();
};
},
resizeobject: function() {
- var newwidth = $('.tab-content').width();
+ let newwidth = $('.tab-content').width();
modtabjs.obj.css('width', '0px');
modtabjs.obj.css('height', '0px');
- var newheight = window.visualViewport.height - $('div#page').height() - 40;
+ let newheight = window.visualViewport.height - $('div#page').height() - 40;
if (newwidth < 600) {
newwidth = 600;
diff --git a/backup/moodle1/lib.php b/backup/moodle1/lib.php
old mode 100755
new mode 100644
index 4a30519..6805d08
--- a/backup/moodle1/lib.php
+++ b/backup/moodle1/lib.php
@@ -1,4 +1,18 @@
.
/**
* *************************************************************************
@@ -13,18 +27,17 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
* ************************************************************************ */
-defined('MOODLE_INTERNAL') || die();
/**
* Tab Display conversion handler
*/
class moodle1_mod_tab_handler extends moodle1_mod_handler {
- /** @var moodle1_file_manager */
- protected $fileman = null;
+ /** @var ?moodle1_file_manager */
+ protected ?moodle1_file_manager $fileman = null;
- /** @var int cmid */
- protected $moduleid = null;
+ /** @var ?int cmid */
+ protected ?int $moduleid = null;
/**
* Declare the paths in moodle.xml we are able to convert
@@ -39,22 +52,22 @@ class moodle1_mod_tab_handler extends moodle1_mod_handler {
*
* @return array of {@link convert_path} instances
*/
- public function get_paths() {
- return array(
+ public function get_paths(): array {
+ return [
new convert_path('tab', '/MOODLE_BACKUP/COURSE/MODULES/MOD/TAB'),
new convert_path('tab_contents', '/MOODLE_BACKUP/COURSE/MODULES/MOD/TAB/TABCONTENTS'),
new convert_path('tab_content', '/MOODLE_BACKUP/COURSE/MODULES/MOD/TAB/TABCONTENTS/TABCONTENT',
- array(
- 'renamefields' => array(
+ [
+ 'renamefields' => [
'format' => 'contentformat',
- ),
- 'newfields' => array(
- 'externalurl' => NULL,
+ ],
+ 'newfields' => [
+ 'externalurl' => null,
'contentformat' => 1,
- ),
- )
+ ],
+ ]
),
- );
+ ];
}
/**
@@ -63,24 +76,24 @@ public function get_paths() {
*/
public function process_tab($data) {
- // get the course module id and context id
+ // Get the course module id and context id.
$instanceid = $data['id'];
$cminfo = $this->get_cminfo($instanceid);
$this->moduleid = $cminfo['id'];
$contextid = $this->converter->get_contextid(CONTEXT_MODULE, $this->moduleid);
- // get a fresh new file manager for this instance
+ // Get a fresh new file manager for this instance.
$this->fileman = $this->converter->get_file_manager($contextid, 'mod_tab');
- // convert course files embedded into the intro
- //$this->fileman->filearea = 'tabcontent';
- //$this->fileman->itemid = 0;
- //$data['tabcontent'] = moodle1_converter::migrate_referenced_files($data['tabcontent'], $this->fileman);
- // start writing choice.xml
- $this->open_xml_writer("activities/tab_{$this->moduleid}/tab.xml");
- $this->xmlwriter->begin_tag('activity', array('id' => $instanceid, 'moduleid' => $this->moduleid,
- 'modulename' => 'tab', 'contextid' => $contextid));
- $this->xmlwriter->begin_tag('tab', array('id' => $instanceid));
+ // Vonvert course files embedded into the intro
+ // $this->fileman->filearea = 'tabcontent';
+ // $this->fileman->itemid = 0;
+ // $data['tabcontent'] = moodle1_converter::migrate_referenced_files($data['tabcontent'], $this->fileman);
+ // Start writing choice.xml.
+ $this->open_xml_writer("activities/tab_$this->moduleid/tab.xml");
+ $this->xmlwriter->begin_tag('activity', ['id' => $instanceid, 'moduleid' => $this->moduleid,
+ 'modulename' => 'tab', 'contextid' => $contextid, ]);
+ $this->xmlwriter->begin_tag('tab', ['id' => $instanceid]);
foreach ($data as $field => $value) {
if ($field <> 'id') {
@@ -94,7 +107,7 @@ public function process_tab($data) {
/**
* This is executed when the parser reaches the opening element
*/
- public function on_tab_contents_start() {
+ public function on_tab_contents_start(): void {
$this->xmlwriter->begin_tag('tab_contents');
}
@@ -102,22 +115,22 @@ public function on_tab_contents_start() {
* This is executed every time we have one /MOODLE_BACKUP/COURSE/MODULES/MOD/CHOICE/OPTIONS/OPTION
* data available
*/
- public function process_tab_content($data) {
- $this->write_xml('tab_content', $data, array('/tab_content/id'));
+ public function process_tab_content($data): void {
+ $this->write_xml('tab_content', $data, ['/tab_content/id']);
}
/**
* This is executed when the parser reaches the closing element
*/
- public function on_tab_contents_end() {
+ public function on_tab_contents_end(): void {
$this->xmlwriter->end_tag('tab_contents');
}
/**
* This is executed when we reach the closing tag of our 'choice' path
*/
- public function on_tab_end() {
- // finalize tab.xml
+ public function on_tab_end(): void {
+ // Finalize tab.xml.
$this->xmlwriter->end_tag('tab');
$this->xmlwriter->end_tag('activity');
$this->close_xml_writer();
diff --git a/backup/moodle2/backup_tab_activity_task.class.php b/backup/moodle2/backup_tab_activity_task.class.php
old mode 100755
new mode 100644
index c0ffd92..db024c3
--- a/backup/moodle2/backup_tab_activity_task.class.php
+++ b/backup/moodle2/backup_tab_activity_task.class.php
@@ -1,5 +1,18 @@
.
/**
* *************************************************************************
* * OOHOO - Tab Display **
@@ -14,8 +27,10 @@
* *************************************************************************
* ************************************************************************ */
-require_once($CFG->dirroot . '/mod/tab/backup/moodle2/backup_tab_stepslib.php'); // Because it exists (must)
-require_once($CFG->dirroot . '/mod/tab/backup/moodle2/backup_tab_settingslib.php'); // Because it exists (optional)
+defined('MOODLE_INTERNAL') || die;
+
+require_once($CFG->dirroot . '/mod/tab/backup/moodle2/backup_tab_stepslib.php'); // Because it exists (must).
+require_once($CFG->dirroot . '/mod/tab/backup/moodle2/backup_tab_settingslib.php'); // Because it exists (optional).
/**
* choice backup task that provides all the settings and steps to perform one
@@ -27,13 +42,13 @@ class backup_tab_activity_task extends backup_activity_task {
* Define (add) particular settings this activity can have
*/
protected function define_my_settings() {
- // No particular settings for this activity
+ // No particular settings for this activity.
}
/**
* Define (add) particular steps this activity can have
*/
- protected function define_my_steps() {
+ protected function define_my_steps(): void {
$this->add_step(new backup_tab_activity_structure_step('tab_structure', 'tab.xml'));
}
@@ -43,15 +58,13 @@ protected function define_my_steps() {
* @param string $content some HTML text that eventually contains URLs to the activity instance scripts
* @return string the content with the URLs encoded
*/
- static public function encode_content_links($content) {
+ public static function encode_content_links($content): string {
global $CFG;
$base = preg_quote($CFG->wwwroot, "/");
- // Link to page view by moduleid
- $search = "/(" . $base . "\/mod\/tab\/view.php\?id\=)([0-9]+)/";
- $content = preg_replace($search, '$@TABVIEWBYID*$2@$', $content);
-
- return $content;
+ // Link to page view by moduleid.
+ $search = "/(" . $base . "\/mod\/tab\/view.php\?id=)([0-9]+)/";
+ return preg_replace($search, '$@TABVIEWBYID*$2@$', $content);
}
-}
\ No newline at end of file
+}
diff --git a/backup/moodle2/backup_tab_settingslib.php b/backup/moodle2/backup_tab_settingslib.php
old mode 100755
new mode 100644
index 0c8206f..5d9c686
--- a/backup/moodle2/backup_tab_settingslib.php
+++ b/backup/moodle2/backup_tab_settingslib.php
@@ -1,18 +1,32 @@
-.
+
+/**
+ * *************************************************************************
+ * * OOHOO - Tab Display **
+ * *************************************************************************
+ * @package mod **
+ * @subpackage tab **
+ * @name tab **
+ * @copyright oohoo.biz **
+ * @link http://oohoo.biz **
+ * @author Patrick Thibaudeau **
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
+ * *************************************************************************
+ * ************************************************************************ */
+// This activity has not particular settings but the inherited from the generic
+// backup_activity_task so here there isn't any class definition, like the ones
+// existing in /backup/moodle2/backup_settingslib.php (activities section).
diff --git a/backup/moodle2/backup_tab_stepslib.php b/backup/moodle2/backup_tab_stepslib.php
old mode 100755
new mode 100644
index f9fdd51..5c999c5
--- a/backup/moodle2/backup_tab_stepslib.php
+++ b/backup/moodle2/backup_tab_stepslib.php
@@ -1,5 +1,18 @@
.
/**
* *************************************************************************
* * OOHOO - Tab Display **
@@ -19,37 +32,37 @@
*/
class backup_tab_activity_structure_step extends backup_activity_structure_step {
- protected function define_structure() {
-
- // To know if we are including userinfo
- $userinfo = $this->get_setting_value('userinfo');
+ protected function define_structure(): backup_nested_element {
- // Define each element separated
- $tab = new backup_nested_element('tab', array('id'), array('name', 'intro',
- 'css', 'menucss', 'displaymenu', 'menuname', 'taborder', 'legacyfiles', 'legacyfileslast', 'timemodified', 'introformat'));
+ // Define each element separated.
+ $tab = new backup_nested_element('tab', ['id'], [
+ 'name', 'intro', 'css', 'menucss', 'displaymenu', 'menuname', 'taborder',
+ 'legacyfiles', 'legacyfileslast', 'timemodified', 'introformat',
+ ]
+ );
- $tab_contents = new backup_nested_element('tab_contents');
+ $tabcontents = new backup_nested_element('tab_contents');
- $tab_content = new backup_nested_element('tab_content', array('id'), array('tabname',
- 'tabcontent', 'tabcontentorder', 'externalurl', 'contentformat', 'timemodified'));
+ $tabcontent = new backup_nested_element('tab_content', ['id'], ['tabname',
+ 'tabcontent', 'tabcontentorder', 'externalurl', 'contentformat', 'timemodified', ]);
- // Build the tree
- $tab->add_child($tab_contents);
- $tab_contents->add_child($tab_content);
- // Define sources
- $tab->set_source_table('tab', array('id' => backup::VAR_ACTIVITYID));
+ // Build the tree.
+ $tab->add_child($tabcontents);
+ $tabcontents->add_child($tabcontent);
+ // Define sources.
+ $tab->set_source_table('tab', ['id' => backup::VAR_ACTIVITYID]);
- $tab_content->set_source_sql(
+ $tabcontent->set_source_sql(
'SELECT * FROM {tab_content}
- WHERE tabid = ?', array(backup::VAR_PARENTID));
+ WHERE tabid = ?', [backup::VAR_PARENTID]);
// Define id annotations
- //$tab_content->annotate_ids('tabid', 'tabid');
- // Define file annotations
+ // $tab_content->annotate_ids('tabid', 'tabid');
+ // Define file annotations.
$tab->annotate_files('mod_tab', 'intro', null);
- $tab_content->annotate_files('mod_tab', 'content', 'id');
+ $tabcontent->annotate_files('mod_tab', 'content', 'id');
- // Return the root element (tab), wrapped into standard activity structure
+ // Return the root element (tab), wrapped into standard activity structure.
return $this->prepare_activity_structure($tab);
}
diff --git a/backup/moodle2/restore_tab_activity_task.class.php b/backup/moodle2/restore_tab_activity_task.class.php
old mode 100755
new mode 100644
index 6cdb1c7..909cf33
--- a/backup/moodle2/restore_tab_activity_task.class.php
+++ b/backup/moodle2/restore_tab_activity_task.class.php
@@ -1,4 +1,18 @@
.
/**
* *************************************************************************
@@ -13,9 +27,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
* ************************************************************************ */
+
defined('MOODLE_INTERNAL') || die();
-require_once($CFG->dirroot . '/mod/tab/backup/moodle2/restore_tab_stepslib.php'); // Because it exists (must)
+require_once($CFG->dirroot . '/mod/tab/backup/moodle2/restore_tab_stepslib.php'); // Because it exists (must).
/**
* choice restore task that provides all the settings and steps to perform one
@@ -27,14 +42,14 @@ class restore_tab_activity_task extends restore_activity_task {
* Define (add) particular settings this activity can have
*/
protected function define_my_settings() {
- // No particular settings for this activity
+ // No particular settings for this activity.
}
/**
* Define (add) particular steps this activity can have
*/
- protected function define_my_steps() {
- // Tab only has one structure step
+ protected function define_my_steps(): void {
+ // Tab only has one structure step.
$this->add_step(new restore_tab_activity_structure_step('tab_structure', 'tab.xml'));
}
@@ -42,11 +57,11 @@ protected function define_my_steps() {
* Define the contents in the activity that must be
* processed by the link decoder
*/
- static public function define_decode_contents() {
- $contents = array();
+ public static function define_decode_contents(): array {
+ $contents = [];
- $contents[] = new restore_decode_content('tab', array('intro'), 'tab');
- $contents[] = new restore_decode_content('tab_content', array('tabcontent'), 'tab_content');
+ $contents[] = new restore_decode_content('tab', ['intro'], 'tab');
+ $contents[] = new restore_decode_content('tab_content', ['tabcontent'], 'tab_content');
return $contents;
}
@@ -55,13 +70,11 @@ static public function define_decode_contents() {
* Define the decoding rules for links belonging
* to the activity to be executed by the link decoder
*/
- static public function define_decode_rules() {
- $rules = array();
+ public static function define_decode_rules(): array {
+ $rules = [];
$rules[] = new restore_decode_rule('TABVIEWBYID', '/mod/tab/view.php?id=$1', 'course_module');
return $rules;
-
}
-
}
diff --git a/backup/moodle2/restore_tab_stepslib.php b/backup/moodle2/restore_tab_stepslib.php
old mode 100755
new mode 100644
index 9629242..47c1061
--- a/backup/moodle2/restore_tab_stepslib.php
+++ b/backup/moodle2/restore_tab_stepslib.php
@@ -1,4 +1,18 @@
.
/**
* *************************************************************************
@@ -24,32 +38,28 @@ class restore_tab_activity_structure_step extends restore_activity_structure_ste
protected function define_structure() {
- $paths = array();
- $userinfo = $this->get_setting_value('userinfo');
-
+ $paths = [];
$paths[] = new restore_path_element('tab', '/activity/tab');
$paths[] = new restore_path_element('tab_content', '/activity/tab/tab_contents/tab_content');
-
- // Return the paths wrapped into standard activity structure
+ // Return the paths wrapped into standard activity structure.
return $this->prepare_activity_structure($paths);
}
- protected function process_tab($data) {
+ protected function process_tab($data): void {
global $DB;
$data = (object)$data;
- $oldid = $data->id;
$data->course = $this->get_courseid();
$data->timemodified = $this->apply_date_offset($data->timemodified);
- // insert the tab record
+ // Insert the tab record.
$newitemid = $DB->insert_record('tab', $data);
- // immediately after inserting "activity" record, call this
+ // Immediately after inserting "activity" record, call this.
$this->apply_activity_instance($newitemid);
}
- protected function process_tab_content($data) {
+ protected function process_tab_content($data): void {
global $DB;
$data = (object)$data;
@@ -59,14 +69,12 @@ protected function process_tab_content($data) {
$data->timemodified = $this->apply_date_offset($data->timemodified);
$newitemid = $DB->insert_record('tab_content', $data);
- $this->set_mapping('tab_content', $oldid, $newitemid, true); //has related files
+ $this->set_mapping('tab_content', $oldid, $newitemid, true); // Has related files.
}
- protected function after_execute() {
- global $DB;
- // Add tab related files where itemname = tab_content (taken from $this->set_mapping)
+ protected function after_execute(): void {
+ // Add tab related files where itemname = tab_content (taken from $this->set_mapping).
$this->add_related_files('mod_tab', 'intro', null);
$this->add_related_files('mod_tab', 'content', 'tab_content');
}
-
}
diff --git a/classes/event/course_module_instance_list_viewed.php b/classes/event/course_module_instance_list_viewed.php
index ed2bfb2..e489936 100755
--- a/classes/event/course_module_instance_list_viewed.php
+++ b/classes/event/course_module_instance_list_viewed.php
@@ -1,10 +1,21 @@
.
namespace mod_tab\event;
-defined('MOODLE_INTERNAL') || die();
-
-
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
diff --git a/classes/event/course_module_viewed.php b/classes/event/course_module_viewed.php
index 2e6de0e..4d85600 100755
--- a/classes/event/course_module_viewed.php
+++ b/classes/event/course_module_viewed.php
@@ -23,7 +23,6 @@
*/
namespace mod_tab\event;
-defined('MOODLE_INTERNAL') || die();
/**
* The mod_page course module viewed event class.
@@ -38,14 +37,14 @@ class course_module_viewed extends \core\event\course_module_viewed {
/**
* Init method.
*/
- protected function init() {
+ protected function init(): void {
$this->data['crud'] = 'r';
$this->data['edulevel'] = self::LEVEL_PARTICIPATING;
$this->data['objecttable'] = 'tab';
}
- public static function get_objectid_mapping() {
- return array('db' => 'tab', 'restore' => 'tab');
+ public static function get_objectid_mapping(): array {
+ return ['db' => 'tab', 'restore' => 'tab'];
}
}
diff --git a/classes/output/renderer.php b/classes/output/renderer.php
index d9a87f4..b0fa9c7 100644
--- a/classes/output/renderer.php
+++ b/classes/output/renderer.php
@@ -1,5 +1,18 @@
.
/**
* *************************************************************************
* * OOHOO - Tab Display **
@@ -16,16 +29,18 @@
namespace mod_tab\output;
+use plugin_renderer_base;
+use templatable;
+
/**
* Description of renderer
*
* @author patrick
*/
-class renderer extends \plugin_renderer_base {
+class renderer extends plugin_renderer_base {
- public function render_view(\templatable $view) {
+ public function render_view(templatable $view): bool|string {
$data = $view->export_for_template($this);
return $this->render_from_template('mod_tab/view', $data);
}
-
}
diff --git a/classes/output/view.php b/classes/output/view.php
index dc92fcd..998d078 100644
--- a/classes/output/view.php
+++ b/classes/output/view.php
@@ -1,4 +1,19 @@
.
+
/**
* *************************************************************************
* * OOHOO - Tab Display **
@@ -15,42 +30,49 @@
namespace mod_tab\output;
+use context_course;
+use context_module;
+use core\context\course;
+use moodle_database;
+use renderable;
+use renderer_base;
use stdClass;
+use templatable;
/**
*
- * @param \renderer_base $output
+ * @param renderer_base $output
* @return array
- * @global \stdClass $USER
+ * @global stdClass $USER
*/
-class view implements \renderable, \templatable {
+class view implements renderable, templatable {
- private $tab;
- private $courseId;
- private $courseContext;
- private $cm;
+ private stdClass $tab;
+ private int $courseid;
+ private course|false $coursecontext;
+ private stdClass $cm;
/**
*
* @param stdClass $tab
- * @param int $courseId
+ * @param $courseid
* @param stdClass $cm
*/
- public function __construct($tab, $courseId, $cm) {
+ public function __construct(stdClass $tab, $courseid, stdClass $cm) {
$this->tab = $tab;
- $this->courseId = $courseId;
- $this->courseContext = \context_course::instance($courseId);
+ $this->courseid = $courseid;
+ $this->coursecontext = context_course::instance($courseid);
$this->cm = $cm;
}
/**
*
- * @param \renderer_base $output
+ * @param renderer_base $output
* @return array
- * @global \stdClass $USER
- * @global \moodle_database $DB
+ * @global stdClass $USER
+ * @global moodle_database $DB
*/
- public function export_for_template(\renderer_base $output) {
+ public function export_for_template(renderer_base $output): array {
global $CFG;
$tab = $this->tab;
@@ -60,40 +82,41 @@ public function export_for_template(\renderer_base $output) {
$intro = format_module_intro('tab', $tab, $cm->id);
}
- $data = [
+ return [
'wwwroot' => $CFG->wwwroot,
'intro' => $intro,
'showMenu' => $tab->displaymenu,
'menu' => $this->getTabMenuContent(),
- 'tabs' => $this->getTabContent()
+ 'tabs' => $this->getTabContent(),
+ 'ismoodle40andgreater' => $CFG->version >= 2022041900, // Description is only rendert in < 4.0.
];
-
- return $data;
}
- private function getTabMenuContent() {
+ private function gettabmenucontent(): array {
global $DB;
- $contentSql = 'SELECT {course_modules}.id as id,
- {course_modules}.visible as visible,
- {tab}.name as name,
+ $contentsql = <<<'EOF'
+ SELECT {course_modules}.id as id,
+ {course_modules}.visible as visible,
+ {tab}.name as name,
{tab}.taborder as taborder,
{tab}.menuname as menuname
- FROM ({modules} INNER JOIN {course_modules} ON {modules}.id = {course_modules}.module)
+ FROM ({modules} INNER JOIN {course_modules} ON {modules}.id = {course_modules}.module)
INNER JOIN {tab} ON {course_modules}.instance = {tab}.id
- WHERE ((({modules}.name)=\'tab\') AND (({course_modules}.course)=?))
- ORDER BY taborder;';
+ WHERE ((({modules}.name)='tab') AND (({course_modules}.course)=?))
+ ORDER BY taborder;
+ EOF;
- $results = $DB->get_records_sql($contentSql, [$this->courseId]);
+ $results = $DB->get_records_sql($contentsql, [$this->courseid]);
$items = [];
$i = 0;
- foreach ($results as $result) { /// foreach
- //only print the tabs that have the same menu name
+ foreach ($results as $result) { // Foreach.
+ // Only print the tabs that have the same menu name.
if ($result->menuname == $this->tab->menuname) {
- //only print visible tabs within the menu
+ // Only print visible tabs within the menu.
- if ($result->visible == 1 || has_capability('moodle/course:update', $this->courseContext)) {
+ if ($result->visible == 1 || has_capability('moodle/course:update', $this->coursecontext)) {
$items[$i]['id'] = $result->id;
$items[$i]['name'] = $result->name;
}
@@ -101,58 +124,69 @@ private function getTabMenuContent() {
$i++;
}
- $menu = [
+ return [
'name' => $this->tab->menuname,
- 'items' => $items
+ 'items' => $items,
];
-
- return $menu;
}
- private function getTabContent() {
+ private function gettabcontent(): array {
global $CFG, $DB;
- $context = \context_module::instance($this->cm->id);
- $editoroptions = array('subdirs' => 1, 'maxbytes' => $CFG->maxbytes, 'maxfiles' => -1, 'changeformat' => 1, 'context' => $context, 'noclean' => 1, 'trusttext' => true);
- $options = $DB->get_records('tab_content', array('tabid' => $this->tab->id), 'tabcontentorder');
+ $context = context_module::instance($this->cm->id);
+ $editoroptions = [
+ 'subdirs' => 1,
+ 'maxbytes' => $CFG->maxbytes,
+ 'maxfiles' => -1,
+ 'changeformat' => 1,
+ 'context' => $context,
+ 'noclean' => 1,
+ 'trusttext' => true,
+ ];
+ $options = $DB->get_records('tab_content', ['tabid' => $this->tab->id], 'tabcontentorder');
$contents = [];
$i = 0;
foreach ($options as $option) {
$externalurl = $option->externalurl;
if (!empty($externalurl)) {
- //todo check url
+ // Todo check url.
if (!preg_match('{https?:\/\/}', $externalurl)) {
$externalurl = 'http://' . $externalurl;
}
+ $contents[$i]['content'] .= tab_embed_general(
+ process_urls($externalurl),
+ get_string('embed_fail_msg', 'tab')
+ . "" . get_string('embed_fail_link_text', 'tab') . '');
} else {
if (empty($option->format)) {
$option->format = 1;
}
- $content = file_rewrite_pluginfile_urls($option->tabcontent, 'pluginfile.php', $context->id, 'mod_tab', 'content', $option->id);
+ $content = file_rewrite_pluginfile_urls(
+ $option->tabcontent,
+ 'pluginfile.php',
+ $context->id,
+ 'mod_tab',
+ 'content',
+ $option->id
+ );
$content = format_text($content, $option->contentformat, $editoroptions, $context);
- //PDF
- $content2 = str_ireplace(array(' ', "\n", "\r", "\t", ' '), array(), strip_tags($content, ''));
-
- if (stripos($content2, '') >= strlen($content2) - 4) {
- $start = strpos($content2, '"') + 1;
- $l = strpos($content2, '"', $start + 1) - $start;
-
- $href = substr($content2, $start, $l);
- if (stripos($href, '.pdf') !== false) {
- $externalurl = $href;
+ // PDF.
+ $pattern = '/]*href="([^"]*\.pdf)"[^>]*>(.*?)<\/a>/i';
+ preg_match_all($pattern, $content, $matches);
+ if (count($matches[1]) >= 1) {
+ foreach ($matches[1] as $link) {
+ // Enter into proper div.
+ $contents[$i]['content'] .= tab_embed_general(
+ process_urls($link),
+ get_string('embed_fail_msg', 'tab')
+ . "" . get_string('embed_fail_link_text', 'tab') . '');
}
+ } else {
+ $contents[$i]['content'] = $content;
}
}
- //Enter into proper div
- //Check for pdf
- if (!empty($externalurl) && preg_match('/\bpdf\b/i', $externalurl)) {
- $contents[$i]['content'] = tab_embed_general(process_urls($externalurl), '', get_string('embed_fail_msg', 'tab') . "" . get_string('embed_fail_link_text', 'tab') . '', 'application/pdf');
- } elseif (!empty($externalurl)) {
- $contents[$i]['content'] = tab_embed_general(process_urls($externalurl), '', get_string('embed_fail_msg', 'tab') . "" . get_string('embed_fail_link_text', 'tab') . '', 'text/html');
- } else {
- $contents[$i]['content'] = $content;
- }
+
$contents[$i]['name'] = $option->tabname;
$contents[$i]['id'] = $option->id;
if ($i == 0) {
@@ -165,5 +199,4 @@ private function getTabContent() {
return $contents;
}
-
}
diff --git a/classes/privacy/provider.php b/classes/privacy/provider.php
index cb70a8a..d9bd9b3 100644
--- a/classes/privacy/provider.php
+++ b/classes/privacy/provider.php
@@ -1,4 +1,19 @@
.
+
/**
* *************************************************************************
* * OOHOO - Tab Display **
@@ -15,14 +30,14 @@
namespace mod_tab\privacy;
-defined('MOODLE_INTERNAL') || die();
+use core_privacy\local\metadata\null_provider;
/**
* Privacy Subsystem for local_yukaltura implementing null_provider.
*/
class provider implements
// This plugin does not store any personal user data.
- \core_privacy\local\metadata\null_provider {
+ null_provider {
/**
* Get the language string identifier with the component's language
diff --git a/db/access.php b/db/access.php
old mode 100755
new mode 100644
index 481d934..2dd067e
--- a/db/access.php
+++ b/db/access.php
@@ -1,40 +1,54 @@
- array(
- 'captype' => 'read',
- 'contextlevel' => CONTEXT_MODULE,
- 'archetypes' => array(
- 'manager' => CAP_ALLOW,
- 'teacher' => CAP_ALLOW,
- 'editingteacher' => CAP_ALLOW,
- 'student' => CAP_ALLOW,
- 'guest' => CAP_ALLOW,
- 'user' => CAP_ALLOW,
- )
- ),
- 'mod/tab:addinstance' => array(
- 'captype' => 'write',
- 'contextlevel' => CONTEXT_MODULE,
- 'archetypes' => array(
- 'teacher' => CAP_ALLOW,
- 'editingteacher' => CAP_ALLOW,
- 'manager' => CAP_ALLOW
- )
- ),
-);
\ No newline at end of file
+.
+
+/**
+ * *************************************************************************
+ * * OOHOO - Tab Display **
+ * *************************************************************************
+ * @package mod **
+ * @subpackage tab **
+ * @name tab **
+ * @copyright oohoo.biz **
+ * @link http://oohoo.biz **
+ * @author Patrick Thibaudeau **
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
+ * *************************************************************************
+ * ************************************************************************ */
+defined('MOODLE_INTERNAL') || die;
+
+$capabilities = [
+ 'mod/tab:view' => [
+ 'captype' => 'read',
+ 'contextlevel' => CONTEXT_MODULE,
+ 'archetypes' => [
+ 'manager' => CAP_ALLOW,
+ 'teacher' => CAP_ALLOW,
+ 'editingteacher' => CAP_ALLOW,
+ 'student' => CAP_ALLOW,
+ 'guest' => CAP_ALLOW,
+ 'user' => CAP_ALLOW,
+ ],
+ ],
+ 'mod/tab:addinstance' => [
+ 'captype' => 'write',
+ 'contextlevel' => CONTEXT_MODULE,
+ 'archetypes' => [
+ 'teacher' => CAP_ALLOW,
+ 'editingteacher' => CAP_ALLOW,
+ 'manager' => CAP_ALLOW,
+ ],
+ ],
+];
diff --git a/db/install.xml b/db/install.xml
old mode 100755
new mode 100644
diff --git a/db/upgrade.php b/db/upgrade.php
old mode 100755
new mode 100644
index 5c85999..ade4e64
--- a/db/upgrade.php
+++ b/db/upgrade.php
@@ -1,4 +1,19 @@
.
+
/**
* *************************************************************************
* * OOHOO - Tab Display **
@@ -12,25 +27,25 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
* ************************************************************************ */
-defined('MOODLE_INTERNAL') || die;
/**
* This function is run when the plugin have to be updated
+ *
* @param int $oldversion The older version of the plugin installed on the moodle
* @return boolean True if the update passed successfully
* @global stdClass $CFG
* @global moodle_database $DB
*/
-function xmldb_tab_upgrade($oldversion) {
+function xmldb_tab_upgrade(int $oldversion): bool {
global $DB;
$dbman = $DB->get_manager();
if ($oldversion < 2010120501) {
- //I changed the menu css. So let's upgrade the code
+ // I changed the menu css. So let's upgrade the code.
$sql = "UPDATE {tab} SET menucss = ?";
- $params = array('
+ $params = ['
#tab-menu-wrapper {
float: left;
width: 20%;
@@ -53,48 +68,48 @@ function xmldb_tab_upgrade($oldversion) {
.row {
background-color: #CFCFCF;
}
- ');
+ ', ];
$DB->execute($sql, $params);
- // tab savepoint reached
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2010120501, 'tab');
}
if ($oldversion < 2010120900) {
- //This version empplies that the view.php file has been modified
- //No modificsations to the DB have been done
- // tab savepoint reached
+ // This version empplies that the view.php file has been modified
+ // No modificsations to the DB have been done
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2010120900, 'tab');
}
if ($oldversion < 2010120901) {
- // Define field css to be dropped from tab
+ // Define field css to be dropped from tab.
$table = new xmldb_table('tab');
$field = new xmldb_field('css');
$field2 = new xmldb_field('menucss');
- // Conditionally launch drop field css
+ // Conditionally launch drop field css.
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
- // Conditionally launch drop field css
+ // Conditionally launch drop field css.
if ($dbman->field_exists($table, $field2)) {
$dbman->drop_field($table, $field2);
}
- // tab savepoint reached
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2010120901, 'tab');
}
if ($oldversion < 2011040200) {
- // Define field pdffile to be added to tab_content
+ // Define field pdffile to be added to tab_content.
$table = new xmldb_table('tab_content');
$field = new xmldb_field('pdffile', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'tabcontentorder');
$field2 = new xmldb_field('urlembed', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'pdffile');
- // Conditionally launch add field pdffile
+ // Conditionally launch add field pdffile.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
@@ -102,77 +117,77 @@ function xmldb_tab_upgrade($oldversion) {
$dbman->add_field($table, $field2);
}
- // tab savepoint reached
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2011040200, 'tab');
}
if ($oldversion < 2011040201) {
- // Rename field externalurl on table tab_content to NEWNAMEGOESHERE
+ // Rename field externalurl on table tab_content to NEWNAMEGOESHERE.
$table = new xmldb_table('tab_content');
$field = new xmldb_field('urlembed', XMLDB_TYPE_CHAR, '255', null, null, null, null, 'pdffile');
- // Launch rename field externalurl
+ // Launch rename field externalurl.
$dbman->rename_field($table, $field, 'externalurl');
- // tab savepoint reached
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2011040201, 'tab');
}
if ($oldversion < 2011041300) {
// Rename field externalurl on table tab_content to NEWNAMEGOESHERE
- //Changes where done in the view.php file
- // tab savepoint reached
+ // Changes where done in the view.php file
+ // tab savepoint reached.
upgrade_mod_savepoint(true, 2011041300, 'tab');
}
if ($oldversion < 2011071100) {
- // Define field id to be dropped from tab_content
+ // Define field id to be dropped from tab_content.
$table = new xmldb_table('tab_content');
$field = new xmldb_field('pdffile');
- // Conditionally launch drop field id
+ // Conditionally launch drop field id.
if ($dbman->field_exists($table, $field)) {
$dbman->drop_field($table, $field);
}
- // tab savepoint reached
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2011071100, 'tab');
}
if ($oldversion < 2011071101) {
- // Changing nullability of field tabcontentorder on table tab_content to null
+ // Changing nullability of field tabcontentorder on table tab_content to null.
$table = new xmldb_table('tab_content');
$field = new xmldb_field('tabcontentorder', XMLDB_TYPE_INTEGER, '2', XMLDB_UNSIGNED, null, null, '1', 'tabcontent');
- // Launch change of nullability for field tabcontentorder
+ // Launch change of nullability for field tabcontentorder.
$dbman->change_field_notnull($table, $field);
- // tab savepoint reached
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2011071101, 'tab');
}
if ($oldversion < 2011080800) {
// Fixed two undefined variables
- // tab savepoint reached
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2011080800, 'tab');
}
if ($oldversion < 2011081000) {
// Added PDF embedding
- // tab savepoint reached
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2011081000, 'tab');
}
if ($oldversion < 2011082300) {
- // Define field intro to be added to tab
+ // Define field intro to be added to tab.
$table = new xmldb_table('tab');
$field = new xmldb_field('intro', XMLDB_TYPE_TEXT, 'small', null, null, null, null, 'course');
$field2 = new xmldb_field('introformat', XMLDB_TYPE_INTEGER, '4', null, null, null, null, 'timemodified');
- // Conditionally launch add field intro
+ // Conditionally launch add field intro.
if (!$dbman->field_exists($table, $field)) {
$dbman->add_field($table, $field);
}
@@ -180,98 +195,99 @@ function xmldb_tab_upgrade($oldversion) {
$dbman->add_field($table, $field2);
}
- // tab savepoint reached
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2011082300, 'tab');
}
if ($oldversion < 2012090600) {
- // Add acess addinstance for moodle 2.3 compatibility
+ // Add acess addinstance for moodle 2.3 compatibility.
upgrade_mod_savepoint(true, 2012090600, 'tab');
}
if ($oldversion < 2012101700) {
- // Correction for the recent files
+ // Correction for the recent files.
upgrade_mod_savepoint(true, 2012101700, 'tab');
}
if ($oldversion < 2012120400) {
- // Correction for flash files that did not appear in the tabs
+ // Correction for flash files that did not appear in the tabs.
upgrade_mod_savepoint(true, 2012120400, 'tab');
}
if ($oldversion < 2012121000) {
- // Correction for flash files that did not appear in the tabs
+ // Correction for flash files that did not appear in the tabs.
upgrade_mod_savepoint(true, 2012121000, 'tab');
}
if ($oldversion < 2012121200) {
- // + Add description available
- // + Add PDF embed in a tab
+ // Add description available.
+ // Add PDF embed in a tab.
- // tab savepoint reached
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2012121200, 'tab');
}
if ($oldversion < 2013010200) {
- // + Correction in the JS for an old YAHOO Code
+ // Correction in the JS for an old YAHOO Code.
- // tab savepoint reached
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2013010200, 'tab');
}
if ($oldversion < 2013021200) {
- // + Add the RTL support. Thanks to nadavkav
+ // Add the RTL support. Thanks to nadavkav.
- // tab savepoint reached
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2013021200, 'tab');
}
if ($oldversion < 2013021201) {
- // + Correction on the tab content to allow to put custom HTML like object tag, etc. => change the settype from TYPE_CLEAN to TYPE_RAW
+ // Correction on the tab content to allow to put custom HTML like object tag, etc. =>
+ // change the settype from TYPE_CLEAN to TYPE_RAW.
- // tab savepoint reached
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2013021201, 'tab');
}
if ($oldversion < 2013032800) {
- // + Changes on the logs
+ // Changes on the logs.
- // tab savepoint reached
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2013032800, 'tab');
}
if ($oldversion < 2013062500) {
- // tab savepoint reached
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2013062500, 'tab');
}
if ($oldversion < 2013072200) {
- //+Patch on backups
- // tab savepoint reached
+ // Patch on backups.
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2013072200, 'tab');
}
if ($oldversion < 2013072400) {
- //+Patch on filters
- // tab savepoint reached
+ // Patch on filters
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2013072400, 'tab');
}
if ($oldversion < 2014040200) {
- //+ Moodle 2.6 Update
- // tab savepoint reached
+ // Moodle 2.6 Update
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2014040200, 'tab');
}
if ($oldversion < 2016053102) {
- //+ Moodle 3.0 Update
- // tab savepoint reached
+ // Moodle 3.0 Update
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2016053102, 'tab');
}
if ($oldversion < 2019062400) {
- //+ Moodle 3.7 Update
- // tab savepoint reached
+ // Moodle 3.7 Update
+ // Tab savepoint reached.
upgrade_mod_savepoint(true, 2019062400, 'tab');
}
return true;
-}
\ No newline at end of file
+}
diff --git a/index.php b/index.php
old mode 100755
new mode 100644
index 1d2848e..525568e
--- a/index.php
+++ b/index.php
@@ -1,6 +1,20 @@
.
+
+/*
* *************************************************************************
* * OOHOO - Tab Display **
* *************************************************************************
@@ -13,13 +27,16 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
* ************************************************************************ */
+
+use mod_tab\event\course_module_instance_list_viewed;
+
require('../../config.php');
-$id = required_param('id', PARAM_INT); // course id
+$id = required_param('id', PARAM_INT); // Course id.
-$course = $DB->get_record('course', array('id' => $id), '*', MUST_EXIST);
+$course = $DB->get_record('course', ['id' => $id], '*', MUST_EXIST);
-require_course_login($course, true);
+require_course_login($course);
$PAGE->set_pagelayout('incourse');
$strpage = get_string('modulename', 'tab');
@@ -31,14 +48,14 @@
$modinfo = get_fast_modinfo($course);
-$PAGE->set_url('/mod/tab/index.php', array('id' => $course->id));
+$PAGE->set_url('/mod/tab/index.php', ['id' => $course->id]);
$PAGE->set_title($course->shortname . ': ' . $strpages);
$PAGE->set_heading($course->fullname);
$PAGE->navbar->add($strpages);
echo $OUTPUT->header();
-//log the view information
-$event = \mod_tab\event\course_module_instance_list_viewed::create(array('context' => context_course::instance($course->id)));
+// Log the view information.
+$event = course_module_instance_list_viewed::create(['context' => context_course::instance($course->id)]);
$event->add_record_snapshot('course', $course);
$event->trigger();
@@ -51,18 +68,18 @@
$usesections = course_format_uses_sections($course->format);
if ($usesections) {
- $sections = $modinfo->get_section_info_all($course->id);
+ $sections = $modinfo->get_section_info_all();
}
$table = new html_table();
$table->attributes['class'] = 'generaltable mod_index';
if ($usesections) {
- $table->head = array($strsectionname, $strname, $strintro);
- $table->align = array('center', 'left', 'left');
+ $table->head = [$strsectionname, $strname, $strintro];
+ $table->align = ['center', 'left', 'left'];
} else {
- $table->head = array($strlastmodified, $strname, $strintro);
- $table->align = array('left', 'left', 'left');
+ $table->head = [$strlastmodified, $strname, $strintro];
+ $table->align = ['left', 'left', 'left'];
}
@@ -84,12 +101,12 @@
$printsection = '' . userdate($tab->timemodified) . "";
}
- $class = $tab->visible ? '' : 'class="dimmed"'; // hidden modules are dimmed
+ $class = $tab->visible ? '' : 'class="dimmed"'; // Hidden modules are dimmed.
- $table->data[] = array(
+ $table->data[] = [
$printsection,
"id\">" . format_string($tab->name) . "",
- format_module_intro('tab', $tab, $cm->id));
+ format_module_intro('tab', $tab, $cm->id), ];
}
echo html_writer::table($table);
diff --git a/lang/en/tab.php b/lang/en/tab.php
old mode 100755
new mode 100644
index 7acd20a..e9bb261
--- a/lang/en/tab.php
+++ b/lang/en/tab.php
@@ -1,55 +1,69 @@
-Unable to embed external link. Your browser may be missing a required plugin or the link type might not be supported for embedding at this time.
';
-$string['embed_fail_msg_ie'] = 'Unable to embed external link. Internet Explorer does not support embedding external web pages at this time.
';
-$string['content'] = 'Tab content';
-$string['content_help'] = 'You can embed a pdf file by following these instructions:
-
- - type the name you would like to use for the link.
- - Select the text and click on the inser/edit link button.
- - Click on the browse button at the end of the link url field
- - Upload your pdf file and then click insert
-
- DO NOT ADD ANYTHING ELSE IN THE EDITOR.
- Save and display. The pdf file will be embedded.';
-$string['css'] = 'Stylesheet';
-$string['displaymenu'] = 'Display tab menu';
-$string['displaymenuagree'] = 'Check if you would like to display menu';
-$string['externalurl'] = 'Embed a Web page';
-$string['format'] = 'Tab formatting';
-$string['menucss'] = 'Modify menu stylesheet';
-$string['menuname'] = 'Menu name';
-$string['modulename'] = 'Tab display';
-$string['modulenameplural'] = 'Tab displays';
-$string['moretabs'] = 'Use more tabs';
-$string['name'] = 'Name';
-$string['noformating'] = 'No formatting';
-$string['order'] = 'The order you would like this tab in';
-$string['pluginname'] = 'Tab display';
-$string['pluginadministration'] = 'Tab Administration';
-$string['tab'] = 'Tab';
-$string['tabadministration'] = 'Tab Administration';
-$string['tabcontent'] = 'Tab content';
-$string['tabname'] = 'Tab name';
-$string['taborder'] = 'Tab display activity order within menu';
-$string['tab:addinstance'] = 'Add a new Tab Display';
-$string['tab:view'] = 'View Tabs';
-$string['updatethis'] = 'Update this tab display';
-$string['privacy:metadata'] = 'The Tab display activity only displays content data.';
\ No newline at end of file
+.
+
+/**
+ * *************************************************************************
+ * * OOHOO - Tab Display **
+ * *************************************************************************
+ * @package mod **
+ * @subpackage tab **
+ * @name tab **
+ * @copyright oohoo.biz **
+ * @link http://oohoo.biz **
+ * @author Patrick Thibaudeau **
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
+ * *************************************************************************
+ * ************************************************************************ */
+$string['ajouter'] = 'Add a new tab display';
+$string['addtab'] = 'Add a new tab';
+$string['changestyle'] = 'Modify stylesheet';
+$string['embed_fail_link_text'] = 'Click here to open link.';
+$string['embed_fail_msg'] = 'Unable to embed external link. Your browser may be missing a required plugin or the link type might not be supported for embedding at this time.
';
+$string['embed_fail_msg_ie'] = 'Unable to embed external link. Internet Explorer does not support embedding external web pages at this time.
';
+$string['content'] = 'Tab content';
+$string['content_help'] = 'You can embed a pdf file by following these instructions:
+
+ - type the name you would like to use for the link.
+ - Select the text and click on the inser/edit link button.
+ - Click on the browse button at the end of the link url field
+ - Upload your pdf file and then click insert
+
+ DO NOT ADD ANYTHING ELSE IN THE EDITOR.
+ Save and display. The pdf file will be embedded.';
+$string['css'] = 'Stylesheet';
+$string['displaymenu'] = 'Display tab menu';
+$string['displaymenuagree'] = 'Check if you would like to display menu';
+$string['externalurl'] = 'Embed a Web page';
+$string['format'] = 'Tab formatting';
+$string['menucss'] = 'Modify menu stylesheet';
+$string['menuname'] = 'Menu name';
+$string['modulename'] = 'Tab display';
+$string['modulenameplural'] = 'Tab displays';
+$string['moretabs'] = 'Use more tabs';
+$string['name'] = 'Name';
+$string['noformating'] = 'No formatting';
+$string['order'] = 'The order you would like this tab in';
+$string['pluginname'] = 'Tab display';
+$string['pluginadministration'] = 'Tab Administration';
+$string['tab'] = 'Tab';
+$string['tabadministration'] = 'Tab Administration';
+$string['tabcontent'] = 'Tab content';
+$string['tabname'] = 'Tab name';
+$string['taborder'] = 'Tab display activity order within menu';
+$string['tab:addinstance'] = 'Add a new Tab Display';
+$string['tab:view'] = 'View Tabs';
+$string['updatethis'] = 'Update this tab display';
+$string['privacy:metadata'] = 'The Tab display activity only displays content data.';
diff --git a/lang/fr/tab.php b/lang/fr/tab.php
old mode 100755
new mode 100644
index 9a994f3..d63d95f
--- a/lang/fr/tab.php
+++ b/lang/fr/tab.php
@@ -1,4 +1,19 @@
.
+
/**
* *************************************************************************
* * OOHOO - Tab Display **
@@ -12,7 +27,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
* ************************************************************************ */
-$string['ajouter'] = 'Ajouter un onglet';
+$string['ajouter'] = 'Ajouter un onglet';
$string['addtab'] = 'Àjouter un onglet';
$string['changestyle'] = 'Modifier la feuille de style';
$string['css'] = 'feuille de style';
@@ -38,4 +53,4 @@
$string['embed_fail_msg'] = 'Votre plugin navigateur peut être manquant un plugin requis ou le type de lien ne peut être pris en charge pour ce temps.
';
$string['embed_fail_msg_ie'] = 'Unable to embed external link. Internet Explorer does not support embedding external web pages at this time.
';
$string['tab:addinstance'] = 'Ajouter un nouvel affichage par onglets';
-$string['tab:view'] = 'Afficher l\'affichage par onglets';
\ No newline at end of file
+$string['tab:view'] = 'Afficher l\'affichage par onglets';
diff --git a/lang/fr_ca/tab.php b/lang/fr_ca/tab.php
old mode 100755
new mode 100644
index c383657..06d9b98
--- a/lang/fr_ca/tab.php
+++ b/lang/fr_ca/tab.php
@@ -1,4 +1,19 @@
.
+
/**
* *************************************************************************
* * OOHOO - Tab Display **
@@ -12,7 +27,7 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
* ************************************************************************ */
-$string['name'] = 'Nom';
+$string['name'] = 'Nom';
$string['modulename'] = 'Onglet';
$string['ajouter'] = 'Ajouter un onglet';
$string['modulenameplural'] = 'Onglets';
@@ -29,4 +44,4 @@
$string['menuname'] = 'Nom du menu';
$string['embed_fail_link_text'] = 'Cliquez ici pour ouvrir le lien.';
$string['embed_fail_msg'] = 'Votre plugin navigateur peut manquer un plugin requis ou le type de lien ne peut être pris en charge pour ce temps.
';
-$string['embed_fail_msg_ie'] = 'Unable to embed external link. Internet Explorer does not support embedding external web pages at this time.
';
\ No newline at end of file
+$string['embed_fail_msg_ie'] = 'Unable to embed external link. Internet Explorer does not support embedding external web pages at this time.
';
diff --git a/lib.php b/lib.php
old mode 100755
new mode 100644
index 0cd2d66..e7d98f8
--- a/lib.php
+++ b/lib.php
@@ -1,4 +1,18 @@
.
/**
* *************************************************************************
@@ -13,10 +27,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
* ************************************************************************ */
-defined('MOODLE_INTERNAL') || die;
/**
* List of features supported in Tab display
+ *
* @param string $feature FEATURE_xx constant for requested feature
* @return bool|null True if module supports feature, false if not, null if doesn't know
* @uses FEATURE_IDNUMBER
@@ -28,38 +42,21 @@
* @uses FEATURE_GRADE_HAS_GRADE
* @uses FEATURE_GRADE_OUTCOMES
*/
-function tab_supports($feature) {
- switch ($feature) {
- case FEATURE_IDNUMBER:
- return false;
- case FEATURE_GROUPS:
- return false;
- case FEATURE_GROUPINGS:
- return false;
- case FEATURE_MOD_INTRO:
- return true;
- case FEATURE_COMPLETION_TRACKS_VIEWS:
- return true;
- case FEATURE_GRADE_HAS_GRADE:
- return false;
- case FEATURE_GRADE_OUTCOMES:
- return false;
- case FEATURE_MOD_ARCHETYPE:
- return MOD_ARCHETYPE_RESOURCE;
- case FEATURE_BACKUP_MOODLE2:
- return true;
-
- default:
- return null;
- }
+function tab_supports(string $feature): ?bool {
+ return match ($feature) {
+ FEATURE_IDNUMBER, FEATURE_GROUPS, FEATURE_GROUPINGS, FEATURE_GRADE_HAS_GRADE, FEATURE_GRADE_OUTCOMES => false,
+ FEATURE_MOD_INTRO, FEATURE_COMPLETION_TRACKS_VIEWS, FEATURE_BACKUP_MOODLE2 => true,
+ FEATURE_MOD_ARCHETYPE => MOD_ARCHETYPE_RESOURCE,
+ default => null,
+ };
}
/**
* Returns all other caps used in module
* @return array
*/
-function tab_get_extra_capabilities() {
- return array('moodle/site:accessallgroups');
+function tab_get_extra_capabilities(): array {
+ return ['moodle/site:accessallgroups'];
}
/**
@@ -67,33 +64,32 @@ function tab_get_extra_capabilities() {
* @param $data the data submitted from the reset course.
* @return array status array
*/
-function tab_reset_userdata($tab) {
- return array();
+function tab_reset_userdata($tab): array {
+ return [];
}
/**
* List of view style log actions
* @return array
*/
-function tab_get_view_actions() {
- return array('view', 'view all');
+function tab_get_view_actions(): array {
+ return ['view', 'view all'];
}
/**
* List of update style log actions
* @return array
*/
-function tab_get_post_actions() {
- return array('update', 'add');
+function tab_get_post_actions(): array {
+ return ['update', 'add'];
}
/**
* Add tab display instance.
- * @param object $data
- * @param object $mform
+ * @param object $tab
* @return int new page instance id
*/
-function tab_add_instance($tab) {
+function tab_add_instance($tab): int {
global $CFG, $DB;
require_once("$CFG->libdir/resourcelib.php");
@@ -101,18 +97,25 @@ function tab_add_instance($tab) {
$cmid = $tab->coursemodule;
$tab->timemodified = time();
-
- //insert tabs and content
+ // Insert tabs and content.
if ($tab->id = $DB->insert_record("tab", $tab)) {
- // we need to use context now, so we need to make sure all needed info is already in db
- $DB->set_field('course_modules', 'instance', $tab->id, array('id' => $cmid));
+ // We need to use context now, so we need to make sure all needed info is already in db.
+ $DB->set_field('course_modules', 'instance', $tab->id, ['id' => $cmid]);
$context = context_module::instance($cmid);
- $editoroptions = array('subdirs' => 1, 'maxbytes' => $CFG->maxbytes, 'maxfiles' => -1, 'changeformat' => 1, 'context' => $context, 'noclean' => 1, 'trusttext' => true);
+ $editoroptions = [
+ 'subdirs' => 1,
+ 'maxbytes' => $CFG->maxbytes,
+ 'maxfiles' => -1,
+ 'changeformat' => 1,
+ 'context' => $context,
+ 'noclean' => 1,
+ 'trusttext' => true,
+ ];
foreach ($tab->tabname as $key => $value) {
$value = trim($value);
- if (isset($value) && $value <> '') {
+ if (!empty($value)) {
$option = new stdClass();
$option->tabname = $value;
$option->tabid = $tab->id;
@@ -129,19 +132,26 @@ function tab_add_instance($tab) {
$option->externalurl = $tab->content[$key]['externalurl'];
}
$option->timemodified = time();
- //Must get id number from inserted record to update the editor field (tabcontent)
- $newtab_content_id = $DB->insert_record("tab_content", $option);
+ // Must get id number from inserted record to update the editor field (tabcontent).
+ $newtabcontentid = $DB->insert_record("tab_content", $option);
- //tab content is now an array due to the new editor
- //In order to enter file information from the editor
- //We must now update the record once it has been created
+ // Tab content is now an array due to the new editor.
+ // In order to enter file information from the editor.
+ // We must now update the record once it has been created.
if (isset($tab->content[$key]['text'])) {
$draftitemid = $tab->content[$key]['itemid'];
if ($draftitemid) {
$tabcontentupdate = new stdClass();
- $tabcontentupdate->id = $newtab_content_id;
- $tabcontentupdate->tabcontent = file_save_draft_area_files($draftitemid, $context->id, 'mod_tab', 'content', $newtab_content_id, $editoroptions, $tab->content[$key]['text']);
+ $tabcontentupdate->id = $newtabcontentid;
+ $tabcontentupdate->tabcontent = file_save_draft_area_files(
+ $draftitemid,
+ $context->id,
+ 'mod_tab',
+ 'content', $newtabcontentid,
+ $editoroptions,
+ $tab->content[$key]['text']
+ );
$DB->update_record('tab_content', $tabcontentupdate);
}
}
@@ -156,12 +166,12 @@ function tab_add_instance($tab) {
* (defined by the form in mod.html) this function
* will update an existing instance with new data.
*
- * @param object $instance An object from the form in mod.html
+ * @param object $tab An object from the form in mod.html
* @return boolean Success/Fail
* *@global stdClass $CFG
* @global moodle_database $DB
*/
-function tab_update_instance($tab) {
+function tab_update_instance($tab): bool {
global $CFG, $DB;
require_once("$CFG->libdir/resourcelib.php");
@@ -173,49 +183,67 @@ function tab_update_instance($tab) {
foreach ($tab->tabname as $key => $value) {
- // we need to use context now, so we need to make sure all needed info is already in db
- $DB->set_field('course_modules', 'instance', $tab->id, array('id' => $cmid));
+ // We need to use context now, so we need to make sure all needed info is already in db.
+ $DB->set_field('course_modules', 'instance', $tab->id, ['id' => $cmid]);
$context = context_module::instance($cmid);
- $editoroptions = array('subdirs' => 1, 'maxbytes' => $CFG->maxbytes, 'maxfiles' => -1, 'changeformat' => 1, 'context' => $context, 'noclean' => 1, 'trusttext' => true);
-
+ $editoroptions = [
+ 'subdirs' => 1,
+ 'maxbytes' => $CFG->maxbytes,
+ 'maxfiles' => -1,
+ 'changeformat' => 1,
+ 'context' => $context,
+ 'noclean' => 1,
+ 'trusttext' => true,
+ ];
$value = trim($value);
$option = new stdClass();
$option->tabname = $value;
$option->tabcontentorder = $tab->tabcontentorder[$key];
$option->externalurl = $tab->externalurl[$key];
- //tab content is now an array due to the new editor
+ // Tab content is now an array due to the new editor.
$draftitemid = $tab->content[$key]['itemid'];
if ($draftitemid) {
- $option->tabcontent = file_save_draft_area_files($draftitemid, $context->id, 'mod_tab', 'content', $tab->optionid[$key], $editoroptions, $tab->content[$key]['text']);
+ $option->tabcontent = file_save_draft_area_files(
+ $draftitemid, $context->id,
+ 'mod_tab',
+ 'content',
+ $tab->optionid[$key],
+ $editoroptions,
+ $tab->content[$key]['text']);
}
$option->contentformat = $tab->content[$key]['format'];
$option->tabid = $tab->id;
$option->timemodified = time();
- if (isset($tab->optionid[$key]) && !empty($tab->optionid[$key])) {//existing tab record
+ if (isset($tab->optionid[$key]) && !empty($tab->optionid[$key])) {// Existing tab record.
$option->id = $tab->optionid[$key];
- if (isset($value) && $value <> '') {
+ if (!empty($value)) {
$DB->update_record("tab_content", $option);
- } else { //empty old option - needs to be deleted.
- $DB->delete_records("tab_content", array("id" => $option->id));
+ } else { // Empty old option - needs to be deleted.
+ $DB->delete_records("tab_content", ["id" => $option->id]);
}
- } else {
- if (isset($value) && $value <> '') {
- $newtab_content_id = $DB->insert_record("tab_content", $option);
- //tab content is now an array due to the new editor
- //In order to enter file information from the editor
- //We must now update the record once it has been created
-
- if (isset($tab->content[$key]['text'])) {
- $draftitemid = $tab->content[$key]['itemid'];
- if ($draftitemid) {
- $tabcontentupdate = new stdClass();
- $tabcontentupdate->id = $newtab_content_id;
- $tabcontentupdate->tabcontent = file_save_draft_area_files($draftitemid, $context->id, 'mod_tab', 'content', $newtab_content_id, $editoroptions, $tab->content[$key]['text']);
- $DB->update_record('tab_content', $tabcontentupdate);
- }
+ } else if (!empty($value)) {
+ $newtabcontentid = $DB->insert_record("tab_content", $option);
+ // Tab content is now an array due to the new editor.
+ // In order to enter file information from the editor.
+ // We must now update the record once it has been created.
+
+ if (isset($tab->content[$key]['text'])) {
+ $draftitemid = $tab->content[$key]['itemid'];
+ if ($draftitemid) {
+ $tabcontentupdate = new stdClass();
+ $tabcontentupdate->id = $newtabcontentid;
+ $tabcontentupdate->tabcontent = file_save_draft_area_files(
+ $draftitemid, $context->id,
+ 'mod_tab',
+ 'content',
+ $newtabcontentid,
+ $editoroptions,
+ $tab->content[$key]['text']
+ );
+ $DB->update_record('tab_content', $tabcontentupdate);
}
}
}
@@ -232,21 +260,21 @@ function tab_update_instance($tab) {
* @return boolean Success/Failure
* *@global moodle_database $DB
*/
-function tab_delete_instance($id) {
+function tab_delete_instance(int $id): bool {
global $DB;
- if (!$tab = $DB->get_record("tab", array("id" => "$id"))) {
+ if (!$tab = $DB->get_record("tab", ["id" => "$id"])) {
return false;
}
$result = true;
- # Delete any dependent records here #
+ // Delete any dependent records here.
- if (!$DB->delete_records("tab", array("id" => "$tab->id"))) {
+ if (!$DB->delete_records("tab", ["id" => "$tab->id"])) {
$result = false;
}
- if (!$DB->delete_records("tab_content", array("tabid" => "$tab->id"))) {
+ if (!$DB->delete_records("tab_content", ["tabid" => "$tab->id"])) {
$result = false;
}
@@ -263,8 +291,8 @@ function tab_delete_instance($id) {
* @package mod_tab
* @category files
*/
-function tab_get_file_areas($course, $cm, $context) {
- $areas = array();
+function tab_get_file_areas($course, $cm, $context): array {
+ $areas = [];
$areas['content'] = get_string('content', 'tab');
return $areas;
}
@@ -272,16 +300,16 @@ function tab_get_file_areas($course, $cm, $context) {
/**
* File browsing support for languagelab module content area.
*
- * @param stdClass $browser file browser instance
- * @param stdClass $areas file areas
+ * @param file_browser $browser file browser instance
+ * @param array $areas file areas
* @param stdClass $course course object
* @param stdClass $cm course module object
- * @param stdClass $context context object
+ * @param \core\context $context context object
* @param string $filearea file area
* @param int $itemid item ID
* @param string $filepath file path
* @param string $filename file name
- * @return file_info instance or null if not found
+ * @return file_info_stored instance or null if not found
* @package mod_tab
* @category files
*/
@@ -289,7 +317,7 @@ function tab_get_file_info($browser, $areas, $course, $cm, $context, $filearea,
global $CFG;
if (!has_capability('moodle/course:managefiles', $context)) {
- // students can not peak here!
+ // Students can not peak here!
return null;
}
@@ -301,10 +329,10 @@ function tab_get_file_info($browser, $areas, $course, $cm, $context, $filearea,
$urlbase = $CFG->wwwroot . '/pluginfile.php';
if (!$storedfile = $fs->get_file($context->id, 'mod_tab', 'content', $itemid, $filepath, $filename)) {
- if ($filepath === '/' and $filename === '.') {
+ if ($filepath === '/' && $filename === '.') {
$storedfile = new virtual_root_file($context->id, 'mod_tab', 'content', $itemid);
} else {
- // not found
+ // Not found.
return null;
}
}
@@ -312,7 +340,7 @@ function tab_get_file_info($browser, $areas, $course, $cm, $context, $filearea,
return new tab_content_file_info($browser, $context, $storedfile, $urlbase, $areas[$filearea], true, true, true, false);
}
- // note: page_intro handled in file_browser automatically
+ // Note: page_intro handled in file_browser automatically.
return null;
}
@@ -328,45 +356,46 @@ function tab_get_file_info($browser, $areas, $course, $cm, $context, $filearea,
* @param bool $forcedownload
* @return bool false if file not found, does not return if found - justsend the file
* @global moodle_database $DB
- * @global stdClass $CFG
*/
function tab_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload) {
- global $CFG, $DB;
+ global $DB;
- //The following code is for security
+ // The following code is for security.
require_course_login($course, true, $cm);
if ($context->contextlevel != CONTEXT_MODULE) {
return false;
}
- $fileareas = array('mod_tab', 'content');
+ $fileareas = ['mod_tab', 'content'];
if (!in_array($filearea, $fileareas)) {
return false;
}
- //id of the content row
+ // Id of the content row.
$tabcontentid = (int)array_shift($args);
- //Security - Check if exists
- if (!$tabcontent = $DB->get_record('tab_content', array('id' => $tabcontentid))) {
+ // Security - Check if exists.
+ if (!$DB->record_exists('tab_content', ['id' => $tabcontentid])) {
return false;
}
- if (!$tab = $DB->get_record('tab', array('id' => $cm->instance))) {
+ if (!$DB->record_exists('tab', ['id' => $cm->instance])) {
return false;
}
- //Now gather file information
+ // Now gather file information.
$fs = get_file_storage();
$relativepath = implode('/', $args);
$fullpath = "/$context->id/mod_tab/$filearea/$tabcontentid/$relativepath";
- if (!$file = $fs->get_file_by_hash(sha1($fullpath)) or $file->is_directory()) {
+ $file = $fs->get_file_by_hash(sha1($fullpath));
+ if (is_bool($file) || $file->is_directory()) {
return false;
}
- // finally send the file
+ // Finally send the file.
send_stored_file($file, 0, 0, $forcedownload);
+ return true;
}
/**
@@ -376,15 +405,15 @@ function tab_pluginfile($course, $cm, $context, $filearea, $args, $forcedownload
* $return->time = the time they did it
* $return->info = a short text description
*
- * @return null
+ * @return ?stdClass
* @global moodle_database $DB
* @todo Finish documenting this function
* */
function tab_user_outline($course, $user, $mod, $tab) {
global $DB;
- if ($logs = $DB->get_records('log', array('userid' => $user->id, 'module' => 'tab',
- 'action' => 'view', 'info' => $tab->id . ' - ' . $tab->name), 'time ASC')) {
+ if ($logs = $DB->get_records('log', ['userid' => $user->id, 'module' => 'tab',
+ 'action' => 'view', 'info' => $tab->id . ' - ' . $tab->name, ], 'time ASC')) {
$numviews = count($logs);
$lastlog = array_pop($logs);
@@ -395,23 +424,21 @@ function tab_user_outline($course, $user, $mod, $tab) {
return $result;
}
- return NULL;
+ return null;
}
/**
* Print a detailed representation of what a user has done with
* a given particular instance of this module, for user activity reports.
*
- * @return boolean
* @global moodle_database $DB
- * @global stdClass $CFG
* @todo Finish documenting this function
* */
-function tab_user_complete($course, $user, $mod, $tab) {
- global $CFG, $DB;
+function tab_user_complete($course, $user, $mod, $tab): void {
+ global $DB;
- if ($logs = $DB->get_records('log', array('userid' => $user->id, 'module' => 'tab',
- 'action' => 'view', 'info' => $tab->id . ' - ' . $tab->name), 'time ASC')) {
+ if ($logs = $DB->get_records('log', ['userid' => $user->id, 'module' => 'tab',
+ 'action' => 'view', 'info' => $tab->id . ' - ' . $tab->name, ], 'time ASC')) {
$numviews = count($logs);
$lastlog = array_pop($logs);
@@ -433,10 +460,9 @@ function tab_user_complete($course, $user, $mod, $tab) {
* @global $CFG
* @todo Finish documenting this function
* */
-function tab_print_recent_activity($course, $viewfullnames, $timestart) {
- global $CFG;
+function tab_print_recent_activity($course, $viewfullnames, $timestart): bool {
- return false; // True if anything was printed, otherwise false
+ return false; // True if anything was printed, otherwise false.
}
/**
@@ -446,21 +472,21 @@ function tab_print_recent_activity($course, $viewfullnames, $timestart) {
*
* See {@link get_array_of_activities()} in course/lib.php
*
- * @param object $coursemodule
- * @return object info
+ * @param stdClass $coursemodule
+ * @return ?stdClass info
* @global stdClass $CFG
* @global moodle_database $DB
*/
-function tab_get_coursemodule_info($coursemodule) {
+function tab_get_coursemodule_info($coursemodule): stdClass|null {
global $CFG, $DB;
require_once("$CFG->libdir/resourcelib.php");
- if (!$tab = $DB->get_record('tab', array('id' => $coursemodule->instance), 'id, name')) {
- return NULL;
+ if (!$tab = $DB->get_record('tab', ['id' => $coursemodule->instance], 'id, name')) {
+ return null;
}
$info = new stdClass();
$info->name = $tab->name;
return $info;
-}
\ No newline at end of file
+}
diff --git a/locallib.php b/locallib.php
old mode 100755
new mode 100644
index ebed67e..72e0b18
--- a/locallib.php
+++ b/locallib.php
@@ -1,124 +1,130 @@
-libdir/filelib.php");
-require_once("$CFG->libdir/resourcelib.php");
-require_once("$CFG->dirroot/mod/tab/lib.php");
-
-/**
- * File browsing support class
- */
-class tab_content_file_info extends file_info_stored {
-
- /**
- * Returns parent file_info instance
- * @return file_info|null file_info instance or null for root
- */
- public function get_parent() {
- if ($this->lf->get_filepath() === '/' and $this->lf->get_filename() === '.') {
- return $this->browser->get_file_info($this->context);
- }
- return parent::get_parent();
- }
-
- /**
- * Returns localised visible name.
- * @return string
- */
- public function get_visible_name() {
- if ($this->lf->get_filepath() === '/' and $this->lf->get_filename() === '.') {
- return $this->topvisiblename;
- }
- return parent::get_visible_name();
- }
-
-}
-
-/**
- * Return an array of options for the editor tinyMCE
- * @param type $context The context ID
- * @return array The array of options for the editor
- * @global stdClass $CFG
- */
-function tab_get_editor_options($context) {
- global $CFG;
- return array('subdirs' => 1, 'maxbytes' => $CFG->maxbytes, 'maxfiles' => -1, 'changeformat' => 1, 'context' => $context, 'noclean' => 1, 'trusttext' => 0);
-}
-
-/**
- * Prepare an URL. Trim, delete useless tags, etc.
- * @param string $string The URL to prepare
- * @return string
- * @global stdClass $CFG
- * @global moodle_page $PAGE
- */
-function process_urls($string) {
- preg_match_all("//", $string, $matches);
- foreach ($matches[0] as $mtch) {
- $mtch_bits = explode('"', $mtch);
- $string = str_replace($mtch, "{$mtch_bits[1]}", $string);
- }
- $path = str_replace('', '', $string);
- $path = str_replace('
', '', $path);
- $path = str_replace('', '', $path);
- $path = str_replace('
', '', $path);
-
-
- $string = $path;
-
- return $string;
-}
-
-/**
- * Returns general link or file embedding html.
- * @param string $fullurl
- * @param string $title
- * @param string $clicktoopen
- * @return string html
- * @global stdClass $CFG
- * @global moodle_page $PAGE
- */
-function tab_embed_general($fullurl, $title, $clicktoopen, $mimetype) {
- global $PAGE;
-
- $iframe = true;
-
- $id_suffix = md5($fullurl);
-
- if ($iframe) {
- $code = <<
-
-
-EOT;
- } else {
- $code = <<
-
-
-EOT;
- }
-
- $PAGE->requires->js_call_amd('mod_tab/module', 'init', ["resourceobject_$id_suffix"]);
-
- return $code;
-}
+.
+
+/**
+ * *************************************************************************
+ * * OOHOO - Tab Display **
+ * *************************************************************************
+ * @package mod **
+ * @subpackage tab **
+ * @name tab **
+ * @copyright oohoo.biz **
+ * @link http://oohoo.biz **
+ * @author Patrick Thibaudeau **
+ * @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/tab/lib.php');
+
+/**
+ * File browsing support class
+ */
+class tab_content_file_info extends file_info_stored {
+
+ /**
+ * Returns parent file_info instance
+ * @return file_info|null file_info instance or null for root
+ */
+ public function get_parent(): ?file_info {
+ if ($this->lf->get_filepath() === '/' && $this->lf->get_filename() === '.') {
+ return $this->browser->get_file_info($this->context);
+ }
+ return parent::get_parent();
+ }
+
+ /**
+ * Returns localised visible name.
+ * @return string
+ */
+ public function get_visible_name(): string {
+ if ($this->lf->get_filepath() === '/' && $this->lf->get_filename() === '.') {
+ return $this->topvisiblename;
+ }
+ return parent::get_visible_name();
+ }
+
+}
+
+/**
+ * Return an array of options for the editor tinyMCE
+ *
+ * @param object $context The context ID
+ * @return array The array of options for the editor
+ * @global stdClass $CFG
+ */
+function tab_get_editor_options($context): array {
+ global $CFG;
+ return [
+ 'subdirs' => 1,
+ 'maxbytes' => $CFG->maxbytes,
+ 'maxfiles' => -1,
+ 'changeformat' => 1,
+ 'context' => $context,
+ 'noclean' => 1,
+ 'trusttext' => 0,
+ ];
+}
+
+/**
+ * Prepare an URL. Trim, delete useless tags, etc.
+ *
+ * @param string $string The URL to prepare
+ * @return string
+ */
+function process_urls(string $string): string {
+ preg_match_all("//", $string, $matches);
+ foreach ($matches[0] as $mtch) {
+ $mtchbits = explode('"', $mtch);
+ $string = str_replace($mtch, "{$mtchbits[1]}", $string);
+ }
+ $path = str_replace('', '', $string);
+ $path = str_replace('
', '', $path);
+ $path = str_replace('', '', $path);
+ $path = str_replace('
', '', $path);
+
+ return $path;
+}
+
+/**
+ * Returns general link or file embedding html.
+ *
+ * @param string $fullurl
+ * @param string $clicktoopen
+ * @return string html
+ * @global moodle_page $PAGE
+ */
+function tab_embed_general(string $fullurl, string $clicktoopen): string {
+ global $PAGE;
+
+ $idsuffix = md5($fullurl);
+
+ $code = <<
+
+
+EOT;
+
+ $PAGE->requires->js_call_amd('mod_tab/module', 'init', ["resourceobject_$idsuffix"]);
+
+ return $code;
+}
diff --git a/mod_form.php b/mod_form.php
old mode 100755
new mode 100644
index 7857936..ea6b07f
--- a/mod_form.php
+++ b/mod_form.php
@@ -1,173 +1,205 @@
-dirroot . '/course/moodleform_mod.php');
-require_once($CFG->libdir . '/filelib.php');
-
-/**
- * Class for the form of the tab
- */
-class mod_tab_mod_form extends moodleform_mod {
-
- /**
- * The tab form
- * @global stdClass $CFG
- * @global moodle_database $DB
- */
- function definition() {
- global $CFG, $DB;
-
- $mform = $this->_form;
-
- $config = get_config('tab');
-
- $mform->addElement('header', 'general', get_string('general', 'form'));
- $mform->addElement('text', 'name', get_string('name', 'tab'), array('size' => '45'));
- if (!empty($CFG->formatstringstriptags)) {
- $mform->setType('name', PARAM_TEXT);
- } else {
- $mform->setType('name', PARAM_CLEANHTML);
- }
- $mform->addRule('name', null, 'required', null, 'client');
-
- //Add Intro
- $this->standard_intro_elements(false);
-
- $mform->setDefault('printintro', 0);
- $mform->setAdvanced('printintro', false);
-
- //Have to use this option for postgresqgl to work
- $instance = $this->current->instance;
- if (empty($instance)) {
- $instance = 0;
- }
-
- //following code used to create tabcontent order numbers
- $optionid = optional_param_array('optionid', array(), PARAM_INT);
- if (isset($optionid)) {
- $repeatnum = count($optionid);
- } else {
- $repeatnum = 0;
- }
- if ($repeatnum == 0) {
- $repeatnum = $DB->count_records('tab_content', array('tabid' => $instance));
- }
- $taborder = 1; //initialize to prevent warnings
- for ($i = 1; $i <= $repeatnum + 1; $i++) {
- if ($i == 1) {
- $taborder = 1;
- } else {
- $taborder = $taborder . ',' . $i;
- }
- }
- $context = $this->context;
-
- $editoroptions = array('subdirs' => 1, 'maxbytes' => $CFG->maxbytes, 'maxfiles' => -1, 'changeformat' => 1, 'context' => $context, 'noclean' => 1, 'trusttext' => 1);
- $taborderarray = explode(',', $taborder);
- //-----------------------------for adding tabs---------------------------------------------------------------
- $repeatarray = array();
-
- $repeatarray[] = $mform->createElement('header', 'tabs', get_string('tab', 'tab') . ' {no}');
- $repeatarray[] = $mform->createElement('text', 'tabname', get_string('tabname', 'tab'), array('size' => '65'));
- $repeatarray[] = $mform->createElement('editor', 'content', get_string('tabcontent', 'tab'), null, $editoroptions);
- $repeatarray[] = $mform->createElement('url', 'externalurl', get_string('externalurl', 'tab'), array('size' => '60'), array('usefilepicker' => true));
- $repeatarray[] = $mform->createElement('hidden', 'revision', 1);
- $repeatarray[] = $mform->createElement('select', 'tabcontentorder', get_string('order', 'tab'), $taborderarray);
- $repeatarray[] = $mform->createElement('hidden', 'optionid', 0);
-
- $mform->setType('tabname', PARAM_TEXT);
- $mform->setType('content', PARAM_RAW);
- $mform->setType('externalurl', PARAM_URL);
- $mform->setType('revision', PARAM_INT);
- $mform->setType('tabcontentorder', PARAM_INT);
- $mform->setType('optionid', PARAM_INT);
- $mform->setType('content', PARAM_RAW);
-
- if ($this->_instance) {
- $repeatno = $DB->count_records('tab_content', array('tabid' => $instance));
- $repeatno += 1;
- } else {
- $repeatno = 1;
- }
-
- $repeateloptions = array();
- if (!isset($repeateloptions['tabcontentorder'])) {
- $repeateloptions['tabcontentorder']['default'] = $i - 2;
- }
-
- $repeateloptions['content']['helpbutton'] = array('content', 'tab');
-
-
- $this->repeat_elements($repeatarray, $repeatno, $repeateloptions, 'option_repeats', 'option_add_fields', 1, get_string('addtab', 'tab'));
- //-----------------------------------------------------------------------------------------------------------------------------------------------
- //*********************************************************************************
- //*********************Display menu checkbox and name******************************
- //*********************************************************************************
- $mform->addElement('header', 'menu', get_string('displaymenu', 'tab'));
- $mform->addElement('advcheckbox', 'displaymenu', get_string('displaymenuagree', 'tab'), null, array('group' => 1), array('0', '1'));
- $mform->setType('displaymenu', PARAM_INT);
- $mform->addElement('text', 'taborder', get_string('taborder', 'tab'), array('size' => '15'));
- $mform->addElement('text', 'menuname', get_string('menuname', 'tab'), array('size' => '45'));
-
- $mform->setType('taborder', PARAM_INT);
- $mform->setType('menuname', PARAM_TEXT);
-
- //*********************************************************************************
- //*********************************************************************************
-
- $mform->setAdvanced('printintro', true);
-
- $features = array('groups' => false, 'groupings' => false, 'groupmembersonly' => true,
- 'outcomes' => false, 'gradecat' => false, 'idnumber' => false);
- $this->standard_coursemodule_elements($features);
-
- //-------------------------------------------------------------------------------
- // buttons
- $this->add_action_buttons();
- }
-
- /**
- * The preprocessing data from the form
- * @param array $default_values
- * @global moodle_database $DB
- * @global stdClass $CFG
- */
- function data_preprocessing(&$default_values) {
- global $CFG, $DB;
- if ($this->current->instance) {
- $options = $DB->get_records('tab_content', array('tabid' => $this->current->instance), 'tabcontentorder');
- $tabids = array_keys($options);
- $options = array_values($options);
- $context = $this->context;
- $editoroptions = array('subdirs' => 1, 'maxbytes' => $CFG->maxbytes, 'maxfiles' => -1, 'changeformat' => 1, 'context' => $context, 'noclean' => 1, 'trusttext' => 1);
- foreach (array_keys($options) as $key) {
- $default_values['tabname[' . $key . ']'] = $options[$key]->tabname;
-
- $draftitemid = file_get_submitted_draft_itemid('content[' . $key . ']');
- $default_values['content[' . $key . ']']['format'] = $options[$key]->contentformat;
- $default_values['content[' . $key . ']']['text'] = file_prepare_draft_area($draftitemid, $this->context->id, 'mod_tab', 'content', $options[$key]->id, $editoroptions, $options[$key]->tabcontent);
- $default_values['content[' . $key . ']']['itemid'] = $draftitemid;
-
- //$default_values['format['.$key.']'] = $options[$key]->format;
- $default_values['externalurl[' . $key . ']'] = $options[$key]->externalurl;
- $default_values['tabcontentorder[' . $key . ']'] = $options[$key]->tabcontentorder;
- $default_values['optionid[' . $key . ']'] = $tabids[$key];
- }
- }
- }
-
-}
+.
+
+/**
+ * *************************************************************************
+ * * OOHOO - Tab Display **
+ * *************************************************************************
+ * @package mod **
+ * @subpackage tab **
+ * @name tab **
+ * @copyright oohoo.biz **
+ * @link http://oohoo.biz **
+ * @author Patrick Thibaudeau **
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
+ * *************************************************************************
+ * ************************************************************************ */
+defined('MOODLE_INTERNAL') || die;
+
+require_once($CFG->dirroot . '/course/moodleform_mod.php');
+require_once($CFG->libdir . '/filelib.php');
+
+/**
+ * Class for the form of the tab
+ */
+class mod_tab_mod_form extends moodleform_mod {
+
+ /**
+ * The tab form
+ * @global stdClass $CFG
+ * @global moodle_database $DB
+ */
+ public function definition(): void {
+ global $CFG, $DB;
+
+ $mform = $this->_form;
+
+ $mform->addElement('header', 'general', get_string('general', 'form'));
+ $mform->addElement('text', 'name', get_string('name', 'tab'), ['size' => '45']);
+ if (!empty($CFG->formatstringstriptags)) {
+ $mform->setType('name', PARAM_TEXT);
+ } else {
+ $mform->setType('name', PARAM_CLEANHTML);
+ }
+ $mform->addRule('name', null, 'required', null, 'client');
+
+ // Add Intro.
+ $this->standard_intro_elements(false);
+
+ $mform->setDefault('printintro', 0);
+ $mform->setAdvanced('printintro', false);
+
+ // Have to use this option for postgresqgl to work.
+ $instance = $this->current->instance;
+ if (empty($instance)) {
+ $instance = 0;
+ }
+
+ // Following code used to create tabcontent order numbers.
+ $optionid = optional_param_array('optionid', [], PARAM_INT);
+ if (isset($optionid)) {
+ $repeatnum = count($optionid);
+ } else {
+ $repeatnum = 0;
+ }
+ if ($repeatnum == 0) {
+ $repeatnum = $DB->count_records('tab_content', ['tabid' => $instance]);
+ }
+ $taborder = 1; // Initialize to prevent warnings.
+ for ($i = 1; $i <= $repeatnum + 1; $i++) {
+ if ($i == 1) {
+ $taborder = 1;
+ } else {
+ $taborder = $taborder . ',' . $i;
+ }
+ }
+ $context = $this->context;
+
+ $editoroptions = [
+ 'subdirs' => 1,
+ 'maxbytes' => $CFG->maxbytes,
+ 'maxfiles' => -1,
+ 'changeformat' => 1,
+ 'context' => $context,
+ 'noclean' => 1,
+ 'trusttext' => 1,
+ ];
+
+ $taborderarray = explode(',', $taborder);
+
+ // ...*********************For adding tabs******************************
+ $repeatarray = [];
+
+ $repeatarray[] = $mform->createElement('header', 'tabs', get_string('tab', 'tab') . ' {no}');
+ $repeatarray[] = $mform->createElement('text', 'tabname', get_string('tabname', 'tab'), ['size' => '65']);
+ $repeatarray[] = $mform->createElement('editor', 'content', get_string('tabcontent', 'tab'), null, $editoroptions);
+ $repeatarray[] = $mform->createElement('url', 'externalurl', get_string('externalurl', 'tab'),
+ ['size' => '60'], ['usefilepicker' => true]);
+ $repeatarray[] = $mform->createElement('hidden', 'revision', 1);
+ $repeatarray[] = $mform->createElement('select', 'tabcontentorder', get_string('order', 'tab'), $taborderarray);
+ $repeatarray[] = $mform->createElement('hidden', 'optionid', 0);
+
+ $mform->setType('tabname', PARAM_TEXT);
+ $mform->setType('content', PARAM_RAW);
+ $mform->setType('externalurl', PARAM_URL);
+ $mform->setType('revision', PARAM_INT);
+ $mform->setType('tabcontentorder', PARAM_INT);
+ $mform->setType('optionid', PARAM_INT);
+ $mform->setType('content', PARAM_RAW);
+
+ if ($this->_instance) {
+ $repeatno = $DB->count_records('tab_content', ['tabid' => $instance]);
+ $repeatno += 1;
+ } else {
+ $repeatno = 1;
+ }
+
+ $repeateloptions['tabcontentorder']['default'] = $i - 2;
+
+ $repeateloptions['content']['helpbutton'] = ['content', 'tab'];
+
+ $this->repeat_elements(
+ $repeatarray,
+ $repeatno,
+ $repeateloptions,
+ 'option_repeats',
+ 'option_add_fields',
+ 1,
+ get_string('addtab', 'tab'),
+ );
+ // ...*********************************************************************************
+ // ...*********************Display menu checkbox and name******************************
+ // ...*********************************************************************************
+ $mform->addElement('header', 'menu', get_string('displaymenu', 'tab'));
+ $mform->addElement('advcheckbox', 'displaymenu', get_string('displaymenuagree', 'tab'), null, ['group' => 1], ['0', '1']);
+ $mform->setType('displaymenu', PARAM_INT);
+ $mform->addElement('text', 'taborder', get_string('taborder', 'tab'), ['size' => '15']);
+ $mform->addElement('text', 'menuname', get_string('menuname', 'tab'), ['size' => '45']);
+
+ $mform->setType('taborder', PARAM_INT);
+ $mform->setType('menuname', PARAM_TEXT);
+
+ // ...*********************************************************************************
+ // ...*********************************************************************************
+
+ $mform->setAdvanced('printintro');
+
+ $this->standard_coursemodule_elements();
+
+ // -------------------------------------------------------------------------------
+ // Buttons.
+ $this->add_action_buttons();
+ }
+
+ /**
+ * The preprocessing data from the form
+ * @param array $defaultvalues
+ * @global moodle_database $DB
+ * @global stdClass $CFG
+ */
+ public function data_preprocessing(&$defaultvalues): void {
+ global $CFG, $DB;
+ if ($this->current->instance) {
+ $options = $DB->get_records('tab_content', ['tabid' => $this->current->instance], 'tabcontentorder');
+ $tabids = array_keys($options);
+ $options = array_values($options);
+ $context = $this->context;
+ $editoroptions = [
+ 'subdirs' => 1,
+ 'maxbytes' => $CFG->maxbytes,
+ 'maxfiles' => -1,
+ 'changeformat' => 1,
+ 'context' => $context,
+ 'noclean' => 1,
+ 'trusttext' => 1,
+ ];
+ foreach (array_keys($options) as $key) {
+ $defaultvalues['tabname[' . $key . ']'] = $options[$key]->tabname;
+
+ $draftitemid = file_get_submitted_draft_itemid('content[' . $key . ']');
+ $defaultvalues['content[' . $key . ']']['format'] = $options[$key]->contentformat;
+ $defaultvalues['content[' . $key . ']']['text'] = file_prepare_draft_area($draftitemid, $this->context->id,
+ 'mod_tab', 'content', $options[$key]->id, $editoroptions, $options[$key]->tabcontent);
+ $defaultvalues['content[' . $key . ']']['itemid'] = $draftitemid;
+
+ $defaultvalues['externalurl[' . $key . ']'] = $options[$key]->externalurl;
+ $defaultvalues['tabcontentorder[' . $key . ']'] = $options[$key]->tabcontentorder;
+ $defaultvalues['optionid[' . $key . ']'] = $tabids[$key];
+ }
+ }
+ }
+
+}
diff --git a/styles.css b/styles.css
index 0d60fef..19d8549 100644
--- a/styles.css
+++ b/styles.css
@@ -1,5 +1,5 @@
.mod-tab-embedded{
border: none;
- width: 100%;
- height: 800px;
+ width: 100%;
+ min-height: 80vh;
}
\ No newline at end of file
diff --git a/templates/view.mustache b/templates/view.mustache
index c058034..f80906c 100644
--- a/templates/view.mustache
+++ b/templates/view.mustache
@@ -1,4 +1,20 @@
-
+ * ************************************************************************
+ }}
{{#intro}}
+ {{^ismoodle40andgreater}}
+ {{/ismoodle40andgreater}}
{{/intro}}
{{#showMenu}}
diff --git a/version.php b/version.php
old mode 100755
new mode 100644
index df921f8..5ed77fb
--- a/version.php
+++ b/version.php
@@ -1,4 +1,18 @@
.
/**
* *************************************************************************
@@ -13,7 +27,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
* ************************************************************************ */
-$plugin->version = 2019062404; // The current module version (Date: YYYYMMDDXX)
+
+defined('MOODLE_INTERNAL') || die();
+
+$plugin->version = 2019062404; // The current module version (Date: YYYYMMDDXX).
$plugin->requires = 2022111800;
$plugin->maturity = MATURITY_STABLE;
-$plugin->component = 'mod_tab';
\ No newline at end of file
+$plugin->component = 'mod_tab';
diff --git a/view.php b/view.php
old mode 100755
new mode 100644
index 8bed37b..65e4698
--- a/view.php
+++ b/view.php
@@ -1,4 +1,18 @@
.
/**
* *************************************************************************
@@ -13,6 +27,10 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later **
* *************************************************************************
* ************************************************************************ */
+
+use mod_tab\event\course_module_viewed;
+use mod_tab\output\view;
+
require("../../config.php");
require_once("lib.php");
require_once("locallib.php");
@@ -20,19 +38,19 @@
require_once($CFG->dirroot . '/lib/completionlib.php');
require_once($CFG->dirroot . '/mod/tab/classes/event/course_module_viewed.php');
-$id = optional_param('id', 0, PARAM_INT); // Course Module ID, or
-$a = optional_param('a', 0, PARAM_INT); // tab ID
+$id = optional_param('id', 0, PARAM_INT); // Course Module ID, or.
+$a = optional_param('a', 0, PARAM_INT); // Tab ID.
if ($id) {
if (!$cm = get_coursemodule_from_id("tab", $id)) {
throw new moodle_exception("Course Module ID was incorrect");
}
- if (!$tab = $DB->get_record("tab", array("id" => $cm->instance))) {
+ if (!$tab = $DB->get_record("tab", ["id" => $cm->instance])) {
throw new moodle_exception("Course module is incorrect");
}
} else {
- if (!$tab = $DB->get_record("tab", array("id" => $a))) {
+ if (!$tab = $DB->get_record("tab", ["id" => $a])) {
throw new moodle_exception("Course module is incorrect");
}
@@ -41,7 +59,7 @@
}
}
-$course = $DB->get_record('course', array('id' => $cm->course), '*', MUST_EXIST);
+$course = $DB->get_record('course', ['id' => $cm->course], '*', MUST_EXIST);
require_course_login($course, true, $cm);
@@ -50,25 +68,25 @@
require_capability('mod/tab:view', $context);
-// Update 'viewed' state if required by completion system
+// Update 'viewed' state if required by completion system.
$completion = new completion_info($course);
$completion->set_module_viewed($cm);
-// Print the page header
+// Print the page header.
-$PAGE->set_url('/mod/tab/view.php', array('id' => $cm->id));
+$PAGE->set_url('/mod/tab/view.php', ['id' => $cm->id]);
$PAGE->set_title($tab->name);
$PAGE->set_heading(format_string($course->fullname));
$PAGE->set_activity_record($tab);
-//Gather css
+// Gather css.
$PAGE->requires->css('/mod/tab/styles.css');
-//log the view information
-$event = \mod_tab\event\course_module_viewed::create(array(
+// Log the view information.
+$event = course_module_viewed::create([
'objectid' => $PAGE->cm->instance,
'context' => $PAGE->context,
-));
+]);
$event->add_record_snapshot('course', $PAGE->course);
$event->add_record_snapshot($PAGE->cm->modname, $tab);
$event->trigger();
@@ -76,7 +94,7 @@
echo $OUTPUT->header();
$output = $PAGE->get_renderer('mod_tab');
-$view = new \mod_tab\output\view($tab, $course->id, $cm);
+$view = new view($tab, $course->id, $cm);
echo $output->render_view($view);
echo $OUTPUT->footer();