$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();
$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();
// 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()) {
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) {
}
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();
}
// 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();
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,
$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);
* 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) {
$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) {
$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;
}
}
}
- $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'),
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;
}
// 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
*
* @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) {
* @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);
* @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 = '') {
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);
}
/**
// 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
*/
// 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;
}
}
/**
- * @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() {
}
/**
- * @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() {
}
/**
- * @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() {
/**
* 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) {
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;
}
}
}
/**
- * 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
}
/**
+ * Returns plugin manager to use.
+ *
* @return core_plugin_manager
*/
protected function get_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) {
// 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.
*
* @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 {
}
}
+
/**
* 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 {
}
// 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>
*
* 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++;
<?php
+// This file is empty.
<?php
-
$plugin->component = 'repository_mahara';
$plugin->version = 2014010100;
<?php
-
echo 'One, my little hobbit, never installs malicisous add-ons';
<?php
-
$string['pluginname'] = 'Foo bar!';
<?php
-
$plugin->version = 2013031900;
$plugin->component = 'local_greenbar';
<?php
-
$plugin->component = 'local_one';
<?php
-
$string['pluginname'] = 'This is a plugin with $plugin->component missing in its version.php';
<?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.
<?php
+// This file is empty.
<?php
+// This file is empty.
<?php
-
$string['pluginnname'] = 'Root directory mismatch';
<?php
-
-
+// This file is empty.
<?php
-
$plugin->version = 2014122455;
$plugin->component = 'mod_bah';
<?php
-
echo 'Do not use hardcoded strings, provide the language pack';
<?php
-
$string['pluginversion'] = 'Activity module with no version.php';
<?php
-
$string['pluginversion'] = 'A theme with no version.php';
<?php
-
-// index.php
+// This file is empty.
<?php
-
$string['pluginname'] = 'Foo!';
<?php // $Id$
-
// I don't miss CVS, do you?
<?php
-
echo 'One, my little hobbit, never installs malicisous add-ons';
<?php
-
$string['pluginname'] = 'Foo bar!';
<?php
-
$plugin->version = 2013031900;
$plugin->component = 'local_foobar';
$plugin->requires = 2013031200;
$plugin->maturity = MATURITY_ALPHA;
-//$plugin->release = 'And this is commented';
+// $plugin->release = 'And this is commented';
<?php
-
$string['modulename'] = 'Legacy activity module with $module in version.php';
<?php
-
// Support for the $module has been dropped in Moodle 3.0.
$module->version = 2013031900;
<?php
-
$string['pluginname'] = 'This would be valid filename for module, not a block';
<?php
-
$plugin->version = 2014122455;
$plugin->component = 'block_bah';
}
/**
+ * The combination of ANY_VERSION + $exactmatch is illegal.
+ *
* @expectedException moodle_exception
*/
public function test_get_remote_plugin_info_exception() {
$pluginman = testable_core_plugin_manager::instance();
- // The combination of ANY_VERSION + $exactmatch is illegal.
$pluginman->get_remote_plugin_info('any_thing', ANY_VERSION, true);
}
$this->assertInstanceOf('\core\update\remote_info', $client->validate_pluginfo_format($data));
$this->assertEquals(json_encode($data), json_encode($client->validate_pluginfo_format($data)));
- // All properties must be present;
+ // All properties must be present.
unset($data->version);
$this->assertFalse($client->validate_pluginfo_format($data));
$this->assertTrue($this->has_message($validator->get_messages(), $validator::ERROR,
'filenotexists', array('file' => 'null/')));
- // Missing expected file
+ // Missing expected file.
$validator = testable_core_update_validator::instance($fixtures.'/plugindir', array(
'foobar/' => true,
'foobar/version.php' => true,
$this->assertTrue($this->has_message($validator->get_messages(), $validator::ERROR,
'filenotexists', array('file' => 'foobar/NOTEXISTS.txt')));
- // Errors during ZIP extraction
+ // Errors during ZIP extraction.
$validator = testable_core_update_validator::instance($fixtures.'/multidir', array(
'one/' => true,
'one/version.php' => 'Can not write target file',
$this->assertTrue($this->has_message($validator->get_messages(), $validator::ERROR, 'filestatus',
array('file' => 'one/version.php', 'status' => 'Can not write target file')));
- // Insufficient number of extracted files
+ // Insufficient number of extracted files.
$validator = testable_core_update_validator::instance($fixtures.'/emptydir', array(
'emptydir/' => true,
'emptydir/README.txt' => true));
$this->assertFalse($validator->execute());
$this->assertTrue($this->has_message($validator->get_messages(), $validator::ERROR, 'filesnumber'));
- // No wrapping directory
+ // No wrapping directory.
$validator = testable_core_update_validator::instance($fixtures.'/nowrapdir', array(
'version.php' => true,
'index.php' => true,
$this->assertFalse($validator->execute());
$this->assertTrue($this->has_message($validator->get_messages(), $validator::ERROR, 'onedir'));
- // Multiple directories
+ // Multiple directories.
$validator = testable_core_update_validator::instance($fixtures.'/multidir', array(
'one/' => true,
'one/version.php' => true,
$this->assertFalse($validator->execute());
$this->assertTrue($this->has_message($validator->get_messages(), $validator::ERROR, 'onedir'));
- // Invalid root directory name
+ // Invalid root directory name.
$validator = testable_core_update_validator::instance($fixtures.'/github', array(
'moodle-repository_mahara-master/' => true,
'moodle-repository_mahara-master/lang/' => true,
$this->assertSame('', $validator->message_code_info('some_really_crazy_message_code_that_is_not_localised', 'something'));
}
- // Helper methods.
-
+ /**
+ * Helper method for checking if the given message has been raised by the validator.
+ *
+ * @param array $messages list of returned messages
+ * @param string $level expected message severity level
+ * @param string $msgcode expected message code
+ * @param string|array $addinfo expected additional info
+ * @return bool
+ */
protected function has_message(array $messages, $level, $msgcode, $addinfo = null) {
foreach ($messages as $message) {
if ($message->level === $level and $message->msgcode === $msgcode and $message->addinfo === $addinfo) {