@@ -97,6 +97,11 @@ public function install($arg) {
9797 // Get extension name
9898 $ extension_name = $ arg [0 ];
9999
100+ // Load extension installer
101+ $ app ->log ('Installing extension ' .$ extension_name , LOGLEVEL_DEBUG );
102+ $ app ->uses ('extension_installer ' );
103+ $ app ->load ('extension_installer_base ' );
104+
100105 if (isset ($ arg [1 ])) {
101106 $ version = $ arg [1 ];
102107 } else {
@@ -108,6 +113,41 @@ public function install($arg) {
108113 die ();
109114 }
110115
116+ // check if extension exists in repository
117+ $ response = file_get_contents ($ app ->extension_installer ->getRepoListUrl ());
118+ $ repo_extensions = json_decode ($ response , true );
119+
120+ if (empty ($ repo_extensions )) {
121+ $ this ->swriteln ();
122+ $ this ->swriteln ('Error: No extensions available in repository. ' );
123+ $ this ->swriteln ();
124+ die ();
125+ }
126+
127+ // Check if the extension exists in the repository
128+ $ extension_found = false ;
129+ foreach ($ repo_extensions as $ extension ) {
130+ if ($ extension ['name ' ] == $ extension_name ) {
131+ if ($ version ) {
132+ if ($ extension ['version ' ] != $ version ) {
133+ $ this ->swriteln ();
134+ $ this ->swriteln ('Error: Extension version not found in repository. ' );
135+ $ this ->swriteln ();
136+ die ();
137+ }
138+ }
139+ $ extension_found = true ;
140+ break ;
141+ }
142+ }
143+
144+ if (!$ extension_found ) {
145+ $ this ->swriteln ();
146+ $ this ->swriteln ('Error: Extension not found in repository. ' );
147+ $ this ->swriteln ();
148+ die ();
149+ }
150+
111151 // check version
112152 if (!empty ($ version ) && !preg_match ('/^[0-9\.]{1,10}$/ ' ,$ version )) {
113153 $ this ->swriteln ();
@@ -116,11 +156,6 @@ public function install($arg) {
116156 die ();
117157 }
118158
119- // Load extension installer
120- $ app ->log ('Installing extension ' .$ extension_name , LOGLEVEL_DEBUG );
121- $ app ->uses ('extension_installer ' );
122- $ app ->load ('extension_installer_base ' );
123-
124159 // download extension if not already downloaded
125160 if (!is_dir ($ app ->extension_installer ->getExtensionBasedir ().'/ ' .$ extension_name )) {
126161 if (!$ app ->extension_installer ->download_extension ($ extension_name ,$ version )) {
@@ -493,6 +528,16 @@ public function list($arg) {
493528 $ this ->swriteln ("Time: " . date ('Y-m-d H:i:s ' ));
494529 $ this ->swriteln ();
495530
531+ // Get available extensions form repo API server in json format
532+ $ url = 'https://repo.ispconfig.com/api/v1/list/ ' ;
533+ $ response = file_get_contents ($ url );
534+ $ available_extensions = json_decode ($ response , true );
535+
536+ if (empty ($ available_extensions )) {
537+ $ this ->swriteln ('No extensions available. ' );
538+ return ;
539+ }
540+
496541 // Define ANSI color codes
497542 $ ansi_reset = "\033[0m " ;
498543 $ bold = "\033[1m " ;
@@ -518,7 +563,14 @@ public function list($arg) {
518563 }
519564
520565 $ status = $ extension ['active ' ] ? $ green . 'Active ' . $ ansi_reset : $ red . 'Inactive ' . $ ansi_reset ;
521- $ description = isset ($ extension ['description ' ]) ? $ extension ['description ' ] : 'No description available ' ;
566+
567+ // get description from available extensions
568+ foreach ($ available_extensions as $ available_extension ) {
569+ if ($ available_extension ['name ' ] == $ name ) {
570+ $ title = $ available_extension ['title ' ];
571+ break ;
572+ }
573+ }
522574
523575 // Output each row with fixed column positions
524576 $ this ->swrite ($ bold . $ name . $ ansi_reset );
@@ -534,7 +586,7 @@ public function list($arg) {
534586 $ status_text = $ extension ['active ' ] ? 'Active ' : 'Inactive ' ;
535587 $ this ->swrite (str_repeat (' ' , max (0 , 12 - strlen ($ status_text ))));
536588
537- $ this ->swriteln ($ description );
589+ $ this ->swriteln ($ title );
538590 }
539591
540592 // Display a footer with helpful information
@@ -549,8 +601,11 @@ public function list_available($arg) {
549601
550602 $ app ->log ('Listing available extensions ' , LOGLEVEL_DEBUG );
551603
604+ $ app ->uses ('extension_installer ' );
605+ $ app ->load ('extension_installer_base ' );
606+
552607 // Get available extensions form repo API server in json format
553- $ url = ' https://repo.ispconfig.com/api/v1/list/ ' ;
608+ $ url = $ app -> extension_installer -> getRepoListUrl () ;
554609 $ response = file_get_contents ($ url );
555610 $ extensions = json_decode ($ response , true );
556611
@@ -596,7 +651,7 @@ public function list_available($arg) {
596651 $ license = substr ($ license , 0 , 7 ) . '... ' ;
597652 }
598653
599- $ description = isset ($ extension ['description ' ]) ? $ extension ['description ' ] : 'No description available ' ;
654+ $ title = isset ($ extension ['title ' ]) ? $ extension ['title ' ] : 'No title available ' ;
600655
601656 // Output each row with fixed column positions
602657 $ this ->swrite ($ bold . $ name . $ ansi_reset );
@@ -611,7 +666,7 @@ public function list_available($arg) {
611666 // Add padding after license
612667 $ this ->swrite (str_repeat (' ' , max (0 , 12 - strlen ($ license ))));
613668
614- $ this ->swriteln ($ description );
669+ $ this ->swriteln ($ title );
615670 }
616671
617672 // Display a footer with helpful information
0 commit comments