Технологии
Здравствуйте. Есть код (необязательное уточнение). Хочу добавить страницу viewcity1.php и viewcity2.php - как мне это сделать? - вопрос №1344332
<?php
class Helpers_Document_Views{
protected $data=array();
private $pathFiles;
protected function __clone(){}
protected function __wakeup(){}
public function __construct(){
$this->setPathFiles();
}
public function __set($key,$value) {
$this->data[$key]=$value;
}
public function __get($key){
return (isset($this->data[$key])?$this->data[$key]:null);
}
public function __isset($key){
return isset($this->data[$key]);
}
public function assign($data){
foreach($data as $key=>$val){
$this->data[$key]=$val;
}
}
public function setPathFiles($path=''){
if($path==''){
$this->pathFiles=$_SERVER['DOCUMENT_ROOT'].'/';
}else{
$this->pathFiles=$path;
}
}
public function render($fileName,$type='code'){
$fileName=$this->pathFiles.$fileName;
if(is_file($fileName)){
ob_start();
if($type=='code'){
$c=file_get_contents($fileName);
if(trim($c)!=''){
if(!preg_match('{<!--compile-->}i',$c)){
$c=str_replace("'./","'/",$c);
$c='<!--compile-->'.$c;
file_put_contents($fileName,$c);
}
}
include $fileName;
}elseif($type=='text'){
echo file_get_contents($fileName);
}
return ob_get_clean();
}else{
return false;
}
}
}
class Models_Router
{
public function __construct($request=false){
if(!$request){
$request=$_REQUEST['page'];
}
$this->action($request);
}
protected function action($request){
if(trim($request)==''){
return false;
}
$data=explode('/',$request);
if(isset($data[0]) && trim($data[0])!=''){
$view=new Helpers_Document_Views;
$view->cityName=strtolower($data[0]);
$c=$view->render('viewCity.php');
$c=str_replace("'./","'/",$c);
$c=str_replace(«fancybox/»,"/fancybox/",$c);
die($c);
}
return false;
}
}
$router=new Models_Router;
?>
январь 23, 2015 г.
-
Всего ответов: 0
Похожие вопросы
Ошибка Warning: mysqli_fetch_assoc() expects parameter 1 to be mysqli_result, boolean on line 26
май 6, 2014 г.