| 165 | | * |
| 166 | | * @return void |
| 167 | | */ |
| 168 | | public function appendContent($display_area, $content) { |
| 169 | | if (!isset ($this->contentArray[$display_area])) { |
| 170 | | throw new exception(sprintf(_('%s is not a valid structural display area'), $display_area)); |
| 171 | | } |
| 172 | | $this->contentArray[$display_area] .= $content; |
| | 166 | * |
| | 167 | * @param integer $display_order_index The order in which the content should |
| | 168 | * be displayed |
| | 169 | * |
| | 170 | * @return void |
| | 171 | */ |
| | 172 | public function addContent($displayArea, $content, $displayOrderIndex = 1) { |
| | 173 | //echo "MainUI::addContent(): Debug: displayArea: $displayArea, displayOrderIndex: $displayOrderIndex, content: $content<br/>"; |
| | 174 | if (!isset ($this->_contentDisplayArray[$displayArea])) { |
| | 175 | throw new exception(sprintf(_('%s is not a valid structural display area'), $displayArea)); |
| | 176 | } |
| | 177 | $this->_contentArray[] = array ('display_area' => $displayArea, 'display_order' => $displayOrderIndex, 'content' => $content); |
| | 178 | } |
| | 179 | |
| | 180 | /** Private compare function for sorting the _contentArray() */ |
| | 181 | private static function _contentArrayCmp($a, $b) { |
| | 182 | if ($a['display_order'] == $b['display_order']) { |
| | 183 | return 0; |
| | 184 | } |
| | 185 | return ($a['display_order'] < $b['display_order']) ? -1 : 1; |
| | 186 | } |
| | 187 | |
| | 188 | /** |
| | 189 | * Orders the content and put it in the _contentDisplayArray array |
| | 190 | * |
| | 191 | * @return void |
| | 192 | */ |
| | 193 | private function generateDisplayContent() { |
| | 194 | //pretty_print_r($this->_contentArray); |
| | 195 | usort($this->_contentArray, array ('MainUI', '_contentArrayCmp')); |
| | 196 | foreach ($this->_contentArray as $content_fragment) { |
| | 197 | $this->_contentDisplayArray[$content_fragment['display_area']] .= $content_fragment['content']; |
| | 198 | } |
| | 199 | |
| | 200 | } |
| | 201 | |
| | 202 | /** |
| | 203 | * Add the content marked "everywhere" from both the current node and the |
| | 204 | * current network. |
| | 205 | * |
| | 206 | * @return void |
| | 207 | */ |
| | 208 | private function addEverywhereContent() { |
| | 209 | global $db; |
| | 210 | // Get all network content and node "everywhere" content |
| | 211 | $content_rows = null; |
| | 212 | $network_id = $db->escapeString(Network :: getCurrentNetwork()->getId()); |
| | 213 | $sql_network = "(SELECT content_id, display_area, display_order, subscribe_timestamp FROM network_has_content WHERE network_id='$network_id' AND display_page='everywhere') "; |
| | 214 | $node = Node :: getCurrentNode(); |
| | 215 | $sql_node = null; |
| | 216 | if ($node) { |
| | 217 | // Get all node content |
| | 218 | $node_id = $db->escapeString($node->getId()); |
| | 219 | $sql_node = "UNION (SELECT content_id, display_area, display_order, subscribe_timestamp FROM node_has_content WHERE node_id='$node_id' AND display_page='everywhere')"; |
| | 220 | } |
| | 221 | $sql = "SELECT * FROM ($sql_network $sql_node) AS content_everywhere ORDER BY display_area, display_order, subscribe_timestamp DESC"; |
| | 222 | |
| | 223 | $db->execSql($sql, $content_rows, false); |
| | 224 | if ($content_rows) { |
| | 225 | foreach ($content_rows as $content_row) { |
| | 226 | $content = Content :: getObject($content_row['content_id']); |
| | 227 | if ($content->isDisplayableAt($node)) { |
| | 228 | $this->addContent($content_row['display_area'], $content->getUserUI(), $content_row['display_order']); |
| | 229 | } |
| | 230 | } |
| | 231 | } |
| | 232 | |
| | 233 | } |
| | 234 | |
| | 235 | /** |
| | 236 | * Check if the tool section is enabled |
| | 237 | * |
| | 238 | * @return bool True or false |
| | 239 | * |
| | 240 | * @access public |
| | 241 | */ |
| | 242 | public function isToolSectionEnabled() { |
| | 243 | return $this->_toolSectionEnabled; |
| 356 | | // Set section of Smarty template |
| 357 | | $this->smarty->assign('sectionSTART', true); |
| 358 | | |
| 359 | | // Get information about user |
| 360 | | $_currentUser = User :: getCurrentUser(); |
| 361 | | |
| 362 | | User::assignSmartyValues($this->smarty, $_currentUser); |
| 363 | | |
| 364 | | $this->smarty->assign('logoutParameters', ""); |
| 365 | | $this->smarty->assign('loginParameters', ""); |
| 366 | | $this->smarty->assign('formAction', ""); |
| 367 | | $this->smarty->assign('toolContent', ""); |
| 368 | | $this->smarty->assign('accountInformation', ""); |
| 369 | | $this->smarty->assign('techSupportInformation', ""); |
| 370 | | $this->smarty->assign('shrinkLeftArea', $this->shrink_left_area); |
| 371 | | |
| 372 | | // Provide Smarty with information about the network |
| 373 | | Network::assignSmartyValues($this->smarty); |
| 374 | | |
| 375 | | /* |
| 376 | | * Provide Smarty information about the user's login/logout status |
| 377 | | */ |
| 378 | | |
| 379 | | if ($_currentUser != null) { |
| 380 | | // User is logged in |
| 381 | | |
| 382 | | // Detect gateway information |
| 383 | | $_gwId = $session->get(SESS_GW_ID_VAR); |
| 384 | | $_gwAddress = $session->get(SESS_GW_ADDRESS_VAR); |
| 385 | | $_gwPort = $session->get(SESS_GW_PORT_VAR); |
| 386 | | |
| 387 | | // If gateway information could be detected tell them Smarty |
| 388 | | if ($_gwId && $_gwAddress && $_gwPort) { |
| 389 | | $this->smarty->assign('logoutParameters', "&gw_id=".$_gwId."&gw_address=".$_gwAddress."&gw_port=".$_gwPort); |
| 390 | | } |
| 391 | | } else { |
| 392 | | // Detect gateway information |
| 393 | | $_gwId = !empty ($_REQUEST['gw_id']) ? $_REQUEST['gw_id'] : $session->get(SESS_GW_ID_VAR); |
| 394 | | $_gwAddress = !empty ($_REQUEST['gw_address']) ? $_REQUEST['gw_address'] : $session->get(SESS_GW_ADDRESS_VAR); |
| 395 | | $_gwPort = !empty ($_REQUEST['gw_port']) ? $_REQUEST['gw_port'] : $session->get(SESS_GW_PORT_VAR); |
| 396 | | |
| 397 | | // If gateway information could be detected tell them Smarty |
| 398 | | if (!empty ($_gwId) && !empty ($_gwAddress) && !empty ($_gwPort)) { |
| 399 | | $this->smarty->assign('loginParameters', "?gw_id=".$_gwId."&gw_address=".$_gwAddress."&gw_port=".$_gwPort); |
| 400 | | } |
| 401 | | } |
| 402 | | |
| 403 | | /* |
| 404 | | * Provide Smarty information for the language chooser |
| 405 | | */ |
| 406 | | |
| 407 | | // Assign the action URL for the form |
| 408 | | $this->smarty->assign('formAction', $_SERVER['REQUEST_URI']); |
| 409 | | |
| 410 | | foreach ($AVAIL_LOCALE_ARRAY as $_langIds => $_langNames) { |
| 411 | | if (Locale :: getCurrentLocale()->getId() == $_langIds) { |
| 412 | | $_selected = ' selected="selected"'; |
| 413 | | } else { |
| 414 | | $_selected = ""; |
| 415 | | } |
| 416 | | |
| 417 | | $_languageChooser[] = '<option label="'.$_langNames.'" value="'.$_langIds.'"'.$_selected.'>'.$_langNames.'</option>'; |
| 418 | | } |
| 419 | | |
| 420 | | // Provide Smarty all available languages |
| 421 | | $this->smarty->assign('languageChooser', $_languageChooser); |
| 422 | | |
| 423 | | /* |
| 424 | | * Provide Smarty information for the language chooser |
| 425 | | */ |
| 426 | | |
| 427 | | // Provide information |
| 428 | | $this->smarty->assign('accountInformation', sprintf(_("Accounts on %s are and will stay completely free."), Network :: getCurrentNetwork()->getName())); |
| 429 | | $this->smarty->assign('techSupportInformation', sprintf(_("Please inform us of any problem or service interruption at: %s"), '<a href="mailto:'.Network :: getCurrentNetwork()->getTechSupportEmail().'">'.Network :: getCurrentNetwork()->getTechSupportEmail().'</a>')); |
| 430 | | |
| 431 | | // Compile HTML code |
| 432 | | $_html = $this->smarty->fetch("templates/classes/MainUI_ToolContent.tpl"); |
| 433 | | |
| | 417 | // Set section of Smarty template |
| | 418 | $this->smarty->assign('sectionSTART', true); |
| | 419 | |
| | 420 | // Get information about user |
| | 421 | $_currentUser = User :: getCurrentUser(); |
| | 422 | |
| | 423 | User :: assignSmartyValues($this->smarty, $_currentUser); |
| | 424 | |
| | 425 | $this->smarty->assign('logoutParameters', ""); |
| | 426 | $this->smarty->assign('loginParameters', ""); |
| | 427 | $this->smarty->assign('formAction', ""); |
| | 428 | $this->smarty->assign('toolContent', ""); |
| | 429 | $this->smarty->assign('accountInformation', ""); |
| | 430 | $this->smarty->assign('techSupportInformation', ""); |
| | 431 | $this->smarty->assign('shrinkLeftArea', $this->_shrinkLeftArea); |
| | 432 | |
| | 433 | // Provide Smarty with information about the network |
| | 434 | Network :: assignSmartyValues($this->smarty); |
| | 435 | |
| | 436 | /* |
| | 437 | * Provide Smarty information about the user's login/logout status |
| | 438 | */ |
| | 439 | |
| | 440 | if ($_currentUser != null) { |
| | 441 | // User is logged in |
| | 442 | |
| | 443 | // Detect gateway information |
| | 444 | $_gwId = $session->get(SESS_GW_ID_VAR); |
| | 445 | $_gwAddress = $session->get(SESS_GW_ADDRESS_VAR); |
| | 446 | $_gwPort = $session->get(SESS_GW_PORT_VAR); |
| | 447 | |
| | 448 | // If gateway information could be detected tell them Smarty |
| | 449 | if ($_gwId && $_gwAddress && $_gwPort) { |
| | 450 | $this->smarty->assign('logoutParameters', "&gw_id=".$_gwId."&gw_address=".$_gwAddress."&gw_port=".$_gwPort); |
| | 451 | } |
| | 452 | } |
| | 453 | else { |
| | 454 | // Detect gateway information |
| | 455 | $_gwId = !empty ($_REQUEST['gw_id']) ? $_REQUEST['gw_id'] : $session->get(SESS_GW_ID_VAR); |
| | 456 | $_gwAddress = !empty ($_REQUEST['gw_address']) ? $_REQUEST['gw_address'] : $session->get(SESS_GW_ADDRESS_VAR); |
| | 457 | $_gwPort = !empty ($_REQUEST['gw_port']) ? $_REQUEST['gw_port'] : $session->get(SESS_GW_PORT_VAR); |
| | 458 | |
| | 459 | // If gateway information could be detected tell them Smarty |
| | 460 | if (!empty ($_gwId) && !empty ($_gwAddress) && !empty ($_gwPort)) { |
| | 461 | $this->smarty->assign('loginParameters', "?gw_id=".$_gwId."&gw_address=".$_gwAddress."&gw_port=".$_gwPort); |
| | 462 | } |
| | 463 | } |
| | 464 | |
| | 465 | /* |
| | 466 | * Provide Smarty information for the language chooser |
| | 467 | */ |
| | 468 | |
| | 469 | // Assign the action URL for the form |
| | 470 | $this->smarty->assign('formAction', $_SERVER['REQUEST_URI']); |
| | 471 | |
| | 472 | foreach ($AVAIL_LOCALE_ARRAY as $_langIds => $_langNames) { |
| | 473 | if (Locale :: getCurrentLocale()->getId() == $_langIds) { |
| | 474 | $_selected = ' selected="selected"'; |
| | 475 | } |
| | 476 | else { |
| | 477 | $_selected = ""; |
| | 478 | } |
| | 479 | |
| | 480 | $_languageChooser[] = '<option label="'.$_langNames.'" value="'.$_langIds.'"'.$_selected.'>'.$_langNames.'</option>'; |
| | 481 | } |
| | 482 | |
| | 483 | // Provide Smarty all available languages |
| | 484 | $this->smarty->assign('languageChooser', $_languageChooser); |
| | 485 | |
| | 486 | /* |
| | 487 | * Provide Smarty information for the language chooser |
| | 488 | */ |
| | 489 | |
| | 490 | // Provide information |
| | 491 | $this->smarty->assign('accountInformation', sprintf(_("Accounts on %s are and will stay completely free."), Network :: getCurrentNetwork()->getName())); |
| | 492 | $this->smarty->assign('techSupportInformation', sprintf(_("Please inform us of any problem or service interruption at: %s"), '<a href="mailto:'.Network :: getCurrentNetwork()->getTechSupportEmail().'">'.Network :: getCurrentNetwork()->getTechSupportEmail().'</a>')); |
| | 493 | |
| | 494 | // Compile HTML code |
| | 495 | $_html = $this->smarty->fetch("templates/classes/MainUI_ToolContent.tpl"); |
| | 496 | |
| 547 | | static public function redirect($redirect_url, $redirect_to_title=null, $timeout=60) { |
| 548 | | if (!$redirect_to_title) { |
| 549 | | $network = Network :: getCurrentNetwork(); |
| 550 | | $redirect_to_title = $network ? sprintf(_("%s Login"), $network->getName()) : _("Login"); |
| 551 | | } |
| 552 | | |
| 553 | | header("Location: $redirect_url"); |
| 554 | | echo "<html>\n" . |
| 555 | | "<head><meta http-equiv='Refresh' content='$timeout; URL=$redirect_url'/></head>\n". |
| 556 | | "<body>\n" . |
| 557 | | "<noscript>\n" . |
| 558 | | "<span style='display:none;'>\n" . |
| 559 | | "<h1>" . $redirect_to_title . "</h1>\n" . |
| 560 | | sprintf(_("Click <a href='%s'>here</a> to continue"), $redirect_url) . "<br/>\n" . |
| 561 | | _("The transfer from secure login back to regular http may cause a warning.") . "\n" . |
| 562 | | "</span>\n" . |
| 563 | | "</noscript>\n" . |
| 564 | | "</body>\n" . |
| 565 | | "</html>\n" |
| 566 | | ; |
| 567 | | exit; |
| 568 | | } |
| 569 | | |
| 570 | | public function customBanner() { |
| 571 | | $custom_banner = ''; |
| 572 | | |
| 573 | | return $custom_banner; |
| 574 | | } |
| | 614 | static public function redirect($redirect_url, $redirect_to_title = null, $timeout = 60) { |
| | 615 | if (!$redirect_to_title) { |
| | 616 | $network = Network :: getCurrentNetwork(); |
| | 617 | $redirect_to_title = $network ? sprintf(_("%s Login"), $network->getName()) : _("Login"); |
| | 618 | } |
| | 619 | |
| | 620 | header("Location: $redirect_url"); |
| | 621 | echo "<html>\n"."<head><meta http-equiv='Refresh' content='$timeout; URL=$redirect_url'/></head>\n"."<body>\n"."<noscript>\n"."<span style='display:none;'>\n"."<h1>".$redirect_to_title."</h1>\n".sprintf(_("Click <a href='%s'>here</a> to continue"), $redirect_url)."<br/>\n"._("The transfer from secure login back to regular http may cause a warning.")."\n"."</span>\n"."</noscript>\n"."</body>\n"."</html>\n"; |
| | 622 | exit; |
| | 623 | } |
| | 624 | |
| | 625 | public function customBanner() { |
| | 626 | $custom_banner = ''; |
| | 627 | |
| | 628 | return $custom_banner; |
| | 629 | } |