Last active
January 20, 2020 18:39
-
-
Save joelmiguelvalente/3af602f70977f78e08422e59946c790c to your computer and use it in GitHub Desktop.
Archivo de configuración que va incluido dentro de header.php
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 | |
/* | |
CONFIGURACIÓN PARA INCLUIR EN HEADER.PHP | |
* @author Miguel92 | |
* @copyright 2020 | |
*/ | |
/* | |
* ------------------------------------------------------------------- | |
* DEFINIMOS EL DIRECTORIO DE LA CARPETA TEMPLATES | |
* ------------------------------------------------------------------- | |
*/ | |
define('TS_TEMPLATES', TS_ROOT . DIRECTORY_SEPARATOR .'themes'. DIRECTORY_SEPARATOR . TS_TEMA . DIRECTORY_SEPARATOR . 'templates'); | |
/* | |
* ------------------------------------------------------------------- | |
* DEFINIMOS EL DIRECTORIO DE LA CARPETA CONFIGS | |
* ------------------------------------------------------------------- | |
*/ | |
define('TS_CONFIG', TS_ROOT . DIRECTORY_SEPARATOR .'configs'); | |
/* | |
* ------------------------------------------------------------------- | |
* DEFINIMOS EL DIRECTORIO DE LA CARPETA CACHE | |
* ------------------------------------------------------------------- | |
*/ | |
define('TS_CACHE', TS_ROOT . DIRECTORY_SEPARATOR .'configs'. DIRECTORY_SEPARATOR .'cache' . DIRECTORY_SEPARATOR . TS_TEMA); | |
/* | |
* ------------------------------------------------------------------- | |
* Acá buscamos los archivos t.{tipo}.tpl, fue realizado de esta | |
* manera para poder incluir más directorios en donde se puedan | |
* alojar los t.{tipo}.tpl, sin necesidad de crearlos en la carpeta | |
* "default/templates/". (https://www.smarty.net/docs/en/api.set.template.dir.tpl) | |
* ------------------------------------------------------------------- | |
*/ | |
$smarty->setTemplateDir(array( | |
'templates' => TS_TEMPLATES, | |
/* 'login' => TS_CONFIG . 'login', | |
'dashboard' => TS_CONFIG . 'Dashboard', | |
'mantenimiento' => TS_CONFIG . 'Mantenimiento', */ | |
)); | |
/* | |
* ------------------------------------------------------------------- | |
* CONFIGURAMOS ALGUNOS ELEMENTOS DE SMARTY | |
* ------------------------------------------------------------------- | |
*/ | |
$smarty->setCompileDir(TS_CACHE); | |
/* COMPRIME EL HTML PARA MÁS VELOCIDAD */ | |
$smarty->loadFilter('output', 'trimwhitespace'); | |
/* HABILITA SEGUIRDAD PREDETERMINADA */ | |
$smarty->enableSecurity(); | |
/* Establecer los directorios donde se almacenan los archivos de configuración, lo dejamos así porque no hemos creado directorios de configuraciones. (https://www.smarty.net/docs/en/variable.compile.dir.tpl) */ | |
$smarty->setConfigDir(array('url' => $tsCore->settings['url'],'title' => $tsCore->settings['titulo'])); | |
/* COMPROBAMOS QUE TENGA TODO OK */ | |
// $smarty->testInstall(); | |
/* | |
* ------------------------------------------------------------------- | |
* ELIMINAREMOS EL CONTENIDO DE LA CARPETA CACHE AUTOMÁTICAMENTE | |
* ------------------------------------------------------------------- | |
*/ | |
$Cache = TS_CACHE . DIRECTORY_SEPARATOR . '*'; | |
$files = glob($Cache); | |
foreach($files as $archivo){ | |
if(is_file($archivo)) unlink($archivo); | |
} | |
/* | |
* ------------------------------------------------------------------- | |
* FORZAMOS EL IDIOMA EN ESPAÑOL | |
* ------------------------------------------------------------------- | |
*/ | |
setlocale(LC_ALL, "es_ES"); | |
/* | |
* ------------------------------------------------------------------- | |
* DAMOS LA UBICACIÓN GEOGRÁFICA (https://www.php.net/manual/es/timezones.php) | |
* ------------------------------------------------------------------- | |
*/ | |
date_default_timezone_set("America/Argentina/Buenos_Aires"); | |
/* | |
* ------------------------------------------------------------------- | |
* PLUGINS ADICIONALES CREADOS POR LOS | |
* USUARIOS DE PHPOST (https://phpost.net/foro/) | |
* ------------------------------------------------------------------- | |
*/ | |
/* | |
* PLUGIN: NOBBCODE | |
* AUTOR: 1TSR4SC11 (https://www.phpost.net/foro/perfil/8214-1tsr4sc11/) | |
*/ | |
function smarty_modifier_nobbcode($nobbcode = ''){ | |
$nobbcode = preg_replace('/\[([^\]]*)\]/', '', $nobbcode); | |
$regex = "@(https?://([-\w\.]+[-\w])+(:\d+)?(/([\w/_\.#-]*(\?\S+)?[^\.\s])?)?)@"; | |
$nobbcode = preg_replace($regex, ' ', $nobbcode); | |
return $nobbcode; | |
} | |
/* | |
* PLUGIN: KMG | |
* AUTOR: KMario19 (https://www.phpost.net/foro/perfil/6266-kmario19/) | |
*/ | |
function smarty_modifier_kmg($number){ | |
$pre = 'KMG'; | |
if ($number >= 1000) { | |
for ($i=-1; $number>=1000; ++$i) { $number /= 1000; } | |
return round($number,1).$pre[$i]; | |
} else return $number; | |
} | |
/* | |
* ------------------------------------------------------------------- | |
* PLUGIN DE SMARTY QUE EXTRAÑAMENTE NO LOS TIENE ¿? | |
* ------------------------------------------------------------------- | |
*/ | |
/* NUMBER_FORMAT */ | |
function smarty_modifier_number_format($string, $decimals = 0, $dec_sep=",", $thous_sep = ".") { | |
return number_format($string,$decimals,$dec_sep,$thous_sep); | |
} | |
/* LETRACAPITAL Smarty 3 (ucfirst) */ | |
function smarty_modifier_ucfirst($string) { | |
return ucfirst($string); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment