ultimix
forms.php
Go to the documentation of this file.
1 <?php
2 
3  /*
4  * This source code is a part of the Ultimix Project.
5  * It is distributed under BSD license. All other third side source code (like tinyMCE) is distributed under
6  * it's own license wich could be found from the corresponding files or sources.
7  * This source code is provided "as is" without any warranties or garanties.
8  *
9  * Have a nice day!
10  *
11  * @url http://ultimix.sorceforge.net
12  *
13  * @author Alexey "gdever" Dodonov
14  */
15 
27  {
38  var $Output = false;
39 
50  var $CachedMultyFS = false;
51  var $Mail = false;
52  var $PackageSettings = false;
53  var $String = false;
54  var $SecurityUtilities = false;
55 
66  function __construct()
67  {
68  try
69  {
70  $this->CachedMultyFS = get_package( 'cached_multy_fs' , 'last' , __FILE__ );
71  $this->Mail = get_package( 'mail' , 'last' , __FILE__ );
72  $this->PackageSettings = get_package_object( 'settings::package_settings' , 'last' , __FILE__ );
73  $this->String = get_package( 'string' , 'last' , __FILE__ );
74  $this->SecurityUtilities = get_package( 'security::security_utilities' , 'last' , __FILE__ );
75  }
76  catch( Exception $e )
77  {
78  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
79  }
80  }
81 
100  private function send_email( $Email )
101  {
102  try
103  {
104  $From = $this->PackageSettings->get_package_setting(
105  'gui::forms' , 'last' , 'cf_forms' , 'from_email' , 'no_answer@localhost'
106  );
107 
108  $To = $this->PackageSettings->get_package_setting(
109  'gui::forms' , 'last' , 'cf_forms' , 'to_email' , 'admin@localhost'
110  );
111 
112  $Subject = $this->PackageSettings->get_package_setting(
113  'gui::forms' , 'last' , 'cf_forms' , 'subject' , 'New message'
114  );
115 
116  $this->Mail->send_email( $From , $To , $Subject , $Email );
117  }
118  catch( Exception $e )
119  {
120  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
121  }
122  }
123 
142  function send_form( &$Options )
143  {
144  try
145  {
146  $EmailFile = $Options->get_setting( 'email_template' );
147 
148  $Email = $this->CachedMultyFS->get_template( __FILE__ , "$EmailFile.tpl" );
149 
150  $Data = $this->SecurityUtilities->get_all_posted_data();
151 
152  $Email = $this->String->print_record( $Email , $Data );
153 
154  $this->send_email( $Email );
155  }
156  catch( Exception $e )
157  {
158  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
159  }
160  }
161 
180  function draw_form( &$Options )
181  {
182  try
183  {
184  $FormFile = $Options->get_setting( 'form_template' );
185 
186  $this->Output = $this->CachedMultyFS->get_template( __FILE__ , "$FormFile.tpl" );
187  }
188  catch( Exception $e )
189  {
190  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
191  }
192  }
193 
216  function compile_form( &$Settings )
217  {
218  try
219  {
220  $this->draw_form( $Settings );
221 
222  return( $this->Output );
223  }
224  catch( Exception $e )
225  {
226  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
227  }
228  }
229 
248  function controller( $Options )
249  {
250  try
251  {
252  $ContextSet = get_package( 'gui::context_set' , 'last' , __FILE__ );
253 
254  $ContextSet->add_context( dirname( __FILE__ ).'/conf/cfcx_send_form' );
255 
256  $ContextSet->execute( $Options , $this , __FILE__ );
257  }
258  catch( Exception $e )
259  {
260  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
261  }
262  }
263 
286  function view( &$Options )
287  {
288  try
289  {
290  $ContextSet = get_package( 'gui::context_set' , 'last' , __FILE__ );
291 
292  $ContextSet->add_context( dirname( __FILE__ ).'/conf/cfcx_draw_form' );
293 
294  $ContextSet->execute( $Options , $this , __FILE__ );
295 
296  return( $this->Output );
297  }
298  catch( Exception $e )
299  {
300  $a = func_get_args();_throw_exception_object( __METHOD__ , $a , $e );
301  }
302  }
303  }
304 
305 ?>