Beispiel #1
0
/**
 * Imports data from the outer world as indexed array of records imported by cot_import_list.
 * Used to import table editing data as one array ordered by index (IDs) of table lines.
 *
 * @param For parameters see `cot_import_list`:
 *
 * @return  boolean|array Returns indexed array of data or FALSE if wrong parameters setted
 */
function cot_import_tabledata($nameslist = array(), $source = 'P', $nameprefix = '', $origindata = array(), $maxlen = 0, $dieonerror = false, $buffer = false)
{
    $imported_arrays = cot_import_list($nameslist, $source, $origindata, $nameprefix, 'ARR', $maxlen, $dieonerror, $buffer);
    if (!$imported_arrays) {
        return false;
    }
    $result = array();
    $na_data = array();
    foreach ($imported_arrays as $name => $data) {
        if (!is_array($data)) {
            $na_data[$name] = $data;
            unset($imported_arrays[$name]);
        }
    }
    foreach ($imported_arrays as $name => $data) {
        if (is_array($data)) {
            foreach ($data as $index => $value) {
                $result[$index][$name] = $value;
                foreach ($na_data as $k => $v) {
                    $result[$index][$k] = $v;
                }
            }
        }
    }
    return $result;
}
Beispiel #2
0
$a = cot_import('a', 'G', 'ALP');
$id = (int) cot_import('id', 'G', 'INT');
$maxperpage = $cfg['maxrowsperpage'] && is_numeric($cfg['maxrowsperpage']) && $cfg['maxrowsperpage'] > 0 ? $cfg['maxrowsperpage'] : 15;
list($pg, $d, $durl) = cot_import_pagenav('d', $maxperpage);
$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++;
        }