/** * Write Default Values */ public function writeDefaults() { $defaultTemplates = file_get_contents(IPS_ROOT_PATH . 'setup/xml/system_templates.xml'); if (!class_exists('classXML')) { require_once IPS_KERNEL_PATH . 'classXML.php'; } $xml = new classXML('utf-8'); $xml->loadXML($defaultTemplates); $array = $xml->fetchXMLAsArray(); foreach ($array['system_templates']['template'] as $template) { $params = array(); foreach ($template['params']['param'] as $p) { $params[] = $p['#alltext']; } $this->write($template['key']['#alltext'], $params, $template['content']['#alltext']); } }
/** * Recache menu data * * @return @e void */ public function applicationsMenuDataRecache() { $app_menu_cache = array(); $modules_cache = array(); //----------------------------------------- // Get module data first in one query //----------------------------------------- $this->DB->build(array('select' => '*', 'from' => 'core_sys_module', 'where' => 'sys_module_visible=1 AND sys_module_admin=1', 'order' => 'sys_module_position ASC')); $this->DB->execute(); while ($module = $this->DB->fetch()) { $modules_cache[$module['sys_module_application']][] = $module['sys_module_key']; } //----------------------------------------- // Now get applications and loop //----------------------------------------- $this->DB->build(array('select' => '*', 'from' => 'core_applications', 'order' => 'app_position ASC')); $outer = $this->DB->execute(); while ($row = $this->DB->fetch($outer)) { $app_dir = $row['app_directory']; $main_items = $modules_cache[$app_dir]; //----------------------------------------- // Continue... //----------------------------------------- if (count($main_items)) { foreach ($main_items as $_current_module) { $_file = IPSLib::getAppDir($app_dir) . "/modules_admin/" . $_current_module . '/xml/menu.xml'; if (is_file($_file)) { //----------------------------------------- // Get xml mah-do-dah //----------------------------------------- require_once IPS_KERNEL_PATH . 'classXML.php'; /*noLibHook*/ $xml = new classXML(IPS_DOC_CHAR_SET); $content = @file_get_contents($_file); if ($content) { $xml->loadXML($content); $menu = $xml->fetchXMLAsArray(); $item = array(); $subItemIndex = 0; $itemIndex = 0; /** * Easiest way I could find to get the data in a proper multi-dimensional array */ foreach ($menu as $id => $data) { foreach ($data as $dataKey => $dataValue) { if ($dataKey == 'tabitems') { foreach ($dataValue as $tabitemsKey => $tabItemsValue) { if ($tabitemsKey == 'item') { foreach ($tabItemsValue as $itemKey => $itemValue) { if (is_int($itemKey)) { foreach ($itemValue as $_itemKey => $_itemValue) { $subItemIndex = 0; if ($_itemKey == 'title' or $_itemKey == 'condition') { $item[$itemIndex][$_itemKey] = $_itemValue['#alltext']; } else { if ($_itemKey == 'subitems') { foreach ($_itemValue as $subitemKey => $subitemValue) { if ($subitemKey != '#alltext') { foreach ($subitemValue as $subitemRealKey => $subitemRealValue) { if (is_int($subitemRealKey)) { foreach ($subitemRealValue as $_subitemRealKey => $_subitemRealValue) { if ($_subitemRealKey != '#alltext') { $item[$itemIndex][$_itemKey][$subitemKey][$subItemIndex][$_subitemRealKey] = $_subitemRealValue['#alltext']; } } } else { if ($subitemRealKey != '#alltext') { $item[$itemIndex][$_itemKey][$subitemKey][$subItemIndex][$subitemRealKey] = $subitemRealValue['#alltext']; } } if (is_int($subitemRealKey)) { $subItemIndex++; } } $subItemIndex++; } } } } } $itemIndex++; } else { if ($itemKey == 'title') { $item[$itemIndex][$itemKey] = $itemValue['#alltext']; } else { if ($itemKey == 'subitems') { foreach ($itemValue as $subitemKey => $subitemValue) { if ($subitemKey != '#alltext') { foreach ($subitemValue as $subitemRealKey => $subitemRealValue) { if (is_int($subitemRealKey)) { foreach ($subitemRealValue as $_subitemRealKey => $_subitemRealValue) { if ($_subitemRealKey != '#alltext') { $item[$itemIndex][$itemKey][$subitemKey][$subItemIndex][$_subitemRealKey] = $_subitemRealValue['#alltext']; } } } else { if ($subitemRealKey != '#alltext') { $item[$itemIndex][$itemKey][$subitemKey][$subItemIndex][$subitemRealKey] = $subitemRealValue['#alltext']; } } if (is_int($subitemRealKey)) { $subItemIndex++; } } $subItemIndex++; } } } } } } $itemIndex++; } } } } } foreach ($item as $id => $data) { //----------------------------------------- // INIT //----------------------------------------- if ($data['condition']) { $func = create_function('', $data['condition']); if (!$func()) { continue; } } $_cat_title = $data['title']; $_cat_title = str_replace('&', '&', $_cat_title); // Validation thing $_nav_main_done = 0; if (is_array($data['subitems'])) { //----------------------------------------- // Loop.... //----------------------------------------- foreach ($data['subitems'] as $__data) { foreach ($__data as $_id => $_data) { $_sub_item_title = $_data['subitemtitle']; $_sub_item_url = $_data['subitemurl']; $_sub_is_redirect = $_data['subisredirect']; $_sub_section = $_data['subsection']; $_sub_keywords = $_data['subitemkeywords']; $_sub_item_role_key = isset($_data['subitemrolekey']) ? $_data['subitemrolekey'] : ''; $_sub_language = $_data['subitemlang']; //----------------------------------------- // Continue... //----------------------------------------- if ($_sub_item_title and $_sub_section) { $app_menu_cache[$app_dir][$id . '_' . $_current_module]['title'] = $_cat_title; $app_menu_cache[$app_dir][$id . '_' . $_current_module]['items'][$_id] = array('title' => $_sub_item_title, 'module' => $_current_module, 'langkey' => $_sub_language, 'keywords' => $_sub_keywords, 'section' => $_sub_section, 'url' => $_sub_item_url, 'rolekey' => $_sub_item_role_key, 'redirect' => $_sub_is_redirect); } } } } } } } } } } $this->cache->setCache('app_menu_cache', $app_menu_cache, array('array' => 1)); }