Controllers
Main Controller
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. |
__construct
private function __construct()
Loads the Twig parser into Theme, and sets up the theme l10n domain.
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>.