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'), 'access' => $ia_access, 'type' => MENU_CALLBACK, 'callback' => 'img_assist_insert_html', ); $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 { $path = drupal_get_path('module', 'img_assist'); if (variable_get('img_assist_page_styling', 'yes') == 'yes') { drupal_add_css($path .'/img_assist.css'); } // Assign base_path to insert in image source by javascript. drupal_add_js('var BASE_URL = "'. base_path() .'";', 'inline'); drupal_add_js($path .'/img_assist.js'); } 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 image link underneath textareas. */ function img_assist_textarea($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 (user_access('access img_assist')) { $output = theme('img_assist_textarea_link', $element, $link); $element['#suffix'] = (isset($element['#suffix']) ? $element['#suffix'] . $output : $output); } } } 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() { // 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' => ' | '); $form[] = array('#value' => ''); $form['title'] = array( '#type' => 'textfield', '#title' => t('Title (optional)'), '#default_value' => variable_get('img_assist_load_title', 1) ? $node->title : '', '#size' => 50, '#maxlength' => 255, '#description' => NULL, '#attributes' => array('onblur' => 'parent.updateCaption()'), ); $form['desc'] = array( '#type' => 'textfield', '#title' => t('Description (optional)'), '#default_value' => variable_get('img_assist_load_description', 1) ? $node->body : '', '#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[] = array('#value' => ' ');
$form[] = array('#value' => ' |