/** * Adds the link-list widget to those registered by the user at display time. * * This allows the link-list widget to play well with NXTClass, being able * to receive theme-appropriate parameters, but to not appear in a user's * list of available widgets. * * @param array $areas a list of widgetized areas and their registered widgets * * @access private * @since 0.2 */ public function _add_widget($areas) { // Remove inactive sidebars from the list of widgetized areas $inactive_keys = array(); foreach ($areas as $area => $contents) { foreach ($this->_INACTIVE_SIDEBARS as $search) { if (preg_match($search, $area)) { $inactive_keys[] = $area; } } } $active_areas = $areas; foreach ($inactive_keys as $inactive) { unset($active_areas[$inactive]); } // If there is at least one active widgetized area, try to add our widget to // the first one that declares a meta widget, and, failing that, add // it to the first area in the list if (!empty($active_areas)) { $add_to_area = null; foreach ($active_areas as $area => $widgets) { if (!$add_to_area) { $add_to_area = $area; } if (ClassBlogs_Utils::widget_search(self::_META_WIDGET_BASE_ID, $widgets) !== false) { $add_to_area = $area; break; } } // If the given area does not yet contain an instance of the blog-links // widget, examine its contents. If itstarts with a search widget, // place the link list widget below that. Otherwise, make it the // first widget in the list. if (ClassBlogs_Utils::widget_search($this->get_uid(), $areas[$add_to_area]) === false) { $search_index = ClassBlogs_Utils::widget_search(self::_SEARCH_WIDGET_BASE_ID, $areas[$add_to_area]); if ($search_index === 0) { array_splice($areas[$add_to_area], 1, 0, $this->get_uid()); } else { array_unshift($areas[$add_to_area], $this->get_uid()); } } } return $areas; }