From e51744f5494628c2a1fb51849eebdf41ab4cae20 Mon Sep 17 00:00:00 2001 From: "Donald A. Lobo" Date: Tue, 21 May 2013 14:10:21 -0700 Subject: [PATCH] CRM-12674 ---------------------------------------- * CRM-12674: WordPress updateConfigBackend is confused about URL http://issues.civicrm.org/jira/browse/CRM-12674 --- .../Form/Setting/UpdateConfigBackend.php | 11 ++-- CRM/Core/BAO/ConfigSetting.php | 54 +++++++++++++++---- .../Form/Setting/UpdateConfigBackend.tpl | 10 ++-- 3 files changed, 56 insertions(+), 19 deletions(-) diff --git a/CRM/Admin/Form/Setting/UpdateConfigBackend.php b/CRM/Admin/Form/Setting/UpdateConfigBackend.php index ab70e20766..662cfaa0c3 100644 --- a/CRM/Admin/Form/Setting/UpdateConfigBackend.php +++ b/CRM/Admin/Form/Setting/UpdateConfigBackend.php @@ -51,7 +51,8 @@ class CRM_Admin_Form_Setting_UpdateConfigBackend extends CRM_Admin_Form_Setting public function buildQuickForm() { CRM_Utils_System::setTitle(ts('Settings - Cleanup Caches and Update Paths')); - list($this->_oldBaseURL, + list( + $this->_oldBaseURL, $this->_oldBaseDir, $this->_oldSiteName ) = CRM_Core_BAO_ConfigSetting::getConfigSettings(); @@ -60,7 +61,10 @@ class CRM_Admin_Form_Setting_UpdateConfigBackend extends CRM_Admin_Form_Setting $this->assign('oldBaseDir', $this->_oldBaseDir); $this->assign('oldSiteName', $this->_oldSiteName); - $this->addElement('submit', $this->getButtonName('next', 'cleanup'), 'Cleanup Caches', array('class' => 'form-submit', 'id' => 'cleanup-cache')); + $this->addElement( + 'submit', $this->getButtonName('next', 'cleanup'), 'Cleanup Caches', + array('class' => 'form-submit', 'id' => 'cleanup-cache') + ); $this->add('text', 'newBaseURL', ts('New Base URL'), NULL, TRUE); $this->add('text', 'newBaseDir', ts('New Base Directory'), NULL, TRUE); @@ -77,7 +81,8 @@ class CRM_Admin_Form_Setting_UpdateConfigBackend extends CRM_Admin_Form_Setting parent::setDefaultValues(); $config = CRM_Core_Config::singleton(); - list($this->_defaults['newBaseURL'], + list( + $this->_defaults['newBaseURL'], $this->_defaults['newBaseDir'], $this->_defaults['newSiteName'] ) = CRM_Core_BAO_ConfigSetting::getBestGuessSettings(); diff --git a/CRM/Core/BAO/ConfigSetting.php b/CRM/Core/BAO/ConfigSetting.php index b17b6bd326..7882796e2c 100644 --- a/CRM/Core/BAO/ConfigSetting.php +++ b/CRM/Core/BAO/ConfigSetting.php @@ -360,7 +360,8 @@ class CRM_Core_BAO_ConfigSetting { $url = $dir = $siteName = $siteRoot = NULL; if ($config->userFramework == 'Joomla') { - $url = preg_replace('|administrator/components/com_civicrm/civicrm/|', + $url = preg_replace( + '|administrator/components/com_civicrm/civicrm/|', '', $config->userFrameworkResourceURL ); @@ -368,17 +369,41 @@ class CRM_Core_BAO_ConfigSetting { // lets use imageUploadDir since we dont mess around with its values // in the config object, lets kep it a bit generic since folks // might have different values etc - $dir = preg_replace('|civicrm/templates_c/.*$|', + $dir = preg_replace( + '|civicrm/templates_c/.*$|', '', $config->templateCompileDir ); - $siteRoot = preg_replace('|/media/civicrm/.*$|', + $siteRoot = preg_replace( + '|/media/civicrm/.*$|', + '', + $config->imageUploadDir + ); + } + else if ($config->userFramework == 'WordPress') { + $url = preg_replace( + '|wp-content/plugins/civicrm/civicrm/|', + '', + $config->userFrameworkResourceURL + ); + + // lets use imageUploadDir since we dont mess around with its values + // in the config object, lets kep it a bit generic since folks + // might have different values etc + $dir = preg_replace( + '|civicrm/templates_c/.*$|', + '', + $config->templateCompileDir + ); + $siteRoot = preg_replace( + '|/wp-content/plugins/files/civicrm/.*$|', '', $config->imageUploadDir ); } else { - $url = preg_replace('|sites/[\w\.\-\_]+/modules/civicrm/|', + $url = preg_replace( + '|sites/[\w\.\-\_]+/modules/civicrm/|', '', $config->userFrameworkResourceURL ); @@ -386,13 +411,15 @@ class CRM_Core_BAO_ConfigSetting { // lets use imageUploadDir since we dont mess around with its values // in the config object, lets kep it a bit generic since folks // might have different values etc - $dir = preg_replace('|/files/civicrm/.*$|', + $dir = preg_replace( + '|/files/civicrm/.*$|', '/files/', $config->imageUploadDir ); $matches = array(); - if (preg_match('|/sites/([\w\.\-\_]+)/|', + if (preg_match( + '|/sites/([\w\.\-\_]+)/|', $config->imageUploadDir, $matches )) { @@ -417,23 +444,28 @@ class CRM_Core_BAO_ConfigSetting { $url = $config->userFrameworkBaseURL; $siteName = $siteRoot = NULL; if ($config->userFramework == 'Joomla') { - $url = preg_replace('|/administrator|', + $url = preg_replace( + '|/administrator|', '', $config->userFrameworkBaseURL ); - $siteRoot = preg_replace('|/media/civicrm/.*$|', + $siteRoot = preg_replace( + '|/media/civicrm/.*$|', '', $config->imageUploadDir ); } - $dir = preg_replace('|civicrm/templates_c/.*$|', + + $dir = preg_replace( + '|civicrm/templates_c/.*$|', '', $config->templateCompileDir ); - if ($config->userFramework != 'Joomla') { + if ($config->userFramework->is_drupal) { $matches = array(); - if (preg_match('|/sites/([\w\.\-\_]+)/|', + if (preg_match( + '|/sites/([\w\.\-\_]+)/|', $config->templateCompileDir, $matches )) { diff --git a/templates/CRM/Admin/Form/Setting/UpdateConfigBackend.tpl b/templates/CRM/Admin/Form/Setting/UpdateConfigBackend.tpl index f99a32928c..5a264fbf25 100644 --- a/templates/CRM/Admin/Form/Setting/UpdateConfigBackend.tpl +++ b/templates/CRM/Admin/Form/Setting/UpdateConfigBackend.tpl @@ -29,8 +29,8 @@ {ts}Use this form if you need to reset the Base Directory Path and Base URL settings for your CiviCRM installation. These settings are stored in the database, and generally need adjusting after moving a CiviCRM installation to another location in the file system and/or to another URL.{/ts}

