当前位置: 首页>>代码示例>>PHP>>正文


PHP CRM_Utils_File::addTrailingSlash方法代码示例

本文整理汇总了PHP中CRM_Utils_File::addTrailingSlash方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Utils_File::addTrailingSlash方法的具体用法?PHP CRM_Utils_File::addTrailingSlash怎么用?PHP CRM_Utils_File::addTrailingSlash使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CRM_Utils_File的用法示例。


在下文中一共展示了CRM_Utils_File::addTrailingSlash方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: initialize

 private function initialize()
 {
     $config = CRM_Core_Config::singleton();
     if (isset($config->customTemplateDir) && $config->customTemplateDir) {
         $this->template_dir = array_merge(array($config->customTemplateDir), $config->templateDir);
     } else {
         $this->template_dir = $config->templateDir;
     }
     $this->compile_dir = CRM_Utils_File::addTrailingSlash(CRM_Utils_File::addTrailingSlash($config->templateCompileDir) . $this->getLocale());
     CRM_Utils_File::createDir($this->compile_dir);
     CRM_Utils_File::restrictAccess($this->compile_dir);
     // check and ensure it is writable
     // else we sometime suppress errors quietly and this results
     // in blank emails etc
     if (!is_writable($this->compile_dir)) {
         echo "CiviCRM does not have permission to write temp files in {$this->compile_dir}, Exiting";
         exit;
     }
     //Check for safe mode CRM-2207
     if (ini_get('safe_mode')) {
         $this->use_sub_dirs = FALSE;
     } else {
         $this->use_sub_dirs = TRUE;
     }
     $customPluginsDir = NULL;
     if (isset($config->customPHPPathDir)) {
         $customPluginsDir = $config->customPHPPathDir . DIRECTORY_SEPARATOR . 'CRM' . DIRECTORY_SEPARATOR . 'Core' . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR;
         if (!file_exists($customPluginsDir)) {
             $customPluginsDir = NULL;
         }
     }
     $smartyDir = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'packages' . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR;
     $pluginsDir = __DIR__ . DIRECTORY_SEPARATOR . 'Smarty' . DIRECTORY_SEPARATOR . 'plugins' . DIRECTORY_SEPARATOR;
     if ($customPluginsDir) {
         $this->plugins_dir = array($customPluginsDir, $smartyDir . 'plugins', $pluginsDir);
     } else {
         $this->plugins_dir = array($smartyDir . 'plugins', $pluginsDir);
     }
     // add the session and the config here
     $session = CRM_Core_Session::singleton();
     $this->assign_by_ref('config', $config);
     $this->assign_by_ref('session', $session);
     global $tsLocale;
     $this->assign('tsLocale', $tsLocale);
     // CRM-7163 hack: we don’t display langSwitch on upgrades anyway
     if (!CRM_Core_Config::isUpgradeMode()) {
         $this->assign('langSwitch', CRM_Core_I18n::languages(TRUE));
     }
     $this->register_function('crmURL', array('CRM_Utils_System', 'crmURL'));
     $this->load_filter('pre', 'resetExtScope');
     $this->assign('crmPermissions', new CRM_Core_Smarty_Permissions());
 }
开发者ID:hyebahi,项目名称:civicrm-core,代码行数:52,代码来源:Smarty.php

示例2: _run

 /**
  * Scan all api directories to discover entities
  *
  * @param \Civi\API\Result $result
  */
 public function _run(Result $result)
 {
     $entities = array();
     foreach (explode(PATH_SEPARATOR, get_include_path()) as $path) {
         $dir = \CRM_Utils_File::addTrailingSlash($path) . 'Civi/Api4';
         if (is_dir($dir)) {
             foreach (glob("{$dir}/*.php") as $file) {
                 $matches = array();
                 preg_match('/(\\w*).php/', $file, $matches);
                 $entities[$matches[1]] = $matches[1];
             }
         }
     }
     $result->exchangeArray(array_values($entities));
 }
开发者ID:civicrm,项目名称:api4,代码行数:20,代码来源:Get.php

