| Commit | Line | Data |
|---|---|---|
| c15e9178 | 1 | <?php |
| 2 | // $Id$ | |
| 3 | ||
| 4 | /** | |
| 5 | * gallery.module : gallery_g2image.inc | |
| 6 | * Support functions for g2image by capt_kirk (from http://g2image.steffensenfamily.com) | |
| 7 | */ | |
| e65698fe TW |
8 | |
| 9 | /** | |
| 10 | * Function gallery_g2image_add_js(). | |
| c15e9178 | 11 | */ |
| e65698fe | 12 | function gallery_g2image_add_js() { |
| c15e9178 | 13 | // Ensure only sent once |
| e65698fe | 14 | static $sent = FALSE; |
| c15e9178 | 15 | if (!$sent) { |
| 16 | $path = drupal_get_path('module', 'gallery'); | |
| e65698fe TW |
17 | $g2image_uri = base_path() . $path .'/g2image/'; |
| 18 | ||
| 030f6937 TW |
19 | drupal_add_js(array('gallery' => array('g2image_uri' => $g2image_uri)), 'setting'); |
| 20 | drupal_add_js($path .'/gallery.js'); | |
| c15e9178 | 21 | |
| e65698fe | 22 | $sent = TRUE; |
| c15e9178 | 23 | } |
| 24 | } | |
| e65698fe TW |
25 | |
| 26 | /** | |
| 27 | * Theme function : theme_gallery_g2image_textarea_link(). | |
| 28 | * (for adding an image link underneath textareas) | |
| c15e9178 | 29 | */ |
| 30 | function theme_gallery_g2image_textarea_link($element, $link) { | |
| 31 | $output = '<div class="g2image-button"><a class="g2image-link" id="g2image-link-'. $element['#id'] | |
| e65698fe | 32 | .'" title="'. t('Click here to add images from Gallery2 albums') |
| e6eb5e28 | 33 | .'" href="#" onclick="g2image_open(\''. $element['#id'] .'\');">'; |
| e65698fe | 34 | $output .= t('Add Gallery2 images'); |
| c15e9178 | 35 | $output .= '</a></div>'; |
| 36 | ||
| 37 | return $output; | |
| 38 | } | |
| 39 | ||
| 40 | /** | |
| e65698fe TW |
41 | * Function _gallery_g2image_page_match(). |
| 42 | * (determine if g2image button should be attached to the page/textarea) | |
| c15e9178 | 43 | * |
| 44 | * @return | |
| 45 | * TRUE if can render, FALSE if not allowed. | |
| 46 | */ | |
| 47 | function _gallery_g2image_page_match() { | |
| e65698fe TW |
48 | require_once(drupal_get_path('module', 'gallery') .'/gallery_help.inc'); |
| 49 | ||
| c15e9178 | 50 | $page_match = FALSE; |
| 51 | $only_listed_pages = variable_get('gallery_g2image_only_listed_pages', 1); | |
| e65698fe | 52 | if ($pages = variable_get('gallery_g2image_std_pages', gallery_help('admin/settings/gallery_g2image#pages'))) { |
| c15e9178 | 53 | $path = drupal_get_path_alias($_GET['q']); |
| 54 | $regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. variable_get('site_frontpage', 'node') .'\2'), preg_quote($pages, '/')) .')$/'; | |
| 55 | $page_match = !($only_listed_pages xor preg_match($regexp, $path)); | |
| 56 | } | |
| e65698fe | 57 | |
| c15e9178 | 58 | return $page_match; |
| 59 | } |