getControl() публичный Метод

public getControl ( )
Пример #1
0
 /**
  * Generates control's HTML element.
  * @return Nette\Utils\Html
  */
 public function getControl()
 {
     $input = parent::getControl();
     foreach ($this->getRules() as $rule) {
         if ($rule->isNegative || $rule->branch) {
         } elseif (in_array($rule->validator, [Form::MIN, Form::MAX, Form::RANGE], TRUE) && in_array($input->type, ['number', 'range', 'datetime-local', 'datetime', 'date', 'month', 'week', 'time'], TRUE)) {
             if ($rule->validator === Form::MIN) {
                 $range = [$rule->arg, NULL];
             } elseif ($rule->validator === Form::MAX) {
                 $range = [NULL, $rule->arg];
             } else {
                 $range = $rule->arg;
             }
             if (isset($range[0]) && is_scalar($range[0])) {
                 $input->min = isset($input->min) ? max($input->min, $range[0]) : $range[0];
             }
             if (isset($range[1]) && is_scalar($range[1])) {
                 $input->max = isset($input->max) ? min($input->max, $range[1]) : $range[1];
             }
         } elseif ($rule->validator === Form::PATTERN && is_scalar($rule->arg) && in_array($input->type, ['text', 'search', 'tel', 'url', 'email', 'password'], TRUE)) {
             $input->pattern = $rule->arg;
         }
     }
     if ($input->type !== 'password' && ($this->rawValue !== '' || $this->emptyValue !== '')) {
         $input->value = $this->rawValue === '' ? $this->translate($this->emptyValue) : $this->rawValue;
     }
     return $input;
 }
Пример #2
0
 /**
  * Generates control's HTML element.
  * @return Nette\Utils\Html
  */
 public function getControl()
 {
     $value = $this->getValue();
     if ($value === '') {
         $value = $this->translate($this->emptyValue);
     }
     return parent::getControl()->setText($value);
 }
