stat_pages.php 2.32 KB
<?php

	private function ajax_view(){
		sys_block_disable();
		$p = new staticPagesQuery('f');
		$p -> include_tmpl('t','t.t_path');
		$url = preg_replace('#^/#','',$_REQUEST['url']);
		if (! $p -> where_url($url) ){
			sys_error(ERROR_404);
		}
		//$p -> set_debug(1);
		$p -> get('f.*,f.p_id as check_access',false);
		
		$row = $p -> row();
		if ( !is_array($row)){
			exit();
		}
		if ( !$row['check_access'] ){
			exit();
		}
		
			//	меняем вывод блоков
		//$MAIN_PAGE -> set_tmpl_id($row['t_id']);
		 	//	меняем вывод шаблона
		//$MAIN_PAGE -> set_tmpl($row['t_path']);
		$GLOBALS['_RESULT']['content'] =  $row['p_content'];
		$GLOBALS['_RESULT']['title'] =$row['p_meta_title'];
		exit();
	}
	
	
		//	выводим заданную страницу
	private function view(){
	global $MAIN_PAGE,$MAIN_TMPL;
	  
		$p = new staticPagesQuery('f');
		$p -> include_tmpl('t','t.t_content,t.t_page_content_var');
		$url = preg_replace('#^/#','',$_REQUEST['url']);
		if (! $p -> where_url($url) ){
			sys_error(ERROR_404);
		}
		//$p -> set_debug(1);
		$p -> get('f.*,f.p_id as check_access',false);
	
		$row = $p -> row();
		if ( !is_array($row)){
			sys_error(ERROR_404);
		}
		if ( !$row['check_access'] ){
			sys_error(ERROR_403);
		}
		$MAIN_TMPL -> page_title = $row['p_title'];
     $MAIN_PAGE -> set_title(2,$row['p_title'],MAIN_URL.'/'.$url);
      $MAIN_PAGE -> set_page_content_var($row['t_page_content_var']);
			//	меняем вывод блоков
		 $MAIN_PAGE -> set_tmpl_id($row['t_id']);
		 	//	меняем вывод шаблона
		 //$MAIN_PAGE -> set_tmpl($row['t_path']);
		 $MAIN_PAGE -> set_content($row['t_content']);
		 $MAIN_PAGE -> set_meta_title($row['p_meta_title']);
		
		 $MAIN_PAGE -> set_meta_keywords($row['p_meta_desc']);
		 $MAIN_PAGE -> set_meta_description($row['p_meta_keywords']);
		 	//	выдаём контент
		if( $row['p_type_content']=='HTML' ){
		  return $row['p_content'];
		}elseif( $row['p_type_content']=='PHP'  ){
      return eval($row['p_type_content']);
    }elseif( $row['p_type_content']=='TMPL'){
        //  блоки генерим заранее, чтобы на них можно было ссылаться в шаблоне 
		  sys_blocks_enable();
      $t = new PHPTAL();
      $t -> setSource($row['p_content']);
      return $t -> execute();
    }
	}
?>