02-16-2022, 03:36 PM
1
Para esto deben tener los temas en la carpeta "themes" y Debes agradecer para ver el contenido..., ya que utilizaremos la configuración hecha en smarty.config.php1 - Buscan en inc/class/c.admin.php
Código PHP: ( Seleccionar Todo )
/*
getTemas()
*/
function getTemas()
Arriba agregaremos lo siguiente
Código PHP: ( Seleccionar Todo )
# Buscamos los temas no instalados
public function temas_no_instalados() {
global $smarty;
# Arreglo de temas sin intalar
$no_instalado = [];
# Esto esta configurado en smarty.config.php
# Primero buscamos en la carpeta themes si hay un theme sin instalar
$themes = opendir( $smarty->template_dir["themes"] );
# Recorremos toda la carpeta de themes
while ($theme = readdir($themes)) {
if($theme != '.' && $theme != '..'):
# Obtenemos el archivo de instalacion
include $smarty->template_dir["themes"] . $theme . "/install.php";
# Ahora comprobamos si esta instalado
if(!db_exec('fetch_assoc', db_exec([__FILE__, __LINE__], "query", "SELECT tid FROM w_temas WHERE t_path = '{$theme}' LIMIT 1"))["tid"]) {
array_push($no_instalado, [
"nombre" => $tema["nombre"],
"path" => $tema["path"],
"copy" => $tema["copy"]
]);
}
endif;
}
return $no_instalado;
}
luego un poco más abajo buscamos
Código PHP: ( Seleccionar Todo )
function newTema()
{
global $tsCore;
//
$tema_path = $tsCore->setSecure($_POST['path']);
// ARCHIVO DE INSTALACION
include ("../../themes/" . $tema_path . '/install.php');
//
if (empty($tema))
return 'Revisa que la carpeta del tema sea correcta.';
foreach ($tema as $key => $val)
{
if (empty($val))
return 'El archivo de instalación del tema es incorrecto. Recuerda utilizar temas oficiales.';
else
$temadb[$key] = $tsCore->setSecure($val);
}
// NUEVO
if (db_exec(array(__FILE__, __LINE__), 'query', 'INSERT INTO `w_temas` (`t_name`, `t_url`, `t_path`, `t_copy`) VALUES (\'' .
$tsCore->setSecure($temadb['nombre']) . '\', \'' . $tsCore->setSecure($temadb['url']) .
'\', \'' . $tsCore->setSecure($tema_path) . '\', \'' . $tsCore->setSecure($temadb['copy']) .
'\')'))
return 1;
else
return 'Ocurrió un error durante la instalación. Consulta el foro ofcial de PHPost.';
}
y la reemplazaremos por
Código PHP: ( Seleccionar Todo )
public function newTema() {
global $tsCore, $smarty;
# ARCHIVO DE INSTALACION
$method = (isset($_GET["path"])) ? $_GET["path"] : $_POST["path"];
include $smarty->template_dir["themes"] . $tsCore->setSecure($method) . "/install.php";
# Instalando usando directamente el botón de "instalar tema"
$name = $tsCore->setSecure($tema['nombre']);
$path = $tsCore->setSecure($tema['path']);
$url = $tsCore->settings['url'] . '/themes/' . $path;
$copy = $tsCore->setSecure($tema['copy']);
# Si hay un problema en la carpeta
if(empty($tema)) $data["error"] = 'Revisa que la carpeta del tema sea correcta.';
# Instalamos el tema
if(db_exec([__FILE__, __LINE__], "query", "INSERT INTO w_temas (t_name, t_path, t_url, t_copy) VALUES ('{$name}', '{$path}', '{$url}', '{$copy}')")) {
return true;
} else return $data["error"] = 'Ocurrió un error durante la instalación. Consulta el foro ofcial de PHPost.';
}
2 - Ahora buscamos en inc/php/admin.php
Código PHP: ( Seleccionar Todo )
} elseif($action == 'temas'){
y debajo pegamos
Código PHP: ( Seleccionar Todo )
$tni = $tsAdmin->temas_no_instalados();
un poco más abajo buscan
Código PHP: ( Seleccionar Todo )
$smarty->assign("tsTemas",$tsAdmin->getTemas());
y debajo agregan
Código PHP: ( Seleccionar Todo )
$smarty->assign("tsNoTemas", count($tni));
más abajo buscan
Código PHP: ( Seleccionar Todo )
} elseif($act == 'nuevo'){
// GUARDAR
if(!empty($_POST['path'])) {
$install = $tsAdmin->newTema();
if($install == 1) $tsCore->redirectTo($tsCore->settings['url'].'/admin/temas?save=true');
else $smarty->assign("tsError",$install);
}
}
y debajo agregan
Código PHP: ( Seleccionar Todo )
} elseif($act == 'nuevo'){
# Primero buscamos si hay temas sin instalar
$smarty->assign("tsNoInstall", $tni);
# Guardamos
if(!empty($_POST['path']) or !empty($_GET['path'])) {
if($tsAdmin->newTema()) $tsCore->redirectTo($tsCore->settings['url'].'/admin/temas?save=true');
else $smarty->assign("tsError", $install["error"]);
}
}
3 - Ahora vamos a nuestro tema templates/admin_mods/m.admin_temas.tpl y buscamos
Código: ( Seleccionar Todo )
<div class="boxy-title">
<h3>Administrar Temas</h3>
</div>y la reemplazamos por
Código: ( Seleccionar Todo )
<div class="boxy-title" style="display: flex;justify-content: *****: center;">
<h3>Administrar Temas</h3>
{if $tsNoTemas >= 1}
<span>Hay <b>{$tsNoTemas} tema{if $tsNoTemas > 1}s{/if}</b> sin instalar</span>
{/if}
</div>luego más abajo buscamos
Código: ( Seleccionar Todo )
{elseif $tsAct == 'nuevo'}
{if $tsError}<div style="display: block;" class="mensajes error">{$tsError}</div>{/if}
<form action="" method="post" id="admin_form" autocomplete="off">
<label for="ai_path">Nombre de la carpeta donde esta el tema a instalar:<br /><i>{$tsConfig.url}/themes/</i></label> <input type="text" id="ai_path" name="path" size="30" />
<hr />
<label> </label> <input type="submit" value="Instalar tema" class="mBtn btnOk">
</form>
{/if}y lo reemplazamos por
Código: ( Seleccionar Todo )
{elseif $tsAct == 'nuevo'}
{if $tsError}<div class="alerts error">{$tsError}</div>{/if}
{if !empty($tsNoInstall)}
<h4 style="margin: 6px 0;">Temas no instalados</h4>
<p class="emptyData">Estos son temas que estan en "<u><i>{$tsConfig.url}/themes/</i></u>", pero no estan instalados en la base</p>
<form method="post" autocomplete="off">
<input type="hidden" name="manual" value="0">
{foreach $tsNoInstall key=i item=t}
<div style="display: flex;justify-content: *****: center;margin-bottom: 10px;">
<div>
<span><b>{$t.nombre}</b></span>
<span style="display: block;"><b>Carpeta</b>: {$t.path}</span>
<span><b>Autor</b>: {$t.copy}</span>
</div>
<div style="display: flex;justify-content: *****: center;">
<a href="{$tsConfig.url}/admin/temas?act=nuevo&path={$t.path}" class="mBtn btnOk">Instalar {$t.nombre}</a>
</div>
</div>
{/foreach}
</form>
{else}
<form action="" method="post" id="admin_form" autocomplete="off">
<input type="hidden" name="manual" value="1">
<label for="ai_path">Nombre de la carpeta donde esta el tema a instalar:<br /><i>{$tsConfig.url}/themes/</i></label>
<input type="text" id="ai_path" name="path" size="30" />
<hr class="separator">
<input type="submit" value="Instalar tema" class="mBtn btnOk">
</form>
{/if}
{/if}Puede ser que el atributo style modifique el css, esto ya es a su gusto.
Ahora pueden agregar los themes e instalar desde un botón, sin tener que estar escribiendo el nombre del tema en el input.


Facebook
Twitter
Reddit
Digg
del.icio.us
Tumblr
Pinterest
Blogger
Fark
LinkedIn
Mix
Google