<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array"/>
  <modified type="array">
    <modified>
      <diff>@@ -244,6 +244,52 @@ function style_generator_form($param = NULL, $style_name = NULL) {
   
   $theme_name = arg(4);
   
+  // IMAGE REGEX!!!!!!!!!!!!!!!!!111111
+  
+  // CSS REGEX!!!!!!!!!!!!!!!!!!
+
+
+    $regex = &quot;~(?:\s*)(.*)(?::\s*)(.+)(?:.*;\s*)(?:/\*\s*(?:style:\s*(.*)\s+)\s*\*/)~i&quot;;
+
+  $form['style'][$theme_name] = array(
+      
+        '#type' =&gt; 'fieldset',
+        '#title' =&gt; 'Stylesheets',
+        '#tree' =&gt; TRUE,
+      
+    );
+  
+  $style_list = style_get_stylesheets($theme_name, $style_name);
+  foreach ($style_list as $full_filename) {
+
+    drupal_set_message($full_filename);
+    
+    $style = drupal_load_stylesheet($full_filename, FALSE);
+    $new_style = preg_replace_callback($regex, &quot;_style_generate_form_fields&quot;, $style);
+    $img_regex = &quot;~(.*)\s*{\s*(?:\s*)url\((.*)\)(?:.*)\s*}~im&quot;;
+    preg_replace_callback($img_regex, &quot;_style_image&quot;, $style);
+    $form['style'][$theme_name][$full_filename] = _style_generate_form_fields('', $full_filename, TRUE);
+  }
+  
+  $form['style']['style_name'] = array(
+    '#type' =&gt; 'value',
+    '#value' =&gt; $style_name,
+  );
+  $form['style']['theme_name'] = array(
+    '#type' =&gt; 'value',
+    '#value' =&gt; $theme_name,
+  );
+  $form['style']['save'] = array(
+    '#type' =&gt; 'submit',
+    '#value' =&gt; t('Save'),
+  );
+
+  return $form;
+}
+
+function style_get_stylesheets($theme_name, $style_name) {
+  drupal_set_message(&quot;style_get_stylesheets ({$theme_name}, {$style_name}) &quot;);
+  
   if ($style_name == &quot;self&quot;) {
       $theme_info_file = drupal_get_path('theme', $theme_name) . '/' . $theme_name . '.info';
       $theme_info = drupal_parse_info_file($theme_info_file);
@@ -277,40 +323,24 @@ function style_generator_form($param = NULL, $style_name = NULL) {
 
   }
   
-    
-
-  // CSS REGEX!!!!!!!!!!!!!!!!!!
-
-    $regex = &quot;~(?:\s*)(.*)(?::\s*)(.+)(?:.*;\s*)(?:/\*\s*(?:style:\s*(.*)\s+)\s*\*/)~i&quot;;
+  $full_style_list = array();
+  
+  foreach ($style_list as $filename) {
 
-  $form['style'][$theme_name] = array(
+      if ($style_name == &quot;self&quot;) $full_filename = drupal_get_path('theme', $theme_name) . '/' . $filename;
+      else $full_filename = $dir . '/' . $filename;
       
-        '#type' =&gt; 'fieldset',
-        '#title' =&gt; 'Stylesheets',
-      
-    );
+      $full_style_list[]= $full_filename;
+  }
   
-  $array = $style_list;
-  foreach ($array as $filename) {
-    if ($style_name == &quot;self&quot;) $full_filename = drupal_get_path('theme', $theme_name) . '/' . $filename;
-    else $full_filename = $dir . '/' . $filename;
-    drupal_set_message($full_filename);
-    
-    $style = drupal_load_stylesheet($full_filename, FALSE);
-    $new_style = preg_replace_callback($regex, &quot;_style_stylesheet&quot;, $style);
+  return $full_style_list;
     
-    $img_regex = &quot;~(.*)\s*{\s*(?:\s*)url\((.*)\)(?:.*)\s*}~im&quot;;
-    preg_replace_callback($img_regex, &quot;_style_image&quot;, $style);
-    $form['style'][$theme_name][$filename] = _style_stylesheet('', $filename, TRUE);
-  }
-  // IMAGE REGEX!!!!!!!!!!!!!!!!!111111
+
+}
+
+function style_make_form() {
+  
   
-  $form['style']['save'] = array(
-    '#type' =&gt; 'submit',
-    '#value' =&gt; t('Save'),
-  );
-      
-  return $form;
 }
 
 
@@ -325,10 +355,126 @@ function style_generator_form_submit($form, &amp;$form_state) {
     
   }
   
+  drupal_set_message(&quot;&lt;b&gt;form&lt;/b&gt;&quot;. kprint_r($form, TRUE));
+
+  $theme_name = $form_state['values']['theme_name'];
+  $style_name = $form_state['values']['style_name'];
+    //$regex = &quot;~(?:\s*)(.*)(?::\s*)(.+)(?:.*;\s*)(?:/\*\s*(?:style:\s*(.*)\s+)\s*\*/)~i&quot;;
+  $regex = &quot;~(?:\n*)(\s*)(.*)(?::\s*)(.+)(?:.*;\s*)(?:/\*\s*(?:style:\s*(.*)\s+)\s*\*/)~m&quot;;
+  
+  
+  $style_list = style_get_stylesheets($theme_name, $style_name);
+  foreach ($style_list as $full_filename) {
+
+    drupal_set_message($full_filename);
+    
+    
+    $style = drupal_load_stylesheet($full_filename, FALSE);
+    
+        //  add our static form values to this
+        
+        drupal_set_message(&quot;form['#post'][$theme_name][$full_filename]&quot; . kprint_r($form['#post'][$theme_name][$full_filename], TRUE));
+
+    _style_replace('', $form['#post'][$theme_name][$full_filename]);
+    
+    $style = preg_replace_callback($regex, &quot;_style_replace&quot;, $style);
+    drupal_set_message(&quot;&lt;pre&gt;&quot; . $style . &quot;&lt;/pre&gt;&quot;);
+  }
+  
   drupal_set_message(kprint_r($variables, TRUE));
   
+  
+
+}
+
+function _style_replace($matches = NULL, $enter_form_items = NULL) {
+  
+    static $form_items;
+    if (isset($enter_form_items)) {
+      $form_items = $enter_form_items;
+      return;
+      
+    }
+  if (!isset($form_items) || $form_items == NULL) {
+    
+      //$form_items = array();
+  }
+  
+  drupal_set_message(&quot;form items&quot; . kprint_r($form_items, TRUE));
+  
+    drupal_set_message(&quot;0: &quot; . $matches['0']);
+    drupal_set_message(&quot;1 (indent): &quot; . $matches['1']);
+    drupal_set_message(&quot;2: (property_type) &quot; . $matches['2']);
+
+    drupal_set_message(&quot;3: (property_value) &quot; . $matches['3']);
+
+    drupal_set_message(&quot;4: (property_label) &quot; . $matches['4']);
+  $indent = $matches['1'];
+
+  $property_type = $matches['2'];
+  $property_value = $matches['3'];
+  $property_label = $matches['4'];
+  drupal_set_message(&quot;form_items[property_label] (form_items[{$property_label}]) &quot; . $form_items[$property_label]);
+      drupal_set_message(&quot;compare &quot;. $form_items[$property_label] . &quot;!=?&quot; . $property_value);
+
+  if (isset($form_items[$property_label])) {
+    
+    // check if the matches differ
+    drupal_set_message(&quot;compare &quot;. $form_items[$property_label] . &quot;!=?&quot; . $property_value);
+    if ($form_items[$property_label] != $property_value) {
+      // replace
+      $return = &quot;{$property_type}: &quot; . $form_items[$property_label] . &quot;; /* style: {$property_label} */&quot;;
+      $matches['0'] = &quot;\n&quot; . $indent . $return;
+    }
+          return $matches['0'];
+
+  }
+  
+  if (strlen($property_label) &gt; 0) {
+  }
+}
 
 
+function _style_generate_form_fields($matches = NULL, $stylesheet = NULL, $return = NULL) {
+  
+  static $form_items;
+  if (!isset($form_items) || $form_items == NULL) {
+    
+      $form_items = array();
+  }
+    
+  $property_type = $matches['1'];
+  $property_value = $matches['2'];
+  $property_label = $matches['3'];
+  
+  if (strlen($property_label) &gt; 0) {
+    $form_items[$property_label] = array(
+      '#type' =&gt; 'textfield',
+      '#title' =&gt; $property_label,
+      '#value' =&gt; $property_value,
+      '#attributes' =&gt; array('class' =&gt; $property_type),
+    );
+  }
+   
+
+  if ($return == TRUE) {
+    if (count($form_items) &gt; 0) {
+      $form = array();
+      $form +=  array(  
+          '#type' =&gt; 'fieldset',
+          '#title' =&gt; $stylesheet,
+        );
+      $form += $form_items;
+      
+      $form_items = NULL;
+      return $form;
+    } 
+  }
+  else {
+    return $matches;
+  
+  }
+  
 }
 
 