示例3: _run

 public function _run(Result $result)
 {
     $includePaths = array_unique(explode(PATH_SEPARATOR, get_include_path()));
     $entityReflection = new \ReflectionClass('\\Civi\\Api4\\' . $this->getEntity());
     // First search entity-specific actions (including those provided by extensions
     foreach ($includePaths as $path) {
         $dir = \CRM_Utils_File::addTrailingSlash($path) . 'Civi/API/V4/Entity/' . $this->getEntity();
         $this->scanDir($dir);
     }
     // Scan all generic actions unless this entity does not extend generic entity
     if ($entityReflection->getParentClass()) {
         foreach ($includePaths as $path) {
             $dir = \CRM_Utils_File::addTrailingSlash($path) . 'Civi/API/V4/Action';
             $this->scanDir($dir);
         }
     } else {
         foreach ($entityReflection->getMethods(\ReflectionMethod::IS_STATIC) as $method) {
             $this->loadAction($method->getName());
         }
     }
     $result->exchangeArray(array_values($this->_actions));
 }
开发者ID:civicrm,项目名称:api4,代码行数:22,代码来源:GetActions.php

示例4: __get

 public function __get($k)
 {
     if (!isset($this->map[$k])) {
         throw new \CRM_Core_Exception("Cannot read unrecognized property CRM_Core_Config::\${$k}.");
     }
     if (isset($this->cache[$k])) {
         return $this->cache[$k];
     }
     $type = $this->map[$k][0];
     $name = isset($this->map[$k][1]) ? $this->map[$k][1] : $k;
     switch ($type) {
         case 'setting':
             return $this->getSettings()->get($name);
         case 'setting-path':
             // Array(0 => $type, 1 => $setting, 2 => $actions).
             $value = $this->getSettings()->get($name);
             $value = Civi::paths()->getPath($value);
             if ($value) {
                 $value = CRM_Utils_File::addTrailingSlash($value);
                 if (isset($this->map[$k][2]) && in_array('mkdir', $this->map[$k][2])) {
                     CRM_Utils_File::createDir($value);
                 }
                 if (isset($this->map[$k][2]) && in_array('restrict', $this->map[$k][2])) {
                     CRM_Utils_File::restrictAccess($value);
                 }
             }
             $this->cache[$k] = $value;
             return $value;
         case 'setting-url-abs':
             $value = $this->getSettings()->get($name);
             $this->cache[$k] = Civi::paths()->getUrl($value, 'absolute');
             return $this->cache[$k];
         case 'setting-url-rel':
             $value = $this->getSettings()->get($name);
             $this->cache[$k] = Civi::paths()->getUrl($value, 'relative');
             return $this->cache[$k];
         case 'runtime':
             return \Civi\Core\Container::getBootService('runtime')->{$name};
         case 'boot-svc':
             $this->cache[$k] = \Civi\Core\Container::getBootService($name);
             return $this->cache[$k];
         case 'local':
             $this->initLocals();
             return $this->locals[$name];
         case 'user-system':
             $userSystem = \Civi\Core\Container::getBootService('userSystem');
             $this->cache[$k] = call_user_func(array($userSystem, $name));
             return $this->cache[$k];
         case 'service':
             return \Civi::service($name);
         case 'callback':
             // Array(0 => $type, 1 => $obj, 2 => $getter, 3 => $setter, 4 => $unsetter).
             if (!isset($this->map[$k][1], $this->map[$k][2])) {
                 throw new \CRM_Core_Exception("Cannot find getter for property CRM_Core_Config::\${$k}");
             }
             return \Civi\Core\Resolver::singleton()->call(array($this->map[$k][1], $this->map[$k][2]), array($k));
         default:
             throw new \CRM_Core_Exception("Cannot read property CRM_Core_Config::\${$k} ({$type})");
     }
 }
开发者ID:rollox,项目名称:civicrm-core,代码行数:60,代码来源:MagicMerge.php

示例5: _initVariables

 /**
  * initialize the config variables
  *
  * @return void
  * @access private
  */
 private function _initVariables()
 {
     // initialize component registry early to avoid "race"
     // between CRM_Core_Config and CRM_Core_Component (they
     // are co-dependant)
     require_once 'CRM/Core/Component.php';
     $this->componentRegistry = new CRM_Core_Component();
     // 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);
         // 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;
                 }
             } else {
                 if ($key == 'lcMessages') {
                     // reset the templateCompileDir to locale-specific and make sure it exists
                     $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;
     }
 }
