# ROM (Request Object MOdel)

ROM (Request Object Model) is an abstractaction layer for Request Components like GET, POST, COOKIE, SESSION, File Upload, HTTP Request etc..... You can access the Instance of ROM through $this->request Object from your controller. ROM is not limited in your Controller, you can even use them outside of your controller, actually $this->request Object in Controller is a reference to $request global object. So You can use $request global Object anywhere in your Application. So whatever you can do with $request you can do that same thing with $this->request and vice versa.

$request or $this->request object is an Instance of zRom Class.

## GET Request

You can access get request parameters using $_GET as previous. However $this->request->get also let You not only access GET request parameters also do more with them.$this->request->get->items is an associative array just like$_GET. $this->request->get->valueOf('fieldName'); will also return value of that form field if the form field exists else return false. e.g. If your error level is E_NOTICE PHP will fire Notice if you try to use $this->request->get->items['someNonExistingField'] It will say index doesn't exist or similar Notice message. But if you use $this->request->get->valueOf('someNonExistingField') It will return false so PHP will not fire any message. $this->request->get might seem to be big to write so in your controller You can use $this->getPeer Thats a reference to $this->request->get;

$this->request->get is an instance of zRom_form Class. You can check wheather the form is submitted or not by issuing $this->request->get->isSubmitted()

Zigmoyd lets you Validate both get and post requests in the same way. and obviously through [[validation]] map. You put a [[validation]] map with .vld.map.php in etc/conf.d Directory in your Project's directory. assume your [[validation]] Map name is abcd.vld.map.php

you need to invoke $this->request->get->initValidator('abcd'); To use that [[Validation]] Map to validate get request. after you have invoked initValidator() [[validation]] has also been done and you can see the result. If you now invoke $this->request->get->isValid it will return you a boolean value wheather or not the form is completely valid.

you can also check on the basis of particular form field. after invoking initValidator() you will get Objects representing their corresponding form fields e.g. $this->request->get->formFieldName. so If you have a form field called name it will be represented by $this->request->get->name which will have a method called isValid() by which you can check wheather or not that name form field is valid. you can also do several other things like.

these field objects are of zRom_fields Type
• $this->request->get->name->value this attribute holds the value entered for name form field • $this->request->get->name->isValid
this attribute holds wheather or not name form field is valid
• $this->request->get->name->isValid() same as th above just an access method. • $this->request->get->name->err_msg
this attribute holds the error message applicable for this form field. (Subjected to be changed to errMsg in Next version)
• $this->request->get->name->validationStatus generally holds an integer value of the corresponding index of the [[validation]] rule/criteria violeted. • . ## POST Request Handling POST requests are just same as handling get requests in every way. You can access post request parameters using $_POST as previous. However $this->request->post also let You not only access POST request parameters also do more with them.$this->request->post->items is an associative array just like $_POST. $this->request->post->valueOf('fieldName'); will also return value of that form field if the form field exists else return false. e.g. If your error level is E_NOTICE PHP will fire Notice if you try to use $this->request->post->items['someNonExistingField'] It will say index doesn't exist or similar Notice message. But if you use $this->request->post->valueOf('someNonExistingField') It will return false so PHP will not fire any message.

$this->request->post might seem to be big to write so in your controller You can use $this->postPeer Thats a reference to $this->request->post; See also: $this->request->post is an instance of zRom_form Class.
You can check wheather the form is submitted or not by issuing $this->request->post->isSubmitted() Zigmoyd lets you Validate both post and post requests in the same way. and obviously through [[validation]] map. You put a [[validation]] map with .vld.map.php in etc/conf.d Directory in your Project's directory. assume your [[validation]] Map name is abcd.vld.map.php you need to invoke $this->request->post->initValidator('abcd'); To use that [[Validation]] Map to validate post request.

