コード例 #1
0
 protected function buildForm()
 {
     $this->addText('name', 'Name', NULL, 100)->setRequired('Addon must have a name. Really!');
     $this->addText('composerFullName', 'Composer name', NULL, 100)->setRequired()->addRule(self::PATTERN, 'Invalid composer name', FormValidators::COMPOSER_NAME_RE)->addRule(array($this->validators, 'isComposerVendorNameProtectionFree'), 'This vendor name is protected')->addRule(array($this->validators, 'isComposerFullNameUnique'), 'This composer name has already been taken.');
     $this->addMultiSelect('defaultLicense', 'Default license', $this->licenses->getLicenses(TRUE))->setRequired()->addRule(array($this->validators, 'isLicenseValid'), 'Invalid license identifier.');
     $this->addMultiSelect('tags', 'Categories', $this->getCategories())->setRequired();
     $this->addText('repository', 'Repository URL', NULL, 500)->addCondition(self::FILLED)->addRule(self::URL);
     $this->addText('demo', 'Demo URL', NULL, 500)->setType('url')->addCondition(self::FILLED)->addRule(self::URL);
     $this->addText('shortDescription', 'Short description', NULL, 250)->setRequired();
     $this->addTextArea('description', 'Description')->setRequired();
     $this->addRadioList('descriptionFormat', 'Description format', $this->descriptionFormats)->setDefaultValue(key($this->descriptionFormats))->setRequired();
 }
コード例 #2
0
 protected function buildForm()
 {
     $this->addText('version', 'Version', NULL, 100)->setRequired()->addRule(array($this->validators, 'isVersionValid'), 'Invalid version.');
     $this->addMultiSelect('license', 'License', $this->licenses->getLicenses(TRUE))->setAttribute('class', 'chzn-select')->setRequired()->addRule(array($this->validators, 'isLicenseValid'), 'Invalid license identifier.');
     $this->addHidden('how', 'link');
     $this->addText('archiveLink', 'Link to ZIP archive')->setRequired()->addRule(self::URL);
     $license = $this->addon->defaultLicense;
     if (is_string($license)) {
         if ($license === 'NOLICENSE') {
             $license = array();
         } else {
             $license = array_map('trim', explode(',', $license));
         }
     }
     $this->setDefaults(array('license' => $license));
 }
コード例 #3
0
 /**
  * @param  string|array
  * @return \Nette\Utils\Html
  */
 public function processLicenses($licenses)
 {
     if (is_string($licenses)) {
         $licenses = array_map('trim', explode(',', $licenses));
     }
     $container = Html::el();
     foreach ($licenses as $license) {
         if (count($container->getChildren()) > 0) {
             $container->add(', ');
         }
         if ($this->licenses->isValid($license)) {
             $container->create('a', array('href' => $this->licenses->getUrl($license), 'title' => $this->licenses->getFullName($license)))->setText($license);
         } else {
             $container->add($license);
         }
     }
     return $container;
 }
コード例 #4
0
 public function isLicenseValid($license)
 {
     return $this->licenseValidator->isValid($license);
 }