--- C:\Documents and Settings\Aldo\Local Settings\Temp\TCV0fc2.tmp\flexinode.1.79.module	Sat Jul 01 00:00:16 2006
+++ D:\drupal cvs\contributions\modules\flexinode\flexinode.module	Fri Jun 30 22:38:23 2006
@@ -40,14 +40,14 @@
 <li>create a flexinode content type at <a href="%admin-node-types" title="administer content types to add a flexinode"> administer &gt;&gt; content &gt;&gt; content types</a> and select <strong>add content type</strong>.</li>
 <li><a href="%node-add" title="create a new flexinode type">create content &gt;&gt; add type.</a></li>
 <li>administer flexinode at <a href="%admin-settings-flexinode">administer &gt;&gt; settings &gt;&gt; flexinode</a>.</li>
-', array('%admin-node-types' => url('admin/node/types'), '%node-add' => url('node/add'), '%admin-settings-flexinode' => url('admin/settings/flexinode'))) .'</ul>';
+', array('%admin-node-types' => url('admin/settings/content-types/edit'), '%node-add' => url('node/add'), '%admin-settings-flexinode' => url('admin/settings/flexinode'))) .'</ul>';
       $output .= '<p>'. t('For more information please read the configuration and customization handbook <a href="%flexinode">Flexinode page</a>.', array('%flexinode' => 'http://www.drupal.org/handbook/modules/flexinode/')) .'</p>';
       return $output;
     case 'admin/modules#description':
       return t('Allows administrators to define their own content types.');
-    case 'admin/node/types':
+    case 'admin/settings/content-types/edit':
       return t('You may manage your own content types here. These will all have a "title" field to start off, and contain additional fields that you specify. Choose the "add content type" tab to add a new type. Make a selection below to edit an existing type or field. To delete a field or entire content type, first open the editing form for that field or type.');
-    case 'admin/node/type':
+    case 'admin/settings/content-types/type':
       return t('Once you create a content type here you will be able to add additional fields to it on the "content types" tab.');
   }
 
