[Jaws-commits] r9750 - in branches/0.8/jaws/html/gadgets/UrlMapper: . resources

afz at jaws-project.com afz at jaws-project.com
Fri Oct 31 17:02:12 UTC 2008


Author: afz
Date: 2008-10-31 17:02:12 +0000 (Fri, 31 Oct 2008)
New Revision: 9750

Modified:
   branches/0.8/jaws/html/gadgets/UrlMapper/AdminAjax.php
   branches/0.8/jaws/html/gadgets/UrlMapper/AdminHTML.php
   branches/0.8/jaws/html/gadgets/UrlMapper/AdminModel.php
   branches/0.8/jaws/html/gadgets/UrlMapper/resources/script.js
Log:
Update UrlMapper gadget

Modified: branches/0.8/jaws/html/gadgets/UrlMapper/AdminAjax.php
===================================================================
--- branches/0.8/jaws/html/gadgets/UrlMapper/AdminAjax.php	2008-10-31 17:00:39 UTC (rev 9749)
+++ branches/0.8/jaws/html/gadgets/UrlMapper/AdminAjax.php	2008-10-31 17:02:12 UTC (rev 9750)
@@ -60,13 +60,14 @@
      * @param   string   $gadget   Gadget's name
      * @param   string   $action   Gadget's action
      * @param   string   $map      Map to use
+     * @param   string   $regexp   Regular expression
      * @return  boolean  Success/Failure
      */
-    function AddMap($gadget, $action, $map, $reg)
+    function AddMap($gadget, $action, $map, $regexp)
     {
         $this->CheckSession('UrlMapper', 'ManageUrlMapper');
         $model = $GLOBALS['app']->LoadGadget('UrlMapper', 'AdminModel');
-        $res = $model->AddMap($gadget, $action, $map, $reg);
+        $res = $model->AddMap($gadget, $action, $map, $regexp);
         if (!Jaws_Error::IsError($res)) {
             $model->UpdateCustomMaps();
             $GLOBALS['app']->Session->PushLastResponse(_t('URLMAPPER_MAP_ADDED', $map), RESPONSE_NOTICE);
@@ -108,6 +109,9 @@
         $this->CheckSession('UrlMapper', 'ManageUrlMapper');
         $model = $GLOBALS['app']->LoadGadget('UrlMapper', 'AdminModel');
         $res = $model->DeleteMap($id);
+        if (!Jaws_Error::IsError($res)) {
+            $model->UpdateCustomMaps();
+        }
         return $GLOBALS['app']->Session->PopLastResponse();
     }
 

Modified: branches/0.8/jaws/html/gadgets/UrlMapper/AdminHTML.php
===================================================================
--- branches/0.8/jaws/html/gadgets/UrlMapper/AdminHTML.php	2008-10-31 17:00:39 UTC (rev 9749)
+++ branches/0.8/jaws/html/gadgets/UrlMapper/AdminHTML.php	2008-10-31 17:02:12 UTC (rev 9750)
@@ -183,6 +183,7 @@
 
         $btnSave =& Piwi::CreateWidget('Button', 'btn_save', _t('GLOBAL_SAVE'), STOCK_SAVE);
         $btnSave->SetEnabled(false);
+        $btnSave->AddEvent(ON_CLICK, "javascript: saveMap();");
         $tpl->SetVariable('btn_save', $btnSave->Get());
 
         $tpl->SetVariable('addMap_title',     _t('URLMAPPER_MAPS_ADD_TITLE'));

Modified: branches/0.8/jaws/html/gadgets/UrlMapper/AdminModel.php
===================================================================
--- branches/0.8/jaws/html/gadgets/UrlMapper/AdminModel.php	2008-10-31 17:00:39 UTC (rev 9749)
+++ branches/0.8/jaws/html/gadgets/UrlMapper/AdminModel.php	2008-10-31 17:02:12 UTC (rev 9750)
@@ -393,34 +393,8 @@
      */
     function UpdateCustomMaps()
     {
-        if (file_exists(JAWS_DATA . 'maps/custom_map.php')) {
-            unlink(JAWS_DATA . 'maps/custom_map.php');
-        }
-
-        $sql = '
-            SELECT
-                [gadget], [action], [map], [regexp], [script]
-            FROM [[url_maps]]
-            WHERE 
-                [custom] = {custom}';
-
-        $result = $GLOBALS['db']->queryAll($sql, array('custom', true));
-        if (Jaws_Error::IsError($result)) {
-            return new Jaws_Error($result->getMessage(), 'SQL');
-        }
-
         $GLOBALS['app']->Map->Reset();
-        foreach ($result as $r) {
-            $GLOBALS['app']->Map->Connect($r['gadget'],
-                                          $r['action'],
-                                          $r['map'],
-                                          $r['script'],
-                                          $r['regexp'],
-                                          null, //extraparams
-                                          true);
-        }
         $GLOBALS['app']->Map->CreateMapFile(true);
-
         return true;
     }
 }
