focus = $focus; $this->id = $focus->id; $this->module = $focus->module_dir; $this->layout_def_key = $layout_def_key; $this->subpanel_definitions=new SubPanelDefinitions($focus, $layout_def_key, $layout_def_override); } /* * Return the current selected or requested subpanel tab * @return string The identifier for the selected subpanel tab (e.g., 'Other') */ function getSelectedGroup() { global $current_user; if(isset($_REQUEST['subpanelTabs'])) $_SESSION['subpanelTabs'] = $_REQUEST['subpanelTabs']; require_once 'include/tabConfig.php' ; // include/tabConfig.php in turn includes the customized file at custom/include/tabConfig.php... $subpanelTabsPref = $current_user->getPreference('subpanel_tabs'); if(!isset($subpanelTabsPref)) $subpanelTabsPref = $GLOBALS['sugar_config']['default_subpanel_tabs']; if(!empty($GLOBALS['tabStructure']) && (!empty($_SESSION['subpanelTabs']) || !empty($sugar_config['subpanelTabs']) || !empty($subpanelTabsPref))) { // Determine selected group if(!empty($_REQUEST['subpanel'])) { $selected_group = $_REQUEST['subpanel']; } elseif(!empty($_COOKIE[$this->module.'_sp_tab'])) { $selected_group = $_COOKIE[$this->module.'_sp_tab']; } elseif(!empty($_SESSION['parentTab']) && !empty($GLOBALS['tabStructure'][$_SESSION['parentTab']]) && in_array($this->module, $GLOBALS['tabStructure'][$_SESSION['parentTab']]['modules'])) { $selected_group = $_SESSION['parentTab']; } else { $selected_group = ''; foreach($GLOBALS['tabStructure'] as $mainTab => $group) { if(in_array($this->module, $group['modules'])) { $selected_group = $mainTab; break; } } if(!$selected_group) { $selected_group = 'All'; } } } else { $selected_group = ''; } return $selected_group; } /* * Determine which subpanels should be shown within the selected tab group (e.g., 'Other'); * @param boolean $showTabs True if we should call the code to render each visible tab * @param string $selectedGroup The requested tab group * @return array Visible tabs */ function getTabs($showTabs = true, $selectedGroup='') { global $current_user; //get all the "tabs" - this actually means all the subpanels available for display within a tab $tabs = $this->subpanel_definitions->get_available_tabs(); if(!empty($selectedGroup)) { return SubPanelTilesTabs::getTabs($tabs, $showTabs, $selectedGroup); } else { // see if user current user has custom subpanel layout $tabs = SubPanelTilesTabs::applyUserCustomLayoutToTabs($tabs); /* Check if the preference is set now, * because there's no point in executing this code if * we aren't going to render anything. */ $subpanelLinksPref = $current_user->getPreference('subpanel_links'); if(!isset($subpanelLinksPref)) $subpanelLinksPref = $GLOBALS['sugar_config']['default_subpanel_links']; if($showTabs && $subpanelLinksPref){ require_once('include/SubPanel/SugarTab.php'); $sugarTab = new SugarTab(); $displayTabs = array(); foreach($tabs as $tab){ $displayTabs []= array('key'=>$tab, 'label'=>translate($this->subpanel_definitions->layout_defs['subpanel_setup'][$tab]['title_key'])); //echo '' . translate($this->subpanel_definitions->layout_defs['subpanel_setup'][$tab]['title_key']) . ' | '; } $sugarTab->setup(array(),array(),$displayTabs); $sugarTab->display(); } //echo ' '; } return $tabs; } function display($showContainer = true, $forceTabless = false) { global $layout_edit_mode, $sugar_version, $sugar_config, $current_user, $app_strings; if(isset($layout_edit_mode) && $layout_edit_mode){ return; } global $modListHeader; ob_start(); echo ''; ?> focus->module_dir])){ setcookie($this->focus->module_dir . '_divs', ''); unset($_COOKIE[$this->focus->module_dir . '_divs']); $_SESSION['visited_details'][$this->focus->module_dir] = true; } $default_div_display = 'none'; } $div_cookies = get_sub_cookies($this->focus->module_dir . '_divs'); //Display the group header. this section is executed only if the tabbed interface is being used. $current_key = ''; if (! empty($this->show_tabs)) { require_once('include/tabs.php'); $tab_panel = new SugarWidgetTabs($tabs, $current_key, 'showSubPanel'); echo get_form_header('Related', '', false); echo "
" . $tab_panel->display(); } if(empty($_REQUEST['subpanels'])) { $selected_group = $forceTabless?'':$this->getSelectedGroup(); $usersLayout = $current_user->getPreference('subpanelLayout', $this->focus->module_dir); // we need to use some intelligence here when restoring the user's layout, as new modules with new subpanels might have been installed since the user's layout was recorded // this means that we can't just restore the old layout verbatim as the new subpanels would then go walkabout // so we need to do a merge while attempting as best we can to preserve the sense of the specified order // this is complicated by the different ordering schemes used in the two sources for the panels: the user's layout uses an ordinal layout, the panels from getTabs have an explicit ordering driven by the 'order' parameter // it's not clear how to best reconcile these two schemes; so we punt on it, and add all new panels to the end of the user's layout. At least this will give them a clue that something has changed... // we also now check for tabs that have been removed since the user saved his or her preferences. $tabs = $this->getTabs($showContainer, $selected_group) ; if(!empty($usersLayout)) { $availableTabs = $tabs ; $tabs = array_intersect ( $usersLayout , $availableTabs ) ; // remove any tabs that have been removed since the user's layout was saved foreach (array_diff ( $availableTabs , $usersLayout ) as $tab) $tabs [] = $tab ; } } else { $tabs = explode(',', $_REQUEST['subpanels']); } $tab_names = array(); if($showContainer) { echo ''; if(!empty($selected_group)) { // closing table from tpls/singletabmenu.tpl echo ''; } } // drag/drop code $tab_names = '["' . join($tab_names, '","') . '"]'; global $sugar_config; if(empty($sugar_config['lock_subpanels']) || $sugar_config['lock_subpanels'] == false) { echo << var SubpanelInit = function() { SubpanelInitTabNames({$tab_names}); } var SubpanelInitTabNames = function(tabNames) { subpanel_dd = new Array(); j = 0; for(i in tabNames) { subpanel_dd[j] = new ygDDList('whole_subpanel_' + tabNames[i]); subpanel_dd[j].setHandleElId('subpanel_title_' + tabNames[i]); subpanel_dd[j].onMouseDown = SUGAR.subpanelUtils.onDrag; subpanel_dd[j].afterEndDrag = SUGAR.subpanelUtils.onDrop; j++; } YAHOO.util.DDM.mode = 1; } currentModule = '{$this->module}'; YAHOO.util.Event.addListener(window, 'load', SubpanelInit); EOQ; } $ob_contents = ob_get_contents(); ob_end_clean(); return $ob_contents; } function getLayoutManager() { require_once('include/generic/LayoutManager.php'); if ( $this->layout_manager == null) { $this->layout_manager = new LayoutManager(); } return $this->layout_manager; } function get_buttons($thisPanel,$panel_query=null) { $subpanel_def = $thisPanel->get_buttons(); $layout_manager = $this->getLayoutManager(); $widget_contents = ''; foreach($subpanel_def as $widget_data) { $widget_data['query']=urlencode($panel_query); $widget_data['action'] = $_REQUEST['action']; $widget_data['module'] = $thisPanel->get_inst_prop_value('module'); $widget_data['focus'] = $this->focus; $widget_data['subpanel_definition'] = $thisPanel; $widget_contents .= ''; } $widget_contents .= '
' . "\n"; if(empty($widget_data['widget_class'])) { $widget_contents .= "widget_class not defined for top subpanel buttons"; } else { $widget_contents .= $layout_manager->widgetDisplay($widget_data); } $widget_contents .= '
'; return $widget_contents; } } ?>