Ejemplo n.º 1
0
/**
* Display two lists of blocks, separated by left and right
*
* @return   string  HTML for the two lists
*
*/
function listblocks()
{
    global $_CONF, $_TABLES, $LANG_ADMIN, $LANG21, $_IMAGE_TYPE;
    require_once $_CONF['path_system'] . 'lib-admin.php';
    $retval = '';
    $token = SEC_createToken();
    // writing the menu on top
    $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/block.php?mode=edit', 'text' => $LANG_ADMIN['create_new']), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home']));
    $retval .= COM_startBlock($LANG21[19], '', COM_getBlockTemplate('_admin_block', 'header'));
    $retval .= ADMIN_createMenu($menu_arr, $LANG21[25], $_CONF['layout_url'] . '/images/icons/block.' . $_IMAGE_TYPE);
    reorderblocks();
    // Left
    // Regular Blocks
    $header_arr = array(array('text' => $LANG_ADMIN['edit'], 'field' => 'edit', 'sort' => false), array('text' => $LANG21[65], 'field' => 'blockorder', 'sort' => true), array('text' => $LANG21[46], 'field' => 'move', 'sort' => false), array('text' => $LANG_ADMIN['title'], 'field' => 'title', 'sort' => true), array('text' => $LANG21[48], 'field' => 'name', 'sort' => true), array('text' => $LANG_ADMIN['type'], 'field' => 'type', 'sort' => true), array('text' => $LANG_ADMIN['topic'], 'field' => 'topic', 'sort' => true), array('text' => $LANG_ADMIN['enabled'], 'field' => 'is_enabled', 'sort' => true));
    $defsort_arr = array('field' => 'blockorder', 'direction' => 'asc');
    $text_arr = array('has_extras' => true, 'title' => "{$LANG21['20']} ({$LANG21['40']})", 'form_url' => $_CONF['site_admin_url'] . '/block.php');
    $query_arr = array('table' => 'blocks', 'sql' => "SELECT * FROM {$_TABLES['blocks']} WHERE onleft = 1", 'query_fields' => array('title', 'content'), 'default_filter' => COM_getPermSql('AND'));
    // this is a dummy variable so we know the form has been used if all blocks
    // should be disabled on one side in order to disable the last one.
    // The value is the onleft var
    $form_arr = array('top' => '<input type="hidden" name="' . CSRF_TOKEN . '" value="' . $token . '"' . XHTML . '>', 'bottom' => '<input type="hidden" name="blockenabler" value="1"' . XHTML . '>');
    $retval .= ADMIN_list('blocks', 'ADMIN_getListField_blocks', $header_arr, $text_arr, $query_arr, $defsort_arr, '', $token, '', $form_arr);
    // Dynamic blocks
    $dyn_header_arr = array(array('text' => $LANG21[65], 'field' => 'blockorder', 'sort' => true), array('text' => $LANG21[69], 'field' => 'plugin', 'sort' => true), array('text' => $LANG_ADMIN['title'], 'field' => 'title', 'sort' => true), array('text' => $LANG21[48], 'field' => 'name', 'sort' => true), array('text' => $LANG_ADMIN['type'], 'field' => 'type', 'sort' => true), array('text' => $LANG_ADMIN['topic'], 'field' => 'topic', 'sort' => true), array('text' => $LANG_ADMIN['enabled'], 'field' => 'is_enabled', 'sort' => true));
    $dyn_text_arr = array('title' => "{$LANG21['22']} ({$LANG21['40']})", 'form_url' => $_CONF['site_admin_url'] . '/block.php');
    $leftblocks = PLG_getBlocksConfig('left', '');
    // Sort Dynamic Blocks on Block Order
    usort($leftblocks, "cmpDynamicBlocks");
    $retval .= ADMIN_simpleList('ADMIN_getListField_dynamicblocks', $dyn_header_arr, $dyn_text_arr, $leftblocks, '', $form_arr);
    // Right
    // Regular Blocks
    $query_arr = array('table' => 'blocks', 'sql' => "SELECT * FROM {$_TABLES['blocks']} WHERE onleft = 0", 'query_fields' => array('title', 'content'), 'default_filter' => COM_getPermSql('AND'));
    $text_arr = array('has_extras' => true, 'title' => "{$LANG21['20']} ({$LANG21['41']})", 'form_url' => $_CONF['site_admin_url'] . '/block.php');
    // this is a dummy-variable so we know the form has been used if all blocks should be disabled
    // on one side in order to disable the last one. The value is the onleft var
    $form_arr = array('top' => '<input type="hidden" name="' . CSRF_TOKEN . '" value="' . $token . '"' . XHTML . '>', 'bottom' => '<input type="hidden" name="blockenabler" value="0"' . XHTML . '>');
    $retval .= ADMIN_list('blocks', 'ADMIN_getListField_blocks', $header_arr, $text_arr, $query_arr, $defsort_arr, '', $token, '', $form_arr);
    // Dynamic blocks
    $dyn_text_arr = array('title' => "{$LANG21['22']} ({$LANG21['41']})", 'form_url' => $_CONF['site_admin_url'] . '/block.php');
    $rightblocks = PLG_getBlocksConfig('right', '');
    // Sort Dynamic Blocks on Block Order
    usort($rightblocks, "cmpDynamicBlocks");
    $retval .= ADMIN_simpleList('ADMIN_getListField_dynamicblocks', $dyn_header_arr, $dyn_text_arr, $rightblocks, '', $form_arr);
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}
Ejemplo n.º 2
0
/**
 * Display two lists of blocks, separated by left and right
 *
 * @return   string  HTML for the two lists
 */
