public function __construct()
 {
     parent::__construct();
     if (!file_exists(SUGAR_SMARTY_DIR)) {
         mkdir_recursive(SUGAR_SMARTY_DIR, true);
     }
     if (!file_exists(SUGAR_SMARTY_DIR . 'templates_c')) {
         mkdir_recursive(SUGAR_SMARTY_DIR . 'templates_c', true);
     }
     if (!file_exists(SUGAR_SMARTY_DIR . 'configs')) {
         mkdir_recursive(SUGAR_SMARTY_DIR . 'configs', true);
     }
     if (!file_exists(SUGAR_SMARTY_DIR . 'cache')) {
         mkdir_recursive(SUGAR_SMARTY_DIR . 'cache', true);
     }
     $this->template_dir = '.';
     $this->compile_dir = SUGAR_SMARTY_DIR . 'templates_c';
     $this->config_dir = SUGAR_SMARTY_DIR . 'configs';
     $this->cache_dir = SUGAR_SMARTY_DIR . 'cache';
     $this->request_use_auto_globals = true;
     // to disable Smarty from using long arrays
     if (file_exists('custom/include/Smarty/plugins')) {
         $plugins_dir[] = 'custom/include/Smarty/plugins';
     }
     $plugins_dir[] = 'include/Smarty/plugins';
     $this->plugins_dir = $plugins_dir;
     $this->assign("VERSION_MARK", getVersionedPath(''));
 }
Exemple #2
0
 /**
  * Processes / setups the template
  * assigns all things to the template like mod_srings and app_strings
  *
  */
 function process()
 {
     global $current_language, $app_strings, $sugar_version, $sugar_config, $timedate, $theme;
     $module_strings = return_module_language($current_language, $this->module);
     $this->ss->assign('SUGAR_VERSION', $sugar_version);
     $this->ss->assign('JS_CUSTOM_VERSION', $sugar_config['js_custom_version']);
     $this->ss->assign('VERSION_MARK', getVersionedPath(''));
     $this->ss->assign('THEME', $theme);
     $this->ss->assign('APP', $app_strings);
     $this->ss->assign('MOD', $module_strings);
 }
 function Sugar_Smarty()
 {
     if (!file_exists(SUGAR_SMARTY_DIR)) {
         mkdir_recursive(SUGAR_SMARTY_DIR, true);
     }
     if (!file_exists(SUGAR_SMARTY_DIR . 'templates_c')) {
         mkdir_recursive(SUGAR_SMARTY_DIR . 'templates_c', true);
     }
     if (!file_exists(SUGAR_SMARTY_DIR . 'configs')) {
         mkdir_recursive(SUGAR_SMARTY_DIR . 'configs', true);
     }
     if (!file_exists(SUGAR_SMARTY_DIR . 'cache')) {
         mkdir_recursive(SUGAR_SMARTY_DIR . 'cache', true);
     }
     $this->template_dir = '.';
     $this->compile_dir = SUGAR_SMARTY_DIR . 'templates_c';
     $this->config_dir = SUGAR_SMARTY_DIR . 'configs';
     $this->cache_dir = SUGAR_SMARTY_DIR . 'cache';
     $this->request_use_auto_globals = true;
     // to disable Smarty from using long arrays
     // Smarty will create subdirectories under the compiled templates and cache directories
     $this->use_sub_dirs = true;
     if (empty(self::$_plugins_dir)) {
         self::$_plugins_dir = array();
         if (SugarAutoLoader::fileExists('custom/include/SugarSmarty/plugins')) {
             self::$_plugins_dir[] = 'custom/include/SugarSmarty/plugins';
         }
         if (SugarAutoLoader::fileExists('custom/vendor/Smarty/plugins')) {
             self::$_plugins_dir[] = 'custom/vendor/Smarty/plugins';
         }
         self::$_plugins_dir[] = 'include/SugarSmarty/plugins';
         self::$_plugins_dir[] = 'vendor/Smarty/plugins';
     }
     $this->plugins_dir = self::$_plugins_dir;
     $this->assign("VERSION_MARK", getVersionedPath(''));
 }
Exemple #4
0
 * Copyright (C) SugarCRM Inc. All rights reserved.
 */
// $Id: license.php 54512 2010-02-12 19:13:35Z jmertic $
global $sugar_version, $js_custom_version;
if (!isset($install_script) || !$install_script) {
    die('Unable to process script directly.');
}
// setup session variables (and their defaults) if this page has not yet been submitted
if (!isset($_SESSION['license_submitted']) || !$_SESSION['license_submitted']) {
    $_SESSION['setup_license_accept'] = false;
}
$checked = isset($_SESSION['setup_license_accept']) && !empty($_SESSION['setup_license_accept']) ? 'checked="on"' : '';
require_once "install/install_utils.php";
$license_file = getLicenseContents("LICENSE");
$langHeader = get_language_header();
$versionToken = getVersionedPath(null);
$out = <<<EOQ
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html {$langHeader}>
<head>
   <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
   <meta http-equiv="Content-Style-Type" content="text/css">
   <title>{$mod_strings['LBL_WIZARD_TITLE']} {$mod_strings['LBL_LICENSE_ACCEPTANCE']}</title>
   <link REL="SHORTCUT ICON" HREF="include/images/sugar_icon.ico">
   <link rel="stylesheet" href="install/install.css" type="text/css">
   <script src="cache/include/javascript/sugar_grp1_yui.js?v={$versionToken}"></script>
   <script type="text/javascript">
    <!--
    if ( YAHOO.env.ua )
        UA = YAHOO.env.ua;
    -->
