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;
}
Ejemplo n.º 2
0
    die;
}
$p = $page > 0 ? $page - 1 : $page;
$start = $num <= 0 ? 0 : $p * $limit;
$nav = new RMPageNav($num, $limit, $page);
$nav->target_url($category->permalink() . ($mc['permalinks'] ? 'page/{PAGE_NUM}/' : '?page={PAGE_NUM}'));
$xoopsTpl->assign('pagenav', $nav->render(true));
// Seleccionamos los registros
$sql = str_replace('COUNT(*)', 's.*', $sql);
$sql .= " ORDER BY s.modified DESC";
$sql .= " LIMIT {$start}, {$limit}";
$result = $db->queryF($sql);
while ($row = $db->fetchArray($result)) {
    $item = new DTSoftware();
    $item->assignVars($row);
    $xoopsTpl->append('download_items', array_merge($dtfunc->createItemData($item), array('category' => $category->name())));
}
if ($mc['inner_dest_download']) {
    $xoopsTpl->assign('featured_items', $dtfunc->get_items($category->id(), 'featured', $mc['limit_destdown']));
    $xoopsTpl->assign('lang_incatego', __('In <a href="%s">%s</a>', 'dtransport'));
}
// Descargas el día
if ($mc['inner_daydownload']) {
    $xoopsTpl->assign('daily_items', $dtfunc->get_items($category->id(), 'daily', $mc['limit_daydownload']));
    $xoopsTpl->assign('daily_width', floor(100 / $mc['limit_daydownload']));
    $xoopsTpl->assign('lang_daydown', __('<strong>Day</strong> Downloads', 'dtransport'));
}
$xoopsTpl->assign('xoops_pagetitle', $category->name() . " &raquo; " . $xoopsModule->name());
$xoopsTpl->assign('lang_in', sprintf(__('<strong>Downloads in</strong> %s', 'dtransport'), $category->name()));
$xoopsTpl->assign('lang_featured', sprintf(__('<strong>%s</strong> Featured Downloads', 'dtransport'), $category->name()));
$xoopsTpl->assign('lang_download', __('Download', 'dtransport'));
Ejemplo n.º 3
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;
    }
}
Ejemplo n.º 4
0
/**
* @desc Formulario de Elementos
**/
function formItems($edit = 0)
{
    global $xoopsModule, $xoopsConfig, $xoopsModuleConfig, $rmc_config, $xoopsSecurity, $functions;
    define('RMCSUBLOCATION', 'newitem');
    // Get layout data
    $id = intval(rmc_server_var($_REQUEST, 'id', 0));
    $page = intval(rmc_server_var($_REQUEST, 'page', 0));
    $search = rmc_server_var($_REQUEST, 'search', '');
    $sort = rmc_server_var($_REQUEST, 'sort', 'id_soft');
    $mode = intval(rmc_server_var($_REQUEST, 'mode', 0));
    $catid = intval(rmc_server_var($_REQUEST, 'car', 0));
    $type = rmc_server_var($_REQUEST, 'type', '');
    $ev = RMEvents::get();
    $params = '?page=' . $page . '&search=' . $search . '&sort=' . $sort . '&mode=' . $mode . '&cat=' . $catid . '&type=' . $type;
    if ($edit) {
        //Verificamos que el software sea válido
        if ($id <= 0) {
            redirectMsg('items.php' . $params, __('Download item has not been specified!', 'dtransport'), 1);
            die;
        }
        //Verificamos que el software exista
        if ($type == 'edit') {
            $sw = new DTSoftwareEdited($id);
            $location = __('Verifying edited item!', 'dtransport');
        } else {
            $sw = new DTSoftware($id);
            $location = __('Editing download item', 'dtransport');
        }
        if ($sw->isNew()) {
            redirectMsg('./items.php' . $params, __('Specified download item does not exists!', 'dtransport'), 1);
            die;
        }
    } else {
        $sw = new DTSoftware();
        $location = __('New Download Item', 'dtransport');
    }
    $form = new RMForm('', '', '');
    $ed = new RMFormEditor('', 'desc', '99%', '300px', $edit ? $sw->getVar('desc', $rmc_config['editor_type'] != 'tiny' ? 'e' : 's') : '', $rmc_config['editor_type']);
    $ed->addClass('required');
    $db = XoopsDatabaseFactory::getDatabaseConnection();
    //Lista de categorías
    $categos = array();
    $swcats = $sw->categories();
    DTFunctions::getCategos($categos, 0, 0, array(), false);
    foreach ($categos as $row) {
        $cat = new DTCategory();
        $cat->assignVars($row);
        $categories[] = array('id' => $cat->id(), 'name' => $cat->name(), 'parent' => $cat->parent(), 'active' => $cat->active(), 'description' => $cat->desc(), 'indent' => $row['jumps'], 'selected' => $edit ? in_array($cat->id(), $swcats) : '');
    }
    unset($categos);
    // Licencias
    $sql = "SELECT * FROM " . $db->prefix('dtrans_licences');
    $result = $db->queryF($sql);
    $lics = array();
    $lics[] = array('id' => 0, 'name' => __('Other license', 'dtransport'), 'selected' => !$edit || in_array(0, $sw->licences()) ? 1 : 0);
    while ($row = $db->fetchArray($result)) {
        $lic = new DTLicense();
        $lic->assignVars($row);
        $lics[] = array('id' => $lic->id(), 'name' => $lic->name(), 'selected' => $edit ? in_array($lic->id(), $sw->licences()) : '');
    }
    unset($lic);
    // Plataformas
    $sql = "SELECT * FROM " . $db->prefix('dtrans_platforms');
    $result = $db->queryF($sql);
    $oss = array();
    $oss[] = array('id' => 0, 'name' => __('Other platform', 'dtransport'), 'selected' => !$edit || in_array(0, $sw->platforms()) ? 1 : 0);
    while ($row = $db->fetchArray($result)) {
        $os = new DTPlatform();
        $os->assignVars($row);
        $oss[] = array('id' => $os->id(), 'name' => $os->name(), 'selected' => $edit ? in_array($os->id(), $sw->platforms()) : '');
    }
    unset($os);
    // Allowed groups
    $field = new RMFormGroups('', 'groups', 1, 1, 1, $edit ? $sw->getVar('groups') : array(1, 2));
    $groups = $field->render();
    // Tags
    $ftags = $sw->tags(true);
    $tags = array();
    foreach ($ftags as $tag) {
        $tags[] = $tag->getVar('tag');
    }
    unset($ftags);
    RMTemplate::get()->add_style('admin.css', 'dtransport');
    RMTemplate::get()->add_style('items.css', 'dtransport');
    RMTemplate::get()->add_local_script('itemsform.js', 'dtransport');
    RMTemplate::get()->add_local_script('jquery.validate.min.js', 'rmcommon', 'include');
    include DT_PATH . '/include/js_strings.php';
    DTFunctions::toolbar();
    xoops_cp_location($location);
    xoops_cp_header();
    include RMTemplate::get()->get_template('admin/dtrans_formitems.php', 'module', 'dtransport');
    xoops_cp_footer();
}