|
@@ -22,7 +22,7 @@ class Pico {
|
|
// Load plugins
|
|
// Load plugins
|
|
$this->load_plugins();
|
|
$this->load_plugins();
|
|
$this->run_hooks('plugins_loaded');
|
|
$this->run_hooks('plugins_loaded');
|
|
-
|
|
|
|
|
|
+
|
|
// Get request url and script url
|
|
// Get request url and script url
|
|
$url = '';
|
|
$url = '';
|
|
$request_url = (isset($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : '';
|
|
$request_url = (isset($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : '';
|
|
@@ -51,7 +51,7 @@ class Pico {
|
|
$this->run_hooks('after_404_load_content', array(&$file, &$content));
|
|
$this->run_hooks('after_404_load_content', array(&$file, &$content));
|
|
}
|
|
}
|
|
$this->run_hooks('after_load_content', array(&$file, &$content));
|
|
$this->run_hooks('after_load_content', array(&$file, &$content));
|
|
-
|
|
|
|
|
|
+
|
|
// Load the settings
|
|
// Load the settings
|
|
$settings = $this->get_config();
|
|
$settings = $this->get_config();
|
|
$this->run_hooks('config_loaded', array(&$settings));
|
|
$this->run_hooks('config_loaded', array(&$settings));
|
|
@@ -60,7 +60,7 @@ class Pico {
|
|
$this->run_hooks('file_meta', array(&$meta));
|
|
$this->run_hooks('file_meta', array(&$meta));
|
|
$content = $this->parse_content($content);
|
|
$content = $this->parse_content($content);
|
|
$this->run_hooks('content_parsed', array(&$content));
|
|
$this->run_hooks('content_parsed', array(&$content));
|
|
-
|
|
|
|
|
|
+
|
|
// Get all the pages
|
|
// Get all the pages
|
|
$pages = $this->get_pages($settings['base_url'], $settings['pages_order_by'], $settings['pages_order'], $settings['excerpt_length']);
|
|
$pages = $this->get_pages($settings['base_url'], $settings['pages_order_by'], $settings['pages_order'], $settings['excerpt_length']);
|
|
$prev_page = array();
|
|
$prev_page = array();
|
|
@@ -103,7 +103,7 @@ class Pico {
|
|
$this->run_hooks('after_render', array(&$output));
|
|
$this->run_hooks('after_render', array(&$output));
|
|
echo $output;
|
|
echo $output;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Load any plugins
|
|
* Load any plugins
|
|
*/
|
|
*/
|
|
@@ -147,7 +147,7 @@ class Pico {
|
|
private function read_file_meta($content)
|
|
private function read_file_meta($content)
|
|
{
|
|
{
|
|
global $config;
|
|
global $config;
|
|
-
|
|
|
|
|
|
+
|
|
$headers = array(
|
|
$headers = array(
|
|
'title' => 'Title',
|
|
'title' => 'Title',
|
|
'description' => 'Description',
|
|
'description' => 'Description',
|
|
@@ -166,7 +166,7 @@ class Pico {
|
|
$headers[ $field ] = '';
|
|
$headers[ $field ] = '';
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if(isset($headers['date'])) $headers['date_formatted'] = date($config['date_format'], strtotime($headers['date']));
|
|
if(isset($headers['date'])) $headers['date_formatted'] = date($config['date_format'], strtotime($headers['date']));
|
|
|
|
|
|
return $headers;
|
|
return $headers;
|
|
@@ -198,7 +198,7 @@ class Pico {
|
|
|
|
|
|
return $config;
|
|
return $config;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Get a list of pages
|
|
* Get a list of pages
|
|
*
|
|
*
|
|
@@ -210,7 +210,7 @@ class Pico {
|
|
private function get_pages($base_url, $order_by = 'alpha', $order = 'asc', $excerpt_length = 50)
|
|
private function get_pages($base_url, $order_by = 'alpha', $order = 'asc', $excerpt_length = 50)
|
|
{
|
|
{
|
|
global $config;
|
|
global $config;
|
|
-
|
|
|
|
|
|
+
|
|
$pages = $this->get_files(CONTENT_DIR, CONTENT_EXT);
|
|
$pages = $this->get_files(CONTENT_DIR, CONTENT_EXT);
|
|
$sorted_pages = array();
|
|
$sorted_pages = array();
|
|
$date_id = 0;
|
|
$date_id = 0;
|
|
@@ -225,7 +225,7 @@ class Pico {
|
|
if (in_array(substr($page, -1), array('~','#'))) {
|
|
if (in_array(substr($page, -1), array('~','#'))) {
|
|
unset($pages[$key]);
|
|
unset($pages[$key]);
|
|
continue;
|
|
continue;
|
|
- }
|
|
|
|
|
|
+ }
|
|
// Get title and format $page
|
|
// Get title and format $page
|
|
$page_content = file_get_contents($page);
|
|
$page_content = file_get_contents($page);
|
|
$page_meta = $this->read_file_meta($page_content);
|
|
$page_meta = $this->read_file_meta($page_content);
|
|
@@ -252,13 +252,13 @@ class Pico {
|
|
}
|
|
}
|
|
else $sorted_pages[] = $data;
|
|
else $sorted_pages[] = $data;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
if($order == 'desc') krsort($sorted_pages);
|
|
if($order == 'desc') krsort($sorted_pages);
|
|
else ksort($sorted_pages);
|
|
else ksort($sorted_pages);
|
|
-
|
|
|
|
|
|
+
|
|
return $sorted_pages;
|
|
return $sorted_pages;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Processes any hooks and runs them
|
|
* Processes any hooks and runs them
|
|
*
|
|
*
|
|
@@ -311,14 +311,14 @@ class Pico {
|
|
}
|
|
}
|
|
return $protocol;
|
|
return $protocol;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Helper function to recusively get all files in a directory
|
|
* Helper function to recusively get all files in a directory
|
|
*
|
|
*
|
|
* @param string $directory start directory
|
|
* @param string $directory start directory
|
|
* @param string $ext optional limit to file extensions
|
|
* @param string $ext optional limit to file extensions
|
|
* @return array the matched files
|
|
* @return array the matched files
|
|
- */
|
|
|
|
|
|
+ */
|
|
private function get_files($directory, $ext = '')
|
|
private function get_files($directory, $ext = '')
|
|
{
|
|
{
|
|
$array_items = array();
|
|
$array_items = array();
|
|
@@ -337,14 +337,14 @@ class Pico {
|
|
}
|
|
}
|
|
return $array_items;
|
|
return $array_items;
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* Helper function to limit the words in a string
|
|
* Helper function to limit the words in a string
|
|
*
|
|
*
|
|
* @param string $string the given string
|
|
* @param string $string the given string
|
|
* @param int $word_limit the number of words to limit to
|
|
* @param int $word_limit the number of words to limit to
|
|
* @return string the limited string
|
|
* @return string the limited string
|
|
- */
|
|
|
|
|
|
+ */
|
|
private function limit_words($string, $word_limit)
|
|
private function limit_words($string, $word_limit)
|
|
{
|
|
{
|
|
$words = explode(' ',$string);
|
|
$words = explode(' ',$string);
|