Exemple #5
0
 /**
  * Renders the QuickCreate form from Smarty and returns HTML
  * @param array $vars request variable global
  * @param object $email Fetched email object
  * @param bool $addToAddressBook
  * @return array
  */
 function getQuickCreateForm($vars, $email, $addToAddressBookButton = false)
 {
     require_once "include/EditView/EditView2.php";
     global $app_strings;
     global $mod_strings;
     global $current_user;
     global $beanList;
     global $beanFiles;
     global $current_language;
     //Setup the current module languge
     $mod_strings = return_module_language($current_language, $_REQUEST['qc_module']);
     $bean = $beanList[$_REQUEST['qc_module']];
     $class = $beanFiles[$bean];
     require_once $class;
     $focus = new $bean();
     $people = array('Contact', 'Lead');
     $emailAddress = array();
     // people
     if (in_array($bean, $people)) {
         // lead specific
         $focus->lead_source = 'Email';
         $focus->lead_source_description = trim($email->name);
         $from = isset($email->from_name) && !empty($email->from_name) ? $email->from_name : $email->from_addr;
         if (isset($_REQUEST['sugarEmail']) && !empty($_REQUEST['sugarEmail'])) {
             if ($email->status == "sent") {
                 $from = isset($email->to_addrs_names) && !empty($email->to_addrs_names) ? $email->to_addrs_names : $email->to_addrs;
             } else {
                 $from = isset($email->from_name) && !empty($email->from_name) ? $email->from_name : $email->from_addr_name;
             }
         }
         $name = explode(" ", trim($from));
         $address = trim(array_pop($name));
         $address = str_replace(array("<", ">", "&lt;", "&gt;"), "", $address);
         $emailAddress[] = array('email_address' => $address, 'primary_address' => 1, 'invalid_email' => 0, 'opt_out' => 0, 'reply_to_address' => 1);
         $focus->email1 = $address;
         if (!empty($name)) {
             $focus->last_name = trim(array_pop($name));
             foreach ($name as $first) {
                 if (!empty($focus->first_name)) {
                     $focus->first_name .= " ";
                 }
                 $focus->first_name .= trim($first);
             }
         }
     } else {
         // bugs, cases, tasks
         $focus->name = trim($email->name);
     }
     $focus->description = trim(strip_tags($email->description));
     $focus->assigned_user_id = $current_user->id;
     $EditView = new EditView();
     $EditView->ss = new Sugar_Smarty();
     //MFH BUG#20283 - checks for custom quickcreate fields
     $EditView->setup($_REQUEST['qc_module'], $focus, 'custom/modules/' . $focus->module_dir . '/metadata/editviewdefs.php', 'include/EditView/EditView.tpl');
     $EditView->process();
     $EditView->render();
     $EditView->defs['templateMeta']['form']['buttons'] = array('email2save' => array('id' => 'e2AjaxSave', 'customCode' => '<input type="button" class="button" value="   ' . $app_strings['LBL_SAVE_BUTTON_LABEL'] . '   " onclick="SUGAR.email2.detailView.saveQuickCreate(false);" />'), 'email2saveandreply' => array('id' => 'e2SaveAndReply', 'customCode' => '<input type="button" class="button" value="   ' . $app_strings['LBL_EMAIL_SAVE_AND_REPLY'] . '   " onclick="SUGAR.email2.detailView.saveQuickCreate(\'reply\');" />'), 'email2cancel' => array('id' => 'e2cancel', 'customCode' => '<input type="button" class="button" value="   ' . $app_strings['LBL_EMAIL_CANCEL'] . '   " onclick="SUGAR.email2.detailView.quickCreateDialog.hide();" />'));
     if ($addToAddressBookButton) {
         $EditView->defs['templateMeta']['form']['buttons']['email2saveAddToAddressBook'] = array('id' => 'e2addToAddressBook', 'customCode' => '<input type="button" class="button" value="   ' . $app_strings['LBL_EMAIL_ADDRESS_BOOK_SAVE_AND_ADD'] . '   " onclick="SUGAR.email2.detailView.saveQuickCreate(true);" />');
     }
     //Get the module language for javascript
     if (!is_file(sugar_cached('jsLanguage/') . $_REQUEST['qc_module'] . '/' . $GLOBALS['current_language'] . '.js')) {
         require_once 'include/language/jsLanguage.php';
         jsLanguage::createModuleStringsCache($_REQUEST['qc_module'], $GLOBALS['current_language']);
     }
     $jsLanguage = getVersionedScript("cache/jsLanguage/{$_REQUEST['qc_module']}/{$GLOBALS['current_language']}.js", $GLOBALS['sugar_config']['js_lang_version']);
     $EditView->view = 'EmailQCView';
     $EditView->defs['templateMeta']['form']['headerTpl'] = 'include/EditView/header.tpl';
     $EditView->defs['templateMeta']['form']['footerTpl'] = 'include/EditView/footer.tpl';
     $meta = array();
     $meta['html'] = $jsLanguage . $EditView->display(false, true);
     $meta['html'] = str_replace("src='" . getVersionedPath('include/SugarEmailAddress/SugarEmailAddress.js') . "'", '', $meta['html']);
     $meta['emailAddress'] = $emailAddress;
     $mod_strings = return_module_language($current_language, 'Emails');
     return $meta;
 }
