Commit f6d926e1 authored by profix898's avatar profix898

- Initial version of Gallery G2Image

parent d8886446
// $Id$
Installation
------------
If you install G2Image (http://g2image.steffensenfamily.com) as either a
standalone or TinyMCE plugin you will have an excellent image chooser for
Drupal/Gallery2. The configuration is automatic when you hit the 'Save
configuration' button on the G2Image settings page
(admin/settings/gallery/g2image).
; $Id$
name = "Gallery G2Image"
description = "Integrates G2Image with Gallery module"
package = "Gallery2"
dependencies[] = gallery
core = 6.x
// $Id$
function g2image_open(field) {
// Set some properties
var form = $('#'+field).parents('form').attr('id');
var url = Drupal.settings.gallery.g2image_uri+'/g2image.php?g2ic_form='+form+'&g2ic_field='+field+'&g2ic_tinymce=0';
var name = 'g2image';
var w = 600;
var h = 600;
var valLeft = (screen.width) ? (screen.width-w)/2 : 0;
var valTop = (screen.height) ? (screen.height-h)/2 : 0;
var features = 'width='+w+',height='+h+',left='+valLeft+',top='+valTop+',resizable=1,scrollbars=1';
// Open the G2Image window
window.open(url, name, features);
}
// BUEditor
function g2bueditor_open() {
if (editor.active) {
g2image_open(editor.active.textArea.id);
}
}
<?php
// $Id$
/**
* gallery_g2image.module
*/
/**
* Implementation of hook_theme().
*/
function gallery_g2image_theme() {
return array(
'gallery_g2image_textarea_link' => array(
'arguments' => array('element' => NULL, 'link' => NULL),
)
);
}
/**
* Implementation of hook_perm().
*/
function gallery_g2image_perm() {
return array('access standalone g2image');
}
/**
* Implementation of hook_menu().
*/
function gallery_g2image_menu() {
$items = array();
if (variable_get('gallery_valid', 0)) {
$items['admin/settings/gallery/g2image'] = array(
'title' => 'G2Image',
'access callback' => 'user_access',
'access arguments' => array('administer gallery settings'),
'file' => 'gallery_g2image_settings.inc',
'page callback' => 'drupal_get_form',
'page arguments' => array('_gallery_g2image_settings'),
'type' => MENU_LOCAL_TASK,
'weight' => 3
);
}
return $items;
}
/**
* Implementation of hook_elements().
*/
function gallery_g2image_elements() {
$type['textarea'] = array('#process' => array('gallery_g2image_textarea'));
return $type;
}
/**
* Function gallery_g2image_textarea().
* (add image link underneath textareas)
*/
function gallery_g2image_textarea($element) {
if (!isset($element['#disabled']) && _gallery_g2image_page_match()
&& (variable_get('gallery_g2image_mode', 'disabled') == 'standalone')
&& (user_access('access standalone g2image'))) {
gallery_g2image_add_js();
$link = theme('gallery_g2image_textarea_link', $element);
$element['#suffix'] = (isset($element['#suffix']) ? $element['#suffix'] : '') . $link;
}
return $element;
}
/**
* Function _gallery_g2image_page_match().
* (determine if g2image button should be attached to the page/textarea)
*
* @return
* TRUE if can render, FALSE if not allowed.
*/
function _gallery_g2image_page_match() {
require_once(drupal_get_path('module', 'gallery') .'/gallery_help.inc');
$page_match = FALSE;
$only_listed_pages = variable_get('gallery_g2image_only_listed_pages', 1);
if ($pages = variable_get('gallery_g2image_std_pages', gallery_help('admin/settings/gallery_g2image#pages'))) {
$path = drupal_get_path_alias($_GET['q']);
$regexp = '/^('. preg_replace(array('/(\r\n?|\n)/', '/\\\\\*/', '/(^|\|)\\\\<front\\\\>($|\|)/'), array('|', '.*', '\1'. variable_get('site_frontpage', 'node') .'\2'), preg_quote($pages, '/')) .')$/';
$page_match = !($only_listed_pages xor preg_match($regexp, $path));
}
return $page_match;
}
/**
* Function gallery_g2image_add_js().
*/
function gallery_g2image_add_js() {
// Ensure only sent once
static $sent = FALSE;
if (!$sent) {
if ($path = variable_get('gallery_g2image_path', FALSE)) {
drupal_add_js(array('gallery' => array('g2image_uri' => base_path() . $path)), 'setting');
drupal_add_js(drupal_get_path('module', 'gallery_g2image') .'/gallery_g2image.js');
}
$sent = TRUE;
}
}
/**
* Theme function : theme_gallery_g2image_textarea_link().
* (for adding an image link underneath textareas)
*/
function theme_gallery_g2image_textarea_link($element) {
$output = '<div class="g2image-button"><a class="g2image-link" id="g2image-link-'. $element['#id']
.'" title="'. t('Click here to add images from Gallery2 albums')
.'" href="#" onclick="g2image_open(\''. $element['#id'] .'\');">';
$output .= t('Add Gallery2 images');
$output .= '</a></div>';
return $output;
}
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment