Commit 89e82e29 authored by Nigel McNie's avatar Nigel McNie
Browse files

Implemented get_artefacts in the BlockType parent class, so that all children...

Implemented get_artefacts in the BlockType parent class, so that all children don't have to implement it.

The one exception thus far is the Profile Information blocktype, which needs to add the 'profileicon' field.
parent 88f92567
......@@ -73,23 +73,6 @@ class PluginBlocktypeBlog extends PluginBlocktype {
return $result;
}
// TODO: Implement in parent class, saving us a lot of hassle
public static function get_artefacts(BlockInstance $instance) {
$configdata = $instance->get('configdata');
if (!empty($configdata['artefactid'])) {
//require_once(get_config('docroot') . 'lib/artefact.php');
//$blog = artefact_instance_from_id($configdata['artefactid']);
$list = array();
//foreach ($blog->get_children_instances() as $blogpost) {
// $list = array_merge($list, $blogpost->attachment_id_list());
//}
$list[] = $configdata['artefactid'];
return $list;
}
return false;
}
public static function has_instance_config() {
return true;
}
......
......@@ -71,15 +71,6 @@ class PluginBlocktypeBlogpost extends PluginBlocktype {
return $result;
}
// TODO: Implement in parent class, saving us a lot of hassle
public static function get_artefacts(BlockInstance $instance) {
$configdata = $instance->get('configdata');
if (!empty($configdata['artefactid'])) {
return array($configdata['artefactid']);
}
return false;
}
public static function has_instance_config() {
return true;
}
......
......@@ -71,15 +71,6 @@ class PluginBlocktypeRecentposts extends PluginBlocktype {
return $result;
}
// TODO: Implement in parent class, saving us a lot of hassle
public static function get_artefacts(BlockInstance $instance) {
$configdata = $instance->get('configdata');
if (!empty($configdata['artefactids'])) {
return $configdata['artefactids'];
}
return false;
}
public static function has_instance_config() {
return true;
}
......
......@@ -88,14 +88,6 @@ class PluginBlocktypeFiledownload extends PluginBlocktype {
return $result;
}
public static function get_artefacts(BlockInstance $instance) {
$configdata = $instance->get('configdata');
if (isset($configdata['artefactids']) && is_array($configdata['artefactids'])) {
return $configdata['artefactids'];
}
return false;
}
public static function has_instance_config() {
return true;
}
......
......@@ -79,14 +79,6 @@ class PluginBlocktypeImage extends PluginBlocktype {
return $result;
}
public static function get_artefacts(BlockInstance $instance) {
$configdata = $instance->get('configdata');
if (isset($configdata['artefactid'])) {
return array($configdata['artefactid']);
}
return false;
}
public static function has_instance_config() {
return true;
}
......
......@@ -72,17 +72,6 @@ class PluginBlocktypeContactinfo extends PluginBlocktype {
return $smarty->fetch('blocktype:contactinfo:content.tpl');
}
public static function get_artefacts(BlockInstance $instance) {
$configdata = $instance->get('configdata');
$return = false;
if (isset($configdata['artefactids'])) {
$return = $configdata['artefactids'];
}
return $return;
}
public static function has_instance_config() {
return true;
}
......
......@@ -85,6 +85,14 @@ class PluginBlocktypeProfileinfo extends PluginBlocktype {
return $smarty->fetch('blocktype:profileinfo:content.tpl');
}
/**
* Overrides the standard get_artefacts method to make sure the profileicon
* is added also.
*
* @param BlockInstance $instance The blockinstance to get artefacts for
* @return array A list of artefact IDs in the blockinstance, or false if
* there are none
*/
public static function get_artefacts(BlockInstance $instance) {
$configdata = $instance->get('configdata');
$return = false;
......
......@@ -58,15 +58,6 @@ class PluginBlocktypeResumefield extends PluginBlocktype {
return '';
}
public static function get_artefacts(BlockInstance $instance) {
$configdata = $instance->get('configdata');
if (isset($configdata['artefactid'])) {
return array($configdata['artefactid']);
}
return false;
}
public static function has_instance_config() {
return true;
}
......
......@@ -100,7 +100,16 @@ abstract class PluginBlocktype extends Plugin {
*
* @return array ids of artefacts in this block instance
*/
public static abstract function get_artefacts(BlockInstance $instance);
public static function get_artefacts(BlockInstance $instance) {
$configdata = $instance->get('configdata');
if (isset($configdata['artefactids']) && is_array($configdata['artefactids'])) {
return $configdata['artefactids'];
}
if (!empty($configdata['artefactid'])) {
return array($configdata['artefactid']);
}
return false;
}
/**
* this is different to has_config - has_config is plugin wide config settings
......
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