diff --git a/modules/system/classes/UpdateManager.php b/modules/system/classes/UpdateManager.php index ee3984098..fae554243 100644 --- a/modules/system/classes/UpdateManager.php +++ b/modules/system/classes/UpdateManager.php @@ -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. diff --git a/modules/system/controllers/Updates.php b/modules/system/controllers/Updates.php index c2a653746..3f0cf0e84 100644 --- a/modules/system/controllers/Updates.php +++ b/modules/system/controllers/Updates.php @@ -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]; } diff --git a/modules/system/controllers/updates/_column_author.htm b/modules/system/controllers/updates/_column_author.htm deleted file mode 100644 index cc30988b4..000000000 --- a/modules/system/controllers/updates/_column_author.htm +++ /dev/null @@ -1,9 +0,0 @@ -homepage): ?> - - - - - - - - \ No newline at end of file diff --git a/modules/system/controllers/updates/_list_toolbar.htm b/modules/system/controllers/updates/_list_toolbar.htm index 0d4a27aef..9fa9a9985 100644 --- a/modules/system/controllers/updates/_list_toolbar.htm +++ b/modules/system/controllers/updates/_list_toolbar.htm @@ -6,14 +6,16 @@ data-handler="onLoadUpdates"> - - - - - - +
+ + + + + + +
\ No newline at end of file diff --git a/modules/system/controllers/updates/config_list.yaml b/modules/system/controllers/updates/config_list.yaml index 5bda9f802..49cebd452 100644 --- a/modules/system/controllers/updates/config_list.yaml +++ b/modules/system/controllers/updates/config_list.yaml @@ -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 diff --git a/modules/system/models/PluginVersion.php b/modules/system/models/PluginVersion.php index 6799fc216..dd5bead38 100644 --- a/modules/system/models/PluginVersion.php +++ b/modules/system/models/PluginVersion.php @@ -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)); + } } diff --git a/modules/system/models/pluginversion/columns.yaml b/modules/system/models/pluginversion/columns.yaml index 8d49f9085..3f81e3b17 100644 --- a/modules/system/models/pluginversion/columns.yaml +++ b/modules/system/models/pluginversion/columns.yaml @@ -19,5 +19,3 @@ columns: author: label: system::lang.updates.plugin_author sortable: false - type: partial - path: column_author \ No newline at end of file