Ver Mensaje Individual
  #1 (permalink)  
Antiguo 23/03/2011, 07:28
Avatar de Fleon
Fleon
 
Fecha de Ingreso: febrero-2010
Mensajes: 138
Antigüedad: 15 años
Puntos: 3
Pregunta Problema con una Función en PHP

Saludos a todos, tengo la siguiente funcion que imprime una lista de temas (Aquí el ejemplo), como verán el resultado es sólo texto sin formato HTML, lo que quiero es que me aparezca como lista :

Código HTML:
Ver original
  1. <ul>Algo
  2.    <li>ss</li>
  3.    <li>ss</li>
  4.       <ul>Algo 2
  5.          <li>ss</li>
  6.          <li>ss</li>
  7.       </ul>
  8.    <li>ss</li>
  9. </ul>

La función es esta:

Código PHP:
Ver original
  1. function Faq($seccion, &$array, $nivel) {
  2.     global $context, $txt, $modSettings, $scripturl, $user_info, $smcFunc, $db_prefix; 
  3.        
  4.     $str = '';
  5.     for ( $i=0; $i < $nivel; $i++ )
  6.       $str .= '&nbsp; &nbsp; &nbsp; &nbsp; ';        
  7.    
  8.     //hacemos la consulta del FAQ dependiendo del lenguaje
  9.     $request = $smcFunc['db_query']('', '
  10.         SELECT *           
  11.         FROM {db_prefix}faqs AS f
  12.         WHERE f.id_rel = "'.$seccion.'" AND estado = 1 ORDER BY f.istitle, f.id_rel, f.titulo',
  13.         array(
  14.         )
  15.     );
  16.        
  17.     while ( $row = $smcFunc['db_fetch_assoc']($request) ) {      
  18.       $row['level'] = $str;    
  19.       $array[] = $row;
  20.       Faq($row['id'], $array, $nivel+1 );
  21.     }
  22.     $smcFunc['db_free_result']($request);      
  23. }
  24.  
  25. function printFAQ( $aSection, $all ) {
  26.     global $context, $txt, $settings, $modSettings, $scripturl, $user_info, $smcFunc, $db_prefix;  
  27.    
  28.     echo '<a name="top"></a><p>&nbsp;</p>
  29.    '."\n";
  30.    
  31.     // impresión del Título de las F.A.Q. y motor de búsqueda
  32.     $request = $smcFunc['db_query']('', '
  33.         SELECT *           
  34.         FROM {db_prefix}faqs AS f
  35.         WHERE f.id = "'.$aSection.'"',
  36.         array(
  37.         )
  38.     );
  39.     $row = $smcFunc['db_fetch_assoc']($request);
  40.     $title = '<strong>'.$row['titulo'].'</strong>';
  41.     $stitle = '';
  42.     $id_base = $row['id'];
  43.    
  44.     if ( $row['id_rel'] != 0 ) {
  45.       $id_rel = $aSection;
  46.       do {
  47.         $request = $smcFunc['db_query']('', '
  48.         SELECT *           
  49.         FROM {db_prefix}faqs AS f
  50.         WHERE f.id = "'.$id_rel.'"',
  51.         array(
  52.         )
  53.     );
  54.         $fila = $smcFunc['db_fetch_assoc']($request);
  55.         $id_rel = $fila['id_rel'];
  56.       } while ( $id_rel != 0 );
  57.       $title = '<strong>'.$fila['titulo'].'</strong>';
  58.       $stitle = '<p><h2><strong>'.$row['titulo'].'</strong></h2></p>';
  59.       $id_base = $fila['id'];
  60.     }
  61.     echo '
  62.        <table width="100%" cellpadding="0" cellspacing="0">
  63.          <tr>
  64.            <td class="largetext">'.$title.'</td>            
  65.          </tr>
  66.        </table>
  67.        '.$stitle.'
  68.          '."\n";   
  69.    
  70.     // obtenemos array con las FAQs
  71.     $array = array();
  72.     if ( $all == 1 )
  73.     Faq( 141, $array, 0 );
  74.     Faq( $aSection, $array, 0 );
  75.     $actualId = $aSection;
  76.    
  77.     // mostramos navegador o calculamos y mostramos estadísticas según convenga
  78.     if ( $row['id_rel'] != 0 )  // mostramos navegador
  79.       echo '
  80.        <p><hr><a href="',$scripturl,'?action=faq&id='.$aSection.'">Sumario</a><hr></p>
  81.           '."\n";
  82.     else {  // calculamos y mostramos estadísticas
  83.       $faqs = 0;
  84.       $categos = 0;
  85.       foreach( $array as $row )
  86.         if ( $row['istitle'] == 1 ) $categos++;
  87.         else $faqs++;
  88.      
  89.       echo '
  90.        <hr><p align="center">N&uacute;mero de F.A.Q.s: '.$faqs.'<br>
  91.        N&uacute;mero de categor&iacute;as: '.$categos."</p><hr>\n";
  92.     }
  93.    
  94.         if ( in_array(1, $user_info['groups']) || in_array(2, $user_info['groups']) || in_array(13, $user_info['groups'])) {
  95.         echo '
  96.        <table width="100%" cellpadding="0" cellspacing="0">
  97.          <tr>
  98.            <td><a href="', $scripturl,'?action=faqadd;sec='.$aSection.'">[ Agregar nuevo FAQ ]</a></td>            
  99.          </tr>
  100.           <tr>
  101.             <td><hr /></td>
  102.          </tr>
  103.        </table>'
  104.         ."\n";
  105.     }
  106.    
  107.     echo '<br />
  108.           <br />';
  109.    
  110.     // imprimimos menú
  111.     foreach( $array as $row ) {
  112.       switch ( $row['estado'] ) {
  113.         case 0: $visibilidad = '&nbsp; &nbsp; &nbsp; &nbsp;<span class="textError">-- borrador --</span>'; break;
  114.         case 1: $visibilidad = '&nbsp;'; break;
  115.         case 2: $visibilidad = '&nbsp; &nbsp; &nbsp; &nbsp;<span class="textError">-- S&oacute;lo Moderadores --</span>'; break;
  116.         case 3: $visibilidad = '&nbsp; &nbsp; &nbsp; &nbsp;<span class="textError">-- S&oacute;lo administradores --</span>'; break;
  117.         case 4: $visibilidad = '&nbsp; &nbsp; &nbsp; &nbsp;<span class="textError">-- Pendiente Aprobaci&oacute;n --</span>'; break;
  118.         case 5: $visibilidad = '&nbsp; &nbsp; &nbsp; &nbsp;<span class="textError">-- S&oacute;lo Redactores FAQs --</span>'; break;
  119.       }
  120.  
  121.       if ( ( $actualId != $row['id'] ) && ( $row['istitle'] == 1 ) ) $actualId = $row['id'];
  122.       if ( $row['istitle'] == 1 ) echo ''.$row['level'].'<a href="'.$scripturl.'?action=faqcontent&p='.$aSection.';all=0;fs='.$actualId.'"><strong>';
  123.       elseif ( $actualId == $aSection ) echo ''.$row['level'].'<a href="#'.$row['id'].'">';
  124.       else echo ''.$row['level'].'<a href="'.$scripturl.'?action=faqcontent&p='.$aSection.';all=0;fs='.$actualId.'#'.$row['id'].'">';
  125.       $estado = '';
  126.      
  127.         switch ( $row['accion'] ) {
  128.           case 1:
  129.             if ( ( $row['istitle'] != 1 ) && ( strtotime ("-1 month") < strtotime($row['fecha']) ) )
  130.               $estado = '<img src="'.$settings['default_theme_url'].'/themes/images/new.gif" alt="nuevo"> ';
  131.             break;
  132.           case 2:
  133.             if ( ( $row['istitle'] != 1 ) && ( strtotime ("-1 month") < strtotime($row['fecham']) ) ) {
  134.               if ( $row['ismodified'] == 1 )
  135.                 $estado = '<img src="'.$settings['default_theme_url'].'/themes/images/update.gif" alt="modificado"> ';
  136.               elseif ( strtotime ("-1 month") < strtotime($row['fecha']) )
  137.                 $estado = '<img src="'.$settings['default_theme_url'].'/themes/images/new.gif" alt="nuevo"> ';
  138.             }
  139.             break;
  140.         }
  141.        
  142.       echo $estado.parse_bbc( $row['titulo'] );
  143.       if ( $row['istitle'] == 1 ) echo '</strong>';
  144.       else echo $visibilidad;
  145.       echo "</a><br>\n";
  146.     }
  147.    
  148.     echo "<p>&nbsp;</p>\n";
  149.    
  150.     // imprimimos las FAQs
  151.     foreach( $array as $fila ) {
  152.       switch ( $fila['estado'] ) {
  153.         case 0: $estado = '<span class="textError">borrador</span>'; break;
  154.         case 1: $estado = '&nbsp;'; break;
  155.         case 2: $estado = '<span class="textError">Sólo Moderadores</span>'; break;
  156.         case 3: $estado = '<span class="textError">Sólo administradores</span>'; break;
  157.         case 4: $estado = '<span class="textError">Pendiente aprobación</span>'; break;
  158.         case 5: $estado = '<span class="textError">Sólo Redactores FAQs</span>'; break;
  159.       }
  160.       if ( ( $row['id_rel'] == $aSection ) && ( $row['istitle'] != 1 ) ) {
  161.         echo '
  162.          <a name="'.$row['id'].'"></a>
  163.          <table style="border: 1px solid #696969;padding: 1px;background-color: #ECEDF3;" width="100%" align="center" cellpadding="1" cellspacing="0">
  164.            <tr>
  165.              <td>
  166.                <table style="border: 1px solid #000000; margin: 1px auto 1px auto;" width="100%" align="center" cellpadding="2" cellspacing="0">
  167.                  <tr>
  168.                    <td class="titleBox1">'.parse_bbc( $row['titulo'] ).'</td>
  169.                    <td class="titleBox1">'.$estado.'</td>
  170.                    <td class="titleBox2" width="80">'.date( 'd/m/Y', strtotime($row['fecha']) ).'</td>
  171.                    <td class="titleBox2" width="30"><a href="#top">Top</a></td>
  172.                  </tr>
  173.                </table>
  174.              </td>
  175.            </tr>
  176.             '."\n";
  177.         if ( $row['autor'] != '' ) {
  178.           $str = $row['autor'];
  179.           if ( $row['mailautor'] != '' ) $str = '<a href="mailto:'.$row['mailautor'].'">'.$row['autor'].'</a>';
  180.           if ( $row['webautor'] != '' ) $str .= ' &nbsp; - &nbsp; <strong>Web del autor</strong>: <a href="http://'.$row['webautor'].'" target="_blank">'.$row['webautor'].'</a>';
  181.           echo '
  182.            <tr>
  183.              <td>
  184.                <table style="border: 1px solid #000000; margin: 1px auto 1px auto;" width="100%" align="center" cellpadding="2" cellspacing="0">
  185.                  <tr><td class="backBody1"><strong>Autor</strong>: '.$str.'</td></tr>
  186.                </table>
  187.              </td>
  188.            </tr>'."\n";
  189.         }
  190.         echo '
  191.            <tr>
  192.              <td>
  193.                <table style="border: 1px solid #000000; margin: 1px auto 1px auto;" width="100%" align="center" cellpadding="2" cellspacing="0">
  194.                  <tr><td class="backBody1"><p align="justify"><br>'.parse_bbc( $row['texto'] ).'<br></p></td></tr>
  195.                </table>
  196.              </td>
  197.            </tr>'."\n";
  198.         if ( $row['urls'] != '' )
  199.           echo '
  200.            <tr>
  201.              <td>
  202.                <table style="border: 1px solid #000000; margin: 1px auto 1px auto;" width="100%" align="center" cellpadding="2" cellspacing="0">
  203.                  <tr><td class="backBody1"><p><strong>Enlaces relacionados</strong><br><ul>'.parse_bbc( $row['urls'] ).'</ul></p></td></tr>
  204.                </table>
  205.              </td>
  206.            </tr>'."\n";
  207.         if ( $context['allow_admin'] )
  208.           echo '
  209.          <tr>
  210.            <td>
  211.              <table style="border: 1px solid #000000; margin: 1px auto 1px auto;" width="100%" align="center" cellpadding="2" cellspacing="0">
  212.                <tr><td class="backBody1"><strong>Administraci&oacute;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>
  213.              </table>
  214.            </td>
  215.          </tr>'."\n";
  216.         echo '
  217.        </table>
  218.        '."\n";    
  219.       }
  220.     }
  221.   }

Fleon XD