开发者ID:ksecor,项目名称:civicrm,代码行数:76,代码来源:Config.php

示例6: postProcess

 function postProcess()
 {
     // redirect to admin page after saving
     $session =& CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/admin'));
     $params = $this->controller->exportValues($this->_name);
     //CRM-5679
     foreach ($params as $name => &$val) {
         if ($val && in_array($name, array('newBaseURL', 'newBaseDir', 'newSiteName'))) {
             $val = CRM_Utils_File::addTrailingSlash($val);
         }
     }
     $from = array($this->_oldBaseURL, $this->_oldBaseDir);
     $to = array(trim($params['newBaseURL']), trim($params['newBaseDir']));
     if ($this->_oldSiteName && $params['newSiteName']) {
         $from[] = $this->_oldSiteName;
         $to[] = $params['newSiteName'];
     }
     $newValues = str_replace($from, $to, $this->_defaults);
     parent::commonProcess($newValues);
     parent::rebuildMenu();
 }
开发者ID:bhirsch,项目名称:voipdev,代码行数:22,代码来源:UpdateConfigBackend.php

示例7: testFormatMailchimpWebhookUrl

 function testFormatMailchimpWebhookUrl()
 {
     $url = CIVICRM_UF_BASEURL;
     $url = CRM_Utils_File::addTrailingSlash($url);
     $site_key = CRM_CiviMailchimp_Utils::getSiteKey();
     $expected_webhook_url = "{$url}civicrm/mailchimp/webhook?key={$site_key}";
     $webhook_url = CRM_CiviMailchimp_Utils::formatMailchimpWebhookUrl();
     $this->assertEquals($expected_webhook_url, $webhook_url);
 }
开发者ID:jaapjansma,项目名称:com.giantrabbit.civimailchimp,代码行数:9,代码来源:UtilsTest.php

示例8: getCiviSourceStorage

 /**
  * Determine the location of the CiviCRM source tree.
  *
  * 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 we take the hard way.
  *
  * @return array
  *   - url: string. ex: "http://example.com/sites/all/modules/civicrm"
  *   - path: string. ex: "/var/www/sites/all/modules/civicrm"
  */
 public function getCiviSourceStorage()
 {
     global $civicrm_root;
     $config = CRM_Core_Config::singleton();
     // Don't use $config->userFrameworkBaseURL; it has garbage on it.
     // More generally, w shouldn't be using $config here.
     if (!defined('CIVICRM_UF_BASEURL')) {
         throw new RuntimeException('Undefined constant: CIVICRM_UF_BASEURL');
     }
     $baseURL = CRM_Utils_File::addTrailingSlash(CIVICRM_UF_BASEURL, '/');
     if (CRM_Utils_System::isSSL()) {
         $baseURL = str_replace('http://', 'https://', $baseURL);
     }
     if ($config->userFramework == 'Joomla') {
         $userFrameworkResourceURL = $baseURL . "components/com_civicrm/civicrm/";
     } elseif ($config->userFramework == 'WordPress') {
         $userFrameworkResourceURL = CIVICRM_PLUGIN_URL . "civicrm/";
     } elseif ($this->is_drupal) {
         // Drupal setting
         // check and see if we are installed in sites/all (for D5 and above)
         // we dont use checkURL since drupal generates an error page and throws
         // the system for a loop on lobo's macosx box
         // or in modules
         $cmsPath = $config->userSystem->cmsRootPath();
         $userFrameworkResourceURL = $baseURL . str_replace("{$cmsPath}/", '', str_replace('\\', '/', $civicrm_root));
         $siteName = $config->userSystem->parseDrupalSiteName($civicrm_root);
         if ($siteName) {
             $civicrmDirName = trim(basename($civicrm_root));
             $userFrameworkResourceURL = $baseURL . "sites/{$siteName}/modules/{$civicrmDirName}/";
         }
     } else {
         $userFrameworkResourceURL = NULL;
     }
     return array('url' => CRM_Utils_File::addTrailingSlash($userFrameworkResourceURL), 'path' => CRM_Utils_File::addTrailingSlash($civicrm_root));
 }
