Esempio n. 1
0
 /**
  * 
  * @param array $likes
  * @return string
  */
 public static function likes($idConteudo)
 {
     $_conteudo = new Cms_DataView_Conteudo_MapperView();
     $likes = $_conteudo->getLikes($idConteudo);
     $itens = '';
     $itens .= '<div class="content">';
     if (count($likes)) {
         $count = 0;
         $maxCount = 5;
         $qtd = count($likes);
         $diff = $qtd - $maxCount;
         $style = "display:block";
         foreach ($likes as $data) {
             $idConteudo = $data['id']->get();
             if ($count == $maxCount) {
                 $s = $diff > 1 ? "s" : "";
                 $itens .= '<label id = "like-' . $idConteudo . '-plus"><a href="javascript:void(0)" onclick="$.Cms_ConteudoController.showLike(' . $idConteudo . ')">e outra' . $s . ' ' . $diff . ' pessoa' . $s . '</a></label>' . "\n";
                 $style = "display:none";
             }
             $itens .= '<label style="color:black; ' . $style . '">' . $data['nome_usuario_inc'] . '</label>' . "\n";
             $count++;
         }
     } else {
         $itens .= '<label id = "like-' . $idConteudo . '-first" onClick=$("#like-' . $idConteudo . '").click();><a href = "#">Seja o primeiro a Curtir!</a></label>';
     }
     $itens .= '</div>';
     $result = '
             <div class="header">
             ' . $itens . '
             </div>';
     return $result;
 }
Esempio n. 2
0
 public static function comments($idConteudo)
 {
     $_conteudo = new Cms_DataView_Conteudo_MapperView();
     $comments = $_conteudo->getComments($idConteudo);
     $xhtml = '';
     foreach ($comments as $row) {
         $xhtml .= '
                 <li class="ui-helper-clearfix" id="comment-text">&nbsp;
                     <div class="header ui-helper-clearfix">&nbsp;
                         <span class="name">' . $row['nome_usuario_inc'] . '</span>
                         <span class="date">' . $row['dh_ini_pub'] . '</span>
                     </div>
                     <div class="content ui-helper-clearfix">&nbsp;
                         <span class="avatar">
                             <img src="' . $row['avatar_usuario_inc'] . '">
                         </span>
                         <span class="message comment" calc-width="-100" calc-width-parent="comment-text">
                             ' . $row['corpo'] . '
                         </span>
                     </div>
                 </li>';
     }
     return $xhtml;
 }
Esempio n. 3
0
 public function remove($idConteudo, $idUsuario = '', $deleteFilhos = true)
 {
     if (!$idUsuario) {
         $idUsuario = Zend_Auth::getInstance()->getStorage()->read()->getId();
     }
     $this->setIdConteudo($idConteudo)->setIdUsuario($idUsuario)->delete(null);
     if ($deleteFilhos) {
         $_conteudo = new Cms_DataView_Conteudo_MapperView();
         $_where = new ZendT_Db_Where();
         $_where->addFilter("cms_conteudo.id_conteudo_pai", $this->getIdConteudo(true)->get());
         $_conteudo->findAll($_where, '*');
         while ($_conteudo->fetch()) {
             $this->remove($_conteudo->getId());
         }
     }
 }
Esempio n. 4
0
 public function isValidLastTime($hours = 0, $minutes = 0, $seconds = 0)
 {
     $_conteudo = new Cms_DataView_Conteudo_MapperView();
     $_conteudo->setIdCategoria($this->getIdCategoria())->setIdConteudoPai($this->getIdConteudoPai())->setIdUsuarioInc($this->getIdUsuarioInc())->findAll(null, '*', 'dh_ini_pub desc');
     if (!$_conteudo->exists()) {
         return true;
     }
     $_conteudo->fetch();
     $hours *= 60 * 60;
     $minutes *= 60;
     $total = $hours + $minutes + $seconds;
     $now = ZendT_Type_Date::nowDateTime()->toPhp();
     $last = $_conteudo->getDhIniPub()->toPhp();
     $last += $total;
     if ($now > $last) {
         return true;
     }
     return false;
 }
