domain() public method

public domain ( string $messagePrefix ) : ITranslator
$messagePrefix string
return ITranslator
Ejemplo n.º 1
0
 protected function createComponentPageForm()
 {
     $form = new Form();
     $form->setTranslator($this->translator->domain('pageEditForm'));
     $form->getElementPrototype()->id = 'page-form';
     $form->addText('title', 'title.label', null, Page::LENGTH_TITLE)->setMaxLength(Page::LENGTH_TITLE)->setRequired('title.messages.required')->setAttribute('data-text-length', Page::LENGTH_TITLE)->addRule(Form::MAX_LENGTH, new Phrase('title.messages.maxLength', ['numChars' => Page::LENGTH_TITLE]), Page::LENGTH_TITLE);
     $form->addText('publishedAt', 'publishedAt.label', null, 16)->setHtmlId('datetimepicker')->setRequired('publishedAt.messages.required')->addCondition(Form::FILLED)->addRule(Form::MAX_LENGTH, new Phrase('publishedAt.messages.maxLength', ['numChars' => 16]), 16);
     $form->addTextArea('intro', 'intro.label', null, 7)->setMaxLength(Page::LENGTH_INTRO)->setRequired('intro.messages.required')->setAttribute('data-text-length', Page::LENGTH_INTRO)->addRule(Form::MAX_LENGTH, new Phrase('intro.messages.maxLength', ['numChars' => Page::LENGTH_INTRO]), Page::LENGTH_INTRO);
     $form->addTextArea('text', 'text.label', null, 25);
     //->setRequired('text.messages.required');
     $form->addText('url', 'url.label', null, 255);
     $form->addSelect('lang', 'lang.label')->setItems($this->availableLocales)->setDefaultValue($this->defaultLocale);
     if (isset($this->page)) {
         $form['lang']->setDisabled();
         //$form['lang']->setOmitted();
     }
     $form->addCheckbox('allowedComments', 'allowedComments.label')->setDefaultValue(true);
     $form->addText('keywords', 'keywords.label');
     $form->addText('description', 'description.label');
     $form->addSubmit('saveAndPublish', 'saveAndPublish.caption')->setAttribute('title', $this->translator->translate('pageEditForm.saveAndPublish.title'))->onClick[] = [$this, 'processPageSavingAndPublishing'];
     $form->addSubmit('saveAsDraft', 'saveAsDraft.caption')->setAttribute('title', $this->translator->translate('pageEditForm.saveAsDraft.title'))->onClick[] = [$this, 'processPageSavingAsDraft'];
     if (!$this->authorizator->isAllowed($this->user, 'page', 'create') or !$this->authorizator->isAllowed($this->user, 'page', 'edit')) {
         $form['saveAndPublish']->setDisabled();
         $form['saveAsDraft']->setDisabled();
     }
     $form->addProtection();
     return $form;
 }
Ejemplo n.º 2
0
 protected function createComponentForm()
 {
     $form = new Form();
     $form->setTranslator($this->translator->domain('page.comments.form.inputs'));
     $form->addText('author', 'author.label', null, Comment::LENGTH_AUTHOR)->setRequired('author.messages.required');
     $form->addTextArea('text', 'text.label', null, 6)->setMaxLength(Comment::LENGTH_TEXT)->setRequired('text.messages.required')->setHtmlId('comment-textarea');
     $form->addSubmit('send', 'submit.caption');
     $form->onSuccess[] = [$this, 'processForm'];
     return $form;
 }
Ejemplo n.º 3
0
 protected function createComponentFilter()
 {
     $form = new Form();
     $form->setTranslator($this->translator->domain('tags.filter.form'));
     $form->getElementPrototype()->class = 'ajax';
     $form->addText('name', 'name.label')->setDefaultValue($this->name);
     $form->addSubmit('filter', 'filter.label')->onClick[] = [$this, 'filterTags'];
     $form->addSubmit('reset', 'reset.label')->onClick[] = [$this, 'filterReset'];
     return $form;
 }
Ejemplo n.º 4
0
 protected function createComponentForm()
 {
     $form = new Form();
     $form->setTranslator($this->translator->domain('users.roleRemoval.actions'));
     $form->addSubmit('remove', 'remove')->onClick[] = [$this, 'removeRole'];
     if (!$this->authorizator->isAllowed($this->user, 'user_role', 'remove')) {
         $form['remove']->setDisabled();
     }
     $form->addSubmit('cancel', 'cancel')->onClick[] = [$this, 'cancel'];
     $form->addProtection();
     return $form;
 }
