public function getTags() { $result = array(); $instances = array(); $tags = json_decode($this->_tags); if ($this->id && is_array($tags) && count($tags)) { $tagIds = array(); foreach ($tags as $tag) { if (K2Tags::loaded($tag->id)) { $instance = K2Tags::getInstance($tag->id); if ($instance->state) { $instances[] = $instance; } } else { $tagIds[] = (int) $tag->id; } } if (count($tagIds)) { $application = JFactory::getApplication(); $model = K2Model::getInstance('Tags'); if ($application->isSite()) { $model->setState('state', 1); } $model->setState('id', $tagIds); $rows = $model->getRows(); $result = array_merge($instances, $rows); } else { $result = $instances; } } return $result; }