midcom_baseclasses_components_interfaceBaseclass to use for the component interface in MIDCOM.
The interface presented here superseeds all original component interface classes (COMPONENT, CONTENTADMIN, MIDCOM and NAP). The class uses an event based approache for subclasses to influence the default behavoir.
The actual implementation should be enough for most smaller components, as the classes behavoir is widely configurable. You should not override any of the base classes interface methods if you can avoid it. If you find that an event handler is missing, please contact the MidCOM development team for some advise.
Quick start
This class does a lot of things automatically for you, described below. If you are not interested in the gory details though, here is a quick list of what you have to know (but don't complain if I have missed anything), and do these things after calling the base class constructor:
TODO: Document
The following options can be used to parametrize the components startup and operation. See the individual member documentation for now.
This class now does an awful lot of work for you, you just need to configure it to have the right names and places to look for. It is designed to fit in the current component wildlife with as little collateral damage as possible, but as always, a 100% transparent implementation is both not wanted and not sensible.
The most important change is that all four original component interface concepts have been unified into a single class supporting the full interface. Obviously, MidCOMs component loader had to be adapted to this operation.
At this time, the core will not be able to handle the original pre-2.4 interface any longer. Though it would be possible to implement an according proxy class, I have not yet done that, so right now all components need to be adapted to the new interface.
Actually, you should not need to overwrite any event handler for almost all components I currently know of. Ultimately, this is a proxy class to the actual component code. Its main goals are to automate these tasks:
Usually you will be done at this point, as all other interaction can safely be done by the component. Unless, of course, you have some special requirements.
One thing, which I have seen quite often in components, is the initialize method loading the default schema. While I actually do not endorse this behavoir, schemas should only be loaded on demand during runtime (especially since they are configurable), you should now add code like that to the _on_initialize() event handler, which will be exectued at about the same time as the original implementation would have been.
Advanced notes for Core Developers
The biggest change relevant for the core is the fact, that the various interface directives for on-site and content-admin usage have changed (they were named equally in both of the original concepts). Therefore, if you handle components directly, you need to adapt your code to match the new interface outlined below.
Example usage
The average component will require something like this, part one is the component Manifest:
'name' => 'de.linkm.taviewer',
'purecode' => false,
'version' => 1,
'privileges' => Array
(
'read' => MIDCOM_PRIVILEGE_ALLOW,
'write' => Array (MIDCOM_PRIVILEGE_DENY, MIDCOM_PRIVILEGE_ALLOW)
),
'class_definitions' => Array('my_sepcial_mgd_schema_class.inc'),See the class midcom_core_manifest for further details.
Built on this, we add the following interface class:
- class de_linkm_taviewer_interface extends midcom_baseclasses_components_interface
- {
- function de_linkm_taviewer_interface()
- {
- parent::midcom_baseclasses_components_interface();
- $this->_component = 'de.linkm.taviewer';
- $this->_autoload_files = Array('viewer.php', 'admin.php', 'navigation.php', 'my_special_mgd_schema_class.php');
- $this->_autoload_libraries = Array('midcom.helper.datamanager');
- }
- function _on_reindex($topic, $config, &$indexer)
- {
- $qb = $_MIDCOM->dbfactory->new_query_builder('midcom_baseclasses_database_article');
- $qb->add_constraint('topic', '=', $topic->id);
- $result = $_MIDCOM->dbfactory->exec_query_builder($qb);
- if ($result === false)
- {
- debug_add("Could not query the articles for {$topic->id}, skipping indexing.");
- }
- foreach ($articles as $article)
- {
- $datamanager = new midcom_helper_datamanager($config->get('schemadb'));
- if (! $datamanager)
- {
- debug_add('Warning, failed to create a datamanager instance with this schemapath:' . $this->_config->get('schemadb'),
- MIDCOM_LOG_WARN);
- continue;
- }
- if (! $datamanager->init($article))
- {
- debug_add("Warning, failed to initialize datamanager for Article {$article->id}. See Debug Log for details.", MIDCOM_LOG_WARN);
- debug_print_r('Article dump:', $article);
- continue;
- }
- $indexer->index($datamanager);
- }
- }
- function _on_resolve_permalink($topic, $config, $guid)
- {
- $article = new midcom_baseclasses_database_article($guid);
- if ( ! $article
- || $article->topic != $topic->id)
- {
- return null;
- }
- if ($article->name == 'index')
- {
- return '';
- }
- return "{$article->name}.html";
- }
- }
Located in /midcom.core/midcom/baseclasses/components/interface.php (line 196)
PEAR | --midcom_baseclasses_core_object | --midcom_baseclasses_components_interface
| Class | Description |
|---|---|
de_bitfolge_feedcreator_interface
|
RSS and Atom feed generator library http://www.bitfolge.de/rsscreator-en.html Available under LGPL license |
de_linkm_events_interface
|
Events MidCOM interface class. |
de_linkm_fontrenderer_interface
|
fontrenderer MidCOM interface class. |
de_linkm_newsticker_interface
|
Newsticker MidCOM interface class. |
de_linkm_sitemap_interface
|
Sitemap MidCOM interface class. |
de_linkm_taviewer_interface
|
TAViewer MidCOM interface class. |
fi_mik_lentopaikkakisa_interface
|
Flight competition MidCOM interface class. |
midcom_admin_acls_interface
|
|
|
|
midcom_admin_aegir_interface
|
Created on Aug 3, 2005 |
midcom_admin_content_interface
|
MidCOM AIS interface class. |
midcom_admin_content2_interface
|
|
midcom_admin_core_interface
|
|
midcom_admin_help_interface
|
|
midcom_admin_simplecontent_interface
|
|
midcom_admin_styleeditor_interface
|
|
midcom_tests_interface
|
|
midcom_helper_datamanager2_interface
|
Datamanger 2 Component Interface Class. This is a pure code library. |
midcom_helper_helloworld_interface
|
MidCOM Hello World component interface class. |
midcom_helper_imagepopup_interface
|
|
midcom_helper_search_interface
|
MidCOM Indexer Front-End |
midcom_helper_xml_interface
|
XML Component Interface Class. This is a pure code library. |
midcom_services_at_interface
|
At service library, this interface class is used to register jobs to the service. |
midgard_admin_acl_interface
|
ACL editor handler |
midgard_admin_sitegroup_interface
|
XML Component Interface Class. This is a pure code library. |
midgard_admin_sitewizard_interface
|
Midgard Site Wizard interface |
net_nehmer_account_interface
|
Account Manager MidCOM interface class. |
net_nehmer_blog_interface
|
TAViewer MidCOM interface class. |
net_nehmer_branchenbuch_interface
|
Branchenbuch (Yellow Pages) MidCOM interface class. |
net_nehmer_buddylist_interface
|
Marketplace component. |
net_nehmer_comments_interface
|
Comments component. |
net_nehmer_jobmarket_interface
|
Job market component. |
net_nehmer_mail_interface
|
On-Site E-Mail System MidCOM interface class. |
net_nehmer_markdown_interface
|
Markdown library, based on lib_markdown. |
net_nehmer_marketplace_interface
|
Marketplace component. |
net_nehmer_publications_interface
|
Publications MidCOM interface class. |
net_nehmer_static_interface
|
TAViewer MidCOM interface class. |
net_nemein_bookmarks_interface
|
Bookmarks MidCOM interface class. |
net_nemein_calendar_interface
|
Calendar MidCOM interface class. |
net_nemein_discussion_interface
|
Forum MidCOM interface class. |
net_nemein_hourview_interface
|
Net.nemein.hourview component interface class. |
net_nemein_hourview2_interface
|
Net.nemein.hourview2 component interface class. |
net_nemein_incidentdb_interface
|
IncidentDB MidCOM interface class. |
net_nemein_opendeploydumper_interface
|
Net.nemein.opendeploydumper component interface class. |
net_nemein_orders_interface
|
Orders MidCOM interface class. |
net_nemein_organizations_interface
|
Group viewer MidCOM interface class. |
net_nemein_payment_interface
|
Payment library MidCOM interface class. |
net_nemein_personnel_interface
|
Person viewer MidCOM interface class. |
net_nemein_ping_interface
|
Weblog pinger library based on Weblog_Pinger PHP Class Library by Rogers Cadenhead http://www.cadenhead.org/workbench/weblog-pinger |
net_nemein_quickpoll_interface
|
Quickpoll MidCOM interface class. |
net_nemein_redirector_interface
|
Redirector MidCOM interface class. |
net_nemein_registrations_interface
|
Event registration system. |
net_nemein_repeathandler_interface
|
OpenPSA contact widget for displaying a contact person as hCard |
net_nemein_rss_interface
|
RSS Aggregator MidCOM interface class. |
net_nemein_simpledb_interface
|
Simpledb MidCOM interface class. |
net_nemein_supportview_interface
|
OpenPSA Supporview MidCOM interface class. |
net_nemein_wiki_interface
|
Wiki MidCOM interface class. |
net_siriux_photos_interface
|
Photo Gallery MidCOM interface class. |
no_bergfald_objectbrowser_interface
|
|
no_bergfald_rcs_interface
|
|
no_odindata_quickform_interface
|
|
org_openpsa_calendar_interface
|
OpenPSA group calendar |
org_openpsa_calendarwidget_interface
|
OpenPSA calendar widget for displaying week, month and day calendars |
org_openpsa_contacts_interface
|
OpenPSA Contact registers/user manager |
org_openpsa_contactwidget_interface
|
OpenPSA contact widget for displaying a contact person as hCard |
org_openpsa_core_interface
|
OpenPSA core stuff |
org_openpsa_directmarketing_interface
|
OpenPSA direct marketing and mass mailing component |
org_openpsa_documents_interface
|
OpenPSA Documents document management system |
org_openpsa_helpers_interface
|
OpenPSA helpers library, helpers used around OpenPSA. |
org_openpsa_imp_interface
|
OpenPSA Jabber Instant Messaging Component |
org_openpsa_interviews_interface
|
Phone interview MidCOM interface class. |
org_openpsa_invoices_interface
|
Invoice management MidCOM interface class. |
org_openpsa_jabber_interface
|
OpenPSA Jabber Instant Messaging Component |
org_openpsa_mail_interface
|
OpenPSA mail library, handles encoding/sending and decoding. |
org_openpsa_mypage_interface
|
OpenPSA Personal Summary component |
org_openpsa_notifications_interface
|
OpenPSA notifications manager |
org_openpsa_products_interface
|
|
org_openpsa_projects_interface
|
OpenPSA group projects |
org_openpsa_qbpager_interface
|
OpenPSA qbpager library, handles paging of QB resultsets. |
org_openpsa_queries_interface
|
OpenPSA queries library, handles encoding/sending and decoding. |
org_openpsa_relatedto_interface
|
OpenPSA relatedto library, handled saving and retvieving "related to" information |
org_openpsa_reports_interface
|
OpenPSA Projects reporting engine |
org_openpsa_sales_interface
|
OpenPSA direct marketing and mass mailing component |
org_openpsa_smslib_interface
|
OpenPSA SMS library, handles sending SMS/MMS |
org_routamc_positioning_interface
|
Positioning library interface |
se_anykey_activecalendar_interface
|
Active Calendar is PHP Class, that generates calendars (month or year view) as a HTML Table (XHTML-Valid). |
se_anykey_mmslib_interface
|
mms library http://www.hellkvist.org/software/ Available under GPL license |
midcom_helper_configuration
get_config_for_topic
([midcom_baseclasses_database_topic $topic = null])
bool
_on_check_document_permissions
(midcom_services_indexer_document &$document, midcom_helper_configuration $config, MidgardTopic $topic)
bool
_on_reindex
(MidgardTopic $topic, midgard_helper_config $config, midcom_service_indexer &$indexer)
string
_on_resolve_permalink
(midcom_baseclasses_database_topic $topic, midcom_helper_configuration $config, string $guid)
mixed
$_acl_privileges
= array() (line 287)
string
$_ais_class_suffix
= 'admin' (line 251)
This is the class suffix used when constructing the AIS handler class.
Component configuration variable, must set during the construction of the inherited classes.
It is appended to the component class prefix, f.x. resulting in de_linkm_taviewer_admin (as a default).
mixed
$_autoload_class_definitions
= array() (line 282)
Array
$_autoload_files
= array() (line 219)
A list of files, relative to the components root directory, that should be loaded during initialization.
Component configuration variable, must set during the construction of the inherited classes.
Array
$_autoload_libraries
= array() (line 228)
A list of libraries which should by loaded during initialization.
Component configuration variable, must set during the construction of the inherited classes.
This will be done before actually loading the script files from _autoload_files.
string
$_component
= '' (line 211)
The name of the component, e.g. de.linkm.taviewer
Component configuration variable, must set during the construction of the inherited classes.
string
$_component_path
= '' (line 309)
The full path to the components' root directory. Used for loading files.
Current object state, useful during initialization and automatically populated before _on_initialization is called.
string
$_config_snippet_name
= 'config' (line 242)
This is used during initialization when loading the default configurations from the filesystem ($prefix/config/$name.inc) and the snippetdirs ($GLOBALS['midcom_config']['midcom_sgconfig_basedir']/$component/$name).
Component configuration variable, must set during the construction of the inherited classes.
They will be merged and placed into the component data store under a key with the same name then the snippet as a midcom_helper_configuration object.
Set this to null to disable automatic configuration handling.
mixed
$_context_data
= array() (line 531)
This variable holds the context-specific data during processing.
it is indexed first by context ID and second by a string key. Currently defined keys are:
Array
$_data
= null (line 321)
The component-specific data storage, hold in the global Array $midcom_component_data, which is indexed by the component name.
Current object state, useful during initialization and automatically populated before _on_initialization is called.
It is created during initialization, and a referenc to the actual storagte is put into $_data.
midcom_core_manifest
$_manifest
= null (line 329)
The component manifest instance accociated with this component. Read-Only and automatically populated during initialization.
Current object state, useful during initialization and automatically populated before _on_initialization is called.
string
$_nap_class_suffix
= 'navigation' (line 260)
This is the class suffix used when constructing the NAP handler class.
Component configuration variable, must set during the construction of the inherited classes.
It is appended to the component class prefix, f.x. resulting in de_linkm_taviewer_navigation (as a default).
object
$_nap_instance
= null (line 654)
The NAP interface instance from the component, initialized on demand.
mixed
$_purecode
= false (line 292)
string
$_site_class_suffix
= 'viewer' (line 269)
This is the class suffix used when constructing the on-site handler class.
Component configuration variable, must set during the construction of the inherited classes.
It is appended to the component class prefix, f.x. resulting in de_linkm_taviewer_viewer (as a default).
mixed
$_version
= 0 (line 277)
Initialize the class, nothing to do yet.
Relays the can_handle call to the component, instantinating a new AIS or Site class respecitvly. It will execute can_handle of that class, retruning its result to MidCOM.
Verif an indexer document's permissions.
It will call the corresponding event handler reading the topic configuration beforehand.
Configures the component for usage. The configuration is merged, and, if neccessary, an existing handler object is purged.
Returns the last error code of the component.
Returns the last error message of the component.
This is a small helper function which gets the full configuration set active for a given topic. If no topic is passed, the systemwide default configuration is returned.
Be aware, that this call does not check if the passed topic is actually handled by this component, as it is theoretically possible for components to drop configuration information on other topics as well.
Returns the currently selected leaf of the request.
Originally, this was relayed to the NAP instance. With the new component data framework, the NAP active leaf ID can be returned directly using the data key active_leaf.
Relays the handle call to the component.
Initializes the component. It will first load all dependent libraries and then include the snippets referenced by the component. The components local data storage area is initialized and referenced into the global storage area.
Finally, the on_init event handler is called.
This should not be overwritten by the client. Instead, use the on_initialize event handler.
This helper function reads a file from disk and evaluates its content as array.
This is essentially a simple Array($data\n) eval construct.
If the file does not exist, false is returned.
This function may be called statically.
This helper function reads a snippet and evaluates its content as array.
This is essentially a simple Array($data\n) eval construct.
If the snippet does not exist, false is returned.
This function may be called statically.
This new interface function will initiate a reindex run for the given component and topic. See the _on_reindex() event handler for details.
This interface function is used to check wether a component can handle a given GUID or not on site only. A topic is provided which limits the "scope" of the search accordingly. It can be safely assumed that the topic given is a valid topic in the MidCOM content tree (it is checked through NAP).
If the guid could be successfully resolved, an URL local to the given topic without a leading slash must be returned (f.x. 'article.html'), emtpy strings ('') are allowed indicating root page access. If the GUID is invalid, null will be returned.
This call is realyed to the component using the event handler _on_resolve_permalink(). Before that it will deduce the active configuration for the given topic.
Note, that this is the only event handler which has some kind of default implementation, see its documentation for details.
Retrieve all members of a given virtual group. This information may be cached by the framework.
Executio0n is relayed to the corresponding event handler.
Releays the set_object call to the nap instance. Checks if the NAP instance has already been created beforehand.
Relays the show content call to the component, invoking output.
This function delegates all watched operations, in two phases. First, the general _on_watched_operation handler is called, to allow for handling generic operations. After that, the individual watches are called, to allow for more specific processing.
Checks, wether an instance of the NAP interface class has already been created and creates it if not.
This check is only done during the set_object calls, which will always be the first calls in a sequence of NAP calls. (For performance reasons.)
Loads the configuration file specified by the component configuration
and constructs a midcom_helper_configuration object out of it. Both Component defaults and sitegroup-configuration gets merged. The resulting object is stored under the key 'config' in the components' data storage area.
Errors will be logged as MIDCOM_LOG_WARN but silently ignored. This should be viable, since as of MidCOM 2.4 the configuration class is more flexible when local and global configurations do not match.
Three files will be loaded in order:
Verif an indexer document's permissions. This is used for custom, advanced access control within a components domain.
This is an event handler which is called during MidCOMs component interaction. For most basic components, the default implementation should actually be enough.
The topic and configuration objects are passed for ease of use and performance, as they have already been prepared by the framework.
Usally, you want to limit the visibility of a document in the search result. You can do this by returning false in this function, the indexer will then skip this object before returning the resultset to the callee. You may modify the document that has been passed, to limit the information available to the client, though this should be avoided if possible.
This is an event handler, called after the basic component initialization has been done just before the initialize call will return to MidCOM.
This is an event handler which is called during MidCOMs component interaction. For most basic components, the default implementation should actually be enough.
It should prepare all neccessary information to start processing requests.
Unless you need more functionality then snippet and library loading, configuration merging and basic component data storage initialization, no further modification needs to be done.
Reindex the given topic. The complete configuration set is already available in $config. The original index records are already deleted, so you do not need to bother about this.
This is an event handler which is called during MidCOMs component interaction. For most basic components, the default implementation should actually be enough.
The default event handler does nothing.
This interface function is used to check wether a component can handle a given GUID or not on site only. A topic is provided which limits the "scope" of the search accordingly. It can be safely assumed that the topic given is a valid topic in the MidCOM content tree (it is checked through NAP).
This is an event handler which is called during MidCOMs component interaction. For most basic components, the default implementation should actually be enough.
If the guid could be successfully resolved, an URL local to the given topic without a leading slash must be returned (f.x. 'article.html'), emtpy strings ('') are allowed indicating root page access. If the GUID is invalid, null will be returned.
This call is realyed to the component using the event handler _on_resolve_permalink(). Before that it will deduce the active configuration for the given topic.
The information you return with this call (if no-null) will be considered cacheable by the content caching engine. Therefore you have to ensure that either the resolution is stable or that you configure the content cache accordingly if you have a match. The hard way is setting the no_cache flag in cases where you need full flexibility, but this should be avoided for the sake of performance if somehow possible. The more sophisticated alternative is therefore to selectivly invalidate all GUIDs that have their Permalink lookup affected.
Important Note:
Be aware that this is the only event handler at this time which has a real default implementation: If you do not override the base class implementation, it will iterate through all NAP leaves applicable to the node accociated with the topic. If a match is found, its local URL will be returned. This will not be terribly efficient, so you are strongly encouraged to have some more efficient solution instead. Obviously, if you override the function, you shouldn't call the base class implementation unless you really need it.
Retrieve all members of a given virtual group. This information may be cached by the framework.
This is an event handler which is called during MidCOMs component interaction. For most basic components, the default implementation should actually be enough.
This function is triggered at the end of the request for each watched create operation that has been done during the request.
This is an event handler which is called during MidCOMs component interaction. For most basic components, the default implementation should actually be enough.
It will be called once per operation and unique object, where object uniqueness is determined by the combination of object class and guid. The object has been refreshed before being passed to this event handler.
It is called after the generic _on_watched_operation event handler.
This function is triggered at the end of the request for each watched delete operation that has been done during the request.
This is an event handler which is called during MidCOMs component interaction. For most basic components, the default implementation should actually be enough.
It will be called once per operation and unique object, where object uniqueness is determined by the combination of object class and guid. The object has been refreshed before being passed to this event handler.
It is called after the generic _on_watched_operation event handler.
This function is triggered at the end of the request for each watched update operation that has been done during the request.
This is an event handler which is called during MidCOMs component interaction. For most basic components, the default implementation should actually be enough.
It will be called once per operation and unique object, where object uniqueness is determined by the combination of object class and guid. The object has been refreshed before being passed to this event handler.
It is called after the generic _on_watched_operation event handler.
This function is triggered at the end of the request for each watched operation that has been done during the request.
This is an event handler which is called during MidCOMs component interaction. For most basic components, the default implementation should actually be enough.
It will be called once per operation and unique object, where object uniqueness is determined by the combination of object class and guid. The object has been refreshed before being passed to this event handler.
Inherited From midcom_baseclasses_core_object
midcom_baseclasses_core_object::midcom_baseclasses_core_object()
Documentation generated on Tue, 15 Aug 2006 12:35:59 +0300 by phpDocumentor 1.3.0RC3