Commit aca61905 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review
Browse files

Merge "Put blocks in "shortcut" category to put them at top of the block picker"

parents 28790fc5 c098b01b
......@@ -22,7 +22,7 @@ class PluginBlocktypeImage extends PluginBlocktype {
}
public static function get_categories() {
return array();
return array('shortcut');
}
public static function render_instance(BlockInstance $instance, $editing=false) {
......
......@@ -12,5 +12,5 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2010090801;
$config->release = '1.0.1';
$config->version = 2010090802;
$config->release = '1.0.2';
......@@ -22,7 +22,7 @@ class PluginBlocktypeText extends SystemBlocktype {
}
public static function get_categories() {
return array();
return array('shortcut');
}
public static function render_instance(BlockInstance $instance, $editing=false) {
......
......@@ -12,5 +12,5 @@
defined('INTERNAL') || die();
$config = new StdClass;
$config->version = 2014082201;
$config->release = '1.0.1';
$config->version = 2014082202;
$config->release = '1.0.2';
......@@ -3758,5 +3758,19 @@ function xmldb_core_upgrade($oldversion=0) {
set_config('cacheversion', rand(1000, 9999));
}
}
if ($oldversion < 2014110700) {
// Increment all the existing sorts by 1 to make room...
$cats = get_records_array('blocktype_category', '', '', 'sort desc');
foreach ($cats as $cat) {
$cat->sort = $cat->sort + 1;
update_record('blocktype_category', $cat, 'name');
}
$todb = new stdClass();
$todb->name = 'shortcut';
$todb->sort = '0';
insert_record('blocktype_category', $todb);
}
return $status;
}
......@@ -1109,7 +1109,7 @@ function sort_upgrades($k1, $k2) {
/** blocktype categories the system exports (including artefact categories)
*/
function get_blocktype_categories() {
return array('fileimagevideo', 'blog', 'general', 'internal', 'resume', 'external');
return array('shortcut', 'fileimagevideo', 'blog', 'general', 'internal', 'resume', 'external');
}
function install_blocktype_categories_for_plugin($blocktype) {
......
......@@ -16,7 +16,7 @@ $config = new stdClass();
// See https://wiki.mahara.org/index.php/Developer_Area/Version_Numbering_Policy
// For upgrades on stable branches, increment the version by one. On master, use the date.
$config->version = 2014110500;
$config->version = 2014110700;
$config->series = '15.04';
$config->release = '15.04dev';
$config->minupgradefrom = 2009022600;
......
......@@ -1591,7 +1591,12 @@ class View {
public function build_category_list($category, $new=0) {
$categories = $this->get_category_data();
$flag = false;
foreach ($categories as &$cat) {
foreach ($categories as $i => &$cat) {
// The "shortcut" category should be treated special.
if ($cat['name'] == 'shortcut') {
unset($categories[$i]);
continue;
}
$classes = '';
if (!$flag) {
$flag = true;
......
<div id="content-editor">
<div id="content-editor-header"><div>{str tag=addcontent section=view}</div></div>
<div id="content-editor-foldable">
<div id="blocktype-common" class="blocktype-list">
{* If you are wanting to have some options always showing place the code here. *}
<div class="blocktype">
<a class="blocktypelink" href="#">
<input type="radio" class="blocktype-radio" id="blocktype-radio-text" name="blocktype" value="text">
<img width="24" height="24" title="{str tag=description section=blocktype.text}" alt="{str tag=description section=blocktype.text}" src="{$WWWROOT}thumb.php?type=blocktype&bt=text">
<label for="blocktype-radio-text" class="blocktypetitle">{str tag='title' section='blocktype.text'}</label>
</a>
</div>
<div class="blocktype lastrow">
<a class="blocktypelink" href="#">
<input type="radio" id="blocktype-radio-image" class="blocktype-radio" name="blocktype" value="image">
<img width="24" height="24" title="{str tag=description section=blocktype.file/image}" alt="{str tag=description section=blocktype.file/image}" src="{$WWWROOT}thumb.php?type=blocktype&bt=image&ap=file">
<label for="blocktype-radio-image" class="blocktypetitle">{str tag='image' section='view'}</label>
</a>
</div>
</div>
{if $shortcut_list}<div id="blocktype-common" class="blocktype-list">
{* Blocks with the category 'shortcut' should always be showing. *}
{$shortcut_list|safe}
</div>{/if}
<div id="accordion">
{$category_list|safe}
</div>
......
......@@ -197,6 +197,9 @@ $smarty->assign('addform', $addform);
// The list of categories for the tabbed interface
$smarty->assign('category_list', $view->build_category_list($category, $new));
// The list of shortcut blocks
$smarty->assign('shortcut_list', $view->build_blocktype_list('shortcut'));
// The list of blocktypes for the default category
$smarty->assign('blocktype_list', $view->build_blocktype_list($category));
......
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