@@ -627,48 +773,6 @@ function style_form_alter(&amp;$form, $form_state, $form_id) {
 
 }
 
-function _style_stylesheet($matches = NULL, $stylesheet = NULL, $return = NULL) {
-  
-  static $form_items;
-  if (!isset($form_items) || $form_items == NULL) {
-    
-      $form_items = array();
-  }
-    
-  $property_type = $matches['1'];
-  $property_value = $matches['2'];
-  $property_label = $matches['3'];
-  
-  if (strlen($property_label) &gt; 0) {
-    $form_items[$property_label] = array(
-      '#type' =&gt; 'textfield',
-      '#title' =&gt; $property_label,
-      '#value' =&gt; $property_value,
-      '#attributes' =&gt; array('class' =&gt; $property_type),
-    );
-  }
-   
-
-  if ($return == TRUE) {
-    if (count($form_items) &gt; 0) {
-      $form = array();
-      $form +=  array(  
-          '#type' =&gt; 'fieldset',
-          '#title' =&gt; $stylesheet,
-        );
-      $form += $form_items;
-      
-      $form_items = NULL;
-      return $form;
-    } 
-  }
-  else {
-    return $matches;
-  
-  }
-  
-}
-
 function style_test_ahah() {
 
   $code = &quot;&lt;pre&gt;&quot;;</diff>
      <filename>style.module</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>477d5ab25615dc72caa876a9c5eb435ef113b113</id>
    </parent>
  </parents>
  <author>
    <name>Tony Narlock</name>
    <email>kiwi@kiwi.(none)</email>
  </author>
  <url>http://github.com/skiquel/drupal-style/commit/f9bc1942623876c4724822b67e817c5d6af32d4c</url>
  <id>f9bc1942623876c4724822b67e817c5d6af32d4c</id>
  <committed-date>2009-03-06T11:40:39-08:00</committed-date>
  <authored-date>2009-03-06T11:40:39-08:00</authored-date>
  <message>now replace functionality is working, and it saves indentation! :D</message>
  <tree>5d4948e2722c6e97bdfc846296b4a56ee8ca6c33</tree>
  <committer>
    <name>Tony Narlock</name>
    <email>kiwi@kiwi.(none)</email>
  </committer>
</commit>
