Module: nagvis Branch: master Commit: 68f7503fa5f7d024f60b4df5829be736c1a28577 URL: http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=68f7503fa5f7d024f60b4df5829be736c1a28577
Author: LaMi <[email protected]> Date: Sun Nov 8 13:31:10 2009 +0100 Rotation enabling/disabling is now working again --- .../frontend/nagvis-js/classes/FrontendModMap.php | 6 +++ .../nagvis-js/classes/GlobalHeaderMenu.php | 44 ++++++++++++------- share/frontend/nagvis-js/js/nagvis.js | 46 +++++++------------- .../userfiles/templates/pages/default.header.html | 4 +- 4 files changed, 52 insertions(+), 48 deletions(-) diff --git a/share/frontend/nagvis-js/classes/FrontendModMap.php b/share/frontend/nagvis-js/classes/FrontendModMap.php index 1e487e9..aaa3106 100644 --- a/share/frontend/nagvis-js/classes/FrontendModMap.php +++ b/share/frontend/nagvis-js/classes/FrontendModMap.php @@ -63,6 +63,12 @@ class FrontendModMap extends FrontendModule { if($MAPCFG->getValue('global',0 ,'header_menu')) { // Parse the header menu $HEADER = new GlobalHeaderMenu($this->CORE, $this->AUTHORISATION, $MAPCFG->getValue('global',0 ,'header_template'), $MAPCFG); + + // Put rotation information to header menu + if($this->rotation != '') { + $HEADER->setRotationEnabled(); + } + $INDEX->setHeaderMenu($HEADER->__toString()); } diff --git a/share/frontend/nagvis-js/classes/GlobalHeaderMenu.php b/share/frontend/nagvis-js/classes/GlobalHeaderMenu.php index 6fec9a2..df494b5 100644 --- a/share/frontend/nagvis-js/classes/GlobalHeaderMenu.php +++ b/share/frontend/nagvis-js/classes/GlobalHeaderMenu.php @@ -37,6 +37,7 @@ class GlobalHeaderMenu { private $pathTemplateFile; private $aMacros = Array(); + private $bRotation = false; /** * Class Constructor @@ -59,9 +60,31 @@ class GlobalHeaderMenu { // Read the contents of the template file $this->checkTemplateReadable(1); - - // The static macros should be replaced before caching + } + + /** + * PUBLIC setRotationEnabled() + * + * Tells the header menu that the current view is rotating + * + * @author Lars Michelsen <[email protected]> + */ + public function setRotationEnabled() { + $this->bRotation = true; + } + + /** + * Print the HTML code + * + * return String HTML Code + * @author Lars Michelsen <[email protected]> + */ + public function __toString() { + // Get all macros $this->getMacros(); + + // Build page based on the template file and the data array + return $this->TMPLSYS->get($this->TMPL->getTmplFile('header'), $this->aMacros); } /** @@ -83,8 +106,8 @@ class GlobalHeaderMenu { $this->aMacros['view_type'] = 'Automap'; } - // FIXME: In rotation? - $this->aMacros['bRotation'] = false; + // In rotation? + $this->aMacros['bRotation'] = $this->bRotation; // Check if the user is permitted to edit the current map/automap if(isset($this->aMacros['view_type']) && $this->CORE->getAuthorization() !== null && $this->CORE->getAuthorization()->isPermitted($this->aMacros['view_type'], 'edit', $this->OBJPAGE->getName())) { @@ -227,7 +250,7 @@ class GlobalHeaderMenu { */ private function getStaticMacros() { // Replace paths and language macros - $aReturn = Array('html_base' => $this->pathHtmlBase, + $aReturn = Array('html_base' => $this->pathHtmlBase, 'html_images' => $this->CORE->getMainCfg()->getValue('paths','htmlimages'), 'html_templates' => $this->CORE->getMainCfg()->getValue('paths','htmlpagetemplates'), 'html_template_images' => $this->CORE->getMainCfg()->getValue('paths','htmlheadertemplateimages'), @@ -254,17 +277,6 @@ class GlobalHeaderMenu { } /** - * Print the HTML code - * - * return String HTML Code - * @author Lars Michelsen <[email protected]> - */ - public function __toString () { - // Build page based on the template file and the data array - return $this->TMPLSYS->get($this->TMPL->getTmplFile('header'), $this->aMacros); - } - - /** * Checks for existing header template * * @param Boolean $printErr diff --git a/share/frontend/nagvis-js/js/nagvis.js b/share/frontend/nagvis-js/js/nagvis.js index 2f09096..abffd9d 100644 --- a/share/frontend/nagvis-js/js/nagvis.js +++ b/share/frontend/nagvis-js/js/nagvis.js @@ -379,7 +379,7 @@ function updateWorkerCounter() { */ function rotatePage() { if(oRotationProperties.nextStepUrl !== '') { - if(oRotationProperties.rotationEnabled) { + if(oRotationProperties.rotationEnabled == true) { window.open(oRotationProperties.nextStepUrl, "_self"); return true; } @@ -397,7 +397,9 @@ function rotatePage() { * @author Lars Michelsen <[email protected]> */ function rotationCountdown() { - if(oRotationProperties.nextStepTime && oRotationProperties.nextStepTime !== '') { + // Only proceed with counting when rotation is enabled and the next step time + // has a proper value + if(oRotationProperties.rotationEnabled && oRotationProperties.rotationEnabled == true && oRotationProperties.nextStepTime && oRotationProperties.nextStepTime !== '') { // Countdown one second oRotationProperties.nextStepTime -= 1; @@ -444,18 +446,14 @@ function getUrlParam(name) { * * @author Lars Michelsen <[email protected]> */ -function setRotationLabel(startLabel,stopLabel) { - var oRotationSwitch = document.getElementById('rotationSwitch'); - if(getUrlParam('rotation') === '') { - oRotationSwitch.style.visibility = 'hidden'; +function setRotationLabel() { + if(oRotationProperties.rotationEnabled == true) { + document.getElementById('rotationStart').style.display = 'none'; + document.getElementById('rotationStop').style.display = 'inline'; } else { - if(oRotationProperties.rotationEnabled == 1) { - oRotationSwitch.innerHTML = stopLabel; - } else { - oRotationSwitch.innerHTML = startLabel; - } + document.getElementById('rotationStart').style.display = 'inline'; + document.getElementById('rotationStop').style.display = 'none'; } - oRotationSwitch = null; } /** @@ -463,27 +461,15 @@ function setRotationLabel(startLabel,stopLabel) { * * @author Lars Michelsen <[email protected]> */ -function switchRotation(obj, startLabel, stopLabel) { - if(oRotationProperties.rotationEnabled) { +function switchRotation() { + if(oRotationProperties.rotationEnabled == true) { oRotationProperties.rotationEnabled = false; - setRotationLabel(startLabel, stopLabel); + + setRotationLabel(); } else { oRotationProperties.rotationEnabled = true; - setRotationLabel(startLabel, stopLabel); - } -} - -// FIXME: Not needed in 1.5 anymore, maybe remove? -function changeMap(htmlBase, mapName) { - if(mapName.match('^automap=')) { - mapName = mapName.replace(/automap=/, ''); - location.href=htmlBase+'/frontend/nagvis-js/index.php?mod=AutoMap&act=view&show=' + mapName; - } else { - if (mapName === '') { - location.href=htmlBase+'/frontend/nagvis-js/index.php'; - } else { - location.href=htmlBase+'/frontend/nagvis-js/index.php?mod=Map&act=view&show=' + mapName; - } + + setRotationLabel(); } } diff --git a/share/userfiles/templates/pages/default.header.html b/share/userfiles/templates/pages/default.header.html index 9be93ef..01ce17a 100644 --- a/share/userfiles/templates/pages/default.header.html +++ b/share/userfiles/templates/pages/default.header.html @@ -23,7 +23,8 @@ <li><a href="">{$lang_search}</a></li> {/if} {if $bRotation == true} - <li><a href="">{$lang_rotation_start} / {$lang_rotation_stop}</a></li> + <li id="rotationStart" style="display:none"><a href="javascript:switchRotation()">{$lang_rotation_start}</a></li> + <li id="rotationStop" style="display:inline"><a href="javascript:switchRotation()">{$lang_rotation_stop}</a></li> {/if} {if $view_type == 'Map' && $permitted_edit == true} <li><a href="{$html_base}/frontend/wui/index.php?map={$current_map}" class="underline">{$lang_edit_map}</a></li> @@ -69,4 +70,3 @@ </li> </ul> </div> -<script type="text/javascript">setRotationLabel('{$lang_rotation_start}','{$lang_rotation_stop}');</script> ------------------------------------------------------------------------------ Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day trial. Simplify your report design, integration and deployment - and focus on what you do best, core application coding. Discover what's new with Crystal Reports now. http://p.sf.net/sfu/bobj-july _______________________________________________ Nagvis-checkins mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/nagvis-checkins
