4 * gallery.module : gallery_g2image.inc
5 * Support functions for g2image by capt_kirk (from http://g2image.steffensenfamily.com)
9 * Function gallery_g2image_add_js().
11 function gallery_g2image_add_js() {
12 // Ensure only sent once
15 $path = drupal_get_path('module', 'gallery');
16 $g2image_uri = base_path() .
$path .
'/g2image/';
18 drupal_add_js(array('gallery2' => array('g2image_uri' => $g2image_uri)), 'setting');
19 drupal_add_js($path .
'/g2image.js');
26 * Theme function : theme_gallery_g2image_textarea_link().
27 * (for adding an image link underneath textareas)
29 function theme_gallery_g2image_textarea_link($element, $link) {
30 $output = '<div class="g2image-button"><a class="g2image-link" id="g2image-link-'.
$element['#id']
31 .
'" title="'.
t('Click here to add images from Gallery2 albums')
32 .
'" href="#" onclick="g2ic_open(\''.
$element['#id'] .
'\');">';
33 $output .
= t('Add Gallery2 images');
34 $output .
= '</a></div>';
40 * Function _gallery_g2image_page_match().
41 * (determine if g2image button should be attached to the page/textarea)
44 * TRUE if can render, FALSE if not allowed.
46 function _gallery_g2image_page_match() {
47 require_once(drupal_get_path('module', 'gallery') .
'/gallery_help.inc');
50 $only_listed_pages = variable_get('gallery_g2image_only_listed_pages', 1);
51 if ($pages = variable_get('gallery_g2image_std_pages', gallery_help('admin/settings/gallery_g2image#pages'))) {
52 $path = drupal_get_path_alias($_GET['q']);
53 $regexp = '/^('.
preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'.
variable_get('site_frontpage', 'node') .
'\2'), preg_quote($pages, '/')) .
')$/';
54 $page_match = !($only_listed_pages xor
preg_match($regexp, $path));