Пример #1
0
 /**
  * Generate a list of links for extensions
  *
  * @param array $ext The extensions
  * @return string The HTML code
  */
 function make_linklist($ext)
 {
     $return = '';
     foreach ($ext as $link) {
         $return .= '<bdi><a href="' . $this->gui->tabURL('search', array('q' => 'ext:' . $link)) . '">' . hsc($link) . '</a></bdi>, ';
     }
     return rtrim($return, ', ');
 }
Пример #2
0
 /**
  * Execute the requested action(s) and initialize the plugin repository
  */
 public function handle()
 {
     global $INPUT;
     // initialize the remote repository
     /* @var helper_plugin_extension_repository $repository */
     $repository = $this->loadHelper('extension_repository');
     if (!$repository->hasAccess()) {
         $url = $this->gui->tabURL('', array('purge' => 1));
         msg($this->getLang('repo_error') . ' [<a href="' . $url . '">' . $this->getLang('repo_retry') . '</a>]', -1);
     }
     if (!in_array('ssl', stream_get_transports())) {
         msg($this->getLang('nossl'), -1);
     }
     /* @var helper_plugin_extension_extension $extension */
     $extension = $this->loadHelper('extension_extension');
     try {
         if ($INPUT->post->has('fn') && checkSecurityToken()) {
             $actions = $INPUT->post->arr('fn');
             foreach ($actions as $action => $extensions) {
                 foreach ($extensions as $extname => $label) {
                     switch ($action) {
                         case 'install':
                         case 'reinstall':
                         case 'update':
                             $extension->setExtension($extname);
                             $installed = $extension->installOrUpdate();
                             foreach ($installed as $ext => $info) {
                                 msg(sprintf($this->getLang('msg_' . $info['type'] . '_' . $info['action'] . '_success'), $info['base']), 1);
                             }
                             break;
                         case 'uninstall':
                             $extension->setExtension($extname);
                             $status = $extension->uninstall();
                             if ($status) {
                                 msg(sprintf($this->getLang('msg_delete_success'), hsc($extension->getDisplayName())), 1);
                             } else {
                                 msg(sprintf($this->getLang('msg_delete_failed'), hsc($extension->getDisplayName())), -1);
                             }
                             break;
                         case 'enable':
                             $extension->setExtension($extname);
                             $status = $extension->enable();
                             if ($status !== true) {
                                 msg($status, -1);
                             } else {
                                 msg(sprintf($this->getLang('msg_enabled'), hsc($extension->getDisplayName())), 1);
                             }
                             break;
                         case 'disable':
                             $extension->setExtension($extname);
                             $status = $extension->disable();
                             if ($status !== true) {
                                 msg($status, -1);
                             } else {
                                 msg(sprintf($this->getLang('msg_disabled'), hsc($extension->getDisplayName())), 1);
                             }
                             break;
                     }
                 }
             }
             send_redirect($this->gui->tabURL('', array(), '&', true));
         } elseif ($INPUT->post->str('installurl') && checkSecurityToken()) {
             $installed = $extension->installFromURL($INPUT->post->str('installurl'));
             foreach ($installed as $ext => $info) {
                 msg(sprintf($this->getLang('msg_' . $info['type'] . '_' . $info['action'] . '_success'), $info['base']), 1);
             }
             send_redirect($this->gui->tabURL('', array(), '&', true));
         } elseif (isset($_FILES['installfile']) && checkSecurityToken()) {
             $installed = $extension->installFromUpload('installfile');
             foreach ($installed as $ext => $info) {
                 msg(sprintf($this->getLang('msg_' . $info['type'] . '_' . $info['action'] . '_success'), $info['base']), 1);
             }
             send_redirect($this->gui->tabURL('', array(), '&', true));
         }
     } catch (Exception $e) {
         msg($e->getMessage(), -1);
         send_redirect($this->gui->tabURL('', array(), '&', true));
     }
 }