You are here

function globallink_preview_content in GlobalLink Connect for Drupal 7.7

1 string reference to 'globallink_preview_content'
globallink_node_preview in ./globallink_send_translations.inc

File

./globallink_send_translations.inc, line 2117

Code

function globallink_preview_content() {
  module_load_include('inc', 'globallink', 'globallink_node');
  module_load_include('inc', 'globallink', 'globallink');
  $id = arg(5);
  $output = "";
  $node = node_load($id);
  $string = globallink_generate_xml_document($node, NULL);
  $xml = new SimpleXMLElement($string);
  $title = $xml->title
    ->count();
  $elem = $xml->field
    ->count();
  $output .= "<table><tr><th>Fields</th><th>Source Contents</th></tr>";
  if ($title > 0) {
    foreach ($xml->title as $e) {
      $title_value = (string) $e;
      $label = 'title';
      $output .= "<tr><td><strong>" . ucfirst($label) . "</strong></td><td>" . $title_value . "</td></tr>";
    }
  }
  if ($elem > 0) {
    foreach ($xml->field as $element) {
      $tag = $element
        ->getName();
      $value = (string) $element;
      $label = (string) $element
        ->attributes()->label;
      $output .= "<tr><td><strong>" . ucfirst($label) . "</strong></td><td>" . $value . "</td></tr>";
    }
  }
  $output .= "</table>";
  $form['preview'] = array(
    '#markup' => $output,
  );
  return $form;
}