Ejemplo n.º 5
0
 protected function createComponentNewRoleForm()
 {
     $form = new Form();
     $form->setTranslator($this->translator->domain('users.newRole.form'));
     $form->addText('name', 'name.label', null, Role::LENGTH_NAME)->setRequired('name.messages.required');
     $form->addSelect('parent', $this->translator->translate('users.newRole.form.parent.label'))->setTranslator(null)->setPrompt($this->translator->translate('users.newRole.form.parent.prompt'))->setItems($this->prepareRolesForSelect($this->userFacade->findRolesThatAreNotParents()));
     $form->addSubmit('save', 'save.caption');
     if (!$this->authorizator->isAllowed($this->user, 'user_role', 'create')) {
         $form['save']->setDisabled();
     }
     $form->onSuccess[] = [$this, 'processNewRole'];
     return $form;
 }
Ejemplo n.º 6
0
 protected function createComponentRemovalForm()
 {
     $form = new Form();
     $form->setTranslator($this->translator->domain('pageRemoval'));
     $form->addText('check', 'check.label')->setRequired('check.messages.required')->addRule(Form::EQUAL, 'check.messages.notEqual', $this->page->getTitle());
     $form->addSubmit('remove', 'remove.caption')->onClick[] = [$this, 'removePage'];
     $form->addSubmit('cancel', 'cancel.caption')->setValidationScope([])->onClick[] = [$this, 'cancelClick'];
     if (!$this->authorizator->isAllowed($this->user, 'page', 'remove')) {
         $form['remove']->setDisabled();
     }
     $form->addProtection();
     return $form;
 }
Ejemplo n.º 7
0
 /**
  * @param User|null $user
  * @return Form
  */
 public function create(User $user = null)
 {
     $form = new Form();
     $form->setTranslator($this->translator->domain('users.user.form'));
     $form->addText('username', 'username.label')->setRequired('username.messages.required');
     $form->addText('email', 'email.label')->setRequired('email.messages.required');
     $form->addText('first_name', 'first_name.label');
     $form->addText('last_name', 'last_name.label');
     $form->addSelect('role', $this->translator->translate('users.user.form.role.label'), $this->prepareRolesForSelect())->setTranslator(null);
     $form->addSubmit('save', 'save.caption');
     if ($user !== null) {
         $this->fillForm($form, $user);
     }
     return $form;
 }
Ejemplo n.º 8
0
 protected function createComponentOptionsForm()
 {
     $form = new Form();
     $form->setTranslator($this->translator->domain('options.form'));
     $form->addText('blog_title', 'blogTitle.label', null, 255)->setRequired('blogTitle.messages.required');
     $form->addText('blog_subtitle', 'blogSubtitle.label', null, 255);
     $form->addText('copyright', 'copyright.label', null, 255)->setRequired('copyright.messages.required');
     $form->addText('articles_per_page', 'articlesPerPage.label', null, 2)->setRequired('articlesPerPage.messages.required')->addRule(function ($input) {
         if (Validators::is($input->value, 'numericint:1..')) {
             return true;
         }
         return false;
     }, 'articlesPerPage.messages.wrongInput');
     $form->addText('google_analytics_measure_code', 'gaMeasureCode.label');
     $form->addSubmit('save', 'save.caption');
     $form->onSuccess[] = [$this, 'processForm'];
     $form->addProtection();
     if (!$this->authorizator->isAllowed($this->user, 'options', 'edit')) {
         $form['save']->setDisabled();
     }
     $form->setDefaults($this->optionFacade->loadOptions());
     return $form;
 }
 /**
  * Renders paginator
  *
  * @return void
  */
 public function render()
 {
     $paginator = $this->getPaginator();
     $page = $paginator->getPage();
     if ($paginator->getPageCount() < 2) {
         $steps = [$page];
     } else {
         $arr = range(max($paginator->getFirstPage(), $page - 3), min($paginator->getLastPage(), $page + 3));
         $count = 4;
         $quotient = ($paginator->getPageCount() - 1) / $count;
         for ($i = 0; $i <= $count; $i++) {
             $arr[] = round($quotient * $i) + $paginator->getFirstPage();
         }
         sort($arr);
         $steps = array_values(array_unique($arr));
     }
     $this->template->paginator = $paginator;
     $this->template->steps = $steps;
     $this->template->viewButtonAll = $this->viewButtonAll;
     $this->template->activeButtonAll = $this->page === 0;
     $this->template->setFile($this->templateFilename);
     $this->template->setTranslator($this->translator->domain('visualPaginator'));
     $this->template->render();
 }