Ver Mensaje Individual
  #1 (permalink)  
Antiguo 24/08/2010, 15:58
Sun_shine
 
Fecha de Ingreso: agosto-2010
Mensajes: 4
Antigüedad: 13 años, 8 meses
Puntos: 0
Busqueda código html dentro del código php

He creado Pagina.inc y a partir de las clases y funciones en este archivo pretendo ir creando todas las páginas necesarias para el sitio Web, utilizando require y herencias:

En la primera página inicio.php tenemos:

<?
require ("pagina.inc");

$paginaInicio = new Pagina();

$paginaInicio -> SetContenidos("<table width=\"100%\" border=\"0\" cellspacing=\"0\" cellpadding=\"1\">
<tr>
<th bgcolor=\"#000000\" scope=\"col\"><img src=\"Images/cuerpo.png\" width=\"780\" height=\"449\"></th>
</tr>
</table>"
);
$paginaInicio -> Mostrar();
?>

Dentro de SetContenidos tenemos codigo html, pero es necesario poner la barra invertida (\) antes de las comillas y otros simbolos para que php lo interprete correctamente, mi pregunta es:


El código con los contenidos que quiero incluir es bastante largo, ¿exite la prosibilidad de pasar el codigo html sin tener que poner la \ previamente a todas las comillas?


Muchas gracias por adelantado.




El archivo Pagina.inc es:

<?
class Pagina
{

// atributos de la clase Pagina
var $contenido;
var $titulo = "Multi Librería Online";
var $palabrasClave = "Librería Online, Aquí pondremos las palabras clave,
Podemos personalizarlas para cada página";
var $botones = array( "Inicio" => "inicio.php",
"Contacto" => "contacto.php",
"Servicios" => "servicios.php",
"Mapa Sitio" => "mapa.php"
);

// operaciones de la clase Pagina

function SetContenidos($nuevosContenidos)
{
$this->contenidos = $nuevosContenidos;
}

function SetTitulo($nuevoTitulo)
{
$this->titulo = $nuevoTitulo;
}

function SetPalabrasClave($nuevasPalabrasClave)
{
$this->palabrasClave = $nuevasPalabrasClave;
}

function SetBotones($nuevosBotones)
{
$this->botones = $nuevosBotones;
}

function Mostrar()
{
echo "<html>\n<head>\n";
$this -> MostrarTitulo();
$this -> MostrarPalabrasClave();
$this -> MostrarEstilos();
echo "</head>\n<body>\n";
$this -> MostrarCabecera();
$this -> MostrarMenu($this->botones);
echo $this->contenidos;
$this -> MostrarFooter();
echo "</body>\n</html>\n";
}

function MostrarTitulo()
{
echo "<titulo> $this->titulo </titulo>";
}

function MostrarPalabrasClave()
{
echo "<META name=\"palabrasClave\" contenidos=\"$this->palabrasClave\">";
}

function MostrarEstilos()
{
?>
<style>
body {
background-color: #000000;
}
h1 {color:white; font-size:12pt; text-align:center;
font-family:arial,sans-serif}
.menu {color:#FFCD6A; font-size:10pt; text-align:center;
font-family:arial,sans-serif; font-weight:bold}
td {background:black}
p {color:white; font-size:12pt; text-align:justify;
font-family:arial,sans-serif}
p.foot {color:white; font-size:9pt; text-align:center;
font-family:arial,sans-serif; font-weight:bold}
a:link,a:visited,a:active {color:white}
</style>
<?
}

function MostrarCabecera()
{
?>
<table width="100%" border="0" cellspacing="0" cellpadding="1">
<tr>
<th scope="col"><div align="center">
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="780" height="237">
<param name="movie" value="0042.swf">
<param name="quality" value="high">
<embed src="0042.swf" quality="high" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="780" height="237"></embed>
</object>
</div></th>
</tr>
</table>
<?
}

function MostrarMenu($botones)
{
echo "<table width = \"100%\" bgcolor = white cellpadding = 4 cellspacing = 4>\n";
echo " <tr>\n";

//calcular tamaño botones
$width = 100/count($botones);

while (list($nombre, $url) = each($botones))
{
$this -> MostrarBoton($width, $nombre, $url, !$this->IsURLCurrentPage($url));
}
echo " </tr>\n";
echo "</table>\n";
}

function IsURLCurrentPage($url)
{
if(strpos( $GLOBALS["SCRIPT_NAME"], $url )==false)
{
return false;
}
else
{
return true;
}
}

function MostrarBoton($width, $nombre, $url, $activo = true)
{
if ($activo)
{
echo "<td width = \"$width%\">
<a href = \"$url\">
<img src = \"s-logo.gif\" alt = \"$nombre\" border = 0></a>
<a href = \"$url\"><span class=menu>$nombre</span></a></td>";
}
else
{
echo "<td width = \"$width%\">
<img src = \"side-logo.gif\">
<span class=menu>$nombre</span></td>";
}
}

function MostrarFooter()
{
?>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<!-- ImageReady Slices (footer.psd) -->
<table id="Tabla_01" width="100%" height="51" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<img src="Images/12.jpg" width="234" height="22" alt=""></td>
<td>
<img src="Images/13.jpg" width="65" height="22" alt=""></td>
<td>
<img src="Images/14.jpg" width="54" height="22" alt=""></td>
<td>
<img src="Images/15.jpg" width="58" height="22" alt=""></td>
<td>
<img src="Images/16.jpg" width="64" height="22" alt=""></td>
<td>
<img src="Images/17.jpg" width="67" height="22" alt=""></td>
<td>
<img src="Images/18.jpg" width="238" height="22" alt=""></td>
</tr>
<tr>
<td colspan="7">
<img src="Images/19.jpg" width="100%" height="29" alt=""></td>
</tr>
</table>
<!-- End ImageReady Slices -->
</body>
<?
}
}
?>