Advertisement
Guest User

Untitled

a guest
Jun 19th, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.75 KB | None | 0 0
  1. <?php
  2. require_once 'DbData.php';
  3. require_once '../includes/inc-func-api.php';
  4.  
  5. class SeoController extends DbData
  6. {
  7.     private $template_path = null;
  8.  
  9.     public function __construct(){
  10.         $this->template_path = $_SERVER['DOCUMENT_ROOT'] . '/sitemap/templates/';
  11.     }
  12.  
  13.     private function loadView($name, $params = null) {
  14.         $path = $this->template_path . $name . '.phtml';
  15.  
  16.         if (file_exists($path)){
  17.             $content = '';
  18.  
  19.             ob_end_clean();
  20.             ob_start();
  21.  
  22.             require($path);
  23.  
  24.             $content = ob_get_contents();
  25.             ob_end_clean();
  26.  
  27.             return $content;
  28.         }
  29.  
  30.         return false;
  31.     }
  32.  
  33.     public function index() {
  34.         $page = $this->page;
  35.         $total = $this->total;
  36.         $contentSeoLinks = '';
  37.         echo $this->loadView('header');
  38.         $model = new DbData();
  39.         $prefix = 'semya-';
  40.         $title = 'Семьи';
  41.  
  42.         if (isset($_GET['seo']) && $_GET['seo'] == 'nanny') {
  43.             $prefix = 'nyanya-';
  44.             $title = 'Няни';
  45.         }
  46.         echo "<br>";
  47.         var_dump($total);
  48.         die('$total');
  49.         $seoLinks = $model->getSeoLinks();
  50. //        $num = 100;
  51. //        echo "<table>";
  52. //        for($i = 0; $i < $num; $i++) {
  53. //            echo "<tr>
  54. //            <td>".$seoLinks[$i]['rewrite']."</td></tr>
  55. //            <tr><td colspan=\"2\">".$seoLinks[$i]['text']."</td></tr>";
  56. //        }
  57.         echo "</table>";
  58.         foreach ($seoLinks as $seoLink) {
  59.             $url = $seoLink['rewrite'];
  60.             $contentSeoLinks .= $this->loadView('nannies', array(
  61.                 'url' =>  '../../' . $prefix . $seoLink['rewrite'],
  62.                 'title' => $seoLink['query']));
  63.         }
  64.  
  65.  
  66.  
  67.         if ($page != 1) $pervpage = '<a href= ./page?page=1><<</a><a href= ./page?page='. ($page - 1) .'><</a> ';
  68.         if ($page != $total) $nextpage = ' <a href= ./page?page='. ($page + 1) .'>></a><a href= ./page?page=' .$total. '>>></a>';
  69.  
  70.         if($page - 2 > 0) $page2left = ' <a href= ./page?page='. ($page - 2) .'>'. ($page - 2) .'</a> | ';
  71.         if($page - 1 > 0) $page1left = '<a href= ./page?page='. ($page - 1) .'>'. ($page - 1) .'</a> | ';
  72.         if($page + 2 <= $total) $page2right = ' | <a href= ./page?page='. ($page + 2) .'>'. ($page + 2) .'</a>';
  73.         if($page + 1 <= $total) $page1right = ' | <a href= ./page?page='. ($page + 1) .'>'. ($page + 1) .'</a>';
  74.  
  75.         echo $pervpage.$page2left.$page1left.'<b>'.$page.'</b>'.$page1right.$page2right.$nextpage;
  76.  
  77.  
  78.  
  79.  
  80.  
  81.  
  82.  
  83.  
  84.  
  85.         echo $this->loadView('seo-links', array(
  86.             'seoLinks_nanny' => $contentSeoLinks,
  87.             'title' => $title,
  88.         ));
  89.     }
  90. }
  91. $model = new SeoController();
  92. $model->index();
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement