Module: nagvis
Branch: master
Commit: fa5820db180070ffe0c69088167dddfc521617e7
URL:    
http://nagvis.git.sourceforge.net/git/gitweb.cgi?p=nagvis/nagvis;a=commit;h=fa5820db180070ffe0c69088167dddfc521617e7

Author: LaMi <[email protected]>
Date:   Sun Nov  8 14:54:45 2009 +0100

Reimplemented the search function in a new popup dialog

---

 .../nagvis-js/classes/FrontendModSearch.php        |   32 ++++++++++
 .../nagvis-js/classes/GlobalHeaderMenu.php         |    2 +-
 .../nagvis-js/classes/NagVisSearchView.php         |   60 ++++++++++++++++++++
 share/frontend/nagvis-js/index.php                 |    1 +
 share/frontend/nagvis-js/js/frontend.js            |   17 ++++++
 .../userfiles/templates/pages/default.header.html  |    2 +-
 .../userfiles/templates/pages/default.search.html  |    7 ++
 7 files changed, 119 insertions(+), 2 deletions(-)

diff --git a/share/frontend/nagvis-js/classes/FrontendModSearch.php 
b/share/frontend/nagvis-js/classes/FrontendModSearch.php
new file mode 100644
index 0000000..5fdceb9
--- /dev/null
+++ b/share/frontend/nagvis-js/classes/FrontendModSearch.php
@@ -0,0 +1,32 @@
+<?php
+class FrontendModSearch extends FrontendModule {
+       protected $CORE;
+       
+       public function __construct($CORE) {
+               $this->CORE = $CORE;
+               
+               $this->aActions = Array('view' => REQUIRES_AUTHORISATION);
+       }
+       
+       public function handleAction() {
+               $sReturn = '';
+               
+               if($this->offersAction($this->sAction)) {
+                       switch($this->sAction) {
+                               case 'view':
+                                       // Check if user is already 
authenticated
+                                       if(isset($this->AUTHENTICATION) && 
$this->AUTHENTICATION->isAuthenticated()) {
+                                               $VIEW = new 
NagVisSearchView($this->CORE);
+                                               $sReturn = 
json_encode(Array('code' => $VIEW->parse()));
+                                       } else {
+                                               $sReturn = '';
+                                       }
+                               break;
+                       }
+               }
+               
+               return $sReturn;
+       }
+}
+
+?>
diff --git a/share/frontend/nagvis-js/classes/GlobalHeaderMenu.php 
b/share/frontend/nagvis-js/classes/GlobalHeaderMenu.php
index df494b5..f05a183 100644
--- a/share/frontend/nagvis-js/classes/GlobalHeaderMenu.php
+++ b/share/frontend/nagvis-js/classes/GlobalHeaderMenu.php
@@ -251,6 +251,7 @@ class GlobalHeaderMenu {
        private function getStaticMacros() {
                // Replace paths and language macros
                $aReturn = Array('html_base' => $this->pathHtmlBase,
+                       'langSearch' => 
$this->CORE->getLang()->getText('Search'),
                        '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'),
@@ -266,7 +267,6 @@ class GlobalHeaderMenu {
                        'lang_online_doc' => 
$this->CORE->getLang()->getText('onlineDoc'),
                        'lang_forum' => 
$this->CORE->getLang()->getText('forum'),
                        'lang_support_info' => 
$this->CORE->getLang()->getText('supportInfo'),
-                       'lang_search' => 
$this->CORE->getLang()->getText('Search'),
                        'lang_overview' => 
$this->CORE->getLang()->getText('overview'),
                        'lang_instance' => 
$this->CORE->getLang()->getText('instance'),
                        'lang_logout' => 
$this->CORE->getLang()->getText('Logout'),
diff --git a/share/frontend/nagvis-js/classes/NagVisSearchView.php 
b/share/frontend/nagvis-js/classes/NagVisSearchView.php
new file mode 100644
index 0000000..951dca8
--- /dev/null
+++ b/share/frontend/nagvis-js/classes/NagVisSearchView.php
@@ -0,0 +1,60 @@
+<?php
+/*****************************************************************************
+ *
+ * NagVisSearchView.php - Class for handling the search dialog
+ *
+ * Copyright (c) 2004-2009 NagVis Project (Contact: [email protected])
+ *
+ * License:
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2 as
+ * published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ *
+ *****************************************************************************/
+ 
+/**
+ * @author     Lars Michelsen <[email protected]>
+ */
+class NagVisSearchView {
+       private $CORE;
+       
+       /**
+        * Class Constructor
+        *
+        * @param       GlobalCore      $CORE
+        * @author      Lars Michelsen <[email protected]>
+        */
+       public function __construct($CORE) {
+               $this->CORE = $CORE;
+       }
+       
+       /**
+        * Parses the information in html format
+        *
+        * @return      String  String with Html Code
+        * @author      Lars Michelsen <[email protected]>
+        */
+       public function parse() {
+               // Initialize template system
+               $TMPL = New FrontendTemplateSystem($this->CORE);
+               $TMPLSYS = $TMPL->getTmplSys();
+               
+               $aData = Array(
+                       'langSearch' => 
$this->CORE->getLang()->getText('Search')
+               );
+               
+               // Build page based on the template file and the data array
+               return $TMPLSYS->get($TMPL->getTmplFile('search'), $aData);
+       }
+}
+?>
diff --git a/share/frontend/nagvis-js/index.php 
b/share/frontend/nagvis-js/index.php
index 2740095..55c526f 100644
--- a/share/frontend/nagvis-js/index.php
+++ b/share/frontend/nagvis-js/index.php
@@ -103,6 +103,7 @@ $MHANDLER->regModule('Url');
 $MHANDLER->regModule('AutoMap');
 $MHANDLER->regModule('Overview');
 $MHANDLER->regModule('Rotation');
+$MHANDLER->regModule('Search');
 
 // Load the module
 $MODULE = $MHANDLER->loadModule($UHANDLER->get('mod'));
diff --git a/share/frontend/nagvis-js/js/frontend.js 
b/share/frontend/nagvis-js/js/frontend.js
index b1b00ca..d417793 100644
--- a/share/frontend/nagvis-js/js/frontend.js
+++ b/share/frontend/nagvis-js/js/frontend.js
@@ -88,6 +88,23 @@ function showChangePassword(sTitle) {
 }
 
 /**
+ * showSearch()
+ *
+ * Show the search dialog to the user
+ *
+ * @author  Lars Michelsen <[email protected]>
+ */
+function showSearch(sTitle) {
+       var oContent = 
getSyncRequest(oGeneralProperties.path_base+'/frontend/nagvis-js/index.php?mod=Search&act=view',
 true, false);
+       
+       if(typeof oContent !== 'undefined') {
+               popupWindow(sTitle, oContent, true);
+       }
+       
+       oContent = null;
+}
+
+/**
  * searchObjectsKeyCheck()
  *
  * Checks the keys which are entered to the object search field
diff --git a/share/userfiles/templates/pages/default.header.html 
b/share/userfiles/templates/pages/default.header.html
index 01ce17a..e621710 100644
--- a/share/userfiles/templates/pages/default.header.html
+++ b/share/userfiles/templates/pages/default.header.html
@@ -20,7 +20,7 @@
                        <dd id="action-ddcontent" 
onmouseover="cancelHide('action')" onmouseout="ddMenu('action',-1)">
                                <ul>
                                        {if $view_type == 'Map' || $view_type 
== 'Automap'}
-                                       <li><a href="">{$lang_search}</a></li>
+                                       <li><a 
href="javascript:showSearch('{$langSearch}')">{$langSearch}</a></li>
                                        {/if}
                                        {if $bRotation == true}
                                        <li id="rotationStart" 
style="display:none"><a 
href="javascript:switchRotation()">{$lang_rotation_start}</a></li>
diff --git a/share/userfiles/templates/pages/default.search.html 
b/share/userfiles/templates/pages/default.search.html
new file mode 100644
index 0000000..5cd89f8
--- /dev/null
+++ b/share/userfiles/templates/pages/default.search.html
@@ -0,0 +1,7 @@
+<div id="search">
+<label>{$langSearch}<br />
+       <input type="text" name="highlightInput" id="highlightInput" 
onkeypress="searchObjectsKeyCheck(this.value, event)" /></label>
+</div>
+<script type="text/javascript">
+try\{document.getElementById('highlightInput').focus();}catch(e)\{}
+</script>
\ No newline at end of file


------------------------------------------------------------------------------
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

Reply via email to