after you have invoked initValidator() [[validation]] has also been done and you can see the result. If you now invoke $this->request->post->isValid it will return you a boolean value wheather or not the form is completely valid. you can also check on the basis of particular form field. after invoking initValidator() you will post Objects representing their corresponding form fields e.g. $this->request->post->formFieldName. so If you have a form field called name it will be represented by $this->request->post->name which will have a method called isValid() by which you can check wheather or not that name form field is valid. you can also do several other things like. See also: these field objects are of zRom_fields Type • $this->request->post->name->value
this attribute holds the value entered for name form field
• $this->request->post->name->isValid this attribute holds wheather or not name form field is valid • $this->request->post->name->isValid()
same as th above just an access method.
• $this->request->post->name->err_msg this attribute holds the error message applicable for this form field. (Subjected to be changed to errMsg in Next version) • $this->request->post->name->validationStatus
generally holds an integer value of teh corresponding index of the [[validation]] rule/criteria violeted.
• .

## Session

Session object is located on $this->request->session. which is actually an instance of zSession Class. When Instantiated you can additionally do some magic operations like $this->request->session->setEncryptedKey('key'), $this->request->session->getEncryptedKey(),$this->request->session->setKey('value'), $this->request->session->getKey('value'),$this->request->session->getKey()

However you can still use $_SESSION ## Cookie Cookie object is located on $this->request->cookie. which is actually an instance of zCookie Class. When Instantiated you can additionally do some magic operations like $this->request->cookie->setEncryptedKey('key'),$this->request->cookie->getEncryptedKey(), $this->request->cookie->setKey('value'),$this->request->cookie->getKey('value'), $this->request->cookie->getKey() However you can still use $_COOKIE

By default Zigmoyd upload's everything on transfer/up Directory in your Project's directory.

Upload works more or less same as GET/POST requests and is very simple.First you should check wheather or the form has been submitted using $this->request->file->isSubmitted(), however you can also do this through $this->isUploadRequest().

Now Invoke doUpload() Method $this->request->file->doUpload() that does the Uploading job.It returns true/false depending upon success or failure. You can simply code something like. if($this->request->file->isSubmitted()){
if($this->request->file->doUpload()){ //Uploaded Successfully }else{ //Problem while Uploading } }else{ //Form not yet Submitted } \sa See \ref uploadPage "Upload Page" for more information on it.  You can also invoke Validation Maps through $this->request->file->initValidator() method in the same way.

## HTTP Request

You can use $this->request->client to get Client Request attributes and $this->request->server to get server information. You can execute (you can understand their usage by their names)
• $this->request->client->browser •$this->request->client->userAgent
• $this->request->client->host •$this->request->client->accept
• $this->request->client->acceptLanguage •$this->request->client->acceptCharSet
• $this->request->client->acceptEncoding •$this->request->client->connection
• $this->request->client->remotePort •$this->request->client->remoteAddr
• $this->request->client->requestMethod •$this->request->client->request
• $this->request->client->version •$this->request->client->platform

• $this->request->server->software •$this->request->server->signature
• $this->request->server->port •$this->request->server->name
• $this->request->server->address •$this->request->server->admin
• \$this->request->server->protocol

### Constants

You can also define constants that can access easily to identify Client's Browser/Operating system. They are
• CLIENT_OS
• IS_WIN
• IS_WINDOWS
• IS_MAC
• IS_MACINTOSH
• IS_LINUX
• IS_OS2
• IS_BEOS

• CLIENT_BROWSER
• IS_OPERA
• IS_WEBTV
• IS_IE
• IS_NETPOSITIVE
• IS_MSIE
• IS_MSPIE
• IS_GALEON
• IS_KONQUEROR
• IS_ICAB
• IS_OMNIWEB
• IS_PHOENIX
• IS_FIREBIRD
• IS_FIREFOX
• IS_MOZILLA
• IS_AMAYA
• IS_LYNX
• IS_SAFARI
• IS_NETSCAPE

CLIENT_OS Holds the Operating System name of Client as a string. and you can run a switch case using CLIENT_OS in the switch and other IS_.... in cases.

Same applies in Browser Checks too.

Generated on Mon Oct 27 23:51:59 2008 for zigmoyd.kdevelop by  1.5.6