| 1 |
<?php
|
| 2 |
// $Id: gallery_g2image.inc,v 1.1.6.5 2007/09/10 18:04:08 profix898 Exp $
|
| 3 |
|
| 4 |
/**
|
| 5 |
* gallery.module : gallery_g2image.inc
|
| 6 |
* Support functions for g2image by capt_kirk (from http://g2image.steffensenfamily.com)
|
| 7 |
*/
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Function gallery_g2image_add_js().
|
| 11 |
*/
|
| 12 |
function gallery_g2image_add_js() {
|
| 13 |
// Ensure only sent once
|
| 14 |
static $sent = FALSE;
|
| 15 |
if (!$sent) {
|
| 16 |
$path = drupal_get_path('module', 'gallery');
|
| 17 |
$g2image_uri = base_path() . $path .'/g2image/';
|
| 18 |
|
| 19 |
drupal_add_js(array('gallery2' => array('g2image_uri' => $g2image_uri)), 'setting');
|
| 20 |
drupal_add_js($path .'/g2image.js');
|
| 21 |
|
| 22 |
$sent = TRUE;
|
| 23 |
}
|
| 24 |
}
|
| 25 |
|
| 26 |
/**
|
| 27 |
* Theme function : theme_gallery_g2image_textarea_link().
|
| 28 |
* (for adding an image link underneath textareas)
|
| 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']
|
| 32 |
.'" title="'. t('Click here to add images from Gallery2 albums')
|
| 33 |
.'" href="#" onclick="g2ic_open(\''. $element['#id'] .'\');">';
|
| 34 |
$output .= t('Add Gallery2 images');
|
| 35 |
$output .= '</a></div>';
|
| 36 |
|
| 37 |
return $output;
|
| 38 |
}
|
| 39 |
|
| 40 |
/**
|
| 41 |
* Function _gallery_g2image_page_match().
|
| 42 |
* (determine if g2image button should be attached to the page/textarea)
|
| 43 |
*
|
| 44 |
* @return
|
| 45 |
* TRUE if can render, FALSE if not allowed.
|
| 46 |
*/
|
| 47 |
function _gallery_g2image_page_match() {
|
| 48 |
require_once(drupal_get_path('module', 'gallery') .'/gallery_help.inc');
|
| 49 |
|
| 50 |
$page_match = FALSE;
|
| 51 |
$only_listed_pages = variable_get('gallery_g2image_only_listed_pages', 1);
|
| 52 |
if ($pages = variable_get('gallery_g2image_std_pages', gallery_help('admin/settings/gallery_g2image#pages'))) {
|
| 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 |
}
|
| 57 |
|
| 58 |
return $page_match;
|
| 59 |
}
|