return array($url, $dir, $siteName, $siteRoot);
}
+/**
+ * Return likely default settings
+ * @return array site settings
+ * -$url,
+ * - $dir Base Directory
+ * - $siteName
+ * - $siteRoot
+ */
static function getBestGuessSettings() {
$config = CRM_Core_Config::singleton();
-
- $url = $config->userFrameworkBaseURL;
- $siteName = $siteRoot = NULL;
- if ($config->userFramework == 'Joomla') {
- $url = preg_replace(
- '|/administrator|',
- '',
- $config->userFrameworkBaseURL
- );
- $siteRoot = preg_replace(
- '|/media/civicrm/.*$|',
- '',
- $config->imageUploadDir
- );
- }
-
$dir = preg_replace(
'|civicrm/templates_c/.*$|',
'',
$config->templateCompileDir
);
-
- if ($config->userFramework->is_drupal) {
- $matches = array();
- if (preg_match(
- '|/sites/([\w\.\-\_]+)/|',
- $config->templateCompileDir,
- $matches
- )) {
- $siteName = $matches[1];
- if ($siteName) {
- $siteName = "/sites/$siteName/";
- $siteNamePos = strpos($dir, $siteName);
- if ($siteNamePos !== FALSE) {
- $siteRoot = substr($dir, 0, $siteNamePos);
- }
- }
- }
- }
-
+ list($url, $siteName, $siteRoot) = $config->userSystem->getDefaultSiteSettings($dir);
return array($url, $dir, $siteName, $siteRoot);
}
function flush() {
// nullop by default
}
+ /**
+ * Return default Site Settings
+ * @return array array
+ * - $url, (Joomla - non admin url)
+ * - $siteName,
+ * - $siteRoot
+ */
+ function getDefaultSiteSettings($dir){
+ $config = CRM_Core_Config::singleton();
+ $url = $config->userFrameworkBaseURL;
+ return array($url, NULL, NULL);
+ }
}
/**
* Drupal specific stuff goes here
*/
-class CRM_Utils_System_Drupal extends CRM_Utils_System_Base {
- function __construct() {
- $this->is_drupal = TRUE;
- $this->supports_form_extensions = TRUE;
- }
+class CRM_Utils_System_Drupal extends CRM_Utils_System_DrupalBase {
/**
* Function to create a user in Drupal.
/**
* Drupal specific stuff goes here
*/
-class CRM_Utils_System_Drupal6 extends CRM_Utils_System_Base {
- function __construct() {
- $this->is_drupal = TRUE;
- $this->supports_form_extensions = TRUE;
- }
+class CRM_Utils_System_Drupal6 extends CRM_Utils_System_DrupalBase {
/**
* if we are using a theming system, invoke theme, else just print the
--- /dev/null
+<?php
+/*
+ +--------------------------------------------------------------------+
+ | CiviCRM version 4.3 |
+ +--------------------------------------------------------------------+
+ | Copyright CiviCRM LLC (c) 2004-2013 |
+ +--------------------------------------------------------------------+
+ | This file is a part of CiviCRM. |
+ | |
+ | CiviCRM is free software; you can copy, modify, and distribute it |
+ | under the terms of the GNU Affero General Public License |
+ | Version 3, 19 November 2007 and the CiviCRM Licensing Exception. |
+ | |
+ | CiviCRM is distributed in the hope that it will be useful, but |
+ | WITHOUT ANY WARRANTY; without even the implied warranty of |
+ | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
+ | See the GNU Affero General Public License for more details. |
+ | |
+ | You should have received a copy of the GNU Affero General Public |
+ | License and the CiviCRM Licensing Exception along |
+ | with this program; if not, contact CiviCRM LLC |
+ | at info[AT]civicrm[DOT]org. If you have questions about the |
+ | GNU Affero General Public License or the licensing of CiviCRM, |
+ | see the CiviCRM license FAQ at http://civicrm.org/licensing |
+ +--------------------------------------------------------------------+
+*/
+
+/**
+ *
+ * @package CRM
+ * @copyright CiviCRM LLC (c) 2004-2013
+ * $Id$
+ *
+ */
+
+/**
+ * Drupal specific stuff goes here
+ */
+abstract class CRM_Utils_System_DrupalBase extends CRM_Utils_System_Base {
+ function __construct() {
+ $this->is_drupal = TRUE;
+ $this->supports_form_extensions = TRUE;
+ }
+
+ /**
+ * @param string dir base civicrm directory
+ * Return default Site Settings
+ * @return array array
+ * - $url, (Joomla - non admin url)
+ * - $siteName,
+ * - $siteRoot
+ */
+ function getDefaultSiteSettings($dir){
+ $config = CRM_Core_Config::singleton();
+ $siteName = $siteRoot = NULL;
+ $matches = array();
+ if (preg_match(
+ '|/sites/([\w\.\-\_]+)/|',
+ $config->templateCompileDir,
+ $matches
+ )) {
+ $siteName = $matches[1];
+ if ($siteName) {
+ $siteName = "/sites/$siteName/";
+ $siteNamePos = strpos($dir, $siteName);
+ if ($siteNamePos !== FALSE) {
+ $siteRoot = substr($dir, 0, $siteNamePos);
+ }
+ }
+ }
+ $url = $config->userFrameworkBaseURL;
+ return array($url, $siteName, $siteRoot);
+ }
+}
\ No newline at end of file
public function getLoginDestination(&$form) {
return;
}
+
+ /**
+ * Return default Site Settings
+ * @return array array
+ * - $url, (Joomla - non admin url)
+ * - $siteName,
+ * - $siteRoot
+ */
+ function getDefaultSiteSettings($dir){
+ $config = CRM_Core_Config::singleton();
+ $url = preg_replace(
+ '|/administrator|',
+ '',
+ $config->userFrameworkBaseURL
+ );
+ $siteRoot = preg_replace(
+ '|/media/civicrm/.*$|',
+ '',
+ $config->imageUploadDir
+ );
+ return array($url, NULL, $siteRoot);
+ }
}