yash3/inc/yash3.behaviors.php

43 lines
1.2 KiB
PHP
Raw Normal View History

2016-12-01 19:27:25 +01:00
<?php
# -- BEGIN LICENSE BLOCK ----------------------------------
2016-12-16 19:23:05 +01:00
# This file is part of yash3, a plugin for Dotclear 2.
2016-12-01 19:27:25 +01:00
#
# Copyright (c) Franck Paul and contributors
# carnet.franck.paul@gmail.com
#
# Licensed under the GPL version 2.0 license.
# A copy of this license is available in LICENSE file or at
# http://www.gnu.org/licenses/old-licenses/gpl-2.0.html
# -- END LICENSE BLOCK ------------------------------------
2016-12-16 19:23:05 +01:00
class yash3Behaviors
2016-12-01 19:27:25 +01:00
{
public static function adminPostEditor($editor='',$context='',array $tags=array(),$syntax='')
{
global $core;
if ($editor != 'dcLegacyEditor') return;
return
2016-12-16 19:23:05 +01:00
dcPage::jsLoad(urldecode(dcPage::getPF('yash3/js/post.js')),$core->getVersion('yash')).
2016-12-01 19:27:25 +01:00
'<script type="text/javascript">'."\n".
"//<![CDATA[\n".
2016-12-16 19:23:05 +01:00
dcPage::jsVar('jsToolBar.prototype.elements.yash3.title',__('Highlighted Code')).
2016-12-01 19:27:25 +01:00
"\n//]]>\n".
"</script>\n";
}
public static function coreInitWikiPost($wiki2xhtml)
{
2016-12-19 19:03:24 +01:00
$wiki2xhtml->registerFunction('macro:yash3',array('yash3Behaviors','transform'));
2016-12-01 19:27:25 +01:00
}
public static function transform($text,$args)
{
$text = trim($text);
$real_args = explode(' ',$args);
$class = empty($real_args[1])?'plain':$real_args[1];
return '<pre class="brush: '.$class.'">'.htmlspecialchars($text).'</pre>';
}
}