<?xml version="1.0" encoding="UTF-8"?>
<commit>
  <added type="array">
    <added>
      <filename>lib/classes/module/class.cms_module_request.php</filename>
    </added>
  </added>
  <modified type="array">
    <modified>
      <diff>@@ -129,7 +129,8 @@ if (count($gCms-&gt;modules) &gt; 0)
 		}
 		$id = 'm1_';
 		$params = GetModuleParameters($id);
-		echo $gCms-&gt;modules[$module]['object']-&gt;do_action_base($action, $id, $params);
+		$request = $gCms-&gt;modules[$module]['object']-&gt;create_request_instance($id);
+		echo $request-&gt;do_action_base($action, $params);
 		if (!(isset($USE_OUTPUT_BUFFERING) &amp;&amp; $USE_OUTPUT_BUFFERING == false))
 		{
 			$content = @ob_get_contents();</diff>
      <filename>admin/moduleinterface.php</filename>
    </modified>
    <modified>
      <diff>@@ -898,81 +898,6 @@ abstract class CmsModuleBase extends CmsObject
 	
 	/**
 	 * ------------------------------------------------------------------
-	 * Navigation Related Methods
-	 * ------------------------------------------------------------------
-	 */
-
-	/**
-	 * Used for navigation between &quot;pages&quot; of a module.	 Forms and links should
-	 * pass an action with them so that the module will know what to do next.
-	 * By default, DoAction will be passed 'default' and 'defaultadmin',
-	 * depending on where the module was called from.  If being used as a module
-	 * or content type, 'default' will be passed.  If the module was selected
-	 * from the list on the admin menu, then 'defaultadmin' will be passed.
-	 *
-	 * @param string Name of the action to perform
-	 * @param string The ID of the module
-	 * @param string The parameters targeted for this module
-	 */
-	public function do_action($action_name, $id, $params, $returnid='')
-	{
-		$return_id = $returnid; //avoid confusion
-
-		if ($action_name != '')
-		{
-			$filename = cms_join_path($this-&gt;get_module_path(), 'action.' . $action_name . '.php');
-
-			if (@is_file($filename))
-			{
-				{
-					$gCms = cmsms(); //Backwards compatibility
-					$db = cms_db();
-					$config = cms_config();
-					$smarty = cms_smarty();
-
-					$smarty-&gt;assign('module_action',$action_name);
-
-					include($filename);
-
-				}
-			}
-		}
-	}
-
-	public function do_action_base($name, $id, $incoming_params, $returnid = '')
-	{
-		if ($returnid != '')
-		{
-			if (!$this-&gt;restrict_unknown_params &amp;&amp; CmsApplication::get_preference('allowparamcheckwarnings', 0))
-			{
-				trigger_error('WARNING: '.$this-&gt;get_name().' is not properly cleaning input params.', E_USER_WARNING);
-			}
-			// used to try to avert XSS flaws, this will
-			// clean as many parameters as possible according
-			// to a map specified with the SetParameterType metods.
-			$incoming_params = $this-&gt;clean_param_hash($incoming_params, !$this-&gt;restrict_unknown_params);
-		}
-
-		if (isset($incoming_params['lang']))
-		{
-			$this-&gt;curlang = $incoming_params['lang'];
-			$this-&gt;langhash = array();
-		}
-
-		if (!isset($incoming_params['action']))
-		{
-			$incoming_params['action'] = $name;
-		}
-
-		$incoming_params['action'] = cms_htmlentities($incoming_params['action']);
-		$returnid = cms_htmlentities($returnid);
-		$id = cms_htmlentities($id);
-		$name = cms_htmlentities($name);
-		return $this-&gt;do_action($name, $id, $incoming_params, $returnid);
-	}
-	
-	/**
-	 * ------------------------------------------------------------------
 	 * Web Service Methods
 	 * ------------------------------------------------------------------
 	 */
@@ -1012,71 +937,6 @@ abstract class CmsModuleBase extends CmsObject
 		return '&lt;/fieldset&gt;'.&quot;\n&quot;;
 	}
 
