Guest User

Untitled

a guest
Apr 23rd, 2018
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. <?php defined('SYSPATH') or die('No direct access allowed.');
  2.  
  3. class Term
  4. {
  5. public static $terms = NULL;
  6.  
  7. public static function load(){
  8. Term::$terms = ORM::factory('term')->find_all()->as_array('id', 'min_text');
  9. }
  10.  
  11. public static function replace($str){
  12. return preg_replace_callback('#<abbr id="(.+?)\"\>(.*?)\<\/abbr\>#msi', "Term::term_url", $str);
  13. }
  14.  
  15. public static function term_url($arg = array())
  16. {
  17. if(Term::$terms === NULL)
  18. Term::load();
  19. 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, '');
  20. }
  21. }
Add Comment
Please, Sign In to add comment