*
  • camposDependientes: Acción privada de Igep que sirve para recalcular las listas dependientes con el nuevo valor seleccionado. Nunca tiene que ser utilizado por los programadores.
  • *
  • abrirVentanaLiveSearch: Acción privada de Igep que sirve para abrir una ventana Live Search. Nunca tiene que ser utilizado por los programadores.
  • *
  • abrirVentanaSeleccion: Acción privada de Igep que sirve para abrir una ventana de Selección. Nunca tiene que ser utilizado por los programadores.
  • *
  • buscarVentanaSeleccion: Acción privada de Igep que sirve para buscar en una ventana de Selección. Nunca tiene que ser utilizado por los programadores.
  • *
  • ordenarTabla: Acción privada de Igep que ordena los registros de una tabla por un campo y en un sentido.
  • * * * @license http://opensource.org/licenses/gpl-2.0.php GNU Public License v.2 * @version $Id: IgepAccionesGenericas.php,v 1.74 2018-08-11 13:21:53 belenguer_jor Exp $ * @author David Pascual * @author Vero Navarro * @author Toni Felix * @author Jorge Belenguer * * @package gvHidra */ class IgepAccionesGenericas extends Action { /** * Variable de error. * * @var IgepError */ var $obj_errorNegocio; /** * La instancia de IgepComunicación para comunicarnos con la presentación. * @var IgepComunicacion */ var $comunica; /** * Variable que contendrá el posible mensaje a enviar al panel. Tiene que ser de la clase IgepMensaje. * @var IgepMensaje */ var $obj_mensaje; /** * Objeto que permite manejar/registrar el javascript de esta clase. * @var IgepSmarty */ var $obj_IgSmarty; private $_modal = false; private $_closeModal = false; /** * Constructor. Generará a partir de los parámetros que se le pasen una conexión a al base de datos y un * array de manejadores de tablas (una por cada una de las que mantenga el panel hijo). */ public function __construct() { /** @global IgepError */ global $g_error; if( !isset($g_error) ) { $g_error = new IgepError(); } $this->obj_errorNegocio = & $g_error; $this->setModal( false ); } //Fin del constructor /** * Método que se ejecuta tras el constructor y que permite seleccionar la acción a realizar. * En esta clase se encuentran las siguientes acciones genéricas: *
      *
    • camposDependientes : Recalcula listas dependientes y dispara acciones de interfaz.
    • *
    • abrirVentanaLiveSearch : Abre la ventana de Live Search.
    • *
    • abrirVentanaSeleccion : Abre la ventana de Selección.
    • *
    • buscarVentanaSeleccion : Realiza la busqueda en la ventana de Selección.
    • *
    * * @param ActionMapping $actionMapping * @param object $actionForm */ public function perform( $actionMapping, $actionForm ) { //Recogemos la accion y le quitamos el prefijo que nos viene de la ventana $str_accion = $actionForm->get( 'action' ); //Debug:Indicamos que entramos en Negocio y la accion a ejecutar IgepDebug::setDebug( DEBUG_IGEP, __CLASS__ . ": ejecutamos acción {$str_accion}" ); //creamos la instancia de IgepComunicacion $this->comunica = new IgepComunicacion( array() ); switch( $str_accion ) { // REDMINE #23201 PATH TRAVERSAL case 'gvhLoadImg': // Carga inicial de imágenes // REDMINE #23227 allowedPath $conf = ConfigFramework::getConfig(); $allowedPaths = $conf->getAllowedPath(); $vImg = array(); if ( (isset($_REQUEST['file']) && !empty($_REQUEST['file'])) && (isset($_REQUEST['ext']) && !empty($_REQUEST['ext']))) { $src =''; $file = $_REQUEST['file'].'.'.$_REQUEST['ext']; $dirname = $_REQUEST['dirname']; $path = $file; if (isset($dirname) && ($dirname != '.')) { $path = $dirname."/".$file; } $src = 'igep/images/noImage.png'; if (isset($allowedPaths) && (!empty($allowedPaths))) { foreach ($allowedPaths as $id=>$dir) { $file = $path; if(file_exists($file)) { $src = $file; break; } } } else { $file = $path; if(file_exists($file)) { //IgepDebug::setDebug(PANIC, "
    FILE EXISTE ".print_r($src,true)."
    "); $src = $file; } } $tipo = $this->mimeTypes($file); ob_clean(); if(strpos($tipo,'image')!==false)//Sólo servimos imágenes... { //IgepDebug::setDebug(PANIC, "
    FILE EXTENSIÓN CORRECTA ".print_r($src,true)."
    "); $gestor = fopen($src, 'r'); $contenido = fread($gestor, filesize($src)); echo $contenido; die; } else { IgepDebug::setDebug(PANIC, "
    El fichero ".print_r($file,true)." no tiene extensión de imagen
    "); } } $file = 'igep/images/noImage.png'; $gestor = fopen($file, 'r'); $contenido = fread($gestor, filesize($file)); echo $contenido; die; break; /* // REVIEW: Por si cambiamos a devolver la ruta y no el fichero en si */ /*case 'gvhLoadImgPag': // Paginación de imágenes $conf = ConfigFramework::getConfig(); $allowedPaths = $conf->getAllowedPath(); $vImg = array(); $src =''; if (isset($allowedPaths)) { IgepDebug::setDebug(PANIC, "
    paths permitidos ".print_r($allowedPaths,true)."
    "); if (is_array($_POST['vImages'])) { $numImg = count($_POST['vImages']); for($img=0;$img<$numImg;$img++) { $src = 'igep/images/noImage.png'; foreach ($allowedPaths as $id=>$dir) { $file = $dir."/".$_POST['vImages'][$img]['valueJSONDecode']; if(file_exists($file)) { $src = $file; break; } } $vImg['images'][] = array( 'id' => $_POST['vImages'][$img]['idCampo'], 'src' => $src ); } } } else { if (is_array($_POST['vImages'])) { $numImg = count($_POST['vImages']); for($img=0;$img<$numImg;$img++) { $src = 'igep/images/noImage.png'; $file = $_POST['vImages'][$img]['valueJSONDecode']; if(file_exists($file)) { $src = $file; } $vImg['images'][] = array( 'id' => $_POST['vImages'][$img]['idCampo'], 'src' => $src ); } } } IgepDebug::setDebug(PANIC, "
    vImg ".print_r($vImg,true)."
    "); $response = json_encode( $vImg, JSON_FORCE_OBJECT ); print( $response ); die; break;*/ // REDMINE: Live Search Ajax #22982 case 'gvhLSautocomplete': $field = $_POST['gvhidcampojson']; $value = $_POST['ls_query']; $claseManejadora = $_POST['gvhclasemanejadora']; $objClase = IgepSession::damePanel( $claseManejadora ); $objClase->regenerarInstancia(); $resultado = null; if( isset($objClase->matching[$field]) ) { $query = ""; if (isset($_GET['DBSource'])) { $confLS = Config::getConfig($_GET['DBSource']); if ($confLS != null) { $value = Config::getSearchPattern($value, $confLS); $campoBD = $confLS['camposBusqueda'][0]; $headers = $confLS['headers']; $where = " (translate ( lower($campoBD),'áàéèíóòúüç','aaeeioouuc') like translate( '%$value%','áàéèíóòúüç','aaeeioouuc' )) "; $query = "{$confLS['consulta']} WHERE {$where}"; } } else { $value = Config::getConfig($field) != null ? Config::getSearchPattern($value, $field) : Config::getSearchPattern($value); $campoBD = $objClase->matching[$field]['campo']; $tablaBD = $objClase->matching[$field]['tabla']; $query = "SELECT * FROM {$tablaBD} WHERE {$campoBD} LIKE '{$value}'"; } $resultado = $objClase->consultar( $query ); $params = (new \AjaxLiveSearch\core\AjaxHandler($objClase))->getParamsToTemplate($resultado, $headers); $html = (new \AjaxLiveSearch\core\AjaxHandler($objClase))->renderView($params); $template = (new \AjaxLiveSearch\core\AjaxHandler($objClase))->formResponse('success', 'Successful request', $html); } $objClase->limpiarInstancia(); print $template; die; break; case 'gvhAutocomplete' : //Recogemos los valores $field = $_GET['field']; $value = $_GET['term']; $claseManejadora = $_GET['claseManejadora']; $objClase = IgepSession::damePanel( $claseManejadora ); $objClase->regenerarInstancia(); $resultado = null; //Primero delegamos en el programador $resultado = $objClase->setAutocomplete( $field, $value ); //Si no tiene programado nada, miramos si tiene matching if( is_null($resultado) ) { if( isset($objClase->matching[$field]) ) { $campoBD = $objClase->matching[$field]['campo']; $tablaBD = $objClase->matching[$field]['tabla']; $query = 'SELECT '.$campoBD.' as "autocomplete" FROM '.$tablaBD.' WHERE upper('.$campoBD.") like '%".strtoupper($value)."%' ORDER BY 1"; $res = $objClase->consultar( $query ); $resultado = array(); if( $res!=-1 and is_array($res) ) { foreach( $res as $row ) { $resultado[] = $row['autocomplete']; } } } } $objClase->limpiarInstancia(); $json = json_encode( $resultado ); print $json; die; break; //Acción Genérica de Igep que lanzan automáticamente los plug-ins cuando se actualiza un campo que tiene otros campos dependientes. Tipicamente las listas. case 'gvhJSRefreshUI': $this->listasDependientesJs = ''; $this->accionesInterfazJs = ''; $this->comunica->buildDataRefreshUI( $actionForm ); //$resultado = $this->calcularCamposDependientes(); //Creamos un objeto para la gestión de javascript $this->obj_IgSmarty = new IgepSmarty(); //Recogemos los datos del comunicacion $datosCampoDependiente = $this->comunica->dameDatos('camposDependientes'); //Descomponemos el nombre del campo origen que nos viene con prefijos $descCampoOrigen = explode('___', $datosCampoDependiente['origen']); //El campo puede tener prefijo (cam__ , ins__) o no (si está en un panel de busqueda). Si tiene prefijo count(descCampoOrigen)>1 sino no if( is_array($descCampoOrigen) && (count($descCampoOrigen)>1) ) { $campoOrigen = $descCampoOrigen[1]; } else { $campoOrigen = $descCampoOrigen[0]; } //Obtenemos los campos destino de la validación $destinos = explode( "," , $datosCampoDependiente['destino'] ); $destinosAdaptados = array(); foreach( $destinos as $indice => $dest ) { $destinosAdaptados[$indice] = str_replace( $campoOrigen, trim($dest), $datosCampoDependiente['origen'] ); } if( IgepSession::existePanel($datosCampoDependiente['claseManejadora']) ) { //Hacemos la nueva conexión. $objPanel = IgepSession::damePanel( $datosCampoDependiente['claseManejadora'] ); //si necesitamos dsn para regenerar lo obtenemos if( method_exists($objPanel,'getDSN') ) { $dsn = $objPanel->getDSN(); } $objPanel->regenerarInstancia( $dsn ); $objPanel->comunica = new IgepComunicacion( $objPanel->v_descCamposPanel ); $objPanel->comunica->setPanel( $_REQUEST['gvhpanel'] ); $objPanel->comunica->data2Arrays(); $objPanel->comunica->setOperation( 'visibles' ); $objPanel->comunica->posicionarEnTupla( $datosCampoDependiente['registroActivo'] ); //Si actualizamos listas, tenemos que recorrer cada uno de ellas para obtener la forma en que se cargan. $this->listasDependientesJs = $objPanel->_recalcularListasDependientes( $destinos, $destinosAdaptados ); $this->obj_IgSmarty->addPreScript( $this->listasDependientesJs ); //Ahora comprobamos si el campo origen tiene una validación. En este caso ejecutaremos la función de validación correspondiente // REDMINE #23367 $this->accionesInterfazJs = $objPanel->_accionesInterfaz( $campoOrigen, $datosCampoDependiente['origen'], $datosCampoDependiente['gvhPaginando'] ); // REDMINE #23143 if (!empty($this->accionesInterfazJs)) { $this->obj_IgSmarty->addPostScript( $this->accionesInterfazJs ); } //Por el paso a PHP5 tenemos que eliminar la referencia del mensaje. $objPanel->obj_mensaje=null; $objPanel->limpiarInstancia(); unset( $objPanel ); } //Arreglamos los destinos IgepSession::guardaVariable( 'camposDependientes', 'formulario', $datosCampoDependiente['formulario'] ); IgepSession::guardaVariable( 'camposDependientes', 'origen', $datosCampoDependiente['origen'] ); IgepSession::guardaVariable( 'camposDependientes', 'obj_jsOculto', $this->obj_IgSmarty ); $jsLoadScript = $this->listasDependientesJs; $jsLoadScript .= $this->accionesInterfazJs; $params = array ( 'path' => '' , 'context' => array( 'targetType' => 'self' , 'action' => 'NoAction', 'script' => "$jsLoadScript" ) ); $response = json_encode( $params, JSON_FORCE_OBJECT ); print( $response );die; /*$this->comunica->buildDataRefreshUI( $actionForm ); $resultado = $this->calcularCamposDependientes(); $jsLoadScript = $this->listasDependientesJs; $jsLoadScript .= $this->accionesInterfazJs; ob_clean(); $params = array ( 'path' => '' , 'context' => array( 'targetType' => 'self' , 'action' => 'NoAction' , 'script' => "$jsLoadScript" ) ); $response = json_encode( $params, JSON_FORCE_OBJECT ); print( $response );die;*/ break; case 'gvhChangeLanguage': //Cambiamos el idioma $conf = ConfigFramework::getConfig(); $lang = $_REQUEST['lang']; $lang = str_replace( "'" , "''", $lang ); $conf->setLanguage( $lang ); // Borramos la variable de los menús para que se generen con el idioma elegido // REDMINE #23193 IgepSession::borraVariable('global', 'menuPHP'); IgepSession::borraVariable('global', 'menuModulos'); IgepSession::borraVariable('global', 'menuHerramientas'); IgepSession::borraVariable('global', 'menuAdministracion'); //Se debe cargar de nuvo el AppMainWindow $principal = new AppMainWindow(); IgepSession::_guardaPanelIgep( 'principal', $principal ); //$actionForward = $actionMapping->get( 'gvHidraSuccess' ); ob_clean(); $params = array ( 'path' => '' , 'context' => array( 'targetType' => 'self' , 'action' => 'reload' ) ); $response = json_encode( $params, JSON_FORCE_OBJECT ); print( $response ); die; break; case 'gvhChangeCustom': //Cambiamos el custom $conf = ConfigFramework::getConfig(); $logStatus = $conf->getLogStatus(); $logJSStatus = $conf->getLogJSStatus(); $custom = $_REQUEST['custom']; //TODO: el parámetro es uno de los de la lista $conf->setCustomDirName( $custom ); global $s; $s = new Smarty_Phrame(); $s->clear_compiled_tpl(); ob_clean(); $conf->setLogStatus($logStatus); $conf->setLogJSStatus($logJSStatus); $params = array ( 'path' => '' , 'context' => array( 'targetType' => 'self' , 'action' => 'reload' ) ); $response = json_encode( $params, JSON_FORCE_OBJECT ); print( $response ); die; break; // REDMINE #23002 Ventana LiveSearch /*case 'abrirVentanaLiveSearch': $this->comunica->construirArrayAbrirVentanaLiveSearch( $actionForm ); $actionForward = $this->abrirVentanaLiveSearch( $actionMapping ); break;*/ case 'buscarVentanaLiveSearch': // Parámetros que se envían a través del ajax live search $field = $_POST['gvhidcampojson']; $idField = $_POST['id']; $value = $_POST['ls_query']; $claseM = $_POST['gvhclasemanejadora']; // Obtenemos el objeto correspondiente a la clase manejadora del panel $objClase = IgepSession::damePanel( $claseM ); $objClase->regenerarInstancia(); $resultado = null; // En el objeto de la clase se encuentra la zona [claseM]['v_ventanasLiveSearch'] //IgepDebug::setDebug(PANIC, "
    1) Acción buscarVentanaLiveSearch para el campo $field
    "); //IgepDebug::setDebug(PANIC, "
    2) En el objeto de la clase $claseM se encuentra la definición del liveSearch [$claseM]['v_ventanasLiveSearch']
    "); // El campo existe en el objeto de la clase? /*if( isset($objClase->matching[$field]) ) {*/ //IgepDebug::setDebug(PANIC, "
    3) El campo $field se encuentra en la zona de matching de la clase $claseM 
    "); $this->comunica->construirArrayAbrirVentanaLiveSearch( $field, $idField, $value, $claseM ); $actionForward = $this->abrirVentanaLiveSearch( $actionMapping ); $coleccionVentanas = IgepSession::dameVariable( $claseM, 'v_ventanasLiveSearch' ); //IgepDebug::setDebug(PANIC, "
    11) coleccionVentanas: ".print_r($coleccionVentanas,true)."
    "); $datosVentana = IgepSession::damePanel('ventanaLiveSearch'); //IgepDebug::setDebug(PANIC, "
    12) Obtener los datos de la ventana con damePanel: ".print_r($datosVentana,true)."
    "); $vLS = $coleccionVentanas[$field]; $defVLiveSearch = $vLS->getDescripcionVentana(); //IgepDebug::setDebug(PANIC, "
    13) De la colección de ventanas obtener la estructura de la de $field: ".print_r($defVLiveSearch,true)."
    "); $headers = $defVLiveSearch['headers']; $resultado = $datosVentana['resultado']; $matching = $defVLiveSearch['matching']; $params = array ( 'path' => '' , 'context' => array( 'targetType' => 'self' , 'action' => 'WLiveSearch' , 'resultado' => $resultado, 'matching' => $matching ) ); $response = json_encode( $params, JSON_FORCE_OBJECT ); $params = (new \AjaxLiveSearch\core\AjaxHandler($objClase))->getParamsToTemplate($resultado, $headers, $matching); /* $params = [ 'headers' => $headers, 'rows' => $rows, 'number_of_results' => $numItems, 'total_pages' => $pagesNumber ]; */ $html = (new \AjaxLiveSearch\core\AjaxHandler($objClase))->renderView($params); /* $html = [ 'headers' => $html['headers'], 'rows' => $html['rows'], 'number_of_results' => $number_of_results, 'total_pages' => $total_pages ]; */ $template = (new \AjaxLiveSearch\core\AjaxHandler($objClase))->formResponse('success', 'Successful request', $html); /* $template = json_encode([ 'status' => $status, 'message' => $msg, 'result' => [ 'headers' => $html['headers'], 'rows' => $html['rows'], 'number_of_results' => $number_of_results, 'total_pages' => $total_pages ]; ]); */ $objClase->limpiarInstancia(); print( $template );die; //} break; case 'abrirVentanaSeleccion': $this->comunica->construirArrayAbrirVentanaSeleccion( $actionForm ); $actionForward = $this->abrirVentanaSeleccion( $actionMapping ); break; //Acción Genérica de Igep que se lanza al pulsar al botón de búsqueda en la ventana de selección (la lupa). case 'buscarVentanaSeleccion': $this->comunica->construirArrayBuscarVentanaSeleccion( $actionForm ); $this->buscarVentanaSeleccion(); $actionForward = $actionMapping->get( 'IgepVentanaSeleccion' ); break; case 'ordenarTabla': $this->comunica->construirArrayOrdenarTabla( $actionForm ); $datosOrdenacion = $this->comunica->dameDatos( 'ordenarTabla' ); $idVentana = $datosOrdenacion['idVentana']; $columna = $datosOrdenacion['columna']; $orden = (empty($datosOrdenacion['orden']) ? 'desc' : $datosOrdenacion['orden']); $nombreClaseManejadora = $datosOrdenacion['claseManejadora']; $objClase = IgepSession::damePanel( $nombreClaseManejadora ); $objClase->regenerarInstancia(); //Guardamos el modo de ordenación $objClase->v_ordenCamposPanel = array(); if( !empty ($columna)) { $objClase->v_ordenCamposPanel[$columna] = $orden; } //Recuperamos el tipo de la columna de ordenación $tipo = $objClase->v_descCamposPanel[$columna]['tipo']; //Recogemos los datos a ordenar $cursor = $objClase->getResultForSearch(); $this->ordenarCursor( $cursor, $columna, $tipo, $orden ); $objClase->setResultForSearch( $cursor ); $objClase->limpiarInstancia(); ob_clean(); header( "Cache-Control: no-store, no-cache, must-revalidate, max-age=0" ); header( "Cache-Control: post-check=0, pre-check=0", false ); header( "Pragma: no-cache" ); // REDMINE #23340 $columnBD = $objClase->matching[$columna]['campo']; if ( !empty($idVentana)) { $params = array ( 'path' => '', 'context' => array( 'targetType' => 'JDialog' , 'action' => 'gvHidraOpenJDialog' , 'claseM' => $nombreClaseManejadora , 'idVentana' => $idVentana, 'orderByColumn' => $columnBD, 'orderBy' => $orden ) ); } else { $params = array ( 'path' => '' , 'context' => array( 'targetType' => 'self' , 'action' => 'reload', 'orderByColumn' => $columnBD, 'orderBy' => $orden ) , ); } $response = json_encode( $params, JSON_FORCE_OBJECT ); echo $response; ob_flush(); die; break; case 'IgepSaltoVentana': case 'IgepRegresoVentana': $nombreClase = $_REQUEST['claseManejadora']; $nomForm = $_REQUEST['formActua']; $idBtnCompleto = $_REQUEST['idBtn']; $gvhpanel = $_REQUEST['gvhpanel']; $idVentana = ''; if (isset($_REQUEST['idVentana'])) { $idVentana = $_REQUEST['idVentana']; } $objClase = IgepSession::damePanel( $nombreClase ); $objClase->regenerarInstancia(); //Creamos el objDatos $objClase->comunica = new IgepComunicacion( $objClase->v_descCamposPanel ); $objClase->comunica->data2Arrays(); $objClase->comunica->setPanel( $gvhpanel ); //Comprobamos si el salto está sobre ventana modal, en cuyo caso marcamos la clase como modal. if( $objClase->isModal() ) { $this->setModal(true); } $comunicaUsuario = new IgepComunicaUsuario( $objClase->comunica, $objClase->v_preInsercionDatos, $objClase->v_listas ); //Validamos los campos antes de saltar $checkForm = $objClase->comunica->getCheckForm(); if( $checkForm != 0 ) { $validacionIgep = $objClase->comunica->checkDataTypes(); if( $validacionIgep != '0' ) { $objClase->showMessage( 'IGEP-17', array($validacionIgep) ); $actionForward = new ActionForward( 'gvHidraNoAction' ); $actionForward->put( 'IGEPclaseManejadora', $nombreClase ); return $actionForward; } } //Obtenemos el objSalto if( $str_accion == 'IgepSaltoVentana' ) { // REDMINE #23302 if ((isset($_REQUEST['wizard'])) && ($_REQUEST['wizard'])) { $salto = gvHidraWizardForm_DB::dameOrigenWizard(); $salto->setId( $idBtnCompleto ); } else { $salto = new IgepSalto( $nombreClase, $_REQUEST['idBotonSalto'] ); } $salto->setBtnId( $idBtnCompleto ); $salto->setNameSourcePanel( $gvhpanel ); $resultadoSalto = $objClase->saltoDeVentana( $comunicaUsuario, $salto ); } else { $salto = IgepSession::dameSalto(); $salto->setId( $_REQUEST['idBotonSalto'] ); $resultadoSalto = $objClase->regresoAVentana( $comunicaUsuario, $salto ); } if (!empty ($idVentana) && !$salto->isModal()) { $salto->setIdModal ($idVentana); } if( $resultadoSalto==0 ) { //Guardamos datos del salto IgepSession::guardaSalto( $salto ); $actionForward = $actionMapping->get('IgepSaltoVentana'); //Si es una vuelta borramos el panel origen if( $str_accion == 'IgepRegresoVentana') { if( $salto->isModal() ) { $this->obj_IgSmarty = new IgepSmarty(); //$salto->js = IgepSmarty::getJsCloseModalWindow(); //$this->obj_IgSmarty->addPreScript( $salto->js ); $this->setCloseModalWindow( true ); IgepSession::guardaVariable( IgepSession::GVHIDRA_JUMP,'obj_jsOculto', $this->obj_IgSmarty ); $actionForward = $actionMapping->get( 'gvHidraCloseJDialog' ); $returnPath = ''; $width = ''; $height = ''; if( is_object($salto )) { $returnPath = $salto->getDestinoVuelta(); $claseManejadoraRetorno = $salto->getNameSourceClass(); $actionForward->put( 'IGEPclaseManejadora', $salto->getClaseDestino() ); $panelRetorno = $salto->getNameSourcePanel(); $actionForward->put( 'IGEPpanelRetorno', $panelRetorno ); $idModal = $salto->getIdModal(); $actionForward->put( 'IGEPmodalID', $idModal ); $returnPath.= '&claseManejadora='.$claseManejadoraRetorno.'&gvhpanel='.$panelRetorno; $actionForward->put( 'IGEPSaltoDestinoVuelta', $returnPath ); } } else { $idModal = $salto->getIdModal(); if (!empty ($idModal)) { $actionForward->put( 'IGEPmodalID', $idModal ); } IgepSession::borraPanel( $nombreClase ); $actionForward->put( 'IGEPaccionDestinoSalto', $salto->getDestinoVuelta() ); } } else { /************ MODAL *********************/ //Comprobamos si es un salto modal o no //Es un salto if( $salto->isModal() ) { //Si es modal $salto->setForm( $nomForm ); $actionForwardSalto = new ActionForward( 'saltoModal' ); $actionForwardSalto->setPath( $salto->getDestinoIda() ); //$path = $actionForwardSalto->getPath(); //Si viene de un salto almacenamos los datos para la accion de retorno $actionForward = $actionMapping->get( 'IgepSaltoVentanaModal' ); $actionForward->put( 'IGEPaccionDestinoSalto', $salto->getDestinoIda() ); $actionForward->put( 'IGEPclaseManejadora', $salto->getClaseDestino() ); $actionForward->put( 'IGEPaccionDestinoVueltaSalto', $salto->getDestinoVuelta() ); $returnPath = ''; $width = ''; $height = ''; if( is_object($salto) ) { $idModal = $salto->getIdModal(); $actionForward->put( 'IGEPmodalID', $idModal ); $width = $salto->getWidthModal(); $height = $salto->getHeightModal(); $actionForward->put( 'IGEPmodalWidth', $width ); $actionForward->put( 'IGEPmodalHeight', $height ); } } else { $idModal = $salto->getIdModal(); if (!empty ($idModal)) { $actionForward->put( 'IGEPmodalID', $idModal ); } $actionForward->put( 'IGEPaccionDestinoSalto', $salto->getDestinoIda() ); } /************ MODAL *********************/ } } else { if( is_object($resultadoSalto) ) { $actionForward = $resultadoSalto; } else { $actionForward = new ActionForward( 'gvHidraNoAction' ); $actionForward->put( 'IGEPclaseManejadora', $nombreClase ); } } break; case 'cambiarPanelDetalle': $nombreClaseMaestro = $_REQUEST['claseManejadoraPadre']; $nombreClaseDetalle = $_REQUEST['claseManejadora']; $panel = (array_key_exists ('gvhpanel', $_REQUEST) ? $_REQUEST['gvhpanel'] : null); $idVentana = (array_key_exists ('idVentana', $_REQUEST) ? $_REQUEST['idVentana'] : null); $objClaseMaestro = IgepSession::damePanel( $nombreClaseMaestro ); $objClaseMaestro->regenerarInstancia(); //// Si cambiamos de panel detalle, borramos el anterior panel. //if (!empty ($objClaseMaestro->panelDetalleActivo) // && $objClaseMaestro->panelDetalleActivo != $nombreClaseDetalle) //{ // IgepSession::borraPanel ($objClaseMaestro->panelDetalleActivo); //} $objClaseMaestro->panelDetalleActivo = $nombreClaseDetalle; IgepSession::borraVariable( $nombreClaseDetalle, 'obj_ultimaConsulta' ); if ($panel == 'edi' && isset ($objClaseMaestro->obj_ultimaEdicion)){ $m_datos = $objClaseMaestro->getResultForEdit(); } else { $m_datos = $objClaseMaestro->getResultForSearch(); } $tupla = array( $m_datos[$objClaseMaestro->int_filaActual] ); $res = $objClaseMaestro->buildQueryDetails( $tupla ); $objClaseMaestro->limpiarInstancia(); $objeto = IgepSession::damePanel($nombreClaseDetalle); $jsLoadScript = ''; //Recuperamos mensaje if(IgepSession::existeMensaje($nombreClaseDetalle)) { $mensaje = IgepSession::dameMensaje($nombreClaseDetalle); $jsLoadScript .= gvHidraUTF8::toUTF8(IgepSmarty::getJsMensaje($mensaje)); IgepSession::borraMensaje($nombreClaseDetalle); }; //Recuperamos scripts if(isset($objeto->obj_IgSmarty) and is_object($objeto->obj_IgSmarty)) { $jsLoadScript .= $objeto->obj_IgSmarty->getScriptLoad(false); } ob_clean(); header( "Cache-Control: no-store, no-cache, must-revalidate, max-age=0" ); header( "Cache-Control: post-check=0, pre-check=0", false ); header( "Pragma: no-cache"); if ( !empty($idVentana)) { // REDMINE #23195 if(IgepSession::existeMensaje($nombreClaseDetalle)) { IgepSession::borraMensaje($nombreClaseDetalle); } $params = array ( 'path' => '', 'context' => array( 'targetType' => 'JDialog' , 'action' => 'gvHidraOpenJDialog' , 'claseM' => $nombreClaseDetalle , 'idVentana' => $idVentana , 'script' => $jsLoadScript , ) ); } else { // REDMINE #23195 $params = array ( 'path' => '' , 'context' => array( 'targetType' => 'self' , 'action' => 'reload', 'script' => $jsLoadScript ) ); } $response = json_encode( $params, JSON_FORCE_OBJECT ); echo $response; ob_flush(); die; case 'defaultPrint': $nombreClase = $_REQUEST['claseManejadora']; $actuaSobre = $_REQUEST['actuaSobre']; $titulo = $_REQUEST['titulo']; $objClase = IgepSession::damePanel( $nombreClase ); $objClase->regenerarInstancia(); if( !isset($actuaSobre) ) { $actuaSobre = 'tabla'; } if( $actuaSobre=='ficha' ) { $data = $objClase->getResultForEdit(); } else { $data = $objClase->getResultForSearch(); } $total_registros = 0; $num_columnas = 0; $nom_columnas = array(); if (is_array($data)) { $total_registros = count($data); if (is_array($data[0])) { $num_columnas = count($data[0]); $nom_columnas = array_keys( $data[0] ); } } /*$num_columnas = count( $data[0] ); $nom_columnas = array_keys( $data[0] ); $total_registros = count( $data );*/ ob_end_clean(); ob_start(); $html = << Impresión página - $titulo cabecera; if( $actuaSobre=='ficha' ) { $html .= "\n"; $html .= "\n"; $html .= "\n"; $html .= "\n"; $html .= "\n"; foreach( $data as $index => $row ) { $html .= "\n"; $html .= "\n"; foreach( $row as $name => $value ) { $html .= "\n"; $html .= ""; $html .= "\n"; $html .= "\n"; } $html.=""; $html.="\n"; $html.="\n"; $html.="\n"; } //Contador $html .= "\n"; $html .= "\n"; $html .= "\n"; $html .= "
    $titulo
    "; if( empty($name) ) { $name = " "; } else { $name .= ': '; } $html .= $name; $html .= ""; if( empty($value) ) { $value = " "; } elseif(is_array($value)) { $value = $value['seleccionado']; } $html .= $value."
    "; $html .= "
    "; $html.= "Registro ".(++$index).""; $html.="
    Total registros: $total_registros
    \n"; $html .= "\n"; $html .= "\n"; } else { $html .= "\n"; $html .= "\n"; $html .= "\n"; $html .= "\n"; $html .= "\n"; $html .= "\n"; $html .= "\n"; $html .= "\n"; foreach( $nom_columnas as $col ) { if( empty($col) ) { $col = " "; } $html .= "\n"; } $html .= "\n"; $html .= "\n"; foreach( $data as $row ) { $html .= "\n"; $html .= "\n"; $html .= "\n"; foreach( $row as $field ) { if( empty($field) ) { $field = " "; } elseif( is_array($field) ) { $field = $field['seleccionado']; } $html .= "\n"; } $html .= "\n"; $html .= "\n"; } //Contador $html .= "\n"; $html .= "\n"; $html .= "\n"; $html .= "
    $titulo
    $col
    $field
    Total registros: $total_registros
    \n"; $html .= "\n"; $html .= "\n"; } print $html; die; break; case 'sendMail': $claseManejadora = $_REQUEST["claseManejadora"]; $mailer = IgepSession::dameVariable( $claseManejadora, gvHidraMailer::SESSION_VAR_NAME ); try { $mailer->sendByRequestObj(gvHidraMailer::getMailerRequestObj()); } catch(gvHidraException $err) { $objClase = IgepSession::damePanel($claseManejadora); $objClase->showMessage('IGEP-26', array($err->getMessage())); $actionForward = new ActionForward('gvHidraNoAction'); $actionForward->put('IGEPclaseManejadora', $claseManejadora); return $actionForward; } die; break; case 'exportCSV': $nombreClase = $_REQUEST['claseManejadora']; $actuaSobre = $_REQUEST['actuaSobre']; $objClase = IgepSession::damePanel( $nombreClase ); $objClase->regenerarInstancia(); if( !isset($actuaSobre) ) { $actuaSobre = 'tabla'; } if( $actuaSobre=='ficha' ) { $data = $objClase->getResultForEdit(); } else { $data = $objClase->getResultForSearch(); } //Vaciamos la cache del navegador ob_end_clean(); ob_start(); $nombre_fich = 'listado-'.date('d-m-H-i-s'); /* $fecha_hoy = date('d/m/Y'); //Indicamos en el header que se trata de un csv header( "Content-Type: application/soffice" ); header( 'Content-Disposition: inline; filename='.$nombre_fich.'.csv' );*/ //Cabeceras $cabeceras = array_keys( $data[0] ); $content_csv = ''; foreach( $cabeceras as $col ) { //Comprobamos si tiene etiqueta para la columna. $type = $objClase->getFieldType( $col ); if( $type!=null AND $type->getLabel()!='' ) { //echo $type->getLabel()."\t"; $content_csv .= $type->getLabel()."\t"; } else { //echo $col."\t"; $content_csv .= $col."\t"; } } //echo PHP_EOL; $content_csv .= "\r\n"; foreach( $data as $row ) { foreach( $row as $field ) { if( is_object($field) and method_exists($field,'formatUser') ) { //Comprobación de fechas //echo gvHidraUTF8::toUTF8( $field->formatUser() ); $content_csv .= gvHidraUTF8::toUTF8( $field->formatUser() ); } elseif( is_array($field) ) { //Comprobación de listas $seleccionado = $field['seleccionado']; foreach( $field['lista'] as $value ) { if( $seleccionado==$value['valor'] ) { //echo $field['seleccionado'].' '.$value['descripcion']; $content_csv .= $field['seleccionado'].' '.$value['descripcion']; } } } else { //Quitamos retorno de carro //echo str_replace( "\r\n", '', $field ); $content_csv .= str_replace( "\r\n", '', $field ); } //echo "\t"; $content_csv .= "\t"; } //echo PHP_EOL; $content_csv .= "\r\n"; } //Vaciamos la cache //ob_end_flush(); //Ponemos este die para que corte la ejecución y no redireccione la pagina $params = array ( 'path' => '' , 'context' => array( 'targetType' => 'self' , 'action' => 'exportCSV' ) , 'csv' => array( 'content' => $content_csv, 'filename' => $nombre_fich.".csv" ) ); $response = json_encode( $params, JSON_FORCE_OBJECT ); echo $response; ob_flush(); die; break; default: die( 'Error: La acción '.$str_accion.' no se reconoce.' ); break; }//Fin switch return $actionForward; }// Fin de perform /*------------------------ METODOS DE LAS ACCIONES ------------------------*/ public function mimeTypes($nombreFichero) { //Vector de tipos MIME $mime_types = array ( 'txt' => 'text/plain', 'htm' => 'text/html', 'html' => 'text/html', 'php' => 'text/html', 'css' => 'text/css', 'js' => 'application/javascript', 'json' => 'application/json', 'xml' => 'application/xml', 'swf' => 'application/x-shockwave-flash', 'flv' => 'video/x-flv', // images 'png' => 'image/png', 'jpe' => 'image/jpeg', 'jpeg' => 'image/jpeg', 'jpg' => 'image/jpeg', 'gif' => 'image/gif', 'bmp' => 'image/bmp', 'ico' => 'image/vnd.microsoft.icon', 'tiff' => 'image/tiff', 'tif' => 'image/tiff', 'svg' => 'image/svg+xml', 'svgz' => 'image/svg+xml', // archives 'zip' => 'application/zip', 'rar' => 'application/x-rar-compressed', 'exe' => 'application/x-msdownload', 'msi' => 'application/x-msdownload', 'cab' => 'application/vnd.ms-cab-compressed', // audio/video 'mp3' => 'audio/mpeg', 'qt' => 'video/quicktime', 'mov' => 'video/quicktime', // adobe 'pdf' => 'application/pdf', 'psd' => 'image/vnd.adobe.photoshop', 'ai' => 'application/postscript', 'eps' => 'application/postscript', 'ps' => 'application/postscript', // ms office 'doc' => 'application/msword', 'docx' => 'application/msword', 'rtf' => 'application/rtf', 'xls' => 'application/vnd.ms-excel', 'xlsx' => 'application/vnd.ms-excel', 'ppt' => 'application/vnd.ms-powerpoint', 'pptx' => 'application/vnd.ms-powerpoint', // open office 'odt' => 'application/vnd.oasis.opendocument.text', 'ods' => 'application/vnd.oasis.opendocument.spreadsheet', ); //Extensión del fichero $ext = trim(strtolower(array_pop(explode('.',$nombreFichero)))); $tipo = null; //Si la extensión se contempla en nuestro vector de tipos... if (array_key_exists($ext, $mime_types)) { $tipo = $mime_types[$ext]; } elseif (function_exists('finfo_open')) //Si no está y existe finfo_open { $finfo = finfo_open(FILEINFO_MIME); $mimetype = finfo_file($finfo, $nombreFichero); finfo_close($finfo); $tipo = $mimetype; } elseif(function_exists('mime_content_type'))//si no probamos con mime_content_type { $tipo = mime_content_type($nombreFichero); } else //En cualquier otor caso, lo servimos como binario... { $tipo = 'application/octet-stream'; } return $tipo; } /** * Método encargado de realizar la recarga dinamica de las listas Dependientes. */ public function calcularCamposDependientes() { //Creamos un objeto para la gestión de javascript $this->obj_IgSmarty = new IgepSmarty(); //Recogemos los datos del comunicacion $datosCampoDependiente = $this->comunica->dameDatos('camposDependientes'); //Descomponemos el nombre del campo origen que nos viene con prefijos $descCampoOrigen = explode('___', $datosCampoDependiente['origen']); //El campo puede tener prefijo (cam__ , ins__) o no (si está en un panel de busqueda). Si tiene prefijo count(descCampoOrigen)>1 sino no if( is_array($descCampoOrigen) && (count($descCampoOrigen)>1) ) { $campoOrigen = $descCampoOrigen[1]; } else { $campoOrigen = $descCampoOrigen[0]; } //Obtenemos los campos destino de la validación $destinos = explode( "," , $datosCampoDependiente['destino'] ); $destinosAdaptados = array(); foreach( $destinos as $indice => $dest ) { $destinosAdaptados[$indice] = str_replace( $campoOrigen, trim($dest), $datosCampoDependiente['origen'] ); } if( IgepSession::existePanel($datosCampoDependiente['claseManejadora']) ) { //Hacemos la nueva conexión. $objPanel = IgepSession::damePanel( $datosCampoDependiente['claseManejadora'] ); //si necesitamos dsn para regenerar lo obtenemos if( method_exists($objPanel,'getDSN') ) { $dsn = $objPanel->getDSN(); } $objPanel->regenerarInstancia( $dsn ); $objPanel->comunica = new IgepComunicacion( $objPanel->v_descCamposPanel ); $objPanel->comunica->setPanel( $_REQUEST['gvhpanel'] ); $objPanel->comunica->data2Arrays(); $objPanel->comunica->setOperation( 'visibles' ); $objPanel->comunica->posicionarEnTupla( $datosCampoDependiente['registroActivo'] ); //Validamos los campos antes de saltar // TODO: 02-09-2009. Toni: Validacion de datos en acciones de interfaz // Este codigo permite validar los datos al entrar en una accion de interfaz. // Esta comentado porque provoca efectos no deseados. Bloque la interfaz y no // deja que se ejectuen el resto de acciondes de interfaz. /* $validacionIgep = $objPanel->comunica->checkDataTypes(); if( $validacionIgep!= '0' ) { $jsMensajeError =IgepSmarty::getJsMensaje( new IgepMensaje('IGEP-17', array($validacionIgep)) ); $this->obj_IgSmarty->addPostScript( $jsMensajeError ); } else { */ //Si actualizamos listas, tenemos que recorrer cada uno de ellas para obtener la forma en que se cargan. $this->listasDependientesJs = $objPanel->_recalcularListasDependientes( $destinos, $destinosAdaptados ); $this->obj_IgSmarty->addPreScript( $this->listasDependientesJs ); //Ahora comprobamos si el campo origen tiene una validación. En este caso ejecutaremos la función de validación correspondiente $this->accionesInterfazJs = $objPanel->_accionesInterfaz( $campoOrigen, $datosCampoDependiente['origen'], $datosCampoDependiente['gvhPaginando'] ); $this->obj_IgSmarty->addPostScript( $this->accionesInterfazJs ); //Por el paso a PHP5 tenemos que eliminar la referencia del mensaje. $objPanel->obj_mensaje=null; // } $objPanel->limpiarInstancia(); unset( $objPanel ); } //Arreglamos los destinos IgepSession::guardaVariable( 'camposDependientes', 'formulario', $datosCampoDependiente['formulario'] ); IgepSession::guardaVariable( 'camposDependientes', 'origen', $datosCampoDependiente['origen'] ); IgepSession::guardaVariable( 'camposDependientes', 'obj_jsOculto', $this->obj_IgSmarty ); return 0; } //Fin de calcularCamposDependientes /** * Método encargado de realizar las operaciones necesarias para la fase de apertura de una ventana de Selección * * @param ActionMapping $actionMapping */ public function abrirVentanaSeleccion( $actionMapping ) { $datosVentana = $this->comunica->dameDatos( 'abrirVentanaSeleccion' ); $coleccionVentanas = IgepSession::dameVariable( $datosVentana['claseManejadora'], 'v_ventanasSeleccion' ); $actionForward = $actionMapping->get( 'IgepVentanaSeleccion' ); if( isset($coleccionVentanas[$datosVentana['nomCampo']]) ) { $size = $coleccionVentanas[$datosVentana['nomCampo']]->getWindowSize(); $coleccionVentanas[$datosVentana['nomCampo']]->abrirVentanaSeleccion( $datosVentana ); $coleccionVentanas[$datosVentana['nomCampo']]->buscarVentanaSeleccion( $datosVentana, $this->obj_errorNegocio ); $actionForward->put( 'IGEPmodalWidth' , $size['width'] ); $actionForward->put( 'IGEPmodalHeight', $size['height'] ); } else { $panelVentanaSeleccion = array(); $panelVentanaSeleccion['mensaje'] = new IgepMensaje( 'IGEP-19', array($datosVentana['nomCampo'],$datosVentana['claseManejadora']) ); IgepSession::_guardaPanelIgep( 'ventanaSeleccion', $panelVentanaSeleccion ); } return $actionForward; } /** * Método encargado de realizar las operaciones necesarias para la fase de busqueda de una ventana de Selección * * @return int */ public function buscarVentanaSeleccion() { $datosVentana = $this->comunica->dameDatos( 'abrirVentanaSeleccion' ); $coleccionVentanas = IgepSession::dameVariable( $datosVentana['claseManejadora'], 'v_ventanasSeleccion' ); if( isset($coleccionVentanas[$datosVentana['nomCampo']]) ) { $coleccionVentanas[$datosVentana['nomCampo']]->buscarVentanaSeleccion( $datosVentana ); } return 0; } /** * Método encargado de realizar las operaciones necesarias para la fase de apertura de una ventana Live Search * * @param ActionMapping $actionMapping * REDMINE #23002 Ventana Live Search */ public function abrirVentanaLiveSearch( $actionMapping ) { // Acción de retorno. Views que se debe ejecutar $actionForward = $actionMapping->get( 'IgepVentanaLiveSearch' ); // Obtenemos datos de inicio $datosVentana = $this->comunica->dameDatos( 'abrirVentanaLiveSearch' ); // Obtenemos todas las ventanas tipo LIVE SEARCH que se han definido para la clase manejadora $claseM = $datosVentana['claseManejadora']; $coleccionVentanas = IgepSession::dameVariable( $claseM, 'v_ventanasLiveSearch' ); // Comprobamos que la definición LIVE SEARCH para el campo que nos interesa, "nomCampo", está definida if( isset($coleccionVentanas[$datosVentana['nomCampo']]) ) { $coleccionVentanas[$datosVentana['nomCampo']]->abrirVentanaLiveSearch( $datosVentana ); $coleccionVentanas[$datosVentana['nomCampo']]->buscarVentanaLiveSearch( $datosVentana, $this->obj_errorNegocio ); } else { $panelVentanaLiveSearch = array(); $panelVentanaLiveSearch['mensaje'] = new IgepMensaje( 'IGEP-19', array($datosVentana['nomCampo'],$datosVentana['claseManejadora']) ); IgepSession::_guardaPanelIgep( 'ventanaLiveSearch', $panelVentanaLiveSearch); } return $actionForward; } /** * Método encargado de realizar las operaciones necesarias para la fase de busqueda de una ventana de Selección * * @return int * REDMINE #23002 Ventana Live Search */ public function buscarVentanaLiveSearch() { /* Obtenemos los datos de la ventana padre, necesarios para la ventana Live Search, y el valor introducido en el campo a buscar Array () = ( [nomCampo] => fil_LS_dcentro [filaActual] => 0 [panelActua] => fil [claseManejadora] => ParametrosCampos [actionOrigen] => [modoPanelOrigen] => W [valor] => terr ) */ $datosInicialesLS = $this->comunica->dameDatos( 'buscarVentanaLiveSearch' ); // IgepDebug::setDebug(DEBUG_IGEP,'
    buscarVentanaLiveSearch() DATOS INICIALES - '.print_r($datosInicialesLS,true)."
    "); /* Estructura de live search definido en el constructor de la clase manejadora addLiveSearchWindow() [fil_LS_dcentro] => gvHidraLiveSearchWindow Object ( ['DBSource'] => 'VAI_centros' ['class'] => ['camposBusqueda'] => Array ( [0] => tinv_centros.dcentro ) ['consulta'] => ['orden'] => ['queryMode'] => ['matching'] => Array( ['fieldsTPL'] => Array ( [0] => fil_LS_dcentro [1] => fil_ccentro ) [fieldsSource] => Array ( [0] => dcentro [1] => ccentro ) ) ['templateSource'] => array(); ['headers'] => array( [ccentro] => Código [dcentro] => Centro [lugar] => Ubicación ) ['rowsNumber'] => array(); ['size'] => array(); ) */ $coleccionVentanas = IgepSession::dameVariable( $datosInicialesLS['claseManejadora'], 'v_ventanasLiveSearch' ); // IgepDebug::setDebug(DEBUG_IGEP,'buscarVentanaLiveSearch() coleccionVentanas - '.print_r($coleccionVentanas,true)); $valor = $datosInicialesLS['valor']; $id_LS = $datosInicialesLS['nomCampo']; $claseMOrigen = $datosInicialesLS['claseManejadora']; // VERO: Necesito saber los carácteres q se van introduciendo if( isset($coleccionVentanas[$id_LS]) ) { // Objeto de la clase gvHidraLiveSearchWindow -> ejecutamos su método buscarVentanaLiveSearch() //$coleccionVentanas[$id_LS]->buscarVentanaLiveSearch( $coleccionVentanas[$id_LS], $claseMOrigen, $valor ); $coleccionVentanas[$id_LS]->buscarVentanaLiveSearch( $datosInicialesLS ); } return 0; } /** * Funcion que ordena cursores (vectores de registros) * por la clave que se indique por argumento y de forma * ascedente o descendente. * TODO: * Si no se define el tipo en v_descCampos, se puede intentar obtener el tipo * a partir del valor de la primera fila * Esta funcion solo se llama desde IgepAccionesGenericas donde no se * inicializa el dsn, luego de momento no se pueden obtener fechas ni numeros * si no se han declarado * * @private * @param array $cursor * @param string $clave * @param string $tipo * @param string $orden */ private function ordenarCursor( & $cursor, $clave, $tipo, $orden = 'asc') { if (is_array($cursor) && (count($cursor) < 2)) { return; } //Inicializacion de variables $vectorClave = array (); $cursorOrdenado = array (); $es_numero = ($tipo==TIPO_DECIMAL OR $tipo==TIPO_ENTERO); $es_fecha = ($tipo==TIPO_FECHA OR $tipo==TIPO_FECHAHORA); if( $es_fecha ) { $tipoOrdenacion = SORT_REGULAR; } elseif( $es_numero ) { $tipoOrdenacion = SORT_NUMERIC; } else { $tipoOrdenacion = SORT_STRING; } foreach( $cursor as $fila => $valor ) { $vectorClave[$fila] = $valor[$clave]; } if( $tipoOrdenacion == SORT_STRING ) { if ( is_array($vectorClave) && (count($vectorClave) == count($vectorClave, COUNT_RECURSIVE)) ) { function fnCustomComparer ($a, $b) { $a = iconv ('UTF-8', 'ASCII//TRANSLIT//IGNORE', $a); $b = iconv ('UTF-8', 'ASCII//TRANSLIT//IGNORE', $b); return strcasecmp($a, $b); } // Para ordenar sin distinguir entre mayúsculas y minúsculas //uasort( $vectorClave, 'strcasecmp' ); uasort( $vectorClave, 'fnCustomComparer' ); if( strtolower($orden) != 'asc' ) // Reverse para ordenación descendente $vectorClave = array_reverse( $vectorClave, true ); } else { // Ordenamos por campo tipo lista if( strtolower($orden) == 'asc' ) { uasort( $vectorClave, array(__CLASS__,'sortBySelectedAsc') ); } else { uasort( $vectorClave, array(__CLASS__,'sortBySelectedDesc') ); } } } else { if( strtolower($orden) == 'asc' ) { asort( $vectorClave, $tipoOrdenacion ); } else { arsort( $vectorClave, $tipoOrdenacion ); } } foreach( $vectorClave as $fila => $valor ) { $cursorOrdenado[] = $cursor[$fila]; } $cursor = $cursorOrdenado; } private static function sortBySelectedAsc($a, $b) { if( $a['seleccionado'] == $b['seleccionado'] ) { return 0; } return ($a['seleccionado'] < $b['seleccionado']) ? -1 : 1; } private static function sortBySelectedDesc($a, $b) { if( $a['seleccionado'] == $b['seleccionado'] ) { return 0; } return ($a['seleccionado'] > $b['seleccionado']) ? -1 : 1; } /** * Método isModal * * @return boolean */ public final function isModal() { return $this->_modal; } /** * Método setModal * * @param boolean $value */ public final function setModal( $value ) { $this->_modal = $value; } /** * Método getCloseModalWindow * * @return boolean */ public function getCloseModalWindow() { return $this->_closeModal; } /** * Método setCloseModalWindow * * @param boolean $value */ public function setCloseModalWindow( $value ) { $this->_closeModal = $value; } } //End IgepAccionesGenericas