index.php
body.php
index.php (includes/layout)
menu.php
Опитах се да изкарам html извън класовете , тоест във class site да има колкото се може по малко html код , но не мога
Съжалявам за дългия код
<?php
define('index.php',true);
require('classes/body.php');
$obj=new Site;
$obj->connect();
$obj->header('Уеб класация');
$obj->head_title='Твоята уеб класация';
$obj->body_index();
$obj->footer();
?>
body.php
<?php
class site{
protected $host='localhost';
protected $user='root';
protected $pass='';
protected $db='directory';
public function connect(){
mysql_connect($this->host,$this->user,$this->pass);
mysql_select_db($this->db);
}
var $head_title;
public function header($title){
echo'<!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=utf-8" />
<title>'.$title.'</title>
</head>
<style>
body{margin:0px;background:#999;}
.header{width:700px;height:100px;border:1px #444 dashed;background:#888;text-shadow:#fff 2px 2px 5px}
.menu{width:700px;height:30px;border:1px #444 dashed;background:#888}
.footer{width:700px;height:30px;border:1px #444 dashed;background:#888;line-height:30px;}
.button{width:100px;height:30px;float:left;background:#777;line-height:30px;font-family:verdana;font-size:12px;text-shadow:#fff 1px 1px 5px}
.button:hover{background:#f60;}
a{text-decoration:none;color:#000;}
a:hover{text-decoration:none;color:#000;}
a:active{text-decoration:none;color:#000;}
.content{float:left;height:400px;background:#888;border:1px #444 dashed;text-shadow:#fff 1px 1px 5px}
.category{width:180px;float:left;margin-left:20px;height:400px;background:#888;border:1px #444 dashed;text-shadow:#fff 1px 1px 5px}
.wrapper{width:704px;}
</style>
<body>
';
}
protected $link1='Начало';
protected $link2='Топ 100';
protected $link3='Категории';
protected $link4='Добави сайт';
protected $link5='Статистика';
protected $link6='Най-нови';
protected $link7='Контакти';
public function body_index(){
include("/includes/layout/".$this->content[0]);
}
public $content=array('index.php','add_site.php','most_new.php','contacts.php','categories.php','view_cat.php');
function body($title){
echo'<center><div class="header"><h2>'.$this->head_title.'</h2></div><br/>
<div class="menu">
<div class="button"><a href="#">'.$this->link1.'</a></div>
<div class="button"><a href="#">'.$this->link2.'</a></div>
<div class="button"><a href="#">'.$this->link3.'</a></div>
<div class="button"><a href="#">'.$this->link4.'</a></div>
<div class="button"><a href="#">'.$this->link5.'</a></div>
<div class="button"><a href="#">'.$this->link6.'</a></div>
<div class="button"><a href="#">'.$this->link7.'</a></div>
</div><br/><div class="wrapper">
<div class="content" style="width:700px">'.$title.
include('includes/layout/'.$this->content[0]);
'</div>';
}
public function footer(){
echo'<div style="clear:both"></div><br/><div class="footer">© All rights reserved.</div>';
}
}
?>
index.php (includes/layout)
<?php
require('includes/layout/menu.php');
if(defined('index.php'))
{
$style='style="width:500px"';
}
else
{
$style='style="width:700px"';
}
echo'<div class="wrapper">
<div class="content" '.$style.'>Топ сайтове
</div>';
if(defined('index.php'))
{
echo'<div class="category">Категории</div></div>';
}
?>
menu.php
<?php
echo'<center><div class="header"><h2>'.$this->head_title.'</h2></div><br/>
<div class="menu">
<div class="button"><a href="#">'.$this->link1.'</a></div>
<div class="button"><a href="#">'.$this->link2.'</a></div>
<div class="button"><a href="#">'.$this->link3.'</a></div>
<div class="button"><a href="#">'.$this->link4.'</a></div>
<div class="button"><a href="#">'.$this->link5.'</a></div>
<div class="button"><a href="#">'.$this->link6.'</a></div>
<div class="button"><a href="#">'.$this->link7.'</a></div>
</div><br/>';
?>
Опитах се да изкарам html извън класовете , тоест във class site да има колкото се може по малко html код , но не мога
Съжалявам за дългия код