29 define(
'ROOTPATH', __DIR__);
30 require_once(ROOTPATH .
'/vendor/bmlt/bmlt-satellite-base-class/bmlt-cms-satellite-plugin.php');
34 if (isset($_COOKIE) && isset($_COOKIE[
'bmlt_lang_selector']) && $_COOKIE[
'bmlt_lang_selector']) {
40 if (function_exists(
'i18n_get_lang')) {
41 $language = i18n_get_lang();
64 class BMLTDrupalPlugin
extends BMLTPlugin
70 public $local_strings = array (
'en' => array (
71 'list_text' =>
'Substitute the BMLT shortcodes or HTML comments with instances of the BMLT',
72 'add_instance' =>
'Add a BMLT instance inline in text.',
73 'bmlt' =>
'Basic Meeting List Toolbox',
74 'bmlt_settings' =>
'BMLT Settings',
75 'describe_admin' =>
'Configure the BMLT Settings',
76 'access_admin' =>
'access administration pages' 83 public function __construct()
85 parent::__construct();
94 protected function get_admin_ajax_base_uri()
97 return $this->get_ajax_base_uri().
'?q=admin/settings/bmlt';
106 protected function get_admin_form_uri()
109 return $this->get_admin_ajax_base_uri();
118 protected function get_ajax_base_uri()
124 $from_proxy = array_key_exists(
"HTTP_X_FORWARDED_PROTO", $_SERVER);
129 $https = $_SERVER[
'HTTP_X_FORWARDED_PROTO'] ==
'https';
130 if (array_key_exists(
"HTTP_X_FORWARDED_PORT", $_SERVER)) {
131 $port = intval($_SERVER[
'HTTP_X_FORWARDED_PORT']);
138 $port = $_SERVER[
'SERVER_PORT'];
140 $https = (!empty($_SERVER[
'HTTPS']) && (($_SERVER[
'HTTPS'] !==
'off') || ($port == 443)));
143 $server_path = $_SERVER[
'SERVER_NAME'];
144 $my_path = $_SERVER[
'PHP_SELF'];
145 $server_path .= trim((($https && ($port != 443)) || (!$https && ($port != 80))) ?
':'.$port :
'',
'/');
146 $server_path =
'http'.($https ?
's' :
'').
'://'.$server_path.$my_path;
156 protected function get_plugin_path()
159 if (function_exists(
'drupal_get_path')) {
162 $ret = $base_url.
'/'.drupal_get_path(
'module',
'bmlt').
'/vendor/bmlt/bmlt-satellite-base-class/';
164 $ret = isset($this->my_http_vars[
'base_url']) ? $this->my_http_vars[
'base_url'] : null;
179 public function process_text( $in_string
183 if (function_exists(
't')) {
184 $in_string = htmlspecialchars(t($in_string));
186 echo
"<!-- BMLTPlugin Warning (process_text): t() does not exist! -->";
198 protected function cms_get_option( $in_option_key
204 $row = unserialize(variable_get(
'bmlt_settings', serialize(array ( 0 => $this->geDefaultBMLTOptions() ))));
206 if ($in_option_key != self::$admin2OptionsName) {
207 $index = max(1, intval(str_replace(self::$adminOptionsName.
'_',
'', $in_option_key)));
209 $ret = isset($row[$index - 1]) ? $row[$index - 1] : $defaults[$index - 1];
211 $ret = array (
'num_servers' => count($row) );
221 protected function cms_set_option(
230 if ($in_option_key != self::$admin2OptionsName) {
231 $index = max(1, intval(str_replace(self::$adminOptionsName.
'_',
'', $in_option_key)));
233 $row_data = unserialize(variable_get(
'bmlt_settings', serialize(array ( 0 => $this->geDefaultBMLTOptions() ))));
235 if (isset($row_data) && is_array($row_data) && count($row_data)) {
236 $row_data[$index - 1] = $in_option_value;
238 variable_set(
'bmlt_settings', serialize($row_data));
253 protected function cms_delete_option( $in_option_key
259 $row = unserialize(variable_get(
'bmlt_settings', serialize(array ( 0 => $this->geDefaultBMLTOptions() ))));
260 if ($in_option_key != self::$admin2OptionsName) {
261 $index = max(1, intval(str_replace(self::$adminOptionsName.
'_',
'', $in_option_key)));
263 unset($row[$index - 1]);
265 if (variable_set(
'bmlt_settings', serialize($row))) {
279 protected function cms_get_post_meta(
298 protected function cms_get_page_settings_id(
300 $in_check_mobile =
false 303 $my_option_id = parent::cms_get_page_settings_id($in_text, $in_check_mobile);
305 if (!$in_check_mobile && !$my_option_id) {
306 $options = $this->getBMLTOptions(1);
307 $my_option_id = $options[
'id'];
310 return $my_option_id;
321 public function admin_page()
324 echo $this->return_admin_page();
334 public function option_menu()
337 if (function_exists(
'add_options_page') && (self::get_plugin_object() instanceof BMLTPlugin)) {
338 add_options_page(self::$local_options_title, self::$local_menu_string, 9, basename(__FILE__), array ( self::get_plugin_object(),
'admin_page' ));
339 } elseif (!function_exists(
'add_options_page')) {
340 echo
"<!-- BMLTPlugin ERROR (option_menu)! No add_options_page()! -->";
342 echo
"<!-- BMLTPlugin ERROR (option_menu)! No BMLTPlugin Object! -->";
350 public function standard_head( $in_text = null
356 $additional_stuff =
"<!-- Added by the BMLT plugin 3.X. -->\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=EmulateIE7\" />\n<meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />\n<meta http-equiv=\"Content-Script-Type\" content=\"text/javascript\" />\n";
358 $support_mobile = $this->cms_get_page_settings_id($in_text,
true);
360 if ($support_mobile) {
361 $mobile_options = $this->getBMLTOptions_by_id($support_mobile);
363 $support_mobile = null;
366 $options = $this->getBMLTOptions_by_id($this->cms_get_page_settings_id($in_text));
367 if ($support_mobile && is_array($mobile_options) && count($mobile_options)) {
368 $mobile_url = $_SERVER[
'PHP_SELF'].
'?BMLTPlugin_mobile&bmlt_settings_id='.$support_mobile;
369 if (isset($this->my_http_vars[
'WML'])) {
370 $mobile_url .=
'&WML='.intval($this->my_http_vars[
'WML']);
372 if (isset($this->my_http_vars[
'simulate_smartphone'])) {
373 $mobile_url .=
'&simulate_smartphone';
376 if (isset($this->my_http_vars[
'base_url'])) {
377 $mobile_url .=
'&base_url='.urlencode($this->my_http_vars[
'base_url']);
379 $mobile_url .=
'&base_url='.urlencode($this->get_plugin_path());
383 header(
"location: $mobile_url");
387 $this->load_params();
389 $root_server_root = $options[
'root_server'];
391 $additional_stuff .=
'<meta name="BMLT-Root-URI" content="'.htmlspecialchars($root_server_root).
'" />';
393 if ($root_server_root) {
394 $root_server = $root_server_root.
"/client_interface/xhtml/index.php";
396 $additional_css =
'.bmlt_container * {margin:0;padding:0 }';
398 $temp = self::stripFile(
"nouveau_map_styles.css");
400 $additional_css .=
"\t$temp\n";
403 $temp = self::stripFile(
"table_styles.css");
405 $additional_css .=
"\t$temp\n";
408 $temp = self::stripFile(
"styles.css", $options[
'theme']);
410 $image_dir_path = $this->get_plugin_path() .
'/themes/' . $options[
'theme'] .
'/images/';
411 $temp = str_replace(
'##-IMAGEDIR-##', $image_dir_path, $temp);
412 $additional_css .=
"\t$temp\n";
415 $temp = self::stripFile(
"nouveau_map_styles.css", $options[
'theme']);
417 $image_dir_path = $this->get_plugin_path() .
'/themes/' . $options[
'theme'] .
'/images/';
418 $temp = str_replace(
'##-IMAGEDIR-##', $image_dir_path, $temp);
419 $additional_css .=
"\t$temp\n";
422 $temp = self::stripFile(
"quicksearch.css");
424 $additional_css .=
"\t$temp\n";
427 $dirname = dirname(__FILE__) .
'/vendor/bmlt/bmlt-satellite-base-class/themes';
428 $dir =
new DirectoryIterator($dirname);
430 foreach ($dir as $fileinfo) {
431 if (!$fileinfo->isDot()) {
432 $fName = $fileinfo->getFilename();
434 $temp = self::stripFile(
"table_styles.css", $fName);
436 $image_dir_path = $this->get_plugin_path() .
'/themes/' . $fName .
'/images/';
437 $temp = str_replace(
'##-IMAGEDIR-##', $image_dir_path, $temp);
438 $additional_css .=
"\t$temp\n";
441 $temp = self::stripFile(
"quicksearch.css", $fName);
443 $additional_css .=
"\t$temp\n";
448 $temp = self::stripFile(
"responsiveness.css");
450 $additional_css .=
"\t$temp\n";
453 if ($options[
'additional_css']) {
454 $additional_css .= $options[
'additional_css'];
457 if ($additional_css) {
458 $additional_stuff .=
'<style type="text/css">'.preg_replace(
"|\s+|",
" ", $additional_css).
'</style>';
461 $additional_stuff .=
'<script type="text/javascript">';
463 $additional_stuff .= self::stripFile(
'javascript.js');
465 if ($this->get_shortcode($in_text,
'bmlt_quicksearch')) {
466 $additional_stuff .= self::stripFile(
'quicksearch.js') . (defined(
'_DEBUG_MODE_') ?
"\n" :
'');
469 if ($this->get_shortcode($in_text,
'bmlt_map')) {
470 $additional_stuff .= self::stripFile(
'map_search.js');
473 if ($this->get_shortcode($in_text,
'bmlt_mobile')) {
474 $additional_stuff .= self::stripFile(
'fast_mobile_lookup.js');
477 $additional_stuff .=
'</script>';
479 if ($additional_stuff) {
480 if (function_exists(
'drupal_set_html_head')) {
481 drupal_set_html_head($additional_stuff);
482 } elseif (function_exists(
'drupal_add_html_head')) {
485 '#markup' => $additional_stuff
487 drupal_add_html_head($element,
'bmlt');
497 public function admin_head()
500 $head_content =
"<!-- Added by the BMLT plugin 3.0. -->\n<meta http-equiv=\"X-UA-Compatible\" content=\"IE=EmulateIE7\" />\n<meta http-equiv=\"Content-Style-Type\" content=\"text/css\" />\n<meta http-equiv=\"Content-Script-Type\" content=\"text/javascript\" />\n";
501 $head_content .=
'<script type="text/javascript">';
503 $head_content .= self::stripFile(
'javascript.js');
505 $head_content .=
'</script>';
507 $options = $this->getBMLTOptions(1);
508 $key = $options[
'google_api_key'];
510 $head_content .=
'<script type="text/javascript" src="https://maps.google.com/maps/api/js?key='.$key.
'"></script>';
512 $head_content .=
'<link rel="stylesheet" type="text/css" href="';
514 $url = $this->get_plugin_path();
516 $head_content .= htmlspecialchars($url);
518 if (!defined(
'_DEBUG_MODE_')) {
519 $head_content .=
'style_stripper.php?filename=';
522 $head_content .=
'admin_styles.css" />';
524 $head_content .=
'<script type="text/javascript" src="';
526 $head_content .= htmlspecialchars($url);
528 if (!defined(
'_DEBUG_MODE_')) {
529 $head_content .=
'js_stripper.php?filename=';
532 $head_content .=
'admin_javascript.js"></script>';
534 if (function_exists(
'drupal_set_html_head')) {
535 drupal_set_html_head($head_content);
536 } elseif (function_exists(
'drupal_add_html_head')) {
539 '#markup' => $head_content
541 drupal_add_html_head($element,
'bmlt');
549 global $BMLTPluginOp;
551 if (!isset($BMLTPluginOp) && class_exists(
"BMLTDrupalPlugin")) {
552 $BMLTPluginOp =
new BMLTDrupalPlugin();
global $bmlt_localization
Use this to control the localization.