public static function __initialize() { $app = static::instance(); $uri = Url::current()->uri(); $css = ['css/bootstrap.css', 'css/bootstrap-responsive.css']; $js = ['js/jquery.js', 'js/bootstrap.js']; $app->response = Response::instance(); $app->session = Session::instance(); $app->cache = Datastore::instance(); $app->css = Asset::collection($css); $app->js = Asset::collection($js); // If there is no url, then we're on the home page. trim($uri, '/') == '' and $uri = '@@HOME'; if ($page = Model\Page::findOneByUri($uri)) { $app->response->setBody($page->title); return; } try { Controller::instance()->dispatch($uri, $app->response); return; } catch (HttpException $e) { if (!($page = Model\Page::findOneByUri($uri = '@@404'))) { // Fallback to system handling. throw new HttpException(404, 'Page Not Found'); } $app->response->setStatus(404); $app->response->setBody($page->title); return; } }
/** * Instance Constructor * * @param string Path to file relative to DOCROOT * @throws OutOfBoundsException When the asset cannot be located * @return Nerd\Asset\Type */ public function __construct($file) { $this->file = Url::asset($file); $this->fullPath = DOCROOT . DS . 'assets' . DS . trim($file, '/'); if (!file_exists($this->fullPath)) { throw new \OutOfBoundsException("The asset [{$file}] could not be found."); } }
public function actionDelete($id = null) { try { $page = Page::findOneById($id); list($success, $count) = $page->delete(); } catch (\Nerd\DB\Exception $e) { $this->flash->set('warning', "You may not delete <em>{$page->title}</em>. It is a <strong>Nerd</strong> protected file."); $this->application->redirect(Url::site('/pages')); } if ($success and $count > 0) { $this->flash->set('success', "<em>{$page->title}</em> has been deleted."); } else { $this->flash->set('error', "<em>{$page->title}</em> could not be deleted."); } $this->application->redirect(Url::site('/pages')); }
<?php namespace Nerd; use Application\Flash; ?> <h2>Host <small><?php echo $site->host; ?> </small></h2> <?php echo Flash::info($flash->get('info')); echo Flash::success($flash->get('success')); echo Flash::warning($flash->get('warning')); echo Flash::error($flash->get('error')); ?> <a href="<?php echo Url::site('/sites'); ?> " class="btn">Back</a><?php
public function actionDelete($id = null) { try { $site = Site::findOneById($id); list($success, $count) = $site->delete(); } catch (\Nerd\DB\Exception $e) { $this->flash->set('warning', "There was a database error..."); $this->application->redirect(Url::site('/sites')); } if ($success and $count > 0) { $this->flash->set('success', "<strong>{$site->host}</strong> has been deleted."); } else { $this->flash->set('error', "<strong>{$site->host}</strong> could not be deleted."); } $this->application->redirect(Url::site('/sites')); }
?> " class="btn btn-mini">View</a> <a href="<?php echo Url::site("/sites/update/{$site->id}"); ?> " class="btn btn-mini">Edit</a> <a href="<?php echo Url::site("/sites/delete/{$site->id}"); ?> " class="btn btn-mini btn-danger">Delete</a> </td> </tr> <?php } ?> </tbody> </table> <?php } else { ?> <p>There are no results to display.</p> <?php } ?> <div class="form-actions"> <a href="<?php echo Url::site('/sites/create'); ?> " class="btn btn-primary">New Site</a> </div><?php
<?php namespace Nerd; use Application\Flash; ?> <h2><?php echo $page->title; ?> <small><?php echo $page->uri; ?> </small></h2> <?php echo Flash::info($flash->get('info')); echo Flash::success($flash->get('success')); echo Flash::warning($flash->get('warning')); echo Flash::error($flash->get('error')); ?> <a href="<?php echo Url::site($lastSearch); ?> " class="btn">Back</a><?php