You are here

function print_query_string_encode in Printer, email and PDF versions 5.x

Same name and namespace in other branches
  1. 5.4 print.module \print_query_string_encode()
  2. 5.3 print.module \print_query_string_encode()
  3. 6 print.module \print_query_string_encode()
  4. 7 print.module \print_query_string_encode()

Parse an array into a valid urlencoded query string. Modified from drupal_query_string_encode to prevent re-encoding of encoded original.

Parameters

$query: The array to be processed e.g. $_GET

$exclude: The array filled with keys to be excluded.

Return value

urlencoded string which can be appended to/as the URL query string

6 calls to print_query_string_encode()
print_insert_link in ./print.module
Auxiliary function to display a formatted Printer-friendly link
print_link in ./print.module
Implementation of hook_link().
print_mail_insert_link in print_mail/print_mail.module
Auxiliary function to display a formatted send by e-mail link
print_mail_link in print_mail/print_mail.module
Implementation of hook_link().
print_pdf_insert_link in print_pdf/print_pdf.module
Auxiliary function to display a formatted PDF version link

... See full list

File

./print.module, line 860
Displays Printer-friendly versions of Drupal pages.

Code

function print_query_string_encode($query, $exclude = array(), $parent = '') {
  $params = array();
  foreach ($query as $key => $value) {
    if ($parent) {
      $key = $parent . '[' . $key . ']';
    }
    if (in_array($key, $exclude)) {
      continue;
    }
    if (is_array($value)) {
      $params[] = print_query_string_encode($value, $exclude, $key);
    }
    else {
      $params[] = $key . '=' . rawurlencode($value);
    }
  }
  return implode('&', $params);
}