Exemple #6
0
function getJSPath($relative_path, $additional_attrs = '')
{
    if (defined('TEMPLATE_URL')) {
        $relative_path = SugarTemplateUtilities::getWebPath($relative_path);
    }
    return getVersionedPath($relative_path) . (!empty($additional_attrs) ? "&{$additional_attrs}" : "");
}
Exemple #7
0
 function parse($bname)
 {
     global $sugar_version, $sugar_config;
     $this->assign('SUGAR_VERSION', $GLOBALS['js_version_key']);
     $this->assign('JS_CUSTOM_VERSION', $sugar_config['js_custom_version']);
     $this->assign('VERSION_MARK', getVersionedPath(''));
     if (empty($this->blocks[$bname])) {
         return;
     }
     $copy = $this->blocks[$bname];
     if (!isset($this->blocks[$bname])) {
         $this->set_error("parse: blockname [{$bname}] does not exist");
     }
     preg_match_all("/\\{([A-Za-z0-9\\._]+?)}/", $this->blocks[$bname], $var_array);
     $var_array = $var_array[1];
     foreach ($var_array as $k => $v) {
         $sub = explode(".", $v);
         if ($sub[0] == "_BLOCK_") {
             unset($sub[0]);
             $bname2 = implode(".", $sub);
             if (isset($this->parsed_blocks[$bname2])) {
                 $var = $this->parsed_blocks[$bname2];
             } else {
                 $var = null;
             }
             $nul = !isset($this->NULL_BLOCK[$bname2]) ? $this->NULL_BLOCK[""] : $this->NULL_BLOCK[$bname2];
             $var = empty($var) ? $nul : trim($var);
             // Commented out due to regular expression issue with '$' in replacement string.
             //$copy=preg_replace("/\{".$v."\}/","$var",$copy);
             // This should be faster and work better for '$'
             $copy = str_replace("{" . $v . "}", $var, $copy);
         } else {
             $var = $this->VARS;
             foreach ($sub as $k1 => $v1) {
                 if (is_array($var) && isset($var[$v1])) {
                     $var = $var[$v1];
                 } else {
                     $var = null;
                 }
             }
             $nul = !isset($this->NULL_STRING[$v]) ? $this->NULL_STRING[""] : $this->NULL_STRING[$v];
             $var = !isset($var) ? $nul : $var;
             // Commented out due to regular expression issue with '$' in replacement string.
             //$copy=preg_replace("/\{$v\}/","$var",$copy);
             // This should be faster and work better for '$'
             // this was periodically returning an array to string conversion error....
             if (!is_array($var)) {
                 $copy = str_replace("{" . $v . "}", $var, $copy);
             }
         }
     }
     if (isset($this->parsed_blocks[$bname])) {
         $this->parsed_blocks[$bname] .= $copy;
     } else {
         $this->parsed_blocks[$bname] = $copy;
     }
     // reset sub-blocks
     if ($this->AUTORESET && !empty($this->sub_blocks[$bname])) {
         reset($this->sub_blocks[$bname]);
         foreach ($this->sub_blocks[$bname] as $v) {
             $this->reset($v);
         }
     }
 }
 /**
  * Returns a list of URL's pointing to json-encoded versions of the strings
  *
  * @param boolean $ordered is a flag that determines $app_list_strings should be key => value pairs or tuples
  * @return array
  */
 public function getStringUrls($ordered = false)
 {
     $languageList = array_keys(get_languages());
     sugar_mkdir(sugar_cached('api/metadata'), null, true);
     $fileList = array();
     foreach ($languageList as $language) {
         $fileList[$language] = $this->getLangUrl($language, $ordered);
     }
     $urlList = array();
     foreach ($fileList as $lang => $file) {
         // Get the hash for this lang file so we can append it to the URL.
         // This fixes issues where lang strings or list strings change but
         // don't force a metadata refresh
         $urlList[$lang] = getVersionedPath($this->getUrlForCacheFile($file), $GLOBALS['sugar_config']['js_lang_version'], true);
     }
     $urlList['default'] = $GLOBALS['sugar_config']['default_language'];
     return $urlList;
 }
 /**
  * display
  * This method makes the Smarty variable assignments and theautocomplete_ajax'vars the
  * generated view.
  * @param $showTitle boolean value indicating whether or not to show a title on the resulting page
  * @param $ajaxSave boolean value indicating whether or not the operation is an Ajax save request
  * @return HTML display for view as String
  */
 function display($showTitle = true, $ajaxSave = false)
 {
     global $mod_strings, $sugar_config, $app_strings, $app_list_strings, $theme, $current_user;
     if (isset($this->defs['templateMeta']['javascript'])) {
         if (is_array($this->defs['templateMeta']['javascript'])) {
             //$this->th->ss->assign('externalJSFile', 'modules/' . $this->module . '/metadata/editvewdefs.js');
             $this->th->ss->assign('externalJSFile', $this->defs['templateMeta']['javascript']);
         } else {
             $this->th->ss->assign('scriptBlocks', $this->defs['templateMeta']['javascript']);
         }
     }
     $this->th->ss->assign('id', $this->fieldDefs['id']['value']);
     $this->th->ss->assign('offset', $this->offset + 1);
     $this->th->ss->assign('APP', $app_strings);
     $this->th->ss->assign('MOD', $mod_strings);
     $this->th->ss->assign('fields', $this->fieldDefs);
     $this->th->ss->assign('sectionPanels', $this->sectionPanels);
     $this->th->ss->assign('config', $sugar_config);
     $this->th->ss->assign('returnModule', $this->returnModule);
     $this->th->ss->assign('returnAction', $this->returnAction);
     $this->th->ss->assign('returnId', $this->returnId);
     $this->th->ss->assign('isDuplicate', $this->isDuplicate);
     $this->th->ss->assign('def', $this->defs);
     $this->th->ss->assign('useTabs', isset($this->defs['templateMeta']['useTabs']) ? $this->defs['templateMeta']['useTabs'] : false);
     $this->th->ss->assign('maxColumns', isset($this->defs['templateMeta']['maxColumns']) ? $this->defs['templateMeta']['maxColumns'] : 2);
     $this->th->ss->assign('module', $this->module);
     $this->th->ss->assign('headerTpl', isset($this->defs['templateMeta']['form']['headerTpl']) ? $this->defs['templateMeta']['form']['headerTpl'] : 'include/' . $this->view . '/header.tpl');
     $this->th->ss->assign('footerTpl', isset($this->defs['templateMeta']['form']['footerTpl']) ? $this->defs['templateMeta']['form']['footerTpl'] : 'include/' . $this->view . '/footer.tpl');
     $this->th->ss->assign('current_user', $current_user);
     $this->th->ss->assign('bean', $this->focus);
     $this->th->ss->assign('isAuditEnabled', $this->focus->is_AuditEnabled());
     $this->th->ss->assign('gridline', $current_user->getPreference('gridline') == 'on' ? '1' : '0');
     $this->th->ss->assign('VERSION_MARK', getVersionedPath(''));
     global $js_custom_version;
     global $sugar_version;
     $this->th->ss->assign('SUGAR_VERSION', $sugar_version);
     $this->th->ss->assign('JS_CUSTOM_VERSION', $js_custom_version);
     //this is used for multiple forms on one page
     if (!empty($this->formName)) {
         $form_id = $this->formName;
         $form_name = $this->formName;
     } else {
         $form_id = $this->view;
         $form_name = $this->view;
     }
     if ($ajaxSave && empty($this->formName)) {
         $form_id = 'form_' . $this->view . '_' . $this->module;
         $form_name = $form_id;
         $this->view = $form_name;
         //$this->defs['templateMeta']['form']['buttons'] = array();
         //$this->defs['templateMeta']['form']['buttons']['ajax_save'] = array('id' => 'AjaxSave', 'customCode'=>'<input type="button" class="button" value="Save" onclick="this.form.action.value=\'AjaxFormSave\';return saveForm(\''.$form_name.'\', \'multiedit_form_{$module}\', \'Saving {$module}...\');"/>');
     }
     $form_name = $form_name == 'QuickCreate' ? "QuickCreate_{$this->module}" : $form_name;
     $form_id = $form_id == 'QuickCreate' ? "QuickCreate_{$this->module}" : $form_id;
     if (isset($this->defs['templateMeta']['preForm'])) {
         $this->th->ss->assign('preForm', $this->defs['templateMeta']['preForm']);
     }
     if (isset($this->defs['templateMeta']['form']['closeFormBeforeCustomButtons'])) {
         $this->th->ss->assign('closeFormBeforeCustomButtons', $this->defs['templateMeta']['form']['closeFormBeforeCustomButtons']);
     }
     if (isset($this->defs['templateMeta']['form']['enctype'])) {
         $this->th->ss->assign('enctype', 'enctype="' . $this->defs['templateMeta']['form']['enctype'] . '"');
     }
     //for SugarFieldImage, we must set form enctype to "multipart/form-data"
     foreach ($this->fieldDefs as $field) {
         if (isset($field['type']) && $field['type'] == 'image') {
             $this->th->ss->assign('enctype', 'enctype="multipart/form-data"');
             break;
         }
     }
     $this->th->ss->assign('showDetailData', $this->showDetailData);
     $this->th->ss->assign('showSectionPanelsTitles', $this->showSectionPanelsTitles);
     $this->th->ss->assign('form_id', $form_id);
     $this->th->ss->assign('form_name', $form_name);
     $this->th->ss->assign('set_focus_block', get_set_focus_js());
     $this->th->ss->assign('form', isset($this->defs['templateMeta']['form']) ? $this->defs['templateMeta']['form'] : null);
     $this->th->ss->assign('includes', isset($this->defs['templateMeta']['includes']) ? $this->defs['templateMeta']['includes'] : null);
     $this->th->ss->assign('view', $this->view);
     //Calculate time & date formatting (may need to calculate this depending on a setting)
     global $timedate;
     $this->th->ss->assign('CALENDAR_DATEFORMAT', $timedate->get_cal_date_format());
     $this->th->ss->assign('USER_DATEFORMAT', $timedate->get_user_date_format());
     $time_format = $timedate->get_user_time_format();
     $this->th->ss->assign('TIME_FORMAT', $time_format);
     $date_format = $timedate->get_cal_date_format();
     $time_separator = ':';
     if (preg_match('/\\d+([^\\d])\\d+([^\\d]*)/s', $time_format, $match)) {
         $time_separator = $match[1];
     }
     // Create Smarty variables for the Calendar picker widget
     $t23 = strpos($time_format, '23') !== false ? '%H' : '%I';
     if (!isset($match[2]) || $match[2] == '') {
         $this->th->ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . '%M');
     } else {
         $pm = $match[2] == 'pm' ? '%P' : '%p';
         $this->th->ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . '%M' . $pm);
     }
     $this->th->ss->assign('CALENDAR_FDOW', $current_user->get_first_day_of_week());
     $this->th->ss->assign('TIME_SEPARATOR', $time_separator);
     $seps = get_number_seperators();
     $this->th->ss->assign('NUM_GRP_SEP', $seps[0]);
     $this->th->ss->assign('DEC_SEP', $seps[1]);
     if ($this->view == 'EditView') {
         $height = $current_user->getPreference('text_editor_height');
         $width = $current_user->getPreference('text_editor_width');
         $height = isset($height) ? $height : '300px';
         $width = isset($width) ? $width : '95%';
         $this->th->ss->assign('RICH_TEXT_EDITOR_HEIGHT', $height);
         $this->th->ss->assign('RICH_TEXT_EDITOR_WIDTH', $width);
     } else {
         $this->th->ss->assign('RICH_TEXT_EDITOR_HEIGHT', '100px');
         $this->th->ss->assign('RICH_TEXT_EDITOR_WIDTH', '95%');
     }
     $this->th->ss->assign('SHOW_VCR_CONTROL', $this->showVCRControl);
     $str = $this->showTitle($showTitle);
     //Use the output filter to trim the whitespace
     $this->th->ss->load_filter('output', 'trimwhitespace');
     $str .= $this->th->displayTemplate($this->module, $form_name, $this->tpl, $ajaxSave, $this->defs);
     return $str;
 }
