forked from luisomoreau/okcdesign-D7
-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.php
136 lines (117 loc) · 3.79 KB
/
template.php
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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
<?php
/**
* @file
* Template.php
*
* No custom code should be written here, only invocations
* to plugin via theme_plugins_manager.
*
* @see theme_plugins_manager/theme_plugins_manager.php
*/
// load plugins system
include_once 'theme_plugins_manager/theme_plugins_manager.php';
// all this things happen when submitting theme settings form.
/*
$okcdesign_custom_scss_path = variable_get('file_public_path', conf_path() . '/files') . '/okcdesign';
if (!is_readable($okcdesign_custom_scss_path)) {
mkdir($okcdesign_custom_scss_path);
}
$okcdesign_theme_custom_theme_scss_path = $okcdesign_custom_scss_path . '/' . variable_get("theme_default");
if (!is_readable($okcdesign_theme_custom_theme_scss_path)) {
mkdir($okcdesign_theme_custom_theme_scss_path);
}
$okcdesign_theme_custom_theme_scss_file = $okcdesign_theme_custom_theme_scss_path . '/_theme_custom_settings.scss';
if (!is_readable($okcdesign_theme_custom_theme_scss_file)) {
file_put_contents($okcdesign_theme_custom_theme_scss_file, '');
}
if (is_readable($okcdesign_theme_custom_theme_scss_file)) {
require "bower_components/scssphp/scss.inc.php";
// we have to recompile ALL scss file if user what to customize scss.
$default_theme_path = drupal_get_path('theme', variable_get('theme_default'));
$base_theme_path = drupal_get_path('theme', 'okcdesign');
$app_scss = "$default_theme_path/scss/app.scss";
// configure import pathes for our php scss compilator.
$import_paths = array(
"$base_theme_path/bower_components/foundation/scss",
"$base_theme_path/scss",
$okcdesign_theme_custom_theme_scss_path,
);
$scss = new scssc();
$scss->setImportPaths($import_paths);
$scss_to_compile = file($app_scss);;
$scss_to_compile = _scssphp_buil_scss_import_file($scss_to_compile);
$app_css = $scss->compile($scss_to_compile);
file_put_contents($okcdesign_theme_custom_theme_scss_path . '/app.css', $app_css);
}
*/
/**
* Rebuild app.scss file, but add an import of "theme_custom_settings.scss"
* that lives in files/okcdesign/{active_theme}
* @param $lines
* @return string
*/
function _scssphp_buil_scss_import_file($lines) {
$file = '';
foreach ($lines as $i => $line) {
$file .= $line . "\r\n";
$cleaned_line = str_replace(' ', '', $line);
if(strpos($cleaned_line, "@import'settings'") !== FALSE || strpos($cleaned_line, '@import"settings"') !== FALSE) {
$file .= '@import "theme_custom_settings";' . "\r\n";
}
}
return $file;
}
/*=============================
HOOKS
==============================*/
/**
* Implements hook_theme()
*/
function okcdesign_theme() {
$themes = array();
theme_plugins_invoke(__FUNCTION__, $themes);
return $themes;
}
/*=============================
PREPROCESS
==============================*/
/**
* Implements template_preprocess_page()
*/
function okcdesign_preprocess_page(&$variables) {
theme_plugins_invoke(__FUNCTION__, $variables);
}
/**
* Implements hook_css_alter()
*/
function okcdesign_css_alter(&$variables) {
theme_plugins_invoke(__FUNCTION__, $variables);
}
/**
* Implements hook_html_head_alter().
*/
function okcdesign_html_head_alter(&$variables) {
theme_plugins_invoke(__FUNCTION__, $variables);
}
/**
* Implements template_preprocess_foundation_topbar()
*/
function okcdesign_preprocess_foundation_topbar(&$variables) {
theme_plugins_invoke(__FUNCTION__, $variables);
}
/*=============================
THEME OVERRIDES
==============================*/
/**
* Implements hook_theme_breadcrumb()
*/
function okcdesign_breadcrumb($variables) {
$html = theme_plugins_invoke(__FUNCTION__, $variables);
if ($html) return $html;
return theme_breadcrumb($variables);
}
function okcdesign_status_messages($variables) {
$html = theme_plugins_invoke(__FUNCTION__, $variables);
if ($html) return $html;
return theme_status_messages($variables);
}