Skip to content

Commit

Permalink
refs #4053 display a possible error when displaying plugin detail
Browse files Browse the repository at this point in the history
  • Loading branch information
tsteur committed Sep 21, 2013
1 parent dd2179f commit 435ebca
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 6 deletions.
10 changes: 8 additions & 2 deletions plugins/CorePluginsAdmin/Controller.php
Expand Up @@ -87,15 +87,21 @@ public function installPlugin()
public function pluginDetails()
{
$pluginName = Common::getRequestVar('pluginName', '', 'string');
$pluginName = strip_tags($pluginName);

if (empty($pluginName)) {
return;
}

$view = $this->configureView('@CorePluginsAdmin/pluginDetails');
$view->errorMessage = '';

$marketplace = new MarketplaceApiClient();
$view->plugin = $marketplace->getPluginInfo($pluginName);
try {
$marketplace = new MarketplaceApiClient();
$view->plugin = $marketplace->getPluginInfo($pluginName);
} catch (\Exception $e) {
$view->errorMessage = $e->getMessage();
}

echo $view->render();
}
Expand Down
4 changes: 2 additions & 2 deletions plugins/CorePluginsAdmin/javascripts/pluginDetail.js
Expand Up @@ -65,8 +65,8 @@ $(document).ready(function () {
});

var showPopover = function (pluginName) {
var url = 'module=CorePluginsAdmin&action=pluginDetails&pluginName=' + pluginName;
Piwik_Popover.createPopupAndLoadUrl(url, 'theme details');
var url = 'module=CorePluginsAdmin&action=pluginDetails&pluginName=' + encodeURIComponent(pluginName);
Piwik_Popover.createPopupAndLoadUrl(url, 'details');
};

broadcast.addPopoverHandler('browsePluginDetail', showPopover);
Expand Down
7 changes: 5 additions & 2 deletions plugins/CorePluginsAdmin/templates/pluginDetails.twig
Expand Up @@ -3,8 +3,11 @@

<div style="max-width:980px;">

{{ plugin.detailPageHtml|raw }}

{% if errorMessage %}
{{ errorMessage }}
{% elseif plugin %}
{{ plugin.detailPageHtml|raw }}
{% endif %}
</div>

{% endblock %}

0 comments on commit 435ebca

Please sign in to comment.