Exemplo n.º 1
0
 public static function form($idConteudoPai)
 {
     $xhtml = '';
     if (Auth_Session_User::getInstance()->authenticated()) {
         $_comentarForm = new Cms_Form_Conteudo_Edit();
         $_comentarForm->loadElements("", "comment");
         $_profile = ZendT_Profile::get('Cms_Form_Conteudo_Edit', '', 'comentario');
         $_comentarForm->loadProfile($_profile);
         $_comentarForm->getElement('corpo')->editorHtml('comment')->setLabel('');
         $_comentarForm->populate(array('id_conteudo_pai' => $idConteudoPai));
         $_comentarForm->loadButtons();
         $nomeUsuario = Auth_Session_User::getInstance()->getName();
         $avatarUsuario = Auth_Session_User::getInstance()->getAvatar();
         $xhtml = '
             <li class="ui-helper-clearfix" id="comment-text">&nbsp;
                 <div class="header ui-helper-clearfix">&nbsp;
                     <span class="name">' . $nomeUsuario . '</span>
                 </div>
                 <div class="content ui-helper-clearfix">&nbsp;
                     <span class="avatar">
                         <img src="' . $avatarUsuario . '">
                     </span>
                     <span class="message comment" calc-width-parent="" calc-width="-100">
                         ' . $_comentarForm . '
                     </span>
                 </div>
             </li>';
     }
     return $xhtml;
 }
Exemplo n.º 2
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);
     }
 }