NCCOOS Trac Projects: Top | Web | Platforms | Processing | Viz | Sprints | Sandbox | (Wind)

root/Chameleon/trunk/Chameleon/ExpressionBuilder/ExpressionBuilder.phtml

Revision 13 (checked in by jcleary, 17 years ago)

Latest Chameleon code checkout from previous repository

Line 
1 <?php
2 /**
3  * @project     Chameleon
4  * @revision    $Id: ExpressionBuilder.phtml,v 1.4 2004/12/03 03:31:53 pspencer Exp $
5  * @purpose     This the main user interface page for the expression builder
6  *              widget.
7  * @author      William A. Bronsema, C.E.T. (dev@dmsolutions.ca)
8  * @copyright
9  * <b>Copyright (c) 2003, DM Solutions Group Inc.</b>
10  * Permission is hereby granted, free of charge, to any person obtaining a
11  * copy of this software and associated documentation files (the "Software"),
12  * to deal in the Software without restriction, including without limitation
13  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14  * and/or sell copies of the Software, and to permit persons to whom the
15  * Software is furnished to do so, subject to the following conditions:
16  *
17  * The above copyright notice and this permission notice shall be included
18  * in all copies or substantial portions of the Software.
19  *
20  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
23  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
25  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
26  * DEALINGS IN THE SOFTWARE.
27  **/
28  
29 // include the supporting php functions
30 include( "./ExpressionBuilder.php" );
31 ?>
32 <html>
33 <head>
34 <title><?php echo $oMLT->get("0", "Build Expression") ?></title>
35 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
36 <link rel="stylesheet" type="text/css" href=" <?php echo $szCSSFile ?> ">
37 <style type="text/css">
38 <!-- .exprList {
39     font-family: Arial, Helvetica, sans-serif;
40     font-size: 11px;
41     width: 200px;
42 }
43 .helpArea2
44 {
45     font-family: Arial, Helvetica, sans-serif;
46     font-size: 12px;
47     color: #666666;
48     background-color: #FFFFFF;
49     border: 1px solid #666666;
50     width: 250px;
51     text-align: left;
52 }
53 .deleteall
54 /* Defines the style of text labels.
55    - Basic useage sets the size, colour and font of any labels of input
56        elements. */
57 {
58     font-family: Arial, Helvetica, sans-serif;
59     font-size: 8px;
60     color: #ff0000;
61 }
62 .bboxonly
63 /* Defines the style of text labels.
64    - Basic useage sets the size, colour and font of any labels of input
65        elements. */
66 {
67     font-family: Arial, Helvetica, sans-serif;
68     font-size: 9px;
69     color: #000000;
70 }-->
71 </style>
72 <script language="javascript" src="../js/expressionBuilder.js" type="text/javascript"></script>
73 <script language="JavaScript" src="<?php echo $_SESSION['gszCoreWebPath']; ?>/widgets/js/cwc_dhtml.js" type="text/javascript"></script>
74 <script language="JavaScript" src="<?php echo $_SESSION['gszCoreWebPath']; ?>/widgets/js/cwc_button.js" type="text/javascript"></script>
75 <script language="javascript" type="text/javascript">
76 <?php
77 // init flag
78 $bSuppressAlerts = false;
79
80 // close window is requested
81 if ( isset( $_FORM['txtCloseWindow'] ) && $_FORM['txtCloseWindow'] == 1 )
82 {
83     echo 'window.close();';
84 }
85
86 // check selected count and give meassage
87 if ( $nCount <= 0 )
88 {
89     // give message
90     echo "alert('".$oMLT->get("1", "There is no active layer selected.  You must select a layer inorder to use this tool." )."');";
91      
92     // set flag
93     $bSuppressAlerts = true;
94    
95     // exit
96     echo "window.close();";
97 }
98
99 // give a warning message
100 elseif ( $nCount > 1 )
101 {
102     // give message
103     echo "alert('".$oMLT->get("2", "More than one layer has been selected.  Only the `%1\$s` layer will be processed.", array( $szSelectedLayerName ) )."');";
104 }
105
106 // give notice that errors occurred and the process cannot continue
107 if ( strlen( $szErrorNotice ) > 0 && !$bSuppressAlerts )
108 {
109     // give message
110     echo "alert('".$szErrorNotice."');";
111    
112     // exit
113     echo "window.close();";
114 }
115 ?>
116
117 // set flag to save changes
118 var bSaveRequired = false;
119
120 // set widget type based on input
121 var szWidgetType = "<?php echo "WFS" ?>";
122
123 // add the like properties to javascript vars
124 var szWildCard = "<?php echo LIKE_WILDCARD ?>";
125 var szSingleChar = "<?php echo LIKE_SINGLECHAR ?>";
126 var szEscapeChar = "<?php echo LIKE_ESCAPECHAR ?>";
127
128 // set the javascript variables for translation
129 var szLang15 = '<?php echo $oMLT->get("15", "Invalid character found.  The \" character is not allowed in filter expressions.") ?>';
130 var szLang16 = '<?php echo $oMLT->get("16", "Your expression does not make sense.  The two selected expressions are equal.") ?>';
131 var szLang17 = '<?php echo $oMLT->get("17", "Please select an expression before continuing.") ?>';
132 var szLang18 = '<?php echo $oMLT->get("18", "The `LIKE` operator may not be used in a complex expression in conjunction with the `AND` operator.  Only the `OR` operator may be used.") ?>';
133 var szLang19 = '<?php echo $oMLT->get("19", "Only 1 instance of the `LIKE` operator may used in a complex expression.") ?>';
134
135 function selectAttribute()
136 {
137     // update the attribute testbox with the current selected attribute
138     //document.forms[0].txtAttributeLabel.value = document.forms[0].selField.selected.text;
139     for (var i = 0; i < document.forms[0].selField.length; i++)
140     {
141         if ( document.forms[0].selField.options[i].selected == true )
142         {
143             // set label
144             document.forms[0].butPickAttribute.value =
145                 reduceString( document.forms[0].selField.options[i].value, 15 );
146                
147             // hide pick box
148             setLayerVis('attribute_layer', false );
149                
150             // return
151             return null;
152         }
153     }
154    
155     // return
156     return null;
157 }
158
159 function reduceString( szString, nSize )
160 {
161     // limit size to at least 3
162     if ( nSize < 3 )
163         nSize = 3;
164    
165     // check if length is already less than size
166     if ( szString.length <= nSize )
167         return szString;
168     else
169     {
170         // reduce to size and add "..."
171         return szString.substr( 0, nSize - 3 ) + "...";
172     }   
173 }
174
175 function doneLoading()
176 {
177     // select the first item in the attribute list
178     if( document.forms[0].selField.length > 0 )
179         document.forms[0].selField.options[0].selected = true;
180    
181     // update the attribute text button
182     selectAttribute();
183    
184     // give self focus
185     window.focus();
186 }
187
188 function showAttributes()
189 {
190     // get info on image placeholder
191     var oImage = getImageObj( "imgSpacer2" );
192     var xPos = findObjectPosX( oImage ) + 5;
193     var yPos = findObjectPosY( oImage );
194    
195     // position the attribute list
196     setLayerPos( "attribute_layer", xPos, yPos );
197    
198     // toggle visibility
199     toggleLayerVis( 'attribute_layer' );
200    
201     // return void
202     return;
203 }
204
205 function closeBuilder()
206 {
207     // check if save is required
208     if ( bSaveRequired )
209     {
210         // give the user an option
211         if ( !confirm('<?php echo $oMLT->get("24",'Save changes before closing?' )?>') )
212         {
213             window.close();
214             return null;
215         }
216        
217         // save changes
218         saveExpressions();
219        
220         // close window
221         window.close();
222        
223     }
224     else
225         window.close();
226        
227     // return
228     return null;
229 }
230
231 function saveExpressions()
232 {
233     // send command to update the opener
234     window.opener.saveExpressions( document.forms[0].txtLayerIndex.value, document.forms[0].txtExpressions.value );
235    
236     // reset flag
237     bSaveRequired = false;
238 }
239
240 </script>
241 </head>
242 <body class="page" onload="javascript:doneLoading()">
243 <form method="POST">
244 <table border="0" cellpadding="1" cellspacing="10">
245   <tr>
246     <td colspan="2" class="layoutTable">
247       <table class="titleArea" width="100%" border="0" cellpadding="4" cellspacing="0">
248         <tr>
249           <td><span class="title"><?php echo $oMLT->get("3", "Selected Layer") ?></span></td>
250         </tr>
251       </table>
252       <table class="contentArea" width="100%" border="0" cellpadding="4" cellspacing="0">
253         <tr>
254           <td valign="top"><span class="label"><?php echo $oMLT->get('32', 'Name') ?>: <b><?php echo $szSelectedLayerName?></b></span></td>
255           <?php echo $szLayerTypeHTML ?>
256         </tr>
257       </table>   
258     </td>
259   </tr>
260   <?php
261   // show styles if a choice is necessary
262   if ( isset( $szStyleForm ) )
263     echo $szStyleForm;
264   ?>
265   <tr>
266     <td colspan="2" class="layoutTable" valign="top">
267       <table class="titleArea" width="100%" border="0" cellpadding="4" cellspacing="0">
268         <tr>
269           <td><span class="title"><?php echo $oMLT->get("4", "Build & Select Expression") ?></span></td>
270         </tr>
271       </table>   
272       <table class="contentArea" width="100%"  border="0" cellpadding="4" cellspacing="0">
273         <tr>
274           <td align="center" colspan="3" valign="top"><p class="helpArea"><?php echo $oMLT->get("5", "In this section you can build either simple or complex expressions.  Complex expressions can be made by combining simple and/or complex expressions.  Inorder to create a complex expression at least two expressions must exist.") ?></p></td>
275           <td rowspan="3">
276             <table border="0" cellpadding="0" cellspacing="0">
277               <tr>
278                 <td><span class="label"><?php echo $oMLT->get("6", "User Defined Expressions") ?>:</span></td>
279                 <td align="right"><span class="deleteall"><a href="javascript:deleteAllExpressions()"><?php echo $oMLT->get("7", "delete all") ?></a></span></td>
280               </tr>
281               <tr>
282                 <td colspan="2"><select name="selExpressions" size="8" class="exprList" onchange="javascript:updateDetails()"></select></td>
283               </tr>
284             </table></td>
285         </tr>
286         <tr>
287           <td colspan="2" valign="top" height="40"><div id="simple_expression" style="position:absolute">
288   <table>
289     <tr>
290       <td valign="top"><span class="label"><?php echo $oMLT->get("9", "Simple Expression") ?> | <a href="javascript:showExpressionTab(1)"><?php echo $oMLT->get("10", "Complex Expression") ?></a></span><br>
291         <table border="0" align="left" width="0" cellpadding="1" cellspacing="0">
292           <tr>
293             <td valign="top"><input type="button" name="butPickAttribute" value="" onclick="javascript:showAttributes()"></td>
294             <td valign="top">
295               <select name="selOperator" class="inputList" onchange="javascript:checkBetween();checkLikeHelp()" onblur="setLayerVis('attribute_layer', false );">
296                 <option value="=">=</option>
297                 <option value="!=">!=</option>
298                 <option value="<">&lt;</option>
299                 <option value="<=">&lt;=</option>
300                 <option value=">">&gt;</option>
301                 <option value=">=">&gt;=</option>
302                 <option value="LIKE">LIKE</option>
303                 <option value="BETWEEN">BETWEEN</option>
304               </select></td>
305             <td align="center" valign="top"><input type="textbox" name="txtValue1" value="" class="inputBox" size="15"><div id="extra_between"><span class="label"><br>and<br></span><input type="textbox" name="txtValue2" value="" class="inputBox" size="15"></div></td>
306           </tr>
307         </table></td>
308     </tr>
309   </table>
310 </div><div id="complex_expression" style="position:absolute">
311   <table>
312     <tr>
313       <td colspan="2" valign="top" nowrap><span class="label"><a href="javascript:showExpressionTab(0)"><?php echo $oMLT->get("9", "Simple Expression") ?></a> | <?php echo $oMLT->get("10", "Complex Expression") ?></span><br>
314         <table border="0" align="left" width="0" cellpadding="1" cellspacing="0">
315           <tr>
316             <td>
317               <select name="selCompExpression1" class="inputList">
318               </select></td>
319             <td>
320               <select name="selAndOr" class="inputList">
321                 <option value="AND">AND</option>
322                 <option value="OR">OR</option>
323              </select></td>
324             <td>
325               <select name="selNot" class="inputList">
326                 <option value="" selected></option>
327                 <option value="NOT">NOT</option>
328              </select></td>
329             <td>
330               <select name="selCompExpression2" class="inputList">
331               </select></td>
332           </tr>
333         </table></td>
334     </tr>
335   </table>
336 </div></td>
337           <td align="right" valign="middle" rowspan="2"><input type="button" name="butAdd" value="<?php echo $oMLT->get("14", "Add") ?> >>" onmouseup="javascript:addExpression(document.forms[0].txtExpressionType.value, document.forms[0].selField.value, document.forms[0].selOperator.value, document.forms[0].txtValue1.value, document.forms[0].txtValue2.value, document.forms[0].selAndOr.value, document.forms[0].selNot.value, document.forms[0].selCompExpression1.value, document.forms[0].selCompExpression2.value)"></td>
338         </tr>
339         <tr>
340           <td colspan="2" valign="top" height="50"><img src="../../images/a_pixel.gif" name="imgSpacer2" width="10" height="50"></td>
341         </tr>
342       </table></td>
343   </tr>
344   <tr>
345     <td colspan="2" class="layoutTable">
346       <table class="titleArea" width="100%" border="0" cellpadding="4" cellspacing="0">
347         <tr>
348           <td><span class="title"><?php echo $oMLT->get("8", "Selected Expression") ?></span></td>
349         </tr>
350       </table>
351       <table class="contentArea" width="100%" border="0" cellpadding="4" cellspacing="0">
352         <tr>
353           <td align="center"><textarea name="txtExpressionDetails" rows="5" cols="70" class="inputBox" readonly></textarea></td>
354           <td>
355             <table border="0" cellpadding="0" cellspacing="0">
356               <tr>
357                 <td><input type="checkbox" name="chkBBOnly"><span class="bboxonly"><?php echo $oMLT->get('23', 'Bounding Box Only (ignore expression)') ?></span></td>
358               </tr>
359               <tr>
360                 <td><input type="checkbox" name="chkApplyToMap" checked><span class="bboxonly"><?php echo $oMLT->get('27', 'Apply filter to map') ?></span></td>
361               </tr>
362             </table>
363           </td>
364         </tr>
365       </table>   
366     </td>
367   </tr> 
368   <tr>
369     <td>
370       <?php echo makeButton( 'saveExpressions', '', 'ExpressionBuilder', "icons/icon_save.png", $oMLT->get('25', 'Save'), $oMLT->get('26', 'Save Expressions'), array( 'width' => 75) ); ?>
371     </td>
372     <td align="right">
373       <?php echo makeButton( 'execute', '', 'ExpressionBuilder', "icons/icon_ok.png", $oCommonMLT->get("Apply", "Apply"), $oCommonMLT->get("ApplyTip", "Apply"), array( 'width' => 75) ); ?>
374       <?php echo makeButton( 'closeBuilder', '', 'ExpressionBuilder', "icons/icon_cancel.png", $oCommonMLT->get("Close", "Close"), $oCommonMLT->get("CloseTip", "Close Dialog"), array( 'width' => 75) ); ?>
375     </td>
376   </tr>
377 </table>
378 <!--  HIDDEN VARIABLES -->
379 <input type="hidden" name="txtExpressionType" value="0">
380 <input type="hidden" name="txtLayerIndex" value="">
381 <input type="hidden" name="txtCloseWindow" value="">
382 <input type="hidden" name="txtSaveExpressions" value="">
383 <input type="hidden" name="sid" value="<?php echo session_id() ?>">
384 <input type="hidden" name="selectedlayers" value="<?php echo $szSelectedLayerName ?>">
385 <input type="hidden" name="txtExpressions" value="">
386 <input type="hidden" name="txtWMSConnection" value="<?php echo $szWFSConnection ?>">
387
388 <!--  ATTRIBUTE LAYER -->
389 <div id="attribute_layer" style="position:absolute">
390   <select name="selField" class="inputList" size="5" onchange="javascript:selectAttribute();" onblur="setLayerVis('attribute_layer', false );">
391     <?php echo $szAttributeOptions ?>
392   </select>
393 </div>
394
395 <!-- LIKE-HELP LAYER -->
396 <div id="like_help" style="position:absolute">
397   <table>
398     <tr>
399       <td>
400         <p class="helpArea2">&nbsp;<?php echo $oMLT->get("11", "For a wild card use") ?>:&nbsp;&nbsp;&nbsp;" <?php echo LIKE_WILDCARD ?> "<br>
401                              &nbsp;<?php echo $oMLT->get("12", "For a single char use") ?>:&nbsp;&nbsp;&nbsp;" <?php echo LIKE_SINGLECHAR ?> "<br>
402                              &nbsp;<?php echo $oMLT->get("13", "For an escape char use") ?>:&nbsp;&nbsp;&nbsp;" <?php echo LIKE_ESCAPECHAR ?> "</p>
403       </td>
404     </tr>
405   </table>
406 </div>
407
408 <script language="javascript" type="text/javascript">
409   // hide the attribute selector
410   setLayerVis('attribute_layer', false );
411
412   // show the simple expressions tab
413   showExpressionTab(0);
414  
415   // hide the extra textbox for the between
416   checkBetween();
417  
418   // hide/position the help layer for the LIKE opertator
419   checkLikeHelp();
420    
421   // set z-index of attributes
422   var oLayer = getLayerObj( "attribute_layer" );
423   oLayer.zIndex=999;
424  
425   // set the layer index
426   document.forms[0].txtLayerIndex.value = "<?php echo $nSelectedLayer ?>";
427
428 <?php 
429 // load any saved expressions
430 if ( isset( $szJavascriptExpressions ) )
431 {
432     echo $szJavascriptExpressions;
433    
434     // reset save flag
435     echo 'bSaveRequired = false';
436 }
437 ?>
438 </script>
439 </form>
440 </body>
441 </html>
Note: See TracBrowser for help on using the browser.