You are here

function _messaging_debug_format_object in Messaging 6.3

Same name and namespace in other branches
  1. 6.2 messaging_debug/messaging_debug.module \_messaging_debug_format_object()

Format objects/array in logs

1 call to _messaging_debug_format_object()
_messaging_debug_format_array in messaging_debug/messaging_debug.module
Format array

File

messaging_debug/messaging_debug.module, line 386
Simple messaging using html page. Messaging method plug-in

Code

function _messaging_debug_format_object($data, $name = '') {
  if (is_string($data) || is_numeric($data)) {

    // Make line endings visible
    return str_replace("\n", '\\n<br />', check_plain($data));
  }
  elseif (is_array($data)) {
    return _messaging_debug_format_array($data);
  }
  elseif (function_exists('kprint_r')) {
    return kprint_r($data, TRUE, $name);
  }
  else {
    return '<pre>' . print_r($value) . '</pre>';
  }

  /*
  $rows = array();
  $data = is_array($data) ? $data : (array)$data;
  foreach ($data as $key => $value) {
    if (is_object($value) || is_array($value)) {
      $content = _messaging_debug_format_object($value, $key);
    }
    elseif (is_string($value)) {
      // Make line endings visible
      $content = str_replace("\n", '\n<br />', check_plain($value));
    }
    else {

    }
    $rows[] = array(
      check_plain($key),
      $content,
    );
  }
  $header = array(check_plain($name), is_object($data) ? t('Object') : t('Array'));
  $output = theme('table', $header, $rows);
  */
}