Exemple #10
0
    /**
     * display
     * This method makes the Smarty variable assignments and then displays the
     * generated view.
     * @param $showTitle boolean value indicating whether or not to show a title on the resulting page
     * @param $ajaxSave boolean value indicating whether or not the operation is an Ajax save request
     * @return HTML display for view as String
     */
    function display($showTitle = true, $ajaxSave = false)
    {
        global $mod_strings, $sugar_config, $app_strings, $app_list_strings, $theme, $current_user;
        if (isset($this->defs['templateMeta']['javascript'])) {
            if (is_array($this->defs['templateMeta']['javascript'])) {
                //$this->th->ss->assign('externalJSFile', 'modules/' . $this->module . '/metadata/editvewdefs.js');
                $this->th->ss->assign('externalJSFile', $this->defs['templateMeta']['javascript']);
            } else {
                $this->th->ss->assign('scriptBlocks', $this->defs['templateMeta']['javascript']);
            }
        }
        $this->th->ss->assign('id', $this->fieldDefs['id']['value']);
        $this->th->ss->assign('offset', $this->offset + 1);
        $this->th->ss->assign('APP', $app_strings);
        $this->th->ss->assign('MOD', $mod_strings);
        $this->th->ss->assign('fields', $this->fieldDefs);
        $this->th->ss->assign('sectionPanels', $this->sectionPanels);
        $this->th->ss->assign('config', $sugar_config);
        $this->th->ss->assign('returnModule', $this->returnModule);
        $this->th->ss->assign('returnAction', $this->returnAction);
        $this->th->ss->assign('returnId', $this->returnId);
        $this->th->ss->assign('isDuplicate', $this->isDuplicate);
        $this->th->ss->assign('def', $this->defs);
        $this->th->ss->assign('useTabs', isset($this->defs['templateMeta']['useTabs']) && isset($this->defs['templateMeta']['tabDefs']) ? $this->defs['templateMeta']['useTabs'] : false);
        $this->th->ss->assign('maxColumns', isset($this->defs['templateMeta']['maxColumns']) ? $this->defs['templateMeta']['maxColumns'] : 2);
        $this->th->ss->assign('module', $this->module);
        $this->th->ss->assign('headerTpl', isset($this->defs['templateMeta']['form']['headerTpl']) ? $this->defs['templateMeta']['form']['headerTpl'] : 'include/' . $this->view . '/header.tpl');
        $this->th->ss->assign('footerTpl', isset($this->defs['templateMeta']['form']['footerTpl']) ? $this->defs['templateMeta']['form']['footerTpl'] : 'include/' . $this->view . '/footer.tpl');
        $this->th->ss->assign('current_user', $current_user);
        $this->th->ss->assign('bean', $this->focus);
        $this->th->ss->assign('isAuditEnabled', $this->focus->is_AuditEnabled());
        $this->th->ss->assign('gridline', $current_user->getPreference('gridline') == 'on' ? '1' : '0');
        $this->th->ss->assign('tabDefs', isset($this->defs['templateMeta']['tabDefs']) ? $this->defs['templateMeta']['tabDefs'] : false);
        $this->th->ss->assign('VERSION_MARK', getVersionedPath(''));
        global $js_custom_version;
        global $sugar_version;
        $this->th->ss->assign('SUGAR_VERSION', $sugar_version);
        $this->th->ss->assign('JS_CUSTOM_VERSION', $js_custom_version);
        //this is used for multiple forms on one page
        if (!empty($this->formName)) {
            $form_id = $this->formName;
            $form_name = $this->formName;
        } else {
            $form_id = $this->view;
            $form_name = $this->view;
        }
        if ($ajaxSave && empty($this->formName)) {
            $form_id = 'form_' . $this->view . '_' . $this->module;
            $form_name = $form_id;
            $this->view = $form_name;
            //$this->defs['templateMeta']['form']['buttons'] = array();
            //$this->defs['templateMeta']['form']['buttons']['ajax_save'] = array('id' => 'AjaxSave', 'customCode'=>'<input type="button" class="button" value="Save" onclick="this.form.action.value=\'AjaxFormSave\';return saveForm(\''.$form_name.'\', \'multiedit_form_{$module}\', \'Saving {$module}...\');"/>');
        }
        $form_name = $form_name == 'QuickCreate' ? "QuickCreate_{$this->module}" : $form_name;
        $form_id = $form_id == 'QuickCreate' ? "QuickCreate_{$this->module}" : $form_id;
        if (isset($this->defs['templateMeta']['preForm'])) {
            $this->th->ss->assign('preForm', $this->defs['templateMeta']['preForm']);
        }
        if (isset($this->defs['templateMeta']['form']['closeFormBeforeCustomButtons'])) {
            $this->th->ss->assign('closeFormBeforeCustomButtons', $this->defs['templateMeta']['form']['closeFormBeforeCustomButtons']);
        }
        if (isset($this->defs['templateMeta']['form']['enctype'])) {
            $this->th->ss->assign('enctype', 'enctype="' . $this->defs['templateMeta']['form']['enctype'] . '"');
        }
        //for SugarFieldImage, we must set form enctype to "multipart/form-data"
        foreach ($this->fieldDefs as $field) {
            if (isset($field['type']) && $field['type'] == 'image') {
                $this->th->ss->assign('enctype', 'enctype="multipart/form-data"');
                break;
            }
        }
        $this->th->ss->assign('showDetailData', $this->showDetailData);
        $this->th->ss->assign('showSectionPanelsTitles', $this->showSectionPanelsTitles);
        $this->th->ss->assign('form_id', $form_id);
        $this->th->ss->assign('form_name', $form_name);
        $this->th->ss->assign('set_focus_block', get_set_focus_js());
        $this->th->ss->assign('form', isset($this->defs['templateMeta']['form']) ? $this->defs['templateMeta']['form'] : null);
        $this->th->ss->assign('includes', isset($this->defs['templateMeta']['includes']) ? $this->defs['templateMeta']['includes'] : null);
        $this->th->ss->assign('view', $this->view);
        //Calculate time & date formatting (may need to calculate this depending on a setting)
        global $timedate;
        $this->th->ss->assign('CALENDAR_DATEFORMAT', $timedate->get_cal_date_format());
        $this->th->ss->assign('USER_DATEFORMAT', $timedate->get_user_date_format());
        $time_format = $timedate->get_user_time_format();
        $this->th->ss->assign('TIME_FORMAT', $time_format);
        $date_format = $timedate->get_cal_date_format();
        $time_separator = ':';
        if (preg_match('/\\d+([^\\d])\\d+([^\\d]*)/s', $time_format, $match)) {
            $time_separator = $match[1];
        }
        // Create Smarty variables for the Calendar picker widget
        $t23 = strpos($time_format, '23') !== false ? '%H' : '%I';
        if (!isset($match[2]) || $match[2] == '') {
            $this->th->ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . '%M');
        } else {
            $pm = $match[2] == 'pm' ? '%P' : '%p';
            $this->th->ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . '%M' . $pm);
        }
        $this->th->ss->assign('CALENDAR_FDOW', $current_user->get_first_day_of_week());
        $this->th->ss->assign('TIME_SEPARATOR', $time_separator);
        $seps = get_number_seperators();
        $this->th->ss->assign('NUM_GRP_SEP', $seps[0]);
        $this->th->ss->assign('DEC_SEP', $seps[1]);
        if ($this->view == 'EditView') {
            $height = $current_user->getPreference('text_editor_height');
            $width = $current_user->getPreference('text_editor_width');
            $height = isset($height) ? $height : '300px';
            $width = isset($width) ? $width : '95%';
            $this->th->ss->assign('RICH_TEXT_EDITOR_HEIGHT', $height);
            $this->th->ss->assign('RICH_TEXT_EDITOR_WIDTH', $width);
        } else {
            $this->th->ss->assign('RICH_TEXT_EDITOR_HEIGHT', '100px');
            $this->th->ss->assign('RICH_TEXT_EDITOR_WIDTH', '95%');
        }
        $this->th->ss->assign('SHOW_VCR_CONTROL', $this->showVCRControl);
        $str = $this->showTitle($showTitle);
        //Use the output filter to trim the whitespace
        $this->th->ss->load_filter('output', 'trimwhitespace');
        $str .= $this->th->displayTemplate($this->module, $form_name, $this->tpl, $ajaxSave, $this->defs);
        /* BEGIN - SECURITY GROUPS */
        //if popup select add panel if user is a member of multiple groups to metadataFile
        global $sugar_config;
        if (isset($sugar_config['securitysuite_popup_select']) && $sugar_config['securitysuite_popup_select'] == true && empty($this->focus->fetched_row['id']) && $this->focus->module_dir != "Users" && $this->focus->module_dir != "SugarFeed") {
            //there are cases such as uploading an attachment to an email template where the request module may
            //not be the same as the current bean module. If that happens we can just skip it
            //however...let quickcreate through
            if ($this->view != 'QuickCreate' && (empty($_REQUEST['module']) || $_REQUEST['module'] != $this->focus->module_dir)) {
                return $str;
            }
            require_once 'modules/SecurityGroups/SecurityGroup.php';
            $groupFocus = new SecurityGroup();
            $security_modules = $groupFocus->getSecurityModules();
            if (in_array($this->focus->module_dir, array_keys($security_modules))) {
                global $current_user;
                $group_count = $groupFocus->getMembershipCount($current_user->id);
                if ($group_count > 1) {
                    $groups = $groupFocus->getUserSecurityGroups($current_user->id);
                    $group_options = '';
                    foreach ($groups as $group) {
                        $group_options .= '<option value="' . $group['id'] . '" label="' . $group['name'] . '" selected="selected">' . $group['name'] . '</option>';
                    }
                    //multilingual support
                    global $current_language;
                    $ss_mod_strings = return_module_language($current_language, 'SecurityGroups');
                    $lbl_securitygroups_select = $ss_mod_strings['LBL_GROUP_SELECT'];
                    $lbl_securitygroups = $ss_mod_strings['LBL_LIST_FORM_TITLE'];
                    $group_panel = <<<EOQ
<div class="edit view edit508 " id="detailpanel_securitygroups">
    <h4>&nbsp;&nbsp;
    {$lbl_securitygroups_select}
    </h4>
    <table width="100%" cellspacing="1" cellpadding="0" border="0" class="edit view panelContainer" id="LBL_PANEL_SECURITYGROUPS">
    <tbody><tr>
    <td width="12.5%" valign="top" scope="col" id="account_type_label">
        {$lbl_securitygroups}:
    </td>
    <td width="37.5%" valign="top">
        <select title="" id="securitygroup_list" name="securitygroup_list[]" multiple="multiple" size="{$group_count}">
        {$group_options}
        </select>
    </td>
    </tr>
    </tbody></table>
</div>
EOQ;
                    $group_panel = preg_replace("/[\r\n]+/", "", $group_panel);
                    $group_panel_append = <<<EOQ
<script>
    \$('#{$form_name}_tabs div:first').append(\$('{$group_panel}'));
</script>
EOQ;
                    $str .= $group_panel_append;
                }
            }
        }
        /* END - SECURITY GROUPS */
        return $str;
    }
 /**
  * createSprites
  *
  * This is the public function to allow the sprites to be built.
  *
  * @return $result boolean value indicating whether or not sprites were created
  */
 public function createSprites()
 {
     global $mod_strings;
     if (!$this->isAvailable) {
         if (!$this->silentRun) {
             $msg = $mod_strings['LBL_SPRITES_NOT_SUPPORTED'];
             $GLOBALS['log']->warn($msg);
             $this->logMessage($msg);
         }
         return false;
     }
     // add repeatable sprites
     if (count($this->spriteRepeat)) {
         $this->spriteSrc = array_merge($this->spriteSrc, $this->spriteRepeat);
     }
     foreach ($this->spriteSrc as $name => $dirs) {
         if (!$this->silentRun) {
             $msg = string_format($mod_strings['LBL_SPRITES_CREATING_NAMESPACE'], array($name));
             $GLOBALS['log']->debug($msg);
             $this->logMessage($msg);
         }
         // setup config for sprite placement algorithm
         if (substr($name, 0, 6) == 'repeat') {
             $isRepeat = true;
             $type = substr($name, 7, 10) == 'horizontal' ? 'horizontal' : 'vertical';
             $config = array('type' => $type);
         } else {
             $isRepeat = false;
             $config = array('type' => 'boxed', 'width' => $this->maxWidth, 'height' => $this->maxHeight, 'rowcnt' => $this->rowCnt);
         }
         // use separate class to arrange the images
         $sp = new SpritePlacement($dirs, $config);
         $sp->processSprites();
         //if(! $this->silentRun)
         //	echo " (size {$sp->width()}x{$sp->height()})<br />";
         // we need a target image size
         if ($sp->width() && $sp->height()) {
             // init sprite image
             $this->initSpriteImg($sp->width(), $sp->height());
             // add sprites based upon determined coordinates
             foreach ($dirs as $dir => $files) {
                 if (!$this->silentRun) {
                     $msg = string_format($mod_strings['LBL_SPRITES_PROCESSING_DIR'], array($dir));
                     $GLOBALS['log']->debug($msg);
                     $this->logMessage($msg);
                 }
                 foreach ($files as $file => $info) {
                     if ($im = $this->loadImage($dir, $file, $info['type'])) {
                         // coordinates
                         $dst_x = $sp->spriteMatrix[$dir . '/' . $file]['x'];
                         $dst_y = $sp->spriteMatrix[$dir . '/' . $file]['y'];
                         imagecopy($this->spriteImg, $im, $dst_x, $dst_y, 0, 0, $info['x'], $info['y']);
                         imagedestroy($im);
                         if (!$this->silentRun) {
                             $msg = string_format($mod_strings['LBL_SPRITES_ADDED'], array("{$dir}/{$file}"));
                             $GLOBALS['log']->debug($msg);
                             $this->logMessage($msg);
                         }
                     }
                 }
             }
             // dir & filenames
             if ($isRepeat) {
                 $outputDir = sugar_cached("sprites/Repeatable");
                 $spriteFileName = "{$name}.png";
                 $cssFileName = "{$this->fileName}.css";
                 $metaFileName = "{$this->fileName}.meta.php";
                 $nameSpace = "Repeatable";
             } else {
                 $outputDir = sugar_cached("sprites/{$name}");
                 $spriteFileName = "{$this->fileName}.png";
                 $cssFileName = "{$this->fileName}.css";
                 $metaFileName = "{$this->fileName}.meta.php";
                 $nameSpace = "{$name}";
             }
             // directory structure
             if (!is_dir(sugar_cached("sprites/{$nameSpace}"))) {
                 sugar_mkdir(sugar_cached("sprites/{$nameSpace}"), 0775, true);
             }
             // save sprite image
             // Unfortunately, in PHP before 5.4 imagepng can not save to streams, so we need to do a little trick here
             $temp = tempnam($outputDir, "sprites");
             imagepng($this->spriteImg, $temp, $this->pngCompression, $this->pngFilter);
             copy($temp, "{$outputDir}/{$spriteFileName}");
             unlink($temp);
             imagedestroy($this->spriteImg);
             /* generate css & metadata */
             $head = '';
             $body = '';
             $metadata = '';
             foreach ($sp->spriteSrc as $id => $info) {
                 // sprite id
                 $hash_id = md5($id);
                 // header
                 $head .= "span.spr_{$hash_id},\n";
                 // image size
                 $w = $info['x'];
                 $h = $info['y'];
                 // image offset
                 $offset_x = $sp->spriteMatrix[$id]['x'];
                 $offset_y = $sp->spriteMatrix[$id]['y'];
                 // sprite css
                 $body .= "/* {$id} */\nspan.spr_{$hash_id} {\nwidth: {$w}px;\nheight: {$h}px;\nbackground-position: -{$offset_x}px -{$offset_y}px;\n}\n";
                 $metadata .= '$sprites["' . $id . '"] = array ("class"=>"' . $hash_id . '","width"=>"' . $w . '","height"=>"' . $h . '");' . "\n";
             }
             // common css header
             require_once 'include/utils.php';
             $bg_path = getVersionedPath('index.php') . '&entryPoint=getImage&imageName=' . $spriteFileName . '&spriteNamespace=' . $nameSpace;
             $head = rtrim($head, "\n,") . " {background: url('../../../{$bg_path}'); no-repeat;display:inline-block;}\n";
             // append mode for repeatable sprites
             $fileMode = $isRepeat ? 'a' : 'w';
             // save css
             $css_content = "\n/* autogenerated sprites - {$name} */\n" . $head . $body;
             if ($this->cssMinify) {
                 $css_content = cssmin::minify($css_content);
             }
             $fh = fopen("{$outputDir}/{$cssFileName}", $fileMode);
             fwrite($fh, $css_content);
             fclose($fh);
             /* save metadata */
             $add_php_tag = file_exists("{$outputDir}/{$metaFileName}") && $isRepeat ? false : true;
             $fh = fopen("{$outputDir}/{$metaFileName}", $fileMode);
             if ($add_php_tag) {
                 fwrite($fh, '<?php');
             }
             fwrite($fh, "\n/* sprites metadata - {$name} */\n");
             fwrite($fh, $metadata . "\n");
             fclose($fh);
             // if width & height
         } else {
             if (!$this->silentRun) {
                 $msg = string_format($mod_strings['LBL_SPRITES_ADDED'], array($name));
                 $GLOBALS['log']->debug($msg);
                 $this->logMessage($msg);
             }
         }
     }
     return true;
 }