@@ -154,28 +154,36 @@
 
     // admin menu items
     $items[] = array(
-      'path' => 'admin/node/types',
-      'title' => t('content types'),
+      'path' => 'admin/settings/content-types/overview', 
+      'title' => t('list'),
+      'access' => $access,
+      'type' => MENU_DEFAULT_LOCAL_TASK, 
+      'weight' => -10,
+      );
+    $items[] = array(
+      'path' => 'admin/settings/content-types/edit',
+      'title' => t('edit content types'),
       'callback' => 'flexinode_page_admin',
       'access' => $admin_access,
       'type' => MENU_LOCAL_TASK,
       );
     $items[] = array(
-      'path' => 'admin/node/type',
+      'path' => 'admin/settings/content-types/type',
       'title' => t('add content type'),
       'callback' => 'flexinode_content_type_form',
       'access' => $admin_access,
       'type' => MENU_LOCAL_TASK,
+      'weight' => 1
       );
     $items[] = array(
-      'path' => 'admin/node/type/delete',
+      'path' => 'admin/settings/content-types/delete',
       'title' => t('delete content type'),
       'callback' => 'flexinode_confirm_delete_content_type',
       'access' => $admin_access,
       'type' => MENU_CALLBACK,
       );
     $items[] = array(
-      'path' => 'admin/node/field',
+      'path' => 'admin/settings/content-types/field',
       'title' => t('edit fields'),
       'callback' => 'flexinode_admin_field',
       'access' => $admin_access,
@@ -342,14 +350,13 @@
   $output = '';
   foreach ($content_types as $ctype) {
     $ctype = flexinode_load_content_type($ctype->ctype_id);
-    $ctype->links[] = array('#href' => 'admin/node/type/' . $ctype->ctype_id, '#title' => t('edit content type'));
-    $ctype->links[] = array('#href' => 'admin/settings/content-types/flexinode-' . $ctype->ctype_id, '#title' => t('settings'));
-
+    $ctype->links[] = l(t('edit content type'), 'admin/settings/content-types/type/' . $ctype->ctype_id);
+    $ctype->links[] = l(t('settings'), 'admin/settings/content-types/flexinode-' . $ctype->ctype_id);
 
     $ctype->controls = flexinode_field_select($ctype->ctype_id);
 
     foreach ($ctype->fields as $field) {
-      $ctype->fieldlist[] = $field->label . ' (' . l(t('edit field'), 'admin/node/field/' . $field->field_id) .')';
+      $ctype->fieldlist[] = $field->label . ' (' . l(t('edit field'), 'admin/settings/content-types/field/' . $field->field_id) .')';
     }
 
     $output .= theme('flexinode_type', $ctype, ($first || ($ctype_id == $ctype->ctype_id)));
@@ -357,7 +364,7 @@
   }
 
   if (strlen($output) == 0) {
-    $output = '<p>'. t('No flexinode content types have been defined. You can <a href="%url">add a new content type</a>.', array('%url' => url('admin/node/type'))) .'</p>';
+    $output = '<p>'. t('No flexinode content types have been defined. You can <a href="%url">add a new content type</a>.', array('%url' => url('admin/settings/content-types/type'))) .'</p>';
   }
 
   drupal_add_js('misc/collapse.js');
@@ -373,7 +380,7 @@
   $op = $_POST['op'];
 
   $crumbs = drupal_get_breadcrumb();
-  $crumbs[] = l('content types', 'admin/node/types');
+  $crumbs[] = l('content types', 'admin/settings/content-types/edit');
   drupal_set_breadcrumb($crumbs);
 
   switch ($op) {
@@ -385,7 +392,7 @@
     case t('Confirm'):
       $field = flexinode_load_field($field_id);
       flexinode_delete_field($field);
-      drupal_goto('admin/node/types/'. $field->ctype_id);
+      drupal_goto('admin/settings/content-types/edit/'. $field->ctype_id);
       break;
     case t('Delete'):
       $field = flexinode_load_field($field_id);
@@ -841,7 +848,7 @@
  */
 function flexinode_content_type_form_submit($form_id, $edit) {
   if($_POST['op'] == t('Delete')) {
-    drupal_goto('admin/node/type/delete/'. $edit['ctype_id']);
+    drupal_goto('admin/settings/content-types/delete/'. $edit['ctype_id']);
   }
   if ($edit['ctype_id']) {
     $ctype_id = $edit['ctype_id'];
@@ -862,7 +869,7 @@
 
   // update the cached "create content" menu
   menu_rebuild();
-  drupal_goto('admin/node/types/'. $ctype_id);
+  drupal_goto('admin/settings/content-types/'. $edit['$ctype_id']);
 }
 
 /**
@@ -871,7 +878,7 @@
 function flexinode_confirm_delete_content_type($ctype_id) {
   if($_POST['op'] == t('Confirm')) {
     flexinode_delete_content_type($ctype_id);
-    drupal_goto('admin/node/types');
+    drupal_goto('admin/settings/content-types');
   }
 
   $ctype = flexinode_load_content_type($ctype_id);
@@ -883,7 +890,7 @@
     '#type' => 'hidden',
     '#value' =>  $ctype->name,
     );
-  return confirm_form('flexinode_confirm_delete_content_type', $form, t('Are you sure you want to delete the content type "%name"? All nodes of this type will be lost.', array('%name' => $ctype->name)), 'admin/node/type/'. $ctype_id);
+  return confirm_form('flexinode_confirm_delete_content_type', $form, t('Are you sure you want to delete the content type "%name"? All nodes of this type will be lost.', array('%name' => $ctype->name)), 'admin/settings/content-types/type/'. $ctype_id);
 }
 
 /**
@@ -1005,7 +1012,7 @@
     '#value' => $field->field_type,
     );
 
-  $form['#action'] = url('admin/node/field/'. $field_id);
+  $form['#action'] = url('admin/settings/content-types/field/'. $field_id);
 
   if ($field->field_id) {
     $form['delete'] = array(
@@ -1039,7 +1046,7 @@
  */
 function flexinode_field_form_submit($form_id, $edit) {
   flexinode_save_field($edit);
-  drupal_goto('admin/node/types/'. $edit['ctype_id']);
+  drupal_goto('admin/settings/content-types/edit/'. $edit['ctype_id']);
 }
 
 /**
@@ -1065,7 +1072,7 @@
   foreach (flexinode_field_types() as $field) {
     $options[$field] = t('add %fieldtype', array('%fieldtype' => flexinode_invoke('name', $field)));
   }
-  $form['#action'] = url('admin/node/field/');
+  $form['#action'] = url('admin/settings/content-types/field/');
   $form['#redirect'] = FALSE;
   $form['field_type'] = array(
     '#type' => 'select',
@@ -1126,7 +1133,7 @@
  * Generate a confirmation page prior to deleting a custom field.
  */
 function flexinode_confirm_delete_field($field) {
-  return confirm_form('delete_field', array(), t('Are you sure you want to delete field "%name"? All data in this field will be lost.', array('%name' => $field->label)), 'admin/node/field/'. $field->field_id);
+  return confirm_form('delete_field', array(), t('Are you sure you want to delete field "%name"? All data in this field will be lost.', array('%name' => $field->label)), 'admin/settings/content-types/field/'. $field->field_id);
 }
 
 /**
@@ -1140,12 +1147,63 @@
   drupal_set_message(t('deleted field %name', array('%name' => $field->label)));
 }
 
+
+function flexinode_save_path($metapath) {
+  $savepath=variable_get('file_directory_path', NULL);
+  if(isset($metapath)) {
+    $path_extention=preg_replace_callback("/%.*?(?=(\W|$))/","_flexinode_save_path_markup",$metapath);
+    // create the subdirectories if path_extention is set
+    foreach(explode("/",$path_extention) as $p) {
+      if($p!="/") {
+        $extpath.="/$p";
+        if(!file_exists($savepath."/".$extpath)) {
+          mkdir($savepath."/".$extpath);
+        }
+      }
+    }
+    $savepath.=$extpath;
+  }
+  return $savepath;
+}
+
+// replaces save path tags with correct values
+function _flexinode_save_path_markup($metatag) {
+  global $user; 
+
+  // add any extra functionality here, such as %workflowstate etc
+  foreach($metatag as $tag) {
+    switch(strtolower($tag)) {
+      case "%day":
+        return date("j");
+        break;
+      case "%dayname":
+        return date("l");
+        break;
+      case "%month":
+        return date("n");
+        break;
+      case "%monthname":
+        return date("F");
+        break;
+      case "%year":
+        return date("Y");
+        break;
+      case "%username":
+        return $user->name;
+        break;
+      case "%userid":
+        return $user->uid;
+        break;
+    }
+  }
+}
+
 /**
  * THEME FUNCTIONS
 **/
 
 function theme_flexinode_type($type, $first) {
-  $output = "<div><fieldset class=\"collapsible\"><legend>". $type->name ."</legend>\n";
+  $output = "<div><fieldset class=\"collapsible collapsed\"><legend>". $type->name ."</legend>\n";
   $output .= "  <p class=\"description\">". $type->description ." (". theme('links', $type->links) .")</p>\n";
   $output .= "  <p class=\"fields\">\n";
   $output .= theme('item_list', $type->fieldlist, t('Field list'));
