[Eis-commits] SF.net SVN: eis: [227] trunk/mod/eis_widget/services/MainService.php
Status: Pre-Alpha
Brought to you by:
baslijnse
|
From: <bas...@us...> - 2008-02-24 14:42:25
|
Revision: 227
http://eis.svn.sourceforge.net/eis/?rev=227&view=rev
Author: baslijnse
Date: 2008-02-24 06:42:21 -0800 (Sun, 24 Feb 2008)
Log Message:
-----------
various small bugfixes in the widget module
Modified Paths:
--------------
trunk/mod/eis_widget/services/MainService.php
Modified: trunk/mod/eis_widget/services/MainService.php
===================================================================
--- trunk/mod/eis_widget/services/MainService.php 2008-02-24 14:40:44 UTC (rev 226)
+++ trunk/mod/eis_widget/services/MainService.php 2008-02-24 14:42:21 UTC (rev 227)
@@ -85,7 +85,7 @@
* @return html rendering of the widget
*/
function displayString($value, $conf = null) {
- $html = nl2br(htmlentities($value));
+ $html = nl2br($value);
if(isset($conf['link']) && $conf['link'] != '')
$html = '<a href="'.$conf['link'].'">'.$html.'</a>';
@@ -134,7 +134,7 @@
if(isset($conf['format']) && $conf['format'] != '') {
$format = $conf['format'];
} else {
- $format = "H:i:s";
+ $format = "H:i";
}
return '<span class="widget-display-time">'.date($format, $timestamp).'</span>';
} else {
@@ -208,6 +208,21 @@
return '<span class="widget-display-currency">'.$sign.' '.$value.'</span>';
}
+ /**
+ * Displays a localized label
+ * @param $label the label to display
+ * @param $conf optional configuration of the widget
+ * @return html rendering of the widget
+ */
+ function displayLabel($label, $conf = null) {
+
+ $html = $this->e->getString($label);
+ if(isset($conf['link']) && $conf['link'] != '')
+ $html = '<a href="'.$conf['link'].'">'.$html.'</a>';
+
+ return '<span class="widget-display-label">'.$html.'</span>';
+ }
+
//BASIC SCALAR INPUT
/**
@@ -398,22 +413,43 @@
if($id == null) {
$id = 'input-'.$name;
}
- //If a value is given parse it into a timestamp
- if($value != null) {
- $date = strtotime($value);
- }
+ $vals = array();
switch($type) {
case 'date':
$fields = array('j','m','Y');
$format = "j-m-Y";
+ if(ereg("^([^-]*)-([^-]*)-(.*)$", $value, $matches)) {
+ $vals['j'] = $matches[3];
+ $vals['m'] = $matches[2];
+ $vals['Y'] = $matches[1];
+ } else {
+ $vals = array_combine($fields,array_fill(0,count($fields),""));
+ }
break;
case 'time':
$fields = array('H','i','s');
$format = "H:i:s";
+ if(ereg("^([^:]*):([^:]*):(.*)$", $value, $matches)) {
+ $vals['H'] = $matches[1];
+ $vals['i'] = $matches[2];
+ $vals['s'] = $matches[3];
+ } else {
+ $vals = array_combine($fields,array_fill(0,count($fields),""));
+ }
break;
case 'datetime':
$fields = array('j','m','Y','H','i','s');
$format = "j-m-Y H:i:s";
+ if(ereg("^([^-]*)-([^-]*)-([^ ]*) ([^:]*):([^:]*):(.*)$", $value, $matches)) {
+ $vals['j'] = $matches[3];
+ $vals['m'] = $matches[2];
+ $vals['Y'] = $matches[1];
+ $vals['H'] = $matches[4];
+ $vals['i'] = $matches[5];
+ $vals['s'] = $matches[6];
+ } else {
+ $vals = array_combine($fields,array_fill(0,count($fields),""));
+ }
break;
}
//Use custom format if configured
@@ -422,17 +458,16 @@
} else {
$html = $format;
}
- //Replace format markers by unique markers in format string
+ //Replace fields by unique markers
foreach($fields as $field) {
- $html = str_replace($field,'__'.$field.'__',$html);
+ $html = str_replace($field,'__'.$field.'__', $html);
}
//Replace unique markers by html
foreach($fields as $field) {
$inp = '<input type="text" id="'.$id.'-'.$field.'" ';
- if($value != null) {
- $inp .= 'value="'.date($field,$date).'" ';
- }
+ $inp .= 'value="'.$vals[$field].'" ';
+
if($field == 'Y') {
$inp .= 'size="4" maxlength="4" ';
} else {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|