install.php 8.8 KB

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