added bugfixes for latest gallery changes
This commit is contained in:
parent
e952c1002e
commit
cd089cb36c
@ -116,6 +116,10 @@ class Gallery_Remote_Controller extends Controller {
|
|||||||
return (false); // no match at all
|
return (false); // no match at all
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static function decode($input) {
|
||||||
|
return html_entity_decode(trim($input), ENT_COMPAT, 'UTF-8');
|
||||||
|
}
|
||||||
|
|
||||||
private function _login(&$input, &$reply) {
|
private function _login(&$input, &$reply) {
|
||||||
$uname = trim($input->post('uname'));
|
$uname = trim($input->post('uname'));
|
||||||
if (empty($uname)) {
|
if (empty($uname)) {
|
||||||
@ -198,9 +202,9 @@ class Gallery_Remote_Controller extends Controller {
|
|||||||
|
|
||||||
private function _new_album(&$input, &$reply) {
|
private function _new_album(&$input, &$reply) {
|
||||||
$album = trim($input->post('set_albumName'));
|
$album = trim($input->post('set_albumName'));
|
||||||
$name = trim($input->post('newAlbumName'));
|
$name = $this->decode($input->post('newAlbumName'));
|
||||||
$title = trim($input->post('newAlbumTitle'));
|
$title = $this->decode($input->post('newAlbumTitle'));
|
||||||
$desc = trim($input->post('newAlbumDesc'));
|
$desc = $this->decode($input->post('newAlbumDesc'));
|
||||||
|
|
||||||
if($album=='0') $parent = item::root();
|
if($album=='0') $parent = item::root();
|
||||||
else $parent = ORM::factory("item")->where("id", "=", $album)->find();
|
else $parent = ORM::factory("item")->where("id", "=", $album)->find();
|
||||||
@ -269,9 +273,9 @@ class Gallery_Remote_Controller extends Controller {
|
|||||||
|
|
||||||
private function _add_item(&$input, &$reply) {
|
private function _add_item(&$input, &$reply) {
|
||||||
$album = trim($input->post('set_albumName'));
|
$album = trim($input->post('set_albumName'));
|
||||||
$userfilename = trim($input->post('userfile_name'));
|
$userfilename = $this->decode($input->post('userfile_name'));
|
||||||
$title = trim($input->post('caption'));
|
$title = $this->decode($input->post('caption'));
|
||||||
$forcefilename = trim($input->post('force_filename'));
|
$forcefilename = $this->decode($input->post('force_filename'));
|
||||||
$autorotate = trim($input->post('auto_rotate'));
|
$autorotate = trim($input->post('auto_rotate'));
|
||||||
|
|
||||||
if($album=='0') $parent = item::root();
|
if($album=='0') $parent = item::root();
|
||||||
@ -314,6 +318,18 @@ class Gallery_Remote_Controller extends Controller {
|
|||||||
if($pos!==false)
|
if($pos!==false)
|
||||||
$slug = substr($slug, 0, $pos);
|
$slug = substr($slug, 0, $pos);
|
||||||
|
|
||||||
|
//*/ fix for a gallery remote bug...
|
||||||
|
$filename = str_replace('.JPG.jpeg', '.jpeg', $filename);
|
||||||
|
//*/
|
||||||
|
|
||||||
|
//*/ suddenly gallery fails because the uploaded(!) file (of cause!) doesn't contain a file extension
|
||||||
|
if(strpos($_FILES['userfile']['tmp_name'], '.')===false) {
|
||||||
|
$moveto = $_FILES['userfile']['tmp_name'].'.'.substr($type, strpos($type, '/')+1);
|
||||||
|
rename($_FILES['userfile']['tmp_name'], $moveto);
|
||||||
|
$_FILES['userfile']['tmp_name'] = $moveto;
|
||||||
|
}
|
||||||
|
//*/
|
||||||
|
|
||||||
try {
|
try {
|
||||||
$item = ORM::factory('item');
|
$item = ORM::factory('item');
|
||||||
$item->type = 'photo';
|
$item->type = 'photo';
|
||||||
@ -337,7 +353,14 @@ class Gallery_Remote_Controller extends Controller {
|
|||||||
$reply->set('status_text', 'New item created successfuly.');
|
$reply->set('status_text', 'New item created successfuly.');
|
||||||
$reply->send();
|
$reply->send();
|
||||||
|
|
||||||
} catch (Exception $e) {
|
}
|
||||||
|
catch (ORM_Validation_Exception $e) {
|
||||||
|
$validation = $e->validation;
|
||||||
|
//print_r($validation->errors()); exit;
|
||||||
|
$reply->set('status_text', t('Failed to validate item %item: %errors', array('item' => $filename, 'errors' => str_replace("\n", ' ', print_r($validation->errors(),true))) ));
|
||||||
|
$reply->send(gallery_remote::UPLOAD_PHOTO_FAIL); //FIXME gallery remote ignores this return value and continues to wait
|
||||||
|
}
|
||||||
|
catch (Exception $e) {
|
||||||
$reply->set('status_text', t('Failed to add item %item.', array('item' => $filename)));
|
$reply->set('status_text', t('Failed to add item %item.', array('item' => $filename)));
|
||||||
$reply->send(gallery_remote::UPLOAD_PHOTO_FAIL); //FIXME gallery remote ignores this return value and continues to wait
|
$reply->send(gallery_remote::UPLOAD_PHOTO_FAIL); //FIXME gallery remote ignores this return value and continues to wait
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user