Example #1
0
<?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();
}
Example #2
0
$totalitems = $db->countRows($db_bbcode);
// FIXME AJAX-based pagination doesn't work because of some strange PHP bug
// Xtpl_block->text() returns 'str' instead of a long string which it has in $text
//$pagenav = cot_pagenav('admin', 'm=other&p=bbcode', $d, $totalitems, $maxperpage, 'd', '', $cfg['jquery'] && $cfg['turnajax']);
$pagenav = cot_pagenav('admin', 'm=other&p=bbcode', $d, $totalitems, $maxperpage, 'd');
/* === Hook === */
foreach (cot_getextplugins('bbcode.admin.first') as $pl) {
    include $pl;
}
/* ===== */
$fields = array('name' => 'ALP', 'mode' => 'ALP', 'pattern' => 'HTM', 'priority' => 'INT', 'container' => 'BOL', 'replacement' => 'HTM', 'postrender' => 'BOL', 'enabled' => 'BOL');
$bbc = cot_import_list($fields, 'P', null, 'bbc_');
if ($a == 'add') {
    if (!empty($bbc['name']) && !empty($bbc['pattern']) && !empty($bbc['replacement'])) {
        cot_bbcode_clearcache();
        cot_bbcode_add($bbc['name'], $bbc['mode'], $bbc['pattern'], $bbc['replacement'], $bbc['container'], $bbc['priority'], '', $bbc['postrender']) ? cot_message('adm_bbcodes_added') : cot_error('adm_bbcodes_added');
    } else {
        cot_error('adm_bbcodes_notallfields');
    }
} elseif ($a == 'upd') {
    $bbca = cot_import_tabledata($fields, 'P', 'bbca_');
    $updated = 0;
    $errors = 0;
    foreach ($bbca as $id => $bbc) {
        if (!empty($bbc['name']) && !empty($bbc['pattern']) && !empty($bbc['replacement'])) {
            cot_bbcode_update($id, $bbc['enabled'], $bbc['name'], $bbc['mode'], $bbc['pattern'], $bbc['replacement'], $bbc['container'], $bbc['priority'], $bbc['postrender']) ? $updated++ : $errors++;
        }
    }
    if ($updated == sizeof($bbca)) {
        cot_message('adm_bbcodes_updated');
    } else {