├── .editorconfig
├── .gitignore
├── .travis.yml
├── LICENSE
├── README.md
├── build
├── composer.json
├── demo
├── images
│ ├── 350x350.gif
│ ├── unsplash1.jpeg
│ └── unsplash2.jpeg
└── index.php
├── docs
├── classes
│ ├── ImageCache.ImageCache.html
│ └── ImageCache.html
├── css
│ ├── jquery.iviewer.css
│ ├── phpdocumentor-clean-icons
│ │ ├── Read Me.txt
│ │ ├── fonts
│ │ │ ├── phpdocumentor-clean-icons.dev.svg
│ │ │ ├── phpdocumentor-clean-icons.eot
│ │ │ ├── phpdocumentor-clean-icons.svg
│ │ │ ├── phpdocumentor-clean-icons.ttf
│ │ │ └── phpdocumentor-clean-icons.woff
│ │ ├── lte-ie7.js
│ │ └── style.css
│ ├── prism.css
│ └── template.css
├── files
│ ├── ImageCache.php.html
│ └── ImageCache.php.txt
├── graphs
│ └── class.html
├── images
│ ├── apple-touch-icon-114x114.png
│ ├── apple-touch-icon-72x72.png
│ ├── apple-touch-icon.png
│ ├── custom-icons.svg
│ ├── favicon.ico
│ ├── hierarchy-item.png
│ ├── icon-class-13x13.png
│ ├── icon-class.svg
│ ├── icon-interface-13x13.png
│ ├── icon-interface.svg
│ ├── icon-trait-13x13.png
│ ├── icon-trait.svg
│ └── iviewer
│ │ ├── grab.cur
│ │ ├── hand.cur
│ │ ├── iviewer.rotate_left.png
│ │ ├── iviewer.rotate_right.png
│ │ ├── iviewer.zoom_fit.png
│ │ ├── iviewer.zoom_in.png
│ │ ├── iviewer.zoom_out.png
│ │ └── iviewer.zoom_zero.png
├── index.html
├── js
│ ├── jquery.dotdotdot-1.5.9.js
│ ├── jquery.dotdotdot-1.5.9.min.js
│ ├── jquery.iviewer.js
│ ├── jquery.iviewer.min.js
│ ├── jquery.smooth-scroll.js
│ └── prism.min.js
├── namespaces
│ ├── ImageCache.html
│ └── default.html
├── phpdoc-cache-1b
│ └── phpdoc-cache-file_d04bb9de03626450ab11fb2173acc40e.dat
├── phpdoc-cache-2e
│ └── phpdoc-cache-settings.dat
└── reports
│ ├── deprecated.html
│ ├── errors.html
│ └── markers.html
├── phpdoc.xml
├── phpunit.xml
├── src
└── ImageCache
│ ├── ImageCache.php
│ └── php-image-cache
│ ├── 18e3af47b74127eb56de83345552aa7e.gif
│ └── 18e3af47b74127eb56de83345552aa7e.gif.gz
└── unittests
└── ImageCacheTest.php
/.editorconfig:
--------------------------------------------------------------------------------
1 | # editorconfig.org
2 |
3 | root = true
4 |
5 | [*]
6 | indent_style = tab
7 | indent_size = 4
8 | end_of_line = lf
9 | charset = utf-8
10 | trim_trailing_whitespace = true
11 | insert_final_newline = true
12 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | *.tmp
2 | # docs
3 | # docs/*
4 | compressed
5 | compressed/*
6 | src/ImageCache/php-image-cache
7 | demo/images/cached
8 | /nbproject
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: php
2 | php:
3 | - "5.5"
4 | - "5.4"
5 | - "5.3"
6 |
7 | notifications:
8 | email: "erik@312development.com"
9 |
10 | script: "phpunit"
11 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | License
2 |
3 | THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW. ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR COPYRIGHT LAW IS PROHIBITED.
4 |
5 | BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE MAY BE CONSIDERED TO BE A CONTRACT, THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
6 |
7 | 1. Definitions
8 |
9 | "Adaptation" means a work based upon the Work, or upon the Work and other pre-existing works, such as a translation, adaptation, derivative work, arrangement of music or other alterations of a literary or artistic work, or phonogram or performance and includes cinematographic adaptations or any other form in which the Work may be recast, transformed, or adapted including in any form recognizably derived from the original, except that a work that constitutes a Collection will not be considered an Adaptation for the purpose of this License. For the avoidance of doubt, where the Work is a musical work, performance or phonogram, the synchronization of the Work in timed-relation with a moving image ("synching") will be considered an Adaptation for the purpose of this License.
10 | "Collection" means a collection of literary or artistic works, such as encyclopedias and anthologies, or performances, phonograms or broadcasts, or other works or subject matter other than works listed in Section 1(f) below, which, by reason of the selection and arrangement of their contents, constitute intellectual creations, in which the Work is included in its entirety in unmodified form along with one or more other contributions, each constituting separate and independent works in themselves, which together are assembled into a collective whole. A work that constitutes a Collection will not be considered an Adaptation (as defined above) for the purposes of this License.
11 | "Distribute" means to make available to the public the original and copies of the Work or Adaptation, as appropriate, through sale or other transfer of ownership.
12 | "Licensor" means the individual, individuals, entity or entities that offer(s) the Work under the terms of this License.
13 | "Original Author" means, in the case of a literary or artistic work, the individual, individuals, entity or entities who created the Work or if no individual or entity can be identified, the publisher; and in addition (i) in the case of a performance the actors, singers, musicians, dancers, and other persons who act, sing, deliver, declaim, play in, interpret or otherwise perform literary or artistic works or expressions of folklore; (ii) in the case of a phonogram the producer being the person or legal entity who first fixes the sounds of a performance or other sounds; and, (iii) in the case of broadcasts, the organization that transmits the broadcast.
14 | "Work" means the literary and/or artistic work offered under the terms of this License including without limitation any production in the literary, scientific and artistic domain, whatever may be the mode or form of its expression including digital form, such as a book, pamphlet and other writing; a lecture, address, sermon or other work of the same nature; a dramatic or dramatico-musical work; a choreographic work or entertainment in dumb show; a musical composition with or without words; a cinematographic work to which are assimilated works expressed by a process analogous to cinematography; a work of drawing, painting, architecture, sculpture, engraving or lithography; a photographic work to which are assimilated works expressed by a process analogous to photography; a work of applied art; an illustration, map, plan, sketch or three-dimensional work relative to geography, topography, architecture or science; a performance; a broadcast; a phonogram; a compilation of data to the extent it is protected as a copyrightable work; or a work performed by a variety or circus performer to the extent it is not otherwise considered a literary or artistic work.
15 | "You" means an individual or entity exercising rights under this License who has not previously violated the terms of this License with respect to the Work, or who has received express permission from the Licensor to exercise rights under this License despite a previous violation.
16 | "Publicly Perform" means to perform public recitations of the Work and to communicate to the public those public recitations, by any means or process, including by wire or wireless means or public digital performances; to make available to the public Works in such a way that members of the public may access these Works from a place and at a place individually chosen by them; to perform the Work to the public by any means or process and the communication to the public of the performances of the Work, including by public digital performance; to broadcast and rebroadcast the Work by any means including signs, sounds or images.
17 | "Reproduce" means to make copies of the Work by any means including without limitation by sound or visual recordings and the right of fixation and reproducing fixations of the Work, including storage of a protected performance or phonogram in digital form or other electronic medium.
18 | 2. Fair Dealing Rights. Nothing in this License is intended to reduce, limit, or restrict any uses free from copyright or rights arising from limitations or exceptions that are provided for in connection with the copyright protection under copyright law or other applicable laws.
19 |
20 | 3. License Grant. Subject to the terms and conditions of this License, Licensor hereby grants You a worldwide, royalty-free, non-exclusive, perpetual (for the duration of the applicable copyright) license to exercise the rights in the Work as stated below:
21 |
22 | to Reproduce the Work, to incorporate the Work into one or more Collections, and to Reproduce the Work as incorporated in the Collections;
23 | to create and Reproduce Adaptations provided that any such Adaptation, including any translation in any medium, takes reasonable steps to clearly label, demarcate or otherwise identify that changes were made to the original Work. For example, a translation could be marked "The original work was translated from English to Spanish," or a modification could indicate "The original work has been modified.";
24 | to Distribute and Publicly Perform the Work including as incorporated in Collections; and,
25 | to Distribute and Publicly Perform Adaptations.
26 | For the avoidance of doubt:
27 |
28 | Non-waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme cannot be waived, the Licensor reserves the exclusive right to collect such royalties for any exercise by You of the rights granted under this License;
29 | Waivable Compulsory License Schemes. In those jurisdictions in which the right to collect royalties through any statutory or compulsory licensing scheme can be waived, the Licensor waives the exclusive right to collect such royalties for any exercise by You of the rights granted under this License; and,
30 | Voluntary License Schemes. The Licensor waives the right to collect royalties, whether individually or, in the event that the Licensor is a member of a collecting society that administers voluntary licensing schemes, via that society, from any exercise by You of the rights granted under this License.
31 | The above rights may be exercised in all media and formats whether now known or hereafter devised. The above rights include the right to make such modifications as are technically necessary to exercise the rights in other media and formats. Subject to Section 8(f), all rights not expressly granted by Licensor are hereby reserved.
32 |
33 | 4. Restrictions. The license granted in Section 3 above is expressly made subject to and limited by the following restrictions:
34 |
35 | You may Distribute or Publicly Perform the Work only under the terms of this License. You must include a copy of, or the Uniform Resource Identifier (URI) for, this License with every copy of the Work You Distribute or Publicly Perform. You may not offer or impose any terms on the Work that restrict the terms of this License or the ability of the recipient of the Work to exercise the rights granted to that recipient under the terms of the License. You may not sublicense the Work. You must keep intact all notices that refer to this License and to the disclaimer of warranties with every copy of the Work You Distribute or Publicly Perform. When You Distribute or Publicly Perform the Work, You may not impose any effective technological measures on the Work that restrict the ability of a recipient of the Work from You to exercise the rights granted to that recipient under the terms of the License. This Section 4(a) applies to the Work as incorporated in a Collection, but this does not require the Collection apart from the Work itself to be made subject to the terms of this License. If You create a Collection, upon notice from any Licensor You must, to the extent practicable, remove from the Collection any credit as required by Section 4(b), as requested. If You create an Adaptation, upon notice from any Licensor You must, to the extent practicable, remove from the Adaptation any credit as required by Section 4(b), as requested.
36 | If You Distribute, or Publicly Perform the Work or any Adaptations or Collections, You must, unless a request has been made pursuant to Section 4(a), keep intact all copyright notices for the Work and provide, reasonable to the medium or means You are utilizing: (i) the name of the Original Author (or pseudonym, if applicable) if supplied, and/or if the Original Author and/or Licensor designate another party or parties (e.g., a sponsor institute, publishing entity, journal) for attribution ("Attribution Parties") in Licensor's copyright notice, terms of service or by other reasonable means, the name of such party or parties; (ii) the title of the Work if supplied; (iii) to the extent reasonably practicable, the URI, if any, that Licensor specifies to be associated with the Work, unless such URI does not refer to the copyright notice or licensing information for the Work; and (iv) , consistent with Section 3(b), in the case of an Adaptation, a credit identifying the use of the Work in the Adaptation (e.g., "French translation of the Work by Original Author," or "Screenplay based on original Work by Original Author"). The credit required by this Section 4 (b) may be implemented in any reasonable manner; provided, however, that in the case of a Adaptation or Collection, at a minimum such credit will appear, if a credit for all contributing authors of the Adaptation or Collection appears, then as part of these credits and in a manner at least as prominent as the credits for the other contributing authors. For the avoidance of doubt, You may only use the credit required by this Section for the purpose of attribution in the manner set out above and, by exercising Your rights under this License, You may not implicitly or explicitly assert or imply any connection with, sponsorship or endorsement by the Original Author, Licensor and/or Attribution Parties, as appropriate, of You or Your use of the Work, without the separate, express prior written permission of the Original Author, Licensor and/or Attribution Parties.
37 | Except as otherwise agreed in writing by the Licensor or as may be otherwise permitted by applicable law, if You Reproduce, Distribute or Publicly Perform the Work either by itself or as part of any Adaptations or Collections, You must not distort, mutilate, modify or take other derogatory action in relation to the Work which would be prejudicial to the Original Author's honor or reputation. Licensor agrees that in those jurisdictions (e.g. Japan), in which any exercise of the right granted in Section 3(b) of this License (the right to make Adaptations) would be deemed to be a distortion, mutilation, modification or other derogatory action prejudicial to the Original Author's honor and reputation, the Licensor will waive or not assert, as appropriate, this Section, to the fullest extent permitted by the applicable national law, to enable You to reasonably exercise Your right under Section 3(b) of this License (right to make Adaptations) but not otherwise.
38 | 5. Representations, Warranties and Disclaimer
39 |
40 | UNLESS OTHERWISE MUTUALLY AGREED TO BY THE PARTIES IN WRITING, LICENSOR OFFERS THE WORK AS-IS AND MAKES NO REPRESENTATIONS OR WARRANTIES OF ANY KIND CONCERNING THE WORK, EXPRESS, IMPLIED, STATUTORY OR OTHERWISE, INCLUDING, WITHOUT LIMITATION, WARRANTIES OF TITLE, MERCHANTIBILITY, FITNESS FOR A PARTICULAR PURPOSE, NONINFRINGEMENT, OR THE ABSENCE OF LATENT OR OTHER DEFECTS, ACCURACY, OR THE PRESENCE OF ABSENCE OF ERRORS, WHETHER OR NOT DISCOVERABLE. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OF IMPLIED WARRANTIES, SO SUCH EXCLUSION MAY NOT APPLY TO YOU.
41 |
42 | 6. Limitation on Liability. EXCEPT TO THE EXTENT REQUIRED BY APPLICABLE LAW, IN NO EVENT WILL LICENSOR BE LIABLE TO YOU ON ANY LEGAL THEORY FOR ANY SPECIAL, INCIDENTAL, CONSEQUENTIAL, PUNITIVE OR EXEMPLARY DAMAGES ARISING OUT OF THIS LICENSE OR THE USE OF THE WORK, EVEN IF LICENSOR HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
43 |
44 | 7. Termination
45 |
46 | This License and the rights granted hereunder will terminate automatically upon any breach by You of the terms of this License. Individuals or entities who have received Adaptations or Collections from You under this License, however, will not have their licenses terminated provided such individuals or entities remain in full compliance with those licenses. Sections 1, 2, 5, 6, 7, and 8 will survive any termination of this License.
47 | Subject to the above terms and conditions, the license granted here is perpetual (for the duration of the applicable copyright in the Work). Notwithstanding the above, Licensor reserves the right to release the Work under different license terms or to stop distributing the Work at any time; provided, however that any such election will not serve to withdraw this License (or any other license that has been, or is required to be, granted under the terms of this License), and this License will continue in full force and effect unless terminated as stated above.
48 | 8. Miscellaneous
49 |
50 | Each time You Distribute or Publicly Perform the Work or a Collection, the Licensor offers to the recipient a license to the Work on the same terms and conditions as the license granted to You under this License.
51 | Each time You Distribute or Publicly Perform an Adaptation, Licensor offers to the recipient a license to the original Work on the same terms and conditions as the license granted to You under this License.
52 | If any provision of this License is invalid or unenforceable under applicable law, it shall not affect the validity or enforceability of the remainder of the terms of this License, and without further action by the parties to this agreement, such provision shall be reformed to the minimum extent necessary to make such provision valid and enforceable.
53 | No term or provision of this License shall be deemed waived and no breach consented to unless such waiver or consent shall be in writing and signed by the party to be charged with such waiver or consent.
54 | This License constitutes the entire agreement between the parties with respect to the Work licensed here. There are no understandings, agreements or representations with respect to the Work not specified here. Licensor shall not be bound by any additional provisions that may appear in any communication from You. This License may not be modified without the mutual written agreement of the Licensor and You.
55 | The rights granted under, and the subject matter referenced, in this License were drafted utilizing the terminology of the Berne Convention for the Protection of Literary and Artistic Works (as amended on September 28, 1979), the Rome Convention of 1961, the WIPO Copyright Treaty of 1996, the WIPO Performances and Phonograms Treaty of 1996 and the Universal Copyright Convention (as revised on July 24, 1971). These rights and subject matter take effect in the relevant jurisdiction in which the License terms are sought to be enforced according to the corresponding provisions of the implementation of those treaty provisions in the applicable national law. If the standard suite of rights granted under applicable copyright law includes additional rights not granted under this License, such additional rights are deemed to be included in the License; this License is not intended to restrict the license of any rights under applicable law.
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # NO LONGER MAINTAINED!!!
2 |
3 | # Image Cache v. 1.0.0
4 |
5 | Image Cache is a very simple PHP class that accepts an image source and will compress and cache the file, move it to a new directory, and returns the new source for the image.
6 |
7 | ## Current Status
8 |
9 | [](https://travis-ci.org/nielse63/php-image-cache)
10 |
11 | Employing travis-ci.org for continuous integration testing and assurance of code validity.
12 |
13 | ## Installation
14 |
15 | Install Composer by opening Terminal and navigating to the directory in which you'd like to install Image Cache.
16 |
17 | Download Composer:
18 |
19 | ```bash
20 | curl -sS https://getcomposer.org/installer | php
21 | ```
22 |
23 | Create a `composer.json` file:
24 |
25 | ```json
26 | {
27 | "require" : {
28 | "nielse63/phpimagecache": "dev-master"
29 | }
30 | }
31 | ```
32 |
33 | Navigate to your project root and run the `install` command.
34 |
35 | ```bash
36 | $ php composer.phar install
37 | ```
38 |
39 | From there, include the `vendor/autoload.php` file in your project, and initialize the class as normal.
40 |
41 | More information on installing and using Composer can be found at getcomposer.org , and dependency information on the package can be found at packagist.org .
42 |
43 | ## Testing
44 |
45 | ### Manual Testing
46 |
47 | To test the script manually by receiving visual output, setup a virtual host and load `demo/index.php` in your browser. Three examples are set in that file: the original image called from an outside source; a cached example referencing the outside source via an absolute URL; and an internal source referencing a file path.
48 |
49 | Using Chrome Developer Tools you can see the difference in load times between the external source (non-cached image) and the internally stored and cached image.
50 |
51 | ### Unit Testing
52 |
53 | Some extremely basic unit tests are included with the script and can be run using PHP Unit . I'm working on continuing to build up these tests and would more than welcome any contributions to the tests.
54 |
55 | To execute the tests in a bundled script (along with rebuilding the docs), clone the repository, navigate to the root of the repo in terminal, and execute:
56 |
57 | ```bash
58 | $: sh build
59 | ```
60 |
61 | Assuming you have the `phpunit` and `phpdoc` commands intalled, the tests will pass and docs will be rebuilt.
62 |
63 | ## What's Next
64 |
65 | See the source for a full to do list of changes that I wish to accomplish moving forward.
66 |
67 | ## Contributing
68 |
69 | Contributing to the project would be a massive help in maintaining and extending the script. The module is being used on a larger scale than I initially imagined, and continuing to maintain it is becoming a little time consuming for just me.
70 |
71 | If you're interested in contributing, issue a pull request on Github or email me directly at erik@312development.com .
72 |
73 | For any issues found or extensions you'd like to see, feel free to submit an issue ticket so we can start a discussion about the viability of the problem and how it can be resolved.
74 |
75 | ## License
76 |
77 | Creative Commons Attribution Lisence:
78 |
79 | http://freedomdefined.org/Licenses/CC-BY
80 |
81 | [](https://bitdeli.com/free "Bitdeli Badge")
82 |
83 |
--------------------------------------------------------------------------------
/build:
--------------------------------------------------------------------------------
1 | #!/bin/sh
2 |
3 | PHP_UNIT=`which phpunit`
4 | PHP_DOC=`which phpdoc`
5 |
6 | cd unittests && $PHP_UNIT ImageCacheTest ;
7 | cd ../ $PHP_DOC
--------------------------------------------------------------------------------
/composer.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "nielse63/phpimagecache",
3 | "version" : "1.0.0",
4 | "type": "library",
5 | "description": "Image Cache is a very simple PHP module that accepts an image source and will compress and cache the file, move it to a new directory, and return the cache source for the image.",
6 | "keywords": ["cache","caching","php cache","image cache"],
7 | "homepage": "http://nielse63.github.io/php-image-cache",
8 | "license": "Creative Commons Attribution",
9 | "authors": [
10 | {
11 | "name": "Erik Nielsen",
12 | "email": "erik@312development.com",
13 | "homepage": "http://312development.com",
14 | "role": "Developer"
15 | }
16 | ],
17 | "require": {
18 | "php": ">=5.4.0"
19 | },
20 | "autoload": {
21 | "psr-0": {
22 | "ImageCache": "src/"
23 | }
24 | }
25 | }
26 |
--------------------------------------------------------------------------------
/demo/images/350x350.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/demo/images/350x350.gif
--------------------------------------------------------------------------------
/demo/images/unsplash1.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/demo/images/unsplash1.jpeg
--------------------------------------------------------------------------------
/demo/images/unsplash2.jpeg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/demo/images/unsplash2.jpeg
--------------------------------------------------------------------------------
/demo/index.php:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | Image Cache Test
8 |
9 |
17 |
18 |
19 | cached_image_directory = dirname(__FILE__) . '/images/cached';
22 |
23 | $cached_src_one = $imagecache->cache( 'images/unsplash1.jpeg' );
24 | echo 'Original file size: ' . filesize($imagecache->image_src) . ' bytes
';
25 | echo 'PHPImageCach-ified file size: ' . filesize($imagecache->cached_filename) . ' bytes
';
26 | echo 'Total image size reduction: ' . (((filesize($imagecache->image_src) - filesize($imagecache->cached_filename)) / filesize($imagecache->image_src))*100) . '%
';
27 | ?>
28 |
29 |
30 | check_link_cached = false;
32 | $cached_src_two = $imagecache->cache( 'images/unsplash2.jpeg' );
33 | echo 'Original file size: ' . filesize($imagecache->image_src) . ' bytes
';
34 | echo 'PHPImageCach-ified file size: ' . filesize($imagecache->cached_filename) . ' bytes
';
35 | echo 'Total image size reduction: ' . (((filesize($imagecache->image_src) - filesize($imagecache->cached_filename)) / filesize($imagecache->image_src))*100) . '%
';
36 | ?>
37 |
38 |
39 | cache( 'http://placehold.it/350x350' );
41 | echo 'Original file size: ' . filesize($imagecache->image_src) . ' bytes ';
42 | echo 'PHPImageCach-ified file size: ' . filesize($imagecache->cached_filename) . ' bytes ';
43 | echo 'Total image size reduction: ' . (((filesize($imagecache->image_src) - filesize($imagecache->cached_filename)) / filesize($imagecache->image_src))*100) . '%';
44 | ?>
45 | Because the "compressed" file size is larger than the original, a local copy of the original file will be server instead.
46 |
47 |
48 |
49 |
50 |
--------------------------------------------------------------------------------
/docs/css/jquery.iviewer.css:
--------------------------------------------------------------------------------
1 | .viewer {
2 | -ms-touch-action: none;
3 | }
4 |
5 | .iviewer_common {
6 | position:absolute;
7 | bottom:10px;
8 | border: 1px solid #000;
9 | height: 28px;
10 | z-index: 5000;
11 | }
12 |
13 | .iviewer_cursor {
14 | cursor: url(../images/iviewer/hand.cur) 6 8, pointer;
15 | }
16 |
17 | .iviewer_drag_cursor {
18 | cursor: url(../images/iviewer/grab.cur) 6 8, pointer;
19 | }
20 |
21 | .iviewer_button {
22 | width: 28px;
23 | cursor: pointer;
24 | background-position: center center;
25 | background-repeat: no-repeat;
26 | }
27 |
28 | .iviewer_zoom_in {
29 | left: 20px;
30 | background: url(../images/iviewer/iviewer.zoom_in.png);
31 | }
32 |
33 | .iviewer_zoom_out {
34 | left: 55px;
35 | background: url(../images/iviewer/iviewer.zoom_out.png);
36 | }
37 |
38 | .iviewer_zoom_zero {
39 | left: 90px;
40 | background: url(../images/iviewer/iviewer.zoom_zero.png);
41 | }
42 |
43 | .iviewer_zoom_fit {
44 | left: 125px;
45 | background: url(../images/iviewer/iviewer.zoom_fit.png);
46 | }
47 |
48 | .iviewer_zoom_status {
49 | left: 160px;
50 | font: 1em/28px Sans;
51 | color: #000;
52 | background-color: #fff;
53 | text-align: center;
54 | width: 60px;
55 | }
56 |
57 | .iviewer_rotate_left {
58 | left: 227px;
59 | background: #fff url(../images/iviewer/iviewer.rotate_left.png) center center no-repeat;
60 | }
61 |
62 | .iviewer_rotate_right {
63 | left: 262px;
64 | background: #fff url(../images/iviewer/iviewer.rotate_right.png) center center no-repeat;
65 | }
66 |
--------------------------------------------------------------------------------
/docs/css/phpdocumentor-clean-icons/Read Me.txt:
--------------------------------------------------------------------------------
1 | To modify your generated font, use the *dev.svg* file, located in the *fonts* folder in this package. You can import this dev.svg file to the IcoMoon app. All the tags (class names) and the Unicode points of your glyphs are saved in this file.
2 |
3 | See the documentation for more info on how to use this package: http://icomoon.io/#docs/font-face
--------------------------------------------------------------------------------
/docs/css/phpdocumentor-clean-icons/fonts/phpdocumentor-clean-icons.dev.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | This is a custom SVG font generated by IcoMoon.
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/docs/css/phpdocumentor-clean-icons/fonts/phpdocumentor-clean-icons.eot:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/docs/css/phpdocumentor-clean-icons/fonts/phpdocumentor-clean-icons.eot
--------------------------------------------------------------------------------
/docs/css/phpdocumentor-clean-icons/fonts/phpdocumentor-clean-icons.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | This is a custom SVG font generated by IcoMoon.
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
--------------------------------------------------------------------------------
/docs/css/phpdocumentor-clean-icons/fonts/phpdocumentor-clean-icons.ttf:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/docs/css/phpdocumentor-clean-icons/fonts/phpdocumentor-clean-icons.ttf
--------------------------------------------------------------------------------
/docs/css/phpdocumentor-clean-icons/fonts/phpdocumentor-clean-icons.woff:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/docs/css/phpdocumentor-clean-icons/fonts/phpdocumentor-clean-icons.woff
--------------------------------------------------------------------------------
/docs/css/phpdocumentor-clean-icons/lte-ie7.js:
--------------------------------------------------------------------------------
1 | /* Load this script using conditional IE comments if you need to support IE 7 and IE 6. */
2 |
3 | window.onload = function() {
4 | function addIcon(el, entity) {
5 | var html = el.innerHTML;
6 | el.innerHTML = '' + entity + ' ' + html;
7 | }
8 | var icons = {
9 | 'icon-trait' : '',
10 | 'icon-interface' : '',
11 | 'icon-class' : ''
12 | },
13 | els = document.getElementsByTagName('*'),
14 | i, attr, html, c, el;
15 | for (i = 0; ; i += 1) {
16 | el = els[i];
17 | if(!el) {
18 | break;
19 | }
20 | attr = el.getAttribute('data-icon');
21 | if (attr) {
22 | addIcon(el, attr);
23 | }
24 | c = el.className;
25 | c = c.match(/icon-[^\s'"]+/);
26 | if (c && icons[c[0]]) {
27 | addIcon(el, icons[c[0]]);
28 | }
29 | }
30 | };
--------------------------------------------------------------------------------
/docs/css/phpdocumentor-clean-icons/style.css:
--------------------------------------------------------------------------------
1 | @font-face {
2 | font-family: 'phpdocumentor-clean-icons';
3 | src:url('fonts/phpdocumentor-clean-icons.eot');
4 | src:url('fonts/phpdocumentor-clean-icons.eot?#iefix') format('embedded-opentype'),
5 | url('fonts/phpdocumentor-clean-icons.woff') format('woff'),
6 | url('fonts/phpdocumentor-clean-icons.ttf') format('truetype'),
7 | url('fonts/phpdocumentor-clean-icons.svg#phpdocumentor-clean-icons') format('svg');
8 | font-weight: normal;
9 | font-style: normal;
10 | }
11 |
12 | /* Use the following CSS code if you want to use data attributes for inserting your icons */
13 | [data-icon]:before {
14 | font-family: 'phpdocumentor-clean-icons';
15 | content: attr(data-icon);
16 | speak: none;
17 | font-weight: normal;
18 | font-variant: normal;
19 | text-transform: none;
20 | line-height: 1;
21 | -webkit-font-smoothing: antialiased;
22 | }
23 |
24 | /* Use the following CSS code if you want to have a class per icon */
25 | /*
26 | Instead of a list of all class selectors,
27 | you can use the generic selector below, but it's slower:
28 | [class*="icon-"] {
29 | */
30 | .icon-trait, .icon-interface, .icon-class {
31 | font-family: 'phpdocumentor-clean-icons';
32 | speak: none;
33 | font-style: normal;
34 | font-weight: normal;
35 | font-variant: normal;
36 | text-transform: none;
37 | line-height: 1;
38 | -webkit-font-smoothing: antialiased;
39 | }
40 | .icon-trait:before {
41 | content: "\e000";
42 | }
43 | .icon-interface:before {
44 | content: "\e001";
45 | }
46 | .icon-class:before {
47 | content: "\e002";
48 | }
49 |
--------------------------------------------------------------------------------
/docs/css/prism.css:
--------------------------------------------------------------------------------
1 | /**
2 | * prism.js default theme for JavaScript, CSS and HTML
3 | * Based on dabblet (http://dabblet.com)
4 | * @author Lea Verou
5 | */
6 |
7 | code[class*="language-"],
8 | pre[class*="language-"] {
9 | color: black;
10 | text-shadow: 0 1px white;
11 | font-family: Consolas, Monaco, 'Andale Mono', monospace;
12 | direction: ltr;
13 | text-align: left;
14 | white-space: pre;
15 | word-spacing: normal;
16 |
17 | -moz-tab-size: 4;
18 | -o-tab-size: 4;
19 | tab-size: 4;
20 |
21 | -webkit-hyphens: none;
22 | -moz-hyphens: none;
23 | -ms-hyphens: none;
24 | hyphens: none;
25 | }
26 |
27 | ::-moz-selection {
28 | text-shadow: none;
29 | background: #b3d4fc;
30 | }
31 |
32 | ::selection {
33 | text-shadow: none;
34 | background: #b3d4fc;
35 | }
36 |
37 | @media print {
38 | code[class*="language-"],
39 | pre[class*="language-"] {
40 | text-shadow: none;
41 | }
42 | }
43 |
44 | /* Code blocks */
45 | pre[class*="language-"] {
46 | padding: 1em;
47 | margin: .5em 0;
48 | overflow: auto;
49 | }
50 |
51 | :not(pre) > code[class*="language-"],
52 | pre[class*="language-"] {
53 | background: #f5f2f0;
54 | }
55 |
56 | /* Inline code */
57 | :not(pre) > code[class*="language-"] {
58 | padding: .1em;
59 | border-radius: .3em;
60 | }
61 |
62 | .token.comment,
63 | .token.prolog,
64 | .token.doctype,
65 | .token.cdata {
66 | color: slategray;
67 | }
68 |
69 | .token.punctuation {
70 | color: #999;
71 | }
72 |
73 | .namespace {
74 | opacity: .7;
75 | }
76 |
77 | .token.property,
78 | .token.tag,
79 | .token.boolean,
80 | .token.number {
81 | color: #905;
82 | }
83 |
84 | .token.selector,
85 | .token.attr-name,
86 | .token.string {
87 | color: #690;
88 | }
89 |
90 | .token.operator,
91 | .token.entity,
92 | .token.url,
93 | .language-css .token.string,
94 | .style .token.string {
95 | color: #a67f59;
96 | background: hsla(0,0%,100%,.5);
97 | }
98 |
99 | .token.atrule,
100 | .token.attr-value,
101 | .token.keyword {
102 | color: #07a;
103 | }
104 |
105 |
106 | .token.regex,
107 | .token.important {
108 | color: #e90;
109 | }
110 |
111 | .token.important {
112 | font-weight: bold;
113 | }
114 |
115 | .token.entity {
116 | cursor: help;
117 | }
118 | pre[data-line] {
119 | position: relative;
120 | padding: 1em 0 1em 3em;
121 | }
122 |
123 | .line-highlight {
124 | position: absolute;
125 | left: 0;
126 | right: 0;
127 | padding: inherit 0;
128 | margin-top: 1em; /* Same as .prism’s padding-top */
129 |
130 | background: hsla(24, 20%, 50%,.08);
131 | background: -moz-linear-gradient(left, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
132 | background: -webkit-linear-gradient(left, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
133 | background: -o-linear-gradient(left, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
134 | background: linear-gradient(left, hsla(24, 20%, 50%,.1) 70%, hsla(24, 20%, 50%,0));
135 |
136 | pointer-events: none;
137 |
138 | line-height: inherit;
139 | white-space: pre;
140 | }
141 |
142 | .line-highlight:before,
143 | .line-highlight[data-end]:after {
144 | content: attr(data-start);
145 | position: absolute;
146 | top: .4em;
147 | left: .6em;
148 | min-width: 1em;
149 | padding: 0 .5em;
150 | background-color: hsla(24, 20%, 50%,.4);
151 | color: hsl(24, 20%, 95%);
152 | font: bold 65%/1.5 sans-serif;
153 | text-align: center;
154 | vertical-align: .3em;
155 | border-radius: 999px;
156 | text-shadow: none;
157 | box-shadow: 0 1px white;
158 | }
159 |
160 | .line-highlight[data-end]:after {
161 | content: attr(data-end);
162 | top: auto;
163 | bottom: .4em;
164 | }
165 | pre.line-numbers {
166 | position: relative;
167 | padding-left: 3.8em;
168 | counter-reset: linenumber;
169 | }
170 |
171 | pre.line-numbers > code {
172 | position: relative;
173 | }
174 |
175 | .line-numbers .line-numbers-rows {
176 | position: absolute;
177 | pointer-events: none;
178 | top: 0;
179 | font-size: 100%;
180 | left: -3.8em;
181 | width: 3em; /* works for line-numbers below 1000 lines */
182 | letter-spacing: -1px;
183 | border-right: 1px solid #999;
184 |
185 | -webkit-user-select: none;
186 | -moz-user-select: none;
187 | -ms-user-select: none;
188 | user-select: none;
189 |
190 | }
191 |
192 | .line-numbers-rows > span {
193 | pointer-events: none;
194 | display: block;
195 | counter-increment: linenumber;
196 | }
197 |
198 | .line-numbers-rows > span:before {
199 | content: counter(linenumber);
200 | color: #999;
201 | display: block;
202 | padding-right: 0.8em;
203 | text-align: right;
204 | }
205 |
--------------------------------------------------------------------------------
/docs/css/template.css:
--------------------------------------------------------------------------------
1 | @import url(https://fonts.googleapis.com/css?family=Source+Sans+Pro);
2 | @import url('phpdocumentor-clean-icons/style.css');
3 |
4 | body {
5 | padding-top: 40px;
6 | background-color: #333333;
7 | }
8 |
9 | a {
10 | color: #6495ed;
11 | }
12 | a.anchor {
13 | height: 40px;
14 | margin-top: -40px;
15 | display: block;
16 | }
17 |
18 | h1, h2, h3, h4, h5, h6, .brand {
19 | font-family: 'Source Sans Pro', sans-serif;
20 | font-weight: normal;
21 | letter-spacing: 0.05em;
22 | }
23 |
24 | h2, h3, .detailsbar h1 {
25 | overflow: hidden;
26 | white-space: nowrap;
27 | margin: 30px 0 20px 0;
28 | }
29 |
30 | h2:after, h3:after, .detailsbar h1:after {
31 | content: '';
32 | display: inline-block;
33 | vertical-align: middle;
34 | width: 100%;
35 | height: 2px;
36 | margin-left: 1em;
37 | background: silver;
38 | }
39 |
40 | h3 {
41 | margin: 10px 0 20px 0;
42 | }
43 |
44 | h4 {
45 | margin: 20px 0 10px 0;
46 | color: gray;
47 | font-size: 18.5px;
48 | }
49 |
50 | h3.public, h3.protected, h3.private {
51 | padding-left: 10px;
52 | text-overflow: ellipsis;
53 | }
54 |
55 | .table tr:first-of-type th, .table tr:first-of-type td {
56 | border-top: none;
57 | }
58 | .detailsbar {
59 | color: #eeeeee;
60 | background-color: #333333;
61 | font-size: 0.9em;
62 | overflow: hidden;
63 | border-left: 2px solid gray;
64 | }
65 |
66 | .detailsbar h1 {
67 | font-size: 1.5em;
68 | margin-bottom: 20px;
69 | margin-top: 0;
70 | }
71 |
72 | .detailsbar h2 {
73 | font-size: 1.2em;
74 | margin: 0;
75 | padding: 0;
76 | }
77 |
78 | .detailsbar h1:after {
79 | background: gray;
80 | }
81 | .detailsbar h2:after, .detailsbar h3:after {
82 | background: transparent;
83 | }
84 |
85 | .detailsbar dt {
86 | font-variant: small-caps;
87 | text-transform: lowercase;
88 | font-size: 1.1em;
89 | letter-spacing: 0.1em;
90 | color: silver;
91 | }
92 |
93 | .hierarchy div:nth-of-type(2) { margin-left: 11px; }
94 | .hierarchy div:nth-of-type(3) { margin-left: 22px; }
95 | .hierarchy div:nth-of-type(4) { margin-left: 33px; }
96 | .hierarchy div:nth-of-type(5) { margin-left: 44px; }
97 | .hierarchy div:nth-of-type(6) { margin-left: 55px; }
98 | .hierarchy div:nth-of-type(7) { margin-left: 66px; }
99 | .hierarchy div:nth-of-type(8) { margin-left: 77px; }
100 | .hierarchy div:nth-of-type(9) { margin-left: 88px; }
101 | .hierarchy div:before {
102 | content: "\f0da";
103 | font-family: FontAwesome;
104 | margin-right: 5px;
105 | }
106 |
107 | .row-fluid {
108 | background-color: white;
109 | overflow: hidden;
110 | }
111 |
112 | footer.row-fluid, footer.row-fluid * {
113 | background-color: #333333;
114 | color: white;
115 | }
116 |
117 | footer.row-fluid {
118 | border-top: 2px dashed #555;
119 | margin-top: 2px;
120 | }
121 |
122 | .footer-sections .span4 {
123 | border: 2px solid #555;
124 | text-align: center;
125 | border-radius: 10px;
126 | margin-top: 70px;
127 | margin-bottom: 20px;
128 | background: #373737;
129 | }
130 |
131 | .footer-sections .span4 h1 {
132 | background: transparent;
133 | margin-top: -30px;
134 | margin-bottom: 20px;
135 | font-size: 5em;
136 | }
137 |
138 | .footer-sections .span4 h1 * {
139 | background: transparent;
140 | }
141 |
142 | .footer-sections .span4 div {
143 | border-bottom-right-radius: 6px;
144 | border-bottom-left-radius: 6px;
145 | padding: 10px;
146 | min-height: 40px;
147 | }
148 | .footer-sections .span4 div, .footer-sections .span4 div * {
149 | background-color: #555;
150 | }
151 | .footer-sections .span4 ul {
152 | text-align: left;
153 | list-style: none;
154 | margin: 0;
155 | padding: 0;
156 | }
157 |
158 | .content {
159 | background-color: white;
160 | padding-right: 20px;
161 | }
162 |
163 | .content nav {
164 | text-align: center;
165 | border-bottom: 1px solid silver;
166 | margin: 5px 0 20px 0;
167 | padding-bottom: 5px;
168 | }
169 |
170 | .content > h1 {
171 | padding-bottom: 15px;
172 | }
173 |
174 | .content > h1 small {
175 | display: block;
176 | padding-bottom: 8px;
177 | font-size: 0.6em;
178 | }
179 |
180 | .deprecated {
181 | text-decoration: line-through;
182 | }
183 |
184 | .method {
185 | margin-bottom: 20px;
186 | }
187 |
188 | .method .signature .argument {
189 | color: maroon;
190 | font-weight: bold;
191 | }
192 |
193 | .class #summary section.row-fluid {
194 | overflow: hidden
195 | }
196 |
197 | .class #summary .heading {
198 | font-weight: bold;
199 | text-align: center;
200 | }
201 |
202 | .class #summary section .span4 {
203 | padding: 3px;
204 | overflow: hidden;
205 | margin-bottom: -9999px;
206 | padding-bottom: 9999px;
207 | white-space: nowrap;
208 | text-overflow: ellipsis;
209 | border-left: 5px solid transparent;
210 | }
211 |
212 | .class #summary section.public .span4:first-of-type:before,
213 | .class #summary section.public .span6:first-of-type:before,
214 | h3.public:before {
215 | font-family: FontAwesome;
216 | content: "\f046";
217 | color: green;
218 | display: inline-block;
219 | width: 1.2em;
220 | }
221 |
222 | .class #summary section .span4:first-of-type,
223 | .class #summary section .span6:first-of-type {
224 | padding-left: 21px;
225 | }
226 | .class #summary section .span4:first-of-type:before,
227 | .class #summary section .span6:first-of-type:before {
228 | margin-left: -21px;
229 | }
230 | .class #summary section.protected .span4:first-of-type:before,
231 | .class #summary section.protected .span6:first-of-type:before,
232 | h3.protected:before {
233 | font-family: FontAwesome;
234 | content: "\f132";
235 | color: orange;
236 | display: inline-block;
237 | width: 1.2em;
238 | }
239 |
240 | .class #summary section.private .span4:first-of-type:before,
241 | .class #summary section.private .span6:first-of-type:before,
242 | h3.private:before {
243 | font-family: FontAwesome;
244 | content: "\f023";
245 | color: red;
246 | display: inline-block;
247 | width: 1.2em;
248 | }
249 |
250 | .class #summary section em {
251 | font-size: 0.9em;
252 | color: silver;
253 | }
254 | .class #summary .inherited {
255 | color: gray;
256 | font-style: italic;
257 | }
258 |
259 | .accordion-group {
260 | border: none;
261 | }
262 |
263 | .accordion {
264 | margin-bottom: 0;
265 | }
266 |
267 | .accordion a:hover {
268 | text-decoration: none;
269 | background: #333333;
270 | color: #eeeeee;
271 | }
272 |
273 | .accordion-heading .accordion-toggle:before {
274 | content: "\f078";
275 | font-family: FontAwesome;
276 | margin-right: 5px;
277 | }
278 |
279 | .accordion-heading .accordion-toggle.collapsed:before {
280 | content: "\f054";
281 | }
282 | .accordion-heading .accordion-toggle {
283 | float: left;
284 | width: 16px;
285 | height: 16px;
286 | padding: 4px 2px 4px 12px;
287 | }
288 | .accordion-heading a {
289 | display: block;
290 | padding: 4px 12px;
291 | }
292 |
293 | .accordion-inner a {
294 | display: block;
295 | padding: 4px 12px;
296 | }
297 |
298 | .accordion-inner > ul a:before {
299 | font-family: 'phpdocumentor-clean-icons';
300 | content: "\e001";
301 | margin-right: 5px;
302 | }
303 |
304 | .accordion-inner li.class a:before {
305 | content: "\e002";
306 | }
307 |
308 | .accordion-inner li.interface a:before {
309 | content: "\e001";
310 | }
311 |
312 | .accordion-inner li.trait a:before {
313 | content: "\e000";
314 | }
315 |
316 | .accordion-inner {
317 | padding: 4px 0 4px 12px;
318 | }
319 | .accordion-inner ul {
320 | list-style: none;
321 | padding: 0;
322 | margin: 0;
323 | }
324 |
325 | .row-fluid .span2 {
326 | width: 16.5%;
327 | }
328 |
329 | body .modal {
330 | width: 90%; /* desired relative width */
331 | left: 5%; /* (100%-width)/2 */
332 | /* place center */
333 | margin-left:auto;
334 | margin-right:auto;
335 | }
336 |
337 | @media (min-width: 767px) {
338 | .sidebar {
339 | position: fixed;
340 | top: 40px;
341 | bottom: 0;
342 | background-color: #f3f3f3;
343 | left: 0;
344 | border-right: 1px solid #e9e9e9;
345 | overflow-y: scroll;
346 | overflow-x: hidden;
347 | padding-top: 10px;
348 | }
349 |
350 | .sidebar::-webkit-scrollbar {
351 | width: 10px;
352 | }
353 |
354 | .sidebar::-webkit-scrollbar-thumb {
355 | background: #cccccc;
356 | background-clip: padding-box;
357 | border: 3px solid #f3f3f3;
358 | border-radius: 5px;
359 | }
360 |
361 | .sidebar::-webkit-scrollbar-button {
362 | display: none;
363 | }
364 |
365 | .sidebar::-webkit-scrollbar-track {
366 | background: #f3f3f3;
367 | }
368 | }
369 |
370 | @media (max-width: 979px) {
371 | body {
372 | padding-top: 0;
373 | }
374 | }
375 |
376 | @media (max-width: 767px) {
377 | .class #summary .heading {
378 | display: none;
379 | }
380 |
381 | .detailsbar h1 {
382 | display: none;
383 | }
384 |
385 | body {
386 | background-color: white;
387 | }
388 |
389 | footer.row-fluid, footer.row-fluid * {
390 | background-color: white;
391 | }
392 |
393 | .footer-sections h1 {
394 | color: #ccccd9;
395 | }
396 |
397 | .detailsbar {
398 | background-color: white;
399 | color: #333;
400 | border: none;
401 | }
402 | }
403 |
404 | @media (min-width: 767px) {
405 | .detailsbar {
406 | min-height: 100%;
407 | margin-bottom: -99999px;
408 | padding-bottom: 99999px;
409 | padding-left: 20px;
410 | padding-top: 10px;
411 | }
412 | }
413 |
414 | @media (min-width: 1200px) {
415 | .row-fluid .span2 {
416 | width: 16.5%;
417 | }
418 | }
419 |
--------------------------------------------------------------------------------
/docs/files/ImageCache.php.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | API Documentation
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
72 |
73 |
74 |
75 |
76 |
77 |
78 |
79 |
80 |
81 |
130 |
131 |
132 |
133 |
134 |
135 |
136 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
ImageCache.php
167 |
The primary class file for PHP Image Compressor & Caching
168 |
This file is to be used in any PHP project that requires image compression
169 |
170 |
171 |
172 |
Classes
173 |
179 |
180 |
181 |
182 |
183 | Package
184 | PHP Image Compressor & Caching
185 |
186 |
187 |
188 | Tags
189 |
216 |
217 |
218 |
219 |
220 |
221 |
222 |
223 |
224 |
225 |
234 |
235 |
236 |
237 |
267 |
268 |
269 |
270 | Documentation is powered by phpDocumentor and authored
271 | on
272 | Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /Users/imnikkilee/pear/share/pear/phpDocumentor/vendor/twig/twig/lib/Twig/Extension/Core.php on line 89
273 | September 29th, 2014 at 23:57.
274 |
275 |
276 |
277 |
278 |
279 |
280 |
281 |
282 |
--------------------------------------------------------------------------------
/docs/files/ImageCache.php.txt:
--------------------------------------------------------------------------------
1 |
9 | * @license http://freedomdefined.org/Licenses/CC-BY MIT
10 | * @version GIT: 1.0.0
11 | *
12 | * http://dtbaker.net/web-development/how-to-cache-images-generated-by-php/
13 | */
14 |
15 | ob_start();
16 |
17 | class ImageCache
18 | {
19 |
20 | const memory_value = 128;
21 |
22 | /**
23 | * Stores the image source given for reference
24 | */
25 | public $image_src;
26 |
27 | /**
28 | * If the file is remote or not
29 | */
30 | public $is_remote;
31 |
32 | /**
33 | * Allow the user to set the options for the setup
34 | */
35 | public $options;
36 |
37 | /**
38 | * The location of the cached images directory
39 | */
40 | public $cached_image_directory;
41 |
42 | /**
43 | * The name of the cached file
44 | */
45 | public $cached_filename;
46 |
47 | /**
48 | * Stores the server's version of the GD Library, if enabled
49 | */
50 | private $gd_version;
51 |
52 | /**
53 | * The memory limit currently established on the server
54 | */
55 | private $memory_limit;
56 |
57 | /**
58 | * The file mime type
59 | */
60 | private $file_mime_type;
61 |
62 | /**
63 | * The extension of the file
64 | */
65 | private $file_extension;
66 |
67 | /**
68 | * The original size of the file
69 | */
70 | private $local_image_src;
71 |
72 | /**
73 | * The original size of the file
74 | */
75 | private $src_filesize;
76 |
77 | /**
78 | * The extension of the file
79 | */
80 | private $cached_filesize;
81 |
82 | /**
83 | * Constructor function
84 | *
85 | * @param array $options Options include the keys 'echo' (boolean) and 'cache_time' (integer). 'cache_time' is currently not employed, but in place for future reference.
86 | * @return object Returns the class object for the user to reference it in the future.
87 | */
88 | public function __construct( $options = array() )
89 | {
90 | if( ! $this->can_run_image_cache() )
91 | $this->error( 'PHP Image Cache must be run on a server with a bundled GD version.' );
92 | $defaults = array(
93 | 'echo' => false, // Determines whether the resulting source should be echoed or returned
94 | 'cache_time' => 0 // How long the image should be cached for. If the value is 0, then the cache never expires. Default is 0, never expires.
95 | );
96 | $this->options = (object) array_merge( $defaults, $options );
97 | if(!$this->cached_image_directory) {
98 | $this->cached_image_directory = dirname(__FILE__) . '/php-image-cache';
99 | }
100 | return $this;
101 | }
102 |
103 | /**
104 | * Validates whether the user can use this class or not, based on the GD Version their server is carrying.
105 | *
106 | * @return bool
107 | */
108 | public function can_run_image_cache()
109 | {
110 | $gd_info = gd_info();
111 | $this->gd_version = false;
112 | if( preg_match( '#bundled \((.+)\)$#i', $gd_info['GD Version'], $matches ) ) {
113 | $this->gd_version = (float) $matches[1];
114 | } else {
115 | $this->gd_version = (float) substr( $gd_info['GD Version'], 0, 3 );
116 | }
117 | return (bool) $this->gd_version;
118 | }
119 |
120 | /**
121 | * Caches the image. When using this method, the image will be compressed and then cached.
122 | *
123 | * @return string The source file to be referenced after compressing an image
124 | */
125 | public function cache( $image )
126 | {
127 | if( ! is_string( $image ) )
128 | $this->error( 'Image source given must be a string.' );
129 |
130 | $this->image_src = strtolower( $image );
131 | $this->pre_set_class_vars();
132 |
133 | // If the image hasn't been server up at this point, fetch, compress, cache, and return
134 | if( $this->cached_file_exists() ) {
135 | $this->src_filesize = filesize( $this->image_src );
136 | $this->cached_filesize = filesize( $this->cached_filename );
137 | if( $this->src_filesize < $this->cached_filesize ) {
138 | return $this->docroot_to_url( $this->image_src );
139 | }
140 | return $this->docroot_to_url();
141 | }
142 | if($this->is_remote) {
143 | $this->download_image();
144 | }
145 | if( ! $this->fetch_image() )
146 | $this->error( 'Could not copy image resource.' );
147 | $this->src_filesize = filesize( $this->image_src );
148 | $this->cached_filesize = filesize( $this->cached_filename );
149 | if( $this->src_filesize < $this->cached_filesize ) {
150 | return $this->docroot_to_url( $this->image_src );
151 | }
152 | return $this->docroot_to_url();
153 | }
154 |
155 | /**
156 | * Downloads a remote file and stores it locally to be used for compression
157 | */
158 | private function download_image()
159 | {
160 | $image_resource = file_get_contents( $this->image_src );
161 | $basename = basename($this->image_src);
162 | if( ! stripos( $basename, '.' . $this->file_extension ) ) {
163 | $basename .= '.' . $this->file_extension;
164 | }
165 | $image_location = dirname( $this->cached_image_directory ) . '/' . $basename;
166 | if( ! file_exists( $image_location ) ) {
167 | if( ! file_put_contents( $image_location, $image_resource ) ) {
168 | $this->error( 'Could not download the remote image' );
169 | }
170 | }
171 | $this->image_src = $image_location;
172 | }
173 |
174 | /**
175 | * Creates the cached directory
176 | *
177 | * @return bool If the directory was successfully created or not
178 | */
179 | private function make_cache_directory()
180 | {
181 | if( is_dir( $this->cached_image_directory ) ) {
182 | return true;
183 | }
184 | try {
185 | mkdir( $this->cached_image_directory );
186 | } catch (Exception $e) {
187 | $this->error( 'There was an error creating the new directory:', $e );
188 | return false;
189 | }
190 | return true;
191 | }
192 |
193 | /**
194 | * Fetch the image as a resource and save it into the cache directory.
195 | *
196 | * @source http://stackoverflow.com/questions/9839150/image-compression-in-php
197 | * @return If the image was successfully created or not
198 | */
199 | private function fetch_image()
200 | {
201 | $image_size = getimagesize( $this->image_src );
202 | $image_width = $image_size[0];
203 | $image_height = $image_size[1];
204 | $file_mime_as_ext = end( @explode( '/', $this->file_mime_type ) );
205 | $image_dest_func = 'imagecreate';
206 | if( $this->gd_version >= 2 )
207 | $image_dest_func = 'imagecreatetruecolor';
208 | if( in_array( $file_mime_as_ext, array( 'gif', 'jpeg', 'png' ) ) ) {
209 | $image_src_func = 'imagecreatefrom' . $this->file_extension;
210 | $image_create_func = 'image' . $this->file_extension;
211 | } else {
212 | $this->error('The image you supply must have a .gif, .jpg/.jpeg, or .png extension.');
213 | return false;
214 | }
215 | $image_src = @call_user_func( $image_src_func, $this->image_src );
216 | $image_dest = @call_user_func( $image_dest_func, $image_width, $image_height );
217 | $this->increase_memory_limit();
218 | if( $file_mime_as_ext === 'jpeg' ) {
219 | $background = imagecolorallocate( $image_dest, 255, 255, 255 );
220 | imagefill( $image_dest, 0, 0, $background );
221 | } elseif( in_array( $file_mime_as_ext, array( 'gif', 'png' ) ) ) {
222 | imagealphablending( $image_src, false );
223 | imagesavealpha( $image_src, true );
224 | imagealphablending( $image_dest, false );
225 | imagesavealpha( $image_dest, true );
226 | }
227 | imagecopy( $image_dest, $image_src, 0, 0, 0, 0, $image_width, $image_width );
228 | switch( $file_mime_as_ext ) {
229 | case 'jpeg':
230 | $created = imagejpeg( $image_dest, $this->cached_filename, 85 );
231 | break;
232 | case 'png':
233 | $created = imagepng( $image_dest, $this->cached_filename, 8 );
234 | break;
235 | case 'gif':
236 | $created = imagegif( $image_dest, $this->cached_filename );
237 | break;
238 | default:
239 | return false;
240 | break;
241 | }
242 | imagedestroy( $image_src );
243 | imagedestroy( $image_dest );
244 | $this->reset_memory_limit();
245 | return $created;
246 | }
247 |
248 | /**
249 | * Returns
250 | *
251 | * @param string $url The url to check validate
252 | * @return string The URL of the image
253 | */
254 | private function docroot_to_url($src = null)
255 | {
256 | if( is_null( $src ) ) {
257 | $src = $this->cached_filename;
258 | }
259 | $url = '//' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
260 | $image_path = str_replace($_SERVER['DOCUMENT_ROOT'], '', $src);
261 | $image_url = $url . substr($image_path, 1);
262 | if($this->link_is_broken($image_url)) {
263 | $this->error('Final image URL is broken');
264 | }
265 | return $image_url;
266 | }
267 |
268 | /**
269 | * Sets up all class variables in one central function.
270 | */
271 | private function pre_set_class_vars()
272 | {
273 | $this->set_file_mime_type();
274 | $this->set_cached_filename();
275 | $this->set_memory_limit();
276 | $this->set_is_remote();
277 | }
278 |
279 | /**
280 | * Utility function to determine of the link in question is broken or not.
281 | *
282 | * @param string $url The url to check validate
283 | * @return bool Indicates whether or not the link is broken
284 | */
285 | private function link_is_broken( $url )
286 | {
287 | if( ! function_exists( 'curl_init' ) )
288 | return false;
289 | $ch = curl_init( $url );
290 | curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true );
291 | curl_exec( $ch );
292 | $http_code = curl_getinfo( $ch, CURLINFO_HTTP_CODE );
293 | if($http_code == 404) {
294 | $broken = true;
295 | } else {
296 | $broken = false;
297 | }
298 | curl_close( $ch );
299 | return $broken;
300 | }
301 |
302 | /**
303 | * Quick and dirty way to see if the file is remote or local. Deeper checking comes
304 | * later if we don't find a compressed version of the file locally.
305 | *
306 | * @return bool Whether or not the image is remote
307 | */
308 | private function is_image_local()
309 | {
310 | if( file_exists( $this->image_src ) )
311 | return true;
312 | $parsed_src = parse_url( $this->image_src );
313 | if( $_SERVER['HTTP_HOST'] === $parsed_src['host'] )
314 | return true;
315 | return false;
316 | }
317 |
318 | /**
319 | * Determines if the image is local or being referenced from a remote URL
320 | */
321 | private function set_is_remote()
322 | {
323 | $this->is_remote = ! $this->is_image_local();
324 | }
325 |
326 | /**
327 | * This function creates the filename of the new image using an MD5 hash of the original filename. This helps to create a unique
328 | * filename for the newly compressed image so that this class can easily find and determine if the image has already been compressed and stored locally.
329 | *
330 | * Employing use of the "alt" and "title" tags on the image (which hopefully you're already doing) will negate any potentially negative impacts on SEO. See
331 | * this article for more information: http://searchenginewatch.com/article/2120682/Image-Optimization-How-to-Rank-on-Image-Search
332 | */
333 | private function set_cached_filename()
334 | {
335 | $pathinfo = pathinfo( $this->image_src );
336 | $this->cached_filename = $this->cached_image_directory . '/' . md5( basename( $this->image_src ) ) . '.' . $this->file_extension;
337 | }
338 |
339 | /**
340 | * Simply determines if a compressed of the image that's sent is already compressed or not.
341 | */
342 | private function cached_file_exists()
343 | {
344 | if($this->is_remote) {
345 | $this->download_image();
346 | }
347 | if( file_exists( $this->cached_filename ) )
348 | return true;
349 | return false;
350 | }
351 |
352 | /**
353 | * Stores the file's mime type and validates that the file being compressed is indeed an image.
354 | */
355 | private function set_file_mime_type()
356 | {
357 | $image_type = exif_imagetype( $this->image_src );
358 | if( ! $image_type )
359 | $this->error( 'The file you supplied isn\'t a valid image.' );
360 | $this->file_mime_type = image_type_to_mime_type( $image_type );
361 | $this->file_extension = image_type_to_extension( $image_type, false );
362 | }
363 |
364 | /**
365 | * Stores the original value of the server's memory limit
366 | */
367 | private function set_memory_limit()
368 | {
369 | $this->memory_limit = (int) ini_get('memory_limit');
370 | }
371 |
372 | /**
373 | * Temporarily increases the servers memory limit to 2480 MB to handle building larger images. Based on initial
374 | * tests, this seems to be a large enough increase to handle rebuilding jpg images as large as 4300px wide with no pre-compression.
375 | */
376 | private function increase_memory_limit()
377 | {
378 | ini_set('memory_limit', '2480M');
379 | }
380 |
381 | /**
382 | * Resets the servers memory limit to its original value
383 | */
384 | private function reset_memory_limit()
385 | {
386 | ini_set('memory_limit', $this->memory_limit);
387 | }
388 |
389 | /**
390 | * Displays an error and kills the script
391 | *
392 | * @param String $status The message to be passed to the native `exit()` function
393 | */
394 | private function error( $status = null )
395 | {
396 | if( is_null( $status ) )
397 | $status = 'Unknown Error:';
398 | exit( $status );
399 | }
400 |
401 | }
402 |
403 |
--------------------------------------------------------------------------------
/docs/graphs/class.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | API Documentation
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
24 |
25 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
49 |
50 |
51 |
52 |
53 |
54 |
55 |
56 |
57 |
58 |
107 |
108 |
109 |
110 |
111 |
112 |
113 |
120 |
121 |
122 |
123 |
153 |
154 |
155 |
156 | Documentation is powered by phpDocumentor and authored
157 | on
158 | Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /Users/imnikkilee/pear/share/pear/phpDocumentor/vendor/twig/twig/lib/Twig/Extension/Core.php on line 89
159 | September 29th, 2014 at 23:57.
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
--------------------------------------------------------------------------------
/docs/images/apple-touch-icon-114x114.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/docs/images/apple-touch-icon-114x114.png
--------------------------------------------------------------------------------
/docs/images/apple-touch-icon-72x72.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/docs/images/apple-touch-icon-72x72.png
--------------------------------------------------------------------------------
/docs/images/apple-touch-icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/docs/images/apple-touch-icon.png
--------------------------------------------------------------------------------
/docs/images/custom-icons.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
18 |
20 |
43 |
45 |
46 |
48 | image/svg+xml
49 |
51 |
52 |
53 |
54 |
55 |
61 |
67 |
68 |
74 |
77 |
82 |
83 |
84 |
90 |
93 |
98 |
99 |
100 |
106 |
109 |
114 |
115 |
116 |
117 |
--------------------------------------------------------------------------------
/docs/images/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/docs/images/favicon.ico
--------------------------------------------------------------------------------
/docs/images/hierarchy-item.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/docs/images/hierarchy-item.png
--------------------------------------------------------------------------------
/docs/images/icon-class-13x13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/docs/images/icon-class-13x13.png
--------------------------------------------------------------------------------
/docs/images/icon-class.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
16 |
18 |
19 |
21 | image/svg+xml
22 |
24 |
25 |
26 |
27 |
28 |
31 |
36 |
37 |
40 |
43 |
47 |
48 |
49 |
52 | I
62 |
63 |
66 | T
76 |
77 |
78 |
--------------------------------------------------------------------------------
/docs/images/icon-interface-13x13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/docs/images/icon-interface-13x13.png
--------------------------------------------------------------------------------
/docs/images/icon-interface.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
16 |
18 |
19 |
21 | image/svg+xml
22 |
24 |
25 |
26 |
27 |
28 |
31 |
36 |
37 |
40 |
43 |
47 |
48 |
49 |
52 |
55 |
59 |
60 |
61 |
64 |
67 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/docs/images/icon-trait-13x13.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/docs/images/icon-trait-13x13.png
--------------------------------------------------------------------------------
/docs/images/icon-trait.svg:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
14 |
16 |
18 |
19 |
21 | image/svg+xml
22 |
24 |
25 |
26 |
27 |
28 |
31 |
36 |
37 |
40 |
43 |
47 |
48 |
49 |
52 |
55 |
59 |
60 |
61 |
64 |
67 |
71 |
72 |
73 |
74 |
--------------------------------------------------------------------------------
/docs/images/iviewer/grab.cur:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/docs/images/iviewer/grab.cur
--------------------------------------------------------------------------------
/docs/images/iviewer/hand.cur:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/docs/images/iviewer/hand.cur
--------------------------------------------------------------------------------
/docs/images/iviewer/iviewer.rotate_left.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/docs/images/iviewer/iviewer.rotate_left.png
--------------------------------------------------------------------------------
/docs/images/iviewer/iviewer.rotate_right.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/docs/images/iviewer/iviewer.rotate_right.png
--------------------------------------------------------------------------------
/docs/images/iviewer/iviewer.zoom_fit.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/docs/images/iviewer/iviewer.zoom_fit.png
--------------------------------------------------------------------------------
/docs/images/iviewer/iviewer.zoom_in.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/docs/images/iviewer/iviewer.zoom_in.png
--------------------------------------------------------------------------------
/docs/images/iviewer/iviewer.zoom_out.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/docs/images/iviewer/iviewer.zoom_out.png
--------------------------------------------------------------------------------
/docs/images/iviewer/iviewer.zoom_zero.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/docs/images/iviewer/iviewer.zoom_zero.png
--------------------------------------------------------------------------------
/docs/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | API Documentation
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
86 |
87 |
88 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
\
118 |
119 |
120 |
121 |
122 |
Classes
123 |
129 |
130 |
131 |
132 |
133 | Namespace hierarchy
134 |
135 | \
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
178 |
179 |
180 |
181 | Documentation is powered by phpDocumentor and authored
182 | on
183 | Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /Users/imnikkilee/pear/share/pear/phpDocumentor/vendor/twig/twig/lib/Twig/Extension/Core.php on line 89
184 | September 29th, 2014 at 23:57.
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
--------------------------------------------------------------------------------
/docs/js/jquery.dotdotdot-1.5.9.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jQuery dotdotdot 1.5.9
3 | *
4 | * Copyright (c) 2013 Fred Heusschen
5 | * www.frebsite.nl
6 | *
7 | * Plugin website:
8 | * dotdotdot.frebsite.nl
9 | *
10 | * Dual licensed under the MIT and GPL licenses.
11 | * http://en.wikipedia.org/wiki/MIT_License
12 | * http://en.wikipedia.org/wiki/GNU_General_Public_License
13 | */
14 |
15 | (function( $ )
16 | {
17 | if ( $.fn.dotdotdot )
18 | {
19 | return;
20 | }
21 |
22 | $.fn.dotdotdot = function( o )
23 | {
24 | if ( this.length == 0 )
25 | {
26 | if ( !o || o.debug !== false )
27 | {
28 | debug( true, 'No element found for "' + this.selector + '".' );
29 | }
30 | return this;
31 | }
32 | if ( this.length > 1 )
33 | {
34 | return this.each(
35 | function()
36 | {
37 | $(this).dotdotdot( o );
38 | }
39 | );
40 | }
41 |
42 |
43 | var $dot = this;
44 |
45 | if ( $dot.data( 'dotdotdot' ) )
46 | {
47 | $dot.trigger( 'destroy.dot' );
48 | }
49 |
50 | $dot.data( 'dotdotdot-style', $dot.attr( 'style' ) );
51 | $dot.css( 'word-wrap', 'break-word' );
52 |
53 | $dot.bind_events = function()
54 | {
55 | $dot.bind(
56 | 'update.dot',
57 | function( e, c )
58 | {
59 | e.preventDefault();
60 | e.stopPropagation();
61 |
62 | opts.maxHeight = ( typeof opts.height == 'number' )
63 | ? opts.height
64 | : getTrueInnerHeight( $dot );
65 |
66 | opts.maxHeight += opts.tolerance;
67 |
68 | if ( typeof c != 'undefined' )
69 | {
70 | if ( typeof c == 'string' || c instanceof HTMLElement )
71 | {
72 | c = $('
').append( c ).contents();
73 | }
74 | if ( c instanceof $ )
75 | {
76 | orgContent = c;
77 | }
78 | }
79 |
80 | $inr = $dot.wrapInner( '
' ).children();
81 | $inr.empty()
82 | .append( orgContent.clone( true ) )
83 | .css({
84 | 'height' : 'auto',
85 | 'width' : 'auto',
86 | 'border' : 'none',
87 | 'padding' : 0,
88 | 'margin' : 0
89 | });
90 |
91 | var after = false,
92 | trunc = false;
93 |
94 | if ( conf.afterElement )
95 | {
96 | after = conf.afterElement.clone( true );
97 | conf.afterElement.remove();
98 | }
99 | if ( test( $inr, opts ) )
100 | {
101 | if ( opts.wrap == 'children' )
102 | {
103 | trunc = children( $inr, opts, after );
104 | }
105 | else
106 | {
107 | trunc = ellipsis( $inr, $dot, $inr, opts, after );
108 | }
109 | }
110 | $inr.replaceWith( $inr.contents() );
111 | $inr = null;
112 |
113 | if ( $.isFunction( opts.callback ) )
114 | {
115 | opts.callback.call( $dot[ 0 ], trunc, orgContent );
116 | }
117 |
118 | conf.isTruncated = trunc;
119 | return trunc;
120 | }
121 |
122 | ).bind(
123 | 'isTruncated.dot',
124 | function( e, fn )
125 | {
126 | e.preventDefault();
127 | e.stopPropagation();
128 |
129 | if ( typeof fn == 'function' )
130 | {
131 | fn.call( $dot[ 0 ], conf.isTruncated );
132 | }
133 | return conf.isTruncated;
134 | }
135 |
136 | ).bind(
137 | 'originalContent.dot',
138 | function( e, fn )
139 | {
140 | e.preventDefault();
141 | e.stopPropagation();
142 |
143 | if ( typeof fn == 'function' )
144 | {
145 | fn.call( $dot[ 0 ], orgContent );
146 | }
147 | return orgContent;
148 | }
149 |
150 | ).bind(
151 | 'destroy.dot',
152 | function( e )
153 | {
154 | e.preventDefault();
155 | e.stopPropagation();
156 |
157 | $dot.unwatch()
158 | .unbind_events()
159 | .empty()
160 | .append( orgContent )
161 | .attr( 'style', $dot.data( 'dotdotdot-style' ) )
162 | .data( 'dotdotdot', false );
163 | }
164 | );
165 | return $dot;
166 | }; // /bind_events
167 |
168 | $dot.unbind_events = function()
169 | {
170 | $dot.unbind('.dot');
171 | return $dot;
172 | }; // /unbind_events
173 |
174 | $dot.watch = function()
175 | {
176 | $dot.unwatch();
177 | if ( opts.watch == 'window' )
178 | {
179 | var $window = $(window),
180 | _wWidth = $window.width(),
181 | _wHeight = $window.height();
182 |
183 | $window.bind(
184 | 'resize.dot' + conf.dotId,
185 | function()
186 | {
187 | if ( _wWidth != $window.width() || _wHeight != $window.height() || !opts.windowResizeFix )
188 | {
189 | _wWidth = $window.width();
190 | _wHeight = $window.height();
191 |
192 | if ( watchInt )
193 | {
194 | clearInterval( watchInt );
195 | }
196 | watchInt = setTimeout(
197 | function()
198 | {
199 | $dot.trigger( 'update.dot' );
200 | }, 10
201 | );
202 | }
203 | }
204 | );
205 | }
206 | else
207 | {
208 | watchOrg = getSizes( $dot );
209 | watchInt = setInterval(
210 | function()
211 | {
212 | var watchNew = getSizes( $dot );
213 | if ( watchOrg.width != watchNew.width ||
214 | watchOrg.height != watchNew.height )
215 | {
216 | $dot.trigger( 'update.dot' );
217 | watchOrg = getSizes( $dot );
218 | }
219 | }, 100
220 | );
221 | }
222 | return $dot;
223 | };
224 | $dot.unwatch = function()
225 | {
226 | $(window).unbind( 'resize.dot' + conf.dotId );
227 | if ( watchInt )
228 | {
229 | clearInterval( watchInt );
230 | }
231 | return $dot;
232 | };
233 |
234 | var orgContent = $dot.contents(),
235 | opts = $.extend( true, {}, $.fn.dotdotdot.defaults, o ),
236 | conf = {},
237 | watchOrg = {},
238 | watchInt = null,
239 | $inr = null;
240 |
241 | conf.afterElement = getElement( opts.after, $dot );
242 | conf.isTruncated = false;
243 | conf.dotId = dotId++;
244 |
245 |
246 | $dot.data( 'dotdotdot', true )
247 | .bind_events()
248 | .trigger( 'update.dot' );
249 |
250 | if ( opts.watch )
251 | {
252 | $dot.watch();
253 | }
254 |
255 | return $dot;
256 | };
257 |
258 |
259 | // public
260 | $.fn.dotdotdot.defaults = {
261 | 'ellipsis' : '... ',
262 | 'wrap' : 'word',
263 | 'lastCharacter': {
264 | 'remove' : [ ' ', ',', ';', '.', '!', '?' ],
265 | 'noEllipsis' : []
266 | },
267 | 'tolerance' : 0,
268 | 'callback' : null,
269 | 'after' : null,
270 | 'height' : null,
271 | 'watch' : false,
272 | 'windowResizeFix': true,
273 | 'debug' : false
274 | };
275 |
276 |
277 | // private
278 | var dotId = 1;
279 |
280 | function children( $elem, o, after )
281 | {
282 | var $elements = $elem.children(),
283 | isTruncated = false;
284 |
285 | $elem.empty();
286 |
287 | for ( var a = 0, l = $elements.length; a < l; a++ )
288 | {
289 | var $e = $elements.eq( a );
290 | $elem.append( $e );
291 | if ( after )
292 | {
293 | $elem.append( after );
294 | }
295 | if ( test( $elem, o ) )
296 | {
297 | $e.remove();
298 | isTruncated = true;
299 | break;
300 | }
301 | else
302 | {
303 | if ( after )
304 | {
305 | after.remove();
306 | }
307 | }
308 | }
309 | return isTruncated;
310 | }
311 | function ellipsis( $elem, $d, $i, o, after )
312 | {
313 | var $elements = $elem.contents(),
314 | isTruncated = false;
315 |
316 | $elem.empty();
317 |
318 | var notx = 'table, thead, tbody, tfoot, tr, col, colgroup, object, embed, param, ol, ul, dl, select, optgroup, option, textarea, script, style';
319 | for ( var a = 0, l = $elements.length; a < l; a++ )
320 | {
321 |
322 | if ( isTruncated )
323 | {
324 | break;
325 | }
326 |
327 | var e = $elements[ a ],
328 | $e = $(e);
329 |
330 | if ( typeof e == 'undefined' )
331 | {
332 | continue;
333 | }
334 |
335 | $elem.append( $e );
336 | if ( after )
337 | {
338 | $elem[ ( $elem.is( notx ) ) ? 'after' : 'append' ]( after );
339 | }
340 | if ( e.nodeType == 3 )
341 | {
342 | if ( test( $i, o ) )
343 | {
344 | isTruncated = ellipsisElement( $e, $d, $i, o, after );
345 | }
346 | }
347 | else
348 | {
349 | isTruncated = ellipsis( $e, $d, $i, o, after );
350 | }
351 |
352 | if ( !isTruncated )
353 | {
354 | if ( after )
355 | {
356 | after.remove();
357 | }
358 | }
359 | }
360 | return isTruncated;
361 | }
362 | function ellipsisElement( $e, $d, $i, o, after )
363 | {
364 | var isTruncated = false,
365 | e = $e[ 0 ];
366 |
367 | if ( typeof e == 'undefined' )
368 | {
369 | return false;
370 | }
371 |
372 | var seporator = ( o.wrap == 'letter' ) ? '' : ' ',
373 | textArr = getTextContent( e ).split( seporator ),
374 | position = -1,
375 | midPos = -1,
376 | startPos = 0,
377 | endPos = textArr.length - 1;
378 |
379 | while ( startPos <= endPos )
380 | {
381 | var m = Math.floor( ( startPos + endPos ) / 2 );
382 | if ( m == midPos )
383 | {
384 | break;
385 | }
386 | midPos = m;
387 |
388 | setTextContent( e, textArr.slice( 0, midPos + 1 ).join( seporator ) + o.ellipsis );
389 |
390 | if ( !test( $i, o ) )
391 | {
392 | position = midPos;
393 | startPos = midPos;
394 | }
395 | else
396 | {
397 | endPos = midPos;
398 | }
399 | }
400 |
401 | if ( position != -1 && !( textArr.length == 1 && textArr[ 0 ].length == 0 ) )
402 | {
403 | var txt = addEllipsis( textArr.slice( 0, position + 1 ).join( seporator ), o );
404 | isTruncated = true;
405 | setTextContent( e, txt );
406 | }
407 | else
408 | {
409 | var $w = $e.parent();
410 | $e.remove();
411 |
412 | var afterLength = ( after ) ? after.length : 0 ;
413 |
414 | if ( $w.contents().size() > afterLength )
415 | {
416 | var $n = $w.contents().eq( -1 - afterLength );
417 | isTruncated = ellipsisElement( $n, $d, $i, o, after );
418 | }
419 | else
420 | {
421 | var $p = $w.prev()
422 | var e = $p.contents().eq( -1 )[ 0 ];
423 |
424 | if ( typeof e != 'undefined' )
425 | {
426 | var txt = addEllipsis( getTextContent( e ), o );
427 | setTextContent( e, txt );
428 | if ( after )
429 | {
430 | $p.append( after );
431 | }
432 | $w.remove();
433 | isTruncated = true;
434 | }
435 |
436 | }
437 | }
438 |
439 | return isTruncated;
440 | }
441 | function test( $i, o )
442 | {
443 | return $i.innerHeight() > o.maxHeight;
444 | }
445 | function addEllipsis( txt, o )
446 | {
447 | while( $.inArray( txt.slice( -1 ), o.lastCharacter.remove ) > -1 )
448 | {
449 | txt = txt.slice( 0, -1 );
450 | }
451 | if ( $.inArray( txt.slice( -1 ), o.lastCharacter.noEllipsis ) < 0 )
452 | {
453 | txt += o.ellipsis;
454 | }
455 | return txt;
456 | }
457 | function getSizes( $d )
458 | {
459 | return {
460 | 'width' : $d.innerWidth(),
461 | 'height': $d.innerHeight()
462 | };
463 | }
464 | function setTextContent( e, content )
465 | {
466 | if ( e.innerText )
467 | {
468 | e.innerText = content;
469 | }
470 | else if ( e.nodeValue )
471 | {
472 | e.nodeValue = content;
473 | }
474 | else if (e.textContent)
475 | {
476 | e.textContent = content;
477 | }
478 |
479 | }
480 | function getTextContent( e )
481 | {
482 | if ( e.innerText )
483 | {
484 | return e.innerText;
485 | }
486 | else if ( e.nodeValue )
487 | {
488 | return e.nodeValue;
489 | }
490 | else if ( e.textContent )
491 | {
492 | return e.textContent;
493 | }
494 | else
495 | {
496 | return "";
497 | }
498 | }
499 | function getElement( e, $i )
500 | {
501 | if ( typeof e == 'undefined' )
502 | {
503 | return false;
504 | }
505 | if ( !e )
506 | {
507 | return false;
508 | }
509 | if ( typeof e == 'string' )
510 | {
511 | e = $(e, $i);
512 | return ( e.length )
513 | ? e
514 | : false;
515 | }
516 | if ( typeof e == 'object' )
517 | {
518 | return ( typeof e.jquery == 'undefined' )
519 | ? false
520 | : e;
521 | }
522 | return false;
523 | }
524 | function getTrueInnerHeight( $el )
525 | {
526 | var h = $el.innerHeight(),
527 | a = [ 'paddingTop', 'paddingBottom' ];
528 |
529 | for ( var z = 0, l = a.length; z < l; z++ ) {
530 | var m = parseInt( $el.css( a[ z ] ), 10 );
531 | if ( isNaN( m ) )
532 | {
533 | m = 0;
534 | }
535 | h -= m;
536 | }
537 | return h;
538 | }
539 | function debug( d, m )
540 | {
541 | if ( !d )
542 | {
543 | return false;
544 | }
545 | if ( typeof m == 'string' )
546 | {
547 | m = 'dotdotdot: ' + m;
548 | }
549 | else
550 | {
551 | m = [ 'dotdotdot:', m ];
552 | }
553 |
554 | if ( typeof window.console != 'undefined' )
555 | {
556 | if ( typeof window.console.log != 'undefined' )
557 | {
558 | window.console.log( m );
559 | }
560 | }
561 | return false;
562 | }
563 |
564 |
565 | // override jQuery.html
566 | var _orgHtml = $.fn.html;
567 | $.fn.html = function( str ) {
568 | if ( typeof str != 'undefined' )
569 | {
570 | if ( this.data( 'dotdotdot' ) )
571 | {
572 | if ( typeof str != 'function' )
573 | {
574 | return this.trigger( 'update', [ str ] );
575 | }
576 | }
577 | return _orgHtml.call( this, str );
578 | }
579 | return _orgHtml.call( this );
580 | };
581 |
582 |
583 | // override jQuery.text
584 | var _orgText = $.fn.text;
585 | $.fn.text = function( str ) {
586 | if ( typeof str != 'undefined' )
587 | {
588 | if ( this.data( 'dotdotdot' ) )
589 | {
590 | var temp = $( '
' );
591 | temp.text( str );
592 | str = temp.html();
593 | temp.remove();
594 | return this.trigger( 'update', [ str ] );
595 | }
596 | return _orgText.call( this, str );
597 | }
598 | return _orgText.call( this );
599 | };
600 |
601 |
602 | })( jQuery );
603 |
--------------------------------------------------------------------------------
/docs/js/jquery.dotdotdot-1.5.9.min.js:
--------------------------------------------------------------------------------
1 | /*
2 | * jQuery dotdotdot 1.5.9
3 | *
4 | * Copyright (c) 2013 Fred Heusschen
5 | * www.frebsite.nl
6 | *
7 | * Plugin website:
8 | * dotdotdot.frebsite.nl
9 | *
10 | * Dual licensed under the MIT and GPL licenses.
11 | * http://en.wikipedia.org/wiki/MIT_License
12 | * http://en.wikipedia.org/wiki/GNU_General_Public_License
13 | */
14 |
15 | (function(a){function c(a,b,c){var d=a.children(),e=!1;a.empty();for(var g=0,h=d.length;h>g;g++){var i=d.eq(g);if(a.append(i),c&&a.append(c),f(a,b)){i.remove(),e=!0;break}c&&c.remove()}return e}function d(b,c,g,h,i){var j=b.contents(),k=!1;b.empty();for(var l="table, thead, tbody, tfoot, tr, col, colgroup, object, embed, param, ol, ul, dl, select, optgroup, option, textarea, script, style",m=0,n=j.length;n>m&&!k;m++){var o=j[m],p=a(o);void 0!==o&&(b.append(p),i&&b[b.is(l)?"after":"append"](i),3==o.nodeType?f(g,h)&&(k=e(p,c,g,h,i)):k=d(p,c,g,h,i),k||i&&i.remove())}return k}function e(a,b,c,d,h){var k=!1,l=a[0];if(l===void 0)return!1;for(var m="letter"==d.wrap?"":" ",n=j(l).split(m),o=-1,p=-1,q=0,r=n.length-1;r>=q;){var s=Math.floor((q+r)/2);if(s==p)break;p=s,i(l,n.slice(0,p+1).join(m)+d.ellipsis),f(c,d)?r=p:(o=p,q=p)}if(-1==o||1==n.length&&0==n[0].length){var u=a.parent();a.remove();var v=h?h.length:0;if(u.contents().size()>v){var w=u.contents().eq(-1-v);k=e(w,b,c,d,h)}else{var x=u.prev(),l=x.contents().eq(-1)[0];if(l!==void 0){var t=g(j(l),d);i(l,t),h&&x.append(h),u.remove(),k=!0}}}else{var t=g(n.slice(0,o+1).join(m),d);k=!0,i(l,t)}return k}function f(a,b){return a.innerHeight()>b.maxHeight}function g(b,c){for(;a.inArray(b.slice(-1),c.lastCharacter.remove)>-1;)b=b.slice(0,-1);return 0>a.inArray(b.slice(-1),c.lastCharacter.noEllipsis)&&(b+=c.ellipsis),b}function h(a){return{width:a.innerWidth(),height:a.innerHeight()}}function i(a,b){a.innerText?a.innerText=b:a.nodeValue?a.nodeValue=b:a.textContent&&(a.textContent=b)}function j(a){return a.innerText?a.innerText:a.nodeValue?a.nodeValue:a.textContent?a.textContent:""}function k(b,c){return b===void 0?!1:b?"string"==typeof b?(b=a(b,c),b.length?b:!1):"object"==typeof b?b.jquery===void 0?!1:b:!1:!1}function l(a){for(var b=a.innerHeight(),c=["paddingTop","paddingBottom"],d=0,e=c.length;e>d;d++){var f=parseInt(a.css(c[d]),10);isNaN(f)&&(f=0),b-=f}return b}function m(a,b){return a?(b="string"==typeof b?"dotdotdot: "+b:["dotdotdot:",b],window.console!==void 0&&window.console.log!==void 0&&window.console.log(b),!1):!1}if(!a.fn.dotdotdot){a.fn.dotdotdot=function(e){if(0==this.length)return e&&e.debug===!1||m(!0,'No element found for "'+this.selector+'".'),this;if(this.length>1)return this.each(function(){a(this).dotdotdot(e)});var g=this;g.data("dotdotdot")&&g.trigger("destroy.dot"),g.data("dotdotdot-style",g.attr("style")),g.css("word-wrap","break-word"),g.bind_events=function(){return g.bind("update.dot",function(b,e){b.preventDefault(),b.stopPropagation(),j.maxHeight="number"==typeof j.height?j.height:l(g),j.maxHeight+=j.tolerance,e!==void 0&&(("string"==typeof e||e instanceof HTMLElement)&&(e=a("
").append(e).contents()),e instanceof a&&(i=e)),q=g.wrapInner('
').children(),q.empty().append(i.clone(!0)).css({height:"auto",width:"auto",border:"none",padding:0,margin:0});var h=!1,k=!1;return n.afterElement&&(h=n.afterElement.clone(!0),n.afterElement.remove()),f(q,j)&&(k="children"==j.wrap?c(q,j,h):d(q,g,q,j,h)),q.replaceWith(q.contents()),q=null,a.isFunction(j.callback)&&j.callback.call(g[0],k,i),n.isTruncated=k,k}).bind("isTruncated.dot",function(a,b){return a.preventDefault(),a.stopPropagation(),"function"==typeof b&&b.call(g[0],n.isTruncated),n.isTruncated}).bind("originalContent.dot",function(a,b){return a.preventDefault(),a.stopPropagation(),"function"==typeof b&&b.call(g[0],i),i}).bind("destroy.dot",function(a){a.preventDefault(),a.stopPropagation(),g.unwatch().unbind_events().empty().append(i).attr("style",g.data("dotdotdot-style")).data("dotdotdot",!1)}),g},g.unbind_events=function(){return g.unbind(".dot"),g},g.watch=function(){if(g.unwatch(),"window"==j.watch){var b=a(window),c=b.width(),d=b.height();b.bind("resize.dot"+n.dotId,function(){c==b.width()&&d==b.height()&&j.windowResizeFix||(c=b.width(),d=b.height(),p&&clearInterval(p),p=setTimeout(function(){g.trigger("update.dot")},10))})}else o=h(g),p=setInterval(function(){var a=h(g);(o.width!=a.width||o.height!=a.height)&&(g.trigger("update.dot"),o=h(g))},100);return g},g.unwatch=function(){return a(window).unbind("resize.dot"+n.dotId),p&&clearInterval(p),g};var i=g.contents(),j=a.extend(!0,{},a.fn.dotdotdot.defaults,e),n={},o={},p=null,q=null;return n.afterElement=k(j.after,g),n.isTruncated=!1,n.dotId=b++,g.data("dotdotdot",!0).bind_events().trigger("update.dot"),j.watch&&g.watch(),g},a.fn.dotdotdot.defaults={ellipsis:"... ",wrap:"word",lastCharacter:{remove:[" ",",",";",".","!","?"],noEllipsis:[]},tolerance:0,callback:null,after:null,height:null,watch:!1,windowResizeFix:!0,debug:!1};var b=1,n=a.fn.html;a.fn.html=function(a){return a!==void 0?this.data("dotdotdot")&&"function"!=typeof a?this.trigger("update",[a]):n.call(this,a):n.call(this)};var o=a.fn.text;a.fn.text=function(b){if(b!==void 0){if(this.data("dotdotdot")){var c=a("
");return c.text(b),b=c.html(),c.remove(),this.trigger("update",[b])}return o.call(this,b)}return o.call(this)}}})(jQuery);
--------------------------------------------------------------------------------
/docs/js/jquery.smooth-scroll.js:
--------------------------------------------------------------------------------
1 | $(document).ready(function() {
2 | function filterPath(string) {
3 | return string
4 | .replace(/^\//,'')
5 | .replace(/(index|default).[a-zA-Z]{3,4}$/,'')
6 | .replace(/\/$/,'');
7 | }
8 | var locationPath = filterPath(location.pathname);
9 |
10 | $('a[href*=#]').each(function() {
11 | var thisPath = filterPath(this.pathname) || locationPath;
12 | if ( locationPath == thisPath
13 | && (location.hostname == this.hostname || !this.hostname)
14 | && this.hash.replace(/#/,'') ) {
15 | var $target = $(this.hash), target = this.hash;
16 | if (target) {
17 | $(this).click(function(event) {
18 | if (!$(this.hash).offset()) {
19 | return;
20 | }
21 |
22 | event.preventDefault();
23 | position = $(this.hash).offset().top;
24 |
25 | $('html,body').animate({scrollTop: position}, 400, function() {
26 | location.hash = target;
27 | });
28 | });
29 | }
30 | }
31 | });
32 | });
33 |
--------------------------------------------------------------------------------
/docs/js/prism.min.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Prism: Lightweight, robust, elegant syntax highlighting
3 | * MIT license http://www.opensource.org/licenses/mit-license.php/
4 | * @author Lea Verou http://lea.verou.me
5 | */(function(){var e=/\blang(?:uage)?-(?!\*)(\w+)\b/i,t=self.Prism={util:{type:function(e){return Object.prototype.toString.call(e).match(/\[object (\w+)\]/)[1]},clone:function(e){var n=t.util.type(e);switch(n){case"Object":var r={};for(var i in e)e.hasOwnProperty(i)&&(r[i]=t.util.clone(e[i]));return r;case"Array":return e.slice()}return e}},languages:{extend:function(e,n){var r=t.util.clone(t.languages[e]);for(var i in n)r[i]=n[i];return r},insertBefore:function(e,n,r,i){i=i||t.languages;var s=i[e],o={};for(var u in s)if(s.hasOwnProperty(u)){if(u==n)for(var a in r)r.hasOwnProperty(a)&&(o[a]=r[a]);o[u]=s[u]}return i[e]=o},DFS:function(e,n){for(var r in e){n.call(e,r,e[r]);t.util.type(e)==="Object"&&t.languages.DFS(e[r],n)}}},highlightAll:function(e,n){var r=document.querySelectorAll('code[class*="language-"], [class*="language-"] code, code[class*="lang-"], [class*="lang-"] code');for(var i=0,s;s=r[i++];)t.highlightElement(s,e===!0,n)},highlightElement:function(r,i,s){var o,u,a=r;while(a&&!e.test(a.className))a=a.parentNode;if(a){o=(a.className.match(e)||[,""])[1];u=t.languages[o]}if(!u)return;r.className=r.className.replace(e,"").replace(/\s+/g," ")+" language-"+o;a=r.parentNode;/pre/i.test(a.nodeName)&&(a.className=a.className.replace(e,"").replace(/\s+/g," ")+" language-"+o);var f=r.textContent;if(!f)return;f=f.replace(/&/g,"&").replace(/e.length)break e;if(p instanceof i)continue;a.lastIndex=0;var d=a.exec(p);if(d){l&&(c=d[1].length);var v=d.index-1+c,d=d[0].slice(c),m=d.length,g=v+m,y=p.slice(0,v+1),b=p.slice(g+1),w=[h,1];y&&w.push(y);var E=new i(u,f?t.tokenize(d,f):d);w.push(E);b&&w.push(b);Array.prototype.splice.apply(s,w)}}}return s},hooks:{all:{},add:function(e,n){var r=t.hooks.all;r[e]=r[e]||[];r[e].push(n)},run:function(e,n){var r=t.hooks.all[e];if(!r||!r.length)return;for(var i=0,s;s=r[i++];)s(n)}}},n=t.Token=function(e,t){this.type=e;this.content=t};n.stringify=function(e,r,i){if(typeof e=="string")return e;if(Object.prototype.toString.call(e)=="[object Array]")return e.map(function(t){return n.stringify(t,r,e)}).join("");var s={type:e.type,content:n.stringify(e.content,r,i),tag:"span",classes:["token",e.type],attributes:{},language:r,parent:i};s.type=="comment"&&(s.attributes.spellcheck="true");t.hooks.run("wrap",s);var o="";for(var u in s.attributes)o+=u+'="'+(s.attributes[u]||"")+'"';return"<"+s.tag+' class="'+s.classes.join(" ")+'" '+o+">"+s.content+""+s.tag+">"};if(!self.document){self.addEventListener("message",function(e){var n=JSON.parse(e.data),r=n.language,i=n.code;self.postMessage(JSON.stringify(t.tokenize(i,t.languages[r])));self.close()},!1);return}var r=document.getElementsByTagName("script");r=r[r.length-1];if(r){t.filename=r.src;document.addEventListener&&!r.hasAttribute("data-manual")&&document.addEventListener("DOMContentLoaded",t.highlightAll)}})();;
6 | Prism.languages.markup={comment:/<!--[\w\W]*?-->/g,prolog:/<\?.+?\?>/,doctype:/<!DOCTYPE.+?>/,cdata:/<!\[CDATA\[[\w\W]*?]]>/i,tag:{pattern:/<\/?[\w:-]+\s*(?:\s+[\w:-]+(?:=(?:("|')(\\?[\w\W])*?\1|\w+))?\s*)*\/?>/gi,inside:{tag:{pattern:/^<\/?[\w:-]+/i,inside:{punctuation:/^<\/?/,namespace:/^[\w-]+?:/}},"attr-value":{pattern:/=(?:('|")[\w\W]*?(\1)|[^\s>]+)/gi,inside:{punctuation:/=|>|"/g}},punctuation:/\/?>/g,"attr-name":{pattern:/[\w:-]+/g,inside:{namespace:/^[\w-]+?:/}}}},entity:/&#?[\da-z]{1,8};/gi};Prism.hooks.add("wrap",function(e){e.type==="entity"&&(e.attributes.title=e.content.replace(/&/,"&"))});;
7 | Prism.languages.css={comment:/\/\*[\w\W]*?\*\//g,atrule:{pattern:/@[\w-]+?.*?(;|(?=\s*{))/gi,inside:{punctuation:/[;:]/g}},url:/url\((["']?).*?\1\)/gi,selector:/[^\{\}\s][^\{\};]*(?=\s*\{)/g,property:/(\b|\B)[\w-]+(?=\s*:)/ig,string:/("|')(\\?.)*?\1/g,important:/\B!important\b/gi,ignore:/&(lt|gt|amp);/gi,punctuation:/[\{\};:]/g};Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{style:{pattern:/(<|<)style[\w\W]*?(>|>)[\w\W]*?(<|<)\/style(>|>)/ig,inside:{tag:{pattern:/(<|<)style[\w\W]*?(>|>)|(<|<)\/style(>|>)/ig,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.css}}});;
8 | Prism.languages.css.selector={pattern:/[^\{\}\s][^\{\}]*(?=\s*\{)/g,inside:{"pseudo-element":/:(?:after|before|first-letter|first-line|selection)|::[-\w]+/g,"pseudo-class":/:[-\w]+(?:\(.*\))?/g,"class":/\.[-:\.\w]+/g,id:/#[-:\.\w]+/g}};Prism.languages.insertBefore("css","ignore",{hexcode:/#[\da-f]{3,6}/gi,entity:/\\[\da-f]{1,8}/gi,number:/[\d%\.]+/g,"function":/(attr|calc|cross-fade|cycle|element|hsla?|image|lang|linear-gradient|matrix3d|matrix|perspective|radial-gradient|repeating-linear-gradient|repeating-radial-gradient|rgba?|rotatex|rotatey|rotatez|rotate3d|rotate|scalex|scaley|scalez|scale3d|scale|skewx|skewy|skew|steps|translatex|translatey|translatez|translate3d|translate|url|var)/ig});;
9 | Prism.languages.clike={comment:{pattern:/(^|[^\\])(\/\*[\w\W]*?\*\/|(^|[^:])\/\/.*?(\r?\n|$))/g,lookbehind:!0},string:/("|')(\\?.)*?\1/g,"class-name":{pattern:/((?:(?:class|interface|extends|implements|trait|instanceof|new)\s+)|(?:catch\s+\())[a-z0-9_\.\\]+/ig,lookbehind:!0,inside:{punctuation:/(\.|\\)/}},keyword:/\b(if|else|while|do|for|return|in|instanceof|function|new|try|catch|finally|null|break|continue)\b/g,"boolean":/\b(true|false)\b/g,"function":{pattern:/[a-z0-9_]+\(/ig,inside:{punctuation:/\(/}}, number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?)\b/g,operator:/[-+]{1,2}|!|<=?|>=?|={1,3}|(&){1,2}|\|?\||\?|\*|\/|\~|\^|\%/g,ignore:/&(lt|gt|amp);/gi,punctuation:/[{}[\];(),.:]/g};;
10 | Prism.languages.javascript=Prism.languages.extend("clike",{keyword:/\b(var|let|if|else|while|do|for|return|in|instanceof|function|new|with|typeof|try|catch|finally|null|break|continue)\b/g,number:/\b-?(0x[\dA-Fa-f]+|\d*\.?\d+([Ee]-?\d+)?|NaN|-?Infinity)\b/g});Prism.languages.insertBefore("javascript","keyword",{regex:{pattern:/(^|[^/])\/(?!\/)(\[.+?]|\\.|[^/\r\n])+\/[gim]{0,3}(?=\s*($|[\r\n,.;})]))/g,lookbehind:!0}});Prism.languages.markup&&Prism.languages.insertBefore("markup","tag",{script:{pattern:/(<|<)script[\w\W]*?(>|>)[\w\W]*?(<|<)\/script(>|>)/ig,inside:{tag:{pattern:/(<|<)script[\w\W]*?(>|>)|(<|<)\/script(>|>)/ig,inside:Prism.languages.markup.tag.inside},rest:Prism.languages.javascript}}});;
11 | Prism.languages.php=Prism.languages.extend("clike",{keyword:/\b(and|or|xor|array|as|break|case|cfunction|class|const|continue|declare|default|die|do|else|elseif|enddeclare|endfor|endforeach|endif|endswitch|endwhile|extends|for|foreach|function|include|include_once|global|if|new|return|static|switch|use|require|require_once|var|while|abstract|interface|public|implements|extends|private|protected|parent|static|throw|null|echo|print|trait|namespace|use|final|yield|goto|instanceof|finally|try|catch)\b/ig, constant:/\b[A-Z0-9_]{2,}\b/g});Prism.languages.insertBefore("php","keyword",{delimiter:/(\?>|<\?php|<\?)/ig,variable:/(\$\w+)\b/ig,"package":{pattern:/(\\|namespace\s+|use\s+)[\w\\]+/g,lookbehind:!0,inside:{punctuation:/\\/}}});Prism.languages.insertBefore("php","operator",{property:{pattern:/(->)[\w]+/g,lookbehind:!0}}); Prism.languages.markup&&(Prism.hooks.add("before-highlight",function(a){"php"===a.language&&(a.tokenStack=[],a.code=a.code.replace(/(?:<\?php|<\?|<\?php|<\?)[\w\W]*?(?:\?>|\?>)/ig,function(b){a.tokenStack.push(b);return"{{{PHP"+a.tokenStack.length+"}}}"}))}),Prism.hooks.add("after-highlight",function(a){if("php"===a.language){for(var b=0,c;c=a.tokenStack[b];b++)a.highlightedCode=a.highlightedCode.replace("{{{PHP"+(b+1)+"}}}",Prism.highlight(c,a.grammar,"php"));a.element.innerHTML=a.highlightedCode}}), Prism.hooks.add("wrap",function(a){"php"===a.language&&"markup"===a.type&&(a.content=a.content.replace(/(\{\{\{PHP[0-9]+\}\}\})/g,'$1 '))}),Prism.languages.insertBefore("php","comment",{markup:{pattern:/(<|<)[^?]\/?(.*?)(>|>)/g,inside:Prism.languages.markup},php:/\{\{\{PHP[0-9]+\}\}\}/g}));;
12 | Prism.languages.insertBefore("php","variable",{"this":/\$this/g,global:/\$_?(GLOBALS|SERVER|GET|POST|FILES|REQUEST|SESSION|ENV|COOKIE|HTTP_RAW_POST_DATA|argc|argv|php_errormsg|http_response_header)/g,scope:{pattern:/\b[\w\\]+::/g,inside:{keyword:/(static|self|parent)/,punctuation:/(::|\\)/}}});;
13 | (function(){function e(e,t){return Array.prototype.slice.call((t||document).querySelectorAll(e))}function n(e,t,n){var r=t.replace(/\s+/g,"").split(","),i=+e.getAttribute("data-line-offset")||0,s=parseFloat(getComputedStyle(e).lineHeight);for(var o=0,u;u=r[o++];){u=u.split("-");var a=+u[0],f=+u[1]||a,l=document.createElement("div");l.textContent=Array(f-a+2).join(" \r\n");l.className=(n||"")+" line-highlight";l.setAttribute("data-start",a);f>a&&l.setAttribute("data-end",f);l.style.top=(a-i-1)*s+"px";(e.querySelector("code")||e).appendChild(l)}}function r(){var t=location.hash.slice(1);e(".temporary.line-highlight").forEach(function(e){e.parentNode.removeChild(e)});var r=(t.match(/\.([\d,-]+)$/)||[,""])[1];if(!r||document.getElementById(t))return;var i=t.slice(0,t.lastIndexOf(".")),s=document.getElementById(i);if(!s)return;s.hasAttribute("data-line")||s.setAttribute("data-line","");n(s,r,"temporary ");document.querySelector(".temporary.line-highlight").scrollIntoView()}if(!window.Prism)return;var t=crlf=/\r?\n|\r/g,i=0;Prism.hooks.add("after-highlight",function(t){var s=t.element.parentNode,o=s&&s.getAttribute("data-line");if(!s||!o||!/pre/i.test(s.nodeName))return;clearTimeout(i);e(".line-highlight",s).forEach(function(e){e.parentNode.removeChild(e)});n(s,o);i=setTimeout(r,1)});addEventListener("hashchange",r)})();;
14 | Prism.hooks.add("after-highlight",function(e){var t=e.element.parentNode;if(!t||!/pre/i.test(t.nodeName)||t.className.indexOf("line-numbers")===-1){return}var n=1+e.code.split("\n").length;var r;lines=new Array(n);lines=lines.join(" ");r=document.createElement("span");r.className="line-numbers-rows";r.innerHTML=lines;if(t.hasAttribute("data-start")){t.style.counterReset="linenumber "+(parseInt(t.getAttribute("data-start"),10)-1)}e.element.appendChild(r)})
15 | ;
16 | (function(){if(!self.Prism||!self.document||!document.querySelector)return;var e={js:"javascript",html:"markup",svg:"markup"};Array.prototype.slice.call(document.querySelectorAll("pre[data-src]")).forEach(function(t){var n=t.getAttribute("data-src"),r=(n.match(/\.(\w+)$/)||[,""])[1],i=e[r]||r,s=document.createElement("code");s.className="language-"+i;t.textContent="";s.textContent="Loading…";t.appendChild(s);var o=new XMLHttpRequest;o.open("GET",n,!0);o.onreadystatechange=function(){if(o.readyState==4)if(o.status<400&&o.responseText){s.textContent=o.responseText;Prism.highlightElement(s)}else o.status>=400?s.textContent="✖ Error "+o.status+" while fetching file: "+o.statusText:s.textContent="✖ Error: File does not exist or is empty"};o.send(null)})})();;
17 |
--------------------------------------------------------------------------------
/docs/namespaces/ImageCache.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | API Documentation
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
87 |
88 |
89 |
128 |
129 |
130 |
131 |
132 |
133 | \
134 |
135 |
\ ImageCache
136 |
137 |
138 |
139 |
140 |
Classes
141 |
147 |
148 |
149 |
150 |
151 | Namespace hierarchy
152 |
153 |
154 |
155 | \ImageCache
156 |
157 |
158 |
159 |
160 |
161 |
162 |
163 |
164 |
165 |
166 |
167 |
168 |
199 |
200 |
201 |
202 | Documentation is powered by phpDocumentor and authored
203 | on
204 | Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /usr/local/pear/share/pear/phpDocumentor/vendor/twig/twig/lib/Twig/Extension/Core.php on line 89
205 | February 4th, 2014 at 14:43.
206 |
207 |
208 |
209 |
210 |
211 |
212 |
213 |
214 |
--------------------------------------------------------------------------------
/docs/namespaces/default.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | API Documentation
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
86 |
87 |
88 |
110 |
111 |
112 |
113 |
114 |
115 |
116 |
117 |
\
118 |
119 |
120 |
121 |
122 |
Classes
123 |
129 |
130 |
131 |
132 |
133 | Namespace hierarchy
134 |
135 | \
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
147 |
148 |
178 |
179 |
180 |
181 | Documentation is powered by phpDocumentor and authored
182 | on
183 | Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /Users/imnikkilee/pear/share/pear/phpDocumentor/vendor/twig/twig/lib/Twig/Extension/Core.php on line 89
184 | September 29th, 2014 at 23:57.
185 |
186 |
187 |
188 |
189 |
190 |
191 |
192 |
193 |
--------------------------------------------------------------------------------
/docs/phpdoc-cache-2e/phpdoc-cache-settings.dat:
--------------------------------------------------------------------------------
1 | O:51:"phpDocumentor\Descriptor\ProjectDescriptor\Settings":2:{s:13:" * isModified";b:0;s:13:" * visibility";i:7;}
--------------------------------------------------------------------------------
/docs/reports/deprecated.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | » Deprecated elements
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
87 |
88 |
89 |
90 |
91 |
96 |
97 |
98 |
99 | \
100 | Deprecated elements
101 |
102 |
103 |
104 |
No deprecated elements have been found in this project.
105 |
106 |
107 |
108 |
109 |
110 |
111 |
141 |
142 |
143 |
144 | Documentation is powered by phpDocumentor and authored
145 | on
146 | Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /Users/imnikkilee/pear/share/pear/phpDocumentor/vendor/twig/twig/lib/Twig/Extension/Core.php on line 89
147 | September 29th, 2014 at 23:57.
148 |
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
--------------------------------------------------------------------------------
/docs/reports/errors.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | » Compilation errors
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
87 |
88 |
89 |
90 |
97 |
98 |
99 |
100 | \
101 | Compilation Errors
102 |
103 |
104 |
105 |
106 |
107 |
108 |
109 | ImageCache.php
110 | 3
111 |
112 |
113 |
114 |
115 |
116 | Type
117 | Line
118 | Description
119 |
120 |
121 |
122 |
123 | error
124 | 17
125 | No summary for class \ImageCache
126 |
127 |
128 | error
129 | 125
130 | Argument $image is missing from the Docblock of cache()
131 |
132 |
133 | error
134 | 254
135 | Argument $src is missing from the Docblock of docroot_to_url()
136 |
137 |
138 |
139 |
140 |
141 |
142 |
143 |
144 |
145 |
146 |
176 |
177 |
178 |
179 | Documentation is powered by phpDocumentor and authored
180 | on
181 | Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /Users/imnikkilee/pear/share/pear/phpDocumentor/vendor/twig/twig/lib/Twig/Extension/Core.php on line 89
182 | September 29th, 2014 at 23:57.
183 |
184 |
185 |
186 |
187 |
188 |
189 |
190 |
191 |
--------------------------------------------------------------------------------
/docs/reports/markers.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 | » Markers
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
87 |
88 |
89 |
90 |
95 |
96 |
97 |
98 |
99 | \
100 | Markers
101 |
102 |
103 |
No markers have been found in this project.
104 |
105 |
106 |
107 |
108 |
109 |
110 |
111 |
112 |
142 |
143 |
144 |
145 | Documentation is powered by phpDocumentor and authored
146 | on
147 | Warning: date_default_timezone_get(): It is not safe to rely on the system's timezone settings. You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone identifier. We selected the timezone 'UTC' for now, but please set date.timezone to select your timezone. in /Users/imnikkilee/pear/share/pear/phpDocumentor/vendor/twig/twig/lib/Twig/Extension/Core.php on line 89
148 | September 29th, 2014 at 23:57.
149 |
150 |
151 |
152 |
153 |
154 |
155 |
156 |
157 |
--------------------------------------------------------------------------------
/phpdoc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | docs
5 |
6 |
7 | docs
8 |
9 |
10 | src
11 | ./demo
12 | ./unittests
13 |
14 |
--------------------------------------------------------------------------------
/phpunit.xml:
--------------------------------------------------------------------------------
1 |
2 |
23 |
24 |
25 | .
26 |
27 |
28 |
29 |
30 |
31 | ./demo
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
--------------------------------------------------------------------------------
/src/ImageCache/ImageCache.php:
--------------------------------------------------------------------------------
1 |
10 | * @license http://freedomdefined.org/Licenses/CC-BY MIT
11 | * @version GIT: 1.0.0
12 | *
13 | * http://dtbaker.net/web-development/how-to-cache-images-generated-by-php/
14 | */
15 |
16 | namespace ImageCache;
17 |
18 | ob_start();
19 |
20 | class ImageCache {
21 |
22 | const memory_value = 128;
23 |
24 | /**
25 | * Stores the image source given for reference
26 | */
27 | public $image_src;
28 |
29 | /**
30 | * The version of the source image to which will be part of the cached filename (used to "force" browser to download a new version of the image).
31 | * @var string
32 | */
33 | public $image_src_version;
34 |
35 | /**
36 | * If the file is remote or not
37 | */
38 | public $is_remote;
39 |
40 | /**
41 | * Allow the user to set the options for the setup
42 | */
43 | public $options;
44 |
45 | /**
46 | * The location of the cached images directory
47 | */
48 | public $cached_image_directory;
49 |
50 | /**
51 | * The version of the cached directory to which will be part of the cached filename (used to "force" browser to download a new version of the entire cache directory).
52 | * @var string
53 | */
54 | public $cached_directory_version;
55 |
56 | /**
57 | * The URL to access the cached images directory
58 | */
59 | public $cached_image_url;
60 |
61 | /**
62 | * The name of the cached file
63 | */
64 | public $cached_filename;
65 |
66 | /**
67 | * The compression's output quality
68 | * @var array
69 | */
70 | public $quality;
71 |
72 | /**
73 | * check link of cached file if is valid by curl
74 | */
75 | public $check_link_cached;
76 |
77 | /**
78 | * Stores the server's version of the GD Library, if enabled
79 | */
80 | private $gd_version;
81 |
82 | /**
83 | * The memory limit currently established on the server
84 | */
85 | private $memory_limit;
86 |
87 | /**
88 | * The file mime type
89 | */
90 | private $file_mime_type;
91 |
92 | /**
93 | * The extension of the file
94 | */
95 | private $file_extension;
96 |
97 | /**
98 | * The original size of the file
99 | */
100 | private $local_image_src;
101 |
102 | /**
103 | * The original size of the file
104 | */
105 | private $src_filesize;
106 |
107 | /**
108 | * The extension of the file
109 | */
110 | private $cached_filesize;
111 |
112 | /**
113 | * Constructor function
114 | *
115 | * @param array $options Options include the keys 'echo' (boolean) and 'cache_time' (integer). 'cache_time' is currently not employed, but in place for future reference.
116 | * @return object Returns the class object for the user to reference it in the future.
117 | */
118 | public function __construct($options = array()) {
119 | if (!$this->can_run_image_cache())
120 | $this->error('PHP Image Cache must be run on a server with a bundled GD version.');
121 | $defaults = array(
122 | 'check_link_cached' => true, // Check link of cached file if is valid by curl
123 | 'echo' => false, // Determines whether the resulting source should be echoed or returned
124 | 'cache_time' => 0, // How long the image should be cached for. If the value is 0, then the cache never expires. Default is 0, never expires.m
125 | "quality" => array(// Determines the quality of cache output
126 | "jpeg" => 85,
127 | "png" => 8
128 | ),
129 | "cached_image_directory" => dirname(__FILE__) . "/php-image-cache",
130 | "cached_image_url" => "",
131 | "cached_directory_version" => ""
132 | );
133 | $this->options = (object) array_merge($defaults, $options);
134 | $this->cached_image_directory = $this->options->cached_image_directory;
135 | $this->cached_image_url = rtrim($this->options->cached_image_url, "/");
136 | $this->quality = (object) array(
137 | "jpeg" => $this->options->quality["jpeg"],
138 | "png" => $this->options->quality["png"]
139 | );
140 | $this->cached_directory_version = $this->options->cached_directory_version;
141 | $this->check_link_cached = $this->options->check_link_cached;
142 |
143 | return $this;
144 | }
145 |
146 | /**
147 | * Validates whether the user can use this class or not, based on the GD Version their server is carrying.
148 | *
149 | * @return bool
150 | */
151 | public function can_run_image_cache() {
152 | $gd_info = gd_info();
153 | $this->gd_version = false;
154 | if (preg_match('#bundled \((.+)\)$#i', $gd_info['GD Version'], $matches)) {
155 | $this->gd_version = (float) $matches[1];
156 | } else {
157 | $this->gd_version = (float) substr($gd_info['GD Version'], 0, 3);
158 | }
159 | return (bool) $this->gd_version;
160 | }
161 |
162 | /**
163 | * Caches the image. When using this method, the image will be compressed and then cached.
164 | *
165 | * @return string The source file to be referenced after compressing an image
166 | */
167 | public function cache($image, $version = "") {
168 | ob_start();
169 | if ( ! is_writable($this->cached_image_directory))
170 | $this->error( $this->cached_image_directory . ' must writable!');
171 |
172 | if (!is_string($image))
173 | $this->error('Image source given must be a string.');
174 |
175 | $this->image_src = $image;
176 | $this->image_src_version = $version;
177 | $this->pre_set_class_vars();
178 |
179 | // If the image hasn't been server up at this point, fetch, compress, cache, and return
180 | if ($this->cached_file_exists()) {
181 | $this->src_filesize = filesize($this->image_src);
182 | $this->cached_filesize = filesize($this->cached_filename);
183 | if ($this->src_filesize < $this->cached_filesize) {
184 | ob_end_clean();
185 | return $this->docroot_to_url($this->image_src);
186 | }
187 | ob_end_clean();
188 | return $this->docroot_to_url();
189 | }
190 | if ($this->is_remote) {
191 | $this->download_image();
192 | }
193 | if (!$this->fetch_image())
194 | $this->error('Could not copy image resource.');
195 | $this->src_filesize = filesize($this->image_src);
196 | $this->cached_filesize = filesize($this->cached_filename);
197 | if ($this->src_filesize < $this->cached_filesize) {
198 | ob_end_clean();
199 | return $this->docroot_to_url($this->image_src);
200 | }
201 | ob_end_clean();
202 | return $this->docroot_to_url();
203 | }
204 |
205 | /**
206 | * Downloads a remote file and stores it locally to be used for compression
207 | */
208 | private function download_image() {
209 | $image_resource = file_get_contents($this->image_src);
210 | $basename = basename($this->image_src);
211 | if (!stripos($basename, '.' . $this->file_extension)) {
212 | $basename .= '.' . $this->file_extension;
213 | }
214 | $image_location = dirname($this->cached_image_directory) . '/' . $basename;
215 | if (!file_exists($image_location)) {
216 | if (!file_put_contents($image_location, $image_resource)) {
217 | $this->error('Could not download the remote image');
218 | }
219 | }
220 | $this->image_src = $image_location;
221 | }
222 |
223 | /**
224 | * Creates the cached directory
225 | *
226 | * @return bool If the directory was successfully created or not
227 | */
228 | private function make_cache_directory() {
229 | if (is_dir($this->cached_image_directory)) {
230 | return true;
231 | }
232 | try {
233 | mkdir($this->cached_image_directory);
234 | } catch (Exception $e) {
235 | $this->error('There was an error creating the new directory:', $e);
236 | return false;
237 | }
238 | return true;
239 | }
240 |
241 | /**
242 | * Fetch the image as a resource and save it into the cache directory.
243 | *
244 | * @source http://stackoverflow.com/questions/9839150/image-compression-in-php
245 | * @return If the image was successfully created or not
246 | */
247 | private function fetch_image() {
248 | $image_size = getimagesize($this->image_src);
249 | $image_width = $image_size[0];
250 | $image_height = $image_size[1];
251 | $mime_array = explode('/', $this->file_mime_type);
252 | $file_mime_as_ext = end($mime_array);
253 | $image_dest_func = 'imagecreate';
254 | if ($this->gd_version >= 2)
255 | $image_dest_func = 'imagecreatetruecolor';
256 | if (in_array($file_mime_as_ext, array('gif', 'jpeg', 'png'))) {
257 | $image_src_func = 'imagecreatefrom' . $this->file_extension;
258 | $image_create_func = 'image' . $this->file_extension;
259 | } else {
260 | $this->error('The image you supply must have a .gif, .jpg/.jpeg, or .png extension.');
261 | return false;
262 | }
263 | $this->increase_memory_limit();
264 | $image_src = @call_user_func($image_src_func, $this->image_src);
265 | $image_dest = @call_user_func($image_dest_func, $image_width, $image_height);
266 | if ($file_mime_as_ext === 'jpeg') {
267 | $background = imagecolorallocate($image_dest, 255, 255, 255);
268 | imagefill($image_dest, 0, 0, $background);
269 | } elseif (in_array($file_mime_as_ext, array('gif', 'png'))) {
270 | imagealphablending($image_src, false);
271 | imagesavealpha($image_src, true);
272 | imagealphablending($image_dest, false);
273 | imagesavealpha($image_dest, true);
274 | }
275 | imagecopy($image_dest, $image_src, 0, 0, 0, 0, $image_width, $image_height);
276 | switch ($file_mime_as_ext) {
277 | case 'jpeg':
278 | $created = imagejpeg($image_dest, $this->cached_filename, $this->quality->jpeg);
279 | break;
280 | case 'png':
281 | $created = imagepng($image_dest, $this->cached_filename, $this->quality->png);
282 | break;
283 | case 'gif':
284 | $created = imagegif($image_dest, $this->cached_filename);
285 | break;
286 | default:
287 | return false;
288 | break;
289 | }
290 | imagedestroy($image_src);
291 | imagedestroy($image_dest);
292 | $this->reset_memory_limit();
293 | return $created;
294 | }
295 |
296 | /**
297 | * Returns
298 | *
299 | * @param string $src The url to check validate
300 | * @return string The URL of the image
301 | */
302 | private function docroot_to_url($src = null) {
303 | if (is_null($src)) {
304 | $src = $this->cached_filename;
305 | }
306 | if (empty($this->cached_image_url)) {
307 | $image_path = str_replace($_SERVER['DOCUMENT_ROOT'], '', $src);
308 | $image_url = $_SERVER['REQUEST_SCHEME']."://" . $_SERVER['HTTP_HOST'].'/' . substr($image_path, 1);
309 | } else {
310 | $image_url = $this->cached_image_url . "/" . basename($src);
311 | }
312 | if ($this->link_is_broken($image_url)) {
313 | $this->error('Final image URL is broken');
314 | }
315 | return $image_url;
316 | }
317 |
318 | /**
319 | * Sets up all class variables in one central function.
320 | */
321 | private function pre_set_class_vars() {
322 | $this->set_file_mime_type();
323 | $this->set_cached_filename();
324 | $this->set_memory_limit();
325 | $this->set_is_remote();
326 | }
327 |
328 | /**
329 | * Utility function to determine of the link in question is broken or not.
330 | *
331 | * @param string $url The url to check validate
332 | * @return bool Indicates whether or not the link is broken
333 | */
334 | private function link_is_broken($url) {
335 | if (!$this->check_link_cached || !function_exists('curl_init'))
336 | return false;
337 |
338 | $ch = curl_init($url);
339 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
340 | curl_exec($ch);
341 | $http_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
342 | if ($http_code == 404) {
343 | $broken = true;
344 | } else {
345 | $broken = false;
346 | }
347 | curl_close($ch);
348 | return $broken;
349 | }
350 |
351 | /**
352 | * Quick and dirty way to see if the file is remote or local. Deeper checking comes
353 | * later if we don't find a compressed version of the file locally.
354 | *
355 | * @return bool Whether or not the image is remote
356 | */
357 | private function is_image_local() {
358 | if (file_exists($this->image_src))
359 | return true;
360 | $parsed_src = parse_url($this->image_src);
361 | if ($_SERVER['HTTP_HOST'] === $parsed_src['host'])
362 | return true;
363 | return false;
364 | }
365 |
366 | /**
367 | * Determines if the image is local or being referenced from a remote URL
368 | */
369 | private function set_is_remote() {
370 | $this->is_remote = !$this->is_image_local();
371 | }
372 |
373 | /**
374 | * This function creates the filename of the new image using an MD5 hash of the original filename. This helps to create a unique
375 | * filename for the newly compressed image so that this class can easily find and determine if the image has already been compressed and stored locally.
376 | *
377 | * Employing use of the "alt" and "title" tags on the image (which hopefully you're already doing) will negate any potentially negative impacts on SEO. See
378 | * this article for more information: http://searchenginewatch.com/article/2120682/Image-Optimization-How-to-Rank-on-Image-Search
379 | */
380 | private function set_cached_filename() {
381 | $pathinfo = pathinfo($this->image_src);
382 | $this->cached_filename = $this->cached_image_directory . '/' . md5($this->cached_directory_version . basename($this->image_src) . $this->image_src_version) . '.' . $this->file_extension;
383 | }
384 |
385 | /**
386 | * Simply determines if a compressed of the image that's sent is already compressed or not.
387 | */
388 | private function cached_file_exists() {
389 | if ($this->is_remote) {
390 | $this->download_image();
391 | }
392 | if (file_exists($this->cached_filename))
393 | return true;
394 | return false;
395 | }
396 |
397 | /**
398 | * Stores the file's mime type and validates that the file being compressed is indeed an image.
399 | */
400 | private function set_file_mime_type() {
401 | $image_type = exif_imagetype($this->image_src);
402 | if (!$image_type)
403 | $this->error('The file you supplied isn\'t a valid image.');
404 | $this->file_mime_type = image_type_to_mime_type($image_type);
405 | $this->file_extension = image_type_to_extension($image_type, false);
406 | }
407 |
408 | /**
409 | * Stores the original value of the server's memory limit
410 | */
411 | private function set_memory_limit() {
412 | $this->memory_limit = ini_get('memory_limit');
413 | }
414 |
415 | /**
416 | * Temporarily increases the servers memory limit to 2480 MB to handle building larger images. Based on initial
417 | * tests, this seems to be a large enough increase to handle rebuilding jpg images as large as 4300px wide with no pre-compression.
418 | */
419 | private function increase_memory_limit() {
420 | ini_set('memory_limit', '2480M');
421 | }
422 |
423 | /**
424 | * Resets the servers memory limit to its original value
425 | */
426 | private function reset_memory_limit() {
427 | ini_set('memory_limit', $this->memory_limit);
428 | }
429 |
430 | /**
431 | * Displays an error and kills the script
432 | *
433 | * @param String $status The message to be passed to the native `exit()` function
434 | */
435 | private function error($status = null) {
436 | if (is_null($status))
437 | $status = 'Unknown Error:';
438 | exit($status);
439 | }
440 |
441 | }
442 |
--------------------------------------------------------------------------------
/src/ImageCache/php-image-cache/18e3af47b74127eb56de83345552aa7e.gif:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/src/ImageCache/php-image-cache/18e3af47b74127eb56de83345552aa7e.gif
--------------------------------------------------------------------------------
/src/ImageCache/php-image-cache/18e3af47b74127eb56de83345552aa7e.gif.gz:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/nielse63/php-image-cache/2b13107761f80b1f5369aad07951cb8ad513b0b3/src/ImageCache/php-image-cache/18e3af47b74127eb56de83345552aa7e.gif.gz
--------------------------------------------------------------------------------
/unittests/ImageCacheTest.php:
--------------------------------------------------------------------------------
1 | assertFileExists( '../src/ImageCache/ImageCache.php' );
15 | }
16 |
17 | /**
18 | * @author nielse63
19 | * @depends testCanFindFile
20 | */
21 | public function testClassDoesHaveAttributes()
22 | {
23 | $this->assertClassHasAttribute( 'image_src', 'ImageCache\ImageCache' );
24 | $this->assertClassHasAttribute( 'is_remote', 'ImageCache\ImageCache' );
25 | $this->assertClassHasAttribute( 'options', 'ImageCache\ImageCache' );
26 | $this->assertClassHasAttribute( 'cached_image_directory', 'ImageCache\ImageCache' );
27 | $this->assertClassHasAttribute( 'cached_filename', 'ImageCache\ImageCache' );
28 | $this->assertClassHasAttribute( 'gd_version', 'ImageCache\ImageCache' );
29 | $this->assertClassHasAttribute( 'memory_limit', 'ImageCache\ImageCache' );
30 | $this->assertClassHasAttribute( 'file_mime_type', 'ImageCache\ImageCache' );
31 | $this->assertClassHasAttribute( 'file_extension', 'ImageCache\ImageCache' );
32 | $this->assertClassHasAttribute( 'local_image_src', 'ImageCache\ImageCache' );
33 | $this->assertClassHasAttribute( 'src_filesize', 'ImageCache\ImageCache' );
34 | $this->assertClassHasAttribute( 'cached_filesize', 'ImageCache\ImageCache' );
35 | }
36 |
37 | /**
38 | * @author nielse63
39 | * @depends testCanFindFile
40 | */
41 | public function testCanRunImageCache()
42 | {
43 | $imagecache = new ImageCache\ImageCache();
44 | $this->assertTrue( $imagecache->can_run_image_cache() );
45 | }
46 | }
47 |
--------------------------------------------------------------------------------