public function render()
 {
     $this->template->categories = $this->tags->findMainTagsWithAddons();
     $this->template->active = $this->presenter->getParameter('category');
     $this->template->setFile(__DIR__ . '/Categories.latte');
     $this->template->render();
 }
 protected function buildForm()
 {
     $this->tagsPairs = $this->tags->findMainTags()->fetchPairs('slug', 'name');
     $this->addText('search', 'Search', NULL, 100);
     $this->addSelect('category', 'Category', $this->tagsPairs)->setPrompt('Choose category');
     $this->addSubmit('sub', 'Filter');
 }
 /**
  * @param \NetteAddons\Model\Addon
  * @return AddonForm
  */
 public function setAddon(Addon $addon)
 {
     $this->addon = $addon;
     if (!is_null($addon->repositoryHosting)) {
         if (is_null($addon->id)) {
             $this->removeComponent($this['repository']);
         }
         if ($addon->defaultLicense) {
             $this->removeComponent($this['defaultLicense']);
         }
     }
     if ($addon->composerFullName) {
         $this->removeComponent($this['composerFullName']);
     }
     $license = $addon->defaultLicense;
     if (is_string($license)) {
         if ($license === 'NOLICENSE') {
             $license = array();
         } else {
             $license = array_map('trim', explode(',', $license));
         }
     }
     if ($key = array_search('NOLICENSE', $license)) {
         unset($license[$key]);
     }
     $tagItems = $this['tags']->getItems();
     $tags = array();
     foreach ($addon->getTagsIds() as $id) {
         if (!isset($tagItems[$id])) {
             $tag = $this->tags->find($id);
             if ($tag) {
                 $tagItems[$tag->id] = $tag->name;
             }
         }
         if (isset($tagItems[$id])) {
             $tags[] = $id;
         }
     }
     $this['tags']->setItems($tagItems)->setDefaultValue($tags);
     $this->setDefaults(array('name' => $addon->name, 'shortDescription' => $addon->shortDescription, 'description' => $addon->description, 'descriptionFormat' => $addon->descriptionFormat, 'defaultLicense' => $license, 'repository' => $addon->repository, 'demo' => $addon->demo));
     return $this;
 }
 protected function beforeRender()
 {
     $this->template->auth = $this->auth;
     $this->template->categories = $this->tags->findMainTags();
     $this->template->tags = $this->tags;
 }