Exemple #12
0
    function yahooJS()
    {
        $custom_module = $_SESSION['studio']['module'];
        $custom_type = $this->curType;
        $v = getVersionedPath('');
        return <<<EOQ
\t\t<style type='text/css'>
\t\t.slot {
\t\tborder-width:1px;border-color:#999999;border-style:solid;padding:0px 1px 0px 1px;margin:2px;cursor:move;

\t}

\t.slotB {
\tborder-width:0;cursor:move;

\t}
\t</style>

\t<!-- Namespace source file -->

\t<script type="text/javascript" src="modules/Studio/JSTransaction.js?v={$v}" ></script>
\t<script>
\tvar jstransaction = new JSTransaction();
\t</script>

\t<!-- Drag and Drop source file -->
\t<script type="text/javascript" src="include/javascript/yui/build/dragdrop/dragdrop.js?v={$v}" ></script>
\t<script type="text/javascript" src="modules/Studio/studiodd.js?v={$v}" ></script>
\t<script type="text/javascript" src="modules/Studio/studio.js?v={$v}" ></script>
\t<script>

\tvar yahooSlots = [];

\tfunction dragDropInit(){

\tYAHOO.util.DDM.mode = YAHOO.util.DDM.POINT;

\tfor(mj = 0; mj <= {$this->yahooSlotCount}; mj++){
\tyahooSlots["slot" + mj] = new ygDDSlot("slot" + mj, "studio");
\t}
\tfor(mj = 0; mj < dyn_field_count; mj++){
\tyahooSlots["dyn_field_" + mj] = new ygDDSlot("dyn_field_" + mj, "studio");
\t}
\t// initPointMode();
\tyahooSlots['s_field_delete'] =  new YAHOO.util.DDTarget("s_field_delete", 'studio');
\t}

\tYAHOO.util.Event.addListener(window, "load", dragDropInit);
\tvar custom_module = '{$custom_module}';
\tvar custom_view = '{$custom_type}';

\t\t\t</script>

EOQ;
    }
