Add a new Navigation Destination (will add a new functional node to this software accessible as http://.../your_script.cgi?NAVG=TheNewDestination)
Is it for Public access or it's only for Administrator's use? Public destinations are accessible through urls like http://...../x.cgi?NAVG=MyPage and are designed to be used by everyone looking at your web-site. Administrator's destinations are accessible only through the admin/admin.cgi script with urls like http://.../admin/admin.cgi?NAVG=MyPage. Depends on this we store the correspondent perl module (.pm file) implementing the destination either under DBPUB1/NAVG directory (public) or under DBPUB1/ADMIN directory (administrator's). Select the directory: NAVG ADMIN
Destination name. It will be part of a filename so make it short, alphanumeric with not spaces. The implementation of the destination will be as a perl module (.pm file) with the same name. For example if your destination is MyPage a perl module with name MyPage.pm will be created. You will access it as http://.../your_script.cgi?NAVG=MyPage example: NewPage
Define the input:
Define in this table which parameters we pass from the web form to the script:
Form field name:
Field label. We show this string on the pages when have to mention beautifully this form field.
Initial value defined in the html form:
Input checked by script?
Default value set by script if empty value is received from the form:
not mandatory non-empty string digits only url format email address
Except the above list of parameters we pass the hidden variable NAVG with value the destination name. You do not have to enter it in the above table because it is considered automatically. Based on the above input an input cgi form template file will be created just for testing purposes. The file name is formed by the destination name followed by suffix -form.htm. Later You can edit this file with your favorite html editor to make it looking more nicely or delete it if your destination does not need it.
Flat-file DataBase Setup:
You can use a simple text files as a data storage for this application. It's recommended for short databases with no more than 1000 records. For bigger databases and better performance you should use a SQL database server. Our flat-file database format includes | as a field separator and the new line symbol as a record separator. If you consider to use this way for data storage enter the path to the data file. Use full or relative to the script directory path. There is a special directory data in this software where you may wish to store your database files. Leave this field empty if you consider to use SQL database server instead or if this destination does not need any database processing. example: data/my_test_db.txt
Enter the names of the database fields in same order as they appear in the file record. Separate them by spaces or commas. The first field will be the unique key for our database. example: AccountID FirstName LastName Address Telephone
The following actions will be performed in the same order as follows: 1.delete rows. First we can delete some rows from our data-base which matched our criteria. The criteria is a perl expression which we will evaluate for every database row. If it returns 1 we will delete that row. We store the current database row in a hash reference variable $row. The cgi input is stored in hash %in. You can access the values of the database row as string \$\$row{'a_field_name'} and the form input variables as \$in{'an_input_variable'}. expression syntax: < - returns true if the left argument is numerically less than the right argument > - returns true if the left argument is numerically greater than the right argument <= - returns true if the left argument is numerically less than or equal to the right argument >= - returns true if the left argument is numerically greater than or equal to the right argument lt - returns true if the left argument is stringwise less than the right argument gt - returns true if the left argument is stringwise greater than the right argument le - returns true if the left argument is stringwise less than or equal to the right argument ge - returns true if the left argument is stringwise greater than or equal to the right argument == - returns true if the left argument is numerically equal to the right argument != - returns true if the left argument is numerically not equal to the right argument eq - returns true if the left argument is stringwise equal to the right argument ne - returns true if the left argument is stringwise not equal to the right argument (, ), and, or, not, xor - the standard boolean operators example: \$\$row{'AccountID'} eq 'AC1655643' - will delete account # AC1655643 example: \$\$row{'AccountID'} eq \$in{'ID'} - will delete account with number equal to the value of the cgi input form field ID as entered by user. example: (\$\$row{'Age'} < 18) and (not \$\$row{'PaidAccount'}) - will delete all non-paid accounts of people of age less than 18 years. As well you can use regular expressions: example: \$\$row{'email'} =~ /hotmail.com/i - will delete all accounts of people having free email accounts with hotmail.com Leave this field empty if we do not have to delete any rows from the data file.
2.add /update a row. We can create a new database record with the values passed from the web form. Note that some database fields may left empty if there is no variable passed from the web form with the same name as the database field name. Should we add or update rows this way: No Yes
3.search. Perform a search using the criteria below. For each search result the database field values are stored in %out and could be shown using a template as defined later below. Leave it empty to disable the search action. example: (\$\$row{'FirstName'} eq 'Robert') AND ( \$\$row{'LastName'} !~ /^Mon/) - will find all accounts with first personal name Robert but with family name not starting with Mon. example: \$\$row{'FirstName'} eq \$in{'find_by_name'} - will find people having first name equal to the value of the cgi input form field find_by_name as entered by user. example: (\$\$row{'price'} <= 5000) and (\$\$row{'Model'} eq 'Ford Escort') - will find all cars with price no more than 5000 and model is Ford Escort. example: \$\$row{'email'} !~ /yahoo.com/i - will find all accounts of people who do not have free email accounts with yahoo.com example: 1 - will show the entire database because this criteria expression returns always 1 (TRUE).
If you wish to have results sorted by a field fill the name below. example: FirstName - will sort by first name. example: \$in{'sort_by'} - will sort results by field name entered by user.
Sort by this field:
Order
Comparison
SQL DataBase Setup:
Which database to use? This destination will use the database server settings as defined in Admin Panel -> Configure The Software page. However you can specify a different database name below or leave empty to use the default one.
The script will run SQL queries in the same order as they appear below. If not applicable leave any of the text areas empty.
SQL query1 for general purpose: (add/update/delete records): example: REPLACE accounts SET AccountID='543', FirstName='John' - will add a new account or update an existing account with ID 543 example: DELETE FROM accounts WHERE AccountID='543' - will delete account with ID 543
SQL query2 for general purpose: (add/update/delete records):
SQL query for search purpose: (will use select operator to search in database):
FROM clause: defines which database table to read. example: FROM accounts - will search in table accounts
WHERE clause: defines logical expression which table's rows should match. You can leave this field empty to get all table records. example: WHERE (FirstName like "Rob%") - will find people having first name starting with Rob. example: WHERE (FirstName = "\$in{'find_by_name'}") - will find people having first name equal to the value of the cgi input form field find_by_name as entered by user.
ORDER BY clause: how to order the search results. example: ORDER BY FirstName - will order the search results by FirstName.
Define the output:
Search results template file. This template file defines how a search result will appear on the page. The resulted record fields values will be accessible via %out hash variable as \$out{'a_field_name'}, ... Also you can use an additionally generated variable: \$out{'result_number'} which is the current result number. Leave this field empty to use a default file name formed by the destination name plus suffix -sr.htm. If the template file does not exists and there is search activity defined for this destination an default template file is automatically created just for testing purposes. example: NewPage-sr.htm (create/update file) Which fields to include in the results template if have to autogenerate it? example: AccountID FirstName LastName Address Telephone
Use a html template an output for this destination? This file will reside either under your templates/en or templates/admin directory depending on if it is for public of admin use. Also if you make is for public use, may wish to design not only default public english version (in templates/en) but html versions for other languages as well. It's recommended but not mandatory to keep the template name same as the destination name. For example if the destination is MyPage use a template file name MyPage.htm. This will make the process more clean and easy to support. IF A SEARCH ACTION IS ENABLED for this destinations we can put in our template file the following strings - values of the output hash variable %out: \$out{'start'} - start showing results from this number \$out{'end'} - finish showing results to this number \$out{'results'} - the search results in html code \$out{'number_of_results'} - number of found search results \$out{'number_of_pages'} - number of generated search result pages \$out{'page'} - current search results page number \$out{'per_page'} - number of results per page \$out{'links_to_pages'} - links to all of the generated search result pages If variable per_page is not passed to the script we show by default 50 results per page. Also we can pass parameter page telling the script which search results page to show. Default page to show is number one. For example: http://.../x.cgi?NAVG=MySearchEngine&per_page=20 &page=5 will return the 20 search results from the 5th search results page. Enter the name of template file below: example: NewPage.htm (create/update file) or left it empty to make response as a simple message: