Exemplo n.º 1
0
 /**
  * Test
  *
  * @return void
  */
 public function testRenderOptions()
 {
     $this->element->setValueOptions(array(1, 2, 3));
     $this->element->setValue(1);
     $this->element->setAttribute('id', 'test');
     $this->element->setAttribute('class', 'input-checkbox');
     $this->object->setLabelPosition('prepend');
     $markup = $this->object->render($this->element);
     $this->assertContains('type="checkbox"', $markup);
     $this->assertContains('name="foo[]"', $markup);
 }
Exemplo n.º 2
0
 public function testCheckWithCheckedValue()
 {
     $element = new CheckboxElement();
     $this->assertEquals(false, $element->isChecked());
     $element->setValue($element->getCheckedValue());
     $this->assertEquals(true, $element->isChecked());
 }
Exemplo n.º 3
0
 /**
  * Test
  *
  * @return void
  */
 public function testRenderWithClass()
 {
     $this->element->setValue('checked');
     $this->element->setAttribute('class', 'input-checkbox');
     $markup = $this->object->render($this->element);
     $this->assertContains('checked="checked"', $markup);
     $this->assertContains('class="input-checkbox"', $markup);
 }
Exemplo n.º 4
0
 /**
  * Load Boolean editor
  *
  * @return Element\Checkbox
  */
 public function load()
 {
     $boolean = new Element\Checkbox($this->getName());
     $boolean->setLabel($this->getProperty()->getName());
     $boolean->setAttribute('class', 'input-checkbox');
     $boolean->setAttribute('id', 'boolean' . $this->getProperty()->getId());
     $boolean->setValue($this->getProperty()->getValue());
     return $boolean;
 }
Exemplo n.º 5
0
 public function __construct($name = null)
 {
     parent::__construct('page');
     $id_hidden = new Element\Hidden('id');
     $id_hidden->setName('id');
     $title_text = new Element\Text('title');
     $title_text->setLabel('Title');
     $title_text->setLabelAttributes(array('class' => 'type_text type_text_short'));
     $title_text->setAttributes(array('class' => 'type_text_input', 'placeholder' => 'Type something...', 'required' => 'require'));
     $url_text = new Element\Text('url');
     $url_text->setLabel('Url');
     $url_text->setLabelAttributes(array('class' => 'type_text type_text_short'));
     $url_text->setAttributes(array('class' => 'type_text_input', 'placeholder' => 'Type something...', 'required' => 'require'));
     $text_textarea = new Element\Textarea('text');
     $text_textarea->setLabel('Text');
     $text_textarea->setLabelAttributes(array('class' => 'type_text'));
     $text_textarea->setAttributes(array('placeholder' => 'Type something...'));
     $auto_check = new Element\Checkbox('auto');
     $auto_check->setLabel('Automatically');
     $auto_check->setLabelAttributes(array('class' => 'type_text type_check'));
     $auto_check->setUseHiddenElement(true);
     $auto_check->setCheckedValue("1");
     $auto_check->setUncheckedValue("0");
     $auto_check->setValue('1');
     $meta_text = new Element\Text('meta');
     $meta_text->setLabel('Meta');
     $meta_text->setLabelAttributes(array('class' => 'type_text type_text_mod_darker'));
     $meta_text->setAttributes(array('class' => 'type_text_input'));
     $keywords_text = new Element\Text('keywords');
     $keywords_text->setLabel('Keywords');
     $keywords_text->setLabelAttributes(array('class' => 'type_text type_text_mod_darker'));
     $keywords_text->setAttributes(array('class' => 'type_text_input'));
     $desc_text = new Element\Text('description');
     $desc_text->setLabel('Description');
     $desc_text->setLabelAttributes(array('class' => 'type_text type_text_mod_darker'));
     $desc_text->setAttributes(array('class' => 'type_text_input'));
     $submit_button = new Element\Submit('submit');
     $submit_button->setValue('Submit');
     $submit_button->setAttributes(array('class' => 'btn btn_white'));
     $cancel_button = new Element\Submit('cancel');
     $cancel_button->setValue('Cancel');
     $cancel_button->setAttributes(array('class' => 'btn btn_rozy'));
     $this->add($id_hidden);
     $this->add($title_text);
     $this->add($url_text);
     $this->add($text_textarea);
     $this->add($auto_check);
     $this->add($meta_text);
     $this->add($keywords_text);
     $this->add($desc_text);
     $this->add($submit_button);
     $this->add($cancel_button);
 }
 public function __construct($roleName, array $permissions, Acl $acl)
 {
     parent::__construct();
     $this->setAttribute('method', 'post');
     $roles = $acl->getRoles();
     $parentPermissions = [];
     foreach ($roles as $role) {
         if ($acl->inheritsRole($roleName, $role, true)) {
             foreach ($permissions as $permissionId => $permission) {
                 if ($acl->isAllowed($role, $permission)) {
                     $parentPermissions[$permissionId] = $permissionId;
                 }
             }
         }
     }
     $permissionGroups = [];
     foreach ($permissions as $permissionId => $permission) {
         $fragments = explode('/', $permission);
         $groupName = reset($fragments);
         if (!array_key_exists($groupName, $permissionGroups)) {
             $permissionGroups[$groupName] = [];
         }
         $permissionGroups[$groupName][] = $permissionId;
     }
     foreach ($permissionGroups as $groupName => $groupPermissions) {
         foreach ($groupPermissions as $permission) {
             $permissionCheck = new Checkbox($permission);
             $permissionCheck->setLabel($permissions[$permission]);
             if (array_key_exists($permission, $parentPermissions)) {
                 $permissionCheck->setValue(true);
                 $permissionCheck->setAttribute('disabled', true);
             }
             $this->add($permissionCheck);
             if (!array_key_exists($groupName, $this->permissionGroups)) {
                 $this->permissionGroups[$groupName] = [];
             }
             $this->permissionGroups[$groupName][] = $permissionCheck;
         }
     }
     $submit = new Submit('save');
     $submit->setValue('save');
     $submit->setAttribute('class', 'btn btn-primary');
     $this->add($submit);
 }
