public function load($reload = false) { $sql = "SELECT nvl(url,'menu-' || trim(to_char(cms_categoria.id,'99999999999'))) as recurso,\n descricao,\n 'menu-' || nvl(trim(to_char(cms_categoria.id_categoria_pai,'99999999999')),'root') as recurso_pai,\n level as nivel,\n ordem,\n CASE WHEN id_categoria_pai IS NOT NULL AND url IS NULL THEN\n 'S'\n ELSE\n 'N'\n END as grupo,\n level as nivel\n FROM cms_categoria\n WHERE menu = 'S' \n AND status = 'A'\n AND ( publico = 'S' OR EXISTS (" . $this->_restritionSql() . ") )\n START WITH id_categoria_pai IS NULL\n CONNECT BY PRIOR id = id_categoria_pai\n ORDER BY level, ordem, descricao"; $moduleName = 'cms'; $_session = Zend_Auth::getInstance()->getStorage()->read(); if (!isset($_session->dataMenu[$moduleName]) || $reload) { $baseUrl = ZendT_Url::getBaseUrl(); $_session->dataMenu = array(); $rows = $this->getModel()->getAdapter()->fetchAll($sql); foreach ($rows as $row) { $data = array(); $data['url'] = str_replace('{baseUrl}', $baseUrl, $row['recurso']); $data['level'] = $row['nivel']; $data['desc'] = utf8_encode($row['descricao']); $data['group'] = $row['grupo'] == 'S'; $_session->dataMenu[$moduleName][$row['recurso_pai']][] = $data; } $_session->dataMenuEncode[$moduleName] = 'UTF8'; /* echo '<pre>'; print_r($_session->dataMenu); echo '</pre>'; exit; */ $storage = Zend_Auth::getInstance()->getStorage(); $storage->write($_session); Zend_Auth::getInstance()->setStorage($storage); } return true; }
/** * Renderiza o objeto para uma string html */ public function render(&$profileName = '') { $name = ''; $itens = ''; foreach ($this->_options as $value => $config) { $class = ''; if ($value == $this->_value) { $name = $config['nome']; $class = 'focus'; } $itens .= '<li onclick="setProfile(this.value,\'' . $this->_object . '\');" value = "' . $value . '" class="link ' . $class . '">' . $config['nome'] . '</li>'; } if (ZendT_Acl::getInstance()->isAllowed('object-view', 'profile')) { $urlAdmin = ZendT_Url::getBaseUrl() . '/profile/object-view/list-config/objeto/' . $this->_object . '/tipo/' . $this->_type . '/id/' . $this->_value; $itens .= '<li role = "separator" class = "divider"></li>'; $itens .= '<li>'; $itens .= ' <a href="' . $urlAdmin . '" target="_new" class="ui-helper-clearfix">'; $itens .= ' ' . _i18n('Administrar'); $itens .= ' </a>'; $itens .= '</li>'; } if ($name) { $profileName = $name; } $xhtml = '<div style="height: 30px; float:left;" class="default ui-button ui-no-radius-bottom " id="title-profile-' . $this->_name . '">'; $xhtml .= ' <span class="ui-icon ui-icon-transfer-e-w" />'; $xhtml .= ' <ul role="title-profile-' . $this->_name . '" align="left" class="dropdown-menu position ui-helper-clearfix ui-no-radius-tr">'; $xhtml .= $itens; $xhtml .= ' </ul>'; $xhtml .= '</div>'; return $xhtml; }
/** * * @param type $spec * @param type $options */ public function __construct($spec, $options = null) { parent::__construct($spec, $options); $this->setAttrib('urlDownload', ZendT_Url::getBaseUrl() . '/file/download'); $this->setAttrib('urlUpload', ZendT_Url::getBaseUrl() . '/file'); $this->setAttrib('urlDelete', ZendT_Url::getBaseUrl() . '/file/delete'); }
/** * * @param type $local */ public function __construct($local = false) { if (!$local) { $local = ZendT_Url::getBaseUrl(); } $this->_local = $local; $this->_where = null; }
/** * Retorna a URL de acesso * * @param bool $removeAction * @return string */ public static function getUri($removeAction = false) { $uri = ZendT_Url::getHostName(); $uri .= ZendT_Url::getBaseUrl(); $route = ZendT_Controller_Front::getInstance()->getRequest()->getParams(); $uri .= '/' . $route['module']; $uri .= '/' . $route['controller']; if (!$removeAction) { $uri .= '/' . $route['action']; } return $uri; }
/** * * @param string $moduleName * * @return ZendT_Acl_Resource_RowMenu[] */ public function getMenu($moduleName) { $moduleName = strtoupper($moduleName); $sql = "SELECT rsu.hierarquia AS recurso, \n rsu.descricao, \n rsuPai.hierarquia AS recurso_pai,\n rsu.nivel,\n rsu.observacao\n FROM " . Auth_Model_Recurso_Mapper::$table . " rsu\n JOIN " . Auth_Model_TipoRecurso_Mapper::$table . " tpRsu ON (rsu.id_tipo_recurso = tpRsu.Id)\n LEFT JOIN " . Auth_Model_Recurso_Mapper::$table . " rsuPai ON (rsu.id_recurso_pai = rsuPai.Id)\n WHERE tpRsu.Nome = 'MENU'\n AND rsu.status = 'A'\n AND rsuPai.hierarquia LIKE '" . $moduleName . "%'\n ORDER BY rsuPai.hierarquia, rsu.ordem, rsu.hierarquia, rsu.descricao"; $rows = $this->getAdapter()->fetchAll($sql); $result = array(); $baseUrl = ZendT_Url::getBaseUrl(); foreach ($rows as $row) { if ($row['observacao'] == '') { $row['observacao'] = $row['recurso']; } $menu = new ZendT_Acl_Resource_RowMenu(); $menu->setDescription($row['descricao'])->setParent($row['recurso'])->setUrl(str_replace("{baseUrl}", $baseUrl, $row['observacao'])); $result[$row['recurso_pai']][] = $menu; } return $result; }
/** * Carrega os elementos no formulário para serem renderizado * @return void */ public function loadElements() { $this->setName('frm_auth'); $this->setAction(ZendT_Url::getBaseUrl() . '/auth/user/authenticate'); $_elements = new Auth_Form_Usuario_Elements(); $element = $_elements->getLogin(); $element->setLabel(_i18n('E-Mail')); $element->setRequired(true); $this->addElement($element); $element = $_elements->getSenha(); $element->setRequired(true); $this->addElement($element); $element = new ZendT_Form_Element_Button('btn_auth'); $element->setIcon('ui-icon-check'); $element->setLabel(_i18n('Autenticar')); $element->setAttrib('onClick', 'jQuery.AjaxT.submitJson({selector: \'#frm_auth\', success: function(result){console.log(result);}})'); $this->addElement($element); }
/** * Ação :: Formulário de Inclusão e Alteração */ public function formAction() { $this->_form = new $this->_formName(); $module = $this->getRequest()->getModuleName(); $controller = $this->getRequest()->getControllerName(); $params = $this->getRequest()->getParams(); $action = $params['action_form']; if ($params['typeModal'] == 'AJAX') { Zend_Layout::getMvcInstance()->setLayout('ajax'); } else { if ($params['typeModal'] == 'IFRAME') { Zend_Layout::getMvcInstance()->setLayout('iframe'); } else { if ($params['typeModal'] == 'WINDOW') { Zend_Layout::getMvcInstance()->setLayout('window'); } } } $this->view->onLoad = stripslashes(urldecode($params['afterLoad'])); if (substr($this->view->onLoad, 0, 7) == 'base64:') { $this->view->onLoad = base64_decode(substr($this->view->onLoad, 7)); } $event = 'insert'; $actionForm = Zend_Controller_Front::getInstance()->getRequest()->getParam('action_form'); if ($actionForm) { $event = $actionForm; } $this->getForm()->loadElements($event); if ($params['id']) { $row = $this->_retrieve(); $this->getForm()->populate($row); } $_buttons = array(); $first = true; if (count($params['buttons']) > 0) { foreach ($params['buttons'] as $caption => $button) { $_button = array(); $_button['caption'] = $caption; $_button['icon'] = $button['icon']; $_button['onClick'] = $button['onClick']; if ($first) { $first = false; $_button['class'] = 'btn primary'; } $_buttons[] = $_button; } } else { if (!$params['grid']) { $formParams = array(); if ($params['callback']) { $params['callback'] = urldecode($params['callback']); if (substr($params['callback'], 0, 7) == 'base64:') { $params['callback'] = base64_decode(substr($params['callback'], 7)); } if ($params['callback']) { $formParams['success'] = new ZendT_JS_Command($params['callback']); } } $formParams = ZendT_JS_Json::encode($formParams); $_button = array(); $_button['caption'] = _i18n('Salvar'); $_button['icon'] = 'ui-icon-disk'; $_button['onClick'] = "function(){" . " var form = jQuery('#" . $this->getForm()->getName() . "'); " . " form.TForm('save'," . $formParams . ");" . "}"; $_button['class'] = 'btn primary'; $_buttons[] = $_button; } } $this->getForm()->loadElements($event); $profile = ZendT_Profile::get($this->_formName, 'F'); /** * Utiliza o profile cadastrado, do contrário utiliza o Form Default */ if ($profile) { $this->getForm()->loadProfile($profile); } $listProfile = ZendT_Profile::listProfile($this->_formName, 'F'); $_profile = new ZendT_View_Profile('selProfile', $profile['id'], $listProfile, 'F', $this->_formName); $screenName = $this->view->screenName; $this->view->profileMenu = $_profile->render($screenName); $this->view->screenName = $screenName; $this->view->placeholder('title')->set($screenName); /* $screenName = $_profile->render($this->view->screenName); $this->view->screenName = $screenName; $this->view->placeholder('title')->set($screenName); */ $this->getForm()->populate($params); $hasAction = $this->getForm()->setAction($action); if (!$hasAction) { $action = ZendT_Url::getBaseUrl() . '/' . $module . '/' . $controller . '/' . $action; $this->getForm()->setAction($action); } $buttons = $this->_createButtons($_buttons); $this->view->buttonsLoad = $buttons['buttons']; $buttons['buttons'] = $buttons['buttons']; $this->view->buttons = $buttons; $this->view->grid = ''; if ($params['grid']) { $configColumns = $this->_mapper->getColumns()->toArray(); foreach ($configColumns as $column => $key) { if ($key['subtotal']) { $this->getGrid()->setFooterRow(true); $this->getGrid()->setUserDataOnFooter(true); break; } } $this->getColumns(); $this->configGrid(); $onCellSelect = "function(){\n var grid = jQuery('#" . $this->getGrid()->getID() . "');\n var id = grid.jqGrid('getGridParam','selrow');\n jQuery('#" . $this->getForm()->getName() . "').TForm('retrieve',id);\n }"; $this->getGrid()->setOnCellSelect($onCellSelect); $this->getGrid()->setObjToolbar(null); /* getObjToolbar()->removeButton('add'); $this->getGrid()->getObjToolbar()->removeButton('edit'); */ //$this->getGrid()->getT // getToolbarButton('edit') $this->view->grid = $this->getGrid(); $_element = new ZendT_Form_Element_Button('btn_save'); $_element->setLabel('Salvar'); $_element->setIcon('ui-icon ui-icon-disk'); $_element->setAttrib('onClick', "jQuery('#" . $this->getForm()->getName() . "').TForm('save',{grid: '#" . $this->getGrid()->getID() . "'});"); $this->getForm()->addElement($_element); $_element = new ZendT_Form_Element_Button('btn_new'); $_element->setLabel('Novo'); $_element->setIcon('ui-icon ui-icon-document'); $_element->setAttrib('onClick', "jQuery('#" . $this->getForm()->getName() . "').TForm('clear',{});"); $this->getForm()->addElement($_element); if (ZendT_Acl::getInstance()->isAllowed('delete', $this->_resourceBase)) { $_element = new ZendT_Form_Element_Button('btn_delete'); $_element->setLabel('Excluir'); $_element->setIcon('ui-icon ui-icon-trash'); $_element->setAttrib('onClick', "jQuery('#" . $this->getForm()->getName() . "').TForm('delete',{grid: '#" . $this->getGrid()->getID() . "'});"); $this->getForm()->addElement($_element); } $_element = new ZendT_Form_Element_Button('btn_next'); $_element->setIcon('ui-icon ui-icon-seek-next'); $_element->addStyle('float', 'right'); $_element->addClass('ui-button-icon ui-state-default ui-group-item item last'); $_element->setAttrib('onClick', "jQuery('#" . $this->getForm()->getName() . "').TForm('navByGrid',{grid: '#" . $this->getGrid()->getID() . "',move:'next'});"); $this->getForm()->addElement($_element); $_element = new ZendT_Form_Element_Button('btn_prev'); $_element->setIcon('ui-icon ui-icon-seek-prev'); $_element->addStyle('float', 'right'); $_element->addClass('ui-button-icon ui-state-default ui-group-item item first'); $_element->setAttrib('onClick', "jQuery('#" . $this->getForm()->getName() . "').TForm('navByGrid',{grid: '#" . $this->getGrid()->getID() . "',move:'prev'});"); $this->getForm()->addElement($_element); $this->getForm()->addDisplayGroup(array('btn_save', 'btn_new', 'btn_delete', 'btn_next', 'btn_prev'), 'group-nav-buttons', array('id' => 'group-nav-buttons-' . $this->getForm()->getName(), 'class' => 'ui-nav-form')); } $this->view->form = $this->getForm(); }
public function init() { $this->view->baseUrl = ZendT_Url::getBaseUrl(); }
/** * * @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; }
public function getApps($id) { $sql = "SELECT aplicacao.descricao, aplicacao.observacao, aplicacao.hierarquia\n FROM " . Auth_Model_Recurso_Mapper::$table . " aplicacao\n JOIN " . Auth_Model_TipoRecurso_Mapper::$table . " tipo_recurso ON (aplicacao.id_tipo_recurso = tipo_recurso.id)\n WHERE tipo_recurso.nome = 'MODULE'\n AND aplicacao.status = 'A'\n AND aplicacao.observacao IS NOT NULL\n AND EXISTS (\n SELECT 1\n FROM " . Auth_Model_Privilegio_Mapper::$table . " privilegio\n JOIN " . Auth_Model_Conta_Mapper::$table . " papel ON (privilegio.id_papel = papel.id)\n JOIN " . Auth_Model_Recurso_Mapper::$table . " recurso ON (privilegio.id_recurso = recurso.id)\n JOIN " . Auth_Model_ContaRel_Mapper::$table . " papel_rel ON (papel_rel.id_papel = :id_usuario)\n JOIN " . Auth_Model_Conta_Mapper::$table . " papel_usu ON (papel_rel.id_papel_rel = papel_usu.id)\n WHERE recurso.status = 'A'\n AND privilegio.acesso = 'P'\n AND papel.status = 'A'\n AND papel_usu.hierarquia LIKE {$this->getAdapter()->concat(array("papel.hierarquia", "'%'"))}\n AND recurso.hierarquia LIKE {$this->getAdapter()->concat(array("aplicacao.hierarquia", "'%'"))}\n ) ORDER BY aplicacao.descricao "; $rows = $this->getAdapter()->fetchAll($sql, array('id_usuario' => $id)); $baseUrl = ZendT_Url::getBaseUrl(); if ($rows) { foreach ($rows as &$row) { $row['observacao'] = str_replace('{baseUrl}', $baseUrl, $row['observacao']); } } return $rows; }
/** * Cria cria um campo hidden, um campo para id, um para descrição e um botão para a busca no seeker. * * @param string $id * @param string $value * @param array $params jQuery Widget Parameters * @param array $attribs HTML Element Attributes * @return string */ public function fileUpload($id, $value = null, array $attribs = array()) { /* echo '<pre>'; print_r($attribs); echo '</pre>'; exit; */ if ($value instanceof ZendT_Type_FileSystem) { $_file = $value->getFile(); if ($_file) { $attribs['jQueryParams']['data']['name'] = $_file->getName(); $attribs['jQueryParams']['data']['type'] = $_file->getType(); $attribs['jQueryParams']['data']['id'] = $_file->getId(); $attribs['jQueryParams']['data']['filename'] = $_file->toFilenameCrypt(); $value = $_file->getName(); } else { $value = ""; } } $params = $attribs['jQueryParams']; unset($attribs['jQueryParams']); if (!isset($attribs['name'])) { $attribs['name'] = $attribs['id']; } $params['url']['base'] = ZendT_Url::getBaseUrl(); $params['url']['public'] = ZendT_Url::getBaseDiretoryPublic(); $id = $this->view->escape($id); $name = $this->view->escape($attribs['name']); $list = '<ul id="' . $id . '_menu" class="dropdown-menu position" role="' . $id . '" style="width: 270px;">'; $list .= ' <li class="ui-no-hover dropdown-menu-group footer">'; $list .= ' <ul class="facescroll" style="width: 260px; height: 130px;" id="files-selected-' . $id . '">'; $list .= ' </ul>'; $list .= ' <button type="button" id="clear-files-' . $id . '" class="ui-button ok ui-state-default">'; $list .= ' <span class="ui-icon ui-icon-close"></span>'; $list .= ' <span class="ui-text">Limpar</span>'; $list .= ' </button>'; $list .= ' '; $list .= ' </li>'; $list .= '</ul>'; $inputAuto = "ui-input-auto"; $xhtml = '<input style="width: 270px;" type="text" id="' . $id . '" name="' . $name . '_display" class="item ' . $inputAuto . '" placeholder="' . $value . '" />'; if ($params['load_id']) { $xhtml .= '<input type="hidden" name="' . $name . '[id]" id="' . $id . '_id" /> <input type="hidden" name="' . $name . '[file]" id="' . $id . '_file" /> <input type="hidden" name="' . $name . '[type]" id="' . $id . '_type" /> <input type="hidden" name="' . $name . '[name]" id="' . $id . '_name" />'; } else { $nameType = $this->_prepareName($name, 'type'); $nameName = $this->_prepareName($name, 'name'); $nameId = $this->_prepareName($name, 'id'); $xhtml .= '<input type="hidden" name="' . $name . '" id="' . $id . '_file" /> <input type="hidden" name="' . $nameType . '" id="' . $id . '_type" /> <input type="hidden" name="' . $nameName . '" id="' . $id . '_name" /> <input type="hidden" name="' . $nameId . '" id="' . $id . '_id" />'; } /* if ($params['multiple']) { $xhtml.= $list; $xhtml.= '<button type="button" id="dropdown-files-' . $id . '" class="ui-button item ui-state-default"><span class="ui-icon ui-icon ui-icon-triangle-1-s"></button>'; } else { $xhtml.= '<button type="button" id="download-files-' . $id . '" class="ui-button item ui-state-default"><span class="ui-icon ui-icon-arrowthickstop-1-s"></button>'; $xhtml.= '<button type="button" id="clear-files-' . $id . '" class="ui-button item ui-state-default"><span class="ui-icon ui-icon-close"></button>'; } */ $xhtml .= $list; //$xhtml.= '<button type="button" id="dropdown-files-' . $id . '" class="ui-button item ui-state-default"><span class="ui-icon ui-icon ui-icon-triangle-1-s"></button>'; $xhtml .= '<button type="button" id="select-files-' . $id . '" class="ui-button item ui-state-default"><span class="ui-icon ui-icon-folder-open"></button>'; $xhtml .= '<div style="clear:both">'; $xhtml .= ' <label class="error" id="error-' . $id . '"></label>'; $xhtml .= '</div>'; $params['elements']['container'] = 'group-' . $id; $params['elements']['files-selected'] = 'files-selected-' . $id; $params['elements']['selectFiles'] = 'select-files-' . $id; $params['elements']['clearFiles'] = 'clear-files-' . $id; $params['elements']['startUpload'] = 'start-upload-' . $id; $params['elements']['id'] = $id; $this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/plupload/plupload.js'); $this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/plupload/plupload.gears.js'); $this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/plupload/plupload.silverlight.js'); $this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/plupload/plupload.flash.js'); $this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/plupload/plupload.html4.js'); $this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/plupload/plupload.html5.js'); $this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/layout/jquery/widget/TJQuery.js'); $this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/layout/jquery/widget/TFileUpload.js'); $this->view->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/layout/jquery/widget/TDropdown.js'); $this->jquery->addOnLoad('jQuery("#' . $id . '").TFileUpload(' . ZendT_JS_Json::encode($params) . ');'); //if ($params['multiple']) { $this->jquery->addOnLoad('jQuery("#' . $id . '_menu").TDropdown({configsHideShow:{events:[\'focus\']}});'); //} return '<div class="ui-form-group">' . $xhtml . '</div>'; }
/** * Cria linhas no relatório * * @param array $columns * @param bool $title */ protected function _addRow($columns, $title = false, $subtotal = false, $columnsTitle = array(), $borderTop = true) { $styles = array(); if ($this->_styleRow && !$title) { $styles = $this->_mapper->getStylesRow($columns, $this->_options['id'], $subtotal); } if ($title && count($this->_columnsTitle) > 0) { foreach ($this->_columnsTitle as $column) { $_cell = new ZendT_Report_Cell(); $_cell->setValue($column['label']); $_cell->setWidth($column['width']); if ($column['colspan']) { $_cell->setColspan($column['colspan'] - 1); } $_cell->setTextAlign('center'); $_cell->setFontWeight(true); $_cell->setFontSize($this->_fontSize); //$this->_configBorder($_cell,$column['border']); $this->_report->addCell($_cell); } $this->_report->printCells(false, $title); } /* echo '<pre>'; print_r($columns); echo '</pre>'; $this->count++; if ($this->count > 3) { exit; } */ foreach ($this->_columns as $column => $atributes) { /** * @todo Verificar qual o melhor lugar para colocar o replace abaixo */ $column = str_replace('-distinct', '', $column); $column = str_replace('_distinct', '', $column); if ($title) { $value = $atributes['label']; } else { if (isset($columns[$column])) { $value = $columns[$column]; } else { $value = ''; } } $_cell = new ZendT_Report_Cell(); if ($title) { $column = 'title_' . $column; } if ($subtotal) { $column = 'total_' . $column; } $_cell->setName($column); $_cell->setValue($value); $parseUrl = false; if ($value instanceof ZendT_Type) { $valueColumn = $value->getValueToDb(); if (isset($this->_columnsJumped[$column])) { $jumpedRow = in_array($valueColumn, $this->_columnsJumped[$column]); } if ($atributes['first_record'] && $valueColumn) { if ($this->_columnsRepeat[$column] == $valueColumn) { $_cell->setValue(NULL); } $this->_columnsRepeat[$column] = $valueColumn; } $parseUrl = true; } $url = str_replace("?", "&", $atributes['url']); $urlView = current(explode('&', $url)); if ($urlView) { $isUrlView = strpos($urlView, "view=") || is_numeric($urlView); if ($isUrlView) { $urlParams = explode('&', substr($url, strpos($url, "&") + 1)); $newParams = ''; foreach ($urlParams as $key => $val) { $data = explode("=", $urlParams[$key]); if ($data[0] && $data[1]) { $newParams[$data[0]] = $data[1]; } } $urlView = end(explode("view=", $urlView)); $urlParams = $newParams; $atributes['url'] = ''; foreach ($this->_params as $param => $key) { $atributes['url'] .= "&{$param}=:{$param}"; } if (!$this->_arrayUrl) { foreach ($this->_columnsOrig as $param => $key) { if (!$key['subtotal']) { $this->_arrayUrl[] = $param; } } } if ($subtotal) { if ($this->_labelBreak == 'Subtotal') { foreach ($this->_columnsBreak as $param => $key) { $atributes['url'] .= "&{$param}=:{$param}"; } } else { if ($this->_labelBreak == 'Total') { } } } else { foreach ($this->_arrayUrl as $key => $param) { $atributes['url'] .= "&{$param}=:{$param}"; } } if ($urlParams) { foreach ($urlParams as $key => $val) { if ($key == $val) { $val = ":{$val}"; } $atributes['url'] .= "&{$key}={$val}"; } } } } if ($atributes['input'] && $this->_configColumns[$column]['input'] != null) { $atributes['input'] = $this->_configColumns[$column]['input']; } $_cell->setInput($atributes['input']); if ($atributes['url'] && !$title && $parseUrl) { $url = trim($atributes['url']); if (strpos($url, ':') !== false) { preg_match_all("/\\:(.*?)\\&/", $url . "&", $params); #print_r($params);die; list($aliasName, $aliasName2) = explode('_', $column); $paramKey = array(); $paramValues = array(); foreach ($params[1] as $paramName) { $paramValue = ''; if (isset($this->_columnsOrig[$paramName])) { $paramValue = $this->_columnsOrig[$paramName]; } else { if (isset($columns[$paramName])) { $paramValue = $columns[$paramName]; } else { if (isset($this->_columnsPivot[$paramName]['labels'][$aliasName])) { $paramValue = $this->_columnsPivot[$paramName]['labels'][$aliasName]; } else { if (isset($this->_columnsPivot[$paramName]['labels'][$aliasName2])) { $paramValue = $this->_columnsPivot[$paramName]['labels'][$aliasName2]; } else { if (isset($this->_params[$paramName])) { $paramValue = $this->_params[$paramName]; } else { foreach ($this->_columns as $column => $keys) { if ($keys['columnName'] == $paramName) { $subtotalColumn = $paramName . "_" . $keys['subtotal']; if ($columns[$paramName]) { $paramValue = $columns[$paramName]->get(); } else { if ($columns[$subtotalColumn]) { $paramValue = $columns[$subtotalColumn]->get(); } } } } } } } } } /* if (substr($paramName,0,3) == 'exp'){ $paramValue = utf8_decode($paramValue); } */ $paramKey[] = ':' . $paramName; $paramValues[] = utf8_decode($paramValue); } $url = str_replace($paramKey, $paramValues, $url); } else { $url .= $value; } if ($isUrlView) { $url = ZendT_Url::getUri() . "?profile=" . $urlView . $url; } $url = str_replace('{host}', ZendT_Url::getHostName(), $url); $url = str_replace('{baseUrl}', ZendT_Url::getHostName() . ZendT_Url::getBaseUrl(), $url); $_cell->setUrl($url); } if ($atributes['width']) { if (strpos($atributes['width'], ',') !== false) { $atributes['width'] = (double) str_replace(array('.', ','), array('', '.'), $atributes['width']); } $_cell->setWidth($atributes['width']); } else { $_cell->setWidth($atributes['width']); } $_cell->setTextAlign($atributes['align']); $_cell->setFontWeight($title || $subtotal || $jumpedRow); $this->_configBorder($_cell, $atributes['border']); if ($title) { $_cell->setBorderBottom(0.4, 'solid', '#000000'); } if ($this->firstLine) { $_cell->setBorderTop(0.2, 'solid', '#000000'); } if ($subtotal && $borderTop) { $_cell->setBorderTop(0.2, 'solid', '#000000'); } if ($atributes['font-size']) { if (strpos($atributes['font-size'], ',') !== false) { $atributes['font-size'] = (double) str_replace(array('.', ','), array('', '.'), $atributes['font-size']); } $_cell->setFontSize($atributes['font-size']); } else { $_cell->setFontSize($this->_fontSize); } if (isset($styles[$column])) { $_cell->setStyles($styles[$column]); } $this->_report->addCell($_cell); if ($atributes['subtotal'] && $subtotal == false && ($value instanceof ZendT_Type_Number || $value instanceof ZendT_Type_NumberTime)) { if (!isset($this->_total[$column])) { $this->_total[$column] = clone $value; } if (isset($atributes['calctotal'])) { $this->_total[$column]->setTotalCalc($columns, $atributes['calctotal']); } else { $this->_total[$column]->setTotal($value, $atributes['subtotal']); } if (count($this->_columnsBreak) > 0) { foreach ($this->_columnsBreak as &$columnBreak) { if (!isset($columnBreak['subtotal'][$column])) { $columnBreak['subtotal'][$column] = clone $value; } if (isset($atributes['calctotal'])) { $columnBreak['subtotal'][$column]->setTotalCalc($columns, $atributes['calctotal']); } else { $columnBreak['subtotal'][$column]->setTotal($value, $atributes['subtotal']); } } } } } $zebra = true; if ($subtotal && $borderTop) { $zebra = false; } if ($title) { $this->firstLine = true; $zebra = false; } else { $this->firstLine = false; } $this->_report->printCells($zebra, $title); }
/** * * @param Zend_View_Interface $view * @return type */ public function render(Zend_View_Interface $view = null) { $element = new ZendT_Form_Element('clear_both'); $element->setDecorators(array(new ZendT_Form_Decorator_ClearBoth())); $this->addElement($element); if ($this->_enablejQueryValidate) { $onLoad = $this->getView()->placeholder('onLoad')->getValue(); $onLoad['jQueryFormValidate'] = "jQuery('#" . $this->getId() . "').validate({ignore:[]});"; $this->getView()->placeholder('onLoad')->set($onLoad); } if (count($this->_url) > 1) { $this->getView()->headScript()->appendFile(ZendT_Url::getBaseDiretoryPublic() . '/scripts/jquery/widget/TForm.js?' . $data); $baseUrl = ZendT_Url::getBaseUrl(); $url = array(); foreach ($this->_url as $key => $value) { $url['url'][$key] = $baseUrl . $value; } $jsonParam = ZendT_JS_Json::encode($url); $onLoad = $this->getView()->placeholder('onLoad')->getValue(); $onLoad['jQueryForm'] = "jQuery('#" . $this->getId() . "').TForm(" . $jsonParam . ");"; $this->getView()->placeholder('onLoad')->set($onLoad); } if ($this->_enableFocusFirstElement) { $onLoad = $this->getView()->placeholder('onLoad')->getValue(); $onLoad['jQueryFormFocus'] = "focusFirstElement('#" . $this->getId() . " input, #" . $this->getId() . " textare, #" . $this->getId() . " select');"; $this->getView()->placeholder('onLoad')->set($onLoad); } $enableTinyMCE = false; $elements = $this->getElements(); $tinyMCE = ''; foreach ($elements as $element) { if ($element instanceof ZendT_Form_Element_Textarea) { if ($element->isEditorHtml()) { $tinyMCE .= "tinyMCE.get('" . $element->getId() . "').save();"; $enableTinyMCE = true; } } } if ($enableTinyMCE) { $onLoad = $this->getView()->placeholder('onLoad')->getValue(); $onLoad['tinyMCE'] = "jQuery('#" . $this->getId() . "').submit(function(){" . $tinyMCE . "});"; $this->getView()->placeholder('onLoad')->set($onLoad); } return parent::render($view); }
public function enableAdd($url) { list($module, $controller) = explode('/', substr($url, 1)); if (!ZendT_Acl::getInstance()->isAllowed('insert', $module . '.' . $controller)) { return $this; } $button = new ZendT_Form_Element_Button('btn_add'); //$button->setTitle(_i18n('Adicionar')); $button->setIcon('ui-icon-plus'); $button->setAttrib('url', ZendT_Url::getBaseUrl() . $url); $this->setAttrib('btn_add', $button); return $this; }
public static function getUrlView($idConteudo, $idCategoria = "", $includeHost = false) { $url = ''; if ($includeHost) { $url .= ZendT_Url::getHostName(); } $url .= ZendT_Url::getBaseUrl() . "/cms/conteudo/view/id/" . $idConteudo; if ($idCategoria) { $url .= "/categoria/{$idCategoria}"; } return $url; }
/** * * @return string */ public function render($type = '') { $content = parent::render(); if ($type == 'PDF') { return $content; } $title = $this->_options['title']; $name = strtolower(str_replace(array(' '), array('-'), utf8_decode($title))); $nameIframe = strtolower('ifr' . clearAccent($name)); $driver = strtolower($this->_options['driver']); $download = Zend_Controller_Front::getInstance()->getRequest()->getParam('download'); $iframeDownload = Zend_Controller_Front::getInstance()->getRequest()->getParam('iframeDownload'); $iframeHeight = Zend_Controller_Front::getInstance()->getRequest()->getParam('iframeHeight'); if (!$driver) { $driver = 'pdf'; } $file = new ZendT_File($name . '.' . $driver, $content, 'application/' . strtolower($driver)); $fileUri = $file->toArrayJson(); $cmdHtml = ''; $src = ZendT_Url::getBaseUrl() . '/file'; if ($driver == 'xls' || $download) { $src .= '/download'; $width = 0; $height = 0; if (!$iframeDownload) { $cmdHtml .= '<div class="ui-widget ui-state-default ui-corner-all" style="height:30px;padding:5px;">' . "\n"; $cmdHtml .= ' <span style="float:left;" class="ui-icon ui-icon-arrowstop-1-s"></span>' . "\n"; $cmdHtml .= ' <span style="float:left;"><a href="javascript:javascript:downloadReport();">Se o download não iniciar automaticamente clique aqui.</a></span>' . "\n"; $cmdHtml .= ' <span style="clear:both"></span>' . "\n"; $cmdHtml .= '</div>' . "\n"; } } else { if ($driver == 'html') { return $content; } else { $src .= '/pdf'; $width = '100%'; $height = '520'; if (isset($this->_options['width'])) { $width = $this->_options['width']; } if (isset($this->_options['height'])) { $height = $this->_options['height']; } } } $src .= '?filename=' . $fileUri['filename']; $src .= '&type=' . $fileUri['type']; $src .= '&name=' . $fileUri['name']; $src .= '#zoom=120'; $cmdHtml .= '<iframe'; $cmdHtml .= ' id="' . $nameIframe . '"'; $cmdHtml .= ' name="' . $nameIframe . '"'; $cmdHtml .= ' src="' . $src . '"'; $cmdHtml .= ' width="' . $width . '"'; $cmdHtml .= ' height="100%"'; $cmdHtml .= ' style="min-height:' . $height . 'px"'; $cmdHtml .= ' border="0"'; $cmdHtml .= ' frameborder="0"'; $cmdHtml .= ' align="center"'; $cmdHtml .= ' noresize="noresize"'; $cmdHtml .= ' scrolling="yes"'; if ($iframeDownload) { $cmdHtml .= ' onload="history.go(-1);"'; } $cmdHtml .= '></iframe>'; $cmdHtml .= '<script>function downloadReport(){this.' . $nameIframe . '.location = \'' . $src . '\'; }</script>'; return $cmdHtml; }
public static function convertObjectToUri($objectName) { $itens = ZendT_Lib::mapperViewToArrayUri($objectName); $uri = ZendT_Url::getHostName() . ZendT_Url::getBaseUrl() . '/' . $itens['module'] . '/' . $itens['controller']; return $uri; }
/** * 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'); } } }
public static function formatUrl($url) { $url = str_replace('{host}', ZendT_Url::getHostName(), $url); $baseUrl = ZendT_Url::getBaseUrl(); $url = str_replace('{baseUrl}', $baseUrl, $url); return $url; }
/** * * @return string */ public function toUrlDownload($encode = true) { $filename = $this->toFilenameCrypt(true); $uri = ZendT_Url::getHostName() . ZendT_Url::getBaseUrl() . '/file/download?filename=' . $filename . '&type=' . $this->getType() . '&delete=1'; if ($encode) { $uri = base64_encode($uri); } return $uri; }