1- <?php
2- /**
1+ <?php
2+ /**
33 * phpZenfolio - phpZenfolio is a PHP wrapper class for the Zenfolio API. The intention
44 * of this class is to allow PHP application developers to quickly
55 * and easily interact with the Zenfolio API in their applications,
66 * without having to worry about the finer details of the API.
77 *
88 * @author Colin Seymour <[email protected] > 9- * @version 1.2
9+ * @version 1.3
1010 * @package phpZenfolio
1111 * @license GNU General Public License version 3 {@link http://www.gnu.org/licenses/gpl.html}
1212 * @copyright Copyright (c) 2010 Colin Seymour
2626 * You should have received a copy of the GNU General Public License
2727 * along with phpZenfolio. If not, see <http://www.gnu.org/licenses/>.
2828 *
29- *
29+ *
3030 * For more information about the class and upcoming tools and toys using it,
3131 * visit {@link http://phpzenfolio.com/}.
3232 *
33- * For installation and usage instructions, open the README.txt file
33+ * For installation and usage instructions, open the README.txt file
3434 * packaged with this class. If you don't have a copy, you can refer to the
3535 * documentation at:
36- *
36+ *
3737 * {@link http://phpzenfolio.com/docs/}
38- *
38+ *
3939 * phpZenfolio is based on the worked I have done in phpSmug ({@link http://phpsmug.com}).
4040 *
4141 * Please help support the maintenance and development of phpZenfolio by making
@@ -54,7 +54,7 @@ class PhpZenfolioException extends Exception {}
5454 * @package phpZenfolio
5555 **/
5656class phpZenfolio {
57- static $ version = '1.2 ' ;
57+ static $ version = '1.3 ' ;
5858 private $ cacheType = FALSE ;
5959 private $ cache_expire = 3600 ;
6060 private $ keyring ;
@@ -72,14 +72,14 @@ class phpZenfolio {
7272 * You should try to set it high enough that the cleanup only
7373 * happens every once in a while, so this will depend on the growth
7474 * of your table.
75- *
75+ *
7676 * @var integer
7777 **/
7878 var $ max_cache_rows = 1000 ;
79-
79+
8080 /**
8181 * Constructor to set up a phpZenfolio instance.
82- *
82+ *
8383 * The Application Name (AppName) is obligatory as it helps Zenfolio identify
8484 * your application and diagnose any problems users of your application may encounter.
8585 *
@@ -95,13 +95,13 @@ class phpZenfolio {
9595 * in the form "AppName/version (URI)"
9696 * e.g. "My Cool App/1.0 (http://my.url.com)".
9797 * @param string $APIVer (Optional) API endpoint you wish to use.
98- * Defaults to 1.6
98+ * Defaults to 1.8
9999 * @return void
100100 **/
101101 public function __construct ()
102102 {
103103 $ args = phpZenfolio::processArgs ( func_get_args () );
104- $ this ->APIVer = ( array_key_exists ( 'APIVer ' , $ args ) ) ? $ args ['APIVer ' ] : '1.6 ' ;
104+ $ this ->APIVer = ( array_key_exists ( 'APIVer ' , $ args ) ) ? $ args ['APIVer ' ] : '1.8 ' ;
105105 // Set the Application Name
106106 if ( ! isset ( $ args ['AppName ' ] ) ) {
107107 throw new PhpZenfolioException ( 'Application name missing. ' , -10001 );
@@ -114,7 +114,7 @@ public function __construct()
114114 'X-Zenfolio-User-Agent ' => "{$ this ->AppName } using phpZenfolio/ " . phpZenfolio::$ version ,
115115 'Content-Type ' => 'application/json ' ) );
116116 }
117-
117+
118118 /**
119119 * General debug function used for testing and development of phpZenfolio.
120120 *
@@ -137,15 +137,15 @@ public static function debug( $var, $echo = TRUE )
137137 if ( $ echo ) { ob_end_flush (); } else { $ out = ob_get_clean (); }
138138 return $ out ;
139139 }
140-
140+
141141 /**
142142 * Function enables caching.
143143 *
144144 * Params can be passed as an associative array or a set of param=value strings.
145145 *
146146 * phpZenfolio uses the PEAR MDB2 module to interact with the database. You will
147147 * need to install PEAR, the MDB2 module and corresponding database driver yourself
148- * in order to use database caching.
148+ * in order to use database caching.
149149 *
150150 * @access public
151151 * @param string $type The type of cache to use. It must be either
@@ -170,7 +170,7 @@ public function enableCache()
170170 {
171171 $ args = phpZenfolio::processArgs ( func_get_args () );
172172 $ this ->cacheType = $ args ['type ' ];
173-
173+
174174 $ this ->cache_expire = ( array_key_exists ( 'cache_expire ' , $ args ) ) ? $ args ['cache_expire ' ] : '3600 ' ;
175175 $ this ->cache_table = ( array_key_exists ( 'table ' , $ args ) ) ? $ args ['table ' ] : 'phpzenfolio_cache ' ;
176176
@@ -258,7 +258,7 @@ private function getCached( $request )
258258 }
259259
260260 /**
261- * Caches the unparsed serialized PHP of a request.
261+ * Caches the unparsed serialized PHP of a request.
262262 *
263263 * @access private
264264 * @param array $request Request to the Zenfolio API created by one
@@ -360,7 +360,7 @@ private function request( $command, $args = array() )
360360 if ( ! is_null ( $ this ->keyring ) ) {
361361 $ this ->req ->setHeader ( 'X-Zenfolio-Keyring ' , $ this ->keyring );
362362 }
363-
363+
364364 // To keep things unique, we set the ID to the md5 sum of the method
365365 $ this ->id = md5 ( $ command );
366366 $ args = array ( 'method ' => $ command , 'params ' => $ args , 'id ' => $ this ->id );
@@ -392,7 +392,7 @@ private function request( $command, $args = array() )
392392
393393 return $ this ->response ;
394394 }
395-
395+
396396 /**
397397 * Set a proxy for all phpZenfolio calls.
398398 *
@@ -421,25 +421,25 @@ public function setProxy()
421421 'proxy_password ' => $ this ->proxy ['password ' ],
422422 'proxy_auth_scheme ' => $ this ->proxy ['auth_scheme ' ] ) );
423423 }
424-
424+
425425 /**
426426 * Force phpZenfolio to use HTTPS for ALL requests, not just authentication
427427 * requests.
428- *
428+ *
429429 * NOTE: This may have an adverse effect on performance if used for ALL requests.
430430 * Use with caution.
431- *
431+ *
432432 * @access public
433433 * @return void
434- **/
434+ **/
435435 public function setSecureOnly ()
436436 {
437437 $ this ->secure = TRUE ;
438438 }
439-
439+
440440 /**
441441 * Single login function for all login methods.
442- *
442+ *
443443 * I've created this function to make it easy to login to Zenfolio using either
444444 * the plaintext authentication method, or the more secure challenge-response (default)
445445 * authentication method.
@@ -473,7 +473,7 @@ public function login()
473473 }
474474 return $ this ->authToken ;
475475 }
476-
476+
477477 /**
478478 * To make life easy for phpZenfolio users, I've created a single method that
479479 * can be used to upload files. This uses the Simplified HTTP POST method as
@@ -543,7 +543,7 @@ public function upload()
543543 $ photoset = $ this ->LoadPhotoSet ( $ args ['PhotoSetId ' ] );
544544 $ UploadUrl = 'http://up.zenfolio.com ' . $ photoset ['UploadUrl ' ];
545545 } else {
546- $ photoset = ( $ this ->APIVer == '1.4 ' || $ this ->APIVer == '1.6 ' ) ? $ this ->LoadPhotoSet ( $ args ['PhotoSetId ' ], 'Level1 ' , FALSE ) : $ this ->LoadPhotoSet ( $ args ['PhotoSetId ' ] );
546+ $ photoset = ( $ this ->APIVer == '1.4 ' || $ this ->APIVer == '1.6 ' || $ this -> APIVer == ' 1.8 ' ) ? $ this ->LoadPhotoSet ( $ args ['PhotoSetId ' ], 'Level1 ' , FALSE ) : $ this ->LoadPhotoSet ( $ args ['PhotoSetId ' ] );
547547 $ UploadUrl = $ photoset ['UploadUrl ' ];
548548 }
549549 }
@@ -569,11 +569,11 @@ public function upload()
569569
570570 return $ this ->response ;
571571 }
572-
572+
573573 /**
574574 * Dynamic method handler. This function handles all Zenfolio method calls
575575 * not explicitly implemented by phpZenfolio.
576- *
576+ *
577577 * @access public
578578 * @uses request
579579 * @param string $method The Zenfolio method you want to call.
@@ -628,7 +628,7 @@ public function setAdapter( $adapter )
628628 $ this ->req ->setAdapter ( $ adapter );
629629 }
630630 }
631-
631+
632632 /**
633633 * Process arguments passed to method
634634 *
@@ -950,7 +950,7 @@ public function getParams()
950950 {
951951 return $ this ->params ;
952952 }
953-
953+
954954 /**
955955 * Get the current configuration. This is more for unit testing purposes
956956 */
@@ -1106,7 +1106,7 @@ private function mergeQueryParams( $url, $params )
11061106
11071107}
11081108
1109-
1109+
11101110
11111111class PhpZenfolioCurlRequestProcessor implements PhpZenfolioRequestProcessor
11121112{
@@ -1225,7 +1225,7 @@ public function getHeaders()
12251225 }
12261226}
12271227
1228-
1228+
12291229
12301230class PhpZenfolioSocketRequestProcessor implements PhpZenfolioRequestProcessor
12311231{
@@ -1234,17 +1234,17 @@ class PhpZenfolioSocketRequestProcessor implements PhpZenfolioRequestProcessor
12341234 private $ executed = FALSE ;
12351235 private $ redir_count = 0 ;
12361236 private $ can_followlocation = true ;
1237-
1238- public function __construct ( )
1239- {
1237+
1238+ public function __construct ( )
1239+ {
12401240 // see if we can follow Location: headers
12411241 if ( ini_get ( 'safe_mode ' ) || ini_get ( 'open_basedir ' ) ) {
12421242 $ this ->can_followlocation = false ;
1243- }
1243+ }
12441244 }
1245-
1246- public function execute ( $ method , $ url , $ headers , $ body , $ config )
1247- {
1245+
1246+ public function execute ( $ method , $ url , $ headers , $ body , $ config )
1247+ {
12481248 $ merged_headers = array ();
12491249 foreach ( $ headers as $ k => $ v ) {
12501250 $ merged_headers [] = $ k . ': ' . $ v ;
0 commit comments