Skip to content
Snippets Groups Projects
Unverified Commit 5c84abc3 authored by DaveD's avatar DaveD Committed by GitHub
Browse files

Merge pull request #25329 from herbdool/core-4076

#4076 split up the theme method
parents 7a345a8d 0fec25d1
Branches
Tags
No related merge requests found
......@@ -1157,4 +1157,33 @@ AND u.status = 1
return $text;
}
/**
* @inheritdoc
*/
public function theme(&$content, $print = FALSE, $maintenance = FALSE) {
$ret = FALSE;
if (!$print) {
if ($maintenance) {
backdrop_set_breadcrumb('');
backdrop_maintenance_theme();
if ($region = CRM_Core_Region::instance('html-header', FALSE)) {
CRM_Utils_System::addHTMLHead($region->render(''));
}
print theme('maintenance_page', ['content' => $content]);
exit();
}
$ret = TRUE;
}
$out = $content;
if ($ret) {
return $out;
}
else {
print $out;
return NULL;
}
}
}
......@@ -274,55 +274,8 @@ abstract class CRM_Utils_System_Base {
* @todo Better to always return, and never print.
*/
public function theme(&$content, $print = FALSE, $maintenance = FALSE) {
$ret = FALSE;
// TODO: Split up; this was copied verbatim from CiviCRM 4.0's multi-UF theming function
// but the parts should be copied into cleaner subclass implementations
$config = CRM_Core_Config::singleton();
if (
$config->userSystem->is_drupal &&
function_exists('theme') &&
!$print
) {
if ($maintenance) {
drupal_set_breadcrumb('');
drupal_maintenance_theme();
if ($region = CRM_Core_Region::instance('html-header', FALSE)) {
CRM_Utils_System::addHTMLHead($region->render(''));
}
print theme('maintenance_page', ['content' => $content]);
exit();
}
// TODO: Figure out why D7 returns but everyone else prints
$ret = TRUE;
}
$out = $content;
if (
!$print &&
CRM_Core_Config::singleton()->userFramework == 'WordPress'
) {
if (!function_exists('is_admin')) {
throw new \Exception('Function "is_admin()" is missing, even though WordPress is the user framework.');
}
if (!defined('ABSPATH')) {
throw new \Exception('Constant "ABSPATH" is not defined, even though WordPress is the user framework.');
}
if (is_admin()) {
require_once ABSPATH . 'wp-admin/admin-header.php';
}
else {
// FIXME: we need to figure out to replace civicrm content on the frontend pages
}
}
if ($ret) {
return $out;
}
else {
print $out;
return NULL;
}
print $content;
return NULL;
}
/**
......
......@@ -892,4 +892,33 @@ AND u.status = 1
return $text;
}
/**
* @inheritdoc
*/
public function theme(&$content, $print = FALSE, $maintenance = FALSE) {
$ret = FALSE;
if (!$print) {
if ($maintenance) {
drupal_set_breadcrumb('');
drupal_maintenance_theme();
if ($region = CRM_Core_Region::instance('html-header', FALSE)) {
CRM_Utils_System::addHTMLHead($region->render(''));
}
print theme('maintenance_page', ['content' => $content]);
exit();
}
$ret = TRUE;
}
$out = $content;
if ($ret) {
return $out;
}
else {
print $out;
return NULL;
}
}
}
......@@ -915,4 +915,14 @@ class CRM_Utils_System_Drupal8 extends CRM_Utils_System_DrupalBase {
return '<p><strong>' . ts('To enable CiviCRM Views integration, install the <a %1>CiviCRM Entity</a> module.', [1 => 'href="https://www.drupal.org/project/civicrm_entity"']) . '</strong></p>';
}
/**
* @inheritdoc
*/
public function theme(&$content, $print = FALSE, $maintenance = FALSE) {
// @todo use Drupal "maintenance page" template and theme during installation
// or upgrade.
print $content;
return NULL;
}
}
......@@ -1631,4 +1631,27 @@ class CRM_Utils_System_WordPress extends CRM_Utils_System_Base {
return TRUE;
}
/**
* @inheritdoc
*/
public function theme(&$content, $print = FALSE, $maintenance = FALSE) {
if (!$print) {
if (!function_exists('is_admin')) {
throw new \Exception('Function "is_admin()" is missing, even though WordPress is the user framework.');
}
if (!defined('ABSPATH')) {
throw new \Exception('Constant "ABSPATH" is not defined, even though WordPress is the user framework.');
}
if (is_admin()) {
require_once ABSPATH . 'wp-admin/admin-header.php';
}
else {
// FIXME: we need to figure out to replace civicrm content on the frontend pages
}
}
print $content;
return NULL;
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment