/[drupal]/contributions/modules/iedestroyer/iedestroyer.module
ViewVC logotype

Diff of /contributions/modules/iedestroyer/iedestroyer.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.6.2.19, Tue Jun 17 14:58:22 2008 UTC revision 1.6.2.20, Thu Jun 26 21:47:36 2008 UTC
# Line 4  Line 4 
4   */   */
5  define('IEDESTROYER_SEVERITY_DISABLED', 1);  define('IEDESTROYER_SEVERITY_DISABLED', 1);
6  define('IEDESTROYER_SEVERITY_BAR', 2);  define('IEDESTROYER_SEVERITY_BAR', 2);
7  define('IEDESTROYER_SEVERITY_BLOCK', 3);  define('IEDESTROYER_SEVERITY_BILLBOARD', 3);
8  define('IEDESTROYER_PERSISTENCE_ONCE', 1);  define('IEDESTROYER_PERSISTENCE_ONCE', 1);
9  define('IEDESTROYER_PERSISTENCE_ALWAYS', 2);  define('IEDESTROYER_PERSISTENCE_ALWAYS', 2);
10  define('IEDESTROYER_PERSISTENCE_FORCE', 3);  define('IEDESTROYER_PERSISTENCE_FORCE', 3);
# Line 22  function iedestroyer_help($section) { Line 22  function iedestroyer_help($section) {
22        break;        break;
23      case 'admin/help#iedestroyer':      case 'admin/help#iedestroyer':
24        $code_bar = nl2br(highlight_string("<?php\nif (module_exists('iedestroyer')) echo iedestroyer_view_bar();\n?>", TRUE));        $code_bar = nl2br(highlight_string("<?php\nif (module_exists('iedestroyer')) echo iedestroyer_view_bar();\n?>", TRUE));
25        $code_block = nl2br(highlight_string("<?php\nif (module_exists('iedestroyer')) echo iedestroyer_view_bar();\n?>", TRUE));        $code_billboard = nl2br(highlight_string("<?php\nif (module_exists('iedestroyer')) echo iedestroyer_view_bar();\n?>", TRUE));
26        return t('In order to show the <abbr title="Internet Explorer">IE</abbr> Destroyer to IE users you have to add some code to your template. If you would like to display the bar (which will be displayed over your page\'s contents) insert the following code directly after the &lt;body> tag: <code>!code_bar</code> If you want to display the entire block you may insert the following code in your template exactly where you want the message to appear: <code>!code_block</code> To be safe you may want to insert both pieces of code into your template. IE Destroyer will only be viewed once. The way it will be displayed depends on your settings.', array('!code_bar' => $code_bar, '!code_block' => $code_block));        return t('In order to show the <abbr title="Internet Explorer">IE</abbr> Destroyer to IE users you have to add some code to your template. If you would like to display the bar (which will be displayed over your page\'s contents) insert the following code directly after the &lt;body> tag: <code>!code_bar</code> If you want to display the entire billboard you may insert the following code in your template exactly where you want the message to appear: <code>!code_billboard</code> To be safe you may want to insert both pieces of code into your template. IE Destroyer will only be viewed once. The way it will be displayed depends on your settings.', array('!code_bar' => $code_bar, '!code_billboard' => $code_billboard));
27    }    }
28  }  }
29    
# Line 114  function iedestroyer_admin() { Line 114  function iedestroyer_admin() {
114      '#title' => t('Severity'),      '#title' => t('Severity'),
115      '#default_value' => variable_get('iedestroyer_severity', IEDESTROYER_SEVERITY_DISABLED),      '#default_value' => variable_get('iedestroyer_severity', IEDESTROYER_SEVERITY_DISABLED),
116      '#options' => array(      '#options' => array(
117        IEDESTROYER_SEVERITY_DISABLED => t('Disable IE Destroyer'),        IEDESTROYER_SEVERITY_DISABLED => t('Disabled'),
118        IEDESTROYER_SEVERITY_BAR => t('Show bar'),        IEDESTROYER_SEVERITY_BAR => t('Bar'),
119        IEDESTROYER_SEVERITY_BLOCK => t('Show block'),        IEDESTROYER_SEVERITY_BILLBOARD => t('Billboard'),
120      ),      ),
121    );    );
122    
# Line 161  function iedestroyer_admin() { Line 161  function iedestroyer_admin() {
161      '#type' => 'textarea',      '#type' => 'textarea',
162      '#title' => t('Banner'),      '#title' => t('Banner'),
163      '#default_value' => variable_get('iedestroyer_banner', NULL),      '#default_value' => variable_get('iedestroyer_banner', NULL),
164      '#description' => t('If you want to display a banner or just a logo next to the block message you can insert the code for this banner here.'),      '#description' => t('If you want to display a banner or just a logo next to the billboard message you can insert the code for this banner here.'),
165    );    );
166    
167    $form['iedestroyer_page'] = array(    $form['iedestroyer_page'] = array(
# Line 202  function iedestroyer_admin() { Line 202  function iedestroyer_admin() {
202      '#collapsed' => TRUE,      '#collapsed' => TRUE,
203    );    );
204    
205    $form['iedestroyer_block_message'] = array(    $form['iedestroyer_billboard_message'] = array(
206      '#type' => 'fieldset',      '#type' => 'fieldset',
207      '#title' => t('Block message'),      '#title' => t('Billboard message'),
208      '#description' => t('This is the message displayed in the IE Destroyer block. It may be longer than the bar message and provide the user with reasons for switching. <em>!browser</em> and <em>!url</em> will be replaced by the name and download link of the browser you want to promote.'),      '#description' => t('This is the message displayed in the IE Destroyer billboard. It may be longer than the bar message and provide the user with reasons for switching. <em>!browser</em> and <em>!url</em> will be replaced by the name and download link of the browser you want to promote.'),
209      '#collapsible' => TRUE,      '#collapsible' => TRUE,
210      '#collapsed' => TRUE,      '#collapsed' => TRUE,
211    );    );
# Line 219  function iedestroyer_admin() { Line 219  function iedestroyer_admin() {
219      '#default_value' => variable_get($id_bar, _iedestroyer_default_message(IEDESTROYER_SEVERITY_BAR)),      '#default_value' => variable_get($id_bar, _iedestroyer_default_message(IEDESTROYER_SEVERITY_BAR)),
220      );      );
221    
222      $id_block = 'iedestroyer_message_' . IEDESTROYER_SEVERITY_BLOCK . $locale;      $id_billboard = 'iedestroyer_message_' . IEDESTROYER_SEVERITY_BILLBOARD . $locale;
223      $form['iedestroyer_block_message'][$id_block] = array(      $form['iedestroyer_billboard_message'][$id_billboard] = array(
224      '#type' => 'textarea',      '#type' => 'textarea',
225      '#title' => $name,      '#title' => $name,
226      '#default_value' => variable_get($id_block, _iedestroyer_default_message(IEDESTROYER_SEVERITY_BLOCK)),      '#default_value' => variable_get($id_billboard, _iedestroyer_default_message(IEDESTROYER_SEVERITY_BILLBOARD)),
227      );      );
228    }    }
229    
# Line 254  function iedestroyer_view_bar() { Line 254  function iedestroyer_view_bar() {
254  }  }
255    
256  /**  /**
257   * Display the IE Destroyer block   * Display the IE Destroyer billboard
258   *   *
259   * @return string   * @return string
260   */   */
261  function iedestroyer_view_block() {  function iedestroyer_view_billboard() {
262    return iedestroyer_view(IEDESTROYER_SEVERITY_BLOCK);    return iedestroyer_view(IEDESTROYER_SEVERITY_BILLBOARD);
263  }  }
264    
265  /**  /**
266   * View IE Destroyer   * View IE Destroyer
267   *   *
268   * @param $severity constant IEDESTROYER_SEVERITY_BAR or IEDESTROYER_SEVERITY_BLOCK   * @param $severity constant IEDESTROYER_SEVERITY_BAR or IEDESTROYER_SEVERITY_BILLBOARD
269   *   *
270   * @return string   * @return string
271   */   */
# Line 276  function iedestroyer_view($severity) { Line 276  function iedestroyer_view($severity) {
276          $browser = iedestroyer_browser_load();          $browser = iedestroyer_browser_load();
277      $message = t(variable_get('iedestroyer_message_' . $severity . $locale, _iedestroyer_default_message($severity)), array('!browser' => $browser['name'], '!url' => $browser['url']));      $message = t(variable_get('iedestroyer_message_' . $severity . $locale, _iedestroyer_default_message($severity)), array('!browser' => $browser['name'], '!url' => $browser['url']));
278      $banner = NULL;      $banner = NULL;
279      if ($severity == IEDESTROYER_SEVERITY_BLOCK) {      if ($severity == IEDESTROYER_SEVERITY_BILLBOARD) {
280        $banner = variable_get('iedestroyer_banner', NULL);        $banner = variable_get('iedestroyer_banner', NULL);
281        $theme = 'block';        $theme = 'billboard';
282      }      }
283      else if ($severity == IEDESTROYER_SEVERITY_BAR) {      else if ($severity == IEDESTROYER_SEVERITY_BAR) {
284        $theme = 'bar';        $theme = 'bar';
# Line 316  function theme_iedestroyer_bar($message, Line 316  function theme_iedestroyer_bar($message,
316  }  }
317    
318  /**  /**
319   * Theme a IE Destroyer block   * Theme a IE Destroyer billboard
320   *   *
321   * @param $message string The message to show the user   * @param $message string The message to show the user
322   * @param $button string The button on which users may click to hide IE Destroyer   * @param $button string The button on which users may click to hide IE Destroyer
# Line 324  function theme_iedestroyer_bar($message, Line 324  function theme_iedestroyer_bar($message,
324   *   *
325   * @return string   * @return string
326   */   */
327  function theme_iedestroyer_block($message, $button, $banner) {  function theme_iedestroyer_billboard($message, $button, $banner) {
328    return '<div id="iedestroyer_block" class="iedestroyer">' . '<div class="message">' . $message . '</div>' . '<div class="banner">' . $banner . '</div><span></span>' . $button . '</div>';    return '<div id="iedestroyer_billboard" class="iedestroyer">' . '<div class="message">' . $message . '</div>' . '<div class="banner">' . $banner . '</div><span></span>' . $button . '</div>';
329  }  }
330    
331  /**  /**
# Line 410  function _iedestroyer_should_display_pag Line 410  function _iedestroyer_should_display_pag
410  /**  /**
411   * The default message to present to the user   * The default message to present to the user
412   *   *
413   * @param $type constant IEDESTROYER_SEVERITY_BAR or IEDESTROYER_SEVERITY_BLOCK, depending   * @param $type constant IEDESTROYER_SEVERITY_BAR or IEDESTROYER_SEVERITY_BILLBOARD, depending
414   * on whether to return the message for the IE Destroyer bar or the block   * on whether to return the message for the IE Destroyer bar or the billboard
415   *   *
416   * @return string   * @return string
417   */   */
418  function _iedestroyer_default_message($type) {  function _iedestroyer_default_message($type) {
419    switch ($type) {    switch ($type) {
420      case IEDESTROYER_SEVERITY_BAR:      case IEDESTROYER_SEVERITY_BAR:
421        return t('We see you\'re using Internet Explorer and strongly suggest <a href="!url">downloading !browser</a>. We think you\'ll like it better');        return t('We see you\'re using Internet Explorer and strongly suggest <a href="!url">downloading !browser</a>. We think you\'ll like it better.');
422      case IEDESTROYER_SEVERITY_BLOCK:      case IEDESTROYER_SEVERITY_BILLBOARD:
423        return t('<strong>We see you\'re using Internet Explorer and strongly suggest downloading !browser. We think you\'ll like it better:</strong>        return t('<strong>We see you\'re using Internet Explorer and strongly suggest downloading !browser. We think you\'ll like it better:</strong>
424  <ul>  <ul>
425    <li>!browser protects you from viruses, spyware, and pop-ups.</li>    <li>!browser protects you from viruses, spyware, and pop-ups.</li>

Legend:
Removed from v.1.6.2.19  
changed lines
  Added in v.1.6.2.20

  ViewVC Help
Powered by ViewVC 1.1.2