/** * Get instance * @return unknown_type */ public static function getInstance() { if (!self::$_instance instanceof self) { self::$_instance = new self(); } return self::$_instance; }
public function tags() { require_once APPLICATION_PATH . '/models/TaggedStreamModel.php'; $model = TaggedStreamModel::getInstance(); $params = array('entries' => $model->fetchTopEntries()); return $this->view->partial('_tags.phtml', $params); }
/** * Add new stream entry * @param $data * @throws DuplicateStreamEntryException * @return int Id of added item */ public function add(array $data) { $logger = Zend_Registry::get('logger'); $db = $this->getTable(); if (!isset($data['unique_id'])) { $data['unique_id'] = $this->createUniqueId($data['content_unique_id']); } $entry = $db->fetchRow($db->select()->where('unique_id = ?', $data['unique_id'])); $id = null; if (null == $entry) { $tags = isset($data['tags']) ? $data['tags'] : array(); unset($data['tags']); $id = $db->insert($data); $taggedStreamsModel = TaggedStreamModel::getInstance(); $taggedStreamsModel->addTagsToStream($tags, $id); $logger->info('Added entry ' . $data['unique_id'] . '.'); } else { // Uncomment to always aggregate tags... //$tags = isset($data['tags']) ? $data['tags'] : array(); //$taggedStreamsModel = TaggedStreamModel::getInstance(); //$taggedStreamsModel->addTagsToStream($tags, $entry->id); $logger->debug('Entry exists ' . $data['unique_id'] . '.'); throw new DuplicateStreamEntryException('Entry already exists'); } return $id; }
public function showAction() { $tag = TagModel::getInstance()->fetchEntryByCleanName($this->_getParam('name')); if (null === $tag) { return $this->_forward('notfound', 'error'); } $taggedStreamModel = TaggedStreamModel::getInstance(); $entries = $this->_paginateResult($taggedStreamModel->fetchStreamsByTag($tag), $this->_getParam('page', 1)); $this->view->tag = $tag; $this->view->entries = $entries; }