Esempio n. 5
0
 public function viewAction()
 {
     $this->_defineLayout();
     $id = $this->getRequest()->getParam('id');
     $key = $this->getRequest()->getParam('key');
     $list = $this->getRequest()->getParam('list');
     $chaveCategoria = $this->getRequest()->getParam('chave_categoria');
     $select = $this->getRequest()->getParam('select');
     $sub = $this->getRequest()->getParam('sub');
     $edit = $this->getRequest()->getParam('edit');
     $editDisabled = $this->getRequest()->getParam('edit_disabled');
     $conteudo = $this->getRequest()->getParam('conteudo');
     $categoria = $this->getRequest()->getParam('categoria');
     $restringirUsuario = $this->getRequest()->getParam('ru');
     if ($restringirUsuario) {
         $idUsuario = Zend_Auth::getInstance()->getStorage()->read()->getId();
         $this->getRequest()->setParam('cms_conteudo-id_usuario_inc', $idUsuario);
     }
     $_conteudo = $this->getMapper();
     if (!$id) {
         $id = $conteudo;
     }
     if ($id && !is_numeric($id)) {
         $id = $_conteudo->newRow()->setChave($id)->retrieve()->getId(true)->toPhp();
         $_conteudo->newRow();
     }
     if ($key && !$id) {
         $id = $_conteudo->newRow()->setChave($key)->retrieve()->getId(true)->toPhp();
         $_conteudo->newRow();
     }
     $idCategoriaAtual = "";
     $_where = new ZendT_Db_Where();
     $_where->addFilter("cms_conteudo.id", $id);
     $data = $_conteudo->findAll($_where)->fetch();
     if ($data) {
         $_conteudo->setId($id)->retrieve();
         $_fileSystem = new Ged_Model_Arquivo_FileSystem();
         $thumbnail = $_conteudo->getThumbnail()->toPhp();
         if ($thumbnail) {
             $imgUrl = $_fileSystem->getDirectoryAdress($thumbnail);
             $this->view->img = $imgUrl;
         }
         $this->view->banner = $_conteudo->getBanner()->toPhp();
         if ($this->view->banner) {
             $this->view->banner = $_fileSystem->getDirectoryAdress($this->view->banner);
         }
         $this->view->id = $id;
         $this->view->titulo = $_conteudo->getTitulo()->get();
         $this->view->subtitulo = $_conteudo->getSubtitulo()->get();
         $this->view->corpo = $_conteudo->getCorpo()->get();
         $this->view->corpoUrl = $_conteudo->getCorpoUrl()->get();
         $this->view->viewPdf = $this->getRequest()->getParam('pdf');
         $this->view->arquivo = $_conteudo->getArquivo(true)->toPhp();
         $_arquivo = $_conteudo->getArquivo(true);
         if ($_arquivo->toPhp() && !$this->view->viewPdf) {
             $name = $_arquivo->getFile()->getName();
             if (strpos(strtolower($name), '.pdf')) {
                 $this->view->viewPdf = 1;
             } else {
                 $this->view->urlDownload = $_arquivo->getFile()->toUrlDownload(false);
             }
         }
         $_categoria = new Cms_DataView_Categoria_MapperView();
         $_categoria->setId($_conteudo->getIdCategoria()->toPhp());
         $_categoria->retrieve();
         $idCategoriaPai = $_categoria->getIdCategoriaPai()->toPhp();
         if ($sub) {
             $_categoria = new Cms_DataView_Categoria_MapperView();
             $_categoria->setId($idCategoriaPai);
             $_categoria->retrieve();
             $idCategoriaPai = $_categoria->getIdCategoriaPai()->toPhp();
         }
         $idCategoriaAtual = $_conteudo->getIdCategoria()->toPhp();
         /* Painel da direita */
         $conteudosCategoria = $_conteudo->getContents($_conteudo->getIdCategoria()->toPhp());
         if ($conteudosCategoria) {
             foreach ($conteudosCategoria as $index => $conteudo) {
                 if ($conteudo['id'] == $id || !isset($conteudo['id'])) {
                     unset($conteudosCategoria[$index]);
                 }
             }
             $this->view->painelDireita = $conteudosCategoria;
         }
         /* Painel central */
         $this->view->painelCentral = '';
         $this->view->editPermissao = false;
         if (!$editDisabled) {
             $_conteudoMapperView = new Cms_DataView_Conteudo_MapperView();
             $this->view->editPermissao = $_conteudoMapperView->setId($id)->isEditEnabled();
             if ($edit) {
                 $this->getRequest()->setParam('edit', $this->view->editPermissao);
             }
             $edit = $this->getRequest()->getParam('edit');
         }
         if ($edit && $this->view->editPermissao) {
             $_conteudoForm = new Cms_Form_Conteudo_Edit();
             $_conteudoForm->loadElements();
             $_profile = ZendT_Profile::get('Cms_Form_Conteudo_Edit', '', 'analise');
             $_conteudoForm->loadProfile($_profile);
             $_conteudoForm->loadButtons();
             $_mapper = new Cms_DataView_Conteudo_MapperView();
             $row = $_mapper->setId($id)->getDataEdicao();
             if (count($row)) {
                 $_conteudoForm->populate($row);
                 $this->view->corpo = $_conteudoForm;
             }
         }
         $this->view->comments = Cms_Helper_Comments::comments($id);
         if (!$this->view->corpoUrl && !$edit) {
             $this->view->commentsForm = Cms_Helper_Comments::form($id);
         }
         $this->view->likes = Cms_Helper_Likes::button($id);
         $_notificacao = new Cms_Model_Notificacao_Mapper();
         $_notificacao->remove($id);
     } else {
         if ($list) {
             $this->gridAction();
             $this->getGrid()->setBeforeRequest("function(){\n                                                    \$.gridResize({\n                                                        idGrid: '" . $this->getGrid()->getID() . "'\n                                                       ,width: function(){ return calcWidthGrid(); }\n                                                     /*,height: function(){ return calcHeightGrid(); }*/\n                                                    });\n                                                    \$(window).resize(function(){\n                                                        \$.gridResize({\n                                                            idGrid: '" . $this->getGrid()->getID() . "'\n                                                           ,width: function(){ return calcWidthGrid(); }\n                                                         /*,height: function(){ return calcHeightGrid(); }*/\n                                                        });\n                                                    });\n                                                }");
         } else {
             $this->view->msg = "Conteúdo não disponível ou requer autenticação!";
         }
     }
     /* Painel da esquerda */
     $this->view->painelEsquerda = '';
     if ($categoria) {
         if (!is_numeric($categoria)) {
             $_categoria = new Cms_Model_Categoria_Mapper();
             $_categoria->setChave($categoria)->retrieve();
             $categoria = $_categoria->getId(true)->toPhp();
         }
         if ($chaveCategoria) {
             $_categoria = new Cms_Model_Categoria_Mapper();
             $_categoria->setChave($chaveCategoria)->retrieve();
             $idCategoriaAtual = $_categoria->getId(true)->toPhp();
         }
         if ($select) {
             $_categoria = new Cms_Model_Categoria_Mapper();
             $_categoria->setChave($select)->retrieve();
             $idCategoriaAtual = $_categoria->getId(true)->toPhp();
         }
         $_sideBar = new Cms_DataView_Sidebar_MapperView();
         //$_sideBarHelper = new Cms_Helper_Sidebar();
         //$html = $_sideBarHelper->sidebar($_sideBar->getSidebar($categoria), $idCategoriaAtual);
         $this->view->categoria = $categoria;
         $this->view->painelEsquerda = $this->view->sidebar($_sideBar->getSidebar($categoria), 'menu-' . $idCategoriaAtual);
     }
 }