Пример #1
0
 /**
  * Render a view
  * 
  * Picks the template and the page content
  * @param array $data
  * @return string
  */
 public static function make($data = array())
 {
     // Data to be bound to views
     Xysti::$data = array_merge(Xysti::$data, $data);
     // Which template?
     if (Xysti::page('template') == 'none') {
         Xysti::$views['template'] = FALSE;
         if (Xysti::page('content')) {
             Xysti::$views['template'] = Xysti::page('content');
         } else {
             Xysti::$views['template'] = 'content.' . URI::current();
         }
     } elseif (Xysti::page('template')) {
         Xysti::$views['template'] = Xysti::page('template');
     } else {
         Xysti::$views['template'] = Config::get('xysti.template');
     }
     // What content?
     // Content must be in the sitemap
     if (Xysti::page('exists')) {
         // Is content explicitly set?
         if (Xysti::page('content')) {
             Xysti::$views['content'] = 'content.' . Xysti::page('content');
             // Is this an incorrecty configured dynamic page?
         } elseif (Xysti::page('/') == 'dynamic') {
             return Xysti::error(500, 'Dynamic pages must have a content meta value specified.');
             // Else use the URI
         } else {
             Xysti::$views['content'] = 'content.' . str_replace('/', '.', URI::current());
         }
     } else {
         Log::write('info', 'No sitemap entry for ' . URI::current() . '.');
     }
     // Time to return a view!
     // Is the content set?
     if (isset(Xysti::$views['content']) or isset(Xysti::$content)) {
         // If there is a template then load it
         if (Xysti::$views['template']) {
             return View::make(Xysti::$views['template'], Xysti::$data);
             // Else just load the content
         } else {
             return View::make(Xysti::$views['content'], Xysti::$data);
         }
         // Else 404
     } else {
         return Xysti::error(404);
     }
 }