Merge lp:~mongolito404/ubuntu-drupal-theme/688289_download_tradmaked_css into lp:ubuntu-drupal-theme

Proposed by Pierre Buyle
Status: Merged
Approved by: Michael Lustfield
Approved revision: 76
Merged at revision: 76
Proposed branch: lp:~mongolito404/ubuntu-drupal-theme/688289_download_tradmaked_css
Merge into: lp:ubuntu-drupal-theme
Diff against target: 85 lines (+37/-14)
1 file modified
template.php (+37/-14)
To merge this branch: bzr merge lp:~mongolito404/ubuntu-drupal-theme/688289_download_tradmaked_css
Reviewer Review Type Date Requested Status
Michael Lustfield (community) Approve
Review via email: mp+46185@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Michael Lustfield (michaellustfield) wrote :

This looks to be a solid solution to the bug. Could you please commit this to the main branch for D6 and D7?

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
=== modified file 'template.php'
--- template.php 2010-12-05 09:58:12 +0000
+++ template.php 2011-01-13 21:30:02 +0000
@@ -31,7 +31,7 @@
31 );31 );
3232
33 $settings = array();33 $settings = array();
34 $settings = variable_get($theme_key, NULL);34 $settings = variable_get($theme_key, array());
3535
36 if (module_exists('node')) {36 if (module_exists('node')) {
37 foreach (node_get_types() as $type => $name) {37 foreach (node_get_types() as $type => $name) {
@@ -86,7 +86,6 @@
86 * Generate / override exsisting variables86 * Generate / override exsisting variables
87 */87 */
88function udtheme_preprocess_page(&$vars) {88function udtheme_preprocess_page(&$vars) {
89 $pallette = udtheme_pallette();
9089
91 $vars['menu'] = udtheme_whichmenu($vars['primary_links']);90 $vars['menu'] = udtheme_whichmenu($vars['primary_links']);
92 $vars['logo'] = udtheme_buildlogo($vars);91 $vars['logo'] = udtheme_buildlogo($vars);
@@ -94,9 +93,12 @@
94 $vars['help_text'] = udtheme_help($vars['help']);93 $vars['help_text'] = udtheme_help($vars['help']);
95 $vars['min_width'] = variable_get('page_minwidth', '1000px');94 $vars['min_width'] = variable_get('page_minwidth', '1000px');
96 $vars['pg_width'] = pagewidth();95 $vars['pg_width'] = pagewidth();
97 $vars['trademark'] = udtheme_trademark();96
9897 if ($trademark = udtheme_trademark()) {
99 if ($pallette && !$vars['trademark']) {98 $vars['css'] = drupal_add_css($trademark);
99 $vars['styles'] = drupal_get_css();
100 }
101 elseif ($pallette = udtheme_pallette()) {
100 $vars['css'] = drupal_add_css($pallette);102 $vars['css'] = drupal_add_css($pallette);
101 $vars['styles'] = drupal_get_css();103 $vars['styles'] = drupal_get_css();
102 }104 }
@@ -197,20 +199,41 @@
197}199}
198200
199/**201/**
200 * Add CSS for trademarked sites.202 * Add CSS for trademarked sites. Trademarked CSS files are download into the
201 * In Drupal 7.x this wil be moved into udtheme_pallette but can't be done at this point.203 * temporary CSS directory.
202 */204 */
203function udtheme_trademark() {205function udtheme_trademark() {
204 global $language;
205
206 if (variable_get('udtheme_trademark', FALSE)) {206 if (variable_get('udtheme_trademark', FALSE)) {
207 $css = '<link rel="stylesheet" type="text/css" href="http://edge.launchpad.net/ubuntu-drupal-theme/trademark/6.7.0/+download/trademark.css" />' . PHP_EOL;207 $csspath = file_create_path('css');
208 if ($language->direction == LANGUAGE_RTL) {208 foreach (array('trademark-rtl.css', 'trademark.css') as $filename) {
209 $css = '<link rel="stylesheet" type="text/css" href="http://edge.launchpad.net/ubuntu-drupal-theme/trademark/6.7.0/+download/trademark-rtl.css" />' . PHP_EOL;209 $filepath = $csspath .'/'. $filename;
210 $download = !file_exists($filepath);
211 if (!$download) {
212 $stats = stat($filepath);
213 $download = $stats['ctime'] < (time() - 86400);
214 }
215 if ($download) {
216 $url = 'http://launchpad.net/ubuntu-drupal-theme/trademark/6.7.0/+download/'. $filename;
217 $response = drupal_http_request($url);
218 if ($response->code == 303) {
219 //Handle 303 because drupal_http_request doesn't
220 $response = drupal_http_request($response->headers['Location']);
221 }
222 if (isset($response->data)) {
223 file_save_data($response->data, $filepath, FILE_EXISTS_REPLACE);
224 }
225 else {
226 watchdog('udtheme', 'Unabled to download <a href="@url">@filename</a>: @code @status_message', array(
227 '@url' => $url,
228 '@filename' => $filename,
229 '@code' => $response->code,
230 '@status_message' => $response->status_message
231 ), WATCHDOG_ERROR, $url);
232 }
233 }
210 }234 }
235 return $filepath;
211 }236 }
212
213 return $css;
214}237}
215238
216239

Subscribers

People subscribed via source and target branches