[whups] Patch to customize date format
Mike Baptiste
mike@msbnetworks.net
Mon Nov 11 18:34:32 2002
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1
We've found the extended Weekday Day Month (days ago) time display in
search reports makes it very hard to view resutls in a single line
without wrapping (or expanding the brower wide to obscene widths :) )
We've created a patch that allows the user to select from different time
formats to use in the search reports. We've included it below. It
changes on framework file (adds a method) so if this needs to be done
differently to be accepted, let me know.
Mike
Index: searchresults.inc
===================================================================
RCS file: /repository/whups/templates/searchresults.inc,v
retrieving revision 1.17
diff -c -r1.17 searchresults.inc
*** searchresults.inc 23 Oct 2002 21:45:21 -0000 1.17
- --- searchresults.inc 11 Nov 2002 18:26:47 -0000
***************
*** 65,71 ****
~ $thevalue = !empty($info[$value]) ? $info[$value] : '';
~ if ($value == 'timestamp' || $value == '_date_assigned'
|| $value == '_date_resolved') {
! $thevalue =
Horde_Form_Type_date::getFormattedTime($thevalue);
~ } elseif ($value == 'id' || $value == 'summary') {
~ $thevalue = Horde::link($url, isset($info['summary'])
? $info['summary'] : '') . "<b>$thevalue</b></a>";
~ }
- --- 65,71 ----
~ $thevalue = !empty($info[$value]) ? $info[$value] : '';
~ if ($value == 'timestamp' || $value == '_date_assigned'
|| $value == '_date_resolved') {
! $thevalue =
Horde_Form_Type_date::getFormattedTimeCustom($thevalue,
$prefs->getValue('report_time_format'), $prefs->getValue('show_days_ago'));
~ } elseif ($value == 'id' || $value == 'summary') {
~ $thevalue = Horde::link($url, isset($info['summary'])
? $info['summary'] : '') . "<b>$thevalue</b></a>";
~ }
Index: Form.php
===================================================================
RCS file: /repository/horde/lib/Form.php,v
retrieving revision 1.24
diff -c -r1.24 Form.php
*** Form.php 1 Nov 2002 15:48:50 -0000 1.24
- --- Form.php 11 Nov 2002 18:27:12 -0000
***************
*** 928,933 ****
- --- 928,946 ----
~ }
~ }
+ function getFormattedTimeCustom($timestamp, $format, $useago)
+ {
+ if (!empty($timestamp)) {
+ if ($useago) {
+ return strftime($format, $timestamp) .
Horde_Form_Type_date::_getAgo($timestamp);
+ } else {
+ return strftime($format, $timestamp);
+ }
+ } else {
+ return '';
+ }
+ }
+
~ }
~ class Horde_Form_Type_monthYear extends Horde_Form_Type {
Index: prefs.php.dist
===================================================================
RCS file: /repository/whups/config/prefs.php.dist,v
retrieving revision 1.6
diff -c -r1.6 prefs.php.dist
*** prefs.php.dist 8 Nov 2002 20:54:38 -0000 1.6
- --- prefs.php.dist 11 Nov 2002 18:30:35 -0000
***************
*** 11,17 ****
~ 'column' => _("Other Options"),
~ 'label' => _("Display Options"),
~ 'desc' => _("Change display options such as the color scheme and
how search results are sorted."),
! 'members' => array('sortby', 'sortdir', 'theme',
'summary_show_requested')
~ );
~ // user language
- --- 11,17 ----
~ 'column' => _("Other Options"),
~ 'label' => _("Display Options"),
~ 'desc' => _("Change display options such as the color scheme and
how search results are sorted."),
! 'members' => array('sortby', 'sortdir', 'theme',
'summary_show_requested', 'report_time_format', 'show_days_ago')
~ );
~ // user language
***************
*** 81,83 ****
- --- 81,104 ----
~ 'shared' => false,
~ 'type' => 'checkbox',
~ 'desc' => _("Show tickets you have requested in the summary view?"));
+
+ // Allow custom time/date formats in reports
+ $_prefs['report_time_format'] = array(
+ 'value' => '%a %d %B',
+ 'locked' => false,
+ 'shared' => false,
+ 'type' => 'enum',
+ 'enum' => array('%a %d %B' => _("Weekday Day Month"),
+ '%c' => _("Weekday Day Month HH:MM:SS TZ"),
+ '%D' => _("MM/DD/YY"),
+ '%D %T' => _("MM/DD/YY HH:MM:SS")),
+ 'desc' => _("Date/Time Format for Reports")
+ );
+
+ // Show 'X Days Ago' in Timestamps??
+ $_prefs['show_days_ago'] = array(
+ 'value' => 1,
+ 'locked' => false,
+ 'shared' => false,
+ 'type' => 'checkbox',
+ 'desc' => _("Show \"(X Days Ago)\" in Date field of Reports?"));
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.0 (MingW32)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org
iD8DBQE9z/g4tbf8BjvL+3ERAvO2AJ4w/Y1igd8Oosen1skP0XYZCxsPnACeJ9Nt
JN1x7l8QZsa+3uAI018Tcpw=
=4OYk
-----END PGP SIGNATURE-----
More information about the whups
mailing list