diff --git a/3.0/client/PHP/Gallery3.php b/3.0/client/PHP/Gallery3.php index fb97ddf8..782740c6 100644 --- a/3.0/client/PHP/Gallery3.php +++ b/3.0/client/PHP/Gallery3.php @@ -1,7 +1,7 @@ data = new stdClass(); + $this->data->entity = new stdClass(); $this->token = null; $this->url = null; } @@ -169,7 +169,55 @@ class Gallery3 { } class Gallery3_Helper { + static $instance = null; + static function request($method, $url, $token=null, $params=array(), $file=null) { + if (!isset(self::$instance)) { + @include("HTTP/Request2.php"); + if (class_exists("HTTP_Request2")) { + self::$instance = new Gallery3_Helper_HTTP_Request2(); + } else { + include("HTTP/Request.php"); + self::$instance = new Gallery3_Helper_HTTP_Request(); + } + } + return self::$instance->request($method, $url, $token, $params, $file); + } +} + +class Gallery3_Helper_HTTP_Request2 { + function request($method, $url, $token, $params, $file) { + $req = new HTTP_Request2($url); + $req->setMethod($method == "get" ? 'GET' : 'POST'); + $req->setHeader("X-Gallery-Request-Method", $method); + if ($token) { + $req->setHeader("X-Gallery-Request-Key", $token); + } + foreach ($params as $key => $value) { + $req->addPostParameter($key, is_string($value) ? $value : json_encode($value)); + } + if ($file) { + $req->addUpload("file", $file, basename($file), mime_content_type($file)); + } + $response = $req->send(); + $status = $response->getStatus(); + + switch ($status) { + case 200: + case 201: + return json_decode($response->getBody()); + + case 403: + throw new Gallery3_Forbidden_Exception($response->getBody(),$status); + + default: + throw new Gallery3_Exception($response->getBody(),$status); + } + } +} + +class Gallery3_Helper_HTTP_Request { + function request($method, $url, $token, $params, $file) { $req = new HTTP_Request($url); $req->setMethod($method == "get" ? HTTP_REQUEST_METHOD_GET : HTTP_REQUEST_METHOD_POST); $req->addHeader("X-Gallery-Request-Method", $method); diff --git a/3.0/client/Python/pylibgal3/libg3/G3Items.py b/3.0/client/Python/pylibgal3/libg3/G3Items.py index 0fdae593..ce812551 100644 --- a/3.0/client/Python/pylibgal3/libg3/G3Items.py +++ b/3.0/client/Python/pylibgal3/libg3/G3Items.py @@ -22,7 +22,16 @@ __all__ = ['Album' , 'Image' , 'LocalImage' , 'RemoteImage' , 'LocalMovie' , 'RemoteMovie' , 'getItemFromResp' , 'getItemsFromResp'] from datetime import datetime -import json , weakref , types , os , mimetypes , re +import weakref , types , os , mimetypes , re +try: + import json +except: + try: + import simplejson + except ImportError , e: + raise ImportError('You must have either the "json" or "simplejson"' + 'library installed!') + class BaseRemote(object): def __init__(self , respObj , weakGalObj , weakParent=None): diff --git a/3.0/client/Python/pylibgal3/libg3/Gallery3.py b/3.0/client/Python/pylibgal3/libg3/Gallery3.py index 6345c1a8..13409c8a 100644 --- a/3.0/client/Python/pylibgal3/libg3/Gallery3.py +++ b/3.0/client/Python/pylibgal3/libg3/Gallery3.py @@ -26,7 +26,15 @@ from G3Items import getItemFromResp , getItemsFromResp , BaseRemote , Album , \ RemoteImage , Tag from urllib import quote , urlencode from uuid import uuid4 -import urllib2 , os , json +import urllib2 , os +try: + import json +except: + try: + import simplejson + except ImportError , e: + raise ImportError('You must have either the "json" or "simplejson"' + 'library installed!') class Gallery3(object): """ @@ -129,7 +137,6 @@ class Gallery3(object): uri(str) : The uri string defining the resource on the defined host """ url = self._buildUrl(uri , kwargs) - print url return self.getRespFromUrl(url) def addAlbum(self , parent , albumName , title , description=''): diff --git a/3.0/client/Python/pylibgal3/libg3/__init__.py b/3.0/client/Python/pylibgal3/libg3/__init__.py index eec91668..3805ff18 100644 --- a/3.0/client/Python/pylibgal3/libg3/__init__.py +++ b/3.0/client/Python/pylibgal3/libg3/__init__.py @@ -21,4 +21,4 @@ from G3Items import * from Gallery3 import * -__version__ = '0.1.4' +__version__ = '0.1.5' diff --git a/3.0/modules/about/module.info b/3.0/modules/about/module.info index f0c38ace..52e41635 100644 --- a/3.0/modules/about/module.info +++ b/3.0/modules/about/module.info @@ -3,4 +3,5 @@ description = "About page and detail." author_name = "floridave" author_url = "http://codex.gallery2.org/User:Floridave" info_url = "http://codex.gallery2.org/Gallery3:Modules:about" -discuss_url = "http://gallery.menalto.com/forum_module_about" \ No newline at end of file +discuss_url = "http://gallery.menalto.com/forum_module_about" +version = 1 diff --git a/3.0/modules/about_this_album/helpers/about_this_album_block.php b/3.0/modules/about_this_album/helpers/about_this_album_block.php index aefafff5..b3cd6c26 100644 --- a/3.0/modules/about_this_album/helpers/about_this_album_block.php +++ b/3.0/modules/about_this_album/helpers/about_this_album_block.php @@ -1,7 +1,7 @@ \n
\n\n\n