getQuality($mime); if (isset($final[$ext])) { $quality = max($final[$ext], $quality); } $prefs[$ext] = $quality; } } // Sort $prefs such that the entry with the highest value will // appear first. arsort($prefs); // Return the first entry in $prefs. foreach ($prefs as $ext => $quality) { return VIEWPATH."/pages/$view.$ext.php"; } } /** * Show a $view, in the most appropriate format (according to file * extension and HTTP Accept header). Pass the array $vars to the view. */ protected function showView($view, $vars=null) { global $VARS, $mm; if ($vars===null) { $vars = array(); } $VARS = $vars; $VARS['template'] = $mm->template(); include($this->_resolveView($view)); unset($VARS); } // Here be default handlers //////////////////////////////////////////// public function index($routed, $remainder) { header('Content-type: text/plain'); echo " == Generic Controller Index == \n\n"; $routed_str = implode('/', $routed); $remainder_str = implode('/', $remainder); echo "Full path: $routed_str/$remainder_str\n"; echo "Controller path: $routed_str\n"; echo "Remainder path: $remainder_str\n"; } public function http404($routed, $remainder) { $this->showView('http404', array('routed'=>$routed, 'remainder'=>$remainder)); } }