Exemplo n.º 7
0
 public function __construct($name = null)
 {
     parent::__construct('filmes');
     $this->setAttribute('enctype', 'multipart/form-data');
     $id = new Hidden('filmes_id');
     $nome = new Text('filmes_nome');
     $nome->setLabel('Nome: ');
     $nome->setAttributes(array('class' => 'form-control', 'id' => 'filmes_nome'));
     $preco = new Text('filmes_preco');
     $preco->setLabel('Valor Aluguel: ');
     $preco->setAttributes(array('class' => 'form-control', 'id' => 'filmes_preco'));
     $categoria = new Select('categoria_id');
     $categoria->setLabel('Categoria: ');
     $categoria->setAttributes(array('class' => 'form-control', 'id' => 'categoria_id', 'empty_option' => 'Please select an author', 'value_options' => $this->getOptionsForSelect()));
     $foto = new File('filmes_foto');
     $foto->setLabel('Cartaz: ');
     $foto->setAttributes(array('class' => 'form-control'));
     $descricao = new Textarea('filmes_descricao');
     $descricao->setLabel('Dados do Filme: ');
     $descricao->setAttributes(array('style' => 'height: 100px;', 'class' => 'form-control', 'id' => 'filmes_descricao'));
     $status = new Checkbox('filmes_status');
     $status->setLabel("Mostrar?");
     $status->setValue(1);
     $submit = new Button('submit');
     $submit->setLabel('Cadastrar');
     $submit->setAttributes(array('type' => 'submit', 'class' => 'btn btn-success'));
     $cancel = new Button('cancel');
     $cancel->setLabel('Cancelar');
     $cancel->setAttributes(array('type' => 'button', 'class' => 'btn btn-default', 'onclick' => 'javascript:history.go(-1)'));
     $this->add($id);
     $this->add($nome);
     $this->add($preco);
     $this->add($foto);
     $this->add($descricao);
     $this->add($categoria);
     $this->add($status);
     $this->add($submit);
     $this->add($cancel);
 }
Exemplo n.º 8
0
 public function init()
 {
     $fileupload = new Element\File('files');
     $fileupload->setLabel("files");
     $fileupload->setAttribute('multiple', 'multiple');
     $this->add($fileupload);
     $button = new Element\Button('start');
     $button->setAttribute("type", 'submit');
     $button->setValue("Start upload")->setLabel("Start upload");
     $this->add($button);
     $button = new Element\Button('cancel');
     $button->setAttribute("type", 'reset');
     $button->setValue("Cancel upload")->setLabel("Cancel upload");
     $this->add($button);
     $button = new Element\Button('delete');
     $button->setAttribute("type", 'button');
     $button->setValue("Delete")->setLabel("Delete");
     $this->add($button);
     $checkbox = new Element\Checkbox('toggle');
     $checkbox->setValue("Toggle")->setLabel("Toggle");
     $checkbox->setAttribute("required", "");
     $this->add($checkbox);
 }
