Exemple #1
0
/**
 * Implements hook_preprocess_templatename() to render the fileds for document.
 */
function covidien_theme_preprocess_document_node_form(&$vars) {
  drupal_add_js(drupal_get_path('theme', 'covidien_theme') . '/js/covidien.js');
  if (arg(2) == 'edit') {
    drupal_set_title(t('Edit Document'));
  } else {
    drupal_set_title(t('Add New Document to Catalog'));
  }
  $field_device_type_select = field_device_type_select($vars['form']['field_device_type']['#value'][0]['nid']);
  $field_device_type = $field_device_type_select['select_device_type'];
  $field_device_type['#id'] = 'edit-field-device-type-nid-nid';
  $field_device_type['#name'] = 'field_device_type_nid';
  if (arg(2) == 'edit') {
    $field_device_type['#attributes'] = array('disabled' => 'disabled');
  }
  if (arg(0) == 'node') {
    unset($field_device_type['#options'][0]);
  }
  //$vars['doc_device_type'] = drupal_render($vars['form']['field_device_type']);
  $vars['doc_device_type'] = drupal_render($field_device_type);
  $vars['doc_title'] = drupal_render($vars['form']['title']);
  $vars['doc_part'] = drupal_render($vars['form']['field_document_part_number']);
  $vars['doc_status'] = drupal_render($vars['form']['document_status']);
  $vars['doc_version'] = drupal_render($vars['form']['field_document_version']);
  $vars['field_documnet_type'] = drupal_render($vars['form']['field_documnet_type']);
  $vars['field_document_file'] = drupal_render($vars['form']['field_document_file']);
  $vars['filed_doc_external'] = drupal_render($vars['form']['field_doc_external_users']);
  $vars['field_document_description'] = drupal_render($vars['form']['field_document_description']);
  $vars['field_document_language'] = drupal_render($vars['form']['field_document_language']);
  $vars['hidden_doc_hw_list_id'] = 'doc_hw_listhidden';
  $output = '';
  if (!empty($vars['form']['#post'])) {
    $values = $vars['form']['#post']['field_doc_hw_list']['nid']['nid'];
    $vcount = count($values);
    if ($vcount > 0) {
      foreach ($values as $val) {
        if ($val > 0)
          $output .= '<input type="checkbox" class="form-checkbox" checked="checked" value="' . $val . '"
	  id="edit-field-doc_hw_list-nid-nid-' . $val . '" name="field_doc_hw_list[nid][nid][' . $val . ']">';
      }
    }
  }else {
    $values = $vars['form']['field_doc_hw_list']['#default_value'];
    $vcount = count($values);
    for ($i = 0; $i < $vcount; $i++) {
      if ($values[$i]['nid'] > 0)
        $output .= '<input type="checkbox" class="form-checkbox" checked="checked" value="' . $values[$i]['nid'] . '"
	  id="edit-field-doc_hw_list-nid-nid-' . $values[$i]['nid'] . '" name="field_doc_hw_list[nid][nid][' . $values[$i]['nid'] . ']">';
    }
  }
  $vars['hidden_doc_hw_list'] = $output;
  $vars['doc_hw_list'] = '<div id="doc_hw_list_wraper"></div>';
  drupal_render($vars['form']['field_doc_hw_list']);
  //software associate
  $vars['hidden_doc_sw_list_id'] = 'doc_sw_listhidden';
  $output = '';
  if (!empty($vars['form']['#post'])) {
    $values = $vars['form']['#post']['field_doc_sw_list']['nid']['nid'];
    $vcount = count($values);
    if ($vcount > 0) {
      foreach ($values as $val) {
        if ($val > 0)
          $output .= '<input type="checkbox" class="form-checkbox" checked="checked" value="' . $val . '"
	  id="edit-field-doc_sw_list-nid-nid-' . $val . '" name="field_doc_sw_list[nid][nid][' . $val . ']">';
      }
    }
  }else {
    $values = $vars['form']['field_doc_sw_list']['#default_value'];
    $vcount = count($values);
    for ($i = 0; $i < $vcount; $i++) {
      if ($values[$i]['nid'] > 0)
        $output .= '<input type="checkbox" class="form-checkbox" checked="checked" value="' . $values[$i]['nid'] . '"
	  id="edit-field-doc_sw_list-nid-nid-' . $values[$i]['nid'] . '" name="field_doc_sw_list[nid][nid][' . $values[$i]['nid'] . ']">';
    }
  }
  $vars['hidden_doc_sw_list'] = $output;
  $vars['doc_sw_list'] = '<div id="doc_sw_list_wraper"></div>';
  drupal_render($vars['form']['field_doc_sw_list']);
  $vars['doc_assoicate_type_selection'] = drupal_render($vars['form']['doc_assoicate_type_selection']);
  $vars['sw_filter_lang'] = drupal_render($vars['form']['filter']['filter_lang']);
  $vars['sw_filter_go'] = drupal_render($vars['form']['filter']['go']);
  $vars['hw_filter_type'] = drupal_render($vars['form']['filter']['filter_type']);
  $vars['hw_filter_go'] = drupal_render($vars['form']['filter']['filter_type_go']);
  $vars['form_delete'] = drupal_render($vars['form']['buttons']['delete']);
  $vars['form_cancel'] = drupal_render($vars['form']['buttons']['cancel']);
  $vars['form_submit'] = drupal_render($vars['form']['buttons']['submit']);
  $vars['form_render'] = drupal_render($vars['form']);
}
   <td>
     <div class="form-item-div">
       <div class="form-item-left">
         <?php if (!empty($widget->label)): ?>
           <label for="<?php echo $widget->id; ?>"><?php echo $widget->label; ?>:</label>
         <?php endif; ?>
       </div>
       <div class="form-item-left" style="padding-left : 30px;">
         <?php if (!empty($widget->operator)): ?>
           <div class="views-operator">
             <?php echo $widget->operator; ?>
           </div><?php endif; ?>
         <div class="views-widget">
           <?php
           module_load_include("module", "convidien_ui", "module");
           $select_device_type = field_device_type_select($device_type_id);
           $device_type_form['field_device_type'] = $select_device_type['select_device_type'];
           //sel_device_type
           $device_type_form['field_device_type']['#name'] = 'field_device_type_nid';
           $device_type_form['field_device_type']['#id'] = 'edit-field-device-type-nid';
           echo drupal_render($device_type_form['field_device_type']);
           ?>
         </div>
       </div>
     </div>
   </td>
 </tr>
 <tr>
   <td style="padding-top  : 20px;">
     <div class="clear_div"></div>
     <div class="form-item-div">
 * - $widgets: An array of exposed form widgets. Each widget contains:
 * - $widget->label: The visible label to print. May be optional.
 * - $widget->operator: The operator for the widget. May be optional.
 * - $widget->widget: The widget itself.
 * - $button: The submit button for the form.
 *
 * @ingroup views_templates
 */
