The constants are defined as perl subroutines.
- P4CGI::MAIN_URL()
-
Main entry point.
- P4CGI::DTB_URL()
-
URL to depot tree browser.
- P4CGI::CHB_URL()
-
URL to change browser.
- P4CGI::CHV_URL()
-
URL to change viewer.
- P4CGI::FV_URL()
-
URL to file viewer.
- P4CGI::SFV_URL()
-
URL to special file viewer.
- P4CGI::FLV_URL()
-
URL to file log viewer.
- P4CGI::FDV_URL()
-
URL to file diff viewer.
- P4CGI::LDV_URL()
-
URL to label diff viewer.
- P4CGI::SFF_URL()
-
URL to search for file.
- P4CGI::LAU_URL()
-
URL to list all users.
- P4CGI::LU_URL()
-
URL to view a user.
- P4CGI::LAB_URL()
-
URL to list all branches.
- P4CGI::LAL_URL()
-
URL to list all labels.
- P4CGI::LV_URL()
-
URL to view a labels.
- P4CGI::DTB_UPDATE()
-
Update data files for depot tree browser.
- P4CGI::DTB_LOCKFILE()
-
Lock file name
- P4CGI::DTB_FILESPLIT()
-
Number of data files to split data to.
- P4CGI::DTB_DATAFILE()
-
Data file base name
Return CGI reference
Example:
my $file = P4CGI::cgi()->param("file") ;
print "Parameter \"file\" value: $file\n" ;
Request data from p4. Calls p4 with command command and returns data in result.
This function is really three different functions depeding in the type of
the
result parameter.
- result
-
This parameter can be of three different types:
- Filehandle (typeglob)
-
Data from command can be read from filehandle. NOTE! File must be closed by
caller.
- Reference to array
-
Returns result from command in array (newlines stripped)
- Reference to scalar
-
Returns result from command in scalar. (lines separated by newline)
Any other type of parameter will abort operation
- command
-
Command to send to p4 command line client.
Example:
my $d ;
&P4CGI::p4call(\$d,"changes -m 1") ;
$d =~ /Change (\d+)/ or &bail("No contact with P4 server") ;
$currentChangeLevel=$1 ;
Start a page. Print http header and first part of HTML.
- title
-
Title of page
- legend (Optional)
-
Short help text to be displayed at top of page
Example:
my $start = P4CGI::start_page("Title of page",
&P4CGI::dl_list("This","Goto this",
"That","Goto that")) ;
print $start ;
End a page. Print HTML trailer.
Example:
print P4CGI::end_page() ;
Report an error. This routine will emit HTML code for an error message and
exit.
- message
Message that will be displayed to user
-
Example:
unless(defined $must_be_defined) {
&P4CGI::bail("was not defined") ;
} ;
Start a table with optional table attributes
- table_attribute_text
-
This text will be inserted as attributes to table tag
Example:
print P4CGI::start_table("align=center border") ;
Return end of table string. (trivial function included mostly for symmetry)
Insert a row in table.
- options
-
A list of key/value pairs (a hash will do just fine) containing options for
the row.
The key must start with a ``-''.
Most key/value pairs are treated as attributes to the <TR>-tag. The
following keys are recognized as special:
- -type
-
Type of cells. Default is <TD>-type.
- -anykey
-
anykey will be assumed to be a row option and will be inserted in the TR-tag. The
value for the option is the key value, unless value is empty or undefined,
in which case the option anykey is assumed to have no value.
- listOfValues
-
Row data. Remaining values are assumed to be data for each cell. The data
is typically the text in the cell but can also be:
- undef
-
An undefined value indicates that the next cell spans more than one column.
- Reference to a hash
-
The has contains two keys: ``-text'' for cell text and ``-type'' for cell
type. All other key/value pairs are treated as attributes to the <TD>
or <TH> tag.
Example:
print P4CGI::start_table("align=center") ;
### print header row
print P4CGI::table_row(-type => "th",
-valign => "top",
-align => "left",
"Heading 1","Heading 2",undef,"Heading 3") ;
### print data
my %h = (-text => "text in hash",
-bgcolor => "blue") ;
print P4CGI::table_row(-valign => "top",
-bgcolor => "white",
"Cell 1",
{-text => "Cell 2",
-bgcolor => "red"},
\%h,
"Cell 3-2") ;
print P4CGI::end_table() ;
Return a bulleted list.
- list
-
Lits of data to print as bulleted list
Example:
print P4CGI::ul_list("This","is","a","bulleted","list") ;
Returns a definition list.
- list_of_pairs
-
List of data pairs to print as a definition list. A hash will do just fine,
only that You have no control of the order in the list.
Example:
print P4CGI::dl_list("This","Description of this",
"That","Description of that") ;
Check if file is a valid lock file. Return true if file is a valid lock file.
- file
-
Name of lock file
Example:
if(P4CGI::valid_lockfile("/tmp/lockfile")) {
print "Locked\n" ;
}
Create a valid lock file for this process. Returns true if success.
- file
-
Name of lock file
Example:
P4CGI::create_lockfile("/tmp/lockfile") or die "can't create lockfile!" ;
Convert all '>' to ``>
'', '<' to ``<
'' and '&' to ``&
''.
- str
-
String to convert
Example:
my $cvstr = &P4CGI::fixSpecChar("String containing <,> and &") ;
Create a <A HREF...>...</A> tag pair.
- options
-
Optional list of option-value pairs. Valid options are:
- -url
-
Url for link. Default is current.
- -anchor
-
Anchor in url. Default is none.
Any non-valid option marks the end of the options
- parameters
-
Optional list of parameters for link.
- text
-
The last parameter is used as text for link.
Example:
print &P4CGI::ahref("Back to myself") ; # link to this. No parameters.
print &P4CGI::ahref("-url","www.perforce.com",
"To perforce") ; # link to perforce
print &P4CGI::ahref("-anchor","THERE",
"Go there") ; # link to anchor THERE
print &P4CGI::ahref("-url","chb.cgi",
"FSPC=//depot/.../doc/...",
"Changes for all documentation") ; # url with parameter
Substitutes magic phrases in text with links.
Currently the pattern ``change number'' is replaced with a link to the change browser.
Example:
my $t = "This change is the same as change 4711, but with a twist" ;
print &P4CGI::magic($t) ; # inserts a link to change 4711