Created
April 17, 2009 17:38
-
-
Save morimori/97152 to your computer and use it in GitHub Desktop.
要素にユーザ指定の関数を適用する Nucleus plugin
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
class NP_CustomFilter extends NucleusPlugin { | |
function getName() { return 'NP_CustomFilter'; } | |
function getAuthor() { return 'Takatoshi -morimori- MORIYAMA'; } | |
function getURL() { return 'http://kray.jp/'; } | |
function getVersion() { return '1.0'; } | |
function getDescription() { return 'in template: <%CustomFilter(body,\'"<strong>".%s."</strong>"\')%>'; } | |
function supportsFeature($what) { | |
switch($what) { | |
case 'SqlTablePrefix': | |
return 1; | |
default: | |
return 0; | |
} | |
} | |
function doTemplateVar(&$item, $column, $code, $comma_template = '#C#') { | |
$code = str_replace($comma_template, ',', $code); | |
$result = eval('return '.sprintf($code, '$item->'.$column).';'); | |
if ($result) { | |
echo $result; | |
} else { | |
echo 'CustomFilter error: '.htmlspecialchars('return '.sprintf($code, '$item->'.$column).';'); | |
} | |
} | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment