[ghelda-devel] [29] Move appendOld from private xHTML.class.php to g_functions. |
[ Thread Index |
Date Index
| More lists.tuxfamily.org/ghelda-devel Archives
]
Revision: 29
Author: odyx
Date: 2009-04-29 14:27:39 +0200 (Wed, 29 Apr 2009)
Log Message:
-----------
Move appendOld from private xHTML.class.php to g_functions.
Relate appropriate changes in the plugins.
Modified Paths:
--------------
trunk/inc/g_functions.php
trunk/inc/outputs/xHTML.class.php
trunk/plugins/Address.php
trunk/plugins/Groups.php
trunk/plugins/People.php
Modified: trunk/inc/g_functions.php
===================================================================
--- trunk/inc/g_functions.php 2009-04-29 12:27:35 UTC (rev 28)
+++ trunk/inc/g_functions.php 2009-04-29 12:27:39 UTC (rev 29)
@@ -95,3 +95,15 @@
$rawArrayAge = g_Age($date);
return sprintf(T_('%d years old'),$rawArrayAge['years']);
}
+
+/**
+* appendOld
+* Appends "_old" at the end of the fieldName (or smarter)
+*/
+function g_appendOld($name,$to_append = "_old")
+{
+ if( ($crochet = strpos($name,"[")) )
+ return substr($name,0,$crochet).$to_append.substr($name,$crochet);
+ else
+ return $name.$to_append;
+}
Modified: trunk/inc/outputs/xHTML.class.php
===================================================================
--- trunk/inc/outputs/xHTML.class.php 2009-04-29 12:27:35 UTC (rev 28)
+++ trunk/inc/outputs/xHTML.class.php 2009-04-29 12:27:39 UTC (rev 29)
@@ -372,8 +372,8 @@
// Add the "_old" hidden stag
$paramsArray['type'] = 'hidden';
- $paramsArray['name'] = $this->appendOld($fieldName);
- $paramsArray['id'] = $this->appendOld($fieldName);
+ $paramsArray['name'] = g_appendOld($fieldName);
+ $paramsArray['id'] = g_appendOld($fieldName);
$field .= $this->stag('input',$paramsArray);
@@ -414,8 +414,8 @@
$field = $this->stag('input',$paramsArray);
// Add the "_old" hidden stag
$paramsArray['type'] = 'hidden';
- $paramsArray['name'] = $this->appendOld($fieldName);
- $paramsArray['id'] = $this->appendOld($fieldName);
+ $paramsArray['name'] = g_appendOld($fieldName);
+ $paramsArray['id'] = g_appendOld($fieldName);
unset($paramsArray['maxlength']);
$field .= LB.$this->stag('input',$paramsArray);
@@ -441,8 +441,8 @@
$fields .= $this->xdate($fieldProperties,$fieldsContents[$fieldName_],$fieldName,$paramsArray);
// Add the "_old" hidden stag
$paramsArray['type'] = 'hidden';
- $paramsArray['name'] = $this->appendOld($fieldName);
- $paramsArray['id'] = $this->appendOld($fieldName);
+ $paramsArray['name'] = g_appendOld($fieldName);
+ $paramsArray['id'] = g_appendOld($fieldName);
$paramsArray['value'] = $this->formatDateSimple($fieldsContents[$fieldName_]);
$fields .= LB.$this->stag('input',$paramsArray);
} elseif(stripos($fieldProperties['type'],'enum') !== false) {
@@ -466,8 +466,8 @@
}
// Add the "_old" hidden stag
$paramsArray['type'] = 'hidden';
- $paramsArray['name'] = $this->appendOld($fieldName);
- $paramsArray['id'] = $this->appendOld($fieldName);
+ $paramsArray['name'] = g_appendOld($fieldName);
+ $paramsArray['id'] = g_appendOld($fieldName);
$paramsArray['value'] = $fieldsContents[$fieldName_];
unset($paramsArray['checked']);
$field .= LB.$this->stag('input',$paramsArray);
@@ -695,15 +695,15 @@
private function xdate($fieldProperties,$fieldContent,$fieldName,$paramsArray)
{
// $fieldContent = $fieldsContents[$fieldName];
- $label = $this->tag('label',$fieldProperties['name'],array('for'=>$this->appendOld($fieldName,'_year')));
+ $label = $this->tag('label',$fieldProperties['name'],array('for'=>g_appendOld($fieldName,'_year')));
$formattedDate = T_('%YEAR%-%MONTH%-%DAY%');
preg_match("`([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})`", $fieldContent, $regs);
$dateOptions = array_key_exists('error',$fieldProperties) ? ($fieldProperties['error'] ? array("class" => "input_error") : array() ) : array();
// Get the global lists
global $DAYS,$MONTHS,$YEARS;
- $year = $this->select($YEARS,$regs[1],array_merge($paramsArray,array('name'=>$this->appendOld($fieldName,'_year'))));
- $month = $this->select($MONTHS,$regs[2],array_merge($paramsArray,array('name'=>$this->appendOld($fieldName,'_month'))));
- $day = $this->select($DAYS,$regs[3],array_merge($paramsArray,array('name'=>$this->appendOld($fieldName,'_day'))));
+ $year = $this->select($YEARS,$regs[1],array_merge($paramsArray,array('name'=>g_appendOld($fieldName,'_year'))));
+ $month = $this->select($MONTHS,$regs[2],array_merge($paramsArray,array('name'=>g_appendOld($fieldName,'_month'))));
+ $day = $this->select($DAYS,$regs[3],array_merge($paramsArray,array('name'=>g_appendOld($fieldName,'_day'))));
$formattedDate = str_replace('%YEAR%',$year,$formattedDate);
$formattedDate = str_replace('%MONTH%',$month,$formattedDate);
@@ -752,18 +752,6 @@
return $imageTitle;
}
}
-
- /**
- * appendOld
- * Appends "_old" at the end of the fieldName (or smarter)
- */
- private function appendOld($name,$to_append = "_old")
- {
- if( ($crochet = strpos($name,"[")) )
- return substr($name,0,$crochet).$to_append.substr($name,$crochet);
- else
- return $name.$to_append;
- }
-
+
}
?>
Modified: trunk/plugins/Address.php
===================================================================
--- trunk/plugins/Address.php 2009-04-29 12:27:35 UTC (rev 28)
+++ trunk/plugins/Address.php 2009-04-29 12:27:39 UTC (rev 29)
@@ -149,7 +149,7 @@
// Jump the non-modified ones (and if we are creating a new user)
if( $id != G_ADDRESS_ID_NEW &&
isset($_POST[$fieldName]) &&
- $_POST[$fieldName] == $_POST[$fieldName.'_old']) {
+ $_POST[$fieldName] == $_POST[g_appendOld($fieldName)]) {
continue;
}
// Get the type of the field and store its value
@@ -361,6 +361,7 @@
$to_return['content'][G_ADDRESS_ID] = $addressId;
$this->stopTrad();
+// trigger_error(var_export($addresses,true),G_E_DISPLAY);
return $to_return;
}
}
Modified: trunk/plugins/Groups.php
===================================================================
--- trunk/plugins/Groups.php 2009-04-29 12:27:35 UTC (rev 28)
+++ trunk/plugins/Groups.php 2009-04-29 12:27:39 UTC (rev 29)
@@ -150,7 +150,7 @@
// Jump the non-modified ones (and if we are creating a new user)
if( $id != G_GROUPS_ID_NEW &&
isset($_POST[$fieldName]) &&
- $_POST[$fieldName] == $_POST[$fieldName.'_old']) {
+ $_POST[$fieldName] == $_POST[g_appendOld($fieldName)]) {
continue;
}
// Get the type of the field and store its value
Modified: trunk/plugins/People.php
===================================================================
--- trunk/plugins/People.php 2009-04-29 12:27:35 UTC (rev 28)
+++ trunk/plugins/People.php 2009-04-29 12:27:39 UTC (rev 29)
@@ -146,8 +146,8 @@
$fieldName = $this->name.'_'.$fieldName_;
// Jump the non-modified ones (and if we are creating a new user)
if( $id != G_PEOPLE_ID_NEW &&
- array_key_exists($fieldName.'_old',$_POST) &&
- $_POST[$fieldName] == $_POST[$fieldName.'_old']) {
+ array_key_exists(g_appendOld($fieldName),$_POST) &&
+ $_POST[$fieldName] == $_POST[g_appendOld($fieldName)]) {
continue;
}
// Get the type of the field and store its value
@@ -228,7 +228,7 @@
continue;
}
// Re-check for the dates…
- elseif(array_key_exists($fieldName.'_old',$_POST) && $fieldContent == $_POST[$fieldName.'_old'])
+ elseif(array_key_exists(g_appendOld($fieldName),$_POST) && $fieldContent == $_POST[g_appenOld($fieldName)])
continue;
}
$fieldsContents[$fieldName_] = $fieldContent;