function scanner_view

cis7 scanner.module scanner_view()
cle7 scanner.module scanner_view()
elmsmedia7 scanner.module scanner_view()
icor7 scanner.module scanner_view()
meedjum_blog7 scanner.module scanner_view()
mooc7 scanner.module scanner_view()

Menu callback; presents the scan form and results.

1 string reference to 'scanner_view'
scanner_menu in sites/all/modules/ulmus/scanner/scanner.module
Implements hook_menu().

File

sites/all/modules/ulmus/scanner/scanner.module, line 166
Search and Replace Scanner - works on all nodes text content.

Code

function scanner_view() {

  $output = '';

  //using set_html_head because it seems unecessary to load a separate css
  // file for just two simple declarations:
  drupal_add_css('
      #scanner-form .form-submit { margin-top:0; }
      #scanner-form .form-item { margin-bottom:0; }
    ', array('type' => 'inline'));

  //javascript checks to make sure user has entered some search text:
  drupal_add_js("
    $(document).ready(function() {
      $('input[@type=submit][@value=Search]').click(function() {
        var searchfield = $('#edit-search');
        var chars = searchfield.val().length;
        if (chars == 0) {
          alert('Please provide some search text and try again.');
          searchfield.addClass('error');
          searchfield[0].focus();
          return FALSE;
        } else if (chars < 3) {
          return confirm('Searching for a keyword that has fewer than three characters could take a long time. Are you sure you want to continue?');
        }
        return TRUE;
      });
    });
  ", array('type' => 'inline', 'scope' => JS_DEFAULT));

  if (isset($_SESSION['scanner_search'])) {
    $search = $_SESSION['scanner_search'];
  }
  else {
    $search = NULL;
  }

  if (isset($_SESSION['scanner_status'])) {
    $status = $_SESSION['scanner_status'];
  }
  else {
    $status = NULL;
  }

  if (!is_NULL($search) && $status >= SCANNER_STATUS_GO_SEARCH) {

    if ($status == SCANNER_STATUS_GO_CONFIRM) {
      drupal_goto('admin/content/scanner/scan/confirm');

    }
    elseif ($status == SCANNER_STATUS_GO_REPLACE) {
      $resulttxt = '<a name="results"></a>' . t('Replacement Results');
      $results = scanner_execute('replace');

    }
    else {
      $resulttxt = t('Search Results');
      $results = scanner_execute('search');
    }

    if ($results) {
      // TODO Please change this theme call to use an associative array for the $variables parameter.
      $results = '<a name="results"></a><div><h2>' . $resulttxt . '</h2>' . $results;
    }
    else {
      // TODO Please change this theme call to use an associative array for the $variables parameter.
      $results = t('Your search yielded no results.');
    }
    $scanner_form = drupal_get_form('scanner_form');
    $output = drupal_render($scanner_form);
    $output .= $results;

    //clear any old search form input:
    unset($_SESSION['scanner_search']);
    unset($_SESSION['scanner_replace']);
    unset($_SESSION['scanner_preceded']);
    unset($_SESSION['scanner_followed']);
    unset($_SESSION['scanner_mode']);
    unset($_SESSION['scanner_wholeword']);
    unset($_SESSION['scanner_published']);
    unset($_SESSION['scanner_regex']);
    unset($_SESSION['scanner_terms']);
    //clear old status:
    unset($_SESSION['scanner_status']);

    return $output;
  }
  $scanner_form = drupal_get_form('scanner_form');
  $output = drupal_render($scanner_form);

  return $output;
}
Error | ELMSLN API

Error

×

Error message

  • Warning: Cannot modify header information - headers already sent by (output started at /var/www/html/elmsln_community/api.elmsln.org/includes/common.inc:2791) in drupal_send_headers() (line 1499 of /var/www/html/elmsln_community/api.elmsln.org/includes/bootstrap.inc).
  • Error: Call to undefined function apc_delete() in DrupalAPCCache->clear() (line 289 of /var/www/html/elmsln_community/api.elmsln.org/sites/all/modules/apc/drupal_apc_cache.inc).
The website encountered an unexpected error. Please try again later.