Last active
August 31, 2020 17:12
-
-
Save joelmiguelvalente/a69b34d3e20a53bb19f5001599dbea5f to your computer and use it in GitHub Desktop.
Ajax buscador
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php if ( ! defined('TS_HEADER')) exit('No se permite el acceso directo al script'); | |
/** | |
* Controlador AJAX | |
* | |
* @name ajax.buscador.php | |
* @author Miguel92 | |
*/ | |
/**********************************\ | |
* (VARIABLES POR DEFAULT) * | |
\*********************************/ | |
// NIVELES DE ACCESO Y PLANTILLAS DE CADA ACCIÓN | |
$files = array( | |
'buscador-buscar' => array('n' => 0, 'p' => 'buscar'), | |
'buscador-usuario' => array('n' => 0, 'p' => 'usuario'), | |
); | |
/**********************************\ | |
* (VARIABLES LOCALES ESTE ARCHIVO) * | |
\*********************************/ | |
// REDEFINIR VARIABLES | |
$tsPage = 'php_files/p.buscador.'.$files[$action]['p']; | |
$tsLevel = $files[$action]['n']; | |
$tsAjax = empty($files[$action]['p']) ? 1 : 0; | |
/**********************************\ | |
* (INSTRUCCIONES DE CODIGO) * | |
\*********************************/ | |
// DEPENDE EL NIVEL | |
$tsLevelMsg = $tsCore->setLevel($tsLevel, true); | |
if($tsLevelMsg != 1) { echo '0: '.$tsLevelMsg; die();} | |
// CLASE | |
include("../class/c.buscador.php"); | |
$tsBuscador = new tsBuscador(); | |
// | |
// CODIGO | |
switch($action){ | |
case 'buscador-buscar': | |
//<--- | |
$words = $tsCore->setSecure(trim($_POST['word'])); | |
$resultados = $tsBuscador->SearchAjax($words); | |
$smarty->assign('tsResultados', $resultados['data']); | |
$smarty->assign('tsWord', $words); | |
$smarty->assign('tsTotal', $resultados['total']); | |
//---> | |
break; | |
case 'buscador-usuario': | |
# Asignamos la función | |
$smarty->assign('tsListaU', $tsBuscador->BuscarUsuarios()); | |
break; | |
} | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Se realizó una actualización!