install.php 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. if (!isset($_SERVER['HTTP_HOST'])) {
  4. exit('This script cannot be run from the CLI. Run it from a browser.');
  5. }
  6. use Symfony\Component\Translation\Translator;
  7. use Symfony\Component\Translation\Loader\YamlFileLoader;
  8. use Symfony\Component\Yaml\Yaml;
  9. use Symfony\Component\HttpFoundation\Request;
  10. require_once __DIR__ . '/../app/ChamiloRequirements.php';
  11. require_once __DIR__ . '/../app/autoload.php';
  12. // check for installed system
  13. $paramFile = __DIR__ . '/../app/config/parameters.yml';
  14. if (file_exists($paramFile)) {
  15. $data = Yaml::parse($paramFile);
  16. if (is_array($data)
  17. && isset($data['parameters'])
  18. && isset($data['parameters']['installed'])
  19. && false != $data['parameters']['installed']
  20. ) {
  21. require_once __DIR__.'/app_dev.php';
  22. exit;
  23. require_once __DIR__.'/../app/AppKernel.php';
  24. $kernel = new AppKernel('dev', false);
  25. $kernel->loadClassCache();
  26. $request = Request::createFromGlobals();
  27. $response = $kernel->handle($request);
  28. $response->send();
  29. $kernel->terminate($request, $response);
  30. exit;
  31. }
  32. }
  33. /**
  34. * @todo Identify correct locale (headers?)
  35. */
  36. $locale = 'en';
  37. $collection = new ChamiloRequirements();
  38. $translator = new Translator($locale);
  39. $majorProblems = $collection->getFailedRequirements();
  40. $minorProblems = $collection->getFailedRecommendations();
  41. $translator->addLoader('yml', new YamlFileLoader());
  42. $translator->addResource(
  43. 'yml',
  44. __DIR__ . '/../src/Chamilo/InstallerBundle/Resources/translations/messages.' . $locale . '.yml',
  45. $locale
  46. );
  47. function iterateRequirements(array $collection, $translator) {
  48. foreach ($collection as $requirement) :
  49. ?>
  50. <tr>
  51. <td class="dark">
  52. <?php if ($requirement->isFulfilled()) : ?>
  53. <span class="icon-yes">
  54. <?php elseif (!$requirement->isOptional()) : ?>
  55. <span class="icon-no">
  56. <?php else : ?>
  57. <span class="icon-warning">
  58. <?php endif; ?>
  59. <?php echo $requirement->getTestMessage(); ?>
  60. </span>
  61. <?php if ($requirement instanceof CliRequirement && !$requirement->isFulfilled()) : ?>
  62. <pre class="output"><?php echo $requirement->getOutput(); ?></pre>
  63. <?php endif; ?>
  64. </td>
  65. <td>
  66. <?php
  67. if ($requirement->isFulfilled()) {
  68. echo '<h4><span class="label label-success"><i class="fa fa-check-circle"></i> '.$translator->trans('process.step.check.requirement_status.ok').'</span></h4>';
  69. } else {
  70. if (!$requirement->isOptional()) {
  71. echo '<h4><span class="label label-danger"><i class="fa fa-exclamation-triangle"> </i> '.$translator->trans('process.step.check.requirement_status.danger').'</span></h4>';
  72. } else {
  73. echo '<h4><span class="label label-warning"><i class="fa fa-exclamation-triangle"></i> '.$translator->trans('process.step.check.requirement_status.warning').'</span></h4>';
  74. }
  75. $requirement->getHelpHtml();
  76. echo '</span>';
  77. }
  78. ?>
  79. </td>
  80. </tr>
  81. <?php
  82. endforeach;
  83. }
  84. ?>
  85. <!doctype html>
  86. <!--[if IE 7 ]><html class="no-js ie ie7" lang="en"> <![endif]-->
  87. <!--[if IE 8 ]><html class="no-js ie ie8" lang="en"> <![endif]-->
  88. <!--[if IE 9 ]><html class="no-js ie ie9" lang="en"> <![endif]-->
  89. <!--[if (gte IE 10)|!(IE)]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
  90. <head>
  91. <meta charset="utf-8">
  92. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  93. <title><?php echo $translator->trans('title'); ?></title>
  94. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  95. <link rel="stylesheet" type="text/css" href="bundles/chamilotheme/components/bootstrap/dist/css/bootstrap.css" />
  96. <link rel="stylesheet" type="text/css" href="bundles/chamilotheme/components/fontawesome/css/font-awesome.css" />
  97. <link rel="stylesheet" type="text/css" href="bundles/chamiloinstaller/css/install.css" />
  98. <script type="text/javascript" src="bundles/chamilotheme/components/jquery/dist/jquery.min.js"></script>
  99. <script type="text/javascript">
  100. $(function() {
  101. $('.progress-bar li:last-child em.fix-bg').width($('.progress-bar li:last-child').width() / 2);
  102. $('.progress-bar li:first-child em.fix-bg').width($('.progress-bar li:first-child').width() / 2);
  103. var splash = $('div.start-box'),
  104. body = $('body'),
  105. winHeight = $(window).height();
  106. $('#begin-install').click(function() {
  107. splash.hide();
  108. body.css({ 'overflow': 'visible', 'height': 'auto' });
  109. });
  110. if ('localStorage' in window && window['localStorage'] !== null) {
  111. if (!localStorage.getItem('oroInstallSplash')) {
  112. splash.show().height(winHeight);
  113. body.css({ 'overflow': 'hidden', 'height': winHeight });
  114. localStorage.setItem('oroInstallSplash', true);
  115. }
  116. }
  117. <?php if (!count($majorProblems)) : ?>
  118. // initiate application in background
  119. $.get('app_dev.php/installer/flow/chamilo_installer/configure');
  120. <?php endif; ?>
  121. });
  122. </script>
  123. </head>
  124. <body>
  125. <div class="container">
  126. <div class="page-header">
  127. <h1 class="logo"><?php echo $translator->trans('title'); ?></h1>
  128. </div>
  129. <div class="content">
  130. <div class="page-title">
  131. <h2><?php echo $translator->trans('process.step.check.header'); ?></h2>
  132. </div>
  133. <div>
  134. <?php if (count($majorProblems)) : ?>
  135. <div class="alert alert-warning" role="alert">
  136. <ul>
  137. <li><?php echo $translator->trans('process.step.check.invalid'); ?></li>
  138. <?php if ($collection->hasPhpIniConfigIssue()): ?>
  139. <li id="phpini">*
  140. <?php
  141. if ($collection->getPhpIniConfigPath()) :
  142. echo $translator->trans(
  143. 'process.step.check.phpchanges',
  144. array(
  145. '%path%' => $collection->getPhpIniConfigPath()
  146. )
  147. );
  148. else :
  149. echo $translator->trans('process.step.check.phpchanges');
  150. endif;
  151. ?>
  152. </li>
  153. <?php endif; ?>
  154. </ul>
  155. </div>
  156. <?php endif; ?>
  157. <?php
  158. $requirements = array(
  159. 'mandatory' => $collection->getMandatoryRequirements(),
  160. 'php' => $collection->getPhpIniRequirements(),
  161. 'chamilo' => $collection->getChamiloRequirements(),
  162. 'cli' => $collection->getCliRequirements(),
  163. 'optional' => $collection->getRecommendations(),
  164. );
  165. foreach ($requirements as $type => $requirement) : ?>
  166. <table class="table table-striped">
  167. <col width="75%" valign="top">
  168. <col width="25%" valign="top">
  169. <thead>
  170. <tr>
  171. <th><?php echo $translator->trans('process.step.check.table.' . $type); ?></th>
  172. <th><?php echo $translator->trans('process.step.check.table.status'); ?></th>
  173. </tr>
  174. </thead>
  175. <tbody>
  176. <?php iterateRequirements($requirement, $translator); ?>
  177. </tbody>
  178. </table>
  179. <?php endforeach; ?>
  180. </div>
  181. <hr />
  182. <br />
  183. <div class="install-form-actions">
  184. <?php if (count($majorProblems) || count($minorProblems)): ?>
  185. <a href="install.php" class="btn btn-default btn-lg">
  186. <i class="fa fa-refresh"></i> <?php echo $translator->trans('process.button.refresh'); ?>
  187. </a>
  188. <?php endif; ?>
  189. <a href="<?php echo count($majorProblems) ? 'javascript: void(0);' : 'app_dev.php/installer/flow/chamilo_installer/welcome'; ?>" class="btn btn-lg btn-primary <?php echo count($majorProblems) ? 'disabled' : 'primary'; ?>">
  190. <i class="fa fa-chevron-right"></i> <?php echo $translator->trans('process.button.continue'); ?>
  191. </a>
  192. </div>
  193. </div>
  194. </div>
  195. <hr/ >
  196. <br />
  197. <footer class="footer">
  198. <div class="container">
  199. <p class="text-muted">
  200. Chamilo
  201. </p>
  202. </div>
  203. </footer>
  204. </body>
  205. </html>