Revision [10334]

This is an old revision of UncamelAction made by DennyShimkoski on 2005-08-01 05:30:38.

 

Uncamel The Horses!


Basically -- Keep everything CamelCased in the database, but Uncamel The Links when the page is output.

The following code is designed to be used with the OnPageLoadWithGlobalActions OnPageLoadAction. Just save the code below as "uncamel.php" in the actions directory and you're ready to go!

<?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 you'd like to apply it across the site, create a page called GlobalActions and drop the following line of code in...

{{onpageload uncamel=""}}


Authors


DennyShimkoski


CategoryUserContributions
There is one comment on this page. [Display comment]
Valid XHTML :: Valid CSS: :: Powered by WikkaWiki