ShiftSmith alpha

ShiftSmith - Docs

Documents in gear


string q()

Get the current URL state. For example:, q() would return "/user"

string q( string $string )

Verify if current provided string matches URL path. For example:, q('user') would return true. (Shortcut to function inpath)

string q( int $arg )

Get the current URL path. For example:, q(0) would return "user".

inpath(string $string)

string inpath('/user/*')

Verify if current provided string matches URL path. For example:, inpath("/user/*") would return true.

elog(string $string)


log message in logs/errors.log

form_cache(string $form_name, array $default_values, string $options)

form_cache('my_form', array('first_name'=>'Luc', 'last_name'=>'laverdure))

Steps taken:

  1. If no value is currently set, set default values into session.
  2. Override session variables if POST var or GET var matches a form field


  1. 'FORCE.CACHE': Force override session values with default values.
  2. 'FETCH.ONLY': POST and GET vars are ignored.

validate_email(string $email)


Returns true if email is valid, returns false if email is invalid.

redirect(string $URL)


redirects user to URL specified

t(string $string)


print translated output, Database required to host all strings and their matched translations.

email(string $to, string $subject, string $message)

email('', 'Hi Luc', 'ShiftSmith is awesome!')

Send email to target $to, with $subject and $message.


class MyFirstController extends Controller {
	function validate() {
		// when this function returns false,
		// the controller will be destroyed without execution.
		// the order of execution will be set by the value returned by this function.
		// 1 being first, 2 being second, [...]
		// in the example below,
		// on the page "/user",
		// the controller will fire first.

		// if the user visits any other url,
		// we cancel the execution.
		if (inpath('user')) return 1;
		else return false;

	function execute() {
		// your application logic goes in this function.
		// add models to be passed on to the views
		$this->addModel('page', 'title', 'My First Page Title');
		// render a view and give it all controllers models

Controller->addModel(string $namespace, string $var, string $value)

$this->addModel('page', 'title', 'ShiftSmith')

Add a model to the Controller to render in a view. In the above example, [page.title] would render "ShfitSmith" in a templated file.

Controller->setModel(string $namespace, string $var, string $value)

(deprecated) same as $this->addModel

Controller->modResultsModel(array $results, array $keys, function $function, string $new_col)


I forgot what I built this for, usability coming soon!

Controller->getModel(string $namespace, string $var)

$this->getModel('page', 'title')

returns the value of $namespace.$var

Controller->loadModel(string $namespace, string $var, controller $controler)

$this->loadModel('page', 'title')

I forgot what it does o_O

Controller->cacheForm(string $name, array $default_values, Y/N $forcecache)

$this->cacheForm('subscribe', array('email'=>'', 'first_name'=>'Luc', 'last_name'=>'the batman'))

Automaticcally save to session all values of the form initial or set

Controller->cacheForm(string $namespace, string $name, string $value)

$this->cacheForm('subscribe', 'email', '')

Single namespace + name cache storage

Controller->getcache(string $namespace, string $name)

$this->getcache('subscribe', 'email')

Single namespace + name cache fetch from storage

Controller->loadView(string||array $view_filename)


Render output with models passed to view.

Controller->injectView($selector_output, $mode, $inputURL, $selector_input)

Input: (

							<h1 class="name"><a href="/">Luc Laverdure</a></h1>

Output: (myapp/view.tpl)

						<div class="fetched-title"></div>

Output: (myapp/view.tpl)

				$this->injectView('.fetched-title', 'append', '', 'h1 a');

Inject render within view

Controller->loadViewAsJSON($omitted_namespaces, $ommited_models)

$this->loadViewAsJSON(array('user'), array('password'))

Echoes JSON output of all models, except omitted namespaces and omitted models



Echoes JSON output of all models, no exceptions.


<!-- Include header file -->

<!-- output model value -->

<!-- output translated model value -->

<!-- output array block -->
	<li><a href="[]">[myblock.text]</a></li>