Skip to content

Instantly share code, notes, and snippets.

View makeusabrew's full-sized avatar
💭
I may be slow to respond.

Nick Payne makeusabrew

💭
I may be slow to respond.
View GitHub Profile
@makeusabrew
makeusabrew / articles.php
Created October 6, 2011 07:49
Jaoss - News Article Model
<?php
/* apps/news/models/articles.php */
class Article extends Object {
// we don't any extended functionality just yet
}
class Articles extends Table {
protected $order_by = "`created` DESC"; // we want our newest articles first
@makeusabrew
makeusabrew / build.ini
Created October 6, 2011 08:33
Jaoss - sample build.ini configuration
; live.ini -> demo.ini -> build.ini
; we only override what we need to in here
[errors]
; we want debug level error messages on screen
verbose=true
[log]
level=debug
@makeusabrew
makeusabrew / 1) paths.php
Created October 6, 2011 09:15
Jaoss - simple news article path, controller and view
<?php
/* apps/news/paths.php */
PathManager::loadPaths(
array("/articles/add", "add_article")
);
@makeusabrew
makeusabrew / add_article.tpl
Created October 6, 2011 09:38
Jaoss - add article basic form
{* apps/news/views/add_article *}
<h1>Add an article</h1>
<p>Your story will be automatically published - so keep it clean!</p>
<form action="/articles/add" method="post">
{include file='default/views/helpers/field.tpl' field='title'}
{include file='default/views/helpers/field.tpl' field='intro'}
{include file='default/views/helpers/field.tpl' field='content'}
{include file='default/views/helpers/field.tpl' field='author_email'}
@makeusabrew
makeusabrew / add_article.tpl
Created October 6, 2011 09:47
Jaoss - add article form #2
{* apps/news/views/add_article *}
<h1>Add an article</h1>
<p>Your story will be automatically published - so keep it clean!</p>
<form action="/articles/add" method="post">
{include file='default/views/helpers/field.tpl' field='title' required=true}
{include file='default/views/helpers/field.tpl' field='intro' type='textarea'}
{include file='default/views/helpers/field.tpl' field='content' type='textarea' required=true}
{include file='default/views/helpers/field.tpl' field='author_email' type='email' required=true title='Author Email'}
@makeusabrew
makeusabrew / 1) news.php
Created October 6, 2011 09:55
Jaoss - add article form controller / view refactoring
<?php
/* apps/news/controllers/news.php */
class NewsController extends Controller {
public function add_article() {
// pass the columns array through to smarty
$this->assign("columns", Table::factory('Articles')->getColumns());
}
}
@makeusabrew
makeusabrew / news.php
Created October 6, 2011 10:15
Jaoss - add article controller
<?php
/* apps/news/controllers/news.php */
class NewsController extends Controller {
public function add_article() {
// pass the columns array through to smarty
$this->assign("columns", Table::factory('Articles')->getColumns());
if ($this->request->isPost()) {
// ah ha - handle user input
@makeusabrew
makeusabrew / paths.php
Created October 6, 2011 10:46
Jaoss - dynamic path pattern
<?php
/* apps/news/paths.php */
PathManager::loadPaths(
array("/articles/add", "add_article"),
array("/articles/(?P<id>\d+)", "view_article")
);
@makeusabrew
makeusabrew / news.php
Created October 6, 2011 11:04
Jaoss - view article logic
<?php
/* apps/news/controllers/news.php */
class NewsController extends Controller {
public function add_article() {
$this->assign("columns", Table::factory('Articles')->getColumns());
if ($this->request->isPost()) {
$article = Table::factory('Articles')->newObject();
@makeusabrew
makeusabrew / index.php
Created October 13, 2011 17:02
php 5.2 compat
<?php
// change this:
set_error_handler(function($errno, $errstr, $errfile, $errline) {
if (error_reporting() == 0) {
//Log::info("Surpressed error (".$errno.") caught in handler: [".$errstr."] in [".$errfile."] line ["
return;
}
throw new ErrorException($errstr, 0, $errno, $errfile, $errline);
});