开发者ID:FundingWorks,项目名称:civicrm-core,代码行数:48,代码来源:Base.php

示例9: retrieveMailchimpMemberExportFile

 /**
  * Download the Mailchimp export file to a temporary folder.
  */
 static function retrieveMailchimpMemberExportFile($url, $list_id)
 {
     $config = CRM_Core_Config::singleton();
     $timestamp = microtime();
     $temp_dir = CRM_Utils_File::addTrailingSlash($config->uploadDir);
     $file_path = "{$temp_dir}mailchimp_export_{$list_id}_{$timestamp}.tmp";
     $file = fopen($file_path, 'w');
     if ($file === FALSE) {
         throw new CRM_CiviMailchimp_Exception("Unable to open the temporary Mailchimp Export file located at {$file_path}.");
     }
     $ch = curl_init($url);
     if ($ch === FALSE) {
         $err_number = curl_errno($ch);
         $err_string = curl_error($ch);
         throw new CRM_CiviMailchimp_Exception("cURL failed to initiate for the url {$url}. cURL error # {$err_number}: {$err_string}.");
     }
     curl_setopt($ch, CURLOPT_TIMEOUT, 50);
     curl_setopt($ch, CURLOPT_FILE, $file);
     curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
     $data = curl_exec($ch);
     if ($data === FALSE) {
         $err_number = curl_errno($ch);
         $err_string = curl_error($ch);
         throw new CRM_CiviMailchimp_Exception("cURL failed to retrieve data from the url {$url}. cURL error # {$err_number}: {$err_string}.");
     }
     curl_close($ch);
     fclose($file);
     return $file_path;
 }
开发者ID:jaapjansma,项目名称:com.giantrabbit.civimailchimp,代码行数:32,代码来源:Utils.php

示例10: getCiviSourceStorage

 /**
  * Determine the location of the CiviCRM source tree.
  *
  * @return array
  *   - url: string. ex: "http://example.com/sites/all/modules/civicrm"
  *   - path: string. ex: "/var/www/sites/all/modules/civicrm"
  */
 public function getCiviSourceStorage()
 {
     global $civicrm_root;
     // Don't use $config->userFrameworkBaseURL; it has garbage on it.
     // More generally, we shouldn't be using $config here.
     if (!defined('CIVICRM_UF_BASEURL')) {
         throw new RuntimeException('Undefined constant: CIVICRM_UF_BASEURL');
     }
     $cmsPath = $this->cmsRootPath();
     // $config  = CRM_Core_Config::singleton();
     // overkill? // $cmsUrl = CRM_Utils_System::languageNegotiationURL($config->userFrameworkBaseURL, FALSE, TRUE);
     $cmsUrl = CIVICRM_UF_BASEURL;
     if (CRM_Utils_System::isSSL()) {
         $cmsUrl = str_replace('http://', 'https://', $cmsUrl);
     }
     $civiRelPath = CRM_Utils_File::relativize($civicrm_root, $cmsPath);
     $civiUrl = rtrim($cmsUrl, '/') . '/' . ltrim($civiRelPath, ' /');
     return array('url' => CRM_Utils_File::addTrailingSlash($civiUrl, '/'), 'path' => CRM_Utils_File::addTrailingSlash($civicrm_root));
 }
开发者ID:sarehag,项目名称:civicrm-core,代码行数:26,代码来源:WordPress.php

