示例#1
0
 /**
  * Renderiza um elemento HTML
  * @param string $element Nome do elemento
  * @param string $content Conteúdo interno do elemento. Se este valor for NULO então não haverá tag de fechamento
  * @param array $attrs Array de atributos do elemento (nomedoatributo => valordoatributo)
  * @return string
  */
 protected static function renderElement($element, $content, $attrs)
 {
     $r = array();
     foreach ($attrs as $key => $value) {
         $r[] = array('name' => $key, 'value' => $value);
     }
     $params = array('element' => $element, 'content' => $content, 'attrs' => $r, 'closetag' => !is_null($content));
     return Template::singleton()->renderHTML(self::$completeElement, $params);
 }
 /**
  * 
  * nao usar por enquanto, falta definir a forma de receber os dados
  * na submissão
  */
 protected function chosen($name, $value, $params, $attr)
 {
     MemoryPage::addCss("static/bstemplates/plugins/chosen/chosen.min.css");
     MemoryPage::addJs("static/bstemplates/plugins/chosen/chosen.jquery.min.js");
     $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);
     $dados = $dao->listAll();
     //$attr["value"] = $value;
     //$attr = $this->getHTMLAttributes($attr, $params);
     $template = PATH_APP . '/view/bstemplates/multiselect.mustache';
     $vetor["multiselect"] = ["placeholder" => getValueFromArray($params, Flag::PLACEHOLHER, "Escolha uma opção"), 'options' => $dados];
     return Template::singleton()->renderHTML(file_get_contents($template), $vetor);
 }
示例#3
0
 public function renderContent($content, $file = '')
 {
     if (!empty($file)) {
         $template = Template::singleton();
         # Memory::get('template') eh setado na Factory
         if (Memory::get('template') == 'default') {
             foreach (Memory::get('templates', array()) as $name => $mustache) {
                 $content[$name] = $template->renderTemplate($mustache, $content);
             }
         }
         $template->showRenderTemplate($file, $content);
         if (Memory::get('debug', false)) {
             echo "<pre>";
             var_dump($content);
             echo "</pre>";
         }
     } else {
         //TODO o filename do page não está setado...
         dump("[o arquivo de template não foi configurado para a página solicitada] : o filename do page não está setado");
         dump($content);
     }
 }
示例#4
0
 public function send(AbstractEmail $email)
 {
     try {
         //Set who the message is to be sent from
         $this->mailer->setFrom($email->getFromEmail(), $email->getFromName());
         //Set an alternative reply-to address
         //$mail->addReplyTo($email->getFromEmail(), $email->getFromName());
         $this->mailer->setTo($email->getTo());
         $this->mailer->setCc($email->getCc());
         $this->mailer->setBCc($email->getBCc());
         $this->mailer->setSubject($email->getAssunto());
         if ($email instanceof \MyFrameWork\Email\HtmlInterface) {
             $mustache = Template::singleton();
             $html_body = $mustache->renderHTML(file_get_contents($email->getTemplatePath()), $email->getTemplateParams());
             $this->mailer->setMessage($html_body);
         } else {
             $this->mailer->disableHtml();
             $this->mailer->setMessage($email->getMessage());
         }
         //Replace the plain text body with one created manually
         //$mail->AltBody = 'This is a plain-text message body';
         $this->mailer->addAttachments($email->getAnexos());
         //send the message, check for errors
         if (!$this->mailer->send()) {
             Logger::log()->fatal("Mailer Send Error: " . $this->mailer->getErrorInfo());
             return false;
         }
         return true;
     } catch (phpmailerException $e) {
         Logger::log()->fatal("phpmailer Exception : " . $e->errorMessage());
         //Pretty error messages from PHPMailer
     } catch (\Exception $e) {
         Logger::log()->fatal("phpMailer Exception : " . $e->getMessage());
         //Boring error messages from anything else!
     }
     return false;
 }
示例#5
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;
 }