Skip to content

Commit

Permalink
Dev: Possible to manually check for updates in the plugin manager
Browse files Browse the repository at this point in the history
  • Loading branch information
olleharstedt committed Oct 10, 2018
1 parent 683ae49 commit 1689b64
Show file tree
Hide file tree
Showing 3 changed files with 58 additions and 16 deletions.
54 changes: 41 additions & 13 deletions application/core/plugins/UpdateCheck/UpdateCheck.php
Expand Up @@ -88,14 +88,34 @@ public function beforeControllerAction()
*/
public function beforePluginManagerMenuRender()
{
$notificationUpdateUrl = Notification::getUpdateUrl();
$event = $this->event;
$event->append(
'extraMenus',
new Menu(
[
'href' => ''
]
)
[
new Menu(
[
'href' => $this->getCheckUrl(),
'iconClass' => 'fa fa-refresh',
'label' => gT('Check updates'),
'onClick' => <<<JS
$("#ls-loading").show();
$.ajax(
{
url: this.href,
data: {},
method: "GET",
success: function() {
$("#ls-loading").hide();
LS.updateNotificationWidget("$notificationUpdateUrl", false);
},
}
);
return false;
JS
]
)
]
);
}

Expand Down Expand Up @@ -177,19 +197,27 @@ protected function composerNotification(array $messages, array $errors, bool $fo
protected function spitOutUrl()
{
$data = [
'url' => Yii::app()->createUrl(
'admin/pluginhelper',
array(
'sa' => 'ajax',
'plugin' => 'updateCheck',
'method' => 'checkAll'
)
),
'url' => $this->getCheckUrl(),
'notificationUpdateUrl' => Notification::getUpdateUrl()
];
echo $this->api->renderTwig(__DIR__ . '/views/index.twig', $data);
}

/**
* @return string
*/
protected function getCheckUrl()
{
return Yii::app()->createUrl(
'admin/pluginhelper',
[
'sa' => 'ajax',
'plugin' => 'updateCheck',
'method' => 'checkAll'
]
);
}

/**
* @return void
*/
Expand Down
6 changes: 3 additions & 3 deletions application/libraries/MenuObjects/Menu.php
Expand Up @@ -34,7 +34,7 @@ class Menu implements MenuInterface
/**
* @var string
*/
protected $onCLick = "";
protected $onClick = "";

/**
* @param array $options - Options for either dropdown menu or plain link
Expand Down Expand Up @@ -63,7 +63,7 @@ public function __construct($options)
}

if (isset($options['onClick'])) {
$this->iconClass = $options['onCLick'];
$this->onClick = $options['onClick'];
}
}

Expand Down Expand Up @@ -112,6 +112,6 @@ public function getIconClass()
*/
public function getOnClick()
{
return $this->onCLick;
return $this->onClick;
}
}
14 changes: 14 additions & 0 deletions application/views/admin/pluginmanager/index.php
Expand Up @@ -30,6 +30,20 @@ class='btn btn-default '
<?php eT('Browse the shop'); ?>
</a>
*/ ?>
<?php foreach ($extraMenus as $menu): ?>
<a
href='<?php echo $menu->getHref(); ?>'
<?php if ($menu->getOnClick()): ?>
onclick='<?php echo $menu->getOnClick(); ?>'
<?php endif; ?>
class='btn btn-default'
>
<?php if ($menu->getIconClass()): ?>
<i class='<?php echo $menu->getIconClass(); ?>'></i>&nbsp;
<?php endif; ?>
<?php echo $menu->getLabel(); ?>
</a>
<?php endforeach; ?>
<a
href=''
class='btn btn-success '
Expand Down

0 comments on commit 1689b64

Please sign in to comment.