本文整理汇总了PHP中CRM_Utils_System::languageNegotiationURL方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_System::languageNegotiationURL方法的具体用法?PHP CRM_Utils_System::languageNegotiationURL怎么用?PHP CRM_Utils_System::languageNegotiationURL使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Utils_System
的用法示例。
在下文中一共展示了CRM_Utils_System::languageNegotiationURL方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: readActiveConfig
/**
* @return array
*/
public function readActiveConfig()
{
if (!defined('CIVICRM_SETTINGS_PATH') || CIVICRM_SETTINGS_PATH !== $this->settingsFile) {
return array();
}
$paths = is_callable(array('Civi', 'paths')) ? \Civi::paths() : NULL;
$data = array('CMS_DB_DSN' => CIVICRM_UF_DSN, 'CMS_VERSION' => \CRM_Core_Config::singleton()->userSystem->getVersion(), 'CIVI_DB_DSN' => CIVICRM_DSN, 'CIVI_SITE_KEY' => CIVICRM_SITE_KEY, 'CIVI_VERSION' => \CRM_Utils_System::version(), 'CIVI_SETTINGS' => CIVICRM_SETTINGS_PATH, 'CIVI_TEMPLATEC' => \CRM_Core_Config::singleton()->templateCompileDir, 'CIVI_UF' => \CRM_Core_Config::singleton()->userFramework, 'IS_INSTALLED' => '1', 'SITE_TYPE' => 'cv-auto', 'CMS_URL' => $paths ? \Civi::paths()->getUrl('[cms.root]/', 'absolute') : \CRM_Utils_System::languageNegotiationURL(\CRM_Utils_System::baseCMSURL(), FALSE, TRUE), 'CMS_ROOT' => $paths ? \Civi::paths()->getPath('[cms.root]/.') : \CRM_Core_Config::singleton()->userSystem->cmsRootPath(), 'CIVI_CORE' => $paths ? \Civi::paths()->getPath('[civicrm.root]/.') : $GLOBALS['civicrm_root'], 'CIVI_URL' => $paths ? \Civi::paths()->getUrl('[civicrm.root]/', 'absolute') : '', 'CIVI_FILES' => $paths ? \Civi::paths()->getPath('[civicrm.root]/.') : dirname(\CRM_Core_Config::singleton()->templateCompileDir));
return $data;
}
示例2: getDefaultFileStorage
/**
* Moved from CRM_Utils_System_Base
*/
public function getDefaultFileStorage()
{
$config = CRM_Core_Config::singleton();
$cmsUrl = CRM_Utils_System::languageNegotiationURL($config->userFrameworkBaseURL, FALSE, TRUE);
$cmsPath = $this->cmsRootPath();
$filesPath = CRM_Utils_File::baseFilePath();
$filesRelPath = CRM_Utils_File::relativize($filesPath, $cmsPath);
$filesURL = rtrim($cmsUrl, '/') . '/' . ltrim($filesRelPath, ' /');
return array('url' => CRM_Utils_File::addTrailingSlash($filesURL, '/'), 'path' => CRM_Utils_File::addTrailingSlash($filesPath));
}
示例3: __construct
public function __construct()
{
$this->register('civicrm.root', function () {
return \CRM_Core_Config::singleton()->userSystem->getCiviSourceStorage();
})->register('civicrm.files', function () {
return \CRM_Core_Config::singleton()->userSystem->getDefaultFileStorage();
})->register('cms', function () {
return array('path' => \CRM_Core_Config::singleton()->userSystem->cmsRootPath(), 'url' => \CRM_Utils_System::baseCMSURL());
})->register('cms.root', function () {
return array('path' => \CRM_Core_Config::singleton()->userSystem->cmsRootPath(), 'url' => \CRM_Utils_System::languageNegotiationURL(\CRM_Utils_System::baseCMSURL(), FALSE, TRUE));
});
}
示例4: getDefaultFileStorage
/**
* Moved from CRM_Utils_System_Base
*/
public function getDefaultFileStorage()
{
global $civicrm_root;
$config = CRM_Core_Config::singleton();
$baseURL = CRM_Utils_System::languageNegotiationURL($config->userFrameworkBaseURL, FALSE, TRUE);
$filesURL = NULL;
$filesPath = NULL;
$upload_dir = wp_upload_dir();
$settingsDir = $upload_dir['basedir'] . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR;
$settingsURL = $upload_dir['baseurl'] . DIRECTORY_SEPARATOR . 'civicrm' . DIRECTORY_SEPARATOR;
if (is_dir(WP_PLUGIN_DIR . '/files/civicrm/')) {
//for legacy path
$filesURL = WP_PLUGIN_URL . "/files/civicrm/";
} elseif (is_dir($settingsDir)) {
$filesURL = $settingsURL;
} else {
throw new CRM_Core_Exception("Failed to locate default file storage ({$config->userFramework})");
}
return array('url' => $filesURL, 'path' => CRM_Utils_File::baseFilePath());
}
示例5: getRelativePath
/**
* Return relative path.
*
* @todo make this a method of $config->userSystem (i.e. UF classes) rather than a static function
*
* @param string $absolutePath
* Absolute path.
*
* @return string
* Relative url of uploaded image
*/
public static function getRelativePath($absolutePath)
{
$relativePath = NULL;
$config = CRM_Core_Config::singleton();
if ($config->userFramework == 'Joomla') {
$userFrameworkBaseURL = trim(str_replace('/administrator/', '', $config->userFrameworkBaseURL));
$customFileUploadDirectory = strstr(str_replace('\\', '/', $absolutePath), '/media');
$relativePath = $userFrameworkBaseURL . $customFileUploadDirectory;
} elseif ($config->userSystem->is_drupal == '1') {
//ideally we would do a bigger re-factoring & move the getRelativePath onto the UF class
$rootPath = $config->userSystem->cmsRootPath();
$baseUrl = $config->userFrameworkBaseURL;
//format url for language negotiation, CRM-7135
$baseUrl = CRM_Utils_System::languageNegotiationURL($baseUrl, FALSE, TRUE);
$relativePath = str_replace("{$rootPath}/", $baseUrl, str_replace('\\', '/', $absolutePath));
} elseif ($config->userFramework == 'WordPress') {
$userFrameworkBaseURL = trim(str_replace('/wp-admin/', '', $config->userFrameworkBaseURL));
$customFileUploadDirectory = strstr(str_replace('\\', '/', $absolutePath), '/wp-content/');
$relativePath = $userFrameworkBaseURL . $customFileUploadDirectory;
}
return $relativePath;
}
示例6: getDefaultFileStorage
/**
* Determine the default location for file storage.
*
* FIXME:
* 1. This was pulled out from a bigger function. It should be split
* into even smaller pieces and marked abstract.
* 2. This would be easier to compute by a calling a CMS API, but
* for whatever reason Civi gets it from config data.
*
* @return array
* - url: string. ex: "http://example.com/sites/foo.com/files/civicrm"
* - path: string. ex: "/var/www/sites/foo.com/files/civicrm"
*/
public function getDefaultFileStorage()
{
global $civicrm_root;
$config = CRM_Core_Config::singleton();
$baseURL = CRM_Utils_System::languageNegotiationURL($config->userFrameworkBaseURL, FALSE, TRUE);
$filesURL = NULL;
$filesPath = NULL;
if ($config->userFramework == 'Joomla') {
// gross hack
// we need to remove the administrator/ from the end
$tempURL = str_replace("/administrator/", "/", $baseURL);
$filesURL = $tempURL . "media/civicrm/";
} elseif ($this->is_drupal) {
$siteName = $config->userSystem->parseDrupalSiteName($civicrm_root);
if ($siteName) {
$filesURL = $baseURL . "sites/{$siteName}/files/civicrm/";
} else {
$filesURL = $baseURL . "sites/default/files/civicrm/";
}
} elseif ($config->userFramework == 'UnitTests') {
$filesURL = $baseURL . "sites/default/files/civicrm/";
} else {
throw new CRM_Core_Exception("Failed to locate default file storage ({$config->userFramework})");
}
return array('url' => $filesURL, 'path' => CRM_Utils_File::baseFilePath());
}
示例7: _setUserFrameworkConfig
/**
* @param string $userFramework
* One of 'Drupal', 'Joomla', etc.
*/
private function _setUserFrameworkConfig($userFramework)
{
$this->userFrameworkClass = 'CRM_Utils_System_' . $userFramework;
$this->userHookClass = 'CRM_Utils_Hook_' . $userFramework;
$userPermissionClass = 'CRM_Core_Permission_' . $userFramework;
$this->userPermissionClass = new $userPermissionClass();
$class = $this->userFrameworkClass;
// redundant with _initVariables
$this->userSystem = new $class();
if ($userFramework == 'Joomla') {
$this->userFrameworkURLVar = 'task';
}
if (defined('CIVICRM_UF_BASEURL')) {
$this->userFrameworkBaseURL = CRM_Utils_File::addTrailingSlash(CIVICRM_UF_BASEURL, '/');
//format url for language negotiation, CRM-7803
$this->userFrameworkBaseURL = CRM_Utils_System::languageNegotiationURL($this->userFrameworkBaseURL);
if (CRM_Utils_System::isSSL()) {
$this->userFrameworkBaseURL = str_replace('http://', 'https://', $this->userFrameworkBaseURL);
}
}
if (defined('CIVICRM_UF_DSN')) {
$this->userFrameworkDSN = CIVICRM_UF_DSN;
}
// this is dynamically figured out in the civicrm.settings.php file
if (defined('CIVICRM_CLEANURL')) {
$this->cleanURL = CIVICRM_CLEANURL;
} else {
$this->cleanURL = 0;
}
$this->userFrameworkVersion = $this->userSystem->getVersion();
if ($userFramework == 'Joomla') {
/** @var object|null $mainframe */
global $mainframe;
$dbprefix = $mainframe ? $mainframe->getCfg('dbprefix') : 'jos_';
$this->userFrameworkUsersTableName = $dbprefix . 'users';
} elseif ($userFramework == 'WordPress') {
global $wpdb;
$dbprefix = $wpdb ? $wpdb->prefix : '';
$this->userFrameworkUsersTableName = $dbprefix . 'users';
}
}