<?php /** * markItUp! install handler * * @package MarItUp * @copyright (c) Cotonti Team * @license https://github.com/Cotonti/Cotonti/blob/master/License.txt */ defined('COT_CODE') or die('Wrong URL'); // Installing new bbcodes if (cot_plugin_active('bbcode')) { require_once cot_incfile('bbcode', 'plug'); cot_bbcode_remove(0, 'markitup'); cot_bbcode_add('size', 'pcre', '\\[size=([1-2][0-9])\\](.+?)\\[/size\\]', '<span style="font-size:$1pt">$2</span>', true, 128, 'markitup'); cot_bbcode_add('table', 'str', '[table]', '<table>', true, 128, 'markitup'); cot_bbcode_add('table', 'str', '[/table]', '</table>', true, 128, 'markitup'); cot_bbcode_add('tr', 'str', '[tr]', '<tr>', true, 128, 'markitup'); cot_bbcode_add('tr', 'str', '[/tr]', '</tr>', true, 128, 'markitup'); cot_bbcode_add('th', 'str', '[th]', '<th>', true, 128, 'markitup'); cot_bbcode_add('th', 'str', '[/th]', '</th>', true, 128, 'markitup'); cot_bbcode_add('td', 'str', '[td]', '<td>', true, 128, 'markitup'); cot_bbcode_add('td', 'str', '[/td]', '</td>', true, 128, 'markitup'); cot_bbcode_add('hide', 'callback', '\\[hide\\](.+?)\\[/hide\\]', 'return $usr["id"] > 0 ? $input[1] : "<div class=\\"hidden\\">".$L["Hidden"]."</div>";', true, 150, 'markitup', true); cot_bbcode_add('spoiler', 'pcre', '\\[spoiler\\](.+?)\\[/spoiler\\]', '<div style="margin:4px 0px 4px 0px"><input type="button" value="' . $L['Show'] . '" onclick="if(this.parentNode.getElementsByTagName(\'div\')[0].style.display != \'\') { this.parentNode.getElementsByTagName(\'div\')[0].style.display = \'\'; } else { this.parentNode.getElementsByTagName(\'div\')[0].style.display = \'none\'; }" /><div style="display:none" class="spoiler">$1</div></div>', true, 130, 'markitup'); cot_bbcode_add('spoiler', 'pcre', '\\[spoiler=([^\\]]+)\\](.+?)\\[/spoiler\\]', '<div style="margin:4px 0px 4px 0px"><input type="button" value="$1" onclick="if(this.parentNode.getElementsByTagName(\'div\')[0].style.display != \'\') { this.parentNode.getElementsByTagName(\'div\')[0].style.display = \'\'; } else { this.parentNode.getElementsByTagName(\'div\')[0].style.display = \'none\'; }" /><div style="display:none" class="spoiler">$2</div></div>', true, 130, 'markitup'); cot_bbcode_clearcache(); }
cot_message('adm_bbcodes_updated'); } else { if ($updated + $errors != sizeof($bbca)) { cot_error('adm_bbcodes_fieldrequired'); } if ($errors) { cot_message('adm_bbcodes_notupdated'); } } if ($updated) { cot_bbcode_clearcache(); } unset($bbca, $bbc); } elseif ($a == 'del' && $id > 0) { cot_bbcode_clearcache(); cot_bbcode_remove($id) ? cot_message('adm_bbcodes_removed') : cot_error('adm_bbcodes_notremoved'); } elseif ($a == 'clearcache') { cot_bbcode_clearcache(); cot_message('adm_bbcodes_clearcache_done'); } elseif ($a == 'convert') { // Convert from BBcode to HTML if ($b == 'page') { require_once cot_incfile('page', 'module'); // Attempt to override from HTML cache if ($db->fieldExists($db_pages, 'page_html')) { $db->query("UPDATE {$db_pages} SET page_text = page_html, page_parser = 'html' WHERE page_html != '' AND page_parser = 'bbcode'"); $db->query("ALTER TABLE {$db_pages} DROP COLUMN page_html"); } // Update manually $res = $db->query("SELECT page_text, page_id FROM {$db_pages} WHERE page_parser = 'bbcode'"); while ($row = $res->fetch()) {