Exemplo n.º 1
0
 public function testAddFloatWithCustomStep()
 {
     $this->metadata->type = 'float';
     $this->metadata->custom['step'] = '0.002';
     $this->form->expects($this->once())->method('addText')->with('var', 'Int')->will($this->returnValue($this->control));
     $this->controlPrototype->expects($this->any())->method('type')->with('number');
     $this->controlPrototype->expects($this->any())->method('step')->with('0.002');
     $this->object->addFormControl($this->form, $this->metadata);
 }
Exemplo n.º 2
0
 public function __construct($name, $label)
 {
     $this->monitor('Drahak\\Tables\\Table');
     parent::__construct(NULL, $name);
     $this->cellPrototype = Html::el('td');
     $this->labelPrototype = Html::el('th');
     $this->labelPrototype->add(Html::el('a', $label));
     $this->column = $name;
 }
Exemplo n.º 3
0
 /**
  * Should the element has an icon?
  * @param  Html            $el
  * @param  string|null     $icon
  * @param  string          $name
  * @return void
  */
 public function tryAddIcon(Html $el, $icon, $name)
 {
     if ($icon) {
         $el->addHtml(Html::el('span')->class(DataGrid::$icon_prefix . $icon));
         if (strlen($name)) {
             $el->addHtml(' ');
         }
     }
 }
Exemplo n.º 4
0
 public function render()
 {
     if (empty($this->dotaz)) {
         throw new \Flame\Ares\AresException('Vyplň alespoň jeden IČ.');
     }
     foreach ($this->dotaz as $key => $val) {
         $this->xml->add('<Dotaz><Pomocne_ID>' . $key . '</Pomocne_ID><ICO>' . $val . '</ICO></Dotaz>');
     }
     $this->xml->__set('dotaz_pocet', $this->count);
     return $this->xml->render();
 }
Exemplo n.º 5
0
    public function renderAllErrors(UI\Form $form)
    {
        $html = '';
        foreach ($form->getErrors() as $error) {
            $html .= '<div class="alert alert-danger">
							<a class="close" data-dismiss="alert">×</a>' . $error . '
						</div>';
        }
        $errors = new Html();
        $errors->setHtml($html);
        return $errors;
    }
 public static function input(Html $input, BaseControl $control, $isPart)
 {
     $name = $input->getName();
     if ($name === 'select' || $name === 'textarea' || $name === 'input' && !in_array($input->type, array('radio', 'checkbox', 'file', 'hidden', 'range', 'image', 'submit', 'reset'))) {
         $input->addClass('form-control');
     } elseif ($name === 'input' && ($input->type === 'submit' || $input->type === 'reset')) {
         $input->addClass('btn');
         //			$input->setName('button');
         //			if($input->value !== NULL){
         //				$input->add($input->value);
         //			}
     }
     return $input;
 }
Exemplo n.º 7
0
 /**
  * Get menu title
  *
  * @return string
  */
 public function menuTitle()
 {
     if ($this->count > 0) {
         return $this->tableSingleName . ' ' . Html::el('span class=update-plugins')->add(Html::el('span class="update-count"')->setText($this->count));
     }
     return $this->tableSingleName;
 }
Exemplo n.º 8
0
 public function getControl()
 {
     $container = Html::el();
     $container->add($this->wrappedControl->getControl());
     $container->add($this->applyButton->getControl($this->caption));
     return $container;
 }