Exemple #13
0
    /**
     * Renders the QuickCreate form from Smarty and returns HTML
     * @param array $vars request variable global
     * @param object $email Fetched email object
     * @param bool $addToAddressBook
     * @return array
     */
    function getQuickCreateForm($vars, $email, $addToAddressBookButton = false)
    {
        require_once "include/EditView/EditView2.php";
        global $app_strings;
        global $mod_strings;
        global $current_user;
        global $current_language;
        $module = $_REQUEST['qc_module'];
        $beanName = BeanFactory::getBeanName($module);
        //Setup the current module languge
        $mod_strings = return_module_language($current_language, $module);
        $focus = BeanFactory::getBean($module);
        $people = array('Contact', 'Lead');
        $emailAddress = array();
        // people
        if (in_array($beanName, $people)) {
            // lead specific
            $focus->lead_source = 'Email';
            $focus->lead_source_description = trim($email->name);
            $from = isset($email->from_name) && !empty($email->from_name) ? $email->from_name : $email->from_addr;
            if (isset($_REQUEST['sugarEmail']) && !empty($_REQUEST['sugarEmail'])) {
                if ($email->status == "sent") {
                    $from = isset($email->to_addrs_names) && !empty($email->to_addrs_names) ? $email->to_addrs_names : $email->to_addrs;
                } else {
                    $from = isset($email->from_name) && !empty($email->from_name) ? $email->from_name : $email->from_addr_name;
                }
            }
            $name = explode(" ", trim($from));
            $address = trim(array_pop($name));
            $address = str_replace(array("<", ">", "&lt;", "&gt;"), "", $address);
            $emailAddress[] = array('email_address' => $address, 'primary_address' => 1, 'invalid_email' => 0, 'opt_out' => 0, 'reply_to_address' => 1);
            $focus->email1 = $address;
            if (!empty($name)) {
                $focus->last_name = trim(array_pop($name));
                foreach ($name as $first) {
                    if (!empty($focus->first_name)) {
                        $focus->first_name .= " ";
                    }
                    $focus->first_name .= trim($first);
                }
            }
        } else {
            // case & bug specific
            $focus->source = 'InboundEmail';
            // bugs, cases, tasks
            $focus->name = trim($email->name);
        }
        $focus->description = trim(strip_tags($email->description));
        $focus->assigned_user_id = $current_user->id;
        $focus->team_id = $current_user->default_team;
        $EditView = new EditView();
        $EditView->ss = new Sugar_Smarty();
        //MFH BUG#20283 - checks for custom quickcreate fields
        $EditView->setup($module, $focus, SugarAutoLoader::loadWithMetafiles($module, 'editviewdefs'));
        $EditView->process();
        $EditView->render();
        $EditView->defs['templateMeta']['form']['buttons'] = array('email2save' => array('id' => 'e2AjaxSave', 'customCode' => '<input type="button" class="button" value="   ' . $app_strings['LBL_SAVE_BUTTON_LABEL'] . '   " onclick="SUGAR.email2.detailView.saveQuickCreate(false);" />'), 'email2saveandreply' => array('id' => 'e2SaveAndReply', 'customCode' => '<input type="button" class="button" value="   ' . $app_strings['LBL_EMAIL_SAVE_AND_REPLY'] . '   " onclick="SUGAR.email2.detailView.saveQuickCreate(\'reply\');" />'), 'email2cancel' => array('id' => 'e2cancel', 'customCode' => '<input type="button" class="button" value="   ' . $app_strings['LBL_EMAIL_CANCEL'] . '   " onclick="SUGAR.email2.detailView.quickCreateDialog.hide();" />'));
        if ($addToAddressBookButton) {
            $EditView->defs['templateMeta']['form']['buttons']['email2saveAddToAddressBook'] = array('id' => 'e2addToAddressBook', 'customCode' => '<input type="button" class="button" value="   ' . $app_strings['LBL_EMAIL_ADDRESS_BOOK_SAVE_AND_ADD'] . '   " onclick="SUGAR.email2.detailView.saveQuickCreate(true);" />');
        }
        //Get the module language for javascript
        if (!is_file(sugar_cached('jsLanguage/') . "{$module}/{$GLOBALS['current_language']}.js")) {
            require_once 'include/language/jsLanguage.php';
            jsLanguage::createModuleStringsCache($module, $GLOBALS['current_language']);
        }
        $jsLanguage = getVersionedScript("cache/jsLanguage/{$module}/{$GLOBALS['current_language']}.js", $GLOBALS['sugar_config']['js_lang_version']);
        if ($focus->object_name == 'Contact') {
            $admin = Administration::getSettings();
            if (empty($admin->settings['portal_on']) || !$admin->settings['portal_on']) {
                unset($EditView->sectionPanels[strtoupper('lbl_portal_information')]);
            } else {
                $jsLanguage .= getVersionedScript("modules/Contacts/Contact.js");
                $jsLanguage .= getVersionedScript("modules/Contacts/QuickCreateEmailContact.js");
                $jsLanguage .= <<<EOQ
\t\t\t    <script language="javascript">
\t\t\t\t   addToValidateComparison('form_EmailQCView_Contacts', 'portal_password', 'varchar', false, SUGAR.language.get('app_strings', 'ERR_SQS_NO_MATCH_FIELD') + SUGAR.language.get('Contacts', 'LBL_PORTAL_PASSWORD'), 'portal_password1');
\t\t           addToValidateVerified('form_EmailQCView_Contacts', 'portal_name_verified', 'bool', false, SUGAR.language.get('app_strings', 'ERR_EXISTING_PORTAL_USERNAME'));
\t\t           YAHOO.util.Event.on('portal_name', 'blur', validatePortalName);
\t\t\t\t   YAHOO.util.Event.on('portal_name', 'keydown', handleKeyDown);
\t\t\t    </script>
EOQ;
            }
        }
        $EditView->view = 'EmailQCView';
        $EditView->defs['templateMeta']['form']['headerTpl'] = 'include/EditView/header.tpl';
        $EditView->defs['templateMeta']['form']['footerTpl'] = 'include/EditView/footer.tpl';
        $meta = array();
        $meta['html'] = $jsLanguage . $EditView->display(false, true);
        $meta['html'] = str_replace("src='" . getVersionedPath('include/SugarEmailAddress/SugarEmailAddress.js') . "'", '', $meta['html']);
        $meta['emailAddress'] = $emailAddress;
        $mod_strings = return_module_language($current_language, 'Emails');
        return $meta;
    }
