Merge remote-tracking branch 'upstream/4.3' into 4.3-master-2013-05-24-02-32-04
[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 * Determine the location of the CMS root.
92 *
93 * @return string|NULL local file system path to CMS root, or NULL if it cannot be determined
94 */
95 function cmsRootPath() {
96 return NULL;
97 }
98
99 /**
100 * Get user login URL for hosting CMS (method declared in each CMS system class)
101 *
102 * @param string $destination - if present, add destination to querystring (works for Drupal only)
103 *
104 * @return string - loginURL for the current CMS
105 * @static
106 */
107 public abstract function getLoginURL($destination = '');
108
109 /**
110 * Set a init session with user object
111 *
112 * @param array $data array with user specific data
113 *
114 * @access public
115 */
116 function setUserSession($data) {
117 list($userID, $ufID) = $data;
118 $session = CRM_Core_Session::singleton();
119 $session->set('ufID', $ufID);
120 $session->set('userID', $userID);
121 }
122
123 /**
124 * Reset any system caches that may be required for proper CiviCRM
125 * integration.
126 */
127 function flush() {
128 // nullop by default
129 }
130 }
131