Commit 061070d4 authored by Penny Leach's avatar Penny Leach Committed by Penny Leach
Browse files

edit view page (blocks) filters on enabled viewtypes now both js & non js

parent 421fe313
......@@ -131,13 +131,15 @@ abstract class PluginBlocktype extends Plugin {
return get_string('pluginname', 'artefact.' . $name);
}
public static function get_blocktypes_for_category($category) {
public static function get_blocktypes_for_category_and_viewtype($category, $viewtype) {
$sql = 'SELECT bti.name, bti.artefactplugin
FROM {blocktype_installed} bti
JOIN {blocktype_installed_category} btic ON btic.blocktype = bti.name
JOIN {blocktype_installed_viewtype} bivt ON bivt.blocktype = bti.name
WHERE btic.category = ?
AND bivt.viewtype = ?
ORDER BY bti.name';
if (!$bts = get_records_sql_array($sql, array($category))) {
if (!$bts = get_records_sql_array($sql, array($category, $viewtype))) {
return false;
}
......
......@@ -439,8 +439,15 @@ class View {
$cats = get_records_sql_array('SELECT bc.name, COUNT(*) AS "count"
FROM {blocktype_category} bc
INNER JOIN {blocktype_installed_category} bic ON (bc.name = bic.category)
WHERE EXISTS (
SELECT 1
FROM {blocktype_installed_viewtype} bivt
JOIN {blocktype_installed} bi ON bi.name = bivt.blocktype
WHERE bivt.viewtype = ?
AND bic.blocktype = bi.name
)
GROUP BY bc.name
ORDER BY bc.name', array());
ORDER BY bc.name', array($view->get('type')));
$categories = array_map(
create_function(
'$a',
......@@ -489,9 +496,9 @@ class View {
* meaning that nothing for the standard HTML version
* alone should be output
*/
public static function build_blocktype_list($category, $javascript=false) {
public function build_blocktype_list($category, $javascript=false) {
require_once(get_config('docroot') . 'blocktype/lib.php');
$blocktypes = PluginBlockType::get_blocktypes_for_category($category);
$blocktypes = PluginBlockType::get_blocktypes_for_category_and_viewtype($category, $this->get('type'));
$smarty = smarty_core();
$smarty->assign_by_ref('blocktypes', $blocktypes);
......
......@@ -53,7 +53,7 @@ if ($change) {
switch ($action) {
case 'blocktype_list':
$category = param_alpha('c');
$data = View::build_blocktype_list($category, true);
$data = $view->build_blocktype_list($category, true);
json_reply(false, array('message' => false, 'data' => $data));
break;
}
......
......@@ -119,7 +119,7 @@ $smarty = smarty(array('views', 'tinytinymce', 'paginator', 'tablerenderer'), ar
$smarty->assign('category_list', View::build_category_list($category, $view, $new));
// The list of blocktypes for the default category
$smarty->assign('blocktype_list', View::build_blocktype_list($category));
$smarty->assign('blocktype_list', $view->build_blocktype_list($category));
// The HTML for the columns in the view
$smarty->assign('columns', $columns);
......
Supports Markdown
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