Skip to content
This repository
Browse code

Documented some view helpers and added libraries

  • Loading branch information...
commit b4540cfaeeaebb2f7b0dd9640cbf59c6a48082e6 1 parent 0a7c20d
unknown authored

Showing 105 changed files with 17,727 additions and 5 deletions. Show diff stats Hide diff stats

  1. +20 3 library/Pas/View/Helper/Acronyms.php
  2. +19 2 library/Pas/View/Helper/Adbc.php
  3. +25 0 library/Pas/View/Helper/Allowedtest.php
  4. +66 0 library/Pas/View/Helper/AmILoggedIn.php
  5. +44 0 library/Pas/View/Helper/Applicants.php
  6. +39 0 library/Pas/View/Helper/Certainty.php
  7. +331 0 library/Pas/phMagick.php
  8. +45 0 library/Pas/plugins/cli.php
  9. +148 0 library/Pas/plugins/color.php
  10. +93 0 library/Pas/plugins/compose.php
  11. +47 0 library/Pas/plugins/convert.php
  12. +56 0 library/Pas/plugins/crop.php
  13. +173 0 library/Pas/plugins/decorations.php
  14. +107 0 library/Pas/plugins/enhancements.php
  15. +59 0 library/Pas/plugins/info.php
  16. +115 0 library/Pas/plugins/resize.php
  17. +69 0 library/Pas/plugins/text.php
  18. +136 0 library/Pas/plugins/transform.php
  19. +975 0 library/Pas/simple_html_dom.php
  20. +38 0 library/ZendX/Console/Exception.php
  21. +38 0 library/ZendX/Console/Process/Exception.php
  22. +658 0 library/ZendX/Console/Process/Unix.php
  23. +597 0 library/ZendX/Db/Adapter/Firebird.php
  24. +39 0 library/ZendX/Db/Adapter/Firebird/Exception.php
  25. +369 0 library/ZendX/Db/Statement/Firebird.php
  26. +40 0 library/ZendX/Db/Statement/Firebird/Exception.php
  27. +38 0 library/ZendX/Exception.php
  28. +153 0 library/ZendX/JQuery.php
  29. +76 0 library/ZendX/JQuery/Controller/Action/Helper/AutoComplete.php
  30. +32 0 library/ZendX/JQuery/Exception.php
  31. +67 0 library/ZendX/JQuery/Form.php
  32. +39 0 library/ZendX/JQuery/Form/Decorator/AccordionContainer.php
  33. +39 0 library/ZendX/JQuery/Form/Decorator/AccordionPane.php
  34. +39 0 library/ZendX/JQuery/Form/Decorator/DialogContainer.php
  35. +39 0 library/ZendX/JQuery/Form/Decorator/TabContainer.php
  36. +39 0 library/ZendX/JQuery/Form/Decorator/TabPane.php
  37. +142 0 library/ZendX/JQuery/Form/Decorator/UiWidgetContainer.php
  38. +178 0 library/ZendX/JQuery/Form/Decorator/UiWidgetElement.php
  39. +31 0 library/ZendX/JQuery/Form/Decorator/UiWidgetElementMarker.php
  40. +157 0 library/ZendX/JQuery/Form/Decorator/UiWidgetPane.php
  41. +39 0 library/ZendX/JQuery/Form/Element/AutoComplete.php
  42. +39 0 library/ZendX/JQuery/Form/Element/ColorPicker.php
  43. +39 0 library/ZendX/JQuery/Form/Element/DatePicker.php
  44. +39 0 library/ZendX/JQuery/Form/Element/Slider.php
  45. +39 0 library/ZendX/JQuery/Form/Element/Spinner.php
  46. +179 0 library/ZendX/JQuery/Form/Element/UiWidget.php
  47. +11 0 library/ZendX/JQuery/Form/Exception.php
  48. +32 0 library/ZendX/JQuery/View/Exception.php
  49. +153 0 library/ZendX/JQuery/View/Helper/AccordionContainer.php
  50. +80 0 library/ZendX/JQuery/View/Helper/AccordionPane.php
  51. +308 0 library/ZendX/JQuery/View/Helper/AjaxLink.php
  52. +78 0 library/ZendX/JQuery/View/Helper/AutoComplete.php
  53. +73 0 library/ZendX/JQuery/View/Helper/ColorPicker.php
  54. +146 0 library/ZendX/JQuery/View/Helper/DatePicker.php
  55. +74 0 library/ZendX/JQuery/View/Helper/DialogContainer.php
  56. +167 0 library/ZendX/JQuery/View/Helper/JQuery.php
  57. +837 0 library/ZendX/JQuery/View/Helper/JQuery/Container.php
  58. +164 0 library/ZendX/JQuery/View/Helper/Slider.php
  59. +73 0 library/ZendX/JQuery/View/Helper/Spinner.php
  60. +132 0 library/ZendX/JQuery/View/Helper/TabContainer.php
  61. +74 0 library/ZendX/JQuery/View/Helper/TabPane.php
  62. +84 0 library/ZendX/JQuery/View/Helper/UiWidget.php
  63. +105 0 library/ZendX/JQuery/View/Helper/UiWidgetPane.php
  64. +13 0 min/.htaccess
  65. +145 0 min/README.txt
  66. +253 0 min/builder/_index.js
  67. +36 0 min/builder/bm.js
  68. +15 0 min/builder/bm2.js
  69. +251 0 min/builder/index.php
  70. +36 0 min/builder/ocCheck.php
  71. +1 0  min/builder/rewriteTest.js
  72. +43 0 min/builder/test.php
  73. +168 0 min/config.php
  74. +17 0 min/groupsConfig.php
  75. +81 0 min/index.php
  76. +1,370 0 min/lib/FirePHP.php
  77. +347 0 min/lib/HTTP/ConditionalGet.php
  78. +338 0 min/lib/HTTP/Encoder.php
  79. +348 0 min/lib/JSMin.php
  80. +1,872 0 min/lib/JSMinPlus.php
  81. +566 0 min/lib/Minify.php
  82. +103 0 min/lib/Minify/Build.php
  83. +83 0 min/lib/Minify/CSS.php
  84. +250 0 min/lib/Minify/CSS/Compressor.php
  85. +270 0 min/lib/Minify/CSS/UriRewriter.php
  86. +133 0 min/lib/Minify/Cache/APC.php
  87. +139 0 min/lib/Minify/Cache/File.php
  88. +140 0 min/lib/Minify/Cache/Memcache.php
  89. +89 0 min/lib/Minify/CommentPreserver.php
  90. +235 0 min/lib/Minify/Controller/Base.php
  91. +78 0 min/lib/Minify/Controller/Files.php
  92. +94 0 min/lib/Minify/Controller/Groups.php
  93. +210 0 min/lib/Minify/Controller/MinApp.php
  94. +87 0 min/lib/Minify/Controller/Page.php
  95. +118 0 min/lib/Minify/Controller/Version1.php
  96. +245 0 min/lib/Minify/HTML.php
  97. +193 0 min/lib/Minify/HTML/Helper.php
  98. +157 0 min/lib/Minify/ImportProcessor.php
  99. +137 0 min/lib/Minify/Lines.php
  100. +47 0 min/lib/Minify/Logger.php
  101. +37 0 min/lib/Minify/Packer.php
  102. +187 0 min/lib/Minify/Source.php
  103. +142 0 min/lib/Minify/YUICompressor.php
  104. +199 0 min/lib/Solar/Dir.php
  105. +74 0 min/utils.php
