Added some inline docs.
This commit is contained in:
Gilbert Pellegrom 2013-04-26 17:38:10 +01:00
parent 7d2f97f2f6
commit c88f8e7967
2 changed files with 39 additions and 4 deletions

View file

@ -1,9 +1,5 @@
<?php
/*
* Pico v0.1
*/
// Defines
define('ROOT_DIR', realpath(dirname(__FILE__)) .'/');
define('CONTENT_DIR', ROOT_DIR .'content/');
define('LIB_DIR', ROOT_DIR .'lib/');

View file

@ -1,7 +1,19 @@
<?php
/**
* Pico
*
* @author Gilbert Pellegrom
* @link http://pico.dev7studios.com/
* @license http://opensource.org/licenses/MIT
* @version 0.2
*/
class Pico {
/**
* The constructor carries out all the processing in Pico.
* Does URL routing, Markdown processing and Twig processing.
*/
function __construct()
{
// Get request url and script url
@ -51,6 +63,12 @@ class Pico {
));
}
/**
* Parses the content using Markdown
*
* @param string $content the raw txt content
* @return string $content the Markdown formatted content
*/
function parse_content($content)
{
$content = str_replace('%base_url%', $this->base_url(), $content);
@ -59,6 +77,12 @@ class Pico {
return $content;
}
/**
* Parses the file meta from the txt file header
*
* @param string $content the raw txt content
* @return array $headers an array of meta values
*/
function read_file_meta($content)
{
$headers = array(
@ -78,6 +102,11 @@ class Pico {
return $headers;
}
/**
* Loads the config
*
* @return array $defaults an array of config values
*/
function get_config()
{
global $config;
@ -96,6 +125,11 @@ class Pico {
return $defaults;
}
/**
* Helper function to work out the base URL
*
* @return string the base url
*/
function base_url()
{
global $config;
@ -110,6 +144,11 @@ class Pico {
return rtrim(str_replace($url, '', $protocol . "://" . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']), '/');
}
/**
* Tries to guess the server protocol. Used in base_url()
*
* @return string the current protocol
*/
function get_protocol()
{
preg_match("|^HTTP[S]?|is",$_SERVER['SERVER_PROTOCOL'],$m);