Exemple #14
0
    /**
     * Called from process(). This method will display the correct javascript.
     */
    protected function _displayJavascript()
    {
        global $locale, $sugar_config, $timedate;
        if ($this->_getOption('show_javascript')) {
            if (!$this->_getOption('show_header')) {
                $langHeader = get_language_header();
                echo <<<EOHTML
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html {$langHeader}>
<head>
EOHTML;
            }
            $js_vars = array("sugar_cache_dir" => "cache/");
            if (isset($this->bean->module_dir)) {
                $js_vars['module_sugar_grp1'] = $this->bean->module_dir;
            }
            if (isset($_REQUEST['action'])) {
                $js_vars['action_sugar_grp1'] = $_REQUEST['action'];
            }
            echo '<script>jscal_today = 1000*' . $timedate->asUserTs($timedate->getNow()) . '; if(typeof app_strings == "undefined") app_strings = new Array();</script>';
            // Make sure the necessary cache files are in place
            $jsFiles = array("sugar_grp1.js", "sugar_grp1_yui.js", "sugar_grp1_jquery.js");
            ensureJSCacheFilesExist($jsFiles);
            echo getVersionedScript('cache/include/javascript/sugar_grp1_jquery.js');
            echo getVersionedScript('cache/include/javascript/sugar_grp1_yui.js');
            echo getVersionedScript('cache/include/javascript/sugar_grp1.js');
            $version_mark = getVersionedPath(null);
            echo '<script>SUGAR = SUGAR || {}; SUGAR.VERSION_MARK = ' . json_encode($version_mark) . ';</script>';
            // output necessary config js in the top of the page
            $config_js = $this->getSugarConfigJS();
            if (!empty($config_js)) {
                echo "<script>\n" . implode("\n", $config_js) . "</script>\n";
            }
            // CSRF form token
            echo $this->getCsrfFormTokenJscript();
            if (isset($sugar_config['email_sugarclient_listviewmaxselect'])) {
                echo "<script>SUGAR.config.email_sugarclient_listviewmaxselect = {$GLOBALS['sugar_config']['email_sugarclient_listviewmaxselect']};</script>";
            }
            $image_server = defined('TEMPLATE_URL') ? TEMPLATE_URL . '/' : '';
            echo '<script type="text/javascript">SUGAR.themes.image_server="' . $image_server . '";</script>';
            // cn: bug 12274 - create session-stored key to defend against CSRF
            echo '<script type="text/javascript">var name_format = "' . $locale->getLocaleFormatMacro() . '";</script>';
            echo self::getJavascriptValidation();
            if (!is_file(sugar_cached('jsLanguage/') . $GLOBALS['current_language'] . '.js')) {
                require_once 'include/language/jsLanguage.php';
                jsLanguage::createAppStringsCache($GLOBALS['current_language']);
            }
            echo getVersionedScript('cache/jsLanguage/' . $GLOBALS['current_language'] . '.js', $GLOBALS['sugar_config']['js_lang_version']);
            echo $this->_getModLanguageJS();
            echo getVersionedScript('include/javascript/productTour.js');
            if (isset($sugar_config['disc_client']) && $sugar_config['disc_client']) {
                echo getVersionedScript('modules/Sync/headersync.js');
            }
            if (!is_file(sugar_cached("Expressions/functions_cache.js"))) {
                $GLOBALS['updateSilent'] = true;
                include "include/Expressions/updatecache.php";
            }
            if (inDeveloperMode()) {
                echo getVersionedScript('cache/Expressions/functions_cache_debug.js');
            } else {
                echo getVersionedScript('cache/Expressions/functions_cache.js');
            }
            require_once "include/Expressions/DependencyManager.php";
            echo "\n" . '<script type="text/javascript">' . DependencyManager::getJSUserVariables($GLOBALS['current_user']) . "</script>\n";
            //echo out the $js_vars variables as javascript variables
            echo "<script type='text/javascript'>\n";
            foreach ($js_vars as $var => $value) {
                echo "var {$var} = '{$value}';\n";
            }
            echo "</script>\n";
        }
    }
 public function setupAll($showTitle = false, $ajaxSave = false, $moduleName = '', $readonly = false)
 {
     global $mod_strings, $sugar_config, $app_strings, $app_list_strings, $theme, $current_user;
     if (isset($this->defs['templateMeta']['javascript'])) {
         if (is_array($this->defs['templateMeta']['javascript'])) {
             $this->th->ss->assign('externalJSFile', $this->defs['templateMeta']['javascript']);
         } else {
             $this->th->ss->assign('scriptBlocks', $this->defs['templateMeta']['javascript']);
         }
     }
     $this->setupOriginalEditView();
     $this->th->ss->assign('id', $this->fieldDefs['id']['value']);
     $this->th->ss->assign('offset', $this->offset + 1);
     $this->th->ss->assign('APP', $app_strings);
     $this->th->ss->assign('MOD', $mod_strings);
     $this->th->ss->assign('footerTpl', isset($this->defs['templateMeta']['form']['footerTpl']) ? $this->defs['templateMeta']['form']['footerTpl'] : null);
     $this->fieldDefs = $this->setDefaultAllFields($this->fieldDefs);
     // default editview
     if ($readonly) {
         $this->fieldDefs = $this->setReadOnlyAllFields($this->fieldDefs);
     } else {
         $this->fieldDefs = $this->processReadOnlyFields($this->fieldDefs);
         $this->fieldDefs = $this->processRequiredFields($this->fieldDefs);
     }
     $this->th->ss->assign('fields', $this->fieldDefs);
     $this->sectionPanels = $this->processSectionPanels($this->sectionPanels);
     $this->th->ss->assign('sectionPanels', $this->sectionPanels);
     $this->th->ss->assign('config', $sugar_config);
     $this->th->ss->assign('returnModule', $this->returnModule);
     $this->th->ss->assign('returnAction', $this->returnAction);
     $this->th->ss->assign('returnId', $this->returnId);
     $this->th->ss->assign('isDuplicate', $this->isDuplicate);
     $this->th->ss->assign('def', $this->defs);
     $this->th->ss->assign('useTabs', isset($this->defs['templateMeta']['useTabs']) && isset($this->defs['templateMeta']['tabDefs']) ? $this->defs['templateMeta']['useTabs'] : false);
     $this->th->ss->assign('maxColumns', isset($this->defs['templateMeta']['maxColumns']) ? $this->defs['templateMeta']['maxColumns'] : 2);
     $this->th->ss->assign('module', $moduleName);
     $this->th->ss->assign('current_user', $current_user);
     $this->th->ss->assign('bean', $this->focus);
     $this->th->ss->assign('gridline', $current_user->getPreference('gridline') == 'on' ? '1' : '0');
     $this->th->ss->assign('tabDefs', isset($this->defs['templateMeta']['tabDefs']) ? $this->defs['templateMeta']['tabDefs'] : false);
     $this->th->ss->assign('VERSION_MARK', getVersionedPath(''));
     if (isset($this->relationshipChart[$moduleName])) {
         foreach ($this->relationshipChart[$moduleName] as $relName => $ssName) {
             $this->bean->load_relationship($relName);
             $tempBeanList = $this->bean->{$relName}->getBeans();
             $this->th->ss->assign($ssName, $tempBeanList);
         }
     }
     global $js_custom_version;
     global $sugar_version;
     $this->th->ss->assign('SUGAR_VERSION', $sugar_version);
     $this->th->ss->assign('JS_CUSTOM_VERSION', $js_custom_version);
     //this is used for multiple forms on one page
     if (!empty($this->formName)) {
         $form_id = $this->formName;
         $form_name = $this->formName;
     } else {
         $form_id = $this->view;
         $form_name = $this->view;
     }
     if ($ajaxSave && empty($this->formName)) {
         $form_id = 'form_' . $this->view . '_' . $moduleName;
         $form_name = $form_id;
         $this->view = $form_name;
     }
     $form_name = $form_name == 'QuickCreate' ? "QuickCreate_{$moduleName}" : $form_name;
     $form_id = $form_id == 'QuickCreate' ? "QuickCreate_{$moduleName}" : $form_id;
     if (isset($this->defs['templateMeta']['preForm'])) {
         $this->th->ss->assign('preForm', $this->defs['templateMeta']['preForm']);
     }
     if (isset($this->defs['templateMeta']['form']['closeFormBeforeCustomButtons'])) {
         $this->th->ss->assign('closeFormBeforeCustomButtons', $this->defs['templateMeta']['form']['closeFormBeforeCustomButtons']);
     }
     if (isset($this->defs['templateMeta']['form']['enctype'])) {
         $this->th->ss->assign('enctype', 'enctype="' . $this->defs['templateMeta']['form']['enctype'] . '"');
     }
     //for SugarFieldImage, we must set form enctype to "multipart/form-data"
     foreach ($this->fieldDefs as $field) {
         if (isset($field['type']) && $field['type'] == 'image') {
             $this->th->ss->assign('enctype', 'enctype="multipart/form-data"');
             break;
         }
     }
     $this->th->ss->assign('showDetailData', $this->showDetailData);
     $this->th->ss->assign('showSectionPanelsTitles', $this->showSectionPanelsTitles);
     $this->th->ss->assign('form_id', $form_id);
     $this->th->ss->assign('form_name', $form_name);
     //$form_name change by id form showCaseForm
     $this->th->ss->assign('set_focus_block', get_set_focus_js());
     $this->th->ss->assign('form', isset($this->defs['templateMeta']['form']) ? $this->defs['templateMeta']['form'] : null);
     $this->th->ss->assign('includes', isset($this->defs['templateMeta']['includes']) ? $this->defs['templateMeta']['includes'] : null);
     $this->th->ss->assign('view', $this->view);
     $admin = new Administration();
     $admin->retrieveSettings();
     if (isset($admin->settings['portal_on']) && $admin->settings['portal_on']) {
         $this->th->ss->assign("PORTAL_ENABLED", true);
     } else {
         $this->th->ss->assign("PORTAL_ENABLED", false);
     }
     //Calculate time & date formatting (may need to calculate this depending on a setting)
     global $timedate;
     $this->th->ss->assign('CALENDAR_DATEFORMAT', $timedate->get_cal_date_format());
     $this->th->ss->assign('USER_DATEFORMAT', $timedate->get_user_date_format());
     $time_format = $timedate->get_user_time_format();
     $this->th->ss->assign('TIME_FORMAT', $time_format);
     $date_format = $timedate->get_cal_date_format();
     $time_separator = ':';
     if (preg_match('/\\d+([^\\d])\\d+([^\\d]*)/s', $time_format, $match)) {
         $time_separator = $match[1];
     }
     // Create Smarty variables for the Calendar picker widget
     $t23 = strpos($time_format, '23') !== false ? '%H' : '%I';
     if (!isset($match[2]) || $match[2] == '') {
         $this->th->ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . '%M');
     } else {
         $pm = $match[2] == 'pm' ? '%P' : '%p';
         $this->th->ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23 . $time_separator . '%M' . $pm);
     }
     $this->th->ss->assign('CALENDAR_FDOW', $current_user->get_first_day_of_week());
     $this->th->ss->assign('TIME_SEPARATOR', $time_separator);
     $seps = get_number_seperators();
     $this->th->ss->assign('NUM_GRP_SEP', $seps[0]);
     $this->th->ss->assign('DEC_SEP', $seps[1]);
     if ($this->view == 'EditView' || $this->view == 'BpmView') {
         $height = $current_user->getPreference('text_editor_height');
         $width = $current_user->getPreference('text_editor_width');
         $height = isset($height) ? $height : '300px';
         $width = isset($width) ? $width : '95%';
         $this->th->ss->assign('RICH_TEXT_EDITOR_HEIGHT', $height);
         $this->th->ss->assign('RICH_TEXT_EDITOR_WIDTH', $width);
     } else {
         $this->th->ss->assign('RICH_TEXT_EDITOR_HEIGHT', '100px');
         $this->th->ss->assign('RICH_TEXT_EDITOR_WIDTH', '95%');
     }
     $this->th->ss->assign('SHOW_VCR_CONTROL', $this->showVCRControl);
     $str = $this->showTitle($showTitle);
     $ajaxSave = false;
     //Use the output filter to trim the whitespace
     $this->th->ss->load_filter('output', 'trimwhitespace');
     $form_name = $this->view;
     if ($this->th->checkTemplate($this->bean->module_name, $this->view) && !empty($this->dyn_uid)) {
         $nameTemplateTmp = $this->dyn_uid;
     } else {
         $nameTemplateTmp = 'PMSEDetailView';
     }
     $this->th->buildTemplate($this->bean->module_name, $nameTemplateTmp, $this->tpl, $ajaxSave, $this->defs);
     $this->th->deleteTemplate($this->bean->module_name, $form_name);
     $newTplFile = $this->th->cacheDir . $this->th->templateDir . $this->bean->module_name . '/' . $nameTemplateTmp . '.tpl';
     $str .= $this->th->ss->fetch($newTplFile);
     return $str;
 }