\ No newline at end of file

Modified: branches/0.8/jaws/html/gadgets/UrlMapper/resources/script.js
===================================================================
--- branches/0.8/jaws/html/gadgets/UrlMapper/resources/script.js	2008-10-31 17:00:39 UTC (rev 9749)
+++ branches/0.8/jaws/html/gadgets/UrlMapper/resources/script.js	2008-10-31 17:02:12 UTC (rev 9750)
@@ -16,25 +16,33 @@
      * Adds a new map
      */
     addmap: function(response) {
+        if (response[0]['css'] == 'notice-message') {
+            enableMapEditingArea(false);
+            showActionMaps();
+        }
         showResponse(response);
-        showActionMaps($('gadgets_combo').value, $('actions').value);
     },
-    
+
     /**
      * Updates a map
      */
     updatemap: function(response) {
+        if (response[0]['css'] == 'notice-message') {
+            enableMapEditingArea(false);
+            showActionMaps();
+        }
         showResponse(response);
-        showActionMaps($('gadgets_combo').value, $('actions').value);
     },
 
     /**
      * Deletes a map
      */
     deletemap: function(response) {
+        if (response[0]['css'] == 'notice-message') {
+            enableMapEditingArea(false);
+            showActionMaps();
+        }
         showResponse(response);
-        showActionMaps($('gadgets_combo').value, $('actions').value);
-
     },
 
     /**
@@ -200,22 +208,23 @@
 }
 
 /**
- * Adds a new map
+ * Add/Edit a map
  */
-function addMap2(gadget, actionName)
+function saveMap()
 {
-    urlmapperAsync.addmap(gadget, actionName, $('map_route').value, $('map_reg').value);
+    if (selectedMap) {
+        urlmapperAsync.updatemap(selectedMap,
+                                 $('map_route').value,
+                                 $('map_regexp').value);
+    } else {
+        urlmapperAsync.addmap($('gadgets_combo').value,
+                              $('actions_combo').value,
+                              $('map_route').value,
+                              $('map_regexp').value);
+    }
 }
 
 /**
- * Updates a map
- */
-function updateMap2(gadget, actionName, extraParam)
-{
-    urlmapperAsync.updatemap(extraParam, $('map_route').value, $('map_reg').value);
-}
-
-/**
  * Prepares the UI to add a map
  */
 function addMap(element, mid)
@@ -279,9 +288,7 @@
     var result = urlmapperSync.getmapsofaction($('gadgets_combo').value, $('actions_combo').value);
     resetGrid('maps_datagrid', result);
     hideWorkingNotification();
-
-    $('map_route').value = '';
-    $('map_regexp').value = '';
+    enableMapEditingArea(false);
 }
 
 /**
@@ -307,6 +314,7 @@
         $('btn_cancel').disabled = false;
     } else {
         selectedMap = null;
+        unselectDataGridRow();
         $('map_route').value  = '';
         $('map_regexp').value = '';
         $('map_route').disabled  = true;



More information about the Jaws-commits mailing list