public function test_list_loaded_components() { $componentloader = new midcom_helper__componentloader(); $componentloader->load_all_manifests(); $this->assertEquals(array(), $componentloader->list_loaded_components()); }
/** * This helper is responsible for loading the leaves for a given node out of the * database. It will complete all default fields to provide full blown nap structures. * It will also build the base relative URLs which will later be completed by the * _get_leaves() interface functions. * * Important note: * - The IDs constructed for the leaves are the concatenation of the ID delivered by the component * and the topics' GUID. * * @param Array $node The node data structure for which to retrieve the leaves. * @return Array All leaves found for that node, in complete post processed leave data structures. */ private function _get_leaves_from_database($node) { $topic = $node[MIDCOM_NAV_OBJECT]; // Retrieve a NAP instance $interface = $this->_loader->get_interface_class($node[MIDCOM_NAV_COMPONENT]); if (!$interface) { debug_add("Could not get interface class of '{$node[MIDCOM_NAV_COMPONENT]}' to the topic {$topic->id}, cannot add it to the NAP list.", MIDCOM_LOG_ERROR); return null; } if (!$interface->set_object($topic)) { debug_print_r('Topic object dump:', $topic); throw new midcom_error("Cannot load NAP information, aborting: Could not set the nap instance of {$node[MIDCOM_NAV_COMPONENT]} to the topic {$topic->id}."); } $leafdata = $interface->get_leaves(); $leaves = array(); foreach ($leafdata as $id => $leaf) { // First, try to somehow gain both a GUID and a Leaf. if (!isset($leaf[MIDCOM_NAV_GUID]) && !isset($leaf[MIDCOM_NAV_OBJECT])) { debug_add("Warning: The leaf {$id} of topic {$topic->id} does set neither a GUID nor an object."); $leaf[MIDCOM_NAV_GUID] = null; $leaf[MIDCOM_NAV_OBJECT] = null; // Get the pseudo leaf score from the topic if ($score = $topic->get_parameter('midcom.helper.nav.score', "{$topic->id}-{$id}")) { $leaf[MIDCOM_NAV_SCORE] = (int) $score; } } else { if (!isset($leaf[MIDCOM_NAV_GUID])) { $leaf[MIDCOM_NAV_GUID] = $leaf[MIDCOM_NAV_OBJECT]->guid; } else { if (!isset($leaf[MIDCOM_NAV_OBJECT])) { try { $leaf[MIDCOM_NAV_OBJECT] = midcom::get('dbfactory')->get_object_by_guid($leaf[MIDCOM_NAV_GUID]); } catch (midcom_error $e) { } } } } if (!isset($leaf[MIDCOM_NAV_SORTABLE])) { $leaf[MIDCOM_NAV_SORTABLE] = true; } // Now complete the actual leaf information // Score if (!isset($leaf[MIDCOM_NAV_SCORE])) { if ($leaf[MIDCOM_NAV_OBJECT] && isset($leaf[MIDCOM_NAV_OBJECT]->metadata->score)) { $leaf[MIDCOM_NAV_SCORE] = $leaf[MIDCOM_NAV_OBJECT]->metadata->score; } else { $leaf[MIDCOM_NAV_SCORE] = 0; } } // NAV_NOENTRY Flag if (!isset($leaf[MIDCOM_NAV_NOENTRY])) { $leaf[MIDCOM_NAV_NOENTRY] = false; } // complete NAV_NAMES where necessary if (trim($leaf[MIDCOM_NAV_NAME]) == '') { $leaf[MIDCOM_NAV_NAME] = midcom::get('i18n')->get_string('unknown', 'midcom'); } // Some basic information $leaf[MIDCOM_NAV_TYPE] = 'leaf'; $leaf[MIDCOM_NAV_ID] = "{$node[MIDCOM_NAV_ID]}-{$id}"; $leaf[MIDCOM_NAV_NODEID] = $node[MIDCOM_NAV_ID]; $leaf[MIDCOM_NAV_RELATIVEURL] = $node[MIDCOM_NAV_RELATIVEURL] . $leaf[MIDCOM_NAV_URL]; if (!array_key_exists(MIDCOM_NAV_ICON, $leaf)) { $leaf[MIDCOM_NAV_ICON] = null; } // Save the original Leaf ID so that it is easier to query in topic-specific NAP code $leaf[MIDCOM_NAV_LEAFID] = $id; // The leaf is complete, add it. $leaves[$leaf[MIDCOM_NAV_ID]] = $leaf; } return $leaves; }