Exemple #16
0
 protected function _displayLoginJS()
 {
     global $sugar_config, $timedate;
     $template = new Sugar_Smarty();
     if (isset($this->bean->module_dir)) {
         $template->assign('MODULE_SUGAR_GRP1', $this->bean->module_dir);
     }
     if (isset($_REQUEST['action'])) {
         $template->assign('ACTION_SUGAR_GRP1', $_REQUEST['action']);
     }
     echo '<script>jscal_today = 1000*' . $timedate->asUserTs($timedate->getNow()) . '; if(typeof app_strings == "undefined") app_strings = new Array();</script>';
     if (!is_file(sugar_cached("include/javascript/sugar_grp1.js"))) {
         $_REQUEST['root_directory'] = ".";
         require_once "jssource/minify_utils.php";
         ConcatenateFiles(".");
     }
     $template->assign('SUGAR_GRP1_JQUERY', getVersionedPath('cache/include/javascript/sugar_grp1_jquery.js'));
     $template->assign('SUGAR_GRP1_YUI', getVersionedPath('cache/include/javascript/sugar_grp1_yui.js'));
     $template->assign('SUGAR_GRP1', getVersionedPath('cache/include/javascript/sugar_grp1.js'));
     $template->assign('CALENDAR', getVersionedPath('include/javascript/calendar.js'));
     if (isset($sugar_config['disc_client']) && $sugar_config['disc_client']) {
         $template->assign('HEADERSYNC', getVersionedPath('modules/Sync/headersync.js'));
     }
     echo $template->fetch('include/MVC/View/tpls/displayLoginJS.tpl');
 }