Skip to content

Instantly share code, notes, and snippets.

@morimori
Created April 17, 2009 17:38
Show Gist options
  • Save morimori/97152 to your computer and use it in GitHub Desktop.
Save morimori/97152 to your computer and use it in GitHub Desktop.
要素にユーザ指定の関数を適用する Nucleus plugin
<?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: &lt;%CustomFilter(body,\'"<strong>".%s."</strong>"\')%&gt;'; }
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