/** 
  * 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');
 }
 /**
  * This method prepares the received data and call the addFont method of the fontManager
  * @return boolean true on success
  */
 private function addFont()
 {
     $this->log = "";
     $error = false;
     $files = array("pdf_metric_file", "pdf_font_file");
     foreach ($files as $k) {
         // handle uploaded file
         $uploadFile = new UploadFile($k);
         if (isset($_FILES[$k]) && $uploadFile->confirm_upload()) {
             $uploadFile->final_move(basename($_FILES[$k]['name']));
             $uploadFileNames[$k] = $uploadFile->get_upload_path(basename($_FILES[$k]['name']));
         } else {
             $this->log = translate('ERR_PDF_NO_UPLOAD', "Configurator");
             $error = true;
         }
     }
     if (!$error) {
         require_once 'include/Sugarpdf/FontManager.php';
         $fontManager = new FontManager();
         $error = $fontManager->addFont($uploadFileNames["pdf_font_file"], $uploadFileNames["pdf_metric_file"], $_REQUEST['pdf_embedded'], $_REQUEST['pdf_encoding_table'], array(), htmlspecialchars_decode($_REQUEST['pdf_cidinfo'], ENT_QUOTES), $_REQUEST['pdf_style_list']);
         $this->log .= $fontManager->log;
         if ($error) {
             $this->log .= implode("\n", $fontManager->errors);
         }
     }
     return $error;
 }
 /**
  * Delete a font and go back to the font manager
  */
 function action_deleteFont()
 {
     global $current_user;
     if (!is_admin($current_user)) {
         sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
     }
     $urlSTR = 'index.php?module=Configurator&action=FontManager';
     if (!empty($_REQUEST['filename'])) {
         require_once 'include/Sugarpdf/FontManager.php';
         $fontManager = new FontManager();
         $fontManager->filename = $_REQUEST['filename'];
         if (!$fontManager->deleteFont()) {
             $urlSTR .= '&error=' . urlencode(implode("<br>", $fontManager->errors));
         }
     }
     header("Location: {$urlSTR}");
 }
/**
 * 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);
    }
}
 protected function setupAdvancedTabPdfSettings()
 {
     ///////////////////////////////////////////////////////////////////////////////
     /////////  PDF SETTINGS
     global $focus_user;
     $focus_user = $this->bean;
     if (!isset($this->bean->id)) {
         if (!defined('SUGARPDF_USE_DEFAULT_SETTINGS')) {
             define('SUGARPDF_USE_DEFAULT_SETTINGS', true);
         }
     }
     if (!defined('SUGARPDF_USE_FOCUS')) {
         define('SUGARPDF_USE_FOCUS', true);
     }
     include_once 'include/Sugarpdf/sugarpdf_config.php';
     if (PDF_CLASS == 'TCPDF') {
         $this->ss->assign('SHOW_PDF_OPTIONS', true);
         $this->ss->assign('PDF_CLASS', PDF_CLASS);
         $this->ss->assign('PDF_UNIT', PDF_UNIT);
         $this->ss->assign('PDF_PAGE_FORMAT_LIST', get_select_options_with_id(array_combine(explode(",", PDF_PAGE_FORMAT_LIST), explode(",", PDF_PAGE_FORMAT_LIST)), PDF_PAGE_FORMAT));
         $this->ss->assign('PDF_PAGE_ORIENTATION_LIST', get_select_options_with_id(array("P" => translate("LBL_PDF_PAGE_ORIENTATION_P", 'Users'), "L" => translate("LBL_PDF_PAGE_ORIENTATION_L", 'Users')), PDF_PAGE_ORIENTATION));
         $this->ss->assign('PDF_MARGIN_HEADER', PDF_MARGIN_HEADER);
         $this->ss->assign('PDF_MARGIN_FOOTER', PDF_MARGIN_FOOTER);
         $this->ss->assign('PDF_MARGIN_TOP', PDF_MARGIN_TOP);
         $this->ss->assign('PDF_MARGIN_BOTTOM', PDF_MARGIN_BOTTOM);
         $this->ss->assign('PDF_MARGIN_LEFT', PDF_MARGIN_LEFT);
         $this->ss->assign('PDF_MARGIN_RIGHT', PDF_MARGIN_RIGHT);
         require_once 'include/Sugarpdf/FontManager.php';
         $fontManager = new FontManager();
         $fontlist = $fontManager->getSelectFontList();
         $this->ss->assign('PDF_FONT_NAME_MAIN', get_select_options_with_id($fontlist, PDF_FONT_NAME_MAIN));
         $this->ss->assign('PDF_FONT_NAME_MAIN_DISPLAY', $fontlist[PDF_FONT_NAME_MAIN]);
         $this->ss->assign('PDF_FONT_SIZE_MAIN', PDF_FONT_SIZE_MAIN);
         $this->ss->assign('PDF_FONT_NAME_DATA', get_select_options_with_id($fontlist, PDF_FONT_NAME_DATA));
         $this->ss->assign('PDF_FONT_NAME_DATA_DISPLAY', $fontlist[PDF_FONT_NAME_DATA]);
         $this->ss->assign('PDF_FONT_SIZE_DATA', PDF_FONT_SIZE_DATA);
         ///////// END PDF SETTINGS
         ////////////////////////////////////////////////////////////////////////////////
     }
 }
 public function clearPDFFontCache()
 {
     global $mod_strings, $sugar_config;
     if ($this->show_output) {
         echo "<h3>{$mod_strings['LBL_QR_CLEARPDFFONT']}</h3>";
     }
     $fontManager = new FontManager();
     $fontManager->clearCachedFile();
 }
 function clearPDFFontCache()
 {
     global $mod_strings, $sugar_config;
     if ($this->show_output) {
         echo "<h3>{$mod_strings['LBL_QR_CLEARPDFFONT']}</h3>";
     }
     require_once 'include/Sugarpdf/FontManager.php';
     $fontManager = new FontManager();
     $fontManager->clearCachedFile();
 }
/*
 * Your installation or use of this SugarCRM file is subject to the applicable
 * terms available at
 * http://support.sugarcrm.com/06_Customer_Center/10_Master_Subscription_Agreements/.
 * If you do not agree to all of the applicable terms or do not have the
 * authority to bind the entity as an authorized representative, then do not
 * install or use this SugarCRM file.
 *
 * Copyright (C) SugarCRM Inc. All rights reserved.
 */
global $current_user;
$silent = isset($_REQUEST['silent']) ? true : false;
if (is_admin($current_user)) {
    global $mod_strings;
    if (!$silent) {
        echo $mod_strings['LBL_CLEAR_PDFFONTS_DESC'];
    }
    require_once 'include/Sugarpdf/FontManager.php';
    $fontManager = new FontManager();
    if ($fontManager->clearCachedFile()) {
        if (!$silent) {
            echo '<br><br><br><br>' . $mod_strings['LBL_CLEAR_PDFFONTS_DESC_SUCCESS'];
        }
    } else {
        if (!$silent) {
            echo '<br><br><br><br>' . $mod_strings['LBL_CLEAR_PDFFONTS_DESC_FAILURE'];
        }
    }
} else {
    sugar_die($GLOBALS['app_strings']['ERR_NOT_ADMIN']);
}