Updated CodeCorner2 (markdown)

leithoff 2016-07-07 14:51:18 +02:00
parent b5f1e84f4d
commit 6357403896

@ -133,27 +133,63 @@ var $public_functions = array(
'testinterface' => True, 'testinterface' => True,
); );
``` ```
... to our code. ... to our code. Much better. We recieve our inital page o.k.
Much better, but some nagging error in the upper left corner of the frame where our app appears: ```An error occurred``` ... we added
```php
public function create_header ()
{
common::egw_header();
echo parse_navbar();
}
public function create_footer ()
{
common::egw_footer();
}
```
so we recieve our inital page o.k.
But on Submit. It just did not work. After some work we figured out that ```$_SERVER['PHP_SELF']``` is But on Submit. It just did not work. After some work we figured out that ```$_SERVER['PHP_SELF']``` is
pointing to eGroupware Base ```index.php```. So we had to make our form-action more specific: pointing to eGroupware Base ```index.php```. So we had to make our form-action more specific:
```php ```php
echo "<form action='".$_SERVER['PHP_SELF']."?menuaction=test.test_ui.testinterface' method='post'> echo "<form action='".$_SERVER['PHP_SELF']."?menuaction=test.test_ui.testinterface' method='post'>
``` ```
this is in no way eGroupwarer - style. So this needs further refinement. this is in no way eGroupwarer - style. So this needs further refinement. We ended up with this whole class
```php
<?php
class test_ui
{
var $public_functions = array(
'testinterface' => True,
);
public function testinterface ()
{
if (trim($_POST['fname'].$_POST['sname'])!='')
{
echo "<br>Hello ".$_POST['fname']." ".$_POST['sname']."<br>";
echo "<form action='".$GLOBALS['egw']->link('/index.php',array(
'menuaction' => 'test.test_ui.testinterface','message'=>'YES'))."' method='post'>
<input type='submit' value=' Reload '>
</form>";
}
else
{
echo "Type a name to be greeted accordingly <br>";
echo "<form action='".$GLOBALS['egw']->link('/index.php',array(
'menuaction' => 'test.test_ui.testinterface','message'=>'NO'))."' method='post'>
<p>first name:<br><input name='fname' type='text' size='30' maxlength='30'></p>
<p>name:<br><input name='sname' type='text' size='30' maxlength='40'></p>
<input type='submit' value=' Submit '>
<input type='reset' value=' Cancel'>
</form>";
}
}
}
```
So what is new here?
It is the link functionality:
```$GLOBALS['egw']->link('/index.php',array('menuaction' => 'test.test_ui.testinterface','message'=>'YES'))```
It does enable you to call the required function/action of any application and add a key/value pair to that call.
The whole thing looked like that:
The link functionality provides the possibility to link to internal sites and pass on all internally needed information plus the call of a function with some infos to pass in ```$_GET```
So we introduced functions and the call of a function as well. The major way to call functions within eGroupware is, to call them via build in functions that handle the inclusion and instantiation of the needed classes.
```ExecMethod('test.test_ui.send_request', 'YES');```
Execute a function, and load a class and include the class file if not done so already. This function is used to create an instance of a class, and if the class file has not been included it will do so.
```ExecMethod2('test.test_ui.send_request2', 'YES', 'SOME MORE');```
Execute a function with multiple arguments. The function can take object $GLOBALS[classname] from class if it exists.
So we fiddled around with that a bit more and called it a day.
At the campfire we discussed [[Cross Site Scripting|Cross Site Scripting]] and how to handle/avoid that pitfall.
***
> [Wiki](Home) ▸ [Developer Docs](Developer Docs) ▸ [Code Corner](Code Corner) ▸ **day two** ▸ [day three](CodeCorner3)