Merge 6bcd5c832e
into ec37ff4e75
This commit is contained in:
commit
5f38a5d176
41 changed files with 3805 additions and 1884 deletions
20
.gitignore
vendored
20
.gitignore
vendored
|
@ -1,5 +1,23 @@
|
|||
# Composer
|
||||
composer.lock
|
||||
composer.phar
|
||||
|
||||
# Twig
|
||||
vendor/twig/twig/doc/*
|
||||
vendor/twig/twig/ext/*
|
||||
vendor/twig/twig/test/*
|
||||
vendor/twig/twig/test/*
|
||||
|
||||
# OS Generated
|
||||
.DS_Store*
|
||||
ehthumbs.db
|
||||
Icon?
|
||||
Thumbs.db
|
||||
*.swp
|
||||
|
||||
# User themes
|
||||
themes/*
|
||||
!themes/index.html
|
||||
!themes/default/*
|
||||
|
||||
# User config
|
||||
config.php
|
||||
|
|
|
@ -1,5 +1,14 @@
|
|||
*** Pico Changelog ***
|
||||
|
||||
2013.07.21 - version 0.7a2
|
||||
* [new] Added ability to use custom meta data
|
||||
* [new] Added ability to choose custom template per page
|
||||
* [changed] Removed closing php tags from files
|
||||
* [changed] Now managing markdown parser via composer
|
||||
* [changed] Updated Twig version
|
||||
* [changed] get_files no longer gets dotfiles
|
||||
* [fixed] Issues with updating Pico install once in use
|
||||
|
||||
2013.05.07 - version 0.6.2
|
||||
* [Changed] Replaced glob_recursive with get_files
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
{
|
||||
"require": {
|
||||
"twig/twig": "1.12.*"
|
||||
"twig/twig": "1.*",
|
||||
"michelf/php-markdown": "1.*"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -22,4 +22,4 @@ $config['custom_setting'] = 'Hello'; // Can be accessed by {{ config.custom_set
|
|||
|
||||
*/
|
||||
|
||||
?>
|
||||
// End of file
|
|
@ -9,8 +9,7 @@ define('THEMES_DIR', ROOT_DIR .'themes/');
|
|||
define('CACHE_DIR', LIB_DIR .'cache/');
|
||||
|
||||
require(ROOT_DIR .'vendor/autoload.php');
|
||||
require(LIB_DIR .'markdown.php');
|
||||
require(LIB_DIR .'pico.php');
|
||||
$pico = new Pico();
|
||||
|
||||
?>
|
||||
// End of file
|
1732
lib/markdown.php
1732
lib/markdown.php
File diff suppressed because it is too large
Load diff
105
lib/pico.php
105
lib/pico.php
|
@ -1,5 +1,5 @@
|
|||
<?php
|
||||
|
||||
use \Michelf\MarkdownExtra;
|
||||
/**
|
||||
* Pico
|
||||
*
|
||||
|
@ -21,7 +21,7 @@ class Pico {
|
|||
// Load plugins
|
||||
$this->load_plugins();
|
||||
$this->run_hooks('plugins_loaded');
|
||||
|
||||
|
||||
// Get request url and script url
|
||||
$url = '';
|
||||
$request_url = (isset($_SERVER['REQUEST_URI'])) ? $_SERVER['REQUEST_URI'] : '';
|
||||
|
@ -50,7 +50,7 @@ class Pico {
|
|||
$this->run_hooks('after_404_load_content', array(&$file, &$content));
|
||||
}
|
||||
$this->run_hooks('after_load_content', array(&$file, &$content));
|
||||
|
||||
|
||||
// Load the settings
|
||||
$settings = $this->get_config();
|
||||
$this->run_hooks('config_loaded', array(&$settings));
|
||||
|
@ -59,14 +59,14 @@ class Pico {
|
|||
$this->run_hooks('file_meta', array(&$meta));
|
||||
$content = $this->parse_content($content);
|
||||
$this->run_hooks('content_parsed', array(&$content));
|
||||
|
||||
|
||||
// Get all the pages
|
||||
$pages = $this->get_pages($settings['base_url'], $settings['pages_order_by'], $settings['pages_order'], $settings['excerpt_length']);
|
||||
$prev_page = array();
|
||||
$current_page = array();
|
||||
$next_page = array();
|
||||
while($current_page = current($pages)){
|
||||
if($meta['title'] == $current_page['title']){
|
||||
if((isset($meta['title'])) && ($meta['title'] == $current_page['title'])){
|
||||
break;
|
||||
}
|
||||
next($pages);
|
||||
|
@ -97,12 +97,15 @@ class Pico {
|
|||
'next_page' => $next_page,
|
||||
'is_front_page' => $url ? false : true,
|
||||
);
|
||||
// use a custom template if specified Template: [filename] in page meta e.g. Template: spesh to try and use spesh.html in theme folder
|
||||
$template = ((isset($meta['template']) && file_exists($twig_vars['theme_dir'].'/'.$meta['template'].'.html')) ? $meta['template'].'.html' : 'index.html');
|
||||
|
||||
$this->run_hooks('before_render', array(&$twig_vars, &$twig));
|
||||
$output = $twig->render('index.html', $twig_vars);
|
||||
$output = $twig->render($template, $twig_vars);
|
||||
$this->run_hooks('after_render', array(&$output));
|
||||
echo $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Load any plugins
|
||||
*/
|
||||
|
@ -132,7 +135,7 @@ class Pico {
|
|||
{
|
||||
$content = preg_replace('#/\*.+?\*/#s', '', $content); // Remove comments and meta
|
||||
$content = str_replace('%base_url%', $this->base_url(), $content);
|
||||
$content = Markdown($content);
|
||||
$content = MarkdownExtra::defaultTransform($content);
|
||||
|
||||
return $content;
|
||||
}
|
||||
|
@ -146,24 +149,33 @@ class Pico {
|
|||
private function read_file_meta($content)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$headers = array(
|
||||
'title' => 'Title',
|
||||
'description' => 'Description',
|
||||
'author' => 'Author',
|
||||
'date' => 'Date',
|
||||
'robots' => 'Robots'
|
||||
);
|
||||
$headers = array();
|
||||
|
||||
foreach ($headers as $field => $regex){
|
||||
if (preg_match('/^[ \t\/*#@]*' . preg_quote($regex, '/') . ':(.*)$/mi', $content, $match) && $match[1]){
|
||||
$headers[ $field ] = trim(preg_replace("/\s*(?:\*\/|\?>).*/", '', $match[1]));
|
||||
} else {
|
||||
$headers[ $field ] = '';
|
||||
preg_match('/\/\*.*?\*\//ism', $content, $match);
|
||||
$content = $match[0];
|
||||
|
||||
// parse values and custom fields, add to headers array
|
||||
$rval = preg_match_all('/^(.*):(.*)$/mi', $content, $matches);
|
||||
if($rval){
|
||||
for($m=0;$m<count($matches[1]);$m++){
|
||||
$field = trim(strtolower($matches[1][$m]));
|
||||
$headers[$field] = trim($matches[2][$m]);
|
||||
}
|
||||
}
|
||||
|
||||
if($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']));
|
||||
|
||||
if(empty($headers['title'])){
|
||||
preg_match('/^(.+?)[ ]*\n(=+|-+)[ ]*\n+/imu',$content,$matches);
|
||||
if(count($matches) > 0){
|
||||
$headers['title'] = $matches[1];
|
||||
}else{
|
||||
preg_match('/^\#{1}([^\#].*)$/imu',$content,$matches);
|
||||
if(count($matches) > 0){
|
||||
$headers['title'] = $matches[1];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return $headers;
|
||||
}
|
||||
|
@ -175,10 +187,8 @@ class Pico {
|
|||
*/
|
||||
private function get_config()
|
||||
{
|
||||
if(!file_exists(ROOT_DIR .'config.php')) return array();
|
||||
|
||||
global $config;
|
||||
require_once(ROOT_DIR .'config.php');
|
||||
@include_once(ROOT_DIR .'config.php');
|
||||
|
||||
$defaults = array(
|
||||
'site_title' => 'Pico',
|
||||
|
@ -196,7 +206,7 @@ class Pico {
|
|||
|
||||
return $config;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get a list of pages
|
||||
*
|
||||
|
@ -208,7 +218,7 @@ class Pico {
|
|||
private 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;
|
||||
|
@ -218,36 +228,46 @@ class Pico {
|
|||
unset($pages[$key]);
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// Ignore Emacs (and Nano) temp files
|
||||
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);
|
||||
if(!$page_meta) trigger_error("$page meta not read");
|
||||
$page_content = $this->parse_content($page_content);
|
||||
$url = str_replace(CONTENT_DIR, $base_url .'/', $page);
|
||||
$url = str_replace('index'. CONTENT_EXT, '', $url);
|
||||
$url = str_replace(CONTENT_EXT, '', $url);
|
||||
$data = array(
|
||||
'title' => $page_meta['title'],
|
||||
$data = array();
|
||||
// these are generic fields that are added
|
||||
foreach ($page_meta as $key => $value) {
|
||||
$data[$key] = isset($page_meta[$key]) ? $value : null;
|
||||
}
|
||||
// these are special fields and need to be overwritten
|
||||
$extras = array(
|
||||
'url' => $url,
|
||||
'author' => $page_meta['author'],
|
||||
'date' => $page_meta['date'],
|
||||
'date_formatted' => date($config['date_format'], strtotime($page_meta['date'])),
|
||||
'date_formatted' => isset($page_meta['date']) ? date($config['date_format'], strtotime($page_meta['date'])) : null,
|
||||
'content' => $page_content,
|
||||
'excerpt' => $this->limit_words(strip_tags($page_content), $excerpt_length)
|
||||
);
|
||||
if($order_by == 'date'){
|
||||
$data = array_merge($data, $extras);
|
||||
if($order_by == 'date' && isset($page_meta['date'])){
|
||||
$sorted_pages[$page_meta['date'].$date_id] = $data;
|
||||
$date_id++;
|
||||
}
|
||||
else $sorted_pages[] = $data;
|
||||
}
|
||||
|
||||
|
||||
if($order == 'desc') krsort($sorted_pages);
|
||||
else ksort($sorted_pages);
|
||||
|
||||
|
||||
return $sorted_pages;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Processes any hooks and runs them
|
||||
*
|
||||
|
@ -294,20 +314,20 @@ class Pico {
|
|||
preg_match("|^HTTP[S]?|is",$_SERVER['SERVER_PROTOCOL'],$m);
|
||||
return strtolower($m[0]);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 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
|
||||
*/
|
||||
*/
|
||||
private function get_files($directory, $ext = '')
|
||||
{
|
||||
$array_items = array();
|
||||
if($handle = opendir($directory)){
|
||||
while(false !== ($file = readdir($handle))){
|
||||
if($file != "." && $file != ".."){
|
||||
if(preg_match("/^(^\.)/", $file) === 0){
|
||||
if(is_dir($directory. "/" . $file)){
|
||||
$array_items = array_merge($array_items, $this->get_files($directory. "/" . $file, $ext));
|
||||
} else {
|
||||
|
@ -320,14 +340,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
|
||||
*/
|
||||
*/
|
||||
private function limit_words($string, $word_limit)
|
||||
{
|
||||
$words = explode(' ',$string);
|
||||
|
@ -336,4 +356,3 @@ class Pico {
|
|||
|
||||
}
|
||||
|
||||
?>
|
|
@ -76,4 +76,4 @@ class Pico_Plugin {
|
|||
|
||||
}
|
||||
|
||||
?>
|
||||
// End of file
|
2
vendor/autoload.php
vendored
2
vendor/autoload.php
vendored
|
@ -4,4 +4,4 @@
|
|||
|
||||
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
||||
|
||||
return ComposerAutoloaderInit5115ee54a7a3f173d564b433db6d791a::getLoader();
|
||||
return ComposerAutoloaderInitd3f3ddfcd389e44ff4d537046ed744e9::getLoader();
|
||||
|
|
1
vendor/composer/autoload_namespaces.php
vendored
1
vendor/composer/autoload_namespaces.php
vendored
|
@ -7,4 +7,5 @@ $baseDir = dirname($vendorDir);
|
|||
|
||||
return array(
|
||||
'Twig_' => $vendorDir . '/twig/twig/lib',
|
||||
'Michelf' => $vendorDir . '/michelf/php-markdown',
|
||||
);
|
||||
|
|
6
vendor/composer/autoload_real.php
vendored
6
vendor/composer/autoload_real.php
vendored
|
@ -2,7 +2,7 @@
|
|||
|
||||
// autoload_real.php generated by Composer
|
||||
|
||||
class ComposerAutoloaderInit5115ee54a7a3f173d564b433db6d791a
|
||||
class ComposerAutoloaderInitd3f3ddfcd389e44ff4d537046ed744e9
|
||||
{
|
||||
private static $loader;
|
||||
|
||||
|
@ -19,9 +19,9 @@ class ComposerAutoloaderInit5115ee54a7a3f173d564b433db6d791a
|
|||
return self::$loader;
|
||||
}
|
||||
|
||||
spl_autoload_register(array('ComposerAutoloaderInit5115ee54a7a3f173d564b433db6d791a', 'loadClassLoader'), true, true);
|
||||
spl_autoload_register(array('ComposerAutoloaderInitd3f3ddfcd389e44ff4d537046ed744e9', 'loadClassLoader'), true, true);
|
||||
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInit5115ee54a7a3f173d564b433db6d791a', 'loadClassLoader'));
|
||||
spl_autoload_unregister(array('ComposerAutoloaderInitd3f3ddfcd389e44ff4d537046ed744e9', 'loadClassLoader'));
|
||||
|
||||
$vendorDir = dirname(__DIR__);
|
||||
$baseDir = dirname($vendorDir);
|
||||
|
|
67
vendor/composer/installed.json
vendored
67
vendor/composer/installed.json
vendored
|
@ -1,27 +1,27 @@
|
|||
[
|
||||
{
|
||||
"name": "twig/twig",
|
||||
"version": "v1.12.3",
|
||||
"version_normalized": "1.12.3.0",
|
||||
"version": "v1.13.1",
|
||||
"version_normalized": "1.13.1.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/fabpot/Twig.git",
|
||||
"reference": "v1.12.3"
|
||||
"reference": "v1.13.1"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/fabpot/Twig/zipball/v1.12.3",
|
||||
"reference": "v1.12.3",
|
||||
"url": "https://api.github.com/repos/fabpot/Twig/zipball/v1.13.1",
|
||||
"reference": "v1.13.1",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.2.4"
|
||||
},
|
||||
"time": "2013-04-08 12:40:11",
|
||||
"time": "2013-06-06 06:06:01",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.12-dev"
|
||||
"dev-master": "1.13-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
|
@ -49,5 +49,58 @@
|
|||
"keywords": [
|
||||
"templating"
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "michelf/php-markdown",
|
||||
"version": "1.3",
|
||||
"version_normalized": "1.3.0.0",
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/michelf/php-markdown.git",
|
||||
"reference": "1.3"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/michelf/php-markdown/zipball/1.3",
|
||||
"reference": "1.3",
|
||||
"shasum": ""
|
||||
},
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"time": "2013-04-11 18:53:11",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-lib": "1.3.x-dev"
|
||||
}
|
||||
},
|
||||
"installation-source": "dist",
|
||||
"autoload": {
|
||||
"psr-0": {
|
||||
"Michelf": ""
|
||||
}
|
||||
},
|
||||
"notification-url": "https://packagist.org/downloads/",
|
||||
"license": [
|
||||
"BSD-3-Clause"
|
||||
],
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michel Fortin",
|
||||
"email": "michel.fortin@michelf.ca",
|
||||
"homepage": "http://michelf.ca/",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "John Gruber",
|
||||
"homepage": "http://daringfireball.net/"
|
||||
}
|
||||
],
|
||||
"description": "PHP Markdown",
|
||||
"homepage": "http://michelf.ca/projects/php-markdown/",
|
||||
"keywords": [
|
||||
"markdown"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
36
vendor/michelf/php-markdown/License.md
vendored
Normal file
36
vendor/michelf/php-markdown/License.md
vendored
Normal file
|
@ -0,0 +1,36 @@
|
|||
PHP Markdown Lib
|
||||
Copyright (c) 2004-2013 Michel Fortin
|
||||
<http://michelf.ca/>
|
||||
All rights reserved.
|
||||
|
||||
Based on Markdown
|
||||
Copyright (c) 2003-2006 John Gruber
|
||||
<http://daringfireball.net/>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright notice,
|
||||
this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
* Neither the name "Markdown" nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
This software is provided by the copyright holders and contributors "as
|
||||
is" and any express or implied warranties, including, but not limited
|
||||
to, the implied warranties of merchantability and fitness for a
|
||||
particular purpose are disclaimed. In no event shall the copyright owner
|
||||
or contributors be liable for any direct, indirect, incidental, special,
|
||||
exemplary, or consequential damages (including, but not limited to,
|
||||
procurement of substitute goods or services; loss of use, data, or
|
||||
profits; or business interruption) however caused and on any theory of
|
||||
liability, whether in contract, strict liability, or tort (including
|
||||
negligence or otherwise) arising in any way out of the use of this
|
||||
software, even if advised of the possibility of such damage.
|
3096
vendor/michelf/php-markdown/Michelf/Markdown.php
vendored
Normal file
3096
vendor/michelf/php-markdown/Michelf/Markdown.php
vendored
Normal file
File diff suppressed because it is too large
Load diff
40
vendor/michelf/php-markdown/Michelf/MarkdownExtra.php
vendored
Normal file
40
vendor/michelf/php-markdown/Michelf/MarkdownExtra.php
vendored
Normal file
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
#
|
||||
# Markdown Extra - A text-to-HTML conversion tool for web writers
|
||||
#
|
||||
# PHP Markdown Extra
|
||||
# Copyright (c) 2004-2013 Michel Fortin
|
||||
# <http://michelf.com/projects/php-markdown/>
|
||||
#
|
||||
# Original Markdown
|
||||
# Copyright (c) 2004-2006 John Gruber
|
||||
# <http://daringfireball.net/projects/markdown/>
|
||||
#
|
||||
namespace Michelf;
|
||||
|
||||
|
||||
# Just force Michelf/Markdown.php to load. This is needed to load
|
||||
# the temporary implementation class. See below for details.
|
||||
\Michelf\Markdown::MARKDOWNLIB_VERSION;
|
||||
|
||||
#
|
||||
# Markdown Extra Parser Class
|
||||
#
|
||||
# Note: Currently the implementation resides in the temporary class
|
||||
# \Michelf\MarkdownExtra_TmpImpl (in the same file as \Michelf\Markdown).
|
||||
# This makes it easier to propagate the changes between the three different
|
||||
# packaging styles of PHP Markdown. Once this issue is resolved, the
|
||||
# _MarkdownExtra_TmpImpl will disappear and this one will contain the code.
|
||||
#
|
||||
|
||||
class MarkdownExtra extends \Michelf\_MarkdownExtra_TmpImpl {
|
||||
|
||||
### Parser Implementation ###
|
||||
|
||||
# Temporarily, the implemenation is in the _MarkdownExtra_TmpImpl class.
|
||||
# See note above.
|
||||
|
||||
}
|
||||
|
||||
|
||||
?>
|
259
vendor/michelf/php-markdown/Readme.md
vendored
Normal file
259
vendor/michelf/php-markdown/Readme.md
vendored
Normal file
|
@ -0,0 +1,259 @@
|
|||
PHP Markdown
|
||||
============
|
||||
|
||||
PHP Markdown Lib 1.3 - 11 Apr 2013
|
||||
|
||||
by Michel Fortin
|
||||
<http://michelf.ca/>
|
||||
|
||||
based on Markdown by John Gruber
|
||||
<http://daringfireball.net/>
|
||||
|
||||
|
||||
Introduction
|
||||
------------
|
||||
|
||||
This is a library package that includes the PHP Markdown parser and its
|
||||
sibling PHP Markdown Extra which additional features.
|
||||
|
||||
Markdown is a text-to-HTML conversion tool for web writers. Markdown
|
||||
allows you to write using an easy-to-read, easy-to-write plain text
|
||||
format, then convert it to structurally valid XHTML (or HTML).
|
||||
|
||||
"Markdown" is two things: a plain text markup syntax, and a software
|
||||
tool, written in Perl, that converts the plain text markup to HTML.
|
||||
PHP Markdown is a port to PHP of the original Markdown program by
|
||||
John Gruber.
|
||||
|
||||
PHP Markdown can work as a plug-in for WordPress, as a modifier for
|
||||
the Smarty templating engine, or as a replacement for Textile
|
||||
formatting in any software that supports Textile.
|
||||
|
||||
Full documentation of Markdown's syntax is available on John's
|
||||
Markdown page: <http://daringfireball.net/projects/markdown/>
|
||||
|
||||
|
||||
Requirement
|
||||
-----------
|
||||
|
||||
This library package requires PHP 5.3 or later.
|
||||
|
||||
Note: The older plugin/library hybrid package for PHP Markdown and
|
||||
PHP Markdown Extra is still maintained and will work with PHP 4.0.5 and later.
|
||||
|
||||
Before PHP 5.3.7, pcre.backtrack_limit defaults to 100 000, which is too small
|
||||
in many situations. You might need to set it to higher values. Later PHP
|
||||
releases defaults to 1 000 000, which is usually fine.
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
This library package is meant to be used with class autoloading. For autoloading
|
||||
to work, your project needs have setup a PSR-0-compatible autoloader. See the
|
||||
included Readme.php file for a minimal autoloader setup. (If you don't want to
|
||||
use autoloading you can do a classic `require_once` to manually include the
|
||||
files prior use instead.)
|
||||
|
||||
With class autoloading in place, putting the 'Michelf' folder in your
|
||||
include path should be enough for this to work:
|
||||
|
||||
use \Michelf\Markdown;
|
||||
$my_html = Markdown::defaultTransform($my_text);
|
||||
|
||||
Markdown Extra syntax is also available the same way:
|
||||
|
||||
use \Michelf\MarkdownExtra;
|
||||
$my_html = MarkdownExtra::defaultTransform($my_text);
|
||||
|
||||
If you wish to use PHP Markdown with another text filter function
|
||||
built to parse HTML, you should filter the text *after* the `transform`
|
||||
function call. This is an example with [PHP SmartyPants][psp]:
|
||||
|
||||
use \Michelf\Markdown, \Michelf\SmartyPants;
|
||||
$my_html = Markdown::defaultTransform($my_text);
|
||||
$my_html = SmartyPants::defaultTransform($my_html);
|
||||
|
||||
All these examples are using the static `defaultTransform` static function
|
||||
found inside the parser class. If you want to customize the parser
|
||||
configuration, you can also instantiate it directly and change some
|
||||
configuration variables:
|
||||
|
||||
use \Michelf\MarkdownExtra;
|
||||
$parser = new MarkdownExtra;
|
||||
$parser->fn_id_prefix = "post22-";
|
||||
$my_html = $parser->transform($my_text);
|
||||
|
||||
|
||||
Usage
|
||||
-----
|
||||
|
||||
This library package is meant to be used with class autoloading. For autoloading
|
||||
to work, your project needs have setup a PSR-0-compatible autoloader. See the
|
||||
included Readme.php file for a minimal autoloader setup. (If you don't want to
|
||||
use autoloading you can do a classic `require_once` to manually include the
|
||||
files prior use instead.)
|
||||
|
||||
With class autoloading in place, putting the 'Michelf' folder in your
|
||||
include path should be enough for this to work:
|
||||
|
||||
use \Michelf\Markdown;
|
||||
$my_html = Markdown::defaultTransform($my_text);
|
||||
|
||||
Markdown Extra syntax is also available the same way:
|
||||
|
||||
use \Michelf\MarkdownExtra;
|
||||
$my_html = MarkdownExtra::defaultTransform($my_text);
|
||||
|
||||
If you wish to use PHP Markdown with another text filter function
|
||||
built to parse HTML, you should filter the text *after* the `transform`
|
||||
function call. This is an example with [PHP SmartyPants][psp]:
|
||||
|
||||
use \Michelf\Markdown, \Michelf\SmartyPants;
|
||||
$my_html = Markdown::defaultTransform($my_text);
|
||||
$my_html = SmartyPants::defaultTransform($my_html);
|
||||
|
||||
All these examples are using the static `defaultTransform` static function
|
||||
found inside the parser class. If you want to customize the parser
|
||||
configuration, you can also instantiate it directly and change some
|
||||
configuration variables:
|
||||
|
||||
use \Michelf\MarkdownExtra;
|
||||
$parser = new MarkdownExtra;
|
||||
$parser->fn_id_prefix = "post22-";
|
||||
$my_html = $parser->transform($my_text);
|
||||
|
||||
To learn more, see the full list of [configuration variables].
|
||||
|
||||
[configuration variables]: http://michelf.ca/project/php-markdown/configuration/
|
||||
|
||||
|
||||
Public API and Versionning Policy
|
||||
---------------------------------
|
||||
|
||||
Version numbers are of the form *major*.*minor*.*patch*.
|
||||
|
||||
The public API of PHP Markdown consist of the two parser classes `Markdown`
|
||||
and `MarkdownExtra`, their constructors, the `transform` and `defaultTransform`
|
||||
functions and their configuration variables. The public API is stable for
|
||||
a given major version number. It might get additions when the minor version
|
||||
number increments.
|
||||
|
||||
**Protected members are not considered public API.** This is unconventionnal
|
||||
and deserves an explanation. Incrementing the major version number every time
|
||||
the underlying implementation of something changes is going to give nonsential
|
||||
version numbers for the vast majority of people who just use the parser.
|
||||
Protected members are meant to create parser subclasses that behave in
|
||||
different ways. Very few people create parser subclasses. I don't want to
|
||||
discourage it by making everything private, but at the same time I can't
|
||||
guarenty any stable hook between versions if you use protected members.
|
||||
|
||||
**Syntax changes** will increment the minor number for new features, and the
|
||||
patch number for small corrections. A *new feature* is something that needs a
|
||||
change in the syntax documentation. Note that since PHP Markdown Lib includes
|
||||
two parsers, a syntax change for either of them will increment the minor
|
||||
number. Also note that there is nothigng perfectly backward-compatible with the
|
||||
Markdown syntax: all inputs are always valid, so new features always replace
|
||||
something that was previously legal, although generally non-sensial to do.
|
||||
|
||||
|
||||
Bugs
|
||||
----
|
||||
|
||||
To file bug reports please send email to:
|
||||
<michel.fortin@michelf.ca>
|
||||
|
||||
Please include with your report: (1) the example input; (2) the output you
|
||||
expected; (3) the output PHP Markdown actually produced.
|
||||
|
||||
If you have a problem where Markdown gives you an empty result, first check
|
||||
that the backtrack limit is not too low by running `php --info | grep pcre`.
|
||||
See Installation and Requirement above for details.
|
||||
|
||||
|
||||
Version History
|
||||
---------------
|
||||
|
||||
PHP Markdown Lib 1.3 (11 Apr 2013):
|
||||
|
||||
This is the first release of PHP Markdown Lib. This package requires PHP
|
||||
version 4.3 or later and is designed to work with PSR-0 autoloading and,
|
||||
optionally with Composer. Here is a list of the changes since
|
||||
PHP Markdown Extra 1.2.6:
|
||||
|
||||
* Plugin interface for Wordpress and other systems is no longer present in
|
||||
the Lib package. The classic package is still available if you need it:
|
||||
<http://michelf.ca/projects/php-markdown/classic/>
|
||||
|
||||
* Added `public` and `protected` protection attributes, plus a section about
|
||||
what is "public API" and what isn't in the Readme file.
|
||||
|
||||
* Changed HTML output for footnotes: now instead of adding `rel` and `rev`
|
||||
attributes, footnotes links have the class name `footnote-ref` and
|
||||
backlinks `footnote-backref`.
|
||||
|
||||
* Fixed some regular expressions to make PCRE not shout warnings about POSIX
|
||||
collation classes (dependent on your version of PCRE).
|
||||
|
||||
* Added optional class and id attributes to images and links using the same
|
||||
syntax as for headers:
|
||||
|
||||
[link](url){#id .class}
|
||||
{#id .class}
|
||||
|
||||
It work too for reference-style links and images. In this case you need
|
||||
to put those attributes at the reference definition:
|
||||
|
||||
[link][linkref] or [linkref]
|
||||
![img][linkref]
|
||||
|
||||
[linkref]: url "optional title" {#id .class}
|
||||
|
||||
* Fixed a PHP notice message triggered when some table column separator
|
||||
markers are missing on the separator line below column headers.
|
||||
|
||||
* Fixed a small mistake that could cause the parser to retain an invalid
|
||||
state related to parsing links across multiple runs. This was never
|
||||
observed (that I know of), but it's still worth fixing.
|
||||
|
||||
|
||||
Copyright and License
|
||||
---------------------
|
||||
|
||||
PHP Markdown Lib
|
||||
Copyright (c) 2004-2013 Michel Fortin
|
||||
<http://michelf.ca/>
|
||||
All rights reserved.
|
||||
|
||||
Based on Markdown
|
||||
Copyright (c) 2003-2005 John Gruber
|
||||
<http://daringfireball.net/>
|
||||
All rights reserved.
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are
|
||||
met:
|
||||
|
||||
* Redistributions of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
* Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the
|
||||
distribution.
|
||||
|
||||
* Neither the name "Markdown" nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software
|
||||
without specific prior written permission.
|
||||
|
||||
This software is provided by the copyright holders and contributors "as
|
||||
is" and any express or implied warranties, including, but not limited
|
||||
to, the implied warranties of merchantability and fitness for a
|
||||
particular purpose are disclaimed. In no event shall the copyright owner
|
||||
or contributors be liable for any direct, indirect, incidental, special,
|
||||
exemplary, or consequential damages (including, but not limited to,
|
||||
procurement of substitute goods or services; loss of use, data, or
|
||||
profits; or business interruption) however caused and on any theory of
|
||||
liability, whether in contract, strict liability, or tort (including
|
||||
negligence or otherwise) arising in any way out of the use of this
|
||||
software, even if advised of the possibility of such damage.
|
31
vendor/michelf/php-markdown/Readme.php
vendored
Normal file
31
vendor/michelf/php-markdown/Readme.php
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
# This file passes the content of the Readme.md file in the same directory
|
||||
# through the Markdown filter. You can adapt this sample code in any way
|
||||
# you like.
|
||||
|
||||
# Install PSR-0-compatible class autoloader
|
||||
spl_autoload_register(function($class){
|
||||
require preg_replace('{\\\\|_(?!.*\\\\)}', DIRECTORY_SEPARATOR, ltrim($class, '\\')).'.php';
|
||||
});
|
||||
|
||||
# Get Markdown class
|
||||
use \Michelf\Markdown;
|
||||
|
||||
# Read file and pass content through the Markdown praser
|
||||
$text = file_get_contents('Readme.md');
|
||||
$html = Markdown::defaultTransform($text);
|
||||
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<title>PHP Markdown Lib - Readme</title>
|
||||
</head>
|
||||
<body>
|
||||
<?php
|
||||
# Put HTML content in the document
|
||||
echo $html;
|
||||
?>
|
||||
</body>
|
||||
</html>
|
31
vendor/michelf/php-markdown/composer.json
vendored
Normal file
31
vendor/michelf/php-markdown/composer.json
vendored
Normal file
|
@ -0,0 +1,31 @@
|
|||
{
|
||||
"name": "michelf/php-markdown",
|
||||
"type": "library",
|
||||
"description": "PHP Markdown",
|
||||
"homepage": "http://michelf.ca/projects/php-markdown/",
|
||||
"keywords": ["markdown"],
|
||||
"license": "BSD-3-Clause",
|
||||
"authors": [
|
||||
{
|
||||
"name": "Michel Fortin",
|
||||
"email": "michel.fortin@michelf.ca",
|
||||
"homepage": "http://michelf.ca/",
|
||||
"role": "Developer"
|
||||
},
|
||||
{
|
||||
"name": "John Gruber",
|
||||
"homepage": "http://daringfireball.net/"
|
||||
}
|
||||
],
|
||||
"require": {
|
||||
"php": ">=5.3.0"
|
||||
},
|
||||
"autoload": {
|
||||
"psr-0": { "Michelf": "" }
|
||||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-lib": "1.3.x-dev"
|
||||
}
|
||||
}
|
||||
}
|
17
vendor/twig/twig/CHANGELOG
vendored
17
vendor/twig/twig/CHANGELOG
vendored
|
@ -1,3 +1,20 @@
|
|||
* 1.13.1 (2013-06-06)
|
||||
|
||||
* added the possibility to ignore the filesystem constructor argument in Twig_Loader_Filesystem
|
||||
* fixed Twig_Loader_Chain::exists() for a loader which implements Twig_ExistsLoaderInterface
|
||||
* adjusted backtrace call to reduce memory usage when an error occurs
|
||||
* added support for object instances as the second argument of the constant test
|
||||
* fixed the include function when used in an assignment
|
||||
|
||||
* 1.13.0 (2013-05-10)
|
||||
|
||||
* fixed getting a numeric-like item on a variable ('09' for instance)
|
||||
* fixed getting a boolean or float key on an array, so it is consistent with PHP's array access:
|
||||
`{{ array[false] }}` behaves the same as `echo $array[false];` (equals `$array[0]`)
|
||||
* made the escape filter 20% faster for happy path (escaping string for html with UTF-8)
|
||||
* changed ☃ to § in tests
|
||||
* enforced usage of named arguments after positional ones
|
||||
|
||||
* 1.12.3 (2013-04-08)
|
||||
|
||||
* fixed a security issue in the filesystem loader where it was possible to include a template one
|
||||
|
|
2
vendor/twig/twig/composer.json
vendored
2
vendor/twig/twig/composer.json
vendored
|
@ -25,7 +25,7 @@
|
|||
},
|
||||
"extra": {
|
||||
"branch-alias": {
|
||||
"dev-master": "1.12-dev"
|
||||
"dev-master": "1.13-dev"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
11
vendor/twig/twig/lib/Twig/Autoloader.php
vendored
11
vendor/twig/twig/lib/Twig/Autoloader.php
vendored
|
@ -18,11 +18,16 @@ class Twig_Autoloader
|
|||
{
|
||||
/**
|
||||
* Registers Twig_Autoloader as an SPL autoloader.
|
||||
*
|
||||
* @param Boolean $prepend Whether to prepend the autoloader or not.
|
||||
*/
|
||||
public static function register()
|
||||
public static function register($prepend = false)
|
||||
{
|
||||
ini_set('unserialize_callback_func', 'spl_autoload_call');
|
||||
spl_autoload_register(array(new self, 'autoload'));
|
||||
if (version_compare(phpversion(), '5.3.0', '>=')) {
|
||||
spl_autoload_register(array(new self, 'autoload'), true, $prepend);
|
||||
} else {
|
||||
spl_autoload_register(array(new self, 'autoload'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
19
vendor/twig/twig/lib/Twig/Environment.php
vendored
19
vendor/twig/twig/lib/Twig/Environment.php
vendored
|
@ -16,7 +16,7 @@
|
|||
*/
|
||||
class Twig_Environment
|
||||
{
|
||||
const VERSION = '1.12.3';
|
||||
const VERSION = '1.13.1';
|
||||
|
||||
protected $charset;
|
||||
protected $loader;
|
||||
|
@ -53,7 +53,7 @@ class Twig_Environment
|
|||
* * debug: When set to true, it automatically set "auto_reload" to true as
|
||||
* well (default to false).
|
||||
*
|
||||
* * charset: The charset used by the templates (default to utf-8).
|
||||
* * charset: The charset used by the templates (default to UTF-8).
|
||||
*
|
||||
* * base_template_class: The base template class to use for generated
|
||||
* templates (default to Twig_Template).
|
||||
|
@ -99,7 +99,7 @@ class Twig_Environment
|
|||
), $options);
|
||||
|
||||
$this->debug = (bool) $options['debug'];
|
||||
$this->charset = $options['charset'];
|
||||
$this->charset = strtoupper($options['charset']);
|
||||
$this->baseTemplateClass = $options['base_template_class'];
|
||||
$this->autoReload = null === $options['auto_reload'] ? $this->debug : (bool) $options['auto_reload'];
|
||||
$this->strictVariables = (bool) $options['strict_variables'];
|
||||
|
@ -566,7 +566,7 @@ class Twig_Environment
|
|||
*/
|
||||
public function setCharset($charset)
|
||||
{
|
||||
$this->charset = $charset;
|
||||
$this->charset = strtoupper($charset);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1099,10 +1099,17 @@ class Twig_Environment
|
|||
{
|
||||
$globals = array();
|
||||
foreach ($this->extensions as $extension) {
|
||||
$globals = array_merge($globals, $extension->getGlobals());
|
||||
$extGlob = $extension->getGlobals();
|
||||
if (!is_array($extGlob)) {
|
||||
throw new UnexpectedValueException(sprintf('"%s::getGlobals()" must return an array of globals.', get_class($extension)));
|
||||
}
|
||||
|
||||
$globals[] = $extGlob;
|
||||
}
|
||||
|
||||
return array_merge($globals, $this->staging->getGlobals());
|
||||
$globals[] = $this->staging->getGlobals();
|
||||
|
||||
return call_user_func_array('array_merge', $globals);
|
||||
}
|
||||
|
||||
protected function initExtensions()
|
||||
|
|
9
vendor/twig/twig/lib/Twig/Error.php
vendored
9
vendor/twig/twig/lib/Twig/Error.php
vendored
|
@ -186,7 +186,14 @@ class Twig_Error extends Exception
|
|||
protected function guessTemplateInfo()
|
||||
{
|
||||
$template = null;
|
||||
foreach (debug_backtrace() as $trace) {
|
||||
|
||||
if (version_compare(phpversion(), '5.3.6', '>=')) {
|
||||
$backtrace = debug_backtrace(DEBUG_BACKTRACE_IGNORE_ARGS | DEBUG_BACKTRACE_PROVIDE_OBJECT);
|
||||
} else {
|
||||
$backtrace = debug_backtrace();
|
||||
}
|
||||
|
||||
foreach ($backtrace as $trace) {
|
||||
if (isset($trace['object']) && $trace['object'] instanceof Twig_Template && 'Twig_Template' !== get_class($trace['object'])) {
|
||||
if (null === $this->filename || $this->filename == $trace['object']->getTemplateName()) {
|
||||
$template = $trace['object'];
|
||||
|
|
|
@ -365,7 +365,7 @@ class Twig_ExpressionParser
|
|||
throw new Twig_Error_Syntax('Expected name or number', $lineno, $this->parser->getFilename());
|
||||
}
|
||||
|
||||
if ($node instanceof Twig_Node_Expression_Name && null !== $alias = $this->parser->getImportedSymbol('template', $node->getAttribute('name'))) {
|
||||
if ($node instanceof Twig_Node_Expression_Name && null !== $this->parser->getImportedSymbol('template', $node->getAttribute('name'))) {
|
||||
if (!$arg instanceof Twig_Node_Expression_Constant) {
|
||||
throw new Twig_Error_Syntax(sprintf('Dynamic macro names are not supported (called on "%s")', $node->getAttribute('name')), $token->getLine(), $this->parser->getFilename());
|
||||
}
|
||||
|
|
101
vendor/twig/twig/lib/Twig/Extension/Core.php
vendored
101
vendor/twig/twig/lib/Twig/Extension/Core.php
vendored
|
@ -191,7 +191,7 @@ class Twig_Extension_Core extends Twig_Extension
|
|||
new Twig_SimpleFunction('cycle', 'twig_cycle'),
|
||||
new Twig_SimpleFunction('random', 'twig_random', array('needs_environment' => true)),
|
||||
new Twig_SimpleFunction('date', 'twig_date_converter', array('needs_environment' => true)),
|
||||
new Twig_SimpleFunction('include', 'twig_include', array('needs_environment' => true, 'needs_context' => true)),
|
||||
new Twig_SimpleFunction('include', 'twig_include', array('needs_environment' => true, 'needs_context' => true, 'is_safe' => array('all'))),
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -847,21 +847,62 @@ function twig_in_filter($value, $compare)
|
|||
*/
|
||||
function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html', $charset = null, $autoescape = false)
|
||||
{
|
||||
if ($autoescape && is_object($string) && $string instanceof Twig_Markup) {
|
||||
if ($autoescape && $string instanceof Twig_Markup) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
if (!is_string($string) && !(is_object($string) && method_exists($string, '__toString'))) {
|
||||
return $string;
|
||||
if (!is_string($string)) {
|
||||
if (is_object($string) && method_exists($string, '__toString')) {
|
||||
$string = (string) $string;
|
||||
} else {
|
||||
return $string;
|
||||
}
|
||||
}
|
||||
|
||||
if (null === $charset) {
|
||||
$charset = $env->getCharset();
|
||||
}
|
||||
|
||||
$string = (string) $string;
|
||||
|
||||
switch ($strategy) {
|
||||
case 'html':
|
||||
// see http://php.net/htmlspecialchars
|
||||
|
||||
// Using a static variable to avoid initializing the array
|
||||
// each time the function is called. Moving the declaration on the
|
||||
// top of the function slow downs other escaping strategies.
|
||||
static $htmlspecialcharsCharsets = array(
|
||||
'ISO-8859-1' => true, 'ISO8859-1' => true,
|
||||
'ISO-8859-15' => true, 'ISO8859-15' => true,
|
||||
'utf-8' => true, 'UTF-8' => true,
|
||||
'CP866' => true, 'IBM866' => true, '866' => true,
|
||||
'CP1251' => true, 'WINDOWS-1251' => true, 'WIN-1251' => true,
|
||||
'1251' => true,
|
||||
'CP1252' => true, 'WINDOWS-1252' => true, '1252' => true,
|
||||
'KOI8-R' => true, 'KOI8-RU' => true, 'KOI8R' => true,
|
||||
'BIG5' => true, '950' => true,
|
||||
'GB2312' => true, '936' => true,
|
||||
'BIG5-HKSCS' => true,
|
||||
'SHIFT_JIS' => true, 'SJIS' => true, '932' => true,
|
||||
'EUC-JP' => true, 'EUCJP' => true,
|
||||
'ISO8859-5' => true, 'ISO-8859-5' => true, 'MACROMAN' => true,
|
||||
);
|
||||
|
||||
if (isset($htmlspecialcharsCharsets[$charset])) {
|
||||
return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
|
||||
}
|
||||
|
||||
if (isset($htmlspecialcharsCharsets[strtoupper($charset)])) {
|
||||
// cache the lowercase variant for future iterations
|
||||
$htmlspecialcharsCharsets[$charset] = true;
|
||||
|
||||
return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
|
||||
}
|
||||
|
||||
$string = twig_convert_encoding($string, 'UTF-8', $charset);
|
||||
$string = htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
|
||||
return twig_convert_encoding($string, $charset, 'UTF-8');
|
||||
|
||||
case 'js':
|
||||
// escape all non-alphanumeric characters
|
||||
// into their \xHH or \uHHHH representations
|
||||
|
@ -915,40 +956,10 @@ function twig_escape_filter(Twig_Environment $env, $string, $strategy = 'html',
|
|||
|
||||
return $string;
|
||||
|
||||
case 'html':
|
||||
// see http://php.net/htmlspecialchars
|
||||
|
||||
// Using a static variable to avoid initializing the array
|
||||
// each time the function is called. Moving the declaration on the
|
||||
// top of the function slow downs other escaping strategies.
|
||||
static $htmlspecialcharsCharsets = array(
|
||||
'iso-8859-1' => true, 'iso8859-1' => true,
|
||||
'iso-8859-15' => true, 'iso8859-15' => true,
|
||||
'utf-8' => true,
|
||||
'cp866' => true, 'ibm866' => true, '866' => true,
|
||||
'cp1251' => true, 'windows-1251' => true, 'win-1251' => true,
|
||||
'1251' => true,
|
||||
'cp1252' => true, 'windows-1252' => true, '1252' => true,
|
||||
'koi8-r' => true, 'koi8-ru' => true, 'koi8r' => true,
|
||||
'big5' => true, '950' => true,
|
||||
'gb2312' => true, '936' => true,
|
||||
'big5-hkscs' => true,
|
||||
'shift_jis' => true, 'sjis' => true, '932' => true,
|
||||
'euc-jp' => true, 'eucjp' => true,
|
||||
'iso8859-5' => true, 'iso-8859-5' => true, 'macroman' => true,
|
||||
);
|
||||
|
||||
if (isset($htmlspecialcharsCharsets[strtolower($charset)])) {
|
||||
return htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, $charset);
|
||||
}
|
||||
|
||||
$string = twig_convert_encoding($string, 'UTF-8', $charset);
|
||||
$string = htmlspecialchars($string, ENT_QUOTES | ENT_SUBSTITUTE, 'UTF-8');
|
||||
|
||||
return twig_convert_encoding($string, $charset, 'UTF-8');
|
||||
|
||||
case 'url':
|
||||
if (version_compare(PHP_VERSION, '5.3.0', '<')) {
|
||||
// hackish test to avoid version_compare that is much slower, this works unless PHP releases a 5.10.*
|
||||
// at that point however PHP 5.2.* support can be removed
|
||||
if (PHP_VERSION < '5.3.0') {
|
||||
return str_replace('%7E', '~', rawurlencode($string));
|
||||
}
|
||||
|
||||
|
@ -1262,11 +1273,11 @@ function twig_test_iterable($value)
|
|||
/**
|
||||
* Renders a template.
|
||||
*
|
||||
* @param string template The template to render
|
||||
* @param array variables The variables to pass to the template
|
||||
* @param Boolean with_context Whether to pass the current context variables or not
|
||||
* @param Boolean ignore_missing Whether to ignore missing templates or not
|
||||
* @param Boolean sandboxed Whether to sandbox the template or not
|
||||
* @param string $template The template to render
|
||||
* @param array $variables The variables to pass to the template
|
||||
* @param Boolean $with_context Whether to pass the current context variables or not
|
||||
* @param Boolean $ignore_missing Whether to ignore missing templates or not
|
||||
* @param Boolean $sandboxed Whether to sandbox the template or not
|
||||
*
|
||||
* @return string The rendered template
|
||||
*/
|
||||
|
@ -1284,7 +1295,7 @@ function twig_include(Twig_Environment $env, $context, $template, $variables = a
|
|||
}
|
||||
|
||||
try {
|
||||
return $env->resolveTemplate($template)->display($variables);
|
||||
return $env->resolveTemplate($template)->render($variables);
|
||||
} catch (Twig_Error_Loader $e) {
|
||||
if (!$ignoreMissing) {
|
||||
throw $e;
|
||||
|
|
|
@ -24,6 +24,7 @@ class Twig_Extension_Debug extends Twig_Extension
|
|||
// false means that it was not set (and the default is on) or it explicitly enabled
|
||||
// xdebug.overload_var_dump produces HTML only when html_errors is also enabled
|
||||
&& (false === ini_get('html_errors') || ini_get('html_errors'))
|
||||
|| 'cli' === php_sapi_name()
|
||||
;
|
||||
|
||||
return array(
|
||||
|
|
|
@ -33,7 +33,7 @@ class Twig_Extension_StringLoader extends Twig_Extension
|
|||
* Loads a template from a string.
|
||||
*
|
||||
* <pre>
|
||||
* {% include template_from_string("Hello {{ name }}") }}
|
||||
* {{ include(template_from_string("Hello {{ name }}")) }}
|
||||
* </pre>
|
||||
*
|
||||
* @param Twig_Environment $env A Twig_Environment instance
|
||||
|
|
2
vendor/twig/twig/lib/Twig/Filter.php
vendored
2
vendor/twig/twig/lib/Twig/Filter.php
vendored
|
@ -62,8 +62,6 @@ abstract class Twig_Filter implements Twig_FilterInterface, Twig_FilterCallableI
|
|||
if (isset($this->options['is_safe_callback'])) {
|
||||
return call_user_func($this->options['is_safe_callback'], $filterArgs);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getPreservesSafety()
|
||||
|
|
8
vendor/twig/twig/lib/Twig/Loader/Chain.php
vendored
8
vendor/twig/twig/lib/Twig/Loader/Chain.php
vendored
|
@ -76,8 +76,12 @@ class Twig_Loader_Chain implements Twig_LoaderInterface, Twig_ExistsLoaderInterf
|
|||
}
|
||||
|
||||
foreach ($this->loaders as $loader) {
|
||||
if ($loader instanceof Twig_ExistsLoaderInterface && $loader->exists($name)) {
|
||||
return $this->hasSourceCache[$name] = true;
|
||||
if ($loader instanceof Twig_ExistsLoaderInterface) {
|
||||
if ($loader->exists($name)) {
|
||||
return $this->hasSourceCache[$name] = true;
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
|
|
|
@ -24,9 +24,11 @@ class Twig_Loader_Filesystem implements Twig_LoaderInterface, Twig_ExistsLoaderI
|
|||
*
|
||||
* @param string|array $paths A path or an array of paths where to look for templates
|
||||
*/
|
||||
public function __construct($paths)
|
||||
public function __construct($paths = array())
|
||||
{
|
||||
$this->setPaths($paths);
|
||||
if ($paths) {
|
||||
$this->setPaths($paths);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -98,7 +98,10 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
|
|||
if (!is_int($name)) {
|
||||
$named = true;
|
||||
$name = $this->normalizeName($name);
|
||||
} elseif ($named) {
|
||||
throw new Twig_Error_Syntax(sprintf('Positional arguments cannot be used after named arguments for %s "%s".', $this->getAttribute('type'), $this->getAttribute('name')));
|
||||
}
|
||||
|
||||
$parameters[$name] = $node;
|
||||
}
|
||||
|
||||
|
@ -142,6 +145,10 @@ abstract class Twig_Node_Expression_Call extends Twig_Node_Expression
|
|||
$name = $this->normalizeName($param->name);
|
||||
|
||||
if (array_key_exists($name, $parameters)) {
|
||||
if (array_key_exists($pos, $parameters)) {
|
||||
throw new Twig_Error_Syntax(sprintf('Arguments "%s" is defined twice for %s "%s".', $name, $this->getAttribute('type'), $this->getAttribute('name')));
|
||||
}
|
||||
|
||||
$arguments[] = $parameters[$name];
|
||||
unset($parameters[$name]);
|
||||
} elseif (array_key_exists($pos, $parameters)) {
|
||||
|
|
|
@ -28,6 +28,17 @@ class Twig_Node_Expression_Test_Constant extends Twig_Node_Expression_Test
|
|||
->raw('(')
|
||||
->subcompile($this->getNode('node'))
|
||||
->raw(' === constant(')
|
||||
;
|
||||
|
||||
if ($this->getNode('arguments')->hasNode(1)) {
|
||||
$compiler
|
||||
->raw('get_class(')
|
||||
->subcompile($this->getNode('arguments')->getNode(1))
|
||||
->raw(')."::".')
|
||||
;
|
||||
}
|
||||
|
||||
$compiler
|
||||
->subcompile($this->getNode('arguments')->getNode(0))
|
||||
->raw('))')
|
||||
;
|
||||
|
|
|
@ -34,7 +34,7 @@ class Twig_Node_Expression_Test_Defined extends Twig_Node_Expression_Test
|
|||
|
||||
$this->changeIgnoreStrictCheck($node);
|
||||
} else {
|
||||
throw new Twig_Error_Syntax('The "defined" test only works with simple variables', $this->getLine(), $compiler->getFilename());
|
||||
throw new Twig_Error_Syntax('The "defined" test only works with simple variables', $this->getLine());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
2
vendor/twig/twig/lib/Twig/Node/For.php
vendored
2
vendor/twig/twig/lib/Twig/Node/For.php
vendored
|
@ -107,6 +107,6 @@ class Twig_Node_For extends Twig_Node
|
|||
$compiler->write('unset($context[\'_seq\'], $context[\'_iterated\'], $context[\''.$this->getNode('key_target')->getAttribute('name').'\'], $context[\''.$this->getNode('value_target')->getAttribute('name').'\'], $context[\'_parent\'], $context[\'loop\']);'."\n");
|
||||
|
||||
// keep the values set in the inner context for variables defined in the outer context
|
||||
$compiler->write("\$context = array_merge(\$_parent, array_intersect_key(\$context, \$_parent));\n");
|
||||
$compiler->write("\$context = array_intersect_key(\$context, \$_parent) + \$_parent;\n");
|
||||
}
|
||||
}
|
||||
|
|
|
@ -20,8 +20,6 @@ class Twig_NodeVisitor_SafeAnalysis implements Twig_NodeVisitorInterface
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected function setSafe(Twig_NodeInterface $node, array $safe)
|
||||
|
|
2
vendor/twig/twig/lib/Twig/SimpleFilter.php
vendored
2
vendor/twig/twig/lib/Twig/SimpleFilter.php
vendored
|
@ -80,8 +80,6 @@ class Twig_SimpleFilter
|
|||
if (null !== $this->options['is_safe_callback']) {
|
||||
return call_user_func($this->options['is_safe_callback'], $filterArgs);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getPreservesSafety()
|
||||
|
|
28
vendor/twig/twig/lib/Twig/Template.php
vendored
28
vendor/twig/twig/lib/Twig/Template.php
vendored
|
@ -336,21 +336,21 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|||
*/
|
||||
protected function getAttribute($object, $item, array $arguments = array(), $type = Twig_TemplateInterface::ANY_CALL, $isDefinedTest = false, $ignoreStrictCheck = false)
|
||||
{
|
||||
$item = ctype_digit((string) $item) ? (int) $item : (string) $item;
|
||||
|
||||
// array
|
||||
if (Twig_TemplateInterface::METHOD_CALL !== $type) {
|
||||
if ((is_array($object) && array_key_exists($item, $object))
|
||||
|| ($object instanceof ArrayAccess && isset($object[$item]))
|
||||
$arrayItem = is_bool($item) || is_float($item) ? (int) $item : $item;
|
||||
|
||||
if ((is_array($object) && array_key_exists($arrayItem, $object))
|
||||
|| ($object instanceof ArrayAccess && isset($object[$arrayItem]))
|
||||
) {
|
||||
if ($isDefinedTest) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return $object[$item];
|
||||
return $object[$arrayItem];
|
||||
}
|
||||
|
||||
if (Twig_TemplateInterface::ARRAY_CALL === $type) {
|
||||
if (Twig_TemplateInterface::ARRAY_CALL === $type || !is_object($object)) {
|
||||
if ($isDefinedTest) {
|
||||
return false;
|
||||
}
|
||||
|
@ -360,11 +360,13 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|||
}
|
||||
|
||||
if (is_object($object)) {
|
||||
throw new Twig_Error_Runtime(sprintf('Key "%s" in object (with ArrayAccess) of type "%s" does not exist', $item, get_class($object)), -1, $this->getTemplateName());
|
||||
throw new Twig_Error_Runtime(sprintf('Key "%s" in object (with ArrayAccess) of type "%s" does not exist', $arrayItem, get_class($object)), -1, $this->getTemplateName());
|
||||
} elseif (is_array($object)) {
|
||||
throw new Twig_Error_Runtime(sprintf('Key "%s" for array with keys "%s" does not exist', $item, implode(', ', array_keys($object))), -1, $this->getTemplateName());
|
||||
throw new Twig_Error_Runtime(sprintf('Key "%s" for array with keys "%s" does not exist', $arrayItem, implode(', ', array_keys($object))), -1, $this->getTemplateName());
|
||||
} elseif (Twig_TemplateInterface::ARRAY_CALL === $type) {
|
||||
throw new Twig_Error_Runtime(sprintf('Impossible to access a key ("%s") on a %s variable ("%s")', $item, gettype($object), $object), -1, $this->getTemplateName());
|
||||
} else {
|
||||
throw new Twig_Error_Runtime(sprintf('Impossible to access a key ("%s") on a "%s" variable', $item, gettype($object)), -1, $this->getTemplateName());
|
||||
throw new Twig_Error_Runtime(sprintf('Impossible to access an attribute ("%s") on a %s variable ("%s")', $item, gettype($object), $object), -1, $this->getTemplateName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -378,14 +380,14 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|||
return null;
|
||||
}
|
||||
|
||||
throw new Twig_Error_Runtime(sprintf('Item "%s" for "%s" does not exist', $item, is_array($object) ? 'Array' : $object), -1, $this->getTemplateName());
|
||||
throw new Twig_Error_Runtime(sprintf('Impossible to invoke a method ("%s") on a %s variable ("%s")', $item, gettype($object), $object), -1, $this->getTemplateName());
|
||||
}
|
||||
|
||||
$class = get_class($object);
|
||||
|
||||
// object property
|
||||
if (Twig_TemplateInterface::METHOD_CALL !== $type) {
|
||||
if (isset($object->$item) || array_key_exists($item, $object)) {
|
||||
if (isset($object->$item) || array_key_exists((string) $item, $object)) {
|
||||
if ($isDefinedTest) {
|
||||
return true;
|
||||
}
|
||||
|
@ -405,13 +407,13 @@ abstract class Twig_Template implements Twig_TemplateInterface
|
|||
|
||||
$lcItem = strtolower($item);
|
||||
if (isset(self::$cache[$class]['methods'][$lcItem])) {
|
||||
$method = $item;
|
||||
$method = (string) $item;
|
||||
} elseif (isset(self::$cache[$class]['methods']['get'.$lcItem])) {
|
||||
$method = 'get'.$item;
|
||||
} elseif (isset(self::$cache[$class]['methods']['is'.$lcItem])) {
|
||||
$method = 'is'.$item;
|
||||
} elseif (isset(self::$cache[$class]['methods']['__call'])) {
|
||||
$method = $item;
|
||||
$method = (string) $item;
|
||||
} else {
|
||||
if ($isDefinedTest) {
|
||||
return false;
|
||||
|
|
|
@ -38,8 +38,6 @@ class Twig_TokenParser_Extends extends Twig_TokenParser
|
|||
$this->parser->setParent($this->parser->getExpressionParser()->parseExpression());
|
||||
|
||||
$this->parser->getStream()->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -49,8 +49,6 @@ class Twig_TokenParser_Macro extends Twig_TokenParser
|
|||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
|
||||
$this->parser->setMacro($name, new Twig_Node_Macro($name, new Twig_Node_Body(array($body)), $arguments, $lineno, $this->getTag()));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function decideBlockEnd(Twig_Token $token)
|
||||
|
|
|
@ -68,8 +68,6 @@ class Twig_TokenParser_Use extends Twig_TokenParser
|
|||
$stream->expect(Twig_Token::BLOCK_END_TYPE);
|
||||
|
||||
$this->parser->addTrait(new Twig_Node(array('template' => $template, 'targets' => new Twig_Node($targets))));
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -111,8 +111,6 @@ class Twig_TokenParserBroker implements Twig_TokenParserBrokerInterface
|
|||
}
|
||||
$broker = prev($this->brokers);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public function getParsers()
|
||||
|
|
Loading…
Add table
Reference in a new issue