Exemplo n.º 9
0
 /**
  * Get all items as form
  *
  * @return array
  */
 public function getAllItems()
 {
     $elements = array();
     $items = $this->getAllToolbarItems();
     $toolbarItems = $this->getToolbarItems();
     foreach ($items as $group) {
         if (!empty($group['items']) and is_array($group['items'])) {
             $fieldset = new Fieldset($group['name']);
             foreach ($group['items'] as $idxItem => $item) {
                 if ($item == '-') {
                     continue;
                 }
                 $element = new Element\Checkbox('toolbar-items[' . $item . ']');
                 $element->setAttribute('id', 'i' . $group['name'] . $idxItem)->setCheckedValue(1)->setAttribute('class', 'input-checkbox')->setLabel($item);
                 if (!empty($toolbarItems[$item])) {
                     $element->setValue(1);
                 }
                 $fieldset->add($element);
             }
             $elements[] = $fieldset;
         }
     }
     return $elements;
 }
Exemplo n.º 10
0
 public function __construct(OrmNivel $orm = null)
 {
     parent::__construct("formNivel");
     /*
      * txtId
      */
     $txtId = new Element\Hidden("id");
     $txtNome = new Element\Text("nome");
     $txtNome->setAttributes(array('class' => 'form-control', 'placeholder' => 'Nome da Categoria', 'data-parsley-trigger' => 'change', 'pattern' => '^[aA-zZ]+((\\s[aA-zZ]+)+)?$', 'required' => 'true'));
     /*
      * chkDashbord
      */
     $chkDashbord = new Element\Checkbox('dashboard');
     $chkDashbord->setAttributes(array('id' => "switch01", 'class' => 'onoffswitch-checkbox'));
     $chkPublicador = new Element\Checkbox('publicador');
     $chkPublicador->setAttributes(array('id' => "switch02", 'class' => 'onoffswitch-checkbox'));
     /*
      * chkCongregacao
      */
     $chkCongregacao = new Element\Checkbox('congregacao');
     $chkCongregacao->setAttributes(array('id' => "switch07", 'class' => 'onoffswitch-checkbox'));
     /*
      * chkRelatorio
      */
     $chkRelatorio = new Element\Checkbox('relatorio');
     $chkRelatorio->setAttributes(array('id' => "switch03", 'class' => 'onoffswitch-checkbox'));
     /*
      * chkGrupo
      */
     $chkGrupo = new Element\Checkbox('grupo');
     $chkGrupo->setAttributes(array('id' => "switch04", 'class' => 'onoffswitch-checkbox'));
     /*
      * chkUsuario
      */
     $chkUsuario = new Element\Checkbox('usuario');
     $chkUsuario->setAttributes(array('id' => "switch05", 'class' => 'onoffswitch-checkbox'));
     /*
      * chkNivel
      */
     $chkNivel = new Element\Checkbox('nivel');
     $chkNivel->setAttributes(array('id' => "switch06", 'class' => 'onoffswitch-checkbox'));
     /*
      * chkPrivilegios
      */
     $chkPrivilegios = new Element\Checkbox('privilegios');
     $chkPrivilegios->setAttributes(array('id' => "switch07", 'class' => 'onoffswitch-checkbox'));
     /*
      * chkEscolaMinisterio
      */
     $chkEscolaMinisterio = new Element\Checkbox('escola');
     $chkEscolaMinisterio->setAttributes(array('id' => "switch08", 'class' => 'onoffswitch-checkbox'));
     /*
      * iToken
      */
     $iToken = new Element\Csrf("iToken");
     /*
      * btnSalvar
      */
     $btnSalvar = new Element\Button('salvar');
     $btnSalvar->setAttributes(array('class' => 'btn btn-darkgray btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button'));
     /*
      * btnVoltar
      */
     $btnVoltar = new Element\Button('voltar');
     $btnVoltar->setAttributes(array('class' => 'btn btn-blue btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button'));
     /*
      * Preencher Objetos
      */
     if ($orm != null) {
         $txtId->setValue($orm->getId());
         $txtNome->setValue($orm->getNome());
         $chkDashbord->setValue($orm->getDashboard());
         $chkPublicador->setValue($orm->getPublicador());
         $chkGrupo->setValue($orm->getGrupo());
         $chkCongregacao->setValue($orm->getCongregacao());
         $chkRelatorio->setValue($orm->getRelatorio());
         $chkUsuario->setValue($orm->getUsuario());
         $chkPrivilegios->setValue($orm->getPrivilegios());
         $chkEscolaMinisterio->setValue($orm->getEscolaMinisterio());
         $chkNivel->setValue($orm->getNivel());
     }
     /*
      * Adiciona Objetos ao form
      */
     $this->add($txtId);
     $this->add($txtNome);
     $this->add($chkDashbord);
     $this->add($chkPublicador);
     $this->add($chkGrupo);
     $this->add($chkRelatorio);
     $this->add($chkCongregacao);
     $this->add($chkUsuario);
     $this->add($chkNivel);
     $this->add($chkPrivilegios);
     $this->add($chkEscolaMinisterio);
     $this->add($iToken);
     $this->add($btnSalvar);
     $this->add($btnVoltar);
     /*
      * Form
      */
     $this->setAttributes(array('id' => 'form', 'data-parsley-validate' => NULL));
 }