Пример #3
0
 /**
  * @return Nette\Utils\Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     $value = $this->getValue();
     if ($value instanceof \DateTime) {
         $control->value = $value->format($this->format);
     }
     return $control;
 }
Пример #4
0
 public function getControl()
 {
     $control = parent::getControl();
     $form = $this->lookup('Nette\\Forms\\Form');
     $control->style = "display:none;";
     $extIdentifier = substr($this->name, 4);
     $extName = $form->presenter->mediaManagerService->getLabelExtNameByIdentifier($extIdentifier);
     $control->value = $this->getValue() === '' ? $this->translate($this->emptyValue) : $this->value;
     $divContainer = Nette\Utils\Html::el('div');
     $divContainer->class('media-container');
     $divContent = $divContainer->create('div');
     $divContent->class('media-container-content');
     $thumbImage = Nette\Utils\Html::el('img');
     $buttonParams = array('cid' => $control->id, 'media-extName' => $extName, 'media-trigger' => 'container');
     //dump(json_decode($control->value, TRUE));
     $encodedParams = json_decode($control->value, TRUE);
     $mediaType = NULL;
     $mediaId = NULL;
     $restoreUrl = NULL;
     if ($encodedParams !== NULL && is_array($encodedParams)) {
         $mediaType = isset($encodedParams['mediaType']) ? $encodedParams['mediaType'] : NULL;
         $mediaId = isset($encodedParams['mediaId']) ? $encodedParams['mediaId'] : NULL;
         $restoreUrl = isset($encodedParams['restoreUrl']) ? $encodedParams['restoreUrl'] : NULL;
     }
     if ($mediaType !== NULL && $mediaId !== NULL) {
         switch ($mediaType) {
             case 'file':
                 $file = $form->presenter->mediaManagerService->getFile($mediaId);
                 $section = $form->presenter->mediaManagerService->getFileSection($mediaId);
                 $iconSrc = $form->presenter->mediaManagerService->getFileIconSrc($file);
                 $thumbImage->src = $iconSrc;
                 //$buttonParams = array_merge($buttonParams, $this->_getFileDetailParams($matches[2], $file['folder_id'], $section));
                 $buttonParams = array_merge($buttonParams, $form->presenter->mediaManagerService->getFileRestoreParams($file['folder_id'], $mediaId, $section, FALSE));
                 break;
             case 'gallery':
                 $folder = $form->presenter->mediaManagerService->getFolder($mediaId);
                 $iconSrc = $form->presenter->mediaManagerService->getGalleryIconSrc($folder['folder_id']);
                 $thumbImage->src = $iconSrc;
                 //$buttonParams = array_merge($buttonParams, $this->_getGalleryDetailParams($matches[2], $folder['parent_folder']));
                 $buttonParams = array_merge($buttonParams, $form->presenter->mediaManagerService->getGalleryRestoreParams($mediaId, $folder['parent_folder'], FALSE));
                 break;
         }
     }
     $divContent->add($thumbImage);
     $actionButton = $divContainer->create('a');
     $actionButton->href($form->presenter->link('Tiny:pokus', $buttonParams))->class('colorbox vdColorbox')->setText('Otevřít disk');
     $sep = $divContainer->create(NULL);
     $sep->setText(' ');
     $removeButton = $divContainer->create('a');
     $removeButton->href('#')->class('remove-media-item')->cid($control->id)->setText('Smazat');
     if (!$control->value) {
         $removeButton->style('display:none;');
     }
     $divContainer->add($control);
     return $divContainer;
 }
Пример #5
0
 public function getControl()
 {
     $el = parent::getControl();
     $questionId = $this->session->getSection($this->sessionSection)->questionId;
     if (isset($this->questions[$questionId]['question'])) {
         $label = $this->questions[$questionId]['question'];
     } else {
         $label = '';
     }
     return Html::el('label')->setText($label)->add($el);
 }
Пример #6
0
 /**
  * Generates control's HTML element.
  *
  * @return Nette\Utils\Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     foreach ($this->getRules() as $rule) {
         if ($rule->isNegative || $rule->type !== Nette\Forms\Rule::VALIDATOR) {
         } elseif ($rule->operation === Nette\Forms\Form::RANGE && $control->type !== 'text') {
             list($control->min, $control->max) = $rule->arg;
         } elseif ($rule->operation === Nette\Forms\Form::PATTERN) {
             $control->pattern = $rule->arg;
         }
     }
     if ($control->type !== 'password') {
         $control->value = $this->getValue() === '' ? $this->translate($this->emptyValue) : $this->value;
     }
     return $control;
 }
Пример #7
0
 /**
  * Generates control's HTML element.
  * @return Nette\Utils\Html
  */
 public function getControl()
 {
     $input = parent::getControl();
     foreach ($this->getRules() as $rule) {
         if ($rule->isNegative || $rule->branch) {
         } elseif ($rule->validator === Nette\Forms\Form::RANGE && $input->type !== 'text') {
             $input->min = isset($rule->arg[0]) && is_scalar($rule->arg[0]) ? $rule->arg[0] : NULL;
             $input->max = isset($rule->arg[1]) && is_scalar($rule->arg[1]) ? $rule->arg[1] : NULL;
         } elseif ($rule->validator === Nette\Forms\Form::PATTERN && is_scalar($rule->arg)) {
             $input->pattern = $rule->arg;
         }
     }
     if ($input->type !== 'password') {
         $input->value = $this->rawValue === '' ? $this->translate($this->emptyValue) : $this->rawValue;
     }
     return $input;
 }
