Chciałem napisać plugin w którym możemy zmienić kolorowanie składni, pisałem na podstawie:
i mam coś takiego:
i problem mam taki iż nie wiem jak umieścić to w showthread coś robię na bank źle wiec piszę do was z proźbą o pomoc. Piszę to z myślą aby było łatwiej zmienić kolorowanie bez konieczności edytowania plików silnika.
https://webboard.pl/thread-53369.html
<?php
if(!defined("IN_MYBB"))
{
die("Direct initialization of this file is not allowed.<br /><br />Please make sure IN_MYBB is defined.");
}
$plugins->add_hook("global_start", "phpcolors");
$plugins->add_hook("showthread_start", "phpcolors");
function phpcolors_info()
{
global $lang, $db;
$lang->load('phpcolors');
$query = $db->simple_select('settinggroups', '*', "name='phpcolors'");
if (count($db->fetch_array($query)))
$settings_link = '(<a href="index.php?module=config&action=change&search=phpcolors" style="color:#FF1493;font-weight:bold;">'.'Ustawienia'.'</a>)';
return array(
"name" => $lang->phpcolors_name,
"description" => $lang->phpcolors_desc . $settings_link,
"website" => "http://mybbsecurity.net/",
"author" => "Nathan Malcolm",
"authorsite" => "http://mybbsecurity.net/",
"version" => "1.0",
"guid" => "",
"compatibility" => "*"
);
}
function phpcolors_activate()
{
require MYBB_ROOT."inc/adminfunctions_templates.php";
global $db;
$result = $db->simple_select('settinggroups', 'MAX(disporder) AS max_disporder');
$max_disporder = $db->fetch_field($result, 'max_disporder');
$disporter = 1;
$insertarray = array(
'gid' => 'NULL',
'name' => 'phpcolors',
'title' => 'Zmień kolory kodu PHP',
'description' => 'Ten plugin pomoże zmienić kolory kodu PHP.',
'disporder' => $max_disporder + 1,
'isdefault' => 'no'
);
$db->insert_query("settinggroups", $insertarray);
$group['gid'] = $db->insert_id();
$settings = array(
'name' => 'phpcolors',
'title' => 'Zmień kolory kodu PHP',
'description' => 'Chcesz włączyć?',
'optionscode' => 'yesno',
'value' => 'yes',
'disporder' => $disporter++,
'gid' => $group['gid'],
);
$db->insert_query('settings', $settings);
$settings1 = array(
'name' => 'highlight.string',
'title' => 'Kolor string',
'description' => 'Tu podaj kolor HEX',
'optionscode' => 'text',
'value' => '#C0FF21',
'disporder' => $disporter++,
'gid' => $group['gid'],
);
$db->insert_query('settings', $settings1);
$settings2 = array(
'name' => 'highlight.comment',
'title' => 'Kolor comment',
'description' => 'Tu podaj kolor HEX',
'optionscode' => 'text',
'value' => '#1E90FF',
'disporder' => $disporter++,
'gid' => $group['gid'],
);
$db->insert_query('settings', $settings2);
$settings3 = array(
'name' => 'highlight.keyword',
'title' => 'Kolor keyword',
'description' => 'Tu podaj kolor HEX',
'optionscode' => 'text',
'value' => '#FFC0CB',
'disporder' => $disporter++,
'gid' => $group['gid'],
);
$db->insert_query('settings', $settings3);
$settings4 = array(
'name' => 'highlight.default',
'title' => 'Kolor default',
'description' => 'Tu podaj kolor HEX',
'optionscode' => 'text',
'value' => '#cecece',
'disporder' => $disporter++,
'gid' => $group['gid'],
);
$db->insert_query('settings', $settings4);
}
function phpcolors_deactivate(){
global $db;
$db->delete_query("settings", "name='phpcolors'");
$db->delete_query("settings", "name='highlight.string'");
$db->delete_query("settings", "name='highlight.comment'");
$db->delete_query("settings", "name='highlight.keyword'");
$db->delete_query("settings", "name='highlight.default'");
$db->delete_query("settinggroups", "name='phpcolors'");
}
function phpcolors_insert(){
global $mybb;
if(intval($mybb->settings['phpcolors']) == 1){
ini_set('highlight.string', ''.$mybb->settings['highlight.string'].'');
ini_set('highlight.comment', ''.$mybb->settings['highlight.comment'].'');
ini_set('highlight.keyword', ''.$mybb->settings['highlight.keyword'].'');
ini_set('highlight.default', ''.$mybb->settings['highlight.default'].'');
}}
?>