示例#1
0
文件: view.php 项目: LucasFyl/korakia
 public function render()
 {
     $file = $this->root . DS . str_replace('.', DS, $this->file) . '.php';
     if (!file_exists($file)) {
         throw new Exception('Invalid view: ' . $this->file);
     }
     return f::load($file, $this->data);
 }
示例#2
0
 /**
  * Safely requires a file if it exists
  *
  * @param array $data Optional variables, which will be made available to the file
  */
 public function load($data = array())
 {
     return f::load($this->root, $data);
 }
示例#3
0
        include 'lib/' . str_replace('\\', '/', $class) . '.php';
    }
});
$instagram = new Instagram();
$kirby = $this;
$this->options['routes'][] = array('pattern' => 'kirbygram/install', 'method' => 'GET', 'action' => function ($path = null) use($instagram, $kirby) {
    if (!$instagram->is_installed()) {
        return f::load(__DIR__ . '/templates/install.php', array('instagram' => $instagram));
    }
    return false;
});
$this->options['routes'][] = array('pattern' => 'kirbygram/done', 'method' => 'GET', 'action' => function ($path = null) use($instagram) {
    if ($instagram->is_installed()) {
        return f::load(__DIR__ . '/templates/complete.php', array('instagram' => $instagram));
    } else {
        return f::load(__DIR__ . '/templates/error.php', array('instagram' => $instagram));
    }
});
$this->options['routes'][] = array('pattern' => 'kirbygram/complete', 'method' => 'POST', 'action' => function ($path = null) use($instagram) {
    if (!$instagram->is_installed()) {
        //write to cache
        $data = $_POST;
        if ($data['kgt'] == $instagram->get_config('csrf')) {
            if ($data['token'] && $data['user']) {
                $instagram->set_config(array('token' => $data['token'], 'user' => $data['user'], 'uid' => $data['uid'], 'installed' => true));
            }
            $instagram->save_config();
        }
        exit;
    }
    return false;
示例#4
0
 /**
  * Get the generated view content.
  *
  * @return  string
  */
 public function content()
 {
     ob_start();
     f::load($this->file, $this->scope);
     $output = ob_get_contents();
     ob_end_clean();
     return $output;
 }