-
-	/**
-	 * Returns the start of a module form, optimized for frontend use
-	 *
-	 * @param string The id given to the module on execution
-	 * @param string The id to eventually return to when the module is finished it's task
-	 * @param string The action that this form should do when the form is submitted
-	 * @param string Method to use for the form tag.  Defaults to 'post'
-	 * @param string Optional enctype to use, Good for situations where files are being uploaded
-	 * @param boolean A flag to determine if actions should be handled inline (no moduleinterface.php -- only works for frontend)
-	 * @param string Text to append to the end of the id and name of the form
-	 * @param array Extra parameters to pass along when the form is submitted
-	 */
-	public function create_frontend_form_start($id, $returnid, $action='default', $method='post', $enctype='', $inline=true, $idsuffix='', $params=array())
-	{
-		return $this-&gt;create_form_start($id,$action,$returnid,$method,$enctype,$inline,$idsuffix,$params);
-	}
-
-
-	/**
-	 * Returns the start of a module form
-	 *
-	 * @param string The id given to the module on execution
-	 * @param string The action that this form should do when the form is submitted
-	 * @param string The id to eventually return to when the module is finished it's task
-	 * @param string Method to use for the form tag.  Defaults to 'post'
-	 * @param string Optional enctype to use, Good for situations where files are being uploaded
-	 * @param boolean A flag to determine if actions should be handled inline (no moduleinterface.php -- only works for frontend)
-	 * @param string Text to append to the end of the id and name of the form
-	 * @param array Extra parameters to pass along when the form is submitted
-	 * @param string Text to append to the &lt;form&gt;-statement, for instanse for javascript-validation code
-	 * @param boolean A flag to determine if the action should just redirect back to this exact page
-	 */
-	public function create_form_start($id, $action='default', $returnid='', $method='post', $enctype='', $inline=false, $idsuffix='', $params = array(), $extra='', $html_id = '', $use_current_page_as_action = false)
-	{
-		$this-&gt;load_form_methods();
-		return cms_module_CreateFormStart($this, $id, $action, $returnid, $method, $enctype, $inline, $idsuffix, $params, $extra, $html_id, $use_current_page_as_action);
-	}
-
-	/**
-	 * Returns the end of the a module form.  This is basically just a wrapper around &lt;/form&gt;, but
-	 * could be extended later on down the road.  It's here mainly for consistency.
-	 */
-	public function create_form_end()
-	{
-		return '&lt;/form&gt;'.&quot;\n&quot;;
-	}
-
-	/**
-	 * Returns the xhtml equivalent of an input textbox.  This is basically a nice little wrapper
-	 * to make sure that id's are placed in names and also that it's xhtml compliant.
-	 *
-	 * @param string The id given to the module on execution
-	 * @param string The html name of the textbox
-	 * @param string The predefined value of the textbox, if any
-	 * @param string The number of columns wide the textbox should be displayed
-	 * @param string The maximum number of characters that should be allowed to be entered
-	 * @param string Any additional text that should be added into the tag when rendered
-	 */
-	public function create_input_text($id, $name, $value='', $size='10', $maxlength='255', $addttext='', $html_id = '')
-	{
-		$this-&gt;load_form_methods();
-		return cms_module_CreateInputText($this, $id, $name, $value, $size, $maxlength, $addttext, $html_id);
-	}
-
 	/**
 	 * Returns the xhtml equivalent of an label for input field.  This is basically a nice little wrapper
 	 * to make sure that id's are placed in names and also that it's xhtml compliant.
@@ -1093,25 +953,6 @@ abstract class CmsModuleBase extends CmsObject
 	}
 
 	/**
-	 * Returns the xhtml equivalent of an input textbox with label.  This is basically a nice little wrapper
-	 * to make sure that id's are placed in names and also that it's xhtml compliant.
-	 *
-	 * @param string The id given to the module on execution
-	 * @param string The html name of the textbox
-	 * @param string The predefined value of the textbox, if any
-	 * @param string The number of columns wide the textbox should be displayed
-	 * @param string The maximum number of characters that should be allowed to be entered
-	 * @param string Any additional text that should be added into the tag when rendered
-	 * @param string The text for label 
-	 * @param string Any additional text that should be added into the tag when rendered
-	 */
-	public function create_input_text_with_label($id, $name, $value='', $size='10', $maxlength='255', $addttext='', $label='', $labeladdtext='', $html_id = '')
-	{
-		$this-&gt;load_form_methods();
-		return cms_module_CreateInputTextWithLabel($this, $id, $name, $value, $size, $maxlength, $addttext, $label, $labeladdtext, $html_id);
-	}
-
-	/**
 	 * Returns the xhtml equivalent of a file-selector field.  This is basically a nice little wrapper
 	 * to make sure that id's are placed in names and also that it's xhtml compliant.
 	 *
@@ -1128,71 +969,6 @@ abstract class CmsModuleBase extends CmsObject
 	}
 
 	/**
-	 * Returns the xhtml equivalent of an input password-box.  This is basically a nice little wrapper
-	 * to make sure that id's are placed in names and also that it's xhtml compliant.
-	 *
-	 * @param string The id given to the module on execution
-	 * @param string The html name of the textbox
-	 * @param string The predefined value of the textbox, if any
-	 * @param string The number of columns wide the textbox should be displayed
-	 * @param string The maximum number of characters that should be allowed to be entered
-	 * @param string Any additional text that should be added into the tag when rendered
-	 */
-	public function create_input_password($id, $name, $value='', $size='10', $maxlength='255', $addttext='', $html_id = '')
-	{
-		$this-&gt;load_form_methods();
-		return cms_module_CreateInputPassword($this, $id, $name, $value, $size, $maxlength, $addttext, $html_id);
-	}
-
-	/**
-	 * Returns the xhtml equivalent of a hidden field.	This is basically a nice little wrapper
-	 * to make sure that id's are placed in names and also that it's xhtml compliant.
-	 *
-	 * @param string The id given to the module on execution
-	 * @param string The html name of the hidden field
-	 * @param string The predefined value of the field, if any
-	 * @param string Any additional text that should be added into the tag when rendered
-	 */
-	public function create_input_hidden($id, $name, $value='', $addttext='', $html_id = '')
-	{
-		$this-&gt;load_form_methods();
-		return cms_module_CreateInputHidden($this, $id, $name, $value, $addttext, $html_id);
-	}
-
-	/**
-	 * Returns the xhtml equivalent of a checkbox.	This is basically a nice little wrapper
-	 * to make sure that id's are placed in names and also that it's xhtml compliant.
-	 *
-	 * @param string The id given to the module on execution
-	 * @param string The html name of the checkbox
-	 * @param string The predefined value of the field, if any
-	 * @param string Any additional text that should be added into the tag when rendered
-	 */
-	public function create_input_checkbox($id, $name, $selected = false, $addttext='', $html_id = '')
-	{
-		$id = cms_htmlentities($id);
-		$name = cms_htmlentities($name);
-
-		if ($html_id == '')
-			$html_id = CmsResponse::make_dom_id($id . $name);
-
-		$text = '&lt;input type=&quot;hidden&quot; name=&quot;'.$id.$name.'&quot; value=&quot;0&quot; /&gt;';
-		$text .= '&lt;input type=&quot;checkbox&quot; name=&quot;'.$id.$name.'&quot; id=&quot;'.$html_id.'&quot; value=&quot;1&quot;';
-		if ($selected)
-		{
-			$text .= ' checked=&quot;checked&quot;';
-		}
-		if ($addttext != '')
-		{
-			$text .= ' '.$addttext;
-		}
-		$text .= &quot; /&gt;\n&quot;;
-
-		return $text;
-	}
-
-
-	/**
 	 * Returns the xhtml equivalent of a submit button.	 This is basically a nice little wrapper
 	 * to make sure that id's are placed in names and also that it's xhtml compliant.
 	 *
@@ -2053,6 +1829,11 @@ abstract class CmsModuleBase extends CmsObject
 	function GetNotificationOutput($priority=2) {
 		return '';
 	}
+	
+	function create_request_instance($id, $return_id = '')
+	{
+		return new CmsModuleRequest($this, $id, $return_id);
+	}
 }
 
 # vim:ts=4 sw=4 noet</diff>
      <filename>lib/classes/module/class.cms_module_base.php</filename>
    </modified>
    <modified>
      <diff>@@ -314,6 +314,62 @@ function remove_keys($array, $keys_to_remove)
 }
 
 /**
+ * Check to see if all keys in the given hash exist
+ * in the check array.  If there are any extra, it will
+ * return false.
+ *
+ * @param array The hash to check
+ * @param array The hash to test against
+ * @return boolean Returns false if there are extra keys
+ * @author Ted Kulp
+ **/
+function are_all_keys_valid($array, $valid_keys)
+{
+	return invalid_key($array, $valid_keys) == null;
+}
+
+/**
+ * Check to see if all keys in the given hash exist
+ * in the check array.  If there are any extra, it will
+ * return the name of the first extra one.
+ *
+ * @param array The hash to check
+ * @param array The hash to test against
+ * @return string The name of the extra key, if any.  If there are none, it returns null.
+ * @author Ted Kulp
+ **/
+function invalid_key($array, $valid_keys)
+{
+	if (array_keys($valid_keys) != $valid_keys)
+		$valid_keys = array_keys($valid_keys);
+
+	foreach (array_keys($array) as $one_key)
+	{
+		if (!in_array($one_key, $valid_keys))
+		{
+			return $one_key;
+		}
+	}
+	
+	return null;
+}
+
+function array_search_keys($array, $keys_to_search)
+{
+	$result = array();
+
+	foreach ($array as $k=&gt;$v)
+	{
+		if (in_array($k, $keys_to_search))
+		{
+			$result[$key] = $value;
+		}
+	}
+	
+	return $result;
+}
+
+/**
  * Global wrapper for CmsResponse::redirect()
  *
  * @param $to The url to redirect to</diff>
      <filename>lib/cmsms.api.php</filename>
    </modified>
    <modified>
      <diff>@@ -18,27 +18,13 @@
 
 function smarty_cms_block_mod_form($params, $content, &amp;$smarty, &amp;$repeat)
 {
-	$module =&amp; $smarty-&gt;get_template_vars('cms_mapi_module');
-	$id = $smarty-&gt;get_template_vars('cms_mapi_id');
-	$return_id = $smarty-&gt;get_template_vars('cms_mapi_return_id');
+	$request =&amp; $smarty-&gt;get_template_vars('request');
 	
 	if (!$repeat)
 	{
 		if (isset($content))
 		{
-			return $module-&gt;create_form_start(
-				$id,
-				coalesce_key($params, 'action', 'default'),
-				$return_id, 
-				coalesce_key($params, 'method', 'post'),
-				coalesce_key($params, 'enctype', ''), 
-				coalesce_key($params, 'inline', false),
-				coalesce_key($params, 'id_suffix', ''), 
-				coalesce_key($params, 'params', array()),
-				coalesce_key($params, 'extra', ''),
-				coalesce_key($params, 'id', ''),
-				coalesce_key($params, 'use_current_page_as_action', false)) . 
-				$content . $module-&gt;create_form_end();
+			return $request-&gt;create_form_start($params) . $content . $request-&gt;create_form_end();
 		}
 	}
 }</diff>
      <filename>lib/module_plugins/block.mod_form.php</filename>
    </modified>
    <modified>
      <diff>@@ -18,14 +18,9 @@
 
 function smarty_cms_function_mod_checkbox($params, &amp;$smarty)
 {
-	$module =&amp; $smarty-&gt;get_template_vars('cms_mapi_module');
-	$id = $smarty-&gt;get_template_vars('cms_mapi_id');
+	$request =&amp; $smarty-&gt;get_template_vars('request');
 
-	return $module-&gt;create_input_checkbox($id,
-		$params['name'], 
-		coalesce_key($params, 'selected', false),
-		coalesce_key($params, 'additional_text', ''),
-		coalesce_key($params, 'id', ''));
+	return $request-&gt;create_input_checkbox($params);
 }
 
 ?&gt;</diff>
      <filename>lib/module_plugins/function.mod_checkbox.php</filename>
    </modified>
    <modified>
      <diff>@@ -18,10 +18,9 @@
 
 function smarty_cms_function_mod_hidden($params, &amp;$smarty)
 {
-	$module =&amp; $smarty-&gt;get_template_vars('cms_mapi_module');
-	$id = $smarty-&gt;get_template_vars('cms_mapi_id');
+	$request =&amp; $smarty-&gt;get_template_vars('request');
 
-	return $module-&gt;create_input_hidden($id, $params['name'], coalesce_key($params, 'value', ''), coalesce_key($params, 'addttext', ''), coalesce_key($params, 'id', ''));
+	return $request-&gt;create_input_hidden($params);
 }
 
 ?&gt;</diff>
      <filename>lib/module_plugins/function.mod_hidden.php</filename>
    </modified>
    <modified>
      <diff>@@ -18,11 +18,9 @@
 
 function smarty_cms_function_mod_textbox($params, &amp;$smarty)
 {
-	$module =&amp; $smarty-&gt;get_template_vars('cms_mapi_module');
-	$id = $smarty-&gt;get_template_vars('cms_mapi_id');
-	#$return_id = $smarty-&gt;get_template_vars('cms_mapi_return_id');
+	$request =&amp; $smarty-&gt;get_template_vars('request');
 
-	return $module-&gt;create_input_text($id, $params['name'], coalesce_key($params, 'value', ''), coalesce_key($params, 'size', '10'), coalesce_key($params, 'maxlength', '255'), coalesce_key($params, 'addttext', ''), coalesce_key($params, 'id', ''));
+	return $request-&gt;create_input_text($params);
 }
 
 ?&gt;</diff>
      <filename>lib/module_plugins/function.mod_textbox.php</filename>
    </modified>
  </modified>
  <removed type="array"/>
  <parents type="array">
    <parent>
      <id>b2d2ccd7a6a7dc2f086772d3818d9f51e50ec8a4</id>
    </parent>
  </parents>
  <author>
    <name>wishy</name>
    <email>wishy@3d254a34-79dc-0310-9e5f-be208747d8a0</email>
  </author>
  <url>http://github.com/tedkulp/cmsmadesimple-2-0/commit/d574446b4cf300cee6184e80b7b066ef170c0141</url>
  <id>d574446b4cf300cee6184e80b7b066ef170c0141</id>
  <committed-date>2008-12-14T10:32:50-08:00</committed-date>
  <authored-date>2008-12-14T10:32:50-08:00</authored-date>
  <message>Added the CmsModuleRequest class, which is only implemented in the admin for the moment
Moving module form methods out of CmsModuleBase to CmsModuleRequest and converting them to array input style

git-svn-id: http://svn.cmsmadesimple.org/svn/cmsmadesimple/trunk@5346 3d254a34-79dc-0310-9e5f-be208747d8a0</message>
  <tree>dc25128b4fa925cf72518d8b0c385fcd80784a48</tree>
  <committer>
    <name>wishy</name>
    <email>wishy@3d254a34-79dc-0310-9e5f-be208747d8a0</email>
  </committer>
</commit>
