/** * getPanelIds * */ protected function getPanelIds($panels) { $panel_ids = array(); $setDefaultPanel = false; if (count($panels) == 1) { $arrayKeys = array_keys($panels); if (!empty($arrayKeys[0])) { $this->defaulPanel = $arrayKeys[0]; $panels = $panels[$arrayKeys[0]]; } else { $panels = $panels['']; } $setDefaultPanel = true; } if ($this->scanForMultiPanel) { require_once 'include/SugarFields/Parsers/MetaParser.php'; if ($setDefaultPanel || !MetaParser::hasMultiplePanels($panels)) { $panels = array($this->defaultPanel => $panels); $this->isMultiPanel = false; } } foreach ($panels as $panel_id => $panel) { $panel_ids[$panel_id] = $panel_id; } return $panel_ids; }
/** * smarty_function_sugar_button * This is the constructor for the Smarty plugin. * * @param $params The runtime Smarty key/value arguments * @param $smarty The reference to the Smarty object used in this invocation */ function smarty_function_sugar_button($params, &$smarty) { if (empty($params['module'])) { $smarty->trigger_error("sugar_button: missing required param (module)"); } else { if (empty($params['id'])) { $smarty->trigger_error("sugar_button: missing required param (id)"); } else { if (empty($params['view'])) { $smarty->trigger_error("sugar_button: missing required param (view)"); } } } $type = $params['id']; $location = empty($params['location']) ? "" : "_" . $params['location']; if (!is_array($type)) { $module = $params['module']; $view = $params['view']; switch (strtoupper($type)) { case "SEARCH": return '<input tabindex="2" title="{$APP.LBL_SEARCH_BUTTON_TITLE}" accessKey="{$APP.LBL_SEARCH_BUTTON_KEY}" onclick="SUGAR.savedViews.setChooser(); SUGAR.ajaxUI.submitForm(this.form);" class="button" type="button" name="button" value="{$APP.LBL_SEARCH_BUTTON_LABEL}" id="search_form_submit"/> '; break; case "CANCEL": $cancelButton = '{if !empty($smarty.request.return_action) && ($smarty.request.return_action == "DetailView" && !empty($smarty.request.return_id))}'; $cancelButton .= '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="SUGAR.ajaxUI.loadContent(\'index.php?action=DetailView&module={$smarty.request.return_module}&record={$smarty.request.return_id}\'); return false;" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" type="button" id="' . $type . $location . '"> '; $cancelButton .= '{elseif !empty($smarty.request.return_action) && ($smarty.request.return_action == "DetailView" && !empty($fields.id.value))}'; $cancelButton .= '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="SUGAR.ajaxUI.loadContent(\'index.php?action=DetailView&module={$smarty.request.return_module}&record={$fields.id.value}\'); return false;" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" id="' . $type . $location . '"> '; $cancelButton .= '{elseif empty($smarty.request.return_action) || empty($smarty.request.return_id) && !empty($fields.id.value)}'; $cancelButton .= '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="SUGAR.ajaxUI.loadContent(\'index.php?action=index&module=' . $module . '\'); return false;" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" id="' . $type . $location . '"> '; $cancelButton .= '{else}'; $cancelButton .= '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="SUGAR.ajaxUI.loadContent(\'index.php?action=index&module={$smarty.request.return_module}&record={$smarty.request.return_id}\'); return false;" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" id="' . $type . $location . '"> '; $cancelButton .= '{/if}'; return $cancelButton; break; case "DELETE": return '{if $bean->aclAccess("delete")}<input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="button" onclick="this.form.return_module.value=\'' . $module . '\'; this.form.return_action.value=\'ListView\'; this.form.action.value=\'Delete\'; return confirm(\'{$APP.NTC_DELETE_CONFIRMATION}\');" type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}" id="delete_button">{/if} '; break; case "DUPLICATE": return '{if $bean->aclAccess("edit")}<input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="button" onclick="this.form.return_module.value=\'' . $module . '\'; this.form.return_action.value=\'DetailView\'; this.form.isDuplicate.value=true; this.form.action.value=\'' . $view . '\'; this.form.return_id.value=\'{$id}\';SUGAR.ajaxUI.submitForm(this.form);" type="button" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}" id="duplicate_button">{/if} '; break; case "EDIT": return '{if $bean->aclAccess("edit")}<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="button primary" onclick="this.form.return_module.value=\'' . $module . '\'; this.form.return_action.value=\'DetailView\'; this.form.return_id.value=\'{$id}\'; this.form.action.value=\'EditView\';SUGAR.ajaxUI.submitForm(this.form);" type="button" name="Edit" id="edit_button" value="{$APP.LBL_EDIT_BUTTON_LABEL}">{/if} '; break; case "FIND_DUPLICATES": return '{if $bean->aclAccess("edit") && $bean->aclAccess("delete")}<input title="{$APP.LBL_DUP_MERGE}" accessKey="M" class="button" onclick="this.form.return_module.value=\'' . $module . '\'; this.form.return_action.value=\'DetailView\'; this.form.return_id.value=\'{$id}\'; this.form.action.value=\'Step1\'; this.form.module.value=\'MergeRecords\';SUGAR.ajaxUI.submitForm(this.form);" type="button" name="Merge" value="{$APP.LBL_DUP_MERGE}" id="merge_duplicate_button">{/if} '; break; case "SAVE": $view = $_REQUEST['action'] == 'EditView' ? 'EditView' : ($view == 'EditView' ? 'EditView' : $view); return '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button primary" onclick="{if $isDuplicate}this.form.return_id.value=\'\'; {/if}this.form.action.value=\'Save\'; if(check_form(\'' . $view . '\'))SUGAR.ajaxUI.submitForm(this.form);return false;" type="submit" name="button" value="{$APP.LBL_SAVE_BUTTON_LABEL}" id="' . $type . $location . '">{/if} '; break; case "SUBPANELSAVE": if ($view == 'QuickCreate' || (isset($_REQUEST['target_action']) && strtolower($_REQUEST['target_action'])) == 'quickcreate') { $view = "form_SubpanelQuickCreate_{$module}"; } return '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button" onclick="disableOnUnloadEditView();this.form.action.value=\'Save\';if(check_form(\'' . $view . '\'))return SUGAR.subpanelUtils.inlineSave(this.form.id, \'' . $params['module'] . '_subpanel_save_button\');return false;" type="submit" name="' . $params['module'] . '_subpanel_save_button" id="' . $params['module'] . '_subpanel_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; case "SUBPANELCANCEL": return '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="return SUGAR.subpanelUtils.cancelCreate(\'' . $params['module'] . '_subpanel_cancel_button\');return false;" type="submit" name="' . $params['module'] . '_subpanel_cancel_button" id="' . $params['module'] . '_subpanel_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; case "SUBPANELFULLFORM": $html = '<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" accessKey="{$APP.LBL_FULL_FORM_BUTTON_KEY}" class="button" onclick="disableOnUnloadEditView(this.form); this.form.return_action.value=\'DetailView\'; this.form.action.value=\'EditView\'; if(typeof(this.form.to_pdf)!=\'undefined\') this.form.to_pdf.value=\'0\';" type="submit" name="' . $params['module'] . '_subpanel_full_form_button" id="' . $params['module'] . '_subpanel_full_form_button" value="{$APP.LBL_FULL_FORM_BUTTON_LABEL}"> '; $html .= '<input type="hidden" name="full_form" value="full_form">'; return $html; case "DCMENUCANCEL": return '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="javascript:lastLoadedMenu=undefined;DCMenu.closeOverlay();return false;" type="submit" name="' . $params['module'] . '_dcmenu_cancel_button" id="' . $params['module'] . '_dcmenu_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; case "DCMENUSAVE": if ($view == 'QuickCreate') { $view = "form_DCQuickCreate_{$module}"; } else { if ($view == 'EditView') { $view = "form_DCEditView_{$module}"; } } return '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button primary" onclick="this.form.action.value=\'Save\';if(check_form(\'' . $view . '\'))return DCMenu.save(this.form.id, \'' . $params['module'] . '_subpanel_save_button\');return false;" type="submit" name="' . $params['module'] . '_dcmenu_save_button" id="' . $params['module'] . '_dcmenu_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; case "DCMENUFULLFORM": $html = '<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" accessKey="{$APP.LBL_FULL_FORM_BUTTON_KEY}" class="button" onclick="disableOnUnloadEditView(this.form); this.form.return_action.value=\'DetailView\'; this.form.action.value=\'EditView\'; this.form.return_module.value=\'' . $params['module'] . '\';this.form.return_id.value=this.form.record.value;if(typeof(this.form.to_pdf)!=\'undefined\') this.form.to_pdf.value=\'0\';SUGAR.ajaxUI.submitForm(this.form,null,true);DCMenu.closeOverlay();" type="button" name="' . $params['module'] . '_subpanel_full_form_button" id="' . $params['module'] . '_subpanel_full_form_button" value="{$APP.LBL_FULL_FORM_BUTTON_LABEL}"> '; $html .= '<input type="hidden" name="full_form" value="full_form">'; return $html; case "POPUPSAVE": $view = $view == 'QuickCreate' ? "form_QuickCreate_{$module}" : $view; return '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" ' . 'class="button primary" onclick="this.form.action.value=\'Popup\';' . 'return check_form(\'' . $view . '\')" type="submit" name="' . $params['module'] . '_popupcreate_save_button" id="' . $params['module'] . '_popupcreate_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; case "POPUPCANCEL": return '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" ' . 'class="button" onclick="toggleDisplay(\'addform\');return false;" ' . 'name="' . $params['module'] . '_popup_cancel_button" type="submit"' . 'id="' . $params['module'] . '_popup_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; case "AUDIT": $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array()); $json = getJSONobj(); require_once 'include/SugarFields/Parsers/MetaParser.php'; $encoded_popup_request_data = MetaParser::parseDelimiters($json->encode($popup_request_data)); $audit_link = '<input id="btn_view_change_log" title="{$APP.LNK_VIEW_CHANGE_LOG}" class="button" onclick=\'open_popup("Audit", "600", "400", "&record={$fields.id.value}&module_name=' . $params['module'] . '", true, false, ' . $encoded_popup_request_data . '); return false;\' type="button" value="{$APP.LNK_VIEW_CHANGE_LOG}">'; $view = '{if $bean->aclAccess("detail")}{if !empty($fields.id.value) && $isAuditEnabled}' . $audit_link . '{/if}{/if}'; return $view; } //switch } else { if (is_array($type) && isset($type['customCode'])) { return $type['customCode']; } } }
public function setHoverField(&$viewdefs, $module, $hover_field, $source_id) { //Check for metadata files that aren't correctly created require_once 'include/SugarFields/Parsers/MetaParser.php'; $metaParser = new MetaParser(); if (!$metaParser->hasMultiplePanels($viewdefs[$module]['DetailView']['panels'])) { $keys = array_keys($viewdefs[$module]['DetailView']['panels']); if (!empty($keys) && count($keys) != 1) { $viewdefs[$module]['DetailView']['panels'] = array('default' => $viewdefs[$module]['DetailView']['panels']); } } foreach ($viewdefs[$module]['DetailView']['panels'] as $panel_id => $panel) { foreach ($panel as $row_id => $row) { foreach ($row as $field_id => $field) { $name = is_array($field) ? $field['name'] : $field; if ($name == $hover_field) { if (is_array($field)) { if (!empty($viewdefs[$module]['DetailView']['panels'][$panel_id][$row_id][$field_id]['displayParams'])) { $newDisplayParam = $viewdefs[$module]['DetailView']['panels'][$panel_id][$row_id][$field_id]['displayParams']; $newDisplayParam['module'] = $module; $newDisplayParam['enableConnectors'] = true; if (!is_null($source_id) && !in_array($source_id, $newDisplayParam['connectors'])) { $newDisplayParam['connectors'][] = $source_id; } $viewdefs[$module]['DetailView']['panels'][$panel_id][$row_id][$field_id]['displayParams'] = $newDisplayParam; } else { $field['displayParams'] = array('enableConnectors' => true, 'module' => $module, 'connectors' => array(0 => $source_id)); $viewdefs[$module]['DetailView']['panels'][$panel_id][$row_id][$field_id] = $field; } } else { $viewdefs[$module]['DetailView']['panels'][$panel_id][$row_id][$field_id] = array('name' => $field, 'displayParams' => array('enableConnectors' => true, 'module' => $module, 'connectors' => array(0 => $source_id))); } return true; } } } } return false; }
/** * This takes in a list of panels and returns an associative array of field names to the meta-data of the field as well as the locations of that field * * @param ARRAY $panels - this is the 'panel' section of the meta-data * @return ARRAY $fields - an associate array of fields and their meta-data as well as their location */ protected function getFields($panels) { $fields = array(); $blanks = 0; $setDefaultPanel = false; if (count($panels) == 1) { $arrayKeys = array_keys($panels); if (!empty($arrayKeys[0])) { $panels = $panels[$arrayKeys[0]]; } else { $panels = $panels['']; } $setDefaultPanel = true; } if ($this->scanForMultiPanel) { require_once 'include/SugarFields/Parsers/MetaParser.php'; if ($setDefaultPanel || !MetaParser::hasMultiplePanels($panels)) { $panels = array($this->defaultPanel => $panels); $this->isMultiPanel = false; } } foreach ($panels as $panel_id => $panel) { foreach ($panel as $row_id => $rows) { foreach ($rows as $col_id => $col) { if (is_array($col)) { if (isset($col['name'])) { $field_name = $col['name']; } } else { $field_name = $col; } if (empty($field_name)) { $field_name = 'BLANK_' . $blanks; $blanks++; } $fields[$field_name] = array('data' => $col, 'loc' => array('panel' => $panel_id, 'row' => $row_id, 'col' => $col_id)); } } } return $fields; }
/** * smarty_function_sugar_button * This is the constructor for the Smarty plugin. * * @param $params The runtime Smarty key/value arguments * @param $smarty The reference to the Smarty object used in this invocation */ function smarty_function_sugar_button($params, $smarty) { if (empty($params['module'])) { $smarty->trigger_error("sugar_button: missing required param (module)"); } else { if (empty($params['id'])) { $smarty->trigger_error("sugar_button: missing required param (id)"); } else { if (empty($params['view'])) { $smarty->trigger_error("sugar_button: missing required param (view)"); } } } $js_form = empty($params['form_id']) ? "var _form = (this.form) ? this.form : document.forms[0];" : "var _form = document.getElementById('{$params['form_id']}');"; $type = $params['id']; $location = empty($params['location']) ? "" : "_" . $params['location']; if (isset($GLOBALS['sugar_config']['enable_action_menu']) && $GLOBALS['sugar_config']['enable_action_menu'] === false) { $enable_action_menu = false; } else { $enable_action_menu = true; } if (!is_array($type)) { $module = $params['module']; $view = $params['view']; switch (strtoupper($type)) { case "SEARCH": $output = '<input tabindex="2" title="{$APP.LBL_SEARCH_BUTTON_TITLE}" onclick="SUGAR.savedViews.setChooser();" class="button" type="submit" name="button" value="{$APP.LBL_SEARCH_BUTTON_LABEL}" id="search_form_submit"/> '; break; case "CANCEL": $cancelButton = '{capture name="cancelReturnUrl" assign="cancelReturnUrl"}'; $cancelButton .= '{if !empty($smarty.request.return_action) && $smarty.request.return_action == "DetailView" && !empty($fields.id.value) && empty($smarty.request.return_id)}'; $cancelButton .= 'parent.SUGAR.App.router.buildRoute(\'{$smarty.request.return_module|escape:"url"}\', \'{$fields.id.value|escape:"url"}\', \'{$smarty.request.return_action|escape:"url"}\')'; $cancelButton .= '{elseif !empty($smarty.request.return_module) || !empty($smarty.request.return_action) || !empty($smarty.request.return_id)}'; $cancelButton .= 'parent.SUGAR.App.router.buildRoute(\'{$smarty.request.return_module|escape:"url"}\', \'{$smarty.request.return_id|escape:"url"}\', \'{$smarty.request.return_action|escape:"url"}\')'; $cancelButton .= '{else}'; $cancelButton .= "parent.SUGAR.App.router.buildRoute('{$module}')"; $cancelButton .= '{/if}'; $cancelButton .= '{/capture}'; $cancelButton .= '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="parent.SUGAR.App.bwc.revertAttributes();parent.SUGAR.App.router.navigate({$cancelReturnUrl}, {literal}{trigger: true}{/literal}); return false;" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" id="' . $type . $location . '"> '; $output = $cancelButton; break; case "DELETE": $output = '{if $bean->aclAccess("delete")}<input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="button" onclick="' . $js_form . ' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'ListView\'; _form.action.value=\'Delete\'; if(confirm(\'{$APP.NTC_DELETE_CONFIRMATION}\')) SUGAR.ajaxUI.submitForm(_form);" type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}" id="delete_button">{/if} '; break; case "DUPLICATE": $output = '{if $bean->aclAccess("edit")}<input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="button" onclick="' . $js_form . ' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'DetailView\'; _form.isDuplicate.value=true; _form.action.value=\'' . $view . '\'; _form.return_id.value=\'{$id}\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}" id="duplicate_button">{/if} '; break; case "EDIT": $output = '{if $bean->aclAccess("edit")}<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="button primary" onclick="' . $js_form . ' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'DetailView\'; _form.return_id.value=\'{$id}\'; _form.action.value=\'EditView\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Edit" id="edit_button" value="{$APP.LBL_EDIT_BUTTON_LABEL}">{/if} '; break; case "FIND_DUPLICATES": $output = '{if $bean->aclAccess("edit") && $bean->aclAccess("delete")}<input title="{$APP.LBL_DUP_MERGE}" class="button" onclick="' . $js_form . ' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'DetailView\'; _form.return_id.value=\'{$id}\'; _form.action.value=\'Step1\'; _form.module.value=\'MergeRecords\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Merge" value="{$APP.LBL_DUP_MERGE}" id="merge_duplicate_button">{/if} '; break; case "SAVE": $view = $_REQUEST['action'] == 'EditView' ? 'EditView' : ($view == 'EditView' ? 'EditView' : $view); $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button primary" onclick="' . $js_form . ' {if $isDuplicate}_form.return_id.value=\'\'; {/if}_form.action.value=\'Save\'; if(check_form(\'' . $view . '\'))SUGAR.ajaxUI.submitForm(_form);return false;" type="submit" name="button" value="{$APP.LBL_SAVE_BUTTON_LABEL}" id="' . $type . $location . '">{/if} '; break; case "SUBPANELSAVE": if ($view == 'QuickCreate' || isset($_REQUEST['target_action']) && strtolower($_REQUEST['target_action']) == 'quickcreate') { $view = "form_SubpanelQuickCreate_{$module}"; } $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" class="button" onclick="' . $js_form . ' _form.action.value=\'Save\';if(check_form(\'' . $view . '\'))return SUGAR.subpanelUtils.inlineSave(_form.id, \'' . $params['module'] . '_subpanel_save_button\');return false;" type="submit" name="' . $params['module'] . '_subpanel_save_button" id="' . $params['module'] . '_subpanel_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; break; case "SUBPANELCANCEL": $output = '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" class="button" onclick="return SUGAR.subpanelUtils.cancelCreate($(this).attr(\'id\'));return false;" type="submit" name="' . $params['module'] . '_subpanel_cancel_button" id="' . $params['module'] . '_subpanel_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; break; case "SUBPANELFULLFORM": $output = '<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" class="button" onclick="' . $js_form . ' _form.return_action.value=\'DetailView\'; _form.action.value=\'EditView\'; if(typeof(_form.to_pdf)!=\'undefined\') _form.to_pdf.value=\'0\';" type="submit" name="' . $params['module'] . '_subpanel_full_form_button" id="' . $params['module'] . '_subpanel_full_form_button" value="{$APP.LBL_FULL_FORM_BUTTON_LABEL}"> '; $output .= '<input type="hidden" name="full_form" value="full_form">'; break; case "DCMENUCANCEL": $output = '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="javascript:lastLoadedMenu=undefined;DCMenu.closeOverlay();return false;" type="submit" name="' . $params['module'] . '_dcmenu_cancel_button" id="' . $params['module'] . '_dcmenu_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; break; case "DCMENUSAVE": if ($view == 'QuickCreate') { $view = "form_DCQuickCreate_{$module}"; } else { if ($view == 'EditView') { $view = "form_DCEditView_{$module}"; } } $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button primary" onclick="' . $js_form . ' _form.action.value=\'Save\';if(check_form(\'' . $view . '\'))return DCMenu.save(_form.id, \'' . $params['module'] . '_subpanel_save_button\');return false;" type="submit" name="' . $params['module'] . '_dcmenu_save_button" id="' . $params['module'] . '_dcmenu_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; break; case "DCMENUFULLFORM": $output = '<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" accessKey="{$APP.LBL_FULL_FORM_BUTTON_KEY}" class="button" onclick="' . $js_form . ' _form.return_action.value=\'DetailView\'; _form.action.value=\'EditView\'; _form.return_module.value=\'' . $params['module'] . '\';_form.return_id.value=_form.record.value;if(typeof(_form.to_pdf)!=\'undefined\') _form.to_pdf.value=\'0\';SUGAR.ajaxUI.submitForm(_form,null,true);DCMenu.closeOverlay();" type="button" name="' . $params['module'] . '_subpanel_full_form_button" id="' . $params['module'] . '_subpanel_full_form_button" value="{$APP.LBL_FULL_FORM_BUTTON_LABEL}"> '; $output .= '<input type="hidden" name="full_form" value="full_form">'; $output .= '<input type="hidden" name="is_admin" value="">'; break; case "POPUPSAVE": $view = $view == 'QuickCreate' ? "form_QuickCreate_{$module}" : $view; $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" ' . 'class="button primary" onclick="' . $js_form . ' _form.action.value=\'Popup\';' . 'return check_form(\'' . $view . '\')" type="submit" name="' . $params['module'] . '_popupcreate_save_button" id="' . $params['module'] . '_popupcreate_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; break; case "POPUPCANCEL": $output = '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" ' . 'class="button" onclick="toggleDisplay(\'addform\');return false;" ' . 'name="' . $params['module'] . '_popup_cancel_button" type="submit"' . 'id="' . $params['module'] . '_popup_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; break; case "AUDIT": $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array()); $json = getJSONobj(); require_once 'include/SugarFields/Parsers/MetaParser.php'; $encoded_popup_request_data = MetaParser::parseDelimiters($json->encode($popup_request_data)); $audit_link = '<input id="btn_view_change_log" title="{$APP.LNK_VIEW_CHANGE_LOG}" class="button" onclick=\'open_popup("Audit", "600", "400", "&record={$fields.id.value}&module_name=' . $params['module'] . '", true, false, ' . $encoded_popup_request_data . '); return false;\' type="button" value="{$APP.LNK_VIEW_CHANGE_LOG}">'; $output = '{if $bean->aclAccess("detail")}{if !empty($fields.id.value) && $isAuditEnabled}' . $audit_link . '{/if}{/if}'; break; //Button for the Connector intergration wizard //Button for the Connector intergration wizard case "CONNECTOR": require_once 'include/connectors/utils/ConnectorUtils.php'; require_once 'include/connectors/sources/SourceFactory.php'; $modules_sources = ConnectorUtils::getDisplayConfig(); if (!is_null($modules_sources) && !empty($modules_sources)) { foreach ($modules_sources as $mod => $entry) { if ($mod == $module && !empty($entry)) { foreach ($entry as $source_id) { $source = SourceFactory::getSource($source_id); if ($source->isEnabledInWizard()) { $output = '<input title="{$APP.LBL_MERGE_CONNECTORS}" type="button" class="button" onClick="document.location=\'index.php?module=Connectors&action=Step1&record={$fields.id.value}&merge_module={$module}\'" name="merge_connector" value="{$APP.LBL_MERGE_CONNECTORS}">'; if (isset($params['appendTo'])) { $smarty->append($params['appendTo'], $output); return; } return $output; } } } } } return ''; case "PDFVIEW": $output = '{sugar_button module="$module" id="REALPDFVIEW" view="$view" form_id="formDetailView" record=$fields.id.value}'; break; case "REALPDFVIEW": if (empty($params['record'])) { $smarty->trigger_error("sugar_button: missing required param (record)"); } $record = $params['record']; require_once 'modules/PdfManager/PdfManagerHelper.php'; $pdfManagerList = PdfManagerHelper::getPublishedTemplatesForModule($module); //quote legacy templates if ($module == "Quotes") { require_once 'modules/Quotes/Layouts.php'; $tplLayouts = get_layouts(); } $output = ''; if (!empty($pdfManagerList) || !empty($tplLayouts)) { if (SugarThemeRegistry::current()->name != "Classic") { if ($enable_action_menu) { $output = ' <input id="pdfview_button" value="' . translate('LBL_PDF_VIEW') . '" type="button" class="button" />'; } $pdfItems = array(); if (!empty($pdfManagerList)) { foreach ($pdfManagerList as $pdfTemplate) { if (!$enable_action_menu) { $urlParams[] = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id, 'name' => $pdfTemplate->name); } else { $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id); $pdfItems[] = array('html' => '<a id="' . $pdfTemplate->name . '_pdfview" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $pdfTemplate->name . '</a>', 'items' => array()); } } } //quote legacy templates if ($module == "Quotes") { foreach ($tplLayouts as $sugarpdf => $path) { if (!$enable_action_menu) { $urlParams[] = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => '', 'name' => $path); } else { $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => ''); $pdfItems[] = array('html' => '<a href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $GLOBALS['app_strings']['LBL_EXISTING'] . '_' . $path . '</a>', 'items' => array()); } } } sort($pdfItems); if (!$enable_action_menu) { if (!empty($urlParams)) { $output .= '<ul class="clickMenu fancymenu">'; $output .= '<li class="sugar_action_button">'; $output .= '<a>' . translate('LBL_PDF_VIEW') . '</a>'; $output .= '<ul class="subnav" style="display: none;">'; foreach ($urlParams as $tplButton) { if (isset($tplButton['pdf_template_id'])) { $parentLocation = 'index.php?module=' . $module . '&record=' . $tplButton['record'] . '&action=' . $tplButton['action'] . '&sugarpdf=' . $tplButton['sugarpdf'] . '&pdf_template_id=' . $tplButton['pdf_template_id']; $output .= '<li><a id="' . $tplButton['name'] . '_pdfview" ' . 'href="' . $parentLocation . '">' . $tplButton['name'] . '</a></li>'; } else { // legacy templates $parentLocation = 'index.php?module=' . $module . '&record=' . $tplButton['record'] . '&action=' . $tplButton['action'] . '&sugarpdf=' . $tplButton['sugarpdf'] . '&email_action=' . $tplButton['email_action']; $output .= '<li><a id="' . $tplButton['name'] . '_pdfview" ' . 'href="' . $parentLocation . '">' . $GLOBALS['app_strings']['LBL_EXISTING'] . '_' . $tplButton['name'] . '</a></li>'; } } $output .= '</ul><span class="ab"></span></li></ul>'; } } else { require_once 'include/SugarSmarty/plugins/function.sugar_menu.php'; $output .= smarty_function_sugar_menu(array('id' => "pdfview_action_menu", 'items' => $pdfItems, 'htmlOptions' => array('class' => 'subnav-sub'), 'itemOptions' => array(), 'submenuHtmlOptions' => array()), $smarty); } } else { $output = ' <script type="text/javascript"> function display_pdf_list(el) { var menu = \''; if (!empty($pdfManagerList)) { foreach ($pdfManagerList as $pdfTemplate) { $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id); $output .= '<a style="width: 150px" class="menuItem" onmouseover="hiliteItem(this,\\\'yes\\\');" onmouseout="unhiliteItem(this);" onclick="" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $pdfTemplate->name . '</a>'; } } //quote legacy templates if ($module == "Quotes") { require_once 'modules/Quotes/Layouts.php'; $tplLayouts = get_layouts(); foreach ($tplLayouts as $sugarpdf => $path) { $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => ''); $output .= '<a style="width: 150px" class="menuItem" onmouseover="hiliteItem(this,\\\'yes\\\');" onmouseout="unhiliteItem(this);" onclick="" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $path . '</a>'; } } $output .= '\'; SUGAR.util.showHelpTips(el,menu); } </script> <a onclick="display_pdf_list(this);" />' . translate('LBL_PDF_VIEW') . '</a> '; } } break; case "PDFEMAIL": $output = '{sugar_button module="$module" id="REALPDFEMAIL" view="$view" form_id="formDetailView" record=$fields.id.value}'; break; case "REALPDFEMAIL": $output = ''; global $current_user, $sugar_config; $userPref = $current_user->getPreference('email_link_type'); $defaultPref = $sugar_config['email_default_client']; if ($userPref != '') { $client = $userPref; } else { $client = $defaultPref; } if ($client == 'sugar') { if (empty($params['record'])) { $smarty->trigger_error("sugar_button: missing required param (record)"); } $record = $params['record']; require_once 'modules/PdfManager/PdfManagerHelper.php'; $pdfManagerList = PdfManagerHelper::getPublishedTemplatesForModule($module); //quote legacy templates if ($module == "Quotes") { require_once 'modules/Quotes/Layouts.php'; $tplLayouts = get_layouts(); } if (!empty($pdfManagerList) || !empty($tplLayouts)) { if (SugarThemeRegistry::current()->name != "Classic") { if ($enable_action_menu) { $output = ' <input id="pdfemail_button" value="' . translate('LBL_PDF_EMAIL') . '" type="button" class="button" />'; } $pdfItems = array(); if (!empty($pdfManagerList)) { foreach ($pdfManagerList as $pdfTemplate) { if (!$enable_action_menu) { $urlParams[] = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id, 'to_email' => "1", 'name' => $pdfTemplate->name); } else { $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id, 'to_email' => "1"); $pdfItems[] = array('html' => '<a id="' . $pdfTemplate->name . '_pdfemail" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $pdfTemplate->name . '</a>', 'items' => array()); } } } //quote legacy templates if ($module == "Quotes") { foreach ($tplLayouts as $sugarpdf => $path) { if (!$enable_action_menu) { $urlParams[] = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => 'EmailLayout', 'name' => $path); } else { $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => 'EmailLayout'); $pdfItems[] = array('html' => '<a href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $GLOBALS['app_strings']['LBL_EXISTING'] . '_' . $path . '</a>', 'items' => array()); } } } sort($pdfItems); if (!$enable_action_menu) { if (!empty($urlParams)) { $output .= '<ul class="clickMenu fancymenu">'; $output .= '<li class="sugar_action_button">'; $output .= '<a>' . translate('LBL_PDF_EMAIL') . '</a>'; $output .= '<ul class="subnav" style="display: none;">'; foreach ($urlParams as $tplButton) { if (isset($tplButton['pdf_template_id'])) { $parentLocation = 'index.php?module=' . $module . '&record=' . $tplButton['record'] . '&action=' . $tplButton['action'] . '&sugarpdf=' . $tplButton['sugarpdf'] . '&pdf_template_id=' . $tplButton['pdf_template_id'] . '&to_email=' . $tplButton['to_email']; $output .= '<li><a id="' . $tplButton['name'] . '_pdfemail" ' . 'href="' . $parentLocation . '">' . $tplButton['name'] . '</a></li>'; } else { // legacy templates $parentLocation = 'index.php?module=' . $module . '&record=' . $tplButton['record'] . '&action=' . $tplButton['action'] . '&sugarpdf=' . $tplButton['sugarpdf'] . '&email_action=' . $tplButton['email_action']; $output .= '<li><a id="' . $tplButton['name'] . '_pdfemail" ' . 'href="' . $parentLocation . '">' . $GLOBALS['app_strings']['LBL_EXISTING'] . '_' . $tplButton['name'] . '</a></li>'; } } $output .= '</ul><span class="ab"></span></li></ul>'; } } else { require_once 'include/SugarSmarty/plugins/function.sugar_menu.php'; $output .= smarty_function_sugar_menu(array('id' => "pdfview_action_menu", 'items' => $pdfItems, 'htmlOptions' => array('class' => 'subnav-sub'), 'itemOptions' => array(), 'submenuHtmlOptions' => array()), $smarty); } } else { $output = ' <script language="javascript"> function display_pdf_email_list(el) { var menu = \''; if (!empty($pdfManagerList)) { foreach ($pdfManagerList as $pdfTemplate) { $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => 'pdfmanager', 'pdf_template_id' => $pdfTemplate->id, 'to_email' => "1"); $output .= '<a style="width: 150px" class="menuItem" onmouseover="hiliteItem(this,\\\'yes\\\');" onmouseout="unhiliteItem(this);" onclick="" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $pdfTemplate->name . '</a>'; } } //quote legacy templates if ($module == "Quotes") { require_once 'modules/Quotes/Layouts.php'; $tplLayouts = get_layouts(); foreach ($tplLayouts as $sugarpdf => $path) { $urlParams = array('module' => $module, 'record' => $record, 'action' => 'sugarpdf', 'sugarpdf' => $sugarpdf, 'email_action' => 'EmailLayout'); $output .= '<a style="width: 150px" class="menuItem" onmouseover="hiliteItem(this,\\\'yes\\\');" onmouseout="unhiliteItem(this);" onclick="" href="index.php?' . http_build_query($urlParams, '', '&') . '">' . $sugarpdf . '</a>'; } } $output .= '\'; SUGAR.util.showHelpTips(el,menu); } </script> <a onclick="display_pdf_email_list(this);" />' . translate('LBL_PDF_EMAIL') . '</a> '; } } } break; case 'SHARE': // TODO we shouldn't rely on the name field only, but we don't // have this information anywhere and this is BWC code... $shareButton = <<<ENDB <form> <input type="hidden" id="share_button_name" value="{\$fields.name.value}"> <input title="{\$APP.LBL_SHARE_BUTTON_TITLE}" accessKey="{\$APP.LBL_SHARE_BUTTON_KEY}" class="button" onclick="parent.SUGAR.App.bwc.shareRecord('{$params['module']}', '{\$fields.id.value}', this.form.share_button_name.value)" type="button" name="button" value="{\$APP.LBL_SHARE_BUTTON_LABEL}"> </form> ENDB; $output = $shareButton; break; } //switch if (isset($params['appendTo'])) { $smarty->append($params['appendTo'], $output); return; } return $output; } else { if (is_array($type) && isset($type['sugar_html'])) { require_once 'include/SugarHtml/SugarHtml.php'; $dom_tree = SugarHtml::parseSugarHtml($type['sugar_html']); replaceFormClick($dom_tree, $js_form); $output = SugarHtml::createHtml($dom_tree); if (isset($params['appendTo'])) { $smarty->append($params['appendTo'], $output); return; } return $output; } else { if (is_array($type) && isset($type['customCode'])) { require_once 'include/SugarHtml/SugarHtml.php'; $dom_tree = SugarHtml::parseHtmlTag($type['customCode']); $hidden_exists = false; replaceFormClick($dom_tree, $js_form, $hidden_exists); if ($hidden_exists) { //If the customCode contains hidden fields, the extracted hidden fields need to append in the original form $form = $smarty->get_template_vars('form'); $hidden_fields = $dom_tree; extractHiddenInputs($hidden_fields); if (!isset($form)) { $form = array(); } if (!isset($form['hidden'])) { $form['hidden'] = array(); } $form['hidden'][] = SugarHtml::createHtml($hidden_fields); $smarty->assign('form', $form); } $output = SugarHtml::createHtml($dom_tree); if (isset($params['appendTo'])) { $smarty->append($params['appendTo'], $output); return; } return $output; } } } }
/** * getContentCharset * * @note The `url` value being used from the curler info is valid to * use since it is the redirect url. For example, if a bit.ly * link is specified, the `url` value being used below is not * bit.ly, but rather whatever site it's being redirect to. * @access public * @return String|false */ public function getContentCharset() { // dependency check if (class_exists('MetaParser') === false) { throw new Exception('*MetaParser* class required. Please see ' . 'https://github.com/onassar/PHP-MetaParser'); } // instantiate parser to get access to content's provided charset $info = $this->getInfo(); $parser = new MetaParser($this->_response, $info['url']); return $parser->getCharset(); }
/** * smarty_function_sugar_button * This is the constructor for the Smarty plugin. * * @param $params The runtime Smarty key/value arguments * @param $smarty The reference to the Smarty object used in this invocation */ function smarty_function_sugar_button($params, &$smarty) { if (empty($params['module'])) { $smarty->trigger_error("sugar_button: missing required param (module)"); } else { if (empty($params['id'])) { $smarty->trigger_error("sugar_button: missing required param (id)"); } else { if (empty($params['view'])) { $smarty->trigger_error("sugar_button: missing required param (view)"); } } } $js_form = empty($params['form_id']) ? "var _form = (this.form) ? this.form : document.forms[0];" : "var _form = document.getElementById('{$params['form_id']}');"; $type = $params['id']; $location = empty($params['location']) ? "" : "_" . $params['location']; if (!is_array($type)) { $module = $params['module']; $view = $params['view']; switch (strtoupper($type)) { case "SEARCH": $output = '<input tabindex="2" title="{$APP.LBL_SEARCH_BUTTON_TITLE}" onclick="SUGAR.savedViews.setChooser();" class="button" type="submit" name="button" value="{$APP.LBL_SEARCH_BUTTON_LABEL}" id="search_form_submit"/> '; break; case "CANCEL": $cancelButton = '{if !empty($smarty.request.return_action) && ($smarty.request.return_action == "DetailView" && !empty($smarty.request.return_id))}'; $cancelButton .= '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="SUGAR.ajaxUI.loadContent(\'index.php?action=DetailView&module={$smarty.request.return_module|escape:"url"}&record={$smarty.request.return_id|escape:"url"}\'); return false;" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" type="button" id="' . $type . $location . '"> '; $cancelButton .= '{elseif !empty($smarty.request.return_action) && ($smarty.request.return_action == "DetailView" && !empty($fields.id.value))}'; $cancelButton .= '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="SUGAR.ajaxUI.loadContent(\'index.php?action=DetailView&module={$smarty.request.return_module|escape:"url"}&record={$fields.id.value}\'); return false;" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" id="' . $type . $location . '"> '; $cancelButton .= '{elseif empty($smarty.request.return_action) || empty($smarty.request.return_id) && !empty($fields.id.value)}'; $cancelButton .= '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="SUGAR.ajaxUI.loadContent(\'index.php?action=index&module=' . $module . '\'); return false;" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" id="' . $type . $location . '"> '; $cancelButton .= '{else}'; $cancelButton .= '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="SUGAR.ajaxUI.loadContent(\'index.php?action=index&module={$smarty.request.return_module|escape:"url"}&record={$smarty.request.return_id|escape:"url"}\'); return false;" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" id="' . $type . $location . '"> '; $cancelButton .= '{/if}'; $output = $cancelButton; break; case "DELETE": $output = '{if $bean->aclAccess("delete")}<input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="button" onclick="' . $js_form . ' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'ListView\'; _form.action.value=\'Delete\'; if(confirm(\'{$APP.NTC_DELETE_CONFIRMATION}\')) SUGAR.ajaxUI.submitForm(_form);" type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}" id="delete_button">{/if} '; break; case "DUPLICATE": $output = '{if $bean->aclAccess("edit")}<input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="button" onclick="' . $js_form . ' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'DetailView\'; _form.isDuplicate.value=true; _form.action.value=\'' . $view . '\'; _form.return_id.value=\'{$id}\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}" id="duplicate_button">{/if} '; break; case "EDIT": $output = '{if $bean->aclAccess("edit")}<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="button primary" onclick="' . $js_form . ' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'DetailView\'; _form.return_id.value=\'{$id}\'; _form.action.value=\'EditView\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Edit" id="edit_button" value="{$APP.LBL_EDIT_BUTTON_LABEL}">{/if} '; break; case "FIND_DUPLICATES": $output = '{if $bean->aclAccess("edit") && $bean->aclAccess("delete")}<input title="{$APP.LBL_DUP_MERGE}" class="button" onclick="' . $js_form . ' _form.return_module.value=\'' . $module . '\'; _form.return_action.value=\'DetailView\'; _form.return_id.value=\'{$id}\'; _form.action.value=\'Step1\'; _form.module.value=\'MergeRecords\';SUGAR.ajaxUI.submitForm(_form);" type="button" name="Merge" value="{$APP.LBL_DUP_MERGE}" id="merge_duplicate_button">{/if} '; break; case "SAVE": $view = $_REQUEST['action'] == 'EditView' ? 'EditView' : ($view == 'EditView' ? 'EditView' : $view); $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button primary" onclick="' . $js_form . ' {if $isDuplicate}_form.return_id.value=\'\'; {/if}_form.action.value=\'Save\'; if(check_form(\'' . $view . '\'))SUGAR.ajaxUI.submitForm(_form);return false;" type="submit" name="button" value="{$APP.LBL_SAVE_BUTTON_LABEL}" id="' . $type . $location . '">{/if} '; break; case "SUBPANELSAVE": if ($view == 'QuickCreate' || isset($_REQUEST['target_action']) && strtolower($_REQUEST['target_action']) == 'quickcreate') { $view = "form_SubpanelQuickCreate_{$module}"; } $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" class="button" onclick="' . $js_form . ' disableOnUnloadEditView(); _form.action.value=\'Save\';if(check_form(\'' . $view . '\'))return SUGAR.subpanelUtils.inlineSave(_form.id, \'' . $params['module'] . '_subpanel_save_button\');return false;" type="submit" name="' . $params['module'] . '_subpanel_save_button" id="' . $params['module'] . '_subpanel_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; break; case "SUBPANELCANCEL": $output = '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" class="button" onclick="return SUGAR.subpanelUtils.cancelCreate($(this).attr(\'id\'));return false;" type="submit" name="' . $params['module'] . '_subpanel_cancel_button" id="' . $params['module'] . '_subpanel_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; break; case "SUBPANELFULLFORM": $output = '<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" class="button" onclick="' . $js_form . ' disableOnUnloadEditView(_form); _form.return_action.value=\'DetailView\'; _form.action.value=\'EditView\'; if(typeof(_form.to_pdf)!=\'undefined\') _form.to_pdf.value=\'0\';" type="submit" name="' . $params['module'] . '_subpanel_full_form_button" id="' . $params['module'] . '_subpanel_full_form_button" value="{$APP.LBL_FULL_FORM_BUTTON_LABEL}"> '; $output .= '<input type="hidden" name="full_form" value="full_form">'; break; case "DCMENUCANCEL": $output = '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="javascript:lastLoadedMenu=undefined;DCMenu.closeOverlay();return false;" type="submit" name="' . $params['module'] . '_dcmenu_cancel_button" id="' . $params['module'] . '_dcmenu_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; break; case "DCMENUSAVE": if ($view == 'QuickCreate') { $view = "form_DCQuickCreate_{$module}"; } else { if ($view == 'EditView') { $view = "form_DCEditView_{$module}"; } } $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button primary" onclick="' . $js_form . ' _form.action.value=\'Save\';if(check_form(\'' . $view . '\'))return DCMenu.save(_form.id, \'' . $params['module'] . '_subpanel_save_button\');return false;" type="submit" name="' . $params['module'] . '_dcmenu_save_button" id="' . $params['module'] . '_dcmenu_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; break; case "DCMENUFULLFORM": $output = '<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" accessKey="{$APP.LBL_FULL_FORM_BUTTON_KEY}" class="button" onclick="' . $js_form . ' disableOnUnloadEditView(_form); _form.return_action.value=\'DetailView\'; _form.action.value=\'EditView\'; _form.return_module.value=\'' . $params['module'] . '\';_form.return_id.value=_form.record.value;if(typeof(_form.to_pdf)!=\'undefined\') _form.to_pdf.value=\'0\';SUGAR.ajaxUI.submitForm(_form,null,true);DCMenu.closeOverlay();" type="button" name="' . $params['module'] . '_subpanel_full_form_button" id="' . $params['module'] . '_subpanel_full_form_button" value="{$APP.LBL_FULL_FORM_BUTTON_LABEL}"> '; $output .= '<input type="hidden" name="full_form" value="full_form">'; $output .= '<input type="hidden" name="is_admin" value="">'; break; case "POPUPSAVE": $view = $view == 'QuickCreate' ? "form_QuickCreate_{$module}" : $view; $output = '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" ' . 'class="button primary" onclick="' . $js_form . ' _form.action.value=\'Popup\';' . 'return check_form(\'' . $view . '\')" type="submit" name="' . $params['module'] . '_popupcreate_save_button" id="' . $params['module'] . '_popupcreate_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; break; case "POPUPCANCEL": $output = '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" ' . 'class="button" onclick="toggleDisplay(\'addform\');return false;" ' . 'name="' . $params['module'] . '_popup_cancel_button" type="submit"' . 'id="' . $params['module'] . '_popup_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; break; case "AUDIT": $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array()); $json = getJSONobj(); require_once 'include/SugarFields/Parsers/MetaParser.php'; $encoded_popup_request_data = MetaParser::parseDelimiters($json->encode($popup_request_data)); $audit_link = '<input id="btn_view_change_log" title="{$APP.LNK_VIEW_CHANGE_LOG}" class="button" onclick=\'open_popup("Audit", "600", "400", "&record={$fields.id.value}&module_name=' . $params['module'] . '", true, false, ' . $encoded_popup_request_data . '); return false;\' type="button" value="{$APP.LNK_VIEW_CHANGE_LOG}">'; $output = '{if $bean->aclAccess("detail")}{if !empty($fields.id.value) && $isAuditEnabled}' . $audit_link . '{/if}{/if}'; break; } //switch if (isset($params['appendTo'])) { $smarty->append($params['appendTo'], $output); return; } return $output; } else { if (is_array($type) && isset($type['sugar_html'])) { require_once 'include/SugarHtml/SugarHtml.php'; $dom_tree = SugarHtml::parseSugarHtml($type['sugar_html']); replaceFormClick($dom_tree, $js_form); $output = SugarHtml::createHtml($dom_tree); if (isset($params['appendTo'])) { $smarty->append($params['appendTo'], $output); return; } return $output; } else { if (is_array($type) && isset($type['customCode'])) { require_once 'include/SugarHtml/SugarHtml.php'; $dom_tree = SugarHtml::parseHtmlTag($type['customCode']); $hidden_exists = false; replaceFormClick($dom_tree, $js_form, $hidden_exists); if ($hidden_exists) { //If the customCode contains hidden fields, the extracted hidden fields need to append in the original form $form = $smarty->get_template_vars('form'); $hidden_fields = $dom_tree; extractHiddenInputs($hidden_fields); if (!isset($form)) { $form = array(); } if (!isset($form['hidden'])) { $form['hidden'] = array(); } $form['hidden'][] = SugarHtml::createHtml($hidden_fields); $smarty->assign('form', $form); } $output = SugarHtml::createHtml($dom_tree); if (isset($params['appendTo'])) { $smarty->append($params['appendTo'], $output); return; } return $output; } } } }
/** * smarty_function_sugar_button * This is the constructor for the Smarty plugin. * * @param $params The runtime Smarty key/value arguments * @param $smarty The reference to the Smarty object used in this invocation */ function smarty_function_sugar_button($params, &$smarty) { if (empty($params['module'])) { $smarty->trigger_error("sugar_button: missing required param (module)"); } else { if (empty($params['id'])) { $smarty->trigger_error("sugar_button: missing required param (id)"); } else { if (empty($params['view'])) { $smarty->trigger_error("sugar_button: missing required param (view)"); } } } $type = $params['id']; if (!is_array($type)) { $module = $params['module']; $view = $params['view']; switch (strtoupper($type)) { case "CANCEL": $cancelButton = '{if !empty($smarty.request.return_action) && ($smarty.request.return_action == "DetailView" && !empty($fields.id.value))}'; $cancelButton .= '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="this.form.action.value=\'DetailView\'; this.form.module.value=\'{$smarty.request.return_module}\'; this.form.record.value=\'{$smarty.request.return_id}\';" type="submit" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; $cancelButton .= '{elseif !empty($smarty.request.return_action) && ($smarty.request.return_action == "DetailView" && !empty($smarty.request.return_id))}'; $cancelButton .= '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="this.form.action.value=\'DetailView\'; this.form.module.value=\'{$smarty.request.return_module}\'; this.form.record.value=\'{$smarty.request.return_id}\';" type="submit" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; $cancelButton .= '{else}'; $cancelButton .= '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="this.form.action.value=\'index\'; this.form.module.value=\'{$smarty.request.return_module}\'; this.form.record.value=\'{$smarty.request.return_id}\';" type="submit" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; $cancelButton .= '{/if}'; return $cancelButton; break; case "DELETE": return '{if $bean->aclAccess("delete")}<input title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" class="button" onclick="this.form.return_module.value=\'' . $module . '\'; this.form.return_action.value=\'ListView\'; this.form.action.value=\'Delete\'; return confirm(\'{$APP.NTC_DELETE_CONFIRMATION}\');" type="submit" name="Delete" value="{$APP.LBL_DELETE_BUTTON_LABEL}">{/if} '; break; case "DUPLICATE": return '{if $bean->aclAccess("edit")}<input title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" class="button" onclick="this.form.return_module.value=\'' . $module . '\'; this.form.return_action.value=\'DetailView\'; this.form.isDuplicate.value=true; this.form.action.value=\'' . $view . '\'; this.form.return_id.value=\'{$id}\';" type="submit" name="Duplicate" value="{$APP.LBL_DUPLICATE_BUTTON_LABEL}" id="duplicate_button">{/if} '; break; case "EDIT": return '{if $bean->aclAccess("edit")}<input title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" class="button" onclick="this.form.return_module.value=\'' . $module . '\'; this.form.return_action.value=\'DetailView\'; this.form.return_id.value=\'{$id}\'; this.form.action.value=\'' . $view . '\';" type="submit" name="Edit" id="edit_button" value="{$APP.LBL_EDIT_BUTTON_LABEL}">{/if} '; break; case "FIND_DUPLICATES": return '{if $bean->aclAccess("edit")}<input title="{$APP.LBL_DUP_MERGE}" accessKey="M" class="button" onclick="this.form.return_module.value=\'' . $module . '\'; this.form.return_action.value=\'DetailView\'; this.form.return_id.value=\'{$id}\'; this.form.action.value=\'Step1\'; this.form.module.value=\'MergeRecords\';" type="submit" name="Merge" value="{$APP.LBL_DUP_MERGE}">{/if} '; break; case "SAVE": $view = $_REQUEST['action'] == 'EditView' ? 'EditView' : ($view == 'EditView' ? 'EditView' : $view); return '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button" onclick="{if $isDuplicate}this.form.return_id.value=\'\'; {/if}this.form.action.value=\'Save\'; return check_form(\'' . $view . '\');" type="submit" name="button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; break; case "SUBPANELSAVE": $view = $view == 'QuickCreate' ? "QuickCreate_{$module}" : $view; return '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button" onclick="this.form.action.value=\'Save\';if(check_form(\'' . $view . '\'))return SUGAR.subpanelUtils.inlineSave(this.form.id, \'' . $params['module'] . '_subpanel_save_button\');return false;" type="submit" name="' . $params['module'] . '_subpanel_save_button" id="' . $params['module'] . '_subpanel_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; case "SUBPANELCANCEL": return '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="return SUGAR.subpanelUtils.cancelCreate(\'' . $params['module'] . '_subpanel_cancel_button\');return false;" type="submit" name="' . $params['module'] . '_subpanel_cancel_button" id="' . $params['module'] . '_subpanel_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; case "SUBPANELFULLFORM": $html = '<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" accessKey="{$APP.LBL_FULL_FORM_BUTTON_KEY}" class="button" onclick="this.form.return_action.value=\'DetailView\'; this.form.action.value=\'EditView\'; if(typeof(this.form.to_pdf)!=\'undefined\') this.form.to_pdf.value=\'0\';" type="submit" name="' . $params['module'] . '_subpanel_full_form_button" id="' . $params['module'] . '_subpanel_full_form_button" value="{$APP.LBL_FULL_FORM_BUTTON_LABEL}"> '; $html .= '<input type="hidden" name="full_form" value="full_form">'; return $html; case "AUDIT": $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array()); $json = getJSONobj(); require_once 'include/SugarFields/Parsers/MetaParser.php'; $encoded_popup_request_data = MetaParser::parseDelimiters($json->encode($popup_request_data)); $audit_link = '<input title="{$APP.LNK_VIEW_CHANGE_LOG}" class="button" onclick=\'open_popup("Audit", "600", "400", "&record={$fields.id.value}&module_name=' . $params['module'] . '", true, false, ' . $encoded_popup_request_data . '); return false;\' type="submit" value="{$APP.LNK_VIEW_CHANGE_LOG}">'; $view = '{if $bean->aclAccess("detail")}{if !empty($fields.id.value) && $isAuditEnabled}' . $audit_link . '{/if}{/if}'; return $view; } //switch } else { if (is_array($type) && isset($type['customCode'])) { return $type['customCode']; } } }
} } if ($image == "null") { $tempimg = 'http://www.google.com/s2/favicons?domain=www.' . "{$domain_name}"; $image[] = $tempimg; $image = json_encode($image); } if ($description == "null") { $description = "[]"; } break; default: // curling $curler = new Curler(); $body = $curler->get($url); $parser = new MetaParser($body, $url); $meta_detail = $parser->getDetails(); $meta_detail['openGraph']['image']; $image[] = $meta_detail['openGraph']['image']; $image = json_encode($image); if ($image == "null" || $image == "") { $tempimg = 'http://www.google.com/s2/favicons?domain=www.' . "{$domain_name}"; $image[] = $tempimg; $image = json_encode($image); } foreach ($html->find('title') as $value) { $title = $value->plaintext; } $description = "[]"; } //if(empty($image)){
/** * smarty_function_sugar_actions_link * This is the constructor for the Smarty plugin. * * @param $params The runtime Smarty key/value arguments * @param $smarty The reference to the Smarty object used in this invocation */ function smarty_function_sugar_actions_link($params, &$smarty) { if (empty($params['module'])) { $smarty->trigger_error("sugar_button: missing required param (module)"); } else { if (empty($params['id'])) { $smarty->trigger_error("sugar_button: missing required param (id)"); } else { if (empty($params['view'])) { $smarty->trigger_error("sugar_button: missing required param (view)"); } } } $type = $params['id']; $location = empty($params['location']) ? "" : "_" . $params['location']; if (!is_array($type)) { $module = $params['module']; $view = $params['view']; switch (strtoupper($type)) { case "SEARCH": // TODO review these SUGAR.ajaxUI.* methods return '<input tabindex="2" title="{$APP.LBL_SEARCH_BUTTON_TITLE}" accessKey="{$APP.LBL_SEARCH_BUTTON_KEY}" onclick="SUGAR.savedViews.setChooser(); SUGAR.ajaxUI.submitForm(this.form);" class="button" type="button" name="button" value="{$APP.LBL_SEARCH_BUTTON_LABEL}" id="search_form_submit"/> '; break; case "CANCEL": $cancelButton = '{capture name="cancelReturnUrl" assign="cancelReturnUrl"}'; $cancelButton .= '{if !empty($smarty.request.return_action) && $smarty.request.return_action == "DetailView" && !empty($fields.id.value)}'; $cancelButton .= 'parent.SUGAR.App.router.buildRoute(\'{$smarty.request.return_module|escape:"url"}\', \'{$fields.id.value|escape:"url"}\', \'{$smarty.request.return_action|escape:"url"}\')'; $cancelButton .= '{elseif !empty($smarty.request.return_module) || !empty($smarty.request.return_action) || !empty($smarty.request.return_id)}'; $cancelButton .= 'parent.SUGAR.App.router.buildRoute(\'{$smarty.request.return_module|escape:"url"}\', \'{$smarty.request.return_id|escape:"url"}\', \'{$smarty.request.return_action|escape:"url"}\')'; $cancelButton .= '{else}'; $cancelButton .= "parent.SUGAR.App.router.buildRoute('{$module}')"; $cancelButton .= '{/if}'; $cancelButton .= '{/capture}'; $cancelButton .= '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="parent.SUGAR.App.router.navigate({$cancelReturnUrl}, {literal}{trigger: true}{/literal}); return false;" type="button" name="button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}" id="' . $type . $location . '"> '; return $cancelButton; break; case "DELETE": return '{if $bean->aclAccess("delete")}<a title="{$APP.LBL_DELETE_BUTTON_TITLE}" accessKey="{$APP.LBL_DELETE_BUTTON_KEY}" onclick="$(\'#form\')[0].return_module.value=\'' . $module . '\'; $(\'#form\')[0].return_action.value=\'ListView\'; $(\'#form\')[0].action.value=\'Delete\'; if(confirm(\'{$APP.NTC_DELETE_CONFIRMATION}\')){literal}{$(\'#form\').submit()}{/literal};" name="Delete" id="delete_button">{$APP.LBL_DELETE_BUTTON_LABEL}</a>{/if} '; break; case "DUPLICATE": return '{if $bean->aclAccess("edit")}<a title="{$APP.LBL_DUPLICATE_BUTTON_TITLE}" accessKey="{$APP.LBL_DUPLICATE_BUTTON_KEY}" onclick="$(\'#form\')[0].return_module.value=\'' . $module . '\'; $(\'#form\')[0].return_action.value=\'DetailView\'; $(\'#form\')[0].isDuplicate.value=true; $(\'#form\')[0].action.value=\'' . $view . '\'; $(\'#form\')[0].return_id.value=\'{$id}\';SUGAR.ajaxUI.submitForm($(\'#form\')[0]);" name="Duplicate" id="duplicate_button">{$APP.LBL_DUPLICATE_BUTTON_LABEL}</a>{/if} '; break; case "EDIT": return '{if $bean->aclAccess("edit")}<a title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" onclick="$(\'#form\')[0].return_module.value=\'' . $module . '\'; $(\'#form\')[0].return_action.value=\'DetailView\'; $(\'#form\')[0].return_id.value=\'{$id}\'; $(\'#form\')[0].action.value=\'EditView\';SUGAR.ajaxUI.submitForm($(\'#form\')[0]);" name="Edit" id="edit_button">{$APP.LBL_EDIT_BUTTON_LABEL}</a>{/if} '; break; case "EDIT2": return '{if $bean->aclAccess("edit")}<a title="{$APP.LBL_EDIT_BUTTON_TITLE}" accessKey="{$APP.LBL_EDIT_BUTTON_KEY}" onclick="$(\'#form\')[0].return_module.value=\'' . $module . '\'; $(\'#form\')[0].return_action.value=\'DetailView\'; $(\'#form\')[0].return_id.value=\'{$id}\'; $(\'#form\')[0].action.value=\'EditView\';SUGAR.ajaxUI.submitForm($(\'#form\')[0]);" name="Edit">{$APP.LBL_EDIT_BUTTON_LABEL}</a>{/if} '; break; case "FIND_DUPLICATES": return '{if $bean->aclAccess("edit") && $bean->aclAccess("delete")}<a title="{$APP.LBL_DUP_MERGE}" accessKey="M" onclick="$(\'#form\')[0].return_module.value=\'' . $module . '\'; $(\'#form\')[0].return_action.value=\'DetailView\'; $(\'#form\')[0].return_id.value=\'{$id}\'; $(\'#form\')[0].action.value=\'Step1\'; $(\'#form\')[0].module.value=\'MergeRecords\';SUGAR.ajaxUI.submitForm($(\'#form\')[0]);" name="Merge" id="merge_duplicate_button">{$APP.LBL_DUP_MERGE}</a>{/if} '; break; case "SAVE": $view = $_REQUEST['action'] == 'EditView' ? 'EditView' : ($view == 'EditView' ? 'EditView' : $view); return '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button primary" onclick="{if $isDuplicate}this.form.return_id.value=\'\'; {/if}this.form.action.value=\'Save\'; if(check_form(\'' . $view . '\'))SUGAR.ajaxUI.submitForm(this.form);return false;" type="submit" name="button" value="{$APP.LBL_SAVE_BUTTON_LABEL}" id="' . $type . $location . '">{/if} '; break; case "SUBPANELSAVE": if ($view == 'QuickCreate' || (isset($_REQUEST['target_action']) && strtolower($_REQUEST['target_action'])) == 'quickcreate') { $view = "form_SubpanelQuickCreate_{$module}"; } return '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" class="button" onclick="this.form.action.value=\'Save\';if(check_form(\'' . $view . '\'))return SUGAR.subpanelUtils.inlineSave(this.form.id, \'' . $params['module'] . '_subpanel_save_button\');return false;" type="submit" name="' . $params['module'] . '_subpanel_save_button" id="' . $params['module'] . '_subpanel_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; case "SUBPANELCANCEL": return '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" class="button" onclick="return SUGAR.subpanelUtils.cancelCreate($(this).attr(\'id\'));return false;" type="submit" name="' . $params['module'] . '_subpanel_cancel_button" id="' . $params['module'] . '_subpanel_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; case "SUBPANELFULLFORM": $html = '<input title="{$APP.LBL_FULL_FORM_BUTTON_TITLE}" accessKey="{$APP.LBL_FULL_FORM_BUTTON_KEY}" class="button" onclick="this.form.return_action.value=\'DetailView\'; this.form.action.value=\'EditView\'; if(typeof(this.form.to_pdf)!=\'undefined\') this.form.to_pdf.value=\'0\';" type="submit" name="' . $params['module'] . '_subpanel_full_form_button" id="' . $params['module'] . '_subpanel_full_form_button" value="{$APP.LBL_FULL_FORM_BUTTON_LABEL}"> '; $html .= '<input type="hidden" name="full_form" value="full_form">'; return $html; case "POPUPSAVE": $view = $view == 'QuickCreate' ? "form_QuickCreate_{$module}" : $view; return '{if $bean->aclAccess("save")}<input title="{$APP.LBL_SAVE_BUTTON_TITLE}" accessKey="{$APP.LBL_SAVE_BUTTON_KEY}" ' . 'class="button primary" onclick="this.form.action.value=\'Popup\';' . 'return check_form(\'' . $view . '\')" type="submit" name="' . $params['module'] . '_popupcreate_save_button" id="' . $params['module'] . '_popupcreate_save_button" value="{$APP.LBL_SAVE_BUTTON_LABEL}">{/if} '; case "POPUPCANCEL": return '<input title="{$APP.LBL_CANCEL_BUTTON_TITLE}" accessKey="{$APP.LBL_CANCEL_BUTTON_KEY}" ' . 'class="button" onclick="toggleDisplay(\'addform\');return false;" ' . 'name="' . $params['module'] . '_popup_cancel_button" type="submit"' . 'id="' . $params['module'] . '_popup_cancel_button" value="{$APP.LBL_CANCEL_BUTTON_LABEL}"> '; case "AUDIT": $popup_request_data = array('call_back_function' => 'set_return', 'form_name' => 'EditView', 'field_to_name_array' => array()); $json = getJSONobj(); require_once 'include/SugarFields/Parsers/MetaParser.php'; $encoded_popup_request_data = MetaParser::parseDelimiters($json->encode($popup_request_data)); $audit_link = '<a id="btn_view_change_log" title="{$APP.LNK_VIEW_CHANGE_LOG}" onclick=\'open_popup("Audit", "600", "400", "&record={$fields.id.value}&module_name=' . $params['module'] . '", true, false, ' . $encoded_popup_request_data . '); return false;\'>{$APP.LNK_VIEW_CHANGE_LOG}</a>'; $view = '{if $bean->aclAccess("detail")}{if !empty($fields.id.value) && $isAuditEnabled}' . $audit_link . '{/if}{/if}'; return $view; //Button for the Connector intergration wizard //Button for the Connector intergration wizard case "CONNECTOR": require_once 'include/connectors/utils/ConnectorUtils.php'; require_once 'include/connectors/sources/SourceFactory.php'; $modules_sources = ConnectorUtils::getDisplayConfig(); if (!is_null($modules_sources) && !empty($modules_sources)) { foreach ($modules_sources as $mod => $entry) { if ($mod == $module && !empty($entry)) { foreach ($entry as $source_id) { $source = SourceFactory::getSource($source_id); if ($source->isEnabledInWizard()) { return '<a title="{$APP.LBL_MERGE_CONNECTORS}" accessKey="{$APP.LBL_MERGE_CONNECTORS_BUTTON_KEY}" onClick="document.location=\'index.php?module=Connectors&action=Step1&record={$fields.id.value}&merge_module={$module}\'" name="merge_connector">{$APP.LBL_MERGE_CONNECTORS}</a>'; } } } } } return ''; } //switch } else { if (is_array($type) && isset($type['customCode'])) { return $type['customCode']; } } }