示例11: _initVariables

 /**
  * Initialize the config variables.
  *
  * @return void
  */
 private function _initVariables()
 {
     // retrieve serialised settings
     $variables = array();
     CRM_Core_BAO_ConfigSetting::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)
         CRM_Core_Config_Defaults::setValues($variables);
         // retrieve directory and url preferences also
         CRM_Core_BAO_Setting::retrieveDirectoryAndURLPreferences($variables);
         // add component specific settings
         $this->componentRegistry->addConfig($this);
         // serialise settings
         $settings = $variables;
         CRM_Core_BAO_ConfigSetting::add($settings);
     }
     $urlArray = array('userFrameworkResourceURL', 'imageUploadURL');
     $dirArray = array('uploadDir', 'customFileUploadDir');
     foreach ($variables as $key => $value) {
         if (in_array($key, $urlArray)) {
             $value = CRM_Utils_File::addTrailingSlash($value, '/');
         } elseif (in_array($key, $dirArray)) {
             if ($value) {
                 $value = CRM_Utils_File::addTrailingSlash($value);
             }
             if (empty($value) || 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)), ts('Check Settings'), 'alert');
             }
         } elseif ($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);
                 CRM_Utils_File::restrictAccess($this->templateCompileDir);
             }
         }
         $this->{$key} = $value;
     }
     if ($this->userFrameworkResourceURL) {
         // we need to do this here so all blocks also load from an ssl server
         if (CRM_Utils_System::isSSL()) {
             CRM_Utils_System::mapConfigToSSL();
         }
         $rrb = parse_url($this->userFrameworkResourceURL);
         // don't use absolute path if resources are stored on a different server
         // CRM-4642
         $this->resourceBase = $this->userFrameworkResourceURL;
         if (isset($_SERVER['HTTP_HOST']) && isset($rrb['host'])) {
             $this->resourceBase = $rrb['host'] == $_SERVER['HTTP_HOST'] ? $rrb['path'] : $this->userFrameworkResourceURL;
         }
     }
     if (!$this->customFileUploadDir) {
         $this->customFileUploadDir = $this->uploadDir;
     }
     if ($this->geoProvider) {
         $this->geocodeMethod = 'CRM_Utils_Geocode_' . $this->geoProvider;
     } elseif ($this->mapProvider) {
         $this->geocodeMethod = 'CRM_Utils_Geocode_' . $this->mapProvider;
     }
     require_once str_replace('_', DIRECTORY_SEPARATOR, $this->userFrameworkClass) . '.php';
     $class = $this->userFrameworkClass;
     // redundant with _setUserFrameworkConfig
     $this->userSystem = new $class();
 }
开发者ID:BorislavZlatanov,项目名称:civicrm-core,代码行数:80,代码来源:Config.php

示例12: baseFilePath

 /**
  * Create the base file path from which all our internal directories are
  * offset. This is derived from the template compile directory set
  */
 static function baseFilePath($templateCompileDir = NULL)
 {
     static $_path = NULL;
     if (!$_path) {
         if ($templateCompileDir == NULL) {
             $config = CRM_Core_Config::singleton();
             $templateCompileDir = $config->templateCompileDir;
         }
         $path = dirname($templateCompileDir);
         //this fix is to avoid creation of upload dirs inside templates_c directory
         $checkPath = explode(DIRECTORY_SEPARATOR, $path);
         $cnt = count($checkPath) - 1;
         if ($checkPath[$cnt] == 'templates_c') {
             unset($checkPath[$cnt]);
             $path = implode(DIRECTORY_SEPARATOR, $checkPath);
         }
         $_path = CRM_Utils_File::addTrailingSlash($path);
     }
     return $_path;
 }
开发者ID:hguru,项目名称:224Civi,代码行数:24,代码来源:File.php

