本文整理汇总了PHP中sugar_is_file函数的典型用法代码示例。如果您正苦于以下问题:PHP sugar_is_file函数的具体用法?PHP sugar_is_file怎么用?PHP sugar_is_file使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了sugar_is_file函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: mkdir_recursive
function mkdir_recursive($path, $check_is_parent_dir = false)
{
if (sugar_is_dir($path, 'instance')) {
return true;
}
if (sugar_is_file($path, 'instance')) {
if (!empty($GLOBALS['log'])) {
$GLOBALS['log']->fatal("ERROR: mkdir_recursive(): argument {$path} is already a file.");
}
return false;
}
//make variables with file paths
$pathcmp = $path = rtrim(clean_path($path), '/');
$basecmp = $base = rtrim(clean_path(getcwd()), '/');
if (is_windows()) {
//make path variable lower case for comparison in windows
$pathcmp = strtolower($path);
$basecmp = strtolower($base);
}
if ($basecmp == $pathcmp) {
return true;
}
$base .= "/";
if (strncmp($pathcmp, $basecmp, strlen($basecmp)) == 0) {
/* strip current path prefix */
$path = substr($path, strlen($base));
}
$thePath = '';
$dirStructure = explode("/", $path);
if ($dirStructure[0] == '') {
// absolute path
$base = '/';
array_shift($dirStructure);
}
if (is_windows()) {
if (strlen($dirStructure[0]) == 2 && $dirStructure[0][1] == ':') {
/* C: prefix */
$base = array_shift($dirStructure) . "\\";
} elseif ($dirStructure[0][0] . $dirStructure[0][1] == "\\\\") {
/* UNC absolute path */
$base = array_shift($dirStructure) . "\\" . array_shift($dirStructure) . "\\";
// we won't try to mkdir UNC share name
}
}
foreach ($dirStructure as $dirPath) {
$thePath .= $dirPath . "/";
$mkPath = $base . $thePath;
if (!is_dir($mkPath)) {
if (!sugar_mkdir($mkPath)) {
return false;
}
}
}
return true;
}
示例2: getJSLanguage
/**
* Retrieves the requested js language file, building it if it doesn't exist.
*/
function getJSLanguage()
{
require_once 'include/language/jsLanguage.php';
global $app_list_strings;
if (empty($_REQUEST['lang'])) {
echo "No language specified";
return;
}
$lang = clean_path($_REQUEST['lang']);
$languages = get_languages();
if (!preg_match("/^\\w\\w_\\w\\w\$/", $lang) || !isset($languages[$lang])) {
if (!preg_match("/^\\w\\w_\\w\\w\$/", $lang)) {
echo "did not match regex<br/>";
} else {
echo "{$lang} was not in list . <pre>" . print_r($languages, true) . "</pre>";
}
echo "Invalid language specified";
return;
}
if (empty($_REQUEST['module']) || $_REQUEST['module'] === 'app_strings') {
$file = sugar_cached('jsLanguage/') . $lang . '.js';
if (!sugar_is_file($file)) {
$jsLanguage = new jsLanguage();
$jsLanguage->createAppStringsCache($lang);
}
} else {
$module = clean_path($_REQUEST['module']);
$fullModuleList = array_merge($GLOBALS['moduleList'], $GLOBALS['modInvisList']);
if (!isset($app_list_strings['moduleList'][$module]) && !in_array($module, $fullModuleList)) {
echo "Invalid module specified";
return;
}
$file = sugar_cached('jsLanguage/') . $module . "/" . $lang . '.js';
if (!sugar_is_file($file)) {
jsLanguage::createModuleStringsCache($module, $lang);
}
}
//Setup cache headers
header("Content-Type: application/javascript");
header("Cache-Control: max-age=31556940, private");
header("Pragma: ");
header("Expires: " . gmdate('D, d M Y H:i:s \\G\\M\\T', time() + 31556940));
readfile($file);
}
示例3: mkdir_recursive
function mkdir_recursive($path, $check_is_parent_dir = false)
{
if (sugar_is_dir($path, 'instance')) {
return true;
}
if (sugar_is_file($path, 'instance')) {
print "ERROR: mkdir_recursive(): argument {$path} is already a file.\n";
return false;
}
$path = clean_path($path);
$path = str_replace(clean_path(getcwd()), '', $path);
$thePath = '';
$dirStructure = explode("/", $path);
$status = true;
foreach ($dirStructure as $dirPath) {
$thePath .= '/' . $dirPath;
$mkPath = getcwd() . '/' . $thePath;
if (!is_dir($mkPath)) {
$status = $status & sugar_mkdir($mkPath);
}
}
return $status;
}
示例4: uninstall
function uninstall($base_dir)
{
if (defined('TEMPLATE_URL')) {
SugarTemplateUtilities::disableCache();
}
global $app_strings;
$total_steps = 5;
//min steps with no tasks
$current_step = 0;
$this->base_dir = $base_dir;
$tasks = array('pre_uninstall', 'uninstall_relationships', 'uninstall_copy', 'uninstall_dcactions', 'uninstall_menus', 'uninstall_dashlets', 'uninstall_userpage', 'uninstall_administration', 'uninstall_connectors', 'uninstall_vardefs', 'uninstall_layoutdefs', 'uninstall_layoutfields', 'uninstall_languages', 'uninstall_logichooks', 'post_uninstall');
$total_steps += count($tasks);
//now the real number of steps
if (file_exists($this->base_dir . '/manifest.php')) {
if (!$this->silent) {
$current_step++;
display_progress_bar('install', $current_step, $total_steps);
echo '<div id ="displayLoglink" ><a href="#" onclick="toggleDisplay(\'displayLog\')">' . $app_strings['LBL_DISPLAY_LOG'] . '</a> </div><div id="displayLog" style="display:none">';
}
global $moduleList;
include $this->base_dir . '/manifest.php';
$this->installdefs = $installdefs;
$this->id_name = $this->installdefs['id'];
$installed_modules = array();
if (isset($this->installdefs['beans'])) {
foreach ($this->installdefs['beans'] as $bean) {
$installed_modules[] = $bean['module'];
$this->uninstall_user_prefs($bean['module']);
}
$this->modulesInPackage = $installed_modules;
$this->uninstall_beans($installed_modules);
$this->uninstall_customizations($installed_modules);
if (!$this->silent) {
$current_step++;
update_progress_bar('install', $total_steps, $total_steps);
}
if (sugar_is_file("custom/Extension/application/Ext/Include/{$this->id_name}.php", 'w')) {
rmdir_recursive("custom/Extension/application/Ext/Include/{$this->id_name}.php");
} else {
if (sugar_is_file("custom/Extension/application/Ext/Include/" . DISABLED_PATH . "/{$this->id_name}.php", 'w')) {
rmdir_recursive("custom/Extension/application/Ext/Include/" . DISABLED_PATH . "/{$this->id_name}.php");
}
}
$this->rebuild_modules();
}
if (!$this->silent) {
$current_step++;
update_progress_bar('install', $current_step, $total_steps);
}
foreach ($tasks as $task) {
$this->{$task}();
if (!$this->silent) {
$current_step++;
update_progress_bar('install', $current_step, $total_steps);
}
}
if (isset($installdefs['custom_fields']) && (isset($GLOBALS['mi_remove_tables']) && $GLOBALS['mi_remove_tables'])) {
$this->log(translate('LBL_MI_UN_CUSTOMFIELD'));
$this->uninstall_custom_fields($installdefs['custom_fields']);
}
if (!$this->silent) {
$current_step++;
update_progress_bar('install', $current_step, $total_steps);
echo '</div>';
}
//since we are passing $silent = true to rebuildAll() in that method it will set $this->silent = true, so
//we need to save the setting to set it back after rebuildAll() completes.
$silentBak = $this->silent;
$this->rebuild_all(true);
$this->silent = $silentBak;
//#27877, If the request from MB redeploy a custom module , we will not remove the ACL actions for this package.
if (!isset($_REQUEST['action']) || $_REQUEST['action'] != 'DeployPackage') {
$this->remove_acl_actions();
}
//end
if (!$this->silent) {
$current_step++;
update_progress_bar('install', $current_step, $total_steps);
echo '</div>';
}
UpdateSystemTabs('Restore', $installed_modules);
//clear the unified_search_module.php file
require_once 'modules/Home/UnifiedSearchAdvanced.php';
UnifiedSearchAdvanced::unlinkUnifiedSearchModulesFile();
$this->log('<br><b>' . translate('LBL_MI_COMPLETE') . '</b>');
if (!$this->silent) {
update_progress_bar('install', $total_steps, $total_steps);
}
} else {
die("No manifest.php Defined In {$this->base_dir}/manifest.php");
}
}
示例5: display
/**
* @see SugarView::display()
*/
public function display()
{
global $mod_strings, $app_strings, $current_user;
global $sugar_config;
$selectedData = $this->_retrieveParams();
$this->ss->assign("MODULE_TITLE", $this->getModuleTitle());
$this->ss->assign("DELETE_INLINE_PNG", SugarThemeRegistry::current()->getImage('delete_inline', 'align="absmiddle" alt="' . $app_strings['LNK_DELETE'] . '" border="0"'));
$this->ss->assign("PUBLISH_INLINE_PNG", SugarThemeRegistry::current()->getImage('publish_inline', 'align="absmiddle" alt="' . $mod_strings['LBL_PUBLISH'] . '" border="0"'));
$this->ss->assign("UNPUBLISH_INLINE_PNG", SugarThemeRegistry::current()->getImage('unpublish_inline', 'align="absmiddle" alt="' . $mod_strings['LBL_UNPUBLISH'] . '" border="0"'));
$this->ss->assign("IMPORT_MODULE", $_REQUEST['import_module']);
$this->ss->assign("JAVASCRIPT", $this->_getJS(isset($selectedData->source) ? $selectedData->source : false));
// handle publishing and deleting import maps
if (isset($_REQUEST['delete_map_id'])) {
$import_map = new ImportMap();
$import_map->mark_deleted($_REQUEST['delete_map_id']);
}
if (isset($_REQUEST['publish'])) {
$import_map = new ImportMap();
$result = 0;
$import_map = $import_map->retrieve($_REQUEST['import_map_id'], false);
if ($_REQUEST['publish'] == 'yes') {
$result = $import_map->mark_published($current_user->id, true);
if (!$result) {
$this->ss->assign("ERROR", $mod_strings['LBL_ERROR_UNABLE_TO_PUBLISH']);
}
} elseif ($_REQUEST['publish'] == 'no') {
// if you don't own this importmap, you do now!
// unless you have a map by the same name
$result = $import_map->mark_published($current_user->id, false);
if (!$result) {
$this->ss->assign("ERROR", $mod_strings['LBL_ERROR_UNABLE_TO_UNPUBLISH']);
}
}
}
// trigger showing other software packages
$this->ss->assign("show_salesforce", false);
$this->ss->assign("show_outlook", false);
$this->ss->assign("show_act", false);
switch ($_REQUEST['import_module']) {
case "Prospects":
break;
case "Accounts":
$this->ss->assign("show_salesforce", true);
$this->ss->assign("show_act", true);
break;
case "Contacts":
$this->ss->assign("show_salesforce", true);
$this->ss->assign("show_outlook", true);
$this->ss->assign("show_act", true);
break;
default:
$this->ss->assign("show_salesforce", true);
break;
}
// show any custom mappings
if (sugar_is_dir('custom/modules/Import') && ($dir = opendir('custom/modules/Import'))) {
while (($file = readdir($dir)) !== false) {
if (sugar_is_file("custom/modules/Import/{$file}") && strpos($file, ".php") !== false) {
require_once "custom/modules/Import/{$file}";
$classname = str_replace('.php', '', $file);
$mappingClass = new $classname();
$custom_mappings[] = $mappingClass->name;
}
}
}
// get user defined import maps
$this->ss->assign('is_admin', is_admin($current_user));
$import_map_seed = new ImportMap();
$custom_imports_arr = $import_map_seed->retrieve_all_by_string_fields(array('assigned_user_id' => $current_user->id, 'is_published' => 'no', 'module' => $_REQUEST['import_module']));
if (count($custom_imports_arr)) {
$custom = array();
foreach ($custom_imports_arr as $import) {
$custom[] = array("IMPORT_NAME" => $import->name, "IMPORT_ID" => $import->id);
}
$this->ss->assign('custom_imports', $custom);
}
// get globally defined import maps
$published_imports_arr = $import_map_seed->retrieve_all_by_string_fields(array('is_published' => 'yes', 'module' => $_REQUEST['import_module']));
if (count($published_imports_arr)) {
$published = array();
foreach ($published_imports_arr as $import) {
$published[] = array("IMPORT_NAME" => $import->name, "IMPORT_ID" => $import->id);
}
$this->ss->assign('published_imports', $published);
}
$this->ss->display('modules/Import/tpls/step1.tpl');
}
示例6: array
/*********************************************************************************
* Description: controls which link show up in the upper right hand corner of the app
********************************************************************************/
global $app_strings, $current_user;
global $sugar_config, $sugar_version, $sugar_flavor, $server_unique_key, $current_language, $action;
if (!isset($global_control_links)) {
$global_control_links = array();
$sub_menu = array();
}
if (isset($sugar_config['disc_client']) && $sugar_config['disc_client']) {
require_once 'modules/Sync/headermenu.php';
}
$global_control_links['employees'] = array('linkinfo' => array($app_strings['LBL_EMPLOYEES'] => 'index.php?module=Employees&action=index&query=true'), 'submenu' => '');
if (is_admin($current_user)) {
$global_control_links['admin'] = array('linkinfo' => array($app_strings['LBL_ADMIN'] => 'index.php?module=Administration&action=index'), 'submenu' => '');
}
$global_control_links['training'] = array('linkinfo' => array($app_strings['LBL_TRAINING'] => 'javascript:void(window.open(\'http://support.sugarcrm.com\'))'), 'submenu' => '');
/* no longer goes in the menubar - now implemented in the bottom bar.
$global_control_links['help'] = array(
'linkinfo' => array($app_strings['LNK_HELP'] => ' javascript:void window.open(\'index.php?module=Administration&action=SupportPortal&view=documentation&version='.$sugar_version.'&edition='.$sugar_flavor.'&lang='.$current_language.'&help_module='.$GLOBALS['module'].'&help_action='.$action.'&key='.$server_unique_key.'\')'),
'submenu' => ''
);
*/
$global_control_links['users'] = array('linkinfo' => array($app_strings['LBL_LOGOUT'] => 'index.php?module=Users&action=Logout'), 'submenu' => '');
$global_control_links['about'] = array('linkinfo' => array($app_strings['LNK_ABOUT'] => 'index.php?module=Home&action=About'), 'submenu' => '');
if (sugar_is_file('custom/include/globalControlLinks.php')) {
include 'custom/include/globalControlLinks.php';
}
if (sugar_is_file('custom/application/Ext/GlobalLinks/links.ext.php')) {
include 'custom/application/Ext/GlobalLinks/links.ext.php';
}
示例7: uninstall_languages
function uninstall_languages()
{
$languages = array();
if (isset($this->installdefs['language'])) {
$this->log(translate('LBL_MI_UN_LANG'));
foreach ($this->installdefs['language'] as $packs) {
$modules[] = $packs['to_module'];
$languages[$packs['language']] = $packs['language'];
$packs['from'] = str_replace('<basepath>', $this->base_dir, $packs['from']);
$GLOBALS['log']->debug("Uninstalling Language Pack ..." . $packs['from'] . " for " . $packs['to_module']);
$path = 'custom/Extension/modules/' . $packs['to_module'] . '/Ext/Language';
if ($packs['to_module'] == 'application') {
$path = 'custom/Extension/' . $packs['to_module'] . '/Ext/Language';
}
if (sugar_is_file($path . '/' . $packs['language'] . '.' . $this->id_name . '.php', 'w')) {
rmdir_recursive($path . '/' . $packs['language'] . '.' . $this->id_name . '.php');
} else {
if (sugar_is_file($path . '/' . DISABLED_PATH . '/' . $packs['language'] . '.' . $this->id_name . '.php', 'w')) {
rmdir_recursive($path . '/' . DISABLED_PATH . '/' . $packs['language'] . '.' . $this->id_name . '.php', 'w');
}
}
}
$this->rebuild_languages($languages, $modules);
}
}
示例8: getCurrentURL
// awu: Fixes the ProjectTasks pluralization issue -- must fix in later versions.
if ($send_module == 'ProjectTasks') {
$send_module = 'ProjectTask';
}
if ($send_module == 'ProductCatalog') {
$send_module = 'ProductTemplates';
}
if ($send_module == 'TargetLists') {
$send_module = 'ProspectLists';
}
if ($send_module == 'Targets') {
$send_module = 'Prospects';
}
// FG - Bug 39819 - Check for custom help files
$helpPath = 'modules/' . $send_module . '/language/' . $send_lang . '.help.' . $send_action . '.html';
if (sugar_is_file("custom/" . $helpPath)) {
$helpPath = 'custom/' . $helpPath;
}
$sugar_smarty = new Sugar_Smarty();
//go to the support portal if the file is not found.
// FG - Bug 39820 - Devs can write help files also in english, so skip check for language not equals "en_us" !
if (file_exists($helpPath)) {
$sugar_smarty->assign('helpFileExists', TRUE);
$sugar_smarty->assign('MOD', $mod_strings);
$sugar_smarty->assign('modulename', $send_module);
$sugar_smarty->assign('helpPath', $helpPath);
$sugar_smarty->assign('currentURL', getCurrentURL());
$sugar_smarty->assign('title', $mod_strings['LBL_SUGARCRM_HELP'] . " - " . $send_module);
$sugar_smarty->assign('styleSheet', SugarThemeRegistry::current()->getCSS());
$sugar_smarty->assign('table', "<table class='tabForm'><tr><td>");
$sugar_smarty->assign('endtable', "</td></tr></table>");
示例9: saveCache
/**
* Save the dictionary object to the cache
* @param string $module the name of the module
* @param string $object the name of the object
*/
static function saveCache($module, $object, $additonal_objects = array())
{
if (empty($GLOBALS['dictionary'][$object])) {
$object = BeanFactory::getObjectName($module);
}
$file = create_cache_directory('modules/' . $module . '/' . $object . 'vardefs.php');
$out = "<?php \n \$GLOBALS[\"dictionary\"][\"" . $object . "\"]=" . var_export($GLOBALS['dictionary'][$object], true) . ";";
sugar_file_put_contents_atomic($file, $out);
if (sugar_is_file($file) && is_readable($file)) {
include $file;
}
// put the item in the sugar cache.
$key = "VardefManager.{$module}.{$object}";
//Sometimes bad definitions can get in from left over extensions or file system lag(caching). We need to clean those.
$data = self::cleanVardefs($GLOBALS['dictionary'][$object]);
sugar_cache_put($key, $data);
}
示例10: _getExternal
/**
* @see SugarCacheAbstract::_getExternal()
*/
protected function _getExternal($key)
{
// load up the external cache file
if (sugar_is_file($GLOBALS['sugar_config']['cache_dir'] . '/' . $this->_cacheFileName)) {
$this->localCache = unserialize(file_get_contents($GLOBALS['sugar_config']['cache_dir'] . '/' . $this->_cacheFileName));
}
if (isset($this->_localStore[$key])) {
return $this->_localStore[$key];
}
return null;
}
示例11: return_app_list_strings_language
// get the list_strings in order for module friendly name display.
$app_list_strings = return_app_list_strings_language($current_language);
foreach ($sm as $mod_dir_name => $links) {
$module_friendly_name = $app_list_strings['moduleList'][$mod_dir_name];
$temphtml = "";
$temphtml .= '<h4><a href="javascript:window.location=\'index.php?module=' . $mod_dir_name . '&action=index\'">' . $module_friendly_name . '</a></h4><ul class=\'noBullet\'>';
foreach ($links as $name => $href) {
$temphtml .= '<li class=\'noBullet\'><a href="javascript:window.location=\'' . $href . '\'">' . $name . ' ' . '</a></li>';
}
$temphtml .= '</ul>';
$sm_smarty->assign(strtoupper($mod_dir_name), $temphtml);
}
// Specify the sitemap template to use; allow developers to override this with a custom one to add/remove modules
// from the list
$tpl = 'modules/Home/sitemap.tpl';
if (sugar_is_file('custom/modules/Home/sitemap.tpl')) {
$tpl = 'custom/modules/Home/sitemap.tpl';
}
echo $sm_smarty->fetch($tpl);
function sm_build_array()
{
//if the sitemap array is already stored, then pass it back
if (isset($_SESSION['SM_ARRAY']) && !empty($_SESSION['SM_ARRAY'])) {
return $_SESSION['SM_ARRAY'];
}
include "include/modules.php";
global $sugar_config, $mod_strings;
// Need to set up mod_strings when we iterate through module menus.
$orig_modstrings = array();
if (!empty($mod_strings)) {
$orig_modstrings = $mod_strings;
示例12: _getExternal
/**
* @see SugarCacheAbstract::_getExternal()
*/
protected function _getExternal($key)
{
// load up the external cache file
if (sugar_is_file($cachedfile = sugar_cached($this->_cacheFileName))) {
$this->localCache = unserialize(file_get_contents($cachedfile));
}
if (isset($this->_localStore[$key])) {
return $this->_localStore[$key];
}
return null;
}
示例13: displayHeader
/**
* Determine whether or not to dispay the header on the page.
*/
function displayHeader()
{
global $theme;
global $max_tabs;
global $app_strings;
global $current_user;
global $sugar_config;
global $app_list_strings;
$GLOBALS['app']->headerDisplayed = true;
if (!function_exists('get_new_record_form') && (file_exists('modules/' . $this->module . '/metadata/sidecreateviewdefs.php') || file_exists('custom/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);
}
$themeObject = SugarThemeRegistry::current();
$theme = $themeObject->__toString();
$ss = new Sugar_Smarty();
$ss->assign("APP", $app_strings);
$ss->assign("THEME", $theme);
$ss->assign("MODULE_NAME", $this->module);
// get css
$css = $themeObject->getCSS();
if ($this->_getOption('view_print')) {
$css .= '\\n<link rel="stylesheet" type="text/css" href="' . $themeObject->getCSSURL('print.css') . '" media="all" />';
}
$ss->assign("SUGAR_CSS", $css);
// get javascript
ob_start();
$this->renderJavascript();
$ss->assign("SUGAR_JS", ob_get_contents() . $themeObject->getJS());
ob_end_clean();
// get favicon
$user_module_favicon = $current_user->getPreference('module_favicon');
if (!isset($user_module_favicon) && isset($GLOBALS['sugar_config']['default_module_favicon'])) {
$user_module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
} elseif (!isset($user_module_favicon)) {
$user_module_favicon = false;
}
$favicon = $themeObject->getImageURL($this->module . '.gif', false);
if (!sugar_is_file($favicon) || !$user_module_favicon) {
$favicon = $themeObject->getImageURL('sugar_icon.ico', false);
}
$ss->assign('FAVICON_URL', getJSPath($favicon));
// get the module menu
$shortcut_menu = array();
$module_menu = load_menu("modules/" . $this->module . "/");
foreach ($module_menu as $key => $menu_item) {
$shortcut_menu[$key] = array("URL" => $menu_item[0], "LABEL" => $menu_item[1], "MODULE_NAME" => $menu_item[2], "IMAGE" => $themeObject->getImage($menu_item[2], "alt='" . $menu_item[1] . "' border='0' align='absmiddle'"));
}
$ss->assign("SHORTCUT_MENU", $shortcut_menu);
// handle rtl text direction
if (isset($_REQUEST['RTL']) && $_REQUEST['RTL'] == 'RTL') {
$_SESSION['RTL'] = true;
}
if (isset($_REQUEST['LTR']) && $_REQUEST['LTR'] == 'LTR') {
unset($_SESSION['RTL']);
}
if (isset($_SESSION['RTL']) && $_SESSION['RTL']) {
$ss->assign("DIR", 'dir="RTL"');
}
// handle resizing of the company logo correctly on the fly
$companyLogoURL = $themeObject->getImageURL('company_logo.png', false);
$ss->assign("COMPANY_LOGO_URL", getJSPath($companyLogoURL));
$company_logo_attributes = sugar_cache_retrieve('company_logo_attributes');
if (!empty($company_logo_attributes) && md5_file($companyLogoURL) == $company_logo_attributes[0]) {
$ss->assign("COMPANY_LOGO_WIDTH", $company_logo_attributes[1]);
$ss->assign("COMPANY_LOGO_HEIGHT", $company_logo_attributes[2]);
} else {
list($width, $height) = getimagesize($companyLogoURL);
if ($width > 212 || $height > 40) {
$resizePctWidth = ($width - 212) / 212;
$resizePctHeight = ($height - 40) / 40;
if ($resizePctWidth > $resizePctHeight) {
$resizeAmount = $width / 212;
} else {
$resizeAmount = $height / 40;
}
$ss->assign("COMPANY_LOGO_WIDTH", round($width * (1 / $resizeAmount)));
$ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1 / $resizeAmount)));
sugar_cache_put('company_logo_attributes', array(md5_file($companyLogoURL), $ss->get_template_vars("COMPANY_LOGO_WIDTH"), $ss->get_template_vars("COMPANY_LOGO_HEIGHT")));
} else {
$ss->assign("COMPANY_LOGO_WIDTH", $width);
$ss->assign("COMPANY_LOGO_HEIGHT", $height);
}
}
// get the global links
$gcls = array();
$global_control_links = array();
require "include/globalControlLinks.php";
foreach ($global_control_links as $key => $value) {
if ($key == 'users') {
//represents logout link.
$ss->assign("LOGOUT_LINK", $value['linkinfo'][key($value['linkinfo'])]);
$ss->assign("LOGOUT_LABEL", key($value['linkinfo']));
//key value for first element.
//.........这里部分代码省略.........
示例14: buildRegistry
/**
* Builds the theme registry
*/
public static function buildRegistry()
{
self::$_themes = array();
$dirs = array("themes/", "custom/themes/");
foreach ($dirs as $dirPath) {
if (sugar_is_dir('./' . $dirPath) && ($dir = opendir('./' . $dirPath))) {
while (($file = readdir($dir)) !== false) {
if ($file == ".." || $file == "." || $file == ".svn" || $file == "CVS" || $file == "Attic" || !sugar_is_dir("./{$dirPath}" . $file) || !sugar_is_file("./{$dirPath}{$file}/themedef.php")) {
continue;
}
$themedef = array();
require "./{$dirPath}{$file}/themedef.php";
$themedef['dirName'] = $file;
// check for theme already existing in the registry
// if so, then it will override the current one
if (self::exists($themedef['dirName'])) {
$existingTheme = self::get($themedef['dirName']);
foreach (SugarTheme::getThemeDefFields() as $field) {
if (!isset($themedef[$field])) {
$themedef[$field] = $existingTheme->{$field};
}
}
self::remove($themedef['dirName']);
}
if (isset($themedef['name'])) {
self::add($themedef);
}
}
closedir($dir);
}
}
// default to setting the default theme as the current theme
self::set($GLOBALS['sugar_config']['default_theme']);
}
示例15: displayHeader
/**
* Determine whether or not to dispay the header on the page.
*/
function displayHeader()
{
global $theme;
global $max_tabs;
global $app_strings;
global $current_user;
global $sugar_config;
global $app_list_strings;
$GLOBALS['app']->headerDisplayed = true;
if (!function_exists('get_new_record_form') && (file_exists('modules/' . $this->module . '/metadata/sidecreateviewdefs.php') || file_exists('custom/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);
}
$themeObject = SugarThemeRegistry::current();
$theme = $themeObject->__toString();
$ss = new Sugar_Smarty();
$ss->assign("APP", $app_strings);
$ss->assign("THEME", $theme);
$ss->assign("THEME_IE6COMPAT", $themeObject->ie6compat ? 'true' : 'false');
$ss->assign("MODULE_NAME", $this->module);
// get css
$css = $themeObject->getCSS();
if ($this->_getOption('view_print')) {
$css .= '<link rel="stylesheet" type="text/css" href="' . $themeObject->getCSSURL('print.css') . '" media="all" />';
}
$ss->assign("SUGAR_CSS", $css);
// get javascript
ob_start();
$this->renderJavascript();
$ss->assign("SUGAR_JS", ob_get_contents() . $themeObject->getJS());
ob_end_clean();
// get favicon
if (isset($GLOBALS['sugar_config']['default_module_favicon'])) {
$module_favicon = $GLOBALS['sugar_config']['default_module_favicon'];
} else {
$module_favicon = false;
}
$favicon = '';
if ($module_favicon) {
$favicon = $themeObject->getImageURL($this->module . '.gif', false);
}
if (!sugar_is_file($favicon) || !$module_favicon) {
$favicon = $themeObject->getImageURL('sugar_icon.ico', false);
}
$ss->assign('FAVICON_URL', getJSPath($favicon));
// get the module menu
$shortcut_menu = array();
$module_menu = load_menu("modules/" . $this->module . "/");
foreach ($module_menu as $key => $menu_item) {
$shortcut_menu[$key] = array("URL" => $menu_item[0], "LABEL" => $menu_item[1], "MODULE_NAME" => $menu_item[2], "IMAGE" => $themeObject->getImage($menu_item[2], "alt='" . $menu_item[1] . "' border='0' align='absmiddle'"));
}
$ss->assign("SHORTCUT_MENU", $shortcut_menu);
// handle rtl text direction
if (isset($_REQUEST['RTL']) && $_REQUEST['RTL'] == 'RTL') {
$_SESSION['RTL'] = true;
}
if (isset($_REQUEST['LTR']) && $_REQUEST['LTR'] == 'LTR') {
unset($_SESSION['RTL']);
}
if (isset($_SESSION['RTL']) && $_SESSION['RTL']) {
$ss->assign("DIR", 'dir="RTL"');
}
// handle resizing of the company logo correctly on the fly
$companyLogoURL = $themeObject->getImageURL('company_logo.png');
$companyLogoURL_arr = explode('?', $companyLogoURL);
$companyLogoURL = $companyLogoURL_arr[0];
$company_logo_attributes = sugar_cache_retrieve('company_logo_attributes');
if (!empty($company_logo_attributes)) {
$ss->assign("COMPANY_LOGO_MD5", $company_logo_attributes[0]);
$ss->assign("COMPANY_LOGO_WIDTH", $company_logo_attributes[1]);
$ss->assign("COMPANY_LOGO_HEIGHT", $company_logo_attributes[2]);
} else {
// Always need to md5 the file
$ss->assign("COMPANY_LOGO_MD5", md5_file($companyLogoURL));
list($width, $height) = getimagesize($companyLogoURL);
if ($width > 212 || $height > 40) {
$resizePctWidth = ($width - 212) / 212;
$resizePctHeight = ($height - 40) / 40;
if ($resizePctWidth > $resizePctHeight) {
$resizeAmount = $width / 212;
} else {
$resizeAmount = $height / 40;
}
$ss->assign("COMPANY_LOGO_WIDTH", round($width * (1 / $resizeAmount)));
$ss->assign("COMPANY_LOGO_HEIGHT", round($height * (1 / $resizeAmount)));
} else {
$ss->assign("COMPANY_LOGO_WIDTH", $width);
$ss->assign("COMPANY_LOGO_HEIGHT", $height);
}
// Let's cache the results
sugar_cache_put('company_logo_attributes', array($ss->get_template_vars("COMPANY_LOGO_MD5"), $ss->get_template_vars("COMPANY_LOGO_WIDTH"), $ss->get_template_vars("COMPANY_LOGO_HEIGHT")));
}
$ss->assign("COMPANY_LOGO_URL", getJSPath($companyLogoURL) . "&logo_md5=" . $ss->get_template_vars("COMPANY_LOGO_MD5"));
// get the global links
//.........这里部分代码省略.........