| 1 |
<?php
|
| 2 |
// $Id
|
| 3 |
|
| 4 |
require_once("common_methods.php");
|
| 5 |
|
| 6 |
if (get_drupal_version() == 5) {
|
| 7 |
require_once("drupal5_methods.php");
|
| 8 |
}
|
| 9 |
else {
|
| 10 |
require_once("drupal6_methods.php");
|
| 11 |
}
|
| 12 |
|
| 13 |
/* Common methods */
|
| 14 |
|
| 15 |
function get_drupal_version() {
|
| 16 |
$tok = strtok(VERSION, '.');
|
| 17 |
//return first part of version number
|
| 18 |
return (int)$tok[0];
|
| 19 |
}
|
| 20 |
|
| 21 |
function get_page_language($language) {
|
| 22 |
if (get_drupal_version() >= 6) return $language->language;
|
| 23 |
return $language;
|
| 24 |
}
|
| 25 |
|
| 26 |
function get_full_path_to_theme()
|
| 27 |
{
|
| 28 |
return base_path().path_to_theme();
|
| 29 |
}
|
| 30 |
|
| 31 |
function green_service_links_node_format($links) {
|
| 32 |
return '<div class="service-links"><div class="service-label">'. t('Bookmark/Search this post with: ') .'</div>'. art_links_woker($links) .'</div>';
|
| 33 |
}
|
| 34 |
|
| 35 |
/**
|
| 36 |
* Theme a form button.
|
| 37 |
*
|
| 38 |
* @ingroup themeable
|
| 39 |
*/
|
| 40 |
function green_button($element) {
|
| 41 |
// Make sure not to overwrite classes.
|
| 42 |
if (isset($element['#attributes']['class'])) {
|
| 43 |
$element['#attributes']['class'] = 'Button form-'. $element['#button_type'] .' '. $element['#attributes']['class'];
|
| 44 |
}
|
| 45 |
else {
|
| 46 |
$element['#attributes']['class'] = 'Button form-'. $element['#button_type'];
|
| 47 |
}
|
| 48 |
|
| 49 |
return '<button type="submit" '. (empty($element['#name']) ? '' : 'name="'. $element['#name']
|
| 50 |
.'" ') .'id="'. $element['#id'].'" value="'. check_plain($element['#value']) .'" '. drupal_attributes($element['#attributes']).'>'
|
| 51 |
.'<span class="btn">'
|
| 52 |
.'<span class="l"></span>'
|
| 53 |
.'<span class="r"></span>'
|
| 54 |
.'<span class="t">'.check_plain($element['#value']).'</span>'
|
| 55 |
.'</span></button>';
|
| 56 |
}
|
| 57 |
|
| 58 |
/**
|
| 59 |
* Image assist module support.
|
| 60 |
* Using Artisteer styles in IE
|
| 61 |
*/
|
| 62 |
function green_img_assist_page($content, $attributes = NULL) {
|
| 63 |
$title = drupal_get_title();
|
| 64 |
$output = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'."\n";
|
| 65 |
$output .= '<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">'."\n";
|
| 66 |
$output .= "<head>\n";
|
| 67 |
$output .= '<title>'. $title ."</title>\n";
|
| 68 |
|
| 69 |
// Note on CSS files from Benjamin Shell:
|
| 70 |
// Stylesheets are a problem with image assist. Image assist works great as a
|
| 71 |
// TinyMCE plugin, so I want it to LOOK like a TinyMCE plugin. However, it's
|
| 72 |
// not always a TinyMCE plugin, so then it should like a themed Drupal page.
|
| 73 |
// Advanced users will be able to customize everything, even TinyMCE, so I'm
|
| 74 |
// more concerned about everyone else. TinyMCE looks great out-of-the-box so I
|
| 75 |
// want image assist to look great as well. My solution to this problem is as
|
| 76 |
// follows:
|
| 77 |
// If this image assist window was loaded from TinyMCE, then include the
|
| 78 |
// TinyMCE popups_css file (configurable with the initialization string on the
|
| 79 |
// page that loaded TinyMCE). Otherwise, load drupal.css and the theme's
|
| 80 |
// styles. This still leaves out sites that allow users to use the TinyMCE
|
| 81 |
// plugin AND the Add Image link (visibility of this link is now a setting).
|
| 82 |
// However, on my site I turned off the text link since I use TinyMCE. I think
|
| 83 |
// it would confuse users to have an Add Images link AND a button on the
|
| 84 |
// TinyMCE toolbar.
|
| 85 |
//
|
| 86 |
// Note that in both cases the img_assist.css file is loaded last. This
|
| 87 |
// provides a way to make style changes to img_assist independently of how it
|
| 88 |
// was loaded.
|
| 89 |
$output .= drupal_get_html_head();
|
| 90 |
$output .= drupal_get_js();
|
| 91 |
$output .= "\n<script type=\"text/javascript\"><!-- \n";
|
| 92 |
$output .= " if (parent.tinyMCE && parent.tinyMCEPopup && parent.tinyMCEPopup.getParam('popups_css')) {\n";
|
| 93 |
$output .= " document.write('<link href=\"' + parent.tinyMCEPopup.getParam('popups_css') + '\" rel=\"stylesheet\" type=\"text/css\">');\n";
|
| 94 |
$output .= " } else {\n";
|
| 95 |
foreach (drupal_add_css() as $media => $type) {
|
| 96 |
$paths = array_merge($type['module'], $type['theme']);
|
| 97 |
foreach (array_keys($paths) as $path) {
|
| 98 |
// Don't import img_assist.css twice.
|
| 99 |
if (!strstr($path, 'img_assist.css')) {
|
| 100 |
$output .= " document.write('<style type=\"text/css\" media=\"{$media}\">@import \"". base_path() . $path ."\";<\/style>');\n";
|
| 101 |
}
|
| 102 |
}
|
| 103 |
}
|
| 104 |
$output .= " }\n";
|
| 105 |
$output .= "--></script>\n";
|
| 106 |
// Ensure that img_assist.js is imported last.
|
| 107 |
$path = drupal_get_path('module', 'img_assist') .'/img_assist_popup.css';
|
| 108 |
$output .= "<style type=\"text/css\" media=\"all\">@import \"". base_path() . $path ."\";</style>\n";
|
| 109 |
|
| 110 |
$output .= '<!--[if IE 6]><link rel="stylesheet" href="'.get_full_path_to_theme().'/style.ie6.css" type="text/css" /><![endif]-->'."\n";
|
| 111 |
$output .= '<!--[if IE 7]><link rel="stylesheet" href="'.get_full_path_to_theme().'/style.ie7.css" type="text/css" /><![endif]-->'."\n";
|
| 112 |
|
| 113 |
$output .= "</head>\n";
|
| 114 |
$output .= '<body'. drupal_attributes($attributes) .">\n";
|
| 115 |
|
| 116 |
$output .= theme_status_messages();
|
| 117 |
|
| 118 |
$output .= "\n";
|
| 119 |
$output .= $content;
|
| 120 |
$output .= "\n";
|
| 121 |
$output .= '</body>';
|
| 122 |
$output .= '</html>';
|
| 123 |
return $output;
|
| 124 |
}
|