Esempio n. 1
0
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;
}
 /**
  * @desc Obtiene las etiquestas a las que pertenece el software
  * @param bool True devuelve como objetos
  * @return array
  **/
 public function tags($asobj = false)
 {
     $tbl1 = $this->db->prefix("dtrans_softtag");
     $tbl2 = $this->db->prefix("dtrans_tags");
     if (empty($this->_tags) || $asobj && !is_a($this->_tags[0], 'DTTag')) {
         $this->_tags = array();
         $sql = "SELECT b.* FROM {$tbl1} a, {$tbl2} b WHERE a.id_soft='" . $this->id() . "' AND b.id_tag=a.id_tag";
         $result = $this->db->queryF($sql);
         while ($rows = $this->db->fetchArray($result)) {
             if ($asobj) {
                 $tmp = new DTTag();
                 $tmp->assignVars($rows);
             } else {
                 $tmp = $rows['id_tag'];
             }
             $this->_tags[] = $tmp;
         }
     }
     return $this->_tags;
 }
 /**
  * @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;
 }
Esempio n. 4
0
// $Id$
// --------------------------------------------------------------
// D-Transport
// Manage files for download in XOOPS
// Author: Eduardo Cortés <*****@*****.**>
// 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;
Esempio n. 5
0
    }
}
// Imágenes de la Descarga
$imgs = $item->screens(true);
$xoopsTpl->assign('screens_count', $item->getVar('screens'));
$data['screens'] = array();
foreach ($imgs as $img) {
    $data['screens'][] = array('id' => $img->id(), 'title' => $img->title(), 'image' => $img->url(), 'ths' => $img->url('ths'));
}
unset($imgs, $img);
//Etiquetas
$tags = $item->tags(false);
$relatedTags = array();
$data['tags'] = array();
foreach ($tags as $tag) {
    $otag = new DTTag();
    $otag->assignVars($tag);
    $data['tags'][] = array('id' => $tag['id_tag'], 'name' => $tag['tag'], 'link' => $otag->permalink());
    $relatedTags[] = $tag['id_tag'];
}
unset($tags, $otag, $tag);
// Categories
$cats = $item->categories(true);
$data['categories'] = array();
foreach ($cats as $ocat) {
    $data['categories'][] = array('id' => $ocat->id(), 'name' => $ocat->name(), 'link' => $ocat->permalink());
}
unset($ocat, $cats, $cat);
// Características
$chars = $item->features(true);
$data['features'] = array();