示例13: initialize

 /**
  * @param bool $loadFromDB
  */
 public function initialize($loadFromDB = TRUE)
 {
     if (!defined('CIVICRM_DSN') && $loadFromDB) {
         $this->fatal('You need to define CIVICRM_DSN in civicrm.settings.php');
     }
     $this->dsn = defined('CIVICRM_DSN') ? CIVICRM_DSN : NULL;
     if (!defined('CIVICRM_TEMPLATE_COMPILEDIR') && $loadFromDB) {
         $this->fatal('You need to define CIVICRM_TEMPLATE_COMPILEDIR in civicrm.settings.php');
     }
     if (defined('CIVICRM_TEMPLATE_COMPILEDIR')) {
         $this->configAndLogDir = CRM_Utils_File::baseFilePath() . 'ConfigAndLog' . DIRECTORY_SEPARATOR;
         CRM_Utils_File::createDir($this->configAndLogDir);
         CRM_Utils_File::restrictAccess($this->configAndLogDir);
         $this->templateCompileDir = defined('CIVICRM_TEMPLATE_COMPILEDIR') ? CRM_Utils_File::addTrailingSlash(CIVICRM_TEMPLATE_COMPILEDIR) : NULL;
         CRM_Utils_File::createDir($this->templateCompileDir);
         CRM_Utils_File::restrictAccess($this->templateCompileDir);
     }
     if (!defined('CIVICRM_UF')) {
         $this->fatal('You need to define CIVICRM_UF in civicrm.settings.php');
     }
     $this->userFramework = CIVICRM_UF;
     $this->userFrameworkClass = 'CRM_Utils_System_' . CIVICRM_UF;
     $this->userHookClass = 'CRM_Utils_Hook_' . CIVICRM_UF;
     if (CIVICRM_UF == 'Joomla') {
         $this->userFrameworkURLVar = 'task';
     }
     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->templateDir = array(dirname(dirname(dirname(__DIR__))) . DIRECTORY_SEPARATOR . 'templates' . DIRECTORY_SEPARATOR);
     $this->initialized = 1;
 }
开发者ID:sarehag,项目名称:civicrm-core,代码行数:41,代码来源:Runtime.php

示例14: postProcess

 function postProcess()
 {
     if (!empty($_POST['_qf_UpdateConfigBackend_next_cleanup'])) {
         $config = CRM_Core_Config::singleton();
         // cleanup templates_c directory
         $config->cleanup(1, FALSE);
         // clear db caching
         CRM_Core_Config::clearDBCache();
         parent::rebuildMenu();
         CRM_Core_BAO_WordReplacement::rebuild();
         CRM_Core_Session::setStatus(ts('Cache has been cleared and menu has been rebuilt successfully.'), ts("Success"), "success");
         return CRM_Utils_System::redirect(CRM_Utils_System::url('civicrm/admin/setting/updateConfigBackend', 'reset=1'));
     }
     // redirect to admin page after saving
     $session = CRM_Core_Session::singleton();
     $session->pushUserContext(CRM_Utils_System::url('civicrm/admin'));
     $params = $this->controller->exportValues($this->_name);
     //CRM-5679
     foreach ($params as $name => &$val) {
         if ($val && in_array($name, array('newBaseURL', 'newBaseDir', 'newSiteName'))) {
             $val = CRM_Utils_File::addTrailingSlash($val);
         }
     }
     $from = array($this->_oldBaseURL, $this->_oldBaseDir);
     $to = array(trim($params['newBaseURL']), trim($params['newBaseDir']));
     if ($this->_oldSiteName && $params['newSiteName']) {
         $from[] = $this->_oldSiteName;
         $to[] = $params['newSiteName'];
     }
     $newValues = str_replace($from, $to, $this->_defaults);
     parent::commonProcess($newValues);
     parent::rebuildMenu();
 }
开发者ID:archcidburnziso,项目名称:civicrm-core,代码行数:33,代码来源:UpdateConfigBackend.php

