1 <?php
2
3 4 5 6 7 8 9 10
11
12 namespace Icybee\Installer;
13
14 use ICanBoogie\Errors;
15
16 17 18
19 class UserConfigRequirement extends Requirement
20 {
21 public function __construct()
22 {
23 $this->title = t('requirement.user_config.title');
24 $this->description = t
25 (
26 'requirement.user_config.description', array
27 (
28 'action' => new TellMeMore('user_config'),
29 'data' => '<textarea class="span8" readonly="readonly">' . \ICanBoogie\escape($this->get_data()) . '</textarea>'
30 )
31 );
32 }
33
34 public function __invoke(Errors $errors)
35 {
36 $pathname = WEBSITE_CONFIG_DIR . 'user.php';
37
38 if (file_exists($pathname))
39 {
40 return;
41 }
42
43 if (is_writable($pathname))
44 {
45 file_put_contents($pathname, $data);
46
47 return;
48 }
49
50 $errors['user_config'] = t('requirement.user_config.error.create', array('path' => \ICanBoogie\strip_root($pathname)));
51 }
52
53 public function get_data()
54 {
55 $password_salt = \ICanboogie\generate_token_wide();
56
57 return <<<EOT
58 <?php
59
60 return array
61 (
62 'password_salt' => '$password_salt'
63 );
64 EOT;
65 }
66 }