Example #1
0
 /** 
  * display the form
  */
 public function display()
 {
     global $mod_strings, $app_list_strings, $app_strings, $current_user;
     $error = "";
     if (!is_admin($current_user)) {
         sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
     }
     $fontManager = new FontManager();
     if (!$fontManager->listFontFiles()) {
         $error = implode("<br>", $fontManager->errors);
     }
     $this->ss->assign("MODULE_TITLE", getClassicModuleTitle($mod_strings['LBL_MODULE_ID'], array($mod_strings['LBL_FONTMANAGER_TITLE']), false));
     if (!empty($_REQUEST['error'])) {
         $error .= "<br>" . $_REQUEST['error'];
     }
     $this->ss->assign("error", $error);
     $this->ss->assign("MOD", $mod_strings);
     $this->ss->assign("APP", $app_strings);
     $this->ss->assign("JAVASCRIPT", $this->_getJS());
     if (isset($_REQUEST['return_action'])) {
         $this->ss->assign("RETURN_ACTION", $_REQUEST['return_action']);
     } else {
         $this->ss->assign("RETURN_ACTION", 'SugarpdfSettings');
     }
     $this->ss->assign("K_PATH_FONTS", K_PATH_FONTS);
     // YUI List
     $this->ss->assign("COLUMNDEFS", $this->getYuiColumnDefs($fontManager->fontList));
     $this->ss->assign("DATASOURCE", $this->getYuiDataSource($fontManager->fontList));
     $this->ss->assign("RESPONSESCHEMA", $this->getYuiResponseSchema());
     //display
     $this->ss->display('modules/Configurator/tpls/fontmanager.tpl');
 }
Example #2
0
/**
 * This function define a Sugarpdf setting from the user preferences.
 * This function use the default value if there is no preference.
 * If SUGARPDF_USE_DEFAULT_SETTINGS is define the function will always
 * use the default value.
 * SUGARPDF_USE_FOCUS is use to load the preference of the none current user. To use
 * this constant you have to define a global variable $focus_user.
 * 
 * @param $value    settings to search
 * @param $default  default value
 */
function defineFromUserPreference($value, $default)
{
    global $focus_user, $current_user;
    $lowerValue = strtolower($value);
    if (defined('SUGARPDF_USE_FOCUS')) {
        $pref = $focus_user->getPreference("sugarpdf_" . $lowerValue);
    } else {
        $pref = $current_user->getPreference("sugarpdf_" . $lowerValue);
    }
    if (strpos($value, "PDF_FONT_NAME_") !== false) {
        require_once 'include/Sugarpdf/FontManager.php';
        $fontManager = new FontManager();
        $fontManager->listFontFiles();
        if (!isset($fontManager->fontList[$pref]) || !$fontManager->fontFileExist($fontManager->fontList[$pref]['filename'])) {
            $pref = $default;
        }
    }
    if (isset($pref) && !defined('SUGARPDF_USE_DEFAULT_SETTINGS')) {
        define($value, $pref);
    } else {
        define($value, $default);
    }
}