From: Jan Schneider Date: Wed, 17 Mar 2010 22:08:35 +0000 (+0000) Subject: Allow to switch search time. X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=3912301ac6650bf8e4166861e418b9a9e62375c7;p=horde.git Allow to switch search time. --- diff --git a/kronolith/js/kronolith.js b/kronolith/js/kronolith.js index ecb144b81..8fa92e38c 100644 --- a/kronolith/js/kronolith.js +++ b/kronolith/js/kronolith.js @@ -34,6 +34,7 @@ KronolithCore = { mapMarker: null, map: null, mapInitialized: false, + search: 'future', doActionOpts: { onException: function(parentfunc, r, e) @@ -353,8 +354,18 @@ KronolithCore = { break; case 'search': - var cals = [], term = locParts[0], + var cals = [], time = locParts[0], term = locParts[1], query = Object.toJSON({ title: term }); + + if (!($w('all past future').include(time))) { + return; + } + + this.search = time; + $w('All Past Future').each(function(time) { + $('kronolithSearch' + time).up().removeClassName('activeTab'); + }); + $('kronolithSearch' + this.search.capitalize()).up().addClassName('activeTab'); this.closeView('agenda'); this.updateView(null, 'search', term); $H(Kronolith.conf.calendars).each(function(type) { @@ -366,7 +377,7 @@ KronolithCore = { }); this.startLoading('search', query); this.doAction('searchEvents', - { cals: cals.toJSON(), query: query }, + { cals: cals.toJSON(), query: query, time: this.search }, function(r) { // Hide spinner. this.loading--; @@ -592,9 +603,13 @@ KronolithCore = { day = dates[0].clone(); $('kronolithAgendaDate') .update(this.setTitle(Kronolith.text.agenda + ' ' + dates[0].toString('d') + ' - ' + dates[1].toString('d'))); + $('kronolithAgendaNavigation').show(); + $('kronolithSearchNavigation').hide(); } else { $('kronolithAgendaDate') .update(this.setTitle(Kronolith.text.searching.interpolate({ term: data }))); + $('kronolithAgendaNavigation').hide(); + $('kronolithSearchNavigation').show(); } // Remove old rows. Maybe we should only rebuild the calendars if @@ -3147,7 +3162,7 @@ KronolithCore = { break; case 'kronolithSearchForm': - this.go('search:' + $F('kronolithSearchTerm')) + this.go('search:' + this.search + ':' + $F('kronolithSearchTerm')) e.stop(); break; @@ -3510,7 +3525,28 @@ KronolithCore = { return; case 'kronolithSearchButton': - this.go('search:' + $F('kronolithSearchTerm')) + this.go('search:' + this.search + ':' + $F('kronolithSearchTerm')); + e.stop(); + break; + + case 'kronolithSearchFuture': + if (this.search != 'future') { + this.go('search:future:' + $F('kronolithSearchTerm')); + } + e.stop(); + break; + + case 'kronolithSearchPast': + if (this.search != 'past') { + this.go('search:past:' + $F('kronolithSearchTerm')); + } + e.stop(); + break; + + case 'kronolithSearchAll': + if (this.search != 'all') { + this.go('search:all:' + $F('kronolithSearchTerm')); + } e.stop(); break; diff --git a/kronolith/lib/Ajax/Application.php b/kronolith/lib/Ajax/Application.php index 5c63c2996..bbf16eef0 100644 --- a/kronolith/lib/Ajax/Application.php +++ b/kronolith/lib/Ajax/Application.php @@ -252,6 +252,20 @@ class Kronolith_Ajax_Application extends Horde_Ajax_Application_Base if (!isset($query->end)) { $query->end = null; } + switch ($this->_vars->time) { + case 'all': + $query->start = null; + $query->end = null; + break; + case 'future': + $query->start = new Horde_Date($_SERVER['REQUEST_TIME']); + $query->end = null; + break; + case 'past': + $query->start = null; + $query->end = new Horde_Date($_SERVER['REQUEST_TIME']); + break; + } $cals = Horde_Serialize::unserialize($this->_vars->cals, Horde_Serialize::JSON); $events = array(); diff --git a/kronolith/lib/Driver/Sql.php b/kronolith/lib/Driver/Sql.php index 9df2e5866..845337b92 100644 --- a/kronolith/lib/Driver/Sql.php +++ b/kronolith/lib/Driver/Sql.php @@ -181,19 +181,24 @@ class Kronolith_Driver_Sql extends Kronolith_Driver $event = $this->getEvent($eventId); $showRecurrence = true; if ($event->recurs()) { - if (empty($query->end)) { - $eventEnd = $event->recurrence->nextRecurrence($now); - if (!$eventEnd) { - continue; - } - } else { - $eventEnd = $query->end; - } - if (empty($query->start)) { + if (empty($query->start) && empty($query->end)) { $eventStart = $event->start; - $showRecurrence = false; + $eventEnd = $event->end; } else { - $eventStart = $query->start; + if (empty($query->end)) { + $eventEnd = $event->recurrence->nextRecurrence($now); + if (!$eventEnd) { + continue; + } + } else { + $eventEnd = $query->end; + } + if (empty($query->start)) { + $eventStart = $event->start; + $showRecurrence = false; + } else { + $eventStart = $query->start; + } } } else { $eventStart = $event->start; diff --git a/kronolith/templates/index/agenda.inc b/kronolith/templates/index/agenda.inc index 5a45e3c87..771d50164 100644 --- a/kronolith/templates/index/agenda.inc +++ b/kronolith/templates/index/agenda.inc @@ -1,12 +1,19 @@