--- evalwf.class	2010-02-23 21:38:51.000000000 +0100
+++ evalwf.class	2010-09-02 15:32:32.000000000 +0200
@@ -45,8 +45,8 @@ class evalwf_component_values {
   *	@param  $sor - datas of the answer possibility
   */
   public function sor_beszur($sor) {
-    $this->sorok[$sor['kulcs']] = array(
-      'name' => $sor['name'], 
+    $this->sorok[trim($sor['kulcs'])] = array(
+      'name' => trim($sor['name']),
       'is_selected' => $sor['is_selected'], 
       'selection' => $sor['selection'],
       'value' => $sor['value'],
@@ -192,17 +192,17 @@ class evalwf_component_values {
     switch ($type) {
       case 'select':
           foreach ($points as $key => $point) {
-            $is_validname = ($this->sorok[$key]['name']!=$key);
-            if (!$is_validname) $this->sorok[$key]['value'] = $point;
-              $is_componentchanged |= $is_validname;
+            $is_validname = is_array($this->sorok[$key]);
+            if ($is_validname) $this->sorok[$key]['value'] = $point;
+              $is_componentchanged |= !$is_validname;
             }
         break;
       case 'grid':
           foreach ($points as $rid => $rows) {
             foreach ($rows as $key => $point) {
-              $is_validoption = ($this->sorok[$rid]['value'][$key]['option']!=$key);
-              if (!$is_validoption) $this->sorok[$rid]['value'][$key]['value'] = $point;
-              $is_componentchanged |= $is_validoption;
+              $is_validoption = is_array($this->sorok[$rid]['value'][$key]);
+              if ($is_validoption) $this->sorok[$rid]['value'][$key]['value'] = $point;
+              $is_componentchanged |= !$is_validoption;
             }
           }
         break;
@@ -221,10 +221,10 @@ class evalwf_component_values {
       foreach ($this->sorok as $kulcs => $sor) {
         switch ($type) {
           case 'select':
-              $form['ertek'][$sor['name']] = array(
+              $form['ertek'][trim($kulcs)] = array(
                 'name' => array(
                   '#type' => 'markup',
-                  '#value' => $sor['name'],
+                  '#value' => trim($sor['name']),
                   '#prefix' => '<TR class="ertek_sor"><TD class="ertek_nev">',
                   '#suffix' => '</TD>',
                 ),
@@ -245,8 +245,8 @@ class evalwf_component_values {
               );
             break;
           case 'grid': // itt a sor['selection'] kell majd....
-              foreach ($sor['value'] as $value) {
-                $form['ertek'][$sor['name']][$value['option']] = array(
+              foreach ($sor['value'] as $key => $value) {
+                $form['ertek'][$sor['name']][$key] = array(
                   'name' => array(
                     '#type' => 'markup',
                     '#value' => $sor['name'],
@@ -686,22 +686,21 @@ class evalwf_component_tree {
       switch ($komp->type) {
         case 'select' : $items = _webform_select_options($extra['items'], TRUE);
             foreach ($items as $key => $item) {
-              if ($key = 'items') {
                 $sor = NULL;
-                $sor['kulcs'] = $item;
-                $sor['name'] = $item;
+                $sor['kulcs'] = ($key!=NULL) ? trim($key) : trim($item) ;
+                $sor['name'] = trim($item);
                 $sor['is_selected'] = FALSE;
                 $sor['value'] = NULL;
                 $komp->ertek_beszur($sor);
-              }
             }
           break;
         case 'grid' : $items = _webform_select_options($extra['questions'], TRUE);
             $i = 0;
             $options = _webform_select_options($extra['options'], TRUE);
             $values = NULL;
-            foreach ($options as $option) {
-              $values[$option] = array('option' => $option, 'value' => NULL);
+            foreach ($options as $key => $option) {
+              $kulcs = ($key!=NULL) ? trim($key) : trim($option);
+              $values[$kulcs] = array('option' => trim($option), 'value' => NULL);
               $i++;
             }
             $i = 0;
@@ -895,7 +894,7 @@ class evalwf_component_tree {
     while ($data = db_fetch_object($queryResult)) {
       $k = $this->find_parrent($this->component_tree, $data->cid);
       if ($k['is_found'] && ($k['component'] != NULL)) {
-        $k['component']->set_submission_data(array('no' => $data->no, 'data' => $data->data));
+        $k['component']->set_submission_data(array('no' => $data->no, 'data' => trim($data->data)));
       }
     }
   } //	evalwf_component_tree::submission_betoltese()
