PageRenderTime 47ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/concreteOLD/tools/marketplace/download.php

https://bitbucket.org/selfeky/xclusivescardwebsite
PHP | 84 lines | 73 code | 11 blank | 0 comment | 17 complexity | e5215f9cbfd406bbb5754f5e8313a164 MD5 | raw file
  1. <?php defined('C5_EXECUTE') or die("Access Denied.");
  2. $tp = new TaskPermission();
  3. if (!$tp->canInstallPackages()) { ?>
  4. <p><?php echo t('You do not have permission to download packages from the marketplace.')?></p>
  5. <?php exit;
  6. }
  7. Loader::library('marketplace');
  8. Loader::model('marketplace_remote_item');
  9. $mpID = $_REQUEST['mpID'];
  10. $install = isset($_REQUEST['install']) ? $_REQUEST['install'] : false;
  11. $error = Loader::helper('validation/error');
  12. if (!empty($mpID)) {
  13. $mri = MarketplaceRemoteItem::getByID($mpID);
  14. if (is_object($mri)) {
  15. $r = $mri->download();
  16. if ($r != false) {
  17. if (is_array($r)) {
  18. $errors = Package::mapError($r);
  19. foreach($errors as $e) {
  20. $error->add($e);
  21. }
  22. } else {
  23. $error->add($r);
  24. }
  25. }
  26. }
  27. }
  28. if (!is_object($mri)) {
  29. $error->add(t('Invalid package or no package specified.'));
  30. }
  31. if (!$error->has() && $install) {
  32. $tests = Package::testForInstall($mri->getHandle());
  33. if (is_array($tests)) {
  34. $results = Package::mapError($tests);
  35. foreach($results as $te) {
  36. $error->add($te);
  37. }
  38. } else {
  39. $p = Loader::package($mri->getHandle());
  40. try {
  41. $p->install();
  42. } catch(Exception $e) {
  43. $error->add($e->getMessage());
  44. }
  45. }
  46. }
  47. if (!$error->has()) { ?>
  48. <p>
  49. <?php if ($install) {
  50. echo t('The package was successfully installed.');
  51. } else {
  52. echo t('The package was successfully downloaded and decompressed on your server.');
  53. }
  54. print '<div class="dialog-buttons">';
  55. print Loader::helper('concrete/interface')->button_js(t('Return'), 'javascript:ccm_getMarketplaceItem.onComplete()', 'right');
  56. print '</div>';
  57. ?>
  58. </p>
  59. <?php } else { ?>
  60. <p><?php echo t("The package could not be installed:") ?></p>
  61. <?php $error->output(); ?>
  62. <hr/>
  63. <?php if (is_object($mri)) { ?>
  64. <p><?php echo t("To install the package manually:") ?></p>
  65. <ol>
  66. <li><?php echo t('Download the package from <a href="%s">here</a>.', $mri->getRemoteURL())?></li>
  67. <li><?php echo t('Upload and unpack the package on your web server. Place the unpacked files in the packages directory of the root of your concrete5 installation.')?></li>
  68. <li><?php echo t('Go to the <a href="%s">Add Functionality</a> page in your concrete5 Dashboard.', View::url('/dashboard/install'))?></li>
  69. <li><?php echo t('Click the Install button next to the package name.')?></li>
  70. </ol>
  71. <div class="dialog-buttons"></div>
  72. <?php } ?>
  73. <?php } ?>