diff --git a/.travis.yml b/.travis.yml index 58c794c..73697a6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,10 +3,12 @@ language: php php: - 5.4 - 5.5 + - 5.6 - hhvm matrix: allow_failures: + - php: 5.6 - php: hhvm services: diff --git a/LICENSE b/LICENSE index a6c8f0c..ad65074 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2007-2014 Joshua Sherman +Copyright (c) 2007-2014 Josh Sherman 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 diff --git a/README.md b/README.md index 1578593..185ea86 100644 --- a/README.md +++ b/README.md @@ -1,50 +1,43 @@ -# PHP Interface Collection of Killer Libraries to Enhance Stuff +# PICKLES [![Build Status](https://travis-ci.org/joshtronic/pickles.png?branch=master)](https://travis-ci.org/joshtronic/pickles) [![Coverage Status](https://coveralls.io/repos/joshtronic/pickles/badge.png)](https://coveralls.io/r/joshtronic/pickles) [![Dependency Status](https://www.versioneye.com/user/projects/52d1bc1eec13751bde00002a/badge.png)](https://www.versioneye.com/user/projects/52d1bc1eec13751bde00002a) -[![Build Status](https://travis-ci.org/joshtronic/pickles.png?branch=master)](https://travis-ci.org/joshtronic/pickles) -[![Coverage Status](https://coveralls.io/repos/joshtronic/pickles/badge.png)](https://coveralls.io/r/joshtronic/pickles) -[![Dependency Status](https://www.versioneye.com/user/projects/52d1bc1eec13751bde00002a/badge.png)](https://www.versioneye.com/user/projects/52d1bc1eec13751bde00002a) - -## What is PICKLES? - -PICKLES is an open source framework for the rapid development of web applications. - -## Okay, but why? - -I could have went with any number of existing frameworks, but I opted to build my own because I like to code. I’ve built quite a few sites from the ground up over the years, and I wanted to roll that experience into a single system that I could not only use for my sites, but share with the world. - -## Wait, what, it’s not MVC? - -PICKLES is in fact not a true MVC system and won’t be masquerading around as one (yeah, I know, I borrowed some naming conventions). PICKLES does have a main controller that handles incoming page views. The controller loads a module that contains all of the business logic (optionally interacting with data models) and then execution is passed off to the display layer. The display layer gives the user what they asked for (even if they didn’t say please). This is how web pages work, and there has never been a reason for me to force PICKLES into the MVC box just for the hell of it. +PICKLES (PHP Interface Collection of Killer Libraries to Enhance Stuff) is an open source framework for rapid PHP development. PICKLES aims to be an “API First” system for building APIs as well as AJAX/AJAJ-centric web applications. ## Requirements ### Required Software -* Web server of your choice (nginx is highly recommended) +* Web server of your choice (nginx is highly recommended but Apache with `mod_rewrite` will suffice) * PHP 5.4+ -Please note that strides are being made to be compatible with bleeding edge technologies. PICKLES is currently developed against PHP 5.5 and does not pass build tests against prior versions. This effort will be with somewhat of a reckless abandon towards backwards compatibility to keep up with deprecations within PHP. +Please note that PICKLES development is focused on the most recent stable version of PHP (currently 5.5) but will maintain backwards compatibility with the previous stable version. It may not be immediate, but when PHP 5.6 is released compatibility for PHP 5.4 will be dropped in favor of modern niceties. -To help anyone that is “stuck” using PHP 5.3.x, the version distributed with Ubuntu 12.04 LTS, you can still use the 5.3 compatible branch [available here](https://github.com/joshtronic/pickles/archive/php53-compatible.zip) instead. This branch is a fork of the master branch just before we started to these efforts and is considered very stable. The branch will remain available for the foreseeable future but will be indefinitely frozen unless pull requests are submitted. +For anyone stuck using PHP 5.3 is welcome to use [PICKLES v13.12.x](https://github.com/joshtronic/pickles/tree/13.12) which at this time is still receiving bug fixes but will not be seeing any new development by myself. Pull requests are welcome. -As developers we make demands that our end users use modern day browsers while we’re just as guilty by running older server software, typically under the guise that it’s “stable”. I feel that we should be holding ourselves to the same standards when it comes to our server stacks. Stability is great, but at a certain point you’re sacrificing your own technology advancements as a developer as well as turning a blind eye to optimizations that can benefit your users. +My rant about outdated server stacks can be found [on my blog](http://joshtronic.com/2014/01/13/your-stack-is-outdated/#.UuVzI3n0A18). ### Optional Software -* MySQL with PDO and PDO_MYSQL drivers -* PostgreSQL with PDO and PDO_PGSQL drivers -* SQLite 3 with PDO and PDO_SQLITE drivers -* Memcached with the Memcache module -* composer if you want to compile LESS, SCSS or JS also necessary if you want - to run the unit tests +* MySQL server with the `PDO_MYSQL` driver +* PostgreSQL server with the `PDO_PGSQL` driver +* SQLite 3 with the `PDO_SQLITE` driver +* Memcached server with the `Memcache` module +* `composer` if you want to compile LESS, SCSS or JS also necessary if you want to use AYAH integration or run the test suite * [ext/test_helpers](https://github.com/php-test-helpers/php-test-helpers) if you want to be able to run the test suite ## Installation Installation is quite simple as there is no installer to run, and all server configuration options can be set in your index.php for your site. -1. [Download the PICKLES source code](https://github.com/joshtronic/pickles/archive/master.zip) (or clone the repository) -2. Place the code anywhere you’d like (that’s at least 2 directories up from the root of your website). I recommend using `/usr/share/pickles` -3. A starter site can be obtained from http://github.com/joshtronic/pickles-starter. It has everything you need to get a site up and running. -4. At this point you should have a very rudimentary site up and running. -5. Run `composer update` +1. [Download the PICKLES source](https://github.com/joshtronic/pickles/archive/master.zip) (or clone the repository) +2. Place the code anywhere you’d like (that’s at least 2 directories up from the root of your website). I recommend using `/usr/share/pickles[-vVERSION]` +3. Run `composer update` +4. A site already built in PICKLES can be found [here](https://github.com/gravityblvd/tools.gravityblvd.com) + +## TODO + +* Bring the project's Wiki up to date +* Build an actual boilerplate site that would be included in this project + +## Thanks + +Special thanks to [Geoff Oliver](https://github.com/geoffoliver) for being a long time user and contributor of PICKLES and to [Dean Jones](https://github.com/deanproxy) for coming up with the PICKLES acronym. diff --git a/composer.json b/composer.json index 46d338d..299e3c4 100644 --- a/composer.json +++ b/composer.json @@ -12,14 +12,18 @@ "autoload": { "classmap": ["src/"] }, + "repositories": [{ + "type": "vcs", + "url": "https://github.com/joshtronic/php-ayah" + }], "require-dev": { "mikey179/vfsStream": "1.2.0", "satooshi/php-coveralls": "dev-master" }, "require": { "devize/closure-compiler": "@dev", - "joshtronic/php-ayah": "1.1.8", + "joshtronic/php-ayah": "@dev", "leafo/lessphp": "0.4.0", - "leafo/scssphp": "0.0.9" + "leafo/scssphp": "0.0.10" } } diff --git a/composer.lock b/composer.lock index eeae658..89ee739 100644 --- a/composer.lock +++ b/composer.lock @@ -3,7 +3,7 @@ "This file locks the dependencies of your project to a known state", "Read more about it at http://getcomposer.org/doc/01-basic-usage.md#composer-lock-the-lock-file" ], - "hash": "34fec617e973fcd94cae8d9158e5ce4b", + "hash": "ea54b51744a27e84d6badff2b973acac", "packages": [ { "name": "devize/closure-compiler", @@ -44,11 +44,17 @@ }, { "name": "joshtronic/php-ayah", - "version": "v1.1.8", + "version": "dev-master", "source": { "type": "git", "url": "https://github.com/joshtronic/php-ayah.git", - "reference": "cc0ebf289394f80a83372e36e097afe2d3355b45" + "reference": "98e39e2e16de9c77267a6dea4230f6387d5bd1aa" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/joshtronic/php-ayah/zipball/98e39e2e16de9c77267a6dea4230f6387d5bd1aa", + "reference": "98e39e2e16de9c77267a6dea4230f6387d5bd1aa", + "shasum": "" }, "type": "library", "autoload": { @@ -61,7 +67,7 @@ ], "authors": [ { - "name": "Some awesome developer over at AreYouAHuman.com", + "name": "Elvis “Bear” Jakupovic", "email": "support@areyouahuman.com" }, { @@ -70,7 +76,10 @@ } ], "description": "Are You a Human PHP Bundle", - "time": "2014-01-21 02:56:55" + "support": { + "source": "https://github.com/joshtronic/php-ayah/tree/master" + }, + "time": "2014-02-02 14:58:38" }, { "name": "leafo/lessphp", @@ -115,16 +124,16 @@ }, { "name": "leafo/scssphp", - "version": "v0.0.9", + "version": "0.0.10", "source": { "type": "git", "url": "https://github.com/leafo/scssphp.git", - "reference": "a06d702ebf9fabb22542bbb27cc12a905813bb6d" + "reference": "558357feceb9b932a192966945904414dc372e4d" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/leafo/scssphp/zipball/a06d702ebf9fabb22542bbb27cc12a905813bb6d", - "reference": "a06d702ebf9fabb22542bbb27cc12a905813bb6d", + "url": "https://api.github.com/repos/leafo/scssphp/zipball/558357feceb9b932a192966945904414dc372e4d", + "reference": "558357feceb9b932a192966945904414dc372e4d", "shasum": "" }, "require": { @@ -157,22 +166,22 @@ ], "description": "scssphp is a compiler for SCSS written in PHP.", "homepage": "http://leafo.net/scssphp/", - "time": "2013-12-23 23:28:02" + "time": "2014-04-15 02:25:09" } ], "packages-dev": [ { "name": "guzzle/guzzle", - "version": "v3.8.0", + "version": "v3.8.1", "source": { "type": "git", "url": "https://github.com/guzzle/guzzle.git", - "reference": "b4a3ce8c05e777fa18b802956d5d0e38ad338a69" + "reference": "4de0618a01b34aa1c8c33a3f13f396dcd3882eba" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/guzzle/guzzle/zipball/b4a3ce8c05e777fa18b802956d5d0e38ad338a69", - "reference": "b4a3ce8c05e777fa18b802956d5d0e38ad338a69", + "url": "https://api.github.com/repos/guzzle/guzzle/zipball/4de0618a01b34aa1c8c33a3f13f396dcd3882eba", + "reference": "4de0618a01b34aa1c8c33a3f13f396dcd3882eba", "shasum": "" }, "require": { @@ -210,8 +219,8 @@ "phpunit/phpunit": "3.7.*", "psr/log": "1.0.*", "symfony/class-loader": "*", - "zendframework/zend-cache": "2.0.*", - "zendframework/zend-log": "2.0.*" + "zendframework/zend-cache": "<2.3", + "zendframework/zend-log": "<2.3" }, "type": "library", "extra": { @@ -221,8 +230,8 @@ }, "autoload": { "psr-0": { - "Guzzle\\Tests": "tests/", - "Guzzle": "src/" + "Guzzle": "src/", + "Guzzle\\Tests": "tests/" } }, "notification-url": "https://packagist.org/downloads/", @@ -251,7 +260,7 @@ "rest", "web service" ], - "time": "2013-12-05 23:39:20" + "time": "2014-01-28 22:29:15" }, { "name": "mikey179/vfsStream", @@ -327,12 +336,12 @@ "source": { "type": "git", "url": "https://github.com/satooshi/php-coveralls.git", - "reference": "c95c07e971e4b687718f54fc3447a260fb989e16" + "reference": "9fce7133a1d79b19f38a8fc975009703468172f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/c95c07e971e4b687718f54fc3447a260fb989e16", - "reference": "c95c07e971e4b687718f54fc3447a260fb989e16", + "url": "https://api.github.com/repos/satooshi/php-coveralls/zipball/9fce7133a1d79b19f38a8fc975009703468172f0", + "reference": "9fce7133a1d79b19f38a8fc975009703468172f0", "shasum": "" }, "require": { @@ -364,6 +373,11 @@ "composer/bin/coveralls" ], "type": "library", + "extra": { + "branch-alias": { + "dev-master": "0.7-dev" + } + }, "autoload": { "psr-0": { "Satooshi\\Component": "src/", @@ -389,21 +403,21 @@ "github", "test" ], - "time": "2013-07-25 11:22:39" + "time": "2014-03-27 16:05:26" }, { "name": "symfony/config", - "version": "v2.4.1", + "version": "v2.4.3", "target-dir": "Symfony/Component/Config", "source": { "type": "git", "url": "https://github.com/symfony/Config.git", - "reference": "27d0b35879ebefcfee6d218512c32ab2d6cd6a6a" + "reference": "e98693981385224bd31667e56204f311d9e0f98e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Config/zipball/27d0b35879ebefcfee6d218512c32ab2d6cd6a6a", - "reference": "27d0b35879ebefcfee6d218512c32ab2d6cd6a6a", + "url": "https://api.github.com/repos/symfony/Config/zipball/e98693981385224bd31667e56204f311d9e0f98e", + "reference": "e98693981385224bd31667e56204f311d9e0f98e", "shasum": "" }, "require": { @@ -428,7 +442,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -437,21 +453,21 @@ ], "description": "Symfony Config Component", "homepage": "http://symfony.com", - "time": "2014-01-01 08:14:50" + "time": "2014-03-26 11:35:33" }, { "name": "symfony/console", - "version": "v2.4.1", + "version": "v2.4.3", "target-dir": "Symfony/Component/Console", "source": { "type": "git", "url": "https://github.com/symfony/Console.git", - "reference": "4c1ed2ff514bd85ee186eebb010ccbdeeab05af7" + "reference": "ef20f1f58d7f693ee888353962bd2db336e3bbcb" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/4c1ed2ff514bd85ee186eebb010ccbdeeab05af7", - "reference": "4c1ed2ff514bd85ee186eebb010ccbdeeab05af7", + "url": "https://api.github.com/repos/symfony/Console/zipball/ef20f1f58d7f693ee888353962bd2db336e3bbcb", + "reference": "ef20f1f58d7f693ee888353962bd2db336e3bbcb", "shasum": "" }, "require": { @@ -481,7 +497,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -490,21 +508,21 @@ ], "description": "Symfony Console Component", "homepage": "http://symfony.com", - "time": "2014-01-01 08:14:50" + "time": "2014-03-01 17:35:04" }, { "name": "symfony/event-dispatcher", - "version": "v2.4.1", + "version": "v2.4.3", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "e3ba42f6a70554ed05749e61b829550f6ac33601" + "reference": "4708b8cd41984a5ba29fe7dd40716f7f761ac501" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/e3ba42f6a70554ed05749e61b829550f6ac33601", - "reference": "e3ba42f6a70554ed05749e61b829550f6ac33601", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/4708b8cd41984a5ba29fe7dd40716f7f761ac501", + "reference": "4708b8cd41984a5ba29fe7dd40716f7f761ac501", "shasum": "" }, "require": { @@ -535,7 +553,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -544,21 +564,21 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com", - "time": "2013-12-28 08:12:03" + "time": "2014-02-11 13:52:09" }, { "name": "symfony/filesystem", - "version": "v2.4.1", + "version": "v2.4.3", "target-dir": "Symfony/Component/Filesystem", "source": { "type": "git", "url": "https://github.com/symfony/Filesystem.git", - "reference": "b3c3b5a8108b3e5d604dc23241b4ea84a067fc78" + "reference": "b717952487176a993e9b12a08b87beae25ae419c" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/b3c3b5a8108b3e5d604dc23241b4ea84a067fc78", - "reference": "b3c3b5a8108b3e5d604dc23241b4ea84a067fc78", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/b717952487176a993e9b12a08b87beae25ae419c", + "reference": "b717952487176a993e9b12a08b87beae25ae419c", "shasum": "" }, "require": { @@ -582,7 +602,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -591,21 +613,21 @@ ], "description": "Symfony Filesystem Component", "homepage": "http://symfony.com", - "time": "2013-12-31 13:43:26" + "time": "2014-03-26 11:55:03" }, { "name": "symfony/stopwatch", - "version": "v2.4.1", + "version": "v2.4.3", "target-dir": "Symfony/Component/Stopwatch", "source": { "type": "git", "url": "https://github.com/symfony/Stopwatch.git", - "reference": "c8e21e1380c7eef6197a8165620da8457b7c69a5" + "reference": "bffad325e36a3e71fba6d5dcce6e2f4b4637b91a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/c8e21e1380c7eef6197a8165620da8457b7c69a5", - "reference": "c8e21e1380c7eef6197a8165620da8457b7c69a5", + "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/bffad325e36a3e71fba6d5dcce6e2f4b4637b91a", + "reference": "bffad325e36a3e71fba6d5dcce6e2f4b4637b91a", "shasum": "" }, "require": { @@ -629,7 +651,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -638,21 +662,21 @@ ], "description": "Symfony Stopwatch Component", "homepage": "http://symfony.com", - "time": "2013-12-12 16:06:47" + "time": "2014-02-11 13:52:09" }, { "name": "symfony/yaml", - "version": "v2.4.1", + "version": "v2.4.3", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "4e1a237fc48145fae114b96458d799746ad89aa0" + "reference": "77a41c2835ab7cfe8bf6d15e25d3af8f3eb3bacd" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/4e1a237fc48145fae114b96458d799746ad89aa0", - "reference": "4e1a237fc48145fae114b96458d799746ad89aa0", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/77a41c2835ab7cfe8bf6d15e25d3af8f3eb3bacd", + "reference": "77a41c2835ab7cfe8bf6d15e25d3af8f3eb3bacd", "shasum": "" }, "require": { @@ -676,7 +700,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -685,7 +711,7 @@ ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2013-12-28 08:12:03" + "time": "2014-03-12 18:29:58" } ], "aliases": [ @@ -694,6 +720,7 @@ "minimum-stability": "stable", "stability-flags": { "devize/closure-compiler": 20, + "joshtronic/php-ayah": 20, "satooshi/php-coveralls": 20 }, "platform": [ diff --git a/src/classes/API/AYAH.php b/src/classes/API/AYAH.php index 9fa9239..f32fe87 100644 --- a/src/classes/API/AYAH.php +++ b/src/classes/API/AYAH.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/API/Google/Profanity.php b/src/classes/API/Google/Profanity.php index f74c978..fd1e0fc 100644 --- a/src/classes/API/Google/Profanity.php +++ b/src/classes/API/Google/Profanity.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/API/Gravatar.php b/src/classes/API/Gravatar.php index 0f8a208..770a7a4 100644 --- a/src/classes/API/Gravatar.php +++ b/src/classes/API/Gravatar.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/API/PlaceholdIt.php b/src/classes/API/PlaceholdIt.php new file mode 100644 index 0000000..5b7bd08 --- /dev/null +++ b/src/classes/API/PlaceholdIt.php @@ -0,0 +1,107 @@ + + * @copyright Copyright 2007-2014, Josh Sherman + * @license http://www.opensource.org/licenses/mit-license.html + * @package PICKLES + * @link https://github.com/joshtronic/pickles + */ + +/** + * Placehold.it API Interface + * + * @link http://placehold.it + */ +class API_PlaceholdIt extends Object +{ + /** + * URL + * + * Generates a Placehold.it URL based on the passed parameters. + * + * @param integer $width width of the image + * @param integer $height optional height of the image + * @param string $format optional format of the image + * @param string $background optional background color of the image + * @param string $foreground optional foreground color of the image + * @param string $text optional text to display in the image + * @return string Placehold.it URL + */ + public function url($width, $height = null, $format = 'gif', $background = null, $foreground = null, $text = null) + { + // Checks if the format is valid + if (!in_array($format, ['gif', 'jpeg', 'jpg', 'png'])) + { + throw new Exception('Invalid format. Valid formats: gif, jpeg, jpg and png.'); + } + // Checks if foreground is present without background + elseif ($foreground && !$background) + { + throw new Exception('You must specify a background color if you wish to specify a foreground color.'); + } + // Checks the background color's length + elseif ($background && strlen($background) < 6) + { + throw new Exception('The background color must be a 6 character hex code.'); + } + // Checks the foreground color's length + elseif ($foreground && strlen($foreground) < 6) + { + throw new Exception('The foreground color must be a 6 character hex code.'); + } + + $url = 'http://placehold.it/' . $width; + + if ($height) + { + $url .= 'x' . $height; + } + + $url .= '.' . $format; + + if ($background) + { + $url .= '/' . $background; + } + + if ($foreground) + { + $url .= '/' . $foreground; + } + + if ($text) + { + $url .= '&text=' . urlencode($text); + } + + return $url; + } + + /** + * URL + * + * Generates a Placehold.it tag based on the passed parameters. + * + * @param integer $width width of the image + * @param integer $height optional height of the image + * @param string $format optional format of the image + * @param string $background optional background color of the image + * @param string $foreground optional foreground color of the image + * @param string $text optional text to display in the image + * @return string tag with the Placehold.it URL + */ + public function img($width, $height = null, $format = 'gif', $background = null, $foreground = null, $text = null) + { + return ''; + } +} + +?> diff --git a/src/classes/Browser.php b/src/classes/Browser.php index 5ebf2bf..dd5b9a7 100644 --- a/src/classes/Browser.php +++ b/src/classes/Browser.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/Cache.php b/src/classes/Cache.php index b71e861..b930ae6 100644 --- a/src/classes/Cache.php +++ b/src/classes/Cache.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/Config.php b/src/classes/Config.php index f8a1bc8..20c07e6 100644 --- a/src/classes/Config.php +++ b/src/classes/Config.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/Controller.php b/src/classes/Controller.php index 6795b50..9ad0c2e 100644 --- a/src/classes/Controller.php +++ b/src/classes/Controller.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/Convert.php b/src/classes/Convert.php index 31a4b6e..b556905 100644 --- a/src/classes/Convert.php +++ b/src/classes/Convert.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/Database.php b/src/classes/Database.php index e73e792..91ea33e 100644 --- a/src/classes/Database.php +++ b/src/classes/Database.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/Date.php b/src/classes/Date.php index df4ca6c..be07c3b 100644 --- a/src/classes/Date.php +++ b/src/classes/Date.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/Display.php b/src/classes/Display.php index 94deb75..e2c693c 100644 --- a/src/classes/Display.php +++ b/src/classes/Display.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/Distance.php b/src/classes/Distance.php index 6879299..550a931 100644 --- a/src/classes/Distance.php +++ b/src/classes/Distance.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/Dynamic.php b/src/classes/Dynamic.php index e10ea2d..115e8c8 100644 --- a/src/classes/Dynamic.php +++ b/src/classes/Dynamic.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles @@ -150,31 +150,31 @@ class Dynamic extends Object { $reference = $original_reference; - // Compiles LESS & SASS to CSS before minifying - if ($less || $sass) - { - $compiled_filename = str_replace('.min', '', $minified_filename); - - if ($less) - { - $less = new lessc(); - $less->compileFile($original_filename, $compiled_filename); - } - elseif ($sass) - { - $scss = new scssc(); - - file_put_contents( - $compiled_filename, - $scss->compile(file_get_contents($original_filename)) - ); - } - - $original_filename = $compiled_filename; - } - if ($this->config->pickles['minify'] === true) { + // Compiles LESS & SASS to CSS before minifying + if ($less || $sass) + { + $compiled_filename = str_replace('.min', '', $minified_filename); + + if ($less) + { + $less = new lessc(); + $less->compileFile($original_filename, $compiled_filename); + } + elseif ($sass) + { + $scss = new scssc(); + + file_put_contents( + $compiled_filename, + $scss->compile(file_get_contents($original_filename)) + ); + } + + $original_filename = $compiled_filename; + } + // Minifies CSS with a few basic character replacements. $stylesheet = file_get_contents($original_filename); $stylesheet = str_replace( diff --git a/src/classes/File.php b/src/classes/File.php index 4867e19..82e8970 100644 --- a/src/classes/File.php +++ b/src/classes/File.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/Form.php b/src/classes/Form.php index 019dbda..3fc9f3d 100644 --- a/src/classes/Form.php +++ b/src/classes/Form.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/HTML.php b/src/classes/HTML.php index 95f35cf..c8296e8 100644 --- a/src/classes/HTML.php +++ b/src/classes/HTML.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/Log.php b/src/classes/Log.php index c45da55..4e27a4e 100644 --- a/src/classes/Log.php +++ b/src/classes/Log.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/Model.php b/src/classes/Model.php index e6a7c8e..edc4337 100644 --- a/src/classes/Model.php +++ b/src/classes/Model.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/Module.php b/src/classes/Module.php index 32a54e8..9ed9205 100644 --- a/src/classes/Module.php +++ b/src/classes/Module.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/Number.php b/src/classes/Number.php index ad1672d..b2572fc 100644 --- a/src/classes/Number.php +++ b/src/classes/Number.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/Object.php b/src/classes/Object.php index 47fe847..a04f560 100644 --- a/src/classes/Object.php +++ b/src/classes/Object.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/Profiler.php b/src/classes/Profiler.php index 937c341..fff7aaa 100644 --- a/src/classes/Profiler.php +++ b/src/classes/Profiler.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/Security.php b/src/classes/Security.php index 49d3c74..e09ef20 100644 --- a/src/classes/Security.php +++ b/src/classes/Security.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/Session.php b/src/classes/Session.php index 890645b..23b5a05 100644 --- a/src/classes/Session.php +++ b/src/classes/Session.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/Sort.php b/src/classes/Sort.php index 5cca7d2..8b6ac58 100644 --- a/src/classes/Sort.php +++ b/src/classes/Sort.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/classes/String.php b/src/classes/String.php index 08cf8f6..f333c32 100644 --- a/src/classes/String.php +++ b/src/classes/String.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles @@ -225,11 +225,11 @@ class String { if ($hover == true) { - $string = '' . substr($string, 0, $length) . '…'; + $string = '' . mb_strcut($string, 0, $length, 'UTF-8') . '…'; } else { - $string = substr($string, 0, $length) . '...'; + $string = mb_strcut($string, 0, $length, 'UTF-8') . '…'; } } diff --git a/src/classes/Time.php b/src/classes/Time.php index e6604d5..e8ba3b6 100644 --- a/src/classes/Time.php +++ b/src/classes/Time.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles @@ -176,40 +176,80 @@ class Time $time_ago = 'seconds'; } // Less than 1 hour ago (minutes ago) - elseif ($difference < 3600) + elseif ($difference < Time::HOUR) { - $minutes = round($difference / 60); - $time_ago = $minutes . ' minute' . ($minutes != 1 ? 's' : ''); + $minutes = round($difference / 60); + + if ($minutes == 60) + { + $time_ago = 'an hour'; + } + else + { + $time_ago = ($minutes == 1 ? 'a' : $minutes) . ' minute' . ($minutes != 1 ? 's' : ''); + } } // Less than 1 day ago (hours ago) - elseif ($difference < 86400) + elseif ($difference < Time::DAY) { - $hours = round($difference / 3600); - $time_ago = $hours . ' hour' . ($hours != 1 ? 's' : ''); + $hours = round($difference / Time::HOUR); + + if ($hours == 24) + { + $time_ago = 'a day'; + } + else + { + $time_ago = ($hours == 1 ? 'an' : $hours) . ' hour' . ($hours != 1 ? 's' : ''); + } } // Less than 1 week ago (days ago) - elseif ($difference < 604800) + elseif ($difference < Time::WEEK) { - $days = round($difference / 86400); - $time_ago = $days . ' day' . ($days != 1 ? 's' : ''); + $days = round($difference / Time::DAY); + + if ($days == 7) + { + $time_ago = 'a week'; + } + else + { + $time_ago = ($days == 1 ? 'a' : $days) . ' day' . ($days != 1 ? 's' : ''); + } } // Less than 1 month ago (weeks ago) - elseif ($difference < 2419200) + elseif ($difference < Time::MONTH) { - $weeks = round($difference / 604800); - $time_ago = $weeks . ' week' . ($weeks != 1 ? 's' : ''); + $weeks = round($difference / Time::WEEK); + + if ($weeks == 4) + { + $time_ago = 'a month'; + } + else + { + $time_ago = ($weeks == 1 ? 'a' : $weeks) . ' week' . ($weeks != 1 ? 's' : ''); + } } // Less than 1 year ago (months ago) - elseif ($difference < 31449600) + elseif ($difference < Time::YEAR) { - $months = round($difference / 2419200); - $time_ago = $months . ' month' . ($months != 1 ? 's' : ''); + $months = round($difference / Time::MONTH); + + if ($months == 12) + { + $time_ago = 'a year'; + } + else + { + $time_ago = ($months == 1 ? 'a' : $months) . ' month' . ($months != 1 ? 's' : ''); + } } // Over 1 year ago (years ago) else { - $years = round($difference / 31449600); - $time_ago = $years . ' year' . ($years != 1 ? 's' : ''); + $years = round($difference / Time::YEAR); + $time_ago = ($years == 1 ? 'a' : $years) . ' year' . ($years != 1 ? 's' : ''); } $time_ago .= $suffix; diff --git a/src/classes/Validate.php b/src/classes/Validate.php index 807b0c2..7567be8 100644 --- a/src/classes/Validate.php +++ b/src/classes/Validate.php @@ -8,8 +8,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/src/pickles.php b/src/pickles.php index 56dcc1d..a77769a 100644 --- a/src/pickles.php +++ b/src/pickles.php @@ -13,8 +13,8 @@ * Licensed under The MIT License * Redistribution of these files must retain the above copyright notice. * - * @author Joshua Sherman - * @copyright Copyright 2007-2014, Joshua Sherman + * @author Josh Sherman + * @copyright Copyright 2007-2014, Josh Sherman * @license http://www.opensource.org/licenses/mit-license.html * @package PICKLES * @link https://github.com/joshtronic/pickles diff --git a/tests/classes/API/AYAHTest.php b/tests/classes/API/AYAHTest.php index e36c29e..7c72c33 100644 --- a/tests/classes/API/AYAHTest.php +++ b/tests/classes/API/AYAHTest.php @@ -28,7 +28,7 @@ class API_AYAHTest extends PHPUnit_Framework_TestCase 'scoring_key' => '80cc3f9c6e1da29369c238d55bd8528a968473ad', ]; - $this->assertRegExp('/
<\/div>