Пример #1
0
 /**
  * 
  * @param string|int $categoria
  * @param string $orderBy
  * @return array
  */
 protected function _list($categoria, $idConteudoPai = '', $orderBy = '')
 {
     $this->_removeLob = false;
     $_fileSystem = new Ged_Model_Arquivo_FileSystem();
     $idUsuario = Auth_Session_User::getInstance()->getId();
     $_auth = new Auth_Model_Usuario_Mapper();
     $_auth->setLogin('GUEST')->retrieve();
     $avatarGuest = $_auth->getAvatar(true)->toPhp();
     /**
      * caso seja uma string retorna o id
      */
     $idCategoria = $this->_getIdCategoria($categoria);
     if (!$orderBy) {
         $orderBy = 'cms_conteudo.dh_ini_pub';
     }
     $_whereGroup = new ZendT_Db_Where_Group('AND');
     $_where = new ZendT_Db_Where();
     $_where->addFilter("cms_conteudo.id_categoria", $idCategoria);
     if ($idConteudoPai) {
         $_where->addFilter("cms_conteudo.id_conteudo_pai", $idConteudoPai);
     }
     $_where->addFilter("cms_conteudo.dh_ini_pub", ZendT_Type_Date::nowDateTime(), "<=");
     $_where->addFilter("status.acao", "A");
     $_whereGroup->addWhere($_where);
     $_where = new ZendT_Db_Where('OR');
     $_where->addFilter("cms_conteudo.dh_fim_pub", ZendT_Type_Date::nowDateTime(), ">=");
     $_where->addFilter("cms_conteudo.dh_fim_pub", "", "NULL");
     $_whereGroup->addWhere($_where);
     //($where, $retrieve = false, $found = false, $orderBy='1')
     $_recordset = $this->recordset($_whereGroup, false, false, $orderBy);
     $data = array();
     $result = array();
     while ($data = $_recordset->getRow()) {
         $data['url'] = ZendT_Url::getBaseUrl() . '/cms/conteudo/view/id/' . $data['id']->toPhp();
         $thumbnail = $data['thumbnail']->toPhp();
         if (!$thumbnail) {
             $_conteudo = new Cms_Model_Conteudo_Mapper();
             $_conteudo->setChave('generic')->retrieve();
             $thumbnail = $_conteudo->getThumbnail(true)->toPhp();
         }
         $data['thumbnail'] = $_fileSystem->getDirectoryAdress($thumbnail);
         $data['banner'] = $_fileSystem->getDirectoryAdress($data['banner']->toPhp());
         $avatar = $data['avatar_usuario_inc']->toPhp();
         if (!$avatar) {
             $avatar = $avatarGuest;
             //avatar genérico
         }
         $data['avatar_usuario_inc'] = $_fileSystem->getDirectoryAdress($avatar);
         $data['html_like'] = Cms_Helper_Likes::button($data['id']);
         $data['html_comment'] = Cms_Helper_Feeds::button($data['id']);
         if ($data['id_usuario_inc']->toPhp() == $idUsuario) {
             $data['nome_usuario_inc'] = 'Você';
         }
         $result[] = $data;
     }
     return $result;
 }
Пример #2
0
 public function likeAction()
 {
     $this->_disableRender();
     $json = new ZendT_Json_Result();
     try {
         $id = $this->getRequest()->getParam('id');
         $_conteudo = $this->getMapper();
         $result = $_conteudo->like($id, $this->getRequest()->getParam('onlyLoad'));
         if ($result) {
             $comments = $_conteudo->getLikes($id);
         }
         $qtd = count($comments);
         $html = Cms_Helper_Likes::likes($id);
         $json->setResult(array('qtd' => $qtd, 'html' => $html));
     } catch (Exception $ex) {
         $json->setException($ex);
     }
     echo $json->render();
 }