function listblocks($position = BLOCK_ALL_POSITIONS)
{
    global $_CONF, $_TABLES, $LANG_ADMIN, $LANG21, $_IMAGE_TYPE;
    require_once $_CONF['path_system'] . 'lib-admin.php';
    $retval = '';
    $token = SEC_createToken();
    // writing the menu on top
    $menu_arr = array(array('url' => $_CONF['site_admin_url'] . '/block.php?mode=edit', 'text' => $LANG_ADMIN['create_new']), array('url' => $_CONF['site_admin_url'], 'text' => $LANG_ADMIN['admin_home']));
    $retval .= COM_startBlock($LANG21[19], '', COM_getBlockTemplate('_admin_block', 'header'));
    $retval .= ADMIN_createMenu($menu_arr, $LANG21[25], $_CONF['layout_url'] . '/images/icons/block.' . $_IMAGE_TYPE);
    reorderblocks();
    // Regular Blocks
    switch ($position) {
        case BLOCK_NONE_POSITION:
        case BLOCK_LEFT_POSITION:
        case BLOCK_RIGHT_POSITION:
            break;
        default:
            $position = BLOCK_ALL_POSITIONS;
            break;
    }
    $show_position = '';
    $position_filter = '<option value="' . BLOCK_ALL_POSITIONS . '" title="' . $LANG21[7] . '"';
    if ($position == BLOCK_ALL_POSITIONS) {
        $position_filter .= ' selected="selected"';
    } else {
        $show_position = ' AND onleft = ' . $position;
    }
    $position_filter .= '>' . $LANG21[7] . '</option>';
    $position_filter .= '<option value="' . BLOCK_LEFT_POSITION . '" title="' . $LANG21[40] . '"';
    if ($position == BLOCK_LEFT_POSITION) {
        $position_filter .= ' selected="selected"';
    }
    $position_filter .= '>' . $LANG21[40] . '</option>';
    $position_filter .= '<option value="' . BLOCK_RIGHT_POSITION . '" title="' . $LANG21[41] . '"';
    if ($position == BLOCK_RIGHT_POSITION) {
        $position_filter .= ' selected="selected"';
    }
    $position_filter .= '>' . $LANG21[41] . '</option>';
    $position_filter .= '<option value="' . BLOCK_NONE_POSITION . '" title="' . $LANG21[47] . '"';
    if ($position == BLOCK_NONE_POSITION) {
        $position_filter .= ' selected="selected"';
    }
    $position_filter .= '>' . $LANG21[47] . '</option>';
    $filter = $LANG21['position'] . ': <select name="position" style="width: 125px" onchange="this.form.submit()">' . $position_filter . '</select>';
    $header_arr = array(array('text' => $LANG_ADMIN['edit'], 'field' => 'edit', 'sort' => false), array('text' => $LANG21['position'], 'field' => 'onleft', 'sort' => false), array('text' => $LANG21[65], 'field' => 'blockorder', 'sort' => true, 'sort_field' => 'onleft DESC, blockorder'), array('text' => $LANG21[46], 'field' => 'move', 'sort' => false), array('text' => $LANG_ADMIN['device'], 'field' => 'device', 'sort' => true), array('text' => $LANG_ADMIN['title'], 'field' => 'title', 'sort' => true), array('text' => $LANG21[48], 'field' => 'name', 'sort' => true), array('text' => $LANG_ADMIN['type'], 'field' => 'type', 'sort' => true), array('text' => $LANG_ADMIN['topic'], 'field' => 'topic', 'sort' => true), array('text' => $LANG_ADMIN['enabled'], 'field' => 'is_enabled', 'sort' => true));
    // Sort by position and then order for default
    $defsort_arr = array('field' => 'onleft DESC, blockorder', 'direction' => 'asc');
    $text_arr = array('has_extras' => true, 'title' => $LANG21[20], 'form_url' => $_CONF['site_admin_url'] . '/block.php');
    $query_arr = array('table' => 'blocks', 'sql' => "SELECT * FROM {$_TABLES['blocks']} WHERE 1=1 ", 'query_fields' => array('title', 'content'), 'default_filter' => $show_position . COM_getPermSQL('AND'));
    // this is a dummy variable so we know the form has been used if all blocks
    // should be disabled on one side in order to disable the last one.
    // The value is the onleft var
    $form_arr = array('top' => '<input type="hidden" name="' . CSRF_TOKEN . '" value="' . $token . '"' . XHTML . '>', 'bottom' => '<input type="hidden" name="blockenabler" value="1"' . XHTML . '>');
    // Add in position filter so it is remembered with paging
    $pagenavurl = '&amp;position=' . $position;
    $retval .= ADMIN_list('blocks', 'ADMIN_getListField_blocks', $header_arr, $text_arr, $query_arr, $defsort_arr, $filter, $token, '', $form_arr, true, $pagenavurl);
    // Dynamic blocks
    $dyn_header_arr = array(array('text' => $LANG21['position'], 'field' => 'onleft'), array('text' => $LANG21[65], 'field' => 'blockorder'), array('text' => $LANG21[69], 'field' => 'plugin'), array('text' => $LANG_ADMIN['title'], 'field' => 'title'), array('text' => $LANG21[48], 'field' => 'name'), array('text' => $LANG_ADMIN['type'], 'field' => 'type'), array('text' => $LANG_ADMIN['topic'], 'field' => 'topic'), array('text' => $LANG_ADMIN['enabled'], 'field' => 'is_enabled'));
    $dyn_text_arr = array('title' => $LANG21[22], 'form_url' => $_CONF['site_admin_url'] . '/block.php');
    $leftblocks = PLG_getBlocksConfig('left', '');
    // Sort Dynamic Blocks on Block Order
    usort($leftblocks, "cmpDynamicBlocks");
    $rightblocks = PLG_getBlocksConfig('right', '');
    // Sort Dynamic Blocks on Block Order
    usort($rightblocks, "cmpDynamicBlocks");
    $dynamicblocks = array_merge($leftblocks, $rightblocks);
    $retval .= ADMIN_simpleList('ADMIN_getListField_dynamicblocks', $dyn_header_arr, $dyn_text_arr, $dynamicblocks, '', $form_arr);
    $retval .= COM_endBlock(COM_getBlockTemplate('_admin_block', 'footer'));
    return $retval;
}