Commit e51744f5 authored by lobo's avatar lobo

CRM-12674

----------------------------------------
* CRM-12674: WordPress updateConfigBackend is confused about URL
  http://issues.civicrm.org/jira/browse/CRM-12674
parent 17fb9e92
......@@ -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();
......
......@@ -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
)) {
......
......@@ -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}</p>
<p>
{ts}CiviCRM will attempt to detect the new values that should be used. These are provided below as the default values for the <strong>New Base Directory</strong> and <strong>New Base URL</strong> fields.{/ts}</p>
</div>
<div>{$form._qf_UpdateConfigBackend_next_cleanup.html}</div>
</div>
<div>{$form._qf_UpdateConfigBackend_next_cleanup.html}</div>
<table>
<tr class="crm-config-backend-form-block-oldBaseDir">
<td class="label">{ts}Old Base Directory{/ts}</td>
......@@ -39,7 +39,7 @@
<tr class="crm-config-backend-form-block-newBaseDir">
<td class="label">{$form.newBaseDir.label}</td>
<td>{$form.newBaseDir.html|crmAddClass:'huge'}<br />
<span class="description">{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}</span></td>
<span class="description">{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}</span></td>
</tr>
<tr class="crm-config-backend-form-block-oldBaseURL">
<td class="label">{ts}Old Base URL{/ts}</td>
......@@ -48,7 +48,7 @@
<tr class="crm-config-backend-form-block-newBaseURL">
<td class="label">{$form.newBaseURL.label}</td>
<td>{$form.newBaseURL.html|crmAddClass:'huge'}<br />
<span class="description">{ts}This is the URL for your Drupal or Joomla site URL (e.g. http://www.mysite.com/drupal/).{/ts}</span></td>
<span class="description">{ts}This is the URL for your Drupal, Joomla or WordPress site (e.g. http://www.mysite.com/drupal/).{/ts}</span></td>
</tr>
{if $oldSiteName}
<tr class="crm-config-backend-form-block-oldSiteName">
......@@ -60,7 +60,7 @@
<td>{$form.newSiteName.html|crmAddClass:'huge'}<br />
<span class="description">{ts}This is the your site name for a multisite install.{/ts}</span></td>
</tr>
{/if}
{/if}
</table>
<div>{include file="CRM/common/formButtons.tpl" location="bottom"}</div>
<div class="spacer"></div>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment