Esempio n. 1
0
 public function error()
 {
     $view = new View($this->viewPath . '/error.phtml');
     $view->title = 'Error - Page Not Found.';
     $this->response->setBody($view->render());
     $this->response->send(404);
 }
Esempio n. 2
0
 /**
  * Get map with locations
  *
  * @param  int $id
  * @return string
  */
 public function getMap($id)
 {
     $map = Table\Maps::findById($id);
     if (isset($map->id)) {
         $mapData = $map->getColumns();
         $mapData['map_id'] = 'phire-map-' . $id;
         $mapData['map_class'] = 'phire-map-div';
         $mapData['locations'] = Table\MapLocations::findBy(['map_id' => $id])->rows();
         $view = new View(__DIR__ . '/../../view/maps-public/map.phtml', $mapData);
         return $view->render();
     } else {
         return '';
     }
 }
Esempio n. 3
0
 public function send($code = 200, array $headers = null, $body = null)
 {
     $this->response->setCode($code);
     if (null !== $body) {
         $this->response->setBody($body);
     } else {
         if (null !== $this->view) {
             $this->response->setBody($this->view->render());
         }
     }
     $this->response->send($code, $headers);
 }
 /**
  * Send response
  *
  * @param  int    $code
  * @param  array  $headers
  * @param  string $body
  * @return void
  */
 public function send($code = 200, array $headers = null, $body = null)
 {
     $this->response->setCode($code);
     $this->application->trigger('app.send.pre', ['controller' => $this]);
     if (null !== $body) {
         $this->response->setBody($body);
     } else {
         if (null !== $this->view) {
             $this->response->setBody($this->view->render());
         }
     }
     $this->application->trigger('app.send.post', ['controller' => $this]);
     $this->response->send($code, $headers);
 }
 protected function output($dir)
 {
     if (!file_exists($dir)) {
         mkdir($dir);
     }
     if (!file_exists($dir . '/css')) {
         mkdir($dir . '/css');
     }
     if (!file_exists($dir . '/js')) {
         mkdir($dir . '/js');
     }
     copy(__DIR__ . '/../../data/assets/css/styles.css', $dir . '/css/styles.css');
     copy(__DIR__ . '/../../data/assets/js/scripts.js', $dir . '/js/scripts.js');
     $data = ['base' => $this->crawler->getBaseUrl(), 'urls' => $this->crawler->getCrawled()];
     $index = new View(__DIR__ . '/../../view/index.phtml', $data);
     $sitemap = new View(__DIR__ . '/../../view/sitemap.php', $data);
     file_put_contents($dir . '/index.html', $index->render());
     file_put_contents($dir . '/sitemap.xml', $sitemap->render());
 }