protected function declareParameters() { $this->source = new XorParameter('source'); $email = new String('email'); $email->setValidateType('email'); $this->source->addParameter($email); $user = new User('user'); $this->source->addParameter($user); $this->source->setDefaultParameter($user); global $wgUser; $this->source->setDefaultValue($wgUser, false); $this->addParameter($this->source); $this->size = new IntegerInPixel('size'); global $wgWFMKMaxWidth; $this->size->setMax(min(array($wgWFMKMaxWidth, 2048))); $this->size->setDefaultValue(80); $this->addParameter($this->size); /* * Currently, rating is forced to G: "suitable for display on all websites with any audience type" $this->rating = new XorParameter('rating'); $this->rating->addParameter(new Option('g')); // +++ all websites with any audience type $this->rating->addParameter(new Option('pg')); // ++ $this->rating->addParameter(new Option('r')); // + $this->rating->addParameter(new Option('x')); // ! hardcore $this->addParameter($this->rating); */ $float = new XorParameter('float'); $this->right = new Option('right'); $float->addParameter($this->right); $this->left = new Option('left'); $float->addParameter($this->left); $this->addParameter($float); }
public function declareParameters() { $track = new String('track'); $track->setValidateType('int'); $album = new String('album'); $album->setValidateType('int'); $this->source = new XorParameter('source'); $this->source->addParameter($track); $this->source->addParameter($album); $this->source->setRequired(); $this->source->setDefaultParameter($track); $this->addParameter($this->source); $this->autoplay = new Boolean('autoplay'); $this->addParameter($this->autoplay); $this->lang = new XorParameter('lang'); $this->lang->addParameter(new Option('en')); $this->lang->addParameter(new Option('fr')); $this->lang->setDefaultValue('en'); $this->addParameter($this->lang); $float = new XorParameter('float'); $this->right = new Option('right'); $float->addParameter($this->right); $this->left = new Option('left'); $float->addParameter($this->left); $this->addParameter($float); }
protected function declareParameters() { global $wgWFMKMaxWidth; $this->title = new Title('title'); $this->title->setRequired(); $this->addParameter($this->title); $this->caption = new Wikitext('caption'); $this->caption->setParser($this->getParser()); $this->caption->setRequired(); $this->addParameter($this->caption); $this->color = new XorParameter('color'); $red = new Option('red'); $this->color->addParameter($red); $grey = new Option('grey'); $this->color->addParameter($grey); $this->color->setDefaultValue('red'); $this->addParameter($this->color); $this->width = new IntegerInPixel('width'); $this->width->setMax($wgWFMKMaxWidth); $this->addParameter($this->width); $this->height = new IntegerInPixel('height'); $this->addParameter($this->height); $float = new XorParameter('float'); $this->right = new Option('right'); $float->addParameter($this->right); $this->left = new Option('left'); $float->addParameter($this->left); $this->addParameter($float); }
/** * Checks parameters requirements (required, min, max,...). * Updates default values of some parameters according the other parameters * values. * * @throws UserError When a parameter fails its validate. */ protected function validate() { // 100 - 180 // set default url (default parameter is url) $this->target->setDefaultValue($this->parser->getTitle()->getCanonicalUrl()); if ($this->target->getParameter()->getName() == 'url') { if ($this->annotation->getOutput() == 'inline') { // displaying a +1 button inline // google documentation about width: min = 120, default (when unspecified) = 450 $this->width->setMin(120); } } else { // $this->target->getParameter()->getName() = 'user' if (!$this->icon->getValue()) { // displaying a badge, not just an icon if ($this->size->getOutput() == 'small') { $this->height_value = 69; $this->width->setMin(170); // google documentation } else { $this->height_value = 131; $this->width->setMin(100); // google documentation } } } parent::validate(); }