Merge branch 'w13_MDL-32095_m23_strict2' of git://github.com/skodak/moodle

This commit is contained in:
Eloy Lafuente (stronk7) 2012-03-28 22:49:38 +02:00
commit 3f0cb423b2
36 changed files with 117 additions and 78 deletions

View File

@ -200,6 +200,7 @@ if ($version > $CFG->version) { // upgrade
}
if (empty($confirmupgrade)) {
$a = new stdClass();
$a->oldversion = "$CFG->release ($CFG->version)";
$a->newversion = "$release ($version)";
$strdatabasechecking = get_string('databasechecking', '', $a);

View File

@ -101,7 +101,7 @@ if ($backup->enforce_changed_dependencies()) {
echo $renderer->dependency_notification(get_string('dependenciesenforced','backup'));
}
echo $renderer->progress_bar($backup->get_progress_bar());
echo $backup->display();
echo $backup->display($renderer);
$backup->destroy();
unset($backup);
echo $OUTPUT->footer();

View File

@ -157,7 +157,7 @@ if ($backup->enforce_changed_dependencies()) {
echo $renderer->dependency_notification(get_string('dependenciesenforced','backup'));
}
echo $renderer->progress_bar($backup->get_progress_bar());
echo $backup->display();
echo $backup->display($renderer);
$backup->destroy();
unset($backup);
echo $OUTPUT->footer();

View File

@ -67,7 +67,7 @@ class backup_root_task extends backup_task {
require_once($CFG->dirroot . '/backup/util/helper/convert_helper.class.php');
// Define filename setting
$filename = new backup_filename_setting('filename', base_setting::IS_FILENAME, 'backup.mbz');
$filename->set_ui(get_string('filename', 'backup'), 'backup.mbz', array('size'=>50));
$filename->set_ui_filename(get_string('filename', 'backup'), 'backup.mbz', array('size'=>50));
$this->add_setting($filename);
//Sample custom settings

View File

@ -52,8 +52,8 @@ class backup_filename_setting extends backup_generic_setting {
parent::__construct($name, $vtype, $value, $visibility, $status);
}
public function set_ui($label, $value, array $options = null) {
parent::make_ui(self::UI_HTML_TEXTFIELD, $label, null, $options);
public function set_ui_filename($label, $value, array $options = null) {
$this->make_ui(self::UI_HTML_TEXTFIELD, $label, null, $options);
$this->set_value($value);
}
}

View File

@ -2249,7 +2249,11 @@ class restore_block_instance_structure_step extends restore_structure_step {
// If there is already one block of that type in the parent context
// and the block is not multiple, stop processing
// Use blockslib loader / method executor
if (!block_method_result($data->blockname, 'instance_allow_multiple')) {
if (!$bi = block_instance($data->blockname)) {
return false;
}
if (!$bi->instance_allow_multiple()) {
if ($DB->record_exists_sql("SELECT bi.id
FROM {block_instances} bi
JOIN {block} b ON b.name = bi.blockname

View File

@ -90,7 +90,10 @@ abstract class backup_setting extends base_setting implements checksumable {
}
}
public function add_dependency(backup_setting $dependentsetting, $type=setting_dependency::DISABLED_VALUE, $options=array()) {
public function add_dependency(base_setting $dependentsetting, $type=setting_dependency::DISABLED_VALUE, $options=array()) {
if (!($dependentsetting instanceof backup_setting)) {
throw new backup_setting_exception('invalid_backup_setting_parameter');
}
// Check the dependency level is >= current level
if ($dependentsetting->get_level() < $this->level) {
throw new backup_setting_exception('cannot_add_upper_level_dependency');

View File

@ -410,7 +410,7 @@ class backup_ui_stage_final extends backup_ui_stage {
/**
* should NEVER be called... throws an exception
*/
public function display() {
public function display(core_backup_renderer $renderer) {
throw new backup_ui_exception('backup_ui_must_execute_first');
}
}
@ -444,13 +444,13 @@ class backup_ui_stage_complete extends backup_ui_stage_final {
/**
* Displays the completed backup stage.
*
* Currently this just envolves redirecting to the file browser with an
* Currently this just involves redirecting to the file browser with an
* appropriate message.
*
* @global core_renderer $OUTPUT
* @param core_backup_renderer $renderer
* @return string HTML code to echo
*/
public function display() {
global $OUTPUT;
public function display(core_backup_renderer $renderer) {
// Get the resulting stored_file record
$type = $this->get_ui()->get_controller()->get_type();
@ -468,9 +468,12 @@ class backup_ui_stage_complete extends backup_ui_stage_final {
$restorerul = new moodle_url('/backup/restorefile.php', array('contextid'=>$coursecontext->id));
}
echo $OUTPUT->box_start();
echo $OUTPUT->notification(get_string('executionsuccess', 'backup'), 'notifysuccess');
echo $OUTPUT->continue_button($restorerul);
echo $OUTPUT->box_end();
$output = '';
$output .= $renderer->box_start();
$output .= $renderer->notification(get_string('executionsuccess', 'backup'), 'notifysuccess');
$output .= $renderer->continue_button($restorerul);
$output .= $renderer->box_end();
return $output;
}
}

View File

@ -140,14 +140,14 @@ abstract class base_ui {
/**
* Displays the UI for the backup!
*
* @throws base_ui_exception
* @return string HTML code
* @param core_backup_renderer $renderer
* @return string HTML code to echo
*/
public function display() {
public function display(core_backup_renderer $renderer) {
if ($this->progress < self::PROGRESS_SAVED) {
throw new base_ui_exception('backupsavebeforedisplay');
}
return $this->stage->display();
return $this->stage->display($renderer);
}
/**
* Gets all backup tasks from the controller

View File

@ -115,9 +115,10 @@ abstract class base_ui_stage {
* By default this involves instantiating the form for the stage and the calling
* it to display.
*
* @return string HTML code to display
* @param core_backup_renderer $renderer
* @return string HTML code to echo
*/
public function display() {
public function display(core_backup_renderer $renderer) {
$form = $this->initialise_stage_form();
// a nasty hack follows to work around the sad fact that moodle quickforms

View File

@ -133,8 +133,11 @@ class import_ui_stage_confirmation extends backup_ui_stage_confirmation {
*
* This function is overriden so that we can manipulate the strings on the
* buttons.
*
* @param core_backup_renderer $renderer
* @return string HTML code to echo
*/
public function display() {
public function display(core_backup_renderer $renderer) {
$form = $this->initialise_stage_form();
$form->require_definition_after_data();
if ($e = $form->get_element('submitbutton')) {
@ -147,7 +150,16 @@ class import_ui_stage_confirmation extends backup_ui_stage_confirmation {
}
}
}
// a nasty hack follows to work around the sad fact that moodle quickforms
// do not allow to actually return the HTML content, just to echo it
flush();
ob_start();
$form->display();
$output = ob_get_contents();
ob_end_clean();
return $output;
}
}
/**

View File

@ -289,7 +289,7 @@ class restore_ui extends base_ui {
* @param core_backup_renderer $renderer
* @return string HTML code to echo
*/
public function display($renderer) {
public function display(core_backup_renderer $renderer) {
if ($this->progress < self::PROGRESS_SAVED) {
throw new base_ui_exception('backupsavebeforedisplay');
}

View File

@ -95,7 +95,7 @@ abstract class restore_ui_stage extends base_ui_stage {
abstract class restore_ui_independent_stage {
abstract public function __construct($contextid);
abstract public function process();
abstract public function display($renderer);
abstract public function display(core_backup_renderer $renderer);
abstract public function get_stage();
/**
* Gets an array of progress bar items that can be displayed through the restore renderer.
@ -177,7 +177,7 @@ class restore_ui_stage_confirm extends restore_ui_independent_stage {
* @param core_backup_renderer $renderer renderer instance to use
* @return string HTML code
*/
public function display($renderer) {
public function display(core_backup_renderer $renderer) {
$prevstageurl = new moodle_url('/backup/restorefile.php', array('contextid' => $this->contextid));
$nextstageurl = new moodle_url('/backup/restore.php', array(
@ -262,7 +262,7 @@ class restore_ui_stage_destination extends restore_ui_independent_stage {
* @param core_backup_renderer $renderer renderer instance to use
* @return string HTML code
*/
public function display($renderer) {
public function display(core_backup_renderer $renderer) {
$format = backup_general_helper::detect_backup_format($this->filepath);
@ -676,7 +676,7 @@ class restore_ui_stage_process extends restore_ui_stage {
* @param core_backup_renderer $renderer renderer instance to use
* @return string HTML code
*/
public function display($renderer) {
public function display(core_backup_renderer $renderer) {
global $PAGE;
$html = '';
@ -752,6 +752,7 @@ class restore_ui_stage_complete extends restore_ui_stage_process {
* appropriate message.
*
* @param core_backup_renderer $renderer
* @return string HTML code to echo
*/
public function display(core_backup_renderer $renderer) {

View File

@ -33,7 +33,7 @@ defined('MOODLE_INTERNAL') || die();
* it may fail sometimes, so we always do a full sync in cron too.
*/
class enrol_category_handler {
public function role_assigned($ra) {
public static function role_assigned($ra) {
global $DB;
if (!enrol_is_enabled('category')) {
@ -84,7 +84,7 @@ class enrol_category_handler {
return true;
}
public function role_unassigned($ra) {
public static function role_unassigned($ra) {
global $DB;
if (!enrol_is_enabled('category')) {

View File

@ -40,7 +40,7 @@ class enrol_cohort_handler {
* @param stdClass $ca
* @return bool
*/
public function member_added($ca) {
public static function member_added($ca) {
global $DB;
if (!enrol_is_enabled('cohort')) {
@ -79,7 +79,7 @@ class enrol_cohort_handler {
* @param stdClass $ca
* @return bool
*/
public function member_removed($ca) {
public static function member_removed($ca) {
global $DB;
// does anything want to sync with this cohort?
@ -114,7 +114,7 @@ class enrol_cohort_handler {
* @param stdClass $cohort
* @return bool
*/
public function deleted($cohort) {
public static function deleted($cohort) {
global $DB;
// does anything want to sync with this cohort?

View File

@ -43,15 +43,15 @@ class filter_activitynames extends moodle_text_filter {
}
// Initialise/invalidate our trivial cache if dealing with a different course
if (!isset($this->cachedcourseid) || $this->cachedcourseid !== (int)$courseid) {
$this->activitylist = null;
if (!isset(self::$cachedcourseid) || self::$cachedcourseid !== (int)$courseid) {
self::$activitylist = null;
}
$this->cachedcourseid = (int)$courseid;
self::$cachedcourseid = (int)$courseid;
/// It may be cached
if (is_null($this->activitylist)) {
$this->activitylist = array();
if (is_null(self::$activitylist)) {
self::$activitylist = array();
if ($COURSE->id == $courseid) {
$course = $COURSE;
@ -68,7 +68,7 @@ class filter_activitynames extends moodle_text_filter {
if (!empty($modinfo)) {
$this->activitylist = array(); /// We will store all the activities here
self::$activitylist = array(); /// We will store all the activities here
//Sort modinfo by name length
usort($modinfo, 'filter_activitynames_comparemodulenamesbylength');
@ -82,9 +82,9 @@ class filter_activitynames extends moodle_text_filter {
/// Avoid empty or unlinkable activity names
if (!empty($title)) {
$href_tag_begin = "<a class=\"autolink\" title=\"$title\" href=\"$CFG->wwwroot/mod/$activity->mod/view.php?id=$activity->cm\">";
$this->activitylist[] = new filterobject($currentname, $href_tag_begin, '</a>', false, true);
self::$activitylist[] = new filterobject($currentname, $href_tag_begin, '</a>', false, true);
if ($currentname != $entitisedname) { /// If name has some entity (&amp; &quot; &lt; &gt;) add that filter too. MDL-17545
$this->activitylist[] = new filterobject($entitisedname, $href_tag_begin, '</a>', false, true);
self::$activitylist[] = new filterobject($entitisedname, $href_tag_begin, '</a>', false, true);
}
}
}
@ -92,8 +92,8 @@ class filter_activitynames extends moodle_text_filter {
}
}
if ($this->activitylist) {
return $text = filter_phrases ($text, $this->activitylist);
if (self::$activitylist) {
return $text = filter_phrases ($text, self::$activitylist);
} else {
return $text;
}

View File

@ -33,18 +33,18 @@ class HTML_QuickForm_Rule
/**
* Validates a value
*
*
* @access public
* @abstract
*/
function validate($value)
function validate($value, $options = null)
{
return true;
}
/**
* Sets the rule name
*
*
* @access public
*/
function setName($ruleName)

View File

@ -34,7 +34,7 @@ class HTML_QuickForm_Rule_Range extends HTML_QuickForm_Rule
* @access public
* @return boolean true if value is valid
*/
function validate($value, $options)
function validate($value, $options = null)
{
$length = strlen($value);
switch ($this->name) {
@ -48,13 +48,13 @@ class HTML_QuickForm_Rule_Range extends HTML_QuickForm_Rule
function getValidationScript($options = null)
{
switch ($this->name) {
case 'minlength':
case 'minlength':
$test = '{jsVar}.length < '.$options;
break;
case 'maxlength':
case 'maxlength':
$test = '{jsVar}.length > '.$options;
break;
default:
default:
$test = '({jsVar}.length < '.$options[0].' || {jsVar}.length > '.$options[1].')';
}
return array('', "{jsVar} != '' && {$test}");

View File

@ -40,6 +40,7 @@ require_once($CFG->libdir . '/outputlib.php');
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
class xhtml_container_stack_test extends UnitTestCase {
protected $olddebug;
public static $includecoverage = array('lib/outputlib.php');
protected function start_capture() {
@ -52,6 +53,19 @@ class xhtml_container_stack_test extends UnitTestCase {
return $result;
}
function setUp() {
global $CFG;
parent::setUp();
$this->olddebug = $CFG->debug;
$CFG->debug = DEBUG_DEVELOPER;
}
function tearDown() {
global $CFG;
$CFG->debug = $this->olddebug;
parent::tearDown();
}
public function test_push_then_pop() {
// Set up.
$stack = new xhtml_container_stack();

View File

@ -238,7 +238,7 @@ class repository_alfresco extends repository {
* @param string $search_text
* @return array
*/
public function search($search_text) {
public function search($search_text, $page = 0) {
$space = optional_param('space', 'workspace://SpacesStore', PARAM_RAW);
$currentStore = $this->user_session->getStoreFromString($space);
$nodes = $this->user_session->query($currentStore, $search_text);

View File

@ -114,7 +114,7 @@ class repository_boxnet extends repository {
* @param string $search_text
* @return mixed
*/
public function search($search_text) {
public function search($search_text, $page = 0) {
global $OUTPUT;
$list = array();
$ret = array();
@ -206,7 +206,7 @@ class repository_boxnet extends repository {
* Add Plugin settings input to Moodle form
* @param object $mform
*/
public function type_config_form($mform) {
public static function type_config_form($mform, $classname = 'repository') {
global $CFG;
parent::type_config_form($mform);
$public_account = get_config('boxnet', 'public_account');

View File

@ -258,7 +258,7 @@ class repository_dropbox extends repository {
* Add Plugin settings input to Moodle form
* @param object $mform
*/
public function type_config_form($mform) {
public static function type_config_form($mform, $classname = 'repository') {
global $CFG;
parent::type_config_form($mform);
$key = get_config('dropbox', 'dropbox_key');

View File

@ -55,7 +55,7 @@ class dropbox extends oauth_helper {
/**
* Download a file
*/
public function get_file($filepath, $saveas) {
public function get_file($filepath, $saveas = '') {
$info = pathinfo($filepath);
$dirname = $info['dirname'];
$basename = $info['basename'];

View File

@ -200,7 +200,7 @@ class repository_flickr extends repository {
* @param string $search_text
* @return array
*/
public function search($search_text) {
public function search($search_text, $page = 0) {
$photos = $this->flickr->photos_search(array(
'user_id'=>$this->nsid,
'per_page'=>24,
@ -274,7 +274,7 @@ class repository_flickr extends repository {
* Add Plugin settings input to Moodle form
* @param object $mform
*/
public function type_config_form($mform) {
public static function type_config_form($mform, $classname = 'repository') {
global $CFG;
$api_key = get_config('flickr', 'api_key');
$secret = get_config('flickr', 'secret');

View File

@ -224,7 +224,7 @@ class repository_flickr_public extends repository {
* @param string $search_text
* @return array
*/
public function search($search_text, $page = 1) {
public function search($search_text, $page = 0) {
global $SESSION;
$ret = array();
if (empty($page)) {
@ -471,7 +471,7 @@ class repository_flickr_public extends repository {
* Add Plugin settings input to Moodle form
* @param object $mform
*/
public function type_config_form($mform) {
public static function type_config_form($mform, $classname = 'repository') {
$api_key = get_config('flickr_public', 'api_key');
if (empty($api_key)) {
$api_key = '';

View File

@ -84,12 +84,12 @@ class repository_googledocs extends repository {
return $ret;
}
public function search($query){
public function search($search_text, $page = 0) {
$gdocs = new google_docs(new google_authsub($this->subauthtoken));
$ret = array();
$ret['dynload'] = true;
$ret['list'] = $gdocs->get_file_list($query);
$ret['list'] = $gdocs->get_file_list($search_text);
return $ret;
}
@ -108,7 +108,7 @@ class repository_googledocs extends repository {
return parent::logout();
}
public function get_file($url, $file) {
public function get_file($url, $file = '') {
global $CFG;
$path = $this->prepare_file($file);

View File

@ -1672,7 +1672,7 @@ abstract class repository {
*
* @return mixed, see get_listing()
*/
public function search($search_text) {
public function search($search_text, $page = 0) {
$list = array();
$list['list'] = array();
return false;
@ -1754,7 +1754,7 @@ abstract class repository {
* @param object $mform Moodle form (passed by reference)
* @param string $classname repository class name
*/
public function type_config_form($mform, $classname = 'repository') {
public static function type_config_form($mform, $classname = 'repository') {
$instnaceoptions = call_user_func(array($classname, 'get_instance_option_names'), $mform, $classname);
if (empty($instnaceoptions)) {
// this plugin has only one instance

View File

@ -57,7 +57,7 @@ class repository_merlot extends repository {
* @param string $search_text
* @return array
*/
public function search($search_text) {
public function search($search_text, $page = 0) {
$ret = array();
$ret['nologin'] = true;
$ret['list'] = $this->_get_collection($this->keyword, $this->author);
@ -132,7 +132,7 @@ class repository_merlot extends repository {
*
* @param object $mform
*/
public function type_config_form($mform) {
public static function type_config_form($mform, $classname = 'repository') {
parent::type_config_form($mform);
$licensekey = get_config('merlot', 'licensekey');
if (empty($licensekey)) {

View File

@ -88,11 +88,11 @@ class repository_picasa extends repository {
return $ret;
}
public function search($query){
public function search($search_text, $page = 0) {
$picasa = new google_picasa(new google_authsub($this->subauthtoken));
$ret = array();
$ret['list'] = $picasa->do_photo_search($query);
$ret['list'] = $picasa->do_photo_search($search_text);
return $ret;
}

View File

@ -132,7 +132,7 @@ class repository_recent extends repository {
return array('recentfilesnumber', 'pluginname');
}
public function type_config_form($mform, $classname = 'repository') {
public static function type_config_form($mform, $classname = 'repository') {
parent::type_config_form($mform, $classname);
$number = get_config('repository_recent', 'recentfilesnumber');
if (empty($number)) {

View File

@ -104,7 +104,7 @@ class repository_s3 extends repository {
* @param string $file The file path in moodle
* @return array The local stored path
*/
public function get_file($filepath, $file) {
public function get_file($filepath, $file = '') {
global $CFG;
$arr = explode('/', $filepath);
$bucket = $arr[0];
@ -136,7 +136,7 @@ class repository_s3 extends repository {
return array('access_key', 'secret_key', 'pluginname');
}
public function type_config_form($mform) {
public static function type_config_form($mform, $classname = 'repository') {
parent::type_config_form($mform);
$strrequired = get_string('required');
$mform->addElement('text', 'access_key', get_string('access_key', 'repository_s3'));

View File

@ -61,7 +61,7 @@ class repository_webdav extends repository {
public function check_login() {
return true;
}
public function get_file($url, $title) {
public function get_file($url, $title = '') {
global $CFG;
$url = urldecode($url);
$path = $this->prepare_file($title);

View File

@ -106,7 +106,7 @@ EOD;
public function global_search() {
return false;
}
public function search($search_text) {
public function search($search_text, $page = 0) {
$client = new wikimedia;
$search_result = array();
$search_result['list'] = $client->search_images($search_text);

View File

@ -141,11 +141,11 @@ class wikimedia {
* @param string $keyword
* @return array
*/
public function search_images($keyword, $page = 0) {
public function search($search_text, $page = 0) {
$files_array = array();
$this->_param['action'] = 'query';
$this->_param['generator'] = 'search';
$this->_param['gsrsearch'] = $keyword;
$this->_param['gsrsearch'] = $search_text;
$this->_param['gsrnamespace'] = WIKIMEDIA_FILE_NS;
$this->_param['gsrlimit'] = WIKIMEDIA_THUMBS_PER_PAGE;
$this->_param['gsroffset'] = $page * WIKIMEDIA_THUMBS_PER_PAGE;

View File

@ -49,7 +49,7 @@ class repository_youtube extends repository {
* @param string $search_text
* @return array
*/
public function search($search_text, $page) {
public function search($search_text, $page = 0) {
global $SESSION;
$sort = optional_param('youtube_sort', '', PARAM_TEXT);
$sess_keyword = 'youtube_'.$this->id.'_keyword';

View File

@ -12,7 +12,7 @@ class theme_anomaly_core_renderer extends core_renderer {
* @param string $region the region the block is appearing in.
* @return string the HTML to be output.
*/
function block($bc, $region) {
function block(block_contents $bc, $region) {
$bc = clone($bc); // Avoid messing up the object passed in.
if (empty($bc->blockinstanceid) || !strip_tags($bc->title)) {
@ -35,7 +35,7 @@ class theme_anomaly_core_renderer extends core_renderer {
}
$output .= html_writer::start_tag('div', $bc->attributes);
/** Rounded corners **/
$output .= html_writer::start_tag('div', array('class'=>'corner-box'));
$output .= html_writer::start_tag('div', array('class'=>'rounded-corner top-left')).html_writer::end_tag('div');