23 library/Pas/View/Helper/Acronyms.php
... ... @@ -1,12 +1,29 @@
1 1 <?php
  2 +/**
  3 + * A view helper for automatically inserting HTML abbreviations
  4 + * Not sure if this was inspired by a wordpress plugin or not?!
  5 + * @category Pas
  6 + * @package Pas_View_Helper
  7 + * @subpackage Abstract
  8 + * @copyright Copyright (c) 2011 dpett @ britishmuseum.org
  9 + * @license http://framework.zend.com/license/new-bsd New BSD License
  10 + * @see Zend_View_Helper_Abstract
  11 + */
2 12 class Pas_View_Helper_Acronyms extends Zend_View_Helper_Abstract {
3   -
4   - public function Acronyms($string) {
  13 +
  14 + /** Function to add acronyms/abbreviations
  15 + *
  16 + * @param $string text to add abbreviations to
  17 + * @return $string Text with abbreviations inserted into html
  18 + */
  19 + public function Acronyms($string) {
  20 + //Retrieve acronyms array from the database
5 21 $acros = new Acronyms();
6 22 $acronyms = $acros->getValid();
7 23 $text = " $string ";
8 24 foreach ( $acronyms as $acronym => $fulltext )
9   - $text = preg_replace( "|(?!<[^<>]*?)(?<![?.&])\b$acronym\b(?!:)(?![^<>]*?>)|msU", "<abbr title=\"$fulltext\">$acronym</abbr>" , $text );
  25 + $text = preg_replace( "|(?!<[^<>]*?)(?<![?.&])\b$acronym\b(?!:)(?![^<>]*?>)|msU",
  26 + "<abbr title=\"$fulltext\">$acronym</abbr>" , $text );
10 27 $text = trim($text);
11 28 return $text;
12 29 }
21 library/Pas/View/Helper/Adbc.php
... ... @@ -1,7 +1,24 @@
1 1 <?php
2   -class Pas_View_Helper_ADBC extends Zend_View_Helper_Abstract {
  2 +/**
  3 + * A view helper for turning dates into AD or BC calenderical dates
  4 + * @category Pas
  5 + * @package Pas_View_Helper
  6 + * @subpackage Abstract
  7 + * @copyright Copyright (c) 2011 dpett @ britishmuseum.org
  8 + * @license http://framework.zend.com/license/new-bsd New BSD License
  9 + * @see Zend_View_Helper_Abstract
  10 + */
  11 +class Pas_View_Helper_Adbc extends Zend_View_Helper_Abstract {
3 12
4   - public function ADBC($date = NULL, $suffix="BC", $prefix="AD") {
  13 + /**
  14 + * A function for turning the integer into a string with AD or BC added
  15 + *
  16 + * @param $date integer
  17 + * @param $suffix string
  18 + * @param $prefix string
  19 + */
  20 +
  21 + public function adbc($date = NULL, $suffix="BC", $prefix="AD") {
5 22 $validator = new Zend_Validate_Int();
6 23 if($validator->isValid($date)){
7 24 if ($date < 0) {
25 library/Pas/View/Helper/Allowedtest.php
... ... @@ -0,0 +1,25 @@
  1 +<?php
  2 +/**
  3 + * A view helper for checking if a user can do something
  4 + * @category Pas
  5 + * @package Pas_View_Helper
  6 + * @subpackage Abstract
  7 + * @copyright Copyright (c) 2011 dpett @ britishmuseum.org
  8 + * @license http://framework.zend.com/license/new-bsd New BSD License
  9 + * @see Zend_View_Helper_Abstract
  10 + * @todo See if this is worth keeping, limited and bad code
  11 + */
  12 +class Pas_View_Helper_Allowedtest extends Zend_View_Helper_Abstract {
  13 +
  14 + public function allowedtest($string) {
  15 + $auth = Zend_Auth::getInstance();
  16 + if($auth->hasIdentity()) {
  17 + $higherLevel = array('admin');
  18 + $user = $auth->getIdentity();
  19 + $role = $user->role;
  20 + if(in_array($role,$higherLevel)) {
  21 + echo $string;
  22 + }
  23 + }
  24 + }
  25 +}
66 library/Pas/View/Helper/AmILoggedIn.php
... ... @@ -0,0 +1,66 @@
  1 +<?php
  2 +/**
  3 + * A view helper for checking if a user has logged in
  4 + * @category Pas
  5 + * @package Pas_View_Helper
  6 + * @subpackage Abstract
  7 + * @copyright Copyright (c) 2011 dpett @ britishmuseum.org
  8 + * @license http://framework.zend.com/license/new-bsd New BSD License
  9 + * @uses Zend_View_Helper_Abstract
  10 + * @uses Zend_View_Helper_Url
  11 + * @uses Zend_View_Helper_Gravatar
  12 + * @uses Zend_View_Helper_HeadMeta
  13 + */
  14 +
  15 +class Pas_View_Helper_AmILoggedIn extends Zend_View_Helper_Abstract {
  16 +
  17 + protected $_auth;
  18 +
  19 + public function __construct(){
  20 + $this->_auth = Zend_Auth::getInstance();
  21 + }
  22 +
  23 + public function AmILoggedIn() {
  24 + if($this->_auth->hasIdentity()) {
  25 +
  26 + $logoutUrl = $this->view->url(array('module' => 'users','controller'=>'account',
  27 + 'action'=>'logout'),'default', true);
  28 +
  29 + $user = $this->_auth->getIdentity();
  30 +
  31 + $gravatar = $this->view->gravatar()
  32 + ->setEmail($user->email)
  33 + ->setImgSize(30)
  34 + ->setDefaultImg(Zend_View_Helper_Gravatar::DEFAULT_MONSTERID)
  35 + ->setSecure(true)
  36 + ->setAttribs(array('class' => 'avatar'));
  37 +
  38 + $fullname = $this->view->escape(ucfirst($user->fullname));
  39 + $id = $this->view->escape(ucfirst($user->id));
  40 + $string = '<div id="gravatar">' . $gravatar . '</div>';
  41 +
  42 + $string .= '<p>
  43 + <a href="'.$this->view->url(array('module' => 'users','controller' => 'account'),
  44 + 'default',true).'" title="View your user profile">' . $fullname . '</a> &raquo; <a href="'
  45 + . $logoutUrl . '">Log out</a></p><p>Assigned role: ' . ucfirst($user->role) . '</p>';
  46 +
  47 + $this->view->headMeta(ucfirst($user->fullname),'page-user-screen_name');
  48 +
  49 + $allowed = array('admin' , 'fa');
  50 + if(in_array($user->role,$allowed)) {
  51 + $string .= '<p><a href="' .$this->view->url(array('module' => 'admin'),'default',true)
  52 + . '">Administer site</a></p>';
  53 + }
  54 + } else {
  55 + $loginUrl = $this->view->url(array('module' => 'users'),'default', true);
  56 + $register = $this->view->url(array('module' => 'users','controller' => 'account',
  57 + 'action'=> 'register'),'default',true);
  58 + $string = '<p><a href="'.$loginUrl.'" title="Login to our database">Log in</a> | <a href="'
  59 + . $register . '" title="Register with us">Register</a></p>';
  60 + $this->view->headMeta('Public User','page-user-screen_name');
  61 + }
  62 + return $string;
  63 +
  64 + }
  65 +
  66 +}
44 library/Pas/View/Helper/Applicants.php
... ... @@ -0,0 +1,44 @@
  1 +<?php
  2 +/**
  3 + * A view helper for returning the number of applicants that have applied for
  4 + * higher level status
  5 + * @category Pas
  6 + * @package Pas_View_Helper
  7 + * @subpackage Abstract
  8 + * @copyright Copyright (c) 2011 dpett @ britishmuseum.org
  9 + * @license http://framework.zend.com/license/new-bsd New BSD License
  10 + * @see Zend_View_Helper_Abstract
  11 + */
  12 +class Pas_View_Helper_Applicants extends Zend_View_Helper_Abstract {
  13 +
  14 + public function _getUsers() {
  15 + $users = new Users();
  16 + $data = $users->getNewHigherLevelRequests();
  17 + return $data;
  18 + }
  19 +
  20 + public function buildHtml() {
  21 + $url = $this->view->url(array(
  22 + 'module' => 'admin',
  23 + 'controller' => 'users',
  24 + 'action' => 'upgrades'
  25 + ),NULL,true);
  26 + $data = $this->_getUsers();
  27 + if($data){
  28 + $html = '';
  29 + $html .= '<li class="purple">';
  30 + $html .= '<a href="';
  31 + $html .= $url;
  32 + $html .= '" title="View upgrade requests">';
  33 + $html .= $data['0']['applicants'];
  34 + $html .= ' applicants waiting</a></li>';
  35 + return $html;
  36 + } else {
  37 + return false;
  38 + }
  39 + }
  40 +
  41 + public function Applicants(){
  42 + return $this->buildHtml();
  43 + }
  44 +}
39 library/Pas/View/Helper/Certainty.php
... ... @@ -0,0 +1,39 @@
  1 +<?php
  2 +/**
  3 + * A basic view helper for displaying certainty for object types
  4 + * @category Pas
  5 + * @package Pas_View_Helper
  6 + * @subpackage Abstract
  7 + * @copyright Copyright (c) 2011 dpett @ britishmuseum.org
  8 + * @license http://framework.zend.com/license/new-bsd New BSD License
  9 + * @see Zend_View_Helper_Abstract
  10 + */
  11 +class Pas_View_Helper_Certainty extends Zend_View_Helper_Abstract {
  12 +
  13 + /**
  14 + * Check for the certainty
  15 + * @param $int The certainty lookup number
  16 + */
  17 + public function certainty($int){
  18 + $validator = new Zend_Validate_Int();
  19 + if($validator->isValid($int)){
  20 + switch ($int) {
  21 + case 1:
  22 + $cert = 'Certain';
  23 + break;
  24 + case 2:
  25 + $cert = 'Probably';
  26 + break;
  27 + case 3:
  28 + $cert = 'Possibly';
  29 + break;
  30 + default:
  31 + return false;
  32 + break;
  33 + }
  34 + return $cert;
  35 + } else {
  36 + return false;
  37 + }
  38 + }
  39 +}
331 library/Pas/phMagick.php
... ... @@ -0,0 +1,331 @@
  1 +<?php
  2 +/*
  3 + +--------------------------------------------------------------------------------------------+
  4 + | DISCLAIMER - LEGAL NOTICE - |
  5 + +--------------------------------------------------------------------------------------------+
  6 + | |
  7 + | This program is free for non comercial use, see the license terms available at |
  8 + | http://www.francodacosta.com/licencing/ for more information |
  9 + | |
  10 + | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
  11 + | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
  12 + | |
  13 + | USE IT AT YOUR OWN RISK |
  14 + | |
  15 + | |
  16 + +--------------------------------------------------------------------------------------------+
  17 +
  18 +*/
  19 +/**
  20 + * phMagick - Image manipulation with Image Magick
  21 + *
  22 + * @version 0.4.0
  23 + * @author Nuno Costa - sven@francodacosta.com
  24 + * @copyright Copyright (c) 2007
  25 + * @license http://www.francodacosta.com/phmagick/license/
  26 + * @link http://www.francodacosta.com/phmagick
  27 + * @since 2008-03-13
  28 + */
  29 +class phmagick{
  30 + private $availableMethods = array();
  31 + private $loadedPlugins = array();
  32 +
  33 +
  34 + private $history = array();
  35 + private $originalFile = '';
  36 + private $source = '';
  37 + private $destination = '';
  38 + private $imageMagickPath = '/usr/bin/';
  39 + private $imageQuality = 80 ;
  40 +
  41 + public $debug = false;
  42 + private $log = array();
  43 +
  44 + function __construct($sourceFile='', $destinationFile=''){
  45 + $this->originalFile = $sourceFile;
  46 +
  47 + $this->source = $sourceFile ;
  48 + $this->destination = $destinationFile;
  49 +
  50 + $this->loadPlugins();
  51 + }
  52 +
  53 +
  54 + public function getLog(){
  55 + return $this->log;
  56 + }
  57 + public function getBinary($binName){
  58 + return $this->getImageMagickPath() . $binName ;
  59 + }
  60 +
  61 + //-----------------
  62 + function setSource ($path){
  63 + $this->source = str_replace(' ','\ ',$path) ;
  64 + return $this ;
  65 + }
  66 +
  67 + function getSource (){
  68 + return $this->source ;
  69 + }
  70 +
  71 + //-----------------
  72 + function setDestination ($path){
  73 + $path = str_replace(' ','\ ',$path) ;
  74 + $this->destination = $path ;
  75 + return $this;
  76 + }
  77 +
  78 + function getDestination (){
  79 + if( ($this->destination == '')){
  80 + $source = $this->getSource() ;
  81 + $ext = end (explode('.', $source)) ;
  82 + $this->destinationFile = dirname($source) . '/' . md5(microtime()) . '.' . $ext;
  83 + }
  84 + return $this->destination ;
  85 + }
  86 +
  87 + //-----------------
  88 +
  89 + function setImageMagickPath ($path){
  90 + if($path != '')
  91 + if ( strpos($path, '/') < strlen($path))
  92 + $path .= '/';
  93 + $this->imageMagickPath = str_replace(' ','\ ',$path) ;
  94 + }
  95 +
  96 + function getImageMagickPath (){
  97 + return $this->imageMagickPath;
  98 + }
  99 + //-----------------
  100 + function setImageQuality($value){
  101 + $this->imageQuality = intval($value);
  102 + return $this;
  103 + }
  104 +
  105 + function getImageQuality(){
  106 + return $this->imageQuality;
  107 + }
  108 +
  109 + //-----------------
  110 +
  111 + function getHistory( $type = Null ){
  112 + switch ($type){
  113 +
  114 + case phMagickHistory::returnCsv:
  115 + return explode(',', array_unique($this->history));
  116 + break;
  117 +
  118 + default:
  119 + case phMagickHistory::returnArray :
  120 + return array_unique($this->history) ;
  121 + break;
  122 +
  123 + }
  124 + }
  125 +
  126 + public function setHistory($path){
  127 + $this->history[] = $path ;
  128 + return $this;
  129 + }
  130 +
  131 + public function clearHistory(){
  132 + unset ($this->history);
  133 + $this->history = array();
  134 + }
  135 +
  136 +
  137 + public function requirePlugin($name, $version=null){
  138 +
  139 + if(key_exists($name, $this->loadedPlugins)) {
  140 + if(! is_null($version)) {
  141 + if( property_exists($this->loadedPlugins[$name], 'version') ){
  142 + if($this->loadedPlugins[$name]->version > $version)
  143 + return true;
  144 +
  145 + if($this->debug) throw new phMagickException ('Plugin "'.$name.'" version ='.$this->loadedPlugins[$name]->version . ' required >= ' . $version);
  146 + }
  147 + }
  148 + return true ;
  149 + }
  150 +
  151 + if($this->debug) throw new phMagickException ('Plugin "'.$name.'" not found!');
  152 + return false;
  153 + }
  154 +
  155 + //-----------------
  156 +
  157 + private function loadPlugins(){
  158 + $base = dirname(__FILE__) . '/plugins';
  159 + $plugins = glob($base . '/*.php');
  160 + foreach($plugins as $plugin){
  161 + include_once $plugin ;
  162 + $name = basename($plugin, '.php');
  163 + $className = 'phMagick_'.$name ;
  164 + $obj = new $className();
  165 + $this->loadedPlugins[$name] = $obj ;
  166 + foreach (get_class_methods($obj) as $method )
  167 + $this->availableMethods[$method] = $name ;
  168 + }
  169 + }
  170 +
  171 +
  172 + public function execute($cmd){
  173 +
  174 + $ret = null ;
  175 + $out = array();
  176 + exec($cmd .' 2>&1', $out, $ret);
  177 +
  178 + if($ret != 0)
  179 + if($this->debug) trigger_error (new phMagickException ('Error executing "'. $cmd.'" <br>return code: '. $ret .' <br>command output :"'. implode("<br>", $out).'"' ), E_USER_NOTICE );
  180 +
  181 + $this->log[] = array(
  182 + 'cmd' => $cmd
  183 + ,'return' => $ret
  184 + ,'output' => $out
  185 + );
  186 +
  187 +
  188 + return $ret ;
  189 + }
  190 +
  191 + public function __call($method, $args){
  192 + if(! key_exists($method, $this->availableMethods))
  193 + throw new Exception ('Call to undefined method : ' . $method);
  194 +
  195 + array_unshift($args, $this);
  196 + $ret = call_user_func_array(array($this->loadedPlugins[$this->availableMethods[$method]], $method), $args);
  197 +
  198 + if($ret === false)
  199 + throw new Exception ('Error executing method "' . $method ."'");
  200 +
  201 + return $ret ;
  202 + }
  203 +}
  204 +
  205 +class phMagickHistory{
  206 + const returnArray = 0 ;
  207 + const returnCsv = 1 ;
  208 +
  209 + private function __construct(){}
  210 +}
  211 +
  212 +
  213 +class phMagickException extends Exception {
  214 +
  215 + function __construct($message, $code=1){
  216 + //parent::__construct('', $code);
  217 + $this->message($message);
  218 + }
  219 + function message($message){
  220 + echo '<br><b>phMagick</b>: ' . $message ;
  221 + }
  222 +}
  223 +
  224 +
  225 +class phMagickGravity{
  226 + const None = 'None' ;
  227 + const Center = 'Center' ;
  228 + const East = 'East' ;
  229 + const Forget = 'Forget' ;
  230 + const NorthEast = 'NorthEast' ;
  231 + const North = 'North' ;
  232 + const NorthWest = 'NorthWest' ;
  233 + const SouthEast = 'SouthEast' ;
  234 + const South = 'South' ;
  235 + const SouthWest = 'SouthWest' ;
  236 + const West = 'West' ;
  237 +
  238 + private function __construct(){}
  239 +}
  240 +
  241 +
  242 +class phMagickTextObjectDefaults{
  243 + public static $fontSize ='12';
  244 + public static $font = false;
  245 +
  246 + public static $color = '#000';
  247 + public static $background = false;
  248 +
  249 + public static $gravity = phMagickGravity::Center; //ignored in fromString()
  250 + public $Text = '';
  251 +
  252 + private function __construct(){}
  253 +}
  254 +
  255 +
  256 +class phMagickTextObject {
  257 + protected $fontSize;
  258 + protected $font;
  259 +
  260 + protected $color;
  261 + protected $background;
  262 +
  263 + protected $pGravity; //ignored in fromString()
  264 + protected $pText = '';
  265 +
  266 + public function __construct(){
  267 + $this->fontSize = phMagickTextObjectDefaults::$fontSize;
  268 + $this->font = phMagickTextObjectDefaults::$font;
  269 + $this->color = phMagickTextObjectDefaults::$color ;
  270 + $this->background = phMagickTextObjectDefaults::$background;
  271 + $this->pGravity = phMagickTextObjectDefaults::$gravity;
  272 + }
  273 +
  274 + function defaultFontSize($value){
  275 + phMagickTextObjectDefaults::$fontSize = $value;
  276 + }
  277 +
  278 + function defaultFont($value){
  279 + phMagickTextObjectDefaults::$font = $value;
  280 + }
  281 +
  282 + function defaultColor($value){
  283 + phMagickTextObjectDefaults::$color = $value;
  284 + }
  285 +
  286 + function defaultBackground($value){
  287 + phMagickTextObjectDefaults::$background = $value;
  288 + }
  289 +
  290 + function defaultGravity($value){
  291 + phMagickTextObjectDefaults::$gravity = $value;
  292 + }
  293 +
  294 +
  295 +
  296 + function fontSize($i){
  297 + $this->fontSize = $i ;
  298 + return $this;
  299 + }
  300 +
  301 + function font($i){
  302 + $this->font = $i ;
  303 + return $this;
  304 + }
  305 +
  306 + function color($i){
  307 + $this->color = $i ;
  308 + return $this;
  309 + }
  310 +
  311 + function background($i){
  312 + $this->background = $i ;
  313 + return $this;
  314 + }
  315 +
  316 + function __get($var){
  317 + return $this->$var ;
  318 + }
  319 +
  320 + function gravity( $gravity){
  321 + $this->pGravity = $gravity;
  322 + return $this ;
  323 + }
  324 +
  325 + function text( $text){
  326 + $this->pText = $text;
  327 + return $this ;
  328 + }
  329 +}
  330 +
  331 +?>
45 library/Pas/plugins/cli.php
... ... @@ -0,0 +1,45 @@
  1 +<?php
  2 +
  3 +/*
  4 + +--------------------------------------------------------------------------------------------+
  5 + | DISCLAIMER - LEGAL NOTICE - |
  6 + +--------------------------------------------------------------------------------------------+
  7 + | |
  8 + | This program is free for non comercial use, see the license terms available at |
  9 + | http://www.francodacosta.com/licencing/ for more information |
  10 + | |
  11 + | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
  12 + | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
  13 + | |
  14 + | USE IT AT YOUR OWN RISK |
  15 + | |
  16 + | |
  17 + +--------------------------------------------------------------------------------------------+
  18 +
  19 +*/
  20 +/**
  21 + * phMagick - execute direct calls to image magick binaries
  22 + *
  23 + * @package phMagick
  24 + * @version 0.1.0
  25 + * @author Nuno Costa - sven@francodacosta.com
  26 + * @copyright Copyright (c) 2007
  27 + * @license http://www.francodacosta.com/phmagick/license/
  28 + * @link http://www.francodacosta.com/phmagick
  29 + * @since 2008-03-13
  30 + */
  31 +
  32 +
  33 +class phMagick_cli{
  34 + function cmd(phmagick $p, $string){
  35 + /*var list
  36 + %width
  37 + %height
  38 + %source
  39 + %destination
  40 + %tmp
  41 + */
  42 +
  43 + }
  44 +}
  45 +?>
148 library/Pas/plugins/color.php
... ... @@ -0,0 +1,148 @@
  1 +<?php
  2 +/*
  3 + +--------------------------------------------------------------------------------------------+
  4 + | DISCLAIMER - LEGAL NOTICE - |
  5 + +--------------------------------------------------------------------------------------------+
  6 + | |
  7 + | This program is free for non comercial use, see the license terms available at |
  8 + | http://www.francodacosta.com/licencing/ for more information |
  9 + | |
  10 + | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
  11 + | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
  12 + | |
  13 + | USE IT AT YOUR OWN RISK |
  14 + | |
  15 + | |
  16 + +--------------------------------------------------------------------------------------------+
  17 +
  18 +*/
  19 +/**
  20 + * phMagick - Color manipulation function
  21 + *
  22 + * @package phMagick
  23 + * @version 0.1.0
  24 + * @author Nuno Costa - sven@francodacosta.com
  25 + * @copyright Copyright (c) 2007
  26 + * @license http://www.francodacosta.com/phmagick/license/
  27 + * @link http://www.francodacosta.com/phmagick
  28 + * @since 2008-03-13
  29 + */
  30 +class phMagick_color {
  31 + function darken(phmagick $p ,$alphaValue = 50){
  32 + $percent = 100 - (int) $alphaValue;
  33 +
  34 + //get original file dimentions
  35 +
  36 + list ($width, $height) = $p->getInfo();
  37 +
  38 + $cmd = $p->getBinary('composite');
  39 + $cmd .= ' -blend ' . $percent . ' ';
  40 + $cmd .= '"'.$p->getSource().'"';
  41 + $cmd .= ' -size '. $width .'x'. $height.' xc:black ';
  42 + $cmd .= '-matte "' . $p->getDestination().'"' ;
  43 +
  44 + $p->execute($cmd);
  45 + $p->setSource($p->getDestination());
  46 + $p->setHistory($p->getDestination());
  47 + return $p ;
  48 + }
  49 +
  50 + /**
  51 + *
  52 + * Brightens an image, defualt: 50%
  53 + *
  54 + * @param $imageFile String - Physical path of the umage file
  55 + * @param $newFile String - Physical path of the generated image
  56 + * @param $alphaValue Integer - 100: white , 0: original color (no change)
  57 + * @return boolean - True: success
  58 + */
  59 + function brighten(phmagick $p, $alphaValue = 50){
  60 +
  61 + $percent = 100 - (int) $alphaValue;
  62 +
  63 + //get original file dimentions
  64 +
  65 + list ($width, $height) = $p->getInfo();
  66 +
  67 + $cmd = $p->getBinary('composite');
  68 + $cmd .= ' -blend ' . $percent . ' ';
  69 + $cmd .= '"'.$p->getSource().'"';
  70 + $cmd .= ' -size '. $width .'x'. $height.' xc:white ';
  71 + $cmd .= '-matte "' . $p->getDestination().'"' ;
  72 +
  73 + $p->execute($cmd);
  74 + $p->setSource($p->getDestination());
  75 + $p->setHistory($p->getDestination());
  76 + return $p ;
  77 + }
  78 +
  79 + /**
  80 + * Convert's the image to grayscale
  81 + */
  82 +// function toGrayScale(phmagick $p){
  83 +// $cmd = $p->getBinary('convert');
  84 +// $cmd .= ' "' . $p->getSource() .'"';
  85 +// $cmd .= ' -colorspace Gray ';
  86 +// $cmd .= ' "' . $p->getDestination().'"' ;
  87 +//
  88 +// $p->execute($cmd);
  89 +// $p->setSource($p->getDestination());
  90 +// $p->setHistory($p->getDestination());
  91 +// return $p ;
  92 +// }
  93 +
  94 + function toGreyScale(phmagick $p, $enhance=2){
  95 + $cmd = $p->getBinary('convert');
  96 + $cmd .= ' -modulate 100,0 ' ;
  97 + $cmd .= ' -sigmoidal-contrast '.$enhance.'x50%' ;
  98 + $cmd .= ' -background "none" "' . $p->getSource().'"' ;
  99 + $cmd .= ' "' . $p->getDestination() .'"';
  100 +
  101 + $p->execute($cmd);
  102 + $p->setSource($p->getDestination());
  103 + $p->setHistory($p->getDestination());
  104 + return $p ;
  105 + }
  106 +
  107 + /**
  108 + * Inverts the image colors
  109 + */
  110 + function invertColors(phmagick $p){
  111 + $cmd = $p->getBinary('convert');
  112 + $cmd .= ' "' . $p->getSource() .'"';
  113 + $cmd .= ' -negate ';
  114 + $cmd .= ' "' . $p->getDestination() .'"';
  115 +
  116 + $p->execute($cmd);
  117 + $p->setSource($p->getDestination());
  118 + $p->setHistory($p->getDestination());
  119 + return $p ;
  120 + }
  121 +
  122 + function sepia(phmagick $p, $tone = 90){
  123 + $cmd = $p->getBinary('convert');
  124 + $cmd .= ' -sepia-tone '. $tone .'% ' ;
  125 + $cmd .= ' -modulate 100,50 ' ;
  126 + $cmd .= ' -normalize ' ;
  127 + $cmd .= ' -background "none" "' . $p->getSource() .'"' ;
  128 + $cmd .= ' "' . $p->getDestination().'"' ;
  129 + $p->execute($cmd);
  130 + $p->setSource($p->getDestination());
  131 + $p->setHistory($p->getDestination());
  132 + return $p ;
  133 + }
  134 +
  135 + function autoLevels(phmagick $p){
  136 + $cmd = $p->getBinary('convert');
  137 + $cmd .= ' -normalize ' ;
  138 + $cmd .= ' -background "none" "' . $p->getSource().'"' ;
  139 + $cmd .= ' "' . $p->getDestination() .'"' ;
  140 +
  141 + $p->execute($cmd);
  142 + $p->setSource($p->getDestination());
  143 + $p->setHistory($p->getDestination());
  144 + return $p ;
  145 + }
  146 +
  147 +}
  148 +?>
93 library/Pas/plugins/compose.php
... ... @@ -0,0 +1,93 @@
  1 +<?php
  2 +/*
  3 + +--------------------------------------------------------------------------------------------+
  4 + | DISCLAIMER - LEGAL NOTICE - |
  5 + +--------------------------------------------------------------------------------------------+
  6 + | |
  7 + | This program is free for non comercial use, see the license terms available at |
  8 + | http://www.francodacosta.com/licencing/ for more information |
  9 + | |
  10 + | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
  11 + | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
  12 + | |
  13 + | USE IT AT YOUR OWN RISK |
  14 + | |
  15 + | |
  16 + +--------------------------------------------------------------------------------------------+
  17 +
  18 +*/
  19 +/**
  20 + * phMagick - creating new images by joining several images or by grabbing frames
  21 + *
  22 + * @package phMagick
  23 + * @version 0.1.0
  24 + * @author Nuno Costa - sven@francodacosta.com
  25 + * @copyright Copyright (c) 2007
  26 + * @license http://www.francodacosta.com/phmagick/license/
  27 + * @link http://www.francodacosta.com/phmagick
  28 + * @since 2008-03-13
  29 + */
  30 +class phMagick_compose{
  31 +/**
  32 + * Add's an watermark to an image
  33 + *
  34 + * @param $watermarkImage String - Image path
  35 + * @param $gravity phMagickGravity - The placement of the watermark
  36 + * @param $transparency Integer - 1 to 100 the tranparency of the watermark (100 = opaque)
  37 + */
  38 + function watermark(phmagick $p, $watermarkImage, $gravity = 'center', $transparency = 50){
  39 + //composite -gravity SouthEast watermark.png original-image.png output-image.png
  40 + $cmd = $p->getBinary('composite');
  41 + $cmd .= ' -dissolve ' . $transparency ;
  42 + $cmd .= ' -gravity ' . $gravity ;
  43 + $cmd .= ' ' . $watermarkImage ;
  44 + $cmd .= ' "' . $p->getSource() .'"' ;
  45 + $cmd .= ' "' . $p->getDestination() .'"' ;
  46 +
  47 + $p->execute($cmd);
  48 + $p->setSource($p->getDestination());
  49 + $p->setHistory($p->getDestination());
  50 + return $p ;
  51 + }
  52 +
  53 + /**
  54 + *
  55 + * Joins severall imagens in one tab strip
  56 + *
  57 + * @param $paths Array of Strings - the paths of the images to join
  58 + */
  59 + function tile(phmagick $p, Array $paths = null, $tileWidth = '', $tileHeight=1){
  60 + if( is_null($paths) ) {
  61 + $paths = $p->getHistory(phMagickHistory::returnArray);
  62 + }
  63 + $cmd = $p->getBinary('montage');
  64 + $cmd .= ' -geometry x+0+0 -tile '.$tileWidth.'x'.$tileHeight.' ';
  65 + $cmd .= implode(' ', $paths);
  66 + $cmd .= ' "' . $p->getDestination() .'"' ;
  67 +
  68 + $p->execute($cmd);
  69 + $p->setSource($p->getDestination());
  70 + $p->setHistory($p->getDestination());
  71 + return $p ;
  72 + }
  73 +
  74 + /**
  75 + * Attempts to create an image(s) from a File (PDF & Avi are supported on most systems)
  76 + * it grabs the first frame / page from the source file
  77 + * @param $file String - the path to the file
  78 + * @param $ext String - the extention of the generated image
  79 + */
  80 + function acquireFrame(phmagick $p, $file, $frames=0){
  81 + // $cmd = 'echo "" | '; //just a workarround for videos,
  82 + // imagemagick first converts all frames then deletes all but the first
  83 + $cmd = $p->getBinary('convert');
  84 + $cmd .= ' "' . $file .'"['.$frames.']' ;
  85 + $cmd .= ' "' . $p->getDestination().'"' ;
  86 +
  87 + $p->execute($cmd);
  88 + $p->setSource($p->getDestination());
  89 + $p->setHistory($p->getDestination());
  90 + return $p ;
  91 + }
  92 +}
  93 +?>
47 library/Pas/plugins/convert.php
... ... @@ -0,0 +1,47 @@
  1 +<?php
  2 +/*
  3 + +--------------------------------------------------------------------------------------------+
  4 + | DISCLAIMER - LEGAL NOTICE - |
  5 + +--------------------------------------------------------------------------------------------+
  6 + | |
  7 + | This program is free for non comercial use, see the license terms available at |
  8 + | http://www.francodacosta.com/licencing/ for more information |
  9 + | |
  10 + | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
  11 + | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
  12 + | |
  13 + | USE IT AT YOUR OWN RISK |
  14 + | |
  15 + | |
  16 + +--------------------------------------------------------------------------------------------+
  17 +
  18 +*/
  19 +/**
  20 + * phMagick - Conversion function
  21 + *
  22 + * @package phMagick
  23 + * @version 0.1.0
  24 + * @author Nuno Costa - sven@francodacosta.com
  25 + * @copyright Copyright (c) 2007
  26 + * @license http://www.francodacosta.com/phmagick/license/
  27 + * @link http://www.francodacosta.com/phmagick
  28 + * @since 2008-03-13
  29 + */
  30 +class phMagick_convert{
  31 +
  32 + function convert(phmagick $p){
  33 + $cmd = $p->getBinary('convert');
  34 + $cmd .= ' -quality ' . $p->getImageQuality();
  35 + $cmd .= ' "' . $p->getSource() .'" "'. $p->getDestination().'"';
  36 +
  37 + $p->execute($cmd);
  38 + $p->setSource($p->getDestination());
  39 + $p->setHistory($p->getDestination());
  40 + return $p ;
  41 + }
  42 +
  43 + function save(phmagick $p){
  44 + return $this->save($p);
  45 + }
  46 +}
  47 +?>
56 library/Pas/plugins/crop.php
... ... @@ -0,0 +1,56 @@
  1 +<?php
  2 +/*
  3 + +--------------------------------------------------------------------------------------------+
  4 + | DISCLAIMER - LEGAL NOTICE - |
  5 + +--------------------------------------------------------------------------------------------+
  6 + | |
  7 + | This program is free for non comercial use, see the license terms available at |
  8 + | http://www.francodacosta.com/licencing/ for more information |
  9 + | |
  10 + | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
  11 + | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
  12 + | |
  13 + | USE IT AT YOUR OWN RISK |
  14 + | |
  15 + | |
  16 + +--------------------------------------------------------------------------------------------+
  17 +
  18 +*/
  19 +/**
  20 + * phMagick - Crop function
  21 + *
  22 + * @package phMagick
  23 + * @version 0.1.0
  24 + * @author Nuno Costa - sven@francodacosta.com
  25 + * @copyright Copyright (c) 2007
  26 + * @license http://www.francodacosta.com/phmagick/license/
  27 + * @link http://www.francodacosta.com/phmagick
  28 + * @since 2008-03-13
  29 + */
  30 +class phMagick_crop{
  31 +/**
  32 + *
  33 + * @param $width Integer
  34 + * @param $height Integer
  35 + * @param $top Integer - The Y coordinate for the left corner of the crop rectangule
  36 + * @param $left Integer - The X coordinate for the left corner of the crop rectangule
  37 + * @param $gravity phMagickGravity - The initial placement of the crop rectangule
  38 + * @return unknown_type
  39 + */
  40 + function crop(phmagick $p, $width, $height, $top = 0, $left = 0, $gravity = 'center'){
  41 + $cmd = $p->getBinary('convert');
  42 + $cmd .= ' ' . $p->getSource() ;
  43 +
  44 + if (($gravity != '')|| ($gravity != phMagickGravity::None) ) $cmd .= ' -gravity ' . $gravity ;
  45 +
  46 + $cmd .= ' -crop ' . (int)$width . 'x'.(int)$height ;
  47 + $cmd .= '+' . $left.'+'.$top;
  48 + $cmd .= ' ' . $p->getDestination() ;
  49 +
  50 + $p->execute($cmd);
  51 + $p->setSource($p->getDestination());
  52 + $p->setHistory($p->getDestination());
  53 + return $p ;
  54 + }
  55 +}
  56 +?>
173 library/Pas/plugins/decorations.php
... ... @@ -0,0 +1,173 @@
  1 +<?php
  2 +/*
  3 + +--------------------------------------------------------------------------------------------+
  4 + | DISCLAIMER - LEGAL NOTICE - |
  5 + +--------------------------------------------------------------------------------------------+
  6 + | |
  7 + | This program is free for non comercial use, see the license terms available at |
  8 + | http://www.francodacosta.com/licencing/ for more information |
  9 + | |
  10 + | This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; |
  11 + | without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
  12 + | |
  13 + | USE IT AT YOUR OWN RISK |
  14 + | |
  15 + | |
  16 + +--------------------------------------------------------------------------------------------+
  17 +
  18 +*/
  19 +/**
  20 + * phMagick - Image decorations function
  21 + *
  22 + * @package phMagick
  23 + * @version 0.1.0
  24 + * @author Nuno Costa - sven@francodacosta.com
  25 + * @copyright Copyright (c) 2007
  26 + * @license http://www.francodacosta.com/phmagick/license/
  27 + * @link http://www.francodacosta.com/phmagick
  28 + * @since 2008-03-13
  29 + */
  30 +class phmagick_decorations{
  31 + function roundCorners(phmagick $p,$i = 15){
  32 +
  33 + //original idea from Leif ��strand <leif@sitelogic.fi>
  34 + $cmd = $p->getBinary('convert');
  35 + $cmd .= ' "' . $p->getSource().'"' ;
  36 + $cmd .= ' ( +clone -threshold -1 ' ;
  37 + $cmd .= "-draw \"fill black polygon 0,0 0,$i $i,0 fill white circle $i,$i $i,0\" ";
  38 + $cmd .= '( +clone -flip ) -compose Multiply -composite ';
  39 + $cmd .= '( +clone -flop ) -compose Multiply -composite ';
  40 + $cmd .= ') +matte -compose CopyOpacity -composite ' ;
  41 + $cmd .= ' "' . $p->getDestination().'"' ;
  42 +
  43 +
  44 + $p->execute($cmd);
  45 + $p->setSource($p->getDestination());
  46 + $p->setHistory($p->getDestination());
  47 + return $p ;
  48 + }
  49 +
  50 + function dropShadow(phmagick $p,$color = '#000', $offset = 4, $transparency = 60, $top = 4, $left=4){
  51 +
  52 + $top = $top > 0 ? '+' . $top : $top;
  53 + $left = $left > 0 ? '+' . $left : $left;
  54 +
  55 + $cmd = $p->getBinary('convert');
  56 + $cmd .= ' -page '.$top.$left.' "' . $p->getSource().'"' ;
  57 + $cmd .= ' -matte ( +clone -background "'. $color .'" -shadow '. $transparency.'x4+'.$offset.'+'.$offset.' ) +swap ';
  58 + $cmd .= ' -background none -mosaic ';
  59 + $cmd .= ' "' . $p->getDestination().'"' ;
  60 +
  61 + $p->execute($cmd);
  62 + $p->setSource($p->getDestination());
  63 + $p->setHistory($p->getDestination());
  64 + return $p ;
  65 + }
  66 +
  67 + function glow(phmagick $p, $color='#827f00',$offset = 10, $transparency=60){
  68 +
  69 + $p->requirePlugin('info');
  70 + list ($w, $h) = $p->getInfo($p->getSource());
  71 +
  72 +
  73 + $cmd = $p->getBinary('convert');
  74 +
  75 + $cmd .= ' "' . $p->getSource() .'" ' ;
  76 + $cmd .= '( +clone -background "'.$color.'" -shadow '.$transparency.'x'.$offset.'-'.($offset/4).'+'.($offset/4).' ) +swap -background none -layers merge +repage ';
  77 +
  78 + $cmd .= ' "' . $p->getDestination().'"' ;
  79 +
  80 + $p->execute($cmd);
  81 + $p->setSource($p->getDestination());
  82 + $p->setHistory($p->getDestination());
  83 + return $p ;
  84 + }
  85 +
  86 + /**
  87 + * Fake polaroid effect (white border and rotation)
  88 + *
  89 + * @param $rotation Int - The imahe will be rotatex x degrees
  90 + * @param $borderColor - Polaroid border (ussuay white)
  91 + * @param $shaddowColor - drop shaddow color
  92 + * @param $background - Image background color (use for jpegs or images that do not support transparency or you will end up with a black background)
  93 + */
  94 + function fakePolaroid(phmagick $p,$rotate = 6 , $borderColor = "#fff", $background ="none"){
  95 + $cmd = $p->getBinary('convert');
  96 + $cmd .= ' "' . $p->getSource().'"' ;
  97 + $cmd .= ' -bordercolor "'. $borderColor.'" -border 6 -bordercolor grey60 -border 1 -background "none" -rotate '. $rotate .' -background black ( +clone -shadow 60x4+4+4 ) +swap -background "'. $background.'" -flatten';
  98 + $cmd .= ' ' . $p->getDestination() ;
  99 +
  100 + //echo $cmd .'<br>';;
  101 + $ret = $p->execute($cmd);
  102 + $p->setSource($p->getDestination());
  103 + $p->setHistory($p->getDestination());
  104 + return $p ;
  105 + }
  106 +
  107