Ejemplo n.º 1
0
 /**
  * Uma action nesse contexto representa o link que executa uma ação específica
  * em um grid, específicamente na última coluna do grid, na coluna AÇÕES.
  * 
  * @param Mustache_Engine $mustache
  * @param array $row
  */
 public function getActions($mustache, $row)
 {
     $actions = "";
     foreach ($this->actions as $config) {
         $actions .= "  " . HTML::link($mustache->renderHTML($config['url'], $row), '<span class="' . $config['icon_class'] . '"></span> ' . $config['label_text'] . '  ', $config['title'], $config['extra']);
     }
     return $actions;
 }
Ejemplo n.º 2
0
 public function getHTMLEditable($name, $value, $params, $attr = array())
 {
     $params = $this->normalizeParams($params);
     if (empty($value)) {
         $attr['value'] = getValueFromArray($params, Flag::DEFAULT_VALUE, '');
     } else {
         $attr['value'] = $value;
     }
     $attr = $this->getHTMLAttributes($attr, $params);
     return HTML::input($name, $attr, $name . '_id', $this->getHTMLInputType());
 }
Ejemplo n.º 3
0
 public function getHTMLEditable($name, $value, $params, $attr = array())
 {
     $params = $this->normalizeParams($params);
     $attr = $this->getHTMLAttributes($attr, $params);
     $enum = $this->getEnum($params);
     $options = $enum->labels();
     if (!getValueFromArray($params, Flag::REQUIRED, false)) {
         array_unshift($options, getValueFromArray($params, Flag::PLACEHOLHER, 'Escolha uma opção'));
     }
     return HTML::select($name, $options, $value, $attr, $name . '_id');
 }
Ejemplo n.º 4
0
 public function getHTMLEditable($name, $value, $params, $attr = array())
 {
     $params = $this->normalizeParams($params);
     if (!$this->_isValid($value)) {
         $value = getValueFromArray($params, Flag::DEFAULT_VALUE);
     }
     $attr = $this->getHTMLAttributes($attr, $params);
     $options = array('true' => getValueFromArray($params, Flag::TRUE_LABEL, 'Verdadeiro'), 'false' => getValueFromArray($params, Flag::FALSE_LABEL, 'Falso'));
     if (!getValueFromArray($params, Flag::REQUIRED, false)) {
         array_unshift($options, '');
     }
     return HTML::select($name, $options, var_export($value, true), $attr, $name . '_id');
 }
Ejemplo n.º 5
0
 public function getHTMLEditable($name, $value, $params, $attr = array())
 {
     $params = $this->normalizeParams($params);
     if (!$this->_isValid($value)) {
         $value = getValueFromArray($params, Flag::DEFAULT_VALUE);
     }
     $attr = $this->getHTMLAttributes($attr, $params);
     if (is_bool($value) and $value) {
         $attr["checked"] = "checked";
     }
     $element = "<div class='checkbox'>";
     $element .= "<label for='{$name}_id' >";
     $element .= HTML::input($name, $attr, $name . '_id', 'checkbox');
     $element .= getValueFromArray($params, Flag::LABEL) . "</label></div>";
     return $element;
 }
Ejemplo n.º 6
0
 public function getHTMLEditable($name, $value, $params, $attr = array())
 {
     $params = $this->normalizeParams($params);
     $attr = $this->getHTMLAttributes($attr, $params);
     if (empty($value)) {
         $value = getValueFromArray($params, Flag::DEFAULT_VALUE, '');
     }
     $maxlenght = getValueFromArray($params, Flag::MAXLENGHT, false);
     if ($maxlenght) {
         MemoryPage::addJs("static/js/bootstrap-maxlength.js");
         MemoryPage::addJs("static/js/autosize.v3.js");
         $extra = ["maxlength" => $maxlenght, "data-limite-caracteres" => $maxlenght];
         $attr = array_merge($attr, $extra);
     }
     return HTML::textarea($name, $attr, $name . '_id', $value);
 }
