id message;
}
+- (NSString *)defaultSortKey;
+- (NSString *)imap4SortKey;
+- (NSString *)imap4SortOrdering;
+
+- (BOOL)isSortedDescending;
+
@end
#include "common.h"
sort = [[[self context] request] formValueForKey:@"sort"];
- // TODO: reversed sorts
-
if ([sort length] == 0)
sort = [self defaultSortKey];
return [sort uppercaseString];
}
+- (BOOL)isSortedDescending {
+ return [[[self context] request] formValueForKey:@"desc"] ? YES : NO;
+}
+
+- (NSString *)imap4SortOrdering {
+ NSString *sort;
+
+ sort = [self imap4SortKey];
+ if(![self isSortedDescending])
+ return sort;
+ return [@"REVERSE " stringByAppendingString:sort];
+}
+
- (NSRange)fetchRange {
if (self->firstMessageNumber == 0)
return NSMakeRange(0, 50);
self->sortedUIDs
= [[[self clientObject] fetchUIDsMatchingQualifier:[self qualifier]
- sortOrdering:[self imap4SortKey]] retain];
+ sortOrdering:[self imap4SortOrdering]] retain];
return self->sortedUIDs;
}
- (unsigned int)totalMessageCount {
title="name"
>
<div class="titlediv">
- <a rsrc:href="tbird_073_mailwelcome.png"><var:string label:value="View" />:</a>, <!-- TODO ;-) -->
+ <a rsrc:href="tbird_073_mailwelcome.png"
+ ><var:string label:value="View" />:</a>, <!-- TODO ;-) -->
<select name="viewfilter"> <!-- var:popup? -->
<option value="all" ><var:string label:value="All" /></option>
<option value="unread"><var:string label:value="Unread" /></option>
<var:entity const:name="nbsp" />
</td>
<td class="tbtv_headercell" width="50%">
- <a href="view" _sort="subject">
+ <a href="view" _sort="subject">
<var:string label:value="Subject" />
- <var:if condition="imap4SortKey" const:value="SUBJECT">
- <img rsrc:src="title_sortdown_12x12.png"
- class="tbtv_sortcell" />
- </var:if>
</a>
+ <var:if condition="imap4SortKey" const:value="SUBJECT">
+ <var:if condition="isSortedDescending" >
+ <a href="view" _sort="subject">
+ <img rsrc:src="title_sortup_12x12.png"
+ class="tbtv_sortcell"
+ />
+ </a>
+ </var:if>
+ <var:if condition="isSortedDescending" const:negate="YES" >
+ <a href="view" _sort="subject" _desc="1">
+ <img rsrc:src="title_sortdown_12x12.png"
+ class="tbtv_sortcell"
+ />
+ </a>
+ </var:if>
+ </var:if>
</td>
<td class="tbtv_headercell">
<var:if condition="showToAddress" const:negate="YES">
- <a href="view" _sort="from">
+ <a href="view"
+ _sort="from"
+ var:queryDictionary="queryParameters"
+ >
<var:string label:value="From" />
- <var:if condition="imap4SortKey" const:value="FROM">
- <img rsrc:src="title_sortdown_12x12.png"
- class="tbtv_sortcell" />
- </var:if>
</a>
+ <var:if condition="imap4SortKey" const:value="FROM">
+ <var:if condition="isSortedDescending" >
+ <a href="view"
+ _sort="from"
+ var:queryDictionary="queryParameters"
+ >
+ <img rsrc:src="title_sortup_12x12.png"
+ class="tbtv_sortcell"
+ />
+ </a>
+ </var:if>
+ <var:if condition="isSortedDescending" const:negate="YES" >
+ <a href="view"
+ _sort="from"
+ _desc="1"
+ var:queryDictionary="queryParameters"
+ >
+ <img rsrc:src="title_sortdown_12x12.png"
+ class="tbtv_sortcell"
+ />
+ </a>
+ </var:if>
+ </var:if>
</var:if>
<var:if condition="showToAddress">
- <a href="view" _sort="to">
+ <a href="view"
+ _sort="to"
+ var:queryDictionary="queryParameters"
+ >
<var:string label:value="To" />
- <var:if condition="imap4SortKey" const:value="TO">
- <img rsrc:src="title_sortdown_12x12.png"
- class="tbtv_sortcell" />
- </var:if>
</a>
+ <var:if condition="imap4SortKey" const:value="TO">
+ <var:if condition="isSortedDescending" >
+ <a href="view"
+ _sort="to"
+ var:queryDictionary="queryParameters"
+ >
+ <img rsrc:src="title_sortup_12x12.png"
+ class="tbtv_sortcell"
+ />
+ </a>
+ </var:if>
+ <var:if condition="isSortedDescending" const:negate="YES" >
+ <a href="view"
+ _sort="to"
+ _desc="1"
+ var:queryDictionary="queryParameters"
+ >
+ <img rsrc:src="title_sortdown_12x12.png"
+ class="tbtv_sortcell"
+ />
+ </a>
+ </var:if>
+ </var:if>
</var:if>
</td>
<td class="tbtv_headercell" width="17">
<img rsrc:src="title_attachment_14x14.png" width="14" height="14" />
</td>
<td class="tbtv_headercell">
- <a href="view" _sort="date">
+ <a href="view"
+ _sort="date"
+ var:queryDictionary="queryParameters"
+ >
<var:string label:value="Date" />
- <var:if condition="imap4SortKey" const:value="DATE">
- <img rsrc:src="title_sortdown_12x12.png"
- class="tbtv_sortcell"/>
- </var:if>
</a>
+ <var:if condition="imap4SortKey" const:value="DATE">
+ <var:if condition="isSortedDescending" >
+ <a href="view"
+ _sort="date"
+ var:queryDictionary="queryParameters"
+ >
+ <img rsrc:src="title_sortup_12x12.png"
+ class="tbtv_sortcell"
+ />
+ </a>
+ </var:if>
+ <var:if condition="isSortedDescending" const:negate="YES" >
+ <a href="view"
+ _sort="date"
+ _desc="1"
+ var:queryDictionary="queryParameters"
+ >
+ <img rsrc:src="title_sortdown_12x12.png"
+ class="tbtv_sortcell"
+ />
+ </a>
+ </var:if>
+ </var:if>
</td>
</tr>
<tr class="tableview">
<var:if condition="hasPrevious">
<a href="view"
_idx="1"
+ var:queryDictionary="queryParameters"
><var:string label:value="first"/></a> |
<a href="view"
var:_idx="prevFirstMessageNumber"
+ var:queryDictionary="queryParameters"
><var:string label:value="previous"/></a> |
</var:if>
<var:if condition="hasNext">
| <a href="view"
var:_idx="nextFirstMessageNumber"
+ var:queryDictionary="queryParameters"
><var:string label:value="next" /></a>
</var:if>
</var:if>
@interface UIxComponent (PrivateAPI)
- (void)_parseQueryString:(NSString *)_s;
+- (NSMutableDictionary *)_queryParameters;
@end
@implementation UIxComponent
}
}
-- (id)init {
- if ((self = [super init])) {
- self->queryParameters = [[NSMutableDictionary alloc] initWithCapacity:8];
- }
- return self;
-}
-
- (void)dealloc {
[self->queryParameters release];
[super dealloc];
}
-/* notifications */
-
-- (void)awake {
- WORequest *req;
- NSString *uri;
- NSRange r;
-
- [super awake];
-
- req = [[self context] request];
- uri = [req uri];
- r = [uri rangeOfString:@"?"];
- if (r.length > 0) {
- NSString *qs;
-
- qs = [uri substringFromIndex:(r.location + r.length)];
- [self->queryParameters removeAllObjects];
- [self _parseQueryString:qs];
- }
-}
-
/* query parameters */
- (void)_parseQueryString:(NSString *)_s {
}
- (NSString *)queryParameterForKey:(NSString *)_key {
- return [self->queryParameters objectForKey:_key];
+ return [[self _queryParameters] objectForKey:_key];
}
- (void)setQueryParameter:(NSString *)_param forKey:(NSString *)_key {
return;
if(_param != nil)
- [self->queryParameters setObject:_param forKey:_key];
+ [[self _queryParameters] setObject:_param forKey:_key];
else
- [self->queryParameters removeObjectForKey:_key];
+ [[self _queryParameters] removeObjectForKey:_key];
}
-- (NSDictionary *)queryParameters {
+- (NSMutableDictionary *)_queryParameters {
+ if(!self->queryParameters) {
+ WORequest *req;
+ NSString *uri;
+ NSRange r;
+
+ self->queryParameters = [[NSMutableDictionary alloc] initWithCapacity:8];
+
+ req = [[self context] request];
+ uri = [req uri];
+ r = [uri rangeOfString:@"?" options:NSBackwardsSearch];
+ if (r.length > 0) {
+ NSString *qs;
+
+ qs = [uri substringFromIndex:NSMaxRange(r)];
+ [self _parseQueryString:qs];
+ }
+ }
return self->queryParameters;
}
+- (NSDictionary *)queryParameters {
+ return [self _queryParameters];
+}
+
- (NSDictionary *)queryParametersBySettingSelectedDate:(NSCalendarDate *)_date{
NSMutableDictionary *qp;