Skip to content

Commit

Permalink
MDL-55071 theme/output: PHPCS fixes for new theme branch
Browse files Browse the repository at this point in the history
Part of MDL-55071
  • Loading branch information
Damyon Wiese authored and danpoltawski committed Sep 23, 2016
1 parent e8272e7 commit e584e6a
Show file tree
Hide file tree
Showing 30 changed files with 112 additions and 80 deletions.
2 changes: 1 addition & 1 deletion admin/settings/appearance.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
// "themesettings" settingpage
$temp = new admin_settingpage('themesettings', new lang_string('themesettings', 'admin'));
$setting = new admin_setting_configtext('themelist', new lang_string('themelist', 'admin'),
new lang_string('configthemelist','admin'), '', PARAM_NOTAGS);
new lang_string('configthemelist', 'admin'), '', PARAM_NOTAGS);
$setting->set_force_ltr(true);
$temp->add($setting);
$setting = new admin_setting_configcheckbox('themedesignermode', new lang_string('themedesignermode', 'admin'), new lang_string('configthemedesignermode', 'admin'), 0);
Expand Down
2 changes: 1 addition & 1 deletion auth/classes/output/login.php
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public function __construct(array $authsequence, $username = '') {

// Identity providers.
$identityproviders = [];
foreach($authsequence as $authname) {
foreach ($authsequence as $authname) {
$authplugin = get_auth_plugin($authname);
$identityproviders = array_merge($identityproviders, $authplugin->loginpage_idp_list($SESSION->wantsurl));
}
Expand Down
2 changes: 1 addition & 1 deletion course/classes/output/modchooser.php
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public function __construct(stdClass $course, array $modules) {
$sections = [];
$context = context_course::instance($course->id);

// Activities
// Activities.
$activities = array_filter($modules, function($mod) {
return ($mod->archetype !== MOD_ARCHETYPE_RESOURCE && $mod->archetype !== MOD_ARCHETYPE_SYSTEM);
});
Expand Down
2 changes: 1 addition & 1 deletion grade/edit/tree/lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ static function get_weight_input($item) {
$tpldata = [
'id' => $item->id,
'itemname' => $itemname,
'value' => grade_edit_tree::format_number($item->aggregationcoef2 * 100.0),
'value' => self::format_number($item->aggregationcoef2 * 100.0),
'checked' => $item->weightoverride,
'disabled' => !$item->weightoverride
];
Expand Down
6 changes: 3 additions & 3 deletions lib/adminlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -4411,7 +4411,7 @@ class admin_settings_country_select extends admin_setting_configselect {
protected $includeall;
public function __construct($name, $visiblename, $description, $defaultsetting, $includeall=false) {
$this->includeall = $includeall;
parent::__construct($name, $visiblename, $description, $defaultsetting, NULL);
parent::__construct($name, $visiblename, $description, $defaultsetting, null);
}

/**
Expand Down Expand Up @@ -4691,7 +4691,7 @@ class admin_setting_question_behaviour extends admin_setting_configselect {
* @param string $default default.
*/
public function __construct($name, $visiblename, $description, $default) {
parent::__construct($name, $visiblename, $description, $default, NULL);
parent::__construct($name, $visiblename, $description, $default, null);
}

/**
Expand Down Expand Up @@ -9086,7 +9086,7 @@ protected function validate($data) {
public function output_html($data, $query = '') {
global $PAGE, $OUTPUT;

$icon = new pix_icon('i/loading', get_string('loading', 'admin'), 'moodle', ['class'=>'loadingicon']);
$icon = new pix_icon('i/loading', get_string('loading', 'admin'), 'moodle', ['class' => 'loadingicon']);
$context = (object) [
'id' => $this->get_id(),
'name' => $this->get_full_name(),
Expand Down
34 changes: 17 additions & 17 deletions lib/form/group.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class MoodleQuickForm_group extends HTML_QuickForm_group implements templatable
/** @var MoodleQuickForm */
protected $_mform = null;

var $_renderedfromtemplate = false;
protected $_renderedfromtemplate = false;

/**
* constructor
Expand Down Expand Up @@ -198,28 +198,28 @@ public function export_for_template(renderer_base $output) {
return $context;
}

/**
* Accepts a renderer
*
* @param object An HTML_QuickForm_Renderer object
* @param bool Whether a group is required
* @param string An error message associated with a group
* @access public
* @return void
*/
function accept(&$renderer, $required = false, $error = null) {
/**
* Accepts a renderer
*
* @param object An HTML_QuickForm_Renderer object
* @param bool Whether a group is required
* @param string An error message associated with a group
* @access public
* @return void
*/
public function accept(&$renderer, $required = false, $error = null) {
$this->_createElementsIfNotExist();
$renderer->startGroup($this, $required, $error);
if (!$this->_renderedfromtemplate) {
// Backwards compatible path - only do this if we didn't render the sub-elements already.
$name = $this->getName();
foreach (array_keys($this->_elements) as $key) {
$element =& $this->_elements[$key];

$elementname = '';
if ($this->_appendName) {
$elementName = $element->getName();
if (isset($elementName)) {
$element->setName($name . '['. (strlen($elementName)? $elementName: $key) .']');
$elementname = $element->getName();
if (isset($elementname)) {
$element->setName($name . '['. (strlen($elementname) ? $elementname : $key) .']');
} else {
$element->setName($name);
}
Expand All @@ -229,9 +229,9 @@ function accept(&$renderer, $required = false, $error = null) {

$element->accept($renderer, $required);

// restore the element's name
// Restore the element's name.
if ($this->_appendName) {
$element->setName($elementName);
$element->setName($elementname);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion lib/form/text.php
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ function getFrozenHtml()
*
* @return string
*/
function toHtml() {
public function toHtml() {

// Add the class at the last minute.
if ($this->get_force_ltr()) {
Expand Down
11 changes: 5 additions & 6 deletions lib/form/url.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,6 @@ function setHiddenLabel($hiddenLabel){
*/
function toHtml(){


$id = $this->_attributes['id'];
$elname = $this->_attributes['name'];

Expand All @@ -121,31 +120,31 @@ function toHtml(){
return $str;
}

// print out file picker
// Print out file picker.
$str .= $this->getFilePickerHTML();

return $str;
}

function getFilePickerHTML() {
public function getFilePickerHTML() {
global $PAGE, $OUTPUT;

$str = '';
$client_id = uniqid();
$clientid = uniqid();

$args = new stdClass();
$args->accepted_types = '*';
$args->return_types = FILE_EXTERNAL;
$args->context = $PAGE->context;
$args->client_id = $client_id;
$args->client_id = $clientid;
$args->env = 'url';
$fp = new file_picker($args);
$options = $fp->options;

if (count($options->repositories) > 0) {
$straddlink = get_string('choosealink', 'repository');
$str .= <<<EOD
<button id="filepicker-button-js-{$client_id}" class="visibleifjs btn btn-secondary">
<button id="filepicker-button-js-{$clientid}" class="visibleifjs btn btn-secondary">
$straddlink
</button>
EOD;
Expand Down
18 changes: 9 additions & 9 deletions lib/formslib.php
Original file line number Diff line number Diff line change
Expand Up @@ -2694,17 +2694,17 @@ public function __construct() {
// switch next two lines for ol li containers for form items.
// $this->_elementTemplates=array('default'=>"\n\t\t".'<li class="fitem"><label>{label}{help}<!-- BEGIN required -->{req}<!-- END required --></label><div class="qfelement<!-- BEGIN error --> error<!-- END error --> {typeclass}"><!-- BEGIN error --><span class="error">{error}</span><br /><!-- END error -->{element}</div></li>');
$this->_elementTemplates = array(
'default'=>"\n\t\t".'<div id="{id}" class="fitem {advanced}<!-- BEGIN required --> required<!-- END required --> fitem_{typeclass} {emptylabel} {class}" {aria-live}><div class="fitemtitle"><label>{label}<!-- BEGIN required -->{req}<!-- END required -->{advancedimg} </label>{help}</div><div class="felement {typeclass}<!-- BEGIN error --> error<!-- END error -->" data-fieldtype="{type}"><!-- BEGIN error --><span class="error" tabindex="0">{error}</span><br /><!-- END error -->{element}</div></div>',
'default' => "\n\t\t".'<div id="{id}" class="fitem {advanced}<!-- BEGIN required --> required<!-- END required --> fitem_{typeclass} {emptylabel} {class}" {aria-live}><div class="fitemtitle"><label>{label}<!-- BEGIN required -->{req}<!-- END required -->{advancedimg} </label>{help}</div><div class="felement {typeclass}<!-- BEGIN error --> error<!-- END error -->" data-fieldtype="{type}"><!-- BEGIN error --><span class="error" tabindex="0">{error}</span><br /><!-- END error -->{element}</div></div>',

'actionbuttons'=>"\n\t\t".'<div id="{id}" class="fitem fitem_actionbuttons fitem_{typeclass} {class}"><div class="felement {typeclass}" data-fieldtype="{type}">{element}</div></div>',
'actionbuttons' => "\n\t\t".'<div id="{id}" class="fitem fitem_actionbuttons fitem_{typeclass} {class}"><div class="felement {typeclass}" data-fieldtype="{type}">{element}</div></div>',

'fieldset'=>"\n\t\t".'<div id="{id}" class="fitem {advanced} {class}<!-- BEGIN required --> required<!-- END required --> fitem_{typeclass} {emptylabel}"><div class="fitemtitle"><div class="fgrouplabel"><label>{label}<!-- BEGIN required -->{req}<!-- END required -->{advancedimg} </label>{help}</div></div><fieldset class="felement {typeclass}<!-- BEGIN error --> error<!-- END error -->" data-fieldtype="{type}"><!-- BEGIN error --><span class="error" tabindex="0">{error}</span><br /><!-- END error -->{element}</fieldset></div>',
'fieldset' => "\n\t\t".'<div id="{id}" class="fitem {advanced} {class}<!-- BEGIN required --> required<!-- END required --> fitem_{typeclass} {emptylabel}"><div class="fitemtitle"><div class="fgrouplabel"><label>{label}<!-- BEGIN required -->{req}<!-- END required -->{advancedimg} </label>{help}</div></div><fieldset class="felement {typeclass}<!-- BEGIN error --> error<!-- END error -->" data-fieldtype="{type}"><!-- BEGIN error --><span class="error" tabindex="0">{error}</span><br /><!-- END error -->{element}</fieldset></div>',

'static'=>"\n\t\t".'<div id="{id}" class="fitem {advanced} {emptylabel} {class}"><div class="fitemtitle"><div class="fstaticlabel">{label}<!-- BEGIN required -->{req}<!-- END required -->{advancedimg} {help}</div></div><div class="felement fstatic <!-- BEGIN error --> error<!-- END error -->" data-fieldtype="static"><!-- BEGIN error --><span class="error" tabindex="0">{error}</span><br /><!-- END error -->{element}</div></div>',
'static' => "\n\t\t".'<div id="{id}" class="fitem {advanced} {emptylabel} {class}"><div class="fitemtitle"><div class="fstaticlabel">{label}<!-- BEGIN required -->{req}<!-- END required -->{advancedimg} {help}</div></div><div class="felement fstatic <!-- BEGIN error --> error<!-- END error -->" data-fieldtype="static"><!-- BEGIN error --><span class="error" tabindex="0">{error}</span><br /><!-- END error -->{element}</div></div>',

'warning'=>"\n\t\t".'<div id="{id}" class="fitem {advanced} {emptylabel} {class}">{element}</div>',
'warning' => "\n\t\t".'<div id="{id}" class="fitem {advanced} {emptylabel} {class}">{element}</div>',

'nodisplay'=>'');
'nodisplay' => '');

parent::__construct();
}
Expand Down Expand Up @@ -2871,19 +2871,19 @@ function renderElement(&$element, $required, $error){
if (($this->_inGroup) and !empty($this->_groupElementTemplate)) {
// So it gets substitutions for *each* element.
$html = $this->_groupElementTemplate;
} else if (method_exists($element, 'getElementTemplateType')){
} else if (method_exists($element, 'getElementTemplateType')) {
$html = $this->_elementTemplates[$element->getElementTemplateType()];
} else {
$html = $this->_elementTemplates['default'];
}
if (isset($this->_advancedElements[$element->getName()])){
if (isset($this->_advancedElements[$element->getName()])) {
$html = str_replace(' {advanced}', ' advanced', $html);
$html = str_replace(' {aria-live}', ' aria-live="polite"', $html);
} else {
$html = str_replace(' {advanced}', '', $html);
$html = str_replace(' {aria-live}', '', $html);
}
if (isset($this->_advancedElements[$element->getName()]) || $element->getName() == 'mform_showadvanced'){
if (isset($this->_advancedElements[$element->getName()]) || $element->getName() == 'mform_showadvanced') {
$html = str_replace('{advancedimg}', $this->_advancedHTML, $html);
} else {
$html = str_replace('{advancedimg}', '', $html);
Expand Down
2 changes: 1 addition & 1 deletion lib/outputlib.php
Original file line number Diff line number Diff line change
Expand Up @@ -780,7 +780,7 @@ public function css_urls(moodle_page $page) {
}
$url->set_slashargument($slashargs, 'noparam', true);
} else {
$params = array('theme' => $this->name,'rev' => $rev, 'type' => $filename);
$params = array('theme' => $this->name, 'rev' => $rev, 'type' => $filename);
if (!$svg) {
// We add an SVG param so that we know not to serve SVG images.
// We do this because all modern browsers support SVG and this param will one day be removed.
Expand Down
5 changes: 4 additions & 1 deletion lib/tests/behat/behat_action_menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ public function i_choose_in_the_open_action_menu($linkstring) {
throw new DriverException('Action menu steps are not available with Javascript disabled');
}
// Gets the node based on the requested selector type and locator.
$node = $this->get_node_in_container("link", $linkstring, "css_element", ".moodle-actionmenu [role=menu][aria-hidden=false]");
$node = $this->get_node_in_container("link",
$linkstring,
"css_element",
".moodle-actionmenu [role=menu][aria-hidden=false]");
$this->ensure_node_is_visible($node);
$node->click();
}
Expand Down
3 changes: 2 additions & 1 deletion lib/tests/behat/behat_hooks.php
Original file line number Diff line number Diff line change
Expand Up @@ -613,4 +613,5 @@ protected static function is_first_scenario() {
* @copyright 2016 Rajesh Taneja <[email protected]>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class behat_stop_exception extends \Exception{}
class behat_stop_exception extends \Exception {
}
2 changes: 1 addition & 1 deletion lib/tests/outputrequirementslib_test.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public function test_jquery_plugin() {
$this->assertTrue($requirements->jquery_plugin('ui'));

// Get the code containing the required jquery plugins.
$renderer = $PAGE->get_renderer('core', NULL, RENDERER_TARGET_MAINTENANCE);
$renderer = $PAGE->get_renderer('core', null, RENDERER_TARGET_MAINTENANCE);
$requirecode = $requirements->get_top_of_body_code($renderer);
// Make sure that the generated code does not contain backslashes.
$this->assertFalse(strpos($requirecode, '\\'), "Output contains backslashes: " . $requirecode);
Expand Down
4 changes: 3 additions & 1 deletion mod/lesson/locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -536,7 +536,9 @@ function lesson_menu_block_contents($cmid, $lesson) {
return null;
}

$content = '<a href="#maincontent" class="accesshide">'.get_string('skip', 'lesson')."</a>\n<div class=\"menuwrapper\">\n<ul>\n";
$content = '<a href="#maincontent" class="accesshide">' .
get_string('skip', 'lesson') .
"</a>\n<div class=\"menuwrapper\">\n<ul>\n";

while ($pageid != 0) {
$page = $pages[$pageid];
Expand Down
14 changes: 7 additions & 7 deletions question/classes/output/qbank_chooser.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,17 +53,17 @@ class qbank_chooser extends \core\output\chooser {
public function __construct($real, $fake, $course, $hiddenparams, $context) {
$sections = [];
$sections[] = new chooser_section('questions', new lang_string('questions', 'question'),
array_map(function($qtype) use ($context) {
return new qbank_chooser_item($qtype, $context);
}, $real));
array_map(function($qtype) use ($context) {
return new qbank_chooser_item($qtype, $context);
}, $real));

$sections[] = new chooser_section('other', new lang_string('other'),
array_map(function($qtype) use ($context) {
return new qbank_chooser_item($qtype, $context);
}, $fake));
array_map(function($qtype) use ($context) {
return new qbank_chooser_item($qtype, $context);
}, $fake));

parent::__construct(new moodle_url('/question/question.php'),
new lang_string('chooseqtypetoadd', 'question'), $sections, 'qtype');
new lang_string('chooseqtypetoadd', 'question'), $sections, 'qtype');

$this->set_instructions(new lang_string('selectaqtypefordescription', 'question'));

Expand Down
5 changes: 4 additions & 1 deletion theme/boost/classes/autoprefixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,10 @@ protected function manipulateRuleValues(array $rules) {
$newrule->setValue('-webkit-sticky');
$finalrules[] = $newrule;

} else if ($property === 'background-image' && $value instanceof CSSFUnction && $value->getName() === 'linear-gradient') {
} else if ($property === 'background-image' &&
$value instanceof CSSFunction &&
$value->getName() === 'linear-gradient') {

foreach (['-webkit-', '-o-'] as $prefix) {
$newfunction = clone $value;
$newfunction->setName($prefix . $value->getName());
Expand Down
2 changes: 1 addition & 1 deletion theme/boost/classes/output/core/course_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ class course_renderer extends \core_course_renderer {
* @param string $format display format - 'plain' (default), 'short' or 'navbar'
* @return string
*/
function course_search_form($value = '', $format = 'plain') {
public function course_search_form($value = '', $format = 'plain') {
static $count = 0;
$formid = 'coursesearch';
if ((++$count) > 1) {
Expand Down
7 changes: 4 additions & 3 deletions theme/boost/classes/output/core/files_renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@

use plugin_renderer_base;

require_once($CFG->dirroot . '/files/renderer.php');

defined('MOODLE_INTERNAL') || die();

require_once($CFG->dirroot . '/files/renderer.php');

/**
* Rendering of files viewer related widgets.
* @package theme_boost
Expand Down Expand Up @@ -120,7 +120,8 @@ protected function fp_js_template_selectlayout() {
}

/**
* FilePicker JS template for popup dialogue window asking for action when file with the same name already exists (multiple-file version).
* FilePicker JS template for popup dialogue window asking for action when file with the same name already exists
* (multiple-file version).
*
* @return string
*/
Expand Down
9 changes: 4 additions & 5 deletions theme/boost/cli/import-bootswatch.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@


// Now get cli options.
list($options, $unrecognized) = cli_get_params(array('help'=>false),
array('h'=>'help', 'v'=>'variables', 'b'=>'bootswatch', 'p'=>'preset'));
list($options, $unrecognized) = cli_get_params(array('help' => false),
array('h' => 'help', 'v' => 'variables', 'b' => 'bootswatch', 'p' => 'preset'));

if ($unrecognized) {
$unrecognized = implode("\n ", $unrecognized);
Expand All @@ -49,8 +49,7 @@
}

if ($options['help']) {
$help =
"Convert a Bootswatch file from Bootstrap 3 to a Moodle preset file compatible with bootstrap 4.
$help = "Convert a Bootswatch file from Bootstrap 3 to a Moodle preset file compatible with bootstrap 4.
This scripts takes the scss files from a Bootstrap 3 Bootswatch and produces a Moodle compatible preset file.
Expand Down Expand Up @@ -140,7 +139,7 @@ function str_replace_one($needle, $replace, $haystack) {
$nextline = '//** Global textual link color.';
$workingvariables = str_replace_one($nextline, "$newrule\n\n$nextline", $workingvariables);

// Add a font-size-root the same as font-size-base;
// Add a font-size-root the same as font-size-base.
$newrule = '$font-size-root: $font-size-base;';
$nextline = '$font-size-large';
$workingvariables = str_replace_one($nextline, "$newrule\n\n$nextline", $workingvariables);
Expand Down
2 changes: 0 additions & 2 deletions theme/boost/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,6 @@
)
];

// $THEME->javascripts = array();
// $THEME->javascripts_footer = array();
$THEME->parents = [];
$THEME->enable_dock = false;
$THEME->csstreepostprocessor = 'theme_boost_css_tree_post_processor';
Expand Down
Loading

0 comments on commit e584e6a

Please sign in to comment.