blog->settings->kUtRL; # Do nothing on comment preview and post preview if (!empty($_POST['preview']) || !empty($GLOBALS['_ctx']) && $GLOBALS['_ctx']->preview || !$s->kutrl_active) return; if (null === ($kut = kutrl::quickPlace('wiki'))) return; foreach($kut->allow_protocols as $protocol) { $wiki2xhtml->registerFunction( 'url:'.$protocol, array('kutrlWiki','transform') ); } } public static function transform($url,$content) { global $core; $s = $core->blog->settings->kUtRL; if (!$s->kutrl_active) return; if (null === ($kut = kutrl::quickPlace('wiki'))) return array(); # Test if long url exists $is_new = false; $rs = $kut->isKnowUrl($url); if (!$rs) { $is_new = true; $rs = $kut->hash($url); } if (!$rs) { return array(); } else { $res = array(); $testurl = strlen($rs->url) > 35 ? substr($rs->url,0,35).'...' : $rs->url; $res['url'] = $kut->url_base.$rs->hash; $res['title'] = sprintf(__('%s (Shorten with %s)'),$rs->url,__($kut->name)); if ($testurl == $content) $res['content'] = $res['url']; # ex: Send new url to messengers if (!empty($rs)) { $core->callBehavior('wikiAfterKutrlCreate',$core,$rs,__('New short URL')); } return $res; } } } ?>