{ts}CiviCRM will attempt to detect the new values that should be used. These are provided below as the default values for the New Base Directory and New Base URL fields.{/ts}

- -
{$form._qf_UpdateConfigBackend_next_cleanup.html}
+ +
{$form._qf_UpdateConfigBackend_next_cleanup.html}
@@ -39,7 +39,7 @@ + {ts}For Drupal and WordPress installs, this is the absolute path to the location of the 'files' directory. For Joomla installs this is the absolute path to the location of the 'media' directory.{/ts} @@ -48,7 +48,7 @@ + {ts}This is the URL for your Drupal, Joomla or WordPress site (e.g. http://www.mysite.com/drupal/).{/ts} {if $oldSiteName} @@ -60,7 +60,7 @@ -{/if} +{/if}
{ts}Old Base Directory{/ts}
{$form.newBaseDir.label} {$form.newBaseDir.html|crmAddClass:'huge'}
- {ts}For Drupal installs, this is the absolute path to the location of the 'files' directory. For Joomla installs this is the absolute path to the location of the 'media' directory.{/ts}
{ts}Old Base URL{/ts}
{$form.newBaseURL.label} {$form.newBaseURL.html|crmAddClass:'huge'}
- {ts}This is the URL for your Drupal or Joomla site URL (e.g. http://www.mysite.com/drupal/).{/ts}
{$form.newSiteName.html|crmAddClass:'huge'}
{ts}This is the your site name for a multisite install.{/ts}
{include file="CRM/common/formButtons.tpl" location="bottom"}
-- 2.25.1