Ejemplo n.º 7
0
 /**
  * Retorna o html para renderizar o elemento na página
  * 
  * @param  string $name   O nome do componente
  * @param  string $value  O caminho da imagem
  * @param  array  $params Parâmetros utilizados com as Flag::CONSTANTES
  * @param  array  $attr   Atributos html para o elemento
  * @return string         Retorna o html para o elemento
  */
 public function getHTMLEditable($name, $value, $params, $attr = array())
 {
     MemoryPage::addCss('static/css/page/filemanager.css');
     MemoryPage::addJs("js/modal-fileupload.js");
     MemoryPage::addJs("static/plugin/bootstrap-fileinput-master/js/fileinput.min.js");
     MemoryPage::addCss('static/plugin/bootstrap-fileinput-master/css/fileinput.min.css');
     $params = $this->normalizeParams($params);
     $link = 'filemanager/index?path=' . getValueFromArray($params, Flag::MOVE_TO, 'image/') . '&header=false';
     $linkextra = ['data-toggle' => 'modal', 'data-target' => '#myFileUpload', 'data-up-action' => 'fileupload', 'data-hiddenid' => $name . '_id', 'data-imgid' => $name . '_img_id', 'class' => 'filemanager-action-link'];
     $linkextra = array_merge($linkextra, $attr);
     $imgattr = ['class' => 'imgfile img-responsive', 'id' => $name . '_img_id'];
     $hasOrdenator = getValueFromArray($params, Flag::FILEIMAGE_HAS_ORDENATOR, false);
     $placeholder = '<small>' . getValueFromArray($params, Flag::PLACEHOLHER, '') . '</small>';
     if (empty($value)) {
         $helpText = getValueFromArray($params, Flag::FILEIMAGE_HELP_TEXT, false);
         if (!$helpText) {
             $helpText = 'Adicionar imagem';
         }
         $noimg = "";
         $showImgComponent = getValueFromArray($params, Flag::FILEIMAGE_SHOW_IMGCOMPONENT, true);
         if ($showImgComponent) {
             $noimg = HTML::img('image/icons/img-icon.png', 'Nenhuma imagem selecionada', $imgattr);
             $img = $noimg . HTML::link($link, $helpText, 'Adicionar imagem', $linkextra);
         } else {
             $img = HTML::link($link, $noimg . $helpText, 'Adicionar imagem', $linkextra);
         }
         if ($hasOrdenator) {
             $ordem = $linkextra["data-ordem"];
             $paginaformandoid = isset($linkextra["data-pagina_id"]) ? $linkextra["data-pagina_id"] : '';
             $img .= "<div class='fileimage-ordem' title='ordem da imagem nesta página personalizada'>{$ordem}</div>";
             $img .= "<div class='glyphicon glyphicon-trash unselect' \n                        data-ordem='" . $ordem . "' data-paginaformando_id=' " . $paginaformandoid . " '   style='display:none;'\n                        title='clique aqui para remover esta imagem!'></div>";
         }
     } else {
         $img = HTML::img($value, 'Imagem selecionada', $imgattr);
         $img .= HTML::link($link, 'Alterar imagem', 'Trocar a imagem', $linkextra);
         if ($hasOrdenator) {
             $ordem = $linkextra["data-ordem"];
             $paginaformandoid = isset($linkextra["data-pagina_id"]) ? $linkextra["data-pagina_id"] : '';
             $img .= "<div class='fileimage-ordem' title='ordem da imagem nesta página personalizada'>{$ordem}</div>";
             $img .= "<div class='glyphicon glyphicon-trash unselect' \n                        data-ordem='" . $ordem . "' data-paginaformando_id=' " . $paginaformandoid . " '   \n                        title='clique aqui para remover esta imagem!'></div>";
         }
     }
     return $placeholder . $img . HTML::input($name, array('value' => $value), $name . '_id', 'hidden');
 }
Ejemplo n.º 8
0
 /**
  * 
  * @param string $name
  * @param string $value
  * @param array $params
  * @param array $attr
  * @return string
  */
 public function getHTMLEditable($name, $value, $params, $attr = array())
 {
     $params = $this->normalizeParams($params);
     $dao = $this->getDAO($params);
     $dao_label = getValueFromArray($params, Flag::DAO_LABEL, Flag::DAO_LABEL);
     $dao_value = getValueFromArray($params, Flag::DAO_VALUE, Flag::DAO_VALUE);
     $gerericItems = $dao->listAll();
     $options = array();
     if (!getValueFromArray($params, Flag::REQUIRED, false)) {
         array_unshift($options, '');
     }
     foreach ($gerericItems as $line) {
         $options[$line[$dao_value]] = $line[$dao_label];
     }
     if (empty($value)) {
         $value = getValueFromArray($params, Flag::DEFAULT_VALUE, '');
     }
     $attr["value"] = $value;
     $attr = $this->getHTMLAttributes($attr, $params);
     return HTML::select($name, $options, $value, $attr, $name . "_id");
 }
Ejemplo n.º 9
0
 public function getHTMLEditable($name, $value, $params, $attr = array())
 {
     MemoryPage::addCss('static/plugin/bootstrap-wysihtml5/bootstrap-wysihtml5-0.0.2.css');
     MemoryPage::addJs('static/plugin/bootstrap-wysihtml5/wysihtml5-0.3.0.min.js');
     MemoryPage::addJs('static/plugin/bootstrap-wysihtml5/bootstrap-wysihtml5-0.0.2.js');
     MemoryPage::addJs('static/plugin/bootstrap-wysihtml5/bootstrap-wysihtml5.pt-BR.js');
     MemoryPage::addJs('static/plugin/bootstrap-wysihtml5/lib/js/bootstrap-button.js');
     MemoryPage::addJs('static/plugin/bootstrap-wysihtml5/htmleditor.js');
     $params = $this->normalizeParams($params);
     if (empty($attr['class'])) {
         $attr['class'] = 'htmleditor';
     } else {
         $classes = explode(' ', $attr['class']);
         if (!in_array('htmleditor', $classes)) {
             $attr['class'] .= ' htmleditor';
         }
     }
     $attr['rows'] = 10;
     $attr = $this->getHTMLAttributes($attr, $params);
     return HTML::textarea($name, $attr, $name . '_id', $value);
 }
