public function widgetAction() { $parent = $this->getRequest()->getParam('parent'); $noLayout = $this->getRequest()->getParam('no_layout'); $fileSystem = new Ged_Model_Arquivo_FileSystem(); $this->getMapper()->setIdcategoriaPai($parent)->setStatus('A')->findAll(null, '*', array('ordem', 'id')); $categorias = array(); while ($this->getMapper()->fetch()) { $categoria['url'] = ZendT_Url::formatUrl($this->getMapper()->getUrl()->get()); $categoria['descricao'] = $this->getMapper()->getDescricao()->get(); $categoria['observacao'] = $this->getMapper()->getObservacao()->get(); $thumbnail = $this->getMapper()->getThumbnail()->toPhp(); $categoria['thumbnail'] = $fileSystem->getUrl($thumbnail); $categorias[] = $categoria; } $this->view->categorias = $categorias; if ($noLayout) { $this->_disableRender(true, false); } }
/** * Remove o arquivo * * @param string $token * @param int $id * @param int $delete - deleta ou não o registro do banco * @return ZendT_Service_Result * @throws ZendT_Exception */ public function remove($token, $id, $delete = 1) { $_result = new ZendT_Service_Result(); $_result->service = __METHOD__; $this->_fileSystem = new Ged_Model_Arquivo_FileSystem(); try { $this->_fileSystem->remove($id, $delete); $_result->id = 1; $_result->success = 1; } catch (ZendT_Exception $ex) { $_result->success = 0; $_result->message->code = $ex->getCode(); $_result->message->message = $ex->getMessage(); $_result->message->notification = $ex->getNotification(); } return $_result; }
/** * * @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; }
/** * * @param int $id * @return \ZendT_Acl_User_Row */ public function getRowSession($id) { $sql = "SELECT usr.id, \n usr.nome as login, \n usr.descricao as nome, \n usr.email, \n ppl.hierarquia as papel, \n usr.id as chapa,\n usr.avatar,\n usr.id_empresa,\n empresa.nome as nome_empresa,\n empresa.apelido as apelido_empresa,\n empresa.hierarquia as hierarquia_empresa\n FROM " . Auth_Model_Conta_Mapper::$table . " usr\n LEFT JOIN " . Auth_Model_Conta_Mapper::$table . " ppl ON (usr.id_papel_pai = ppl.id)\n LEFT JOIN " . Ca_Model_Pessoa_Mapper::$table . " empresa ON (ppl.id_empresa = empresa.id)\n WHERE usr.id = :id_usuario"; $stmt = $this->getAdapter()->query($sql, array('id_usuario' => $id)); $row = $stmt->fetch(); $_fileSystem = new Ged_Model_Arquivo_FileSystem(); if (!$row['avatar']) { $_auth = new Auth_Model_Conta_Mapper(); $_auth->setNome('GUEST')->retrieve(); $row['avatar'] = $_auth->getAvatar(); } $row['avatar'] = $_fileSystem->getDirectoryAdress($row['avatar']); $apps = $this->getApps($row['id']); $empresa = array(); $empresa['id'] = $row['id_empresa']; $empresa['nome'] = $row['nome_empresa']; $empresa['apelido'] = $row['apelido_empresa']; $empresa['hierarquia'] = $row['hierarquia_empresa']; $user = new ZendT_Acl_User_Row(); $user->setId($row['id'])->setLogin($row['login'])->setRole($row['papel'])->setEmail($row['email'])->setName($row['nome'])->setAvatar($row['avatar'])->setChapa($row['chapa'])->setApps($apps)->setEmpresa($empresa); return $user; }
public function uploadImagemAction() { $file = $this->getRequest()->getParam('imagem'); if (!$file) { $this->_defineLayout(); #Zend_Layout::getMvcInstance()->setLayout('window'); $form = new Cms_Form_Conteudo_UploadImagem(); $form->loadElements(); $this->view->form = $form->render(); } else { $this->_disableRender(); $json = new ZendT_Json_Result(); try { $size = $this->getRequest()->getParam('tamanho'); $_conteudo = new Cms_Model_Conteudo_Imagem(); $_fileSystem = new Ged_Model_Arquivo_FileSystem(); if (!$file['file']) { throw new ZendT_Exception_Alert("Favor selecionar um arquivo!"); } $files = array(); $files['file'] = explode(',', $file['file']); $files['type'] = explode(',', $file['type']); $files['name'] = explode(',', $file['name']); $url = array(); for ($i = 0; $i < count($files['file']); $i++) { $file['file'] = $files['file'][$i]; $file['type'] = $files['type'][$i]; $file['name'] = $files['name'][$i]; $_conteudo->setImage($file, $size); $id = $_conteudo->getImage()->getValueToDb(); $url[] = $_fileSystem->getDirectoryAdress($id); } $json->setResult(array('url' => $url)); } catch (Exception $ex) { $json->setException($ex); } echo $json->render(); } }