mirror of
https://github.com/moodle/moodle.git
synced 2025-04-14 13:02:07 +02:00
Merge branch 'w27_MDL-34115_m24_arrayofarrayssort' of git://github.com/skodak/moodle
This commit is contained in:
commit
78e43b866b
@ -131,12 +131,25 @@
|
||||
$table->setup();
|
||||
$tablerows = array();
|
||||
|
||||
// Sort blocks using current locale.
|
||||
$blocknames = array();
|
||||
foreach ($blocks as $blockid=>$block) {
|
||||
$blockname = $block->name;
|
||||
if (file_exists("$CFG->dirroot/blocks/$blockname/block_$blockname.php")) {
|
||||
$blocknames[$blockid] = get_string('pluginname', 'block_'.$blockname);
|
||||
} else {
|
||||
$blocknames[$blockid] = $blockname;
|
||||
}
|
||||
}
|
||||
collatorlib::asort($blocknames);
|
||||
|
||||
foreach ($blocknames as $blockid=>$strblockname) {
|
||||
$block = $blocks[$blockid];
|
||||
$blockname = $block->name;
|
||||
|
||||
if (!file_exists("$CFG->dirroot/blocks/$blockname/block_$blockname.php")) {
|
||||
$blockobject = false;
|
||||
$strblockname = '<span class="notifyproblem">'.$blockname.' ('.get_string('missingfromdisk').')</span>';
|
||||
$strblockname = '<span class="notifyproblem">'.$strblockname.' ('.get_string('missingfromdisk').')</span>';
|
||||
$plugin = new stdClass();
|
||||
$plugin->version = $block->version;
|
||||
|
||||
@ -151,7 +164,6 @@
|
||||
$incompatible[] = $block;
|
||||
continue;
|
||||
}
|
||||
$strblockname = get_string('pluginname', 'block_'.$blockname);
|
||||
}
|
||||
|
||||
$delete = '<a href="blocks.php?delete='.$blockid.'&sesskey='.sesskey().'">'.$strdelete.'</a>';
|
||||
@ -222,12 +234,7 @@
|
||||
$delete,
|
||||
$settings
|
||||
);
|
||||
$tablerows[] = array(strip_tags($strblockname), $row); // first element will be used for sorting
|
||||
}
|
||||
|
||||
collatorlib::asort($tablerows);
|
||||
foreach ($tablerows as $row) {
|
||||
$table->add_data($row[1]);
|
||||
$table->add_data($row);
|
||||
}
|
||||
|
||||
$table->print_html();
|
||||
|
@ -471,6 +471,12 @@ class collatorlib_testcase extends basic_testcase {
|
||||
$this->assertSame(array_keys($arr), array(0, 'b', 1));
|
||||
$this->assertTrue($result);
|
||||
|
||||
// test sorting of array of arrays - first element should be used for actual comparison
|
||||
$arr = array(0=>array('bb', 'z'), 1=>array('ab', 'a'), 2=>array('zz', 'x'));
|
||||
$result = collatorlib::asort($arr, collatorlib::SORT_REGULAR);
|
||||
$this->assertSame(array_keys($arr), array(1, 0, 2));
|
||||
$this->assertTrue($result);
|
||||
|
||||
$arr = array('a' => 'áb', 'b' => 'ab', 1 => 'aa', 0=>'cc', 'x' => 'Áb',);
|
||||
$result = collatorlib::asort($arr);
|
||||
$this->assertSame(array_values($arr), array('aa', 'ab', 'áb', 'Áb', 'cc'), $this->error);
|
||||
|
@ -616,7 +616,7 @@ class textlib {
|
||||
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
|
||||
*/
|
||||
class collatorlib {
|
||||
/** @const compare items as strings, equivalent to Collator::SORT_REGULAR */
|
||||
/** @const compare items using general PHP comparison, equivalent to Collator::SORT_REGULAR, this may bot be locale aware! */
|
||||
const SORT_REGULAR = 0;
|
||||
|
||||
/** @const compare items as strings, equivalent to Collator::SORT_STRING */
|
||||
|
Loading…
x
Reference in New Issue
Block a user