Merge branch 'CRM-13014' of git://github.com/eileenmcnaughton/civicrm-core into pull...
[civicrm-core.git] / CRM / Utils / System / Base.php
1 <?php
2
3 /**
4 * Base class for UF system integrations
5 */
6 abstract class CRM_Utils_System_Base {
7 var $is_drupal = FALSE;
8 var $is_joomla = FALSE;
9 var $is_wordpress = FALSE;
10
11 /*
12 * Does the CMS allow CMS forms to be extended by hooks
13 */
14 var $supports_form_extensions = FALSE;
15
16 /**
17 * if we are using a theming system, invoke theme, else just print the
18 * content
19 *
20 * @param string $content the content that will be themed
21 * @param boolean $print are we displaying to the screen or bypassing theming?
22 * @param boolean $maintenance for maintenance mode
23 *
24 * @return void prints content on stdout
25 * @access public
26 */
27 function theme(&$content, $print = FALSE, $maintenance = FALSE) {
28 $ret = FALSE;
29
30 // TODO: Split up; this was copied verbatim from CiviCRM 4.0's multi-UF theming function
31 // but the parts should be copied into cleaner subclass implementations
32 if (function_exists('theme') && !$print) {
33 if ($maintenance) {
34 drupal_set_breadcrumb('');
35 drupal_maintenance_theme();
36 if ($region = CRM_Core_Region::instance('html-header', FALSE)) {
37 CRM_Utils_System::addHTMLHead($region->render(''));
38 }
39 print theme('maintenance_page', array('content' => $content));
40 exit();
41 }
42 $ret = TRUE; // TODO: Figure out why D7 returns but everyone else prints
43 }
44 $out = $content;
45
46 $config = &CRM_Core_Config::singleton();
47 if (!$print &&
48 $config->userFramework == 'WordPress'
49 ) {
50 if (is_admin()) {
51 require_once (ABSPATH . 'wp-admin/admin-header.php');
52 }
53 else {
54 // FIX ME: we need to figure out to replace civicrm content on the frontend pages
55 }
56 }
57
58 if ($ret) {
59 return $out;
60 }
61 else {
62 print $out;
63 }
64 }
65
66 function getDefaultBlockLocation() {
67 return 'left';
68 }
69
70 function getVersion() {
71 return 'Unknown';
72 }
73
74 /**
75 * Format the url as per language Negotiation.
76 *
77 * @param string $url
78 *
79 * @return string $url, formatted url.
80 * @static
81 */
82 function languageNegotiationURL(
83 $url,
84 $addLanguagePart = TRUE,
85 $removeLanguagePart = FALSE
86 ) {
87 return $url;
88 }
89
90 /*
91 * Currently this is just helping out the test class as defaults is calling it - maybe move fix to defaults
92 */
93 function cmsRootPath() {
94 }
95
96 /**
97 * Get user login URL for hosting CMS (method declared in each CMS system class)
98 *
99 * @param string $destination - if present, add destination to querystring (works for Drupal only)
100 *
101 * @return string - loginURL for the current CMS
102 * @static
103 */
104 public abstract function getLoginURL($destination = '');
105
106 /**
107 * Set a init session with user object
108 *
109 * @param array $data array with user specific data
110 *
111 * @access public
112 */
113 function setUserSession($data) {
114 list($userID, $ufID) = $data;
115 $session = CRM_Core_Session::singleton();
116 $session->set('ufID', $ufID);
117 $session->set('userID', $userID);
118 }
119
120 /**
121 * Reset any system caches that may be required for proper CiviCRM
122 * integration.
123 */
124 function flush() {
125 // nullop by default
126 }
127
128 /**
129 * Perform any post login activities required by the CMS -
130 * e.g. for drupal: records a watchdog message about the new session, saves the login timestamp,
131 * calls hook_user op 'login' and generates a new session.
132 *
133 * @param array params
134 *
135 * FIXME: Document values accepted/required by $params
136 */
137 function userLoginFinalize($params = array()){
138 }
139 }
140