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_theme(). */ function img_assist_theme() { return array( 'img_assist_inline' => array( 'arguments' => array('node' => NULL, 'size' => NULL, 'attributes' => NULL), ), 'img_assist_filter' => array( 'arguments' => array('text' => NULL), ), 'img_assist_popup' => array( 'arguments' => array('content' => NULL, 'attributes' => NULL), ), 'img_assist_page' => array( 'arguments' => array('content' => NULL, 'attributes' => NULL), ), 'img_assist_legacy' => array(), ); } /** * Implementation of hook_menu(). */ function img_assist_menu() { $items['img_assist/cache/clear'] = array( 'title' => 'Empty cache', 'page callback' => 'img_assist_cache_clear', 'access arguments' => array('administer site configuration'), 'type' => MENU_CALLBACK, ); $items['img_assist/load'] = array( 'title' => 'Image assist', 'page callback' => 'img_assist_loader', 'access arguments' => array('access img_assist'), 'type' => MENU_CALLBACK, ); // Page callbacks called internally by img_assist/load. $items['img_assist/header'] = array( 'title' => 'Image assist header', 'page callback' => 'img_assist_header', 'page arguments' => array(2), 'access arguments' => array('access img_assist'), 'type' => MENU_CALLBACK, ); $items['img_assist/thumbs'] = array( 'title' => 'Image assist thumbnails', 'page callback' => 'img_assist_thumbs', 'access arguments' => array('access img_assist'), 'type' => MENU_CALLBACK, ); $items['img_assist/upload'] = array( 'title' => 'Image assist upload', 'page callback' => 'img_assist_upload', 'access arguments' => array('access img_assist'), 'type' => MENU_CALLBACK, ); $items['img_assist/properties'] = array( 'title' => 'Image assist properties', 'page callback' => 'img_assist_properties', 'access arguments' => array('access img_assist'), 'type' => MENU_CALLBACK, ); // Popup images page. $items['img_assist/popup'] = array( 'title' => 'Popup image', 'page callback' => 'img_assist_popup', 'access arguments' => array('access content'), 'type' => MENU_CALLBACK, ); // Insert callback (only for inserting HTML, not filter tag). $items['img_assist/insert_html'] = array( 'title' => 'Insert callback', 'page callback' => 'img_assist_insert_html', 'access arguments' => array('access img_assist'), 'type' => MENU_CALLBACK, ); $items['admin/settings/img_assist'] = array( 'title' => 'Image assist', 'description' => 'Change settings for the Image assist module.', 'page callback' => 'drupal_get_form', 'page arguments' => array('img_assist_admin_settings'), 'access arguments' => array('administer site configuration'), ); return $items; } /** * Implementation of hook_init(). */ function img_assist_init() { $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'); } } } /** * 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' => 'img_assist_textarea' ); 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; 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' => ' |