Ejemplo n.º 10
0
 /**
  * Retorna o html que monta um editor de html
  * 
  * @param  string $name   O nome do component
  * @param  string $value  O valor que o componente exibe para o usuário
  * @param  string $params Os parâmetros do compomente passados pela classe Flag  
  * @param  string $attr   Atributos do html do componente
  * @return string         Retorna todo o html formatado e pronto para ser renderizado em qualquer view
  */
 public function getHTMLEditable($name, $value, $params, $attr = array())
 {
     MemoryPage::addCss('static/plugin/bootstrap-wysihtml5/bootstrap-wysihtml5-0.0.2.css');
     MemoryPage::addJs('static/plugin/bootstrap-wysihtml5/wysihtml5-0.3.0.min.js');
     MemoryPage::addJs('static/plugin/bootstrap-wysihtml5/bootstrap-wysihtml5-0.0.2.js');
     MemoryPage::addJs('static/plugin/bootstrap-wysihtml5/bootstrap-wysihtml5.pt-BR.js');
     MemoryPage::addJs('static/plugin/bootstrap-wysihtml5/lib/js/bootstrap-button.js');
     MemoryPage::addJs('static/plugin/bootstrap-wysihtml5/htmleditor.js');
     $params = $this->normalizeParams($params);
     if (empty($attr['class'])) {
         $attr['class'] = 'htmleditor';
     } else {
         $classes = explode(' ', $attr['class']);
         if (!in_array('htmleditor', $classes)) {
             $attr['class'] .= ' htmleditor';
         }
     }
     $attr['rows'] = 10;
     $attr = $this->getHTMLAttributes($attr, $params);
     #. '<small>Para vídeos use: [vimeo:Id_do_video] (ex: [vimeo:115835208]), altura e largura ([vimeo:123123 width=600 height=300])</small>'
     return HTML::textarea($name, $attr, $name . '_id', $value);
 }
Ejemplo n.º 11
0
 /**
  * Configura os dados para o modo render em tabela
  * 
  * @param array $dados
  * @param array $schema
  * @return string
  */
 public function getTable($dados, $schema)
 {
     $thead = array_keys($schema);
     $action = getValueFromArray($this->config, Crud::SHOW_TABLE_ACTIONS, true);
     if ($action) {
         $thead[] = 'Ações';
         #@todo refatorar init
         $dao_pks = $this->dao->getPKFieldName();
         if (is_string($dao_pks)) {
             $pk = $dao_pks;
         } else {
             if (is_array($dao_pks)) {
                 $pk = isset($dao_pks[0]) ? $dao_pks[0] : "no-primary-key-setted";
             } else {
                 $pk = "id";
                 //daoname_id
             }
         }
         $default_edit_url = str_replace('<id>', $pk, $this->urlbase . 'edit/{{<id>}}');
         $default_delete_url = str_replace('<id>', $pk, $this->urlbase . 'delete/{{<id>}}');
         $urledit = getValueFromArray($this->config, Crud::ACTION_URL_EDIT, $default_edit_url);
         $urldelete = getValueFromArray($this->config, Crud::ACTION_URL_DELETE, $default_delete_url);
         #refatorar end
     }
     $r = ['tfoot' => count($dados) . ' registro(s)', 'thead' => $thead, 'tbody' => [], 'class' => 'table-striped table-hover table-bordered browsetable'];
     $t = Template::singleton();
     foreach ($dados as $row) {
         $td = [];
         foreach ($schema as $template) {
             //date format would can be here :)
             $td[] = $t->renderHTML($template, $row);
         }
         if ($action) {
             $actions = HTML::link($t->renderHTML($urledit, $row), '<span class="glyphicon glyphicon-pencil"></span>', 'Editar este item', ['class' => 'btn btn-default btn-xs']);
             $actions .= ' ' . $this->getUserActions($t, $row);
             $showDelete = getValueFromArray($this->config, Crud::SHOW_DELETE_LINK, true);
             if ($showDelete) {
                 $actions .= ' ' . HTML::link($t->renderHTML($urldelete, $row), '<span class="glyphicon glyphicon-trash"></span>', 'Excluir este item', ['class' => 'btn btn-danger  btn-xs confirmacao']);
             }
             $td[] = $actions;
         }
         $r['tbody'][] = $td;
     }
     return $r;
 }
Ejemplo n.º 12
0
 public function getHTMLEditable($name, $value, $params, $attr = array())
 {
     return HTML::link(getValueFromArray($params, Flag::URL), getValueFromArray($params, Flag::LABEL), "", $attr);
 }