Commit 937a624a authored by Nigel McNie's avatar Nigel McNie
Browse files

Made the top pane work for displaying the block types, both with and without javascript.

With javascript, an AJAX request is made to retrieve the new blocktypes. Without javascript, a standard GET request changes which one is displayed. When javascript is on, the radio buttons are not sent back.
parent 7497db25
......@@ -6,23 +6,10 @@
<div id="page">
<div id="top-pane">
<div id="category-list">
<ul>
{foreach from=$categories.cats item=category}
<li{if $category.classes} class="{$category.classes}"{/if}><a href="viewrework.php?category={$category.name|escape}">{$category.title|escape}</a></li>
{/foreach}
</ul>
{$category_list}
</div>
<div id="blocktype-list">
<ul>
{foreach from=$blocktypes item=blocktype}
<li>
<img src="{$blocktype.thumbnail_path}" alt="Preview">
<h3>{$blocktype.title|escape}</h3>
<p>{$blocktype.description|escape}</p>
<input type="radio" class="blocktype-radio" name="blocktype" value="blocktype_{$blocktype.id}">
</li>
{/foreach}
</ul>
{$blocktype_list}
</div>
<div id="blocktype-footer"></div>
</div>
......
......@@ -28,6 +28,7 @@ define('INTERNAL', 1);
define('JSON', 1);
define('PUBLIC', 1);
require(dirname(__FILE__) . '/init.php');
require(dirname(__FILE__) . '/viewlib.php');
$action = param_alphanumext('action');
......@@ -39,10 +40,6 @@ case 'delete_blockinstance':
case 'blocktype_list':
$category = param_alpha('category');
// TODO:
// Put the logic for generating the blocktype list into one function.
// Call this function both here, and somewhere so it ends up in the static page
// NOTE: if javascript is enabled (e.g. the call comes from json), then things like the radio buttons don't have to be output
// Work on this until it works both with javascript enabled and disabled
//
// Where I can get to:
// Static version: Clicking buttons = response, but no action. Category browser works, for hard coded block types
......@@ -60,25 +57,7 @@ case 'blocktype_list':
//
//
//
// Need to duplicate this smarty logic somewhere
// <ul>
//{foreach from=$blocktypes item=blocktype}
// <li>
// <img src="{$blocktype.thumbnail_path}" alt="Preview">
// <h3>{$blocktype.title|escape}</h3>
// <p>{$blocktype.description|escape}</p>
// <input type="radio" class="blocktype-radio" name="blocktype" value="blocktype_{$blocktype.id}">
// </li>
//{/foreach}
// </ul>
$data = '<ul>
<li>
<img src="" alt="Preview">
<h3>Test</h3>
<p>Description</p>
<input type="radio">
</li>
</ul>';
$data = views_build_blocktype_list($category, true);
json_reply(false, array('message' => false, 'data' => $data));
break;
}
......
......@@ -28,88 +28,19 @@ define('INTERNAL', 1);
define('PUBLIC', 1);
define('MENUITEM', 'viewrework');
require('init.php');
require('viewlib.php');
define('TITLE', 'Views Rework [DANGER construction site]');
require_once('artefact.php');
rebuild_artefact_parent_cache_complete();
$smarty = smarty(array('views'), array('<link rel="stylesheet" href="views.css" type="text/css">'));
// Categories
$categories = array(
'cats' => array(
array(
'name' => 'aboutme',
'title' => 'About Me',
),
array(
'name' => 'blogs',
'title' => 'Blogs',
),
array(
'name' => 'filesandfolders',
'title' => 'Files and Folders',
),
array(
'name' => 'general',
'title' => 'General',
),
array(
'name' => 'system',
'title' => 'System Blocks',
),
),
'current' => 'aboutme',
);
$flag = false;
foreach ($categories['cats'] as &$category) {
if (!$flag) {
$flag = true;
$category['classes'] = 'first';
}
if ($categories['current'] == $category['name']) {
$category['classes'] = (isset($category['classes'])) ? $category['classes'] . ' current' : 'current';
// certainly done now
break;
}
}
// FIXME: we can't know the first category is 'aboutme'
$category = param_alpha('category', 'aboutme');
$smarty->assign('categories', $categories);
// Block types for the selected category
$blocktypes = array(
array(
'id' => 1,
'name' => 'blocktype1',
'title' => 'Block Type 1',
'description' => 'This is the description for block type 1',
'thumbnail_path' => 'theme/default/static/images/no_thumbnail.gif',
),
array(
'id' => 2,
'name' => 'blocktype2',
'title' => 'Block Type 2',
'description' => 'This is the description for block type 2',
'thumbnail_path' => 'theme/default/static/images/no_thumbnail.gif',
),
array(
'id' => 3,
'name' => 'blocktype3',
'title' => 'Block Type 3',
'description' => 'This is the description for block type 3',
'thumbnail_path' => 'theme/default/static/images/no_thumbnail.gif',
),
array(
'id' => 4,
'name' => 'blocktype4',
'title' => 'Block Type 4',
'description' => 'This is the description for block type 4',
'thumbnail_path' => 'theme/default/static/images/no_thumbnail.gif',
),
);
// The list of categories for the tabbed interface
$smarty->assign('category_list', views_build_category_list($category));
$smarty->assign('blocktypes', $blocktypes);
// The list of blocktypes for the default category
$smarty->assign('blocktype_list', views_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