Hi bakers again :),
i managed to do it another way.
These two function provided below are the key for it. As you can see I
placed them inside of the app_controller.php
class AppController extends Controller {
function htmlchars($data) {
if (empty($data)) {
return $data;
}
if (is_array($data)) {
foreach ($data as $key => $val) {
$data[$key] = $this->htmlchars($val);
}
return $data;
}
else {
$patterns = array("/\&/", "/%/", "/</", "/>/", '/"/',
"/'/", "/\
(/", "/\)/", "/\+/", "/-/", "/ä/", "/Ä/", "/ö/", "/Ö/", "/ü/", "/Ü/");
$replacements = array("&", "%", "<", ">",
""",
"'", "(", ")", "+", "-", "ä", "Ä",
"ö", "Ö", "ü", "Ü");
$data = preg_replace($patterns, $replacements, $data);
return $data;
}
}
function unhtmlchars($data) {
if (empty($data)) {
return $data;
}
if (is_array($data)) {
foreach ($data as $key => $val) {
$data[$key] = $this->unhtmlchars($val);
}
return $data;
}
else {
$patterns = array("/&/", "/%/", "/</",
"/>/", "/
"/", "/'/", "/(/", "/)/", "/+/", "/-/", "/
ä/", "/Ä/", "/ö/", "/Ö/", "/ü/", "/Ü/");
$replacements = array("&", "%", "<", ">", '"', "'",
"(", ")", "+",
"-", "ä", "Ä", "ö", "Ö", "ü", "Ü");
$data = preg_replace($patterns, $replacements, $data);
return $data;
}
}
}
So if i retrieve any data for a view i simply do $cleandata = $this-
>htmlchars($this->data); and use $cleandata for now on.
The same with unhtmlchars().
The only problem i have now is the following.
Lets say I have an edit form with a "Name" field.
If the Name contains no special chars like "ä","ö","ü" etc. the value
of the field is filled automatically through the $form helper, but if
the Name contains one of those special chars, the field is not filled.
I don't know how to solve this.
Please help me as I'm stuck here.
Thanks in advance
worthy
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---