Exemplo n.º 11
0
 /**
  * Add property sub form
  *
  * @param mixed $property \Gc\Property\Model|array
  *
  * @return DocumentType
  */
 public function addProperty($property)
 {
     if (!is_array($property) and !$property instanceof Property\Model) {
         return $this;
     }
     $fieldsets = $this->getProperties();
     $name = new Element\Text('name');
     $identifier = new Element('identifier');
     $tab = new Element\Select('tab');
     $tab->setAttribute('class', 'select-tab')->setValueOptions(array());
     $datatype = new Element\Select('datatype');
     $datatype->setAttribute('class', 'select-datatype')->setValueOptions($this->datatypeCollection->getSelect());
     $description = new Element\Text('description');
     $required = new Element\Checkbox('required');
     $required->setCheckedValue('1')->setAttribute('id', 'required')->setAttribute('class', 'input-checkbox');
     $propertyId = new Element\Hidden('property_id');
     if ($property instanceof Property\Model) {
         $name->setValue($property->getName());
         $identifier->setValue($property->getIdentifier());
         $tab->setValue($property->getTabId());
         $datatype->setValue($property->getDatatypeId());
         $description->setValue($property->getDescription());
         $required->setValue((string) $property->isRequired());
         $propertyId->setValue($property->getId());
         $propertyFieldsetName = $property->getId();
     } else {
         $name->setValue($property['name']);
         $identifier->setValue($property['identifier']);
         $tab->setValue($property['tab']);
         $datatype->setValue($property['datatype']);
         $description->setValue($property['description']);
         $required->setValue((string) (!empty($property['isRequired'])));
         $propertyId->setValue(str_replace('property', '', $property['id']));
         $propertyFieldsetName = $property['id'];
     }
     $propertyForm = new FieldSet($propertyFieldsetName);
     $propertyForm->add($propertyId);
     $propertyForm->add($name);
     $propertyForm->add($identifier);
     $propertyForm->add($tab);
     $propertyForm->add($datatype);
     $propertyForm->add($description);
     $propertyForm->add($required);
     $fieldsets->add($propertyForm);
     $this->getInputFilter()->get('properties')->add(array('type' => 'Zend\\InputFilter\\InputFilter', 'name' => array('name' => 'name', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'identifier' => array('name' => 'identifier', 'required' => true, 'validators' => array(array('name' => 'not_empty'), array('name' => 'regex', 'options' => array('pattern' => parent::IDENTIFIER_PATTERN)))), 'tab' => array('name' => 'tab', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'datatype' => array('name' => 'datatype', 'required' => true, 'validators' => array(array('name' => 'not_empty'))), 'description' => array('name' => 'description', 'required' => false, 'allow_empty' => true), 'required' => array('name' => 'required', 'required' => false, 'allow_empty' => true)), $propertyFieldsetName);
     return $this;
 }
Exemplo n.º 12
0
 public function __construct(EntityManager $em, OrmPublicador $publicador)
 {
     parent::__construct("frmImprimi");
     /*
      * cmbPublicador
      */
     $dao = $em->getRepository('Stj\\Entity\\OrmPublicador');
     if (empty($publicador)) {
         $lista = $dao->findAll();
     } else {
         $lista = $dao->ListALLWhere($publicador->getGrupo()->getCongregacao()->getId());
     }
     $option = array();
     foreach ($lista as $key => $value) {
         $tipoPrivilegio = new OrmPublicador();
         $tipoPrivilegio = $value;
         $option[$tipoPrivilegio->getId()] = $tipoPrivilegio->getNome();
     }
     $cmbPublicador = new Element\Select('publicador');
     $cmbPublicador->setValueOptions($option);
     $cmbPublicador->setEmptyOption("Selecionar");
     $cmbPublicador->setAttributes(array('class' => 'chosen-select', 'style' => 'width:175px;', 'required' => 'true'));
     /*
      * chkDados
      */
     $chkDados = new Element\Checkbox('dados');
     $chkDados->setAttributes(array('id' => "switch00", 'class' => 'onoffswitch-checkbox'));
     $chkDados->setValue(TRUE);
     /*
      * chkSetembro
      */
     $chkSetembro = new Element\Checkbox('setembro');
     $chkSetembro->setAttributes(array('id' => "switch01", 'class' => 'onoffswitch-checkbox'));
     $chkSetembro->setValue(TRUE);
     /*
      * $chkOutubro
      */
     $chkOutubro = new Element\Checkbox('outubro');
     $chkOutubro->setAttributes(array('id' => "switch02", 'class' => 'onoffswitch-checkbox'));
     $chkOutubro->setValue(TRUE);
     /*
      * $chkNovembro
      */
     $chkNovembro = new Element\Checkbox('novembro');
     $chkNovembro->setAttributes(array('id' => "switch03", 'class' => 'onoffswitch-checkbox'));
     $chkNovembro->setValue(TRUE);
     /*
      * $chkDezembro
      */
     $chkDezembro = new Element\Checkbox('dezembro');
     $chkDezembro->setAttributes(array('id' => "switch04", 'class' => 'onoffswitch-checkbox'));
     $chkDezembro->setValue(TRUE);
     /*
      * $chkJaneiro
      */
     $chkJaneiro = new Element\Checkbox('janeiro');
     $chkJaneiro->setAttributes(array('id' => "switch05", 'class' => 'onoffswitch-checkbox'));
     $chkJaneiro->setValue(TRUE);
     /*
      * $chkFevereiro
      */
     $chkFevereiro = new Element\Checkbox('fevereiro');
     $chkFevereiro->setAttributes(array('id' => "switch06", 'class' => 'onoffswitch-checkbox'));
     $chkFevereiro->setValue(TRUE);
     /*
      * $chkMarco
      */
     $chkMarco = new Element\Checkbox('marco');
     $chkMarco->setAttributes(array('id' => "switch07", 'class' => 'onoffswitch-checkbox'));
     $chkMarco->setValue(TRUE);
     /*
      * $chkAbril
      */
     $chkAbril = new Element\Checkbox('abril');
     $chkAbril->setAttributes(array('id' => "switch08", 'class' => 'onoffswitch-checkbox'));
     $chkAbril->setValue(TRUE);
     /*
      * $chkMaio
      */
     $chkMaio = new Element\Checkbox('maio');
     $chkMaio->setAttributes(array('id' => "switch09", 'class' => 'onoffswitch-checkbox'));
     $chkMaio->setValue(TRUE);
     /*
      * $chkJunho
      */
     $chkJunho = new Element\Checkbox('junho');
     $chkJunho->setAttributes(array('id' => "switch10", 'class' => 'onoffswitch-checkbox'));
     $chkJunho->setValue(TRUE);
     /*
      * $chkJulho
      */
     $chkJulho = new Element\Checkbox('julho');
     $chkJulho->setAttributes(array('id' => "switch11", 'class' => 'onoffswitch-checkbox'));
     $chkJulho->setValue(TRUE);
     /*
      * $chkAgosto
      */
     $chkAgosto = new Element\Checkbox('agosto');
     $chkAgosto->setAttributes(array('id' => "switch12", 'class' => 'onoffswitch-checkbox'));
     $chkAgosto->setValue(TRUE);
     /*
      * iToken
      */
     $iToken = new Element\Csrf("iToken");
     /*
      * btnImprimir
      */
     $btnSalvar = new Element\Button('imprimir');
     $btnSalvar->setAttributes(array('class' => 'btn btn-darkgray btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button'));
     /*
      * btnVoltar
      */
     $btnVoltar = new Element\Button('voltar');
     $btnVoltar->setAttributes(array('class' => 'btn btn-blue btn-ef btn-ef-4 btn-ef-4c mb-10', 'type' => 'button'));
     /*
      * Adiciona Objetos ao form
      */
     $this->add($cmbPublicador);
     $this->add($chkDados);
     $this->add($chkSetembro);
     $this->add($chkOutubro);
     $this->add($chkNovembro);
     $this->add($chkDezembro);
     $this->add($chkJaneiro);
     $this->add($chkFevereiro);
     $this->add($chkMarco);
     $this->add($chkAbril);
     $this->add($chkMaio);
     $this->add($chkJunho);
     $this->add($chkJulho);
     $this->add($chkAgosto);
     $this->add($iToken);
     $this->add($btnSalvar);
     $this->add($btnVoltar);
     /*
      * Form
      */
     $this->setAttributes(array('id' => 'form', 'data-parsley-validate' => NULL));
 }