Revision [19242]
This is an old revision of UncamelAction made by DennyShimkoski on 2008-01-28 00:14:44.
Uncamel The Camels!
Keep everything CamelCased in the database, but Uncamel The Camels when the page is output.
The following code is designed to be used with the OnPageLoadWithGlobalActions OnPageLoadAction. Look there for examples.
Save the following as actions/uncamel.php...
<?php
if (!function_exists('uncamel'))
{
function uncamel($matches)
{
$text = preg_match_all('/([A-Z][^A-Z]*)/', $matches[2], $words) ? join(' ', $words[1]) : $matches[2];
return "<a$matches[1]>$text</a>";
}
}
$this->page['body'] = preg_replace_callback('|<a([^>]+)>(.*)</a>|smU', 'uncamel', $this->page['body']);
?>
if (!function_exists('uncamel'))
{
function uncamel($matches)
{
$text = preg_match_all('/([A-Z][^A-Z]*)/', $matches[2], $words) ? join(' ', $words[1]) : $matches[2];
return "<a$matches[1]>$text</a>";
}
}
$this->page['body'] = preg_replace_callback('|<a([^>]+)>(.*)</a>|smU', 'uncamel', $this->page['body']);
?>
Authors
DennyShimkoski
CategoryUserContributions