Chyrp

Main Controller

The logic behind the Chyrp install.

Summary
Main Controller The logic behind the Chyrp install.
Variables
$urls An array of clean URL => dirty URL translations.
$displayed Has anything been displayed?
$context Context for displaying pages.
Functions
__construct Loads the Twig parser into Theme, and sets up the theme l10n domain.
parse Determines the action.
post_from_url Check to see if we’re viewing a post, and if it is, handle it.
key_regexp Converts the values in $config->post_url to regular expressions.
index Grabs the posts for the main page.
archive Grabs the posts for the Archive page when viewing a year or a month.
search Grabs the posts for a search query.
drafts Grabs the posts for viewing the Drafts lists.
view Views a post.
page Handles page viewing.
rss Redirects to /feed (backwards compatibility).
id Views a post by its static ID.
toggle_admin Toggles the Admin control panel (if available).
register Process registration.  If registration is disabled or if the user is already logged in, it will error.
login Process logging in.  If the username and password are incorrect or if the user is already logged in, it will error.
logout Logs the current user out.  If they are not logged in, it will error.
controls Updates the current user when the form is submitted.  Shows an error if they aren’t logged in.
lost_password Handles e-mailing lost passwords to a user’s email address.
feed Grabs posts for the feed.
display Display the page.
current Returns a singleton reference to the current class.

Variables

$urls

public $urls

An array of clean URL => dirty URL translations.

$displayed

public $displayed

Has anything been displayed?

$context

public $context

Context for displaying pages.

Functions

__construct

private function __construct()

Loads the Twig parser into Theme, and sets up the theme l10n domain.

parse

public function parse( $route )

Determines the action.

post_from_url

public function post_from_url( $route,   
$request,   
$return_post  =  false )

Check to see if we’re viewing a post, and if it is, handle it.

This can also be used for grabbing a Post from a given URL.

Parameters

$route The route to respond to.
$url If this argument is passed, it will attempt to grab a post from a given URL.  If a post is found by that URL, it will be returned.
$return_post Return a Post?

key_regexp

private function key_regexp( $key )

Converts the values in $config->post_url to regular expressions.

Parameters

$key Input URL with the keys from Post.$url_attrs.

Returns

$key values replaced with their regular expressions from <Routes->$code>.

index

public function index()

Grabs the posts for the main page.

archive

public function archive()

Grabs the posts for the Archive page when viewing a year or a month.

search

public function search()

Grabs the posts for a search query.

drafts

public function drafts()

Grabs the posts for viewing the Drafts lists.

view

public function view( $attrs  =  null )

Views a post.

page

public function page( $urls  =  null )

Handles page viewing.

rss

public function rss()

Redirects to /feed (backwards compatibility).

id

public function id()

Views a post by its static ID.

toggle_admin

public function toggle_admin()

Toggles the Admin control panel (if available).

register

public function register()

Process registration.  If registration is disabled or if the user is already logged in, it will error.

login

public function login()

Process logging in.  If the username and password are incorrect or if the user is already logged in, it will error.

logout

public function logout()

Logs the current user out.  If they are not logged in, it will error.

controls

public function controls()

Updates the current user when the form is submitted.  Shows an error if they aren’t logged in.

lost_password

public function lost_password()

Handles e-mailing lost passwords to a user’s email address.

feed

public function feed( $posts  =  null )

Grabs posts for the feed.

display

public function display( $file  =  null,
$context  =  array(),
$title  =  "" )

Display the page.

If “posts” is in the context and the visitor requested a feed, they will be served.

Parameters

$file The theme file to display.
$context The context for the file.
$title The title for the page.

current

public static function & current()

Returns a singleton reference to the current class.