Exemplo n.º 9
0
  /**
 * Formular pre editaciu udajov
 * @param boolean $admin
 * @param array $druh
 * @return Nette\Application\UI\Form
 */
  public function create($admin, $druh, $ur_reg)
  {
      $this->ur_reg = $ur_reg;
      $form = new Form();
      $form->addProtection();
      $form->addGroup();
      $form->addHidden('id');
      $form->addHidden('id_udaje_typ');
      if ($admin) {
          $form->addText('nazov', 'Názov prvku:', 20, 20)->addRule(Form::MIN_LENGTH, 'Názov musí mať spoň %d znaky!', 2)->setAttribute('class', 'heading')->setRequired('Názov musí byť zadaný!');
          $form->addText('comment', 'Komentár k hodnote :', 90, 255)->addRule(Form::MIN_LENGTH, 'Komentár musí mať spoň %d znaky!', 2)->setRequired('Komentár musí byť zadaný!');
      } else {
          $form->addHidden('nazov');
          $form->addHidden('comment');
      }
      $form->addText('text', 'Hodnota prvku:', 90, 255)->setRequired('Hodnota prvku musí byť zadaná!');
      if ($admin) {
          $form->addCheckbox('spravca', ' Povolená zmena pre správcu')->setDefaultValue(1);
          $form->addCheckbox("druh_null", " Hodnota druhu je NULL")->setDefaultValue(1)->addCondition(Form::EQUAL, TRUE)->toggle("druh", FALSE);
          $form->addGroup()->setOption('container', Html::el('fieldset')->id("druh"));
          $form->addSelect('id_druh', 'Druhová skupina pre nastavenia:', $druh)->setDefaultValue(1);
          $form->setCurrentGroup(NULL);
Exemplo n.º 10
0
 public function getHeaderContent()
 {
     if (!isset($this->option[self::ORDERING])) {
         $this->option[self::ORDERING] = TRUE;
     }
     if (isset($this->option[self::ORDERING]) && $this->option[self::ORDERING]) {
         $ordering = $this->grid['ordering']->getOrdering($this->option[self::ID]);
         $link = Html::el('a', array('href' => $this->grid['ordering']->link('ordering!', $this->option[self::ID]), 'class' => 'mesour-ajax ordering' . (!is_null($ordering) ? ' ' . strtolower($ordering) : '')));
         $link->setText($this->getTranslator() ? $this->getTranslator()->translate($this->option[self::HEADER]) : $this->option[self::HEADER]);
         $link->addHtml(Html::el('span', array('class' => 'glyphicon no-sort'))->setHtml('&nbsp;'));
         if ($this instanceof Number || $this instanceof Date) {
             $link->addHtml(Html::el('span', array('class' => 'order-asc glyphicon glyphicon-sort-by-order')));
             $link->addHtml(Html::el('span', array('class' => 'order-desc glyphicon glyphicon-sort-by-order-alt')));
         } else {
             if ($this instanceof Status) {
                 $link->addHtml(Html::el('span', array('class' => 'order-asc glyphicon glyphicon-sort-by-attributes')));
                 $link->addHtml(Html::el('span', array('class' => 'order-desc glyphicon glyphicon-sort-by-attributes-alt')));
             } else {
                 $link->addHtml(Html::el('span', array('class' => 'order-asc glyphicon glyphicon-sort-by-alphabet')));
                 $link->addHtml(Html::el('span', array('class' => 'order-desc glyphicon glyphicon-sort-by-alphabet-alt')));
             }
         }
         return $link;
     } else {
         return $this->getTranslator() ? $this->getTranslator()->translate($this->option[self::HEADER]) : $this->option[self::HEADER];
     }
 }
Exemplo n.º 11
0
 public function createComponentCarouselGrid($name)
 {
     $grid = new \Ublaboo\DataGrid\DataGrid($this, $name);
     $test = $this->database->table("carousel")->order("sorted");
     $grid->setDataSource($test);
     $grid->setSortable(true);
     $grid->addGroupAction('Smazat')->onSelect[] = [$this, 'handleDelete'];
     $grid->addColumnText('title', 'dictionary.main.Title')->setRenderer(function ($item) {
         if ($item->title == '') {
             $title = \Nette\Utils\Html::el('a')->href('/admin/appearance/carousel-detail/' . $item->id)->setText('- nemá název - ');
         } else {
             $title = \Nette\Utils\Html::el('a')->href('/admin/appearance/carousel-detail/' . $item->id)->setText($item->title);
         }
         return $title;
     });
     $grid->addColumnText('test', 'dictionary.main.Image')->setRenderer(function ($item) {
         if ($item->image == '') {
             $fileImage = '';
         } else {
             $fileImage = \Nette\Utils\Html::el('img', array('style' => 'max-height: 130px;'))->src('/images/carousel/' . $item->image);
         }
         return $fileImage;
     });
     $grid->setTranslator($this->presenter->translator);
 }
Exemplo n.º 12
0
 /**
  * @return Html
  */
 public function getElementPrototype()
 {
     if ($this->elementPrototype === NULL) {
         $this->elementPrototype = Html::el('div');
     }
     return $this->elementPrototype;
 }
Exemplo n.º 13
0
 public function __construct(IContainer $parent = NULL, $name = NULL)
 {
     parent::__construct($name, $parent);
     $this->elementPrototype = Html::el('table');
     // Setup table
     $this->setup();
 }
Exemplo n.º 14
0
 protected function createTemplate($class = NULL)
 {
     $servise = $this;
     $template = parent::createTemplate($class);
     $template->addFilter('obr_v_txt', function ($text) use($servise) {
         $rozloz = explode("#", $text);
         $serv = $servise->presenter;
         $vysledok = '';
         $cesta = 'http://' . $serv->nazov_stranky . "/";
         foreach ($rozloz as $k => $cast) {
             if (substr($cast, 0, 2) == "I-") {
                 $obr = $serv->dokumenty->find((int) substr($cast, 2));
                 if ($obr !== FALSE) {
                     $cast = \Nette\Utils\Html::el('a class="fotky" rel="fotky"')->href($cesta . $obr->subor)->title($obr->nazov)->setHtml(\Nette\Utils\Html::el('img')->src($cesta . $obr->thumb)->alt($obr->nazov));
                 }
             }
             $vysledok .= $cast;
         }
         return $vysledok;
     });
     $template->addFilter('koncova_znacka', function ($text) use($servise) {
         $rozloz = explode("{end}", $text);
         $vysledok = $text;
         if (count($rozloz) > 1) {
             //Ak som nasiel znacku
             $vysledok = $rozloz[0] . \Nette\Utils\Html::el('a class="cely_clanok"')->href($servise->link("this"))->title($servise->texty["title"])->setHtml('&gt;&gt;&gt; ' . $servise->texty["viac"]) . '<div class="ostatok">' . $rozloz[1] . '</div>';
         }
         return $vysledok;
     });
     return $template;
 }
Exemplo n.º 15
0
 public function create()
 {
     $tree = Html::el('div', $this->attributes);
     $tree->add($this->header->create());
     $tree->add($this->body->create());
     return $tree;
 }
Exemplo n.º 16
0
 /**
  * @return Html
  */
 protected function getWrapperPrototype()
 {
     if ($this->wrapper == NULL) {
         $this->wrapper = Html::el("div");
     }
     return $this->wrapper;
 }
Exemplo n.º 17
0
 /**
  * @param string $label
  * @param CaptchaProvider $provider
  */
 public function __construct($label, CaptchaProvider $provider)
 {
     parent::__construct($label);
     $this->provider = $provider;
     $this->control = Html::el('img');
     $this->control->addClass('captcha-image seznam-captcha-image');
 }
Exemplo n.º 18
0
 public function create()
 {
     $table = Html::el('table', $this->attributes);
     $table->add($this->header->create());
     $table->add($this->body->create());
     return $table;
 }
Exemplo n.º 19
0
 function getControl()
 {
     // create input element
     $el = parent::getControl();
     $el->addAttributes(array('class' => 'form-control'));
     // converts datetime value into php format
     // $TODO
     if ($this->multidate && is_array($this->value)) {
         $pom = [];
         foreach ($this->value as $v) {
             if ($v !== NULL) {
                 array_push($pom, $v->format($this->toPhpDateTimeFormat($this->dateTimeFormat)));
             }
         }
         $value = implode($this->multidateSeparator, $pom);
     } else {
         $value = $this->value ? $this->value->format($this->toPhpDateTimeFormat($this->dateTimeFormat)) : NULL;
     }
     $el->value = $value;
     // generate field group
     $group = Utils\Html::el('div')->addHtml($el);
     if ($this->inline) {
         $el->addAttributes(array('style' => 'display:none;'));
         $group->addHtml(Utils\Html::el('div'));
     } else {
         $group->addHtml(Utils\Html::el('span')->class('input-group-addon')->addHtml(Utils\Html::el('span')->class($this->getIco())));
     }
     $group->addAttributes(['data-vojtys-forms-datepicker' => '', 'class' => 'input-group date', 'data-locale' => $this->getLanguage(), 'data-settings' => $this->getControlSettings()]);
     return $group;
 }
Exemplo n.º 20
0
 /**
  * Render row item into template
  * @param  Row   $row
  * @return mixed
  */
 public function render(Row $row)
 {
     /**
      * Renderer function may be used
      */
     try {
         return $this->useRenderer($row);
     } catch (DataGridColumnRendererException $e) {
         /**
          * Do not use renderer
          */
     }
     $link = $this->createLink($this->grid, $this->href, $this->getItemParams($row, $this->params));
     $a = Html::el('a')->href($link);
     $this->tryAddIcon($a, $this->getIcon($row), $this->getName());
     if (!empty($this->data_attributes)) {
         foreach ($this->data_attributes as $key => $value) {
             $a->data($key, $value);
         }
     }
     if (!empty($this->attributes)) {
         $a->addAttributes($this->attributes);
     }
     $a->addText($this->translate($this->getName()));
     if ($this->title) {
         $a->title($this->translate($this->getTitle($row)));
     }
     if ($this->class) {
         $a->class($this->getClass($row));
     }
     if ($confirm = $this->getConfirm($row)) {
         $a->data(static::$data_confirm_attribute_name, $confirm);
     }
     return $a;
 }
Exemplo n.º 21
0
 /**
  * @param string $name
  * @param Selection $selection
  * @return Grid
  * @throws GridNotExistsException
  */
 public function create($name, Selection $selection)
 {
     $className = '\\App\\AdminModule\\Grid\\' . $name;
     if (!class_exists($className)) {
         throw new GridNotExistsException("Grid class {$className} does not exist!");
     }
     if ($this->presenter === NULL) {
         throw new InvalidArgumentException('Presenter must be set!');
     }
     /** @var Grid $grid */
     $grid = new $className($this->db, $selection);
     $grid->setDefaultPerPage(100);
     $grid->setModel($selection)->setTranslator(new FileTranslator('cs'));
     $grid->addActionHref('edit', '')->setIcon('pencil');
     $grid->addActionHref('hide', 'Skrýt')->setCustomRender(function ($row) {
         $icon = Html::el('i');
         $button = Html::el('a')->href($this->presenter->link('hide!', $row->id))->title('Skrýt');
         if (isset($row->visible)) {
             $icon->class('fa fa-eye');
             if ($row->visible) {
                 $button->class('btn btn-default btn-xs btn-mini');
             } else {
                 $button->class('btn btn-danger btn-xs btn-mini');
             }
             $button->setHtml($icon);
         } else {
             $button->style('display: none');
         }
         return $button;
     });
     $grid->addActionHref('delete', '', 'delete!')->setIcon('times')->setConfirm('Opravdu smazat?');
     return $grid;
 }
Exemplo n.º 22
0
 /**
  * @param  string  label
  */
 public function __construct($label = NULL)
 {
     parent::__construct($label);
     $this->control->type = 'checkbox';
     $this->wrapper = Nette\Utils\Html::el();
     $this->setOption('type', 'checkbox');
 }
Exemplo n.º 23
0
 public function traverse()
 {
     // roots are pages labeled by active labels
     $roots = $this->getRoots();
     $topLevelContainer = $this->getRenderer()->createTopLevelContainer();
     //        dump($this->label);
     //        die();
     $descendantsParams = array('lang' => $this->getLang(), 'labelId' => $this->label['label_id'], 'entityConfig' => $this->getEntityConfig(), 'groupName' => $this->getGroupName(), 'searchGhosts' => $this->canSearchGhosts(), 'states' => $this->getAcceptedStates(), 'searchAllTimeZones' => $this->canSearchAllTimeZones(), 'orderDirection' => $this->getOrderDirection(), 'limit' => $this->getLimit(), 'sortingCallback' => $this->getSortingCallback());
     if (!empty($roots)) {
         $rel = 0;
         foreach ($roots as $root) {
             $descendants = $root->getDescendants($descendantsParams);
             if (count($descendants) > 0) {
                 $horizontalLevel = 1;
                 $regionElement = NULL;
                 foreach ($descendants as $descendant) {
                     $firstInRegion = FALSE;
                     if ($descendant->_ext_region['key'] != $this->lastRegion) {
                         $firstInRegion = TRUE;
                         $this->lastRegion = $descendant->_ext_region['key'];
                     }
                     if ($firstInRegion) {
                         $element = \Nette\Utils\Html::el('div');
                         $element->class = 'region r' . $rel++;
                         $regionElement = $topLevelContainer->add($element);
                     }
                     $this->getRenderer()->renderMenuItem($descendant, $descendantsParams, $element, 1, $horizontalLevel++, FALSE, $firstInRegion);
                 }
             }
         }
     }
     return $topLevelContainer;
 }
 public function flashParametrized($message, $type, $count = NULL, $parameters = [])
 {
     $flash = $this->translateFlash($message, $count, $parameters);
     $flash = Html::el('span')->setHtml($flash);
     //return as Html because it may contain tags
     return parent::flashMessage($flash, $type);
 }
Exemplo n.º 25
0
 /**
  * Render row item into template
  * @param  Row   $row
  * @return mixed
  */
 public function render(Row $row)
 {
     /**
      * Renderer function may be used
      */
     if ($renderer = $this->getRenderer()) {
         if (!$renderer->getConditionCallback()) {
             return call_user_func_array($renderer->getCallback(), [$row->getItem()]);
         }
         if (call_user_func_array($this->getRenderer(), [$row->getItem()])) {
             return call_user_func_array($renderer->getCallback(), [$row->getItem()]);
         }
     }
     $a = Html::el('a')->href($this->grid->getPresenter()->link($this->href, $this->getItemParams($row)));
     if ($this->icon) {
         $a->add(Html::el('span')->class(DataGrid::$icon_prefix . $this->icon));
         if (strlen($this->name)) {
             $a->add('&nbsp;');
         }
     }
     $a->add($this->name);
     if ($this->title) {
         $a->title($this->title);
     }
     if ($this->class) {
         $a->class($this->class);
     }
     if ($confirm = $this->getConfirm($row)) {
         $a->data('confirm', $confirm);
     }
     return $a;
 }
Exemplo n.º 26
0
 /**
  * Generates control's HTML element
  *
  * @return Html
  */
 public function getControl()
 {
     $control = parent::getControl()->addClass('pswdinput');
     $this->data['fid'] = $this->getForm()->getElementPrototype()->id;
     $control->data('lohini-pswd', \Nette\Utils\Json::encode(array_filter($this->data)));
     return Html::el('span', ['style' => 'position: relative; float: left;'])->add($control);
 }
Exemplo n.º 27
0
 public function __clone()
 {
     parent::__clone();
     $this->clonePlaceholder($this->originalMe, $this);
     $this->cloneChildrenWithPlaceholders($this, $this->originalMe->children);
     $this->originalMe = $this;
 }
Exemplo n.º 28
0
 public function getControl()
 {
     $control = Html::el('div');
     $control->id = $this->getHtmlId();
     //$this->value = $this->value != null ? $this->value : $this->defaultValue;
     $slider = Html::el('div');
     $slider->class('slider');
     $slider->{'data-min'} = $this->min;
     $slider->{'data-max'} = $this->max;
     $slider->{'data-value'} = $this->value;
     $slider->{'data-step'} = $this->increment;
     $slider->{'data-units'} = $this->units;
     $slider->{'data-linkedinput'} = $this->linkedInput;
     $input = Html::el('input')->type('hidden')->value($this->value / 100);
     $input->name = $this->getHtmlName('value');
     $input->id = $this->getHtmlId() . '-value';
     $control->{'data-inputid'} = '#' . $input->id;
     if (isset($this->linkedElement)) {
         $slider->{'data-linkedelement'} = $this->linkedElement;
         $slider->{'data-linkedproperty'} = $this->linkedProperty;
     }
     $valuePreview = Html::el('span');
     $valuePreview->id = $this->getHtmlId() . '-preview';
     $valuePreview->setText($this->value . $this->units);
     $slider->{'data-previewelement'} = '#' . $valuePreview->id;
     $control->add($slider);
     $control->add($input);
     $control->add($valuePreview);
     return $control;
 }
Exemplo n.º 29
0
 /**
  * @param  string  label
  * @param  array   options from which to choose
  */
 public function __construct($label = NULL, array $items = NULL)
 {
     parent::__construct($label, $items);
     $this->control->type = 'checkbox';
     $this->container = Html::el();
     $this->separator = Html::el('br');
 }
Exemplo n.º 30
0
 /**
  * Generates control's HTML element.
  * @return Html
  */
 public function getControl()
 {
     //DOROBIT TY KOKOT LENIVY
     $fromControl = Html::el('input')->class('datepicker')->autocomplete('on');
     $fromControl->name = $this->getHtmlName() . '[from]';
     $fromControl->disabled = $this->disabled;
     $fromControl->id = $this->getHtmlId() . '-from';
     if (isset($this->value['from'])) {
         $from = $this->value['from'];
         if ($from instanceof \DateTime) {
             $fromControl->value($this->value['from']->format('d.m.Y'));
         } else {
             $fromControl->value($this->value['from']);
         }
     }
     $toControl = Html::el('input')->class('datepicker')->autocomplete('on');
     $toControl->name = $this->getHtmlName() . '[to]';
     $toControl->disabled = $this->disabled;
     $toControl->id = $this->getHtmlId() . '-to';
     if (isset($this->value['to'])) {
         $to = $this->value['to'];
         if ($to instanceof \DateTime) {
             $toControl->value($this->value['to']->format('d.m.Y'));
         } else {
             $toControl->value($this->value['to']);
         }
     }
     $control = Html::el('span')->add($fromControl)->add($toControl)->class('range-input');
     $control->disabled = $this->disabled;
     return $control;
 }