/** * Get tags for a list of IDs * * @param array $ids Bulletin ids * @param integer $admin Admin flag * @return array */ public function getTagsForIds($ids = array(), $admin = 0) { $tt = new Tables\Tag($this->_db); $tj = new Tables\Object($this->_db); if (!is_array($ids) || empty($ids)) { return false; } $ids = array_map('intval', $ids); $sql = "SELECT t.tag, t.raw_tag, t.admin, rt.objectid\n\t\t\t\tFROM " . $tt->getTableName() . " AS t \n\t\t\t\tINNER JOIN " . $tj->getTableName() . " AS rt ON (rt.tagid = t.id) AND rt.tbl='" . $this->_scope . "' \n\t\t\t\tWHERE rt.objectid IN (" . implode(',', $ids) . ") "; switch ($admin) { case 1: $sql .= ""; break; case 0: default: $sql .= "AND t.admin=0 "; break; } $sql .= "ORDER BY raw_tag ASC"; $this->_db->setQuery($sql); $tags = array(); if ($items = $this->_db->loadObjectList()) { foreach ($items as $item) { if (!isset($tags[$item->objectid])) { $tags[$item->objectid] = array(); } $tags[$item->objectid][] = $item; } } return $tags; }
/** * Get module contents * * @return void */ public function run() { require_once \Component::path('com_tags') . DS . 'models' . DS . 'cloud.php'; $database = \App::get('db'); $obj = new Tag($database); $this->tags = $obj->getTopTags($this->params->get('numtags', 25)); require $this->getLayoutPath(); }
/** * Generate module contents * * @return void */ public function run() { require_once Component::path('com_tags') . DS . 'helpers' . DS . 'handler.php'; require_once Component::path('com_resources') . DS . 'tables' . DS . 'type.php'; $database = \App::get('db'); $obj = new Tag($database); $this->tags = $obj->getTopTags(intval($this->params->get('limit', 25))); // Get major types $t = new \Components\Resources\Tables\Type($database); $this->categories = $t->getMajorTypes(); require $this->getLayoutPath(); }
/** * Get a tag cloud for an object * * @param integer $showsizes Show tag size based on use? * @param integer $admin Show admin tags? * @param integer $objectid Object ID * @return mixed Return description (if any) ... */ public function getTopTagString($limit) { $t = new Tag($this->_db); $tags = $t->getTopTags($limit, $this->_scope, 'tcount DESC', 0); if ($tags && count($tags) > 0) { $tagarray = array(); foreach ($tags as $tag) { $tagarray[] = $tag->raw_tag; } $tags = implode(', ', $tagarray); } else { $tags = is_array($tags) ? implode('', $tags) : ''; } return $tags; }
/** * Get the ID of a normalized tag * * @param string $tag Normalized tag * @return mixed False if errors, integer on success */ private function _getTagId($tag) { if (!isset($tag)) { $this->setError(__CLASS__ . '::' . __METHOD__ . ' - Tag argument missing.'); return false; } $t = new Tables\Tag($this->_db); $t->loadTag($this->normalize($tag)); return $t->id; }