Código :
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Clase pagina Nro 2</title>
</head>
<body>
<?
class Pagina
{
////CAMARADAS ACÁ LES MANDO UN EJEMPLO MUY UTIL DE LA UTILIZACION DE ORIENTACION A OBJETOS
////CON PHP, ES UN CODIGO MUY REUTILIZABLE, SUERTE!!!!////////////////////////////////////
///////// ACÁ DECLARAMOS LOS ATRIBUTOS DE LA CLASE/////////////////////////
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" => "ARCHIVO.php",
"Contacto" => "ARCHIVO.php",
"Servicios" => "ARCHIVO.php",
"Mapa Sitio" => "ARCHIVO.php"
);
//////// ACÁ DECLARAMOS LAS OPERACIONES DE LA CLASE///////////////////////////////
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(); // LLAMO A LA FUNCION MOSTRAR TITULO
$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()
{
?>
<!-- ACA CODIFICAMOS NUESTRO ESTILO CSS-->
<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>
<!-- FIN DE LA CODIFICACIÓN CSS-->
<? // ACA HABRIMOS CODIGO PHP UNICAMENTE PARA DECLARAR LA FUNCION MOSTRAR CABECERA//
}
function MostrarCabecera()
{
// ACA CERRAMOS EL CODIGO PHP PARA PARA REALIZARLA CABECERA EN HTML
?>
<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>
<?
}// ESTA LLAVE ES LA LLAVE DE CIERRE DE LA DECLARACIÓN DE LA FUNCION "MostrarCabecera", antes abierta/////////
function MostrarMenu($botones)
{
echo "<table width = \"100%\" bgcolor = white cellpadding = 4 cellspacing = 4>\n";
echo " <tr>\n";
//ACÁ SE CALCULA EL TAMAÑO DE LOS BOTONES, YA QUE ESTA CLASE NOS PERMITE AGREGAR BOTONES SEGUN LAS
//LAS NECESIDADES DEL CASO. SE CUENTAN LOS BOTONES Y SE LOS DIVIDE EN UN ESPACIO DE 100,CON ESTO OBTENEMOS
//EL ANCHO EFECTIVO DE PAGINA PARA LOS 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 = \"IMAGEN.gif\" alt = \"$nombre\" border = 0></a>
<a href = \"$url\"><span class=menu>$nombre</span></a></td>";
}
else
{
echo "<td width = \"$width%\">
<img src = \"IMAGEN.gif\">
<span class=menu>$nombre</span></td>";
}
}
function MostrarFooter() // CON ESTA FUNCION GENERAMOS EL PIE DE LA PAGINA//
{
?>
<body bgcolor="#FFFFFF" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<table id="Tabla_01" width="100%" height="51" border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<img src="Images.jpg" width="234" height="22" alt=""></td>
<td>
<img src="Images.jpg" width="65" height="22" alt=""></td>
<td>
<img src="Images.jpg" width="54" height="22" alt=""></td>
<td>
<img src="Images.jpg" width="58" height="22" alt=""></td>
<td>
<img src="Images.jpg" width="64" height="22" alt=""></td>
<td>
<img src="Images.jpg" width="67" height="22" alt=""></td>
<td>
<img src="Images.jpg" width="238" height="22" alt=""></td>
</tr>
<tr>
<td colspan="7">
<img src="Images.jpg" width="100%" height="29" alt=""></td>
</tr>
</table>
<!-- End ImageReady Slices -->
</body>
<?
}
}
?>
<!--************ACÁ HAGO LA INSTANCIACION DE LA CLASE PAGINA************ -->
<?
$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();
?>
<!--****************************************************************** -->
</body>
</html>
