本文整理汇总了PHP中CRM_Core_BAO_Preferences::retrieveDirectoryAndURLPreferences方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_Preferences::retrieveDirectoryAndURLPreferences方法的具体用法?PHP CRM_Core_BAO_Preferences::retrieveDirectoryAndURLPreferences怎么用?PHP CRM_Core_BAO_Preferences::retrieveDirectoryAndURLPreferences使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_Preferences
的用法示例。
在下文中一共展示了CRM_Core_BAO_Preferences::retrieveDirectoryAndURLPreferences方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _initVariables
/**
* initialize the config variables
*
* @return void
* @access private
*/
private function _initVariables()
{
// retrieve serialised settings
require_once "CRM/Core/BAO/Setting.php";
$variables = array();
CRM_Core_BAO_Setting::retrieve($variables);
// if settings are not available, go down the full path
if (empty($variables)) {
// Step 1. get system variables with their hardcoded defaults
$variables = get_object_vars($this);
// Step 2. get default values (with settings file overrides if
// available - handled in CRM_Core_Config_Defaults)
require_once 'CRM/Core/Config/Defaults.php';
CRM_Core_Config_Defaults::setValues($variables);
// retrieve directory and url preferences also
require_once 'CRM/Core/BAO/Preferences.php';
CRM_Core_BAO_Preferences::retrieveDirectoryAndURLPreferences($defaults);
// add component specific settings
$this->componentRegistry->addConfig($this);
// serialise settings
CRM_Core_BAO_Setting::add($variables);
}
$urlArray = array('userFrameworkResourceURL', 'imageUploadURL');
$dirArray = array('uploadDir', 'customFileUploadDir');
foreach ($variables as $key => $value) {
if (in_array($key, $urlArray)) {
$value = CRM_Utils_File::addTrailingSlash($value, '/');
} else {
if (in_array($key, $dirArray)) {
$value = CRM_Utils_File::addTrailingSlash($value);
if (CRM_Utils_File::createDir($value, false) === false) {
// seems like we could not create the directories
// settings might have changed, lets suppress a message for now
// so we can make some more progress and let the user fix their settings
// for now we assign it to a know value
// CRM-4949
$value = $this->templateCompileDir;
$url = CRM_Utils_System::url('civicrm/admin/setting/path', 'reset=1');
CRM_Core_Session::setStatus(ts('%1 has an incorrect directory path. Please go to the <a href="%2">path setting page</a> and correct it.', array(1 => $key, 2 => $url)) . '<br/>');
}
} else {
if ($key == 'lcMessages') {
// reset the templateCompileDir to locale-specific and make sure it exists
if (substr($this->templateCompileDir, -1 * strlen($value) - 1, -1) != $value) {
$this->templateCompileDir .= CRM_Utils_File::addTrailingSlash($value);
CRM_Utils_File::createDir($this->templateCompileDir);
}
}
}
}
$this->{$key} = $value;
}
if ($this->userFrameworkResourceURL) {
// we need to do this here so all blocks also load from an ssl server
if (isset($_SERVER['HTTPS']) && strtolower($_SERVER['HTTPS']) != 'off') {
CRM_Utils_System::mapConfigToSSL();
}
$rrb = parse_url($this->userFrameworkResourceURL);
// dont use absolute path if resources are stored on a different server
// CRM-4642
$this->resourceBase = $this->userFrameworkResourceURL;
if (isset($_SERVER['HTTP_HOST'])) {
$this->resourceBase = $rrb['host'] == $_SERVER['HTTP_HOST'] ? $rrb['path'] : $this->userFrameworkResourceURL;
}
}
if (!$this->customFileUploadDir) {
$this->customFileUploadDir = $this->uploadDir;
}
if ($this->mapProvider) {
$this->geocodeMethod = 'CRM_Utils_Geocode_' . $this->mapProvider;
}
}
示例2: retrieve
//.........这里部分代码省略.........
unset($defaults[$skip]);
}
}
// since language field won't be present before upgrade.
if (CRM_Utils_Array::value('q', $_GET) == 'civicrm/upgrade') {
return;
}
// check if there are any locale strings
if ($domain->locale_custom_strings) {
$defaults['localeCustomStrings'] = unserialize($domain->locale_custom_strings);
} else {
$defaults['localeCustomStrings'] = null;
}
// are we in a multi-language setup?
$multiLang = $domain->locales ? true : false;
// set the current language
$lcMessages = null;
$session = CRM_Core_Session::singleton();
// for logging purposes, pass the userID to the db
if ($session->get('userID')) {
CRM_Core_DAO::executeQuery('SET @civicrm_user_id = %1', array(1 => array($session->get('userID'), 'Integer')));
}
// on multi-lang sites based on request and civicrm_uf_match
if ($multiLang) {
require_once 'CRM/Utils/Request.php';
$lcMessagesRequest = CRM_Utils_Request::retrieve('lcMessages', 'String', $this);
$languageLimit = array();
if (array_key_exists('languageLimit', $defaults) && is_array($defaults['languageLimit'])) {
$languageLimit = $defaults['languageLimit'];
}
if (in_array($lcMessagesRequest, array_keys($languageLimit))) {
$lcMessages = $lcMessagesRequest;
} else {
$lcMessagesRequest = null;
}
if (!$lcMessagesRequest) {
$lcMessagesSession = $session->get('lcMessages');
if (in_array($lcMessagesSession, array_keys($languageLimit))) {
$lcMessages = $lcMessagesSession;
} else {
$lcMessagesSession = null;
}
}
if ($lcMessagesRequest) {
require_once 'CRM/Core/DAO/UFMatch.php';
$ufm = new CRM_Core_DAO_UFMatch();
$ufm->contact_id = $session->get('userID');
if ($ufm->find(true)) {
$ufm->language = $lcMessages;
$ufm->save();
}
$session->set('lcMessages', $lcMessages);
}
if (!$lcMessages and $session->get('userID')) {
require_once 'CRM/Core/DAO/UFMatch.php';
$ufm = new CRM_Core_DAO_UFMatch();
$ufm->contact_id = $session->get('userID');
if ($ufm->find(true) && in_array($ufm->language, array_keys($languageLimit))) {
$lcMessages = $ufm->language;
}
$session->set('lcMessages', $lcMessages);
}
}
global $dbLocale;
// if unset and the install is so configured, try to inherit the language from the hosting CMS
if ($lcMessages === null and CRM_Utils_Array::value('inheritLocale', $defaults)) {
// FIXME: On multilanguage installs, CRM_Utils_System::getUFLocale() in many cases returns nothing if $dbLocale is not set
$dbLocale = $multiLang ? "_{$defaults['lcMessages']}" : '';
require_once 'CRM/Utils/System.php';
$lcMessages = CRM_Utils_System::getUFLocale();
require_once 'CRM/Core/BAO/CustomOption.php';
if ($domain->locales and !in_array($lcMessages, explode(CRM_Core_BAO_CustomOption::VALUE_SEPERATOR, $domain->locales))) {
$lcMessages = null;
}
}
if ($lcMessages) {
// update config lcMessages - CRM-5027 fixed.
$defaults['lcMessages'] = $lcMessages;
} else {
// if a single-lang site or the above didn't yield a result, use default
$lcMessages = $defaults['lcMessages'];
}
// set suffix for table names - use views if more than one language
$dbLocale = $multiLang ? "_{$lcMessages}" : '';
// FIXME: an ugly hack to fix CRM-4041
global $tsLocale;
$tsLocale = $lcMessages;
// FIXME: as bad aplace as any to fix CRM-5428
// (to be moved to a sane location along with the above)
if (function_exists('mb_internal_encoding')) {
mb_internal_encoding('UTF-8');
}
}
// dont add if its empty
if (!empty($defaults)) {
// retrieve directory and url preferences also
require_once 'CRM/Core/BAO/Preferences.php';
CRM_Core_BAO_Preferences::retrieveDirectoryAndURLPreferences($defaults);
}
}