Version Description
- Fixed capitalization problem for WP.org version
Download this release
Release Info
Developer | jarednova |
Plugin | Timber |
Version | 0.21.1 |
Comparing to | |
See all releases |
Code changes from version 0.20.10 to 0.21.1
- README.md +4 -3
- lib/cache/loader.php +0 -24
- lib/integrations/acf-timber.php +1 -5
- lib/integrations/timber-command.php +36 -0
- lib/integrations/wpcli-timber.php +47 -78
- lib/timber-admin.php +5 -10
- lib/timber-image-helper.php +30 -34
- lib/timber-image.php +4 -0
- lib/timber-integrations.php +24 -0
- lib/timber-loader.php +5 -8
- lib/timber-routes.php +20 -99
- lib/timber-twig.php +7 -2
- readme.txt +11 -2
- timber-starter-theme/.gitignore +2 -0
- {vendor/jarednova/php-router → timber-starter-theme}/LICENSE +1 -1
- timber-starter-theme/README.md +2 -0
- timber-starter-theme/composer.json +33 -0
- timber-starter-theme/composer.lock +288 -0
- timber-starter-theme/phpunit.xml +20 -0
- timber-starter-theme/tests/bootstrap.php +18 -0
- timber-starter-theme/tests/test-timber-starter-theme.php +44 -0
- timber.php +505 -534
- vendor/altorouter/altorouter/.travis.yml +7 -0
- vendor/altorouter/altorouter/AltoRouter.php +270 -0
- vendor/altorouter/altorouter/AltoRouterTest.php +423 -0
- vendor/altorouter/altorouter/README.md +92 -0
- vendor/altorouter/altorouter/composer.json +28 -0
- vendor/altorouter/altorouter/examples/basic/.htaccess +3 -0
- vendor/altorouter/altorouter/examples/basic/index.php +27 -0
- vendor/autoload.php +1 -1
- vendor/composer/autoload_classmap.php +39 -0
- vendor/composer/autoload_namespaces.php +1 -1
- vendor/composer/autoload_real.php +4 -4
- vendor/composer/installed.json +113 -24
- vendor/composer/installers/README.md +3 -1
- vendor/composer/installers/composer.json +1 -0
- vendor/composer/installers/src/Composer/Installers/AimeosInstaller.php +9 -0
- vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php +5 -72
- vendor/composer/installers/src/Composer/Installers/Installer.php +2 -0
- vendor/composer/installers/src/Composer/Installers/PrestashopInstaller.php +10 -0
- vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php +5 -53
- vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php +6 -0
- vendor/jarednova/php-router/.gitignore +0 -36
- vendor/jarednova/php-router/.htaccess +0 -3
- vendor/jarednova/php-router/README.md +0 -43
- vendor/jarednova/php-router/composer.json +0 -26
- vendor/jarednova/php-router/example.php +0 -37
- vendor/jarednova/php-router/src/PHPRouter/Route.php +0 -115
- vendor/jarednova/php-router/src/PHPRouter/Router.php +0 -164
- vendor/upstatement/routes/.gitignore +19 -0
- vendor/upstatement/routes/.travis.yml +29 -0
- vendor/upstatement/routes/README.md +15 -0
- vendor/upstatement/routes/Routes.php +159 -0
- vendor/upstatement/routes/bin/install-wp-tests.sh +78 -0
- vendor/upstatement/routes/composer.json +34 -0
- vendor/upstatement/routes/composer.lock +1374 -0
- vendor/upstatement/routes/phpunit.xml +20 -0
- vendor/upstatement/routes/tests/bootstrap.php +14 -0
- vendor/upstatement/routes/tests/test-routes.php +244 -0
README.md
CHANGED
@@ -6,7 +6,7 @@ By Jared Novack (<a href="http://twitter.com/jarednova">@JaredNova</a>) and <a h
|
|
6 |
|
7 |
[![Build Status](https://travis-ci.org/jarednova/timber.png?branch=master)](https://travis-ci.org/jarednova/timber)
|
8 |
[![Coverage Status](https://coveralls.io/repos/jarednova/timber/badge.svg?branch=master)](https://coveralls.io/r/jarednova/timber?branch=master)
|
9 |
-
[![Dependency Status](https://www.versioneye.com/
|
10 |
|
11 |
### Because WordPress is awesome, but the_loop isn't
|
12 |
Timber helps you create fully-customized WordPress themes faster with more sustainable code. With Timber, you write your HTML using the [Twig Template Engine](http://twig.sensiolabs.org/) separate from your PHP files.
|
@@ -38,13 +38,13 @@ Once Timber is installed and activated in your plugin directory, it gives any Wo
|
|
38 |
|
39 |
### Installation
|
40 |
|
41 |
-
|
42 |
|
43 |
```shell
|
44 |
composer create-project --no-dev jarednova/timber ~/MYSITE/wp-content/plugins/timber
|
45 |
```
|
46 |
|
47 |
-
Once this is complete, activate Timber your WordPress admin. If you're looking for a 'blank' theme to start developing with,
|
48 |
|
49 |
* * *
|
50 |
|
@@ -61,6 +61,7 @@ Nothing. Timber is meant for you to build a theme on. Like the [Starkers](https:
|
|
61 |
Timber is great for any WordPress developer who cares about writing good, maintainable code. It helps teams of designers and developers working together. At [Upstatement](http://upstatement.com) we made Timber because while our entire team needs to participate in building WordPress sites, not everyone knows the ins-and-outs of the_loop(), codex and PHP (nor should they). With Timber your best WordPress dev can focus on building the .php files with requests from WordPress and pass the data into .twig files. Once there, designers can easily mark-up data and build out a site's look-and-feel.
|
62 |
|
63 |
#### Related Projects
|
|
|
64 |
* [**Timber Debug Bar**](https://github.com/upstatement/debug-bar-timber) Adds a debug bar panel that will show you want template is in-use and the data sent to your twig file.
|
65 |
* [**TimberPhoton**](https://github.com/slimndap/TimberPhoton) Plug-in to use JetPack's free Photon image manipulation and CDN with Timber.
|
66 |
* [**Timber Sugar**](https://github.com/Upstatement/timber-sugar) A catch-all for goodies to use w Timber.
|
6 |
|
7 |
[![Build Status](https://travis-ci.org/jarednova/timber.png?branch=master)](https://travis-ci.org/jarednova/timber)
|
8 |
[![Coverage Status](https://coveralls.io/repos/jarednova/timber/badge.svg?branch=master)](https://coveralls.io/r/jarednova/timber?branch=master)
|
9 |
+
[![Dependency Status](https://www.versioneye.com/user/projects/54e3c717d1ec5734f4000099/badge.svg?style=flat)](https://www.versioneye.com/user/projects/54e3c717d1ec5734f4000099)
|
10 |
|
11 |
### Because WordPress is awesome, but the_loop isn't
|
12 |
Timber helps you create fully-customized WordPress themes faster with more sustainable code. With Timber, you write your HTML using the [Twig Template Engine](http://twig.sensiolabs.org/) separate from your PHP files.
|
38 |
|
39 |
### Installation
|
40 |
|
41 |
+
The GitHub version of Timber requires [Composer](https://getcomposer.org/download/). If you'd prefer one-click installation, you should use the [WordPress.org](http://wordpress.org/plugins/timber-library/) version.
|
42 |
|
43 |
```shell
|
44 |
composer create-project --no-dev jarednova/timber ~/MYSITE/wp-content/plugins/timber
|
45 |
```
|
46 |
|
47 |
+
Once this is complete, activate Timber your WordPress admin. If you're looking for a 'blank' theme to start developing with, download the [timber-starter-theme](https://github.com/upstatement/timber-starter-theme) into your themes directory.
|
48 |
|
49 |
* * *
|
50 |
|
61 |
Timber is great for any WordPress developer who cares about writing good, maintainable code. It helps teams of designers and developers working together. At [Upstatement](http://upstatement.com) we made Timber because while our entire team needs to participate in building WordPress sites, not everyone knows the ins-and-outs of the_loop(), codex and PHP (nor should they). With Timber your best WordPress dev can focus on building the .php files with requests from WordPress and pass the data into .twig files. Once there, designers can easily mark-up data and build out a site's look-and-feel.
|
62 |
|
63 |
#### Related Projects
|
64 |
+
* [**Timber Starter Theme**](https://github.com/upstatement/timber-starter-theme) The "_s" of Timber to give you an easy start to the most basic theme you can build upon and customize.
|
65 |
* [**Timber Debug Bar**](https://github.com/upstatement/debug-bar-timber) Adds a debug bar panel that will show you want template is in-use and the data sent to your twig file.
|
66 |
* [**TimberPhoton**](https://github.com/slimndap/TimberPhoton) Plug-in to use JetPack's free Photon image manipulation and CDN with Timber.
|
67 |
* [**Timber Sugar**](https://github.com/Upstatement/timber-sugar) A catch-all for goodies to use w Timber.
|
lib/cache/loader.php
DELETED
@@ -1,24 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class TimberCache_Loader
|
4 |
-
{
|
5 |
-
|
6 |
-
public static function register($prepend = false) {
|
7 |
-
if (version_compare(phpversion(), '5.3.0', '>=')) {
|
8 |
-
spl_autoload_register(array(new self, 'autoload'), true, $prepend);
|
9 |
-
} else {
|
10 |
-
spl_autoload_register(array(new self, 'autoload'));
|
11 |
-
}
|
12 |
-
}
|
13 |
-
|
14 |
-
public static function autoload($class) {
|
15 |
-
if (0 === strpos($class, 'Timber\Cache')) {
|
16 |
-
$classes = explode('\\', $class);
|
17 |
-
array_splice($classes, 0, 2);
|
18 |
-
$path = implode($classes, '/');
|
19 |
-
if (is_file($file = dirname(__FILE__) . '/' . $path . '.php')) {
|
20 |
-
require $file;
|
21 |
-
}
|
22 |
-
}
|
23 |
-
}
|
24 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lib/integrations/acf-timber.php
CHANGED
@@ -55,8 +55,4 @@ class ACFTimber {
|
|
55 |
}
|
56 |
}
|
57 |
|
58 |
-
|
59 |
-
if ( class_exists( 'ACF' ) ) {
|
60 |
-
new ACFTimber();
|
61 |
-
}
|
62 |
-
} );
|
55 |
}
|
56 |
}
|
57 |
|
58 |
+
|
|
|
|
|
|
|
|
lib/integrations/timber-command.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* These are methods that can be executed by WPCLI, other CLI mechanism or other external controllers
|
5 |
+
* @package timber
|
6 |
+
*/
|
7 |
+
class TimberCommand {
|
8 |
+
|
9 |
+
public static function clear_cache($mode = 'all'){
|
10 |
+
if (is_array($mode)){
|
11 |
+
$mode = reset($mode);
|
12 |
+
}
|
13 |
+
if ($mode == 'all') {
|
14 |
+
$twig_cache = self::clear_cache_twig();
|
15 |
+
$timber_cache = self::clear_cache_timber();
|
16 |
+
if ($twig_cache && $timber_cache){
|
17 |
+
return true;
|
18 |
+
}
|
19 |
+
} else if ($mode == 'twig') {
|
20 |
+
return self::clear_cache_twig();
|
21 |
+
} else if ($mode == 'timber') {
|
22 |
+
return self::clear_cache_timber();
|
23 |
+
}
|
24 |
+
}
|
25 |
+
|
26 |
+
static function clear_cache_timber(){
|
27 |
+
$loader = new TimberLoader();
|
28 |
+
return $loader->clear_cache_timber();
|
29 |
+
}
|
30 |
+
|
31 |
+
static function clear_cache_twig(){
|
32 |
+
$loader = new TimberLoader();
|
33 |
+
return $loader->clear_cache_twig();
|
34 |
+
}
|
35 |
+
|
36 |
+
}
|
lib/integrations/wpcli-timber.php
CHANGED
@@ -1,88 +1,57 @@
|
|
1 |
<?php
|
2 |
-
if (class_exists('WP_CLI_Command')) {
|
3 |
-
|
4 |
-
|
5 |
-
/**
|
6 |
-
* Clears Timber and Twig's Cache
|
7 |
-
*
|
8 |
-
* ## EXAMPLES
|
9 |
-
*
|
10 |
-
* wp timber clear_cache
|
11 |
-
*
|
12 |
-
*/
|
13 |
-
public function clear_cache($mode = 'all') {
|
14 |
-
TimberCommand::clear_cache($mode);
|
15 |
-
}
|
16 |
-
|
17 |
-
/**
|
18 |
-
* Clears Twig's Cache
|
19 |
-
*
|
20 |
-
* ## EXAMPLES
|
21 |
-
*
|
22 |
-
* wp timber clear_cache_twig
|
23 |
-
*
|
24 |
-
*/
|
25 |
-
function clear_cache_twig(){
|
26 |
-
$clear = TimberCommand::clear_cache_twig();
|
27 |
-
if ($clear){
|
28 |
-
WP_CLI::success('Cleared contents of twig cache');
|
29 |
-
} else {
|
30 |
-
WP_CLI::warning('Failed to clear twig cache');
|
31 |
-
}
|
32 |
-
}
|
33 |
-
|
34 |
-
/**
|
35 |
-
* Clears Timber's Cache
|
36 |
-
*
|
37 |
-
* ## EXAMPLES
|
38 |
-
*
|
39 |
-
* wp timber clear_cache_timber
|
40 |
-
*
|
41 |
-
*/
|
42 |
-
function clear_cache_timber() {
|
43 |
-
$clear = TimberCommand::clear_cache_timber();
|
44 |
-
$message = 'Failed to clear timber cache';
|
45 |
-
if ($clear){
|
46 |
-
$message = "Cleared contents of Timber's Cache";
|
47 |
-
WP_CLI::success($message);
|
48 |
-
} else {
|
49 |
-
WP_CLI::warning($message);
|
50 |
-
}
|
51 |
-
return $message;
|
52 |
-
}
|
53 |
-
|
54 |
-
}
|
55 |
-
|
56 |
-
WP_CLI::add_command('timber', 'Timber_WP_CLI_Command');
|
57 |
}
|
58 |
|
59 |
-
class
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
} else if ($mode == 'twig') {
|
72 |
-
return self::clear_cache_twig();
|
73 |
-
} else if ($mode == 'timber') {
|
74 |
-
return self::clear_cache_timber();
|
75 |
-
}
|
76 |
}
|
77 |
|
78 |
-
|
79 |
-
|
80 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
81 |
}
|
82 |
|
83 |
-
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
}
|
87 |
|
88 |
}
|
1 |
<?php
|
2 |
+
if (!class_exists('WP_CLI_Command')) {
|
3 |
+
return;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
4 |
}
|
5 |
|
6 |
+
class Timber_WP_CLI_Command extends WP_CLI_Command {
|
7 |
+
|
8 |
+
/**
|
9 |
+
* Clears Timber and Twig's Cache
|
10 |
+
*
|
11 |
+
* ## EXAMPLES
|
12 |
+
*
|
13 |
+
* wp timber clear_cache
|
14 |
+
*
|
15 |
+
*/
|
16 |
+
public function clear_cache($mode = 'all') {
|
17 |
+
TimberCommand::clear_cache($mode);
|
|
|
|
|
|
|
|
|
|
|
18 |
}
|
19 |
|
20 |
+
/**
|
21 |
+
* Clears Twig's Cache
|
22 |
+
*
|
23 |
+
* ## EXAMPLES
|
24 |
+
*
|
25 |
+
* wp timber clear_cache_twig
|
26 |
+
*
|
27 |
+
*/
|
28 |
+
function clear_cache_twig(){
|
29 |
+
$clear = TimberCommand::clear_cache_twig();
|
30 |
+
if ($clear){
|
31 |
+
WP_CLI::success('Cleared contents of twig cache');
|
32 |
+
} else {
|
33 |
+
WP_CLI::warning('Failed to clear twig cache');
|
34 |
+
}
|
35 |
}
|
36 |
|
37 |
+
/**
|
38 |
+
* Clears Timber's Cache
|
39 |
+
*
|
40 |
+
* ## EXAMPLES
|
41 |
+
*
|
42 |
+
* wp timber clear_cache_timber
|
43 |
+
*
|
44 |
+
*/
|
45 |
+
function clear_cache_timber() {
|
46 |
+
$clear = TimberCommand::clear_cache_timber();
|
47 |
+
$message = 'Failed to clear timber cache';
|
48 |
+
if ($clear){
|
49 |
+
$message = "Cleared contents of Timber's Cache";
|
50 |
+
WP_CLI::success($message);
|
51 |
+
} else {
|
52 |
+
WP_CLI::warning($message);
|
53 |
+
}
|
54 |
+
return $message;
|
55 |
}
|
56 |
|
57 |
}
|
lib/timber-admin.php
CHANGED
@@ -2,18 +2,16 @@
|
|
2 |
|
3 |
class TimberAdmin {
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
|
9 |
/**
|
10 |
-
*
|
11 |
-
*
|
12 |
* @param array $links
|
13 |
* @param string $file
|
14 |
* @return array
|
15 |
*/
|
16 |
-
function meta_links( $links, $file ) {
|
17 |
if ( strstr( $file, '/timber.php' ) ) {
|
18 |
unset($links[2]);
|
19 |
$links[] = '<a href="/wp-admin/plugin-install.php?tab=plugin-information&plugin=timber-library&TB_iframe=true&width=600&height=550" class="thickbox" aria-label="More information about Timber" data-title="Timber">View details</a>';
|
@@ -25,7 +23,4 @@ class TimberAdmin {
|
|
25 |
return $links;
|
26 |
}
|
27 |
|
28 |
-
}
|
29 |
-
|
30 |
-
global $timber_admin;
|
31 |
-
$timber_admin = new TimberAdmin();
|
2 |
|
3 |
class TimberAdmin {
|
4 |
|
5 |
+
public static function init() {
|
6 |
+
add_filter( 'plugin_row_meta', array( __CLASS__, 'meta_links' ), 10, 2 );
|
7 |
+
}
|
8 |
|
9 |
/**
|
|
|
|
|
10 |
* @param array $links
|
11 |
* @param string $file
|
12 |
* @return array
|
13 |
*/
|
14 |
+
public static function meta_links( $links, $file ) {
|
15 |
if ( strstr( $file, '/timber.php' ) ) {
|
16 |
unset($links[2]);
|
17 |
$links[] = '<a href="/wp-admin/plugin-install.php?tab=plugin-information&plugin=timber-library&TB_iframe=true&width=600&height=550" class="thickbox" aria-label="More information about Timber" data-title="Timber">View details</a>';
|
23 |
return $links;
|
24 |
}
|
25 |
|
26 |
+
}
|
|
|
|
|
|
lib/timber-image-helper.php
CHANGED
@@ -17,11 +17,17 @@ class TimberImageHelper {
|
|
17 |
|
18 |
const BASE_UPLOADS = 1;
|
19 |
const BASE_CONTENT = 2;
|
20 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
/**
|
22 |
* Generates a new image with the specified dimensions.
|
23 |
* New dimensions are achieved by cropping to maintain ratio.
|
24 |
-
*
|
25 |
* @param string $src an URL (absolute or relative) to the original image
|
26 |
* @param int $w target width
|
27 |
* @param int $h target heighth
|
@@ -84,8 +90,9 @@ class TimberImageHelper {
|
|
84 |
$post = get_post( $post_id );
|
85 |
$image_types = array( 'image/jpeg', 'image/png', 'image/gif', 'image/jpg' );
|
86 |
if ( $post->post_type == 'attachment' && in_array( $post->post_mime_type, $image_types ) ) {
|
87 |
-
|
88 |
-
TimberImageHelper::
|
|
|
89 |
}
|
90 |
} );
|
91 |
}
|
@@ -101,19 +108,6 @@ class TimberImageHelper {
|
|
101 |
}
|
102 |
}
|
103 |
|
104 |
-
|
105 |
-
/**
|
106 |
-
* load the dependencies of TimberImageOperations
|
107 |
-
* @return void
|
108 |
-
*/
|
109 |
-
static function load_dependencies() {
|
110 |
-
require_once('image/timber-image-operation.php');
|
111 |
-
require_once('image/timber-image-operation-pngtojpg.php');
|
112 |
-
require_once('image/timber-image-operation-retina.php');
|
113 |
-
require_once('image/timber-image-operation-letterbox.php');
|
114 |
-
require_once('image/timber-image-operation-resize.php');
|
115 |
-
}
|
116 |
-
|
117 |
/**
|
118 |
* adds a 'relative' key to wp_upload_dir() result.
|
119 |
* It will contain the relative url to upload dir.
|
@@ -126,10 +120,10 @@ class TimberImageHelper {
|
|
126 |
} );
|
127 |
}
|
128 |
|
129 |
-
//-- end of public
|
|
|
|
|
130 |
|
131 |
-
|
132 |
-
|
133 |
|
134 |
/**
|
135 |
* @return boolean true if $path is an external url, false if relative or local.
|
@@ -139,11 +133,16 @@ class TimberImageHelper {
|
|
139 |
}
|
140 |
|
141 |
/**
|
142 |
-
* Deletes resized versions of the supplied file name
|
|
|
143 |
*
|
144 |
-
* @param string $local_file
|
|
|
145 |
*/
|
146 |
static function delete_resized_files( $local_file ) {
|
|
|
|
|
|
|
147 |
$info = pathinfo( $local_file );
|
148 |
$dir = $info['dirname'];
|
149 |
$ext = $info['extension'];
|
@@ -168,6 +167,9 @@ class TimberImageHelper {
|
|
168 |
* @param string $local_file
|
169 |
*/
|
170 |
static function delete_letterboxed_files( $local_file ) {
|
|
|
|
|
|
|
171 |
$info = pathinfo( $local_file );
|
172 |
$dir = $info['dirname'];
|
173 |
$ext = $info['extension'];
|
@@ -256,7 +258,7 @@ class TimberImageHelper {
|
|
256 |
* Takes in an URL and breaks it into components,
|
257 |
* that will then be used in the different steps of image processing.
|
258 |
* The image is expected to be either part of a theme, plugin, or an upload.
|
259 |
-
*
|
260 |
* @param string $url an URL (absolute or relative) pointing to an image
|
261 |
* @return array an array (see keys in code below)
|
262 |
*/
|
@@ -306,7 +308,7 @@ class TimberImageHelper {
|
|
306 |
|
307 |
/**
|
308 |
* Builds the public URL of a file based on its different components
|
309 |
-
*
|
310 |
* @param int $base one of self::BASE_UPLOADS, self::BASE_CONTENT to indicate if file is an upload or a content (theme or plugin)
|
311 |
* @param string $subdir subdirectory in which file is stored, relative to $base root folder
|
312 |
* @param string $filename file name, including extension (but no path)
|
@@ -335,7 +337,7 @@ class TimberImageHelper {
|
|
335 |
|
336 |
/**
|
337 |
* Builds the absolute file system location of a file based on its different components
|
338 |
-
*
|
339 |
* @param int $base one of self::BASE_UPLOADS, self::BASE_CONTENT to indicate if file is an upload or a content (theme or plugin)
|
340 |
* @param string $subdir subdirectory in which file is stored, relative to $base root folder
|
341 |
* @param string $filename file name, including extension (but no path)
|
@@ -364,12 +366,12 @@ class TimberImageHelper {
|
|
364 |
* 2. use components to determine result file and URL
|
365 |
* 3. check if a result file already exists
|
366 |
* 4. otherwise, delegate to supplied TimberImageOperation
|
367 |
-
*
|
368 |
* @param string $src an URL (absolute or relative) to an image
|
369 |
* @param object $op object of class TimberImageOperation
|
370 |
* @param boolean $force if true, remove any already existing result file and forces file generation
|
371 |
* @return string URL to the new image - or the source one if error
|
372 |
-
*
|
373 |
*/
|
374 |
private static function _operate( $src, $op, $force = false ) {
|
375 |
if ( empty( $src ) ) {
|
@@ -419,7 +421,7 @@ class TimberImageHelper {
|
|
419 |
|
420 |
|
421 |
// -- the below methods are just used for unit testing the URL generation code
|
422 |
-
//
|
423 |
static function get_letterbox_file_url($url, $w, $h, $color) {
|
424 |
$au = self::analyze_url($url);
|
425 |
$op = new TimberImageOperationLetterbox($w, $h, $color);
|
@@ -465,9 +467,3 @@ class TimberImageHelper {
|
|
465 |
|
466 |
|
467 |
}
|
468 |
-
|
469 |
-
|
470 |
-
TimberImageHelper::load_dependencies();
|
471 |
-
TimberImageHelper::add_constants();
|
472 |
-
TimberImageHelper::add_actions();
|
473 |
-
TimberImageHelper::add_filters();
|
17 |
|
18 |
const BASE_UPLOADS = 1;
|
19 |
const BASE_CONTENT = 2;
|
20 |
+
|
21 |
+
public static function init() {
|
22 |
+
self::add_constants();
|
23 |
+
self::add_actions();
|
24 |
+
self::add_filters();
|
25 |
+
}
|
26 |
+
|
27 |
/**
|
28 |
* Generates a new image with the specified dimensions.
|
29 |
* New dimensions are achieved by cropping to maintain ratio.
|
30 |
+
*
|
31 |
* @param string $src an URL (absolute or relative) to the original image
|
32 |
* @param int $w target width
|
33 |
* @param int $h target heighth
|
90 |
$post = get_post( $post_id );
|
91 |
$image_types = array( 'image/jpeg', 'image/png', 'image/gif', 'image/jpg' );
|
92 |
if ( $post->post_type == 'attachment' && in_array( $post->post_mime_type, $image_types ) ) {
|
93 |
+
$attachment = new TimberImage( $post_id );
|
94 |
+
TimberImageHelper::delete_resized_files( $attachment->file_loc );
|
95 |
+
TimberImageHelper::delete_letterboxed_files( $attachment->file_loc );
|
96 |
}
|
97 |
} );
|
98 |
}
|
108 |
}
|
109 |
}
|
110 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
111 |
/**
|
112 |
* adds a 'relative' key to wp_upload_dir() result.
|
113 |
* It will contain the relative url to upload dir.
|
120 |
} );
|
121 |
}
|
122 |
|
123 |
+
//-- end of public methods --//
|
124 |
+
|
125 |
+
|
126 |
|
|
|
|
|
127 |
|
128 |
/**
|
129 |
* @return boolean true if $path is an external url, false if relative or local.
|
133 |
}
|
134 |
|
135 |
/**
|
136 |
+
* Deletes resized versions of the supplied file name.
|
137 |
+
* So if passed a value like my-pic.jpg, this function will delete my-pic-500x200-c-left.jpg, my-pic-400x400-c-default.jpg, etc.
|
138 |
*
|
139 |
+
* @param string $local_file ex: /var/www/wp-content/uploads/2015/my-pic.jpg
|
140 |
+
* ex: http://example.org/wp-content/uploads/2015/foo.png
|
141 |
*/
|
142 |
static function delete_resized_files( $local_file ) {
|
143 |
+
if (TimberURLHelper::is_absolute( $local_file ) ) {
|
144 |
+
$local_file = TimberURLHelper::url_to_file_system( $local_file );
|
145 |
+
}
|
146 |
$info = pathinfo( $local_file );
|
147 |
$dir = $info['dirname'];
|
148 |
$ext = $info['extension'];
|
167 |
* @param string $local_file
|
168 |
*/
|
169 |
static function delete_letterboxed_files( $local_file ) {
|
170 |
+
if (TimberURLHelper::is_absolute( $local_file ) ) {
|
171 |
+
$local_file = TimberURLHelper::url_to_file_system( $local_file );
|
172 |
+
}
|
173 |
$info = pathinfo( $local_file );
|
174 |
$dir = $info['dirname'];
|
175 |
$ext = $info['extension'];
|
258 |
* Takes in an URL and breaks it into components,
|
259 |
* that will then be used in the different steps of image processing.
|
260 |
* The image is expected to be either part of a theme, plugin, or an upload.
|
261 |
+
*
|
262 |
* @param string $url an URL (absolute or relative) pointing to an image
|
263 |
* @return array an array (see keys in code below)
|
264 |
*/
|
308 |
|
309 |
/**
|
310 |
* Builds the public URL of a file based on its different components
|
311 |
+
*
|
312 |
* @param int $base one of self::BASE_UPLOADS, self::BASE_CONTENT to indicate if file is an upload or a content (theme or plugin)
|
313 |
* @param string $subdir subdirectory in which file is stored, relative to $base root folder
|
314 |
* @param string $filename file name, including extension (but no path)
|
337 |
|
338 |
/**
|
339 |
* Builds the absolute file system location of a file based on its different components
|
340 |
+
*
|
341 |
* @param int $base one of self::BASE_UPLOADS, self::BASE_CONTENT to indicate if file is an upload or a content (theme or plugin)
|
342 |
* @param string $subdir subdirectory in which file is stored, relative to $base root folder
|
343 |
* @param string $filename file name, including extension (but no path)
|
366 |
* 2. use components to determine result file and URL
|
367 |
* 3. check if a result file already exists
|
368 |
* 4. otherwise, delegate to supplied TimberImageOperation
|
369 |
+
*
|
370 |
* @param string $src an URL (absolute or relative) to an image
|
371 |
* @param object $op object of class TimberImageOperation
|
372 |
* @param boolean $force if true, remove any already existing result file and forces file generation
|
373 |
* @return string URL to the new image - or the source one if error
|
374 |
+
*
|
375 |
*/
|
376 |
private static function _operate( $src, $op, $force = false ) {
|
377 |
if ( empty( $src ) ) {
|
421 |
|
422 |
|
423 |
// -- the below methods are just used for unit testing the URL generation code
|
424 |
+
//
|
425 |
static function get_letterbox_file_url($url, $w, $h, $color) {
|
426 |
$au = self::analyze_url($url);
|
427 |
$op = new TimberImageOperationLetterbox($w, $h, $color);
|
467 |
|
468 |
|
469 |
}
|
|
|
|
|
|
|
|
|
|
|
|
lib/timber-image.php
CHANGED
@@ -189,6 +189,10 @@ class TimberImage extends TimberPost implements TimberCoreInterface {
|
|
189 |
} else if (isset($this->_wp_attached_file)) {
|
190 |
$this->file = reset($this->_wp_attached_file);
|
191 |
$this->file_loc = $basedir . DIRECTORY_SEPARATOR . $this->file;
|
|
|
|
|
|
|
|
|
192 |
}
|
193 |
if (isset($image_info['id'])) {
|
194 |
$this->ID = $image_info['id'];
|
189 |
} else if (isset($this->_wp_attached_file)) {
|
190 |
$this->file = reset($this->_wp_attached_file);
|
191 |
$this->file_loc = $basedir . DIRECTORY_SEPARATOR . $this->file;
|
192 |
+
} else if ( isset( $this->guid ) ) {
|
193 |
+
if ( TimberURLHelper::is_absolute( $this->guid ) ) {
|
194 |
+
$this->file_loc = TimberURLHelper::url_to_file_system( $this->guid );
|
195 |
+
}
|
196 |
}
|
197 |
if (isset($image_info['id'])) {
|
198 |
$this->ID = $image_info['id'];
|
lib/timber-integrations.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* This is for integrating external plugins into timber
|
5 |
+
* @package timber
|
6 |
+
*/
|
7 |
+
class TimberIntegrations {
|
8 |
+
public static function init() {
|
9 |
+
|
10 |
+
add_action( 'init', array( __CLASS__, 'maybe_init_acftimber' ) );
|
11 |
+
|
12 |
+
if ( class_exists( 'WP_CLI_Command' ) ) {
|
13 |
+
WP_CLI::add_command( 'timber', 'Timber_WP_CLI_Command' );
|
14 |
+
}
|
15 |
+
}
|
16 |
+
|
17 |
+
public static function maybe_init_acftimber() {
|
18 |
+
|
19 |
+
if ( class_exists( 'ACF' ) ) {
|
20 |
+
new ACFTimber();
|
21 |
+
}
|
22 |
+
|
23 |
+
}
|
24 |
+
}
|
lib/timber-loader.php
CHANGED
@@ -320,14 +320,11 @@ class TimberLoader {
|
|
320 |
* @return \Asm89\Twig\CacheExtension\Extension
|
321 |
*/
|
322 |
private function _get_cache_extension() {
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
$
|
328 |
-
$cache_provider = new \Timber\Cache\WPObjectCacheAdapter($this);
|
329 |
-
$cache_strategy = new \Asm89\Twig\CacheExtension\CacheStrategy\GenerationalCacheStrategy($cache_provider, $key_generator);
|
330 |
-
$cache_extension = new \Asm89\Twig\CacheExtension\Extension($cache_strategy);
|
331 |
|
332 |
return $cache_extension;
|
333 |
}
|
320 |
* @return \Asm89\Twig\CacheExtension\Extension
|
321 |
*/
|
322 |
private function _get_cache_extension() {
|
323 |
+
|
324 |
+
$key_generator = new \Timber\Cache\KeyGenerator();
|
325 |
+
$cache_provider = new \Timber\Cache\WPObjectCacheAdapter( $this );
|
326 |
+
$cache_strategy = new \Asm89\Twig\CacheExtension\CacheStrategy\GenerationalCacheStrategy( $cache_provider, $key_generator );
|
327 |
+
$cache_extension = new \Asm89\Twig\CacheExtension\Extension( $cache_strategy );
|
|
|
|
|
|
|
328 |
|
329 |
return $cache_extension;
|
330 |
}
|
lib/timber-routes.php
CHANGED
@@ -2,106 +2,27 @@
|
|
2 |
|
3 |
class TimberRoutes {
|
4 |
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
add_action('init', array($this, 'init'));
|
9 |
}
|
10 |
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
$callback($params);
|
19 |
-
}
|
20 |
-
}
|
21 |
-
}
|
22 |
-
|
23 |
-
/**
|
24 |
-
* @param string $route
|
25 |
-
* @param callable $callback
|
26 |
-
*/
|
27 |
-
public static function add_route($route, $callback, $args = array()) {
|
28 |
-
global $timber;
|
29 |
-
if (!isset($timber->router)) {
|
30 |
-
$timber->router = new PHPRouter\Router();
|
31 |
-
$site_url = get_bloginfo('url');
|
32 |
-
$site_url_parts = explode('/', $site_url);
|
33 |
-
$site_url_parts = array_slice($site_url_parts, 3);
|
34 |
-
$base_path = implode('/', $site_url_parts);
|
35 |
-
if (!$base_path || strpos($route, $base_path) === 0) {
|
36 |
-
$base_path = '/';
|
37 |
-
} else {
|
38 |
-
$base_path = '/' . $base_path . '/';
|
39 |
-
}
|
40 |
-
$timber->router->setBasePath($base_path);
|
41 |
-
}
|
42 |
-
$timber->router->map($route, $callback, $args);
|
43 |
-
}
|
44 |
-
|
45 |
-
/**
|
46 |
-
* @param array $template
|
47 |
-
* @param mixed $query
|
48 |
-
* @param int $status_code
|
49 |
-
* @param bool $tparams
|
50 |
-
* @return bool
|
51 |
-
*/
|
52 |
-
public static function load_view($template, $query = false, $status_code = 200, $tparams = false) {
|
53 |
-
$fullPath = is_readable($template);
|
54 |
-
if (!$fullPath) {
|
55 |
-
$template = locate_template($template);
|
56 |
-
}
|
57 |
-
if ($tparams){
|
58 |
-
global $params;
|
59 |
-
$params = $tparams;
|
60 |
-
}
|
61 |
-
if ($status_code) {
|
62 |
-
add_filter('status_header', function($status_header, $header, $text, $protocol) use ($status_code) {
|
63 |
-
$text = get_status_header_desc($status_code);
|
64 |
-
$header_string = "$protocol $status_code $text";
|
65 |
-
return $header_string;
|
66 |
-
}, 10, 4 );
|
67 |
-
if (404 != $status_code) {
|
68 |
-
add_action('parse_query', function($query) {
|
69 |
-
if ($query->is_main_query()){
|
70 |
-
$query->is_404 = false;
|
71 |
-
}
|
72 |
-
},1);
|
73 |
-
add_action('template_redirect', function(){
|
74 |
-
global $wp_query;
|
75 |
-
$wp_query->is_404 = false;
|
76 |
-
},1);
|
77 |
-
}
|
78 |
-
}
|
79 |
-
|
80 |
-
if ($query) {
|
81 |
-
add_action('do_parse_request', function() use ($query) {
|
82 |
-
global $wp;
|
83 |
-
if ( is_callable($query) )
|
84 |
-
$query = call_user_func($query);
|
85 |
-
|
86 |
-
if ( is_array($query) )
|
87 |
-
$wp->query_vars = $query;
|
88 |
-
elseif ( !empty($query) )
|
89 |
-
parse_str($query, $wp->query_vars);
|
90 |
-
else
|
91 |
-
return true; // Could not interpret query. Let WP try.
|
92 |
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
}
|
104 |
}
|
105 |
-
|
106 |
-
global $timberRoutes;
|
107 |
-
$timberRoutes = new TimberRoutes();
|
2 |
|
3 |
class TimberRoutes {
|
4 |
|
5 |
+
public static function init( $timber ) {
|
6 |
+
// Install ourselves in Timber
|
7 |
+
$timber->routes = new TimberRoutes();
|
|
|
8 |
}
|
9 |
|
10 |
+
/**
|
11 |
+
* @param string $route
|
12 |
+
* @param callable $callback
|
13 |
+
*/
|
14 |
+
public static function add_route($route, $callback, $args = array()) {
|
15 |
+
Routes::map($route, $callback, $args);
|
16 |
+
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
17 |
|
18 |
+
/**
|
19 |
+
* @param array $template
|
20 |
+
* @param mixed $query
|
21 |
+
* @param int $status_code
|
22 |
+
* @param bool $tparams
|
23 |
+
* @return bool
|
24 |
+
*/
|
25 |
+
public static function load_view($template, $query = false, $status_code = 200, $tparams = false) {
|
26 |
+
Routes::load($template, $tparams, $query, $status_code);
|
27 |
+
}
|
|
|
28 |
}
|
|
|
|
|
|
lib/timber-twig.php
CHANGED
@@ -4,6 +4,13 @@ class TimberTwig {
|
|
4 |
|
5 |
public static $dir_name;
|
6 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
function __construct() {
|
8 |
add_action( 'twig_apply_filters', array( $this, 'add_timber_filters_deprecated' ) );
|
9 |
add_action( 'twig_apply_filters', array( $this, 'add_timber_filters' ) );
|
@@ -285,5 +292,3 @@ class TimberTwig {
|
|
285 |
}
|
286 |
|
287 |
}
|
288 |
-
|
289 |
-
new TimberTwig();
|
4 |
|
5 |
public static $dir_name;
|
6 |
|
7 |
+
/**
|
8 |
+
* Initialization
|
9 |
+
*/
|
10 |
+
public static function init() {
|
11 |
+
new TimberTwig();
|
12 |
+
}
|
13 |
+
|
14 |
function __construct() {
|
15 |
add_action( 'twig_apply_filters', array( $this, 'add_timber_filters_deprecated' ) );
|
16 |
add_action( 'twig_apply_filters', array( $this, 'add_timber_filters' ) );
|
292 |
}
|
293 |
|
294 |
}
|
|
|
|
readme.txt
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
Contributors: jarednova
|
3 |
Tags: template engine, templates, twig
|
4 |
Requires at least: 3.7
|
5 |
-
Stable tag: 0.
|
6 |
Tested up to: 4.1
|
7 |
PHP version: 5.3.0 or greater
|
8 |
License: GPLv2 or later
|
@@ -41,6 +41,15 @@ Timber is great for any WordPress developer who cares about writing good, mainta
|
|
41 |
|
42 |
== Changelog ==
|
43 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
44 |
= 0.20.10 =
|
45 |
* Resolved lingering composer issues (thanks @austinpray, @lucasmichot)
|
46 |
* You can now access `{{comment.status}}` when working with comments (thanks @simonmilz)
|
@@ -82,7 +91,7 @@ Timber is great for any WordPress developer who cares about writing good, mainta
|
|
82 |
= 0.20.4 =
|
83 |
* Fixed issue with Timber::get_posts and Timber::query_posts using numberposts in args
|
84 |
|
85 |
-
= 0.20.3 =
|
86 |
* Fixed some issues with linking to menu items with a hash
|
87 |
|
88 |
= 0.20.2 =
|
2 |
Contributors: jarednova
|
3 |
Tags: template engine, templates, twig
|
4 |
Requires at least: 3.7
|
5 |
+
Stable tag: 0.21.1
|
6 |
Tested up to: 4.1
|
7 |
PHP version: 5.3.0 or greater
|
8 |
License: GPLv2 or later
|
41 |
|
42 |
== Changelog ==
|
43 |
|
44 |
+
= 0.21.1 =
|
45 |
+
* Fixed capitalization problem for WP.org version
|
46 |
+
|
47 |
+
= 0.21.0 =
|
48 |
+
* Routes is now its own independent repo
|
49 |
+
* Timber Starter Theme is now its own independent repo
|
50 |
+
* Improved loading of files (thanks @mgmartel)
|
51 |
+
* Fixed some errors with TimberImages (thanks @imranismail)
|
52 |
+
|
53 |
= 0.20.10 =
|
54 |
* Resolved lingering composer issues (thanks @austinpray, @lucasmichot)
|
55 |
* You can now access `{{comment.status}}` when working with comments (thanks @simonmilz)
|
91 |
= 0.20.4 =
|
92 |
* Fixed issue with Timber::get_posts and Timber::query_posts using numberposts in args
|
93 |
|
94 |
+
= 0.20.3 =
|
95 |
* Fixed some issues with linking to menu items with a hash
|
96 |
|
97 |
= 0.20.2 =
|
timber-starter-theme/.gitignore
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
vendor
|
2 |
+
wp-content
|
{vendor/jarednova/php-router → timber-starter-theme}/LICENSE
RENAMED
@@ -1,4 +1,4 @@
|
|
1 |
-
Copyright (c) 2012
|
2 |
|
3 |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4 |
|
1 |
+
Copyright (c) 2012-2013 Jared Novack
|
2 |
|
3 |
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4 |
|
timber-starter-theme/README.md
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
1 |
+
# timber-starter-theme
|
2 |
+
The "_s" for Timber: a dead-simple theme that you can build from
|
timber-starter-theme/composer.json
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "upstatement/timber-starter-theme",
|
3 |
+
"description": "Starter theme to build a Timber theme",
|
4 |
+
"type":"wordpress-plugin",
|
5 |
+
"minimum-stability" : "dev",
|
6 |
+
"authors": [
|
7 |
+
{
|
8 |
+
"name": "jarednova",
|
9 |
+
"email": "jared@upstatement.com"
|
10 |
+
}
|
11 |
+
],
|
12 |
+
"require-dev": {
|
13 |
+
"jarednova/timber": "dev-master"
|
14 |
+
},
|
15 |
+
"repositories": [
|
16 |
+
{
|
17 |
+
"type" : "package",
|
18 |
+
"package" : {
|
19 |
+
"name" : "jarednova/php-router",
|
20 |
+
"version" : "1.0.1",
|
21 |
+
"dist" : {
|
22 |
+
"url" : "https://github.com/jarednova/PHP-Router/archive/fix_psr_0.zip",
|
23 |
+
"type" : "zip"
|
24 |
+
},
|
25 |
+
"autoload": {
|
26 |
+
"psr-0": {
|
27 |
+
"PHPRouter": "src/"
|
28 |
+
}
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
]
|
33 |
+
}
|
timber-starter-theme/composer.lock
ADDED
@@ -0,0 +1,288 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_readme": [
|
3 |
+
"This file locks the dependencies of your project to a known state",
|
4 |
+
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
5 |
+
"This file is @generated automatically"
|
6 |
+
],
|
7 |
+
"hash": "1af701633a1ce830ac7dcdad25ae49d6",
|
8 |
+
"packages": [],
|
9 |
+
"packages-dev": [
|
10 |
+
{
|
11 |
+
"name": "asm89/twig-cache-extension",
|
12 |
+
"version": "dev-master",
|
13 |
+
"source": {
|
14 |
+
"type": "git",
|
15 |
+
"url": "https://github.com/asm89/twig-cache-extension.git",
|
16 |
+
"reference": "1a13fe102241a1b22d2e72a19f31212f328b57a7"
|
17 |
+
},
|
18 |
+
"dist": {
|
19 |
+
"type": "zip",
|
20 |
+
"url": "https://api.github.com/repos/asm89/twig-cache-extension/zipball/1a13fe102241a1b22d2e72a19f31212f328b57a7",
|
21 |
+
"reference": "1a13fe102241a1b22d2e72a19f31212f328b57a7",
|
22 |
+
"shasum": ""
|
23 |
+
},
|
24 |
+
"require": {
|
25 |
+
"php": ">=5.3.2",
|
26 |
+
"twig/twig": "~1.0"
|
27 |
+
},
|
28 |
+
"require-dev": {
|
29 |
+
"doctrine/cache": "~1.0"
|
30 |
+
},
|
31 |
+
"type": "library",
|
32 |
+
"extra": {
|
33 |
+
"branch-alias": {
|
34 |
+
"dev-master": "1.0-dev"
|
35 |
+
}
|
36 |
+
},
|
37 |
+
"autoload": {
|
38 |
+
"psr-4": {
|
39 |
+
"": "lib/"
|
40 |
+
}
|
41 |
+
},
|
42 |
+
"notification-url": "https://packagist.org/downloads/",
|
43 |
+
"license": [
|
44 |
+
"MIT"
|
45 |
+
],
|
46 |
+
"authors": [
|
47 |
+
{
|
48 |
+
"name": "Alexander",
|
49 |
+
"email": "iam.asm89@gmail.com"
|
50 |
+
}
|
51 |
+
],
|
52 |
+
"description": "Cache fragments of templates directly within Twig.",
|
53 |
+
"homepage": "https://github.com/asm89/twig-cache-extension",
|
54 |
+
"keywords": [
|
55 |
+
"cache",
|
56 |
+
"extension",
|
57 |
+
"twig"
|
58 |
+
],
|
59 |
+
"time": "2014-07-28 07:30:56"
|
60 |
+
},
|
61 |
+
{
|
62 |
+
"name": "composer/installers",
|
63 |
+
"version": "dev-master",
|
64 |
+
"source": {
|
65 |
+
"type": "git",
|
66 |
+
"url": "https://github.com/composer/installers.git",
|
67 |
+
"reference": "d64e23fce42a4063d63262b19b8e7c0f3b5e4c45"
|
68 |
+
},
|
69 |
+
"dist": {
|
70 |
+
"type": "zip",
|
71 |
+
"url": "https://api.github.com/repos/composer/installers/zipball/d64e23fce42a4063d63262b19b8e7c0f3b5e4c45",
|
72 |
+
"reference": "d64e23fce42a4063d63262b19b8e7c0f3b5e4c45",
|
73 |
+
"shasum": ""
|
74 |
+
},
|
75 |
+
"replace": {
|
76 |
+
"roundcube/plugin-installer": "*",
|
77 |
+
"shama/baton": "*"
|
78 |
+
},
|
79 |
+
"require-dev": {
|
80 |
+
"composer/composer": "1.0.*@dev",
|
81 |
+
"phpunit/phpunit": "4.1.*"
|
82 |
+
},
|
83 |
+
"type": "composer-installer",
|
84 |
+
"extra": {
|
85 |
+
"class": "Composer\\Installers\\Installer",
|
86 |
+
"branch-alias": {
|
87 |
+
"dev-master": "1.0-dev"
|
88 |
+
}
|
89 |
+
},
|
90 |
+
"autoload": {
|
91 |
+
"psr-0": {
|
92 |
+
"Composer\\Installers\\": "src/"
|
93 |
+
}
|
94 |
+
},
|
95 |
+
"notification-url": "https://packagist.org/downloads/",
|
96 |
+
"license": [
|
97 |
+
"MIT"
|
98 |
+
],
|
99 |
+
"authors": [
|
100 |
+
{
|
101 |
+
"name": "Kyle Robinson Young",
|
102 |
+
"email": "kyle@dontkry.com",
|
103 |
+
"homepage": "https://github.com/shama"
|
104 |
+
}
|
105 |
+
],
|
106 |
+
"description": "A multi-framework Composer library installer",
|
107 |
+
"homepage": "http://composer.github.com/installers/",
|
108 |
+
"keywords": [
|
109 |
+
"Craft",
|
110 |
+
"Dolibarr",
|
111 |
+
"Hurad",
|
112 |
+
"MODX Evo",
|
113 |
+
"OXID",
|
114 |
+
"SMF",
|
115 |
+
"Thelia",
|
116 |
+
"WolfCMS",
|
117 |
+
"agl",
|
118 |
+
"aimeos",
|
119 |
+
"annotatecms",
|
120 |
+
"bitrix",
|
121 |
+
"cakephp",
|
122 |
+
"chef",
|
123 |
+
"codeigniter",
|
124 |
+
"concrete5",
|
125 |
+
"croogo",
|
126 |
+
"dokuwiki",
|
127 |
+
"drupal",
|
128 |
+
"elgg",
|
129 |
+
"fuelphp",
|
130 |
+
"grav",
|
131 |
+
"installer",
|
132 |
+
"joomla",
|
133 |
+
"kohana",
|
134 |
+
"laravel",
|
135 |
+
"lithium",
|
136 |
+
"magento",
|
137 |
+
"mako",
|
138 |
+
"mediawiki",
|
139 |
+
"modulework",
|
140 |
+
"moodle",
|
141 |
+
"phpbb",
|
142 |
+
"piwik",
|
143 |
+
"ppi",
|
144 |
+
"puppet",
|
145 |
+
"roundcube",
|
146 |
+
"shopware",
|
147 |
+
"silverstripe",
|
148 |
+
"symfony",
|
149 |
+
"typo3",
|
150 |
+
"wordpress",
|
151 |
+
"zend",
|
152 |
+
"zikula"
|
153 |
+
],
|
154 |
+
"time": "2015-02-18 17:17:01"
|
155 |
+
},
|
156 |
+
{
|
157 |
+
"name": "jarednova/php-router",
|
158 |
+
"version": "1.0.1",
|
159 |
+
"dist": {
|
160 |
+
"type": "zip",
|
161 |
+
"url": "https://github.com/jarednova/PHP-Router/archive/fix_psr_0.zip",
|
162 |
+
"reference": null,
|
163 |
+
"shasum": null
|
164 |
+
},
|
165 |
+
"type": "library",
|
166 |
+
"autoload": {
|
167 |
+
"psr-0": {
|
168 |
+
"PHPRouter": "src/"
|
169 |
+
}
|
170 |
+
}
|
171 |
+
},
|
172 |
+
{
|
173 |
+
"name": "jarednova/timber",
|
174 |
+
"version": "dev-master",
|
175 |
+
"source": {
|
176 |
+
"type": "git",
|
177 |
+
"url": "https://github.com/jarednova/timber.git",
|
178 |
+
"reference": "c34e79f073b6b905f6fcaa9479977fc60ba5f17c"
|
179 |
+
},
|
180 |
+
"dist": {
|
181 |
+
"type": "zip",
|
182 |
+
"url": "https://api.github.com/repos/jarednova/timber/zipball/c34e79f073b6b905f6fcaa9479977fc60ba5f17c",
|
183 |
+
"reference": "c34e79f073b6b905f6fcaa9479977fc60ba5f17c",
|
184 |
+
"shasum": ""
|
185 |
+
},
|
186 |
+
"require": {
|
187 |
+
"asm89/twig-cache-extension": "~1.0",
|
188 |
+
"composer/installers": "~1.0",
|
189 |
+
"jarednova/php-router": "1.0.1",
|
190 |
+
"php": ">=5.3.0",
|
191 |
+
"twig/twig": "~1.15"
|
192 |
+
},
|
193 |
+
"require-dev": {
|
194 |
+
"advancedcustomfields/acf5-beta": "5.0",
|
195 |
+
"phpunit/phpunit": "~4.0",
|
196 |
+
"satooshi/php-coveralls": "dev-master",
|
197 |
+
"wp-cli/wp-cli": "*"
|
198 |
+
},
|
199 |
+
"type": "wordpress-plugin",
|
200 |
+
"notification-url": "https://packagist.org/downloads/",
|
201 |
+
"license": [
|
202 |
+
"MIT"
|
203 |
+
],
|
204 |
+
"authors": [
|
205 |
+
{
|
206 |
+
"name": "Jared Novack",
|
207 |
+
"email": "jared@upstatement.com",
|
208 |
+
"homepage": "http://upstatement.com"
|
209 |
+
}
|
210 |
+
],
|
211 |
+
"description": "Plugin to write WordPress themes w Object-Oriented Code and the Twig Template Engine",
|
212 |
+
"homepage": "http://timber.upstatement.com",
|
213 |
+
"keywords": [
|
214 |
+
"templating",
|
215 |
+
"themes",
|
216 |
+
"timber",
|
217 |
+
"twig"
|
218 |
+
],
|
219 |
+
"time": "2015-02-21 21:36:29"
|
220 |
+
},
|
221 |
+
{
|
222 |
+
"name": "twig/twig",
|
223 |
+
"version": "dev-master",
|
224 |
+
"source": {
|
225 |
+
"type": "git",
|
226 |
+
"url": "https://github.com/twigphp/Twig.git",
|
227 |
+
"reference": "19f8d073aaf7cadf6218d88c9f651657cfda9211"
|
228 |
+
},
|
229 |
+
"dist": {
|
230 |
+
"type": "zip",
|
231 |
+
"url": "https://api.github.com/repos/twigphp/Twig/zipball/19f8d073aaf7cadf6218d88c9f651657cfda9211",
|
232 |
+
"reference": "19f8d073aaf7cadf6218d88c9f651657cfda9211",
|
233 |
+
"shasum": ""
|
234 |
+
},
|
235 |
+
"require": {
|
236 |
+
"php": ">=5.2.7"
|
237 |
+
},
|
238 |
+
"type": "library",
|
239 |
+
"extra": {
|
240 |
+
"branch-alias": {
|
241 |
+
"dev-master": "1.18-dev"
|
242 |
+
}
|
243 |
+
},
|
244 |
+
"autoload": {
|
245 |
+
"psr-0": {
|
246 |
+
"Twig_": "lib/"
|
247 |
+
}
|
248 |
+
},
|
249 |
+
"notification-url": "https://packagist.org/downloads/",
|
250 |
+
"license": [
|
251 |
+
"BSD-3-Clause"
|
252 |
+
],
|
253 |
+
"authors": [
|
254 |
+
{
|
255 |
+
"name": "Fabien Potencier",
|
256 |
+
"email": "fabien@symfony.com",
|
257 |
+
"homepage": "http://fabien.potencier.org",
|
258 |
+
"role": "Lead Developer"
|
259 |
+
},
|
260 |
+
{
|
261 |
+
"name": "Armin Ronacher",
|
262 |
+
"email": "armin.ronacher@active-4.com",
|
263 |
+
"role": "Project Founder"
|
264 |
+
},
|
265 |
+
{
|
266 |
+
"name": "Twig Team",
|
267 |
+
"homepage": "http://twig.sensiolabs.org/contributors",
|
268 |
+
"role": "Contributors"
|
269 |
+
}
|
270 |
+
],
|
271 |
+
"description": "Twig, the flexible, fast, and secure template language for PHP",
|
272 |
+
"homepage": "http://twig.sensiolabs.org",
|
273 |
+
"keywords": [
|
274 |
+
"templating"
|
275 |
+
],
|
276 |
+
"time": "2015-02-27 16:10:10"
|
277 |
+
}
|
278 |
+
],
|
279 |
+
"aliases": [],
|
280 |
+
"minimum-stability": "dev",
|
281 |
+
"stability-flags": {
|
282 |
+
"jarednova/timber": 20
|
283 |
+
},
|
284 |
+
"prefer-stable": false,
|
285 |
+
"prefer-lowest": false,
|
286 |
+
"platform": [],
|
287 |
+
"platform-dev": []
|
288 |
+
}
|
timber-starter-theme/phpunit.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<phpunit
|
2 |
+
bootstrap="tests/bootstrap.php"
|
3 |
+
backupGlobals="false"
|
4 |
+
colors="true"
|
5 |
+
convertErrorsToExceptions="true"
|
6 |
+
convertNoticesToExceptions="true"
|
7 |
+
convertWarningsToExceptions="true"
|
8 |
+
>
|
9 |
+
<testsuites>
|
10 |
+
<testsuite>
|
11 |
+
<directory prefix="test-" suffix=".php">./tests/</directory>
|
12 |
+
</testsuite>
|
13 |
+
<!-- The suite below HAS to be last to run,
|
14 |
+
as it includes a test that sets some const and would contaminate
|
15 |
+
the other tests as well. -->
|
16 |
+
<testsuite>
|
17 |
+
<directory prefix="testX-" suffix=".php">./tests/</directory>
|
18 |
+
</testsuite>
|
19 |
+
</testsuites>
|
20 |
+
</phpunit>
|
timber-starter-theme/tests/bootstrap.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if ( file_exists($composer_autoload = __DIR__ . '/../vendor/autoload.php') ) {
|
4 |
+
require_once($composer_autoload);
|
5 |
+
}
|
6 |
+
|
7 |
+
|
8 |
+
$_tests_dir = getenv('WP_TESTS_DIR');
|
9 |
+
if ( !$_tests_dir ) $_tests_dir = '/tmp/wordpress-tests-lib';
|
10 |
+
|
11 |
+
require_once $_tests_dir . '/includes/functions.php';
|
12 |
+
|
13 |
+
function _manually_load_plugin() {
|
14 |
+
require dirname( __FILE__ ) . '/../wp-content/plugins/timber/timber.php';
|
15 |
+
}
|
16 |
+
|
17 |
+
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
|
18 |
+
require $_tests_dir . '/includes/bootstrap.php';
|
timber-starter-theme/tests/test-timber-starter-theme.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class TestTimberStarterTheme extends WP_UnitTestCase {
|
4 |
+
|
5 |
+
function testFunctionsPHP(){
|
6 |
+
self::_setupStarterTheme();
|
7 |
+
require_once(get_template_directory().'/functions.php');
|
8 |
+
$context = Timber::get_context();
|
9 |
+
$this->assertEquals('StarterSite', get_class($context['site']));
|
10 |
+
$this->assertTrue(current_theme_supports('post-thumbnails'));
|
11 |
+
$this->assertEquals('bar', $context['foo']);
|
12 |
+
switch_theme('twentythirteen');
|
13 |
+
}
|
14 |
+
|
15 |
+
static function _setupStarterTheme(){
|
16 |
+
$dest = WP_CONTENT_DIR.'/themes/timber-starter-theme/';
|
17 |
+
$src = __DIR__.'/../../timber-starter-theme/';
|
18 |
+
if (is_dir($src)) {
|
19 |
+
echo 'its a directory';
|
20 |
+
return;
|
21 |
+
self::_copyDirectory($src, $dest);
|
22 |
+
switch_theme('timber-starter-theme');
|
23 |
+
} else {
|
24 |
+
echo 'no its not';
|
25 |
+
}
|
26 |
+
}
|
27 |
+
|
28 |
+
static function _copyDirectory($src, $dst){
|
29 |
+
$dir = opendir($src);
|
30 |
+
@mkdir($dst);
|
31 |
+
while(false !== ( $file = readdir($dir)) ) {
|
32 |
+
if (( $file != '.' ) && ( $file != '..' )) {
|
33 |
+
if ( is_dir($src . '/' . $file) ) {
|
34 |
+
self::_copyDirectory($src . '/' . $file,$dst . '/' . $file);
|
35 |
+
}
|
36 |
+
else {
|
37 |
+
copy($src . '/' . $file,$dst . '/' . $file);
|
38 |
+
}
|
39 |
+
}
|
40 |
+
}
|
41 |
+
closedir($dir);
|
42 |
+
}
|
43 |
+
|
44 |
+
}
|
timber.php
CHANGED
@@ -4,7 +4,7 @@ Plugin Name: Timber
|
|
4 |
Plugin URI: http://timber.upstatement.com
|
5 |
Description: The WordPress Timber Library allows you to write themes using the power Twig templates
|
6 |
Author: Jared Novack + Upstatement
|
7 |
-
Version: 0.
|
8 |
Author URI: http://upstatement.com/
|
9 |
*/
|
10 |
|
@@ -13,41 +13,13 @@ global $timber;
|
|
13 |
|
14 |
// we look for Composer files first in the theme (theme install)
|
15 |
// then in the wp-content dir (site install)
|
16 |
-
if ( file_exists($composer_autoload = __DIR__ . '/vendor/autoload.php')
|
17 |
-
|
18 |
-
|
19 |
}
|
20 |
|
21 |
-
|
22 |
-
|
23 |
-
require_once(__DIR__ . '/lib/timber-url-helper.php');
|
24 |
-
require_once(__DIR__ . '/lib/timber-image-helper.php');
|
25 |
-
|
26 |
-
require_once(__DIR__ . '/lib/timber-core-interface.php');
|
27 |
-
require_once(__DIR__ . '/lib/timber-core.php');
|
28 |
-
require_once(__DIR__ . '/lib/timber-post.php');
|
29 |
-
require_once(__DIR__ . '/lib/timber-post-getter.php');
|
30 |
-
require_once(__DIR__ . '/lib/timber-comment.php');
|
31 |
-
require_once(__DIR__ . '/lib/timber-user.php');
|
32 |
-
require_once(__DIR__ . '/lib/timber-term.php');
|
33 |
-
require_once(__DIR__ . '/lib/timber-term-getter.php');
|
34 |
-
require_once(__DIR__ . '/lib/timber-image.php');
|
35 |
-
require_once(__DIR__ . '/lib/timber-menu-item.php');
|
36 |
-
require_once(__DIR__ . '/lib/timber-menu.php');
|
37 |
-
require_once(__DIR__ . '/lib/timber-query-iterator.php');
|
38 |
-
require_once(__DIR__ . '/lib/timber-posts-collection.php');
|
39 |
-
|
40 |
-
//Other 2nd-class citizens
|
41 |
-
require_once(__DIR__ . '/lib/timber-archives.php');
|
42 |
-
require_once(__DIR__ . '/lib/timber-routes.php');
|
43 |
-
require_once(__DIR__ . '/lib/timber-site.php');
|
44 |
-
require_once(__DIR__ . '/lib/timber-theme.php');
|
45 |
-
require_once(__DIR__ . '/lib/timber-loader.php');
|
46 |
-
require_once(__DIR__ . '/lib/timber-function-wrapper.php');
|
47 |
-
require_once(__DIR__ . '/lib/integrations/acf-timber.php');
|
48 |
-
require_once(__DIR__ . '/lib/integrations/wpcli-timber.php');
|
49 |
-
|
50 |
-
require_once(__DIR__ . '/lib/timber-admin.php');
|
51 |
|
52 |
/** Usage:
|
53 |
*
|
@@ -61,507 +33,506 @@ require_once(__DIR__ . '/lib/timber-admin.php');
|
|
61 |
* Timber::render('index.twig', $context);
|
62 |
*/
|
63 |
|
64 |
-
|
65 |
-
|
66 |
class Timber {
|
67 |
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
76 |
-
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
82 |
-
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
143 |
-
|
144 |
-
|
145 |
-
|
146 |
-
|
147 |
-
|
148 |
-
|
149 |
-
|
150 |
-
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
|
155 |
-
|
156 |
-
|
157 |
-
|
158 |
-
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
177 |
-
|
178 |
-
|
179 |
-
|
180 |
-
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
|
185 |
-
|
186 |
-
|
187 |
-
|
188 |
-
|
189 |
-
|
190 |
-
|
191 |
-
|
192 |
-
|
193 |
-
|
194 |
-
|
195 |
-
|
196 |
-
|
197 |
-
|
198 |
-
|
199 |
-
|
200 |
-
|
201 |
-
|
202 |
-
|
203 |
-
|
204 |
-
|
205 |
-
|
206 |
-
|
207 |
-
|
208 |
-
|
209 |
-
|
210 |
-
|
211 |
-
|
212 |
-
|
213 |
-
|
214 |
-
|
215 |
-
|
216 |
-
|
217 |
-
|
218 |
-
|
219 |
-
|
220 |
-
|
221 |
-
|
222 |
-
|
223 |
-
|
224 |
-
|
225 |
-
|
226 |
-
|
227 |
-
|
228 |
-
|
229 |
-
|
230 |
-
|
231 |
-
|
232 |
-
|
233 |
-
|
234 |
-
|
235 |
-
|
236 |
-
|
237 |
-
|
238 |
-
|
239 |
-
|
240 |
-
|
241 |
-
|
242 |
-
|
243 |
-
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
-
|
250 |
-
|
251 |
-
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
257 |
-
|
258 |
-
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
275 |
-
|
276 |
-
|
277 |
-
|
278 |
-
|
279 |
-
|
280 |
-
|
281 |
-
|
282 |
-
|
283 |
-
|
284 |
-
|
285 |
-
|
286 |
-
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
293 |
-
|
294 |
-
|
295 |
-
|
296 |
-
|
297 |
-
|
298 |
-
|
299 |
-
|
300 |
-
|
301 |
-
|
302 |
-
|
303 |
-
|
304 |
-
|
305 |
-
|
306 |
-
|
307 |
-
|
308 |
-
|
309 |
-
|
310 |
-
|
311 |
-
|
312 |
-
|
313 |
-
|
314 |
-
|
315 |
-
|
316 |
-
|
317 |
-
|
318 |
-
|
319 |
-
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
-
|
327 |
-
|
328 |
-
|
329 |
-
|
330 |
-
|
331 |
-
|
332 |
-
|
333 |
-
|
334 |
-
|
335 |
-
|
336 |
-
|
337 |
-
|
338 |
-
|
339 |
-
|
340 |
-
|
341 |
-
|
342 |
-
|
343 |
-
|
344 |
-
|
345 |
-
|
346 |
-
|
347 |
-
|
348 |
-
|
349 |
-
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
|
397 |
-
|
398 |
-
|
399 |
-
|
400 |
-
|
401 |
-
|
402 |
-
|
403 |
-
|
404 |
-
|
405 |
-
|
406 |
-
|
407 |
-
|
408 |
-
|
409 |
-
|
410 |
-
|
411 |
-
|
412 |
-
|
413 |
-
|
414 |
-
|
415 |
-
|
416 |
-
|
417 |
-
|
418 |
-
|
419 |
-
|
420 |
-
|
421 |
-
|
422 |
-
|
423 |
-
|
424 |
-
|
425 |
-
|
426 |
-
|
427 |
-
|
428 |
-
|
429 |
-
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
438 |
-
|
439 |
-
|
440 |
-
|
441 |
-
|
442 |
-
|
443 |
-
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
-
|
455 |
-
|
456 |
-
|
457 |
-
|
458 |
-
|
459 |
-
|
460 |
-
|
461 |
-
|
462 |
-
|
463 |
-
|
464 |
-
|
465 |
-
|
466 |
-
|
467 |
-
|
468 |
-
|
469 |
-
|
470 |
-
|
471 |
-
|
472 |
-
|
473 |
-
|
474 |
-
|
475 |
-
|
476 |
-
|
477 |
-
|
478 |
-
|
479 |
-
|
480 |
-
|
481 |
-
|
482 |
-
|
483 |
-
|
484 |
-
|
485 |
-
|
486 |
-
|
487 |
-
|
488 |
-
|
489 |
-
|
490 |
-
|
491 |
-
|
492 |
-
|
493 |
-
|
494 |
-
|
495 |
-
|
496 |
-
|
497 |
-
|
498 |
-
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
512 |
-
|
513 |
-
|
514 |
-
|
515 |
-
|
516 |
-
|
517 |
-
|
518 |
-
|
519 |
-
|
520 |
-
|
521 |
-
|
522 |
-
|
523 |
-
|
524 |
-
|
525 |
-
|
526 |
-
|
527 |
-
|
528 |
-
|
529 |
-
|
530 |
-
|
531 |
-
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
|
550 |
-
|
551 |
-
|
552 |
-
|
553 |
-
|
554 |
-
|
555 |
-
|
556 |
-
|
557 |
-
|
558 |
-
|
559 |
-
|
560 |
-
|
561 |
-
|
|
|
|
|
|
|
|
|
|
|
562 |
|
563 |
}
|
564 |
-
|
565 |
-
$timber = new Timber();
|
566 |
-
$GLOBALS['timber'] = $timber;
|
567 |
-
Timber::$dirname = 'views';
|
4 |
Plugin URI: http://timber.upstatement.com
|
5 |
Description: The WordPress Timber Library allows you to write themes using the power Twig templates
|
6 |
Author: Jared Novack + Upstatement
|
7 |
+
Version: 0.21.1
|
8 |
Author URI: http://upstatement.com/
|
9 |
*/
|
10 |
|
13 |
|
14 |
// we look for Composer files first in the theme (theme install)
|
15 |
// then in the wp-content dir (site install)
|
16 |
+
if ( file_exists( $composer_autoload = __DIR__ . '/vendor/autoload.php' )
|
17 |
+
|| file_exists( $composer_autoload = WP_CONTENT_DIR.'/vendor/autoload.php' ) ) {
|
18 |
+
require_once $composer_autoload;
|
19 |
}
|
20 |
|
21 |
+
$timber = new Timber();
|
22 |
+
Timber::$dirname = 'views';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
24 |
/** Usage:
|
25 |
*
|
33 |
* Timber::render('index.twig', $context);
|
34 |
*/
|
35 |
|
|
|
|
|
36 |
class Timber {
|
37 |
|
38 |
+
public static $locations;
|
39 |
+
public static $dirname;
|
40 |
+
public static $twig_cache = false;
|
41 |
+
public static $cache = false;
|
42 |
+
public static $auto_meta = true;
|
43 |
+
public static $autoescape = false;
|
44 |
+
|
45 |
+
public function __construct() {
|
46 |
+
$this->test_compatibility();
|
47 |
+
$this->init_constants();
|
48 |
+
$this->init();
|
49 |
+
}
|
50 |
+
|
51 |
+
protected function test_compatibility() {
|
52 |
+
if ( is_admin() || $_SERVER['PHP_SELF'] == '/wp-login.php' ) {
|
53 |
+
return;
|
54 |
+
}
|
55 |
+
if ( version_compare( phpversion(), '5.3.0', '<' ) && !is_admin() ) {
|
56 |
+
trigger_error( 'Timber requires PHP 5.3.0 or greater. You have '.phpversion(), E_USER_ERROR );
|
57 |
+
}
|
58 |
+
if ( !class_exists( 'Twig_Autoloader' ) ) {
|
59 |
+
trigger_error( 'You have not run "composer install" to download required dependencies for Timber, you can read more on https://github.com/jarednova/timber#installation', E_USER_ERROR );
|
60 |
+
}
|
61 |
+
}
|
62 |
+
|
63 |
+
function init_constants() {
|
64 |
+
defined( "TIMBER_LOC" ) or define( "TIMBER_LOC", realpath( __DIR__ ) );
|
65 |
+
}
|
66 |
+
|
67 |
+
protected function init() {
|
68 |
+
TimberTwig::init();
|
69 |
+
TimberRoutes::init( $this );
|
70 |
+
|
71 |
+
TimberImageHelper::init();
|
72 |
+
TimberAdmin::init();
|
73 |
+
TimberIntegrations::init();
|
74 |
+
}
|
75 |
+
|
76 |
+
/* Post Retrieval
|
77 |
+
================================ */
|
78 |
+
|
79 |
+
/**
|
80 |
+
* @param mixed $query
|
81 |
+
* @param string $PostClass
|
82 |
+
* @return array|bool|null
|
83 |
+
*/
|
84 |
+
public static function get_post( $query = false, $PostClass = 'TimberPost' ) {
|
85 |
+
return TimberPostGetter::get_post( $query, $PostClass );
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* @param mixed $query
|
90 |
+
* @param string $PostClass
|
91 |
+
* @return array|bool|null
|
92 |
+
*/
|
93 |
+
public static function get_posts( $query = false, $PostClass = 'TimberPost', $return_collection = false ) {
|
94 |
+
return TimberPostGetter::get_posts( $query, $PostClass, $return_collection );
|
95 |
+
}
|
96 |
+
|
97 |
+
/**
|
98 |
+
* @param mixed $query
|
99 |
+
* @param string $PostClass
|
100 |
+
* @return array|bool|null
|
101 |
+
*/
|
102 |
+
public static function query_post( $query = false, $PostClass = 'TimberPost' ) {
|
103 |
+
return TimberPostGetter::query_post( $query, $PostClass );
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* @param mixed $query
|
108 |
+
* @param string $PostClass
|
109 |
+
* @return array|bool|null
|
110 |
+
*/
|
111 |
+
public static function query_posts( $query = false, $PostClass = 'TimberPost' ) {
|
112 |
+
return TimberPostGetter::query_posts( $query, $PostClass );
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* @param array|string $query
|
117 |
+
* @return array
|
118 |
+
* @deprecated since 0.20.0
|
119 |
+
*/
|
120 |
+
static function get_pids( $query = null ) {
|
121 |
+
return TimberPostGetter::get_pids( $query );
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* @param string $PostClass
|
126 |
+
* @return array
|
127 |
+
* @deprecated since 0.20.0
|
128 |
+
*/
|
129 |
+
static function get_posts_from_loop( $PostClass ) {
|
130 |
+
return TimberPostGetter::get_posts( $PostClass );
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* @param string $slug
|
135 |
+
* @param string $PostClass
|
136 |
+
* @return array
|
137 |
+
* @deprecated since 0.20.0
|
138 |
+
*/
|
139 |
+
static function get_posts_from_slug( $slug, $PostClass = 'TimberPost' ) {
|
140 |
+
return TimberPostGetter::get_posts( $slug, $PostClass );
|
141 |
+
}
|
142 |
+
|
143 |
+
/**
|
144 |
+
* @param array $query
|
145 |
+
* @param string $PostClass
|
146 |
+
* @return array
|
147 |
+
* @deprecated since 0.20.0
|
148 |
+
*/
|
149 |
+
static function get_posts_from_wp_query( $query = array(), $PostClass = 'TimberPost' ) {
|
150 |
+
return TimberPostGetter::query_posts( $query, $PostClass );
|
151 |
+
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* @param array $query
|
155 |
+
* @param string $PostClass
|
156 |
+
* @return array|null
|
157 |
+
* @deprecated since 0.20.0
|
158 |
+
*/
|
159 |
+
static function get_posts_from_array_of_ids( $query = array(), $PostClass = 'TimberPost' ) {
|
160 |
+
return TimberPostGetter::get_posts( $query, $PostClass );
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* @param array $results
|
165 |
+
* @param string $PostClass
|
166 |
+
* @return TimberPostsCollection
|
167 |
+
* @deprecated since 0.20.0
|
168 |
+
*/
|
169 |
+
static function handle_post_results( $results, $PostClass = 'TimberPost' ) {
|
170 |
+
return TimberPostGetter::handle_post_results( $results, $PostClass );
|
171 |
+
}
|
172 |
+
|
173 |
+
/**
|
174 |
+
* @param unknown $query
|
175 |
+
* @return int
|
176 |
+
* @deprecated since 0.20.0
|
177 |
+
*/
|
178 |
+
static function get_pid( $query ) {
|
179 |
+
$pids = TimberPostGetter::get_pids( $query );
|
180 |
+
if ( is_array( $pids ) && count( $pids ) ) {
|
181 |
+
return $pids[0];
|
182 |
+
}
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* @return bool
|
187 |
+
* @deprecated since 0.20.0
|
188 |
+
*/
|
189 |
+
static function wp_query_has_posts() {
|
190 |
+
return TimberPostGetter::wp_query_has_posts();
|
191 |
+
}
|
192 |
+
|
193 |
+
/* Term Retrieval
|
194 |
+
================================ */
|
195 |
+
|
196 |
+
/**
|
197 |
+
* @param string|array $args
|
198 |
+
* @param array $maybe_args
|
199 |
+
* @param string $TermClass
|
200 |
+
* @return mixed
|
201 |
+
*/
|
202 |
+
public static function get_terms( $args = null, $maybe_args = array(), $TermClass = 'TimberTerm' ) {
|
203 |
+
return TimberTermGetter::get_terms( $args, $maybe_args, $TermClass );
|
204 |
+
}
|
205 |
+
|
206 |
+
/* Site Retrieval
|
207 |
+
================================ */
|
208 |
+
|
209 |
+
/**
|
210 |
+
* @param array|bool $blog_ids
|
211 |
+
* @return array
|
212 |
+
*/
|
213 |
+
public static function get_sites( $blog_ids = false ) {
|
214 |
+
if ( !is_array( $blog_ids ) ) {
|
215 |
+
global $wpdb;
|
216 |
+
$blog_ids = $wpdb->get_col( "SELECT blog_id FROM $wpdb->blogs" );
|
217 |
+
}
|
218 |
+
$return = array();
|
219 |
+
foreach ( $blog_ids as $blog_id ) {
|
220 |
+
$return[] = new TimberSite( $blog_id );
|
221 |
+
}
|
222 |
+
return $return;
|
223 |
+
}
|
224 |
+
|
225 |
+
|
226 |
+
/* Template Setup and Display
|
227 |
+
================================ */
|
228 |
+
|
229 |
+
/**
|
230 |
+
* @return array
|
231 |
+
*/
|
232 |
+
public static function get_context() {
|
233 |
+
$data = array();
|
234 |
+
$data['http_host'] = 'http://' . $_SERVER['HTTP_HOST'];
|
235 |
+
$data['wp_title'] = TimberHelper::get_wp_title();
|
236 |
+
$data['wp_head'] = TimberHelper::function_wrapper( 'wp_head' );
|
237 |
+
$data['wp_footer'] = TimberHelper::function_wrapper( 'wp_footer' );
|
238 |
+
$data['body_class'] = implode( ' ', get_body_class() );
|
239 |
+
|
240 |
+
$data['site'] = new TimberSite();
|
241 |
+
$data['theme'] = $data['site']->theme;
|
242 |
+
//deprecated, these should be fetched via TimberSite or TimberTheme
|
243 |
+
$data['theme_dir'] = WP_CONTENT_SUBDIR.str_replace( WP_CONTENT_DIR, '', get_stylesheet_directory() );
|
244 |
+
$data['language_attributes'] = TimberHelper::function_wrapper( 'language_attributes' );
|
245 |
+
$data['stylesheet_uri'] = get_stylesheet_uri();
|
246 |
+
$data['template_uri'] = get_template_directory_uri();
|
247 |
+
|
248 |
+
$data['posts'] = Timber::query_posts();
|
249 |
+
|
250 |
+
//deprecated, this should be fetched via TimberMenu
|
251 |
+
if ( function_exists( 'wp_nav_menu' ) ) {
|
252 |
+
$locations = get_nav_menu_locations();
|
253 |
+
if ( count( $locations ) ) {
|
254 |
+
$data['wp_nav_menu'] = wp_nav_menu( array( 'container_class' => 'menu-header', 'echo' => false, 'menu_class' => 'nav-menu' ) );
|
255 |
+
}
|
256 |
+
}
|
257 |
+
$data = apply_filters( 'timber_context', $data );
|
258 |
+
return $data;
|
259 |
+
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* @param array $filenames
|
263 |
+
* @param array $data
|
264 |
+
* @param bool $expires
|
265 |
+
* @param string $cache_mode
|
266 |
+
* @param bool $via_render
|
267 |
+
* @return bool|string
|
268 |
+
*/
|
269 |
+
public static function compile( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT, $via_render = false ) {
|
270 |
+
$caller = self::get_calling_script_dir();
|
271 |
+
$caller_file = self::get_calling_script_file();
|
272 |
+
$caller_file = apply_filters( 'timber_calling_php_file', $caller_file );
|
273 |
+
$loader = new TimberLoader( $caller );
|
274 |
+
$file = $loader->choose_template( $filenames );
|
275 |
+
$output = '';
|
276 |
+
if ( is_null( $data ) ) {
|
277 |
+
$data = array();
|
278 |
+
}
|
279 |
+
if ( strlen( $file ) ) {
|
280 |
+
if ( $via_render ) {
|
281 |
+
$file = apply_filters( 'timber_render_file', $file );
|
282 |
+
$data = apply_filters( 'timber_render_data', $data );
|
283 |
+
} else {
|
284 |
+
$file = apply_filters( 'timber_compile_file', $file );
|
285 |
+
$data = apply_filters( 'timber_compile_data', $data );
|
286 |
+
}
|
287 |
+
$output = $loader->render( $file, $data, $expires, $cache_mode );
|
288 |
+
}
|
289 |
+
do_action( 'timber_compile_done' );
|
290 |
+
return $output;
|
291 |
+
}
|
292 |
+
|
293 |
+
/**
|
294 |
+
* @param string $string a string with twig variables
|
295 |
+
* @param array $data an array with data in it
|
296 |
+
* @return bool|string
|
297 |
+
*/
|
298 |
+
public static function compile_string( $string, $data = array() ) {
|
299 |
+
$dummy_loader = new TimberLoader();
|
300 |
+
$dummy_loader->get_twig();
|
301 |
+
$loader = new Twig_Loader_String();
|
302 |
+
$twig = new Twig_Environment( $loader );
|
303 |
+
$twig = apply_filters( 'twig_apply_filters', $twig );
|
304 |
+
return $twig->render( $string, $data );
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* @param array $filenames
|
309 |
+
* @param array $data
|
310 |
+
* @param bool $expires
|
311 |
+
* @param string $cache_mode
|
312 |
+
* @return bool|string
|
313 |
+
*/
|
314 |
+
public static function render( $filenames, $data = array(), $expires = false, $cache_mode = TimberLoader::CACHE_USE_DEFAULT ) {
|
315 |
+
if ( $expires === true ) {
|
316 |
+
//if this is reading as true; the user probably is using the old $echo param
|
317 |
+
//so we should move all vars up by a spot
|
318 |
+
$expires = $cache_mode;
|
319 |
+
$cache_mode = TimberLoader::CACHE_USE_DEFAULT;
|
320 |
+
}
|
321 |
+
$output = self::compile( $filenames, $data, $expires, $cache_mode, true );
|
322 |
+
$output = apply_filters( 'timber_compile_result', $output );
|
323 |
+
echo $output;
|
324 |
+
return $output;
|
325 |
+
}
|
326 |
+
|
327 |
+
/**
|
328 |
+
* @param string $string a string with twig variables
|
329 |
+
* @param array $data an array with data in it
|
330 |
+
* @return bool|string
|
331 |
+
*/
|
332 |
+
public static function render_string( $string, $data = array() ) {
|
333 |
+
$compiled = self::compile_string( $string, $data );
|
334 |
+
echo $compiled;
|
335 |
+
return $compiled;
|
336 |
+
}
|
337 |
+
|
338 |
+
|
339 |
+
/* Sidebar
|
340 |
+
================================ */
|
341 |
+
|
342 |
+
/**
|
343 |
+
* @param string $sidebar
|
344 |
+
* @param array $data
|
345 |
+
* @return bool|string
|
346 |
+
*/
|
347 |
+
public static function get_sidebar( $sidebar = '', $data = array() ) {
|
348 |
+
if ( $sidebar == '' ) {
|
349 |
+
$sidebar = 'sidebar.php';
|
350 |
+
}
|
351 |
+
if ( strstr( strtolower( $sidebar ), '.php' ) ) {
|
352 |
+
return self::get_sidebar_from_php( $sidebar, $data );
|
353 |
+
}
|
354 |
+
return self::compile( $sidebar, $data );
|
355 |
+
}
|
356 |
+
|
357 |
+
/**
|
358 |
+
* @param string $sidebar
|
359 |
+
* @param array $data
|
360 |
+
* @return string
|
361 |
+
*/
|
362 |
+
public static function get_sidebar_from_php( $sidebar = '', $data ) {
|
363 |
+
$caller = self::get_calling_script_dir();
|
364 |
+
$loader = new TimberLoader();
|
365 |
+
$uris = $loader->get_locations( $caller );
|
366 |
+
ob_start();
|
367 |
+
$found = false;
|
368 |
+
foreach ( $uris as $uri ) {
|
369 |
+
if ( file_exists( trailingslashit( $uri ) . $sidebar ) ) {
|
370 |
+
include trailingslashit( $uri ) . $sidebar;
|
371 |
+
$found = true;
|
372 |
+
break;
|
373 |
+
}
|
374 |
+
}
|
375 |
+
if ( !$found ) {
|
376 |
+
TimberHelper::error_log( 'error loading your sidebar, check to make sure the file exists' );
|
377 |
+
}
|
378 |
+
$ret = ob_get_contents();
|
379 |
+
ob_end_clean();
|
380 |
+
return $ret;
|
381 |
+
}
|
382 |
+
|
383 |
+
/* Widgets
|
384 |
+
================================ */
|
385 |
+
|
386 |
+
/**
|
387 |
+
* @param int $widget_id
|
388 |
+
* @return TimberFunctionWrapper
|
389 |
+
*/
|
390 |
+
public static function get_widgets( $widget_id ) {
|
391 |
+
return TimberHelper::function_wrapper( 'dynamic_sidebar', array( $widget_id ), true );
|
392 |
+
}
|
393 |
+
|
394 |
+
|
395 |
+
/* Routes
|
396 |
+
================================ */
|
397 |
+
|
398 |
+
/**
|
399 |
+
* @param string $route
|
400 |
+
* @param callable $callback
|
401 |
+
* @param array $args
|
402 |
+
* @deprecated since 0.20.0
|
403 |
+
*/
|
404 |
+
public static function add_route( $route, $callback, $args = array() ) {
|
405 |
+
Routes::map( $route, $callback, $args );
|
406 |
+
}
|
407 |
+
|
408 |
+
public function cancel_query() {
|
409 |
+
add_action( 'posts_request', array( $this, 'cancel_query_posts_request' ) );
|
410 |
+
}
|
411 |
+
|
412 |
+
function cancel_query_posts_request() {
|
413 |
+
if ( is_main_query() ) {
|
414 |
+
wp_reset_query();
|
415 |
+
}
|
416 |
+
}
|
417 |
+
|
418 |
+
/**
|
419 |
+
* @deprecated since 0.20.0
|
420 |
+
*/
|
421 |
+
public static function load_template( $template, $query = false, $status_code = 200, $tparams = false ) {
|
422 |
+
return Routes::load( $template, $tparams, $query, $status_code );
|
423 |
+
}
|
424 |
+
|
425 |
+
/**
|
426 |
+
* @deprecated since 0.20.2
|
427 |
+
*/
|
428 |
+
public static function load_view( $template, $query = false, $status_code = 200, $tparams = false ) {
|
429 |
+
return Routes::load( $template, $tparams, $query, $status_code );
|
430 |
+
}
|
431 |
+
|
432 |
+
|
433 |
+
/* Pagination
|
434 |
+
================================ */
|
435 |
+
|
436 |
+
/**
|
437 |
+
* @param array $prefs
|
438 |
+
* @return array mixed
|
439 |
+
*/
|
440 |
+
public static function get_pagination( $prefs = array() ) {
|
441 |
+
global $wp_query;
|
442 |
+
global $paged;
|
443 |
+
global $wp_rewrite;
|
444 |
+
$args['total'] = ceil( $wp_query->found_posts / $wp_query->query_vars['posts_per_page'] );
|
445 |
+
if ( $wp_rewrite->using_permalinks() ) {
|
446 |
+
$url = explode( '?', get_pagenum_link( 0 ) );
|
447 |
+
if ( isset( $url[1] ) ) {
|
448 |
+
parse_str( $url[1], $query );
|
449 |
+
$args['add_args'] = $query;
|
450 |
+
}
|
451 |
+
$args['format'] = 'page/%#%';
|
452 |
+
$args['base'] = trailingslashit( $url[0] ).'%_%';
|
453 |
+
} else {
|
454 |
+
$big = 999999999;
|
455 |
+
$args['base'] = str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) );
|
456 |
+
}
|
457 |
+
$args['type'] = 'array';
|
458 |
+
$args['current'] = max( 1, get_query_var( 'paged' ) );
|
459 |
+
$args['mid_size'] = max( 9 - $args['current'], 3 );
|
460 |
+
$args['prev_next'] = false;
|
461 |
+
if ( is_int( $prefs ) ) {
|
462 |
+
$args['mid_size'] = $prefs - 2;
|
463 |
+
} else {
|
464 |
+
$args = array_merge( $args, $prefs );
|
465 |
+
}
|
466 |
+
$data['pages'] = TimberHelper::paginate_links( $args );
|
467 |
+
$next = get_next_posts_page_link( $args['total'] );
|
468 |
+
if ( $next ) {
|
469 |
+
$data['next'] = array( 'link' => untrailingslashit( $next ), 'class' => 'page-numbers next' );
|
470 |
+
}
|
471 |
+
$prev = previous_posts( false );
|
472 |
+
if ( $prev ) {
|
473 |
+
$data['prev'] = array( 'link' => untrailingslashit( $prev ), 'class' => 'page-numbers prev' );
|
474 |
+
}
|
475 |
+
if ( $paged < 2 ) {
|
476 |
+
$data['prev'] = '';
|
477 |
+
}
|
478 |
+
return $data;
|
479 |
+
}
|
480 |
+
|
481 |
+
/* Utility
|
482 |
+
================================ */
|
483 |
+
|
484 |
+
/**
|
485 |
+
* @param int $offset
|
486 |
+
* @return string
|
487 |
+
* @deprecated since 0.20.0
|
488 |
+
*/
|
489 |
+
public static function get_calling_script_path( $offset = 0 ) {
|
490 |
+
$dir = self::get_calling_script_dir( $offset );
|
491 |
+
return str_replace( ABSPATH, '', realpath( $dir ) );
|
492 |
+
}
|
493 |
+
|
494 |
+
/**
|
495 |
+
* @return boolean|string
|
496 |
+
*/
|
497 |
+
public static function get_calling_script_dir( $offset = 0 ) {
|
498 |
+
$caller = self::get_calling_script_file( $offset );
|
499 |
+
if ( !is_null( $caller ) ) {
|
500 |
+
$pathinfo = pathinfo( $caller );
|
501 |
+
$dir = $pathinfo['dirname'];
|
502 |
+
return $dir;
|
503 |
+
}
|
504 |
+
return null;
|
505 |
+
}
|
506 |
+
|
507 |
+
/**
|
508 |
+
* @param int $offset
|
509 |
+
* @return string|null
|
510 |
+
* @deprecated since 0.20.0
|
511 |
+
*/
|
512 |
+
public static function get_calling_script_file( $offset = 0 ) {
|
513 |
+
$caller = null;
|
514 |
+
$backtrace = debug_backtrace();
|
515 |
+
$i = 0;
|
516 |
+
foreach ( $backtrace as $trace ) {
|
517 |
+
if ( $trace['file'] != __FILE__ ) {
|
518 |
+
$caller = $trace['file'];
|
519 |
+
break;
|
520 |
+
}
|
521 |
+
$i++;
|
522 |
+
}
|
523 |
+
if ( $offset ) {
|
524 |
+
$caller = $backtrace[$i + $offset]['file'];
|
525 |
+
}
|
526 |
+
return $caller;
|
527 |
+
}
|
528 |
+
|
529 |
+
/**
|
530 |
+
* @param string|array $args
|
531 |
+
* @return bool
|
532 |
+
* @deprecated since 0.20.0
|
533 |
+
*/
|
534 |
+
public static function is_post_class_or_class_map( $args ) {
|
535 |
+
return TimberPostGetter::is_post_class_or_class_map( $args );
|
536 |
+
}
|
537 |
|
538 |
}
|
|
|
|
|
|
|
|
vendor/altorouter/altorouter/.travis.yml
ADDED
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
language: php
|
2 |
+
php:
|
3 |
+
- 5.3
|
4 |
+
- 5.4
|
5 |
+
- 5.5
|
6 |
+
|
7 |
+
script: phpunit --coverage-text ./
|
vendor/altorouter/altorouter/AltoRouter.php
ADDED
@@ -0,0 +1,270 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class AltoRouter {
|
4 |
+
|
5 |
+
protected $routes = array();
|
6 |
+
protected $namedRoutes = array();
|
7 |
+
protected $basePath = '';
|
8 |
+
protected $matchTypes = array(
|
9 |
+
'i' => '[0-9]++',
|
10 |
+
'a' => '[0-9A-Za-z]++',
|
11 |
+
'h' => '[0-9A-Fa-f]++',
|
12 |
+
'*' => '.+?',
|
13 |
+
'**' => '.++',
|
14 |
+
'' => '[^/\.]++'
|
15 |
+
);
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Create router in one call from config.
|
19 |
+
*
|
20 |
+
* @param array $routes
|
21 |
+
* @param string $basePath
|
22 |
+
* @param array $matchTypes
|
23 |
+
*/
|
24 |
+
public function __construct( $routes = array(), $basePath = '', $matchTypes = array() ) {
|
25 |
+
$this->addRoutes($routes);
|
26 |
+
$this->setBasePath($basePath);
|
27 |
+
$this->addMatchTypes($matchTypes);
|
28 |
+
}
|
29 |
+
|
30 |
+
/**
|
31 |
+
* Add multiple routes at once from array in the following format:
|
32 |
+
*
|
33 |
+
* $routes = array(
|
34 |
+
* array($method, $route, $target, $name)
|
35 |
+
* );
|
36 |
+
*
|
37 |
+
* @param array $routes
|
38 |
+
* @return void
|
39 |
+
* @author Koen Punt
|
40 |
+
*/
|
41 |
+
public function addRoutes($routes){
|
42 |
+
if(!is_array($routes) && !$routes instanceof Traversable) {
|
43 |
+
throw new \Exception('Routes should be an array or an instance of Traversable');
|
44 |
+
}
|
45 |
+
foreach($routes as $route) {
|
46 |
+
call_user_func_array(array($this, 'map'), $route);
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Set the base path.
|
52 |
+
* Useful if you are running your application from a subdirectory.
|
53 |
+
*/
|
54 |
+
public function setBasePath($basePath) {
|
55 |
+
$this->basePath = $basePath;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Add named match types. It uses array_merge so keys can be overwritten.
|
60 |
+
*
|
61 |
+
* @param array $matchTypes The key is the name and the value is the regex.
|
62 |
+
*/
|
63 |
+
public function addMatchTypes($matchTypes) {
|
64 |
+
$this->matchTypes = array_merge($this->matchTypes, $matchTypes);
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Map a route to a target
|
69 |
+
*
|
70 |
+
* @param string $method One of 4 HTTP Methods, or a pipe-separated list of multiple HTTP Methods (GET|POST|PUT|DELETE)
|
71 |
+
* @param string $route The route regex, custom regex must start with an @. You can use multiple pre-set regex filters, like [i:id]
|
72 |
+
* @param mixed $target The target where this route should point to. Can be anything.
|
73 |
+
* @param string $name Optional name of this route. Supply if you want to reverse route this url in your application.
|
74 |
+
*/
|
75 |
+
public function map($method, $route, $target, $name = null) {
|
76 |
+
|
77 |
+
$this->routes[] = array($method, $route, $target, $name);
|
78 |
+
|
79 |
+
if($name) {
|
80 |
+
if(isset($this->namedRoutes[$name])) {
|
81 |
+
throw new \Exception("Can not redeclare route '{$name}'");
|
82 |
+
} else {
|
83 |
+
$this->namedRoutes[$name] = $route;
|
84 |
+
}
|
85 |
+
|
86 |
+
}
|
87 |
+
|
88 |
+
return;
|
89 |
+
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Reversed routing
|
93 |
+
*
|
94 |
+
* Generate the URL for a named route. Replace regexes with supplied parameters
|
95 |
+
*
|
96 |
+
* @param string $routeName The name of the route.
|
97 |
+
* @param array @params Associative array of parameters to replace placeholders with.
|
98 |
+
* @return string The URL of the route with named parameters in place.
|
99 |
+
*/
|
100 |
+
public function generate($routeName, array $params = array()) {
|
101 |
+
|
102 |
+
// Check if named route exists
|
103 |
+
if(!isset($this->namedRoutes[$routeName])) {
|
104 |
+
throw new \Exception("Route '{$routeName}' does not exist.");
|
105 |
+
}
|
106 |
+
|
107 |
+
// Replace named parameters
|
108 |
+
$route = $this->namedRoutes[$routeName];
|
109 |
+
|
110 |
+
// prepend base path to route url again
|
111 |
+
$url = $this->basePath . $route;
|
112 |
+
|
113 |
+
if (preg_match_all('`(/|\.|)\[([^:\]]*+)(?::([^:\]]*+))?\](\?|)`', $route, $matches, PREG_SET_ORDER)) {
|
114 |
+
|
115 |
+
foreach($matches as $match) {
|
116 |
+
list($block, $pre, $type, $param, $optional) = $match;
|
117 |
+
|
118 |
+
if ($pre) {
|
119 |
+
$block = substr($block, 1);
|
120 |
+
}
|
121 |
+
|
122 |
+
if(isset($params[$param])) {
|
123 |
+
$url = str_replace($block, $params[$param], $url);
|
124 |
+
} elseif ($optional) {
|
125 |
+
$url = str_replace($pre . $block, '', $url);
|
126 |
+
}
|
127 |
+
}
|
128 |
+
|
129 |
+
|
130 |
+
}
|
131 |
+
|
132 |
+
return $url;
|
133 |
+
}
|
134 |
+
|
135 |
+
/**
|
136 |
+
* Match a given Request Url against stored routes
|
137 |
+
* @param string $requestUrl
|
138 |
+
* @param string $requestMethod
|
139 |
+
* @return array|boolean Array with route information on success, false on failure (no match).
|
140 |
+
*/
|
141 |
+
public function match($requestUrl = null, $requestMethod = null) {
|
142 |
+
|
143 |
+
$params = array();
|
144 |
+
$match = false;
|
145 |
+
|
146 |
+
// set Request Url if it isn't passed as parameter
|
147 |
+
if($requestUrl === null) {
|
148 |
+
$requestUrl = isset($_SERVER['REQUEST_URI']) ? $_SERVER['REQUEST_URI'] : '/';
|
149 |
+
}
|
150 |
+
|
151 |
+
// strip base path from request url
|
152 |
+
$requestUrl = substr($requestUrl, strlen($this->basePath));
|
153 |
+
|
154 |
+
// Strip query string (?a=b) from Request Url
|
155 |
+
if (($strpos = strpos($requestUrl, '?')) !== false) {
|
156 |
+
$requestUrl = substr($requestUrl, 0, $strpos);
|
157 |
+
}
|
158 |
+
|
159 |
+
// set Request Method if it isn't passed as a parameter
|
160 |
+
if($requestMethod === null) {
|
161 |
+
$requestMethod = isset($_SERVER['REQUEST_METHOD']) ? $_SERVER['REQUEST_METHOD'] : 'GET';
|
162 |
+
}
|
163 |
+
|
164 |
+
// Force request_order to be GP
|
165 |
+
// http://www.mail-archive.com/internals@lists.php.net/msg33119.html
|
166 |
+
$_REQUEST = array_merge($_GET, $_POST);
|
167 |
+
|
168 |
+
foreach($this->routes as $handler) {
|
169 |
+
list($method, $_route, $target, $name) = $handler;
|
170 |
+
|
171 |
+
$methods = explode('|', $method);
|
172 |
+
$method_match = false;
|
173 |
+
|
174 |
+
// Check if request method matches. If not, abandon early. (CHEAP)
|
175 |
+
foreach($methods as $method) {
|
176 |
+
if (strcasecmp($requestMethod, $method) === 0) {
|
177 |
+
$method_match = true;
|
178 |
+
break;
|
179 |
+
}
|
180 |
+
}
|
181 |
+
|
182 |
+
// Method did not match, continue to next route.
|
183 |
+
if(!$method_match) continue;
|
184 |
+
|
185 |
+
// Check for a wildcard (matches all)
|
186 |
+
if ($_route === '*') {
|
187 |
+
$match = true;
|
188 |
+
} elseif (isset($_route[0]) && $_route[0] === '@') {
|
189 |
+
$match = preg_match('`' . substr($_route, 1) . '`u', $requestUrl, $params);
|
190 |
+
} else {
|
191 |
+
$route = null;
|
192 |
+
$regex = false;
|
193 |
+
$j = 0;
|
194 |
+
$n = isset($_route[0]) ? $_route[0] : null;
|
195 |
+
$i = 0;
|
196 |
+
|
197 |
+
// Find the longest non-regex substring and match it against the URI
|
198 |
+
while (true) {
|
199 |
+
if (!isset($_route[$i])) {
|
200 |
+
break;
|
201 |
+
} elseif (false === $regex) {
|
202 |
+
$c = $n;
|
203 |
+
$regex = $c === '[' || $c === '(' || $c === '.';
|
204 |
+
if (false === $regex && false !== isset($_route[$i+1])) {
|
205 |
+
$n = $_route[$i + 1];
|
206 |
+
$regex = $n === '?' || $n === '+' || $n === '*' || $n === '{';
|
207 |
+
}
|
208 |
+
if (false === $regex && $c !== '/' && (!isset($requestUrl[$j]) || $c !== $requestUrl[$j])) {
|
209 |
+
continue 2;
|
210 |
+
}
|
211 |
+
$j++;
|
212 |
+
}
|
213 |
+
$route .= $_route[$i++];
|
214 |
+
}
|
215 |
+
|
216 |
+
$regex = $this->compileRoute($route);
|
217 |
+
$match = preg_match($regex, $requestUrl, $params);
|
218 |
+
}
|
219 |
+
|
220 |
+
if(($match == true || $match > 0)) {
|
221 |
+
|
222 |
+
if($params) {
|
223 |
+
foreach($params as $key => $value) {
|
224 |
+
if(is_numeric($key)) unset($params[$key]);
|
225 |
+
}
|
226 |
+
}
|
227 |
+
|
228 |
+
return array(
|
229 |
+
'target' => $target,
|
230 |
+
'params' => $params,
|
231 |
+
'name' => $name
|
232 |
+
);
|
233 |
+
}
|
234 |
+
}
|
235 |
+
return false;
|
236 |
+
}
|
237 |
+
|
238 |
+
/**
|
239 |
+
* Compile the regex for a given route (EXPENSIVE)
|
240 |
+
*/
|
241 |
+
private function compileRoute($route) {
|
242 |
+
if (preg_match_all('`(/|\.|)\[([^:\]]*+)(?::([^:\]]*+))?\](\?|)`', $route, $matches, PREG_SET_ORDER)) {
|
243 |
+
|
244 |
+
$matchTypes = $this->matchTypes;
|
245 |
+
foreach($matches as $match) {
|
246 |
+
list($block, $pre, $type, $param, $optional) = $match;
|
247 |
+
|
248 |
+
if (isset($matchTypes[$type])) {
|
249 |
+
$type = $matchTypes[$type];
|
250 |
+
}
|
251 |
+
if ($pre === '.') {
|
252 |
+
$pre = '\.';
|
253 |
+
}
|
254 |
+
|
255 |
+
//Older versions of PCRE require the 'P' in (?P<named>)
|
256 |
+
$pattern = '(?:'
|
257 |
+
. ($pre !== '' ? $pre : null)
|
258 |
+
. '('
|
259 |
+
. ($param !== '' ? "?P<$param>" : null)
|
260 |
+
. $type
|
261 |
+
. '))'
|
262 |
+
. ($optional !== '' ? '?' : null);
|
263 |
+
|
264 |
+
$route = str_replace($block, $pattern, $route);
|
265 |
+
}
|
266 |
+
|
267 |
+
}
|
268 |
+
return "`^$route$`u";
|
269 |
+
}
|
270 |
+
}
|
vendor/altorouter/altorouter/AltoRouterTest.php
ADDED
@@ -0,0 +1,423 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require 'AltoRouter.php';
|
4 |
+
|
5 |
+
class AltoRouterDebug extends AltoRouter{
|
6 |
+
|
7 |
+
public function getNamedRoutes(){
|
8 |
+
return $this->namedRoutes;
|
9 |
+
}
|
10 |
+
|
11 |
+
public function getRoutes(){
|
12 |
+
return $this->routes;
|
13 |
+
}
|
14 |
+
|
15 |
+
public function getBasePath(){
|
16 |
+
return $this->basePath;
|
17 |
+
}
|
18 |
+
|
19 |
+
}
|
20 |
+
|
21 |
+
class SimpleTraversable implements Iterator{
|
22 |
+
|
23 |
+
protected $_position = 0;
|
24 |
+
|
25 |
+
protected $_data = array(
|
26 |
+
array('GET', '/foo', 'foo_action', null),
|
27 |
+
array('POST', '/bar', 'bar_action', 'second_route')
|
28 |
+
);
|
29 |
+
|
30 |
+
public function current(){
|
31 |
+
return $this->_data[$this->_position];
|
32 |
+
}
|
33 |
+
public function key(){
|
34 |
+
return $this->_position;
|
35 |
+
}
|
36 |
+
public function next(){
|
37 |
+
++$this->_position;
|
38 |
+
}
|
39 |
+
public function rewind(){
|
40 |
+
$this->_position = 0;
|
41 |
+
}
|
42 |
+
public function valid(){
|
43 |
+
return isset($this->_data[$this->_position]);
|
44 |
+
}
|
45 |
+
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2013-07-14 at 17:47:46.
|
50 |
+
*/
|
51 |
+
class AltoRouterTest extends PHPUnit_Framework_TestCase
|
52 |
+
{
|
53 |
+
/**
|
54 |
+
* @var AltoRouter
|
55 |
+
*/
|
56 |
+
protected $router;
|
57 |
+
|
58 |
+
/**
|
59 |
+
* Sets up the fixture, for example, opens a network connection.
|
60 |
+
* This method is called before a test is executed.
|
61 |
+
*/
|
62 |
+
protected function setUp()
|
63 |
+
{
|
64 |
+
$this->router = new AltoRouterDebug;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Tears down the fixture, for example, closes a network connection.
|
69 |
+
* This method is called after a test is executed.
|
70 |
+
*/
|
71 |
+
protected function tearDown()
|
72 |
+
{
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @covers AltoRouter::addRoutes
|
77 |
+
*/
|
78 |
+
public function testAddRoutes()
|
79 |
+
{
|
80 |
+
$method = 'POST';
|
81 |
+
$route = '/[:controller]/[:action]';
|
82 |
+
$target = function(){};
|
83 |
+
|
84 |
+
$this->router->addRoutes(array(
|
85 |
+
array($method, $route, $target),
|
86 |
+
array($method, $route, $target, 'second_route')
|
87 |
+
));
|
88 |
+
|
89 |
+
$routes = $this->router->getRoutes();
|
90 |
+
|
91 |
+
$this->assertEquals(array($method, $route, $target, null), $routes[0]);
|
92 |
+
$this->assertEquals(array($method, $route, $target, 'second_route'), $routes[1]);
|
93 |
+
}
|
94 |
+
|
95 |
+
/**
|
96 |
+
* @covers AltoRouter::addRoutes
|
97 |
+
*/
|
98 |
+
public function testAddRoutesAcceptsTraverable()
|
99 |
+
{
|
100 |
+
$traversable = new SimpleTraversable();
|
101 |
+
$this->router->addRoutes($traversable);
|
102 |
+
|
103 |
+
$traversable->rewind();
|
104 |
+
|
105 |
+
$first = $traversable->current();
|
106 |
+
$traversable->next();
|
107 |
+
$second = $traversable->current();
|
108 |
+
|
109 |
+
$routes = $this->router->getRoutes();
|
110 |
+
|
111 |
+
$this->assertEquals($first, $routes[0]);
|
112 |
+
$this->assertEquals($second, $routes[1]);
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* @covers AltoRouter::addRoutes
|
117 |
+
* @expectedException Exception
|
118 |
+
*/
|
119 |
+
public function testAddRoutesThrowsExceptionOnInvalidArgument()
|
120 |
+
{
|
121 |
+
$this->router->addRoutes(new stdClass);
|
122 |
+
}
|
123 |
+
|
124 |
+
/**
|
125 |
+
* @covers AltoRouter::setBasePath
|
126 |
+
*/
|
127 |
+
public function testSetBasePath()
|
128 |
+
{
|
129 |
+
$basePath = $this->router->setBasePath('/some/path');
|
130 |
+
$this->assertEquals('/some/path', $this->router->getBasePath());
|
131 |
+
|
132 |
+
$basePath = $this->router->setBasePath('/some/path');
|
133 |
+
$this->assertEquals('/some/path', $this->router->getBasePath());
|
134 |
+
}
|
135 |
+
|
136 |
+
/**
|
137 |
+
* @covers AltoRouter::map
|
138 |
+
*/
|
139 |
+
public function testMap()
|
140 |
+
{
|
141 |
+
$method = 'POST';
|
142 |
+
$route = '/[:controller]/[:action]';
|
143 |
+
$target = function(){};
|
144 |
+
|
145 |
+
$this->router->map($method, $route, $target);
|
146 |
+
|
147 |
+
$routes = $this->router->getRoutes();
|
148 |
+
|
149 |
+
$this->assertEquals(array($method, $route, $target, null), $routes[0]);
|
150 |
+
}
|
151 |
+
|
152 |
+
/**
|
153 |
+
* @covers AltoRouter::map
|
154 |
+
*/
|
155 |
+
public function testMapWithName()
|
156 |
+
{
|
157 |
+
$method = 'POST';
|
158 |
+
$route = '/[:controller]/[:action]';
|
159 |
+
$target = function(){};
|
160 |
+
$name = 'myroute';
|
161 |
+
|
162 |
+
$this->router->map($method, $route, $target, $name);
|
163 |
+
|
164 |
+
$routes = $this->router->getRoutes();
|
165 |
+
$this->assertEquals(array($method, $route, $target, $name), $routes[0]);
|
166 |
+
|
167 |
+
$named_routes = $this->router->getNamedRoutes();
|
168 |
+
$this->assertEquals($route, $named_routes[$name]);
|
169 |
+
|
170 |
+
try{
|
171 |
+
$this->router->map($method, $route, $target, $name);
|
172 |
+
$this->fail('Should not be able to add existing named route');
|
173 |
+
}catch(Exception $e){
|
174 |
+
$this->assertEquals("Can not redeclare route '{$name}'", $e->getMessage());
|
175 |
+
}
|
176 |
+
}
|
177 |
+
|
178 |
+
|
179 |
+
/**
|
180 |
+
* @covers AltoRouter::generate
|
181 |
+
*/
|
182 |
+
public function testGenerate()
|
183 |
+
{
|
184 |
+
$params = array(
|
185 |
+
'controller' => 'test',
|
186 |
+
'action' => 'someaction'
|
187 |
+
);
|
188 |
+
|
189 |
+
$this->router->map('GET', '/[:controller]/[:action]', function(){}, 'foo_route');
|
190 |
+
|
191 |
+
$this->assertEquals('/test/someaction',
|
192 |
+
$this->router->generate('foo_route', $params));
|
193 |
+
|
194 |
+
$params = array(
|
195 |
+
'controller' => 'test',
|
196 |
+
'action' => 'someaction',
|
197 |
+
'type' => 'json'
|
198 |
+
);
|
199 |
+
|
200 |
+
$this->assertEquals('/test/someaction',
|
201 |
+
$this->router->generate('foo_route', $params));
|
202 |
+
|
203 |
+
}
|
204 |
+
|
205 |
+
public function testGenerateWithOptionalUrlParts()
|
206 |
+
{
|
207 |
+
$this->router->map('GET', '/[:controller]/[:action].[:type]?', function(){}, 'bar_route');
|
208 |
+
|
209 |
+
$params = array(
|
210 |
+
'controller' => 'test',
|
211 |
+
'action' => 'someaction'
|
212 |
+
);
|
213 |
+
|
214 |
+
$this->assertEquals('/test/someaction',
|
215 |
+
$this->router->generate('bar_route', $params));
|
216 |
+
|
217 |
+
$params = array(
|
218 |
+
'controller' => 'test',
|
219 |
+
'action' => 'someaction',
|
220 |
+
'type' => 'json'
|
221 |
+
);
|
222 |
+
|
223 |
+
$this->assertEquals('/test/someaction.json',
|
224 |
+
$this->router->generate('bar_route', $params));
|
225 |
+
}
|
226 |
+
|
227 |
+
public function testGenerateWithNonexistingRoute()
|
228 |
+
{
|
229 |
+
try{
|
230 |
+
$this->router->generate('nonexisting_route');
|
231 |
+
$this->fail('Should trigger an exception on nonexisting named route');
|
232 |
+
}catch(Exception $e){
|
233 |
+
$this->assertEquals("Route 'nonexisting_route' does not exist.", $e->getMessage());
|
234 |
+
}
|
235 |
+
}
|
236 |
+
|
237 |
+
/**
|
238 |
+
* @covers AltoRouter::match
|
239 |
+
* @covers AltoRouter::compileRoute
|
240 |
+
*/
|
241 |
+
public function testMatch()
|
242 |
+
{
|
243 |
+
$this->router->map('GET', '/foo/[:controller]/[:action]', 'foo_action', 'foo_route');
|
244 |
+
|
245 |
+
$this->assertEquals(array(
|
246 |
+
'target' => 'foo_action',
|
247 |
+
'params' => array(
|
248 |
+
'controller' => 'test',
|
249 |
+
'action' => 'do'
|
250 |
+
),
|
251 |
+
'name' => 'foo_route'
|
252 |
+
), $this->router->match('/foo/test/do', 'GET'));
|
253 |
+
|
254 |
+
$this->assertFalse($this->router->match('/foo/test/do', 'POST'));
|
255 |
+
|
256 |
+
$this->assertEquals(array(
|
257 |
+
'target' => 'foo_action',
|
258 |
+
'params' => array(
|
259 |
+
'controller' => 'test',
|
260 |
+
'action' => 'do'
|
261 |
+
),
|
262 |
+
'name' => 'foo_route'
|
263 |
+
), $this->router->match('/foo/test/do?param=value', 'GET'));
|
264 |
+
|
265 |
+
}
|
266 |
+
|
267 |
+
public function testMatchWithFixedParamValues()
|
268 |
+
{
|
269 |
+
$this->router->map('POST','/users/[i:id]/[delete|update:action]', 'usersController#doAction', 'users_do');
|
270 |
+
|
271 |
+
$this->assertEquals(array(
|
272 |
+
'target' => 'usersController#doAction',
|
273 |
+
'params' => array(
|
274 |
+
'id' => 1,
|
275 |
+
'action' => 'delete'
|
276 |
+
),
|
277 |
+
'name' => 'users_do'
|
278 |
+
), $this->router->match('/users/1/delete', 'POST'));
|
279 |
+
|
280 |
+
$this->assertFalse($this->router->match('/users/1/delete', 'GET'));
|
281 |
+
$this->assertFalse($this->router->match('/users/abc/delete', 'POST'));
|
282 |
+
$this->assertFalse($this->router->match('/users/1/create', 'GET'));
|
283 |
+
}
|
284 |
+
|
285 |
+
public function testMatchWithServerVars()
|
286 |
+
{
|
287 |
+
$this->router->map('GET', '/foo/[:controller]/[:action]', 'foo_action', 'foo_route');
|
288 |
+
|
289 |
+
$_SERVER['REQUEST_URI'] = '/foo/test/do';
|
290 |
+
$_SERVER['REQUEST_METHOD'] = 'GET';
|
291 |
+
|
292 |
+
$this->assertEquals(array(
|
293 |
+
'target' => 'foo_action',
|
294 |
+
'params' => array(
|
295 |
+
'controller' => 'test',
|
296 |
+
'action' => 'do'
|
297 |
+
),
|
298 |
+
'name' => 'foo_route'
|
299 |
+
), $this->router->match());
|
300 |
+
}
|
301 |
+
|
302 |
+
public function testMatchWithOptionalUrlParts()
|
303 |
+
{
|
304 |
+
$this->router->map('GET', '/bar/[:controller]/[:action].[:type]?', 'bar_action', 'bar_route');
|
305 |
+
|
306 |
+
$this->assertEquals(array(
|
307 |
+
'target' => 'bar_action',
|
308 |
+
'params' => array(
|
309 |
+
'controller' => 'test',
|
310 |
+
'action' => 'do',
|
311 |
+
'type' => 'json'
|
312 |
+
),
|
313 |
+
'name' => 'bar_route'
|
314 |
+
), $this->router->match('/bar/test/do.json', 'GET'));
|
315 |
+
|
316 |
+
}
|
317 |
+
|
318 |
+
public function testMatchWithWildcard()
|
319 |
+
{
|
320 |
+
$this->router->map('GET', '/a', 'foo_action', 'foo_route');
|
321 |
+
$this->router->map('GET', '*', 'bar_action', 'bar_route');
|
322 |
+
|
323 |
+
$this->assertEquals(array(
|
324 |
+
'target' => 'bar_action',
|
325 |
+
'params' => array(),
|
326 |
+
'name' => 'bar_route'
|
327 |
+
), $this->router->match('/everything', 'GET'));
|
328 |
+
|
329 |
+
}
|
330 |
+
|
331 |
+
public function testMatchWithCustomRegexp()
|
332 |
+
{
|
333 |
+
$this->router->map('GET', '@^/[a-z]*$', 'bar_action', 'bar_route');
|
334 |
+
|
335 |
+
$this->assertEquals(array(
|
336 |
+
'target' => 'bar_action',
|
337 |
+
'params' => array(),
|
338 |
+
'name' => 'bar_route'
|
339 |
+
), $this->router->match('/everything', 'GET'));
|
340 |
+
|
341 |
+
$this->assertFalse($this->router->match('/some-other-thing', 'GET'));
|
342 |
+
|
343 |
+
}
|
344 |
+
|
345 |
+
public function testMatchWithUnicodeRegex()
|
346 |
+
{
|
347 |
+
$pattern = '/(?<path>[^';
|
348 |
+
// Arabic characters
|
349 |
+
$pattern .= '\x{0600}-\x{06FF}';
|
350 |
+
$pattern .= '\x{FB50}-\x{FDFD}';
|
351 |
+
$pattern .= '\x{FE70}-\x{FEFF}';
|
352 |
+
$pattern .= '\x{0750}-\x{077F}';
|
353 |
+
// Alphanumeric, /, _, - and space characters
|
354 |
+
$pattern .= 'a-zA-Z0-9\/_-\s';
|
355 |
+
// 'ZERO WIDTH NON-JOINER'
|
356 |
+
$pattern .= '\x{200C}';
|
357 |
+
$pattern .= ']+)';
|
358 |
+
|
359 |
+
$this->router->map('GET', '@' . $pattern, 'unicode_action', 'unicode_route');
|
360 |
+
|
361 |
+
$this->assertEquals(array(
|
362 |
+
'target' => 'unicode_action',
|
363 |
+
'name' => 'unicode_route',
|
364 |
+
'params' => array(
|
365 |
+
'path' => '大家好'
|
366 |
+
)
|
367 |
+
), $this->router->match('/大家好', 'GET'));
|
368 |
+
|
369 |
+
$this->assertFalse($this->router->match('/﷽', 'GET'));
|
370 |
+
}
|
371 |
+
|
372 |
+
/**
|
373 |
+
* @covers AltoRouter::addMatchTypes
|
374 |
+
*/
|
375 |
+
public function testMatchWithCustomNamedRegex()
|
376 |
+
{
|
377 |
+
$this->router->addMatchTypes(array('cId' => '[a-zA-Z]{2}[0-9](?:_[0-9]++)?'));
|
378 |
+
$this->router->map('GET', '/bar/[cId:customId]', 'bar_action', 'bar_route');
|
379 |
+
|
380 |
+
$this->assertEquals(array(
|
381 |
+
'target' => 'bar_action',
|
382 |
+
'params' => array(
|
383 |
+
'customId' => 'AB1',
|
384 |
+
),
|
385 |
+
'name' => 'bar_route'
|
386 |
+
), $this->router->match('/bar/AB1', 'GET'));
|
387 |
+
|
388 |
+
$this->assertEquals(array(
|
389 |
+
'target' => 'bar_action',
|
390 |
+
'params' => array(
|
391 |
+
'customId' => 'AB1_0123456789',
|
392 |
+
),
|
393 |
+
'name' => 'bar_route'
|
394 |
+
), $this->router->match('/bar/AB1_0123456789', 'GET'));
|
395 |
+
|
396 |
+
$this->assertFalse($this->router->match('/some-other-thing', 'GET'));
|
397 |
+
|
398 |
+
}
|
399 |
+
|
400 |
+
public function testMatchWithCustomNamedUnicodeRegex()
|
401 |
+
{
|
402 |
+
$pattern = '[^';
|
403 |
+
// Arabic characters
|
404 |
+
$pattern .= '\x{0600}-\x{06FF}';
|
405 |
+
$pattern .= '\x{FB50}-\x{FDFD}';
|
406 |
+
$pattern .= '\x{FE70}-\x{FEFF}';
|
407 |
+
$pattern .= '\x{0750}-\x{077F}';
|
408 |
+
$pattern .= ']+';
|
409 |
+
|
410 |
+
$this->router->addMatchTypes(array('nonArabic' => $pattern));
|
411 |
+
$this->router->map('GET', '/bar/[nonArabic:string]', 'non_arabic_action', 'non_arabic_route');
|
412 |
+
|
413 |
+
$this->assertEquals(array(
|
414 |
+
'target' => 'non_arabic_action',
|
415 |
+
'name' => 'non_arabic_route',
|
416 |
+
'params' => array(
|
417 |
+
'string' => 'some-path'
|
418 |
+
)
|
419 |
+
), $this->router->match('/bar/some-path', 'GET'));
|
420 |
+
|
421 |
+
$this->assertFalse($this->router->match('/﷽', 'GET'));
|
422 |
+
}
|
423 |
+
}
|
vendor/altorouter/altorouter/README.md
ADDED
@@ -0,0 +1,92 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# AltoRouter [![Build Status](https://api.travis-ci.org/dannyvankooten/AltoRouter.png)](http://travis-ci.org/dannyvankooten/AltoRouter)
|
2 |
+
AltoRouter is a small but powerful routing class for PHP 5.3+, heavily inspired by [klein.php](https://github.com/chriso/klein.php/).
|
3 |
+
|
4 |
+
* Dynamic routing with named parameters
|
5 |
+
* Reversed routing
|
6 |
+
* Flexible regular expression routing (inspired by [Sinatra](http://www.sinatrarb.com/))
|
7 |
+
* Custom regexes
|
8 |
+
|
9 |
+
## Getting started
|
10 |
+
|
11 |
+
1. PHP 5.3.x is required
|
12 |
+
2. Install AltoRouter using Composer or manually
|
13 |
+
2. Setup URL rewriting so that all requests are handled by **index.php**
|
14 |
+
3. Create an instance of AltoRouter, map your routes and match a request.
|
15 |
+
4. Have a look at the basic example in the `examples` directory for a better understanding on how to use AltoRouter.
|
16 |
+
|
17 |
+
## Routing
|
18 |
+
```php
|
19 |
+
$router = new AltoRouter();
|
20 |
+
$router->setBasePath('/AltoRouter'); // (optional) the subdir AltoRouter lives in
|
21 |
+
|
22 |
+
// mapping routes
|
23 |
+
$router->map('GET|POST','/', 'home#index', 'home');
|
24 |
+
$router->map('GET','/users', array('c' => 'UserController', 'a' => 'ListAction'));
|
25 |
+
$router->map('GET','/users/[i:id]', 'users#show', 'users_show');
|
26 |
+
$router->map('POST','/users/[i:id]/[delete|update:action]', 'usersController#doAction', 'users_do');
|
27 |
+
|
28 |
+
// reversed routing
|
29 |
+
$router->generate('users_show', array('id' => 5));
|
30 |
+
|
31 |
+
```
|
32 |
+
|
33 |
+
**You can use the following limits on your named parameters. AltoRouter will create the correct regexes for you.**
|
34 |
+
|
35 |
+
```php
|
36 |
+
* // Match all request URIs
|
37 |
+
[i] // Match an integer
|
38 |
+
[i:id] // Match an integer as 'id'
|
39 |
+
[a:action] // Match alphanumeric characters as 'action'
|
40 |
+
[h:key] // Match hexadecimal characters as 'key'
|
41 |
+
[:action] // Match anything up to the next / or end of the URI as 'action'
|
42 |
+
[create|edit:action] // Match either 'create' or 'edit' as 'action'
|
43 |
+
[*] // Catch all (lazy, stops at the next trailing slash)
|
44 |
+
[*:trailing] // Catch all as 'trailing' (lazy)
|
45 |
+
[**:trailing] // Catch all (possessive - will match the rest of the URI)
|
46 |
+
.[:format]? // Match an optional parameter 'format' - a / or . before the block is also optional
|
47 |
+
```
|
48 |
+
|
49 |
+
**Some more complicated examples**
|
50 |
+
|
51 |
+
```php
|
52 |
+
@/(?[A-Za-z]{2}_[A-Za-z]{2})$ // custom regex, matches language codes like "en_us" etc.
|
53 |
+
/posts/[*:title][i:id] // Matches "/posts/this-is-a-title-123"
|
54 |
+
/output.[xml|json:format]? // Matches "/output", "output.xml", "output.json"
|
55 |
+
/[:controller]?/[:action]? // Matches the typical /controller/action format
|
56 |
+
```
|
57 |
+
|
58 |
+
**The character before the colon (the 'match type') is a shortcut for one of the following regular expressions**
|
59 |
+
|
60 |
+
```php
|
61 |
+
'i' => '[0-9]++'
|
62 |
+
'a' => '[0-9A-Za-z]++'
|
63 |
+
'h' => '[0-9A-Fa-f]++'
|
64 |
+
'*' => '.+?'
|
65 |
+
'**' => '.++'
|
66 |
+
'' => '[^/\.]++'
|
67 |
+
```
|
68 |
+
|
69 |
+
**New match types can be added using the `addMatchTypes()` method**
|
70 |
+
|
71 |
+
```php
|
72 |
+
$router->addMatchTypes(array('cId' => '[a-zA-Z]{2}[0-9](?:_[0-9]++)?'));
|
73 |
+
```
|
74 |
+
|
75 |
+
|
76 |
+
## Contributors
|
77 |
+
- [Danny van Kooten](https://github.com/dannyvankooten)
|
78 |
+
- [Koen Punt](https://github.com/koenpunt)
|
79 |
+
- [John Long](https://github.com/adduc)
|
80 |
+
- [Niahoo Osef](https://github.com/niahoo)
|
81 |
+
|
82 |
+
## License
|
83 |
+
|
84 |
+
(MIT License)
|
85 |
+
|
86 |
+
Copyright (c) 2012-2013 Danny van Kooten <hi@dannyvankooten.com>
|
87 |
+
|
88 |
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
89 |
+
|
90 |
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
91 |
+
|
92 |
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
vendor/altorouter/altorouter/composer.json
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name": "altorouter/altorouter",
|
3 |
+
"description": "A lightning fast router for PHP",
|
4 |
+
"keywords": ["router", "routing", "lightweight"],
|
5 |
+
"homepage": "https://github.com/dannyvankooten/AltoRouter",
|
6 |
+
"license": "MIT",
|
7 |
+
"authors": [
|
8 |
+
{
|
9 |
+
"name": "Danny van Kooten",
|
10 |
+
"email": "dannyvankooten@gmail.com",
|
11 |
+
"homepage": "http://dannyvankooten.com/"
|
12 |
+
},
|
13 |
+
{
|
14 |
+
"name": "Koen Punt",
|
15 |
+
"homepage": "https://github.com/koenpunt"
|
16 |
+
},
|
17 |
+
{
|
18 |
+
"name": "niahoo",
|
19 |
+
"homepage": "https://github.com/niahoo"
|
20 |
+
}
|
21 |
+
],
|
22 |
+
"require": {
|
23 |
+
"php": ">=5.3.0"
|
24 |
+
},
|
25 |
+
"autoload": {
|
26 |
+
"classmap": ["AltoRouter.php"]
|
27 |
+
}
|
28 |
+
}
|
vendor/altorouter/altorouter/examples/basic/.htaccess
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
1 |
+
RewriteEngine On
|
2 |
+
RewriteCond %{REQUEST_FILENAME} !-f
|
3 |
+
RewriteRule . index.php [L]
|
vendor/altorouter/altorouter/examples/basic/index.php
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
require '../../AltoRouter.php';
|
4 |
+
|
5 |
+
$router = new AltoRouter();
|
6 |
+
$router->setBasePath('/AltoRouter/examples/basic');
|
7 |
+
$router->map('GET|POST','/', 'home#index', 'home');
|
8 |
+
$router->map('GET','/users/', array('c' => 'UserController', 'a' => 'ListAction'));
|
9 |
+
$router->map('GET','/users/[i:id]', 'users#show', 'users_show');
|
10 |
+
$router->map('POST','/users/[i:id]/[delete|update:action]', 'usersController#doAction', 'users_do');
|
11 |
+
|
12 |
+
// match current request
|
13 |
+
$match = $router->match();
|
14 |
+
?>
|
15 |
+
<h1>AltoRouter</h1>
|
16 |
+
|
17 |
+
<h3>Current request: </h3>
|
18 |
+
<pre>
|
19 |
+
Target: <?php var_dump($match['target']); ?>
|
20 |
+
Params: <?php var_dump($match['params']); ?>
|
21 |
+
Name: <?php var_dump($match['name']); ?>
|
22 |
+
</pre>
|
23 |
+
|
24 |
+
<h3>Try these requests: </h3>
|
25 |
+
<p><a href="<?php echo $router->generate('home'); ?>">GET <?php echo $router->generate('home'); ?></a></p>
|
26 |
+
<p><a href="<?php echo $router->generate('users_show', array('id' => 5)); ?>">GET <?php echo $router->generate('users_show', array('id' => 5)); ?></a></p>
|
27 |
+
<p><form action="<?php echo $router->generate('users_do', array('id' => 10, 'action' => 'update')); ?>" method="post"><button type="submit"><?php echo $router->generate('users_do', array('id' => 10, 'action' => 'update')); ?></button></form></p>
|
vendor/autoload.php
CHANGED
@@ -4,4 +4,4 @@
|
|
4 |
|
5 |
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
6 |
|
7 |
-
return
|
4 |
|
5 |
require_once __DIR__ . '/composer' . '/autoload_real.php';
|
6 |
|
7 |
+
return ComposerAutoloaderInitc8ae28d171e71bc958bc45eadf43b9f4::getLoader();
|
vendor/composer/autoload_classmap.php
CHANGED
@@ -6,4 +6,43 @@ $vendorDir = dirname(dirname(__FILE__));
|
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
9 |
);
|
6 |
$baseDir = dirname($vendorDir);
|
7 |
|
8 |
return array(
|
9 |
+
'ACFTimber' => $baseDir . '/lib/integrations/acf-timber.php',
|
10 |
+
'AltoRouter' => $vendorDir . '/altorouter/altorouter/AltoRouter.php',
|
11 |
+
'TimberAdmin' => $baseDir . '/lib/timber-admin.php',
|
12 |
+
'TimberArchives' => $baseDir . '/lib/timber-archives.php',
|
13 |
+
'TimberCommand' => $baseDir . '/lib/integrations/timber-command.php',
|
14 |
+
'TimberComment' => $baseDir . '/lib/timber-comment.php',
|
15 |
+
'TimberCore' => $baseDir . '/lib/timber-core.php',
|
16 |
+
'TimberCoreInterface' => $baseDir . '/lib/timber-core-interface.php',
|
17 |
+
'TimberFunctionWrapper' => $baseDir . '/lib/timber-function-wrapper.php',
|
18 |
+
'TimberHelper' => $baseDir . '/lib/timber-helper.php',
|
19 |
+
'TimberImage' => $baseDir . '/lib/timber-image.php',
|
20 |
+
'TimberImageHelper' => $baseDir . '/lib/timber-image-helper.php',
|
21 |
+
'TimberImageOperation' => $baseDir . '/lib/image/timber-image-operation.php',
|
22 |
+
'TimberImageOperationLetterbox' => $baseDir . '/lib/image/timber-image-operation-letterbox.php',
|
23 |
+
'TimberImageOperationPngToJpg' => $baseDir . '/lib/image/timber-image-operation-pngtojpg.php',
|
24 |
+
'TimberImageOperationResize' => $baseDir . '/lib/image/timber-image-operation-resize.php',
|
25 |
+
'TimberImageOperationRetina' => $baseDir . '/lib/image/timber-image-operation-retina.php',
|
26 |
+
'TimberIntegrations' => $baseDir . '/lib/timber-integrations.php',
|
27 |
+
'TimberLoader' => $baseDir . '/lib/timber-loader.php',
|
28 |
+
'TimberMenu' => $baseDir . '/lib/timber-menu.php',
|
29 |
+
'TimberMenuItem' => $baseDir . '/lib/timber-menu-item.php',
|
30 |
+
'TimberPage' => $baseDir . '/lib/timber-page.php',
|
31 |
+
'TimberPost' => $baseDir . '/lib/timber-post.php',
|
32 |
+
'TimberPostGetter' => $baseDir . '/lib/timber-post-getter.php',
|
33 |
+
'TimberPostsCollection' => $baseDir . '/lib/timber-posts-collection.php',
|
34 |
+
'TimberPostsIterator' => $baseDir . '/lib/timber-posts-collection.php',
|
35 |
+
'TimberQueryIterator' => $baseDir . '/lib/timber-query-iterator.php',
|
36 |
+
'TimberRoutes' => $baseDir . '/lib/timber-routes.php',
|
37 |
+
'TimberSite' => $baseDir . '/lib/timber-site.php',
|
38 |
+
'TimberTerm' => $baseDir . '/lib/timber-term.php',
|
39 |
+
'TimberTermGetter' => $baseDir . '/lib/timber-term-getter.php',
|
40 |
+
'TimberTheme' => $baseDir . '/lib/timber-theme.php',
|
41 |
+
'TimberTwig' => $baseDir . '/lib/timber-twig.php',
|
42 |
+
'TimberURLHelper' => $baseDir . '/lib/timber-url-helper.php',
|
43 |
+
'TimberUser' => $baseDir . '/lib/timber-user.php',
|
44 |
+
'Timber\\Cache\\KeyGenerator' => $baseDir . '/lib/cache/KeyGenerator.php',
|
45 |
+
'Timber\\Cache\\TimberKeyGeneratorInterface' => $baseDir . '/lib/cache/TimberKeyGeneratorInterface.php',
|
46 |
+
'Timber\\Cache\\WPObjectCacheAdapter' => $baseDir . '/lib/cache/WPObjectCacheAdapter.php',
|
47 |
+
'Timber_WP_CLI_Command' => $baseDir . '/lib/integrations/wpcli-timber.php',
|
48 |
);
|
vendor/composer/autoload_namespaces.php
CHANGED
@@ -7,7 +7,7 @@ $baseDir = dirname($vendorDir);
|
|
7 |
|
8 |
return array(
|
9 |
'Twig_' => array($vendorDir . '/twig/twig/lib'),
|
10 |
-
'
|
11 |
'Composer\\Installers\\' => array($vendorDir . '/composer/installers/src'),
|
12 |
'Asm89\\Twig\\CacheExtension\\' => array($vendorDir . '/asm89/twig-cache-extension/lib'),
|
13 |
);
|
7 |
|
8 |
return array(
|
9 |
'Twig_' => array($vendorDir . '/twig/twig/lib'),
|
10 |
+
'Routes' => array($vendorDir . '/upstatement/routes'),
|
11 |
'Composer\\Installers\\' => array($vendorDir . '/composer/installers/src'),
|
12 |
'Asm89\\Twig\\CacheExtension\\' => array($vendorDir . '/asm89/twig-cache-extension/lib'),
|
13 |
);
|
vendor/composer/autoload_real.php
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
-
class
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
@@ -19,9 +19,9 @@ class ComposerAutoloaderInit51eed1b778e859bfb3984400f7648ee2
|
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
-
spl_autoload_register(array('
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
-
spl_autoload_unregister(array('
|
25 |
|
26 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
27 |
foreach ($map as $namespace => $path) {
|
@@ -44,7 +44,7 @@ class ComposerAutoloaderInit51eed1b778e859bfb3984400f7648ee2
|
|
44 |
}
|
45 |
}
|
46 |
|
47 |
-
function
|
48 |
{
|
49 |
require $file;
|
50 |
}
|
2 |
|
3 |
// autoload_real.php @generated by Composer
|
4 |
|
5 |
+
class ComposerAutoloaderInitc8ae28d171e71bc958bc45eadf43b9f4
|
6 |
{
|
7 |
private static $loader;
|
8 |
|
19 |
return self::$loader;
|
20 |
}
|
21 |
|
22 |
+
spl_autoload_register(array('ComposerAutoloaderInitc8ae28d171e71bc958bc45eadf43b9f4', 'loadClassLoader'), true, true);
|
23 |
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
|
24 |
+
spl_autoload_unregister(array('ComposerAutoloaderInitc8ae28d171e71bc958bc45eadf43b9f4', 'loadClassLoader'));
|
25 |
|
26 |
$map = require __DIR__ . '/autoload_namespaces.php';
|
27 |
foreach ($map as $namespace => $path) {
|
44 |
}
|
45 |
}
|
46 |
|
47 |
+
function composerRequirec8ae28d171e71bc958bc45eadf43b9f4($file)
|
48 |
{
|
49 |
require $file;
|
50 |
}
|
vendor/composer/installed.json
CHANGED
@@ -1,17 +1,17 @@
|
|
1 |
[
|
2 |
{
|
3 |
"name": "composer/installers",
|
4 |
-
"version": "v1.0.
|
5 |
-
"version_normalized": "1.0.
|
6 |
"source": {
|
7 |
"type": "git",
|
8 |
"url": "https://github.com/composer/installers.git",
|
9 |
-
"reference": "
|
10 |
},
|
11 |
"dist": {
|
12 |
"type": "zip",
|
13 |
-
"url": "https://api.github.com/repos/composer/installers/zipball/
|
14 |
-
"reference": "
|
15 |
"shasum": ""
|
16 |
},
|
17 |
"replace": {
|
@@ -22,7 +22,7 @@
|
|
22 |
"composer/composer": "1.0.*@dev",
|
23 |
"phpunit/phpunit": "4.1.*"
|
24 |
},
|
25 |
-
"time": "2015-
|
26 |
"type": "composer-installer",
|
27 |
"extra": {
|
28 |
"class": "Composer\\Installers\\Installer",
|
@@ -59,6 +59,7 @@
|
|
59 |
"Thelia",
|
60 |
"WolfCMS",
|
61 |
"agl",
|
|
|
62 |
"annotatecms",
|
63 |
"bitrix",
|
64 |
"cakephp",
|
@@ -95,24 +96,6 @@
|
|
95 |
"zikula"
|
96 |
]
|
97 |
},
|
98 |
-
{
|
99 |
-
"name": "jarednova/php-router",
|
100 |
-
"version": "1.0.1",
|
101 |
-
"version_normalized": "1.0.1.0",
|
102 |
-
"dist": {
|
103 |
-
"type": "zip",
|
104 |
-
"url": "https://github.com/jarednova/PHP-Router/archive/fix_psr_0.zip",
|
105 |
-
"reference": null,
|
106 |
-
"shasum": null
|
107 |
-
},
|
108 |
-
"type": "library",
|
109 |
-
"installation-source": "dist",
|
110 |
-
"autoload": {
|
111 |
-
"psr-0": {
|
112 |
-
"PHPRouter": "src/"
|
113 |
-
}
|
114 |
-
}
|
115 |
-
},
|
116 |
{
|
117 |
"name": "twig/twig",
|
118 |
"version": "v1.18.0",
|
@@ -225,5 +208,111 @@
|
|
225 |
"extension",
|
226 |
"twig"
|
227 |
]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
228 |
}
|
229 |
]
|
1 |
[
|
2 |
{
|
3 |
"name": "composer/installers",
|
4 |
+
"version": "v1.0.21",
|
5 |
+
"version_normalized": "1.0.21.0",
|
6 |
"source": {
|
7 |
"type": "git",
|
8 |
"url": "https://github.com/composer/installers.git",
|
9 |
+
"reference": "d64e23fce42a4063d63262b19b8e7c0f3b5e4c45"
|
10 |
},
|
11 |
"dist": {
|
12 |
"type": "zip",
|
13 |
+
"url": "https://api.github.com/repos/composer/installers/zipball/d64e23fce42a4063d63262b19b8e7c0f3b5e4c45",
|
14 |
+
"reference": "d64e23fce42a4063d63262b19b8e7c0f3b5e4c45",
|
15 |
"shasum": ""
|
16 |
},
|
17 |
"replace": {
|
22 |
"composer/composer": "1.0.*@dev",
|
23 |
"phpunit/phpunit": "4.1.*"
|
24 |
},
|
25 |
+
"time": "2015-02-18 17:17:01",
|
26 |
"type": "composer-installer",
|
27 |
"extra": {
|
28 |
"class": "Composer\\Installers\\Installer",
|
59 |
"Thelia",
|
60 |
"WolfCMS",
|
61 |
"agl",
|
62 |
+
"aimeos",
|
63 |
"annotatecms",
|
64 |
"bitrix",
|
65 |
"cakephp",
|
96 |
"zikula"
|
97 |
]
|
98 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
99 |
{
|
100 |
"name": "twig/twig",
|
101 |
"version": "v1.18.0",
|
208 |
"extension",
|
209 |
"twig"
|
210 |
]
|
211 |
+
},
|
212 |
+
{
|
213 |
+
"name": "altorouter/altorouter",
|
214 |
+
"version": "v1.1.0",
|
215 |
+
"version_normalized": "1.1.0.0",
|
216 |
+
"source": {
|
217 |
+
"type": "git",
|
218 |
+
"url": "https://github.com/dannyvankooten/AltoRouter.git",
|
219 |
+
"reference": "09d9d946c546bae6d22a7654cdb3b825ffda54b4"
|
220 |
+
},
|
221 |
+
"dist": {
|
222 |
+
"type": "zip",
|
223 |
+
"url": "https://api.github.com/repos/dannyvankooten/AltoRouter/zipball/09d9d946c546bae6d22a7654cdb3b825ffda54b4",
|
224 |
+
"reference": "09d9d946c546bae6d22a7654cdb3b825ffda54b4",
|
225 |
+
"shasum": ""
|
226 |
+
},
|
227 |
+
"require": {
|
228 |
+
"php": ">=5.3.0"
|
229 |
+
},
|
230 |
+
"time": "2014-04-16 09:44:40",
|
231 |
+
"type": "library",
|
232 |
+
"installation-source": "dist",
|
233 |
+
"autoload": {
|
234 |
+
"classmap": [
|
235 |
+
"AltoRouter.php"
|
236 |
+
]
|
237 |
+
},
|
238 |
+
"notification-url": "https://packagist.org/downloads/",
|
239 |
+
"license": [
|
240 |
+
"MIT"
|
241 |
+
],
|
242 |
+
"authors": [
|
243 |
+
{
|
244 |
+
"name": "Danny van Kooten",
|
245 |
+
"email": "dannyvankooten@gmail.com",
|
246 |
+
"homepage": "http://dannyvankooten.com/"
|
247 |
+
},
|
248 |
+
{
|
249 |
+
"name": "Koen Punt",
|
250 |
+
"homepage": "https://github.com/koenpunt"
|
251 |
+
},
|
252 |
+
{
|
253 |
+
"name": "niahoo",
|
254 |
+
"homepage": "https://github.com/niahoo"
|
255 |
+
}
|
256 |
+
],
|
257 |
+
"description": "A lightning fast router for PHP",
|
258 |
+
"homepage": "https://github.com/dannyvankooten/AltoRouter",
|
259 |
+
"keywords": [
|
260 |
+
"lightweight",
|
261 |
+
"router",
|
262 |
+
"routing"
|
263 |
+
]
|
264 |
+
},
|
265 |
+
{
|
266 |
+
"name": "upstatement/routes",
|
267 |
+
"version": "dev-master",
|
268 |
+
"version_normalized": "9999999-dev",
|
269 |
+
"source": {
|
270 |
+
"type": "git",
|
271 |
+
"url": "https://github.com/Upstatement/routes.git",
|
272 |
+
"reference": "e2711a97c754f2cccf366a8b70106ec27eec933a"
|
273 |
+
},
|
274 |
+
"dist": {
|
275 |
+
"type": "zip",
|
276 |
+
"url": "https://api.github.com/repos/Upstatement/routes/zipball/e2711a97c754f2cccf366a8b70106ec27eec933a",
|
277 |
+
"reference": "e2711a97c754f2cccf366a8b70106ec27eec933a",
|
278 |
+
"shasum": ""
|
279 |
+
},
|
280 |
+
"require": {
|
281 |
+
"altorouter/altorouter": "1.1.0",
|
282 |
+
"composer/installers": "~1.0",
|
283 |
+
"php": ">=5.3.0"
|
284 |
+
},
|
285 |
+
"require-dev": {
|
286 |
+
"phpunit/phpunit": "3.7.*",
|
287 |
+
"satooshi/php-coveralls": "dev-master",
|
288 |
+
"wp-cli/wp-cli": "*"
|
289 |
+
},
|
290 |
+
"time": "2015-03-05 13:17:27",
|
291 |
+
"type": "library",
|
292 |
+
"installation-source": "source",
|
293 |
+
"autoload": {
|
294 |
+
"psr-0": {
|
295 |
+
"Routes": ""
|
296 |
+
}
|
297 |
+
},
|
298 |
+
"notification-url": "https://packagist.org/downloads/",
|
299 |
+
"license": [
|
300 |
+
"MIT"
|
301 |
+
],
|
302 |
+
"authors": [
|
303 |
+
{
|
304 |
+
"name": "Jared Novack",
|
305 |
+
"email": "jared@upstatement.com",
|
306 |
+
"homepage": "http://upstatement.com"
|
307 |
+
}
|
308 |
+
],
|
309 |
+
"description": "Manage rewrites and routes in WordPress with this dead-simple plugin",
|
310 |
+
"homepage": "http://routes.upstatement.com",
|
311 |
+
"keywords": [
|
312 |
+
"redirects",
|
313 |
+
"rewrite",
|
314 |
+
"routes",
|
315 |
+
"routing"
|
316 |
+
]
|
317 |
}
|
318 |
]
|
vendor/composer/installers/README.md
CHANGED
@@ -33,7 +33,8 @@ is not needed to install packages with these frameworks:
|
|
33 |
|
34 |
| Framework | Types
|
35 |
| --------- | -----
|
36 |
-
|
|
|
|
37 |
| AGL | `agl-module`
|
38 |
| AnnotateCms | `annotatecms-module`<br>`annotatecms-component`<br>`annotatecms-service`
|
39 |
| Bitrix | `bitrix-module`<br>`bitrix-component`<br>`bitrix-theme`
|
@@ -83,6 +84,7 @@ is not needed to install packages with these frameworks:
|
|
83 |
| WordPress | <b>`wordpress-plugin`<br>`wordpress-theme`</b><br>`wordpress-muplugin`
|
84 |
| Zend | `zend-library`<br>`zend-extra`<br>`zend-module`
|
85 |
| Zikula | `zikula-module`<br>`zikula-theme`
|
|
|
86 |
|
87 |
## Example `composer.json` File
|
88 |
|
33 |
|
34 |
| Framework | Types
|
35 |
| --------- | -----
|
36 |
+
| Aimeos | `aimeos-extension`
|
37 |
+
| Asgard | `asgard-module`<br>`asgard-theme`
|
38 |
| AGL | `agl-module`
|
39 |
| AnnotateCms | `annotatecms-module`<br>`annotatecms-component`<br>`annotatecms-service`
|
40 |
| Bitrix | `bitrix-module`<br>`bitrix-component`<br>`bitrix-theme`
|
84 |
| WordPress | <b>`wordpress-plugin`<br>`wordpress-theme`</b><br>`wordpress-muplugin`
|
85 |
| Zend | `zend-library`<br>`zend-extra`<br>`zend-module`
|
86 |
| Zikula | `zikula-module`<br>`zikula-theme`
|
87 |
+
| Prestashop | `prestashop-module`<br>`prestashop-theme`
|
88 |
|
89 |
## Example `composer.json` File
|
90 |
|
vendor/composer/installers/composer.json
CHANGED
@@ -5,6 +5,7 @@
|
|
5 |
"description": "A multi-framework Composer library installer",
|
6 |
"keywords": [
|
7 |
"installer",
|
|
|
8 |
"AGL",
|
9 |
"AnnotateCms",
|
10 |
"Bitrix",
|
5 |
"description": "A multi-framework Composer library installer",
|
6 |
"keywords": [
|
7 |
"installer",
|
8 |
+
"Aimeos",
|
9 |
"AGL",
|
10 |
"AnnotateCms",
|
11 |
"Bitrix",
|
vendor/composer/installers/src/Composer/Installers/AimeosInstaller.php
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class AimeosInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'extension' => 'ext/{$name}/',
|
8 |
+
);
|
9 |
+
}
|
vendor/composer/installers/src/Composer/Installers/CakePHPInstaller.php
CHANGED
@@ -17,6 +17,10 @@ class CakePHPInstaller extends BaseInstaller
|
|
17 |
*/
|
18 |
public function inflectPackageVars($vars)
|
19 |
{
|
|
|
|
|
|
|
|
|
20 |
$nameParts = explode('/', $vars['name']);
|
21 |
foreach ($nameParts as &$value) {
|
22 |
$value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value));
|
@@ -34,27 +38,11 @@ class CakePHPInstaller extends BaseInstaller
|
|
34 |
public function getLocations()
|
35 |
{
|
36 |
if ($this->matchesCakeVersion('>=', '3.0.0')) {
|
37 |
-
$this->locations['plugin'] = '
|
38 |
}
|
39 |
return $this->locations;
|
40 |
}
|
41 |
|
42 |
-
/**
|
43 |
-
* Add installer-name for CakePHP >= 3.0.0
|
44 |
-
*
|
45 |
-
* @param PackageInterface $package
|
46 |
-
* @param string $frameworkType
|
47 |
-
* @return string
|
48 |
-
*/
|
49 |
-
public function getInstallPath(PackageInterface $package, $frameworkType = '')
|
50 |
-
{
|
51 |
-
$extra = $package->getExtra();
|
52 |
-
if (empty($extra['installer-name']) && $this->matchesCakeVersion('>=', '3.0.0')) {
|
53 |
-
$this->setInstallerName($package);
|
54 |
-
}
|
55 |
-
return parent::getInstallPath($package, $frameworkType);
|
56 |
-
}
|
57 |
-
|
58 |
/**
|
59 |
* Check if CakePHP version matches against a version
|
60 |
*
|
@@ -87,59 +75,4 @@ class CakePHPInstaller extends BaseInstaller
|
|
87 |
}
|
88 |
return false;
|
89 |
}
|
90 |
-
|
91 |
-
/**
|
92 |
-
* Set installer-name based on namespace for the source path checking in
|
93 |
-
* following order:
|
94 |
-
*
|
95 |
-
* - With only one autoload path the namespace for that path will be used.
|
96 |
-
* - With multiple paths if path 'src' exists it's namespace will be used.
|
97 |
-
* - With two autoload paths provided, the namespace of path other than
|
98 |
-
* 'tests' will be used.
|
99 |
-
*
|
100 |
-
* No installer-name is set if PSR-4 autoload block is not found or if none
|
101 |
-
* of the above conditions are met.
|
102 |
-
*
|
103 |
-
* @param PackageInterface $package
|
104 |
-
*/
|
105 |
-
protected function setInstallerName(PackageInterface $package)
|
106 |
-
{
|
107 |
-
$primaryNS = null;
|
108 |
-
$autoLoad = $package->getAutoload();
|
109 |
-
foreach ($autoLoad as $type => $typeConfig) {
|
110 |
-
if ($type !== 'psr-4') {
|
111 |
-
continue;
|
112 |
-
}
|
113 |
-
$count = count($typeConfig);
|
114 |
-
|
115 |
-
if ($count === 1) {
|
116 |
-
$primaryNS = key($typeConfig);
|
117 |
-
break;
|
118 |
-
}
|
119 |
-
|
120 |
-
$matches = preg_grep('#^(\./)?src/?$#', $typeConfig);
|
121 |
-
if ($matches) {
|
122 |
-
$primaryNS = key($matches);
|
123 |
-
break;
|
124 |
-
}
|
125 |
-
|
126 |
-
if ($count === 2) {
|
127 |
-
reset($typeConfig);
|
128 |
-
if (preg_match('#^(\./)?tests/?$#', current($typeConfig))) {
|
129 |
-
next($typeConfig);
|
130 |
-
}
|
131 |
-
$primaryNS = key($typeConfig);
|
132 |
-
break;
|
133 |
-
}
|
134 |
-
|
135 |
-
break;
|
136 |
-
}
|
137 |
-
|
138 |
-
if ($primaryNS) {
|
139 |
-
$package->setExtra(array(
|
140 |
-
'installer-name' => trim(str_replace('\\', '/', $primaryNS), '/')
|
141 |
-
));
|
142 |
-
}
|
143 |
-
}
|
144 |
-
|
145 |
}
|
17 |
*/
|
18 |
public function inflectPackageVars($vars)
|
19 |
{
|
20 |
+
if ($this->matchesCakeVersion('>=', '3.0.0')) {
|
21 |
+
return $vars;
|
22 |
+
}
|
23 |
+
|
24 |
$nameParts = explode('/', $vars['name']);
|
25 |
foreach ($nameParts as &$value) {
|
26 |
$value = strtolower(preg_replace('/(?<=\\w)([A-Z])/', '_\\1', $value));
|
38 |
public function getLocations()
|
39 |
{
|
40 |
if ($this->matchesCakeVersion('>=', '3.0.0')) {
|
41 |
+
$this->locations['plugin'] = $this->composer->getConfig()->get('vendor-dir') . '/{$vendor}/{$name}/';
|
42 |
}
|
43 |
return $this->locations;
|
44 |
}
|
45 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
/**
|
47 |
* Check if CakePHP version matches against a version
|
48 |
*
|
75 |
}
|
76 |
return false;
|
77 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
}
|
vendor/composer/installers/src/Composer/Installers/Installer.php
CHANGED
@@ -13,6 +13,7 @@ class Installer extends LibraryInstaller
|
|
13 |
* @var array
|
14 |
*/
|
15 |
private $supportedTypes = array(
|
|
|
16 |
'asgard' => 'AsgardInstaller',
|
17 |
'agl' => 'AglInstaller',
|
18 |
'annotatecms' => 'AnnotateCmsInstaller',
|
@@ -66,6 +67,7 @@ class Installer extends LibraryInstaller
|
|
66 |
'wordpress' => 'WordPressInstaller',
|
67 |
'zend' => 'ZendInstaller',
|
68 |
'zikula' => 'ZikulaInstaller',
|
|
|
69 |
);
|
70 |
|
71 |
/**
|
13 |
* @var array
|
14 |
*/
|
15 |
private $supportedTypes = array(
|
16 |
+
'aimeos' => 'AimeosInstaller',
|
17 |
'asgard' => 'AsgardInstaller',
|
18 |
'agl' => 'AglInstaller',
|
19 |
'annotatecms' => 'AnnotateCmsInstaller',
|
67 |
'wordpress' => 'WordPressInstaller',
|
68 |
'zend' => 'ZendInstaller',
|
69 |
'zikula' => 'ZikulaInstaller',
|
70 |
+
'prestashop' => 'PrestashopInstaller',
|
71 |
);
|
72 |
|
73 |
/**
|
vendor/composer/installers/src/Composer/Installers/PrestashopInstaller.php
ADDED
@@ -0,0 +1,10 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
namespace Composer\Installers;
|
3 |
+
|
4 |
+
class PrestashopInstaller extends BaseInstaller
|
5 |
+
{
|
6 |
+
protected $locations = array(
|
7 |
+
'module' => 'modules/{$name}/',
|
8 |
+
'theme' => 'themes/{$name}/',
|
9 |
+
);
|
10 |
+
}
|
vendor/composer/installers/tests/Composer/Installers/Test/CakePHPInstallerTest.php
CHANGED
@@ -9,6 +9,7 @@ use Composer\Package\RootPackage;
|
|
9 |
use Composer\Package\Link;
|
10 |
use Composer\Package\Version\VersionParser;
|
11 |
use Composer\Composer;
|
|
|
12 |
|
13 |
class CakePHPInstallerTest extends TestCase
|
14 |
{
|
@@ -25,6 +26,7 @@ class CakePHPInstallerTest extends TestCase
|
|
25 |
$this->package = new Package('CamelCased', '1.0', '1.0');
|
26 |
$this->io = $this->getMock('Composer\IO\PackageInterface');
|
27 |
$this->composer = new Composer();
|
|
|
28 |
}
|
29 |
|
30 |
/**
|
@@ -61,7 +63,7 @@ class CakePHPInstallerTest extends TestCase
|
|
61 |
*/
|
62 |
public function testGetLocations() {
|
63 |
$package = new RootPackage('CamelCased', '1.0', '1.0');
|
64 |
-
$composer =
|
65 |
$rm = new RepositoryManager(
|
66 |
$this->getMock('Composer\IO\IOInterface'),
|
67 |
$this->getMock('Composer\Config')
|
@@ -94,61 +96,11 @@ class CakePHPInstallerTest extends TestCase
|
|
94 |
// cakephp >= 3.0
|
95 |
$this->setCakephpVersion($rm, '3.0.*-dev');
|
96 |
$result = $installer->getLocations();
|
97 |
-
$this->assertContains('
|
98 |
|
99 |
$this->setCakephpVersion($rm, '~8.8');
|
100 |
$result = $installer->getLocations();
|
101 |
-
$this->
|
102 |
-
}
|
103 |
-
|
104 |
-
/**
|
105 |
-
* Test if installer-name was set
|
106 |
-
*
|
107 |
-
*/
|
108 |
-
public function testGetInstallPath() {
|
109 |
-
$autoload = array(
|
110 |
-
'psr-4' => array(
|
111 |
-
'FOC\\Authenticate' => ''
|
112 |
-
)
|
113 |
-
);
|
114 |
-
$this->package->setAutoload($autoload);
|
115 |
-
$this->package->setType('cakephp-plugin');
|
116 |
-
$rm = new RepositoryManager(
|
117 |
-
$this->getMock('Composer\IO\IOInterface'),
|
118 |
-
$this->getMock('Composer\Config')
|
119 |
-
);
|
120 |
-
$this->composer->setRepositoryManager($rm);
|
121 |
-
$installer = new CakePHPInstaller($this->package, $this->composer);
|
122 |
-
|
123 |
-
$this->setCakephpVersion($rm, '3.0.0');
|
124 |
-
$installer->getInstallPath($this->package, 'cakephp');
|
125 |
-
$extra = $this->package->getExtra();
|
126 |
-
$this->assertEquals('FOC/Authenticate', $extra['installer-name']);
|
127 |
-
|
128 |
-
$autoload = array(
|
129 |
-
'psr-4' => array(
|
130 |
-
'FOC\Acl\Test' => './tests',
|
131 |
-
'FOC\Acl' => ''
|
132 |
-
)
|
133 |
-
);
|
134 |
-
$this->package->setAutoload($autoload);
|
135 |
-
$this->package->setExtra(array());
|
136 |
-
$installer->getInstallPath($this->package, 'cakephp');
|
137 |
-
$extra = $this->package->getExtra();
|
138 |
-
$this->assertEquals('FOC/Acl', $extra['installer-name']);
|
139 |
-
|
140 |
-
$autoload = array(
|
141 |
-
'psr-4' => array(
|
142 |
-
'Foo\Bar' => 'foo',
|
143 |
-
'Acme\Plugin\Test' => 'tests',
|
144 |
-
'Acme\Plugin' => './src'
|
145 |
-
)
|
146 |
-
);
|
147 |
-
$this->package->setAutoload($autoload);
|
148 |
-
$this->package->setExtra(array());
|
149 |
-
$installer->getInstallPath($this->package, 'cakephp');
|
150 |
-
$extra = $this->package->getExtra();
|
151 |
-
$this->assertEquals('Acme/Plugin', $extra['installer-name']);
|
152 |
}
|
153 |
|
154 |
protected function setCakephpVersion($rm, $version) {
|
9 |
use Composer\Package\Link;
|
10 |
use Composer\Package\Version\VersionParser;
|
11 |
use Composer\Composer;
|
12 |
+
use Composer\Config;
|
13 |
|
14 |
class CakePHPInstallerTest extends TestCase
|
15 |
{
|
26 |
$this->package = new Package('CamelCased', '1.0', '1.0');
|
27 |
$this->io = $this->getMock('Composer\IO\PackageInterface');
|
28 |
$this->composer = new Composer();
|
29 |
+
$this->composer->setConfig(new Config(false));
|
30 |
}
|
31 |
|
32 |
/**
|
63 |
*/
|
64 |
public function testGetLocations() {
|
65 |
$package = new RootPackage('CamelCased', '1.0', '1.0');
|
66 |
+
$composer = $this->composer;
|
67 |
$rm = new RepositoryManager(
|
68 |
$this->getMock('Composer\IO\IOInterface'),
|
69 |
$this->getMock('Composer\Config')
|
96 |
// cakephp >= 3.0
|
97 |
$this->setCakephpVersion($rm, '3.0.*-dev');
|
98 |
$result = $installer->getLocations();
|
99 |
+
$this->assertContains('vendor/{$vendor}/{$name}/', $result['plugin']);
|
100 |
|
101 |
$this->setCakephpVersion($rm, '~8.8');
|
102 |
$result = $installer->getLocations();
|
103 |
+
$this->assertEquals('vendor/{$vendor}/{$name}/', $result['plugin']);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
}
|
105 |
|
106 |
protected function setCakephpVersion($rm, $version) {
|
vendor/composer/installers/tests/Composer/Installers/Test/InstallerTest.php
CHANGED
@@ -85,6 +85,7 @@ class InstallerTest extends TestCase
|
|
85 |
{
|
86 |
return array(
|
87 |
array('agl-module', true),
|
|
|
88 |
array('annotatecms-module', true),
|
89 |
array('annotatecms-component', true),
|
90 |
array('annotatecms-service', true),
|
@@ -142,6 +143,8 @@ class InstallerTest extends TestCase
|
|
142 |
array('phpbb-extension', true),
|
143 |
array('pimcore-plugin', true),
|
144 |
array('ppi-module', true),
|
|
|
|
|
145 |
array('puppet-module', true),
|
146 |
array('redaxo-addon', true),
|
147 |
array('redaxo-bestyle-plugin', true),
|
@@ -195,6 +198,7 @@ class InstallerTest extends TestCase
|
|
195 |
{
|
196 |
return array(
|
197 |
array('agl-module', 'More/MyTestPackage/', 'agl/my_test-package'),
|
|
|
198 |
array('annotatecms-module', 'addons/modules/my_module/', 'vysinsky/my_module'),
|
199 |
array('annotatecms-component', 'addons/components/my_component/', 'vysinsky/my_component'),
|
200 |
array('annotatecms-service', 'addons/services/my_service/', 'vysinsky/my_service'),
|
@@ -252,6 +256,8 @@ class InstallerTest extends TestCase
|
|
252 |
array('october-plugin', 'plugins/shama/my_plugin/', 'shama/my_plugin'),
|
253 |
array('october-theme', 'themes/my_theme/', 'shama/my_theme'),
|
254 |
array('piwik-plugin', 'plugins/VisitSummary/', 'shama/visit-summary'),
|
|
|
|
|
255 |
array('phpbb-extension', 'ext/test/foo/', 'test/foo'),
|
256 |
array('phpbb-style', 'styles/foo/', 'test/foo'),
|
257 |
array('phpbb-language', 'language/foo/', 'test/foo'),
|
85 |
{
|
86 |
return array(
|
87 |
array('agl-module', true),
|
88 |
+
array('aimeos-extension', true),
|
89 |
array('annotatecms-module', true),
|
90 |
array('annotatecms-component', true),
|
91 |
array('annotatecms-service', true),
|
143 |
array('phpbb-extension', true),
|
144 |
array('pimcore-plugin', true),
|
145 |
array('ppi-module', true),
|
146 |
+
array('prestashop-module', true),
|
147 |
+
array('prestashop-theme', true),
|
148 |
array('puppet-module', true),
|
149 |
array('redaxo-addon', true),
|
150 |
array('redaxo-bestyle-plugin', true),
|
198 |
{
|
199 |
return array(
|
200 |
array('agl-module', 'More/MyTestPackage/', 'agl/my_test-package'),
|
201 |
+
array('aimeos-extension', 'ext/ai-test/', 'author/ai-test'),
|
202 |
array('annotatecms-module', 'addons/modules/my_module/', 'vysinsky/my_module'),
|
203 |
array('annotatecms-component', 'addons/components/my_component/', 'vysinsky/my_component'),
|
204 |
array('annotatecms-service', 'addons/services/my_service/', 'vysinsky/my_service'),
|
256 |
array('october-plugin', 'plugins/shama/my_plugin/', 'shama/my_plugin'),
|
257 |
array('october-theme', 'themes/my_theme/', 'shama/my_theme'),
|
258 |
array('piwik-plugin', 'plugins/VisitSummary/', 'shama/visit-summary'),
|
259 |
+
array('prestashop-module', 'modules/a-module/', 'vendor/a-module'),
|
260 |
+
array('prestashop-theme', 'themes/a-theme/', 'vendor/a-theme'),
|
261 |
array('phpbb-extension', 'ext/test/foo/', 'test/foo'),
|
262 |
array('phpbb-style', 'styles/foo/', 'test/foo'),
|
263 |
array('phpbb-language', 'language/foo/', 'test/foo'),
|
vendor/jarednova/php-router/.gitignore
DELETED
@@ -1,36 +0,0 @@
|
|
1 |
-
# Compiled source #
|
2 |
-
###################
|
3 |
-
*.com
|
4 |
-
*.class
|
5 |
-
*.dll
|
6 |
-
*.exe
|
7 |
-
*.o
|
8 |
-
*.so
|
9 |
-
*.sublime-project
|
10 |
-
*.sublime-workspace
|
11 |
-
|
12 |
-
# Packages #
|
13 |
-
############
|
14 |
-
# it's better to unpack these files and commit the raw source
|
15 |
-
# git has its own built in compression methods
|
16 |
-
*.7z
|
17 |
-
*.dmg
|
18 |
-
*.gz
|
19 |
-
*.iso
|
20 |
-
*.jar
|
21 |
-
*.rar
|
22 |
-
*.tar
|
23 |
-
*.zip
|
24 |
-
|
25 |
-
# Logs and databases #
|
26 |
-
######################
|
27 |
-
*.log
|
28 |
-
*.sql
|
29 |
-
*.sqlite
|
30 |
-
|
31 |
-
# OS generated files #
|
32 |
-
######################
|
33 |
-
.DS_Store*
|
34 |
-
ehthumbs.db
|
35 |
-
Icon?
|
36 |
-
Thumbs.db
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/jarednova/php-router/.htaccess
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
Options +FollowSymLinks
|
2 |
-
RewriteEngine On
|
3 |
-
RewriteRule ^(.*)$ example.php [NC,L]
|
|
|
|
|
|
vendor/jarednova/php-router/README.md
DELETED
@@ -1,43 +0,0 @@
|
|
1 |
-
# PHP Router class
|
2 |
-
|
3 |
-
A simple Rails inspired PHP router class.
|
4 |
-
|
5 |
-
* Usage of different HTTP Methods
|
6 |
-
* REST / Resourceful routing
|
7 |
-
* Reversed routing using named routes
|
8 |
-
* Dynamic URL's: use URL segments as parameters.
|
9 |
-
|
10 |
-
## Usage
|
11 |
-
```php
|
12 |
-
<?php
|
13 |
-
require 'Router.php';
|
14 |
-
require 'Route.php';
|
15 |
-
|
16 |
-
$router = new Router();
|
17 |
-
|
18 |
-
$router->setBasePath('/PHP-Router');
|
19 |
-
|
20 |
-
// defining routes can be as simple as this
|
21 |
-
$router->map('/', 'users#index');
|
22 |
-
|
23 |
-
// or somewhat more complicated
|
24 |
-
$router->map('/users/:id/edit/', array('controller' => 'SomeController', 'action' => 'someAction'), array('methods' => 'GET,PUT', 'name' => 'users_edit', 'filters' => array('id' => '(\d+)')));
|
25 |
-
|
26 |
-
// You can even specify closures as the Route's target
|
27 |
-
$router->map('/hello/:name', function($name) { echo "Hello $name."; });
|
28 |
-
|
29 |
-
// match current request URL & http method
|
30 |
-
$target = $router->matchCurrentRequest();
|
31 |
-
var_dump($target);
|
32 |
-
|
33 |
-
// generate an URL
|
34 |
-
$router->generate('users_edit', array('id' => 5));
|
35 |
-
```
|
36 |
-
|
37 |
-
## More information
|
38 |
-
Have a look at the example.php file or read trough the class' documentation for a better understanding on how to use this class.
|
39 |
-
|
40 |
-
If you like PHP Router you might also like [AltoRouter](//github.com/dannyvankooten/AltoRouter).
|
41 |
-
|
42 |
-
## License
|
43 |
-
MIT Licensed, http://www.opensource.org/licenses/MIT
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/jarednova/php-router/composer.json
DELETED
@@ -1,26 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"name": "dannyvankooten/php-router",
|
3 |
-
"description": "Simple PHP Router, supports REST and reverse routing.",
|
4 |
-
"keywords": ["router", "routing", "php", "rest"],
|
5 |
-
"homepage": "https://github.com/dannyvankooten/PHP-Router",
|
6 |
-
"license": "MIT",
|
7 |
-
"authors": [
|
8 |
-
{
|
9 |
-
"name": "Danny van Kooten",
|
10 |
-
"email": "dannyvankooten@gmail.com",
|
11 |
-
"homepage": "http://dannyvankooten.com/"
|
12 |
-
},
|
13 |
-
{
|
14 |
-
"name": "Jefersson Nathan",
|
15 |
-
"email": "malukenho@phpse.net"
|
16 |
-
}
|
17 |
-
],
|
18 |
-
"require": {
|
19 |
-
"php": ">=5.3.0"
|
20 |
-
},
|
21 |
-
"autoload": {
|
22 |
-
"psr-0": {
|
23 |
-
"PHPRouter": "src/"
|
24 |
-
}
|
25 |
-
}
|
26 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/jarednova/php-router/example.php
DELETED
@@ -1,37 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
require 'Router.php';
|
3 |
-
require 'Route.php';
|
4 |
-
|
5 |
-
$router = new Router();
|
6 |
-
|
7 |
-
$router->setBasePath('/PHP-Router');
|
8 |
-
|
9 |
-
$router->map('/', 'someController:indexAction', array('methods' => 'GET'));
|
10 |
-
$router->map('/users/','users#create', array('methods' => 'POST', 'name' => 'users_create'));
|
11 |
-
$router->map('/users/:id/edit/', 'users#edit', array('methods' => 'GET', 'name' => 'users_edit', 'filters' => array('id' => '(\d+)')));
|
12 |
-
$router->map('/contact/',array('controller' => 'someController', 'action' => 'contactAction'), array('name' => 'contact'));
|
13 |
-
|
14 |
-
$router->map('/blog/:slug', array('c' => 'BlogController', 'a' => 'showAction'));
|
15 |
-
|
16 |
-
// capture rest of URL in "path" parameter (including forward slashes)
|
17 |
-
$router->map('/site-section/:path','some#target',array( 'filters' => array( 'path' => '(.*)') ) );
|
18 |
-
|
19 |
-
$route = $router->matchCurrentRequest();
|
20 |
-
|
21 |
-
?><h3>Current URL & HTTP method would route to: </h3>
|
22 |
-
<?php if($route) { ?>
|
23 |
-
<strong>Target:</strong>
|
24 |
-
<pre><?php var_dump($route->getTarget()); ?></pre>
|
25 |
-
|
26 |
-
<strong>Parameters:</strong>
|
27 |
-
<pre><?php var_dump($route->getParameters()); ?></pre>
|
28 |
-
<?php } else { ?>
|
29 |
-
<pre>No route matched.</pre>
|
30 |
-
<?php } ?>
|
31 |
-
|
32 |
-
<h3>Try out these URL's.</h3>
|
33 |
-
<p><a href="<?php echo $router->generate('users_edit', array('id' => 5)); ?>"><?php echo $router->generate('users_edit', array('id' => 5)); ?></a></p>
|
34 |
-
<p><a href="<?php echo $router->generate('contact'); ?>"><?php echo $router->generate('contact'); ?></a></p>
|
35 |
-
<p><form action="" method="POST"><input type="submit" value="Post request to current URL" /></form></p>
|
36 |
-
<p><form action="<?php echo $router->generate('users_create'); ?>" method="POST"><input type="submit" value="POST request to <?php echo $router->generate('users_create'); ?>" /></form></p>
|
37 |
-
<p><a href="<?php echo $router->generate('users_list'); ?>">GET request to <?php echo $router->generate('users_list'); ?></p>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/jarednova/php-router/src/PHPRouter/Route.php
DELETED
@@ -1,115 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
namespace PHPRouter;
|
3 |
-
|
4 |
-
class Route
|
5 |
-
{
|
6 |
-
/**
|
7 |
-
* URL of this Route
|
8 |
-
* @var string
|
9 |
-
*/
|
10 |
-
private $_url;
|
11 |
-
|
12 |
-
/**
|
13 |
-
* Accepted HTTP methods for this route
|
14 |
-
* @var array
|
15 |
-
*/
|
16 |
-
private $_methods = array('GET','POST','PUT','DELETE');
|
17 |
-
|
18 |
-
/**
|
19 |
-
* Target for this route, can be anything.
|
20 |
-
* @var mixed
|
21 |
-
*/
|
22 |
-
private $_target;
|
23 |
-
|
24 |
-
/**
|
25 |
-
* The name of this route, used for reversed routing
|
26 |
-
* @var string
|
27 |
-
*/
|
28 |
-
private $_name;
|
29 |
-
|
30 |
-
/**
|
31 |
-
* Custom parameter filters for this route
|
32 |
-
* @var array
|
33 |
-
*/
|
34 |
-
private $_filters = array();
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Array containing parameters passed through request URL
|
38 |
-
* @var array
|
39 |
-
*/
|
40 |
-
private $_parameters = array();
|
41 |
-
|
42 |
-
public function getUrl()
|
43 |
-
{
|
44 |
-
return $this->_url;
|
45 |
-
}
|
46 |
-
|
47 |
-
public function setUrl($url)
|
48 |
-
{
|
49 |
-
$url = (string) $url;
|
50 |
-
|
51 |
-
// make sure that the URL is suffixed with a forward slash
|
52 |
-
if(substr($url,-1) !== '/') $url .= '/';
|
53 |
-
|
54 |
-
$this->_url = $url;
|
55 |
-
}
|
56 |
-
|
57 |
-
public function getTarget()
|
58 |
-
{
|
59 |
-
return $this->_target;
|
60 |
-
}
|
61 |
-
|
62 |
-
public function setTarget($target)
|
63 |
-
{
|
64 |
-
$this->_target = $target;
|
65 |
-
}
|
66 |
-
|
67 |
-
public function getMethods()
|
68 |
-
{
|
69 |
-
return $this->_methods;
|
70 |
-
}
|
71 |
-
|
72 |
-
public function setMethods(array $methods)
|
73 |
-
{
|
74 |
-
$this->_methods = $methods;
|
75 |
-
}
|
76 |
-
|
77 |
-
public function getName()
|
78 |
-
{
|
79 |
-
return $this->_name;
|
80 |
-
}
|
81 |
-
|
82 |
-
public function setName($name)
|
83 |
-
{
|
84 |
-
$this->_name = (string) $name;
|
85 |
-
}
|
86 |
-
|
87 |
-
public function setFilters(array $filters)
|
88 |
-
{
|
89 |
-
$this->_filters = $filters;
|
90 |
-
}
|
91 |
-
|
92 |
-
public function getRegex()
|
93 |
-
{
|
94 |
-
return preg_replace_callback("/:(\w+)/", array(&$this, 'substituteFilter'), $this->_url);
|
95 |
-
}
|
96 |
-
|
97 |
-
private function substituteFilter($matches)
|
98 |
-
{
|
99 |
-
if (isset($matches[1]) && isset($this->_filters[$matches[1]])) {
|
100 |
-
return $this->_filters[$matches[1]];
|
101 |
-
}
|
102 |
-
|
103 |
-
return "([\w-]+)";
|
104 |
-
}
|
105 |
-
|
106 |
-
public function getParameters()
|
107 |
-
{
|
108 |
-
return $this->_parameters;
|
109 |
-
}
|
110 |
-
|
111 |
-
public function setParameters(array $parameters)
|
112 |
-
{
|
113 |
-
$this->_parameters = $parameters;
|
114 |
-
}
|
115 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/jarednova/php-router/src/PHPRouter/Router.php
DELETED
@@ -1,164 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
namespace PHPRouter;
|
3 |
-
|
4 |
-
/**
|
5 |
-
* Routing class to match request URL's against given routes and map them to a controller action.
|
6 |
-
*/
|
7 |
-
class Router
|
8 |
-
{
|
9 |
-
/**
|
10 |
-
* Array that holds all Route objects
|
11 |
-
* @var array
|
12 |
-
*/
|
13 |
-
private $_routes = array();
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Array to store named routes in, used for reverse routing.
|
17 |
-
* @var array
|
18 |
-
*/
|
19 |
-
private $_namedRoutes = array();
|
20 |
-
|
21 |
-
/**
|
22 |
-
* The base REQUEST_URI. Gets prepended to all route _url's.
|
23 |
-
* @var string
|
24 |
-
*/
|
25 |
-
private $_basePath = '';
|
26 |
-
|
27 |
-
/**
|
28 |
-
* Set the base _url - gets prepended to all route _url's.
|
29 |
-
* @param string $base_url
|
30 |
-
*/
|
31 |
-
public function setBasePath($basePath)
|
32 |
-
{
|
33 |
-
$this->_basePath = (string) $basePath;
|
34 |
-
}
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Route factory method
|
38 |
-
*
|
39 |
-
* Maps the given URL to the given target.
|
40 |
-
* @param string $routeUrl string
|
41 |
-
* @param mixed $target The target of this route. Can be anything. You'll have to provide your own method to turn * this into a filename, controller / action pair, etc..
|
42 |
-
* @param array $args Array of optional arguments.
|
43 |
-
*/
|
44 |
-
public function map($routeUrl, $target = '', array $args = array())
|
45 |
-
{
|
46 |
-
$route = new Route();
|
47 |
-
|
48 |
-
$route->setUrl($this->_basePath . $routeUrl);
|
49 |
-
|
50 |
-
$route->setTarget($target);
|
51 |
-
|
52 |
-
if(isset($args['methods'])) {
|
53 |
-
$methods = explode(',', $args['methods']);
|
54 |
-
$route->setMethods($methods);
|
55 |
-
}
|
56 |
-
|
57 |
-
if(isset($args['filters'])) {
|
58 |
-
$route->setFilters($args['filters']);
|
59 |
-
}
|
60 |
-
|
61 |
-
if(isset($args['name'])) {
|
62 |
-
$route->setName($args['name']);
|
63 |
-
if (!isset($this->_namedRoutes[$route->getName()])) {
|
64 |
-
$this->_namedRoutes[$route->getName()] = $route;
|
65 |
-
}
|
66 |
-
}
|
67 |
-
|
68 |
-
$this->_routes[] = $route;
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* Matches the current request against mapped routes
|
73 |
-
*/
|
74 |
-
public function matchCurrentRequest()
|
75 |
-
{
|
76 |
-
$requestMethod = (isset($_POST['_method']) && ($_method = strtoupper($_POST['_method'])) && in_array($_method,array('PUT','DELETE'))) ? $_method : $_SERVER['REQUEST_METHOD'];
|
77 |
-
$requestUrl = $_SERVER['REQUEST_URI'];
|
78 |
-
|
79 |
-
// strip GET variables from URL
|
80 |
-
if(($pos = strpos($requestUrl, '?')) !== false) {
|
81 |
-
$requestUrl = substr($requestUrl, 0, $pos);
|
82 |
-
}
|
83 |
-
|
84 |
-
return $this->match($requestUrl, $requestMethod);
|
85 |
-
}
|
86 |
-
|
87 |
-
/**
|
88 |
-
* Match given request _url and request method and see if a route has been defined for it
|
89 |
-
* If so, return route's target
|
90 |
-
* If called multiple times
|
91 |
-
*/
|
92 |
-
public function match($requestUrl, $requestMethod = 'GET')
|
93 |
-
{
|
94 |
-
|
95 |
-
foreach ($this->_routes as $route) {
|
96 |
-
|
97 |
-
// compare server request method with route's allowed http methods
|
98 |
-
if (! in_array($requestMethod, $route->getMethods())) {
|
99 |
-
continue;
|
100 |
-
}
|
101 |
-
|
102 |
-
// check if request _url matches route regex. if not, return false.
|
103 |
-
if (! preg_match("@^".$route->getRegex()."*$@i", $requestUrl, $matches)) {
|
104 |
-
continue;
|
105 |
-
}
|
106 |
-
|
107 |
-
$params = array();
|
108 |
-
|
109 |
-
if (preg_match_all("/:([\w-]+)/", $route->getUrl(), $argument_keys)) {
|
110 |
-
|
111 |
-
// grab array with matches
|
112 |
-
$argument_keys = $argument_keys[1];
|
113 |
-
|
114 |
-
// loop trough parameter names, store matching value in $params array
|
115 |
-
foreach ($argument_keys as $key => $name) {
|
116 |
-
if (isset($matches[$key + 1])) {
|
117 |
-
$params[$name] = $matches[$key + 1];
|
118 |
-
}
|
119 |
-
}
|
120 |
-
|
121 |
-
}
|
122 |
-
|
123 |
-
$route->setParameters($params);
|
124 |
-
|
125 |
-
return $route;
|
126 |
-
}
|
127 |
-
return false;
|
128 |
-
}
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
/**
|
133 |
-
* Reverse route a named route
|
134 |
-
*
|
135 |
-
* @param string $route_name The name of the route to reverse route.
|
136 |
-
* @param array $params Optional array of parameters to use in URL
|
137 |
-
* @return string The url to the route
|
138 |
-
*/
|
139 |
-
public function generate($routeName, array $params = array())
|
140 |
-
{
|
141 |
-
// Check if route exists
|
142 |
-
if (! isset($this->_namedRoutes[$routeName])) {
|
143 |
-
throw new Exception("No route with the name $routeName has been found.");
|
144 |
-
}
|
145 |
-
|
146 |
-
$route = $this->_namedRoutes[$routeName];
|
147 |
-
$url = $route->getUrl();
|
148 |
-
|
149 |
-
// replace route url with given parameters
|
150 |
-
if ($params && preg_match_all("/:(\w+)/", $url, $param_keys))
|
151 |
-
{
|
152 |
-
|
153 |
-
// grab array with matches
|
154 |
-
$param_keys = $param_keys[1];
|
155 |
-
|
156 |
-
// loop trough parameter names, store matching value in $params array
|
157 |
-
foreach ($param_keys as $key) {
|
158 |
-
if (isset($params[$key]))
|
159 |
-
$url = preg_replace("/:(\w+)/", $params[$key], $url, 1);
|
160 |
-
}
|
161 |
-
}
|
162 |
-
return $url;
|
163 |
-
}
|
164 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
vendor/upstatement/routes/.gitignore
ADDED
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# osx noise
|
2 |
+
.DS_Store
|
3 |
+
profile
|
4 |
+
|
5 |
+
# xcode noise
|
6 |
+
build/*
|
7 |
+
*.mode1
|
8 |
+
*.mode1v3
|
9 |
+
*.mode2v3
|
10 |
+
*.perspective
|
11 |
+
*.perspectivev3
|
12 |
+
*.pbxuser
|
13 |
+
*.xcworkspace
|
14 |
+
xcuserdata
|
15 |
+
|
16 |
+
# svn & cvs
|
17 |
+
.svn
|
18 |
+
CVS
|
19 |
+
vendor
|
vendor/upstatement/routes/.travis.yml
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
language: php
|
2 |
+
|
3 |
+
php:
|
4 |
+
- 5.3
|
5 |
+
- 5.4
|
6 |
+
|
7 |
+
env:
|
8 |
+
- WP_VERSION=latest WP_MULTISITE=0
|
9 |
+
- WP_VERSION=latest WP_MULTISITE=1
|
10 |
+
- WP_VERSION=3.9 WP_MULTISITE=0
|
11 |
+
- WP_VERSION=3.9 WP_MULTISITE=1
|
12 |
+
- WP_VERSION=3.8.3 WP_MULTISITE=0
|
13 |
+
- WP_VERSION=3.8.3 WP_MULTISITE=1
|
14 |
+
- WP_VERSION=3.7.3 WP_MULTISITE=0
|
15 |
+
- WP_VERSION=3.7.3 WP_MULTISITE=1
|
16 |
+
|
17 |
+
before_script:
|
18 |
+
- bash bin/install-wp-tests.sh wordpress_test root '' localhost $WP_VERSION
|
19 |
+
- composer install --dev
|
20 |
+
|
21 |
+
script:
|
22 |
+
- mkdir -p build/logs
|
23 |
+
- phpunit --coverage-clover build/logs/clover.xml
|
24 |
+
|
25 |
+
after_script:
|
26 |
+
- php vendor/bin/coveralls -v
|
27 |
+
|
28 |
+
after_success:
|
29 |
+
- coveralls
|
vendor/upstatement/routes/README.md
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Routes
|
2 |
+
Simple routing for WordPress.
|
3 |
+
|
4 |
+
[![Build Status](https://travis-ci.org/Upstatement/routes.svg?branch=master)](https://travis-ci.org/Upstatement/routes)
|
5 |
+
|
6 |
+
### Usage
|
7 |
+
```php
|
8 |
+
/* functions.php */
|
9 |
+
Routes::map('myfoo/bar', 'my_callback_function');
|
10 |
+
Routes::map('my-events/:event', function($params) {
|
11 |
+
$event_slug = $params['event'];
|
12 |
+
$event = new ECP_Event($event_slug);
|
13 |
+
Routes::load('single.php', array('event' => $event));
|
14 |
+
});
|
15 |
+
```
|
vendor/upstatement/routes/Routes.php
ADDED
@@ -0,0 +1,159 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/*
|
3 |
+
Plugin Name: Routes
|
4 |
+
Plugin URI: http://routes.upstatement.com
|
5 |
+
Description: The WordPress Timber Library allows you to write themes using the power Twig templates
|
6 |
+
Author: Jared Novack + Upstatement
|
7 |
+
Version: 0.1
|
8 |
+
Author URI: http://upstatement.com/
|
9 |
+
|
10 |
+
Usage:
|
11 |
+
|
12 |
+
Routes::map('/my-location', function(){
|
13 |
+
//do stuff
|
14 |
+
Routes::load('single.php', $data);
|
15 |
+
});
|
16 |
+
*/
|
17 |
+
|
18 |
+
class Routes {
|
19 |
+
|
20 |
+
protected $router;
|
21 |
+
|
22 |
+
function __construct(){
|
23 |
+
add_action('init', array($this, 'match_current_request') );
|
24 |
+
}
|
25 |
+
|
26 |
+
static function match_current_request() {
|
27 |
+
global $upstatement_routes;
|
28 |
+
if (isset($upstatement_routes->router)) {
|
29 |
+
$route = $upstatement_routes->router->match();
|
30 |
+
if ($route && isset($route['target'])) {
|
31 |
+
if ( isset($route['params']) ) {
|
32 |
+
call_user_func($route['target'], $route['params']);
|
33 |
+
} else {
|
34 |
+
call_user_func($route['target']);
|
35 |
+
}
|
36 |
+
}
|
37 |
+
}
|
38 |
+
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* @param string $route A string to match (ex: 'myfoo')
|
42 |
+
* @param callable $callback A function to run, examples:
|
43 |
+
* Routes::map('myfoo', 'my_callback_function');
|
44 |
+
* Routes::map('mybaq', array($my_class, 'method'));
|
45 |
+
* Routes::map('myqux', function() {
|
46 |
+
* //stuff goes here
|
47 |
+
* });
|
48 |
+
*/
|
49 |
+
public static function map($route, $callback, $args = array()) {
|
50 |
+
global $upstatement_routes;
|
51 |
+
if (!isset($upstatement_routes->router)) {
|
52 |
+
$upstatement_routes->router = new AltoRouter();
|
53 |
+
$site_url = get_bloginfo('url');
|
54 |
+
$site_url_parts = explode('/', $site_url);
|
55 |
+
$site_url_parts = array_slice($site_url_parts, 3);
|
56 |
+
$base_path = implode('/', $site_url_parts);
|
57 |
+
if (!$base_path || strpos($route, $base_path) === 0) {
|
58 |
+
$base_path = '/';
|
59 |
+
} else {
|
60 |
+
$base_path = '/' . $base_path . '/';
|
61 |
+
}
|
62 |
+
$upstatement_routes->router->setBasePath($base_path);
|
63 |
+
}
|
64 |
+
$route = self::convert_route($route);
|
65 |
+
$upstatement_routes->router->map('GET|POST', trailingslashit($route), $callback, $args);
|
66 |
+
$upstatement_routes->router->map('GET|POST', untrailingslashit($route), $callback, $args);
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @return string A string in a format for AltoRouter
|
71 |
+
* ex: [:my_param]
|
72 |
+
*/
|
73 |
+
public static function convert_route($route_string) {
|
74 |
+
if (strpos($route_string, '[') > -1) {
|
75 |
+
return $route_string;
|
76 |
+
}
|
77 |
+
$route_string = preg_replace('/(:)\w+/', '/[$0]', $route_string);
|
78 |
+
$route_string = str_replace('[[', '[', $route_string);
|
79 |
+
$route_string = str_replace(']]', ']', $route_string);
|
80 |
+
$route_string = str_replace('[/:', '[:', $route_string);
|
81 |
+
$route_string = str_replace('//[', '/[', $route_string);
|
82 |
+
if ( strpos($route_string, '/') === 0 ) {
|
83 |
+
$route_string = substr($route_string, 1);
|
84 |
+
}
|
85 |
+
return $route_string;
|
86 |
+
}
|
87 |
+
|
88 |
+
/**
|
89 |
+
* @param array $template A php file to load (ex: 'single.php')
|
90 |
+
* @param array|bool $tparams An array of data to send to the php file. Inside the php file
|
91 |
+
* this data can be accessed via:
|
92 |
+
* global $params;
|
93 |
+
* @param int $status_code A code for the status (ex: 200)
|
94 |
+
* @param WP_Query $query Use a WP_Query object in the template file instead of
|
95 |
+
* the default query
|
96 |
+
* @return bool
|
97 |
+
*/
|
98 |
+
public static function load($template, $tparams = false, $query = false, $status_code = 200) {
|
99 |
+
$fullPath = is_readable($template);
|
100 |
+
if (!$fullPath) {
|
101 |
+
$template = locate_template($template);
|
102 |
+
}
|
103 |
+
if ($tparams){
|
104 |
+
global $params;
|
105 |
+
$params = $tparams;
|
106 |
+
}
|
107 |
+
if ($status_code) {
|
108 |
+
add_filter('status_header', function($status_header, $header, $text, $protocol) use ($status_code) {
|
109 |
+
$text = get_status_header_desc($status_code);
|
110 |
+
$header_string = "$protocol $status_code $text";
|
111 |
+
return $header_string;
|
112 |
+
}, 10, 4 );
|
113 |
+
if (404 != $status_code) {
|
114 |
+
add_action('parse_query', function($query) {
|
115 |
+
if ($query->is_main_query()){
|
116 |
+
$query->is_404 = false;
|
117 |
+
}
|
118 |
+
},1);
|
119 |
+
add_action('template_redirect', function(){
|
120 |
+
global $wp_query;
|
121 |
+
$wp_query->is_404 = false;
|
122 |
+
},1);
|
123 |
+
}
|
124 |
+
}
|
125 |
+
|
126 |
+
if ($query) {
|
127 |
+
add_action('do_parse_request', function() use ($query) {
|
128 |
+
global $wp;
|
129 |
+
if ( is_callable($query) )
|
130 |
+
$query = call_user_func($query);
|
131 |
+
|
132 |
+
if ( is_array($query) )
|
133 |
+
$wp->query_vars = $query;
|
134 |
+
elseif ( !empty($query) )
|
135 |
+
parse_str($query, $wp->query_vars);
|
136 |
+
else
|
137 |
+
return true; // Could not interpret query. Let WP try.
|
138 |
+
|
139 |
+
return false;
|
140 |
+
});
|
141 |
+
}
|
142 |
+
if ($template) {
|
143 |
+
add_filter('template_include', function($t) use ($template) {
|
144 |
+
return $template;
|
145 |
+
});
|
146 |
+
return true;
|
147 |
+
}
|
148 |
+
return false;
|
149 |
+
}
|
150 |
+
}
|
151 |
+
|
152 |
+
global $upstatement_routes;
|
153 |
+
$upstatement_routes = new Routes();
|
154 |
+
|
155 |
+
if ( file_exists($composer_autoload = __DIR__ . '/vendor/autoload.php')
|
156 |
+
|| file_exists($composer_autoload = WP_CONTENT_DIR.'/vendor/autoload.php')){
|
157 |
+
require_once($composer_autoload);
|
158 |
+
}
|
159 |
+
|
vendor/upstatement/routes/bin/install-wp-tests.sh
ADDED
@@ -0,0 +1,78 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env bash
|
2 |
+
|
3 |
+
if [ $# -lt 3 ]; then
|
4 |
+
echo "usage: $0 <db-name> <db-user> <db-pass> [db-host] [wp-version]"
|
5 |
+
exit 1
|
6 |
+
fi
|
7 |
+
|
8 |
+
DB_NAME=$1
|
9 |
+
DB_USER=$2
|
10 |
+
DB_PASS=$3
|
11 |
+
DB_HOST=${4-localhost}
|
12 |
+
WP_VERSION=${5-master}
|
13 |
+
|
14 |
+
WP_TESTS_DIR=${WP_TESTS_DIR-/tmp/wordpress-tests-lib}
|
15 |
+
WP_CORE_DIR=/tmp/wordpress/
|
16 |
+
|
17 |
+
set -ex
|
18 |
+
|
19 |
+
install_wp() {
|
20 |
+
mkdir -p $WP_CORE_DIR
|
21 |
+
|
22 |
+
if [ $WP_VERSION == 'latest' ]; then
|
23 |
+
local ARCHIVE_NAME='latest'
|
24 |
+
else
|
25 |
+
local ARCHIVE_NAME="wordpress-$WP_VERSION"
|
26 |
+
fi
|
27 |
+
|
28 |
+
wget -nv -O /tmp/wordpress.tar.gz http://wordpress.org/${ARCHIVE_NAME}.tar.gz
|
29 |
+
tar --strip-components=1 -zxmf /tmp/wordpress.tar.gz -C $WP_CORE_DIR
|
30 |
+
|
31 |
+
wget -nv -O $WP_CORE_DIR/wp-content/db.php https://raw.github.com/markoheijnen/wp-mysqli/master/db.php
|
32 |
+
}
|
33 |
+
|
34 |
+
install_test_suite() {
|
35 |
+
# portable in-place argument for both GNU sed and Mac OSX sed
|
36 |
+
if [[ $(uname -s) == 'Darwin' ]]; then
|
37 |
+
local ioption='-i ""'
|
38 |
+
else
|
39 |
+
local ioption='-i'
|
40 |
+
fi
|
41 |
+
|
42 |
+
# set up testing suite
|
43 |
+
mkdir -p $WP_TESTS_DIR
|
44 |
+
cd $WP_TESTS_DIR
|
45 |
+
svn co --quiet http://develop.svn.wordpress.org/trunk/tests/phpunit/includes/
|
46 |
+
|
47 |
+
wget -nv -O wp-tests-config.php http://develop.svn.wordpress.org/trunk/wp-tests-config-sample.php
|
48 |
+
sed $ioption "s:dirname( __FILE__ ) . '/src/':'$WP_CORE_DIR':" wp-tests-config.php
|
49 |
+
sed $ioption "s/youremptytestdbnamehere/$DB_NAME/" wp-tests-config.php
|
50 |
+
sed $ioption "s/yourusernamehere/$DB_USER/" wp-tests-config.php
|
51 |
+
sed $ioption "s/yourpasswordhere/$DB_PASS/" wp-tests-config.php
|
52 |
+
sed $ioption "s|localhost|${DB_HOST}|" wp-tests-config.php
|
53 |
+
}
|
54 |
+
|
55 |
+
install_db() {
|
56 |
+
# parse DB_HOST for port or socket references
|
57 |
+
local PARTS=(${DB_HOST//\:/ })
|
58 |
+
local DB_HOSTNAME=${PARTS[0]};
|
59 |
+
local DB_SOCK_OR_PORT=${PARTS[1]};
|
60 |
+
local EXTRA=""
|
61 |
+
|
62 |
+
if ! [ -z $DB_HOSTNAME ] ; then
|
63 |
+
if [[ "$DB_SOCK_OR_PORT" =~ ^[0-9]+$ ]] ; then
|
64 |
+
EXTRA=" --host=$DB_HOSTNAME --port=$DB_SOCK_OR_PORT --protocol=tcp"
|
65 |
+
elif ! [ -z $DB_SOCK_OR_PORT ] ; then
|
66 |
+
EXTRA=" --socket=$DB_SOCK_OR_PORT"
|
67 |
+
elif ! [ -z $DB_HOSTNAME ] ; then
|
68 |
+
EXTRA=" --host=$DB_HOSTNAME --protocol=tcp"
|
69 |
+
fi
|
70 |
+
fi
|
71 |
+
|
72 |
+
# create database
|
73 |
+
mysqladmin create $DB_NAME --user="$DB_USER" --password="$DB_PASS"$EXTRA
|
74 |
+
}
|
75 |
+
|
76 |
+
install_wp
|
77 |
+
install_test_suite
|
78 |
+
install_db
|
vendor/upstatement/routes/composer.json
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"name" : "upstatement/routes",
|
3 |
+
"description": "Manage rewrites and routes in WordPress with this dead-simple plugin",
|
4 |
+
"keywords" : ["routes", "routing", "rewrite", "redirects"],
|
5 |
+
"homepage" : "http://routes.upstatement.com",
|
6 |
+
"license" : "MIT",
|
7 |
+
"authors" : [
|
8 |
+
{
|
9 |
+
"name" : "Jared Novack",
|
10 |
+
"email" : "jared@upstatement.com",
|
11 |
+
"homepage": "http://upstatement.com"
|
12 |
+
}
|
13 |
+
],
|
14 |
+
"support" : {
|
15 |
+
"issues": "https://github.com/jarednova/routes/issues",
|
16 |
+
"wiki" : "https://github.com/jarednova/routes/wiki",
|
17 |
+
"source": "https://github.com/jarednova/routes"
|
18 |
+
},
|
19 |
+
"require" : {
|
20 |
+
"php" : ">=5.3.0",
|
21 |
+
"altorouter/altorouter" : "1.1.0",
|
22 |
+
"composer/installers" : "~1.0"
|
23 |
+
},
|
24 |
+
"require-dev": {
|
25 |
+
"phpunit/phpunit": "3.7.*",
|
26 |
+
"wp-cli/wp-cli" : "*",
|
27 |
+
"satooshi/php-coveralls": "dev-master"
|
28 |
+
},
|
29 |
+
"autoload": {
|
30 |
+
"psr-0" : {
|
31 |
+
"Routes" : ""
|
32 |
+
}
|
33 |
+
}
|
34 |
+
}
|
vendor/upstatement/routes/composer.lock
ADDED
@@ -0,0 +1,1374 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
{
|
2 |
+
"_readme": [
|
3 |
+
"This file locks the dependencies of your project to a known state",
|
4 |
+
"Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file",
|
5 |
+
"This file is @generated automatically"
|
6 |
+
],
|
7 |
+
"hash": "75d030ab793ba313e61990602d982498",
|
8 |
+
"packages": [
|
9 |
+
{
|
10 |
+
"name": "altorouter/altorouter",
|
11 |
+
"version": "v1.1.0",
|
12 |
+
"source": {
|
13 |
+
"type": "git",
|
14 |
+
"url": "https://github.com/dannyvankooten/AltoRouter.git",
|
15 |
+
"reference": "09d9d946c546bae6d22a7654cdb3b825ffda54b4"
|
16 |
+
},
|
17 |
+
"dist": {
|
18 |
+
"type": "zip",
|
19 |
+
"url": "https://api.github.com/repos/dannyvankooten/AltoRouter/zipball/09d9d946c546bae6d22a7654cdb3b825ffda54b4",
|
20 |
+
"reference": "09d9d946c546bae6d22a7654cdb3b825ffda54b4",
|
21 |
+
"shasum": ""
|
22 |
+
},
|
23 |
+
"require": {
|
24 |
+
"php": ">=5.3.0"
|
25 |
+
},
|
26 |
+
"type": "library",
|
27 |
+
"autoload": {
|
28 |
+
"classmap": [
|
29 |
+
"AltoRouter.php"
|
30 |
+
]
|
31 |
+
},
|
32 |
+
"notification-url": "https://packagist.org/downloads/",
|
33 |
+
"license": [
|
34 |
+
"MIT"
|
35 |
+
],
|
36 |
+
"authors": [
|
37 |
+
{
|
38 |
+
"name": "Danny van Kooten",
|
39 |
+
"email": "dannyvankooten@gmail.com",
|
40 |
+
"homepage": "http://dannyvankooten.com/"
|
41 |
+
},
|
42 |
+
{
|
43 |
+
"name": "Koen Punt",
|
44 |
+
"homepage": "https://github.com/koenpunt"
|
45 |
+
},
|
46 |
+
{
|
47 |
+
"name": "niahoo",
|
48 |
+
"homepage": "https://github.com/niahoo"
|
49 |
+
}
|
50 |
+
],
|
51 |
+
"description": "A lightning fast router for PHP",
|
52 |
+
"homepage": "https://github.com/dannyvankooten/AltoRouter",
|
53 |
+
"keywords": [
|
54 |
+
"lightweight",
|
55 |
+
"router",
|
56 |
+
"routing"
|
57 |
+
],
|
58 |
+
"time": "2014-04-16 09:44:40"
|
59 |
+
},
|
60 |
+
{
|
61 |
+
"name": "composer/installers",
|
62 |
+
"version": "v1.0.21",
|
63 |
+
"source": {
|
64 |
+
"type": "git",
|
65 |
+
"url": "https://github.com/composer/installers.git",
|
66 |
+
"reference": "d64e23fce42a4063d63262b19b8e7c0f3b5e4c45"
|
67 |
+
},
|
68 |
+
"dist": {
|
69 |
+
"type": "zip",
|
70 |
+
"url": "https://api.github.com/repos/composer/installers/zipball/d64e23fce42a4063d63262b19b8e7c0f3b5e4c45",
|
71 |
+
"reference": "d64e23fce42a4063d63262b19b8e7c0f3b5e4c45",
|
72 |
+
"shasum": ""
|
73 |
+
},
|
74 |
+
"replace": {
|
75 |
+
"roundcube/plugin-installer": "*",
|
76 |
+
"shama/baton": "*"
|
77 |
+
},
|
78 |
+
"require-dev": {
|
79 |
+
"composer/composer": "1.0.*@dev",
|
80 |
+
"phpunit/phpunit": "4.1.*"
|
81 |
+
},
|
82 |
+
"type": "composer-installer",
|
83 |
+
"extra": {
|
84 |
+
"class": "Composer\\Installers\\Installer",
|
85 |
+
"branch-alias": {
|
86 |
+
"dev-master": "1.0-dev"
|
87 |
+
}
|
88 |
+
},
|
89 |
+
"autoload": {
|
90 |
+
"psr-0": {
|
91 |
+
"Composer\\Installers\\": "src/"
|
92 |
+
}
|
93 |
+
},
|
94 |
+
"notification-url": "https://packagist.org/downloads/",
|
95 |
+
"license": [
|
96 |
+
"MIT"
|
97 |
+
],
|
98 |
+
"authors": [
|
99 |
+
{
|
100 |
+
"name": "Kyle Robinson Young",
|
101 |
+
"email": "kyle@dontkry.com",
|
102 |
+
"homepage": "https://github.com/shama"
|
103 |
+
}
|
104 |
+
],
|
105 |
+
"description": "A multi-framework Composer library installer",
|
106 |
+
"homepage": "http://composer.github.com/installers/",
|
107 |
+
"keywords": [
|
108 |
+
"Craft",
|
109 |
+
"Dolibarr",
|
110 |
+
"Hurad",
|
111 |
+
"MODX Evo",
|
112 |
+
"OXID",
|
113 |
+
"SMF",
|
114 |
+
"Thelia",
|
115 |
+
"WolfCMS",
|
116 |
+
"agl",
|
117 |
+
"aimeos",
|
118 |
+
"annotatecms",
|
119 |
+
"bitrix",
|
120 |
+
"cakephp",
|
121 |
+
"chef",
|
122 |
+
"codeigniter",
|
123 |
+
"concrete5",
|
124 |
+
"croogo",
|
125 |
+
"dokuwiki",
|
126 |
+
"drupal",
|
127 |
+
"elgg",
|
128 |
+
"fuelphp",
|
129 |
+
"grav",
|
130 |
+
"installer",
|
131 |
+
"joomla",
|
132 |
+
"kohana",
|
133 |
+
"laravel",
|
134 |
+
"lithium",
|
135 |
+
"magento",
|
136 |
+
"mako",
|
137 |
+
"mediawiki",
|
138 |
+
"modulework",
|
139 |
+
"moodle",
|
140 |
+
"phpbb",
|
141 |
+
"piwik",
|
142 |
+
"ppi",
|
143 |
+
"puppet",
|
144 |
+
"roundcube",
|
145 |
+
"shopware",
|
146 |
+
"silverstripe",
|
147 |
+
"symfony",
|
148 |
+
"typo3",
|
149 |
+
"wordpress",
|
150 |
+
"zend",
|
151 |
+
"zikula"
|
152 |
+
],
|
153 |
+
"time": "2015-02-18 17:17:01"
|
154 |
+
}
|
155 |
+
],
|
156 |
+
"packages-dev": [
|
157 |
+
{
|
158 |
+
"name": "guzzle/guzzle",
|
159 |
+
"version": "v3.9.2",
|
160 |
+
"source": {
|
161 |
+
"type": "git",
|
162 |
+
"url": "https://github.com/guzzle/guzzle3.git",
|
163 |
+
"reference": "54991459675c1a2924122afbb0e5609ade581155"
|
164 |
+
},
|
165 |
+
"dist": {
|
166 |
+
"type": "zip",
|
167 |
+
"url": "https://api.github.com/repos/guzzle/guzzle3/zipball/54991459675c1a2924122afbb0e5609ade581155",
|
168 |
+
"reference": "54991459675c1a2924122afbb0e5609ade581155",
|
169 |
+
"shasum": ""
|
170 |
+
},
|
171 |
+
"require": {
|
172 |
+
"ext-curl": "*",
|
173 |
+
"php": ">=5.3.3",
|
174 |
+
"symfony/event-dispatcher": "~2.1"
|
175 |
+
},
|
176 |
+
"replace": {
|
177 |
+
"guzzle/batch": "self.version",
|
178 |
+
"guzzle/cache": "self.version",
|
179 |
+
"guzzle/common": "self.version",
|
180 |
+
"guzzle/http": "self.version",
|
181 |
+
"guzzle/inflection": "self.version",
|
182 |
+
"guzzle/iterator": "self.version",
|
183 |
+
"guzzle/log": "self.version",
|
184 |
+
"guzzle/parser": "self.version",
|
185 |
+
"guzzle/plugin": "self.version",
|
186 |
+
"guzzle/plugin-async": "self.version",
|
187 |
+
"guzzle/plugin-backoff": "self.version",
|
188 |
+
"guzzle/plugin-cache": "self.version",
|
189 |
+
"guzzle/plugin-cookie": "self.version",
|
190 |
+
"guzzle/plugin-curlauth": "self.version",
|
191 |
+
"guzzle/plugin-error-response": "self.version",
|
192 |
+
"guzzle/plugin-history": "self.version",
|
193 |
+
"guzzle/plugin-log": "self.version",
|
194 |
+
"guzzle/plugin-md5": "self.version",
|
195 |
+
"guzzle/plugin-mock": "self.version",
|
196 |
+
"guzzle/plugin-oauth": "self.version",
|
197 |
+
"guzzle/service": "self.version",
|
198 |
+
"guzzle/stream": "self.version"
|
199 |
+
},
|
200 |
+
"require-dev": {
|
201 |
+
"doctrine/cache": "~1.3",
|
202 |
+
"monolog/monolog": "~1.0",
|
203 |
+
"phpunit/phpunit": "3.7.*",
|
204 |
+
"psr/log": "~1.0",
|
205 |
+
"symfony/class-loader": "~2.1",
|
206 |
+
"zendframework/zend-cache": "2.*,<2.3",
|
207 |
+
"zendframework/zend-log": "2.*,<2.3"
|
208 |
+
},
|
209 |
+
"type": "library",
|
210 |
+
"extra": {
|
211 |
+
"branch-alias": {
|
212 |
+
"dev-master": "3.9-dev"
|
213 |
+
}
|
214 |
+
},
|
215 |
+
"autoload": {
|
216 |
+
"psr-0": {
|
217 |
+
"Guzzle": "src/",
|
218 |
+
"Guzzle\\Tests": "tests/"
|
219 |
+
}
|
220 |
+
},
|
221 |
+
"notification-url": "https://packagist.org/downloads/",
|
222 |
+
"license": [
|
223 |
+
"MIT"
|
224 |
+
],
|
225 |
+
"authors": [
|
226 |
+
{
|
227 |
+
"name": "Michael Dowling",
|
228 |
+
"email": "mtdowling@gmail.com",
|
229 |
+
"homepage": "https://github.com/mtdowling"
|
230 |
+
},
|
231 |
+
{
|
232 |
+
"name": "Guzzle Community",
|
233 |
+
"homepage": "https://github.com/guzzle/guzzle/contributors"
|
234 |
+
}
|
235 |
+
],
|
236 |
+
"description": "Guzzle is a PHP HTTP client library and framework for building RESTful web service clients",
|
237 |
+
"homepage": "http://guzzlephp.org/",
|
238 |
+
"keywords": [
|
239 |
+
"client",
|
240 |
+
"curl",
|
241 |
+
"framework",
|
242 |
+
"http",
|
243 |
+
"http client",
|
244 |
+
"rest",
|
245 |
+
"web service"
|
246 |
+
],
|
247 |
+
"time": "2014-08-11 04:32:36"
|
248 |
+
},
|
249 |
+
{
|
250 |
+
"name": "mustache/mustache",
|
251 |
+
"version": "v2.7.0",
|
252 |
+
"source": {
|
253 |
+
"type": "git",
|
254 |
+
"url": "https://github.com/bobthecow/mustache.php.git",
|
255 |
+
"reference": "fdf41dd673dc99b41d60992470dbae94ae0b6ba1"
|
256 |
+
},
|
257 |
+
"dist": {
|
258 |
+
"type": "zip",
|
259 |
+
"url": "https://api.github.com/repos/bobthecow/mustache.php/zipball/fdf41dd673dc99b41d60992470dbae94ae0b6ba1",
|
260 |
+
"reference": "fdf41dd673dc99b41d60992470dbae94ae0b6ba1",
|
261 |
+
"shasum": ""
|
262 |
+
},
|
263 |
+
"require": {
|
264 |
+
"php": ">=5.2.4"
|
265 |
+
},
|
266 |
+
"require-dev": {
|
267 |
+
"phpunit/phpunit": "*"
|
268 |
+
},
|
269 |
+
"type": "library",
|
270 |
+
"autoload": {
|
271 |
+
"psr-0": {
|
272 |
+
"Mustache": "src/"
|
273 |
+
}
|
274 |
+
},
|
275 |
+
"notification-url": "https://packagist.org/downloads/",
|
276 |
+
"license": [
|
277 |
+
"MIT"
|
278 |
+
],
|
279 |
+
"authors": [
|
280 |
+
{
|
281 |
+
"name": "Justin Hileman",
|
282 |
+
"email": "justin@justinhileman.info",
|
283 |
+
"homepage": "http://justinhileman.com"
|
284 |
+
}
|
285 |
+
],
|
286 |
+
"description": "A Mustache implementation in PHP.",
|
287 |
+
"homepage": "https://github.com/bobthecow/mustache.php",
|
288 |
+
"keywords": [
|
289 |
+
"mustache",
|
290 |
+
"templating"
|
291 |
+
],
|
292 |
+
"time": "2014-08-26 19:50:10"
|
293 |
+
},
|
294 |
+
{
|
295 |
+
"name": "nb/oxymel",
|
296 |
+
"version": "v0.1.0",
|
297 |
+
"source": {
|
298 |
+
"type": "git",
|
299 |
+
"url": "https://github.com/nb/oxymel.git",
|
300 |
+
"reference": "cbe626ef55d5c4cc9b5e6e3904b395861ea76e3c"
|
301 |
+
},
|
302 |
+
"dist": {
|
303 |
+
"type": "zip",
|
304 |
+
"url": "https://api.github.com/repos/nb/oxymel/zipball/cbe626ef55d5c4cc9b5e6e3904b395861ea76e3c",
|
305 |
+
"reference": "cbe626ef55d5c4cc9b5e6e3904b395861ea76e3c",
|
306 |
+
"shasum": ""
|
307 |
+
},
|
308 |
+
"require": {
|
309 |
+
"php": ">=5.2.4"
|
310 |
+
},
|
311 |
+
"type": "library",
|
312 |
+
"autoload": {
|
313 |
+
"psr-0": {
|
314 |
+
"Oxymel": ""
|
315 |
+
}
|
316 |
+
},
|
317 |
+
"notification-url": "https://packagist.org/downloads/",
|
318 |
+
"license": [
|
319 |
+
"MIT"
|
320 |
+
],
|
321 |
+
"authors": [
|
322 |
+
{
|
323 |
+
"name": "Nikolay Bachiyski",
|
324 |
+
"email": "nb@nikolay.bg",
|
325 |
+
"homepage": "http://extrapolate.me/"
|
326 |
+
}
|
327 |
+
],
|
328 |
+
"description": "A sweet XML builder",
|
329 |
+
"homepage": "https://github.com/nb/oxymel",
|
330 |
+
"keywords": [
|
331 |
+
"xml"
|
332 |
+
],
|
333 |
+
"time": "2013-02-24 15:01:54"
|
334 |
+
},
|
335 |
+
{
|
336 |
+
"name": "phpunit/php-code-coverage",
|
337 |
+
"version": "1.2.18",
|
338 |
+
"source": {
|
339 |
+
"type": "git",
|
340 |
+
"url": "https://github.com/sebastianbergmann/php-code-coverage.git",
|
341 |
+
"reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b"
|
342 |
+
},
|
343 |
+
"dist": {
|
344 |
+
"type": "zip",
|
345 |
+
"url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b",
|
346 |
+
"reference": "fe2466802556d3fe4e4d1d58ffd3ccfd0a19be0b",
|
347 |
+
"shasum": ""
|
348 |
+
},
|
349 |
+
"require": {
|
350 |
+
"php": ">=5.3.3",
|
351 |
+
"phpunit/php-file-iterator": ">=1.3.0@stable",
|
352 |
+
"phpunit/php-text-template": ">=1.2.0@stable",
|
353 |
+
"phpunit/php-token-stream": ">=1.1.3,<1.3.0"
|
354 |
+
},
|
355 |
+
"require-dev": {
|
356 |
+
"phpunit/phpunit": "3.7.*@dev"
|
357 |
+
},
|
358 |
+
"suggest": {
|
359 |
+
"ext-dom": "*",
|
360 |
+
"ext-xdebug": ">=2.0.5"
|
361 |
+
},
|
362 |
+
"type": "library",
|
363 |
+
"extra": {
|
364 |
+
"branch-alias": {
|
365 |
+
"dev-master": "1.2.x-dev"
|
366 |
+
}
|
367 |
+
},
|
368 |
+
"autoload": {
|
369 |
+
"classmap": [
|
370 |
+
"PHP/"
|
371 |
+
]
|
372 |
+
},
|
373 |
+
"notification-url": "https://packagist.org/downloads/",
|
374 |
+
"include-path": [
|
375 |
+
""
|
376 |
+
],
|
377 |
+
"license": [
|
378 |
+
"BSD-3-Clause"
|
379 |
+
],
|
380 |
+
"authors": [
|
381 |
+
{
|
382 |
+
"name": "Sebastian Bergmann",
|
383 |
+
"email": "sb@sebastian-bergmann.de",
|
384 |
+
"role": "lead"
|
385 |
+
}
|
386 |
+
],
|
387 |
+
"description": "Library that provides collection, processing, and rendering functionality for PHP code coverage information.",
|
388 |
+
"homepage": "https://github.com/sebastianbergmann/php-code-coverage",
|
389 |
+
"keywords": [
|
390 |
+
"coverage",
|
391 |
+
"testing",
|
392 |
+
"xunit"
|
393 |
+
],
|
394 |
+
"time": "2014-09-02 10:13:14"
|
395 |
+
},
|
396 |
+
{
|
397 |
+
"name": "phpunit/php-file-iterator",
|
398 |
+
"version": "1.3.4",
|
399 |
+
"source": {
|
400 |
+
"type": "git",
|
401 |
+
"url": "https://github.com/sebastianbergmann/php-file-iterator.git",
|
402 |
+
"reference": "acd690379117b042d1c8af1fafd61bde001bf6bb"
|
403 |
+
},
|
404 |
+
"dist": {
|
405 |
+
"type": "zip",
|
406 |
+
"url": "https://api.github.com/repos/sebastianbergmann/php-file-iterator/zipball/acd690379117b042d1c8af1fafd61bde001bf6bb",
|
407 |
+
"reference": "acd690379117b042d1c8af1fafd61bde001bf6bb",
|
408 |
+
"shasum": ""
|
409 |
+
},
|
410 |
+
"require": {
|
411 |
+
"php": ">=5.3.3"
|
412 |
+
},
|
413 |
+
"type": "library",
|
414 |
+
"autoload": {
|
415 |
+
"classmap": [
|
416 |
+
"File/"
|
417 |
+
]
|
418 |
+
},
|
419 |
+
"notification-url": "https://packagist.org/downloads/",
|
420 |
+
"include-path": [
|
421 |
+
""
|
422 |
+
],
|
423 |
+
"license": [
|
424 |
+
"BSD-3-Clause"
|
425 |
+
],
|
426 |
+
"authors": [
|
427 |
+
{
|
428 |
+
"name": "Sebastian Bergmann",
|
429 |
+
"email": "sb@sebastian-bergmann.de",
|
430 |
+
"role": "lead"
|
431 |
+
}
|
432 |
+
],
|
433 |
+
"description": "FilterIterator implementation that filters files based on a list of suffixes.",
|
434 |
+
"homepage": "https://github.com/sebastianbergmann/php-file-iterator/",
|
435 |
+
"keywords": [
|
436 |
+
"filesystem",
|
437 |
+
"iterator"
|
438 |
+
],
|
439 |
+
"time": "2013-10-10 15:34:57"
|
440 |
+
},
|
441 |
+
{
|
442 |
+
"name": "phpunit/php-text-template",
|
443 |
+
"version": "1.2.0",
|
444 |
+
"source": {
|
445 |
+
"type": "git",
|
446 |
+
"url": "https://github.com/sebastianbergmann/php-text-template.git",
|
447 |
+
"reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a"
|
448 |
+
},
|
449 |
+
"dist": {
|
450 |
+
"type": "zip",
|
451 |
+
"url": "https://api.github.com/repos/sebastianbergmann/php-text-template/zipball/206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
|
452 |
+
"reference": "206dfefc0ffe9cebf65c413e3d0e809c82fbf00a",
|
453 |
+
"shasum": ""
|
454 |
+
},
|
455 |
+
"require": {
|
456 |
+
"php": ">=5.3.3"
|
457 |
+
},
|
458 |
+
"type": "library",
|
459 |
+
"autoload": {
|
460 |
+
"classmap": [
|
461 |
+
"Text/"
|
462 |
+
]
|
463 |
+
},
|
464 |
+
"notification-url": "https://packagist.org/downloads/",
|
465 |
+
"include-path": [
|
466 |
+
""
|
467 |
+
],
|
468 |
+
"license": [
|
469 |
+
"BSD-3-Clause"
|
470 |
+
],
|
471 |
+
"authors": [
|
472 |
+
{
|
473 |
+
"name": "Sebastian Bergmann",
|
474 |
+
"email": "sb@sebastian-bergmann.de",
|
475 |
+
"role": "lead"
|
476 |
+
}
|
477 |
+
],
|
478 |
+
"description": "Simple template engine.",
|
479 |
+
"homepage": "https://github.com/sebastianbergmann/php-text-template/",
|
480 |
+
"keywords": [
|
481 |
+
"template"
|
482 |
+
],
|
483 |
+
"time": "2014-01-30 17:20:04"
|
484 |
+
},
|
485 |
+
{
|
486 |
+
"name": "phpunit/php-timer",
|
487 |
+
"version": "1.0.5",
|
488 |
+
"source": {
|
489 |
+
"type": "git",
|
490 |
+
"url": "https://github.com/sebastianbergmann/php-timer.git",
|
491 |
+
"reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c"
|
492 |
+
},
|
493 |
+
"dist": {
|
494 |
+
"type": "zip",
|
495 |
+
"url": "https://api.github.com/repos/sebastianbergmann/php-timer/zipball/19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
|
496 |
+
"reference": "19689d4354b295ee3d8c54b4f42c3efb69cbc17c",
|
497 |
+
"shasum": ""
|
498 |
+
},
|
499 |
+
"require": {
|
500 |
+
"php": ">=5.3.3"
|
501 |
+
},
|
502 |
+
"type": "library",
|
503 |
+
"autoload": {
|
504 |
+
"classmap": [
|
505 |
+
"PHP/"
|
506 |
+
]
|
507 |
+
},
|
508 |
+
"notification-url": "https://packagist.org/downloads/",
|
509 |
+
"include-path": [
|
510 |
+
""
|
511 |
+
],
|
512 |
+
"license": [
|
513 |
+
"BSD-3-Clause"
|
514 |
+
],
|
515 |
+
"authors": [
|
516 |
+
{
|
517 |
+
"name": "Sebastian Bergmann",
|
518 |
+
"email": "sb@sebastian-bergmann.de",
|
519 |
+
"role": "lead"
|
520 |
+
}
|
521 |
+
],
|
522 |
+
"description": "Utility class for timing",
|
523 |
+
"homepage": "https://github.com/sebastianbergmann/php-timer/",
|
524 |
+
"keywords": [
|
525 |
+
"timer"
|
526 |
+
],
|
527 |
+
"time": "2013-08-02 07:42:54"
|
528 |
+
},
|
529 |
+
{
|
530 |
+
"name": "phpunit/php-token-stream",
|
531 |
+
"version": "1.2.2",
|
532 |
+
"source": {
|
533 |
+
"type": "git",
|
534 |
+
"url": "https://github.com/sebastianbergmann/php-token-stream.git",
|
535 |
+
"reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32"
|
536 |
+
},
|
537 |
+
"dist": {
|
538 |
+
"type": "zip",
|
539 |
+
"url": "https://api.github.com/repos/sebastianbergmann/php-token-stream/zipball/ad4e1e23ae01b483c16f600ff1bebec184588e32",
|
540 |
+
"reference": "ad4e1e23ae01b483c16f600ff1bebec184588e32",
|
541 |
+
"shasum": ""
|
542 |
+
},
|
543 |
+
"require": {
|
544 |
+
"ext-tokenizer": "*",
|
545 |
+
"php": ">=5.3.3"
|
546 |
+
},
|
547 |
+
"type": "library",
|
548 |
+
"extra": {
|
549 |
+
"branch-alias": {
|
550 |
+
"dev-master": "1.2-dev"
|
551 |
+
}
|
552 |
+
},
|
553 |
+
"autoload": {
|
554 |
+
"classmap": [
|
555 |
+
"PHP/"
|
556 |
+
]
|
557 |
+
},
|
558 |
+
"notification-url": "https://packagist.org/downloads/",
|
559 |
+
"include-path": [
|
560 |
+
""
|
561 |
+
],
|
562 |
+
"license": [
|
563 |
+
"BSD-3-Clause"
|
564 |
+
],
|
565 |
+
"authors": [
|
566 |
+
{
|
567 |
+
"name": "Sebastian Bergmann",
|
568 |
+
"email": "sb@sebastian-bergmann.de",
|
569 |
+
"role": "lead"
|
570 |
+
}
|
571 |
+
],
|
572 |
+
"description": "Wrapper around PHP's tokenizer extension.",
|
573 |
+
"homepage": "https://github.com/sebastianbergmann/php-token-stream/",
|
574 |
+
"keywords": [
|
575 |
+
"tokenizer"
|
576 |
+
],
|
577 |
+
"time": "2014-03-03 05:10:30"
|
578 |
+
},
|
579 |
+
{
|
580 |
+
"name": "phpunit/phpunit",
|
581 |
+
"version": "3.7.38",
|
582 |
+
"source": {
|
583 |
+
"type": "git",
|
584 |
+
"url": "https://github.com/sebastianbergmann/phpunit.git",
|
585 |
+
"reference": "38709dc22d519a3d1be46849868aa2ddf822bcf6"
|
586 |
+
},
|
587 |
+
"dist": {
|
588 |
+
"type": "zip",
|
589 |
+
"url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/38709dc22d519a3d1be46849868aa2ddf822bcf6",
|
590 |
+
"reference": "38709dc22d519a3d1be46849868aa2ddf822bcf6",
|
591 |
+
"shasum": ""
|
592 |
+
},
|
593 |
+
"require": {
|
594 |
+
"ext-ctype": "*",
|
595 |
+
"ext-dom": "*",
|
596 |
+
"ext-json": "*",
|
597 |
+
"ext-pcre": "*",
|
598 |
+
"ext-reflection": "*",
|
599 |
+
"ext-spl": "*",
|
600 |
+
"php": ">=5.3.3",
|
601 |
+
"phpunit/php-code-coverage": "~1.2",
|
602 |
+
"phpunit/php-file-iterator": "~1.3",
|
603 |
+
"phpunit/php-text-template": "~1.1",
|
604 |
+
"phpunit/php-timer": "~1.0",
|
605 |
+
"phpunit/phpunit-mock-objects": "~1.2",
|
606 |
+
"symfony/yaml": "~2.0"
|
607 |
+
},
|
608 |
+
"require-dev": {
|
609 |
+
"pear-pear.php.net/pear": "1.9.4"
|
610 |
+
},
|
611 |
+
"suggest": {
|
612 |
+
"phpunit/php-invoker": "~1.1"
|
613 |
+
},
|
614 |
+
"bin": [
|
615 |
+
"composer/bin/phpunit"
|
616 |
+
],
|
617 |
+
"type": "library",
|
618 |
+
"extra": {
|
619 |
+
"branch-alias": {
|
620 |
+
"dev-master": "3.7.x-dev"
|
621 |
+
}
|
622 |
+
},
|
623 |
+
"autoload": {
|
624 |
+
"classmap": [
|
625 |
+
"PHPUnit/"
|
626 |
+
]
|
627 |
+
},
|
628 |
+
"notification-url": "https://packagist.org/downloads/",
|
629 |
+
"include-path": [
|
630 |
+
"",
|
631 |
+
"../../symfony/yaml/"
|
632 |
+
],
|
633 |
+
"license": [
|
634 |
+
"BSD-3-Clause"
|
635 |
+
],
|
636 |
+
"authors": [
|
637 |
+
{
|
638 |
+
"name": "Sebastian Bergmann",
|
639 |
+
"email": "sebastian@phpunit.de",
|
640 |
+
"role": "lead"
|
641 |
+
}
|
642 |
+
],
|
643 |
+
"description": "The PHP Unit Testing framework.",
|
644 |
+
"homepage": "http://www.phpunit.de/",
|
645 |
+
"keywords": [
|
646 |
+
"phpunit",
|
647 |
+
"testing",
|
648 |
+
"xunit"
|
649 |
+
],
|
650 |
+
"time": "2014-10-17 09:04:17"
|
651 |
+
},
|
652 |
+
{
|
653 |
+
"name": "phpunit/phpunit-mock-objects",
|
654 |
+
"version": "1.2.3",
|
655 |
+
"source": {
|
656 |
+
"type": "git",
|
657 |
+
"url": "https://github.com/sebastianbergmann/phpunit-mock-objects.git",
|
658 |
+
"reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875"
|
659 |
+
},
|
660 |
+
"dist": {
|
661 |
+
"type": "zip",
|
662 |
+
"url": "https://api.github.com/repos/sebastianbergmann/phpunit-mock-objects/zipball/5794e3c5c5ba0fb037b11d8151add2a07fa82875",
|
663 |
+
"reference": "5794e3c5c5ba0fb037b11d8151add2a07fa82875",
|
664 |
+
"shasum": ""
|
665 |
+
},
|
666 |
+
"require": {
|
667 |
+
"php": ">=5.3.3",
|
668 |
+
"phpunit/php-text-template": ">=1.1.1@stable"
|
669 |
+
},
|
670 |
+
"suggest": {
|
671 |
+
"ext-soap": "*"
|
672 |
+
},
|
673 |
+
"type": "library",
|
674 |
+
"autoload": {
|
675 |
+
"classmap": [
|
676 |
+
"PHPUnit/"
|
677 |
+
]
|
678 |
+
},
|
679 |
+
"notification-url": "https://packagist.org/downloads/",
|
680 |
+
"include-path": [
|
681 |
+
""
|
682 |
+
],
|
683 |
+
"license": [
|
684 |
+
"BSD-3-Clause"
|
685 |
+
],
|
686 |
+
"authors": [
|
687 |
+
{
|
688 |
+
"name": "Sebastian Bergmann",
|
689 |
+
"email": "sb@sebastian-bergmann.de",
|
690 |
+
"role": "lead"
|
691 |
+
}
|
692 |
+
],
|
693 |
+
"description": "Mock Object library for PHPUnit",
|
694 |
+
"homepage": "https://github.com/sebastianbergmann/phpunit-mock-objects/",
|
695 |
+
"keywords": [
|
696 |
+
"mock",
|
697 |
+
"xunit"
|
698 |
+
],
|
699 |
+
"time": "2013-01-13 10:24:48"
|
700 |
+
},
|
701 |
+
{
|
702 |
+
"name": "psr/log",
|
703 |
+
"version": "1.0.0",
|
704 |
+
"source": {
|
705 |
+
"type": "git",
|
706 |
+
"url": "https://github.com/php-fig/log.git",
|
707 |
+
"reference": "fe0936ee26643249e916849d48e3a51d5f5e278b"
|
708 |
+
},
|
709 |
+
"dist": {
|
710 |
+
"type": "zip",
|
711 |
+
"url": "https://api.github.com/repos/php-fig/log/zipball/fe0936ee26643249e916849d48e3a51d5f5e278b",
|
712 |
+
"reference": "fe0936ee26643249e916849d48e3a51d5f5e278b",
|
713 |
+
"shasum": ""
|
714 |
+
},
|
715 |
+
"type": "library",
|
716 |
+
"autoload": {
|
717 |
+
"psr-0": {
|
718 |
+
"Psr\\Log\\": ""
|
719 |
+
}
|
720 |
+
},
|
721 |
+
"notification-url": "https://packagist.org/downloads/",
|
722 |
+
"license": [
|
723 |
+
"MIT"
|
724 |
+
],
|
725 |
+
"authors": [
|
726 |
+
{
|
727 |
+
"name": "PHP-FIG",
|
728 |
+
"homepage": "http://www.php-fig.org/"
|
729 |
+
}
|
730 |
+
],
|
731 |
+
"description": "Common interface for logging libraries",
|
732 |
+
"keywords": [
|
733 |
+
"log",
|
734 |
+
"psr",
|
735 |
+
"psr-3"
|
736 |
+
],
|
737 |
+
"time": "2012-12-21 11:40:51"
|
738 |
+
},
|
739 |
+
{
|
740 |
+
"name": "rhumsaa/array_column",
|
741 |
+
"version": "1.1.2",
|
742 |
+
"source": {
|
743 |
+
"type": "git",
|
744 |
+
"url": "https://github.com/ramsey/array_column.git",
|
745 |
+
"reference": "c09744baae0e023d1021055f9c65755b88a9721f"
|
746 |
+
},
|
747 |
+
"dist": {
|
748 |
+
"type": "zip",
|
749 |
+
"url": "https://api.github.com/repos/ramsey/array_column/zipball/c09744baae0e023d1021055f9c65755b88a9721f",
|
750 |
+
"reference": "c09744baae0e023d1021055f9c65755b88a9721f",
|
751 |
+
"shasum": ""
|
752 |
+
},
|
753 |
+
"type": "library",
|
754 |
+
"autoload": {
|
755 |
+
"files": [
|
756 |
+
"src/array_column.php"
|
757 |
+
]
|
758 |
+
},
|
759 |
+
"notification-url": "https://packagist.org/downloads/",
|
760 |
+
"license": [
|
761 |
+
"MIT"
|
762 |
+
],
|
763 |
+
"authors": [
|
764 |
+
{
|
765 |
+
"name": "Ben Ramsey",
|
766 |
+
"homepage": "http://benramsey.com",
|
767 |
+
"role": "Developer"
|
768 |
+
}
|
769 |
+
],
|
770 |
+
"description": "Provides functionality for array_column() to projects using PHP earlier than version 5.5.",
|
771 |
+
"homepage": "https://github.com/ramsey/array_column",
|
772 |
+
"keywords": [
|
773 |
+
"array",
|
774 |
+
"array_column",
|
775 |
+
"column"
|
776 |
+
],
|
777 |
+
"time": "2013-07-22 16:12:38"
|
778 |
+
},
|
779 |
+
{
|
780 |
+
"name": "rmccue/requests",
|
781 |
+
"version": "v1.6.1",
|
782 |
+
"source": {
|
783 |
+
"type": "git",
|
784 |
+
"url": "https://github.com/rmccue/Requests.git",
|
785 |
+
"reference": "6aac485666c2955077d77b796bbdd25f0013a4ea"
|
786 |
+
},
|
787 |
+
"dist": {
|
788 |
+
"type": "zip",
|
789 |
+
"url": "https://api.github.com/repos/rmccue/Requests/zipball/6aac485666c2955077d77b796bbdd25f0013a4ea",
|
790 |
+
"reference": "6aac485666c2955077d77b796bbdd25f0013a4ea",
|
791 |
+
"shasum": ""
|
792 |
+
},
|
793 |
+
"require": {
|
794 |
+
"php": ">=5.2"
|
795 |
+
},
|
796 |
+
"require-dev": {
|
797 |
+
"satooshi/php-coveralls": "dev-master"
|
798 |
+
},
|
799 |
+
"type": "library",
|
800 |
+
"autoload": {
|
801 |
+
"psr-0": {
|
802 |
+
"Requests": "library/"
|
803 |
+
}
|
804 |
+
},
|
805 |
+
"notification-url": "https://packagist.org/downloads/",
|
806 |
+
"license": [
|
807 |
+
"ISC"
|
808 |
+
],
|
809 |
+
"authors": [
|
810 |
+
{
|
811 |
+
"name": "Ryan McCue",
|
812 |
+
"homepage": "http://ryanmccue.info"
|
813 |
+
}
|
814 |
+
],
|
815 |
+
"description": "A HTTP library written in PHP, for human beings.",
|
816 |
+
"homepage": "http://github.com/rmccue/Requests",
|
817 |
+
"keywords": [
|
818 |
+
"curl",
|
819 |
+
"fsockopen",
|
820 |
+
"http",
|
821 |
+
"idna",
|
822 |
+
"ipv6",
|
823 |
+
"iri",
|
824 |
+
"sockets"
|
825 |
+
],
|
826 |
+
"time": "2014-05-18 04:59:02"
|
827 |
+
},
|
828 |
+
{
|
829 |
+
"name": "satooshi/php-coveralls",
|
830 |
+
"version": "dev-master",
|
831 |
+
"source": {
|
832 |
+
"type": "git",
|
833 |
+
"url": "https://github.com/satooshi/php-coveralls.git",
|
834 |
+
"reference": "2fbf803803d179ab1082807308a67bbd5a760c70"
|
835 |
+
},
|
836 |
+
"dist": {
|
837 |
+
"type": "zip",
|
838 |
+
"url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/2fbf803803d179ab1082807308a67bbd5a760c70",
|
839 |
+
"reference": "2fbf803803d179ab1082807308a67bbd5a760c70",
|
840 |
+
"shasum": ""
|
841 |
+
},
|
842 |
+
"require": {
|
843 |
+
"ext-json": "*",
|
844 |
+
"ext-simplexml": "*",
|
845 |
+
"guzzle/guzzle": ">=2.7",
|
846 |
+
"php": ">=5.3",
|
847 |
+
"psr/log": "1.0.0",
|
848 |
+
"symfony/config": ">=2.0",
|
849 |
+
"symfony/console": ">=2.0",
|
850 |
+
"symfony/stopwatch": ">=2.2",
|
851 |
+
"symfony/yaml": ">=2.0"
|
852 |
+
},
|
853 |
+
"require-dev": {
|
854 |
+
"apigen/apigen": "2.8.*@stable",
|
855 |
+
"pdepend/pdepend": "dev-master as 2.0.0",
|
856 |
+
"phpmd/phpmd": "dev-master",
|
857 |
+
"phpunit/php-invoker": ">=1.1.0,<1.2.0",
|
858 |
+
"phpunit/phpunit": "3.7.*@stable",
|
859 |
+
"sebastian/finder-facade": "dev-master",
|
860 |
+
"sebastian/phpcpd": "1.4.*@stable",
|
861 |
+
"squizlabs/php_codesniffer": "1.4.*@stable",
|
862 |
+
"theseer/fdomdocument": "dev-master"
|
863 |
+
},
|
864 |
+
"suggest": {
|
865 |
+
"symfony/http-kernel": "Allows Symfony integration"
|
866 |
+
},
|
867 |
+
"bin": [
|
868 |
+
"composer/bin/coveralls"
|
869 |
+
],
|
870 |
+
"type": "library",
|
871 |
+
"extra": {
|
872 |
+
"branch-alias": {
|
873 |
+
"dev-master": "0.7-dev"
|
874 |
+
}
|
875 |
+
},
|
876 |
+
"autoload": {
|
877 |
+
"psr-0": {
|
878 |
+
"Satooshi\\Component": "src/",
|
879 |
+
"Satooshi\\Bundle": "src/"
|
880 |
+
}
|
881 |
+
},
|
882 |
+
"notification-url": "https://packagist.org/downloads/",
|
883 |
+
"license": [
|
884 |
+
"MIT"
|
885 |
+
],
|
886 |
+
"authors": [
|
887 |
+
{
|
888 |
+
"name": "Kitamura Satoshi",
|
889 |
+
"email": "with.no.parachute@gmail.com",
|
890 |
+
"homepage": "https://www.facebook.com/satooshi.jp"
|
891 |
+
}
|
892 |
+
],
|
893 |
+
"description": "PHP client library for Coveralls API",
|
894 |
+
"homepage": "https://github.com/satooshi/php-coveralls",
|
895 |
+
"keywords": [
|
896 |
+
"ci",
|
897 |
+
"coverage",
|
898 |
+
"github",
|
899 |
+
"test"
|
900 |
+
],
|
901 |
+
"time": "2014-11-11 15:35:34"
|
902 |
+
},
|
903 |
+
{
|
904 |
+
"name": "symfony/config",
|
905 |
+
"version": "v2.6.4",
|
906 |
+
"target-dir": "Symfony/Component/Config",
|
907 |
+
"source": {
|
908 |
+
"type": "git",
|
909 |
+
"url": "https://github.com/symfony/Config.git",
|
910 |
+
"reference": "a9f781ba1221067d1f07c8cec0bc50f81b8d7408"
|
911 |
+
},
|
912 |
+
"dist": {
|
913 |
+
"type": "zip",
|
914 |
+
"url": "https://api.github.com/repos/symfony/Config/zipball/a9f781ba1221067d1f07c8cec0bc50f81b8d7408",
|
915 |
+
"reference": "a9f781ba1221067d1f07c8cec0bc50f81b8d7408",
|
916 |
+
"shasum": ""
|
917 |
+
},
|
918 |
+
"require": {
|
919 |
+
"php": ">=5.3.3",
|
920 |
+
"symfony/filesystem": "~2.3"
|
921 |
+
},
|
922 |
+
"type": "library",
|
923 |
+
"extra": {
|
924 |
+
"branch-alias": {
|
925 |
+
"dev-master": "2.6-dev"
|
926 |
+
}
|
927 |
+
},
|
928 |
+
"autoload": {
|
929 |
+
"psr-0": {
|
930 |
+
"Symfony\\Component\\Config\\": ""
|
931 |
+
}
|
932 |
+
},
|
933 |
+
"notification-url": "https://packagist.org/downloads/",
|
934 |
+
"license": [
|
935 |
+
"MIT"
|
936 |
+
],
|
937 |
+
"authors": [
|
938 |
+
{
|
939 |
+
"name": "Symfony Community",
|
940 |
+
"homepage": "http://symfony.com/contributors"
|
941 |
+
},
|
942 |
+
{
|
943 |
+
"name": "Fabien Potencier",
|
944 |
+
"email": "fabien@symfony.com"
|
945 |
+
}
|
946 |
+
],
|
947 |
+
"description": "Symfony Config Component",
|
948 |
+
"homepage": "http://symfony.com",
|
949 |
+
"time": "2015-01-21 20:57:55"
|
950 |
+
},
|
951 |
+
{
|
952 |
+
"name": "symfony/console",
|
953 |
+
"version": "v2.6.4",
|
954 |
+
"target-dir": "Symfony/Component/Console",
|
955 |
+
"source": {
|
956 |
+
"type": "git",
|
957 |
+
"url": "https://github.com/symfony/Console.git",
|
958 |
+
"reference": "e44154bfe3e41e8267d7a3794cd9da9a51cfac34"
|
959 |
+
},
|
960 |
+
"dist": {
|
961 |
+
"type": "zip",
|
962 |
+
"url": "https://api.github.com/repos/symfony/Console/zipball/e44154bfe3e41e8267d7a3794cd9da9a51cfac34",
|
963 |
+
"reference": "e44154bfe3e41e8267d7a3794cd9da9a51cfac34",
|
964 |
+
"shasum": ""
|
965 |
+
},
|
966 |
+
"require": {
|
967 |
+
"php": ">=5.3.3"
|
968 |
+
},
|
969 |
+
"require-dev": {
|
970 |
+
"psr/log": "~1.0",
|
971 |
+
"symfony/event-dispatcher": "~2.1",
|
972 |
+
"symfony/process": "~2.1"
|
973 |
+
},
|
974 |
+
"suggest": {
|
975 |
+
"psr/log": "For using the console logger",
|
976 |
+
"symfony/event-dispatcher": "",
|
977 |
+
"symfony/process": ""
|
978 |
+
},
|
979 |
+
"type": "library",
|
980 |
+
"extra": {
|
981 |
+
"branch-alias": {
|
982 |
+
"dev-master": "2.6-dev"
|
983 |
+
}
|
984 |
+
},
|
985 |
+
"autoload": {
|
986 |
+
"psr-0": {
|
987 |
+
"Symfony\\Component\\Console\\": ""
|
988 |
+
}
|
989 |
+
},
|
990 |
+
"notification-url": "https://packagist.org/downloads/",
|
991 |
+
"license": [
|
992 |
+
"MIT"
|
993 |
+
],
|
994 |
+
"authors": [
|
995 |
+
{
|
996 |
+
"name": "Symfony Community",
|
997 |
+
"homepage": "http://symfony.com/contributors"
|
998 |
+
},
|
999 |
+
{
|
1000 |
+
"name": "Fabien Potencier",
|
1001 |
+
"email": "fabien@symfony.com"
|
1002 |
+
}
|
1003 |
+
],
|
1004 |
+
"description": "Symfony Console Component",
|
1005 |
+
"homepage": "http://symfony.com",
|
1006 |
+
"time": "2015-01-25 04:39:26"
|
1007 |
+
},
|
1008 |
+
{
|
1009 |
+
"name": "symfony/event-dispatcher",
|
1010 |
+
"version": "v2.6.4",
|
1011 |
+
"target-dir": "Symfony/Component/EventDispatcher",
|
1012 |
+
"source": {
|
1013 |
+
"type": "git",
|
1014 |
+
"url": "https://github.com/symfony/EventDispatcher.git",
|
1015 |
+
"reference": "f75989f3ab2743a82fe0b03ded2598a2b1546813"
|
1016 |
+
},
|
1017 |
+
"dist": {
|
1018 |
+
"type": "zip",
|
1019 |
+
"url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/f75989f3ab2743a82fe0b03ded2598a2b1546813",
|
1020 |
+
"reference": "f75989f3ab2743a82fe0b03ded2598a2b1546813",
|
1021 |
+
"shasum": ""
|
1022 |
+
},
|
1023 |
+
"require": {
|
1024 |
+
"php": ">=5.3.3"
|
1025 |
+
},
|
1026 |
+
"require-dev": {
|
1027 |
+
"psr/log": "~1.0",
|
1028 |
+
"symfony/config": "~2.0,>=2.0.5",
|
1029 |
+
"symfony/dependency-injection": "~2.6",
|
1030 |
+
"symfony/expression-language": "~2.6",
|
1031 |
+
"symfony/stopwatch": "~2.3"
|
1032 |
+
},
|
1033 |
+
"suggest": {
|
1034 |
+
"symfony/dependency-injection": "",
|
1035 |
+
"symfony/http-kernel": ""
|
1036 |
+
},
|
1037 |
+
"type": "library",
|
1038 |
+
"extra": {
|
1039 |
+
"branch-alias": {
|
1040 |
+
"dev-master": "2.6-dev"
|
1041 |
+
}
|
1042 |
+
},
|
1043 |
+
"autoload": {
|
1044 |
+
"psr-0": {
|
1045 |
+
"Symfony\\Component\\EventDispatcher\\": ""
|
1046 |
+
}
|
1047 |
+
},
|
1048 |
+
"notification-url": "https://packagist.org/downloads/",
|
1049 |
+
"license": [
|
1050 |
+
"MIT"
|
1051 |
+
],
|
1052 |
+
"authors": [
|
1053 |
+
{
|
1054 |
+
"name": "Symfony Community",
|
1055 |
+
"homepage": "http://symfony.com/contributors"
|
1056 |
+
},
|
1057 |
+
{
|
1058 |
+
"name": "Fabien Potencier",
|
1059 |
+
"email": "fabien@symfony.com"
|
1060 |
+
}
|
1061 |
+
],
|
1062 |
+
"description": "Symfony EventDispatcher Component",
|
1063 |
+
"homepage": "http://symfony.com",
|
1064 |
+
"time": "2015-02-01 16:10:57"
|
1065 |
+
},
|
1066 |
+
{
|
1067 |
+
"name": "symfony/filesystem",
|
1068 |
+
"version": "v2.6.4",
|
1069 |
+
"target-dir": "Symfony/Component/Filesystem",
|
1070 |
+
"source": {
|
1071 |
+
"type": "git",
|
1072 |
+
"url": "https://github.com/symfony/Filesystem.git",
|
1073 |
+
"reference": "a1f566d1f92e142fa1593f4555d6d89e3044a9b7"
|
1074 |
+
},
|
1075 |
+
"dist": {
|
1076 |
+
"type": "zip",
|
1077 |
+
"url": "https://api.github.com/repos/symfony/Filesystem/zipball/a1f566d1f92e142fa1593f4555d6d89e3044a9b7",
|
1078 |
+
"reference": "a1f566d1f92e142fa1593f4555d6d89e3044a9b7",
|
1079 |
+
"shasum": ""
|
1080 |
+
},
|
1081 |
+
"require": {
|
1082 |
+
"php": ">=5.3.3"
|
1083 |
+
},
|
1084 |
+
"type": "library",
|
1085 |
+
"extra": {
|
1086 |
+
"branch-alias": {
|
1087 |
+
"dev-master": "2.6-dev"
|
1088 |
+
}
|
1089 |
+
},
|
1090 |
+
"autoload": {
|
1091 |
+
"psr-0": {
|
1092 |
+
"Symfony\\Component\\Filesystem\\": ""
|
1093 |
+
}
|
1094 |
+
},
|
1095 |
+
"notification-url": "https://packagist.org/downloads/",
|
1096 |
+
"license": [
|
1097 |
+
"MIT"
|
1098 |
+
],
|
1099 |
+
"authors": [
|
1100 |
+
{
|
1101 |
+
"name": "Symfony Community",
|
1102 |
+
"homepage": "http://symfony.com/contributors"
|
1103 |
+
},
|
1104 |
+
{
|
1105 |
+
"name": "Fabien Potencier",
|
1106 |
+
"email": "fabien@symfony.com"
|
1107 |
+
}
|
1108 |
+
],
|
1109 |
+
"description": "Symfony Filesystem Component",
|
1110 |
+
"homepage": "http://symfony.com",
|
1111 |
+
"time": "2015-01-03 21:13:09"
|
1112 |
+
},
|
1113 |
+
{
|
1114 |
+
"name": "symfony/finder",
|
1115 |
+
"version": "v2.6.4",
|
1116 |
+
"target-dir": "Symfony/Component/Finder",
|
1117 |
+
"source": {
|
1118 |
+
"type": "git",
|
1119 |
+
"url": "https://github.com/symfony/Finder.git",
|
1120 |
+
"reference": "16513333bca64186c01609961a2bb1b95b5e1355"
|
1121 |
+
},
|
1122 |
+
"dist": {
|
1123 |
+
"type": "zip",
|
1124 |
+
"url": "https://api.github.com/repos/symfony/Finder/zipball/16513333bca64186c01609961a2bb1b95b5e1355",
|
1125 |
+
"reference": "16513333bca64186c01609961a2bb1b95b5e1355",
|
1126 |
+
"shasum": ""
|
1127 |
+
},
|
1128 |
+
"require": {
|
1129 |
+
"php": ">=5.3.3"
|
1130 |
+
},
|
1131 |
+
"type": "library",
|
1132 |
+
"extra": {
|
1133 |
+
"branch-alias": {
|
1134 |
+
"dev-master": "2.6-dev"
|
1135 |
+
}
|
1136 |
+
},
|
1137 |
+
"autoload": {
|
1138 |
+
"psr-0": {
|
1139 |
+
"Symfony\\Component\\Finder\\": ""
|
1140 |
+
}
|
1141 |
+
},
|
1142 |
+
"notification-url": "https://packagist.org/downloads/",
|
1143 |
+
"license": [
|
1144 |
+
"MIT"
|
1145 |
+
],
|
1146 |
+
"authors": [
|
1147 |
+
{
|
1148 |
+
"name": "Symfony Community",
|
1149 |
+
"homepage": "http://symfony.com/contributors"
|
1150 |
+
},
|
1151 |
+
{
|
1152 |
+
"name": "Fabien Potencier",
|
1153 |
+
"email": "fabien@symfony.com"
|
1154 |
+
}
|
1155 |
+
],
|
1156 |
+
"description": "Symfony Finder Component",
|
1157 |
+
"homepage": "http://symfony.com",
|
1158 |
+
"time": "2015-01-03 08:01:59"
|
1159 |
+
},
|
1160 |
+
{
|
1161 |
+
"name": "symfony/stopwatch",
|
1162 |
+
"version": "v2.6.4",
|
1163 |
+
"target-dir": "Symfony/Component/Stopwatch",
|
1164 |
+
"source": {
|
1165 |
+
"type": "git",
|
1166 |
+
"url": "https://github.com/symfony/Stopwatch.git",
|
1167 |
+
"reference": "e8da5286132ba75ce4b4275fbf0f4cd369bfd71c"
|
1168 |
+
},
|
1169 |
+
"dist": {
|
1170 |
+
"type": "zip",
|
1171 |
+
"url": "https://api.github.com/repos/symfony/Stopwatch/zipball/e8da5286132ba75ce4b4275fbf0f4cd369bfd71c",
|
1172 |
+
"reference": "e8da5286132ba75ce4b4275fbf0f4cd369bfd71c",
|
1173 |
+
"shasum": ""
|
1174 |
+
},
|
1175 |
+
"require": {
|
1176 |
+
"php": ">=5.3.3"
|
1177 |
+
},
|
1178 |
+
"type": "library",
|
1179 |
+
"extra": {
|
1180 |
+
"branch-alias": {
|
1181 |
+
"dev-master": "2.6-dev"
|
1182 |
+
}
|
1183 |
+
},
|
1184 |
+
"autoload": {
|
1185 |
+
"psr-0": {
|
1186 |
+
"Symfony\\Component\\Stopwatch\\": ""
|
1187 |
+
}
|
1188 |
+
},
|
1189 |
+
"notification-url": "https://packagist.org/downloads/",
|
1190 |
+
"license": [
|
1191 |
+
"MIT"
|
1192 |
+
],
|
1193 |
+
"authors": [
|
1194 |
+
{
|
1195 |
+
"name": "Symfony Community",
|
1196 |
+
"homepage": "http://symfony.com/contributors"
|
1197 |
+
},
|
1198 |
+
{
|
1199 |
+
"name": "Fabien Potencier",
|
1200 |
+
"email": "fabien@symfony.com"
|
1201 |
+
}
|
1202 |
+
],
|
1203 |
+
"description": "Symfony Stopwatch Component",
|
1204 |
+
"homepage": "http://symfony.com",
|
1205 |
+
"time": "2015-01-03 08:01:59"
|
1206 |
+
},
|
1207 |
+
{
|
1208 |
+
"name": "symfony/yaml",
|
1209 |
+
"version": "v2.6.4",
|
1210 |
+
"target-dir": "Symfony/Component/Yaml",
|
1211 |
+
"source": {
|
1212 |
+
"type": "git",
|
1213 |
+
"url": "https://github.com/symfony/Yaml.git",
|
1214 |
+
"reference": "60ed7751671113cf1ee7d7778e691642c2e9acd8"
|
1215 |
+
},
|
1216 |
+
"dist": {
|
1217 |
+
"type": "zip",
|
1218 |
+
"url": "https://api.github.com/repos/symfony/Yaml/zipball/60ed7751671113cf1ee7d7778e691642c2e9acd8",
|
1219 |
+
"reference": "60ed7751671113cf1ee7d7778e691642c2e9acd8",
|
1220 |
+
"shasum": ""
|
1221 |
+
},
|
1222 |
+
"require": {
|
1223 |
+
"php": ">=5.3.3"
|
1224 |
+
},
|
1225 |
+
"type": "library",
|
1226 |
+
"extra": {
|
1227 |
+
"branch-alias": {
|
1228 |
+
"dev-master": "2.6-dev"
|
1229 |
+
}
|
1230 |
+
},
|
1231 |
+
"autoload": {
|
1232 |
+
"psr-0": {
|
1233 |
+
"Symfony\\Component\\Yaml\\": ""
|
1234 |
+
}
|
1235 |
+
},
|
1236 |
+
"notification-url": "https://packagist.org/downloads/",
|
1237 |
+
"license": [
|
1238 |
+
"MIT"
|
1239 |
+
],
|
1240 |
+
"authors": [
|
1241 |
+
{
|
1242 |
+
"name": "Symfony Community",
|
1243 |
+
"homepage": "http://symfony.com/contributors"
|
1244 |
+
},
|
1245 |
+
{
|
1246 |
+
"name": "Fabien Potencier",
|
1247 |
+
"email": "fabien@symfony.com"
|
1248 |
+
}
|
1249 |
+
],
|
1250 |
+
"description": "Symfony Yaml Component",
|
1251 |
+
"homepage": "http://symfony.com",
|
1252 |
+
"time": "2015-01-25 04:39:26"
|
1253 |
+
},
|
1254 |
+
{
|
1255 |
+
"name": "wp-cli/php-cli-tools",
|
1256 |
+
"version": "v0.10.3",
|
1257 |
+
"source": {
|
1258 |
+
"type": "git",
|
1259 |
+
"url": "https://github.com/wp-cli/php-cli-tools.git",
|
1260 |
+
"reference": "edead860cb60e95ebdad965ab21e4a1dad7e6b6e"
|
1261 |
+
},
|
1262 |
+
"dist": {
|
1263 |
+
"type": "zip",
|
1264 |
+
"url": "https://api.github.com/repos/wp-cli/php-cli-tools/zipball/edead860cb60e95ebdad965ab21e4a1dad7e6b6e",
|
1265 |
+
"reference": "edead860cb60e95ebdad965ab21e4a1dad7e6b6e",
|
1266 |
+
"shasum": ""
|
1267 |
+
},
|
1268 |
+
"require": {
|
1269 |
+
"php": ">= 5.3.0"
|
1270 |
+
},
|
1271 |
+
"type": "library",
|
1272 |
+
"autoload": {
|
1273 |
+
"psr-0": {
|
1274 |
+
"cli": "lib/"
|
1275 |
+
},
|
1276 |
+
"files": [
|
1277 |
+
"lib/cli/cli.php"
|
1278 |
+
]
|
1279 |
+
},
|
1280 |
+
"notification-url": "https://packagist.org/downloads/",
|
1281 |
+
"license": [
|
1282 |
+
"MIT"
|
1283 |
+
],
|
1284 |
+
"authors": [
|
1285 |
+
{
|
1286 |
+
"name": "James Logsdon",
|
1287 |
+
"email": "jlogsdon@php.net",
|
1288 |
+
"role": "Developer"
|
1289 |
+
},
|
1290 |
+
{
|
1291 |
+
"name": "Daniel Bachhuber",
|
1292 |
+
"email": "daniel@handbuilt.co",
|
1293 |
+
"role": "Maintainer"
|
1294 |
+
}
|
1295 |
+
],
|
1296 |
+
"description": "Console utilities for PHP",
|
1297 |
+
"homepage": "http://github.com/wp-cli/php-cli-tools",
|
1298 |
+
"keywords": [
|
1299 |
+
"cli",
|
1300 |
+
"console"
|
1301 |
+
],
|
1302 |
+
"time": "2014-12-03 15:45:28"
|
1303 |
+
},
|
1304 |
+
{
|
1305 |
+
"name": "wp-cli/wp-cli",
|
1306 |
+
"version": "v0.18.0",
|
1307 |
+
"source": {
|
1308 |
+
"type": "git",
|
1309 |
+
"url": "https://github.com/wp-cli/wp-cli.git",
|
1310 |
+
"reference": "d3ea18a17965f94d1498a607087e02594fc826f7"
|
1311 |
+
},
|
1312 |
+
"dist": {
|
1313 |
+
"type": "zip",
|
1314 |
+
"url": "https://api.github.com/repos/wp-cli/wp-cli/zipball/d3ea18a17965f94d1498a607087e02594fc826f7",
|
1315 |
+
"reference": "d3ea18a17965f94d1498a607087e02594fc826f7",
|
1316 |
+
"shasum": ""
|
1317 |
+
},
|
1318 |
+
"require": {
|
1319 |
+
"mustache/mustache": "~2.4",
|
1320 |
+
"nb/oxymel": "0.1.0",
|
1321 |
+
"php": ">=5.3.2",
|
1322 |
+
"rhumsaa/array_column": "~1.1",
|
1323 |
+
"rmccue/requests": "~1.6",
|
1324 |
+
"symfony/finder": "~2.3",
|
1325 |
+
"wp-cli/php-cli-tools": "0.10.3"
|
1326 |
+
},
|
1327 |
+
"require-dev": {
|
1328 |
+
"behat/behat": "2.5.*",
|
1329 |
+
"phpunit/phpunit": "3.7.*"
|
1330 |
+
},
|
1331 |
+
"suggest": {
|
1332 |
+
"psy/psysh": "Enhanced `wp shell` functionality"
|
1333 |
+
},
|
1334 |
+
"bin": [
|
1335 |
+
"bin/wp.bat",
|
1336 |
+
"bin/wp"
|
1337 |
+
],
|
1338 |
+
"type": "library",
|
1339 |
+
"autoload": {
|
1340 |
+
"psr-0": {
|
1341 |
+
"WP_CLI": "php"
|
1342 |
+
},
|
1343 |
+
"files": [
|
1344 |
+
"php/Spyc.php"
|
1345 |
+
],
|
1346 |
+
"classmap": [
|
1347 |
+
"php/export"
|
1348 |
+
]
|
1349 |
+
},
|
1350 |
+
"notification-url": "https://packagist.org/downloads/",
|
1351 |
+
"license": [
|
1352 |
+
"MIT"
|
1353 |
+
],
|
1354 |
+
"description": "A command line interface for WordPress",
|
1355 |
+
"homepage": "http://wp-cli.org",
|
1356 |
+
"keywords": [
|
1357 |
+
"cli",
|
1358 |
+
"wordpress"
|
1359 |
+
],
|
1360 |
+
"time": "2015-01-14 14:10:29"
|
1361 |
+
}
|
1362 |
+
],
|
1363 |
+
"aliases": [],
|
1364 |
+
"minimum-stability": "stable",
|
1365 |
+
"stability-flags": {
|
1366 |
+
"satooshi/php-coveralls": 20
|
1367 |
+
},
|
1368 |
+
"prefer-stable": false,
|
1369 |
+
"prefer-lowest": false,
|
1370 |
+
"platform": {
|
1371 |
+
"php": ">=5.3.0"
|
1372 |
+
},
|
1373 |
+
"platform-dev": []
|
1374 |
+
}
|
vendor/upstatement/routes/phpunit.xml
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<phpunit
|
2 |
+
bootstrap="tests/bootstrap.php"
|
3 |
+
backupGlobals="false"
|
4 |
+
colors="true"
|
5 |
+
convertErrorsToExceptions="true"
|
6 |
+
convertNoticesToExceptions="true"
|
7 |
+
convertWarningsToExceptions="true"
|
8 |
+
>
|
9 |
+
<testsuites>
|
10 |
+
<testsuite>
|
11 |
+
<directory prefix="test-" suffix=".php">./tests/</directory>
|
12 |
+
</testsuite>
|
13 |
+
<!-- The suite below HAS to be last to run,
|
14 |
+
as it includes a test that sets some const and would contaminate
|
15 |
+
the other tests as well. -->
|
16 |
+
<testsuite>
|
17 |
+
<directory prefix="testX-" suffix=".php">./tests/</directory>
|
18 |
+
</testsuite>
|
19 |
+
</testsuites>
|
20 |
+
</phpunit>
|
vendor/upstatement/routes/tests/bootstrap.php
ADDED
@@ -0,0 +1,14 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$_tests_dir = getenv('WP_TESTS_DIR');
|
4 |
+
if ( !$_tests_dir ) $_tests_dir = '/tmp/wordpress-tests-lib';
|
5 |
+
|
6 |
+
require_once $_tests_dir . '/includes/functions.php';
|
7 |
+
|
8 |
+
function _manually_load_plugin() {
|
9 |
+
require dirname( __FILE__ ) . '/../routes.php';
|
10 |
+
}
|
11 |
+
|
12 |
+
tests_add_filter( 'muplugins_loaded', '_manually_load_plugin' );
|
13 |
+
|
14 |
+
require $_tests_dir . '/includes/bootstrap.php';
|
vendor/upstatement/routes/tests/test-routes.php
ADDED
@@ -0,0 +1,244 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class TestRoutes extends WP_UnitTestCase {
|
4 |
+
|
5 |
+
function testThemeRoute(){
|
6 |
+
$template = Routes::load('single.php');
|
7 |
+
$this->assertTrue($template);
|
8 |
+
}
|
9 |
+
|
10 |
+
function testThemeRouteDoesntExist(){
|
11 |
+
$template = Routes::load('singlefoo.php');
|
12 |
+
$this->assertFalse($template);
|
13 |
+
}
|
14 |
+
|
15 |
+
function testFullPathRoute(){
|
16 |
+
$hello = WP_CONTENT_DIR.'/plugins/hello.php';
|
17 |
+
$template = Routes::load($hello);
|
18 |
+
$this->assertTrue($template);
|
19 |
+
}
|
20 |
+
|
21 |
+
function testFullPathRouteDoesntExist(){
|
22 |
+
$hello = WP_CONTENT_DIR.'/plugins/hello-foo.php';
|
23 |
+
$template = Routes::load($hello);
|
24 |
+
$this->assertFalse($template);
|
25 |
+
}
|
26 |
+
|
27 |
+
function testRouterClass(){
|
28 |
+
$this->assertTrue(class_exists('AltoRouter'));
|
29 |
+
}
|
30 |
+
|
31 |
+
function testAppliedRoute(){
|
32 |
+
$_SERVER['REQUEST_METHOD'] = 'GET';
|
33 |
+
global $matches;
|
34 |
+
$matches = array();
|
35 |
+
$phpunit = $this;
|
36 |
+
Routes::map('foo', function() use ($phpunit) {
|
37 |
+
global $matches;
|
38 |
+
$matches = array();
|
39 |
+
$phpunit->assertTrue(true);
|
40 |
+
$matches[] = true;
|
41 |
+
});
|
42 |
+
$this->go_to(home_url('foo'));
|
43 |
+
$this->matchRoutes();
|
44 |
+
$this->assertEquals(1, count($matches));
|
45 |
+
}
|
46 |
+
|
47 |
+
function testRouteWithVariable() {
|
48 |
+
$post_name = 'ziggy';
|
49 |
+
$post = $this->factory->post->create(array('post_title' => 'Ziggy', 'post_name' => $post_name));
|
50 |
+
global $matches;
|
51 |
+
$matches = array();
|
52 |
+
$phpunit = $this;
|
53 |
+
Routes::map('mything/:slug', function($params) use ($phpunit) {
|
54 |
+
global $matches;
|
55 |
+
$matches = array();
|
56 |
+
if ('ziggy' == $params['slug']) {
|
57 |
+
$matches[] = true;
|
58 |
+
}
|
59 |
+
});
|
60 |
+
$this->go_to(home_url('/mything/'.$post_name));
|
61 |
+
$this->matchRoutes();
|
62 |
+
$this->assertEquals(1, count($matches));
|
63 |
+
}
|
64 |
+
|
65 |
+
function testRouteWithAltoVariable() {
|
66 |
+
$post_name = 'ziggy';
|
67 |
+
$post = $this->factory->post->create(array('post_title' => 'Ziggy', 'post_name' => $post_name));
|
68 |
+
global $matches;
|
69 |
+
$matches = array();
|
70 |
+
$phpunit = $this;
|
71 |
+
Routes::map('mything/[*:slug]', function($params) use ($phpunit) {
|
72 |
+
global $matches;
|
73 |
+
$matches = array();
|
74 |
+
if ('ziggy' == $params['slug']) {
|
75 |
+
$matches[] = true;
|
76 |
+
}
|
77 |
+
});
|
78 |
+
$this->go_to(home_url('/mything/'.$post_name));
|
79 |
+
$this->matchRoutes();
|
80 |
+
$this->assertEquals(1, count($matches));
|
81 |
+
}
|
82 |
+
|
83 |
+
function testRouteWithMultiArguments() {
|
84 |
+
$phpunit = $this;
|
85 |
+
Routes::map('artist/[:artist]/song/[:song]', function($params) use ($phpunit) {
|
86 |
+
global $matches;
|
87 |
+
$matches = array();
|
88 |
+
if ($params['artist'] == 'smashing-pumpkins') {
|
89 |
+
$matches[] = true;
|
90 |
+
}
|
91 |
+
if ($params['song'] == 'mayonaise') {
|
92 |
+
$matches[] = true;
|
93 |
+
}
|
94 |
+
});
|
95 |
+
$this->go_to(home_url('/artist/smashing-pumpkins/song/mayonaise'));
|
96 |
+
$this->matchRoutes();
|
97 |
+
global $matches;
|
98 |
+
$this->assertEquals(2, count($matches));
|
99 |
+
}
|
100 |
+
|
101 |
+
function testRouteWithMultiArgumentsOldStyle() {
|
102 |
+
$phpunit = $this;
|
103 |
+
global $matches;
|
104 |
+
Routes::map('studio/:studio/movie/:movie', function($params) use ($phpunit) {
|
105 |
+
global $matches;
|
106 |
+
$matches = array();
|
107 |
+
if ($params['studio'] == 'universal') {
|
108 |
+
$matches[] = true;
|
109 |
+
}
|
110 |
+
if ($params['movie'] == 'brazil') {
|
111 |
+
$matches[] = true;
|
112 |
+
}
|
113 |
+
});
|
114 |
+
$this->go_to(home_url('/studio/universal/movie/brazil/'));
|
115 |
+
$this->matchRoutes();
|
116 |
+
$this->assertEquals(2, count($matches));
|
117 |
+
}
|
118 |
+
|
119 |
+
function testRouteAgainstPostName(){
|
120 |
+
$post_name = 'jared';
|
121 |
+
$post = $this->factory->post->create(array('post_title' => 'Jared', 'post_name' => $post_name));
|
122 |
+
global $matches;
|
123 |
+
$matches = array();
|
124 |
+
$phpunit = $this;
|
125 |
+
Routes::map('randomthing/'.$post_name, function() use ($phpunit) {
|
126 |
+
global $matches;
|
127 |
+
$matches = array();
|
128 |
+
$phpunit->assertTrue(true);
|
129 |
+
$matches[] = true;
|
130 |
+
});
|
131 |
+
$this->go_to(home_url('/randomthing/'.$post_name));
|
132 |
+
$this->matchRoutes();
|
133 |
+
$this->assertEquals(1, count($matches));
|
134 |
+
}
|
135 |
+
|
136 |
+
function testVerySimpleRoute(){
|
137 |
+
$_SERVER['REQUEST_METHOD'] = 'GET';
|
138 |
+
global $matches;
|
139 |
+
$matches = array();
|
140 |
+
$phpunit = $this;
|
141 |
+
Routes::map('crackers', function() use ($phpunit) {
|
142 |
+
global $matches;
|
143 |
+
$matches = array();
|
144 |
+
$matches[] = true;
|
145 |
+
});
|
146 |
+
$this->go_to(home_url('crackers'));
|
147 |
+
$this->matchRoutes();
|
148 |
+
$this->assertEquals(1, count($matches));
|
149 |
+
}
|
150 |
+
|
151 |
+
function testVerySimpleRouteTrailingSlash(){
|
152 |
+
$_SERVER['REQUEST_METHOD'] = 'GET';
|
153 |
+
global $matches;
|
154 |
+
$matches = array();
|
155 |
+
$phpunit = $this;
|
156 |
+
Routes::map('bip/', function() use ($phpunit) {
|
157 |
+
global $matches;
|
158 |
+
$matches = array();
|
159 |
+
$matches[] = true;
|
160 |
+
});
|
161 |
+
$this->go_to(home_url('bip'));
|
162 |
+
$this->matchRoutes();
|
163 |
+
$this->assertEquals(1, count($matches));
|
164 |
+
}
|
165 |
+
|
166 |
+
function testVerySimpleRouteTrailingSlashInRequest(){
|
167 |
+
$_SERVER['REQUEST_METHOD'] = 'GET';
|
168 |
+
global $matches;
|
169 |
+
$matches = array();
|
170 |
+
$phpunit = $this;
|
171 |
+
Routes::map('bopp', function() use ($phpunit) {
|
172 |
+
global $matches;
|
173 |
+
$matches = array();
|
174 |
+
$matches[] = true;
|
175 |
+
});
|
176 |
+
$this->go_to(home_url('bopp/'));
|
177 |
+
$this->matchRoutes();
|
178 |
+
$this->assertEquals(1, count($matches));
|
179 |
+
}
|
180 |
+
|
181 |
+
|
182 |
+
function testVerySimpleRouteTrailingSlashInRequestAndMapping(){
|
183 |
+
$_SERVER['REQUEST_METHOD'] = 'GET';
|
184 |
+
global $matches;
|
185 |
+
$matches = array();
|
186 |
+
$phpunit = $this;
|
187 |
+
Routes::map('zappers', function() use ($phpunit) {
|
188 |
+
global $matches;
|
189 |
+
$matches = array();
|
190 |
+
$matches[] = true;
|
191 |
+
});
|
192 |
+
$this->go_to(home_url('zappers/'));
|
193 |
+
$this->matchRoutes();
|
194 |
+
$this->assertEquals(1, count($matches));
|
195 |
+
}
|
196 |
+
|
197 |
+
function testVerySimpleRoutePreceedingSlash(){
|
198 |
+
$_SERVER['REQUEST_METHOD'] = 'GET';
|
199 |
+
global $matches;
|
200 |
+
$matches = array();
|
201 |
+
$phpunit = $this;
|
202 |
+
Routes::map('/gobbles', function() use ($phpunit) {
|
203 |
+
global $matches;
|
204 |
+
$matches = array();
|
205 |
+
$matches[] = true;
|
206 |
+
});
|
207 |
+
$this->go_to(home_url('gobbles'));
|
208 |
+
$this->matchRoutes();
|
209 |
+
$this->assertEquals(1, count($matches));
|
210 |
+
}
|
211 |
+
|
212 |
+
function testFailedRoute(){
|
213 |
+
$_SERVER['REQUEST_METHOD'] = 'GET';
|
214 |
+
global $matches;
|
215 |
+
$matches = array();
|
216 |
+
$phpunit = $this;
|
217 |
+
Routes::map('foo', function() use ($phpunit){
|
218 |
+
$matches = array();
|
219 |
+
$phpunit->assertTrue(false);
|
220 |
+
$matches[] = true;
|
221 |
+
});
|
222 |
+
$this->go_to(home_url('bar'));
|
223 |
+
$this->matchRoutes();
|
224 |
+
$this->assertEquals(0, count($matches));
|
225 |
+
}
|
226 |
+
|
227 |
+
function testRouteWithClassCallback() {
|
228 |
+
Routes::map('classroute', array('TestRoutes', 'testCallback'));
|
229 |
+
$this->go_to(home_url('classroute'));
|
230 |
+
$this->matchRoutes();
|
231 |
+
global $matches;
|
232 |
+
$this->assertEquals(1, count($matches));
|
233 |
+
}
|
234 |
+
|
235 |
+
function matchRoutes() {
|
236 |
+
global $upstatement_routes;
|
237 |
+
$upstatement_routes->match_current_request();
|
238 |
+
}
|
239 |
+
|
240 |
+
static function testCallback() {
|
241 |
+
global $matches;
|
242 |
+
$matches[] = true;
|
243 |
+
}
|
244 |
+
}
|