Project

General

Profile

How to add a launch page » History » Version 6

Amber Herold, 08/15/2012 11:04 AM

1 1 Amber Herold
h1. How to add a job launch page to the Appion pipeline
2
3 4 Amber Herold
# *Add a php page with the basic appion template*
4 5 Amber Herold
 
5 4 Amber Herold
Most of our launch pages are php files with at leat 2 functions, one to create a form for the user to fill out, and another to build a job command when the user submits the form. You can copy an existing PHP file such as runSimple.php to create your new launch page. To give your page the Appion processing page look and feel with the header and side menu, be sure the functions processing_header($title,$heading,$javascript) and processing_footer() are called. 
6
## Modifying the createForm() function
7
The create form function outputs the html needed for your form. The myami/myamiweb/processing/inc/forms directory holds reusable form classes based on the basicForm.inc class. Any combination of these can be used to add parameters to your form with little knowlege of html. You may also create a new form class to define the parameters specific to your job command. More on that later.
8 5 Amber Herold
 
9 4 Amber Herold
# *Add a link to your page in the menuprocessing.php file or from another page*
10 5 Amber Herold
 
11 4 Amber Herold
The menuprocessing file is a bit tricky to work with.
12 5 Amber Herold
 
13 4 Amber Herold
# *Create a new form class for your package specific parameters*
14 5 Amber Herold
 
15 4 Amber Herold
You can copy simpleParamsForm.inc as a template for your own form parameters. There are 2 primary functions to define.
16
## Define the constructor
17
This is where all your parameters are listed. Values passed into the constructor become default values. Validations can be added to any of the parameters.
18
## Define the generateForm() function
19
This function outputs html. There are many predefined parameter fields that can be used to build your form.
20 5 Amber Herold
 
21 4 Amber Herold
# *Add pop-up help messages to help.js*
22 5 Amber Herold
 
23 4 Amber Herold
Located at myami/myamiweb/processing/js/help.js.
24
## Add a new namespace for your form, you can copy the 'simple' section. Don't forget any commas.
25
## add a help string for each of the parameter keys in your form
26
## make sure $javascript .= writeJavaPopupFunctions(); is in your createForm() function in your php launch page prior to the processing header function.
27 5 Amber Herold
 
28 4 Amber Herold
# *Add a publication reference for the package you are using*
29 5 Amber Herold
 
30 4 Amber Herold
## Edit /myami/myamiweb/processing/inc/publicationList.inc to include an entry for any references you need to add to your launch page.
31
## publications can be added to a page with the following code:
32 3 Amber Herold
<pre>
33 4 Amber Herold
	$pub = new Publication('appion'); 
34
	echo $pub->getHtmlTable(); //returns the html reference to the "appion" publication
35 3 Amber Herold
</pre>
36 6 Amber Herold
&nbsp;
37
# *Use your new form class in your launch page*
38
&nbsp;
39
## Modify the launch page createForm() function
40
### Add a call to your form class generateForm() function, adding default values in the constructor.
41
<pre>
42
	$simpleParamsForm = new SimpleParamsForm('','','','CHECKED','','','10','30','','20','100','2','2','10','','0.8','40','3','3');
43
	echo $simpleParamsForm->generateForm();
44
</pre>
45
### Add a reference to your publication
46
<pre>
47
	$pub = new Publication('appion');
48
	echo $pub->getHtmlTable();
49
</pre>
50
## Modify the launch page createCommand() function
51
### instantiate and validate your form parameters
52
<pre>
53
	$simpleParamsForm = new SimpleParamsForm();
54
	$errorMsg .= $simpleParamsForm->validate( $_POST );
55
</pre>
56
### Create your new command
57
<pre>
58
	/* *******************
59
	 PART 2: Create program command
60
	 ******************** */
61
	$command = "runSimpleCluster.py ";
62
	
63
	// add run parameters
64
	$command .= $runParametersForm->buildCommand( $_POST );
65
66
	// add simple parameters
67
	$command .= $simpleParamsForm->buildCommand( $_POST );
68
</pre>
69
### Add a reference to your publication in the header info
70
### Change the jobtype passed in showOrSubmitCommand()