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"> <div class="header ui-helper-clearfix"> <span class="name">' . $nomeUsuario . '</span> </div> <div class="content ui-helper-clearfix"> <span class="avatar"> <img src="' . $avatarUsuario . '"> </span> <span class="message comment" calc-width-parent="" calc-width="-100"> ' . $_comentarForm . ' </span> </div> </li>'; } return $xhtml; }
public function loadProfile($object) { /** * Consultar o Profile cadastrado pelo usuário e alterar o $profile Default */ if (!strpos($this->_name, '_ObjectView_')) { $profileUser = ZendT_Profile::get($this->_name, 'G'); if ($profileUser) { $fields = $profileUser['cols-detail']['fields']; if ($fields) { $arrFields = array_keys($fields); $hiddenFields = array_diff($this->_profileDefault['order'], $arrFields); $this->_profileDefault['hidden'] = array(); $this->_profileDefault['order'] = array(); foreach ($hiddenFields as $field) { $this->_profileDefault['hidden'][] = $field; } foreach ($fields as $field => $config) { if (isset($config['width'])) { $this->_profileDefault['width'][$field] = $config['width']; } if (isset($config['align'])) { $this->_profileDefault['align'][$field] = $config['align']; } if (isset($config['label'])) { $this->_profileDefault['label'][$field] = $config['label']; } if (isset($config['value']) && $config['value']) { $this->_profileDefault['value'][$field] = $config['value']; } if (isset($config['subtotal'])) { $this->_profileDefault['subtotal'][$field] = $config['subtotal']; } if (isset($config['hidden']) && $config['hidden']) { $this->_profileDefault['hidden'][] = $field; } $this->_profileDefault['order'][] = $field; } } } } }
/** * Aplica as configurações e gera o relatório * * @param string $type * @param array $options */ public function configReport($type = 'pdf', $options = false) { set_time_limit(3200); $objectName = get_class($this->_mapper); if (ZendT_Acl::getInstance()->isAllowed('object-view', 'profile')) { $profile = ZendT_Profile::get($objectName, $type == 'pdf' ? 'P' : 'X'); if ($profile) { $result = $this->configReportProfile($type, $options, $profile); } else { $result = $this->configReportSample($type, $options); } } else { $result = $this->configReportSample($type, $options); } return $result; }
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); } }
/** * Pega o objeto grid pré-configurado para * manipulação. * * @return ZendT_Grid */ public function configGrid() { $module = $this->getRequest()->getModuleName(); $controller = $this->getRequest()->getControllerName(); $params = $this->getRequest()->getParams(); $profileKey = ''; if (isset($params['profile_key'])) { $profileKey = $params['profile_key']; } $urlFilter = '?q=1'; if (isset($params['filter_json'])) { $urlFilter .= '&filter_json=' . $params['filter_json']; } if (isset($params['mapper_view'])) { $urlFilter .= '&mapper_view=' . $params['mapper_view']; } if ($this->_mapper instanceof ZendT_Db_View) { $where = $this->getMapper()->getColumns()->getWhere($params); if ($where) { $params['postData'] = $where->toJsonPostData($params['postData']); } } if ($params['postData'] != '') { $autoFilter = true; } else { $autoFilter = false; } $type = 'G'; #Grid $mapperName = get_class($this->_mapper); $profile = ZendT_Profile::get($mapperName, $type); $profileId = ''; if (isset($profile['id'])) { $profileId = $profile['id']; } $profiles = ZendT_Profile::listProfile($mapperName, $type); $this->getGrid()->setUrl(ZendT_Url::getBaseUrl() . '/' . $module . '/' . $controller . '/grid-data/profile/' . $profileId . $urlFilter)->setDataType('json')->setMType('POST')->setRowNum(30)->setRowList(array(30, 60, 90))->setPager("#pager-" . $this->getGrid()->getID())->setViewRecords('true')->setToolbar(array('true', 'top'))->setMType('POST')->setWidth(960)->setAutoFilter($autoFilter)->setShrinkToFit(false)->setPostData(urldecode($params['postData']))->setBeforeRequest("function(){ gridResize('" . $this->getGrid()->getID() . "'); }")->setGridComplete(" function(){ jQuery.gridAtivaNavKey({ idGrid:'" . $this->getGrid()->getID() . "' }); }"); /** * Analisa Parâmetros */ $newPostData = array(); foreach ($params as $name => $value) { $param = $this->getMapper()->paramName($name); if ($param) { $newPostData[$param] = $value; } } if (count($newPostData) > 0) { $this->getGrid()->setPostData($newPostData); } if ($this->getRequest()->getParam('seekerAjax')) { $objectRetrieve = 'TSeeker'; if ($this->getRequest()->getParam('objectRetrive')) { $objectRetrieve = $this->getRequest()->getParam('objectRetrive'); } $this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/widget/' . $objectRetrieve . '.js'); $seekerName = $this->getRequest()->getParam('seekerName'); $seekerAccess = 'window.opener.jQuery'; $seekerClose = 'window.close();'; if ($params['typeModal'] == 'AJAX') { $seekerAccess = 'jQuery'; $seekerClose = 'seeker.TSeeker(\'divClose\');'; $functionResize = "function(){\n var grid = jQuery('#" . $this->getGrid()->getID() . "');\n var seeker = " . $seekerAccess . "('#" . $seekerName . "');\n var div = seeker.TSeeker('option','elements').div;\n grid.setGridHeight(250);\n grid.setGridWidth(700);\n }"; } else { $functionResize = "function(){\n \$.gridResize({\n idGrid: '" . $this->getGrid()->getID() . "'\n });\n \$(window).resize(function(){\n \$.gridResize({\n idGrid: '" . $this->getGrid()->getID() . "'\n });\n });\n }"; } $functionRetorno = "function(){\n var grid = jQuery('#" . $this->getGrid()->getID() . "');\n if( grid.jqGrid('getGridParam','multiselect') ){\n var id = grid.jqGrid('getGridParam','selarrrow');\n }else{\n var id = grid.jqGrid('getGridParam','selrow');\n }\n var seeker = " . $seekerAccess . "('#" . $seekerName . "');\n try{\n seeker.{$objectRetrieve}('retrieve',{value: id});\n {$seekerClose}\n }catch(err){\n {$seekerClose}\n }\n }"; $this->getGrid()->setOndblClickRow($functionRetorno)->setBeforeRequest($functionResize)->setGridComplete("function(){\n \$.gridAtivaNavKey({\n idGrid: '" . $this->getGrid()->getID() . "',\n functionEnter: " . $functionRetorno . "\n });\n }"); } if ($params['callback']) { $functionCallback = base64_decode($params['callback']); $this->getGrid()->setOndblClickRow($functionCallback)->setGridComplete("function(){\n \$.gridAtivaNavKey({\n idGrid: '" . $this->getGrid()->getID() . "',\n functionEnter: " . $functionCallback . "\n });\n }"); } if ($params['multiple']) { $this->getGrid()->setMultiSelect(true); $idbt = 'selectGrid' . $this->getGrid()->getID(); $multiSelect = new ZendT_Grid_Button($idbt); $multiSelect->setIdGrid($this->getGrid()->getID())->setButtonIcon("ui-icon-check")->setTitle("Selecionar")->setCaption("Selecionar")->setOnClick($functionRetorno); $this->view->hotkeys()->add('btMultiSelect', 'ctrl+s', '$("#' . $idbt . '").click();'); $this->getGrid()->addToolbarButton("multiSel", $multiSelect); } $idbt = 'refreshGrid' . $this->getGrid()->getID(); $refresh = new ZendT_Grid_Button_Refresh($idbt); $refresh->setIdGrid($this->getGrid()->getID())->setButtonIcon("ui-icon-refresh")->setTitle("Atualizar"); $this->view->hotkeys()->add('btRefresh', 'ctrl+r', '$("#' . $idbt . '").click();'); $this->getGrid()->addToolbarButton("refresh", $refresh, 'grid'); /* $clearFiltro = new ZendT_Grid_Button(); $clearFiltro->setIdGrid($this->getGrid()->getID()) ->setButtonIcon('ui-icon ui-icon-arrowreturnthick-1-s') ->setOnClick('function(){$(\'#' . $this->getGrid()->getID() . '\')[0].clearToolbar();}') ->setTitle('Limpar Filtro'); $this->getGrid()->addToolbarButton('clearFilter', $clearFiltro, 'grid'); */ $autoFiltro = new ZendT_Grid_Button(); $autoFiltro->setIdGrid($this->getGrid()->getID())->setButtonIcon('ui-icon ui-icon-pin-s')->setOnClick('function(){$(\'#' . $this->getGrid()->getID() . '\')[0].toggleToolbar();}')->setTitle('Filtro'); $this->getGrid()->addToolbarButton('autofiltro', $autoFiltro, 'grid'); $_profile = new ZendT_View_Profile('selProfile', $profile['id'], $profiles, $type, $mapperName); $screenName = $this->view->screenName; $this->view->profileMenu = $_profile->render($screenName); $this->view->screenName = $screenName; $this->view->placeholder('title')->set($screenName); $navigator = ''; if ($navigator) { $this->getGrid()->getNavigator()->addCommand('navigatorGrid', $navigator); } /** * Botão de adição de registro e * suas configurações vitais */ if ($this instanceof ZendT_Controller_ActionCrud && ZendT_Acl::getInstance()->isAllowed('insert', $this->_resourceBase)) { $filterJson = $this->getRequest()->getParam('filter_json'); $idbt = 'addGrid' . $this->getGrid()->getID(); $add = new ZendT_Grid_Button_Add($idbt); $add->setIdGrid($this->getGrid()->getID())->setButtonIcon('ui-icon-plus')->setUrl(ZendT_Url::getBaseUrl() . '/' . $module . '/' . $controller . '/form?filter_json=' . $filterJson . '&profile_key=' . $profileKey)->setWindowWidth(860)->setWindowHeight(520)->setTitle('Adicionar'); $this->view->hotkeys()->add('btInsert', 'ctrl+a', '$("#' . $idbt . '").click();'); $this->getGrid()->addToolbarButton('add', $add, 'edit'); } /** * Botão de edição de linha e * suas configurações vitais */ if ($this instanceof ZendT_Controller_ActionCrud && ZendT_Acl::getInstance()->isAllowed('update', $this->_resourceBase)) { $idbt = 'editGrid' . $this->getGrid()->getID(); $edit = new ZendT_Grid_Button_Edit($idbt); $edit->setIdGrid($this->getGrid()->getID())->setButtonIcon('ui-icon-pencil')->setUrl(ZendT_Url::getBaseUrl() . '/' . $module . '/' . $controller . '/form' . '?profile_key=' . $profileKey)->setUrlRetrieve(ZendT_Url::getBaseUrl() . '/' . $module . '/' . $controller . '/retrive')->setWindowWidth(860)->setWindowHeight(520)->setTitle('Editar'); $this->view->hotkeys()->add('btEdit', 'ctrl+e', '$("#' . $idbt . '").click();'); $this->getGrid()->addToolbarButton('edit', $edit, 'edit'); if (!$this->getRequest()->getParam('seekerAjax')) { $this->getGrid()->setOndblClickRow("function(){jQuery('#" . $idbt . "').click();}"); } } #Button - Delete if ($this instanceof ZendT_Controller_ActionCrud && ZendT_Acl::getInstance()->isAllowed('delete', $this->_resourceBase)) { $idbt = 'delGrid' . $this->getGrid()->getID(); $del = new ZendT_Grid_Button_Delete($idbt); $del->setIdGrid($this->getGrid()->getID())->setButtonIcon('ui-icon-trash')->setUrl(ZendT_Url::getBaseUrl() . '/' . $module . '/' . $controller . '/delete')->setWindowWidth(800)->setWindowHeight(520)->setTitle('Excluir'); $this->view->hotkeys()->add('btDelete', 'ctrl+d', '$("#' . $idbt . '").click();'); $this->getGrid()->addToolbarButton('del', $del, 'edit'); } if ($this instanceof ZendT_Controller_ActionCrud && ZendT_Acl::getInstance()->isAllowed('log', $this->_resourceBase) && method_exists($this->_mapper, 'isLogger') && $this->_mapper->isLogger()) { $log = new ZendT_Grid_Button_Window(); $log->setIdGrid($this->getGrid()->getID())->setButtonIcon('ui-icon-info')->setUrl(ZendT_Url::getBaseUrl() . '/' . $module . '/' . $controller . '/log')->setWindowWidth(650)->setWindowHeight(450)->setTitle('Log'); $this->getGrid()->addToolbarButton('Log', $log, 'edit'); } $this->view->typeModal = $params['typeModal']; if ($params['typeModal'] == 'AJAX') { Zend_Layout::getMvcInstance()->setLayout('ajax'); } else { if ($params['typeModal'] == 'WINDOW') { $this->view->onLoad = stripslashes(urldecode($params['afterLoad'])); $this->view->onClose = stripslashes(urldecode($params['onClose'])); Zend_Layout::getMvcInstance()->setLayout('window'); } } }