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
    }
    if (!is_numeric($page)) {
        $page = 1;
    }
    $category = new DTCategory($id);
}
// Descargas en esta categoría
$tbls = $db->prefix("dtrans_software");
$tblc = $db->prefix("dtrans_catsoft");
$sql = "SELECT COUNT(*) FROM {$tbls} as s, {$tblc} as c WHERE c.cat='" . $category->id() . "' AND s.id_soft=c.soft AND s.approved=1 AND s.delete=0";
list($num) = $db->fetchRow($db->query($sql));
$limit = $mc['xpage'];
$limit = $limit <= 0 ? 10 : $limit;
$tpages = ceil($num / $limit);
if ($tpages < $page && $tpages > 0) {
    header('location: ' . $category->permalink());
    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);
 /**
  * Get featured items
  * @param int Allows to select items from a specific category
  * @param string Smarty varibale name. Useful when assign is true
  * @param string Type of items (all, featured, recent, daily, rated, updated
  * @return array
  */
 public function get_items($cat = 0, $type = 'all', $limit = 10)
 {
     global $xoopsTpl, $mc;
     $items = array();
     $db = XoopsDatabaseFactory::getDatabaseConnection();
     switch ($type) {
         case 'featured':
             $filter = "a.approved=1 AND a.featured=1 AND a.delete=0";
             $order = "ORDER BY RAND()";
             break;
         case 'recent':
             $filter = "a.approved=1 AND a.delete=0";
             $order = "ORDER BY a.created DESC";
             break;
         case 'daily':
             $filter = "a.approved=1 AND a.daily=1 AND a.delete=0";
             $order = "ORDER BY RAND()";
             break;
         case 'rated':
             $filter = "a.approved=1 AND a.delete=0";
             $order = "ORDER BY a.rating DESC";
             break;
         case 'updated':
             $filter = "a.approved=1 AND a.delete=0";
             $order = "ORDER BY a.modified DESC";
             break;
         default:
             $filter = 'a.delete=0';
             $order = "ORDER BY created DESC";
             break;
     }
     if ($cat > 0) {
         // Categories under current category
         $categos = array();
         $this->categoryTreeId($categos, $cat);
         $sql = "SELECT a.*, b.*, c.name AS namecat, c.id_cat\n                    FROM " . $db->prefix("dtrans_software") . " AS a, " . $db->prefix("dtrans_catsoft") . " AS b\n                    JOIN " . $db->prefix("dtrans_categos") . " AS c\n                    WHERE b.cat IN(" . implode(",", $categos) . ") AND a.id_soft=b.soft AND {$filter} AND c.id_cat=b.cat\n                    GROUP BY b.soft\n                    {$order} LIMIT 0,{$limit}";
     } else {
         $sql = "SELECT a.*, c.name as namecat, c.id_cat\n                    FROM " . $db->prefix("dtrans_software") . " AS a, " . $db->prefix("dtrans_catsoft") . " AS b\n                    JOIN " . $db->prefix("dtrans_categos") . " AS c\n                    WHERE {$filter} AND a.id_soft=b.soft AND c.id_cat=b.cat\n                    GROUP BY b.soft\n                    {$order} LIMIT 0,{$limit}";
     }
     $result = $db->query($sql);
     while ($row = $db->fetchArray($result)) {
         $item = new DTSoftware();
         $item->assignVars($row);
         $ocat = new DTCategory($row['id_cat']);
         $items[] = array_merge($this->createItemData($item), array('category' => $row['namecat'], 'categoryid' => $row['id_cat'], 'categorylink' => $ocat->permalink()));
     }
     return $items;
 }