Example #1
0
 private function _get_css_classes($child, $item, $item_counter, $item_count)
 {
     $classes = array();
     if ($child[MIDCOM_NAV_TYPE] === 'node') {
         // If the listing of nodes is set to false, skip this item and proceed to the next
         if ($this->list_nodes === false) {
             continue;
         }
         if ($item[MIDCOM_NAV_ID] === $this->_nap->get_current_node() && (!$this->_nap->get_current_leaf() || !$this->_nap->get_leaf($this->_nap->get_current_leaf()))) {
             $classes[] = $this->css_active;
         }
         if (in_array($item[MIDCOM_NAV_ID], $this->node_path, true)) {
             $classes[] = $this->css_selected;
         }
         if ($this->component_name_to_class) {
             $classes[] = str_replace('.', '_', $item[MIDCOM_NAV_COMPONENT]);
         }
     } else {
         // Place the corresponding css class for the currently active leaf)
         if ($item[MIDCOM_NAV_ID] === $this->_nap->get_current_leaf()) {
             $classes[] = $this->css_active;
             $classes[] = $this->css_selected;
         }
     }
     // Check if the URL name is supposed to be drawn
     if ($this->url_name_to_class) {
         $classes[] = str_replace('/', '', $item[MIDCOM_NAV_URL]);
     }
     if ($this->first_and_last_to_class) {
         if ($item_count == 1) {
             $classes[] = $this->css_first_last;
         } else {
             if ($item_counter == 1) {
                 $classes[] = $this->css_first;
             } else {
                 if ($item_counter == $item_count) {
                     $classes[] = $this->css_last;
                 }
             }
         }
     }
     if ($this->has_children_to_class) {
         if (!$this->list_leaves) {
             $children = $this->_nap->list_nodes($child[MIDCOM_NAV_ID]);
         } else {
             $children = $this->_nap->list_child_elements($child[MIDCOM_NAV_ID]);
         }
         if (is_array($children) && count($children) > 0) {
             $classes[] = $this->css_has_children;
         }
     }
     // Add information about the object's status
     if ($this->object_status_to_class && isset($item[MIDCOM_NAV_OBJECT]) && ($css_status_class = midcom::get('metadata')->get_object_classes($item[MIDCOM_NAV_OBJECT]))) {
         $classes[] = $css_status_class;
     }
     return implode(' ', $classes);
 }
Example #2
0
 /**
  * Handle a request.
  *
  * The URL of the component that is used to handle the request is obtained automatically.
  * If the handler hook returns false (i.e. handling failed), it will produce an error page.
  *
  * @param midcom_baseclasses_components_interface $handler The component's main handler class
  */
 public function run(midcom_baseclasses_components_interface $handler)
 {
     $result = $handler->handle();
     if (false === $result) {
         throw new midcom_error("Component " . $this->get_key(MIDCOM_CONTEXT_COMPONENT) . " failed to handle the request");
     } else {
         if (is_object($result) && $result instanceof midcom_response) {
             $result->send();
             //this will exit
         }
     }
     // Retrieve Metadata
     $nav = new midcom_helper_nav();
     if ($nav->get_current_leaf() === false) {
         $meta = $nav->get_node($nav->get_current_node());
     } else {
         $meta = $nav->get_leaf($nav->get_current_leaf());
     }
     if ($this->get_key(MIDCOM_CONTEXT_PERMALINKGUID) === null) {
         $this->set_key(MIDCOM_CONTEXT_PERMALINKGUID, $meta[MIDCOM_NAV_GUID]);
     }
     if ($this->get_key(MIDCOM_CONTEXT_PAGETITLE) == '') {
         $this->set_key(MIDCOM_CONTEXT_PAGETITLE, $meta[MIDCOM_NAV_NAME]);
     }
 }