Пример #8
0
 /**
  * Generates control's HTML element.
  *
  * @return Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     $control->type = $this->htmlType;
     $control->addClass($this->htmlType);
     list($min, $max) = $this->extractRangeRule($this->getRules());
     if ($min instanceof DateTime) {
         $control->min = $min->format($this->htmlFormat);
     }
     if ($max instanceof DateTime) {
         $control->max = $max->format($this->htmlFormat);
     }
     $value = $this->getValue();
     if ($value instanceof DateTime) {
         $control->value = $value->format($this->htmlFormat);
     }
     return $control;
 }
Пример #9
0
 /**
  * Generates control's HTML element.
  * @return Nette\Utils\Html
  */
 public function getControl()
 {
     $input = parent::getControl();
     foreach ($this->getRules() as $rule) {
         if ($rule->isNegative || $rule->type !== Nette\Forms\Rule::VALIDATOR) {
         } elseif ($rule->operation === Nette\Forms\Form::RANGE && in_array($input->type, array('number', 'range', 'datetime-local', 'datetime', 'date', 'month', 'week', 'time'))) {
             if (isset($rule->arg[0]) && is_scalar($rule->arg[0])) {
                 $input->min = isset($input->min) ? max($input->min, $rule->arg[0]) : $rule->arg[0];
             }
             if (isset($rule->arg[1]) && is_scalar($rule->arg[1])) {
                 $input->max = isset($input->max) ? min($input->max, $rule->arg[1]) : $rule->arg[1];
             }
         } elseif ($rule->operation === Nette\Forms\Form::PATTERN && is_scalar($rule->arg) && in_array($input->type, array('text', 'search', 'tel', 'url', 'email', 'password'))) {
             $input->pattern = $rule->arg;
         }
     }
     if ($input->type !== 'password') {
         $input->value = $this->rawValue === '' ? $this->translate($this->emptyValue) : $this->rawValue;
     }
     return $input;
 }
Пример #10
0
 /**
  * @return Nette\Utils\Html
  */
 public function getStateControlPart()
 {
     $countryCode = $this->countryCode ?: $this->defaultCountryCode;
     $items = $this->getStates($countryCode);
     $disabled = $this->isDisabled();
     // Disabled ?
     if ($items === NULL && count($items) === 0) {
         $disabled = TRUE;
     }
     if ($items === NULL) {
         $items = array(NULL => 'without state');
     }
     /** @var Nette\Utils\Html $states */
     $states = Nette\Forms\Helpers::createSelectBox($items, array('selected?' => $this->stateCode));
     // Set attributes
     $states->addAttributes(parent::getControl()->attrs);
     $states->attrs['id'] = $this->getHtmlId() . '_states';
     $states->attrs['name'] = Nette\Forms\Helpers::generateHtmlName($this->lookupPath('Nette\\Forms\\Form') . '_states');
     if ($disabled) {
         $states->attrs['disabled'] = TRUE;
     }
     return $states;
 }
Пример #11
0
 /**
  * Generates control's HTML element.
  * @return Nette\Utils\Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     $control->setText($this->getValue() === '' ? $this->translate($this->emptyValue) : $this->value);
     return $control;
 }
 /**
  * Generates control's HTML element
  *
  * @return \Nette\Utils\Html|string
  */
 public function getControl()
 {
     // TODO Make sure captcha is validated at this time
     $parent = $this->getParent();
     $parent[$this->getUidFieldName()]->setValue($this->getUid());
     return parent::getControl();
 }
Пример #13
0
 public function getControl()
 {
     $control = parent::getControl();
     $control->setText($this->arrayToText($this->value));
     return $control;
 }
Пример #14
0
 public function getControl()
 {
     /** TODO: Make sure captcha is validated at this time */
     $parent = $this->getParent();
     $parent[$this->getUidFieldName()]->setValue($this->getUid());
     $container = Html::el();
     $this->setSession($this->getUid(), $this->getWord());
     $image = Html::el('img')->class('captcha');
     $image->src = $this->getImageUri();
     //$image->width = $this->getImageWidth();
     //$image->height = $this->getImageHeight();
     if (!isset($image->alt)) {
         $image->alt = "Captcha";
     }
     $container->add($image);
     $container->add(parent::getControl());
     return $container;
 }
Пример #15
0
 /**
  * Generates control's HTML element.
  * @return Nette\Utils\Html
  */
 public function getControl()
 {
     return parent::getControl()->setText($this->getRenderedValue());
 }
Пример #16
0
 /**
  * Generates control's HTML element.
  * @return Nette\Utils\Html
  */
 public function getControl()
 {
     return parent::getControl()->addAttributes(['value' => $this->control->type === 'password' ? $this->control->value : $this->getRenderedValue(), 'type' => $this->control->type ?: 'text']);
 }