示例15: setValues

 /**
  * Function to set the default values
  *
  * @param array   $defaults  associated array of form elements
  * @param boolena $formMode  this funtion is called to set default
  *                           values in an empty db, also called when setting component using GUI
  *                           this variable is set true for GUI
  *                           mode (eg: Global setting >> Components)    
  *
  * @access public
  */
 public function setValues(&$defaults, $formMode = false)
 {
     $config =& CRM_Core_Config::singleton();
     $baseURL = $config->userFrameworkBaseURL;
     if ($config->templateCompileDir) {
         $path = dirname($config->templateCompileDir);
         //this fix is to avoid creation of upload dirs inside templates_c directory
         $checkPath = explode(DIRECTORY_SEPARATOR, $path);
         $cnt = count($checkPath) - 1;
         if ($checkPath[$cnt] == 'templates_c') {
             unset($checkPath[$cnt]);
             $path = implode(DIRECTORY_SEPARATOR, $checkPath);
         }
         $path = CRM_Utils_File::addTrailingSlash($path);
     }
     //set defaults if not set in db
     if (!isset($defaults['userFrameworkResourceURL'])) {
         $testIMG = "i/tracker.gif";
         if ($config->userFramework == 'Joomla') {
             if (CRM_Utils_System::checkURL("{$baseURL}components/com_civicrm/civicrm/{$testIMG}")) {
                 $defaults['userFrameworkResourceURL'] = $baseURL . "components/com_civicrm/civicrm/";
             }
         } else {
             if ($config->userFramework == 'Standalone') {
                 // potentially sane default for standalone;
                 // could probably be smarter about this, but this
                 // should work in many cases
                 $defaults['userFrameworkResourceURL'] = str_replace('standalone/', '', $baseURL);
             } else {
                 // Drupal setting
                 // check and see if we are installed in sites/all (for D5 and above)
                 // we dont use checkURL since drupal generates an error page and throws
                 // the system for a loop on lobo's macosx box
                 // or in modules
                 global $civicrm_root;
                 $civicrmDirName = trim(basename($civicrm_root));
                 $defaults['userFrameworkResourceURL'] = $baseURL . "sites/all/modules/{$civicrmDirName}/";
                 if (strpos($civicrm_root, DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR . 'all' . DIRECTORY_SEPARATOR . 'modules') === false) {
                     $startPos = strpos($civicrm_root, DIRECTORY_SEPARATOR . 'sites' . DIRECTORY_SEPARATOR);
                     $endPos = strpos($civicrm_root, DIRECTORY_SEPARATOR . 'modules' . DIRECTORY_SEPARATOR);
                     if ($startPos && $endPos) {
                         // if component is in sites/SITENAME/modules
                         $siteName = substr($civicrm_root, $startPos + 7, $endPos - $startPos - 7);
                         $defaults['userFrameworkResourceURL'] = $baseURL . "sites/{$siteName}/modules/{$civicrmDirName}/";
                         if (!isset($defaults['imageUploadURL'])) {
                             $defaults['imageUploadURL'] = $baseURL . "sites/{$siteName}/files/civicrm/persist/contribute/";
                         }
                     }
                 }
             }
         }
     }
     if (!isset($defaults['imageUploadURL'])) {
         if ($config->userFramework == 'Joomla') {
             // gross hack
             // we need to remove the administrator/ from the end
             $tempURL = str_replace("/administrator/", "/", $baseURL);
             $defaults['imageUploadURL'] = $tempURL . "media/civicrm/persist/contribute/";
         } else {
             if ($config->userFramework == 'Standalone') {
                 //for standalone no need of sites/defaults directory
                 $defaults['imageUploadURL'] = $baseURL . "files/civicrm/persist/contribute/";
             } else {
                 $defaults['imageUploadURL'] = $baseURL . "sites/default/files/civicrm/persist/contribute/";
             }
         }
     }
     if (!isset($defaults['imageUploadDir']) && is_dir($config->templateCompileDir)) {
         $imgDir = $path . "persist/contribute/";
         CRM_Utils_File::createDir($imgDir);
         $defaults['imageUploadDir'] = $imgDir;
     }
     if (!isset($defaults['uploadDir']) && is_dir($config->templateCompileDir)) {
         $uploadDir = $path . "upload/";
         CRM_Utils_File::createDir($uploadDir);
         $defaults['uploadDir'] = $uploadDir;
     }
     if (!isset($defaults['customFileUploadDir']) && is_dir($config->templateCompileDir)) {
         $customDir = $path . "custom/";
         CRM_Utils_File::createDir($customDir);
         $defaults['customFileUploadDir'] = $customDir;
     }
     /* FIXME: hack to bypass the step for generating defaults for components, 
        while running upgrade, to avoid any serious non-recoverable error 
        which might hinder the upgrade process. */
     $args = array();
     if (isset($_GET[$config->userFrameworkURLVar])) {
         $args = explode('/', $_GET[$config->userFrameworkURLVar]);
     }
//.........这里部分代码省略.........
开发者ID:bhirsch,项目名称:voipdev,代码行数:101,代码来源:Defaults.php


注:本文中的CRM_Utils_File::addTrailingSlash方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。