Stripping CVS keywords
[project/gallery.git] / gallery_g2image.inc
1 <?php
2
3 /**
4 * gallery.module : gallery_g2image.inc
5 * Support functions for g2image by capt_kirk (from http://g2image.steffensenfamily.com)
6 */
7
8 /**
9 * Function gallery_g2image_add_js().
10 */
11 function gallery_g2image_add_js() {
12 // Ensure only sent once
13 static $sent = FALSE;
14 if (!$sent) {
15 $path = drupal_get_path('module', 'gallery');
16 $g2image_uri = base_path() . $path .'/g2image/';
17
18 drupal_add_js(array('gallery2' => array('g2image_uri' => $g2image_uri)), 'setting');
19 drupal_add_js($path .'/g2image.js');
20
21 $sent = TRUE;
22 }
23 }
24
25 /**
26 * Theme function : theme_gallery_g2image_textarea_link().
27 * (for adding an image link underneath textareas)
28 */
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>';
35
36 return $output;
37 }
38
39 /**
40 * Function _gallery_g2image_page_match().
41 * (determine if g2image button should be attached to the page/textarea)
42 *
43 * @return
44 * TRUE if can render, FALSE if not allowed.
45 */
46 function _gallery_g2image_page_match() {
47 require_once(drupal_get_path('module', 'gallery') .'/gallery_help.inc');
48
49 $page_match = FALSE;
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));
55 }
56
57 return $page_match;
58 }