Class midcom_baseclasses_components_navigation

Description

Base class to encaspulate a NAP interface. Does all the neccessary work for setting the object to the right topic. you just have to fill the gaps for getting the leaves and node data.

Normally, it is enough if you override the members list_leaves() and get_node(). You usually don't even need to write a constructor, as the default one should be enough for your purposes. If you need extra initialization work done when "entering" a topic, use the event handler _on_set_object().

Located in /midcom/baseclasses/components/navigation.php (line 23)


	
			
Direct descendents
Class Description
 class midcom_helper_helloworld_navigation MidCOM Hello World NAP interface class.
 class midcom_helper_search_navigation MidCOM Indexer Front-End, NAP interface Class
 class net_nemein_calendar_navigation Calendar NAP interface class.
 class net_nemein_hourview_navigation Net.nemein.hourview NAP interface class.
 class no_odindata_quickform_navigation Base class to encaspulate a NAP interface. Does all the neccessary work for setting the object to the right topic. you just have to fill the gaps for getting the leaves and node data.
Variable Summary
Method Summary
 midcom_baseclasses_components_navigation midcom_baseclasses_components_navigation ()
 Array get_leaves ()
 Array get_node ([Array $toolbar = null])
 void initialize (string $component)
 void set_object (MidgardTopic $topic, bool 1)
 bool _on_set_object ()
Variables
string $_component = '' (line 38)

Internal helper, holds the name of the component. Should be used whenever the components' name is required instead of hardcoding it.

Component state variable, set during startup. There should be no need to change it in most cases.

  • access: protected
Array $_component_data = null (line 45)

Component data storage area.

Component state variable, set during startup. There should be no need to change it in most cases.

  • access: protected
midcom_helper_configuration $_config = null (line 59)

The current configuration.

Component state variable, set during startup. There should be no need to change it in most cases.

  • access: protected
midcom_helper_services_i18n $_i18n = null (line 66)

A handle to the i18n service.

Component state variable, set during startup. There should be no need to change it in most cases.

  • access: protected
midcom_services__i18n_l10n $_l10n = null (line 73)

The components' L10n string database

Component state variable, set during startup. There should be no need to change it in most cases.

  • access: protected

Redefined in descendants as:
midcom_services__i18n_l10n $_l10n_midcom = null (line 80)

The global MidCOM string database

Component state variable, set during startup. There should be no need to change it in most cases.

  • access: protected

Redefined in descendants as:
MidgardTopic $_topic = null (line 52)

The topic for which we are handling a requiest.

Component state variable, set during startup. There should be no need to change it in most cases.

  • access: protected
Methods
Constructor midcom_baseclasses_components_navigation (line 88)

Create the navigation instance, the constructor doesn't do anything yet, startup is handled by initialize().

midcom_baseclasses_components_navigation midcom_baseclasses_components_navigation ()
get_leaves (line 169)

Leaf listing function, the default implementation returns an empty array indicating no leaves. Note, that the active leaf index set by the other parts of the component must match one leav out of this list.

Here are some code fragments, that you usually connect through some kind of while $articles->fetch() loop:

  1. <?php
  2. // Prepare the toolbar
  3. $toolbar[50] = Array(
  4. MIDCOM_TOOLBAR_URL => '',
  5. MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('edit'),
  6. MIDCOM_TOOLBAR_HELPTEXT => null,
  7. MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/edit.png',
  8. MIDCOM_TOOLBAR_ENABLED => true
  9. );
  10. $toolbar[51] = Array(
  11. MIDCOM_TOOLBAR_URL => '',
  12. MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('delete'),
  13. MIDCOM_TOOLBAR_HELPTEXT => null,
  14. MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/trash.png',
  15. MIDCOM_TOOLBAR_ENABLED => true
  16. );
  17.  
  18. while ($articles->fetch ()) {
  19. // Match the toolbar to the correct URL.
  20. $toolbar[50][MIDCOM_TOOLBAR_URL] = "edit/{$articles->id}.html";
  21. $toolbar[51][MIDCOM_TOOLBAR_URL] = "delete/{$articles->id}.html";
  22.  
  23. $leaves[$articles->id] = array
  24. (
  25. MIDCOM_NAV_SITE => Array
  26. (
  27. MIDCOM_NAV_URL => $articles->name . ".html",
  28. MIDCOM_NAV_NAME => ($articles->title != "") ? $articles->title : $articles->name
  29. ),
  30. MIDCOM_NAV_ADMIN => Array
  31. (
  32. MIDCOM_NAV_URL => "view/" . $articles->id,
  33. MIDCOM_NAV_NAME => ($articles->title != "") ? $articles->title : $articles->name
  34. ),
  35. MIDCOM_NAV_GUID => $articles->guid(),
  36. MIDCOM_NAV_TOOLBAR => $toolbar,
  37. MIDCOM_META_CREATOR => $articles->creator,
  38. MIDCOM_META_EDITOR => $articles->revisor,
  39. MIDCOM_META_CREATED => $articles->created,
  40. MIDCOM_META_EDITED => $articles->revised
  41. )
  42. }
  43.  
  44. return $leaves;
  45.  
  46. ?>

  • return: NAP compilant list of leaves.
Array get_leaves ()

Redefined in descendants as:
get_node (line 203)

Return the node configuration. This defaults to use the topic the NAP instance has been set to directly. You can usually fall back to this behavoir safely, adding a toolbar using the $toolbar parameter in child classes.

So you'd probably do something like this:

  1. <?php
  2. $toolbar = Array();
  3. $toolbar[100] = Array
  4. (
  5. MIDCOM_TOOLBAR_URL => 'config.html',
  6. MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('component configuration'),
  7. MIDCOM_TOOLBAR_HELPTEXT => $this->_l10n_midcom->get('component configuration helptext'),
  8. MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_folder-properties.png',
  9. MIDCOM_TOOLBAR_ENABLED => true
  10. );
  11. return parent::get_node($toolbar);
  12. ?>

The default uses the extra field of the topic as NAV_NAME, which is the default set by MidCOM AIS and shouldn't be changed therefore.

  • return: NAP compilant node declaration
Array get_node ([Array $toolbar = null])
  • Array $toolbar: Set this parameter in child classes calling this base method to add a toolbar to the default node listing. This parameter is not set by the framework and can safely be omitted in the average base class.

Redefined in descendants as:
initialize (line 98)

Initialize the NAP class, sets all state variables.

void initialize (string $component)
  • string $component: The name of the component.
set_object (line 225)

Set a new content object. This updates the local configuration copy with the topic in question. It calls the event handler _on_set_object after initializing everything in case you need to do some custom initializations as well.

void set_object (MidgardTopic $topic, bool 1)
  • MidgardTopic $topic: The topic to pocess.
  • bool 1: Indicating success.

Redefined in descendants as:
_on_set_object (line 242)

Event handler called after a new topic has been set. The configuration is already loaded at this point.

  • return: Set this to false to indicate that you could not set this instance to the topic. NAP will abort loading this node and log the error accordingly. Return true if everything is fine.
  • access: protected
bool _on_set_object ()

Documentation generated on Mon, 21 Nov 2005 18:20:32 +0100 by phpDocumentor 1.3.0RC3