Example #1
0
 /**
  * @param string $tpl
  * @param array $variables
  * @throws Exception
  */
 public function view($tpl, array $variables = [])
 {
     if (!$this->view) {
         foreach ($variables as $key => $variable) {
             Page::assignOnMap($tpl, $key, $variable);
         }
         Page::loadTemplate($tpl);
         $this->view = true;
     } else {
         throw new Exception("View has already been displayed!");
     }
 }
Example #2
0
$cache_dir = rtrim(CACHE . $_SERVER['REQUEST_URI'], '/');
$cache_file = $cache_dir . '/index.html';
/**
 * Load Cache if there's no _POST variables
 *
 * No cache should be created for pages that involve a
 * credential check... so this is sufficient.
 */
if (is_file($cache_file) && $config['program']['cache']['enable'] === true) {
    if (time() - filemtime($cache_file) < $config['program']['cache']['expires']) {
        include $cache_file;
        exit;
    } else {
        unlink($cache_file);
    }
}
/* Autoloader for MmVC */
function __autoload($class_name)
{
    require_once CLASSES . $class_name . '.php';
}
$Page = new Page();
$Page->V = new V();
$Page->init();
$Page->loadConfig($config);
$Page->loadUser();
$Page->loadPages();
$Page->loadTemplate();
/* Write to cache */
// if(!is_dir($cache_dir)) { mkdir($cache_dir, 0777, true); }
// file_put_contents($cache_file, $contents);