Advertisement
Guest User

Untitled

a guest
Dec 6th, 2010
224
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.80 KB | None | 0 0
  1. <?php
  2. class PagesController extends AppController
  3. {
  4.     var $uses = array();
  5.    
  6.     function display()
  7.     {
  8.         $path = func_get_args();
  9.  
  10.         $count = count($path);
  11.         if (!$count) {
  12.             $this->redirect('/');
  13.         }
  14.         $page = $subpage = $title = null;
  15.  
  16.         if (!empty($path[0])) {
  17.             $page = $path[0];
  18.         }
  19.        
  20.         if (!empty($path[1]) && $path[1] == 1) {
  21.             array_pop($path);
  22.             $this->redirect("/".implode('/', $path));
  23.         }
  24.         $subpage = empty($path[1]) ? 1 : $path[1];
  25.        
  26.         if (!empty($path[$count - 1])) {
  27.             $title = Inflector::humanize($path[$count - 1]);
  28.         }
  29.         $this->set(compact('page', 'subpage', 'title'));
  30.         $this->render(implode('/', $path));
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement