5 * gallery.module : gallery_g2image.inc
6 * Support functions for g2image by capt_kirk (from http://g2image.steffensenfamily.com)
12 function gallery_g2image_add_js() {
13 // Ensure only sent once
16 $path = drupal_get_path('module', 'gallery');
17 $g2image_uri = base_path() .
$path .
'/g2image/';
19 $output .
= '<script type="text/javascript">';
20 $output .
= ' var G2IMAGE_URI = "' .
$g2image_uri .
'";';
21 $output .
= '</script>';
23 drupal_set_html_head($output);
24 drupal_add_js($path .
'/g2image.js');
30 * Theme for adding an image link underneath textareas
32 function theme_gallery_g2image_textarea_link($element, $link) {
33 $output = '<div class="g2image-button"><a class="g2image-link" id="g2image-link-'.
$element['#id']
34 .
'" title="'.
t('Click here to add images from Gallery2 albums')
35 .
'" href="#" onclick="g2ic_open(\''.
$element['#id'].
'\');">';
36 $output .
= t('add Gallery2 images');
37 $output .
= '</a></div>';
43 * Determine if g2image button should be attached to the page/textarea.
44 * (from img_assist and tinymce code)
47 * TRUE if can render, FALSE if not allowed.
49 function _gallery_g2image_page_match() {
50 //if (variable_get('gallery_g2image_std_all', 1)) {
52 $only_listed_pages = variable_get('gallery_g2image_only_listed_pages', 1);
53 $pages = variable_get('gallery_g2image_std_pages', gallery_help('admin/settings/gallery_g2image#pages'));
55 $path = drupal_get_path_alias($_GET['q']);
56 $regexp = '/^('.
preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'.
variable_get('site_frontpage', 'node') .
'\2'), preg_quote($pages, '/')) .
')$/';
57 $page_match = !($only_listed_pages xor
preg_match($regexp, $path));