function arrange_fields_export_form in Arrange Fields 7
Same name and namespace in other branches
- 6 arrange_fields.module \arrange_fields_export_form()
 
This function simply provides textareas for the user to copy/paste from which will allow them to export the arrangement of their forms. It does not really need to use the form API, since there is no submission, but I am doing this to make it easier to program.
1 string reference to 'arrange_fields_export_form'
- arrange_fields_menu in ./
arrange_fields.module  - Implementation of hook_menu()
 
File
- ./
arrange_fields.module, line 232  
Code
function arrange_fields_export_form() {
  $form = array();
  // We need to look for every type of form in which we have arrangement data on.
  // The easiest way to do this is to look through the variables table.
  $res = db_query("SELECT * FROM {variable}\n                   WHERE name LIKE 'arrange_fields_position_data_%%' \n                   ORDER BY name ");
  foreach ($res as $cur) {
    $db_name = $cur->name;
    // Convert it to a plain string.
    if (!($db_value = unserialize($cur->value))) {
      continue;
    }
    // Make sure we actually contain arrangement data, and not just an
    // empty string.
    if (trim($db_value) == "") {
      continue;
    }
    // Get the form_id from the name.
    $form_id = str_replace("arrange_fields_position_data_", "", $db_name);
    // If this is a webform, verify that it still exists and has not been
    // deleted.
    if (strstr($form_id, "webform_client_form")) {
      $nid = str_replace("webform_client_form_", "", $form_id);
      if (!($node = node_load($nid))) {
        continue;
      }
      // Otherwise, grab the title so we can append that to the form_id.
      $form_id .= " (Webform: {$node->title})";
    }
    $value = $db_name . "~~!af-name-sep!~~" . $db_value . "~~!af-val-sep!~~";
    $form[$db_name] = array(
      "#title" => $form_id,
      "#type" => "textarea",
      "#default_value" => $value,
    );
  }
  return $form;
}