You are here

function globallink_taxonomy_preview_content in GlobalLink Connect for Drupal 7.7

Helper function

1 string reference to 'globallink_taxonomy_preview_content'
globallink_taxonomy_preview in globallink_taxonomy/globallink_taxonomy_send.inc
Helper function

File

globallink_taxonomy/globallink_taxonomy_send.inc, line 463

Code

function globallink_taxonomy_preview_content() {
  module_load_include('inc', 'globallink', 'globallink_taxonomy/globallink_taxonomy');
  module_load_include('inc', 'globallink', 'globallink');
  $id = arg(5);
  $output = "";
  $taxo = taxonomy_term_load($id);
  $info = entity_translation_taxonomy_term_enabled_vocabulary($taxo->vocabulary_machine_name);
  $output .= "<table><tr><th>Fields</th><th>Source Contents</th></tr>";
  if (!$info) {
    $string = globallink_get_taxonomy_xml_for_I18N_MODE_LOCALIZE($taxo, NULL);
    $xml = new SimpleXMLElement($string);
    $elem = $xml->taxonomy
      ->count();
    if ($elem > 0) {
      foreach ($xml->taxonomy 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>";
      }
    }
  }
  else {
    $string = globallink_get_taxonomy_xml_for_I18N_MODE_ENTITY_TRANSLATE($taxo, NULL);
    $xml = new SimpleXMLElement($string);
    $elem = $xml->field
      ->count();
    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;
}