Pathologic was missing because of a .git folder inside.
[yaffs-website] / web / modules / contrib / hacked / hacked.details.inc
1 <?php
2
3 use Drupal\Core\Template\Attribute;
4 use Drupal\Core\Url;
5
6 /**
7  * Theme project status report.
8  *
9  * @ingroup themeable
10  */
11 function template_preprocess_hacked_detailed_report(&$variables) {
12   $project = $variables['project'];
13
14   $variables['files'] = [
15     '#type'       => 'table',
16     '#attributes' => ['class' => ['update']],
17     // Attach the library to a variable that gets printed always.
18     '#attached'   => [
19       'library' => [
20         'update/drupal.update.admin',
21       ],
22     ]
23   ];
24
25   foreach ($project['files'] as $file => $status) {
26     if (!isset($status)) {
27       continue;
28     }
29
30     $url = NULL;
31     if (\Drupal::currentUser()->hasPermission('view diffs of changed files') && \Drupal::moduleHandler()->moduleExists('diff') && ($status != HACKED_STATUS_UNHACKED) && !empty($project['diffable'][$file])) {
32       $url = Url::fromRoute('hacked.project_diff', ['project' => $project['project_name'], 'file' => $file ]);
33     }
34
35     $file_status = [
36       '#theme' => 'hacked_file_status',
37       '#file'  => [
38         'name'   => $file,
39         'status' => $status,
40         'url' => $url,
41       ],
42     ];
43
44     // Add the project status row and details.
45     $variables['files'][$file]['status'] = $file_status;
46
47     switch ($status) {
48       case HACKED_STATUS_UNHACKED:
49         $variables['files'][$file]['#attributes'] = ['class' => ['color-success']];
50         break;
51       case HACKED_STATUS_DELETED:
52         $variables['files'][$file]['#attributes'] = ['class' => ['color-error']];
53         break;
54       case HACKED_STATUS_HACKED:
55       case HACKED_STATUS_PERMISSION_DENIED:
56       case HACKED_STATUS_UNCHECKED:
57       default:
58         $variables['files'][$file]['#attributes'] = ['class' => ['color-warning']];
59         break;
60     }
61   }
62 }
63
64 /**
65  * @param $variables
66  */
67 function template_preprocess_hacked_file_status(&$variables) {
68   switch ($variables['file']['status']) {
69     case HACKED_STATUS_UNHACKED:
70       $uri = 'core/misc/icons/73b355/check.svg';
71       $text = t('Unchanged');
72       break;
73     case HACKED_STATUS_DELETED:
74       $uri = 'core/misc/icons/e32700/error.svg';
75       $text = t('Deleted');
76       break;
77     case HACKED_STATUS_HACKED:
78       $uri = 'core/misc/icons/e29700/warning.svg';
79       $text = t('Changed!');
80       break;
81     case HACKED_STATUS_PERMISSION_DENIED:
82       $uri = 'core/misc/icons/e29700/warning.svg';
83       $text = t('Permission Denied');
84       break;
85     case HACKED_STATUS_UNCHECKED:
86     default:
87       $uri = 'core/misc/icons/e29700/warning.svg';
88       $text = t('Unchecked');
89       break;
90   }
91
92   $variables['status']['attributes'] = new Attribute();
93   $variables['status']['label'] = $text;
94   $variables['status']['icon'] = [
95     '#theme'  => 'image',
96     '#width'  => 18,
97     '#height' => 18,
98     '#uri'    => $uri,
99     '#alt'    => $text,
100     '#title'  => $text,
101   ];
102 }