From 491385cb0633b2fa580577ffe6fb9fb8de75311a Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Fri, 28 Feb 2014 12:31:34 +0100 Subject: [PATCH 1/2] Fix #1703 bridge is broken --- lib/classes/Bridge/Api/Dailymotion.php | 10 +++++----- lib/classes/Bridge/Api/Flickr.php | 6 +++--- lib/classes/Bridge/Api/Interface.php | 2 +- lib/classes/Bridge/Api/Youtube.php | 8 ++++---- lib/classes/DailymotionWithoutOauth2.php | 2 +- 5 files changed, 14 insertions(+), 14 deletions(-) diff --git a/lib/classes/Bridge/Api/Dailymotion.php b/lib/classes/Bridge/Api/Dailymotion.php index 91b5227d20..9c5cec2529 100644 --- a/lib/classes/Bridge/Api/Dailymotion.php +++ b/lib/classes/Bridge/Api/Dailymotion.php @@ -278,7 +278,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I break; default: - throw new Bridge_Exception_ElementUnknown('Unknown element ' . $type); + throw new Bridge_Exception_ElementUnknown('Unknown element ' . $object); break; } } @@ -378,7 +378,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I $result = $this->_api->call($url, $params, $this->oauth_token); break; default: - throw new Bridge_Exception_ElementUnknown('Unknown element ' . $type); + throw new Bridge_Exception_ElementUnknown('Unknown element ' . $object); break; } @@ -402,7 +402,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I return $playlist["id"]; break; default: - throw new Bridge_Exception_ElementUnknown('Unknown element ' . $type); + throw new Bridge_Exception_ElementUnknown('Unknown element ' . $container_type); break; } } @@ -437,7 +437,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I return $this->get_container_from_id(self::CONTAINER_TYPE_PLAYLIST, $container_id); break; default: - throw new Bridge_Exception_ContainerUnknown('Unknown element ' . $container); + throw new Bridge_Exception_ContainerUnknown('Unknown element ' . $element_type); break; } break; @@ -582,7 +582,7 @@ class Bridge_Api_Dailymotion extends Bridge_Api_Abstract implements Bridge_Api_I { switch ($record->get_type()) { case self::ELEMENT_TYPE_VIDEO : - $url_file = $this->_api->uploadFile($record->get_hd_file()->getRealPath(), $this->oauth_token); + $url_file = $this->_api->sendFile($record->get_hd_file()->getRealPath(), $this->oauth_token); $options = array_merge(array('url' => $url_file), $options); $video = $this->_api->call('POST /me/videos', $options, $this->oauth_token); diff --git a/lib/classes/Bridge/Api/Flickr.php b/lib/classes/Bridge/Api/Flickr.php index 64466833c2..25145109bc 100644 --- a/lib/classes/Bridge/Api/Flickr.php +++ b/lib/classes/Bridge/Api/Flickr.php @@ -205,9 +205,9 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf throw new Bridge_Exception_ApiConnectorRequestFailed('Unable to retrieve photoset infos for ' . $object); $xml = $response->getXml(); - $primary_photo = $this->get_element_from_id((string) $child['primary'], self::ELEMENT_TYPE_PHOTO); + $primary_photo = $this->get_element_from_id((string) $xml->photo['id'], self::ELEMENT_TYPE_PHOTO); - return new Bridge_Api_Flickr_Container($xml, $this->get_user_id(), $type, $primary_photo->get_thumbnail()); + return new Bridge_Api_Flickr_Container($xml, $this->get_user_id(), $object, $primary_photo->get_thumbnail()); break; default: throw new Bridge_Exception_ElementUnknown('Unknown element ' . $object); @@ -288,7 +288,7 @@ class Bridge_Api_Flickr extends Bridge_Api_Abstract implements Bridge_Api_Interf break; default: - throw new Bridge_Exception_ElementUnknown('Unknown element ' . $type); + throw new Bridge_Exception_ElementUnknown('Unknown element ' . $object); break; } diff --git a/lib/classes/Bridge/Api/Interface.php b/lib/classes/Bridge/Api/Interface.php index 6036c33411..eb5c3b9a91 100644 --- a/lib/classes/Bridge/Api/Interface.php +++ b/lib/classes/Bridge/Api/Interface.php @@ -10,7 +10,7 @@ */ use Symfony\Component\Routing\Generator\UrlGenerator; - +use Symfony\Component\HttpFoundation\Request; /** * * @package Bridge diff --git a/lib/classes/Bridge/Api/Youtube.php b/lib/classes/Bridge/Api/Youtube.php index 9a166f0a64..2a64602b2f 100644 --- a/lib/classes/Bridge/Api/Youtube.php +++ b/lib/classes/Bridge/Api/Youtube.php @@ -327,7 +327,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter break; default: - throw new Bridge_Exception_ElementUnknown('Unknown element ' . $type); + throw new Bridge_Exception_ElementUnknown('Unknown element ' . $object); break; } @@ -348,7 +348,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter $container_title = $request->get('f_container_title'); $new_playlist = $this->_api->newPlaylistListEntry(); - if (trim($description) !== '') + if (trim($container_desc) !== '') $new_playlist->description = $this->_api->newDescription()->setText($container_desc); $new_playlist->title = $this->_api->newTitle()->setText($container_title); @@ -359,7 +359,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter break; default: - throw new Bridge_Exception_ElementUnknown('Unknown element ' . $type); + throw new Bridge_Exception_ElementUnknown('Unknown element ' . $container_type); break; } } @@ -389,7 +389,7 @@ class Bridge_Api_Youtube extends Bridge_Api_Abstract implements Bridge_Api_Inter return new Bridge_Api_Youtube_Container($playlistEntry, $destination, null); break; default: - throw new Bridge_Exception_ContainerUnknown('Unknown element ' . $container); + throw new Bridge_Exception_ContainerUnknown('Unknown element ' . $destination); break; } break; diff --git a/lib/classes/DailymotionWithoutOauth2.php b/lib/classes/DailymotionWithoutOauth2.php index e14d496741..159381bb2b 100644 --- a/lib/classes/DailymotionWithoutOauth2.php +++ b/lib/classes/DailymotionWithoutOauth2.php @@ -75,7 +75,7 @@ class DailymotionWithoutOauth2 extends Dailymotion * * @return String the resulting URL */ - public function uploadFile($filePath, $oauth_token) + public function sendFile($filePath, $oauth_token) { $result = $this->call('file.upload', array(), $oauth_token); $timeout = $this->timeout; From 88f179ae808c8874445e7f3da1f945a4469798ab Mon Sep 17 00:00:00 2001 From: Nicolas Le Goff Date: Fri, 28 Feb 2014 13:10:33 +0100 Subject: [PATCH 2/2] Remove prod/bridge/manager hardcoded urls --- lib/Alchemy/Phrasea/Controller/Prod/Bridge.php | 3 ++- .../web/prod/actions/Bridge/callback.html.twig | 2 +- templates/web/prod/actions/Bridge/index.html.twig | 5 +++-- templates/web/prod/index.html.twig | 2 +- www/skins/prod/jquery.main-prod.js | 15 ++++++++------- www/skins/prod/publicator.js | 8 ++++---- 6 files changed, 19 insertions(+), 16 deletions(-) diff --git a/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php b/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php index bbac9e3c31..6da6cd7087 100644 --- a/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php +++ b/lib/Alchemy/Phrasea/Controller/Prod/Bridge.php @@ -32,7 +32,8 @@ class Bridge implements ControllerProviderInterface $app['bridge.controller'] = $this; $controllers - ->post('/manager/', 'bridge.controller:doPostManager'); + ->post('/manager/', 'bridge.controller:doPostManager') + ->bind('prod_bridge_manager'); $controllers ->get('/login/{api_name}/', 'bridge.controller:doGetLogin') diff --git a/templates/web/prod/actions/Bridge/callback.html.twig b/templates/web/prod/actions/Bridge/callback.html.twig index 186522a2b5..9b349911e7 100644 --- a/templates/web/prod/actions/Bridge/callback.html.twig +++ b/templates/web/prod/actions/Bridge/callback.html.twig @@ -6,7 +6,7 @@ {% if error_message is empty %} diff --git a/templates/web/prod/actions/Bridge/index.html.twig b/templates/web/prod/actions/Bridge/index.html.twig index 0bd92b6ea5..58b5407013 100644 --- a/templates/web/prod/actions/Bridge/index.html.twig +++ b/templates/web/prod/actions/Bridge/index.html.twig @@ -1,7 +1,7 @@ {% import "common/thumbnail.html.twig" as thumb %} -
+
{% for id, record in route.get_elements %} @@ -86,6 +86,7 @@ $(function() { var pub_tabs = $("#pub_tabs"); var container = $('#dialog_publicator'); + var managerUrl = container.data("url"); function popme(url) { var newwindow=window.open(url,'logger','height=500,width=800'); @@ -157,7 +158,7 @@ $(function() { success: function(datas){ if(datas.success) { confirmBox.Close(); - publicator_reload_publicator(); + publicator_reload_publicator(managerUrl); } else { confirmBox.Close(); var alertBox = p4.Dialog.Create({ diff --git a/templates/web/prod/index.html.twig b/templates/web/prod/index.html.twig index 129a44bd80..1423cfb941 100644 --- a/templates/web/prod/index.html.twig +++ b/templates/web/prod/index.html.twig @@ -603,7 +603,7 @@
  • - + {% trans 'action : bridge' %} diff --git a/www/skins/prod/jquery.main-prod.js b/www/skins/prod/jquery.main-prod.js index 3077e9ee74..3103aabf31 100644 --- a/www/skins/prod/jquery.main-prod.js +++ b/www/skins/prod/jquery.main-prod.js @@ -1665,27 +1665,28 @@ function activeIcons() { } }); - $('.TOOL_bridge_btn').live('click', function () { - + $('.TOOL_bridge_btn').live('click', function (e) { + e.preventDefault(); + var $button = $(this); var datas = {}; - if ($(this).hasClass('results_window')) { + if ($button.hasClass('results_window')) { if (p4.Results.Selection.length() > 0) datas.lst = p4.Results.Selection.serialize(); } else { - if ($(this).hasClass('basket_window')) { + if ($button.hasClass('basket_window')) { if (p4.WorkZone.Selection.length() > 0) datas.lst = p4.WorkZone.Selection.serialize(); else datas.ssel = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } else { - if ($(this).hasClass('basket_element')) { + if ($button.hasClass('basket_element')) { datas.ssel = $('.SSTT.active').attr('id').split('_').slice(1, 2).pop(); } else { - if ($(this).hasClass('story_window')) { + if ($button.hasClass('story_window')) { if (p4.WorkZone.Selection.length() > 0) { datas.lst = p4.WorkZone.Selection.serialize(); } @@ -1698,7 +1699,7 @@ function activeIcons() { } if (datas.ssel || datas.lst || datas.story) { - init_publicator(datas); + init_publicator($button.attr("href"), datas); } else { alert(language.nodocselected); diff --git a/www/skins/prod/publicator.js b/www/skins/prod/publicator.js index bfd162c2fb..37ef801004 100644 --- a/www/skins/prod/publicator.js +++ b/www/skins/prod/publicator.js @@ -1,15 +1,15 @@ -function publicator_reload_publicator() { +function publicator_reload_publicator(url) { var options = $('#dialog_publicator form[name="current_datas"]').serializeArray(); var dialog = p4.Dialog.get(1); - dialog.load('/prod/bridge/manager/', 'POST', options); + dialog.load(url, 'POST', options); } -function init_publicator(datas) { +function init_publicator(url, datas) { var dialog = p4.Dialog.Create({ size: 'Full', title: 'Bridge', loading: false }); - dialog.load('/prod/bridge/manager/', 'POST', datas); + dialog.load(url, 'POST', datas); }