Commit 2565f2d8 authored by Aaron Wells's avatar Aaron Wells Committed by Robert Lyon
Browse files

Display icons for 3rd-party blocktypes plugins

Bug 1510421

Defines a new static PluginBlocktype method, get_css_icon(), which
fetches the name of the CSS icon to use for this blocktype. It returns
false by default, which tells the theme to "fall back" to the old
thumbnail.png instead. 3rd-party plugins can override this to
specify a particular icon to use.

All the core blocktypes have been refactored to extend
MaharaCoreBlocktype, which uses the blocktype name as the name
of the CSS icon to use. I also deprecated the "SystemBlocktype"
class while I was at it.

PluginBlocktype::get_blocktypes_for_category() now returns both
the results of get_css_icon() and the thumbnail.png path, so that
themes can decide which they want to use. (And of course
thumbnail.png is served via thumbnail.php, so 3rd party themes
can provide their own custom image files if they wish.)

behatnotneeded: Requires installing third-party plugins to test

Change-Id: Idb1ecfc7b21175913708e695788906c11133b0c0
(cherry picked from commit 4f849ed2)
parent 97f65d6b
......@@ -11,7 +11,7 @@
defined ('INTERNAL') || die();
class PluginBlocktypeAnnotation extends SystemBlocktype {
class PluginBlocktypeAnnotation extends MaharaCoreBlocktype {
public static function single_only() {
return false;
}
......
......@@ -11,7 +11,7 @@
defined('INTERNAL') || die();
class PluginBlocktypeBlog extends PluginBlocktype {
class PluginBlocktypeBlog extends MaharaCoreBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.blog/blog');
......
......@@ -11,7 +11,7 @@
defined('INTERNAL') || die();
class PluginBlocktypeBlogpost extends PluginBlocktype {
class PluginBlocktypeBlogpost extends MaharaCoreBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.blog/blogpost');
......
......@@ -11,7 +11,7 @@
defined('INTERNAL') || die();
class PluginBlocktypeRecentposts extends PluginBlocktype {
class PluginBlocktypeRecentposts extends MaharaCoreBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.blog/recentposts');
......@@ -153,7 +153,7 @@ class PluginBlocktypeRecentposts extends PluginBlocktype {
'rules' => array('integer' => true, 'minvalue' => 1, 'maxvalue' => 100),
),
);
return $elements;
}
......
......@@ -11,7 +11,7 @@
defined('INTERNAL') || die();
class PluginBlocktypeTaggedposts extends SystemBlocktype {
class PluginBlocktypeTaggedposts extends MaharaCoreBlocktype {
const TAGTYPE_INCLUDE = 1;
const TAGTYPE_EXCLUDE = 0;
......
......@@ -11,7 +11,7 @@
defined ('INTERNAL') || die();
class PluginBlocktypeComment extends SystemBlocktype {
class PluginBlocktypeComment extends MaharaCoreBlocktype {
public static function should_ajaxify() {
// TinyMCE doesn't play well with loading by ajax
return false;
......@@ -93,4 +93,14 @@ class PluginBlocktypeComment extends SystemBlocktype {
public static function has_instance_config() {
return false;
}
/**
* Shouldn't be linked to any artefacts via the view_artefacts table.
*
* @param BlockInstance $instance
* @return multitype:
*/
public static function get_artefacts(BlockInstance $instance) {
return array();
}
}
......@@ -11,7 +11,7 @@
defined('INTERNAL') || die();
class PluginBlocktypeFiledownload extends PluginBlocktype {
class PluginBlocktypeFiledownload extends MaharaCoreBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.file/filedownload');
......
......@@ -11,7 +11,7 @@
defined('INTERNAL') || die();
class PluginBlocktypeFolder extends PluginBlocktype {
class PluginBlocktypeFolder extends MaharaCoreBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.file/folder');
......
......@@ -13,7 +13,7 @@
defined('INTERNAL') || die();
class PluginBlocktypeGallery extends PluginBlocktype {
class PluginBlocktypeGallery extends MaharaCoreBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.file/gallery');
......
......@@ -11,7 +11,7 @@
defined('INTERNAL') || die();
class PluginBlocktypeHtml extends PluginBlocktype {
class PluginBlocktypeHtml extends MaharaCoreBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.file/html');
......
......@@ -11,7 +11,7 @@
defined('INTERNAL') || die();
class PluginBlocktypeImage extends PluginBlocktype {
class PluginBlocktypeImage extends MaharaCoreBlocktype {
public static function should_ajaxify() {
// Most of the load time for an image block is waiting for
......
......@@ -11,7 +11,7 @@
defined('INTERNAL') || die();
class PluginBlocktypeInternalmedia extends PluginBlocktype {
class PluginBlocktypeInternalmedia extends MaharaCoreBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.file/internalmedia');
......
......@@ -11,7 +11,7 @@
defined('INTERNAL') || die();
class PluginBlocktypePdf extends PluginBlocktype {
class PluginBlocktypePdf extends MaharaCoreBlocktype {
public static function single_only() {
return false;
......
......@@ -11,7 +11,7 @@
defined('INTERNAL') || die();
class PluginBlocktypeProfileinfo extends PluginBlocktype {
class PluginBlocktypeProfileinfo extends MaharaCoreBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.internal/profileinfo');
......
......@@ -12,7 +12,7 @@
defined('INTERNAL') || die();
class PluginBlocktypeSocialprofile extends PluginBlocktype {
class PluginBlocktypeSocialprofile extends MaharaCoreBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.internal/socialprofile');
......
......@@ -11,7 +11,7 @@
defined('INTERNAL') || die();
class PluginBlocktypeTextbox extends PluginBlocktype {
class PluginBlocktypeTextbox extends MaharaCoreBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.internal/textbox');
......
......@@ -11,7 +11,7 @@
defined('INTERNAL') || die();
class PluginBlocktypePlans extends PluginBlocktype {
class PluginBlocktypePlans extends MaharaCoreBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.plans/plans');
......
......@@ -11,7 +11,7 @@
defined('INTERNAL') || die();
class PluginBlocktypeEntireresume extends PluginBlocktype {
class PluginBlocktypeEntireresume extends MaharaCoreBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.resume/entireresume');
......
......@@ -11,7 +11,7 @@
defined('INTERNAL') || die();
class PluginBlocktypeResumefield extends PluginBlocktype {
class PluginBlocktypeResumefield extends MaharaCoreBlocktype {
public static function get_title() {
return get_string('title', 'blocktype.resume/resumefield');
......
......@@ -12,7 +12,7 @@
defined('INTERNAL') || die();
class PluginBlocktypeCreativecommons extends SystemBlocktype {
class PluginBlocktypeCreativecommons extends MaharaCoreBlocktype {
// Standard Creative Commons naming scheme
const noncommercial = 'nc';
......@@ -185,4 +185,13 @@ class PluginBlocktypeCreativecommons extends SystemBlocktype {
return 'full';
}
/**
* Shouldn't be linked to any artefacts via the view_artefacts table.
*
* @param BlockInstance $instance
* @return multitype:
*/
public static function get_artefacts(BlockInstance $instance) {
return array();
}
}
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