'textfield', '#title' => t('image field name'), '#default_value' => variable_get('jcarousel_block_imagefield_name', ''), '#description' => t('The block with read the images from the field name inputted here and display them as the jcarousel sideshow. This field cannot be empty. It can be any type of cck image fields, e.g. imceimage, imagefield, filefield, etc. Currently only imceimage and imagefield supported.'), '#required' => TRUE, ); $form['jcarousel_block_imagefield_type'] = array( // '#type' => 'textfield', // '#title' => t('image field type'), // '#default_value' => variable_get('jcarousel_block_imagefield_type', 'imceimage'), // '#description' => t('Put the cck image field type here, so the module knows how to setup the image path, width, height, etc., as the names of the fields can be different for imagefield, fieldfield, imcefield or any other. \'imceimage\' by default, '), // '#required' => TRUE, '#type' => 'radios', '#title' => t('image source type'), '#default_value' => variable_get('jcarousel_block_imagefield_type', 'imceimage'), '#description' => t("Put the cck image field type here, so the module knows how to setup the image path, width, height, etc., as the names of the fields can be different for imagefield, fieldfield, imcefield or any other. 'imceimage' by default. "), '#options' => array('imceimage' => 'imceimage', 'imagefield' => 'imagefield', 'directoryimage' => 'directoryimage'), '#required' => TRUE, ); $form['imceimage'] = array( '#type' => 'fieldset', '#title' => t('imceimage specific settings'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#description' => t('The settings here only take effect when using imceimage as the field type.'), ); $form['imceimage']['jcarousel_block_imagefield_imce_prefix'] = array( '#type' => 'textfield', '#title' => t('imceimage thumbnail prefix'), '#default_value' => variable_get('jcarousel_block_imagefield_imce_prefix', 'thumb_'), '#description' => t('The prefix set in imce profile, which used to generate the thumbnail.'), ); $form['imagefield'] = array( '#type' => 'fieldset', '#title' => t('imagefield specific settings'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#description' => t('The settings here only take effect when using imagefield as the field type. Currently no specific settings for imagefield.'), ); $form['directoryimage'] = array( '#type' => 'fieldset', '#title' => t('directoryimage option specific settings'), '#collapsible' => TRUE, '#collapsed' => FALSE, '#description' => t('The settings here only take effect when the directoryimage option is selected. It will then use images from directories instead of reading from CCK.'), ); $form['directoryimage']['jcarousel_block_directoryimage_directory'] = array( '#type' => 'textfield', '#title' => t('image directory pattern'), '#default_value' => variable_get('jcarousel_block_directoryimage_directory', '/pictures/$nid'), '#description' => t('Put the the directory pattern here. Should be something like /pictures/$nid. $nid is the only possible variable.'), ); $form['directoryimage']['jcarousel_block_directoryimage_prefix'] = array( '#type' => 'textfield', '#title' => t('thumbnail prefix for images in the directory'), '#default_value' => variable_get('jcarousel_block_directoryimage_prefix', 'thumb_'), '#description' => t('The prefix used for getting the thumbnails.'), ); $form['jcarousel_block_image_rel'] = array( '#type' => 'textfield', '#title' => t('rel'), '#default_value' => variable_get('jcarousel_block_image_rel', 'lightbox[mygroup]'), '#description' => t("Put 'lightbox' here to enable lightbox, or you may enter the name for another effect."), ); //we don't want the user to change the jcarousel_block_block_list_title //so no form for that. $form['jcarousel_block_block_title'] = array( '#type' => 'textfield', '#title' => t('default jcarousel block title'), '#default_value' => variable_get('jcarousel_block_block_title', t('jcarousel block')), '#description' => t('The default jcarousel block title.'), ); $form['jcarousel_block_skin'] = array( '#type' => 'textfield', '#title' => t('skin to use'), '#default_value' => variable_get('jcarousel_block_skin', 'ie7'), '#description' => t('The jcarousel skin to use.'), ); return system_settings_form($form); } /** * Implementation of hook_menu(). */ function jcarousel_block_menu() { $items = array(); $items['admin/settings/jcarousel_block'] = array( 'title' => 'jCarousel Block', 'description' => 'Configurable settings for the jcarousel block module.', 'page callback' => 'drupal_get_form', 'page arguments' => array('jcarousel_block_admin'), 'access arguments' => array('access administration pages'), 'type' => MENU_NORMAL_ITEM, ); return $items; } /** * Implementation of hook_block(). */ function jcarousel_block_block($op = 'list', $delta = 0, $edit = array()) { $blocks = array(); if ($op == 'view') { // load the node if it's in a node page $field = check_plain(variable_get('jcarousel_block_imagefield_name', '')); if (!$field) { $blocks['subject'] = variable_get('jcarousel_block_block_title', t('mycarousel')); $blocks['content'] = t("Imagefield is not set. Please do the setup at admin/settings/jcarousel_block"); return $blocks; } if (arg(0) == 'node' && is_numeric(arg(1)) && ! arg(2)) { //$is_node = true; $imagefield_type = variable_get('jcarousel_block_imagefield_type', 'imceimage'); module_load_include('inc', 'jcarousel_block', "includes/$imagefield_type"); if (jcarousel_block_image_exists(arg(1))) { $blocks['subject'] = variable_get('jcarousel_block_block_title', t('mycarousel')); $blocks['content'] = theme('jcarousel_block_block'); } else { //no image, do not show } } else{ //not visiting a node, do not show } return $blocks; } elseif ($op == 'list') { //op defined by hook $blocks[0] = array( 'info' => variable_get('jcarousel_block_block_list_title', t('jcarousel block')), 'region' => 'content', 'status' => TRUE, 'weight' => 10, 'visibility' => 1, 'pages' => 'node/*', 'cache' => BLOCK_CACHE_PER_PAGE, ); return $blocks; } elseif ($op == 'configure') { $form = array(); // $form['skin'] = array( // '#type' => 'textfield', // '#title' => t('skin to use'), // '#default_value' => variable_get('jcarousel_block_skin', 'ie7'), // '#description' => t('The jcarousel skin to use.'), // ); return $form; } elseif ($op == 'save') { // variable_set('jcarousel_block_skin', $edit['skin']); return; } } /** * Implementation of hook_theme(). */ function jcarousel_block_theme() { return array( 'jcarousel_block_block' => array( 'template' => 'jcarousel_block_block', 'arguments' => array(), // 'preprocess functions' => array('jcarousel_block_preprocess_jcarousel_block_block'), ), ); } /* moduleName_preprocess_hook */ function jcarousel_block_preprocess_jcarousel_block_block(&$variables) { //print_r($variables); $variables['field'] = check_plain(variable_get('jcarousel_block_imagefield_name', '')); $variables['image_rel'] = check_plain(variable_get('jcarousel_block_image_rel', 'lightbox')); $variables['skin'] = check_plain(variable_get('jcarousel_block_skin', 'ie7')); $variables['images'] = array(); // load the node if it's in a node page if (arg(0) == 'node' && is_numeric(arg(1)) && ! arg(2)) { $variables['node'] = node_load(arg(1)); } else { return; } $imagefield_type = variable_get('jcarousel_block_imagefield_type', 'imceimage'); module_load_include('inc', 'jcarousel_block', "includes/$imagefield_type"); _jcarousel_block_preprocess_images($variables); }