sugarview.php

来自「SugarCRM5.1 开源PHP客户关系管理系统」· PHP 代码 · 共 532 行 · 第 1/2 页

PHP
532
字号
<?php/********************************************************************************* * SugarCRM is a customer relationship management program developed by * SugarCRM, Inc. Copyright (C) 2004 - 2007 SugarCRM Inc. *  * This program is free software; you can redistribute it and/or modify it under * the terms of the GNU General Public License version 3 as published by the * Free Software Foundation with the addition of the following permission added * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. *  * This program is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more * details. *  * You should have received a copy of the GNU General Public License along with * this program; if not, see http://www.gnu.org/licenses or write to the Free * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA * 02110-1301 USA. *  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road, * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com. *  * The interactive user interfaces in modified source and object code versions * of this program must display Appropriate Legal Notices, as required under * Section 5 of the GNU General Public License version 3. *  * In accordance with Section 7(b) of the GNU General Public License version 3, * these Appropriate Legal Notices must retain the display of the "Powered by * SugarCRM" logo. If the display of the logo is not reasonably feasible for * technical reasons, the Appropriate Legal Notices must display the words * "Powered by SugarCRM". * *******************************************************************************/class SugarView{    /**     * This array is meant to hold an objects/data that we would like to pass between     * the controller and the view.  The bean will automatically be set for us, but this     * is meant to hold anything else.     */    var $view_object_map = array();    /**     * The name of the current module.     */    var $module = '';    /**     * The name of the current action.     */    var $action = '';    /**     */    var $bean = null;    /**     * Sugar_Smarty. This is useful if you have a view and a subview you can     * share the same smarty object.     */    var $ss = null;    /**     * Any errors that occured this can either be set by the view or the controller or the model     */    var $errors = array();    /**     * Options for what UI elements to hide/show/     */    var $options = array('show_header' => true, 'show_title' => true, 'show_subpanels' => false, 'show_search' => true, 'show_footer' => true, 'show_javascript' => true, 'view_print' => false,);    var $type = null;    var $responseTime;    var $fileResources;    /**     * Constructor which will peform the setup.     */    function SugarView($bean = null, $view_object_map = array())    {        $this->bean = &$bean;        $this->view_object_map = $view_object_map;        $this->action = $GLOBALS['action'];        $this->module = $GLOBALS['module'];        $this->ss = new Sugar_Smarty();    }    function init($bean = null, $view_object_map = array())    {        $this->bean = &$bean;        $this->view_object_map = $view_object_map;    }    /**     * This method will be called from the controller and is not meant to be overridden.     */    function process()    {        LogicHook::initialize();        $this->displayCSS();        if ($this->action !== 'Login') {            $this->displayJavascript();        } else {            $this->displayLoginJS();        }        if ($this->_getOption('view_print')) {            echo ('<link href="themes/Sugar/print.css" media="all" type="text/css" rel="stylesheet">');        }        if ($this->_getOption('show_header')) {            $this->displayHeader();        }        $this->buildModuleList();        $this->preDisplay();        $this->displayErrors();        $this->display();        $GLOBALS['logic_hook']->call_custom_logic('', 'after_ui_frame');        if ($this->_getOption('show_subpanels')) $this->displaySubPanels();        if ($this->action === 'Login') {            //this is needed for a faster loading login page ie won't render unless the tables are closed            echo '</table></table>';            flush();            ob_flush();            $this->displayJavascript();        }        if ($this->_getOption('show_footer')) $this->displayFooter();        $GLOBALS['logic_hook']->call_custom_logic('', 'after_ui_footer');        //Do not track if there is no module or if module is not a String        $this->track();    }    /**     * This method will display the errors on the page.     */    function displayErrors()    {        foreach($this->errors as $error) {            echo '<span class="error">' . $error . '</span><br>';        }    }    /**     * [OVERRIDE] - This method is meant to overidden in a subclass. The purpose of this method is     * to allow a view to do some preprocessing before the display method is called. This becomes     * useful when you have a view defined at the application level and then within a module     * have a sub-view that extends from this application level view.  The application level     * view can do the setup in preDisplay() that is common to itself and any subviews     * and then the subview can just override display(). If it so desires, can also override     * preDisplay().     */    function preDisplay()    {    }    /**     * [OVERRIDE] - This method is meant to overidden in a subclass. This method     * will handle the actual display logic of the view.     */    function display()    {    }    /**     * Determine whether or not to dispay the header on the page.     */    function displayHeader()    {        global $currentModule;        $GLOBALS['app']->headerDisplayed = true;        if (!function_exists('get_new_record_form') && file_exists('modules/' . $this->module . '/metadata/sidecreateviewdefs.php')) {            require_once ('include/EditView/SideQuickCreate.php');        }        if (!$this->_menuExists($this->module) && !empty($GLOBALS['mod_strings']['LNK_NEW_RECORD'])) {            $GLOBALS['module_menu'][] = Array("index.php?module=$this->module&action=EditView&return_module=$this->module&return_action=DetailView",				$GLOBALS['mod_strings']['LNK_NEW_RECORD'],"{$GLOBALS['app_strings']['LBL_CREATE_BUTTON_LABEL']}$this->module" ,$this->module );            $GLOBALS['module_menu'][] = Array("index.php?module=$this->module&action=index", $GLOBALS['mod_strings']['LNK_LIST'], $this->module, $this->module);        }        $this->includeClassicFile('themes/' . $GLOBALS['theme'] . '/header.php');        $this->includeClassicFile('modules/Administration/DisplayWarnings.php');    }    /**     * If the view is classic then this method will include the file and     * setup any global variables.     */    function includeClassicFile($file)    {        global $sugar_config, $theme, $current_user, $sugar_version, $sugar_flavor, $mod_strings, $app_strings, $app_list_strings, $action, $timezones;        global $gridline, $request_string, $modListHeader, $module_menu, $dashletData, $authController, $locale, $currentModule, $import_bean_map, $image_path, $license;        global $user_unique_key, $server_unique_key, $barChartColors, $modules_exempt_from_availability_check, $dictionary, $current_language, $beanList, $beanFiles, $sugar_build, $sugar_codename;        global $timedate, $login_error; // cn: bug 13855 - timedate not available to classic views.        $currentModule = $this->module;        require_once ($file);    }    function displayLoginJS()    {        echo <<<EOQ		<script>			SUGAR = {};			SUGAR.themes = {};		</script>EOQ;    }    function displayCSS()    {        if ($this->_getOption('show_javascript')) {            echo '<link rel="stylesheet" type="text/css" media="all" href="' . getJSPath('themes/' . $GLOBALS['theme'] . '/calendar-win2k-cold-1.css') . '">';        }    }    /**     * Called from process(). This method will display the correct javascript.     */    function displayJavascript()    {        //echo out the headers to enable caching        if ($this->_getOption('show_header')) {            echo "<html><head>";        }        if ($this->_getOption('show_javascript')) {            echo '<script>jscal_today = ' . (1000*strtotime($GLOBALS['timedate']->handle_offset(gmdate('Y-m-d H:i:s'), 'Y-m-d H:i:s'))) . '; if(typeof app_strings == "undefined") app_strings = new Array();</script>';            echo '<script type="text/javascript" src="' . getJSPath('include/javascript/sugar_grp1_yui.js') . '"></script>';            echo '<script type="text/javascript" src="' . getJSPath('include/javascript/sugar_grp1.js') . '"></script>';            echo '<script type="text/javascript" src="' . getJSPath('jscalendar/lang/calendar-' . substr($GLOBALS['current_language'], 0, 2) . '.js') . '"></script>';            // cn: bug 12274 - prepare secret guid for asynchronous calls            if (!isset($_SESSION['asynchronous_key']) || empty($_SESSION['asynchronous_key'])) {                $_SESSION['asynchronous_key'] = create_guid();            }            $image_server = (defined('TEMPLATE_URL'))?TEMPLATE_URL . '/':'';            echo '<script type="text/javascript">var asynchronous_key = "' . $_SESSION['asynchronous_key'] . '";SUGAR.themes.image_server="' . $image_server . '";</script>'; // cn: bug 12274 - create session-stored key to defend against CSRF            echo $GLOBALS['timedate']->get_javascript_validation();            if (!is_file($GLOBALS['sugar_config']['cache_dir'] . 'jsLanguage/' . $GLOBALS['current_language'] . '.js')) {                require_once ('include/language/jsLanguage.php');                jsLanguage::createAppStringsCache($GLOBALS['current_language']);            }            echo '<script type="text/javascript" src="' . $GLOBALS['sugar_config']['cache_dir'] . 'jsLanguage/' . $GLOBALS['current_language'] . '.js?s=' . $GLOBALS['sugar_version'] . '&c=' . $GLOBALS['sugar_config']['js_custom_version'] . '&j=' . $GLOBALS['sugar_config']['js_lang_version'] . '"></script>';            if (!is_file($GLOBALS['sugar_config']['cache_dir'] . 'jsLanguage/' . $this->module . '/' . $GLOBALS['current_language'] . '.js')) {                require_once ('include/language/jsLanguage.php');                jsLanguage::createModuleStringsCache($this->module, $GLOBALS['current_language']);            }            echo '<script type="text/javascript" src="' . $GLOBALS['sugar_config']['cache_dir'] . 'jsLanguage/' . $this->module . '/' . $GLOBALS['current_language'] . '.js?s=' . $GLOBALS['sugar_version'] . '&c=' . $GLOBALS['sugar_config']['js_custom_version'] . '&j=' . $GLOBALS['sugar_config']['js_lang_version'] . '"></script>';        }        if (isset($_REQUEST['popup']) && !empty($_REQUEST['popup'])) {            // cn: bug 12274 - add security metadata envelope for async calls in popups            echo '<script type="text/javascript">var asynchronous_key = "' . $_SESSION['asynchronous_key'] . '";</script>'; // cn: bug 12274 - create session-stored key to defend against CSRF        }    }    /**     * Called from process(). This method will display the footer on the page.     */    function displayFooter()    {        if (empty($this->responseTime)) {            $this->calculateFooterMetrics();        }        global $sugar_config;        global $app_strings;        $sugar_config = $GLOBALS['sugar_config'];        $action = $this->action;        //decide whether or not to show themepicker, default is to show        $showThemePicker = true;        if (isset($sugar_config['showThemePicker'])) {            $showThemePicker = $sugar_config['showThemePicker'];        }

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?