Commit 7c77ed15 authored by Aaron Wells's avatar Aaron Wells Committed by Ghada El-Zoghbi
Browse files

Remove a bunch of abstract static methods of abstract classes to satisfy E_STRICT



Bug 1337547

Change-Id: Idad2fa23d7f30300ed2d602ce2325e0560d7d831
Signed-off-by: default avatarGhada El-Zoghbi <ghada@catalyst-au.net>
parent 26d02ec3
......@@ -13,23 +13,16 @@ defined('INTERNAL') || die();
require_once(get_config('libroot') . 'group.php');
/**
* Base artefact plugin class
* @abstract
* Helper interface to hold the PluginArtefact's abstract static functions
*/
abstract class PluginArtefact extends Plugin {
public static function get_plugintype_name() {
return 'artefact';
}
interface IPluginArtefact {
/**
* This function returns a list of classnames
* of artefact types this plugin provides.
* @abstract
* @return array
*/
public static abstract function get_artefact_types();
public static function get_artefact_types();
/**
* This function returns a list of classnames
......@@ -38,16 +31,25 @@ abstract class PluginArtefact extends Plugin {
* @abstract
* @return array
*/
public static abstract function get_block_types();
public static function get_block_types();
/**
* This function returns the name of the plugin.
* @abstract
* @return string
*/
public static abstract function get_plugin_name();
public static function get_plugin_name();
}
/**
* Base artefact plugin class
* @abstract
*/
abstract class PluginArtefact extends Plugin implements IPluginArtefact {
public static function get_plugintype_name() {
return 'artefact';
}
/**
* This function returns an array of menu items
......@@ -155,11 +157,50 @@ abstract class PluginArtefact extends Plugin {
}
}
/**
* Helper interface to hold the Artefact class's abstract static functions
*/
interface IArtefactType {
/**
* Returns a URL for an icon for the appropriate artefact
*
* @param array $options Options for the artefact. The array MUST have the
* 'id' key, representing the ID of the artefact for
* which the icon is being generated. Other keys
* include 'size' for a [width]x[height] version of
* the icon, as opposed to the default 20x20, and
* 'view' for the id of the view in which the icon is
* being displayed.
* @abstract
* @return string URL for the icon
*/
public static function get_icon($options=null);
/**
* whether a user will have exactly 0 or 1 of this artefact type
* @abstract
*/
public static function is_singular();
/**
* Returns a list of key => value pairs where the key is either '_default'
* or a language string, and value is a URL linking to that behaviour for
* this artefact type
*
* @param integer This is the ID of the artefact being linked to
*/
public static function get_links($id);
// @TODO maybe uncomment this later and implement it everywhere
// when we know a bit more about what blocks we want.
//public function render_self($options);
}
/**
* Base artefact type class
* @abstract
*/
abstract class ArtefactType {
abstract class ArtefactType implements IArtefactType {
protected $dirty;
protected $deleted = false;
......@@ -751,22 +792,6 @@ abstract class ArtefactType {
}
/**
* Returns a URL for an icon for the appropriate artefact
*
* @param array $options Options for the artefact. The array MUST have the
* 'id' key, representing the ID of the artefact for
* which the icon is being generated. Other keys
* include 'size' for a [width]x[height] version of
* the icon, as opposed to the default 20x20, and
* 'view' for the id of the view in which the icon is
* being displayed.
* @abstract
* @return string URL for the icon
*/
public static abstract function get_icon($options=null);
// ******************** STATIC FUNCTIONS ******************** //
public static function get_instances_by_userid($userid, $order, $offset, $limit) {
......@@ -777,26 +802,6 @@ abstract class ArtefactType {
// @todo
}
/**
* whether a user will have exactly 0 or 1 of this artefact type
* @abstract
*/
public static abstract function is_singular();
/**
* Returns a list of key => value pairs where the key is either '_default'
* or a language string, and value is a URL linking to that behaviour for
* this artefact type
*
* @param integer This is the ID of the artefact being linked to
*/
public static abstract function get_links($id);
// @TODO maybe uncomment this later and implement it everywhere
// when we know a bit more about what blocks we want.
//public abstract function render_self($options);
/**
* Returns the printable name of this artefact
* (used in lists and such)
......
......@@ -545,9 +545,30 @@ class ArtefactTypePersonalinformation extends ArtefactTypeResume {
}
}
/**
* Helper interface to hold ArtefactTypeResumeComposite's abstract static methods
*/
interface IArtefactTypeResumeComposite {
/**
* This function should return a snippet of javascript
* to be plugged into a table renderer instantiation
* it comprises the cell function definition
*/
public static function get_tablerenderer_js();
public static function get_tablerenderer_title_js_string();
public static function get_tablerenderer_body_js_string();
/**
* This function should return an array suitable to
* put into the 'elements' part of a pieform array
* to generate a form to add an instance
*/
public static function get_addform_elements();
}
abstract class ArtefactTypeResumeComposite extends ArtefactTypeResume {
abstract class ArtefactTypeResumeComposite extends ArtefactTypeResume implements IArtefactTypeResumeComposite {
public static function is_singular() {
return true;
......@@ -567,21 +588,10 @@ abstract class ArtefactTypeResumeComposite extends ArtefactTypeResume {
);
}
/**
* This function should return a snippet of javascript
* to be plugged into a table renderer instantiation
* it comprises the cell function definition
*/
public static abstract function get_tablerenderer_js();
public static abstract function get_tablerenderer_title_js_string();
public static function get_tablerenderer_extra_js_string() {
return '';
}
public static abstract function get_tablerenderer_body_js_string();
public static function get_tablerenderer_attachments_js_string(){
return '';
}
......@@ -594,13 +604,6 @@ abstract class ArtefactTypeResumeComposite extends ArtefactTypeResume {
return $data;
}
/**
* This function should return an array suitable to
* put into the 'elements' part of a pieform array
* to generate a form to add an instance
*/
public static abstract function get_addform_elements();
/**
* This function processes the form for the composite
* @throws Exception
......
......@@ -12,11 +12,42 @@
defined('INTERNAL') || die();
/**
* Helper interface to hold IPluginBlocktype's abstract static methods
*/
interface IPluginBlocktype {
public static function get_title();
public static function get_description();
public static function get_categories();
public static function render_instance(BlockInstance $instance, $editing=false);
/**
* If this blocktype contains artefacts, and uses the artefactchooser
* Pieform element to choose them, this method must return the definition
* for the element.
*
* This is used in view/artefactchooser.json.php to build pagination for
* the element.
*
* The element returned MUST have the name key set to either 'artefactid'
* or 'artefactids', depending on whether 'selectone' is true or false.
*
* The element must also have the 'blocktype' key set to the name of the
* blocktype that the form is for.
*
* @param mixed $default The default value for the element
*/
public static function artefactchooser_element($default=null);
}
/**
* Base blocktype plugin class
* @abstract
*/
abstract class PluginBlocktype extends Plugin {
abstract class PluginBlocktype extends Plugin implements IPluginBlocktype {
public static function get_plugintype_name() {
return 'blocktype';
......@@ -52,8 +83,6 @@ abstract class PluginBlocktype extends Plugin {
return false;
}
public static abstract function get_title();
/**
* Allows block types to override the instance's title.
*
......@@ -62,10 +91,6 @@ abstract class PluginBlocktype extends Plugin {
public static function override_instance_title(BlockInstance $instance) {
}
public static abstract function get_description();
public static abstract function get_categories();
public static function get_viewtypes() {
static $viewtypes = null;
......@@ -79,8 +104,6 @@ abstract class PluginBlocktype extends Plugin {
return $viewtypes;
}
public static abstract function render_instance(BlockInstance $instance, $editing=false);
/**
* This function must be implemented in the subclass if it requires
* javascript. It returns an array of javascript files, either local
......@@ -96,24 +119,6 @@ abstract class PluginBlocktype extends Plugin {
public static function get_instance_inline_javascript(BlockInstance $instance) {
}
/**
* If this blocktype contains artefacts, and uses the artefactchooser
* Pieform element to choose them, this method must return the definition
* for the element.
*
* This is used in view/artefactchooser.json.php to build pagination for
* the element.
*
* The element returned MUST have the name key set to either 'artefactid'
* or 'artefactids', depending on whether 'selectone' is true or false.
*
* The element must also have the 'blocktype' key set to the name of the
* blocktype that the form is for.
*
* @param mixed $default The default value for the element
*/
public static abstract function artefactchooser_element($default=null);
/**
* subclasses can override this if they need to do something a bit special
* eg more than just what the BlockInstance->delete function does.
......
......@@ -14,6 +14,21 @@ defined('INTERNAL') || die();
require_once('view.php');
require_once(get_config('docroot') . '/artefact/lib.php');
/**
* Helper interface to hold PluginExport's abstract static methods
*/
interface IPluginExport {
/**
* A human-readable title for the export
*/
public static function get_title();
/**
* A human-readable description for the export
*/
public static function get_description();
}
/**
* Base class for all Export plugins.
*
......@@ -25,7 +40,7 @@ require_once(get_config('docroot') . '/artefact/lib.php');
* implement zipping the export in a method in this class to reduce
* duplication.
*/
abstract class PluginExport extends Plugin {
abstract class PluginExport extends Plugin implements IPluginExport {
/**
* Export all views owned by this user
......@@ -89,16 +104,6 @@ abstract class PluginExport extends Plugin {
}
}
/**
* A human-readable title for the export
*/
abstract public static function get_title();
/**
* A human-readable description for the export
*/
abstract public static function get_description();
/**
* Perform the export and return the path to the resulting file.
*
......
......@@ -25,9 +25,26 @@ abstract class PluginGrouptype extends Plugin {
}
/**
* Where is the syntax error?
* Helper interface to hold GroupType's abstract static methods
*/
abstract class GroupType {
interface IGroupType {
public static function allowed_join_types();
public static function user_allowed_join_types($user);
/**
* Returns the roles this group type implements
*/
public static function get_roles();
public static function get_view_moderating_roles();
public static function get_view_assessing_roles();
public static function default_artefact_rolepermissions();
}
abstract class GroupType implements IGroupType {
public function install() {
......@@ -59,10 +76,6 @@ abstract class GroupType {
}
}
public static abstract function allowed_join_types();
public static abstract function user_allowed_join_types($user);
/**
* Returns whether the currently logged in user can create a group of this
* grouptype
......@@ -79,19 +92,7 @@ abstract class GroupType {
return true;
}
/**
* Returns the roles this group type implements
*/
public static abstract function get_roles();
public static abstract function get_view_moderating_roles();
public static abstract function get_view_assessing_roles();
public static function get_group_artefact_plugins() {
return array('file');
}
public static abstract function default_artefact_rolepermissions();
}
......@@ -1986,26 +1986,10 @@ class PluginImportLeap extends PluginImport {
}
}
/**
* Base class for artefact plugin implementations of LEAP import
*
* Any artefact plugin wanting to implement import needs to extend this class
* in the file artefact/<plugin>/import/leap/lib.php.
*
* TODO: link to wiki docs for more info
* Helper interface to hold LeapImportArtefactPlugin's abstract static methods
*/
abstract class LeapImportArtefactPlugin {
/**
* Runs as the importer is starting up, giving the plugin a chance to do
* some initialisation.
*
* @param PluginImportLeap $importer The importer
*/
public static function setup(PluginImportLeap $importer) {
}
interface ILeapImportArtefactPlugin {
/**
* Given an entry, should return a list of the possible ways that it could
* be imported by this plugin.
......@@ -2053,7 +2037,82 @@ abstract class LeapImportArtefactPlugin {
* @param PluginImportLeap $importer The importer
* @return array A list of strategies that could be used to import this entry
*/
abstract public static function get_import_strategies_for_entry(SimpleXMLElement $entry, PluginImportLeap $importer);
public static function get_import_strategies_for_entry(SimpleXMLElement $entry, PluginImportLeap $importer);
/**
* Converts an entry into the appropriate artefacts using the given
* strategy.
*
* The strategy will be one of ones this plugin previously said would be
* possible for this entry. This method may throw an ImportException if it
* is not.
*
* This method is quite tied to get_import_strategies_for_entry: if that
* method exports a certain strategy (with a certain list of other required
* entries), then if that strategy is chosen, this method will be invoked
* with that strategy and that list of other required entries. HOWEVER, you
* cannot assume that both method calls will happen in the same request - a
* UI may be presented to the user to make them choose strategies in
* between these steps, for example. So don't store state between them!
*
* Regarding other entries: based on the previous statement, this class
* said it required them to import this entry, so they should be necessary
* to complete the import of the entry. Alternatively, perhaps you
* recognise that importing them makes no sense when you import this entry.
* But be aware that your class is denying these entries to other classes
* if you do this!
*
* This method should return a list of entry ID => (list of artefact IDs):
*
* array(
* [entryid:string] => array([artefactid:int], [artefactid:int], ...),
* [entryid:string] => array([artefactid:int], [artefactid:int], ...),
* ...
* )
*
* This list informs the importer of how each entry was converted into
* artefact(s). Often, an entry will be converted into just one artefact,
* but there's no reason why it might not be convereted into more.
*
* This information is used by setup_relationships() hooks to work out how
* entries were converted to artefacts, so for example, files can be
* attached to blog posts even though the files and blog posts were
* imported by different plugins.
*
* @param SimpleXMLElement $entry The entry to import
* @param PluginImportLeap $importer The importer
* @param int $strategy The strategy to use (should be a class
* constant on your class, see the documentation
* of get_import_strategies_for_entry for more
* information)
* @param array $otherentries A list of entry IDs that this class
* previously said were required to import
* the entry
* @throws ImportException If the strategy is unrecognised
* @return array A list describing what artefacts were created by the
* import of each entry
*/
public static function import_using_strategy(SimpleXMLElement $entry, PluginImportLeap $importer, $strategy, array $otherentries);
}
/**
* Base class for artefact plugin implementations of LEAP import
*
* Any artefact plugin wanting to implement import needs to extend this class
* in the file artefact/<plugin>/import/leap/lib.php.
*
* TODO: link to wiki docs for more info
*/
abstract class LeapImportArtefactPlugin implements ILeapImportArtefactPlugin {
/**
* Runs as the importer is starting up, giving the plugin a chance to do
* some initialisation.
*
* @param PluginImportLeap $importer The importer
*/
public static function setup(PluginImportLeap $importer) {
}
/**
* The first step in the interactive import process.
......@@ -2209,61 +2268,6 @@ abstract class LeapImportArtefactPlugin {
}
}
/**
* Converts an entry into the appropriate artefacts using the given
* strategy.
*
* The strategy will be one of ones this plugin previously said would be
* possible for this entry. This method may throw an ImportException if it
* is not.
*
* This method is quite tied to get_import_strategies_for_entry: if that
* method exports a certain strategy (with a certain list of other required
* entries), then if that strategy is chosen, this method will be invoked
* with that strategy and that list of other required entries. HOWEVER, you
* cannot assume that both method calls will happen in the same request - a
* UI may be presented to the user to make them choose strategies in
* between these steps, for example. So don't store state between them!
*
* Regarding other entries: based on the previous statement, this class
* said it required them to import this entry, so they should be necessary
* to complete the import of the entry. Alternatively, perhaps you
* recognise that importing them makes no sense when you import this entry.
* But be aware that your class is denying these entries to other classes
* if you do this!
*
* This method should return a list of entry ID => (list of artefact IDs):
*
* array(
* [entryid:string] => array([artefactid:int], [artefactid:int], ...),
* [entryid:string] => array([artefactid:int], [artefactid:int], ...),
* ...
* )
*
* This list informs the importer of how each entry was converted into
* artefact(s). Often, an entry will be converted into just one artefact,
* but there's no reason why it might not be convereted into more.
*
* This information is used by setup_relationships() hooks to work out how
* entries were converted to artefacts, so for example, files can be
* attached to blog posts even though the files and blog posts were
* imported by different plugins.
*
* @param SimpleXMLElement $entry The entry to import
* @param PluginImportLeap $importer The importer
* @param int $strategy The strategy to use (should be a class
* constant on your class, see the documentation
* of get_import_strategies_for_entry for more
* information)
* @param array $otherentries A list of entry IDs that this class
* previously said were required to import
* the entry
* @throws ImportException If the strategy is unrecognised
* @return array A list describing what artefacts were created by the
* import of each entry
*/
abstract public static function import_using_strategy(SimpleXMLElement $entry, PluginImportLeap $importer, $strategy, array $otherentries);
/**
* Gives plugins a chance to import author data
*
......
......@@ -11,11 +11,27 @@
defined('INTERNAL') || die();
/**
* Helper interface to hold PluginImport's abstract static methods
*/
interface IPluginImport {
/**
* validate the import data that we have after the file has been fetched.
* This is static, because the data may need to be validated earlier than setting up everything else
* For example, in the case of the administrator adding a user manually from a Leap2A file,
* we want to validate the leap data before creating the user record.
*
* @param array $importdata usually what ImportTransporter::files_info returns
* @throws ImportException
*/
public static function validate_transported_data(ImporterTransport $transporter);
}
/**
* base class for imports.
* handles queuing and sets up some basic helper functions
*/
abstract class PluginImport extends Plugin {
abstract class PluginImport extends Plugin implements IPluginImport {
// How to import a new entry
const DECISION_IGNORE = 1; // ignore imported entries and keep existing artefacts
......@@ -178,17 +194,6 @@ abstract class PluginImport extends Plugin {
return $i;
}
/**
* validate the import data that we have after the file has been fetched.
* This is static, because the data may need to be validated earlier than setting up everything else
* For example, in the case of the administrator adding a user manually from a Leap2A file,
* we want to validate the leap data before creating the user record.
*