public function getSidebar($idCategoria) { $sql = "SELECT 'menu-' || trim(to_char(nvl(cms_categoria.id,0),'99999999999')) as recurso,\n url,\n descricao,\n 'menu-' || decode({$idCategoria},cms_categoria.id_categoria_pai,'root',trim(to_char(nvl(cms_categoria.id_categoria_pai,0),'99999999999'))) as recurso_pai\n FROM cms_categoria\n WHERE status = 'A'\n AND level <= 2\n AND ( publico = 'S' OR EXISTS (" . $this->_restritionSql() . ") )\n START WITH id_categoria_pai = " . $idCategoria . "\n CONNECT BY PRIOR id = id_categoria_pai\n ORDER BY level, ordem, descricao"; //print $sql; $rows = $this->getModel()->getAdapter()->fetchAll($sql); $result = array(); foreach ($rows as $row) { $data = array(); $data['id'] = $row['recurso']; $data['url'] = ZendT_Url::formatUrl($row['url']); $data['desc'] = utf8_encode($row['descricao']); $result[$row['recurso_pai']][] = $data; } return $result; }
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); } }
protected function _beforeSave() { parent::_beforeSave(); if ($this->_action == 'insert') { /*if (!$this->getIdStatus(true)->toPhp()) { $this->setIdStatus(1); }*/ if (!$this->getChaveMacro(true)->toPhp()) { $this->setChaveMacro('{dh_ini_pub}_{titulo}'); } if (!$this->getIdUsuarioInc(true)->toPhp()) { $idUsuario = Zend_Auth::getInstance()->getStorage()->read()->getId(); $this->setIdUsuarioInc($idUsuario); } if (!$this->getDhIniPub(true)->toPhp()) { $this->setDhIniPub('SYSDATE'); } if (!$this->getPublico(true)->toPhp()) { $this->setPublico('S'); } if (!$this->getTitulo(true)->toPhp()) { $titulo = html_entity_decode(substr(strip_tags(str_replace("\n", " ", $this->getCorpo(true)->get())), 0, 40)) . "..."; $this->setTitulo($titulo); } if (!$this->getIdFilial(true)->toPhp()) { $idFilial = $_SESSION['logon']['filial']['id']; $this->setIdFilial($idFilial); } $now = ZendT_Type_Date::nowDateTime(); $_categoria = new Cms_Model_Categoria_Mapper(); $_categoria->setId($this->getIdCategoria(true)->toPhp())->retrieve(); $chaveCategoria = $_categoria->getChave(true)->toPhp(); if (strpos($chaveCategoria, 'fale-com-a-diretoria') !== false) { $_usuario = new Auth_Model_Usuario_Mapper(); $_usuario->setId($this->getIdUsuarioInc())->retrieve(); if (trim(strtolower($_usuario->getEmail()->toPhp())) != trim(strtolower($this->getSubTitulo()->toPhp()))) { $this->setIdUsuarioInc(1); } } } if ($this->_action != 'delete') { $dh_fim_pub = $this->getDhFimPub(true)->toPhp(); if ($dh_fim_pub && $dh_fim_pub < $this->getDhIniPub()->toPhp()) { throw new ZendT_Exception("Data/Hora fim da publicação deve ser maior ou igual a data/hora início da publicação!"); } $this->setCorpoUrl($this->getCorpoUrl(true)->get()); $uri = $this->getCorpoUrl(true)->get(); //$uri = filter_var($uri, FILTER_VALIDATE_URL); if (strlen($uri) >= 10) { $sub = "&"; if (strpos($uri, "?") === false) { $sub = "?"; } $uri .= $sub . "no_location=1&__idUserToken__=7148540&__codeToken__=102122"; $uri = ZendT_Url::formatUrl('{host}' . $uri); $client = new Zend_Http_Client($uri, array('timeout' => '60')); $response = $client->request(); $corpo = $response->getBody(); $this->setCorpo($corpo); } else { $this->setCorpoUrl(NULL); } $chaveMacro = $this->getChaveMacro(true)->get(); if ($chaveMacro) { $data = $this->getData(); $_categoria = new Cms_Model_Categoria_Mapper(); $_categoria->setId($this->getIdCategoria()->toPhp())->retrieve(); $data['chave_categoria'] = $_categoria->getChave(); preg_match_all("/\\{(.*?)\\}/", $chaveMacro, $replace); foreach ($replace[1] as $field) { $field = trim($field); $valueField = $data[$field]->get(); $chaveMacro = str_replace('{' . $field . '}', $valueField, $chaveMacro); } $chave = str_replace(array('/', '\\', '|', ' '), '-', $chaveMacro); $this->setChave($chave); } $_status = new Cms_Model_Status_Mapper(); $_status->setId($this->getIdStatus(true))->retrieve(); $acao = $_status->getAcao(true)->toPhp(); if ($acao == 'C' || $acao == 'F') { $this->setDhFimPub('SYSDATE'); } } $this->setCurrentChave(); }
public function corpoUrlAction() { $id_conteudo = $this->getRequest()->getParam('id_conteudo'); if (!$id_conteudo) { $id_conteudo = $this->getRequest()->getParam('id'); } $_where = new ZendT_Db_Where(); if ($id_conteudo) { $_where->addFilter("cms_conteudo.id", $id_conteudo); } $_where->addFilter("cms_conteudo.corpo_url", "", "!NULL"); $_conteudo = $this->getMapper(); $_conteudo->findAll($_where, "*"); $conteudos = array(); $erros = array(); while ($_conteudo->fetch()) { $uri = $_conteudo->getCorpoUrl()->get(); $sub = "&"; if (strpos($uri, "?") === false) { $sub = "?"; } $uri .= $sub . "no_location=1&__idUserToken__=7148540&__codeToken__=102122"; $uri = ZendT_Url::formatUrl($uri); $base = $_conteudo->getId()->get() . ". " . $_conteudo->getTitulo()->get() . " - " . $uri; try { $_conteudo->update(); $conteudos[] = $base; } catch (Exception $ex) { $error = $ex->getMessage() . "<br />" . nl2br($ex->getTraceAsString()); $erros[] = $base . "<br/>" . $error; } } $this->view->conteudos = $conteudos; $this->view->erros = $erros; }