private function save() { if ($this->isValid()) { $this->article->save(); header('Location: /admin/articles'); } }
public function __construct() { $id = @$_GET['id']; $this->article = Article::find($id); if (!$this->article) { //Find first article $all = Article::all(); $this->article = reset($all); } }
private function remove() { Article::remove($_GET['id']); header('Location: /admin/articles'); }
<?php use Nbml\AutoLoader\ClassAutoLoader; use Nbml\AutoLoader\ViewAutoLoader; use Nbml\Compiler; use NetBricks\SimpleCms\Di; session_start(); if (!defined('LIBRARY_PATH')) { define('NBML_LIBRARY_DIR', realpath(__DIR__ . '/../../../library')); } require_once NBML_LIBRARY_DIR . '/Nbml/AutoLoader/ViewAutoLoader.php'; require_once NBML_LIBRARY_DIR . '/Nbml/AutoLoader/ClassAutoLoader.php'; initialize_autoloaders: $classAutoLoader = new ClassAutoLoader(); $classAutoLoader->addIncludePath(NBML_LIBRARY_DIR)->addIncludePath(__DIR__ . '/../src')->register(); $viewAutoLoader = new ViewAutoLoader(); $viewAutoLoader->setCompilerDefaultDestinationDir(__DIR__ . '/../tmp')->setAlwaysCompile(true)->addIncludePath(__DIR__ . '/../src')->register(); $viewCompiler = new Compiler(); $viewCompiler->addTagProcessor('\\Nbml\\MetadataTag\\PublicMetadataTag')->addTagProcessor('\\Nbml\\MetadataTag\\StateMetadataTag')->addTagProcessor('\\Nbml\\MetadataTag\\OnDemandMetadataTag')->addTagProcessor('\\Nbml\\MetadataTag\\OnStateMetadataTag')->addTagProcessor('\\Nbml\\MetadataTag\\CssMetadataTag')->addTagProcessor('\\Nbml\\MetadataTag\\JsMetadataTag')->addTagProcessor('\\NetBricks\\SimpleCms\\AdminAccessMetadataTag'); $viewAutoLoader->setViewCompiler($viewCompiler); Di::sqLiteFilePath(realpath(__DIR__ . '/../var/') . '/base.db'); Di::secretFilePath(realpath(__DIR__ . '/../var/') . '/secret'); //Installation: \NetBricks\SimpleCms\Model\Article::initDb(); echo new NetBricks\SimpleCms\View\Application();