summaryrefslogtreecommitdiffstats
path: root/functions/misc.php
blob: ef38de88773802865685977e8914f714d78ac67d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
<?php
/**
 * @file
 * Contains some miscellaneous functions.
 */

/**
 * Get all defined colours as array.
 *
 * @return array
 *   All defined colours for this theme.
 */
function _rijkshuisstijl_defined_colours() {
  return array(
    'violet',
    'pink',
    'red',
    'ruby',
    'purple',
    'orange',
    'moss_green',
    'mint_green',
    'light_blue',
    'azure',
    'green',
    'yellow',
    'dark_green',
    'dark_yellow',
    'dark_brown',
    'brown',
    'intra_app',
  );
}

/**
 * Get all defined logos as array.
 *
 * @return array
 *   An associative array with all defined logos in the starterskit.
 */
function _rijkshuisstijl_defined_logos() {
  $starterskit = _rijkshuisstijl_init_starterskit();
  $path = $starterskit['library path'] . '/logos';

  $filesdir = file_scan_directory($path, '/\.png$/', array('nomask' => '/RO_Footer_Homepage/', 'key' => 'name'));

  $search_replacements = array(
    'AZ_'   => 'Algemene Zaken - ',
    'BZK_'  => 'Binnenlandse Zaken en Koninkrijksrelaties - ',
    'BuZa_' => 'Buitenlandse Zaken - ',
    'ELI_'  => 'Economische Zaken, Landbouw en Innovatie - ',
    'D_'  => 'Defensie - ',
    'F_'  => 'Financiƫn - ',
    'IM_' => 'Infrastructuur en Milieu - ',
    'OCW_'  => 'Onderwijs, Cultuur en Wetenschap - ',
    'SZW_'  => 'Sociale Zaken en Werkgelegenheid - ',
    'VJ_' => 'Veiligheid en Justitie - ',
    'VWS_'  => 'Volksgezondheid, Welzijn en Sport - ',
    'J_'  => 'Justitie - ',
    'WWI_'  => 'Wonen, Wijken en Integratie - ',
    'JG_' => 'Jeugd en Gezin - ',
  );

  $search = array("RO_", "_Logo_Homepage");
  $replacements = array("", "");

  $logofiles = array();
  foreach ($filesdir as $key => $value) {
    $newindex = str_replace($search, $replacements, $key);
    $logofiles[$path . '/' . $value->filename] = str_replace(array_keys($search_replacements), array_values($search_replacements), $newindex);
  }

  return $logofiles;
}

/**
 * Format a color checkbox label on the admin screen.
 *
 * @param string $colour
 *   The name of the colour
 *
 * @return string
 *   A string containing the rendered label.
 */
function _rijkshuisstijl_format_color_swatch($colour) {
  return "<span class=\"" . $colour . "\">" . $colour . "</span>";
}

/**
 * Initialized the Starterskit library, otherwise display an error.
 *
 * @return array
 *   The starterskit library as associative array.
 */
function _rijkshuisstijl_init_starterskit() {
  if (!module_exists('libraries') || !($library = libraries_load('starterskit')) || empty($library['loaded'])) {
    drupal_set_message(t('The Starterskit library cannot be loaded. Please make sure that it exists before using the Rijkshuisstijl theme.'), 'error', FALSE);
    return NULL;
  }

  return $library;
}