/[drupal]/contributions/modules/node_form_rearrange/node_form_rearrange.module
ViewVC logotype

Diff of /contributions/modules/node_form_rearrange/node_form_rearrange.module

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.3, Thu Sep 3 20:52:16 2009 UTC revision 1.4, Thu Sep 3 21:07:26 2009 UTC
# Line 89  function node_form_rearrange_form_alter( Line 89  function node_form_rearrange_form_alter(
89  function node_form_rearrange_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {  function node_form_rearrange_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) {
90    switch ($op) {    switch ($op) {
91      case 'presave':      case 'presave':
92        $vocabularies = db_query(db_rewrite_sql("SELECT v.* FROM {vocabulary} v INNER JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s'        $types = variable_get('node_form_rearrange_content_types', array(0));
93  ORDER BY v.weight, v.name", 'v', 'vid'), $node->type);        if(isset($types[$node->type]) && ($types[$node->type] != '0')) {
94        //loop through vocabularies, resetting the original data arrangement (fields in taxonomy fieldset) so the taxonomy is saved          $vocabularies = db_query(db_rewrite_sql("SELECT v.* FROM {vocabulary} v INNER JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s'
95        while ($vocabulary = db_fetch_object($vocabularies)) {    ORDER BY v.weight, v.name", 'v', 'vid'), $node->type);
96          $fieldname = 'taxonomy_field_'. $vocabulary->vid;          //loop through vocabularies, resetting the original data arrangement (fields in taxonomy fieldset) so the taxonomy is saved
97          if (isset($node->$fieldname) && $node->$fieldname) {          while ($vocabulary = db_fetch_object($vocabularies)) {
98            $node->taxonomy[$vocabulary->vid] = $node->$fieldname;            $fieldname = 'taxonomy_field_'. $vocabulary->vid;
99            unset($node->$fieldname);            if (isset($node->$fieldname) && $node->$fieldname) {
100          }              $node->taxonomy[$vocabulary->vid] = $node->$fieldname;
101          $fieldname = 'taxonomy_field_tags_'. $vocabulary->vid;              unset($node->$fieldname);
102          if (isset($node->$fieldname) && $node->$fieldname) {            }
103            $node->taxonomy['tags'][$vocabulary->vid] = $node->$fieldname;            $fieldname = 'taxonomy_field_tags_'. $vocabulary->vid;
104            unset($node->$fieldname);            if (isset($node->$fieldname) && $node->$fieldname) {
105                $node->taxonomy['tags'][$vocabulary->vid] = $node->$fieldname;
106                unset($node->$fieldname);
107              }
108          }          }
109        }        }
110        break;        break;
# Line 113  ORDER BY v.weight, v.name", 'v', 'vid'), Line 116  ORDER BY v.weight, v.name", 'v', 'vid'),
116   */   */
117    
118  function node_form_rearrange_content_extra_fields($type_name) {  function node_form_rearrange_content_extra_fields($type_name) {
119    $extra = array();    $types = variable_get('node_form_rearrange_content_types', array(0));
120    $vocabularies = db_query(db_rewrite_sql("SELECT v.* FROM {vocabulary} v INNER JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s'    if(isset($types[$type_name]) && ($types[$type_name] != '0')) {
121  ORDER BY v.weight, v.name", 'v', 'vid'), $type_name);      $extra = array();
122    //add rows for each vocabulary      $vocabularies = db_query(db_rewrite_sql("SELECT v.* FROM {vocabulary} v INNER JOIN {vocabulary_node_types} n ON v.vid = n.vid WHERE n.type = '%s'
123    while ($vocabulary = db_fetch_object($vocabularies)) {    ORDER BY v.weight, v.name", 'v', 'vid'), $type_name);
124      if ($vocabulary->tags) {      //add rows for each vocabulary
125        $extra["taxonomy_field_tags_$vocabulary->vid"] = array(      while ($vocabulary = db_fetch_object($vocabularies)) {
126        'label' => $vocabulary->name,        if ($vocabulary->tags) {
127        'description' => t('Individual field for %vocabularyname vocabulary, disables Taxonomy group ', array('%vocabularyname' => $vocabulary->name)),          $extra["taxonomy_field_tags_$vocabulary->vid"] = array(
       'weight' => -5);  
     }  
     else {  
       $extra["taxonomy_field_$vocabulary->vid"] = array(  
128          'label' => $vocabulary->name,          'label' => $vocabulary->name,
129          'description' => t('Individual field for %vocabularyname vocabulary, disables Taxonomy group', array('%vocabularyname' => $vocabulary->name)),          'description' => t('Individual field for %vocabularyname vocabulary, disables Taxonomy group ', array('%vocabularyname' => $vocabulary->name)),
130          'weight' => -5);          'weight' => -5);
131          }
132          else {
133            $extra["taxonomy_field_$vocabulary->vid"] = array(
134              'label' => $vocabulary->name,
135              'description' => t('Individual field for %vocabularyname vocabulary, disables Taxonomy group', array('%vocabularyname' => $vocabulary->name)),
136              'weight' => -5);
137          }
138      }      }
139    }    }
140    return $extra;    return $extra;
141  }  }
142    

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.4

  ViewVC Help
Powered by ViewVC 1.1.2