NilSagor

Multi/classes/Core.php

Mar 1st, 2016
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.14 KB | None | 0 0
  1. <?php
  2.  
  3. class Core{
  4.   public $objLanguage;
  5.   public $lang_menu;
  6.  
  7.   public $objUrl;
  8.   public $objNavigation;
  9.   public $admin;
  10.  
  11.   public $navigation_1;
  12.   public $navigation_2;
  13.   public $navigation_3;
  14.  
  15.   public $meta_title;
  16.   public $meta_description;
  17.   public $meta_keywords;
  18.   public $content;
  19.   public $column;
  20.   public $script;
  21.  
  22.   public function run(){
  23.     $this->objLanguage=new Language();
  24.     $this->lang_menu=Helper::getPlug('language',
  25.     array('objLanguage'=>$this->objLanguage)
  26.   );
  27.   $this->objUrl=new Url();
  28.   $this->objNavigation=new Navigation($this->objUrl,$this->objLanguage);
  29.  
  30.   switch ($this->objUrl->module) {
  31.     case 'panel':
  32.       set_include_path(implode(PATH_SEPARATOR,array(
  33.         realpath(TEMPLATE_PATH.DS.'admin'),
  34.         get_include_path()
  35.       )));
  36.       $this->runAdmin();
  37.       break;
  38.  
  39.     default:
  40.       set_include_path(implode(PATH_SEPARATOR,array(
  41.         get_include_path()
  42.       )));
  43.       $this->runFront();
  44.       break;
  45.     }
  46.   }
  47.  
  48.   public function runFront(){
  49.     $this->parseNavigation();
  50.     $this->parseColumn();
  51.     if (array_key_exists($this->objUrl->cPage,Route::$modules)) {
  52.       $file=ROOT_PATH.DS.'mod'.DS.ROUTE::$_modules[$this->objUrl->cPage].'.php';
  53.       if (is_file($file)) {
  54.         ob_start();
  55.         require_once($file);
  56.         echo ob_get_clean();
  57.       }else{
  58.         $objPage=new Page($this->objLanguage);
  59.         $page=$objPage->getError();
  60.         $this->parsePage($page);
  61.         ob_start();
  62.         require_once('header.php');
  63.         echo $this->content;
  64.         require_once('footer.php');
  65.         echo ob_get_clean();
  66.       }
  67.     }else{
  68.         $objPage=new Page($this->objLanguage);
  69.         $page=$objPage->getByIdentity($this->objUrl->cPage);
  70.         if (empty($page)) {
  71.           $page=$objPage->getError();
  72.         }
  73.         $this->parsePage($page);
  74.         ob_start();
  75.         require_once('header.php');
  76.         echo $this->content;
  77.         require_once('footer.php');
  78.         echo ob_get_clean();
  79.     }
  80.   }
  81.  
  82.  
  83.  
  84.   public function parsePage($page=null){
  85.     if(!empty($page) && is_array($page)){
  86.       $this->meta_title=$page['meta_title'];
  87.       $this->meta_description=$page['meta_description'];
  88.       $this->meta_keywords=$page['meta_keywords'];
  89.       $this->content=$page['content'];
  90.     }
  91.   }
  92.  
  93.  
  94.  
  95.  
  96.  
  97.   public function parseNavigation(){
  98.     $this->navigation_1=$this->objNavigation->get(1);
  99.     $this->navigation_2=$this->objNavigation->get(2);
  100.     $this->navigation_3=$this->objNavigation->get(3);
  101.   }
  102.  
  103.   public function parseColumn(){
  104.     $array=array(
  105.       '<img src="/media/images/new-radicals.jpg"alt="New-redicals" width="250" height="166"
  106.      style="float:left; margin-bottom:17px;"/>',
  107.       '<img src="/media/images/new-radicals.jpg"
  108.      alt="New-redicals" width="250" height="166"
  109.      style="float:left; margin-bottom:17px;"/>',
  110.       '<img src="/media/images/new-radicals.jpg"
  111.      alt="New-redicals" width="250" height="166"
  112.      style="float:left; margin-bottom:17px;"/>'
  113.     );
  114.     $keys=array_rand($array,3);
  115.     $this->column=$array[$keys[0]].$array[$keys[1]].$array[$keys[2]];
  116.   }
  117.  
  118. }
Advertisement
Add Comment
Please, Sign In to add comment