empty the filter cache to correct image paths that are pointing to the old address. Note that this will only work for images that have been inserted using filter tags.', array('!empty-cache' => url('img_assist/cache/clear'))); case 'img_assist/template': return '
'; } } /** * Implementation of hook_menu(). */ function img_assist_menu($may_cache) { $items = array(); if ($may_cache) { $admin_access = user_access('administer site configuration'); $ia_access = user_access('access img_assist'); $items[] = array('path' => 'img_assist/cache/clear', 'title' => t('Empty cache'), 'callback' => 'img_assist_cache_clear', 'access' => $admin_access, 'type' => MENU_CALLBACK, ); $items[] = array( 'path' => 'img_assist/load', 'title' => t('Image assist'), 'callback' => 'img_assist_loader', 'access' => $ia_access, 'type' => MENU_CALLBACK, ); // Page callbacks called internally by img_assist/load. $items[] = array( 'path' => 'img_assist/header', 'title' => t('Image assist header'), 'callback' => 'img_assist_header', 'access' => $ia_access, 'type' => MENU_CALLBACK, ); $items[] = array( 'path' => 'img_assist/thumbs', 'title' => t('Image assist thumbnails'), 'callback' => 'img_assist_thumbs', 'access' => $ia_access, 'type' => MENU_CALLBACK, ); $items[] = array( 'path' => 'img_assist/upload', 'title' => t('Image assist upload'), 'callback' => 'img_assist_upload', 'access' => $ia_access, 'type' => MENU_CALLBACK, ); $items[] = array( 'path' => 'img_assist/properties', 'title' => t('Image assist properties'), 'callback' => 'img_assist_properties', 'access' => $ia_access, 'type' => MENU_CALLBACK, ); // Popup images page. $items[] = array( 'path' => 'img_assist/popup', 'title' => t('Popup image'), 'callback' => 'img_assist_popup', 'access' => user_access('access content'), 'type' => MENU_CALLBACK, ); // Insert callback (only for inserting HTML, not filter tag). $items[] = array( 'path' => 'img_assist/insert_html', 'title' => t('Insert callback'), 'callback' => 'img_assist_insert_html', 'access' => $ia_access, 'type' => MENU_CALLBACK, ); $items[] = array( 'path' => 'admin/settings/img_assist', 'title' => t('Image assist'), 'description' => t('Change settings for the Image assist module.'), 'callback' => 'drupal_get_form', 'callback arguments' => 'img_assist_admin_settings', 'access' => $admin_access, ); } else { // Ensure Drupal.settings.basePath on all pages (including popup window). drupal_add_js(array('basePath' => base_path()), 'setting'); $path = drupal_get_path('module', 'img_assist'); if (arg(0) == 'img_assist') { // Suppress Administration menu. module_invoke('admin_menu', 'suppress'); drupal_add_css($path .'/img_assist_popup.css', 'module', 'all', FALSE); } else { drupal_add_js($path .'/img_assist.js'); if (variable_get('img_assist_page_styling', 'yes') == 'yes') { drupal_add_css($path .'/img_assist.css'); } } } return $items; } /** * Implementation of hook_perm(). */ function img_assist_perm() { return array('access img_assist', 'access all images', 'access advanced options', 'use original size'); } /** * Implementation of hook_elements(). */ function img_assist_elements() { $type['textarea'] = array( '#process' => array('img_assist_textarea' => array()), ); return $type; } /** * Add JavaScript settings for generating the image link underneath textareas. */ function img_assist_textarea($element) { static $initialized = FALSE; if (!user_access('access img_assist')) { return $element; } $link = variable_get('img_assist_link', 'icon'); if ($link == 'icon' || $link == 'text') { if (_img_assist_textarea_match($element['#id']) && _img_assist_page_match() && !strstr($_GET['q'], 'img_assist')) { if (!$initialized) { // Add settings. $settings['link'] = $link; $settings['link_text'] = t('Add image'); // D5 only. if ($link == 'icon') { $settings['icon'] = drupal_get_path('module', 'img_assist') .'/add-image.jpg'; } drupal_add_js(array('img_assist' => $settings), 'setting'); $initialized = TRUE; } // Attach behavior. // @todo Some browsers do not support underscores in CSS classes. if (!isset($element['#attributes']['class'])) { $element['#attributes']['class'] = 'img_assist'; } else { $element['#attributes']['class'] .= ' img_assist'; } } } return $element; } /** * Implementation of hook_block(). * * Generates a block that references the other places the current image is used. * The block is only visible when looking at the full view of an image. */ function img_assist_block($op = 'list', $delta = 0) { if ($op == 'list') { $blocks[0]['info'] = t('Image reference'); return $blocks; } else if ($op == 'view') { switch ($delta) { case 0: // Since blocks aren't passed node objects (which makes sense) we need // to determine if we are viewing a node and grab its nid. if (arg(0) == 'node' && is_numeric(arg(1))) { $block['subject'] = t('This image appears in...'); $block['content'] = img_assist_get_references(arg(1)); return $block; } break; } } } /** * Implementation of hook_settings(). */ function img_assist_admin_settings() { require_once drupal_get_path('module', 'img_assist') .'/includes/img_assist.token.inc'; // Access settings. $form['access'] = array( '#type' => 'fieldset', '#title' => t('Access settings'), '#collapsible' => TRUE, '#collapsed' => TRUE, ); $form['access']['img_assist_paths_type'] = array( '#type' => 'radios', '#title' => t('Display Image assist on paths'), '#default_value' => variable_get('img_assist_paths_type', 2), '#options' => array(t('on specific paths'), t('not on specific paths'), t('all paths')), ); $form['access']['img_assist_paths'] = array( '#type' => 'textarea', '#title' => t('Paths'), '#default_value' => variable_get('img_assist_paths', "node/*\ncomment/*"), '#cols' => 40, '#rows' => 5, '#description' => t("Enter one page per line as Drupal paths. The '*' character is a wildcard. Example paths are %blog for the blog page and %blog-wildcard for every personal blog. %front is the front page.", array('%blog' => 'blog', '%blog-wildcard' => 'blog/*', '%front' => '');
$form[] = array('#value' => $properties_image);
$form[] = array('#value' => ' '. t('Size') .': '. strtr('@widthx@height px', array('@width' => $image_info['width'], '@height' => $image_info['height'])) .' | ');
// Image node properties fieldset.
$form['properties'] = array('#type' => 'fieldset', '#title' => t('Image properties'));
$form['properties'][] = array('#value' => ''); $token_installed = module_exists('token'); if (variable_get('img_assist_load_title', 1)) { $title = img_assist_sanitize($token_installed ? token_replace(variable_get('img_assist_title_pattern', '[title]'), 'node', $node) : $node->title); } if (variable_get('img_assist_load_description', 1)) { $description = img_assist_sanitize($token_installed ? token_replace(variable_get('img_assist_description_pattern', '[body]'), 'node', $node) : $node->body); } $form['title'] = array( '#type' => 'textfield', '#title' => t('Title (optional)'), '#default_value' => isset($title) ? $title : '', '#size' => 50, '#maxlength' => 255, '#description' => NULL, '#attributes' => array('onblur' => 'parent.updateCaption()'), ); $form['desc'] = array( '#type' => 'textfield', '#title' => t('Description (optional)'), '#default_value' => isset($description) ? $description : '', '#size' => 50, '#maxlength' => 255, '#description' => NULL, '#attributes' => array('onblur' => 'parent.updateCaption()'), ); // Size. $form[] = array('#value' => ' | |
');
$form[] = array('#value' => ' ');
$form[] = array('#value' => '');
$form['size_label'] = array(
'#type' => 'select',
'#default_value' => variable_get('img_assist_default_label', '100x100'),
'#options' => $derivatives,
'#attributes' => array('onchange' => 'parent.onChangeSizeLabel()'),
);
$form[] = array('#value' => ' ');
$form[] = array('#value' => '');
$form['width'] = array(
'#type' => 'textfield',
'#default_value' => $default_width,
'#size' => 4,
'#maxlength' => 4,
'#attributes' => array('onblur' => 'parent.onChangeWidth()'),
);
$form[] = array('#value' => ' x ');
$form['height'] = array(
'#type' => 'textfield',
'#default_value' => $default_height,
'#size' => 4,
'#maxlength' => 4,
'#attributes' => array('onblur' => 'parent.onChangeHeight()'),
);
$form[] = array('#value' => ' | ');
// Alignment.
$form['align'] = array(
'#type' => 'select',
'#title' => t('Alignment'),
'#default_value' => variable_get('img_assist_default_alignment', 'left'),
'#options' => array('left' => t('left'), 'right' => t('right'), 'none' => t('none'), 'center' => t('center')),
'#prefix' => ' ',
'#suffix' => ' ',
);
$form[] = array('#value' => ' | |
');
// Link.
if (user_access('access advanced options')) {
$form[] = array('#value' => ' ');
$form['link'] = array(
'#type' => 'select',
'#title' => t('Link'),
'#default_value' => variable_get('img_assist_default_link_behavior', 'none'),
'#options' => array('none' => t('Not a link'), 'node' => t('Link to image page'), 'popup' => t('Open in popup window'), 'url' => t('Go to URL')),
'#attributes' => array('onchange' => 'parent.onChangeLink()'),
);
$form['url'] = array(
'#type' => 'textfield',
'#default_value' => variable_get('img_assist_default_link_url', 'http://'),
'#size' => 25,
'#maxlength' => 255,
'#description' => NULL,
);
$form['link_options_visible'] = array(
'#type' => 'hidden',
'#value' => 1,
);
$form[] = array('#value' => ' ');
}
else {
$form['link'] = array(
'#type' => 'hidden',
'#value' => variable_get('img_assist_default_link_behavior', 'none'),
);
$form['url'] = array(
'#type' => 'hidden',
'#value' => variable_get('img_assist_default_link_url', 'http://'),
);
$form['link_options_visible'] = array(
'#type' => 'hidden',
'#value' => 0,
);
}
// Default link url is needed for JS to indicate if an url has been entered.
$form['default_url'] = array(
'#type' => 'hidden',
'#value' => variable_get('img_assist_default_link_url', 'http://'),
);
// Insert Mode (HTML or Filter Tag).
if (user_access('access advanced options')) {
$form[] = array('#value' => '');
$form['insertmode'] = array(
'#type' => 'select',
'#title' => t('Insert mode'),
'#default_value' => variable_get('img_assist_default_insert_mode', 'filtertag'),
'#options' => array('filtertag' => t('Filter Tag'), 'html' => t('HTML Code')),
);
$form[] = array('#value' => ' ');
}
else {
$form['insertmode'] = array(
'#type' => 'hidden',
'#value' => variable_get('img_assist_default_insert_mode', 'filtertag'),
);
}
// Hidden Fields.
$form['nid'] = array(
'#type' => 'hidden',
'#value' => $node->nid,
);
$form['update'] = array(
'#type' => 'hidden',
'#value' => $update,
);
$form['aspect'] = array(
'#type' => 'hidden',
'#value' => $aspect_ratio,
);
// Buttons.
$form['buttons'] = array(
'#prefix' => ' ',
);
$form['#attributes']['onsubmit'] = 'return parent.insertImage();';
$form['buttons']['insert'] = array(
'#type' => 'submit',
'#value' => ($update) ? t('Update') : t('Insert'),
'#attributes' => array('style' => 'float: left;'),
);
$form['buttons']['cancel'] = array(
'#type' => 'button',
'#value' => t('Cancel'),
'#button_type' => 'button',
'#attributes' => array('onclick' => 'return parent.cancelAction();', 'style' => 'float: right;'),
);
$form[] = array('#value' => ' |