public function executeTag($request) { $this->tag = Doctrine::getTable('Tag')->findBy('name', array($request->getParameter('tag')))->getFirst(); $this->forward404Unless($this->tag); $url = 'talk/tag?&tag=' . $this->tag->getName() . 'page={%page_number}'; $query = Doctrine::getTable('Talk')->getTagQuery()->leftJoin('t.Tagging t1')->leftJoin('t1.Tag t2')->addWhere('t2.name =?', $this->tag->getName()); $this->pager = htPagerLayout::create($query, $url, $request->getParameter("page", 1)); $this->tags = TagTable::getAllTagNameWithCount(); }
public function getTagChoices() { if (isset($this->tags)) { return $this->tags; } $this->tags = TagTable::getAllTagNameWithCount(null, array('model' => $this->getModelName())); foreach ($this->tags as $key => &$tag) { $tag = $key; } return $this->tags; }
public function configure() { $typeOptions = array('' => 'All', 'image' => 'Image', 'video' => 'Video', 'pdf' => 'PDF'); $allTags = TagTable::getAllTagNameWithCount(null, array('model' => 'aMediaItem')); $tagOptions = array(); foreach ($allTags as $tag => $count) { $tagOptions[$tag] = "{$tag} ({$count})"; } $tagOptions = array_merge(array('' => 'All'), $tagOptions); $this->setWidgets(array('search' => new sfWidgetFormInput(array(), array('class' => 'a-search-field')), 'type' => new sfWidgetFormSelect(array('choices' => $typeOptions)), 'tag' => new sfWidgetFormSelect(array('choices' => $tagOptions)))); $this->setValidators(array('search' => new sfValidatorPass(array('required' => false)), 'type' => new sfValidatorChoice(array('required' => false, 'choices' => array_keys($typeOptions))), 'tag' => new sfValidatorChoice(array('required' => false, 'choices' => array_keys($tagOptions))))); // This is safe - it doesn't actually retrieve any extra // fields, it just declines to generate an error merely because // they exist $this->validatorSchema->setOptions('allow_extra_fields', true); $this->widgetSchema->setIdFormat('a_media_browser_%s'); $this->widgetSchema->setFormFormatterName('aAdmin'); // Yes, really: this makes it contextual without extra effort $this->widgetSchema->setNameFormat('%s'); $this->widgetSchema->getFormFormatter()->setTranslationCatalogue('apostrophe'); }
public function executeTagWidget() { if (empty($this->object)) { $object_id = $this->getVarHolder()->get('object_id', false); $object_class = $this->getVarHolder()->get('object_class', false); if (!$object_id || !$object_class) { throw new sfException("Must pass both object_id and object_class as option to this component."); } $this->object = Doctrine::getTable($object_class)->findOneBy('id', $object_id); } else { $object_class = get_class($this->object); $object_id = $this->object->id; } if (!$this->object) { throw new sfException("Object with specified parameters does not exist."); } $this->popular_tags = TagTable::getAllTagNameWithCount(null, array('model' => $object_class, 'sort_by_popularity' => true, 'limit' => 10)); foreach ($this->object->getTags() as $tag) { unset($this->popular_tags[$tag]); } }
public function executeEdit(sfWebRequest $request) { $this->setAEventForUser(); $this->forward404Unless($this->a_event); $this->form = new aEventForm($this->a_event); // Retrieve the tags currently assigned to the event for the inlineTaggableWidget $this->existingTags = $this->form->getObject()->getTags(); // Retrieve the 10 most popular tags for the inlineTaggableWidget $this->popularTags = TagTable::getAllTagNameWithCount(null, array('model' => 'aEvent', 'sort_by_popularity' => true), false, 10); aBlogItemTable::populatePages(array($this->a_event)); }
public function executeTagList() { $this->tags = TagTable::getAllTagNameWithCount(null, array('model' => 'aBlogPost', 'sort_by_popularity' => true, 'limit' => 10)); }
/** * DOCUMENT ME * @return mixed */ public static function getAllTagNameForUserWithCount() { // Retrieves only tags relating to media items this user is allowed to see $q = NULL; if (!sfContext::getInstance()->getUser()->hasCredential(sfConfig::get('app_a_view_locked_sufficient_credentials', 'view_locked'))) { $q = Doctrine_Query::create()->from('Tagging tg, tg.Tag t, aMediaItem m'); // If you're not logged in, you shouldn't see tags relating to secured stuff // Always IS FALSE, never = FALSE $q->andWhere('m.id = tg.taggable_id AND ((m.view_is_secure IS NULL) OR (m.view_is_secure IS FALSE))'); } return TagTable::getAllTagNameWithCount($q, array("model" => "aMediaItem")); }