/** * @desc Visualiza todas los etiquetas existentes **/ function showTags() { global $xoopsModule, $xoopsSecurity, $xoopsModuleConfig; $db = Database::getInstance(); $mc =& $xoopsModuleConfig; $page = isset($_REQUEST['page']) ? $_REQUEST['page'] : 1; $page = $page < 1 ? 1 : $page; $limit = 15; $search = isset($_REQUEST['search']) ? $_REQUEST['search'] : ''; //Barra de Navegación $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_tags'); $sql1 = ''; $words = array(); if ($search) { //Separamos en palabras $words = explode(" ", $search); foreach ($words as $k) { $k = trim($k); if (strlen($k) < $mc['min_tag'] || strlen($k) > $mc['max_tag']) { continue; } $sql1 .= $sql1 == '' ? " WHERE (tag LIKE '%{$k}%')" : " OR (tag LIKE '%{$k}%')"; } } list($num) = $db->fetchRow($db->query($sql . $sql1)); $start = $num <= 0 ? 0 : ($page - 1) * $limit; $tpages = ceil($num / $limit); $nav = new RMPageNav($num, $limit, $page, 5); $nav->target_url("tags.php?search=" . urlencode($search) . "&page={PAGE_NUM}"); $showmax = $start + $limit; $showmax = $showmax > $num ? $num : $showmax; //Fin de barra de navegación $sql = "SELECT * FROM " . $db->prefix('gs_tags'); $sql2 = " LIMIT {$start},{$limit}"; $result = $db->query($sql . $sql1 . $sql2); $tags = array(); while ($rows = $db->fetchArray($result)) { foreach ($words as $k) { $rows['tag'] = eregi_replace("({$k})", "<span class='searchResalte'>\\1</span>", $rows['tag']); } $tag = new GSTag(); $tag->assignVars($rows); //Obtenemos todas las imágenes pertenecientes a la etiqueta $sql = "SELECT COUNT(*) FROM " . $db->prefix('gs_tagsimages') . " WHERE id_tag=" . $tag->id(); list($pics) = $db->fetchRow($db->query($sql)); $tags[] = array('id' => $tag->id(), 'name' => $tag->tag(), 'pics' => $pics, 'url' => $tag->url()); } GSFunctions::toolbar(); xoops_cp_location("<a href='./'>" . $xoopsModule->name() . "</a> » " . __('Tags Management', 'galleries')); RMTemplate::get()->assign('xoops_pagetitle', __('Tags Management', 'galleries')); $cHead = '<link href="' . XOOPS_URL . '/modules/galleries/styles/admin.css" media="all" rel="stylesheet" type="text/css" />'; xoops_cp_header($cHead); include RMTemplate::get()->get_template("admin/gs_tags.php", 'module', 'galleries'); RMTemplate::get()->add_script(RMCURL . '/include/js/jquery.checkboxes.js'); RMTemplate::get()->add_script('../include/js/gsscripts.php?file=sets&form=frm-tags'); RMTemplate::get()->add_script('../include/js/gsscripts.php?file=tags'); RMTemplate::get()->add_head("<script type='text/javascript'>\nvar delete_warning='" . __('Do you really wish to delete selected tags?', 'galleries') . "';\n</script>"); xoops_cp_footer(); }
/** * @desc Devuelve las etiquetas asignadas a un imágen * @param bool $obj Determina si se obtienen los objetos GSTag * @return array */ public function tags($obj = true, $field = '*') { $db =& $this->db; if (empty($this->_tags) || $this->_tagtype != $obj) { $this->_tags = array(); $tbl1 = $db->prefix("gs_tags"); $tbl2 = $db->prefix("gs_tagsimages"); $sql = "SELECT a.{$field} FROM {$tbl1} a, {$tbl2} b WHERE b.id_image='" . $this->id() . "' AND a.id_tag=b.id_tag"; $result = $db->query($sql); while ($row = $db->fetchArray($result)) { if ($obj) { $tag = new GSTag(); $tag->assignVars($row); $this->_tags[] = $tag; } else { $this->_tags[] = $row[$field]; } } } return $this->_tags; }
/** * @desc Visualiza las etiquetas existentes **/ function tags() { global $tpl, $xoopsOption, $xoopsUser, $xoopsModuleConfig, $db, $pag, $usr, $xoopsConfig, $tag; $xoopsOption['template_main'] = 'gs_tags.html'; $xoopsOption['module_subpage'] = 'tags'; include 'header.php'; $mc =& $xoopsModuleConfig; GSFunctions::makeHeader(); //Verificamos si el usuario existe if (isset($usr)) { $user = new GSUser($usr); if ($user->isNew()) { redirect_header(GSFunctions::get_url(), 1, __('Specified user does not exists!', 'galleries')); die; } } //Obtenemos la etiqueta de mayor hit if (!$usr) { $sql = "SELECT MAX(hits) FROM " . $db->prefix('gs_tags'); } else { $sql = "SELECT MAX(hits) FROM " . $db->prefix('gs_tags') . " a INNER JOIN " . $db->prefix('gs_tagsimages'); $sql .= " b INNER JOIN " . $db->prefix('gs_images') . " c ON (a.id_tag=b.id_tag AND b.id_image=c.id_image "; $sql .= " AND c.owner=" . $user->uid() . ")"; } list($maxhit) = $db->fetchRow($db->query($sql)); //Obtenemos la lista de etiquetas if (!$usr) { $sql = "SELECT * FROM " . $db->prefix('gs_tags') . " ORDER BY tag"; } else { $sql = "SELECT a.* FROM " . $db->prefix('gs_tags') . " a INNER JOIN " . $db->prefix('gs_tagsimages'); $sql .= " b INNER JOIN " . $db->prefix('gs_images') . " c ON (a.id_tag=b.id_tag AND b.id_image=c.id_image "; $sql .= " AND c.owner=" . $user->uid() . ")"; $sql .= " GROUP BY a.id_tag ORDER BY tag LIMIT 0," . $mc['num_tags']; } $result = $db->query($sql); $sz = $maxhit > 0 ? $mc['font_tags'] / $maxhit : 11; while ($rows = $db->fetchArray($result)) { $tag = new GSTag(); $tag->assignVars($rows); $size = intval($tag->hits() * $sz); if ($size < 10) { $size = 10; } if ($mc['urlmode']) { $link = GSFunctions::get_url() . "explore/tags/tag/" . $tag->getVar('nameid') . '/'; $link .= $usr ? "usr/" . $user->uname() . "/" : ''; } else { $link = GSFunctions::get_url() . "?explore=tags&tag=" . $tag->getVar('nameid'); $link .= $usr ? "&usr="******"usr/" . $user->uname() . '/' : "?usr="******"explore/sets/usr/" . $user->uname() . "/" : "?explore=sets&usr="******"cp/bookmarks/" : "?cp=bookmarks")); } include 'footer.php'; }