function Faq($seccion, &$array, $nivel) {
global $context, $txt, $modSettings, $scripturl, $user_info, $smcFunc, $db_prefix;
$str = '';
for ( $i=0; $i < $nivel; $i++ )
$str .= ' ';
//hacemos la consulta del FAQ dependiendo del lenguaje
$request = $smcFunc['db_query']('', '
SELECT *
FROM {db_prefix}faqs AS f
WHERE f.id_rel = "'.$seccion.'" AND estado = 1 ORDER BY f.istitle, f.id_rel, f.titulo',
)
);
while ( $row = $smcFunc['db_fetch_assoc']($request) ) {
$row['level'] = $str;
$array[] = $row;
Faq($row['id'], $array, $nivel+1 );
}
$smcFunc['db_free_result']($request);
}
function printFAQ( $aSection, $all ) {
global $context, $txt, $settings, $modSettings, $scripturl, $user_info, $smcFunc, $db_prefix;
echo '<a name="top"></a><p> </p>
'."\n";
// impresión del Título de las F.A.Q. y motor de búsqueda
$request = $smcFunc['db_query']('', '
SELECT *
FROM {db_prefix}faqs AS f
WHERE f.id = "'.$aSection.'"',
)
);
$row = $smcFunc['db_fetch_assoc']($request);
$title = '<strong>'.$row['titulo'].'</strong>';
$stitle = '';
$id_base = $row['id'];
if ( $row['id_rel'] != 0 ) {
$id_rel = $aSection;
do {
$request = $smcFunc['db_query']('', '
SELECT *
FROM {db_prefix}faqs AS f
WHERE f.id = "'.$id_rel.'"',
)
);
$fila = $smcFunc['db_fetch_assoc']($request);
$id_rel = $fila['id_rel'];
} while ( $id_rel != 0 );
$title = '<strong>'.$fila['titulo'].'</strong>';
$stitle = '<p><h2><strong>'.$row['titulo'].'</strong></h2></p>';
$id_base = $fila['id'];
}
echo '
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td class="largetext">'.$title.'</td>
</tr>
</table>
'.$stitle.'
'."\n";
// obtenemos array con las FAQs
if ( $all == 1 )
Faq( 141, $array, 0 );
Faq( $aSection, $array, 0 );
$actualId = $aSection;
// mostramos navegador o calculamos y mostramos estadísticas según convenga
if ( $row['id_rel'] != 0 ) // mostramos navegador
echo '
<p><hr><a href="',$scripturl,'?action=faq&id='.$aSection.'">Sumario</a><hr></p>
'."\n";
else { // calculamos y mostramos estadísticas
$faqs = 0;
$categos = 0;
foreach( $array as $row )
if ( $row['istitle'] == 1 ) $categos++;
else $faqs++;
echo '
<hr><p align="center">Número de F.A.Q.s: '.$faqs.'<br>
Número de categorías: '.$categos."</p><hr>\n";
}
echo '
<table width="100%" cellpadding="0" cellspacing="0">
<tr>
<td><a href="', $scripturl,'?action=faqadd;sec='.$aSection.'">[ Agregar nuevo FAQ ]</a></td>
</tr>
<tr>
<td><hr /></td>
</tr>
</table>'
."\n";
}
echo '<br />
<br />';
// imprimimos menú
foreach( $array as $row ) {
switch ( $row['estado'] ) {
case 0: $visibilidad = ' <span class="textError">-- borrador --</span>'; break;
case 1: $visibilidad = ' '; break;
case 2: $visibilidad = ' <span class="textError">-- Sólo Moderadores --</span>'; break;
case 3: $visibilidad = ' <span class="textError">-- Sólo administradores --</span>'; break;
case 4: $visibilidad = ' <span class="textError">-- Pendiente Aprobación --</span>'; break;
case 5: $visibilidad = ' <span class="textError">-- Sólo Redactores FAQs --</span>'; break;
}
if ( ( $actualId != $row['id'] ) && ( $row['istitle'] == 1 ) ) $actualId = $row['id'];
if ( $row['istitle'] == 1 ) echo ''.$row['level'].'<a href="'.$scripturl.'?action=faqcontent&p='.$aSection.';all=0;fs='.$actualId.'"><strong>';
elseif ( $actualId == $aSection ) echo ''.$row['level'].'<a href="#'.$row['id'].'">';
else echo ''.$row['level'].'<a href="'.$scripturl.'?action=faqcontent&p='.$aSection.';all=0;fs='.$actualId.'#'.$row['id'].'">';
$estado = '';
switch ( $row['accion'] ) {
case 1:
$estado = '<img src="'.$settings['default_theme_url'].'/themes/images/new.gif" alt="nuevo"> ';
break;
case 2:
if ( ( $row['istitle'] != 1 ) && ( strtotime ("-1 month") < strtotime($row['fecham']) ) ) { if ( $row['ismodified'] == 1 )
$estado = '<img src="'.$settings['default_theme_url'].'/themes/images/update.gif" alt="modificado"> ';
$estado = '<img src="'.$settings['default_theme_url'].'/themes/images/new.gif" alt="nuevo"> ';
}
break;
}
echo $estado.parse_bbc( $row['titulo'] );
if ( $row['istitle'] == 1 ) echo '</strong>';
else echo $visibilidad;
echo "</a><br>\n";
}
echo "<p> </p>\n";
// imprimimos las FAQs
foreach( $array as $fila ) {
switch ( $fila['estado'] ) {
case 0: $estado = '<span class="textError">borrador</span>'; break;
case 1: $estado = ' '; break;
case 2: $estado = '<span class="textError">Sólo Moderadores</span>'; break;
case 3: $estado = '<span class="textError">Sólo administradores</span>'; break;
case 4: $estado = '<span class="textError">Pendiente aprobación</span>'; break;
case 5: $estado = '<span class="textError">Sólo Redactores FAQs</span>'; break;
}
if ( ( $row['id_rel'] == $aSection ) && ( $row['istitle'] != 1 ) ) {
echo '
<a name="'.$row['id'].'"></a>
<table style="border: 1px solid #696969;padding: 1px;background-color: #ECEDF3;" width="100%" align="center" cellpadding="1" cellspacing="0">
<tr>
<td>
<table style="border: 1px solid #000000; margin: 1px auto 1px auto;" width="100%" align="center" cellpadding="2" cellspacing="0">
<tr>
<td class="titleBox1">'.parse_bbc( $row['titulo'] ).'</td>
<td class="titleBox1">'.$estado.'</td>
<td class="titleBox2" width="80">'.date( 'd/m/Y', strtotime($row['fecha']) ).'</td> <td class="titleBox2" width="30"><a href="#top">Top</a></td>
</tr>
</table>
</td>
</tr>
'."\n";
if ( $row['autor'] != '' ) {
$str = $row['autor'];
if ( $row['mailautor'] != '' ) $str = '<a href="mailto:'.$row['mailautor'].'">'.$row['autor'].'</a>';
if ( $row['webautor'] != '' ) $str .= ' - <strong>Web del autor</strong>: <a href="http://'.$row['webautor'].'" target="_blank">'.$row['webautor'].'</a>';
echo '
<tr>
<td>
<table style="border: 1px solid #000000; margin: 1px auto 1px auto;" width="100%" align="center" cellpadding="2" cellspacing="0">
<tr><td class="backBody1"><strong>Autor</strong>: '.$str.'</td></tr>
</table>
</td>
</tr>'."\n";
}
echo '
<tr>
<td>
<table style="border: 1px solid #000000; margin: 1px auto 1px auto;" width="100%" align="center" cellpadding="2" cellspacing="0">
<tr><td class="backBody1"><p align="justify"><br>'.parse_bbc( $row['texto'] ).'<br></p></td></tr>
</table>
</td>
</tr>'."\n";
if ( $row['urls'] != '' )
echo '
<tr>
<td>
<table style="border: 1px solid #000000; margin: 1px auto 1px auto;" width="100%" align="center" cellpadding="2" cellspacing="0">
<tr><td class="backBody1"><p><strong>Enlaces relacionados</strong><br><ul>'.parse_bbc( $row['urls'] ).'</ul></p></td></tr>
</table>
</td>
</tr>'."\n";
if ( $context['allow_admin'] )
echo '
<tr>
<td>
<table style="border: 1px solid #000000; margin: 1px auto 1px auto;" width="100%" align="center" cellpadding="2" cellspacing="0">
<tr><td class="backBody1"><strong>Administración</strong>: <a href="'.$scripturl.'/index.php?p=44&id='.$row['id'].'&f='.$row['id_sec'].'"><img src="'.$settings['default_theme_url'].'/themes/images/btn_modify.gif" alt="modificar"></a></td></tr>
</table>
</td>
</tr>'."\n";
echo '
</table>
'."\n";
}
}
}