function dt_block_categories($options)
{
    include_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtcategory.class.php';
    $rmu = RMUtilities::get();
    $rmf = RMFunctions::get();
    $mc = $rmu->module_config('dtransport');
    $url = $rmf->current_url();
    $rpath = parse_url($url);
    $xpath = parse_url(XOOPS_URL);
    if ($mc['permalinks']) {
        $params = trim(str_replace($xpath['path'] . '/' . trim($mc['htbase'], '/'), '', rtrim($rpath['path'], "/")), '/');
        $search = array('category', 'publisher', 'recents', 'popular', 'rated', 'updated');
        if ($params == '') {
            $params = array();
        } else {
            $params = explode("/", trim($params));
        }
        if (!empty($params) && $params[0] == 'category') {
            $db = XoopsDatabaseFactory::getDatabaseConnection();
            $params = explode("page", implode("/", array_slice($params, 1)));
            $path = explode("/", $params[0]);
            foreach ($path as $k) {
                if ($k == '') {
                    continue;
                }
                $category = new DTCategory();
                $sql = "SELECT * FROM " . $db->prefix("dtrans_categos") . " WHERE nameid='{$k}' AND parent='{$idp}'";
                $result = $db->query($sql);
                if ($db->getRowsNum($result) > 0) {
                    $row = $db->fetchArray($result);
                    $idp = $row['id_cat'];
                    $category->assignVars($row);
                } else {
                    $dtfunc->error_404();
                }
            }
        } else {
            $category = new DTCategory();
        }
    }
    $tpl = RMTemplate::get();
    $tpl->add_xoops_style('blocks.css', 'dtransport');
    include_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dtfunctions.class.php';
    $categories = array();
    $dtfunc = new DTFunctions();
    $dtfunc->getCategos($categories, 0, $category->id(), array(), false, 1);
    $block = array();
    foreach ($categories as $cat) {
        if ($cat['jumps'] > $options[0] - 1 && $options[0] > 0) {
            continue;
        }
        $block['categories'][] = $cat;
    }
    if (!$category->isNew()) {
        $block['parent'] = array('name' => $category->name(), 'link' => $category->permalink());
    }
    return $block;
}
Beispiel #2
0
/**
* @desc Elimina las categorías especificadas
**/
function deleteCategos()
{
    global $xoopsModule, $xoopsSecurity;
    $ids = rmc_server_var($_POST, 'ids', array());
    //Verificamos si nos proporcionaron alguna categoria
    if (!is_array($ids) || empty($ids)) {
        redirectMsg('./categories.php', __('You must select at least one category to delete!', 'dtransport'), 1);
    }
    if (!$xoopsSecurity->check()) {
        redirectMsg('categories.php', __('Session token expired!', 'dtransport'), 1);
    }
    $errors = '';
    foreach ($ids as $k) {
        //Verificamos si la categoría es válida
        if ($k <= 0) {
            $errors .= sprintf(__('Category ID "%s" is not valid!', 'dtransport'), $k);
            continue;
        }
        //verificamos si la categoría existe
        $cat = new DTCategory($k);
        if ($cat->isNew()) {
            $errors .= sprintf(__('Category "%s" does not exists!', 'dtransport'), $k);
            continue;
        }
        if (!$cat->delete()) {
            $errors .= sprintf(__('Category "%s" could not be deleted!', 'dtransport'), $cat->name());
        }
    }
    if ($errors != '') {
        redirectMsg('categories.php', __('There was errors trying to delete categories', 'dtransport') . '<br />' . $errors, 1);
        die;
    } else {
        redirectMsg('categories.php', __('Categories deleted successfully!', 'dtransport'), 0);
        die;
    }
}