| 
														
															@@ -7,14 +7,18 @@ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  * 
														 | 
														
														 | 
														
															  * 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  * @copyright 2008 Ouest Systemes Informatiques (OSInet) 
														 | 
														
														 | 
														
															  * @copyright 2008 Ouest Systemes Informatiques (OSInet) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  * @author Frederic G. MARAND 
														 | 
														
														 | 
														
															  * @author Frederic G. MARAND 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- * @version $Id: qbf.module,v 1.3 2008-08-25 17:40:53 marand Exp $ 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ * @version $Id: qbf.module,v 1.4 2008-08-26 16:24:07 marand Exp $ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  * @license CeCILL 2.0 
														 | 
														
														 | 
														
															  * @license CeCILL 2.0 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  * @package QBF 
														 | 
														
														 | 
														
															  * @package QBF 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  */ 
														 | 
														
														 | 
														
															  */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 define('QBF_LEVEL_REMOVE',           0); 
														 | 
														
														 | 
														
															 define('QBF_LEVEL_REMOVE',           0); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-define('QBF_LEVEL_OPTIONAL',         1); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-define('QBF_LEVEL_REQUIRED',         2); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+define('QBF_LEVEL_DISPLAY',          1); // Display only, don't use 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+define('QBF_LEVEL_OPTIONAL',         2); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+define('QBF_LEVEL_REQUIRED',         3); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+define('QBF_PATH_QUERY',             'qbf/query'); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															 function _qbf_view($usNodeType = NULL) 
														 | 
														
														 | 
														
															 function _qbf_view($usNodeType = NULL) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   { 
														 | 
														
														 | 
														
															   { 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -60,7 +64,7 @@ function qbf_rewrite_form($form) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 function qbf_transform_form($form_id) 
														 | 
														
														 | 
														
															 function qbf_transform_form($form_id) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   { 
														 | 
														
														 | 
														
															   { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   $arArgs = func_get_args(); 
														 | 
														
														 | 
														
															   $arArgs = func_get_args(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+//dsm(array('qtf' => $arArgs)); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   // Fetch the basic form and rename it, passing it the caller's arguments 
														 | 
														
														 | 
														
															   // Fetch the basic form and rename it, passing it the caller's arguments 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   $form = call_user_func_array('drupal_retrieve_form', $arArgs); 
														 | 
														
														 | 
														
															   $form = call_user_func_array('drupal_retrieve_form', $arArgs); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   $newFormId = "qbf_$form_id"; 
														 | 
														
														 | 
														
															   $newFormId = "qbf_$form_id"; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -68,6 +72,7 @@ function qbf_transform_form($form_id) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   // Only keep the children of the form and QBF properties on the form itself 
														 | 
														
														 | 
														
															   // Only keep the children of the form and QBF properties on the form itself 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   $elements = array(); 
														 | 
														
														 | 
														
															   $elements = array(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   $newForm = array(); 
														 | 
														
														 | 
														
															   $newForm = array(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  $newForm['#qbf_source_form_id'] = $form_id; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   if (in_array('#qbf', element_properties($form))) 
														 | 
														
														 | 
														
															   if (in_array('#qbf', element_properties($form))) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     { 
														 | 
														
														 | 
														
															     { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     $newForm += $form['#qbf']; 
														 | 
														
														 | 
														
															     $newForm += $form['#qbf']; 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -84,6 +89,9 @@ function qbf_transform_form($form_id) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															   $newForm['#id'] = $newFormId; 
														 | 
														
														 | 
														
															   $newForm['#id'] = $newFormId; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  $newForm['#multistep'] = TRUE; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  $newForm['#redirect']  = FALSE; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  $newForm['#after_build'][] = 'qbf_after_build'; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 // dsm($newForm); 
														 | 
														
														 | 
														
															 // dsm($newForm); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   return $newForm; 
														 | 
														
														 | 
														
															   return $newForm; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   } 
														 | 
														
														 | 
														
															   } 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -107,13 +115,13 @@ function _qbf_transform_element($key, array $element) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     ( 
														 | 
														
														 | 
														
															     ( 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     'button'         => NULL, 
														 | 
														
														 | 
														
															     'button'         => NULL, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     'file'           => NULL, 
														 | 
														
														 | 
														
															     'file'           => NULL, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    'hidden'         => NULL, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    // 'hidden'         => NULL, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     'markup'         => NULL, 
														 | 
														
														 | 
														
															     'markup'         => NULL, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     'password'       => NULL, 
														 | 
														
														 | 
														
															     'password'       => NULL, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     'radio'          => NULL, 
														 | 
														
														 | 
														
															     'radio'          => NULL, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     'submit'         => NULL, 
														 | 
														
														 | 
														
															     'submit'         => NULL, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     'textarea'       => 'textfield', 
														 | 
														
														 | 
														
															     'textarea'       => 'textfield', 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    'value'          => NULL, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    // 'value'          => 'value', 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     ); 
														 | 
														
														 | 
														
															     ); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															   // Properties without a default transformation are not transformed 
														 | 
														
														 | 
														
															   // Properties without a default transformation are not transformed 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -135,7 +143,6 @@ function _qbf_transform_element($key, array $element) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     '#submit'        => NULL, 
														 | 
														
														 | 
														
															     '#submit'        => NULL, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     '#tree'          => NULL, 
														 | 
														
														 | 
														
															     '#tree'          => NULL, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     '#validate'      => NULL, 
														 | 
														
														 | 
														
															     '#validate'      => NULL, 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    '#value'         => NULL, 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     ); 
														 | 
														
														 | 
														
															     ); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															   // Property values causing element removal 
														 | 
														
														 | 
														
															   // Property values causing element removal 
														 | 
													
												
											
										
											
												
													
														 | 
														
															@@ -218,36 +225,45 @@ function _qbf_transform_element($key, array $element) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   return $ret; 
														 | 
														
														 | 
														
															   return $ret; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   } 
														 | 
														
														 | 
														
															   } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-function qbf_search() 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  dsm('qs'); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  } 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 function qbf_perm() 
														 | 
														
														 | 
														
															 function qbf_perm() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   { 
														 | 
														
														 | 
														
															   { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   $ret = array('use qbf search functions'); 
														 | 
														
														 | 
														
															   $ret = array('use qbf search functions'); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   return $ret; 
														 | 
														
														 | 
														
															   return $ret; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   } 
														 | 
														
														 | 
														
															   } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-function qbf_menu($may_cache) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+/** 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ * Implement hook_forms 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ * 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ * @todo dynamically build the list of forms 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ * 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ * @return array 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+ */ 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+function qbf_forms() 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   { 
														 | 
														
														 | 
														
															   { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  $items = array(); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  $forms['qbf_job_form'] = array 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    ( 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    'callback'           => 'qbf_transform_form', 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    'callback arguments' => array('job_form'), 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    ); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  return $forms; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															  
														 | 
														
														 | 
														
															  
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  if ($may_cache) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+function qbf_after_build($form, $form_values) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  $arQuery = array(); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  dsm($form_values); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  foreach (element_children($form) as $childName) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     { 
														 | 
														
														 | 
														
															     { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-    $items[] = array 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      ( 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      'path'      => 'qbf/query', 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      'access'    => user_access('use qbf search functions'), 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      'callback'  => 'qbf_query', 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-      ); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    if ($form[$childName]['#qbf']['#level'] > QBF_LEVEL_REMOVE) 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      { 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      $arQuery[] = $childName . '=' . $form[$childName]['#value']; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+      } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															     } 
														 | 
														
														 | 
														
															     } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  return $items; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  $query = implode(', ', $arQuery); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  $form['food'] = array 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    ( 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    '#type'    => 'markup', 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    '#value'   => "<p>Requête sur $query</p>", 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+    ); 
														 | 
													
												
											
												
													
														| 
														 | 
														
															 
														 | 
														
														 | 
														
															+  return $form; 
														 | 
													
												
											
												
													
														| 
														 | 
														
															   } 
														 | 
														
														 | 
														
															   } 
														 | 
													
												
											
												
													
														| 
														 | 
														
															- 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-function qbf_query($form_id) 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  { 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  dsm("qq $form_id"); 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  return "QQ $form_id"; 
														 | 
														
														 | 
														
															 
														 | 
													
												
											
												
													
														| 
														 | 
														
															-  } 
														 | 
														
														 | 
														
															 
														 |