Merge b79477d65e
into 234c295f69
This commit is contained in:
commit
e307807915
1 changed files with 14 additions and 15 deletions
29
lib/pico.php
29
lib/pico.php
|
@ -63,7 +63,7 @@ class Pico {
|
|||
$content = $this->parse_content($content);
|
||||
$this->run_hooks('after_parse_content', array(&$content));
|
||||
$this->run_hooks('content_parsed', array(&$content)); // Depreciated @ v0.8
|
||||
|
||||
|
||||
// Get all the pages
|
||||
$pages = $this->get_pages($settings['base_url'], $settings['pages_order_by'], $settings['pages_order'], $settings['excerpt_length']);
|
||||
$prev_page = array();
|
||||
|
@ -82,7 +82,6 @@ class Pico {
|
|||
|
||||
// Load the theme
|
||||
$this->run_hooks('before_twig_register');
|
||||
Twig_Autoloader::register();
|
||||
$loader = new Twig_Loader_Filesystem(THEMES_DIR . $settings['theme']);
|
||||
$twig = new Twig_Environment($loader, $settings['twig_config']);
|
||||
$twig->addExtension(new Twig_Extension_Debug());
|
||||
|
@ -108,7 +107,7 @@ class Pico {
|
|||
$this->run_hooks('after_render', array(&$output));
|
||||
echo $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load any plugins
|
||||
*/
|
||||
|
@ -152,7 +151,7 @@ class Pico {
|
|||
protected function read_file_meta($content)
|
||||
{
|
||||
global $config;
|
||||
|
||||
|
||||
$headers = array(
|
||||
'title' => 'Title',
|
||||
'description' => 'Description',
|
||||
|
@ -172,7 +171,7 @@ class Pico {
|
|||
$headers[ $field ] = '';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if(isset($headers['date'])) $headers['date_formatted'] = date($config['date_format'], strtotime($headers['date']));
|
||||
|
||||
return $headers;
|
||||
|
@ -204,7 +203,7 @@ class Pico {
|
|||
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of pages
|
||||
*
|
||||
|
@ -216,7 +215,7 @@ class Pico {
|
|||
protected function get_pages($base_url, $order_by = 'alpha', $order = 'asc', $excerpt_length = 50)
|
||||
{
|
||||
global $config;
|
||||
|
||||
|
||||
$pages = $this->get_files(CONTENT_DIR, CONTENT_EXT);
|
||||
$sorted_pages = array();
|
||||
$date_id = 0;
|
||||
|
@ -231,7 +230,7 @@ class Pico {
|
|||
if (in_array(substr($page, -1), array('~','#'))) {
|
||||
unset($pages[$key]);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
// Get title and format $page
|
||||
$page_content = file_get_contents($page);
|
||||
$page_meta = $this->read_file_meta($page_content);
|
||||
|
@ -258,13 +257,13 @@ class Pico {
|
|||
}
|
||||
else $sorted_pages[] = $data;
|
||||
}
|
||||
|
||||
|
||||
if($order == 'desc') krsort($sorted_pages);
|
||||
else ksort($sorted_pages);
|
||||
|
||||
|
||||
return $sorted_pages;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Processes any hooks and runs them
|
||||
*
|
||||
|
@ -314,14 +313,14 @@ class Pico {
|
|||
}
|
||||
return $protocol;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function to recusively get all files in a directory
|
||||
*
|
||||
* @param string $directory start directory
|
||||
* @param string $ext optional limit to file extensions
|
||||
* @return array the matched files
|
||||
*/
|
||||
*/
|
||||
protected function get_files($directory, $ext = '')
|
||||
{
|
||||
$array_items = array();
|
||||
|
@ -340,14 +339,14 @@ class Pico {
|
|||
}
|
||||
return $array_items;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Helper function to limit the words in a string
|
||||
*
|
||||
* @param string $string the given string
|
||||
* @param int $word_limit the number of words to limit to
|
||||
* @return string the limited string
|
||||
*/
|
||||
*/
|
||||
protected function limit_words($string, $word_limit)
|
||||
{
|
||||
$words = explode(' ',$string);
|
||||
|
|
Loading…
Add table
Reference in a new issue