$template->assign('tplFile', 'CRM/Profile/Form/Edit.tpl');
$profile = trim($template->fetch('CRM/Form/default.tpl'));
- // not sure how to circumvent our own navigation system to generate the right form url
- $urlReplaceWith = 'civicrm/profile/create&gid=' . $gid . '&reset=1';
- if ($config->userSystem->is_drupal && $config->cleanURL) {
- $urlReplaceWith = 'civicrm/profile/create?gid=' . $gid . '&reset=1';
- }
- $profile = str_replace('civicrm/admin/uf/group', $urlReplaceWith, $profile);
-
- // FIXME: (CRM-3587) hack to make standalone profile work
- // in wordpress and joomla without administrator login
- if ($config->userFramework == 'Joomla') {
- $profile = str_replace('/administrator/', '/index.php', $profile);
- }
- elseif ($config->userFramework == 'WordPress') {
- //@todo remove this part when it is OK to deprecate CIVICRM_UF_WP_BASEPAGE-CRM-15933
- if (defined('CIVICRM_UF_WP_BASEPAGE')) {
- $wpbase = CIVICRM_UF_WP_BASEPAGE;
- }
- elseif (!empty($config->wpBasePage)) {
- $wpbase = $config->wpBasePage;
- }
- else {
- $wpbase = 'index.php';
- }
- $profile = str_replace('/wp-admin/admin.php', '/' . $wpbase . '/', $profile);
- }
+ $profile = $config->userSystem->modifyStandaloneProfile($profile, ['gid' => $gid]);
// add header files
CRM_Core_Resources::singleton()->addCoreResources('html-header');
return $contactParameters;
}
+ /**
+ * Modify standalone profile
+ *
+ * @param string $profile
+ * @param array $params
+ *
+ * @return string
+ */
+ public function modifyStandaloneProfile($profile, $params):string {
+ // Not sure how to circumvent our own navigation system to generate the
+ // right form url.
+ $urlReplaceWith = 'civicrm/profile/create&gid=' . $params['gid'] . '&reset=1';
+ $profile = str_replace('civicrm/admin/uf/group', $urlReplaceWith, $profile);
+
+ return $profile;
+ }
+
}
return $contactParameters;
}
+ /**
+ * @inheritdoc
+ */
+ public function modifyStandaloneProfile($profile, $params):string {
+ $config = CRM_Core_Config::singleton();
+ $urlReplaceWith = 'civicrm/profile/create&gid=' . $params['gid'] . '&reset=1';
+ if ($config->cleanURL) {
+ $urlReplaceWith = 'civicrm/profile/create?gid=' . $params['gid'] . '&reset=1';
+ }
+ $profile = str_replace('civicrm/admin/uf/group', $urlReplaceWith, $profile);
+
+ return $profile;
+ }
+
}
return $contactParameters;
}
+ /**
+ * @inheritdoc
+ */
+ public function modifyStandaloneProfile($profile, $params):string {
+ $urlReplaceWith = 'civicrm/profile/create&gid=' . $params['gid'] . '&reset=1';
+ $profile = str_replace('civicrm/admin/uf/group', $urlReplaceWith, $profile);
+
+ // FIXME: (CRM-3587) hack to make standalone profile work
+ // in Joomla without administrator login.
+ $profile = str_replace('/administrator/', '/index.php', $profile);
+ return $profile;
+ }
+
}
return $contactParameters;
}
+ /**
+ * @inheritdoc
+ */
+ public function modifyStandaloneProfile($profile, $params):string {
+ $urlReplaceWith = 'civicrm/profile/create&gid=' . $params['gid'] . '&reset=1';
+ $profile = str_replace('civicrm/admin/uf/group', $urlReplaceWith, $profile);
+
+ //@todo remove this part when it is OK to deprecate CIVICRM_UF_WP_BASEPAGE-CRM-15933
+ $config = CRM_Core_Config::singleton();
+ if (defined('CIVICRM_UF_WP_BASEPAGE')) {
+ $wpbase = CIVICRM_UF_WP_BASEPAGE;
+ }
+ elseif (!empty($config->wpBasePage)) {
+ $wpbase = $config->wpBasePage;
+ }
+ else {
+ $wpbase = 'index.php';
+ }
+ $profile = str_replace('/wp-admin/admin.php', '/' . $wpbase . '/', $profile);
+ return $profile;
+ }
+
}