global $user;
$deviceTypeRelation = get_device_type_relation_with_gateway_version();
$deviceTypeRelationStr = '';
foreach ($deviceTypeRelation as $key => $value) {
  $deviceTypeRelationStr .= $key . ',' . $value . '|';
}
//use new device type list 
$field_device_type_select = field_device_type_select($_GET['field_device_type_nid']);
$field_device_type = $field_device_type_select['select_device_type'];
$field_device_type['#id'] = 'edit-field-device-type-nid';
$field_device_type['#name'] = 'field_device_type_nid';
$sw_device_type = drupal_render($field_device_type);
?>
<?php if (!empty($q)): ?>
  <?php
  // This ensures that, if clean URLs are off, the 'q' is added first so that
  // it shows up first in the URL.
  print $q;
  ?>
<?php endif; ?>
<input type="hidden" id="device_type_relation" name="device_type_relation" value="<?php echo $deviceTypeRelationStr; ?>" />
<table class="form-item-table-full" style="margin-bottom: 10px;">
  <tr>
           <?php endif; ?>
         <?php } ?>
       </div>
     </div>
     <div class="clear_div"></div>
   </td>
 </tr>
 <tr>
   <td>
     <div class="form-item-div">
       <div class="form-item-div">
         <div class="form-item-left">
           <label for="edit-field-device-type-nid">Select Device Type:</label>
         </div>
         <div style="padding-left : 30px;" class="form-item-left">
           <?php echo drupal_render(field_device_type_select()); ?>
         </div>
       </div>
     </div>
     <?php if (!empty($widget->label)): ?>
       <div class="form-item-div">
         <div class="form-item-left">
           <label for="<?php print $widget->id; ?>"><?php print $widget->label; ?>:</label>
         </div>
         <div class="form-item-left" style="padding-left : 30px;">
         <?php endif; ?>
         <?php if (!empty($widget->operator)): ?><div class="views-operator"><?php print $widget->operator; ?></div><?php endif; ?>
         <div class="views-widget"><?php print $widget->widget; ?></div>
       </div>
     </div>
   </td>