Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php defined('SYSPATH') or die('No direct access allowed.');
- class Term
- {
- public static $terms = NULL;
- public static function load(){
- Term::$terms = ORM::factory('term')->find_all()->as_array('id', 'min_text');
- }
- public static function replace($str){
- return preg_replace_callback('#<abbr id="(.+?)\"\>(.*?)\<\/abbr\>#msi', "Term::term_url", $str);
- }
- public static function term_url($arg = array())
- {
- if(Term::$terms === NULL)
- Term::load();
- return (Arr::get($arg, 1) and Arr::get($arg, 2))?Html::anchor('/term#term-'.$arg[1], Arr::get($arg, 2), array('class'=>'def', 'rel'=>Arr::get(Term::$terms, $arg[1]))):Arr::get($arg, 2, '');
- }
- }
Add Comment
Please, Sign In to add comment