diff --git a/.travis.yml b/.travis.yml
new file mode 100644
index 0000000..f02e015
--- /dev/null
+++ b/.travis.yml
@@ -0,0 +1,40 @@
+language: php
+
+sudo: false
+
+cache:
+ directories:
+ - $HOME/.composer/cache
+
+php:
+ - 5.6
+ - 7.0
+
+env:
+ global:
+ - MOODLE_BRANCH=MOODLE_32_STABLE
+ matrix:
+ - DB=pgsql
+ - DB=mysqli
+
+before_install:
+ - phpenv config-rm xdebug.ini
+ - cd ../..
+ - composer selfupdate
+ - composer create-project -n --no-dev --prefer-dist moodlerooms/moodle-plugin-ci ci ^1
+ - export PATH="$(cd ci/bin; pwd):$(cd ci/vendor/bin; pwd):$PATH"
+
+install:
+ - moodle-plugin-ci install
+
+script:
+ - moodle-plugin-ci phplint
+ - moodle-plugin-ci phpcpd
+ - moodle-plugin-ci codechecker
+ - moodle-plugin-ci csslint
+ - moodle-plugin-ci shifter
+ - moodle-plugin-ci jshint
+ - moodle-plugin-ci validate
+ - moodle-plugin-ci phpunit
+ - moodle-plugin-ci behat
+
diff --git a/ajax.php b/ajax.php
index 9c9e620..4857859 100644
--- a/ajax.php
+++ b/ajax.php
@@ -22,12 +22,12 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+require_once(__DIR__ . '/../../config.php');
+
if (!defined('AJAX_SCRIPT')) {
define('AJAX_SCRIPT', true);
}
-require_once(__DIR__ . '/../../config.php');
-
$tid = required_param('tid', PARAM_INT);
$values = required_param('values', PARAM_RAW);
$values = json_decode($values);
diff --git a/amd/build/rearrange-area.min.js b/amd/build/rearrange-area.min.js
index 63e0592..3622b19 100644
--- a/amd/build/rearrange-area.min.js
+++ b/amd/build/rearrange-area.min.js
@@ -1 +1 @@
-define(["jquery","core/yui","core/fragment","mod_customcert/dialogue","core/notification","core/str","core/templates","core/ajax"],function(a,b,c,d,e,f,g,h){var i=function(b){this._node=a(b),this._setEvents()};return i.prototype.CUSTOMCERT_REF_POINT_TOPLEFT=0,i.prototype.CUSTOMCERT_REF_POINT_TOPCENTER=1,i.prototype.CUSTOMCERT_REF_POINT_TOPRIGHT=2,i.prototype.PIXELSINMM=3.779527559055,i.prototype._setEvents=function(){this._node.on("click",".element",this._editElement.bind(this))},i.prototype._editElement=function(a){var g=a.currentTarget.id.substr(8),h=this._node.attr("data-contextid"),i={elementid:g};c.loadFragment("mod_customcert","editelement",h,i).done(function(a,c){f.get_string("editelement","mod_customcert").done(function(e){b.use("moodle-core-formchangechecker",function(){new d(e,"
",this._editElementDialogueConfig.bind(this,g,a,c),(void 0),(!0))}.bind(this))}.bind(this))}.bind(this)).fail(e.exception)},i.prototype._editElementDialogueConfig=function(b,c,d,e){g.replaceNode("#elementcontent",c,d),this._setPositionInForm(b);var f=a(e.getContent());f.on("click","#id_submitbutton",function(c){M.core_formchangechecker.reset_form_dirty_state(),this._saveElement(b).then(function(){this._getElementHTML(b).done(function(c){var d=this._node.find("#element-"+b),f=parseInt(a("#id_refpoint").val()),g="";f==this.CUSTOMCERT_REF_POINT_TOPLEFT?g="refpoint-left":f==this.CUSTOMCERT_REF_POINT_TOPCENTER?g="refpoint-center":f==this.CUSTOMCERT_REF_POINT_TOPRIGHT&&(g="refpoint-right"),d.empty().append(c),d.removeClass(),d.addClass("element "+g),d.attr("data-refpoint",f);var h=a("#editelementform #id_posx").val(),i=a("#editelementform #id_posy").val();this._setPosition(b,f,h,i),e.close()}.bind(this))}.bind(this)),c.preventDefault()}.bind(this)),f.on("click","#id_cancel",function(a){e.close(),a.preventDefault()}.bind(this))},i.prototype._setPosition=function(a,c,d,e){var f=b.one("#element-"+a);d=b.one("#pdf").getX()+d*this.PIXELSINMM,e=b.one("#pdf").getY()+e*this.PIXELSINMM;var g=parseFloat(f.getComputedStyle("width")),h=f.width*this.PIXELSINMM;switch(h&&g>h&&(g=h),c){case this.CUSTOMCERT_REF_POINT_TOPCENTER:d-=g/2;break;case this.CUSTOMCERT_REF_POINT_TOPRIGHT:d=d-g+2}f.setX(d),f.setY(e)},i.prototype._setPositionInForm=function(c){var d=a("#editelementform #id_posx"),e=a("#editelementform #id_posy");if(d.length&&e.length){var f=b.one("#element-"+c),g=f.getX()-b.one("#pdf").getX(),h=f.getY()-b.one("#pdf").getY(),i=parseInt(f.getData("refpoint")),j=parseFloat(f.getComputedStyle("width"));switch(i){case this.CUSTOMCERT_REF_POINT_TOPCENTER:g+=j/2;break;case this.CUSTOMCERT_REF_POINT_TOPRIGHT:g+=j}g=Math.round(parseFloat(g/this.PIXELSINMM)),h=Math.round(parseFloat(h/this.PIXELSINMM)),d.val(g),e.val(h)}},i.prototype._getElementHTML=function(a){var b=this._node.attr("data-templateid"),c=h.call([{methodname:"mod_customcert_get_element_html",args:{templateid:b,elementid:a}}]);return c[0]},i.prototype._saveElement=function(b){var c=this._node.attr("data-templateid"),d=a("#editelementform").serializeArray(),e=h.call([{methodname:"mod_customcert_save_element",args:{templateid:c,elementid:b,values:d}}]);return e[0]},{init:function(a){new i(a)}}});
\ No newline at end of file
+define(["jquery","core/yui","core/fragment","mod_customcert/dialogue","core/notification","core/str","core/templates","core/ajax"],function(a,b,c,d,e,f,g,h){var i=function(b){this._node=a(b),this._setEvents()};return i.prototype.CUSTOMCERT_REF_POINT_TOPLEFT=0,i.prototype.CUSTOMCERT_REF_POINT_TOPCENTER=1,i.prototype.CUSTOMCERT_REF_POINT_TOPRIGHT=2,i.prototype.PIXELSINMM=3.779527559055,i.prototype._setEvents=function(){this._node.on("click",".element",this._editElement.bind(this))},i.prototype._editElement=function(a){var g=a.currentTarget.id.substr(8),h=this._node.attr("data-contextid"),i={elementid:g};c.loadFragment("mod_customcert","editelement",h,i).done(function(a,c){f.get_string("editelement","mod_customcert").done(function(e){b.use("moodle-core-formchangechecker",function(){new d(e,"",this._editElementDialogueConfig.bind(this,g,a,c),(void 0),(!0))}.bind(this))}.bind(this))}.bind(this)).fail(e.exception)},i.prototype._editElementDialogueConfig=function(b,c,d,e){g.replaceNode("#elementcontent",c,d),this._setPositionInForm(b);var f=a(e.getContent());f.on("click","#id_submitbutton",function(c){M.core_formchangechecker.reset_form_dirty_state(),this._saveElement(b).then(function(){this._getElementHTML(b).done(function(c){var d=this._node.find("#element-"+b),f=parseInt(a("#id_refpoint").val()),g="";f==this.CUSTOMCERT_REF_POINT_TOPLEFT?g="refpoint-left":f==this.CUSTOMCERT_REF_POINT_TOPCENTER?g="refpoint-center":f==this.CUSTOMCERT_REF_POINT_TOPRIGHT&&(g="refpoint-right"),d.empty().append(c),d.removeClass(),d.addClass("element "+g),d.attr("data-refpoint",f);var h=a("#editelementform #id_posx").val(),i=a("#editelementform #id_posy").val();this._setPosition(b,f,h,i),e.close()}.bind(this))}.bind(this)),c.preventDefault()}.bind(this)),f.on("click","#id_cancel",function(a){e.close(),a.preventDefault()})},i.prototype._setPosition=function(a,c,d,e){var f=b.one("#element-"+a);d=b.one("#pdf").getX()+d*this.PIXELSINMM,e=b.one("#pdf").getY()+e*this.PIXELSINMM;var g=parseFloat(f.getComputedStyle("width")),h=f.width*this.PIXELSINMM;switch(h&&g>h&&(g=h),c){case this.CUSTOMCERT_REF_POINT_TOPCENTER:d-=g/2;break;case this.CUSTOMCERT_REF_POINT_TOPRIGHT:d=d-g+2}f.setX(d),f.setY(e)},i.prototype._setPositionInForm=function(c){var d=a("#editelementform #id_posx"),e=a("#editelementform #id_posy");if(d.length&&e.length){var f=b.one("#element-"+c),g=f.getX()-b.one("#pdf").getX(),h=f.getY()-b.one("#pdf").getY(),i=parseInt(f.getData("refpoint")),j=parseFloat(f.getComputedStyle("width"));switch(i){case this.CUSTOMCERT_REF_POINT_TOPCENTER:g+=j/2;break;case this.CUSTOMCERT_REF_POINT_TOPRIGHT:g+=j}g=Math.round(parseFloat(g/this.PIXELSINMM)),h=Math.round(parseFloat(h/this.PIXELSINMM)),d.val(g),e.val(h)}},i.prototype._getElementHTML=function(a){var b=this._node.attr("data-templateid"),c=h.call([{methodname:"mod_customcert_get_element_html",args:{templateid:b,elementid:a}}]);return c[0]},i.prototype._saveElement=function(b){var c=this._node.attr("data-templateid"),d=a("#editelementform").serializeArray(),e=h.call([{methodname:"mod_customcert_save_element",args:{templateid:c,elementid:b,values:d}}]);return e[0]},{init:function(a){new i(a)}}});
\ No newline at end of file
diff --git a/amd/src/dialogue.js b/amd/src/dialogue.js
index 88da5ac..d27a064 100644
--- a/amd/src/dialogue.js
+++ b/amd/src/dialogue.js
@@ -42,7 +42,7 @@ define(['core/yui'], function(Y) {
wide = false;
}
- Y.use('moodle-core-notification', 'timers', function () {
+ Y.use('moodle-core-notification', 'timers', function() {
var width = '480px';
if (wide) {
width = '800px';
@@ -91,10 +91,12 @@ define(['core/yui'], function(Y) {
/**
* Get content.
+ *
+ * @returns {HTMLElement}
*/
dialogue.prototype.getContent = function() {
return this.yuiDialogue.bodyNode.getDOMNode();
};
- return /** @alias module:mod_customcert/dialogue */ dialogue;
+ return dialogue;
});
diff --git a/amd/src/rearrange-area.js b/amd/src/rearrange-area.js
index a33007a..7e42270 100644
--- a/amd/src/rearrange-area.js
+++ b/amd/src/rearrange-area.js
@@ -23,190 +23,191 @@
*/
define(['jquery', 'core/yui', 'core/fragment', 'mod_customcert/dialogue', 'core/notification',
'core/str', 'core/templates', 'core/ajax'],
- function($, Y, fragment, Dialogue, notification, str, template, ajax) {
+ function($, Y, fragment, Dialogue, notification, str, template, ajax) {
- /**
- * RearrangeArea class.
- *
- * @param {String} selector The rearrange PDF selector
- */
- var RearrangeArea = function(selector) {
- this._node = $(selector);
- this._setEvents();
- };
+ /**
+ * RearrangeArea class.
+ *
+ * @param {String} selector The rearrange PDF selector
+ */
+ var RearrangeArea = function(selector) {
+ this._node = $(selector);
+ this._setEvents();
+ };
- RearrangeArea.prototype.CUSTOMCERT_REF_POINT_TOPLEFT = 0;
- RearrangeArea.prototype.CUSTOMCERT_REF_POINT_TOPCENTER = 1;
- RearrangeArea.prototype.CUSTOMCERT_REF_POINT_TOPRIGHT = 2;
- RearrangeArea.prototype.PIXELSINMM = 3.779527559055;
+ RearrangeArea.prototype.CUSTOMCERT_REF_POINT_TOPLEFT = 0;
+ RearrangeArea.prototype.CUSTOMCERT_REF_POINT_TOPCENTER = 1;
+ RearrangeArea.prototype.CUSTOMCERT_REF_POINT_TOPRIGHT = 2;
+ RearrangeArea.prototype.PIXELSINMM = 3.779527559055;
- RearrangeArea.prototype._setEvents = function() {
- this._node.on('click', '.element', this._editElement.bind(this));
- };
+ RearrangeArea.prototype._setEvents = function() {
+ this._node.on('click', '.element', this._editElement.bind(this));
+ };
- RearrangeArea.prototype._editElement = function(event) {
- var elementid = event.currentTarget.id.substr(8);
- var contextid = this._node.attr('data-contextid');
- var params = {
- 'elementid' : elementid
- };
+ RearrangeArea.prototype._editElement = function(event) {
+ var elementid = event.currentTarget.id.substr(8);
+ var contextid = this._node.attr('data-contextid');
+ var params = {
+ 'elementid': elementid
+ };
- fragment.loadFragment('mod_customcert', 'editelement', contextid, params).done(function(html, js) {
- str.get_string('editelement', 'mod_customcert').done(function(title) {
- Y.use('moodle-core-formchangechecker', function () {
- new Dialogue(
- title,
- '',
- this._editElementDialogueConfig.bind(this, elementid, html, js),
- undefined,
- true
- );
+ fragment.loadFragment('mod_customcert', 'editelement', contextid, params).done(function(html, js) {
+ str.get_string('editelement', 'mod_customcert').done(function(title) {
+ Y.use('moodle-core-formchangechecker', function() {
+ new Dialogue(
+ title,
+ '',
+ this._editElementDialogueConfig.bind(this, elementid, html, js),
+ undefined,
+ true
+ );
+ }.bind(this));
+ }.bind(this));
+ }.bind(this)).fail(notification.exception);
+ };
+
+ RearrangeArea.prototype._editElementDialogueConfig = function(elementid, html, js, popup) {
+ // Place the content in the dialogue.
+ template.replaceNode('#elementcontent', html, js);
+
+ // We may have dragged the element changing it's position.
+ // Ensure the form has the current up-to-date location.
+ this._setPositionInForm(elementid);
+
+ // Add events for when we save, close and cancel the page.
+ var body = $(popup.getContent());
+ body.on('click', '#id_submitbutton', function(e) {
+ // Do not want to ask the user if they wish to stay on page after saving.
+ M.core_formchangechecker.reset_form_dirty_state();
+ // Save the data.
+ this._saveElement(elementid).then(function() {
+ // Update the DOM to reflect the adjusted value.
+ this._getElementHTML(elementid).done(function(html) {
+ var elementNode = this._node.find('#element-' + elementid);
+ var refpoint = parseInt($('#id_refpoint').val());
+ var refpointClass = '';
+ if (refpoint == this.CUSTOMCERT_REF_POINT_TOPLEFT) {
+ refpointClass = 'refpoint-left';
+ } else if (refpoint == this.CUSTOMCERT_REF_POINT_TOPCENTER) {
+ refpointClass = 'refpoint-center';
+ } else if (refpoint == this.CUSTOMCERT_REF_POINT_TOPRIGHT) {
+ refpointClass = 'refpoint-right';
+ }
+ elementNode.empty().append(html);
+ // Update the ref point.
+ elementNode.removeClass();
+ elementNode.addClass('element ' + refpointClass);
+ elementNode.attr('data-refpoint', refpoint);
+ // Move the element.
+ var posx = $('#editelementform #id_posx').val();
+ var posy = $('#editelementform #id_posy').val();
+ this._setPosition(elementid, refpoint, posx, posy);
+ // All done.
+ popup.close();
+ }.bind(this));
+ }.bind(this));
+ e.preventDefault();
}.bind(this));
- }.bind(this));
- }.bind(this)).fail(notification.exception);
- };
- RearrangeArea.prototype._editElementDialogueConfig = function(elementid, html, js, popup) {
- // Place the content in the dialogue.
- template.replaceNode('#elementcontent', html, js);
-
- // We may have dragged the element changing it's position.
- // Ensure the form has the current up-to-date location.
- this._setPositionInForm(elementid);
-
- // Add events for when we save, close and cancel the page.
- var body = $(popup.getContent());
- body.on('click', '#id_submitbutton', function(e) {
- // Do not want to ask the user if they wish to stay on page after saving.
- M.core_formchangechecker.reset_form_dirty_state();
- // Save the data.
- this._saveElement(elementid).then(function() {
- // Update the DOM to reflect the adjusted value.
- this._getElementHTML(elementid).done(function(html) {
- var elementNode = this._node.find('#element-' + elementid);
- var refpoint = parseInt($('#id_refpoint').val());
- var refpointClass = '';
- if (refpoint == this.CUSTOMCERT_REF_POINT_TOPLEFT) {
- refpointClass = 'refpoint-left';
- } else if (refpoint == this.CUSTOMCERT_REF_POINT_TOPCENTER) {
- refpointClass = 'refpoint-center';
- } else if (refpoint == this.CUSTOMCERT_REF_POINT_TOPRIGHT) {
- refpointClass = 'refpoint-right';
- }
- elementNode.empty().append(html);
- // Update the ref point.
- elementNode.removeClass();
- elementNode.addClass('element ' + refpointClass);
- elementNode.attr('data-refpoint', refpoint);
- // Move the element.
- var posx = $('#editelementform #id_posx').val();
- var posy = $('#editelementform #id_posy').val();
- this._setPosition(elementid, refpoint, posx, posy);
- // All done.
+ body.on('click', '#id_cancel', function(e) {
popup.close();
- }.bind(this));
- }.bind(this));
- e.preventDefault();
- }.bind(this));
+ e.preventDefault();
+ });
+ };
- body.on('click', '#id_cancel', function(e) {
- popup.close();
- e.preventDefault();
- }.bind(this));
- };
+ RearrangeArea.prototype._setPosition = function(elementid, refpoint, posx, posy) {
+ var element = Y.one('#element-' + elementid);
- RearrangeArea.prototype._setPosition = function(elementid, refpoint, posx, posy) {
- var element = Y.one('#element-' + elementid);
+ posx = Y.one('#pdf').getX() + posx * this.PIXELSINMM;
+ posy = Y.one('#pdf').getY() + posy * this.PIXELSINMM;
+ var nodewidth = parseFloat(element.getComputedStyle('width'));
+ var maxwidth = element.width * this.PIXELSINMM;
- posx = Y.one('#pdf').getX() + posx * this.PIXELSINMM;
- posy = Y.one('#pdf').getY() + posy * this.PIXELSINMM;
- var nodewidth = parseFloat(element.getComputedStyle('width'));
- var maxwidth = element.width * this.PIXELSINMM;
+ if (maxwidth && (nodewidth > maxwidth)) {
+ nodewidth = maxwidth;
+ }
- if (maxwidth && (nodewidth > maxwidth)) {
- nodewidth = maxwidth;
+ switch (refpoint) {
+ case this.CUSTOMCERT_REF_POINT_TOPCENTER:
+ posx -= nodewidth / 2;
+ break;
+ case this.CUSTOMCERT_REF_POINT_TOPRIGHT:
+ posx = posx - nodewidth + 2;
+ break;
+ }
+
+ element.setX(posx);
+ element.setY(posy);
+ };
+
+ RearrangeArea.prototype._setPositionInForm = function(elementid) {
+ var posxelement = $('#editelementform #id_posx');
+ var posyelement = $('#editelementform #id_posy');
+
+ if (posxelement.length && posyelement.length) {
+ var element = Y.one('#element-' + elementid);
+ var posx = element.getX() - Y.one('#pdf').getX();
+ var posy = element.getY() - Y.one('#pdf').getY();
+ var refpoint = parseInt(element.getData('refpoint'));
+ var nodewidth = parseFloat(element.getComputedStyle('width'));
+
+ switch (refpoint) {
+ case this.CUSTOMCERT_REF_POINT_TOPCENTER:
+ posx += nodewidth / 2;
+ break;
+ case this.CUSTOMCERT_REF_POINT_TOPRIGHT:
+ posx += nodewidth;
+ break;
+ }
+
+ posx = Math.round(parseFloat(posx / this.PIXELSINMM));
+ posy = Math.round(parseFloat(posy / this.PIXELSINMM));
+
+ posxelement.val(posx);
+ posyelement.val(posy);
+ }
+ };
+
+ RearrangeArea.prototype._getElementHTML = function(elementid) {
+ // Get the variables we need.
+ var templateid = this._node.attr('data-templateid');
+
+ // Call the web service to get the updated element.
+ var promises = ajax.call([{
+ methodname: 'mod_customcert_get_element_html',
+ args: {
+ templateid: templateid,
+ elementid: elementid
+ }
+ }]);
+
+ // Return the promise.
+ return promises[0];
+ };
+
+ RearrangeArea.prototype._saveElement = function(elementid) {
+ // Get the variables we need.
+ var templateid = this._node.attr('data-templateid');
+ var inputs = $('#editelementform').serializeArray();
+
+ // Call the web service to save the element.
+ var promises = ajax.call([{
+ methodname: 'mod_customcert_save_element',
+ args: {
+ templateid: templateid,
+ elementid: elementid,
+ values: inputs
+ }
+ }]);
+
+ // Return the promise.
+ return promises[0];
+ };
+
+ return {
+ init: function(selector) {
+ new RearrangeArea(selector);
+ }
+ };
}
-
- switch (refpoint) {
- case this.CUSTOMCERT_REF_POINT_TOPCENTER:
- posx -= nodewidth / 2;
- break;
- case this.CUSTOMCERT_REF_POINT_TOPRIGHT:
- posx = posx - nodewidth + 2;
- break;
- }
-
- element.setX(posx);
- element.setY(posy);
- };
-
- RearrangeArea.prototype._setPositionInForm = function(elementid) {
- var posxelement = $('#editelementform #id_posx');
- var posyelement = $('#editelementform #id_posy');
-
- if (posxelement.length && posyelement.length) {
- var element = Y.one('#element-' + elementid);
- var posx = element.getX() - Y.one('#pdf').getX();
- var posy = element.getY() - Y.one('#pdf').getY();
- var refpoint = parseInt(element.getData('refpoint'));
- var nodewidth = parseFloat(element.getComputedStyle('width'));
-
- switch (refpoint) {
- case this.CUSTOMCERT_REF_POINT_TOPCENTER:
- posx += nodewidth / 2;
- break;
- case this.CUSTOMCERT_REF_POINT_TOPRIGHT:
- posx += nodewidth;
- break;
- }
-
- posx = Math.round(parseFloat(posx / this.PIXELSINMM));
- posy = Math.round(parseFloat(posy / this.PIXELSINMM));
-
- posxelement.val(posx);
- posyelement.val(posy);
- }
- };
-
- RearrangeArea.prototype._getElementHTML = function(elementid) {
- // Get the variables we need.
- var templateid = this._node.attr('data-templateid');
-
- // Call the web service to get the updated element.
- var promises = ajax.call([{
- methodname: 'mod_customcert_get_element_html',
- args: {
- templateid : templateid,
- elementid : elementid
- }
- }]);
-
- // Return the promise.
- return promises[0];
- };
-
- RearrangeArea.prototype._saveElement = function(elementid) {
- // Get the variables we need.
- var templateid = this._node.attr('data-templateid');
- var inputs = $('#editelementform').serializeArray();
-
- // Call the web service to save the element.
- var promises = ajax.call([{
- methodname: 'mod_customcert_save_element',
- args: {
- templateid : templateid,
- elementid : elementid,
- values : inputs
- }
- }]);
-
- // Return the promise.
- return promises[0];
- };
-
- return {
- init : function(selector) {
- new RearrangeArea(selector);
- }
- };
-});
+ );
diff --git a/backup/moodle2/backup_customcert_activity_task.class.php b/backup/moodle2/backup_customcert_activity_task.class.php
index 68d4dd3..321e242 100644
--- a/backup/moodle2/backup_customcert_activity_task.class.php
+++ b/backup/moodle2/backup_customcert_activity_task.class.php
@@ -15,8 +15,7 @@
// along with Moodle. If not, see .
/**
- * This file contains the backup tasks that provides all the settings and steps to perform
- * one complete backup of the activity.
+ * This file contains the backup tasks that provides all the settings and steps to perform a backup of the activity.
*
* @package mod_customcert
* @copyright 2013 Mark Nelson
@@ -29,6 +28,10 @@ require_once($CFG->dirroot . '/mod/customcert/backup/moodle2/backup_customcert_s
/**
* Handles creating tasks to peform in order to create the backup.
+ *
+ * @package mod_customcert
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class backup_customcert_activity_task extends backup_activity_task {
@@ -49,6 +52,9 @@ class backup_customcert_activity_task extends backup_activity_task {
/**
* Code the transformations to perform in the activity in order to get transportable (encoded) links.
+ *
+ * @param string $content
+ * @return mixed|string
*/
static public function encode_content_links($content) {
global $CFG;
@@ -56,11 +62,11 @@ class backup_customcert_activity_task extends backup_activity_task {
$base = preg_quote($CFG->wwwroot, "/");
// Link to the list of customcerts.
- $search ="/(".$base."\/mod\/customcert\/index.php\?id\=)([0-9]+)/";
+ $search = "/(".$base."\/mod\/customcert\/index.php\?id\=)([0-9]+)/";
$content = preg_replace($search, '$@customcertINDEX*$2@$', $content);
// Link to customcert view by moduleid.
- $search ="/(".$base."\/mod\/customcert\/view.php\?id\=)([0-9]+)/";
+ $search = "/(".$base."\/mod\/customcert\/view.php\?id\=)([0-9]+)/";
$content = preg_replace($search, '$@customcertVIEWBYID*$2@$', $content);
return $content;
diff --git a/backup/moodle2/backup_customcert_stepslib.php b/backup/moodle2/backup_customcert_stepslib.php
index b9db5f5..ac33bba 100644
--- a/backup/moodle2/backup_customcert_stepslib.php
+++ b/backup/moodle2/backup_customcert_stepslib.php
@@ -26,6 +26,10 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
/**
* Define the complete customcert structure for backup, with file and id annotations.
+ *
+ * @package mod_customcert
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class backup_customcert_activity_structure_step extends backup_activity_structure_step {
diff --git a/backup/moodle2/restore_customcert_activity_task.class.php b/backup/moodle2/restore_customcert_activity_task.class.php
index 963ddb1..934e6de 100644
--- a/backup/moodle2/restore_customcert_activity_task.class.php
+++ b/backup/moodle2/restore_customcert_activity_task.class.php
@@ -27,8 +27,11 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once($CFG->dirroot . '/mod/customcert/backup/moodle2/restore_customcert_stepslib.php');
/**
- * The class definition for assigning restore tasks that provides all the settings and steps
- * to perform one complete restore of the activity.
+ * The class definition for assigning tasks that provide the settings and steps to perform a restore of the activity.
+ *
+ * @package mod_customcert
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class restore_customcert_activity_task extends restore_activity_task {
diff --git a/backup/moodle2/restore_customcert_stepslib.php b/backup/moodle2/restore_customcert_stepslib.php
index 908a799..4b3a596 100644
--- a/backup/moodle2/restore_customcert_stepslib.php
+++ b/backup/moodle2/restore_customcert_stepslib.php
@@ -26,6 +26,10 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
/**
* Define the complete customcert structure for restore, with file and id annotations.
+ *
+ * @package mod_customcert
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class restore_customcert_activity_structure_step extends restore_activity_structure_step {
diff --git a/classes/admin_setting_link.php b/classes/admin_setting_link.php
index e12563f..19de718 100644
--- a/classes/admin_setting_link.php
+++ b/classes/admin_setting_link.php
@@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
-namespace mod_customcert;
-
/**
* Creates an upload form on the settings page.
*
@@ -23,10 +21,19 @@ namespace mod_customcert;
* @copyright 2013 Mark Nelson
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+
+namespace mod_customcert;
+
+defined('MOODLE_INTERNAL') || die();
+
require_once($CFG->libdir.'/adminlib.php');
/**
* Class extends admin setting class to allow/process an uploaded file
+ *
+ * @package mod_customcert
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class admin_setting_link extends \admin_setting_configtext {
@@ -40,6 +47,18 @@ class admin_setting_link extends \admin_setting_configtext {
*/
protected $linkname;
+ /**
+ * The admin_setting_link constructor.
+ *
+ * @param string $name
+ * @param string $visiblename
+ * @param string $description
+ * @param string $linkname
+ * @param mixed|string $link
+ * @param int|null $defaultsetting
+ * @param string $paramtype
+ * @param null $size
+ */
public function __construct($name, $visiblename, $description, $linkname, $link, $defaultsetting,
$paramtype = PARAM_RAW, $size=null) {
$this->link = $link;
diff --git a/classes/certificate.php b/classes/certificate.php
index a54534e..c0a48d4 100644
--- a/classes/certificate.php
+++ b/classes/certificate.php
@@ -30,6 +30,10 @@ defined('MOODLE_INTERNAL') || die();
* Class certificate.
*
* Helper functionality for certificates.
+ *
+ * @package mod_customcert
+ * @copyright 2016 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class certificate {
@@ -202,7 +206,7 @@ class certificate {
if ($logs = $DB->get_recordset_sql($sql, $params)) {
foreach ($logs as $log) {
if (!isset($login)) {
- // For the first time $login is not set so the first log is also the first login
+ // For the first time $login is not set so the first log is also the first login.
$login = $log->$timefield;
$lasthit = $log->$timefield;
$totaltime = 0;
@@ -215,7 +219,7 @@ class certificate {
} else {
$totaltime += $delay;
}
- // Now the actual log became the previous log for the next cycle
+ // Now the actual log became the previous log for the next cycle.
$lasthit = $log->$timefield;
}
diff --git a/classes/edit_element_form.php b/classes/edit_element_form.php
index 34088ac..e357530 100644
--- a/classes/edit_element_form.php
+++ b/classes/edit_element_form.php
@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This file contains the form for handling editing a customcert element.
+ *
+ * @package mod_customcert
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
namespace mod_customcert;
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
diff --git a/classes/edit_form.php b/classes/edit_form.php
index 0b7bc99..ad56ddc 100644
--- a/classes/edit_form.php
+++ b/classes/edit_form.php
@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This file contains the form for handling the layout of the customcert instance.
+ *
+ * @package mod_customcert
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
namespace mod_customcert;
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
@@ -34,12 +42,12 @@ require_once($CFG->dirroot . '/mod/customcert/includes/colourpicker.php');
class edit_form extends \moodleform {
/**
- * The id of the template being used.
+ * @var int The id of the template being used.
*/
protected $tid = null;
/**
- * The total number of pages for this cert.
+ * @var int The total number of pages for this cert.
*/
protected $numpages = 1;
@@ -123,8 +131,8 @@ class edit_form extends \moodleform {
/**
* Some basic validation.
*
- * @param $data
- * @param $files
+ * @param array $data
+ * @param array $files
* @return array the errors that were found
*/
public function validation($data, $files) {
@@ -285,7 +293,8 @@ class edit_form extends \moodleform {
if ($this->numpages > 1) {
// Link to delete the element.
$deletelink = new \moodle_url($editlink, $editlinkparams + array('action' => 'deletepage', 'aid' => $page->id));
- $deletelink = \html_writer::tag('a', get_string('deletecertpage', 'customcert'), array('href' => $deletelink->out(false), 'class' => 'deletebutton'));
+ $deletelink = \html_writer::tag('a', get_string('deletecertpage', 'customcert'),
+ array('href' => $deletelink->out(false), 'class' => 'deletebutton'));
$mform->addElement('html', \html_writer::tag('div', $deletelink, array('class' => 'deletebutton')));
}
}
diff --git a/classes/element.php b/classes/element.php
index 5faeef6..9c55060 100644
--- a/classes/element.php
+++ b/classes/element.php
@@ -30,6 +30,10 @@ defined('MOODLE_INTERNAL') || die();
* Class element
*
* All customercert element plugins are based on this class.
+ *
+ * @package mod_customcert
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
abstract class element {
@@ -216,7 +220,9 @@ abstract class element {
*
* @param \restore_customcert_activity_task $restore
*/
- public function after_restore($restore) { }
+ public function after_restore($restore) {
+
+ }
/**
* Magic getter for read only access.
diff --git a/classes/element_helper.php b/classes/element_helper.php
index 00fbc71..805b508 100644
--- a/classes/element_helper.php
+++ b/classes/element_helper.php
@@ -15,12 +15,12 @@
// along with Moodle. If not, see .
/**
-* Provides useful functions related to elements.
-*
-* @package mod_customcert
-* @copyright 2016 Mark Nelson
-* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-*/
+ * Provides useful functions related to elements.
+ *
+ * @package mod_customcert
+ * @copyright 2016 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
namespace mod_customcert;
@@ -30,6 +30,10 @@ defined('MOODLE_INTERNAL') || die();
* Class helper.
*
* Provides useful functions related to elements.
+ *
+ * @package mod_customcert
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class element_helper {
@@ -56,7 +60,7 @@ class element_helper {
* @param string $content the content to render
*/
public static function render_content($pdf, $element, $content) {
- list($font, $attr) = \mod_customcert\element_helper::get_font($element);
+ list($font, $attr) = self::get_font($element);
$pdf->setFont($font, $attr, $element->size);
$fontcolour = \TCPDF_COLORS::convertHTMLColorToDec($element->colour, $fontcolour);
$pdf->SetTextColor($fontcolour['R'], $fontcolour['G'], $fontcolour['B']);
@@ -107,7 +111,7 @@ class element_helper {
* @return string the html
*/
public static function render_html_content($element, $content) {
- list($font, $attr) = \mod_customcert\element_helper::get_font($element);
+ list($font, $attr) = self::get_font($element);
$fontstyle = 'font-family: ' . $font;
if (strpos($attr, 'B') !== false) {
$fontstyle .= ': font-weight: bold';
@@ -196,7 +200,7 @@ class element_helper {
public static function validate_form_element_colour($data) {
$errors = array();
// Validate the colour.
- if (!\mod_customcert\element_helper::validate_colour($data['colour'])) {
+ if (!self::validate_colour($data['colour'])) {
$errors['colour'] = get_string('invalidcolour', 'customcert');
}
return $errors;
diff --git a/classes/event/course_module_viewed.php b/classes/event/course_module_viewed.php
index 509d28f..de9bdca 100644
--- a/classes/event/course_module_viewed.php
+++ b/classes/event/course_module_viewed.php
@@ -34,6 +34,10 @@ defined('MOODLE_INTERNAL') || die();
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class course_module_viewed extends \core\event\course_module_viewed {
+
+ /**
+ * Initialises the event.
+ */
protected function init() {
$this->data['objecttable'] = 'customcert';
parent::init();
diff --git a/classes/external.php b/classes/external.php
index cdb4984..f74bf47 100644
--- a/classes/external.php
+++ b/classes/external.php
@@ -27,11 +27,11 @@ defined('MOODLE_INTERNAL') || die();
require_once("$CFG->libdir/externallib.php");
/**
-* This is the external API for this tool.
-*
-* @copyright 2016 Mark Nelson
-* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
-*/
+ * This is the external API for this tool.
+ *
+ * @copyright 2016 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class external extends \external_api {
/**
diff --git a/classes/load_template_form.php b/classes/load_template_form.php
index 7bad0aa..48a3390 100644
--- a/classes/load_template_form.php
+++ b/classes/load_template_form.php
@@ -14,13 +14,20 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This file contains the form for loading customcert templates.
+ *
+ * @package mod_customcert
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
namespace mod_customcert;
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once($CFG->libdir . '/formslib.php');
-
/**
* The form for loading customcert templates.
*
diff --git a/classes/output/verify_certificate_result.php b/classes/output/verify_certificate_result.php
index 01233a1..e6b698c 100644
--- a/classes/output/verify_certificate_result.php
+++ b/classes/output/verify_certificate_result.php
@@ -77,6 +77,12 @@ class verify_certificate_result implements templatable, renderable {
$this->certificatename = $result->certificatename;
}
+ /**
+ * Function to export the renderer data in a format that is suitable for a mustache template.
+ *
+ * @param \renderer_base $output Used to do a final render of any components that need to be rendered for export.
+ * @return \stdClass|array
+ */
public function export_for_template(\renderer_base $output) {
$result = new \stdClass();
$result->userprofileurl = $this->userprofileurl;
diff --git a/classes/output/verify_certificate_results.php b/classes/output/verify_certificate_results.php
index c08b6ed..d77fe04 100644
--- a/classes/output/verify_certificate_results.php
+++ b/classes/output/verify_certificate_results.php
@@ -68,6 +68,12 @@ class verify_certificate_results implements templatable, renderable {
$this->issues = $result->issues;
}
+ /**
+ * Function to export the renderer data in a format that is suitable for a mustache template.
+ *
+ * @param \renderer_base $output Used to do a final render of any components that need to be rendered for export.
+ * @return \stdClass|array
+ */
public function export_for_template(\renderer_base $output) {
$result = new \stdClass();
$result->success = $this->success;
diff --git a/classes/page_helper.php b/classes/page_helper.php
index 4490194..fd21757 100644
--- a/classes/page_helper.php
+++ b/classes/page_helper.php
@@ -30,6 +30,10 @@ defined('MOODLE_INTERNAL') || die();
* Class helper.
*
* Provides useful functions.
+ *
+ * @package mod_customcert
+ * @copyright 2016 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class page_helper {
diff --git a/classes/plugininfo/customcertelement.php b/classes/plugininfo/customcertelement.php
index 6e386d5..5cd107b 100644
--- a/classes/plugininfo/customcertelement.php
+++ b/classes/plugininfo/customcertelement.php
@@ -27,6 +27,13 @@ use core\plugininfo\base;
defined('MOODLE_INTERNAL') || die();
+/**
+ * Subplugin info class.
+ *
+ * @package mod_customcert
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
class customcertelement extends base {
/**
diff --git a/classes/template.php b/classes/template.php
index 442bf21..710ba0e 100644
--- a/classes/template.php
+++ b/classes/template.php
@@ -17,6 +17,7 @@
/**
* Class represents a customcert template.
*
+ * @package mod_customcert
* @copyright 2015 Mark Nelson
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -28,6 +29,7 @@ defined('MOODLE_INTERNAL') || die();
/**
* Class represents a customcert template.
*
+ * @package mod_customcert
* @copyright 2016 Mark Nelson
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
@@ -70,7 +72,7 @@ class template {
$savedata = new \stdClass();
$savedata->id = $this->id;
$savedata->name = $data->name;
- $savedata->timemodified= time();
+ $savedata->timemodified = time();
$DB->update_record('customcert_templates', $savedata);
}
diff --git a/classes/upload_image_form.php b/classes/upload_image_form.php
index 7caee4e..4422897 100644
--- a/classes/upload_image_form.php
+++ b/classes/upload_image_form.php
@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This file contains the class that handles uploading files.
+ *
+ * @package mod_customcert
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
namespace mod_customcert;
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
@@ -21,7 +29,7 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once($CFG->libdir.'/formslib.php');
/**
- * Handles uploading files
+ * Handles uploading files.
*
* @package mod_customcert
* @copyright 2013 Mark Nelson
@@ -43,7 +51,8 @@ class upload_image_form extends \moodleform {
'maxbytes' => $CFG->maxbytes,
'subdirs' => 1,
'accepted_types' => 'image');
- $mform->addElement('filemanager', 'customcertimage', get_string('uploadimage', 'customcert'), '', $this->filemanageroptions);
+ $mform->addElement('filemanager', 'customcertimage', get_string('uploadimage', 'customcert'), '',
+ $this->filemanageroptions);
$this->add_action_buttons();
}
@@ -56,7 +65,8 @@ class upload_image_form extends \moodleform {
// Editing existing instance - copy existing files into draft area.
$draftitemid = file_get_submitted_draft_itemid('customcertimage');
- file_prepare_draft_area($draftitemid, \context_system::instance()->id, 'mod_customcert', 'image', 0, $this->filemanageroptions);
+ file_prepare_draft_area($draftitemid, \context_system::instance()->id, 'mod_customcert', 'image', 0,
+ $this->filemanageroptions);
$element = $mform->getElement('customcertimage');
$element->setValue($draftitemid);
}
diff --git a/classes/verify_certificate_form.php b/classes/verify_certificate_form.php
index 97020b3..15ce6b8 100644
--- a/classes/verify_certificate_form.php
+++ b/classes/verify_certificate_form.php
@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This files contains the form for verifying a certificate.
+ *
+ * @package mod_customcert
+ * @copyright 2017 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
namespace mod_customcert;
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
@@ -21,7 +29,7 @@ defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once($CFG->libdir . '/formslib.php');
/**
- * The form for verifying a certificate
+ * The form for verifying a certificate.
*
* @package mod_customcert
* @copyright 2017 Mark Nelson
diff --git a/db/services.php b/db/services.php
index 1a74560..b0b6343 100644
--- a/db/services.php
+++ b/db/services.php
@@ -22,6 +22,8 @@
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
+defined('MOODLE_INTERNAL') || die();
+
$functions = array(
'mod_customcert_save_element' => array(
'classname' => 'mod_customcert\external',
diff --git a/element/bgimage/classes/element.php b/element/bgimage/classes/element.php
index c0ba259..f4d6620 100644
--- a/element/bgimage/classes/element.php
+++ b/element/bgimage/classes/element.php
@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This file contains the customcert element background image's core interaction API.
+ *
+ * @package customcertelement_bgimage
+ * @copyright 2016 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
namespace customcertelement_bgimage;
defined('MOODLE_INTERNAL') || die();
@@ -34,7 +42,8 @@ class element extends \customcertelement_image\element {
*/
public function render_form_elements($mform) {
$mform->addElement('select', 'image', get_string('image', 'customcertelement_image'), self::get_images());
- $mform->addElement('filemanager', 'customcertimage', get_string('uploadimage', 'customcert'), '', $this->filemanageroptions);
+ $mform->addElement('filemanager', 'customcertimage', get_string('uploadimage', 'customcert'), '',
+ $this->filemanageroptions);
}
/**
diff --git a/element/border/classes/element.php b/element/border/classes/element.php
index 5b2c877..b2c580d 100644
--- a/element/border/classes/element.php
+++ b/element/border/classes/element.php
@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This file contains the customcert element border's core interaction API.
+ *
+ * @package customcertelement_border
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
namespace customcertelement_border;
defined('MOODLE_INTERNAL') || die();
diff --git a/element/categoryname/classes/element.php b/element/categoryname/classes/element.php
index 8b94996..4b0aeb6 100644
--- a/element/categoryname/classes/element.php
+++ b/element/categoryname/classes/element.php
@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This file contains the customcert element categoryname's core interaction API.
+ *
+ * @package customcertelement_categoryname
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
namespace customcertelement_categoryname;
defined('MOODLE_INTERNAL') || die();
diff --git a/element/code/classes/element.php b/element/code/classes/element.php
index 2cd0f22..c6de625 100644
--- a/element/code/classes/element.php
+++ b/element/code/classes/element.php
@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This file contains the customcert element code's core interaction API.
+ *
+ * @package customcertelement_code
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
namespace customcertelement_code;
defined('MOODLE_INTERNAL') || die();
@@ -45,7 +53,8 @@ class element extends \mod_customcert\element {
// Get the customcert this page belongs to.
$customcert = $DB->get_record('customcert', array('templateid' => $page->templateid), '*', MUST_EXIST);
// Now we can get the issue for this user.
- $issue = $DB->get_record('customcert_issues', array('userid' => $user->id, 'customcertid' => $customcert->id), '*', MUST_EXIST);
+ $issue = $DB->get_record('customcert_issues', array('userid' => $user->id, 'customcertid' => $customcert->id),
+ '*', MUST_EXIST);
$code = $issue->code;
}
diff --git a/element/coursename/classes/element.php b/element/coursename/classes/element.php
index dcd4c9e..b07acaf 100644
--- a/element/coursename/classes/element.php
+++ b/element/coursename/classes/element.php
@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This file contains the customcert element coursename's core interaction API.
+ *
+ * @package customcertelement_coursename
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
namespace customcertelement_coursename;
defined('MOODLE_INTERNAL') || die();
diff --git a/element/date/classes/element.php b/element/date/classes/element.php
index 686287b..f24fbae 100644
--- a/element/date/classes/element.php
+++ b/element/date/classes/element.php
@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This file contains the customcert element date's core interaction API.
+ *
+ * @package customcertelement_date
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
namespace customcertelement_date;
defined('MOODLE_INTERNAL') || die();
@@ -107,7 +115,8 @@ class element extends \mod_customcert\element {
// Get the customcert this page belongs to.
$customcert = $DB->get_record('customcert', array('templateid' => $page->templateid), '*', MUST_EXIST);
// Now we can get the issue for this user.
- $issue = $DB->get_record('customcert_issues', array('userid' => $user->id, 'customcertid' => $customcert->id), '*', MUST_EXIST);
+ $issue = $DB->get_record('customcert_issues', array('userid' => $user->id, 'customcertid' => $customcert->id),
+ '*', MUST_EXIST);
if ($dateitem == CUSTOMCERT_DATE_ISSUE) {
$date = $issue->timecreated;
diff --git a/element/grade/classes/element.php b/element/grade/classes/element.php
index 8fd410c..6553099 100644
--- a/element/grade/classes/element.php
+++ b/element/grade/classes/element.php
@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This file contains the customcert element grade's core interaction API.
+ *
+ * @package customcertelement_grade
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
namespace customcertelement_grade;
defined('MOODLE_INTERNAL') || die();
@@ -53,7 +61,8 @@ class element extends \mod_customcert\element {
$mform->addHelpButton('gradeitem', 'gradeitem', 'customcertelement_grade');
// The grade format.
- $mform->addElement('select', 'gradeformat', get_string('gradeformat', 'customcertelement_grade'), self::get_grade_format_options());
+ $mform->addElement('select', 'gradeformat', get_string('gradeformat', 'customcertelement_grade'),
+ self::get_grade_format_options());
$mform->setType('gradeformat', PARAM_INT);
$mform->addHelpButton('gradeformat', 'gradeformat', 'customcertelement_grade');
diff --git a/element/gradeitemname/classes/element.php b/element/gradeitemname/classes/element.php
index 4721b1f..de25948 100644
--- a/element/gradeitemname/classes/element.php
+++ b/element/gradeitemname/classes/element.php
@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This file contains the customcert element gradeitemname's core interaction API.
+ *
+ * @package customcertelement_gradeitemname
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
namespace customcertelement_gradeitemname;
defined('MOODLE_INTERNAL') || die();
diff --git a/element/image/classes/element.php b/element/image/classes/element.php
index c445da7..4f93d32 100644
--- a/element/image/classes/element.php
+++ b/element/image/classes/element.php
@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This file contains the customcert element image's core interaction API.
+ *
+ * @package customcertelement_image
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
namespace customcertelement_image;
defined('MOODLE_INTERNAL') || die();
@@ -27,6 +35,9 @@ defined('MOODLE_INTERNAL') || die();
*/
class element extends \mod_customcert\element {
+ /**
+ * @var array The file manager options.
+ */
protected $filemanageroptions = array();
/**
@@ -68,7 +79,8 @@ class element extends \mod_customcert\element {
\mod_customcert\element_helper::render_form_element_position($mform);
}
- $mform->addElement('filemanager', 'customcertimage', get_string('uploadimage', 'customcert'), '', $this->filemanageroptions);
+ $mform->addElement('filemanager', 'customcertimage', get_string('uploadimage', 'customcert'), '',
+ $this->filemanageroptions);
}
/**
@@ -237,7 +249,6 @@ class element extends \mod_customcert\element {
$context = \context_course::instance($COURSE->id);
}
-
// Editing existing instance - copy existing files into draft area.
$draftitemid = file_get_submitted_draft_itemid('customcertimage');
file_prepare_draft_area($draftitemid, $context->id, 'mod_customcert', 'image', 0, $this->filemanageroptions);
@@ -267,7 +278,8 @@ class element extends \mod_customcert\element {
}
}
// Loop through the files uploaded in the course context.
- if ($files = $fs->get_area_files(\context_course::instance($COURSE->id)->id, 'mod_customcert', 'image', false, 'filename', false)) {
+ if ($files = $fs->get_area_files(\context_course::instance($COURSE->id)->id, 'mod_customcert', 'image', false,
+ 'filename', false)) {
foreach ($files as $hash => $file) {
$arrfiles[$hash] = $file->get_filename();
}
diff --git a/element/studentname/classes/element.php b/element/studentname/classes/element.php
index 6ddde2d..c70e20a 100644
--- a/element/studentname/classes/element.php
+++ b/element/studentname/classes/element.php
@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This file contains the customcert element studentname's core interaction API.
+ *
+ * @package customcertelement_studentname
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
namespace customcertelement_studentname;
defined('MOODLE_INTERNAL') || die();
diff --git a/element/teachername/classes/element.php b/element/teachername/classes/element.php
index feb4881..3c61745 100644
--- a/element/teachername/classes/element.php
+++ b/element/teachername/classes/element.php
@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This file contains the customcert element teachername's core interaction API.
+ *
+ * @package customcertelement_teachername
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
namespace customcertelement_teachername;
defined('MOODLE_INTERNAL') || die();
diff --git a/element/text/classes/element.php b/element/text/classes/element.php
index b3055d8..5c0c642 100644
--- a/element/text/classes/element.php
+++ b/element/text/classes/element.php
@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This file contains the customcert element text's core interaction API.
+ *
+ * @package customcertelement_text
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
namespace customcertelement_text;
defined('MOODLE_INTERNAL') || die();
diff --git a/element/userfield/classes/element.php b/element/userfield/classes/element.php
index 1c9a541..550a2a2 100644
--- a/element/userfield/classes/element.php
+++ b/element/userfield/classes/element.php
@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This file contains the customcert element userfield's core interaction API.
+ *
+ * @package customcertelement_userfield
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
namespace customcertelement_userfield;
defined('MOODLE_INTERNAL') || die();
diff --git a/element/userpicture/classes/element.php b/element/userpicture/classes/element.php
index 8e40337..9b832d7 100644
--- a/element/userpicture/classes/element.php
+++ b/element/userpicture/classes/element.php
@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This file contains the customcert element userpicture's core interaction API.
+ *
+ * @package customcertelement_userpicture
+ * @copyright 2017 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
namespace customcertelement_userpicture;
defined('MOODLE_INTERNAL') || die();
@@ -165,7 +173,8 @@ class element extends \mod_customcert\element {
// The size of the images to use in the CSS style.
$style = '';
if ($imageinfo->width === 0 && $imageinfo->height === 0) {
- // Do nothing.
+ // Put this in so code checker doesn't complain.
+ $style .= '';
} else if ($imageinfo->width === 0) { // Then the height must be set.
$style .= 'width: ' . $imageinfo->height . 'mm; ';
$style .= 'height: ' . $imageinfo->height . 'mm';
diff --git a/includes/colourpicker.php b/includes/colourpicker.php
index 682e4b3..cad6e2c 100644
--- a/includes/colourpicker.php
+++ b/includes/colourpicker.php
@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This file contains the form element for handling the colour picker.
+ *
+ * @package mod_customcert
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once($CFG->dirroot . '/lib/form/editor.php');
@@ -25,41 +33,21 @@ require_once($CFG->dirroot . '/lib/form/editor.php');
* @copyright 2013 Mark Nelson
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
-class MoodleQuickForm_customcert_colourpicker extends MoodleQuickForm_editor {
-
- /**
- * Constructor for the colour picker.
- *
- * @param string $elementName
- * @param string $elementLabel
- * @param array $attributes
- */
- public function __construct($elementName = null, $elementLabel = null, $attributes = null) {
- parent::__construct($elementName, $elementLabel, $attributes);
- }
-
- /**
- * Old school constructor name to support earlier versions of Moodle.
- *
- * @param string $elementName
- * @param string $elementLabel
- * @param array $attributes
- */
- public function MoodleQuickForm_customcert_colourpicker($elementName = null, $elementLabel = null, $attributes = null) {
- self::__construct($elementName, $elementLabel, $attributes);
- }
+class moodlequickform_customcert_colourpicker extends moodlequickform_editor {
/**
* Sets the value of the form element
+ *
+ * @param string $value
*/
- public function setValue($value) {
+ public function setvalue($value) {
$this->updateAttributes(array('value' => $value));
}
/**
* Gets the value of the form element
*/
- public function getValue() {
+ public function getvalue() {
return $this->getAttribute('value');
}
@@ -68,7 +56,7 @@ class MoodleQuickForm_customcert_colourpicker extends MoodleQuickForm_editor {
*
* @return string
*/
- public function toHtml() {
+ public function tohtml() {
global $PAGE, $OUTPUT;
$PAGE->requires->js_init_call('M.util.init_colour_picker', array($this->getAttribute('id'), null));
@@ -83,6 +71,12 @@ class MoodleQuickForm_customcert_colourpicker extends MoodleQuickForm_editor {
return $content;
}
+ /**
+ * Function to export the renderer data in a format that is suitable for a mustache template.
+ *
+ * @param \renderer_base $output Used to do a final render of any components that need to be rendered for export.
+ * @return \stdClass|array
+ */
public function export_for_template(renderer_base $output) {
$context = $this->export_for_template_base($output);
$context['html'] = $this->toHtml();
diff --git a/index.php b/index.php
index bc85fa6..b4d1cb9 100644
--- a/index.php
+++ b/index.php
@@ -40,7 +40,7 @@ $pageurl = new moodle_url('/mod/customcert/index.php', array('id' => $course->id
$PAGE->set_pagelayout('incourse');
$PAGE->navbar->add(get_string('modulenameplural', 'customcert'));
-// Add the page view to the Moodle log
+// Add the page view to the Moodle log.
$event = \mod_customcert\event\course_module_instance_list_viewed::create(array(
'context' => context_course::instance($course->id)
));
@@ -72,8 +72,8 @@ foreach ($customcerts as $customcert) {
$link = html_writer::tag('a', $customcert->name, array('href' => new moodle_url('/mod/customcert/view.php',
array('id' => $customcert->coursemodule))));
} else {
- $link = html_writer::tag('a', $customcert->name, array('class' => 'dimmed', 'href' =>
- new moodle_url('/mod/customcert/view.php', array('id' => $customcert->coursemodule))));
+ $link = html_writer::tag('a', $customcert->name, array('class' => 'dimmed',
+ 'href' => new moodle_url('/mod/customcert/view.php', array('id' => $customcert->coursemodule))));
}
// If we are at a different section then print a horizontal rule.
if ($customcert->section !== $currentsection) {
diff --git a/lib.php b/lib.php
index c565dd8..a1a1be8 100644
--- a/lib.php
+++ b/lib.php
@@ -249,6 +249,8 @@ function customcert_pluginfile($course, $cm, $context, $filearea, $args, $forced
}
/**
+ * The features this activity supports.
+ *
* @uses FEATURE_GROUPS
* @uses FEATURE_GROUPINGS
* @uses FEATURE_GROUPMEMBERSONLY
@@ -380,9 +382,9 @@ function mod_customcert_myprofile_navigation(core_user\output\myprofile\tree $tr
/**
* Handles editing the 'name' of the element in a list.
*
- * @param $itemtype
- * @param $itemid
- * @param $newvalue
+ * @param string $itemtype
+ * @param int $itemid
+ * @param string $newvalue
* @return \core\output\inplace_editable
*/
function mod_customcert_inplace_editable($itemtype, $itemid, $newvalue) {
diff --git a/mod_form.php b/mod_form.php
index d28c697..be88640 100644
--- a/mod_form.php
+++ b/mod_form.php
@@ -14,6 +14,14 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see .
+/**
+ * This file contains the instance add/edit form.
+ *
+ * @package mod_customcert
+ * @copyright 2013 Mark Nelson
+ * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
+ */
+
defined('MOODLE_INTERNAL') || die('Direct access to this script is forbidden.');
require_once($CFG->dirroot.'/course/moodleform_mod.php');
@@ -53,7 +61,8 @@ class mod_customcert_mod_form extends moodleform_mod {
$mform->setType('requiredtime', PARAM_INT);
$mform->addHelpButton('requiredtime', 'coursetimereq', 'customcert');
- $mform->addElement('checkbox', 'protection_print', get_string('setprotection', 'customcert'), get_string('print', 'customcert'));
+ $mform->addElement('checkbox', 'protection_print', get_string('setprotection', 'customcert'),
+ get_string('print', 'customcert'));
$mform->addElement('checkbox', 'protection_modify', '', get_string('modify', 'customcert'));
$mform->addElement('checkbox', 'protection_copy', '', get_string('copy', 'customcert'));
$mform->addHelpButton('protection_print', 'setprotection', 'customcert');
diff --git a/rearrange.php b/rearrange.php
index 29bba99..5a98cb6 100644
--- a/rearrange.php
+++ b/rearrange.php
@@ -60,7 +60,7 @@ $PAGE->navbar->add($str, new \action_link($link, $str));
$PAGE->navbar->add(get_string('rearrangeelements', 'customcert'));
// Include the JS we need.
-$PAGE->requires->yui_module('moodle-mod_customcert-rearrange', 'M.mod_customcert.rearrange.init',
+$PAGE->requires->yui_module('moodle-mod_customcert-rearrange', 'Y.M.mod_customcert.rearrange.init',
array($template->get_id(),
$page,
$elements));
diff --git a/styles.css b/styles.css
index 6824595..04a6aa0 100644
--- a/styles.css
+++ b/styles.css
@@ -24,13 +24,13 @@
}
#page-mod-customcert-rearrange .element:before {
- content: "";
- display: block;
background-image: url([[pix:mod_customcert|target]]);
background-repeat: no-repeat;
- width: 100%;
- height: 9px;
+ content: "";
+ display: block;
float: left;
+ height: 9px;
+ width: 100%;
}
#page-mod-customcert-rearrange .element:hover {
@@ -53,9 +53,9 @@
}
#page-mod-customcert-rearrange #pdf {
- clear: both;
border-style: solid;
border-width: 1px;
+ clear: both;
}
#page-mod-customcert-rearrange div#leftmargin {
diff --git a/templates/verify_certificate_result.mustache b/templates/verify_certificate_result.mustache
index 8fbb9c6..9dc888b 100644
--- a/templates/verify_certificate_result.mustache
+++ b/templates/verify_certificate_result.mustache
@@ -1,3 +1,46 @@
+{{!
+ 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 .
+}}
+{{!
+ @template mod_customcert/verify_certificate_result
+
+ The certificate verification result
+
+ Classes required for JS:
+ * None
+
+ Data attibutes required for JS:
+ * All data attributes are required
+
+ Context variables required for this template:
+ * userprofileurl The URL to the user's profile
+ * userfullname The fullname of the user
+ * courseurl The URL of the course
+ * coursefullname The full name of the course
+ * certificatename The name of the certificate
+
+ Example context (json):
+ {
+ "userprofileurl": "http://www.example.com",
+ "userfullname": "Mark Smith",
+ "courseurl": "http://www.example.com",
+ "coursefullname": "Computing 101",
+ "certificatename": "Ability to write 'Hello world' in Java."
+ }
+}}
- Fullname: {{userfullname}}
- Course: {{coursefullname}}
diff --git a/templates/verify_certificate_results.mustache b/templates/verify_certificate_results.mustache
index 95c0cbd..82abe10 100644
--- a/templates/verify_certificate_results.mustache
+++ b/templates/verify_certificate_results.mustache
@@ -1,3 +1,37 @@
+{{!
+ 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 .
+}}
+{{!
+ @template mod_customcert/verify_certificate_results
+
+ The certificate verification results page
+
+ Classes required for JS:
+ * None
+
+ Data attibutes required for JS:
+ * All data attributes are required
+
+ Context variables required for this template:
+ * None
+
+ Example context (json):
+ {
+ }
+}}
{{#success}}
{{#issues}}
{{> mod_customcert/verify_certificate_result }}
diff --git a/verify_certificate.php b/verify_certificate.php
index 3e04bc1..16e04f2 100644
--- a/verify_certificate.php
+++ b/verify_certificate.php
@@ -52,7 +52,7 @@ if ($form->get_data()) {
// Ok, now check if the code is valid.
$userfields = get_all_user_name_fields(true, 'u');
- $sql = "SELECT ci.id, u.id as userid, $userfields, co.id as courseid,
+ $sql = "SELECT ci.id, u.id as userid, $userfields, co.id as courseid,
co.fullname as coursefullname, c.name as certificatename
FROM {customcert} c
JOIN {customcert_issues} ci
diff --git a/view.php b/view.php
index 21a06be..b4cfe64 100644
--- a/view.php
+++ b/view.php
@@ -126,7 +126,7 @@ if (empty($action)) {
$customcertissue->customcertid = $customcert->id;
$customcertissue->userid = $USER->id;
$customcertissue->code = \mod_customcert\certificate::generate_code();
- $customcertissue->timecreated = time();
+ $customcertissue->timecreated = time();
// Insert the record into the database.
$DB->insert_record('customcert_issues', $customcertissue);
}
diff --git a/yui/build/moodle-mod_customcert-rearrange/moodle-mod_customcert-rearrange-debug.js b/yui/build/moodle-mod_customcert-rearrange/moodle-mod_customcert-rearrange-debug.js
index 6554b19..9c31971 100644
--- a/yui/build/moodle-mod_customcert-rearrange/moodle-mod_customcert-rearrange-debug.js
+++ b/yui/build/moodle-mod_customcert-rearrange/moodle-mod_customcert-rearrange-debug.js
@@ -3,7 +3,7 @@ YUI.add('moodle-mod_customcert-rearrange', function (Y, NAME) {
/**
* Rearrange elements in the custom certificate
*
- * @class M.mod_customcert.rearrange.rearrange
+ * @class Y.M.mod_customcert.rearrange
* @constructor
*/
var Rearrange = function() {
@@ -14,64 +14,64 @@ Y.extend(Rearrange, Y.Base, {
/**
* The template id.
*/
- templateid : 0,
+ templateid: 0,
/**
* The customcert page we are displaying.
*/
- page : [],
+ page: [],
/**
* The custom certificate elements to display.
*/
- elements : [],
+ elements: [],
/**
* Store the X coordinates of the top left of the pdf div.
*/
- pdfx : 0,
+ pdfx: 0,
/**
* Store the Y coordinates of the top left of the pdf div.
*/
- pdfy : 0,
+ pdfy: 0,
/**
* Store the width of the pdf div.
*/
- pdfwidth : 0,
+ pdfwidth: 0,
/**
* Store the height of the pdf div.
*/
- pdfheight : 0,
+ pdfheight: 0,
/**
* Store the location of the element before we move.
*/
- elementxy : 0,
+ elementxy: 0,
/**
* Store the left boundary of the pdf div.
*/
- pdfleftboundary : 0,
+ pdfleftboundary: 0,
/**
* Store the right boundary of the pdf div.
*/
- pdfrightboundary : 0,
+ pdfrightboundary: 0,
/**
* The number of pixels in a mm.
*/
- pixelsinmm : 3.779527559055, // '3.779528'.
+ pixelsinmm: 3.779527559055, // 3.779528.
/**
* Initialise.
*
- * @param params
+ * @param {Array} params
*/
- initializer : function(params) {
+ initializer: function(params) {
// Set the course module id.
this.templateid = params[0];
// Set the page.
@@ -96,14 +96,14 @@ Y.extend(Rearrange, Y.Base, {
this.pdfrightboundary -= parseInt(this.page.rightmargin * this.pixelsinmm, 10);
}
- this.set_positions();
- this.create_events();
+ this.setpositions();
+ this.createevents();
},
/**
* Sets the current position of the elements.
*/
- set_positions : function() {
+ setpositions: function() {
// Go through the elements and set their positions.
for (var key in this.elements) {
var element = this.elements[key];
@@ -117,10 +117,10 @@ Y.extend(Rearrange, Y.Base, {
}
switch (element.refpoint) {
- case '1': // Top-center
+ case '1': // Top-center.
posx -= nodewidth / 2;
break;
- case '2': // Top-right
+ case '2': // Top-right.
posx = posx - nodewidth + 2;
break;
}
@@ -133,15 +133,15 @@ Y.extend(Rearrange, Y.Base, {
/**
* Creates the JS events for changing element positions.
*/
- create_events : function() {
+ createevents: function() {
// Trigger a save event when save button is pushed.
Y.one('.savepositionsbtn [type=submit]').on('click', function(e) {
- this.save_positions(e);
+ this.savepositions(e);
}, this);
// Trigger a save event when apply button is pushed.
Y.one('.applypositionsbtn [type=submit]').on('click', function(e) {
- this.save_positions(e);
+ this.savepositions(e);
e.preventDefault();
}, this);
@@ -161,7 +161,7 @@ Y.extend(Rearrange, Y.Base, {
// if not, set it back to where it was.
del.on('drag:end', function() {
var node = del.get('currentNode');
- if (this.is_out_of_bounds(node)) {
+ if (this.isoutofbounds(node)) {
node.setXY(this.elementxy);
}
}, this);
@@ -170,10 +170,10 @@ Y.extend(Rearrange, Y.Base, {
/**
* Returns true if any part of the element is placed outside of the PDF div, false otherwise.
*
- * @param node
+ * @param {Node} node
* @returns {boolean}
*/
- is_out_of_bounds : function(node) {
+ isoutofbounds: function(node) {
// Get the width and height of the node.
var nodewidth = parseFloat(node.getComputedStyle('width'));
var nodeheight = parseFloat(node.getComputedStyle('height'));
@@ -185,12 +185,12 @@ Y.extend(Rearrange, Y.Base, {
var bottom = top + nodeheight;
// Check if it is out of bounds horizontally.
- if ((left < this.pdfleftboundary) || (right > this.pdfrightboundary)) {
+ if ((left < this.pdfleftboundary) || (right > this.pdfrightboundary)) {
return true;
}
// Check if it is out of bounds vertically.
- if ((top < this.pdfy) || (bottom > (this.pdfy + this.pdfheight))) {
+ if ((top < this.pdfy) || (bottom > (this.pdfy + this.pdfheight))) {
return true;
}
@@ -200,9 +200,9 @@ Y.extend(Rearrange, Y.Base, {
/**
* Perform an AJAX call and save the positions of the elements.
*
- * @param e
+ * @param {Event} e
*/
- save_positions : function(e) {
+ savepositions: function(e) {
// The parameters to send the AJAX call.
var params = {
tid: this.templateid,
@@ -222,10 +222,10 @@ Y.extend(Rearrange, Y.Base, {
var nodewidth = parseFloat(node.getComputedStyle('width'));
switch (refpoint) {
- case '1': // Top-center
+ case '1': // Top-center.
posx += nodewidth / 2;
break;
- case '2': // Top-right
+ case '2': // Top-right.
posx += nodewidth;
break;
}
@@ -246,18 +246,18 @@ Y.extend(Rearrange, Y.Base, {
data: params,
on: {
failure: function(tid, response) {
- this.ajax_failure(response);
+ this.ajaxfailure(response);
},
success: function() {
- var formNode = e.currentTarget.ancestor('form', true);
- var baseUrl = formNode.getAttribute('action');
- var pageinput = formNode.one('[name=pid]');
+ var formnode = e.currentTarget.ancestor('form', true);
+ var baseurl = formnode.getAttribute('action');
+ var pageinput = formnode.one('[name=pid]');
if (pageinput) {
var pageid = pageinput.get('value');
- window.location = baseUrl + '?pid=' + pageid;
+ window.location = baseurl + '?pid=' + pageid;
} else {
- var templateid = formNode.one('[name=tid]').get('value');
- window.location = baseUrl + '?tid=' + templateid;
+ var templateid = formnode.one('[name=tid]').get('value');
+ window.location = baseurl + '?tid=' + templateid;
}
}
},
@@ -270,10 +270,10 @@ Y.extend(Rearrange, Y.Base, {
/**
* Handles any failures during an AJAX call.
*
- * @param response
+ * @param {XMLHttpRequest} response
* @returns {M.core.exception}
*/
- ajax_failure : function(response) {
+ ajaxfailure: function(response) {
var e = {
name: response.status + ' ' + response.statusText,
message: response.responseText
@@ -282,10 +282,9 @@ Y.extend(Rearrange, Y.Base, {
}
});
-M.mod_customcert = M.mod_customcert || {};
-M.mod_customcert.rearrange = M.mod_customcert.rearrange || {};
-M.mod_customcert.rearrange.init = function(templateid, page, elements) {
+Y.namespace('M.mod_customcert.rearrange').init = function(templateid, page, elements) {
new Rearrange(templateid, page, elements);
};
+
}, '@VERSION@', {"requires": ["dd-delegate", "dd-drag"]});
diff --git a/yui/build/moodle-mod_customcert-rearrange/moodle-mod_customcert-rearrange-min.js b/yui/build/moodle-mod_customcert-rearrange/moodle-mod_customcert-rearrange-min.js
index a2a128d..f21a5a4 100644
--- a/yui/build/moodle-mod_customcert-rearrange/moodle-mod_customcert-rearrange-min.js
+++ b/yui/build/moodle-mod_customcert-rearrange/moodle-mod_customcert-rearrange-min.js
@@ -1 +1 @@
-YUI.add("moodle-mod_customcert-rearrange",function(e,t){var n=function(){n.superclass.constructor.apply(this,[arguments])};e.extend(n,e.Base,{templateid:0,page:[],elements:[],pdfx:0,pdfy:0,pdfwidth:0,pdfheight:0,elementxy:0,pdfleftboundary:0,pdfrightboundary:0,pixelsinmm:3.779527559055,initializer:function(t){this.templateid=t[0],this.page=t[1],this.elements=t[2],this.pdfx=e.one("#pdf").getX(),this.pdfy=e.one("#pdf").getY(),this.pdfwidth=parseFloat(e.one("#pdf").getComputedStyle("width")),this.pdfheight=parseFloat(e.one("#pdf").getComputedStyle("height")),this.pdfleftboundary=this.pdfx,this.page.leftmargin&&(this.pdfleftboundary+=parseInt(this.page.leftmargin*this.pixelsinmm,10)),this.pdfrightboundary=this.pdfx+this.pdfwidth,this.page.rightmargin&&(this.pdfrightboundary-=parseInt(this.page.rightmargin*this.pixelsinmm,10)),this.set_positions(),this.create_events()},set_positions:function(){for(var t in this.elements){var n=this.elements[t],r=this.pdfx+n.posx*this.pixelsinmm,i=this.pdfy+n.posy*this.pixelsinmm,s=parseFloat(e.one("#element-"+n.id).getComputedStyle("width")),o=n.width*this.pixelsinmm;o&&s>o&&(s=o);switch(n.refpoint){case"1":r-=s/2;break;case"2":r=r-s+2}e.one("#element-"+n.id).setX(r),e.one("#element-"+n.id).setY(i)}},create_events:function(){e.one(".savepositionsbtn [type=submit]").on("click",function(e){this.save_positions(e)},this),e.one(".applypositionsbtn [type=submit]").on("click",function(e){this.save_positions(e),e.preventDefault()},this);var t=new e.DD.Delegate({container:"#pdf",nodes:".element"});t.on("drag:start",function(){var e=t.get("currentNode");this.elementxy=e.getXY()},this),t.on("drag:end",function(){var e=t.get("currentNode");this.is_out_of_bounds(e)&&e.setXY(this.elementxy)},this)},is_out_of_bounds:function(e){var t=parseFloat(e.getComputedStyle("width")),n=parseFloat(e.getComputedStyle("height")),r=e.getX(),i=r+t,s=e.getY(),o=s+n;return rthis.pdfrightboundary?!0:sthis.pdfy+this.pdfheight?!0:!1},save_positions:function(t){var n={tid:this.templateid,values:[]};for(var r in this.elements){var i=this.elements[r],s=e.one("#element-"+i.id),o=s.getX()-this.pdfx,u=s.getY()-this.pdfy,a=s.getData("refpoint"),f=parseFloat(s.getComputedStyle("width"));switch(a){case"1":o+=f/2;break;case"2":o+=f}n.values.push({id:i.id,posx:Math.round(parseFloat(o/this.pixelsinmm)),posy:Math.round(parseFloat(u/this.pixelsinmm))})}n.values=JSON.stringify(n.values),e.io(M.cfg.wwwroot+"/mod/customcert/ajax.php",{method:"POST",data:n,on:{failure:function(e,t){this.ajax_failure(t)},success:function(){var e=t.currentTarget.ancestor("form",!0),n=e.getAttribute("action"),r=e.one("[name=pid]");if(r){var i=r.get("value");window.location=n+"?pid="+i}else{var s=e.one("[name=tid]").get("value");window.location=n+"?tid="+s}}},context:this}),t.preventDefault()},ajax_failure:function(e){var t={name:e.status+" "+e.statusText,message:e.responseText};return new M.core.exception(t)}}),M.mod_customcert=M.mod_customcert||{},M.mod_customcert.rearrange=M.mod_customcert.rearrange||{},M.mod_customcert.rearrange.init=function(e,t,r){new n(e,t,r)}},"@VERSION@",{requires:["dd-delegate","dd-drag"]});
+YUI.add("moodle-mod_customcert-rearrange",function(e,t){var n=function(){n.superclass.constructor.apply(this,[arguments])};e.extend(n,e.Base,{templateid:0,page:[],elements:[],pdfx:0,pdfy:0,pdfwidth:0,pdfheight:0,elementxy:0,pdfleftboundary:0,pdfrightboundary:0,pixelsinmm:3.779527559055,initializer:function(t){this.templateid=t[0],this.page=t[1],this.elements=t[2],this.pdfx=e.one("#pdf").getX(),this.pdfy=e.one("#pdf").getY(),this.pdfwidth=parseFloat(e.one("#pdf").getComputedStyle("width")),this.pdfheight=parseFloat(e.one("#pdf").getComputedStyle("height")),this.pdfleftboundary=this.pdfx,this.page.leftmargin&&(this.pdfleftboundary+=parseInt(this.page.leftmargin*this.pixelsinmm,10)),this.pdfrightboundary=this.pdfx+this.pdfwidth,this.page.rightmargin&&(this.pdfrightboundary-=parseInt(this.page.rightmargin*this.pixelsinmm,10)),this.setpositions(),this.createevents()},setpositions:function(){for(var t in this.elements){var n=this.elements[t],r=this.pdfx+n.posx*this.pixelsinmm,i=this.pdfy+n.posy*this.pixelsinmm,s=parseFloat(e.one("#element-"+n.id).getComputedStyle("width")),o=n.width*this.pixelsinmm;o&&s>o&&(s=o);switch(n.refpoint){case"1":r-=s/2;break;case"2":r=r-s+2}e.one("#element-"+n.id).setX(r),e.one("#element-"+n.id).setY(i)}},createevents:function(){e.one(".savepositionsbtn [type=submit]").on("click",function(e){this.savepositions(e)},this),e.one(".applypositionsbtn [type=submit]").on("click",function(e){this.savepositions(e),e.preventDefault()},this);var t=new e.DD.Delegate({container:"#pdf",nodes:".element"});t.on("drag:start",function(){var e=t.get("currentNode");this.elementxy=e.getXY()},this),t.on("drag:end",function(){var e=t.get("currentNode");this.isoutofbounds(e)&&e.setXY(this.elementxy)},this)},isoutofbounds:function(e){var t=parseFloat(e.getComputedStyle("width")),n=parseFloat(e.getComputedStyle("height")),r=e.getX(),i=r+t,s=e.getY(),o=s+n;return rthis.pdfrightboundary?!0:sthis.pdfy+this.pdfheight?!0:!1},savepositions:function(t){var n={tid:this.templateid,values:[]};for(var r in this.elements){var i=this.elements[r],s=e.one("#element-"+i.id),o=s.getX()-this.pdfx,u=s.getY()-this.pdfy,a=s.getData("refpoint"),f=parseFloat(s.getComputedStyle("width"));switch(a){case"1":o+=f/2;break;case"2":o+=f}n.values.push({id:i.id,posx:Math.round(parseFloat(o/this.pixelsinmm)),posy:Math.round(parseFloat(u/this.pixelsinmm))})}n.values=JSON.stringify(n.values),e.io(M.cfg.wwwroot+"/mod/customcert/ajax.php",{method:"POST",data:n,on:{failure:function(e,t){this.ajaxfailure(t)},success:function(){var e=t.currentTarget.ancestor("form",!0),n=e.getAttribute("action"),r=e.one("[name=pid]");if(r){var i=r.get("value");window.location=n+"?pid="+i}else{var s=e.one("[name=tid]").get("value");window.location=n+"?tid="+s}}},context:this}),t.preventDefault()},ajaxfailure:function(e){var t={name:e.status+" "+e.statusText,message:e.responseText};return new M.core.exception(t)}}),e.namespace("M.mod_customcert.rearrange").init=function(e,t,r){new n(e,t,r)}},"@VERSION@",{requires:["dd-delegate","dd-drag"]});
diff --git a/yui/build/moodle-mod_customcert-rearrange/moodle-mod_customcert-rearrange.js b/yui/build/moodle-mod_customcert-rearrange/moodle-mod_customcert-rearrange.js
index 6554b19..9c31971 100644
--- a/yui/build/moodle-mod_customcert-rearrange/moodle-mod_customcert-rearrange.js
+++ b/yui/build/moodle-mod_customcert-rearrange/moodle-mod_customcert-rearrange.js
@@ -3,7 +3,7 @@ YUI.add('moodle-mod_customcert-rearrange', function (Y, NAME) {
/**
* Rearrange elements in the custom certificate
*
- * @class M.mod_customcert.rearrange.rearrange
+ * @class Y.M.mod_customcert.rearrange
* @constructor
*/
var Rearrange = function() {
@@ -14,64 +14,64 @@ Y.extend(Rearrange, Y.Base, {
/**
* The template id.
*/
- templateid : 0,
+ templateid: 0,
/**
* The customcert page we are displaying.
*/
- page : [],
+ page: [],
/**
* The custom certificate elements to display.
*/
- elements : [],
+ elements: [],
/**
* Store the X coordinates of the top left of the pdf div.
*/
- pdfx : 0,
+ pdfx: 0,
/**
* Store the Y coordinates of the top left of the pdf div.
*/
- pdfy : 0,
+ pdfy: 0,
/**
* Store the width of the pdf div.
*/
- pdfwidth : 0,
+ pdfwidth: 0,
/**
* Store the height of the pdf div.
*/
- pdfheight : 0,
+ pdfheight: 0,
/**
* Store the location of the element before we move.
*/
- elementxy : 0,
+ elementxy: 0,
/**
* Store the left boundary of the pdf div.
*/
- pdfleftboundary : 0,
+ pdfleftboundary: 0,
/**
* Store the right boundary of the pdf div.
*/
- pdfrightboundary : 0,
+ pdfrightboundary: 0,
/**
* The number of pixels in a mm.
*/
- pixelsinmm : 3.779527559055, // '3.779528'.
+ pixelsinmm: 3.779527559055, // 3.779528.
/**
* Initialise.
*
- * @param params
+ * @param {Array} params
*/
- initializer : function(params) {
+ initializer: function(params) {
// Set the course module id.
this.templateid = params[0];
// Set the page.
@@ -96,14 +96,14 @@ Y.extend(Rearrange, Y.Base, {
this.pdfrightboundary -= parseInt(this.page.rightmargin * this.pixelsinmm, 10);
}
- this.set_positions();
- this.create_events();
+ this.setpositions();
+ this.createevents();
},
/**
* Sets the current position of the elements.
*/
- set_positions : function() {
+ setpositions: function() {
// Go through the elements and set their positions.
for (var key in this.elements) {
var element = this.elements[key];
@@ -117,10 +117,10 @@ Y.extend(Rearrange, Y.Base, {
}
switch (element.refpoint) {
- case '1': // Top-center
+ case '1': // Top-center.
posx -= nodewidth / 2;
break;
- case '2': // Top-right
+ case '2': // Top-right.
posx = posx - nodewidth + 2;
break;
}
@@ -133,15 +133,15 @@ Y.extend(Rearrange, Y.Base, {
/**
* Creates the JS events for changing element positions.
*/
- create_events : function() {
+ createevents: function() {
// Trigger a save event when save button is pushed.
Y.one('.savepositionsbtn [type=submit]').on('click', function(e) {
- this.save_positions(e);
+ this.savepositions(e);
}, this);
// Trigger a save event when apply button is pushed.
Y.one('.applypositionsbtn [type=submit]').on('click', function(e) {
- this.save_positions(e);
+ this.savepositions(e);
e.preventDefault();
}, this);
@@ -161,7 +161,7 @@ Y.extend(Rearrange, Y.Base, {
// if not, set it back to where it was.
del.on('drag:end', function() {
var node = del.get('currentNode');
- if (this.is_out_of_bounds(node)) {
+ if (this.isoutofbounds(node)) {
node.setXY(this.elementxy);
}
}, this);
@@ -170,10 +170,10 @@ Y.extend(Rearrange, Y.Base, {
/**
* Returns true if any part of the element is placed outside of the PDF div, false otherwise.
*
- * @param node
+ * @param {Node} node
* @returns {boolean}
*/
- is_out_of_bounds : function(node) {
+ isoutofbounds: function(node) {
// Get the width and height of the node.
var nodewidth = parseFloat(node.getComputedStyle('width'));
var nodeheight = parseFloat(node.getComputedStyle('height'));
@@ -185,12 +185,12 @@ Y.extend(Rearrange, Y.Base, {
var bottom = top + nodeheight;
// Check if it is out of bounds horizontally.
- if ((left < this.pdfleftboundary) || (right > this.pdfrightboundary)) {
+ if ((left < this.pdfleftboundary) || (right > this.pdfrightboundary)) {
return true;
}
// Check if it is out of bounds vertically.
- if ((top < this.pdfy) || (bottom > (this.pdfy + this.pdfheight))) {
+ if ((top < this.pdfy) || (bottom > (this.pdfy + this.pdfheight))) {
return true;
}
@@ -200,9 +200,9 @@ Y.extend(Rearrange, Y.Base, {
/**
* Perform an AJAX call and save the positions of the elements.
*
- * @param e
+ * @param {Event} e
*/
- save_positions : function(e) {
+ savepositions: function(e) {
// The parameters to send the AJAX call.
var params = {
tid: this.templateid,
@@ -222,10 +222,10 @@ Y.extend(Rearrange, Y.Base, {
var nodewidth = parseFloat(node.getComputedStyle('width'));
switch (refpoint) {
- case '1': // Top-center
+ case '1': // Top-center.
posx += nodewidth / 2;
break;
- case '2': // Top-right
+ case '2': // Top-right.
posx += nodewidth;
break;
}
@@ -246,18 +246,18 @@ Y.extend(Rearrange, Y.Base, {
data: params,
on: {
failure: function(tid, response) {
- this.ajax_failure(response);
+ this.ajaxfailure(response);
},
success: function() {
- var formNode = e.currentTarget.ancestor('form', true);
- var baseUrl = formNode.getAttribute('action');
- var pageinput = formNode.one('[name=pid]');
+ var formnode = e.currentTarget.ancestor('form', true);
+ var baseurl = formnode.getAttribute('action');
+ var pageinput = formnode.one('[name=pid]');
if (pageinput) {
var pageid = pageinput.get('value');
- window.location = baseUrl + '?pid=' + pageid;
+ window.location = baseurl + '?pid=' + pageid;
} else {
- var templateid = formNode.one('[name=tid]').get('value');
- window.location = baseUrl + '?tid=' + templateid;
+ var templateid = formnode.one('[name=tid]').get('value');
+ window.location = baseurl + '?tid=' + templateid;
}
}
},
@@ -270,10 +270,10 @@ Y.extend(Rearrange, Y.Base, {
/**
* Handles any failures during an AJAX call.
*
- * @param response
+ * @param {XMLHttpRequest} response
* @returns {M.core.exception}
*/
- ajax_failure : function(response) {
+ ajaxfailure: function(response) {
var e = {
name: response.status + ' ' + response.statusText,
message: response.responseText
@@ -282,10 +282,9 @@ Y.extend(Rearrange, Y.Base, {
}
});
-M.mod_customcert = M.mod_customcert || {};
-M.mod_customcert.rearrange = M.mod_customcert.rearrange || {};
-M.mod_customcert.rearrange.init = function(templateid, page, elements) {
+Y.namespace('M.mod_customcert.rearrange').init = function(templateid, page, elements) {
new Rearrange(templateid, page, elements);
};
+
}, '@VERSION@', {"requires": ["dd-delegate", "dd-drag"]});
diff --git a/yui/src/rearrange/js/rearrange.js b/yui/src/rearrange/js/rearrange.js
index 51af888..757c7c0 100644
--- a/yui/src/rearrange/js/rearrange.js
+++ b/yui/src/rearrange/js/rearrange.js
@@ -1,7 +1,7 @@
/**
* Rearrange elements in the custom certificate
*
- * @class M.mod_customcert.rearrange.rearrange
+ * @class Y.M.mod_customcert.rearrange
* @constructor
*/
var Rearrange = function() {
@@ -12,64 +12,64 @@ Y.extend(Rearrange, Y.Base, {
/**
* The template id.
*/
- templateid : 0,
+ templateid: 0,
/**
* The customcert page we are displaying.
*/
- page : [],
+ page: [],
/**
* The custom certificate elements to display.
*/
- elements : [],
+ elements: [],
/**
* Store the X coordinates of the top left of the pdf div.
*/
- pdfx : 0,
+ pdfx: 0,
/**
* Store the Y coordinates of the top left of the pdf div.
*/
- pdfy : 0,
+ pdfy: 0,
/**
* Store the width of the pdf div.
*/
- pdfwidth : 0,
+ pdfwidth: 0,
/**
* Store the height of the pdf div.
*/
- pdfheight : 0,
+ pdfheight: 0,
/**
* Store the location of the element before we move.
*/
- elementxy : 0,
+ elementxy: 0,
/**
* Store the left boundary of the pdf div.
*/
- pdfleftboundary : 0,
+ pdfleftboundary: 0,
/**
* Store the right boundary of the pdf div.
*/
- pdfrightboundary : 0,
+ pdfrightboundary: 0,
/**
* The number of pixels in a mm.
*/
- pixelsinmm : 3.779527559055, // '3.779528'.
+ pixelsinmm: 3.779527559055, // 3.779528.
/**
* Initialise.
*
- * @param params
+ * @param {Array} params
*/
- initializer : function(params) {
+ initializer: function(params) {
// Set the course module id.
this.templateid = params[0];
// Set the page.
@@ -94,14 +94,14 @@ Y.extend(Rearrange, Y.Base, {
this.pdfrightboundary -= parseInt(this.page.rightmargin * this.pixelsinmm, 10);
}
- this.set_positions();
- this.create_events();
+ this.setpositions();
+ this.createevents();
},
/**
* Sets the current position of the elements.
*/
- set_positions : function() {
+ setpositions: function() {
// Go through the elements and set their positions.
for (var key in this.elements) {
var element = this.elements[key];
@@ -115,10 +115,10 @@ Y.extend(Rearrange, Y.Base, {
}
switch (element.refpoint) {
- case '1': // Top-center
+ case '1': // Top-center.
posx -= nodewidth / 2;
break;
- case '2': // Top-right
+ case '2': // Top-right.
posx = posx - nodewidth + 2;
break;
}
@@ -131,15 +131,15 @@ Y.extend(Rearrange, Y.Base, {
/**
* Creates the JS events for changing element positions.
*/
- create_events : function() {
+ createevents: function() {
// Trigger a save event when save button is pushed.
Y.one('.savepositionsbtn [type=submit]').on('click', function(e) {
- this.save_positions(e);
+ this.savepositions(e);
}, this);
// Trigger a save event when apply button is pushed.
Y.one('.applypositionsbtn [type=submit]').on('click', function(e) {
- this.save_positions(e);
+ this.savepositions(e);
e.preventDefault();
}, this);
@@ -159,7 +159,7 @@ Y.extend(Rearrange, Y.Base, {
// if not, set it back to where it was.
del.on('drag:end', function() {
var node = del.get('currentNode');
- if (this.is_out_of_bounds(node)) {
+ if (this.isoutofbounds(node)) {
node.setXY(this.elementxy);
}
}, this);
@@ -168,10 +168,10 @@ Y.extend(Rearrange, Y.Base, {
/**
* Returns true if any part of the element is placed outside of the PDF div, false otherwise.
*
- * @param node
+ * @param {Node} node
* @returns {boolean}
*/
- is_out_of_bounds : function(node) {
+ isoutofbounds: function(node) {
// Get the width and height of the node.
var nodewidth = parseFloat(node.getComputedStyle('width'));
var nodeheight = parseFloat(node.getComputedStyle('height'));
@@ -183,12 +183,12 @@ Y.extend(Rearrange, Y.Base, {
var bottom = top + nodeheight;
// Check if it is out of bounds horizontally.
- if ((left < this.pdfleftboundary) || (right > this.pdfrightboundary)) {
+ if ((left < this.pdfleftboundary) || (right > this.pdfrightboundary)) {
return true;
}
// Check if it is out of bounds vertically.
- if ((top < this.pdfy) || (bottom > (this.pdfy + this.pdfheight))) {
+ if ((top < this.pdfy) || (bottom > (this.pdfy + this.pdfheight))) {
return true;
}
@@ -198,9 +198,9 @@ Y.extend(Rearrange, Y.Base, {
/**
* Perform an AJAX call and save the positions of the elements.
*
- * @param e
+ * @param {Event} e
*/
- save_positions : function(e) {
+ savepositions: function(e) {
// The parameters to send the AJAX call.
var params = {
tid: this.templateid,
@@ -220,10 +220,10 @@ Y.extend(Rearrange, Y.Base, {
var nodewidth = parseFloat(node.getComputedStyle('width'));
switch (refpoint) {
- case '1': // Top-center
+ case '1': // Top-center.
posx += nodewidth / 2;
break;
- case '2': // Top-right
+ case '2': // Top-right.
posx += nodewidth;
break;
}
@@ -244,18 +244,18 @@ Y.extend(Rearrange, Y.Base, {
data: params,
on: {
failure: function(tid, response) {
- this.ajax_failure(response);
+ this.ajaxfailure(response);
},
success: function() {
- var formNode = e.currentTarget.ancestor('form', true);
- var baseUrl = formNode.getAttribute('action');
- var pageinput = formNode.one('[name=pid]');
+ var formnode = e.currentTarget.ancestor('form', true);
+ var baseurl = formnode.getAttribute('action');
+ var pageinput = formnode.one('[name=pid]');
if (pageinput) {
var pageid = pageinput.get('value');
- window.location = baseUrl + '?pid=' + pageid;
+ window.location = baseurl + '?pid=' + pageid;
} else {
- var templateid = formNode.one('[name=tid]').get('value');
- window.location = baseUrl + '?tid=' + templateid;
+ var templateid = formnode.one('[name=tid]').get('value');
+ window.location = baseurl + '?tid=' + templateid;
}
}
},
@@ -268,10 +268,10 @@ Y.extend(Rearrange, Y.Base, {
/**
* Handles any failures during an AJAX call.
*
- * @param response
+ * @param {XMLHttpRequest} response
* @returns {M.core.exception}
*/
- ajax_failure : function(response) {
+ ajaxfailure: function(response) {
var e = {
name: response.status + ' ' + response.statusText,
message: response.responseText
@@ -280,8 +280,6 @@ Y.extend(Rearrange, Y.Base, {
}
});
-M.mod_customcert = M.mod_customcert || {};
-M.mod_customcert.rearrange = M.mod_customcert.rearrange || {};
-M.mod_customcert.rearrange.init = function(templateid, page, elements) {
+Y.namespace('M.mod_customcert.rearrange').init = function(templateid, page, elements) {
new Rearrange(templateid, page, elements);
-};
\ No newline at end of file
+};