install.php 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266
  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. {
  49. foreach ($collection as $requirement) :
  50. ?>
  51. <tr>
  52. <td class="dark">
  53. <?php if ($requirement->isFulfilled()) : ?>
  54. <span class="icon-yes">
  55. <?php elseif (!$requirement->isOptional()) : ?>
  56. <span class="icon-no">
  57. <?php else : ?>
  58. <span class="icon-warning">
  59. <?php endif; ?>
  60. <?php echo $requirement->getTestMessage(); ?>
  61. </span>
  62. <?php if ($requirement instanceof CliRequirement && !$requirement->isFulfilled(
  63. )
  64. ) : ?>
  65. <pre
  66. class="output"><?php echo $requirement->getOutput(
  67. ); ?></pre>
  68. <?php endif; ?>
  69. </td>
  70. <td>
  71. <?php
  72. if ($requirement->isFulfilled()) {
  73. echo '<h4><span class="label label-success"><i class="fa fa-check-circle"></i> '.$translator->trans(
  74. 'process.step.check.requirement_status.ok'
  75. ).'</span></h4>';
  76. } else {
  77. if (!$requirement->isOptional()) {
  78. echo '<h4><span class="label label-danger"><i class="fa fa-exclamation-triangle"> </i> '.$translator->trans(
  79. 'process.step.check.requirement_status.danger'
  80. ).'</span></h4>';
  81. } else {
  82. echo '<h4><span class="label label-warning"><i class="fa fa-exclamation-triangle"></i> '.$translator->trans(
  83. 'process.step.check.requirement_status.warning'
  84. ).'</span></h4>';
  85. }
  86. $requirement->getHelpHtml();
  87. echo '</span>';
  88. }
  89. ?>
  90. </td>
  91. </tr>
  92. <?php
  93. endforeach;
  94. }
  95. ?>
  96. <!doctype html>
  97. <!--[if IE 7 ]>
  98. <html class="no-js ie ie7" lang="en"> <![endif]-->
  99. <!--[if IE 8 ]>
  100. <html class="no-js ie ie8" lang="en"> <![endif]-->
  101. <!--[if IE 9 ]>
  102. <html class="no-js ie ie9" lang="en"> <![endif]-->
  103. <!--[if (gte IE 10)|!(IE)]><!-->
  104. <html class="no-js" lang="en"> <!--<![endif]-->
  105. <head>
  106. <meta charset="utf-8">
  107. <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  108. <title><?php echo $translator->trans('title'); ?></title>
  109. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  110. <link rel="stylesheet" type="text/css"
  111. href="bundles/chamilocore/components/bootstrap/dist/css/bootstrap.css"/>
  112. <link rel="stylesheet" type="text/css"
  113. href="bundles/chamilocore/components/fontawesome/css/font-awesome.css"/>
  114. <link rel="stylesheet" type="text/css"
  115. href="bundles/chamiloinstaller/css/install.css"/>
  116. <script type="text/javascript"
  117. src="bundles/chamilocore/components/jquery/dist/jquery.min.js"></script>
  118. <script type="text/javascript">
  119. $(function () {
  120. $('.progress-bar li:last-child em.fix-bg').width($('.progress-bar li:last-child').width() / 2);
  121. $('.progress-bar li:first-child em.fix-bg').width($('.progress-bar li:first-child').width() / 2);
  122. var splash = $('div.start-box'),
  123. body = $('body'),
  124. winHeight = $(window).height();
  125. $('#begin-install').click(function () {
  126. splash.hide();
  127. body.css({'overflow': 'visible', 'height': 'auto'});
  128. });
  129. if ('localStorage' in window && window['localStorage'] !== null) {
  130. if (!localStorage.getItem('oroInstallSplash')) {
  131. splash.show().height(winHeight);
  132. body.css({'overflow': 'hidden', 'height': winHeight});
  133. localStorage.setItem('oroInstallSplash', true);
  134. }
  135. }
  136. <?php if (!count($majorProblems)) : ?>
  137. // initiate application in background
  138. $.get('app_dev.php/installer/flow/chamilo_installer/configure');
  139. <?php endif; ?>
  140. });
  141. </script>
  142. </head>
  143. <body>
  144. <div class="container">
  145. <div class="page-header">
  146. <h1 class="logo"><?php echo $translator->trans('title'); ?></h1>
  147. </div>
  148. <div class="content">
  149. <div class="page-title">
  150. <h2><?php echo $translator->trans(
  151. 'process.step.check.header'
  152. ); ?></h2>
  153. </div>
  154. <div>
  155. <?php if (count($majorProblems)) : ?>
  156. <div class="alert alert-warning" role="alert">
  157. <ul>
  158. <li><?php echo $translator->trans(
  159. 'process.step.check.invalid'
  160. ); ?></li>
  161. <?php if ($collection->hasPhpIniConfigIssue()): ?>
  162. <li id="phpini">*
  163. <?php
  164. if ($collection->getPhpIniConfigPath()) :
  165. echo $translator->trans(
  166. 'process.step.check.phpchanges',
  167. array(
  168. '%path%' => $collection->getPhpIniConfigPath(
  169. ),
  170. )
  171. );
  172. else :
  173. echo $translator->trans(
  174. 'process.step.check.phpchanges'
  175. );
  176. endif;
  177. ?>
  178. </li>
  179. <?php endif; ?>
  180. </ul>
  181. </div>
  182. <?php endif; ?>
  183. <?php
  184. $requirements = array(
  185. 'mandatory' => $collection->getMandatoryRequirements(),
  186. 'php' => $collection->getPhpIniRequirements(),
  187. 'chamilo' => $collection->getChamiloRequirements(),
  188. 'cli' => $collection->getCliRequirements(),
  189. 'optional' => $collection->getRecommendations(),
  190. );
  191. foreach ($requirements as $type => $requirement) : ?>
  192. <table class="table table-striped">
  193. <col width="75%" valign="top">
  194. <col width="25%" valign="top">
  195. <thead>
  196. <tr>
  197. <th><?php echo $translator->trans(
  198. 'process.step.check.table.'.$type
  199. ); ?></th>
  200. <th><?php echo $translator->trans(
  201. 'process.step.check.table.status'
  202. ); ?></th>
  203. </tr>
  204. </thead>
  205. <tbody>
  206. <?php iterateRequirements($requirement, $translator); ?>
  207. </tbody>
  208. </table>
  209. <?php endforeach; ?>
  210. </div>
  211. <hr/>
  212. <br/>
  213. <div class="install-form-actions">
  214. <?php if (count($majorProblems) || count($minorProblems)): ?>
  215. <a href="install.php" class="btn btn-default btn-lg">
  216. <i class="fa fa-refresh"></i> <?php echo $translator->trans(
  217. 'process.button.refresh'
  218. ); ?>
  219. </a>
  220. <?php endif; ?>
  221. <a href="<?php echo count(
  222. $majorProblems
  223. ) ? 'javascript: void(0);' : 'app_dev.php/installer/flow/chamilo_installer/welcome'; ?>"
  224. class="btn btn-lg btn-primary <?php echo count(
  225. $majorProblems
  226. ) ? 'disabled' : 'primary'; ?>">
  227. <i class="fa fa-chevron-right"></i> <?php echo $translator->trans(
  228. 'process.button.continue'
  229. ); ?>
  230. </a>
  231. </div>
  232. </div>
  233. </div>
  234. <hr/>
  235. <br/>
  236. <footer class="footer">
  237. <div class="container">
  238. <p class="text-muted">
  239. Chamilo
  240. </p>
  241. </div>
  242. </footer>
  243. </body>
  244. </html>