Commit 6ee3058e authored by Hugh Davenport's avatar Hugh Davenport Committed by Gerrit Code Review
Browse files

Merge "Reorder tabs for editing content of a page"

parents 056044c0 9d268535
<TABLE NAME="blocktype_category">
<FIELDS>
<FIELD NAME="name" TYPE="char" LENGTH="50" NOTNULL="true" />
<FIELD NAME="sort" TYPE="int" LENGTH="2" NOTNULL="false" />
</FIELDS>
<KEYS>
<KEY NAME="primary" TYPE="primary" FIELDS="name" />
</KEYS>
<INDEXES>
<INDEX NAME="sortuk" UNIQUE="true" FIELDS="sort"/>
</INDEXES>
</TABLE>
......@@ -2737,5 +2737,21 @@ function xmldb_core_upgrade($oldversion=0) {
add_field($table, $field);
}
if ($oldversion < 2011091300) {
$table = new XMLDBTable('blocktype_category');
$field = new XMLDBField('sort');
$field->setAttributes(XMLDB_TYPE_INTEGER, 2, XMLDB_UNSIGNED, null);
add_field($table, $field);
execute_sql("UPDATE {blocktype_category} SET sort = ? WHERE name = ?", array('0', 'fileimagevideo'));
execute_sql("UPDATE {blocktype_category} SET sort = ? WHERE name = ?", array('1', 'blog'));
execute_sql("UPDATE {blocktype_category} SET sort = ? WHERE name = ?", array('2', 'general'));
execute_sql("UPDATE {blocktype_category} SET sort = ? WHERE name = ?", array('3', 'internal'));
execute_sql("UPDATE {blocktype_category} SET sort = ? WHERE name = ?", array('4', 'resume'));
execute_sql("UPDATE {blocktype_category} SET sort = ? WHERE name = ?", array('5', 'external'));
$index = new XMLDBIndex('sortuk');
$index->setAttributes(XMLDB_INDEX_UNIQUE,array('sort'));
add_index($table, $index, false);
}
return $status;
}
......@@ -989,7 +989,7 @@ function sort_upgrades($k1, $k2) {
/** blocktype categories the system exports (including artefact categories)
*/
function get_blocktype_categories() {
return array('general', 'internal', 'blog', 'resume', 'fileimagevideo', 'external');
return array('fileimagevideo', 'blog', 'general', 'internal', 'resume', 'external');
}
function install_blocktype_categories_for_plugin($blocktype) {
......@@ -1035,10 +1035,11 @@ function install_blocktype_extras() {
$categories = get_blocktype_categories();
$installedcategories = get_column('blocktype_category', 'name');
$sort = empty($installedcategories) ? -1 : get_record_sql('SELECT MAX(sort) AS maxsort FROM {blocktype_category}')->maxsort;
if ($toinstall = array_diff($categories, $installedcategories)) {
foreach ($toinstall as $i) {
insert_record('blocktype_category', (object)array('name' => $i));
insert_record('blocktype_category', (object)array('name' => $i, 'sort' => (++$sort)));
}
}
......
......@@ -28,7 +28,7 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2011091200;
$config->version = 2011091300;
$config->release = '1.5.0dev';
$config->minupgradefrom = 2008040200;
$config->minupgraderelease = '1.0.0 (release tag 1.0.0_RELEASE)';
......
......@@ -1122,20 +1122,23 @@ class View {
require_once(get_config('docroot') . '/blocktype/lib.php');
$categories = array();
$sql = 'SELECT bic.* FROM {blocktype_installed_category} bic
$sql = 'SELECT bic.*, bc.sort FROM {blocktype_installed_category} bic
JOIN {blocktype_installed} bi ON (bic.blocktype = bi.name AND bi.active = 1)
JOIN {blocktype_installed_viewtype} biv ON (bi.name = biv.blocktype AND biv.viewtype = ?)';
JOIN {blocktype_installed_viewtype} biv ON (bi.name = biv.blocktype AND biv.viewtype = ?)
JOIN {blocktype_category} bc ON (bic.category = bc.name)
ORDER BY bc.sort';
if (function_exists('local_get_allowed_blocktype_categories')) {
$localallowed = local_get_allowed_blocktype_categories($this);
}
foreach (get_records_sql_array($sql, array($this->get('type'))) as $blocktypecategory) {
$blockcategories = get_records_sql_array($sql, array($this->get('type')));
foreach ($blockcategories as $blocktypecategory) {
if (isset($localallowed) && is_array($localallowed) && !in_array($blocktypecategory->category, $localallowed)) {
continue;
}
safe_require('blocktype', $blocktypecategory->blocktype);
if (call_static_method(generate_class_name("blocktype", $blocktypecategory->blocktype), "allowed_in_view", $this)) {
if (!isset($categories[$blocktypecategory->category])) {
$categories[$blocktypecategory->category] = array(
if (!isset($categories[$blocktypecategory->sort])) {
$categories[$blocktypecategory->sort] = array(
'name' => $blocktypecategory->category,
'title' => call_static_method("PluginBlocktype", "category_title_from_name", $blocktypecategory->category),
);
......@@ -1143,10 +1146,6 @@ class View {
}
}
// The 'internal' plugin is known to the outside world as 'profile', so
// we need to sort on the actual name
usort($categories, create_function('$a, $b', 'return strnatcasecmp($a[\'title\'], $b[\'title\']);'));
return $this->category_data = $categories;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment