Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
moodle
moodle
Commits
30c26421
Commit
30c26421
authored
Oct 10, 2015
by
David Mudrák
Browse files
MDL-49329 admin: Fix reported coding style warnings
parent
dbdd02c1
Changes
38
Hide whitespace changes
Inline
Side-by-side
admin/index.php
View file @
30c26421
...
...
@@ -213,7 +213,6 @@ if (!core_tables_exist()) {
$PAGE
->
set_heading
(
$strinstallation
);
$PAGE
->
set_cacheable
(
false
);
/** @var core_admin_renderer $output */
$output
=
$PAGE
->
get_renderer
(
'core'
,
'admin'
);
echo
$output
->
install_licence_page
();
die
();
...
...
@@ -228,7 +227,6 @@ if (!core_tables_exist()) {
$PAGE
->
set_heading
(
$strinstallation
.
' - Moodle '
.
$CFG
->
target_release
);
$PAGE
->
set_cacheable
(
false
);
/** @var core_admin_renderer $output */
$output
=
$PAGE
->
get_renderer
(
'core'
,
'admin'
);
echo
$output
->
install_environment_page
(
$maturity
,
$envstatus
,
$environment_results
,
$release
);
die
();
...
...
@@ -320,7 +318,6 @@ if (!$cache and $version > $CFG->version) { // upgrade
// We then purge the regular caches.
purge_all_caches
();
/** @var core_admin_renderer $output */
$output
=
$PAGE
->
get_renderer
(
'core'
,
'admin'
);
if
(
upgrade_stale_php_files_present
())
{
...
...
@@ -526,10 +523,7 @@ if (!$cache and moodle_needs_upgrading()) {
if
(
!
$PAGE
->
headerprinted
)
{
// means core upgrade or installation was not already done
/** @var core_plugin_manager $pluginman */
$pluginman
=
core_plugin_manager
::
instance
();
/** @var core_admin_renderer $output */
$output
=
$PAGE
->
get_renderer
(
'core'
,
'admin'
);
if
(
!
$confirmplugins
)
{
...
...
@@ -561,7 +555,8 @@ if (!$cache and moodle_needs_upgrading()) {
}
redirect
(
$PAGE
->
url
);
}
else
{
$continue
=
new
moodle_url
(
$PAGE
->
url
,
array
(
'abortinstallx'
=>
$abortinstallx
,
'confirmabortinstall'
=>
1
));
$continue
=
new
moodle_url
(
$PAGE
->
url
,
array
(
'abortinstallx'
=>
$abortinstallx
,
'confirmabortinstall'
=>
1
));
echo
$output
->
upgrade_confirm_abort_install_page
(
$abortables
,
$continue
);
die
();
}
...
...
@@ -671,7 +666,6 @@ if (!$cache and moodle_needs_upgrading()) {
// Make sure plugin dependencies are always checked.
$failed
=
array
();
if
(
!
$pluginman
->
all_plugins_ok
(
$version
,
$failed
))
{
/** @var core_admin_renderer $output */
$output
=
$PAGE
->
get_renderer
(
'core'
,
'admin'
);
echo
$output
->
unsatisfied_dependencies_page
(
$version
,
$failed
,
$PAGE
->
url
);
die
();
...
...
@@ -852,7 +846,6 @@ $cachewarnings = cache_helper::warnings();
admin_externalpage_setup
(
'adminnotifications'
);
/* @var core_admin_renderer $output */
$output
=
$PAGE
->
get_renderer
(
'core'
,
'admin'
);
echo
$output
->
admin_notifications_page
(
$maturity
,
$insecuredataroot
,
$errorsdisplayed
,
$cronoverdue
,
$dbproblems
,
...
...
admin/renderer.php
View file @
30c26421
...
...
@@ -1068,8 +1068,8 @@ class core_admin_renderer extends plugin_renderer_base {
$out
.
=
html_writer
::
div
(
html_writer
::
link
(
new
moodle_url
(
$this
->
page
->
url
,
array
(
'showallplugins'
=>
1
)),
get_string
(
'plugincheckall'
,
'core_plugin'
))
.
' '
.
html_writer
::
span
(
$sumtotal
,
'badge'
));
$out
.
=
$this
->
output
->
container_end
();
// .actions
$out
.
=
$this
->
output
->
container_end
();
// #plugins-check-info
$out
.
=
$this
->
output
->
container_end
();
//
End of
.actions
container.
$out
.
=
$this
->
output
->
container_end
();
//
End of
#plugins-check-info
container.
if
(
$sumdisplayed
>
0
or
$options
[
'full'
])
{
$out
.
=
html_writer
::
table
(
$table
);
...
...
@@ -1082,7 +1082,7 @@ class core_admin_renderer extends plugin_renderer_base {
* Display the continue / cancel widgets for the plugins management pages.
*
* @param null|moodle_url $continue URL for the continue button, should it be displayed
* @param moodle_url $cancel URL for the cancel link, defaults to the current page
* @param
null|
moodle_url $cancel URL for the cancel link, defaults to the current page
* @return string HTML
*/
public
function
plugins_management_confirm_buttons
(
moodle_url
$continue
=
null
,
moodle_url
$cancel
=
null
)
{
...
...
@@ -1159,7 +1159,7 @@ class core_admin_renderer extends plugin_renderer_base {
$out
.
=
$this
->
output
->
container_start
(
'plugins-check-dependencies-actions'
);
$out
.
=
' '
.
html_writer
::
link
(
new
moodle_url
(
'/admin/tool/installaddon/'
),
get_string
(
'dependencyuploadmissing'
,
'core_plugin'
));
$out
.
=
$this
->
output
->
container_end
();
// .plugins-check-dependencies-actions
$out
.
=
$this
->
output
->
container_end
();
//
End of
.plugins-check-dependencies-actions
container.
}
if
(
$available
)
{
...
...
@@ -1179,12 +1179,12 @@ class core_admin_renderer extends plugin_renderer_base {
$out
.
=
html_writer
::
div
(
html_writer
::
link
(
new
moodle_url
(
'/admin/tool/installaddon/'
),
get_string
(
'dependencyuploadmissing'
,
'core_plugin'
)),
'dependencyuploadmissing'
);
$out
.
=
$this
->
output
->
container_end
();
// .plugins-check-dependencies-actions
$out
.
=
$this
->
output
->
container_end
();
//
End of
.plugins-check-dependencies-actions
container.
$out
.
=
$this
->
available_missing_dependencies_list
(
$pluginman
,
$available
);
}
$out
.
=
$this
->
output
->
container_end
();
// .plugins-check-dependencies
$out
.
=
$this
->
output
->
container_end
();
//
End of
.plugins-check-dependencies
container.
return
$out
;
}
...
...
@@ -1268,7 +1268,7 @@ class core_admin_renderer extends plugin_renderer_base {
}
}
$info
.
=
$this
->
output
->
container_end
();
// .actions
$info
.
=
$this
->
output
->
container_end
();
//
End of
.actions
container.
$table
->
data
[]
=
array
(
html_writer
::
div
(
$plugin
->
name
,
'name'
)
.
' '
.
html_writer
::
div
(
$plugin
->
component
,
'component'
),
...
...
@@ -1487,7 +1487,7 @@ class core_admin_renderer extends plugin_renderer_base {
html_writer
::
div
(
$infoext
,
'info info-ext'
)
.
html_writer
::
div
(
$infoupdatable
,
'info info-updatable'
);
$out
.
=
html_writer
::
end_div
();
// #plugins-overview-panel
$out
.
=
html_writer
::
end_div
();
//
End of
#plugins-overview-panel
block.
return
$out
;
}
...
...
admin/tool/installaddon/tests/fixtures/testable_installer.php
View file @
30c26421
...
...
@@ -15,6 +15,8 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Provides {@link testable_tool_installaddon_installer} class.
*
* @package tool_installaddon
* @subpackage fixtures
* @category test
...
...
lib/classes/plugin_manager.php
View file @
30c26421
...
...
@@ -939,7 +939,7 @@ class core_plugin_manager {
*
* @param string $component
* @param int $version version number
*
$
param string $reason returned code of the reason why it is not
*
@
param string $reason returned code of the reason why it is not
* @return boolean
*/
public
function
is_remote_plugin_installable
(
$component
,
$version
,
&
$reason
=
null
)
{
...
...
@@ -1095,7 +1095,7 @@ class core_plugin_manager {
* @param string $zipfilepath full path to the saved ZIP file
* @param string $targetdir full path to the directory to extract the ZIP file to
* @param string $rootdir explicitly rename the root directory of the ZIP into this non-empty value
* @
param
array list of extracted files as returned by {@link zip_packer::extract_to_pathname()}
* @
return
array list of extracted files as returned by {@link zip_packer::extract_to_pathname()}
*/
public
function
unzip_plugin_file
(
$zipfilepath
,
$targetdir
,
$rootdir
=
''
)
{
return
$this
->
get_code_manager
()
->
unzip_plugin_file
(
$zipfilepath
,
$targetdir
,
$rootdir
);
...
...
lib/classes/update/code_manager.php
View file @
30c26421
...
...
@@ -155,7 +155,7 @@ class code_manager {
* @param string $zipfilepath full path to the saved ZIP file
* @param string $targetdir full path to the directory to extract the ZIP file to
* @param string $rootdir explicitly rename the root directory of the ZIP into this non-empty value
* @
param
array list of extracted files as returned by {@link zip_packer::extract_to_pathname()}
* @
return
array list of extracted files as returned by {@link zip_packer::extract_to_pathname()}
*/
public
function
unzip_plugin_file
(
$zipfilepath
,
$targetdir
,
$rootdir
=
''
)
{
...
...
lib/classes/update/validator.php
View file @
30c26421
...
...
@@ -36,9 +36,9 @@ use coding_exception;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
if
(
!
defined
(
'T_ML_COMMENT'
))
{
define
(
'T_ML_COMMENT'
,
T_COMMENT
);
define
(
'T_ML_COMMENT'
,
T_COMMENT
);
}
else
{
define
(
'T_DOC_COMMENT'
,
T_ML_COMMENT
);
define
(
'T_DOC_COMMENT'
,
T_ML_COMMENT
);
}
/**
...
...
@@ -263,6 +263,8 @@ class validator {
// End of external API.
/**
* No public constructor, use {@link self::instance()} instead.
*
* @param string $zipcontentpath full path to the extracted ZIP contents
* @param array $zipcontentfiles (string)filerelpath => (bool|string)true or error
*/
...
...
@@ -274,12 +276,14 @@ class validator {
// Validation methods.
/**
* @return bool false if files in the ZIP do not have required layout
* Returns false if files in the ZIP do not have required layout.
*
* @return bool
*/
protected
function
validate_files_layout
()
{
if
(
!
is_array
(
$this
->
extractfiles
)
or
count
(
$this
->
extractfiles
)
<
4
)
{
// We need the English language pack with the name of the plugin at least
// We need the English language pack with the name of the plugin at least
.
$this
->
add_message
(
self
::
ERROR
,
'filesnumber'
);
return
false
;
}
...
...
@@ -319,7 +323,9 @@ class validator {
}
/**
* @return bool false if the version.php file does not declare required information
* Returns false if the version.php file does not declare required information.
*
* @return bool
*/
protected
function
validate_version_php
()
{
...
...
@@ -406,7 +412,9 @@ class validator {
}
/**
* @return bool false if the English language pack is not provided correctly
* Returns false if the English language pack is not provided correctly.
*
* @return bool
*/
protected
function
validate_language_pack
()
{
...
...
@@ -456,7 +464,9 @@ class validator {
}
/**
* @return bool false of the given add-on can't be installed into its location
* Returns false of the given add-on can't be installed into its location.
*
* @return bool
*/
public
function
validate_target_location
()
{
...
...
@@ -510,7 +520,7 @@ class validator {
/**
* Get as much information from existing version.php as possible
*
* @param string full path to the version.php file
* @param string
$fullpath
full path to the version.php file
* @return array of found meta-info declarations
*/
protected
function
parse_version_php
(
$fullpath
)
{
...
...
@@ -576,30 +586,30 @@ class validator {
list
(
$id
,
$text
)
=
$token
;
}
switch
(
$id
)
{
case
T_WHITESPACE
:
case
T_COMMENT
:
case
T_ML_COMMENT
:
case
T_DOC_COMMENT
:
// Ignore whitespaces, inline comments, multiline comments and docblocks.
break
;
case
T_OPEN_TAG
:
// Start processing.
$doprocess
=
true
;
break
;
case
T_CLOSE_TAG
:
// Stop processing.
$doprocess
=
false
;
break
;
default
:
// Anything else is within PHP tags, return it as is.
if
(
$doprocess
)
{
$output
.
=
$text
;
if
(
$text
===
'function'
)
{
// Explicitly keep the whitespace that would be ignored.
$output
.
=
' '
;
case
T_WHITESPACE
:
case
T_COMMENT
:
case
T_ML_COMMENT
:
case
T_DOC_COMMENT
:
// Ignore whitespaces, inline comments, multiline comments and docblocks.
break
;
case
T_OPEN_TAG
:
// Start processing.
$doprocess
=
true
;
break
;
case
T_CLOSE_TAG
:
// Stop processing.
$doprocess
=
false
;
break
;
default
:
// Anything else is within PHP tags, return it as is.
if
(
$doprocess
)
{
$output
.
=
$text
;
if
(
$text
===
'function'
)
{
// Explicitly keep the whitespace that would be ignored.
$output
.
=
' '
;
}
}
}
break
;
break
;
}
}
...
...
@@ -607,7 +617,7 @@ class validator {
}
/**
* Returns the full path to the root directory of the given plugin type
* Returns the full path to the root directory of the given plugin type
.
*
* @param string $plugintype
* @return string|null
...
...
@@ -617,6 +627,8 @@ class validator {
}
/**
* Returns plugin manager to use.
*
* @return core_plugin_manager
*/
protected
function
get_plugin_manager
()
{
...
...
lib/tests/fixtures/testable_plugin_manager.php
View file @
30c26421
...
...
@@ -43,6 +43,10 @@ class testable_core_plugin_manager extends core_plugin_manager {
*
* Do not forget to call our reset_caches() after using this method to force a new
* singleton instance.
*
* @param string $type plugin type
* @param string $name plugin name
* @param \core\plugininfo\base $plugininfo plugin info class
*/
public
function
inject_testable_plugininfo
(
$type
,
$name
,
\
core\plugininfo\base
$plugininfo
)
{
...
...
lib/tests/fixtures/testable_update_checker.php
View file @
30c26421
...
...
@@ -14,8 +14,6 @@
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
namespace
core\update
;
/**
* Provides \core\update\testable_checker class.
*
...
...
@@ -25,11 +23,15 @@ namespace core\update;
* @copyright 2012, 2015 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
namespace
core\update
;
defined
(
'MOODLE_INTERNAL'
)
||
die
();
/**
* Modified version of {@link \core\update\checker} suitable for testing.
*
* @copyright 2012, 2015 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
testable_checker
extends
checker
{
...
...
@@ -166,8 +168,12 @@ class testable_checker extends checker {
}
}
/**
* Exception used to detect {@link checker::cron_execute()} calls.
*
* @copyright 2012, 2015 David Mudrak <david@moodle.com>
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class
testable_checker_cron_executed
extends
\
Exception
{
}
lib/tests/fixtures/testable_update_code_manager.php
View file @
30c26421
...
...
@@ -15,6 +15,8 @@
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Provides {@link testable_code_manager} class.
*
* @package core_plugin
* @category test
* @copyright 2015 David Mudrak <david@moodle.com>
...
...
@@ -44,6 +46,10 @@ class testable_code_manager extends code_manager {
*
* It simply creates a new file in the given location, the contents of
* which is the URL itself.
*
* @param string $url URL to the file
* @param string $tofile full path to where to store the downloaded file
* @return bool
*/
protected
function
download_file_content
(
$url
,
$tofile
)
{
$this
->
downloadscounter
++
;
...
...
lib/tests/fixtures/update_validator/github/moodle-repository_mahara-master/lang/en/repository_mahara.php
View file @
30c26421
<?php
// This file is empty.
lib/tests/fixtures/update_validator/github/moodle-repository_mahara-master/version.php
View file @
30c26421
<?php
$plugin
->
component
=
'repository_mahara'
;
$plugin
->
version
=
2014010100
;
lib/tests/fixtures/update_validator/installed/greenbar/index.php
View file @
30c26421
<?php
echo
'One, my little hobbit, never installs malicisous add-ons'
;
lib/tests/fixtures/update_validator/installed/greenbar/lang/en/local_greenbar.php
View file @
30c26421
<?php
$string
[
'pluginname'
]
=
'Foo bar!'
;
lib/tests/fixtures/update_validator/installed/greenbar/version.php
View file @
30c26421
<?php
$plugin
->
version
=
2013031900
;
$plugin
->
component
=
'local_greenbar'
;
lib/tests/fixtures/update_validator/multidir/one/version.php
View file @
30c26421
<?php
$plugin
->
component
=
'local_one'
;
lib/tests/fixtures/update_validator/nocomponent/baz/lang/en/auth_baz.php
View file @
30c26421
<?php
$string
[
'pluginname'
]
=
'This is a plugin with $plugin->component missing in its version.php'
;
lib/tests/fixtures/update_validator/nocomponent/baz/version.php
View file @
30c26421
<?php
$plugin
->
version
=
2015080600
;
$plugin
->
release
=
'B.A.Z. Auth fake plugin'
;
//$plugin->component is missing here so the validation must fail.
//
$plugin->component is missing here so the validation must fail.
lib/tests/fixtures/update_validator/nolang/bah/index.php
View file @
30c26421
<?php
// This file is empty.
lib/tests/fixtures/update_validator/nolang/bah/lang/en/bah.php
View file @
30c26421
<?php
// This file is empty.
lib/tests/fixtures/update_validator/nolang/bah/lang/en/bleh.php
View file @
30c26421
<?php
$string
[
'pluginnname'
]
=
'Root directory mismatch'
;
Prev
1
2
Next
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment