diff --git a/etemplate/inc/class.etemplate_widget_nextmatch.inc.php b/etemplate/inc/class.etemplate_widget_nextmatch.inc.php
index b2a253ecf5..12c7f1d416 100644
--- a/etemplate/inc/class.etemplate_widget_nextmatch.inc.php
+++ b/etemplate/inc/class.etemplate_widget_nextmatch.inc.php
@@ -948,9 +948,9 @@ class etemplate_widget_nextmatch extends etemplate_widget
if(!$registry) $registry = egw_link::get_registry($app,'index');
foreach($filters as $name => $filter)
{
- $href = egw::link('/index.php', (array)$registry + array('favorite'=>$name),$app);
+ $href = "javascript:app.$app.setState(" . json_encode($filter['filter']) . ');';
$html .= "
\n";
@@ -969,7 +969,7 @@ class etemplate_widget_nextmatch extends etemplate_widget
* @param $app Current application, needed to save preference
* @param $name String Name of the favorite
* @param $action String add or delete
- * @param $group int|String ID of the group to create the favorite for, or All for all users
+ * @param $group int|String ID of the group to create the favorite for, or 'all' for all users
* @param $filters Array of key => value pairs for the filter
*
* @return boolean Success
diff --git a/phpgwapi/js/jsapi/app_base.js b/phpgwapi/js/jsapi/app_base.js
index a79d54a96f..a7ba6296d5 100644
--- a/phpgwapi/js/jsapi/app_base.js
+++ b/phpgwapi/js/jsapi/app_base.js
@@ -177,6 +177,81 @@ var AppJS = Class.extend(
nm.getInstanceManager().submit();
}
}
- }
+ },
+ /**
+ * Set the application's state to the given state.
+ *
+ * While not pretending to implement the history API, it is patterned similarly
+ * @link http://www.whatwg.org/specs/web-apps/current-work/multipage/history.html
+ *
+ * The default implementation works with the favorites to apply filters to a nextmatch.
+ *
+ *
+ * @param {object} state description
+ */
+ setState: function(state)
+ {
+ // State should be an object, not a string, but we'll try
+ if(typeof state == "string")
+ {
+ if(state.indexOf('{') != -1 || state =='null')
+ {
+ state = JSON.parse(state);
+ }
+ }
+ if(typeof state != "object")
+ {
+ egw.debug('error', 'Unable to set state to %o, needs to be an object',state);
+ return;
+ }
+ if(state == null)
+ {
+ state = {};
+ }
+
+ // Try and find a nextmatch widget, and set its filters
+ var nextmatched = false;
+ var et2 = etemplate2.getByApplication(this.appname);
+ for(var i = 0; i < et2.length; i++)
+ {
+ et2[i].widgetContainer.iterateOver(function(_widget) {
+ // Apply
+ _widget.activeFilters = state;
+ _widget.applyFilters();
+ nextmatched = true;
+ }, this, et2_nextmatch);
+ }
+
+ // No nextmatch? Try a redirect to list
+ if(!nextmatched)
+ {
+ egw.open('',this.appname,'list',{'state': state},this.appname);
+ }
+ },
+
+ /**
+ * Retrieve the current state of the application for future restoration
+ *
+ * The state can be anything, as long as it's an object. The contents are
+ * application specific. The default implementation finds a nextmatch and
+ * returns its value.
+ *
+ * @return {object} Value of a nextmatch
+ */
+ getState: function()
+ {
+ var state = {};
+
+ // Try and find a nextmatch widget, and set its filters
+ var et2 = etemplate2.getByApplication(this.appname);
+ for(var i = 0; i < et2.length; i++)
+ {
+ et2.widgetContainer.iterateOver(function(_widget) {
+ state = _widget.getValue();
+ }, this, et2_nextmatch);
+ }
+
+ return state;
+ }
});