t('PageEar'), 'description' => t('Add a peel away ad (magic corner, peelad) to your website.'), 'page callback' => 'drupal_get_form', 'page arguments' => array('pageear_settings'), 'access arguments' => array('administer site configuration'), ); return $items; } function pageear_init() { $settings = variable_get('pageear_settings', array()); if (variable_get('pageear_state', FALSE) && count($settings)) { $conditions = variable_get('pageear_conditions', array()); if (module_exists('condition') && count($conditions)) { if (!condition_selection_validate($conditions)) { return; } } drupal_add_js(drupal_get_path('module', 'pageear').'/pageear/AC_OETags.js'); drupal_add_js(drupal_get_path('module', 'pageear').'/pageear/pageear.js'); $js = ''; foreach ($settings as $name => $setting) { $js .= "var ".$name." = ".drupal_to_js(is_numeric($setting) ? (float) $setting : $setting).";\n"; } $js .= "var pagearSmallSwf = '".base_path().drupal_get_path('module', 'pageear')."/pageear/pageear_s.swf';\n"; $js .= "var pagearBigSwf = '".base_path().drupal_get_path('module', 'pageear')."/pageear/pageear_b.swf';\n"; $js .= "var queryParams = 'pagearSmallImg='+escape(pagearSmallImg);\n"; $js .= "queryParams += '&pagearBigImg='+escape(pagearBigImg);\n"; $js .= "queryParams += '&pageearColor='+pageearColor;\n"; $js .= "queryParams += '&jumpTo='+escape(jumpTo);\n"; $js .= "queryParams += '&openLink='+escape(openLink);\n"; $js .= "queryParams += '&mirror='+escape(mirror);\n"; $js .= "queryParams += '©right='+escape(copyright);\n"; $js .= "queryParams += '&speedSmall='+escape(speedSmall);\n"; $js .= "queryParams += '&openOnLoad='+escape(openOnLoad);\n"; $js .= "queryParams += '&closeOnLoad='+escape(closeOnLoad);\n"; $js .= "queryParams += '&setDirection='+escape(setDirection);\n"; $js .= "queryParams += '&softFadeIn='+escape(softFadeIn);\n"; $js .= "writeObjects();\n"; drupal_add_js($js, 'inline'); } } function pageear_help($path, $arg) { switch ($path) { case 'admin/settings/pageear': return '

'. t('Install the !condition module to add additional conditions for displaying the PageEar. On this page you can set all PageEar variables. For a test-drive, just submit the default values. This module is a Drupal implementation of the excellent !pageear by WebPicasso Media.', array('!pageear' => l(t('PageEar'), 'http://www.webpicasso.de/blog/kostenloses-pagepeel/'), '!condition' => l(t('Condition'), 'http://drupal.org/project/condition'))).'

'; } } function pageear_settings() { $settings = variable_get('pageear_settings', array()); $form['#attributes'] = array('enctype' => "multipart/form-data"); // On / Off $form['pageear_state'] = array( '#type' => 'checkbox', '#title' => t('Enable PageEar'), '#default_value' => variable_get('pageear_state', FALSE), ); // Conditions if (module_exists('condition')) { $form_conditions = module_invoke('condition', 'selection_form', variable_get('pageear_conditions', array())); $form['pageear_conditions'] = $form_conditions['conditions']; } $form['pageear_settings'] = array( '#type' => 'fieldset', '#title' => t('Settings'), '#tree' => TRUE, '#collapsible' => TRUE, '#collapsed' => FALSE, ); // URL to small image $form['pageear_settings']['pagearSmallImg'] = array( '#type' => 'textfield', '#title' => t('Unpeeled image'), '#description' => t('URL of image to show when the ad is not peeled (100x100 pixels).'), '#required' => TRUE, '#default_value' => $settings['pagearSmallImg'] ? $settings['pagearSmallImg'] : base_path().drupal_get_path('module', 'pageear').'/pageear/pageear_s.jpg', ); $form['pageear_settings']['pagearSmallImg_upload'] = array( '#type' => 'file', '#description' => t('Upload an image to show when the ad is not peeled.'), '#tree' => FALSE, ); // URL to big image $form['pageear_settings']['pagearBigImg'] = array( '#type' => 'textfield', '#title' => t('Peeled image'), '#description' => t('URL of the image to show when the ad is peeled (500x500 pixels).'), '#required' => TRUE, '#default_value' => $settings['pagearBigImg'] ? $settings['pagearBigImg'] : base_path().drupal_get_path('module', 'pageear').'/pageear/pageear_b.jpg', ); $form['pageear_settings']['pagearBigImg_upload'] = array( '#type' => 'file', '#description' => t('Upload an image to show when the ad is peeled.'), '#tree' => FALSE, ); // Movement speed of small pageear 1-4 (2=Standard) $form['pageear_settings']['speedSmall'] = array( '#type' => 'select', '#title' => t('Motion speed'), '#description' => t('Speed for the motion in the unpeeled state.'), '#options' => array( 1 => t('1 (slow)'), 2 => t('2 (default)'), 3 => t('3 (faster)'), 4 => t('4 (fastest)'), ), '#default_value' => $settings['speedSmall'] ? $settings['speedSmall'] : 2, '#required' => TRUE, ); // Mirror image ( true | false ) $form['pageear_settings']['mirror'] = array( '#type' => 'select', '#title' => t('Back mirror'), '#description' => t('Mirror the ad on the back of the peeled page.'), '#options' => array( 'true' => t('Enabled'), 'false' => t('Disabled'), ), '#default_value' => $settings['mirror'] ? $settings['mirror'] : 'true', '#required' => TRUE, ); // Color of pagecorner if mirror is false $form['pageear_settings']['pageearColor'] = array( '#type' => 'textfield', '#title' => t('Back color'), '#description' => t('If the mirror effect is disabled, this color will be used on the back.'), '#required' => TRUE, '#default_value' => $settings['pageearColor'] ? $settings['pageearColor'] : 'FFFFFF', ); // URL to open on pageear click $form['pageear_settings']['jumpTo'] = array( '#type' => 'textfield', '#title' => t('URL'), '#description' => t('URL to go to when clicked on the ad.'), '#required' => TRUE, '#default_value' => $settings['jumpTo'] ? $settings['jumpTo'] : 'http://www.webpicasso.de/blog/', ); // Browser target (new) or self (self) $form['pageear_settings']['openLink'] = array( '#type' => 'select', '#title' => t('URL target'), '#description' => t('How to open the URL.'), '#options' => array( 'self' => t('Same window'), 'new' => t('New window'), ), '#default_value' => $settings['openLink'] ? $settings['openLink'] : 'self', '#required' => TRUE, ); // Opens pageear automaticly (false:deactivated | 0.1 - X seconds to open) $form['pageear_settings']['openOnLoad'] = array( '#type' => 'select', '#title' => t('Automaticly peel on load'), '#description' => t('Unpeel automaticly when the page loads.'), '#options' => array( '' => t('(disabled)'), 0.1 => t('After 0.1 second'), 1 => t('After 1 second'), 3 => t('After 3 seconds'), 5 => t('After 5 seconds'), 10 => t('After 10 seconds'), ), '#default_value' => $settings['openOnLoad'] ? $settings['openOnLoad'] : '', ); // Second until pageear close after openOnLoad $form['pageear_settings']['closeOnLoad'] = array( '#type' => 'select', '#title' => t('Automaticly unpeel'), '#description' => t('Automaticly close after unpeeling.'), '#options' => array( '' => t('(disabled)'), 0.1 => t('After 0.1 second'), 1 => t('After 1 second'), 3 => t('After 3 seconds'), 5 => t('After 5 seconds'), 10 => t('After 10 seconds'), ), '#default_value' => $settings['closeOnLoad'] ? $settings['closeOnLoad'] : '', ); // Set direction of pageear in left or right top browser corner (lt: left | rt: right ) $form['pageear_settings']['setDirection'] = array( '#type' => 'select', '#title' => t('Corner'), '#description' => t('In what corner the ad will be displayed.'), '#options' => array( 'rt' => t('Top right'), 'lt' => t('Top left'), ), '#default_value' => $settings['setDirection'] ? $settings['setDirection'] : 'rt', '#required' => TRUE, ); // Fade in pageear if image completly loaded (0-5: 0=off, 1=slow, 5=fast ) $form['pageear_settings']['softFadeIn'] = array( '#type' => 'select', '#title' => t('Fade in'), '#description' => t('Fade in the peel ad once the image is loaded.'), '#options' => array( 0 => t('(disabled)'), 1 => t('Slow'), 5 => t('Fast'), ), '#default_value' => $settings['softFadeIn'] ? $settings['softFadeIn'] : 5, '#required' => TRUE, ); $form['#submit'][] = 'pageear_settings_submit'; return system_settings_form($form); } function pageear_settings_validate($form, &$form_state) { $directory_path = file_directory_path().'/pageear'; file_check_directory($directory_path, FILE_CREATE_DIRECTORY, 'file_directory_path'); foreach(array('pagearBigImg', 'pagearSmallImg') as $image) { if ($file = file_save_upload($image.'_upload', array('file_validate_is_image' => array()))) { $parts = pathinfo($file->filename); $filename = $directory_path.'/'.$image.'.'.$parts['extension']; if (file_copy($file, $filename, FILE_EXISTS_REPLACE)) { $form_state['values']['pageear_settings'][$image] = $file->filepath; } } } } function pageear_settings_submit($form, &$form_state) { if (!is_numeric($form_state['values']['pageear_settings']['openOnLoad'])) { $form_state['values']['pageear_settings']['openOnLoad'] = FALSE; } if (!is_numeric($form_state['values']['pageear_settings']['closeOnLoad'])) { $form_state['values']['pageear_settings']['closeOnLoad'] = FALSE; } $form_state['values']['pageear_settings']['pagearSmallImg'] = url($form_state['values']['pageear_settings']['pagearSmallImg'], array('absolute' => TRUE)); $form_state['values']['pageear_settings']['pagearBigImg'] = url($form_state['values']['pageear_settings']['pagearBigImg'], array('absolute' => TRUE)); } ?>