public
Description: Git mirror of the CMS Made Simple 2.0 rewrite
Homepage: http://cmsmadesimple.org
Clone URL: git://github.com/tedkulp/cmsmadesimple-2-0.git
Added a flag to mod_form that will force the current url to be used 
instead of calculating it
Now passing return_id properly into the $_REQUEST when we calculate routes 
from modules

Signed-off-by: Ted Kulp <ted@cmsmadesimple.org>


git-svn-id: http://svn.cmsmadesimple.org/svn/cmsmadesimple/trunk@4365 
3d254a34-79dc-0310-9e5f-be208747d8a0
tedkulp (author)
Sun Feb 24 09:47:11 -0800 2008
commit  4d7afc34ff509486313f251b31589b38db112112
tree    e9364391bbb9b1eefbb0d956a1cdc90f1a5de63b
parent  eab0c3aa5906d91e264d5aa880c0e219b8db46c2
...
93
94
95
 
96
97
98
...
93
94
95
96
97
98
99
0
@@ -93,6 +93,7 @@ class CmsRoute extends CmsObject
0
           }
0
 
0
           $_REQUEST['mact'] = $matches['module'] . ',' . $matches['id'] . ',' . $matches['action'] . ',' . $matches['inline'];
0
+ $_REQUEST[$matches['id'] . 'returnid'] = $matches['returnid'];
0
           $page = $matches['returnid'];
0
           $smarty->id = $matches['id'];
0
 
...
936
937
938
 
939
940
 
941
942
943
 
944
945
946
...
936
937
938
939
940
 
941
942
943
 
944
945
946
947
0
@@ -936,11 +936,12 @@ abstract class CmsModuleBase extends CmsObject
0
    * @param string Text to append to the end of the id and name of the form
0
    * @param array Extra parameters to pass along when the form is submitted
0
    * @param string Text to append to the <form>-statement, for instanse for javascript-validation code
0
+ * @param boolean A flag to determine if the action should just redirect back to this exact page
0
    */
0
- public function create_form_start($id, $action='default', $returnid='', $method='post', $enctype='', $inline=false, $idsuffix='', $params = array(), $extra='', $html_id = '')
0
+ 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)
0
   {
0
     $this->load_form_methods();
0
- return cms_module_CreateFormStart($this, $id, $action, $returnid, $method, $enctype, $inline, $idsuffix, $params, $extra, $html_id);
0
+ return cms_module_CreateFormStart($this, $id, $action, $returnid, $method, $enctype, $inline, $idsuffix, $params, $extra, $html_id, $use_current_page_as_action);
0
   }
0
 
0
   /**
...
25
26
27
28
 
29
30
31
...
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
 
 
 
 
 
 
 
 
 
60
61
62
...
66
67
68
69
 
 
 
 
 
 
 
70
71
72
...
25
26
27
 
28
29
30
31
...
43
44
45
 
 
46
47
48
 
 
 
 
 
 
 
 
 
49
50
51
52
53
54
55
56
57
58
59
60
...
64
65
66
 
67
68
69
70
71
72
73
74
75
76
0
@@ -25,7 +25,7 @@
0
  * @package    CMS
0
  */
0
 
0
-function cms_module_CreateFormStart(&$modinstance, $id, $action='default', $returnid='', $method='post', $enctype='', $inline=false, $idsuffix='', $params = array(), $extra='', $html_id = '')
0
+function cms_module_CreateFormStart(&$modinstance, $id, $action='default', $returnid='', $method='post', $enctype='', $inline=false, $idsuffix='', $params = array(), $extra='', $html_id = '', $use_current_page_as_action = false)
0
 {
0
   global $gCms;
0
 
0
@@ -43,20 +43,18 @@ function cms_module_CreateFormStart(&$modinstance, $id, $action='default', $retu
0
   $idsuffix = cms_htmlentities($idsuffix);
0
   $extra = cms_htmlentities($extra);
0
 
0
- #if ($idsuffix == '')
0
- # $idsuffix = $formcount;
0
   if ($html_id == '')
0
     $html_id = $id.$action.$idsuffix;
0
 
0
- $goto = ($returnid==''?'moduleinterface.php':'index.php');
0
- #$goto = 'moduleinterface.php';
0
- if ($inline && $returnid != '')
0
- {
0
- #$goto = 'index.php?module='.$this->get_name().'&amp;id='.$id.'&amp;'.$id.'action='.$action;
0
- #$goto = 'index.php?mact='.$this->get_name().','.$id.','.$action;
0
- #$goto .= '&amp;'.$id.'returnid='.$returnid;
0
- #$goto .= '&amp;'.$this->cms->config['query_var'].'='.$returnid;
0
- }
0
+ if ($returnid == null)
0
+ $returnid = '';
0
+
0
+ $goto = '';
0
+ if ($use_current_page_as_action)
0
+ $goto = CmsRequest::get_requested_uri();
0
+ else
0
+ $goto = ($returnid==''?'moduleinterface.php':'index.php');
0
+
0
   $text = '<form id="'.$html_id.'" name="'.$id.$action.$idsuffix.'" method="'.$method.'" action="'.$goto.'"';
0
   if ($enctype != '')
0
   {
0
@@ -66,7 +64,13 @@ function cms_module_CreateFormStart(&$modinstance, $id, $action='default', $retu
0
   {
0
     $text .= ' '.$extra;
0
   }
0
- $text .= '><div class="hidden"><input type="hidden" name="mact" value="'.$modinstance->get_name().','.$id.','.$action.','.($inline == true?1:0).'" />';
0
+
0
+ if ($use_current_page_as_action)
0
+ $text .= '><div class="hidden">';
0
+ else
0
+ $text .= '><div class="hidden"><input type="hidden" name="mact" value="'.$modinstance->get_name().','.$id.','.$action.','.($inline == true?1:0).'" />';
0
+
0
+
0
   if ($returnid != '')
0
   {
0
     $text .= '<input type="hidden" name="'.$id.'returnid" value="'.$returnid.'" />';
...
36
37
38
39
 
 
40
41
42
...
36
37
38
 
39
40
41
42
43
0
@@ -36,7 +36,8 @@ function smarty_cms_block_mod_form($params, $content, &$smarty, &$repeat)
0
         coalesce_key($params, 'id_suffix', ''),
0
         coalesce_key($params, 'params', array()),
0
         coalesce_key($params, 'extra', ''),
0
- coalesce_key($params, 'id', '')) .
0
+ coalesce_key($params, 'id', ''),
0
+ coalesce_key($params, 'use_current_page_as_action', false)) .
0
         $content . $module->create_form_end();
0
     }
0
   }

Comments

    No one has commented yet.