summaryrefslogtreecommitdiff
path: root/includes/common.inc
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2001-05-17 19:14:50 +0000
committerDries Buytaert <dries@buytaert.net>2001-05-17 19:14:50 +0000
commit6c387962199f3b57aff1df4bc0c79ded4935f2a1 (patch)
tree7e547ce9e8455c8154ec722b8c1c0da26999945d /includes/common.inc
parente2f051b3854a72e2c7f1af1506f7c3eed6504891 (diff)
downloadbrdo-6c387962199f3b57aff1df4bc0c79ded4935f2a1.tar.gz
brdo-6c387962199f3b57aff1df4bc0c79ded4935f2a1.tar.bz2
- Fixed bug in account.module.
- Simplified field_set() API. - Made UnConeD's cool common timestamp format conform with the general coding style. Sorry to be so picky about this but I really can't help it. ;)
Diffstat (limited to 'includes/common.inc')
-rw-r--r--includes/common.inc30
1 files changed, 16 insertions, 14 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 44a353fbb..1c5ea330b 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -97,9 +97,9 @@ function format_plural($count, $singular, $plural) {
}
function format_interval($timestamp) {
- $units = array("year|years"=>31536000, "week|weeks"=>604800, "day|days"=>86400, "hour|hours"=>3600, "min|min"=>60, "sec|sec"=>1);
+ $units = array("year|years" => 31536000, "week|weeks" => 604800, "day|days" => 86400, "hour|hours" => 3600, "min|min" => 60, "sec|sec" => 1);
foreach ($units as $key=>$value) {
- $key=explode("|", $key);
+ $key = explode("|", $key);
if ($timestamp >= $value) {
$output .= ($output ? " " : "") . format_plural(floor($timestamp / $value), $key[0], $key[1]);
$timestamp %= $value;
@@ -124,12 +124,16 @@ function format_date($timestamp, $type = "medium", $format = "") {
$date = t(date("l", $timestamp)) .", ". t(date("F", $timestamp)) ." ". date("d, Y - H:i", $timestamp);
break;
case "custom":
- for ($i=strlen($format);$i>=0;$c=$format[--$i]) {
- if (strstr("DFlMSw",$c))
- $date=t(date($c,$timestamp)).$date;
- else if (strstr("AaBdgGhHiIjLmnrstTUYyZz",$c))
- $date=date($c,$timestamp).$date;
- else $date=$c.$date;
+ for ($i = strlen($format); $i >= 0; $c = $format[--$i]) {
+ if (strstr("DFlMSw", $c)) {
+ $date=t(date($c, $timestamp)).$date;
+ }
+ else if (strstr("AaBdgGhHiIjLmnrstTUYyZz", $c)) {
+ $date = date($c, $timestamp).$date;
+ }
+ else {
+ $date = $c.$date;
+ }
}
break;
default:
@@ -169,8 +173,8 @@ function format_text($text) {
return preg_replace($src, $dst, $text);
}
-function form($action, $form, $method = "post", $options="") {
- return "<FORM ACTION=\"$action\" METHOD=\"$method\"". (!empty($options) ? " $options" : "") .">\n$form</FORM>\n";
+function form($action, $form, $method = "post", $options = 0) {
+ return "<FORM ACTION=\"$action\" METHOD=\"$method\"". ($options ? " $options" : "") .">\n$form</FORM>\n";
}
function form_item($title, $value, $description = 0) {
@@ -211,9 +215,7 @@ function field_get($object, $variable, $field) {
return $rval;
}
-function field_set($object, $variable, $name, $value) {
- $field = $object->$variable;
-
+function field_set($field, $name, $value) {
if (!$value) {
// remove entry:
$data = explode(";", $field);
@@ -272,4 +274,4 @@ $theme = theme_init();
// set error handler:
set_error_handler("error_handler");
-?> \ No newline at end of file
+?>