public function __construct(DbTable\Oznam $oznam, DbTable\Registracia $registracia, DbTable\Ikonka $ikonka, User $user)
  {
      $this->oznam = $oznam;
      $this->ikonka = $ikonka;
      $this->urovneReg = $registracia->hladaj_urovne(0, $user->isLoggedIn() ? $user->getIdentity()->id_registracia : 0)->fetchPairs('id', 'nazov');
  }
  /**
 * Formular pre editaciu oznamu
 * @param int $oznam_ucast Povolenie potvrdenia ucasti
 * @param boolean $send_e_mail_news Povolenie zasielania info e-mailov
 * @param boolean $oznam_title_image_en Povolenie titulneho obrazka
 * @param string $nazov_stranky Nazov stranky
 * @return Form
 */
  public function create($oznam_ucast, $send_e_mail_news, $oznam_title_image_en, $nazov_stranky)
  {
      $form = new Form();
      $form->addProtection();
      $form->addHidden("id");
      $form->addHidden("id_user_profiles");
      $form->addHidden("datum_zadania");
      $form->addDatePicker('datum_platnosti', 'Dátum platnosti')->addRule(Form::FILLED, 'Dátum platnosti musí byť zadaný!');
      $form->addText('nazov', 'Nadpis:', 50, 80)->addRule(Form::MIN_LENGTH, 'Nadpis musí mať spoň %d znakov!', 3)->setRequired('Názov musí byť zadaný!');
      $form->addSelect('id_registracia', 'Povolené prezeranie pre min. úroveň:', $this->urovneReg);
      if ($oznam_ucast) {
          $form->addCheckbox('potvrdenie', ' Potvrdenie účasti');
      } else {
          $form->addHidden('potvrdenie');
      }
      if ($send_e_mail_news) {
          $form->addCheckbox('posli_news', ' Posielatie NEWS o tejto aktualite');
      } else {
          $form->addHidden("posli_news", FALSE);
      }
      if (!$oznam_title_image_en) {
          //$this->oznam_title_image_en
 /**
  * allows 'nested options' with only 1 html optgroup (valid)
  * options are indented by 4 spaces per level
  *
  * @param array
  * @param FormControl
  * @param int nesting level
  */
 private function formatOptions($options, &$control, $level = 1)
 {
     $option = Html::el('option');
     $indentation = str_repeat(" ", ($level - 1) * 4);
     foreach ($options as $key => $value) {
         if (!is_array($value)) {
             $value = array($key => $value);
             $dest = $control;
         } else {
             // no nested optgroups allowed -> using disabled options indented by space
             if ($level > 1) {
                 $dest = $control;
                 // simulate optgroup
                 if (is_array($value)) {
                     $dest->add((string) $option->disabled(true)->setHtml($this->translate($key)));
                 }
             } else {
                 $dest = $control->create('optgroup')->label($key);
             }
         }
         foreach ($value as $key2 => $value2) {
             if ($value2 instanceof Html) {
                 $dest->add((string) $value2->selected(isset($this->selected[$key2])));
                 // multidimensional array -> nested optgroups - must by styled with CSS to see hierarchy
             } elseif (is_array($value2)) {
                 $this->formatOptions(array($key2 => $value2), $dest, $level + 1);
             } elseif ($this->areKeysUsed()) {
                 $dest->add((string) $option->disabled(false)->value($key2)->selected(isset($this->selected[$key2]))->setText($indentation . $this->translate($value2)));
             } else {
                 $dest->add((string) $option->disabled(false)->selected(isset($this->selected[$value2]))->setText($indentation . $this->translate($value2)));
             }
         }
     }
 }
Exemple #3
0
 /**
 	 * Generates control's HTML element.
 	 * @return Html
          * <span id="ns" class="ui-stepper">
 	<input type="text" name="ns_textbox" size="2" autocomplete="off" class="ui-stepper-textbox" />
 	<button type="submit" name="ns_button_1" class="ui-stepper-plus">+</button>
 	<button type="submit" name="ns_button_2" class="ui-stepper-minus">-</button>
 </span>
 */
 public function getControl()
 {
     $control = parent::getControl();
     $updown = Html::el('span')->class('ui-stepper')->add($control)->add(Html::el('input')->type('button')->class('ui-stepper-plus'))->add(Html::el('button')->class('ui-stepper-minus'));
     //$control->class = 'numericUpDown';
     return $updown;
 }
Exemple #4
0
 protected function createComponentUsers()
 {
     $grid = new DataGrid();
     $grid->bindDataTable(UsersModel::getUsers());
     $grid->addColumn('userName', 'Uživatelské jméno')->addFilter();
     $grid->addColumn('firstName', 'Jméno')->addFilter();
     $grid->addColumn('surname', 'Přijmení')->addFilter();
     $grid->addColumn('email', 'E-mail')->addFilter();
     $grid->addColumn('icq', 'ICQ')->addFilter();
     $grid->addColumn('mobile', 'Mobilní telefon')->addFilter();
     $grid->addColumn('active', 'Aktivní')->addSelectboxFilter(array(1 => 'Yes', 0 => 'No'));
     $grid->addColumn('holiday', 'Dovolená')->addSelectboxFilter(array(1 => 'Yes', 0 => 'No'));
     $grid->multiOrder = FALSE;
     // order by one column only
     $grid['holiday']->replacement['1'] = 'Ano';
     $grid['holiday']->replacement['0'] = 'Ne';
     $grid['active']->replacement['1'] = 'Ano';
     $grid['active']->replacement['0'] = 'Ne';
     $grid->displayedItems = array(10, 20, 50, 75, 100, 500, 1000);
     // roletka pro výběr počtu řádků na stránku
     $grid->addActionColumn('Actions');
     $grid->keyName = 'id';
     $grid->addAction('Aktivovat/Deaktivovat', 'userActivateChange!', Html::el('span')->setText('Aktivace/Deaktivace'), $useAjax = TRUE);
     $grid->addAction('Dovolená', 'userHolidayChange!', Html::el('span')->setText('Dovolená'), $useAjax = TRUE);
     $grid->addAction('Editovat', 'userChangeRedirect', Html::el('span')->setText('Editovat'), $useAjax = FALSE);
     $grid->addAction('Změnit heslo', 'userPasswordChangeRedirect', Html::el('span')->setText('Změnit heslo'), $useAjax = FALSE);
     $grid->addAction('Smazat', 'confirmForm:confirmUserDelete!', Html::el('span')->setText('Smazat'), $useAjax = TRUE);
     return $grid;
 }
Exemple #5
0
 public static function showLi($object, $deep = 1, $maxDeep = 0, $hrefFunc = null, $order = [])
 {
     $count = 0;
     $isset = false;
     $class = get_class($object);
     $item = $hrefFunc ? $hrefFunc($object) : "<a href='#'> {$object->name()}</a> ";
     $attributes = [];
     if (is_array($item)) {
         $attributes = $item['attributes'];
         $item = $item['text'];
     }
     if (!isset($attributes['id'])) {
         $attributes['id'] = str_replace('\\', '_', get_class($object)) . "-{$object->pk()}";
     }
     if (!$maxDeep || $deep < $maxDeep) {
         $items = $class::getList(['where' => ['parent_id', $object->pk()], 'order' => $order]);
         $count += count($items);
         foreach ($items as $objectChild) {
             if (!$isset) {
                 $isset = true;
                 echo \Html::el('li', $attributes, $item, true);
                 echo '<ul>';
             }
             $count += static::showLi($objectChild, $deep + 1, $maxDeep, $hrefFunc, $order);
         }
     }
     if ($isset) {
         echo '</ul></li>';
     } else {
         echo \Html::el('li', $attributes, $item);
     }
     return $count;
 }
 public function placeLink(Html $row, DibiRow $data, $pres)
 {
     foreach ($row->getChildren() as $cell) {
         $inside = $cell->getText();
         $cell->setText('');
         $cell->add(Html::el('a')->href($this->link(":Front:{$pres}:", $data['link']))->setText($inside));
     }
 }
 /**
  * @param  string  caption
  */
 public function __construct($caption = NULL)
 {
     parent::__construct();
     $this->control = Html::el('input');
     $this->label = Html::el('label');
     $this->caption = $caption;
     $this->rules = new Rules($this);
 }
Exemple #8
0
 /**
  * Formats cell's content.
  * @param  mixed
  * @param  DibiRow|array
  * @return string
  */
 public function formatContent($value, $data = NULL)
 {
     $checkbox = Html::el('input')->type('checkbox')->disabled('disabled');
     if ($value) {
         $checkbox->checked = TRUE;
     }
     return (string) $checkbox;
 }
 /**
  * Returns the code for the panel tab.
  * @return string
  */
 public function getTab()
 {
     $tab = Html::el('span');
     $image = $tab->create('img')->src($this->getIconSrc('flag_blue.png'))->id('TranslationPanel-icon');
     $tab->add('Translations');
     $tab->create('script')->type('text/javascript')->setHtml('translationPanel.init();');
     return (string) $tab;
 }
Exemple #10
0
 /**
  * @param  string  caption
  */
 public function __construct($caption = NULL)
 {
     $this->monitor('Nette\\Forms\\Form');
     parent::__construct();
     $this->control = Html::el('input');
     $this->label = Html::el('label');
     $this->caption = $caption;
     $this->rules = new Rules($this);
 }
Exemple #11
0
 public function __construct($parent = NULL, $name = NULL)
 {
     parent::__construct($parent, $name);
     $this->form = new AppForm($this, 'form');
     $this->form->addSubmit('yes', _('Yes'))->onClick[] = array($this, 'confirmClicked');
     $this->form->addSubmit('no', _('No'))->onClick[] = array($this, 'cancelClicked');
     $this->form->addHidden('token');
     $this->question = Html::el('p');
     $this->session = Environment::getSession('ConfirmationDialog/tokens');
 }
 public function createComponentCategoriesGrid($name)
 {
     $grid = new DataGrid($this, $name);
     $ds = $this->model('categories')->getDs();
     $grid->bindDataTable($ds);
     $grid->keyName = 'id';
     $grid->addColumn('title', 'Title')->addFilter();
     $grid->addActionColumn('Actions');
     $grid->addAction('Edit', 'editCategory!', Html::el('span')->class('icon icon-edit'), $useAjax = TRUE);
     $grid->addAction('Delete', 'confirmForm:confirmDelete!', Html::el('span')->class('icon icon-delete'), $useAjax = TRUE);
     return $grid;
 }
Exemple #13
0
 /**
  * Data grid column constructor.
  * @param  string  textual caption of column
  * @param  int     maximum number of dislayed characters
  */
 public function __construct($caption = NULL, $maxLength = NULL)
 {
     parent::__construct();
     $this->addComponent(new ComponentContainer(), 'filters');
     $this->header = Html::el();
     $this->cell = Html::el();
     $this->caption = $caption;
     if ($maxLength !== NULL) {
         $this->maxLength = $maxLength;
     }
     $this->monitor('DataGrid');
 }
Exemple #14
0
 /**
  * Returns link to editor.
  * @return Html
  */
 public static function editorLink($file, $line)
 {
     if (Debugger::$editor && is_file($file)) {
         $dir = dirname(strtr($file, '/', DIRECTORY_SEPARATOR));
         $base = isset($_SERVER['SCRIPT_FILENAME']) ? dirname(dirname(strtr($_SERVER['SCRIPT_FILENAME'], '/', DIRECTORY_SEPARATOR))) : dirname($dir);
         if (substr($dir, 0, strlen($base)) === $base) {
             $dir = '...' . substr($dir, strlen($base));
         }
         return Html::el('a')->href(strtr(Debugger::$editor, array('%file' => rawurlencode($file), '%line' => $line)))->title("{$file}:{$line}")->setHtml(htmlSpecialChars(rtrim($dir, DIRECTORY_SEPARATOR)) . DIRECTORY_SEPARATOR . '<b>' . htmlSpecialChars(basename($file)) . '</b>');
     } else {
         return Html::el('span')->setText($file);
     }
 }
Exemple #15
0
 private function exampleForm()
 {
     $countries = array('Select your country', 'Europe' => array('CZ' => 'Czech Republic', 'FR' => 'France', 'DE' => 'Germany', 'GR' => 'Greece', 'HU' => 'Hungary', 'IE' => 'Ireland', 'IT' => 'Italy', 'NL' => 'Netherlands', 'PL' => 'Poland', 'SK' => 'Slovakia', 'ES' => 'Spain', 'CH' => 'Switzerland', 'UA' => 'Ukraine', 'GB' => 'United Kingdom'), 'AU' => 'Australia', 'CA' => 'Canada', 'EG' => 'Egypt', 'JP' => 'Japan', 'US' => 'United States', '?' => 'other');
     $sex = array('m' => 'male', 'f' => 'female');
     // Step 1: Define form with validation rules
     $form = new Form();
     // group Personal data
     $form->addGroup('Personal data')->setOption('description', 'We value your privacy and we ensure that the information you give to us will not be shared to other entities.');
     $form->addText('name', 'Your name:', 35)->addRule(Form::FILLED, 'Enter your name');
     $form->addText('age', 'Your age:', 5)->addRule(Form::FILLED, 'Enter your age')->addRule(Form::INTEGER, 'Age must be numeric value')->addRule(Form::RANGE, 'Age must be in range from %.2f to %.2f', array(9.9, 100));
     $form->addRadioList('gender', 'Your gender:', $sex);
     $form->addText('email', 'E-mail:', 35)->setEmptyValue('@')->addCondition(Form::FILLED)->addRule(Form::EMAIL, 'Incorrect E-mail Address');
     // ... then check email
     // group Shipping address
     $form->addGroup('Shipping address')->setOption('embedNext', TRUE);
     $form->addCheckbox('send', 'Ship to address')->addCondition(Form::EQUAL, TRUE)->toggle('sendBox');
     // toggle div #sendBox
     // subgroup
     $form->addGroup()->setOption('container', Html::el('div')->id('sendBox'));
     $form->addText('street', 'Street:', 35);
     $form->addText('city', 'City:', 35)->addConditionOn($form['send'], Form::EQUAL, TRUE)->addRule(Form::FILLED, 'Enter your shipping address');
     $form->addSelect('country', 'Country:', $countries)->skipFirst()->addConditionOn($form['send'], Form::EQUAL, TRUE)->addRule(Form::FILLED, 'Select your country');
     // group Your account
     $form->addGroup('Your account');
     $form->addPassword('password', 'Choose password:'******'Choose your password')->addRule(Form::MIN_LENGTH, 'The password is too short: it must be at least %d characters', 3);
     $form->addPassword('password2', 'Reenter password:'******'password'], Form::VALID)->addRule(Form::FILLED, 'Reenter your password')->addRule(Form::EQUAL, 'Passwords do not match', $form['password']);
     $form->addFile('avatar', 'Picture:')->addCondition(Form::FILLED)->addRule(Form::MIME_TYPE, 'Uploaded file is not image', 'image/*');
     $form->addHidden('userid');
     $form->addTextArea('note', 'Comment:', 30, 5);
     // group for buttons
     $form->addGroup();
     $form->addSubmit('submit1', 'Send');
     // Step 2: Check if form was submitted?
     if ($form->isSubmitted()) {
         // Step 2c: Check if form is valid
         if ($form->isValid()) {
             echo '<h2>Form was submitted and successfully validated</h2>';
             $values = $form->getValues();
             Debug::dump($values);
             // this is the end, my friend :-)
             if (empty($disableExit)) {
                 exit;
             }
         }
     } else {
         // not submitted, define default values
         $defaults = array('name' => 'John Doe', 'userid' => 231, 'country' => 'CZ');
         $form->setDefaults($defaults);
     }
     return $form;
 }
Exemple #16
0
    public function renderJs($base, $dirpath, $files) {
        if ($dirpath !== null) {

            $this->base = $this->getBase($base);

            foreach ($files as $file) {
                echo Html::el("script")
                        ->language("javascript")
                        ->type("text/javascript")
                        ->src($this->base.$dirpath.$file)
                        . "\n";
            }
        }
    }
Exemple #17
0
 /**
  * Form constructor.
  * @param  string
  */
 public function __construct($name = NULL)
 {
     $this->element = Html::el('form');
     $this->element->action = '';
     // RFC 1808 -> empty uri means 'this'
     $this->element->method = self::POST;
     $this->element->id = $name === NULL ? NULL : 'frm-' . $name;
     $this->monitor(__CLASS__);
     if ($name !== NULL) {
         $tracker = new HiddenField($name);
         $tracker->unmonitor(__CLASS__);
         $this[self::TRACKER_ID] = $tracker;
     }
     parent::__construct(NULL, $name);
 }
Exemple #18
0
 public function createTabs($name, $page)
 {
     $params = $this->getRequest()->getParams();
     $action = $params['action'];
     $linkMeta = Html::el('a')->href($this->link('default'))->add(Html::el('span')->add('Admin Themes'));
     $linkAdvanced = Html::el('a')->href($this->link('site'))->add(Html::el('span')->add('Site Themes'));
     $liMeta = Html::el('li')->class('ui-tabs-panel ui-widget-content ui-state-default ui-corner-top');
     $liAdvanced = Html::el('li')->class('ui-tabs-panel ui-widget-content ui-state-default ui-corner-top');
     if ($action == 'site') {
         $liAdvanced->class('ui-tabs-panel ui-widget-content ui-state-default ui-corner-top ui-tabs-selected ui-state-active');
     } else {
         $liMeta->class('ui-tabs-panel ui-widget-content ui-state-default ui-corner-top ui-tabs-selected ui-state-active');
     }
     $tabs = Html::el('div')->class('tabs ui-tabs ui-widget ui-widget-content ui-corner-all')->add(Html::el('ul')->class('ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all')->add($liMeta->add($linkMeta))->add($liAdvanced->add($linkAdvanced)));
     return $tabs;
 }
Exemple #19
0
 /**
  * Data grid action constructor.
  * @note   for full ajax support, destination should not change module, 
  * @note   presenter or action and must be ended with exclamation mark (!)
  * 
  * @param  string  textual title
  * @param  string  textual link destination
  * @param  Html    element which is added to a generated link
  * @param  bool    use ajax? (add class self::$ajaxClass into generated link)
  * @param  bool    generate link with argument? (variable $keyName must be defined in data grid)
  * @return void
  */
 public function __construct($title, $destination, \Nette\Web\Html $icon = NULL, $useAjax = FALSE, $type = self::WITH_KEY)
 {
     parent::__construct();
     $this->type = $type;
     $this->destination = $destination;
     $a = Html::el('a')->title($title);
     if ($useAjax) {
         $a->class[] = self::$ajaxClass;
     }
     if ($icon !== NULL && $icon instanceof \Nette\Web\Html) {
         $a->add($icon);
     } else {
         $a->setText($title);
     }
     $this->html = $a;
 }
Exemple #20
0
 /**
  * Data grid action constructor.
  * @note   for full ajax support, destination should not change module,
  * @note   presenter or action and must be ended with exclamation mark (!)
  *
  * @param  string  textual title
  * @param  string  textual link destination
  * @param  Html    element which is added to a generated link
  * @param  bool    use ajax? (add class self::$ajaxClass into generated link)
  * @param  mixed   generate link with argument? (if yes you can specify name of parameter
  * 				   otherwise variable DataGrid::$keyName will be used and must be defined)
  * @return void
  */
 public function __construct($title, $destination, Html $icon = NULL, $useAjax = FALSE, $key = self::WITH_KEY)
 {
     parent::__construct();
     $this->destination = $destination;
     $this->key = $key;
     $a = Html::el('a')->title($title);
     if ($useAjax) {
         $a->addClass(self::$ajaxClass);
     }
     if ($icon !== NULL && $icon instanceof Html) {
         $a->add($icon);
     } else {
         $a->setText($title);
     }
     $this->html = $a;
 }
Exemple #21
0
 public function formatActions(Html $action, DibiRow $data)
 {
     if ($action->attrs['title'] == 'StatusToggle' || $action->attrs['title'] == 'Enable' || $action->attrs['title'] == 'Disable') {
         if ($data->status == 'enabled') {
             $action->attrs['title'] = 'Disable';
             $action->removeChildren();
             $action->add(Html::el('span')->class('icon icon-stop'));
             $action->href = $action->href . '&new_status=disabled';
         }
         if ($data->status == 'disabled') {
             $action->attrs['title'] = 'Enable';
             $action->removeChildren();
             $action->add(Html::el('span')->class('icon icon-play'));
             $action->href = $action->href . '&new_status=enabled';
         }
         return $action;
     }
 }
 public function createComponentFormAddTerm($name)
 {
     Form::extensionMethod('addDatePicker', array($this, 'Form_addDatePicker'));
     Form::extensionMethod('addTimePicker', array($this, 'Form_addTimePicker'));
     Form::extensionMethod('addNumericUpDown', array($this, 'Form_addNumericUpDown'));
     $form = new LiveForm($this, $name);
     $form->getElementPrototype()->class('ajax');
     $form->addGroup('Exam room and time');
     $rooms = SchoolManager::getRooms();
     $rooms = array('0' => 'Please select') + $rooms;
     $form->addSelect('room', 'Room', $rooms)->addRule(Form::FILLED, 'Please select a room')->skipFirst();
     $form->addDatePicker('start_date', 'Date', 10)->addRule(Form::FILLED, 'Please select a starting date');
     $form->addTimePicker('start_date_time', 'Start time', 10)->addRule(Form::FILLED, 'Please select a starting time');
     $form->addGroup('Application deadline');
     $form->addDatePicker('deadline_date', 'Date', 10)->addRule(Form::FILLED, 'Please select an application deadline date');
     $form->addTimePicker('deadline_date_time', 'Time', 10)->addRule(Form::FILLED, 'Please select an application deadline time');
     $form->addGroup('Conditions');
     $form->addText('max_students', 'Student limit')->addRule(Form::FILLED, 'Please enter a student limit.')->addRule(Form::NUMERIC, 'Limit must be numeric');
     $form->addText('min_seminar_points', 'Minimum points')->addCondition(Form::FILLED)->addRule(Form::NUMERIC, 'Limit must be numeric');
     $form->addGroup('Note')->setOption('container', Html::el('fieldset')->class('no-label'));
     $form->addTextArea('note');
     $form->addHidden('course_id')->setValue($this->course_id);
     $form->addHidden('id');
     $form->addSubmit('btnSubmit', 'Save')->onClick[] = callback($this, 'FormAddTermSubmitted');
     if ($this->isSignalReceiver($this[$name])) {
         $this->template->show_popup = true;
     }
     if (isset($this->exam_id)) {
         $session = Environment::getSession('exam_terms_edit_form_' . $this->exam_id);
         if (isset($session['form_data'])) {
             $form_data = $session->form_data;
         } else {
             $form_data = ExamManager::getExam($this->exam_id);
             $form_data->start_date = $form_data->start_datetime;
             $form_data->deadline_date = $form_data->application_deadline;
             $form_data->start_date_time = $form_data->start_datetime;
             $form_data->deadline_date_time = $form_data->application_deadline;
             $session->form_data = $form_data;
         }
         $form->setDefaults($form_data);
         $form['id']->setValue($this->exam_id);
     }
     return $form;
 }
Exemple #23
0
 public function getControl($caption = NULL)
 {
     $control = parent::getControl($caption);
     $control->setText("");
     // Delete content
     if ($this->icon) {
         $control->class[] = "hasIcon";
         $this->icon->alt = $this->caption;
         $control->add($this->icon);
     }
     if ($this->showCaption) {
         $control->class[] = "hasCaption";
         $control->add(Html::el("span class=caption")->setHtml($this->caption));
     }
     // CSS classes:
     if ($this->icon and !$this->showCaption) {
         $control->class[] = "hasIconAndNoCaption";
     } elseif (!$this->icon and $this->showCaption) {
         $control->class[] = "hasCaptionAndNoIcon";
     } elseif ($this->icon and $this->showCaption) {
         $control->class[] = "hasCaptionAndIcon";
     }
     return $control;
 }
 /**
  * Get script element
  * @param string $source
  * @return Html
  */
 public function getElement($source)
 {
     return Html::el("script")->type("text/javascript")->src($source);
 }
Exemple #25
0
 /**
  * Generates control's HTML element.
  * @param  mixed
  * @return Html
  */
 public function getControl($key = NULL)
 {
     if ($key === NULL) {
         $container = clone $this->container;
         $separator = (string) $this->separator;
     } elseif (!isset($this->items[$key])) {
         return NULL;
     }
     $control = parent::getControl();
     $id = $control->id;
     $counter = -1;
     $value = $this->value === NULL ? NULL : (string) $this->getValue();
     $label = Html::el('label');
     foreach ($this->items as $k => $val) {
         $counter++;
         if ($key !== NULL && $key != $k) {
             continue;
         }
         // intentionally ==
         $control->id = $label->for = $id . '-' . $counter;
         $control->checked = (string) $k === $value;
         $control->value = $k;
         if ($val instanceof Html) {
             $label->setHtml($val);
         } else {
             $label->setText($this->translate($val));
         }
         if ($key !== NULL) {
             return (string) $control . (string) $label;
         }
         $container->add((string) $control . (string) $label . $separator);
         unset($control->data['nette-rules']);
         // TODO: separator after last item?
     }
     return $container;
 }
Exemple #26
0
 public function createNameLink($value, DibiRow $data)
 {
     return Html::el('a', $value)->class('ajax')->href($this->link('MenuItems:default', array('id' => $data['id'])));
 }
 protected function createComponentItemForm()
 {
     $form = new MyAppForm();
     $form->enableAjax();
     $form->enableAjaxFileUpload();
     if (!is_null($this->getTranslator())) {
         $form->setTranslator($this->getTranslator());
     }
     $form->getRenderer()->wrappers['label']['requiredsuffix'] = " *";
     $form->addGroup();
     $form->addText('username', 'User Name')->addRule($form::FILLED)->addRule($form::MIN_LENGTH, NULL, 3)->addRule($form::MAX_LENGTH, NULL, 30)->getControlPrototype()->data('nette-check-url', $this->link('checkAvailability!', array('__NAME__', 'user')))->class[] = 'checkAvailability';
     $form->addText('firstname', 'First Name')->addRule($form::FILLED)->addRule($form::MIN_LENGTH, NULL, 2)->addRule($form::MAX_LENGTH, NULL, 70);
     $form->addText('lastname', 'Last Name')->addRule($form::FILLED)->addRule($form::MIN_LENGTH, NULL, 2)->addRule($form::MAX_LENGTH, NULL, 70);
     if ($this->getAction() === 'add') {
         $form->addPassword('password', 'Password')->addRule($form::FILLED)->addRule($form::MIN_LENGTH, NULL, 6);
         $form->addPassword('password2', 'Confirm Password')->addRule($form::FILLED, 'Confirm user password!')->addRule($form::EQUAL, 'No match for passwords!', $form['password']);
     } elseif ($this->getAction() === 'edit') {
         $form->addPassword('password', 'Password')->setOption('description', 'Fill in only if you want to change current password')->addCondition($form::FILLED)->addRule($form::MIN_LENGTH, NULL, 6);
         $form['password']->getControlPrototype()->autocomplete('off');
         $form->addPassword('password2', 'Confirm Password')->setOption('description', 'Fill in only if you want to change current password')->addConditionOn($form['password'], $form::FILLED)->addRule($form::FILLED, 'Confirm your password!')->addRule($form::EQUAL, 'No match for passwords!', $form['password']);
     }
     $form->addText('email', 'E-Mail')->setEmptyValue('@')->addRule($form::FILLED)->addRule($form::EMAIL)->addRule($form::MAX_LENGTH, NULL, 60);
     if ($this->isClientMode) {
         //		    $form->addSelect('roles', 'Role', $this->prepareRoles())
         $form->addSelect('roles', 'Role', BaseModel::prepareSelect($this->prepareRoles()))->skipFirst()->addRule($form::FILLED);
     } else {
         $form->addMultiSelect('roles', 'Role', $this->prepareRoles(), 7)->addRule($form::FILLED)->addCondition(Form::EQUAL, UsersModel::$clientRolesId)->toggle('supervisorBox')->addCondition(Form::EQUAL, UsersModel::UL_CLIENT_ID)->toggle('clientLogoBox');
         // client as supervisor group
         $form->addGroup()->setOption('container', Html::el('div')->id('supervisorBox'));
         $form->addSelect('supervisor_id', 'Client', $this->prepareClients())->skipFirst()->addConditionOn($form['roles'], Form::EQUAL, UsersModel::$clientRolesId)->addRule(Form::FILLED);
         // client logo group
         $form->addGroup()->setOption('container', Html::el('div')->id('clientLogoBox'));
         // when editing logo is optional
         if ($this->getParam('action') == 'edit') {
             $form->addFile('client_logo', "Client's logo")->setOption('description', 'Choose photo only if you want to change current one')->addCondition(Form::FILLED)->addRule(MyAppForm::SUFFIX, 'Logo must be image (jpg, gif, png)', 'jpg, gif, png')->addRule(Form::MAX_FILE_SIZE, 'File attachment exceeds maximum file size ' . Environment::getConfig("upload")->max_file_size . 'B', Environment::getConfig("upload")->max_file_size);
         } else {
             $form->addFile('client_logo', "Client's logo")->addConditionOn($form['roles'], Form::EQUAL, UsersModel::UL_CLIENT_ID)->addRule(Form::FILLED)->addRule(MyAppForm::SUFFIX, 'Logo must be image (jpg, gif, png)', 'jpg, gif, png')->addRule(Form::MAX_FILE_SIZE, 'File attachment exceeds maximum file size ' . Environment::getConfig("upload")->max_file_size . 'B', Environment::getConfig("upload")->max_file_size);
         }
     }
     $form->addGroup();
     $form->addCheckbox('send_email', 'Send notification email');
     $form->addSubmit('save', 'Add User')->getControlPrototype()->class[] = 'ok-button';
     $_this = $this;
     $form->addSubmit('cancel', 'Cancel')->setValidationScope(NULL)->getControlPrototype()->class[] = 'cancel-button';
     $form['cancel']->onClick[] = function () use($_this) {
         $_this->refresh(null, 'add', array(), true);
     };
     $form->onSubmit[] = callback($this, 'itemFormSubmitted');
     //		$form['save']->onClick[] = callback($this, 'itemFormSubmitted');
     return $form;
 }
Exemple #28
0
 public function createTabAdvanced($name, $page)
 {
     return Html::el('a')->href($this->link('ClearCache!'))->class('ajax')->add('Clear cache!');
 }
Exemple #29
0
 /**
  * Get link element
  * @param string $uri
  * @param string $title
  * @return Html|string
  */
 public function getElement($uri, $title = null)
 {
     return Html::el("link")->href($uri)->type("application/rss+xml")->title($title);
 }
Exemple #30
0
 /**
  * @param  string
  * @return Nette\Web\Html
  */
 protected function getWrapper($name)
 {
     $data = $this->getValue($name);
     return $data instanceof Html ? clone $data : Html::el($data);
 }