Commit 33fbdd53 authored by Richard Mansfield's avatar Richard Mansfield
Browse files

Use instance data store in externalfeed, navigation blocks



Change-Id: I6c90e97b9a6cbb15f17fc10ee552f7a665d31913
Signed-off-by: default avatarRichard Mansfield <richard.mansfield@catalyst.net.nz>
parent 467adec1
......@@ -61,10 +61,8 @@ class PluginBlocktypeExternalfeed extends SystemBlocktype {
public static function render_instance(BlockInstance $instance, $editing=false) {
$configdata = $instance->get('configdata');
if (!empty($configdata['feedid'])) {
$data = get_record(
'blocktype_externalfeed_data', 'id', $configdata['feedid'], null, null, null, null,
'id,url,link,title,description,content,' . db_format_tsfield('lastupdate') . ',image'
);
$data = $instance->get_data('feed', $configdata['feedid']);
$data->content = unserialize($data->content);
$data->image = unserialize($data->image);
......@@ -104,6 +102,14 @@ class PluginBlocktypeExternalfeed extends SystemBlocktype {
return '';
}
// Called by $instance->get_data('feed', ...).
public static function get_instance_feed($id) {
return get_record(
'blocktype_externalfeed_data', 'id', $id, null, null, null, null,
'id,url,link,title,description,content,' . db_format_tsfield('lastupdate') . ',image'
);
}
public static function has_instance_config() {
return true;
}
......@@ -112,7 +118,7 @@ class PluginBlocktypeExternalfeed extends SystemBlocktype {
$configdata = $instance->get('configdata');
if (!empty($configdata['feedid'])) {
$url = get_field('blocktype_externalfeed_data', 'url', 'id', $configdata['feedid']);
$url = $instance->get_data('feed', $configdata['feedid'])->url;
}
else {
$url = '';
......@@ -163,7 +169,7 @@ class PluginBlocktypeExternalfeed extends SystemBlocktype {
$configdata = $bi->get('configdata');
if (!empty($configdata['feedid'])) {
if ($title = get_field('blocktype_externalfeed_data', 'title', 'id', $configdata['feedid'])) {
if ($title = $bi->get_data('feed', $configdata['feedid'])->title) {
return $title;
}
}
......
......@@ -49,11 +49,7 @@ class PluginBlocktypeNavigation extends SystemBlocktype {
$configdata = $bi->get('configdata');
if (!empty($configdata['collection'])) {
require_once('collection.php');
$data = get_record_select('collection', 'id = ?', array($configdata['collection']));
$collection = new Collection($configdata['collection'], (array)$data);
$title = $collection->get('name');
return $title;
return $bi->get_data('collection', $configdata['collection'])->get('name');
}
return '';
}
......@@ -63,21 +59,21 @@ class PluginBlocktypeNavigation extends SystemBlocktype {
$smarty = smarty_core();
if (!empty($configdata['collection'])) {
$sql = "SELECT cv.*, v.title
FROM {collection_view} cv
LEFT JOIN {collection} c ON cv.collection = c.id
LEFT JOIN {view} v ON cv.view = v.id
WHERE c.id = ?
ORDER BY cv.displayorder, v.title, v.ctime ASC";
if ($views = get_records_sql_array($sql, array($configdata['collection']))) {
$smarty->assign('views',$views);
$views = $instance->get_data('collection', $configdata['collection'])->views();
if (!empty($views)) {
$smarty->assign('views', $views['views']);
}
}
$smarty->assign('currentview',$instance->get('view'));
return $smarty->fetch('blocktype:navigation:navigation.tpl');
}
// Called by $instance->get_data('collection', ...).
public static function get_instance_collection($id) {
require_once('collection.php');
return new Collection($id);
}
public static function has_instance_config() {
return true;
}
......
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