mirror of
https://github.com/wintercms/winter.git
synced 2024-06-28 05:33:29 +02:00
Clicking on a plugin redirects to plugin detail page
Upgrade guide can now be fetched from the server
This commit is contained in:
parent
7fcf7347c4
commit
733d783ada
@ -436,6 +436,17 @@ class UpdateManager
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Looks up content for a plugin from the update server.
|
||||
* @param string $name Plugin name.
|
||||
* @return array Content for the plugin.
|
||||
*/
|
||||
public function requestPluginContent($name)
|
||||
{
|
||||
$result = $this->requestServerData('plugin/content', ['name' => $name]);
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Runs update on a single plugin
|
||||
* @param string $name Plugin name.
|
||||
|
@ -127,7 +127,7 @@ class Updates extends Controller
|
||||
|
||||
$pluginVersion = PluginVersion::whereCode($code)->first();
|
||||
$this->vars['pluginName'] = array_get($details, 'name', 'system::lang.plugin.unnamed');
|
||||
$this->vars['pluginVersion'] = $pluginVersion->version;
|
||||
$this->vars['pluginVersion'] = $pluginVersion ? $pluginVersion->version : '???';
|
||||
$this->vars['pluginAuthor'] = array_get($details, 'author');
|
||||
$this->vars['pluginIcon'] = array_get($details, 'icon', 'icon-leaf');
|
||||
$this->vars['pluginHomepage'] = array_get($details, 'homepage');
|
||||
@ -136,6 +136,14 @@ class Updates extends Controller
|
||||
throw new ApplicationException('Plugin not found');
|
||||
}
|
||||
|
||||
/*
|
||||
* Fetch from server
|
||||
*/
|
||||
if (get('fetch')) {
|
||||
$fetchedContent = UpdateManager::instance()->requestPluginContent($code);
|
||||
$upgrades = array_get($fetchedContent, 'upgrade_guide_html');
|
||||
}
|
||||
|
||||
$this->vars['activeTab'] = $tab ?: 'readme';
|
||||
$this->vars['urlCode'] = $urlCode;
|
||||
$this->vars['upgrades'] = $upgrades;
|
||||
@ -292,7 +300,7 @@ class Updates extends Controller
|
||||
if (strpos($description, '!!!') === false) continue;
|
||||
|
||||
$isImportant = $hasImportantUpdates = true;
|
||||
$detailsUrl = Backend::url('system/updates/details/'.strtolower(str_replace('.', '-', $code)).'/upgrades');
|
||||
$detailsUrl = Backend::url('system/updates/details/'.PluginVersion::makeSlug($code).'/upgrades').'?fetch=1';
|
||||
$description = str_replace('!!!', '', $description);
|
||||
$result['plugins'][$code]['updates'][$version] = [$description, $detailsUrl];
|
||||
}
|
||||
|
@ -1,9 +0,0 @@
|
||||
<?php if ($record->homepage): ?>
|
||||
<abbr title="<?= e($record->homepage) ?>">
|
||||
<a href="<?= $record->homepage ?>" class="nolink" target="_blank">
|
||||
<?= $value ?>
|
||||
</a>
|
||||
</abbr>
|
||||
<?php else: ?>
|
||||
<?= $value ?>
|
||||
<?php endif ?>
|
@ -6,14 +6,16 @@
|
||||
data-handler="onLoadUpdates">
|
||||
<?= e(trans('system::lang.updates.check_label')) ?>
|
||||
</a>
|
||||
<a
|
||||
href="<?= Backend::url('system/updates/manage') ?>"
|
||||
class="btn btn-default oc-icon-puzzle-piece">
|
||||
<?= e(trans('system::lang.plugins.manage')) ?>
|
||||
</a>
|
||||
<a
|
||||
href="<?= Backend::url('system/updates/install') ?>"
|
||||
class="btn btn-success oc-icon-plus">
|
||||
<?= e(trans('system::lang.plugins.install')) ?>
|
||||
</a>
|
||||
<div class="btn-group">
|
||||
<a
|
||||
href="<?= Backend::url('system/updates/install') ?>"
|
||||
class="btn btn-success oc-icon-plus">
|
||||
<?= e(trans('system::lang.plugins.install')) ?>
|
||||
</a>
|
||||
<a
|
||||
href="<?= Backend::url('system/updates/manage') ?>"
|
||||
class="btn btn-default oc-icon-puzzle-piece">
|
||||
<?= e(trans('system::lang.plugins.manage')) ?>
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
@ -6,6 +6,7 @@ title: system::lang.updates.title
|
||||
list: ~/modules/system/models/pluginversion/columns.yaml
|
||||
modelClass: System\Models\PluginVersion
|
||||
noRecordsMessage: backend::lang.list.no_records
|
||||
recordUrl: system/updates/details/:slug
|
||||
|
||||
toolbar:
|
||||
buttons: list_toolbar
|
||||
|
@ -37,6 +37,12 @@ class PluginVersion extends Model
|
||||
|
||||
public $orphaned = false;
|
||||
|
||||
/**
|
||||
* The accessors to append to the model's array form.
|
||||
* @var array
|
||||
*/
|
||||
protected $appends = ['slug'];
|
||||
|
||||
/**
|
||||
* After the model is populated
|
||||
*/
|
||||
@ -101,4 +107,20 @@ class PluginVersion extends Model
|
||||
? self::$versionCache[$pluginCode]
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides the slug attribute.
|
||||
*/
|
||||
public function getSlugAttribute()
|
||||
{
|
||||
return self::makeSlug($this->code);
|
||||
}
|
||||
|
||||
/**
|
||||
* Generates a slug for the plugin.
|
||||
*/
|
||||
public static function makeSlug($code)
|
||||
{
|
||||
return strtolower(str_replace('.', '-', $code));
|
||||
}
|
||||
}
|
||||
|
@ -19,5 +19,3 @@ columns:
|
||||
author:
|
||||
label: system::lang.updates.plugin_author
|
||||
sortable: false
|
||||
type: partial
|
||||
path: column_author
|
Loading…
x
Reference in New Issue
Block a user