Exemple #1
0
/**
 * Preprocesses template variables.
 * @param vars variables for the template
 */
function phptemplate_preprocess_page(&$vars) {
	$vars['tabs2'] = menu_secondary_local_tasks();
	if (module_exists('color')) {
		_color_page_alter($vars);
	}
	if (module_exists('mobileplugin')) {
		$vars['styles'] = _mobileplugin_filter_css($vars['css']);
		$vars['scripts'] = _mobileplugin_filter_js();
		$vars['bodyclasses'] = 'mobile' . _mobileplugin_add_class();
		$scaled_logo = _mobileplugin_image_scaled($vars['logo'], 30, 30);
		if (!is_array($scaled_logo)) {
			$vars['logo'] = $scaled_logo;
		}
	}
}
/**
 * Preprocesses template variables.
 * @param vars variables for the template
 */
function phptemplate_preprocess_page(&$vars)
{
    $vars['tabs2'] = menu_secondary_local_tasks();
    if (module_exists('color')) {
        _color_page_alter($vars);
    }
    /*
      echo "<pre>\n";
      print_r($vars);
      echo "</pre>\n";
      die();
    */
    // here there used to be a check for the existence of the mobileplugin. Moved down.
    // everything should be indented back of two spaces
    // Make sure we have set the proper Nokia group IF the theme settings say so
    if (arg(0) != 'admin') {
        _nokia_mobile_force_nokia_group();
    }
    // add my styles - move to a function?
    $css_path = _nokia_mobile_get_css_path();
    $js_path = _nokia_mobile_get_js_path();
    $style_path = path_to_theme() . '/css/' . $css_path . 'reset.css';
    // dynamic based on device group
    $new_styles_order[$style_path] = 1;
    $theme_styles = $vars['css']['all']['theme'];
    $new_styles_order = array_merge($new_styles_order, $theme_styles);
    // Apply the Nokia style last. NO COLORS should be applied here unless really want to force
    $style_path = path_to_theme() . '/css/' . $css_path . 'baseStyles.css';
    // dynamic based on device group
    $new_styles_order[$style_path] = 1;
    $theme_image_color_css_filename = nokia_mobile_settings_css_filename() . '.css';
    $style_path = path_to_theme() . '/css/' . $css_path . $theme_image_color_css_filename;
    // dynamic based on color picked by admin
    $new_styles_order[$style_path] = 1;
    $vars['css']['all']['theme'] = $new_styles_order;
    $vars['header_text_color'] = '#ffffff';
    // make sure we are using color
    if (module_exists('color')) {
        $header_text_color = theme_get_setting('theme_header_text_color');
        $vars['header_text_color'] = $header_text_color;
    }
    $vars['doctype'] = _nokia_mobile_get_doctype();
    /*
    $vars['left'] = str_replace('user-login', 'my-user-login', $vars['left']);
    $vars['left'] = str_replace('user_login', 'my_user_login', $vars['left']);
    */
    // Add Javscript
    if (is_file(drupal_get_path('theme', 'nokia_mobile') . '/scripts/' . $js_path . 'nokia_mobile.js')) {
        drupal_add_js(drupal_get_path('theme', 'nokia_mobile') . '/scripts/' . $js_path . 'nokia_mobile.js', 'theme');
        // dynamic based on device group
    }
    $vars['inline_scripts'] = '';
    // High-end device specifics
    if (_nokia_mobile_device_detection() == NOKIAMOBILE_THEME_HIGHEND_GROUP || _nokia_mobile_device_detection() == NOKIAMOBILE_THEME_HIGHEND_TOUCH_GROUP) {
        if (!empty($vars['tabs'])) {
            // trick to get the closing vertical bar
            $vars['tabs'] .= "<li><a/></li>\n";
        }
        global $user;
        if (is_object($user)) {
            $user_uid = $user->uid;
        } else {
            $user_uid = '';
        }
        $tweaks_path = '/' . path_to_theme() . '/css/' . $css_path . 'tweaks/';
        // dynamic based on device group
        $inline_script = $vars['inline_scripts'] = '
		function init() {
			var myAccordionList = new AccordionList("accordion");
			var myStyleTweaks = new StyleTweaker();
			myStyleTweaks.add("Series60/5.0", "' . $tweaks_path . 'S605th.css");
			myStyleTweaks.add("Series60/3.2", "' . $tweaks_path . 'S603rdFP2.css");
			myStyleTweaks.add("AppleWebKit/420+", "' . $tweaks_path . 'S406th.css");
			myStyleTweaks.add("N900", "' . $tweaks_path . 'maemo.css");
			myStyleTweaks.add("Firefox/3.0a1 Tablet browser 0.3.7", "' . $tweaks_path . 'maemo.css");
			myStyleTweaks.add("Opera Mini/4", "' . $tweaks_path . 'operamini.css");
			myStyleTweaks.tweak();
		}
		addEvent("onload",init);
';
        drupal_add_js($inline_script, 'inline', 'header');
    }
    // Theme the breadcrumb
    /*
    if (!empty($vars['breadcrumb'])) {
    	$vars['breadcrumb'] = phptemplate_breadcrumb(drupal_get_breadcrumb());
    }
    */
    if (module_exists('mobileplugin')) {
        // clean CSS, JS and get scaled logo using mobileplugin's (private) functions
        $vars['styles'] = _mobileplugin_filter_css($vars['css']);
        $vars['scripts'] = _mobileplugin_filter_js();
        $vars['bodyclasses'] = 'mobile' . _mobileplugin_add_class();
        $scaled_logo = _mobileplugin_image_scaled($vars['logo'], 30, 30);
        if (!is_array($scaled_logo)) {
            $vars['logo'] = $scaled_logo;
        }
    } else {
        // clean CSS, JS
        $js = drupal_add_js();
        $vars['scripts'] = _nokia_mobile_filter_js($js);
        $css = $vars['css'];
        $css['handheld']['theme']['/this_is_a_test.css'] = 1;
        $vars['styles'] = _nokia_mobile_filter_css($css);
        // Scale logo?
    }
}