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; $visibility = variable_get('gallery_g2image_visibility', 1); if ($pages = variable_get('gallery_g2image_visibility_pages', "node/add/*\ncomment/*")) { $path = drupal_get_path_alias($_GET['q']); $page_match = !($visibility xor drupal_match_path($path, $pages)); } 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 = '
'; $output .= t('Add Gallery2 images'); $output .= '
'; return $output; }