فهرست منبع

Use Setup class instead app.json

Jaap Marcus 5 سال پیش
والد
کامیت
9d8649f742

+ 13 - 8
web/add/webapp/index.php

@@ -30,14 +30,6 @@ if(!in_array($v_domain, $user_domains)) {
     exit;
 }
 
-$appInstallers = glob(__DIR__.'/../../src/app/WebApp/Installers/*/app.json');
-$v_web_apps = array();
-foreach($appInstallers as $app){
-    $json = json_decode(file_get_contents($app));
-    $array[$json -> name] = $json;
-    $v_web_apps = array_merge($v_web_apps, $array);
-}
-
 // Check GET request
 if (!empty($_GET['app'])) {
     $app = basename($_GET['app']);
@@ -90,6 +82,19 @@ if (!empty($_POST['ok']) && !empty($app) ) {
 if(!empty($installer)) {
     render_page($user, $TAB, 'setup_webapp');
 } else {
+    $appInstallers = glob(__DIR__.'/../../src/app/WebApp/Installers/*/*.php');
+    $v_web_apps = array();
+    foreach($appInstallers as $app){
+        $hestia = new \Hestia\System\HestiaApp();
+        if( preg_match('/Installers\/([a-zA-Z0-0].*)\/([a-zA-Z0-0].*).php/', $app, $matches)){
+            if ($matches[1] != "Resources"){
+                $app_installer_class = '\Hestia\WebApp\Installers\\'.$matches[1].'\\' . $matches[1] . 'Setup';
+                $app_installer = new $app_installer_class($v_domain, $hestia);
+                $v_web_apps[] = $app_installer -> info();
+                
+            }
+        }
+    }
     render_page($user, $TAB, 'list_webapps');
 }
 

+ 36 - 0
web/src/app/WebApp/Installers/Drupal/DrupalSetup.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace Hestia\WebApp\Installers\Drupal;
+
+use \Hestia\WebApp\Installers\BaseSetup as BaseSetup;
+
+class DrupalSetup extends BaseSetup {
+
+    protected $appname = 'drupal';
+    
+    protected $appInfo = [ 
+        'name' => 'Drupal',
+        'group' => 'cms',
+        'enabled' => false,
+        'version' => 'latest',
+        'thumbnail' => 'drupal-thumb.png'
+    ];
+    
+    protected $config = [
+        'form' => [
+        ],
+        'database' => true,
+        'resources' => [
+           
+        ],
+    ];
+    
+    public function info(){
+        return $this -> appInfo;
+    }
+
+    public function install(array $options=null) : bool
+    {
+        exit( "Installer missing" );
+    }
+}

+ 0 - 7
web/src/app/WebApp/Installers/Drupal/app.json

@@ -1,7 +0,0 @@
-{
-    "name": "Drupal",
-    "group": "cms",
-    "enabled": false,
-    "version": "latest",
-    "thumbnail": "drupal-thumb.png"
-}

+ 36 - 0
web/src/app/WebApp/Installers/Joomla/JoomlaSetup.php

@@ -0,0 +1,36 @@
+<?php
+
+namespace Hestia\WebApp\Installers\Joomla;
+
+use \Hestia\WebApp\Installers\BaseSetup as BaseSetup;
+
+class JoomlaSetup extends BaseSetup {
+
+    protected $appname = 'joomla';
+    
+    protected $appInfo = [ 
+        'name' => 'Joomla',
+        'group' => 'cms',
+        'enabled' => false,
+        'version' => 'latest',
+        'thumbnail' => 'joomla-thumb.png'
+    ];
+    
+    protected $config = [
+        'form' => [
+        ],
+        'database' => true,
+        'resources' => [
+        
+        ],
+    ];
+    
+    public function info(){
+        return $this -> appInfo;
+    }
+
+    public function install(array $options=null) : bool
+    {
+        exit( "Installer missing" );
+    }
+}

+ 0 - 7
web/src/app/WebApp/Installers/Joomla/app.json

@@ -1,7 +0,0 @@
-{
-    "name": "Joomla",
-    "group": "cms",
-    "enabled": false,
-    "version": "latest",
-    "thumbnail": "joomla-thumb.png"
-}

+ 13 - 1
web/src/app/WebApp/Installers/Laravel/LaravelSetup.php

@@ -7,7 +7,15 @@ use \Hestia\WebApp\Installers\BaseSetup as BaseSetup;
 class LaravelSetup extends BaseSetup {
 
     protected $appname = 'laravel';
-
+    
+    protected $appInfo = [ 
+        'name' => 'Laravel',
+        'group' => 'framework',
+        'enabled' => true,
+        'version' => '7.x',
+        'thumbnail' => 'laravel-thumb.png'
+    ];
+    
     protected $config = [
         'form' => [
         ],
@@ -16,6 +24,10 @@ class LaravelSetup extends BaseSetup {
             'composer' => [ 'src' => 'laravel/laravel', 'dst' => '/' ],
         ],
     ];
+    
+    public function info(){
+        return $this -> appInfo;
+    }
 
     public function install(array $options=null) : bool
     {

+ 0 - 7
web/src/app/WebApp/Installers/Laravel/app.json

@@ -1,7 +0,0 @@
-{
-    "name": "Laravel",
-    "group": "framework",
-    "enabled": true,
-    "version": "7.x",
-    "thumbnail": "laravel-thumb.png"
-}

+ 13 - 1
web/src/app/WebApp/Installers/Opencart/OpencartSetup.php

@@ -6,6 +6,14 @@ use \Hestia\WebApp\Installers\BaseSetup as BaseSetup;
 
 class OpencartSetup extends BaseSetup {
 
+    protected $appInfo = [ 
+        'name' => 'Opencart',
+        'group' => 'ecommerce',
+        'enabled' => true,
+        'version' => '3.0.3.3',
+        'thumbnail' => 'opencart-thumb.png'
+    ];
+    
     protected $appname = 'opencart';
     protected $extractsubdir="/tmp-opencart";
 
@@ -20,7 +28,11 @@ class OpencartSetup extends BaseSetup {
             'archive'  => [ 'src' => 'https://github.com/opencart/opencart/releases/download/3.0.3.3/opencart-3.0.3.3.zip' ],
         ],
     ];
-
+    
+    public function info(){
+        return $this -> appInfo;
+    }
+    
     public function install(array $options = null) : bool
     {
         parent::install($options);

+ 0 - 7
web/src/app/WebApp/Installers/Opencart/app.json

@@ -1,7 +0,0 @@
-{
-    "name": "Opencart",
-    "group": "ecommerce",
-    "enabled": true,
-    "version": "3.0.3.3",
-    "thumbnail": "opencart-thumb.png"
-}

+ 12 - 0
web/src/app/WebApp/Installers/Prestashop/PrestashopSetup.php

@@ -6,6 +6,14 @@ use \Hestia\WebApp\Installers\BaseSetup as BaseSetup;
 
 class PrestashopSetup extends BaseSetup {
 
+    protected $appInfo = [ 
+        'name' => 'Prestashop',
+        'group' => 'ecommerce',
+        'enabled' => true,
+        'version' => '1.7.7.1',
+        'thumbnail' => 'prestashop-thumb.png'
+    ];
+    
     protected $appname = 'prestashop';
     protected $extractsubdir="/tmp-prestashop";
 
@@ -22,6 +30,10 @@ class PrestashopSetup extends BaseSetup {
         ],
 
     ];
+    
+    public function info(){
+        return $this -> appInfo;
+    }
 
     public function install(array $options=null) : bool
     {

+ 0 - 7
web/src/app/WebApp/Installers/Prestashop/app.json

@@ -1,7 +0,0 @@
-{
-    "name": "Prestashop",
-    "group": "ecommerce",
-    "enabled": true,
-    "version": "1.7.7.1",
-    "thumbnail": "prestashop-thumb.png"
-}

+ 13 - 1
web/src/app/WebApp/Installers/Symfony/SymfonySetup.php

@@ -5,7 +5,15 @@ namespace Hestia\WebApp\Installers\Symfony;
 use \Hestia\WebApp\Installers\BaseSetup as BaseSetup;
 
 class SymfonySetup extends BaseSetup {
-
+    
+    protected $appInfo = [ 
+        'name' => 'Symfony',
+        'group' => 'framework',
+        'enabled' => true,
+        'version' => '5.2',
+        'thumbnail' => 'symfony-thumb.png'
+    ];
+    
     protected $appname = 'symfony';
 
     protected $config = [
@@ -16,6 +24,10 @@ class SymfonySetup extends BaseSetup {
             'composer' => [ 'src' => 'symfony/website-skeleton', 'dst' => '/' ],
         ],
     ];
+    
+    public function info(){
+        return $this -> appInfo;
+    }
 
     public function install(array $options=null) : bool
     {

+ 0 - 7
web/src/app/WebApp/Installers/Symfony/app.json

@@ -1,7 +0,0 @@
-{
-    "name": "Symfony",
-    "group": "framework",
-    "enabled": true,
-    "version": "4.3.x",
-    "thumbnail": "symfony-thumb.png"
-}

+ 13 - 1
web/src/app/WebApp/Installers/Wordpress/WordpressSetup.php

@@ -7,6 +7,14 @@ use \Hestia\WebApp\Installers\BaseSetup as BaseSetup;
 
 class WordpressSetup extends BaseSetup {
 
+    protected $appInfo = [ 
+        'name' => 'Wordpress',
+        'group' => 'cms',
+        'enabled' => true,
+        'version' => 'latest',
+        'thumbnail' => 'wp-thumb.png'
+    ];
+    
     protected $appname = 'wordpress';
     protected $config = [
         'form' => [
@@ -26,7 +34,11 @@ class WordpressSetup extends BaseSetup {
         ],
         
     ];
-
+    
+    public function info(){
+        return $this -> appInfo;
+    }
+    
     public function install(array $options = null)
     {
         parent::install($options);

+ 0 - 7
web/src/app/WebApp/Installers/Wordpress/app.json

@@ -1,7 +0,0 @@
-{
-    "name": "Wordpress",
-    "group": "cms",
-    "enabled": true,
-    "version": "latest",
-    "thumbnail": "wp-thumb.png"
-}

+ 5 - 5
web/templates/admin/list_webapps.html

@@ -39,12 +39,12 @@
         </div>
         <div class="app-list cards">
             <?php foreach($v_web_apps as $webapp):?>
-                <div class="card <?=($webapp->enabled?'':'disable')?>" >
-                    <span class="card-thumb"><img src="/src/app/WebApp/Installers/<?=$webapp -> name;?>/<?=$webapp -> thumbnail;?>"></span>
+                <div class="card <?=($webapp['enabled']?'':'disable')?>" >
+                    <span class="card-thumb"><img src="/src/app/WebApp/Installers/<?=$webapp['name'];?>/<?=$webapp['thumbnail'];?>"></span>
                     <div class="card-details">
-                        <p class="card-title"><?=$webapp->name;?></p>
-                        <p><?=_('version')?>: <?=$webapp->version;?></p>
-                        <a href="/add/webapp/?app=<?=$webapp->name;?>&domain=<?=$v_domain?>" class="ui-button cancel" dir="ltr"><?=_('Setup')?></a>
+                        <p class="card-title"><?=$webapp['name'];?></p>
+                        <p><?=_('version')?>: <?=$webapp['version'];?></p>
+                        <a href="/add/webapp/?app=<?=$webapp['name'];?>&domain=<?=$v_domain?>" class="ui-button cancel" dir="ltr"><?=_('Setup')?></a>
                     </div>
                 </div>
             <?php endforeach; ?>