function dt_block_tags($options) { global $db, $xoopsModule; if ($xoopsModule && $xoopsModule->dirname() == 'dtransport') { global $xoopsModuleConfig; $mc =& $xoopsModuleConfig; } else { $util =& RMUtils::getInstance(); $mc =& $util->moduleConfig('dtransport'); } include_once XOOPS_ROOT_PATH . '/modules/dtransport/class/dttag.class.php'; $sql = "SELECT MAX(hits) FROM " . $db->prefix('dtrans_tags'); list($maxhit) = $db->fetchRow($db->query($sql)); $sql = "SELECT * FROM " . $db->prefix('dtrans_tags'); if ($options[2] < 1) { $sql .= " WHERE hits>0"; } $sql .= " LIMIT 0,{$options['0']}"; $result = $db->query($sql); $sz = $options[1] / $maxhit; $block = array(); while ($row = $db->fetchArray($result)) { $tag = new DTTag(); $tag->assignVars($row); $link = XOOPS_URL . "/modules/dtransport/" . ($mc['urlmode'] ? "tag/" . $tag->tag() : "tags.php?id=" . $tag->tag()); $size = intval($tag->hit() * $sz); if ($size < $options[3]) { $size = $options[3]; } $rtn = array(); $rtn['id'] = $tag->id(); $rtn['tag'] = $tag->tag(); $rtn['hits'] = $tag->hit(); $rtn['link'] = $link; $rtn['size'] = $size; $block['tags'][] = $rtn; } $block['font'] = $options[4]; return $block; }
// Email: i.bitcero@gmail.com // License: GPL 2.0 // -------------------------------------------------------------- $xoopsOption['template_main'] = 'dtrans_tags.html'; $xoopsOption['module_subpage'] = 'tags'; if ($tag == '') { redirect_header(DT_URL, 1, __('Tag not specified!', 'dtransport')); die; } include 'header.php'; $tag = new DTTag($tag); //Incrementamos los hits $tag->setHit($tag->hit() + 1); $tag->save(); // Descargas en esta etiqueta $sql = "SELECT COUNT(*) FROM " . $db->prefix('dtrans_softtag') . " AS a INNER JOIN " . $db->prefix('dtrans_software') . " b ON (a.id_tag=" . $tag->id() . " AND a.id_soft=b.id_soft) WHERE b.approved='1' AND b.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: ' . DT_URL . ($mc['permalinks'] ? '/tag/' . $tag->tagId() : '/?p=tag&tag=' . $tag->id())); die; } $p = $page > 0 ? $page - 1 : $page; $start = $num <= 0 ? 0 : $p * $limit; $nav = new RMPageNav($num, $limit, $page); $nav->target_url(DT_URL . ($mc['permalinks'] ? '/tag/' . $tag->tagId() . '/page/{PAGE_NUM}/' : '/?p=tag&tag=' . $tag->id() . '&page={PAGE_NUM}')); $xoopsTpl->assign('pagenav', $nav->render(true)); // Seleccionamos los registros $sql = str_replace('COUNT(*)', 'b.*', $sql);
/** * @desc Almacena las etiquetas del elemento */ private function saveTags() { $sql = "DELETE FROM " . $this->db->prefix('dtrans_softtag') . " WHERE id_soft=" . $this->id(); $this->db->queryF($sql); $tc = TextCleaner::getInstance(); $tags = array(); foreach ($this->_tags as $tag) { if (is_array($tag)) { $tag = $tag['tag']; } $ot = new DTTag($tc->sweetstring($tag)); if ($ot->isNew()) { $ot->setVar('tag', $tag); $ot->setVar('tagid', $tc->sweetstring($tag)); $ot->save(); } $tags[] = $ot->id(); } if (empty($tags)) { return; } $sql = "INSERT INTO " . $this->db->prefix('dtrans_softtag') . " (`id_soft`,`id_tag`) VALUES "; $sql1 = ''; foreach ($tags as $k) { $sql1 .= $sql1 == "" ? "('" . $this->id() . "','{$k}')" : ",('" . $this->id() . "','{$k}')"; } if ($this->db->queryF($sql . $sql1)) { return true; } $this->addError($this->db->error()); return false; }