Removed unneeded PEAR directories, part of #2020
This commit is contained in:
parent
1589ec3dda
commit
507151aec8
|
@ -1,461 +0,0 @@
|
|||
Documentation for class Archive_Tar
|
||||
===================================
|
||||
Last update : 2001-08-15
|
||||
|
||||
|
||||
|
||||
Overview :
|
||||
----------
|
||||
|
||||
The Archive_Tar class helps in creating and managing GNU TAR format
|
||||
files compressed by GNU ZIP or not.
|
||||
The class offers basic functions like creating an archive, adding
|
||||
files in the archive, extracting files from the archive and listing
|
||||
the archive content.
|
||||
It also provide advanced functions that allow the adding and
|
||||
extraction of files with path manipulation.
|
||||
|
||||
|
||||
Sample :
|
||||
--------
|
||||
|
||||
// ----- Creating the object (uncompressed archive)
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->setErrorHandling(PEAR_ERROR_PRINT);
|
||||
|
||||
// ----- Creating the archive
|
||||
$v_list[0]="file.txt";
|
||||
$v_list[1]="data/";
|
||||
$v_list[2]="file.log";
|
||||
$tar_object->create($v_list);
|
||||
|
||||
// ----- Adding files
|
||||
$v_list[0]="dev/file.txt";
|
||||
$v_list[1]="dev/data/";
|
||||
$v_list[2]="log/file.log";
|
||||
$tar_object->add($v_list);
|
||||
|
||||
// ----- Adding more files
|
||||
$tar_object->add("release/newfile.log release/readme.txt");
|
||||
|
||||
// ----- Listing the content
|
||||
if (($v_list = $tar_object->listContent()) != 0)
|
||||
for ($i=0; $i<sizeof($v_list); $i++)
|
||||
{
|
||||
echo "Filename :'".$v_list[$i][filename]."'<br>";
|
||||
echo " .size :'".$v_list[$i][size]."'<br>";
|
||||
echo " .mtime :'".$v_list[$i][mtime]."' (".date("l dS of F Y h:i:s A", $v_list[$i][mtime]).")<br>";
|
||||
echo " .mode :'".$v_list[$i][mode]."'<br>";
|
||||
echo " .uid :'".$v_list[$i][uid]."'<br>";
|
||||
echo " .gid :'".$v_list[$i][gid]."'<br>";
|
||||
echo " .typeflag :'".$v_list[$i][typeflag]."'<br>";
|
||||
}
|
||||
|
||||
// ----- Extracting the archive in directory "install"
|
||||
$tar_object->extract("install");
|
||||
|
||||
|
||||
Public arguments :
|
||||
------------------
|
||||
|
||||
None
|
||||
|
||||
|
||||
Public Methods :
|
||||
----------------
|
||||
|
||||
Method : Archive_Tar($p_tarname, $compress = null)
|
||||
Description :
|
||||
Archive_Tar Class constructor. This flavour of the constructor only
|
||||
declare a new Archive_Tar object, identifying it by the name of the
|
||||
tar file.
|
||||
If the compress argument is set the tar will be read or created as a
|
||||
gzip or bz2 compressed TAR file.
|
||||
Arguments :
|
||||
$p_tarname : A valid filename for the tar archive file.
|
||||
$p_compress : can be null, 'gz' or 'bz2'. For
|
||||
compatibility reason it can also be true. This
|
||||
parameter indicates if gzip or bz2 compression
|
||||
is required.
|
||||
Return value :
|
||||
The Archive_Tar object.
|
||||
Sample :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object_compressed = new Archive_Tar("tarname.tgz", true);
|
||||
How it works :
|
||||
Initialize the object.
|
||||
|
||||
Method : create($p_filelist)
|
||||
Description :
|
||||
This method creates the archive file and add the files / directories
|
||||
that are listed in $p_filelist.
|
||||
If the file already exists and is writable, it is replaced by the
|
||||
new tar. It is a create and not an add. If the file exists and is
|
||||
read-only or is a directory it is not replaced. The method return
|
||||
false and a PEAR error text.
|
||||
The $p_filelist parameter can be an array of string, each string
|
||||
representing a filename or a directory name with their path if
|
||||
needed. It can also be a single string with names separated by a
|
||||
single blank.
|
||||
See also createModify() method for more details.
|
||||
Arguments :
|
||||
$p_filelist : An array of filenames and directory names, or a single
|
||||
string with names separated by a single blank space.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample 1 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
|
||||
$v_list[0]="file.txt";
|
||||
$v_list[1]="data/"; (Optional '/' at the end)
|
||||
$v_list[2]="file.log";
|
||||
$tar_object->create($v_list);
|
||||
Sample 2 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
|
||||
$tar_object->create("file.txt data/ file.log");
|
||||
How it works :
|
||||
Just calling the createModify() method with the right parameters.
|
||||
|
||||
Method : createModify($p_filelist, $p_add_dir, $p_remove_dir = "")
|
||||
Description :
|
||||
This method creates the archive file and add the files / directories
|
||||
that are listed in $p_filelist.
|
||||
If the file already exists and is writable, it is replaced by the
|
||||
new tar. It is a create and not an add. If the file exists and is
|
||||
read-only or is a directory it is not replaced. The method return
|
||||
false and a PEAR error text.
|
||||
The $p_filelist parameter can be an array of string, each string
|
||||
representing a filename or a directory name with their path if
|
||||
needed. It can also be a single string with names separated by a
|
||||
single blank.
|
||||
The path indicated in $p_remove_dir will be removed from the
|
||||
memorized path of each file / directory listed when this path
|
||||
exists. By default nothing is removed (empty path "")
|
||||
The path indicated in $p_add_dir will be added at the beginning of
|
||||
the memorized path of each file / directory listed. However it can
|
||||
be set to empty "". The adding of a path is done after the removing
|
||||
of path.
|
||||
The path add/remove ability enables the user to prepare an archive
|
||||
for extraction in a different path than the origin files are.
|
||||
See also addModify() method for file adding properties.
|
||||
Arguments :
|
||||
$p_filelist : An array of filenames and directory names, or a single
|
||||
string with names separated by a single blank space.
|
||||
$p_add_dir : A string which contains a path to be added to the
|
||||
memorized path of each element in the list.
|
||||
$p_remove_dir : A string which contains a path to be removed from
|
||||
the memorized path of each element in the list, when
|
||||
relevant.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample 1 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
|
||||
$v_list[0]="file.txt";
|
||||
$v_list[1]="data/"; (Optional '/' at the end)
|
||||
$v_list[2]="file.log";
|
||||
$tar_object->createModify($v_list, "install");
|
||||
// files are stored in the archive as :
|
||||
// install/file.txt
|
||||
// install/data
|
||||
// install/data/file1.txt
|
||||
// install/data/... all the files and sub-dirs of data/
|
||||
// install/file.log
|
||||
Sample 2 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->setErrorHandling(PEAR_ERROR_PRINT); // Optional error handling
|
||||
$v_list[0]="dev/file.txt";
|
||||
$v_list[1]="dev/data/"; (Optional '/' at the end)
|
||||
$v_list[2]="log/file.log";
|
||||
$tar_object->createModify($v_list, "install", "dev");
|
||||
// files are stored in the archive as :
|
||||
// install/file.txt
|
||||
// install/data
|
||||
// install/data/file1.txt
|
||||
// install/data/... all the files and sub-dirs of data/
|
||||
// install/log/file.log
|
||||
How it works :
|
||||
Open the file in write mode (erasing the existing one if one),
|
||||
call the _addList() method for adding the files in an empty archive,
|
||||
add the tar footer (512 bytes block), close the tar file.
|
||||
|
||||
|
||||
Method : addModify($p_filelist, $p_add_dir, $p_remove_dir="")
|
||||
Description :
|
||||
This method add the files / directories listed in $p_filelist at the
|
||||
end of the existing archive. If the archive does not yet exists it
|
||||
is created.
|
||||
The $p_filelist parameter can be an array of string, each string
|
||||
representing a filename or a directory name with their path if
|
||||
needed. It can also be a single string with names separated by a
|
||||
single blank.
|
||||
The path indicated in $p_remove_dir will be removed from the
|
||||
memorized path of each file / directory listed when this path
|
||||
exists. By default nothing is removed (empty path "")
|
||||
The path indicated in $p_add_dir will be added at the beginning of
|
||||
the memorized path of each file / directory listed. However it can
|
||||
be set to empty "". The adding of a path is done after the removing
|
||||
of path.
|
||||
The path add/remove ability enables the user to prepare an archive
|
||||
for extraction in a different path than the origin files are.
|
||||
If a file/dir is already in the archive it will only be added at the
|
||||
end of the archive. There is no update of the existing archived
|
||||
file/dir. However while extracting the archive, the last file will
|
||||
replace the first one. This results in a none optimization of the
|
||||
archive size.
|
||||
If a file/dir does not exist the file/dir is ignored. However an
|
||||
error text is send to PEAR error.
|
||||
If a file/dir is not readable the file/dir is ignored. However an
|
||||
error text is send to PEAR error.
|
||||
If the resulting filename/dirname (after the add/remove option or
|
||||
not) string is greater than 99 char, the file/dir is
|
||||
ignored. However an error text is send to PEAR error.
|
||||
Arguments :
|
||||
$p_filelist : An array of filenames and directory names, or a single
|
||||
string with names separated by a single blank space.
|
||||
$p_add_dir : A string which contains a path to be added to the
|
||||
memorized path of each element in the list.
|
||||
$p_remove_dir : A string which contains a path to be removed from
|
||||
the memorized path of each element in the list, when
|
||||
relevant.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample 1 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
[...]
|
||||
$v_list[0]="dev/file.txt";
|
||||
$v_list[1]="dev/data/"; (Optional '/' at the end)
|
||||
$v_list[2]="log/file.log";
|
||||
$tar_object->addModify($v_list, "install");
|
||||
// files are stored in the archive as :
|
||||
// install/file.txt
|
||||
// install/data
|
||||
// install/data/file1.txt
|
||||
// install/data/... all the files and sub-dirs of data/
|
||||
// install/file.log
|
||||
Sample 2 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
[...]
|
||||
$v_list[0]="dev/file.txt";
|
||||
$v_list[1]="dev/data/"; (Optional '/' at the end)
|
||||
$v_list[2]="log/file.log";
|
||||
$tar_object->addModify($v_list, "install", "dev");
|
||||
// files are stored in the archive as :
|
||||
// install/file.txt
|
||||
// install/data
|
||||
// install/data/file1.txt
|
||||
// install/data/... all the files and sub-dirs of data/
|
||||
// install/log/file.log
|
||||
How it works :
|
||||
If the archive does not exists it create it and add the files.
|
||||
If the archive does exists and is not compressed, it open it, jump
|
||||
before the last empty 512 bytes block (tar footer) and add the files
|
||||
at this point.
|
||||
If the archive does exists and is compressed, a temporary copy file
|
||||
is created. This temporary file is then 'gzip' read block by block
|
||||
until the last empty block. The new files are then added in the
|
||||
compressed file.
|
||||
The adding of files is done by going through the file/dir list,
|
||||
adding files per files, in a recursive way through the
|
||||
directory. Each time a path need to be added/removed it is done
|
||||
before writing the file header in the archive.
|
||||
|
||||
Method : add($p_filelist)
|
||||
Description :
|
||||
This method add the files / directories listed in $p_filelist at the
|
||||
end of the existing archive. If the archive does not yet exists it
|
||||
is created.
|
||||
The $p_filelist parameter can be an array of string, each string
|
||||
representing a filename or a directory name with their path if
|
||||
needed. It can also be a single string with names separated by a
|
||||
single blank.
|
||||
See addModify() method for details and limitations.
|
||||
Arguments :
|
||||
$p_filelist : An array of filenames and directory names, or a single
|
||||
string with names separated by a single blank space.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample 1 :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
[...]
|
||||
$v_list[0]="dev/file.txt";
|
||||
$v_list[1]="dev/data/"; (Optional '/' at the end)
|
||||
$v_list[2]="log/file.log";
|
||||
$tar_object->add($v_list);
|
||||
Sample 2 :
|
||||
$tar_object = new Archive_Tar("tarname.tgz", true);
|
||||
[...]
|
||||
$v_list[0]="dev/file.txt";
|
||||
$v_list[1]="dev/data/"; (Optional '/' at the end)
|
||||
$v_list[2]="log/file.log";
|
||||
$tar_object->add($v_list);
|
||||
How it works :
|
||||
Simply call the addModify() method with the right parameters.
|
||||
|
||||
Method : addString($p_filename, $p_string)
|
||||
Description :
|
||||
This method add a single string as a file at the
|
||||
end of the existing archive. If the archive does not yet exists it
|
||||
is created.
|
||||
Arguments :
|
||||
$p_filename : A string which contains the full filename path
|
||||
that will be associated with the string.
|
||||
$p_string : The content of the file added in the archive.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample 1 :
|
||||
$v_archive = & new Archive_Tar($p_filename);
|
||||
$v_archive->setErrorHandling(PEAR_ERROR_PRINT);
|
||||
$v_result = $v_archive->addString('data/test.txt', 'This is the text of the string');
|
||||
|
||||
|
||||
Method : extract($p_path = "")
|
||||
Description :
|
||||
This method extract all the content of the archive in the directory
|
||||
indicated by $p_path.If $p_path is optional, if not set the archive
|
||||
is extracted in the current directory.
|
||||
While extracting a file, if the directory path does not exists it is
|
||||
created.
|
||||
See extractModify() for details and limitations.
|
||||
Arguments :
|
||||
$p_path : Optional path where the files/dir need to by extracted.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->extract();
|
||||
How it works :
|
||||
Simply call the extractModify() method with appropriate parameters.
|
||||
|
||||
Method : extractModify($p_path, $p_remove_path)
|
||||
Description :
|
||||
This method extract all the content of the archive in the directory
|
||||
indicated by $p_path. When relevant the memorized path of the
|
||||
files/dir can be modified by removing the $p_remove_path path at the
|
||||
beginning of the file/dir path.
|
||||
While extracting a file, if the directory path does not exists it is
|
||||
created.
|
||||
While extracting a file, if the file already exists it is replaced
|
||||
without looking for last modification date.
|
||||
While extracting a file, if the file already exists and is write
|
||||
protected, the extraction is aborted.
|
||||
While extracting a file, if a directory with the same name already
|
||||
exists, the extraction is aborted.
|
||||
While extracting a directory, if a file with the same name already
|
||||
exists, the extraction is aborted.
|
||||
While extracting a file/directory if the destination directory exist
|
||||
and is write protected, or does not exist but can not be created,
|
||||
the extraction is aborted.
|
||||
If after extraction an extracted file does not show the correct
|
||||
stored file size, the extraction is aborted.
|
||||
When the extraction is aborted, a PEAR error text is set and false
|
||||
is returned. However the result can be a partial extraction that may
|
||||
need to be manually cleaned.
|
||||
Arguments :
|
||||
$p_path : The path of the directory where the files/dir need to by
|
||||
extracted.
|
||||
$p_remove_path : Part of the memorized path that can be removed if
|
||||
present at the beginning of the file/dir path.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample :
|
||||
// Imagine tarname.tar with files :
|
||||
// dev/data/file.txt
|
||||
// dev/data/log.txt
|
||||
// readme.txt
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->extractModify("install", "dev");
|
||||
// Files will be extracted there :
|
||||
// install/data/file.txt
|
||||
// install/data/log.txt
|
||||
// install/readme.txt
|
||||
How it works :
|
||||
Open the archive and call a more generic function that can extract
|
||||
only a part of the archive or all the archive.
|
||||
See extractList() method for more details.
|
||||
|
||||
Method : extractInString($p_filename)
|
||||
Description :
|
||||
This method extract from the archive one file identified by $p_filename.
|
||||
The return value is a string with the file content, or NULL on error.
|
||||
Arguments :
|
||||
$p_filename : The path of the file to extract in a string.
|
||||
Return value :
|
||||
a string with the file content or NULL.
|
||||
Sample :
|
||||
// Imagine tarname.tar with files :
|
||||
// dev/data/file.txt
|
||||
// dev/data/log.txt
|
||||
// dev/readme.txt
|
||||
$v_archive = & new Archive_Tar('tarname.tar');
|
||||
$v_archive->setErrorHandling(PEAR_ERROR_PRINT);
|
||||
$v_string = $v_archive->extractInString('dev/readme.txt');
|
||||
echo $v_string;
|
||||
|
||||
Method : listContent()
|
||||
Description :
|
||||
This method returns an array of arrays that describe each
|
||||
file/directory present in the archive.
|
||||
The array is not sorted, so it show the position of the file in the
|
||||
archive.
|
||||
The file informations are :
|
||||
$file[filename] : Name and path of the file/dir.
|
||||
$file[mode] : File permissions (result of fileperms())
|
||||
$file[uid] : user id
|
||||
$file[gid] : group id
|
||||
$file[size] : filesize
|
||||
$file[mtime] : Last modification time (result of filemtime())
|
||||
$file[typeflag] : "" for file, "5" for directory
|
||||
Arguments :
|
||||
Return value :
|
||||
An array of arrays or 0 on error.
|
||||
Sample :
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
if (($v_list = $tar_object->listContent()) != 0)
|
||||
for ($i=0; $i<sizeof($v_list); $i++)
|
||||
{
|
||||
echo "Filename :'".$v_list[$i][filename]."'<br>";
|
||||
echo " .size :'".$v_list[$i][size]."'<br>";
|
||||
echo " .mtime :'".$v_list[$i][mtime]."' (".
|
||||
date("l dS of F Y h:i:s A", $v_list[$i][mtime]).")<br>";
|
||||
echo " .mode :'".$v_list[$i][mode]."'<br>";
|
||||
echo " .uid :'".$v_list[$i][uid]."'<br>";
|
||||
echo " .gid :'".$v_list[$i][gid]."'<br>";
|
||||
echo " .typeflag :'".$v_list[$i][typeflag]."'<br>";
|
||||
}
|
||||
How it works :
|
||||
Call the same function as an extract however with a flag to only go
|
||||
through the archive without extracting the files.
|
||||
|
||||
Method : extractList($p_filelist, $p_path = "", $p_remove_path = "")
|
||||
Description :
|
||||
This method extract from the archive only the files indicated in the
|
||||
$p_filelist. These files are extracted in the current directory or
|
||||
in the directory indicated by the optional $p_path parameter.
|
||||
If indicated the $p_remove_path can be used in the same way as it is
|
||||
used in extractModify() method.
|
||||
Arguments :
|
||||
$p_filelist : An array of filenames and directory names, or a single
|
||||
string with names separated by a single blank space.
|
||||
$p_path : The path of the directory where the files/dir need to by
|
||||
extracted.
|
||||
$p_remove_path : Part of the memorized path that can be removed if
|
||||
present at the beginning of the file/dir path.
|
||||
Return value :
|
||||
true on success, false on error.
|
||||
Sample :
|
||||
// Imagine tarname.tar with files :
|
||||
// dev/data/file.txt
|
||||
// dev/data/log.txt
|
||||
// readme.txt
|
||||
$tar_object = new Archive_Tar("tarname.tar");
|
||||
$tar_object->extractList("dev/data/file.txt readme.txt", "install",
|
||||
"dev");
|
||||
// Files will be extracted there :
|
||||
// install/data/file.txt
|
||||
// install/readme.txt
|
||||
How it works :
|
||||
Go through the archive and extract only the files present in the
|
||||
list.
|
||||
|
|
@ -1,3 +0,0 @@
|
|||
Readme
|
||||
|
||||
See the PEAR manual at http://pear.php.net/manual/en/package.datetime.calendar.php for details.
|
|
@ -1,92 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: Passes through all main calendar classes, beginning with year
|
||||
* and down to seconds, skipping weeks. Useful to test Calendar is (basically)
|
||||
* working correctly
|
||||
*
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
|
||||
if (!isset($_GET['y'])) $_GET['y'] = 2003;
|
||||
if (!isset($_GET['m'])) $_GET['m'] = 8;
|
||||
if (!isset($_GET['d'])) $_GET['d'] = 9;
|
||||
if (!isset($_GET['h'])) $_GET['h'] = 12;
|
||||
if (!isset($_GET['i'])) $_GET['i'] = 34;
|
||||
if (!isset($_GET['s'])) $_GET['s'] = 46;
|
||||
|
||||
switch ( @$_GET['view'] ) {
|
||||
default:
|
||||
$_GET['view'] = 'calendar_year';
|
||||
case 'calendar_year':
|
||||
require_once CALENDAR_ROOT.'Year.php';
|
||||
$c = new Calendar_Year($_GET['y']);
|
||||
break;
|
||||
case 'calendar_month':
|
||||
require_once CALENDAR_ROOT.'Month.php';
|
||||
$c = new Calendar_Month($_GET['y'],$_GET['m']);
|
||||
break;
|
||||
case 'calendar_day':
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
$c = new Calendar_Day($_GET['y'],$_GET['m'],$_GET['d']);
|
||||
break;
|
||||
case 'calendar_hour':
|
||||
require_once CALENDAR_ROOT.'Hour.php';
|
||||
$c = new Calendar_Hour($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h']);
|
||||
break;
|
||||
case 'calendar_minute':
|
||||
require_once CALENDAR_ROOT.'Minute.php';
|
||||
$c = new Calendar_Minute($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h'],$_GET['i']);
|
||||
break;
|
||||
case 'calendar_second':
|
||||
require_once CALENDAR_ROOT.'Second.php';
|
||||
$c = new Calendar_Second($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h'],$_GET['i'],$_GET['s']);
|
||||
break;
|
||||
}
|
||||
|
||||
echo ( 'Viewing: '.@$_GET['view'].'<br />' );
|
||||
echo ( 'The time is now: '.date('Y M d H:i:s',$c->getTimestamp()).'<br >' );
|
||||
|
||||
$i = 1;
|
||||
echo ( '<h1>First Iteration</h1>' );
|
||||
echo ( '<p>The first iteration is more "expensive", the calendar data
|
||||
structures having to be built.</p>' );
|
||||
$start = getmicrotime();
|
||||
$c->build();
|
||||
while ( $e = $c->fetch() ) {
|
||||
$class = strtolower(get_class($e));
|
||||
$link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay().
|
||||
"&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond();
|
||||
$method = 'this'.str_replace('calendar_','',$class);
|
||||
echo ( "<a href=\"".$_SERVER['PHP_SELF']."?view=".$class.$link."\">".$e->{$method}()."</a> : " );
|
||||
if ( ($i % 10) == 0 ) {
|
||||
echo ( '<br>' );
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' );
|
||||
|
||||
$i = 1;
|
||||
echo ( '<h1>Second Iteration</h1>' );
|
||||
echo ( '<p>This second iteration is faster, the data structures
|
||||
being re-used</p>' );
|
||||
$start = getmicrotime();
|
||||
while ( $e = $c->fetch() ) {
|
||||
$class = strtolower(get_class($e));
|
||||
$link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay().
|
||||
"&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond();
|
||||
$method = 'this'.str_replace('calendar_','',$class);
|
||||
echo ( "<a href=\"".$_SERVER['PHP_SELF']."?view=".$class.$link."\">".$e->{$method}()."</a> : " );
|
||||
if ( ($i % 10) == 0 ) {
|
||||
echo ( '<br>' );
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' );
|
||||
?>
|
|
@ -1,92 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: Passes through all main calendar classes, beginning with year
|
||||
* and down to seconds, skipping weeks. Useful to test Calendar is (basically)
|
||||
* working correctly
|
||||
*
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
|
||||
if (!isset($_GET['y'])) $_GET['y'] = 2003;
|
||||
if (!isset($_GET['m'])) $_GET['m'] = 8;
|
||||
if (!isset($_GET['d'])) $_GET['d'] = 9;
|
||||
if (!isset($_GET['h'])) $_GET['h'] = 12;
|
||||
if (!isset($_GET['i'])) $_GET['i'] = 34;
|
||||
if (!isset($_GET['s'])) $_GET['s'] = 46;
|
||||
|
||||
switch ( @$_GET['view'] ) {
|
||||
default:
|
||||
$_GET['view'] = 'calendar_year';
|
||||
case 'calendar_year':
|
||||
require_once CALENDAR_ROOT.'Year.php';
|
||||
$c = new Calendar_Year($_GET['y']);
|
||||
break;
|
||||
case 'calendar_month':
|
||||
require_once CALENDAR_ROOT.'Month.php';
|
||||
$c = new Calendar_Month($_GET['y'],$_GET['m']);
|
||||
break;
|
||||
case 'calendar_day':
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
$c = new Calendar_Day($_GET['y'],$_GET['m'],$_GET['d']);
|
||||
break;
|
||||
case 'calendar_hour':
|
||||
require_once CALENDAR_ROOT.'Hour.php';
|
||||
$c = new Calendar_Hour($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h']);
|
||||
break;
|
||||
case 'calendar_minute':
|
||||
require_once CALENDAR_ROOT.'Minute.php';
|
||||
$c = new Calendar_Minute($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h'],$_GET['i']);
|
||||
break;
|
||||
case 'calendar_second':
|
||||
require_once CALENDAR_ROOT.'Second.php';
|
||||
$c = new Calendar_Second($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h'],$_GET['i'],$_GET['s']);
|
||||
break;
|
||||
}
|
||||
|
||||
echo ( 'Viewing: '.@$_GET['view'].'<br />' );
|
||||
echo ( 'The time is now: '.date('Y M d H:i:s',$c->getTimestamp()).'<br >' );
|
||||
|
||||
$i = 1;
|
||||
echo ( '<h1>First Iteration</h1>' );
|
||||
echo ( '<p>The first iteration is more "expensive", the calendar data
|
||||
structures having to be built.</p>' );
|
||||
$start = getmicrotime();
|
||||
$c->build();
|
||||
while ( $e = $c->fetch() ) {
|
||||
$class = strtolower(get_class($e));
|
||||
$link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay().
|
||||
"&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond();
|
||||
$method = 'this'.str_replace('calendar_','',$class);
|
||||
echo ( "<a href=\"".$_SERVER['PHP_SELF']."?view=".$class.$link."\">".$e->{$method}()."</a> : " );
|
||||
if ( ($i % 10) == 0 ) {
|
||||
echo ( '<br>' );
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' );
|
||||
|
||||
$i = 1;
|
||||
echo ( '<h1>Second Iteration</h1>' );
|
||||
echo ( '<p>This second iteration is faster, the data structures
|
||||
being re-used</p>' );
|
||||
$start = getmicrotime();
|
||||
while ( $e = $c->fetch() ) {
|
||||
$class = strtolower(get_class($e));
|
||||
$link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay().
|
||||
"&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond();
|
||||
$method = 'this'.str_replace('calendar_','',$class);
|
||||
echo ( "<a href=\"".$_SERVER['PHP_SELF']."?view=".$class.$link."\">".$e->{$method}()."</a> : " );
|
||||
if ( ($i % 10) == 0 ) {
|
||||
echo ( '<br>' );
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' );
|
||||
?>
|
|
@ -1,93 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: demonstrates a decorator to provide simple output formatting
|
||||
* on the month while still allowing the days to be accessed via the decorator
|
||||
* In practice you _wouldn't_ do this - each decorator comes with a performance
|
||||
* hit for extra method calls. For this example some simple functions could help
|
||||
* format the month while the days are accessed via the normal Month object
|
||||
*/
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Month/Weekdays.php';
|
||||
require_once CALENDAR_ROOT.'Decorator.php';
|
||||
|
||||
// Decorate a Month with methods to improve formatting
|
||||
class MonthDecorator extends Calendar_Decorator {
|
||||
/**
|
||||
* @param Calendar_Month
|
||||
*/
|
||||
function MonthDecorator(& $Month) {
|
||||
parent::Calendar_Decorator($Month);
|
||||
}
|
||||
/**
|
||||
* Override the prevMonth method to format the output
|
||||
*/
|
||||
function prevMonth() {
|
||||
$prevStamp = parent::prevMonth(TRUE);
|
||||
// Build the URL for the previous month
|
||||
return $_SERVER['PHP_SELF'].'?y='.date('Y',$prevStamp).
|
||||
'&m='.date('n',$prevStamp).'&d='.date('j',$prevStamp);
|
||||
}
|
||||
/**
|
||||
* Override the thisMonth method to format the output
|
||||
*/
|
||||
function thisMonth() {
|
||||
$thisStamp = parent::thisMonth(TRUE);
|
||||
// A human readable string from this month
|
||||
return date('F Y',$thisStamp);
|
||||
}
|
||||
/**
|
||||
* Override the nextMonth method to format the output
|
||||
*/
|
||||
function nextMonth() {
|
||||
$nextStamp = parent::nextMonth(TRUE);
|
||||
// Build the URL for next month
|
||||
return $_SERVER['PHP_SELF'].'?y='.date('Y',$nextStamp).
|
||||
'&m='.date('n',$nextStamp).'&d='.date('j',$nextStamp);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($_GET['y'])) $_GET['y'] = date('Y');
|
||||
if (!isset($_GET['m'])) $_GET['m'] = date('n');
|
||||
|
||||
// Creata a month as usual
|
||||
$Month = new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
|
||||
|
||||
// Pass it to the decorator and use the decorator from now on...
|
||||
$MonthDecorator = new MonthDecorator($Month);
|
||||
$MonthDecorator->build();
|
||||
?>
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> A Simple Decorator </title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>A Simple Decorator</h1>
|
||||
<table>
|
||||
<caption><?php echo ( $MonthDecorator->thisMonth() ); ?></caption>
|
||||
<?php
|
||||
while ( $Day = $MonthDecorator->fetch() ) {
|
||||
if ( $Day->isFirst() ) {
|
||||
echo ( "\n<tr>\n" );
|
||||
}
|
||||
if ( $Day->isEmpty() ) {
|
||||
echo ( "<td> </td>" );
|
||||
} else {
|
||||
echo ( "<td>".$Day->thisDay()."</td>" );
|
||||
}
|
||||
if ( $Day->isLast() ) {
|
||||
echo ( "\n</tr>\n" );
|
||||
}
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="<?php echo ($MonthDecorator->prevMonth()); ?>">Prev</a></td>
|
||||
<td colspan="5"> </td>
|
||||
<td><a href="<?php echo ($MonthDecorator->nextMonth()); ?>">Next</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
|
@ -1,93 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: demonstrates a decorator to provide simple output formatting
|
||||
* on the month while still allowing the days to be accessed via the decorator
|
||||
* In practice you _wouldn't_ do this - each decorator comes with a performance
|
||||
* hit for extra method calls. For this example some simple functions could help
|
||||
* format the month while the days are accessed via the normal Month object
|
||||
*/
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Month/Weekdays.php';
|
||||
require_once CALENDAR_ROOT.'Decorator.php';
|
||||
|
||||
// Decorate a Month with methods to improve formatting
|
||||
class MonthDecorator extends Calendar_Decorator {
|
||||
/**
|
||||
* @param Calendar_Month
|
||||
*/
|
||||
function MonthDecorator(& $Month) {
|
||||
parent::Calendar_Decorator($Month);
|
||||
}
|
||||
/**
|
||||
* Override the prevMonth method to format the output
|
||||
*/
|
||||
function prevMonth() {
|
||||
$prevStamp = parent::prevMonth(TRUE);
|
||||
// Build the URL for the previous month
|
||||
return $_SERVER['PHP_SELF'].'?y='.date('Y',$prevStamp).
|
||||
'&m='.date('n',$prevStamp).'&d='.date('j',$prevStamp);
|
||||
}
|
||||
/**
|
||||
* Override the thisMonth method to format the output
|
||||
*/
|
||||
function thisMonth() {
|
||||
$thisStamp = parent::thisMonth(TRUE);
|
||||
// A human readable string from this month
|
||||
return date('F Y',$thisStamp);
|
||||
}
|
||||
/**
|
||||
* Override the nextMonth method to format the output
|
||||
*/
|
||||
function nextMonth() {
|
||||
$nextStamp = parent::nextMonth(TRUE);
|
||||
// Build the URL for next month
|
||||
return $_SERVER['PHP_SELF'].'?y='.date('Y',$nextStamp).
|
||||
'&m='.date('n',$nextStamp).'&d='.date('j',$nextStamp);
|
||||
}
|
||||
}
|
||||
|
||||
if (!isset($_GET['y'])) $_GET['y'] = date('Y');
|
||||
if (!isset($_GET['m'])) $_GET['m'] = date('n');
|
||||
|
||||
// Creata a month as usual
|
||||
$Month = new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
|
||||
|
||||
// Pass it to the decorator and use the decorator from now on...
|
||||
$MonthDecorator = new MonthDecorator($Month);
|
||||
$MonthDecorator->build();
|
||||
?>
|
||||
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> A Simple Decorator </title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>A Simple Decorator</h1>
|
||||
<table>
|
||||
<caption><?php echo ( $MonthDecorator->thisMonth() ); ?></caption>
|
||||
<?php
|
||||
while ( $Day = $MonthDecorator->fetch() ) {
|
||||
if ( $Day->isFirst() ) {
|
||||
echo ( "\n<tr>\n" );
|
||||
}
|
||||
if ( $Day->isEmpty() ) {
|
||||
echo ( "<td> </td>" );
|
||||
} else {
|
||||
echo ( "<td>".$Day->thisDay()."</td>" );
|
||||
}
|
||||
if ( $Day->isLast() ) {
|
||||
echo ( "\n</tr>\n" );
|
||||
}
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td><a href="<?php echo ($MonthDecorator->prevMonth()); ?>">Prev</a></td>
|
||||
<td colspan="5"> </td>
|
||||
<td><a href="<?php echo ($MonthDecorator->nextMonth()); ?>">Next</a></td>
|
||||
</tr>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
|
@ -1,109 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: demonstrates a decorator used to "attach a payload" to a selection
|
||||
* to make it available when iterating over calendar children
|
||||
*/
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
require_once CALENDAR_ROOT.'Hour.php';
|
||||
require_once CALENDAR_ROOT.'Decorator.php';
|
||||
|
||||
// Decorator to "attach" functionality to selected hours
|
||||
class DiaryEvent extends Calendar_Decorator {
|
||||
var $entry;
|
||||
function DiaryEvent($calendar) {
|
||||
Calendar_Decorator::Calendar_Decorator($calendar);
|
||||
}
|
||||
function setEntry($entry) {
|
||||
$this->entry = $entry;
|
||||
}
|
||||
function getEntry() {
|
||||
return $this->entry;
|
||||
}
|
||||
}
|
||||
|
||||
// Create a day to view the hours for
|
||||
$Day = & new Calendar_Day(2003,10,24);
|
||||
|
||||
// A sample query to get the data for today (NOT ACTUALLY USED HERE)
|
||||
$sql = "
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
diary
|
||||
WHERE
|
||||
eventtime >= '".$Day->thisDay(TRUE)."'
|
||||
AND
|
||||
eventtime < '".$Day->nextDay(TRUE)."';";
|
||||
|
||||
// An array simulating data from a database
|
||||
$result = array (
|
||||
array('eventtime'=>mktime(9,0,0,10,24,2003),'entry'=>'Meeting with sales team'),
|
||||
array('eventtime'=>mktime(11,0,0,10,24,2003),'entry'=>'Conference call with Widget Inc.'),
|
||||
array('eventtime'=>mktime(15,0,0,10,24,2003),'entry'=>'Presentation to board of directors')
|
||||
);
|
||||
|
||||
// An array to place selected hours in
|
||||
$selection = array();
|
||||
|
||||
// Loop through the "database result"
|
||||
foreach ( $result as $row ) {
|
||||
$Hour = new Calendar_Hour(2000,1,1,1); // Create Hour with dummy values
|
||||
$Hour->setTimeStamp($row['eventtime']); // Set the real time with setTimeStamp
|
||||
|
||||
// Create the decorator, passing it the Hour
|
||||
$DiaryEvent = new DiaryEvent($Hour);
|
||||
|
||||
// Attach the payload
|
||||
$DiaryEvent->setEntry($row['entry']);
|
||||
|
||||
// Add the decorator to the selection
|
||||
$selection[] = $DiaryEvent;
|
||||
}
|
||||
|
||||
// Build the hours in that day, passing the selection
|
||||
$Day->build($selection);
|
||||
?>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> Passing a Selection Payload with a Decorator </title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Passing a Selection "Payload" using a Decorator</h1>
|
||||
<table>
|
||||
<caption><b>Your Schedule for <?php echo ( date('D nS F Y',$Day->thisDay(TRUE)) ); ?></b></caption>
|
||||
<tr>
|
||||
<th width="5%">Time</th>
|
||||
<th>Entry</th>
|
||||
</tr>
|
||||
<?php
|
||||
while ( $Hour = & $Day->fetch() ) {
|
||||
|
||||
$hour = $Hour->thisHour();
|
||||
$minute = $Hour->thisMinute();
|
||||
|
||||
// Office hours only...
|
||||
if ( $hour >= 8 && $hour <= 18 ) {
|
||||
echo ( "<tr>\n" );
|
||||
echo ( "<td>$hour:$minute</td>\n" );
|
||||
|
||||
// If the hour is selected, call the decorator method...
|
||||
if ( $Hour->isSelected() ) {
|
||||
echo ( "<td bgcolor=\"silver\">".$Hour->getEntry()."</td>\n" );
|
||||
} else {
|
||||
echo ( "<td> </td>\n" );
|
||||
}
|
||||
echo ( "</tr>\n" );
|
||||
}
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<p>The query to fetch this data, with help from PEAR::Calendar, might be;</p>
|
||||
<pre>
|
||||
<?php echo ( $sql ); ?>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -1,109 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: demonstrates a decorator used to "attach a payload" to a selection
|
||||
* to make it available when iterating over calendar children
|
||||
*/
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
require_once CALENDAR_ROOT.'Hour.php';
|
||||
require_once CALENDAR_ROOT.'Decorator.php';
|
||||
|
||||
// Decorator to "attach" functionality to selected hours
|
||||
class DiaryEvent extends Calendar_Decorator {
|
||||
var $entry;
|
||||
function DiaryEvent($calendar) {
|
||||
Calendar_Decorator::Calendar_Decorator($calendar);
|
||||
}
|
||||
function setEntry($entry) {
|
||||
$this->entry = $entry;
|
||||
}
|
||||
function getEntry() {
|
||||
return $this->entry;
|
||||
}
|
||||
}
|
||||
|
||||
// Create a day to view the hours for
|
||||
$Day = & new Calendar_Day(2003,10,24);
|
||||
|
||||
// A sample query to get the data for today (NOT ACTUALLY USED HERE)
|
||||
$sql = "
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
diary
|
||||
WHERE
|
||||
eventtime >= '".$Day->thisDay(TRUE)."'
|
||||
AND
|
||||
eventtime < '".$Day->nextDay(TRUE)."';";
|
||||
|
||||
// An array simulating data from a database
|
||||
$result = array (
|
||||
array('eventtime'=>mktime(9,0,0,10,24,2003),'entry'=>'Meeting with sales team'),
|
||||
array('eventtime'=>mktime(11,0,0,10,24,2003),'entry'=>'Conference call with Widget Inc.'),
|
||||
array('eventtime'=>mktime(15,0,0,10,24,2003),'entry'=>'Presentation to board of directors')
|
||||
);
|
||||
|
||||
// An array to place selected hours in
|
||||
$selection = array();
|
||||
|
||||
// Loop through the "database result"
|
||||
foreach ( $result as $row ) {
|
||||
$Hour = new Calendar_Hour(2000,1,1,1); // Create Hour with dummy values
|
||||
$Hour->setTimeStamp($row['eventtime']); // Set the real time with setTimeStamp
|
||||
|
||||
// Create the decorator, passing it the Hour
|
||||
$DiaryEvent = new DiaryEvent($Hour);
|
||||
|
||||
// Attach the payload
|
||||
$DiaryEvent->setEntry($row['entry']);
|
||||
|
||||
// Add the decorator to the selection
|
||||
$selection[] = $DiaryEvent;
|
||||
}
|
||||
|
||||
// Build the hours in that day, passing the selection
|
||||
$Day->build($selection);
|
||||
?>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> Passing a Selection Payload with a Decorator </title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Passing a Selection "Payload" using a Decorator</h1>
|
||||
<table>
|
||||
<caption><b>Your Schedule for <?php echo ( date('D nS F Y',$Day->thisDay(TRUE)) ); ?></b></caption>
|
||||
<tr>
|
||||
<th width="5%">Time</th>
|
||||
<th>Entry</th>
|
||||
</tr>
|
||||
<?php
|
||||
while ( $Hour = & $Day->fetch() ) {
|
||||
|
||||
$hour = $Hour->thisHour();
|
||||
$minute = $Hour->thisMinute();
|
||||
|
||||
// Office hours only...
|
||||
if ( $hour >= 8 && $hour <= 18 ) {
|
||||
echo ( "<tr>\n" );
|
||||
echo ( "<td>$hour:$minute</td>\n" );
|
||||
|
||||
// If the hour is selected, call the decorator method...
|
||||
if ( $Hour->isSelected() ) {
|
||||
echo ( "<td bgcolor=\"silver\">".$Hour->getEntry()."</td>\n" );
|
||||
} else {
|
||||
echo ( "<td> </td>\n" );
|
||||
}
|
||||
echo ( "</tr>\n" );
|
||||
}
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<p>The query to fetch this data, with help from PEAR::Calendar, might be;</p>
|
||||
<pre>
|
||||
<?php echo ( $sql ); ?>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -1,116 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: a complete year
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
$start = getmicrotime();
|
||||
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
|
||||
require_once CALENDAR_ROOT.'Year.php';
|
||||
|
||||
define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH_WEEKDAYS);
|
||||
|
||||
if ( !isset($_GET['year']) ) $_GET['year'] = date('Y');
|
||||
|
||||
$Year = new Calendar_Year($_GET['year']);
|
||||
|
||||
$Year->build();
|
||||
?>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> <?php echo ( $Year->thisYear() ); ?> </title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: Georgia, serif;
|
||||
}
|
||||
caption.year {
|
||||
font-weight: bold;
|
||||
font-size: 120%;
|
||||
font-color: navy;
|
||||
}
|
||||
caption.month {
|
||||
font-size: 110%;
|
||||
font-color: navy;
|
||||
}
|
||||
table.month {
|
||||
border: thin groove #800080
|
||||
}
|
||||
tr {
|
||||
vertical-align: top;
|
||||
}
|
||||
th, td {
|
||||
text-align: right;
|
||||
font-size: 70%;
|
||||
}
|
||||
#prev {
|
||||
float: left;
|
||||
font-size: 70%;
|
||||
}
|
||||
#next {
|
||||
float: right;
|
||||
font-size: 70%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table>
|
||||
<caption class="year">
|
||||
<?php echo ( $Year->thisYear() ); ?>
|
||||
<div id="next">
|
||||
<a href="?year=<?php echo ( $Year->nextYear() ); ?>">>></a>
|
||||
</div>
|
||||
<div id="prev">
|
||||
<a href="?year=<?php echo ( $Year->prevYear() ); ?>"><<</a>
|
||||
</div>
|
||||
</caption>
|
||||
<?php
|
||||
$i = 0;
|
||||
while ( $Month = $Year->fetch() ) {
|
||||
|
||||
switch ( $i ) {
|
||||
case 0:
|
||||
echo ( "<tr>\n" );
|
||||
break;
|
||||
case 3:
|
||||
case 6:
|
||||
case 9:
|
||||
echo ( "</tr>\n<tr>\n" );
|
||||
break;
|
||||
case 12:
|
||||
echo ( "</tr>\n" );
|
||||
break;
|
||||
}
|
||||
|
||||
echo ( "<td>\n<table class=\"month\">\n" );
|
||||
echo ( "<caption class=\"month\">".date('F',$Month->thisMonth(TRUE))."</caption>" );
|
||||
echo ( "<tr>\n<th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th><th>S</th>\n</tr>" );
|
||||
$Month->build();
|
||||
while ( $Day = $Month->fetch() ) {
|
||||
if ( $Day->isFirst() ) {
|
||||
echo ( "<tr>\n" );
|
||||
}
|
||||
if ( $Day->isEmpty() ) {
|
||||
echo ( "<td> </td>\n" );
|
||||
} else {
|
||||
echo ( "<td>".$Day->thisDay()."</td>\n" );
|
||||
}
|
||||
if ( $Day->isLast() ) {
|
||||
echo ( "</tr>\n" );
|
||||
}
|
||||
}
|
||||
echo ( "</table>\n</td>\n" );
|
||||
|
||||
$i++;
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<p>Took: <?php echo ((getmicrotime()-$start)); ?></p>
|
||||
</body>
|
||||
</html>
|
|
@ -1,116 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: a complete year
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
$start = getmicrotime();
|
||||
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
|
||||
require_once CALENDAR_ROOT.'Year.php';
|
||||
|
||||
define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH_WEEKDAYS);
|
||||
|
||||
if ( !isset($_GET['year']) ) $_GET['year'] = date('Y');
|
||||
|
||||
$Year = new Calendar_Year($_GET['year']);
|
||||
|
||||
$Year->build();
|
||||
?>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> <?php echo ( $Year->thisYear() ); ?> </title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: Georgia, serif;
|
||||
}
|
||||
caption.year {
|
||||
font-weight: bold;
|
||||
font-size: 120%;
|
||||
font-color: navy;
|
||||
}
|
||||
caption.month {
|
||||
font-size: 110%;
|
||||
font-color: navy;
|
||||
}
|
||||
table.month {
|
||||
border: thin groove #800080
|
||||
}
|
||||
tr {
|
||||
vertical-align: top;
|
||||
}
|
||||
th, td {
|
||||
text-align: right;
|
||||
font-size: 70%;
|
||||
}
|
||||
#prev {
|
||||
float: left;
|
||||
font-size: 70%;
|
||||
}
|
||||
#next {
|
||||
float: right;
|
||||
font-size: 70%;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table>
|
||||
<caption class="year">
|
||||
<?php echo ( $Year->thisYear() ); ?>
|
||||
<div id="next">
|
||||
<a href="?year=<?php echo ( $Year->nextYear() ); ?>">>></a>
|
||||
</div>
|
||||
<div id="prev">
|
||||
<a href="?year=<?php echo ( $Year->prevYear() ); ?>"><<</a>
|
||||
</div>
|
||||
</caption>
|
||||
<?php
|
||||
$i = 0;
|
||||
while ( $Month = $Year->fetch() ) {
|
||||
|
||||
switch ( $i ) {
|
||||
case 0:
|
||||
echo ( "<tr>\n" );
|
||||
break;
|
||||
case 3:
|
||||
case 6:
|
||||
case 9:
|
||||
echo ( "</tr>\n<tr>\n" );
|
||||
break;
|
||||
case 12:
|
||||
echo ( "</tr>\n" );
|
||||
break;
|
||||
}
|
||||
|
||||
echo ( "<td>\n<table class=\"month\">\n" );
|
||||
echo ( "<caption class=\"month\">".date('F',$Month->thisMonth(TRUE))."</caption>" );
|
||||
echo ( "<tr>\n<th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th><th>S</th>\n</tr>" );
|
||||
$Month->build();
|
||||
while ( $Day = $Month->fetch() ) {
|
||||
if ( $Day->isFirst() ) {
|
||||
echo ( "<tr>\n" );
|
||||
}
|
||||
if ( $Day->isEmpty() ) {
|
||||
echo ( "<td> </td>\n" );
|
||||
} else {
|
||||
echo ( "<td>".$Day->thisDay()."</td>\n" );
|
||||
}
|
||||
if ( $Day->isLast() ) {
|
||||
echo ( "</tr>\n" );
|
||||
}
|
||||
}
|
||||
echo ( "</table>\n</td>\n" );
|
||||
|
||||
$i++;
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<p>Took: <?php echo ((getmicrotime()-$start)); ?></p>
|
||||
</body>
|
||||
</html>
|
|
@ -1,99 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: same as 1.php, but using the PEAR::Date engine
|
||||
* Notice the use of the CALENDAR_ENGINE constant, which
|
||||
* switches the calculation "engine"
|
||||
* Note: make sure PEAR::Date is a stable release!!!
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
|
||||
// Switch to PEAR::Date engine
|
||||
define('CALENDAR_ENGINE','PearDate');
|
||||
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
|
||||
if (!isset($_GET['y'])) $_GET['y'] = 2003;
|
||||
if (!isset($_GET['m'])) $_GET['m'] = 8;
|
||||
if (!isset($_GET['d'])) $_GET['d'] = 9;
|
||||
if (!isset($_GET['h'])) $_GET['h'] = 12;
|
||||
if (!isset($_GET['i'])) $_GET['i'] = 34;
|
||||
if (!isset($_GET['s'])) $_GET['s'] = 46;
|
||||
|
||||
switch ( @$_GET['view'] ) {
|
||||
default:
|
||||
$_GET['view'] = 'calendar_year';
|
||||
case 'calendar_year':
|
||||
require_once CALENDAR_ROOT.'Year.php';
|
||||
$c = new Calendar_Year($_GET['y']);
|
||||
break;
|
||||
case 'calendar_month':
|
||||
require_once CALENDAR_ROOT.'Month.php';
|
||||
$c = new Calendar_Month($_GET['y'],$_GET['m']);
|
||||
break;
|
||||
case 'calendar_day':
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
$c = new Calendar_Day($_GET['y'],$_GET['m'],$_GET['d']);
|
||||
break;
|
||||
case 'calendar_hour':
|
||||
require_once CALENDAR_ROOT.'Hour.php';
|
||||
$c = new Calendar_Hour($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h']);
|
||||
break;
|
||||
case 'calendar_minute':
|
||||
require_once CALENDAR_ROOT.'Minute.php';
|
||||
$c = new Calendar_Minute($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h'],$_GET['i']);
|
||||
break;
|
||||
case 'calendar_second':
|
||||
require_once CALENDAR_ROOT.'Second.php';
|
||||
$c = new Calendar_Second($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h'],$_GET['i'],$_GET['s']);
|
||||
break;
|
||||
}
|
||||
|
||||
// Convert timestamp to human readable date
|
||||
$date = new Date($c->getTimestamp());
|
||||
|
||||
echo ( '<h1>Using PEAR::Date engine</h1>' );
|
||||
echo ( 'Viewing: '.@$_GET['view'].'<br />' );
|
||||
echo ( 'The time is now: '.$date->format('%Y %a %e %T').'<br >' );
|
||||
|
||||
$i = 1;
|
||||
echo ( '<h1>First Iteration</h1>' );
|
||||
echo ( '<p>The first iteration is more "expensive", the calendar data
|
||||
structures having to be built.</p>' );
|
||||
$start = getmicrotime();
|
||||
$c->build();
|
||||
while ( $e = $c->fetch() ) {
|
||||
$class = strtolower(get_class($e));
|
||||
$link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay().
|
||||
"&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond();
|
||||
$method = 'this'.str_replace('calendar_','',$class);
|
||||
echo ( "<a href=\"".$_SERVER['PHP_SELF']."?view=".$class.$link."\">".$e->{$method}()."</a> : " );
|
||||
if ( ($i % 10) == 0 ) {
|
||||
echo ( '<br>' );
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' );
|
||||
|
||||
$i = 1;
|
||||
echo ( '<h1>Second Iteration</h1>' );
|
||||
echo ( '<p>This second iteration is faster, the data structures
|
||||
being re-used</p>' );
|
||||
$start = getmicrotime();
|
||||
while ( $e = $c->fetch() ) {
|
||||
$class = strtolower(get_class($e));
|
||||
$link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay().
|
||||
"&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond();
|
||||
$method = 'this'.str_replace('calendar_','',$class);
|
||||
echo ( "<a href=\"".$_SERVER['PHP_SELF']."?view=".$class.$link."\">".$e->{$method}()."</a> : " );
|
||||
if ( ($i % 10) == 0 ) {
|
||||
echo ( '<br>' );
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' );
|
||||
?>
|
|
@ -1,99 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: same as 1.php, but using the PEAR::Date engine
|
||||
* Notice the use of the CALENDAR_ENGINE constant, which
|
||||
* switches the calculation "engine"
|
||||
* Note: make sure PEAR::Date is a stable release!!!
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
|
||||
// Switch to PEAR::Date engine
|
||||
define('CALENDAR_ENGINE','PearDate');
|
||||
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
|
||||
if (!isset($_GET['y'])) $_GET['y'] = 2003;
|
||||
if (!isset($_GET['m'])) $_GET['m'] = 8;
|
||||
if (!isset($_GET['d'])) $_GET['d'] = 9;
|
||||
if (!isset($_GET['h'])) $_GET['h'] = 12;
|
||||
if (!isset($_GET['i'])) $_GET['i'] = 34;
|
||||
if (!isset($_GET['s'])) $_GET['s'] = 46;
|
||||
|
||||
switch ( @$_GET['view'] ) {
|
||||
default:
|
||||
$_GET['view'] = 'calendar_year';
|
||||
case 'calendar_year':
|
||||
require_once CALENDAR_ROOT.'Year.php';
|
||||
$c = new Calendar_Year($_GET['y']);
|
||||
break;
|
||||
case 'calendar_month':
|
||||
require_once CALENDAR_ROOT.'Month.php';
|
||||
$c = new Calendar_Month($_GET['y'],$_GET['m']);
|
||||
break;
|
||||
case 'calendar_day':
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
$c = new Calendar_Day($_GET['y'],$_GET['m'],$_GET['d']);
|
||||
break;
|
||||
case 'calendar_hour':
|
||||
require_once CALENDAR_ROOT.'Hour.php';
|
||||
$c = new Calendar_Hour($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h']);
|
||||
break;
|
||||
case 'calendar_minute':
|
||||
require_once CALENDAR_ROOT.'Minute.php';
|
||||
$c = new Calendar_Minute($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h'],$_GET['i']);
|
||||
break;
|
||||
case 'calendar_second':
|
||||
require_once CALENDAR_ROOT.'Second.php';
|
||||
$c = new Calendar_Second($_GET['y'],$_GET['m'],$_GET['d'],$_GET['h'],$_GET['i'],$_GET['s']);
|
||||
break;
|
||||
}
|
||||
|
||||
// Convert timestamp to human readable date
|
||||
$date = new Date($c->getTimestamp());
|
||||
|
||||
echo ( '<h1>Using PEAR::Date engine</h1>' );
|
||||
echo ( 'Viewing: '.@$_GET['view'].'<br />' );
|
||||
echo ( 'The time is now: '.$date->format('%Y %a %e %T').'<br >' );
|
||||
|
||||
$i = 1;
|
||||
echo ( '<h1>First Iteration</h1>' );
|
||||
echo ( '<p>The first iteration is more "expensive", the calendar data
|
||||
structures having to be built.</p>' );
|
||||
$start = getmicrotime();
|
||||
$c->build();
|
||||
while ( $e = $c->fetch() ) {
|
||||
$class = strtolower(get_class($e));
|
||||
$link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay().
|
||||
"&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond();
|
||||
$method = 'this'.str_replace('calendar_','',$class);
|
||||
echo ( "<a href=\"".$_SERVER['PHP_SELF']."?view=".$class.$link."\">".$e->{$method}()."</a> : " );
|
||||
if ( ($i % 10) == 0 ) {
|
||||
echo ( '<br>' );
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' );
|
||||
|
||||
$i = 1;
|
||||
echo ( '<h1>Second Iteration</h1>' );
|
||||
echo ( '<p>This second iteration is faster, the data structures
|
||||
being re-used</p>' );
|
||||
$start = getmicrotime();
|
||||
while ( $e = $c->fetch() ) {
|
||||
$class = strtolower(get_class($e));
|
||||
$link ="&y=".$e->thisYear()."&m=".$e->thisMonth()."&d=".$e->thisDay().
|
||||
"&h=".$e->thisHour()."&i=".$e->thisMinute()."&s=".$e->thisSecond();
|
||||
$method = 'this'.str_replace('calendar_','',$class);
|
||||
echo ( "<a href=\"".$_SERVER['PHP_SELF']."?view=".$class.$link."\">".$e->{$method}()."</a> : " );
|
||||
if ( ($i % 10) == 0 ) {
|
||||
echo ( '<br>' );
|
||||
}
|
||||
$i++;
|
||||
}
|
||||
echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' );
|
||||
?>
|
|
@ -1,141 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: same as 3.php, but using the PEAR::Date engine
|
||||
* Note: make sure PEAR::Date is a stable release!!!
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
$start = getmicrotime();
|
||||
|
||||
// Switch to PEAR::Date engine
|
||||
define('CALENDAR_ENGINE', 'PearDate');
|
||||
|
||||
if (!@include 'Calendar'.DIRECTORY_SEPARATOR.'Calendar.php') {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Month/Weekdays.php';
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
|
||||
// Initialize GET variables if not set
|
||||
if (!isset($_GET['y'])) $_GET['y'] = date('Y');
|
||||
if (!isset($_GET['m'])) $_GET['m'] = date('m');
|
||||
if (!isset($_GET['d'])) $_GET['d'] = date('d');
|
||||
|
||||
// Build the month
|
||||
$month = new Calendar_Month_Weekdays($_GET['y'], $_GET['m']);
|
||||
|
||||
// Create an array of days which are "selected"
|
||||
// Used for Week::build() below
|
||||
$selectedDays = array (
|
||||
new Calendar_Day($_GET['y'], $_GET['m'], $_GET['d']),
|
||||
new Calendar_Day($_GET['y'], 12, 25),
|
||||
);
|
||||
|
||||
// Build the days in the month
|
||||
$month->build($selectedDays);
|
||||
|
||||
// Construct strings for next/previous links
|
||||
$PMonth = $month->prevMonth('object'); // Get previous month as object
|
||||
$prev = $_SERVER['PHP_SELF'].'?y='.$PMonth->thisYear().'&m='.$PMonth->thisMonth().'&d='.$PMonth->thisDay();
|
||||
$NMonth = $month->nextMonth('object');
|
||||
$next = $_SERVER['PHP_SELF'].'?y='.$NMonth->thisYear().'&m='.$NMonth->thisMonth().'&d='.$NMonth->thisDay();
|
||||
|
||||
$thisDate = new Date($month->thisMonth('timestamp'));
|
||||
?>
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> Calendar using PEAR::Date Engine </title>
|
||||
<style text="text/css">
|
||||
table {
|
||||
background-color: silver;
|
||||
}
|
||||
caption {
|
||||
font-family: verdana;
|
||||
font-size: 12px;
|
||||
background-color: while;
|
||||
}
|
||||
.prevMonth {
|
||||
font-size: 10px;
|
||||
text-align: left;
|
||||
}
|
||||
.nextMonth {
|
||||
font-size: 10px;
|
||||
text-align: right;
|
||||
}
|
||||
th {
|
||||
font-family: verdana;
|
||||
font-size: 11px;
|
||||
color: navy;
|
||||
text-align: right;
|
||||
}
|
||||
td {
|
||||
font-family: verdana;
|
||||
font-size: 11px;
|
||||
text-align: right;
|
||||
}
|
||||
.selected {
|
||||
background-color: yellow;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h2>Calendar using PEAR::Date Engine</h2>
|
||||
<table class="calendar">
|
||||
<caption>
|
||||
<?php echo $thisDate->format('%B %Y'); ?>
|
||||
</caption>
|
||||
<tr>
|
||||
<th>M</th>
|
||||
<th>T</th>
|
||||
<th>W</th>
|
||||
<th>T</th>
|
||||
<th>F</th>
|
||||
<th>S</th>
|
||||
<th>S</th>
|
||||
</tr>
|
||||
<?php
|
||||
while ($day = $month->fetch()) {
|
||||
// Build a link string for each day
|
||||
$link = $_SERVER['PHP_SELF'].
|
||||
'?y='.$day->thisYear().
|
||||
'&m='.$day->thisMonth().
|
||||
'&d='.$day->thisDay();
|
||||
|
||||
// isFirst() to find start of week
|
||||
if ($day->isFirst())
|
||||
echo "<tr>\n";
|
||||
|
||||
if ($day->isSelected()) {
|
||||
echo '<td class="selected">'.$day->thisDay().'</td>'."\n";
|
||||
} else if ($day->isEmpty()) {
|
||||
echo '<td> </td>'."\n";
|
||||
} else {
|
||||
echo '<td><a href="'.$link.'">'.$day->thisDay().'</a></td>'."\n";
|
||||
}
|
||||
|
||||
// isLast() to find end of week
|
||||
if ($day->isLast()) {
|
||||
echo "</tr>\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="<?php echo $prev; ?>" class="prevMonth"><< </a>
|
||||
</td>
|
||||
<td colspan="5"> </td>
|
||||
<td>
|
||||
<a href="<?php echo $next; ?>" class="nextMonth"> >></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
echo '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>';
|
||||
?>
|
||||
</body>
|
||||
</html>
|
|
@ -1,141 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: same as 3.php, but using the PEAR::Date engine
|
||||
* Note: make sure PEAR::Date is a stable release!!!
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
$start = getmicrotime();
|
||||
|
||||
// Switch to PEAR::Date engine
|
||||
define('CALENDAR_ENGINE', 'PearDate');
|
||||
|
||||
if (!@include 'Calendar'.DIRECTORY_SEPARATOR.'Calendar.php') {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Month/Weekdays.php';
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
|
||||
// Initialize GET variables if not set
|
||||
if (!isset($_GET['y'])) $_GET['y'] = date('Y');
|
||||
if (!isset($_GET['m'])) $_GET['m'] = date('m');
|
||||
if (!isset($_GET['d'])) $_GET['d'] = date('d');
|
||||
|
||||
// Build the month
|
||||
$month = new Calendar_Month_Weekdays($_GET['y'], $_GET['m']);
|
||||
|
||||
// Create an array of days which are "selected"
|
||||
// Used for Week::build() below
|
||||
$selectedDays = array (
|
||||
new Calendar_Day($_GET['y'], $_GET['m'], $_GET['d']),
|
||||
new Calendar_Day($_GET['y'], 12, 25),
|
||||
);
|
||||
|
||||
// Build the days in the month
|
||||
$month->build($selectedDays);
|
||||
|
||||
// Construct strings for next/previous links
|
||||
$PMonth = $month->prevMonth('object'); // Get previous month as object
|
||||
$prev = $_SERVER['PHP_SELF'].'?y='.$PMonth->thisYear().'&m='.$PMonth->thisMonth().'&d='.$PMonth->thisDay();
|
||||
$NMonth = $month->nextMonth('object');
|
||||
$next = $_SERVER['PHP_SELF'].'?y='.$NMonth->thisYear().'&m='.$NMonth->thisMonth().'&d='.$NMonth->thisDay();
|
||||
|
||||
$thisDate = new Date($month->thisMonth('timestamp'));
|
||||
?>
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> Calendar using PEAR::Date Engine </title>
|
||||
<style text="text/css">
|
||||
table {
|
||||
background-color: silver;
|
||||
}
|
||||
caption {
|
||||
font-family: verdana;
|
||||
font-size: 12px;
|
||||
background-color: while;
|
||||
}
|
||||
.prevMonth {
|
||||
font-size: 10px;
|
||||
text-align: left;
|
||||
}
|
||||
.nextMonth {
|
||||
font-size: 10px;
|
||||
text-align: right;
|
||||
}
|
||||
th {
|
||||
font-family: verdana;
|
||||
font-size: 11px;
|
||||
color: navy;
|
||||
text-align: right;
|
||||
}
|
||||
td {
|
||||
font-family: verdana;
|
||||
font-size: 11px;
|
||||
text-align: right;
|
||||
}
|
||||
.selected {
|
||||
background-color: yellow;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h2>Calendar using PEAR::Date Engine</h2>
|
||||
<table class="calendar">
|
||||
<caption>
|
||||
<?php echo $thisDate->format('%B %Y'); ?>
|
||||
</caption>
|
||||
<tr>
|
||||
<th>M</th>
|
||||
<th>T</th>
|
||||
<th>W</th>
|
||||
<th>T</th>
|
||||
<th>F</th>
|
||||
<th>S</th>
|
||||
<th>S</th>
|
||||
</tr>
|
||||
<?php
|
||||
while ($day = $month->fetch()) {
|
||||
// Build a link string for each day
|
||||
$link = $_SERVER['PHP_SELF'].
|
||||
'?y='.$day->thisYear().
|
||||
'&m='.$day->thisMonth().
|
||||
'&d='.$day->thisDay();
|
||||
|
||||
// isFirst() to find start of week
|
||||
if ($day->isFirst())
|
||||
echo "<tr>\n";
|
||||
|
||||
if ($day->isSelected()) {
|
||||
echo '<td class="selected">'.$day->thisDay().'</td>'."\n";
|
||||
} else if ($day->isEmpty()) {
|
||||
echo '<td> </td>'."\n";
|
||||
} else {
|
||||
echo '<td><a href="'.$link.'">'.$day->thisDay().'</a></td>'."\n";
|
||||
}
|
||||
|
||||
// isLast() to find end of week
|
||||
if ($day->isLast()) {
|
||||
echo "</tr>\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="<?php echo $prev; ?>" class="prevMonth"><< </a>
|
||||
</td>
|
||||
<td colspan="5"> </td>
|
||||
<td>
|
||||
<a href="<?php echo $next; ?>" class="nextMonth"> >></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
echo '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>';
|
||||
?>
|
||||
</body>
|
||||
</html>
|
|
@ -1,58 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Shows more on how a week can be used
|
||||
*/
|
||||
function getmicrotime() {
|
||||
list($usec, $sec) = explode(" ", microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
$start = getmicrotime();
|
||||
|
||||
if (!@include 'Calendar/Calendar.php') {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Week.php';
|
||||
|
||||
if (!isset($_GET['y'])) $_GET['y'] = date('Y');
|
||||
if (!isset($_GET['m'])) $_GET['m'] = date('m');
|
||||
if (!isset($_GET['d'])) $_GET['d'] = 1;
|
||||
|
||||
// Build the month
|
||||
$Week = new Calendar_Week($_GET['y'], $_GET['m'], $_GET['d']);
|
||||
/*
|
||||
$Validator = $Week->getValidator();
|
||||
if (!$Validator->isValidWeek()) {
|
||||
die ('Please enter a valid week!');
|
||||
}
|
||||
*/
|
||||
?>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> Paging Weeks </title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Paging Weeks</h1>
|
||||
<h2>Week: <?php echo $Week->thisWeek().' '.date('F Y',$Week->thisMonth(true)); ?></h2>
|
||||
<?php
|
||||
$Week->build();
|
||||
while ($Day = $Week->fetch()) {
|
||||
echo '<p>'.date('jS F',$Day->thisDay(true))."</p>\n";
|
||||
}
|
||||
$days = $Week->fetchAll();
|
||||
|
||||
$prevWeek = $Week->prevWeek('array');
|
||||
$prevWeekLink = $_SERVER['PHP_SELF'].
|
||||
'?y='.$prevWeek['year'].
|
||||
'&m='.$prevWeek['month'].
|
||||
'&d='.$prevWeek['day'];
|
||||
|
||||
$nextWeek = $Week->nextWeek('array');
|
||||
$nextWeekLink = $_SERVER['PHP_SELF'].
|
||||
'?y='.$nextWeek['year'].
|
||||
'&m='.$nextWeek['month'].
|
||||
'&d='.$nextWeek['day'];
|
||||
?>
|
||||
<p><a href="<?php echo $prevWeekLink; ?>"><<</a> | <a href="<?php echo $nextWeekLink; ?>">>></a></p>
|
||||
</body>
|
||||
</html>
|
|
@ -1,58 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Shows more on how a week can be used
|
||||
*/
|
||||
function getmicrotime() {
|
||||
list($usec, $sec) = explode(" ", microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
$start = getmicrotime();
|
||||
|
||||
if (!@include 'Calendar/Calendar.php') {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Week.php';
|
||||
|
||||
if (!isset($_GET['y'])) $_GET['y'] = date('Y');
|
||||
if (!isset($_GET['m'])) $_GET['m'] = date('m');
|
||||
if (!isset($_GET['d'])) $_GET['d'] = 1;
|
||||
|
||||
// Build the month
|
||||
$Week = new Calendar_Week($_GET['y'], $_GET['m'], $_GET['d']);
|
||||
/*
|
||||
$Validator = $Week->getValidator();
|
||||
if (!$Validator->isValidWeek()) {
|
||||
die ('Please enter a valid week!');
|
||||
}
|
||||
*/
|
||||
?>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> Paging Weeks </title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Paging Weeks</h1>
|
||||
<h2>Week: <?php echo $Week->thisWeek().' '.date('F Y',$Week->thisMonth(true)); ?></h2>
|
||||
<?php
|
||||
$Week->build();
|
||||
while ($Day = $Week->fetch()) {
|
||||
echo '<p>'.date('jS F',$Day->thisDay(true))."</p>\n";
|
||||
}
|
||||
$days = $Week->fetchAll();
|
||||
|
||||
$prevWeek = $Week->prevWeek('array');
|
||||
$prevWeekLink = $_SERVER['PHP_SELF'].
|
||||
'?y='.$prevWeek['year'].
|
||||
'&m='.$prevWeek['month'].
|
||||
'&d='.$prevWeek['day'];
|
||||
|
||||
$nextWeek = $Week->nextWeek('array');
|
||||
$nextWeekLink = $_SERVER['PHP_SELF'].
|
||||
'?y='.$nextWeek['year'].
|
||||
'&m='.$nextWeek['month'].
|
||||
'&d='.$nextWeek['day'];
|
||||
?>
|
||||
<p><a href="<?php echo $prevWeekLink; ?>"><<</a> | <a href="<?php echo $nextWeekLink; ?>">>></a></p>
|
||||
</body>
|
||||
</html>
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: demonstrates using the Uri decorator
|
||||
*/
|
||||
if (!@include 'Calendar/Calendar.php') {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Month/Weekdays.php';
|
||||
require_once CALENDAR_ROOT.'Decorator/Uri.php';
|
||||
|
||||
if (!isset($_GET['jahr'])) $_GET['jahr'] = date('Y');
|
||||
if (!isset($_GET['monat'])) $_GET['monat'] = date('m');
|
||||
|
||||
// Build the month
|
||||
$Calendar = new Calendar_Month_Weekdays($_GET['jahr'], $_GET['monat']);
|
||||
|
||||
echo ( '<p>The current month is '
|
||||
.$Calendar->thisMonth().' of year '.$Calendar->thisYear().'</p>');
|
||||
|
||||
$Uri = & new Calendar_Decorator_Uri($Calendar);
|
||||
$Uri->setFragments('jahr','monat');
|
||||
// $Uri->setSeperator('/'); // Default is &
|
||||
// $Uri->setScalar(); // Omit variable names
|
||||
echo ( "<pre>Previous Uri:\t".$Uri->prev('month')."\n" );
|
||||
echo ( "This Uri:\t".$Uri->this('month')."\n" );
|
||||
echo ( "Next Uri:\t".$Uri->next('month')."\n</pre>" );
|
||||
?>
|
||||
<p>
|
||||
<a href="<?php echo($_SERVER['PHP_SELF'].'?'.$Uri->prev('month'));?>">Prev</a> :
|
||||
<a href="<?php echo($_SERVER['PHP_SELF'].'?'.$Uri->next('month'));?>">Next</a>
|
||||
</p>
|
|
@ -1,31 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: demonstrates using the Uri decorator
|
||||
*/
|
||||
if (!@include 'Calendar/Calendar.php') {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Month/Weekdays.php';
|
||||
require_once CALENDAR_ROOT.'Decorator/Uri.php';
|
||||
|
||||
if (!isset($_GET['jahr'])) $_GET['jahr'] = date('Y');
|
||||
if (!isset($_GET['monat'])) $_GET['monat'] = date('m');
|
||||
|
||||
// Build the month
|
||||
$Calendar = new Calendar_Month_Weekdays($_GET['jahr'], $_GET['monat']);
|
||||
|
||||
echo ( '<p>The current month is '
|
||||
.$Calendar->thisMonth().' of year '.$Calendar->thisYear().'</p>');
|
||||
|
||||
$Uri = & new Calendar_Decorator_Uri($Calendar);
|
||||
$Uri->setFragments('jahr','monat');
|
||||
// $Uri->setSeperator('/'); // Default is &
|
||||
// $Uri->setScalar(); // Omit variable names
|
||||
echo ( "<pre>Previous Uri:\t".$Uri->prev('month')."\n" );
|
||||
echo ( "This Uri:\t".$Uri->this('month')."\n" );
|
||||
echo ( "Next Uri:\t".$Uri->next('month')."\n</pre>" );
|
||||
?>
|
||||
<p>
|
||||
<a href="<?php echo($_SERVER['PHP_SELF'].'?'.$Uri->prev('month'));?>">Prev</a> :
|
||||
<a href="<?php echo($_SERVER['PHP_SELF'].'?'.$Uri->next('month'));?>">Next</a>
|
||||
</p>
|
|
@ -1,71 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: demonstrates using the Textual decorator
|
||||
*/
|
||||
|
||||
if (!@include 'Calendar'.DIRECTORY_SEPARATOR.'Calendar.php') {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
require_once CALENDAR_ROOT.'Month'.DIRECTORY_SEPARATOR.'Weekdays.php';
|
||||
require_once CALENDAR_ROOT.'Decorator'.DIRECTORY_SEPARATOR.'Textual.php';
|
||||
|
||||
// Could change language like this
|
||||
// setlocale (LC_TIME, "de_DE"); // Unix based (probably)
|
||||
// setlocale (LC_TIME, "ge"); // Windows
|
||||
|
||||
echo "<hr>Calling: Calendar_Decorator_Textual::monthNames('long');<pre>";
|
||||
print_r(Calendar_Decorator_Textual::monthNames('long'));
|
||||
echo '</pre>';
|
||||
|
||||
echo "<hr>Calling: Calendar_Decorator_Textual::weekdayNames('two');<pre>";
|
||||
print_r(Calendar_Decorator_Textual::weekdayNames('two'));
|
||||
echo '</pre>';
|
||||
|
||||
echo "<hr>Creating: new Calendar_Day(date('Y'), date('n'), date('d'));<br />";
|
||||
$Calendar = new Calendar_Day(date('Y'), date('n'), date('d'));
|
||||
|
||||
// Decorate
|
||||
$Textual = & new Calendar_Decorator_Textual($Calendar);
|
||||
|
||||
echo '<hr>Previous month is: '.$Textual->prevMonthName('two').'<br />';
|
||||
echo 'This month is: '.$Textual->thisMonthName('short').'<br />';
|
||||
echo 'Next month is: '.$Textual->nextMonthName().'<br /><hr />';
|
||||
echo 'Previous day is: '.$Textual->prevDayName().'<br />';
|
||||
echo 'This day is: '.$Textual->thisDayName('short').'<br />';
|
||||
echo 'Next day is: '.$Textual->nextDayName('one').'<br /><hr />';
|
||||
|
||||
echo "Creating: new Calendar_Month_Weekdays(date('Y'), date('n'), 6); - Saturday is first day of week<br />";
|
||||
$Calendar = new Calendar_Month_Weekdays(date('Y'), date('n'), 6);
|
||||
|
||||
// Decorate
|
||||
$Textual = & new Calendar_Decorator_Textual($Calendar);
|
||||
?>
|
||||
<p>Rendering calendar....</p>
|
||||
<table>
|
||||
<caption><?php echo $Textual->thisMonthName().' '.$Textual->thisYear(); ?></caption>
|
||||
<tr>
|
||||
<?php
|
||||
$dayheaders = $Textual->orderedWeekdays('short');
|
||||
foreach ($dayheaders as $dayheader) {
|
||||
echo '<th>'.$dayheader.'</th>';
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
$Calendar->build();
|
||||
while ($Day = $Calendar->fetch()) {
|
||||
if ($Day->isFirst()) {
|
||||
echo "<tr>\n";
|
||||
}
|
||||
if ($Day->isEmpty()) {
|
||||
echo '<td> </td>';
|
||||
} else {
|
||||
echo '<td>'.$Day->thisDay().'</td>';
|
||||
}
|
||||
if ($Day->isLast()) {
|
||||
echo "</tr>\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</table>
|
|
@ -1,71 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: demonstrates using the Textual decorator
|
||||
*/
|
||||
|
||||
if (!@include 'Calendar'.DIRECTORY_SEPARATOR.'Calendar.php') {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
require_once CALENDAR_ROOT.'Month'.DIRECTORY_SEPARATOR.'Weekdays.php';
|
||||
require_once CALENDAR_ROOT.'Decorator'.DIRECTORY_SEPARATOR.'Textual.php';
|
||||
|
||||
// Could change language like this
|
||||
// setlocale (LC_TIME, "de_DE"); // Unix based (probably)
|
||||
// setlocale (LC_TIME, "ge"); // Windows
|
||||
|
||||
echo "<hr>Calling: Calendar_Decorator_Textual::monthNames('long');<pre>";
|
||||
print_r(Calendar_Decorator_Textual::monthNames('long'));
|
||||
echo '</pre>';
|
||||
|
||||
echo "<hr>Calling: Calendar_Decorator_Textual::weekdayNames('two');<pre>";
|
||||
print_r(Calendar_Decorator_Textual::weekdayNames('two'));
|
||||
echo '</pre>';
|
||||
|
||||
echo "<hr>Creating: new Calendar_Day(date('Y'), date('n'), date('d'));<br />";
|
||||
$Calendar = new Calendar_Day(date('Y'), date('n'), date('d'));
|
||||
|
||||
// Decorate
|
||||
$Textual = & new Calendar_Decorator_Textual($Calendar);
|
||||
|
||||
echo '<hr>Previous month is: '.$Textual->prevMonthName('two').'<br />';
|
||||
echo 'This month is: '.$Textual->thisMonthName('short').'<br />';
|
||||
echo 'Next month is: '.$Textual->nextMonthName().'<br /><hr />';
|
||||
echo 'Previous day is: '.$Textual->prevDayName().'<br />';
|
||||
echo 'This day is: '.$Textual->thisDayName('short').'<br />';
|
||||
echo 'Next day is: '.$Textual->nextDayName('one').'<br /><hr />';
|
||||
|
||||
echo "Creating: new Calendar_Month_Weekdays(date('Y'), date('n'), 6); - Saturday is first day of week<br />";
|
||||
$Calendar = new Calendar_Month_Weekdays(date('Y'), date('n'), 6);
|
||||
|
||||
// Decorate
|
||||
$Textual = & new Calendar_Decorator_Textual($Calendar);
|
||||
?>
|
||||
<p>Rendering calendar....</p>
|
||||
<table>
|
||||
<caption><?php echo $Textual->thisMonthName().' '.$Textual->thisYear(); ?></caption>
|
||||
<tr>
|
||||
<?php
|
||||
$dayheaders = $Textual->orderedWeekdays('short');
|
||||
foreach ($dayheaders as $dayheader) {
|
||||
echo '<th>'.$dayheader.'</th>';
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
$Calendar->build();
|
||||
while ($Day = $Calendar->fetch()) {
|
||||
if ($Day->isFirst()) {
|
||||
echo "<tr>\n";
|
||||
}
|
||||
if ($Day->isEmpty()) {
|
||||
echo '<td> </td>';
|
||||
} else {
|
||||
echo '<td>'.$Day->thisDay().'</td>';
|
||||
}
|
||||
if ($Day->isLast()) {
|
||||
echo "</tr>\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</table>
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: demonstrates using the Wrapper decorator
|
||||
*/
|
||||
|
||||
if (!@include 'Calendar/Calendar.php') {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Month.php';
|
||||
require_once CALENDAR_ROOT.'Decorator.php'; // Not really needed but added to help this make sense
|
||||
require_once CALENDAR_ROOT.'Decorator/Wrapper.php';
|
||||
|
||||
class MyBoldDecorator extends Calendar_Decorator
|
||||
{
|
||||
function MyBoldDecorator(&$Calendar)
|
||||
{
|
||||
parent::Calendar_Decorator($Calendar);
|
||||
}
|
||||
|
||||
function thisDay()
|
||||
{
|
||||
return '<b>'.parent::thisDay().'</b>';
|
||||
}
|
||||
}
|
||||
|
||||
$Month = new Calendar_Month(date('Y'), date('n'));
|
||||
|
||||
$Wrapper = & new Calendar_Decorator_Wrapper($Month);
|
||||
$Wrapper->build();
|
||||
|
||||
echo '<h2>The Wrapper decorator</h2>';
|
||||
echo '<i>Day numbers are rendered in bold</i><br /> <br />';
|
||||
while ($DecoratedDay = $Wrapper->fetch('MyBoldDecorator')) {
|
||||
echo $DecoratedDay->thisDay().'<br />';
|
||||
}
|
||||
?>
|
|
@ -1,36 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: demonstrates using the Wrapper decorator
|
||||
*/
|
||||
|
||||
if (!@include 'Calendar/Calendar.php') {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Month.php';
|
||||
require_once CALENDAR_ROOT.'Decorator.php'; // Not really needed but added to help this make sense
|
||||
require_once CALENDAR_ROOT.'Decorator/Wrapper.php';
|
||||
|
||||
class MyBoldDecorator extends Calendar_Decorator
|
||||
{
|
||||
function MyBoldDecorator(&$Calendar)
|
||||
{
|
||||
parent::Calendar_Decorator($Calendar);
|
||||
}
|
||||
|
||||
function thisDay()
|
||||
{
|
||||
return '<b>'.parent::thisDay().'</b>';
|
||||
}
|
||||
}
|
||||
|
||||
$Month = new Calendar_Month(date('Y'), date('n'));
|
||||
|
||||
$Wrapper = & new Calendar_Decorator_Wrapper($Month);
|
||||
$Wrapper->build();
|
||||
|
||||
echo '<h2>The Wrapper decorator</h2>';
|
||||
echo '<i>Day numbers are rendered in bold</i><br /> <br />';
|
||||
while ($DecoratedDay = $Wrapper->fetch('MyBoldDecorator')) {
|
||||
echo $DecoratedDay->thisDay().'<br />';
|
||||
}
|
||||
?>
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: demonstrates using the Weekday decorator
|
||||
*/
|
||||
if (!@include 'Calendar'.DIRECTORY_SEPARATOR.'Calendar.php') {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
require_once CALENDAR_ROOT.'Decorator/Weekday.php';
|
||||
|
||||
$Day = new Calendar_Day(date('Y'), date('n'),date('d'));
|
||||
$WeekDay = & new Calendar_Decorator_Weekday($Day);
|
||||
// $WeekDay->setFirstDay(0); // Make Sunday first Day
|
||||
|
||||
echo 'Yesterday: '.$WeekDay->prevWeekDay().'<br>';
|
||||
echo 'Today: '.$WeekDay->thisWeekDay().'<br>';
|
||||
echo 'Tomorrow: '.$WeekDay->nextWeekDay().'<br>';
|
||||
|
||||
$WeekDay->build();
|
||||
echo 'Hours today:<br>';
|
||||
while ( $Hour = $WeekDay->fetch() ) {
|
||||
echo $Hour->thisHour().'<br>';
|
||||
}
|
||||
?>
|
|
@ -1,24 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: demonstrates using the Weekday decorator
|
||||
*/
|
||||
if (!@include 'Calendar'.DIRECTORY_SEPARATOR.'Calendar.php') {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
require_once CALENDAR_ROOT.'Decorator/Weekday.php';
|
||||
|
||||
$Day = new Calendar_Day(date('Y'), date('n'),date('d'));
|
||||
$WeekDay = & new Calendar_Decorator_Weekday($Day);
|
||||
// $WeekDay->setFirstDay(0); // Make Sunday first Day
|
||||
|
||||
echo 'Yesterday: '.$WeekDay->prevWeekDay().'<br>';
|
||||
echo 'Today: '.$WeekDay->thisWeekDay().'<br>';
|
||||
echo 'Tomorrow: '.$WeekDay->nextWeekDay().'<br>';
|
||||
|
||||
$WeekDay->build();
|
||||
echo 'Hours today:<br>';
|
||||
while ( $Hour = $WeekDay->fetch() ) {
|
||||
echo $Hour->thisHour().'<br>';
|
||||
}
|
||||
?>
|
|
@ -1,142 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: Demonstrates building a calendar for a month using the Week class
|
||||
* Uses UnixTs engine
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
$start = getmicrotime();
|
||||
|
||||
// Force UnixTs engine (default setting)
|
||||
define('CALENDAR_ENGINE','UnixTs');
|
||||
|
||||
if (!@include 'Calendar'.DIRECTORY_SEPARATOR.'Calendar.php') {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Month/Weeks.php';
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
|
||||
// Initialize GET variables if not set
|
||||
if (!isset($_GET['y'])) $_GET['y'] = date('Y');
|
||||
if (!isset($_GET['m'])) $_GET['m'] = date('m');
|
||||
if (!isset($_GET['d'])) $_GET['d'] = date('d');
|
||||
|
||||
// Build a month object
|
||||
$Month = new Calendar_Month_Weeks($_GET['y'], $_GET['m']);
|
||||
|
||||
// Create an array of days which are "selected"
|
||||
// Used for Week::build() below
|
||||
$selectedDays = array (
|
||||
new Calendar_Day($_GET['y'],$_GET['m'], $_GET['d']),
|
||||
new Calendar_Day($_GET['y'], 12, 25),
|
||||
new Calendar_Day(date('Y'), date('m'), date('d')),
|
||||
);
|
||||
|
||||
// Instruct month to build Week objects
|
||||
$Month->build();
|
||||
|
||||
// Construct strings for next/previous links
|
||||
$PMonth = $Month->prevMonth('object'); // Get previous month as object
|
||||
$prev = $_SERVER['PHP_SELF'].'?y='.$PMonth->thisYear().'&m='.$PMonth->thisMonth().'&d='.$PMonth->thisDay();
|
||||
$NMonth = $Month->nextMonth('object');
|
||||
$next = $_SERVER['PHP_SELF'].'?y='.$NMonth->thisYear().'&m='.$NMonth->thisMonth().'&d='.$NMonth->thisDay();
|
||||
?>
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> Calendar </title>
|
||||
<style text="text/css">
|
||||
table {
|
||||
background-color: silver;
|
||||
}
|
||||
caption {
|
||||
font-family: verdana;
|
||||
font-size: 12px;
|
||||
background-color: while;
|
||||
}
|
||||
.prevMonth {
|
||||
font-size: 10px;
|
||||
text-align: left;
|
||||
}
|
||||
.nextMonth {
|
||||
font-size: 10px;
|
||||
text-align: right;
|
||||
}
|
||||
th {
|
||||
font-family: verdana;
|
||||
font-size: 11px;
|
||||
color: navy;
|
||||
text-align: right;
|
||||
}
|
||||
td {
|
||||
font-family: verdana;
|
||||
font-size: 11px;
|
||||
text-align: right;
|
||||
}
|
||||
.selected {
|
||||
background-color: yellow;
|
||||
}
|
||||
.empty {
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h2>Build with Calendar_Month_Weeks::build() then Calendar_Week::build()</h2>
|
||||
<table class="calendar">
|
||||
<caption>
|
||||
<?php echo date('F Y', $Month->getTimeStamp()); ?>
|
||||
</caption>
|
||||
<tr>
|
||||
<th>M</th>
|
||||
<th>T</th>
|
||||
<th>W</th>
|
||||
<th>T</th>
|
||||
<th>F</th>
|
||||
<th>S</th>
|
||||
<th>S</th>
|
||||
</tr>
|
||||
<?php
|
||||
while ($Week = $Month->fetch()) {
|
||||
echo "<tr>\n";
|
||||
// Build the days in the week, passing the selected days
|
||||
$Week->build($selectedDays);
|
||||
while ($Day = $Week->fetch()) {
|
||||
|
||||
// Build a link string for each day
|
||||
$link = $_SERVER['PHP_SELF'].
|
||||
'?y='.$Day->thisYear().
|
||||
'&m='.$Day->thisMonth().
|
||||
'&d='.$Day->thisDay();
|
||||
|
||||
// Check to see if day is selected
|
||||
if ($Day->isSelected()) {
|
||||
echo '<td class="selected">'.$Day->thisDay().'</td>'."\n";
|
||||
// Check to see if day is empty
|
||||
} else if ($Day->isEmpty()) {
|
||||
echo '<td class="empty">'.$Day->thisDay().'</td>'."\n";
|
||||
} else {
|
||||
echo '<td><a href="'.$link.'">'.$Day->thisDay().'</a></td>'."\n";
|
||||
}
|
||||
}
|
||||
echo '</tr>'."\n";
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="<?php echo $prev; ?>" class="prevMonth"><< </a>
|
||||
</td>
|
||||
<td colspan="5"> </td>
|
||||
<td>
|
||||
<a href="<?php echo $next; ?>" class="nextMonth"> >></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
echo '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>';
|
||||
?>
|
||||
</body>
|
||||
</html>
|
|
@ -1,142 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: Demonstrates building a calendar for a month using the Week class
|
||||
* Uses UnixTs engine
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
$start = getmicrotime();
|
||||
|
||||
// Force UnixTs engine (default setting)
|
||||
define('CALENDAR_ENGINE','UnixTs');
|
||||
|
||||
if (!@include 'Calendar'.DIRECTORY_SEPARATOR.'Calendar.php') {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Month/Weeks.php';
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
|
||||
// Initialize GET variables if not set
|
||||
if (!isset($_GET['y'])) $_GET['y'] = date('Y');
|
||||
if (!isset($_GET['m'])) $_GET['m'] = date('m');
|
||||
if (!isset($_GET['d'])) $_GET['d'] = date('d');
|
||||
|
||||
// Build a month object
|
||||
$Month = new Calendar_Month_Weeks($_GET['y'], $_GET['m']);
|
||||
|
||||
// Create an array of days which are "selected"
|
||||
// Used for Week::build() below
|
||||
$selectedDays = array (
|
||||
new Calendar_Day($_GET['y'],$_GET['m'], $_GET['d']),
|
||||
new Calendar_Day($_GET['y'], 12, 25),
|
||||
new Calendar_Day(date('Y'), date('m'), date('d')),
|
||||
);
|
||||
|
||||
// Instruct month to build Week objects
|
||||
$Month->build();
|
||||
|
||||
// Construct strings for next/previous links
|
||||
$PMonth = $Month->prevMonth('object'); // Get previous month as object
|
||||
$prev = $_SERVER['PHP_SELF'].'?y='.$PMonth->thisYear().'&m='.$PMonth->thisMonth().'&d='.$PMonth->thisDay();
|
||||
$NMonth = $Month->nextMonth('object');
|
||||
$next = $_SERVER['PHP_SELF'].'?y='.$NMonth->thisYear().'&m='.$NMonth->thisMonth().'&d='.$NMonth->thisDay();
|
||||
?>
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> Calendar </title>
|
||||
<style text="text/css">
|
||||
table {
|
||||
background-color: silver;
|
||||
}
|
||||
caption {
|
||||
font-family: verdana;
|
||||
font-size: 12px;
|
||||
background-color: while;
|
||||
}
|
||||
.prevMonth {
|
||||
font-size: 10px;
|
||||
text-align: left;
|
||||
}
|
||||
.nextMonth {
|
||||
font-size: 10px;
|
||||
text-align: right;
|
||||
}
|
||||
th {
|
||||
font-family: verdana;
|
||||
font-size: 11px;
|
||||
color: navy;
|
||||
text-align: right;
|
||||
}
|
||||
td {
|
||||
font-family: verdana;
|
||||
font-size: 11px;
|
||||
text-align: right;
|
||||
}
|
||||
.selected {
|
||||
background-color: yellow;
|
||||
}
|
||||
.empty {
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h2>Build with Calendar_Month_Weeks::build() then Calendar_Week::build()</h2>
|
||||
<table class="calendar">
|
||||
<caption>
|
||||
<?php echo date('F Y', $Month->getTimeStamp()); ?>
|
||||
</caption>
|
||||
<tr>
|
||||
<th>M</th>
|
||||
<th>T</th>
|
||||
<th>W</th>
|
||||
<th>T</th>
|
||||
<th>F</th>
|
||||
<th>S</th>
|
||||
<th>S</th>
|
||||
</tr>
|
||||
<?php
|
||||
while ($Week = $Month->fetch()) {
|
||||
echo "<tr>\n";
|
||||
// Build the days in the week, passing the selected days
|
||||
$Week->build($selectedDays);
|
||||
while ($Day = $Week->fetch()) {
|
||||
|
||||
// Build a link string for each day
|
||||
$link = $_SERVER['PHP_SELF'].
|
||||
'?y='.$Day->thisYear().
|
||||
'&m='.$Day->thisMonth().
|
||||
'&d='.$Day->thisDay();
|
||||
|
||||
// Check to see if day is selected
|
||||
if ($Day->isSelected()) {
|
||||
echo '<td class="selected">'.$Day->thisDay().'</td>'."\n";
|
||||
// Check to see if day is empty
|
||||
} else if ($Day->isEmpty()) {
|
||||
echo '<td class="empty">'.$Day->thisDay().'</td>'."\n";
|
||||
} else {
|
||||
echo '<td><a href="'.$link.'">'.$Day->thisDay().'</a></td>'."\n";
|
||||
}
|
||||
}
|
||||
echo '</tr>'."\n";
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="<?php echo $prev; ?>" class="prevMonth"><< </a>
|
||||
</td>
|
||||
<td colspan="5"> </td>
|
||||
<td>
|
||||
<a href="<?php echo $next; ?>" class="nextMonth"> >></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
echo '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>';
|
||||
?>
|
||||
</body>
|
||||
</html>
|
|
@ -1,240 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: demonstrates a decorator used to "attach a payload" to a selection
|
||||
* to make it available when iterating over calendar children
|
||||
*/
|
||||
|
||||
//if you use ISO-8601 dates, switch to PearDate engine
|
||||
define('CALENDAR_ENGINE', 'PearDate');
|
||||
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
|
||||
require_once CALENDAR_ROOT . 'Month/Weekdays.php';
|
||||
require_once CALENDAR_ROOT . 'Day.php';
|
||||
require_once CALENDAR_ROOT . 'Decorator.php';
|
||||
|
||||
// accepts multiple entries
|
||||
class DiaryEvent extends Calendar_Decorator
|
||||
{
|
||||
var $entries = array();
|
||||
|
||||
function DiaryEvent($calendar) {
|
||||
Calendar_Decorator::Calendar_Decorator($calendar);
|
||||
}
|
||||
|
||||
function addEntry($entry) {
|
||||
$this->entries[] = $entry;
|
||||
}
|
||||
|
||||
function getEntry() {
|
||||
$entry = each($this->entries);
|
||||
if ($entry) {
|
||||
return $entry['value'];
|
||||
} else {
|
||||
reset($this->entries);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MonthPayload_Decorator extends Calendar_Decorator
|
||||
{
|
||||
//Calendar engine
|
||||
var $cE;
|
||||
var $tableHelper;
|
||||
|
||||
var $year;
|
||||
var $month;
|
||||
var $firstDay = false;
|
||||
|
||||
function build($events=array())
|
||||
{
|
||||
require_once CALENDAR_ROOT . 'Day.php';
|
||||
require_once CALENDAR_ROOT . 'Table/Helper.php';
|
||||
|
||||
$this->tableHelper = & new Calendar_Table_Helper($this, $this->firstDay);
|
||||
$this->cE = & $this->getEngine();
|
||||
$this->year = $this->thisYear();
|
||||
$this->month = $this->thisMonth();
|
||||
|
||||
$daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month);
|
||||
for ($i=1; $i<=$daysInMonth; $i++) {
|
||||
$Day = new Calendar_Day(2000,1,1); // Create Day with dummy values
|
||||
$Day->setTimeStamp($this->cE->dateToStamp($this->year, $this->month, $i));
|
||||
$this->children[$i] = new DiaryEvent($Day);
|
||||
}
|
||||
if (count($events) > 0) {
|
||||
$this->setSelection($events);
|
||||
}
|
||||
Calendar_Month_Weekdays::buildEmptyDaysBefore();
|
||||
Calendar_Month_Weekdays::shiftDays();
|
||||
Calendar_Month_Weekdays::buildEmptyDaysAfter();
|
||||
Calendar_Month_Weekdays::setWeekMarkers();
|
||||
return true;
|
||||
}
|
||||
|
||||
function setSelection($events)
|
||||
{
|
||||
$daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month);
|
||||
for ($i=1; $i<=$daysInMonth; $i++) {
|
||||
$stamp1 = $this->cE->dateToStamp($this->year, $this->month, $i);
|
||||
$stamp2 = $this->cE->dateToStamp($this->year, $this->month, $i+1);
|
||||
foreach ($events as $event) {
|
||||
if (($stamp1 >= $event['start'] && $stamp1 < $event['end']) ||
|
||||
($stamp2 >= $event['start'] && $stamp2 < $event['end']) ||
|
||||
($stamp1 <= $event['start'] && $stamp2 > $event['end'])
|
||||
) {
|
||||
$this->children[$i]->addEntry($event);
|
||||
$this->children[$i]->setSelected();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fetch()
|
||||
{
|
||||
$child = each($this->children);
|
||||
if ($child) {
|
||||
return $child['value'];
|
||||
} else {
|
||||
reset($this->children);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calendar instance used to get the dates in the preferred format:
|
||||
// you can switch Calendar Engine and the example still works
|
||||
$cal = new Calendar;
|
||||
|
||||
$events = array();
|
||||
//add some events
|
||||
$events[] = array(
|
||||
'start' => $cal->cE->dateToStamp(2004, 6, 1, 10),
|
||||
'end' => $cal->cE->dateToStamp(2004, 6, 1, 12),
|
||||
'desc' => 'Important meeting'
|
||||
);
|
||||
$events[] = array(
|
||||
'start' => $cal->cE->dateToStamp(2004, 6, 1, 21),
|
||||
'end' => $cal->cE->dateToStamp(2004, 6, 1, 23, 59),
|
||||
'desc' => 'Dinner with the boss'
|
||||
);
|
||||
$events[] = array(
|
||||
'start' => $cal->cE->dateToStamp(2004, 6, 5),
|
||||
'end' => $cal->cE->dateToStamp(2004, 6, 10, 23, 59),
|
||||
'desc' => 'Holidays!'
|
||||
);
|
||||
|
||||
|
||||
|
||||
$Month = & new Calendar_Month_Weekdays(2004, 6);
|
||||
$MonthDecorator = new MonthPayload_Decorator($Month);
|
||||
$MonthDecorator->build($events);
|
||||
|
||||
?>
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> Calendar </title>
|
||||
<style text="text/css">
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
caption {
|
||||
font-family: verdana;
|
||||
font-size: 14pt;
|
||||
padding-bottom: 4pt;
|
||||
}
|
||||
th {
|
||||
font-family: verdana;
|
||||
font-size: 11px;
|
||||
text-align: center;
|
||||
background-color: #e7e3e7;
|
||||
padding: 5pt;
|
||||
line-height: 150%;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
td {
|
||||
font-family: verdana;
|
||||
font-size: 11px;
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
td.calCell {
|
||||
border: 1px solid #b5bece;
|
||||
padding: 3px;
|
||||
}
|
||||
td.calCellEmpty {
|
||||
background-color: #f3f3f7;
|
||||
}
|
||||
td.calCellBusy {
|
||||
background-color: #efeffa;
|
||||
}
|
||||
div.dayNumber {
|
||||
text-align: right;
|
||||
background-color: #f8f8f8;
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
ul {
|
||||
margin-left: 0;
|
||||
margin-top: 5pt;
|
||||
padding: 0 10pt 0 12pt;
|
||||
list-style-type: square;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h2>Sample Calendar Payload Decorator (using <?php echo CALENDAR_ENGINE; ?> engine)</h2>
|
||||
<table class="calendar" width="98%" cellspacing="0" cellpadding="0">
|
||||
<caption>
|
||||
<?php echo $MonthDecorator->thisMonth().' / '.$MonthDecorator->thisYear(); ?>
|
||||
</caption>
|
||||
<tr>
|
||||
<th>Monday</th>
|
||||
<th>Tuesday</th>
|
||||
<th>Wednesday</th>
|
||||
<th>Thursday</th>
|
||||
<th>Friday</th>
|
||||
<th>Saturday</th>
|
||||
<th>Sunday</th>
|
||||
</tr>
|
||||
<?php
|
||||
while ($Day = $MonthDecorator->fetch()) {
|
||||
|
||||
if ($Day->isFirst()) {
|
||||
echo "<tr>\n";
|
||||
}
|
||||
|
||||
echo '<td class="calCell';
|
||||
if ($Day->isSelected()) {
|
||||
echo ' calCellBusy';
|
||||
} elseif ($Day->isEmpty()) {
|
||||
echo ' calCellEmpty';
|
||||
}
|
||||
echo '">';
|
||||
echo '<div class="dayNumber">'.$Day->thisDay().'</div>';
|
||||
|
||||
if ($Day->isEmpty()) {
|
||||
echo ' ';
|
||||
} else {
|
||||
echo '<div class="dayContents"><ul>';
|
||||
while ($entry = $Day->getEntry()) {
|
||||
echo '<li>'.$entry['desc'].'</li>';
|
||||
//you can print the time range as well
|
||||
}
|
||||
echo '</ul></div>';
|
||||
}
|
||||
echo '</td>';
|
||||
|
||||
if ($Day->isLast()) {
|
||||
echo "</tr>\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
|
@ -1,240 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: demonstrates a decorator used to "attach a payload" to a selection
|
||||
* to make it available when iterating over calendar children
|
||||
*/
|
||||
|
||||
//if you use ISO-8601 dates, switch to PearDate engine
|
||||
define('CALENDAR_ENGINE', 'PearDate');
|
||||
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
|
||||
require_once CALENDAR_ROOT . 'Month/Weekdays.php';
|
||||
require_once CALENDAR_ROOT . 'Day.php';
|
||||
require_once CALENDAR_ROOT . 'Decorator.php';
|
||||
|
||||
// accepts multiple entries
|
||||
class DiaryEvent extends Calendar_Decorator
|
||||
{
|
||||
var $entries = array();
|
||||
|
||||
function DiaryEvent($calendar) {
|
||||
Calendar_Decorator::Calendar_Decorator($calendar);
|
||||
}
|
||||
|
||||
function addEntry($entry) {
|
||||
$this->entries[] = $entry;
|
||||
}
|
||||
|
||||
function getEntry() {
|
||||
$entry = each($this->entries);
|
||||
if ($entry) {
|
||||
return $entry['value'];
|
||||
} else {
|
||||
reset($this->entries);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
class MonthPayload_Decorator extends Calendar_Decorator
|
||||
{
|
||||
//Calendar engine
|
||||
var $cE;
|
||||
var $tableHelper;
|
||||
|
||||
var $year;
|
||||
var $month;
|
||||
var $firstDay = false;
|
||||
|
||||
function build($events=array())
|
||||
{
|
||||
require_once CALENDAR_ROOT . 'Day.php';
|
||||
require_once CALENDAR_ROOT . 'Table/Helper.php';
|
||||
|
||||
$this->tableHelper = & new Calendar_Table_Helper($this, $this->firstDay);
|
||||
$this->cE = & $this->getEngine();
|
||||
$this->year = $this->thisYear();
|
||||
$this->month = $this->thisMonth();
|
||||
|
||||
$daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month);
|
||||
for ($i=1; $i<=$daysInMonth; $i++) {
|
||||
$Day = new Calendar_Day(2000,1,1); // Create Day with dummy values
|
||||
$Day->setTimeStamp($this->cE->dateToStamp($this->year, $this->month, $i));
|
||||
$this->children[$i] = new DiaryEvent($Day);
|
||||
}
|
||||
if (count($events) > 0) {
|
||||
$this->setSelection($events);
|
||||
}
|
||||
Calendar_Month_Weekdays::buildEmptyDaysBefore();
|
||||
Calendar_Month_Weekdays::shiftDays();
|
||||
Calendar_Month_Weekdays::buildEmptyDaysAfter();
|
||||
Calendar_Month_Weekdays::setWeekMarkers();
|
||||
return true;
|
||||
}
|
||||
|
||||
function setSelection($events)
|
||||
{
|
||||
$daysInMonth = $this->cE->getDaysInMonth($this->year, $this->month);
|
||||
for ($i=1; $i<=$daysInMonth; $i++) {
|
||||
$stamp1 = $this->cE->dateToStamp($this->year, $this->month, $i);
|
||||
$stamp2 = $this->cE->dateToStamp($this->year, $this->month, $i+1);
|
||||
foreach ($events as $event) {
|
||||
if (($stamp1 >= $event['start'] && $stamp1 < $event['end']) ||
|
||||
($stamp2 >= $event['start'] && $stamp2 < $event['end']) ||
|
||||
($stamp1 <= $event['start'] && $stamp2 > $event['end'])
|
||||
) {
|
||||
$this->children[$i]->addEntry($event);
|
||||
$this->children[$i]->setSelected();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function fetch()
|
||||
{
|
||||
$child = each($this->children);
|
||||
if ($child) {
|
||||
return $child['value'];
|
||||
} else {
|
||||
reset($this->children);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Calendar instance used to get the dates in the preferred format:
|
||||
// you can switch Calendar Engine and the example still works
|
||||
$cal = new Calendar;
|
||||
|
||||
$events = array();
|
||||
//add some events
|
||||
$events[] = array(
|
||||
'start' => $cal->cE->dateToStamp(2004, 6, 1, 10),
|
||||
'end' => $cal->cE->dateToStamp(2004, 6, 1, 12),
|
||||
'desc' => 'Important meeting'
|
||||
);
|
||||
$events[] = array(
|
||||
'start' => $cal->cE->dateToStamp(2004, 6, 1, 21),
|
||||
'end' => $cal->cE->dateToStamp(2004, 6, 1, 23, 59),
|
||||
'desc' => 'Dinner with the boss'
|
||||
);
|
||||
$events[] = array(
|
||||
'start' => $cal->cE->dateToStamp(2004, 6, 5),
|
||||
'end' => $cal->cE->dateToStamp(2004, 6, 10, 23, 59),
|
||||
'desc' => 'Holidays!'
|
||||
);
|
||||
|
||||
|
||||
|
||||
$Month = & new Calendar_Month_Weekdays(2004, 6);
|
||||
$MonthDecorator = new MonthPayload_Decorator($Month);
|
||||
$MonthDecorator->build($events);
|
||||
|
||||
?>
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> Calendar </title>
|
||||
<style text="text/css">
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
}
|
||||
caption {
|
||||
font-family: verdana;
|
||||
font-size: 14pt;
|
||||
padding-bottom: 4pt;
|
||||
}
|
||||
th {
|
||||
font-family: verdana;
|
||||
font-size: 11px;
|
||||
text-align: center;
|
||||
background-color: #e7e3e7;
|
||||
padding: 5pt;
|
||||
line-height: 150%;
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
td {
|
||||
font-family: verdana;
|
||||
font-size: 11px;
|
||||
text-align: left;
|
||||
vertical-align: top;
|
||||
}
|
||||
td.calCell {
|
||||
border: 1px solid #b5bece;
|
||||
padding: 3px;
|
||||
}
|
||||
td.calCellEmpty {
|
||||
background-color: #f3f3f7;
|
||||
}
|
||||
td.calCellBusy {
|
||||
background-color: #efeffa;
|
||||
}
|
||||
div.dayNumber {
|
||||
text-align: right;
|
||||
background-color: #f8f8f8;
|
||||
border-bottom: 1px solid #ccc;
|
||||
}
|
||||
ul {
|
||||
margin-left: 0;
|
||||
margin-top: 5pt;
|
||||
padding: 0 10pt 0 12pt;
|
||||
list-style-type: square;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<h2>Sample Calendar Payload Decorator (using <?php echo CALENDAR_ENGINE; ?> engine)</h2>
|
||||
<table class="calendar" width="98%" cellspacing="0" cellpadding="0">
|
||||
<caption>
|
||||
<?php echo $MonthDecorator->thisMonth().' / '.$MonthDecorator->thisYear(); ?>
|
||||
</caption>
|
||||
<tr>
|
||||
<th>Monday</th>
|
||||
<th>Tuesday</th>
|
||||
<th>Wednesday</th>
|
||||
<th>Thursday</th>
|
||||
<th>Friday</th>
|
||||
<th>Saturday</th>
|
||||
<th>Sunday</th>
|
||||
</tr>
|
||||
<?php
|
||||
while ($Day = $MonthDecorator->fetch()) {
|
||||
|
||||
if ($Day->isFirst()) {
|
||||
echo "<tr>\n";
|
||||
}
|
||||
|
||||
echo '<td class="calCell';
|
||||
if ($Day->isSelected()) {
|
||||
echo ' calCellBusy';
|
||||
} elseif ($Day->isEmpty()) {
|
||||
echo ' calCellEmpty';
|
||||
}
|
||||
echo '">';
|
||||
echo '<div class="dayNumber">'.$Day->thisDay().'</div>';
|
||||
|
||||
if ($Day->isEmpty()) {
|
||||
echo ' ';
|
||||
} else {
|
||||
echo '<div class="dayContents"><ul>';
|
||||
while ($entry = $Day->getEntry()) {
|
||||
echo '<li>'.$entry['desc'].'</li>';
|
||||
//you can print the time range as well
|
||||
}
|
||||
echo '</ul></div>';
|
||||
}
|
||||
echo '</td>';
|
||||
|
||||
if ($Day->isLast()) {
|
||||
echo "</tr>\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</body>
|
||||
</html>
|
|
@ -1,139 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: a complete year with numeric week numbers
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
$start = getmicrotime();
|
||||
|
||||
if (!@include 'Calendar/Calendar.php') {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
|
||||
require_once CALENDAR_ROOT.'Year.php';
|
||||
require_once CALENDAR_ROOT.'Month/Weeks.php';
|
||||
|
||||
define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH_WEEKS);
|
||||
|
||||
if (!isset($_GET['year'])) $_GET['year'] = date('Y');
|
||||
|
||||
$week_types = array(
|
||||
'n_in_year',
|
||||
'n_in_month',
|
||||
);
|
||||
|
||||
if (!isset($_GET['week_type']) || !in_array($_GET['week_type'],$week_types) ) {
|
||||
$_GET['week_type'] = 'n_in_year';
|
||||
}
|
||||
|
||||
$Year = new Calendar_Year($_GET['year']);
|
||||
|
||||
$Year->build();
|
||||
?>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> <?php echo $Year->thisYear(); ?> </title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: Georgia, serif;
|
||||
}
|
||||
caption.year {
|
||||
font-weight: bold;
|
||||
font-size: 120%;
|
||||
font-color: navy;
|
||||
}
|
||||
caption.month {
|
||||
font-size: 110%;
|
||||
font-color: navy;
|
||||
}
|
||||
table.month {
|
||||
border: thin groove #800080
|
||||
}
|
||||
tr {
|
||||
vertical-align: top;
|
||||
}
|
||||
th, td {
|
||||
text-align: right;
|
||||
font-size: 70%;
|
||||
}
|
||||
#prev {
|
||||
float: left;
|
||||
font-size: 70%;
|
||||
}
|
||||
#next {
|
||||
float: right;
|
||||
font-size: 70%;
|
||||
}
|
||||
#week_type {
|
||||
float: none;
|
||||
font-size: 70%;
|
||||
}
|
||||
.weekNumbers {
|
||||
background-color: #e5e5f5;
|
||||
padding-right: 3pt;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table>
|
||||
<caption class="year">
|
||||
<?php echo $Year->thisYear(); ?>
|
||||
<div id="next">
|
||||
<a href="?year=<?php echo $Year->nextYear(); ?>&week_type=<?php echo $_GET['week_type']; ?>">>></a>
|
||||
</div>
|
||||
<div id="prev">
|
||||
<a href="?year=<?php echo $Year->prevYear(); ?>&week_type=<?php echo $_GET['week_type']; ?>"><<</a>
|
||||
</div>
|
||||
<div id="week_type">
|
||||
<a href="?year=<?php echo $Year->thisYear(); ?>&week_type=n_in_year">Weeks by Year</a> :
|
||||
<a href="?year=<?php echo $Year->thisYear(); ?>&week_type=n_in_month">Weeks by Month</a>
|
||||
</div>
|
||||
</caption>
|
||||
<?php
|
||||
$i = 0;
|
||||
while ($Month = $Year->fetch()) {
|
||||
|
||||
switch ($i) {
|
||||
case 0:
|
||||
echo "<tr>\n";
|
||||
break;
|
||||
case 3:
|
||||
case 6:
|
||||
case 9:
|
||||
echo "</tr>\n<tr>\n";
|
||||
break;
|
||||
case 12:
|
||||
echo "</tr>\n";
|
||||
break;
|
||||
}
|
||||
|
||||
echo "<td>\n<table class=\"month\">\n";
|
||||
echo '<caption class="month">'.date('F', $Month->thisMonth(TRUE)).'</caption>';
|
||||
echo '<colgroup><col class="weekNumbers"><col span="7"></colgroup>'."\n";
|
||||
echo "<tr>\n<th>Week</th><th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th><th>S</th>\n</tr>";
|
||||
$Month->build();
|
||||
while ($Week = $Month->fetch()) {
|
||||
echo "<tr>\n";
|
||||
echo '<td>'.$Week->thisWeek($_GET['week_type'])."</td>\n";
|
||||
$Week->build();
|
||||
|
||||
while ($Day = $Week->fetch()) {
|
||||
if ($Day->isEmpty()) {
|
||||
echo "<td> </td>\n";
|
||||
} else {
|
||||
echo "<td>".$Day->thisDay()."</td>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "</table>\n</td>\n";
|
||||
|
||||
$i++;
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<p>Took: <?php echo ((getmicrotime()-$start)); ?></p>
|
||||
</body>
|
||||
</html>
|
|
@ -1,139 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: a complete year with numeric week numbers
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
$start = getmicrotime();
|
||||
|
||||
if (!@include 'Calendar/Calendar.php') {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
|
||||
require_once CALENDAR_ROOT.'Year.php';
|
||||
require_once CALENDAR_ROOT.'Month/Weeks.php';
|
||||
|
||||
define ('CALENDAR_MONTH_STATE',CALENDAR_USE_MONTH_WEEKS);
|
||||
|
||||
if (!isset($_GET['year'])) $_GET['year'] = date('Y');
|
||||
|
||||
$week_types = array(
|
||||
'n_in_year',
|
||||
'n_in_month',
|
||||
);
|
||||
|
||||
if (!isset($_GET['week_type']) || !in_array($_GET['week_type'],$week_types) ) {
|
||||
$_GET['week_type'] = 'n_in_year';
|
||||
}
|
||||
|
||||
$Year = new Calendar_Year($_GET['year']);
|
||||
|
||||
$Year->build();
|
||||
?>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> <?php echo $Year->thisYear(); ?> </title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: Georgia, serif;
|
||||
}
|
||||
caption.year {
|
||||
font-weight: bold;
|
||||
font-size: 120%;
|
||||
font-color: navy;
|
||||
}
|
||||
caption.month {
|
||||
font-size: 110%;
|
||||
font-color: navy;
|
||||
}
|
||||
table.month {
|
||||
border: thin groove #800080
|
||||
}
|
||||
tr {
|
||||
vertical-align: top;
|
||||
}
|
||||
th, td {
|
||||
text-align: right;
|
||||
font-size: 70%;
|
||||
}
|
||||
#prev {
|
||||
float: left;
|
||||
font-size: 70%;
|
||||
}
|
||||
#next {
|
||||
float: right;
|
||||
font-size: 70%;
|
||||
}
|
||||
#week_type {
|
||||
float: none;
|
||||
font-size: 70%;
|
||||
}
|
||||
.weekNumbers {
|
||||
background-color: #e5e5f5;
|
||||
padding-right: 3pt;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<table>
|
||||
<caption class="year">
|
||||
<?php echo $Year->thisYear(); ?>
|
||||
<div id="next">
|
||||
<a href="?year=<?php echo $Year->nextYear(); ?>&week_type=<?php echo $_GET['week_type']; ?>">>></a>
|
||||
</div>
|
||||
<div id="prev">
|
||||
<a href="?year=<?php echo $Year->prevYear(); ?>&week_type=<?php echo $_GET['week_type']; ?>"><<</a>
|
||||
</div>
|
||||
<div id="week_type">
|
||||
<a href="?year=<?php echo $Year->thisYear(); ?>&week_type=n_in_year">Weeks by Year</a> :
|
||||
<a href="?year=<?php echo $Year->thisYear(); ?>&week_type=n_in_month">Weeks by Month</a>
|
||||
</div>
|
||||
</caption>
|
||||
<?php
|
||||
$i = 0;
|
||||
while ($Month = $Year->fetch()) {
|
||||
|
||||
switch ($i) {
|
||||
case 0:
|
||||
echo "<tr>\n";
|
||||
break;
|
||||
case 3:
|
||||
case 6:
|
||||
case 9:
|
||||
echo "</tr>\n<tr>\n";
|
||||
break;
|
||||
case 12:
|
||||
echo "</tr>\n";
|
||||
break;
|
||||
}
|
||||
|
||||
echo "<td>\n<table class=\"month\">\n";
|
||||
echo '<caption class="month">'.date('F', $Month->thisMonth(TRUE)).'</caption>';
|
||||
echo '<colgroup><col class="weekNumbers"><col span="7"></colgroup>'."\n";
|
||||
echo "<tr>\n<th>Week</th><th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th><th>S</th>\n</tr>";
|
||||
$Month->build();
|
||||
while ($Week = $Month->fetch()) {
|
||||
echo "<tr>\n";
|
||||
echo '<td>'.$Week->thisWeek($_GET['week_type'])."</td>\n";
|
||||
$Week->build();
|
||||
|
||||
while ($Day = $Week->fetch()) {
|
||||
if ($Day->isEmpty()) {
|
||||
echo "<td> </td>\n";
|
||||
} else {
|
||||
echo "<td>".$Day->thisDay()."</td>\n";
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "</table>\n</td>\n";
|
||||
|
||||
$i++;
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<p>Took: <?php echo ((getmicrotime()-$start)); ?></p>
|
||||
</body>
|
||||
</html>
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: demonstrates using the Uri util
|
||||
*/
|
||||
if (!@include 'Calendar/Calendar.php') {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Month/Weekdays.php';
|
||||
require_once CALENDAR_ROOT.'Util/Uri.php';
|
||||
|
||||
if (!isset($_GET['jahr'])) $_GET['jahr'] = date('Y');
|
||||
if (!isset($_GET['monat'])) $_GET['monat'] = date('m');
|
||||
|
||||
// Build the month
|
||||
$Calendar = new Calendar_Month_Weekdays($_GET['jahr'], $_GET['monat']);
|
||||
|
||||
echo ( '<p>The current month is '
|
||||
.$Calendar->thisMonth().' of year '.$Calendar->thisYear().'</p>');
|
||||
|
||||
$Uri = & new Calendar_Util_Uri('jahr','monat');
|
||||
$Uri->setFragments('jahr','monat');
|
||||
|
||||
echo "\"Vector\" URIs<pre>";
|
||||
echo ( "Previous Uri:\t".htmlentities($Uri->prev($Calendar, 'month'))."\n" );
|
||||
echo ( "This Uri:\t".htmlentities($Uri->this($Calendar, 'month'))."\n" );
|
||||
echo ( "Next Uri:\t".htmlentities($Uri->next($Calendar, 'month'))."\n" );
|
||||
echo "</pre>";
|
||||
|
||||
// Switch to scalar URIs
|
||||
$Uri->separator = '/'; // Default is &
|
||||
$Uri->scalar = true; // Omit variable names
|
||||
|
||||
echo "\"Scalar\" URIs<pre>";
|
||||
echo ( "Previous Uri:\t".$Uri->prev($Calendar, 'month')."\n" );
|
||||
echo ( "This Uri:\t".$Uri->this($Calendar, 'month')."\n" );
|
||||
echo ( "Next Uri:\t".$Uri->next($Calendar, 'month')."\n" );
|
||||
echo "</pre>";
|
||||
|
||||
// Restore the vector URIs
|
||||
$Uri->separator = '&';
|
||||
$Uri->scalar = false;
|
||||
?>
|
||||
<p>
|
||||
<a href="<?php echo($_SERVER['PHP_SELF'].'?'.$Uri->prev($Calendar, 'month'));?>">Prev</a> :
|
||||
<a href="<?php echo($_SERVER['PHP_SELF'].'?'.$Uri->next($Calendar, 'month'));?>">Next</a>
|
||||
</p>
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: demonstrates using the Uri util
|
||||
*/
|
||||
if (!@include 'Calendar/Calendar.php') {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Month/Weekdays.php';
|
||||
require_once CALENDAR_ROOT.'Util/Uri.php';
|
||||
|
||||
if (!isset($_GET['jahr'])) $_GET['jahr'] = date('Y');
|
||||
if (!isset($_GET['monat'])) $_GET['monat'] = date('m');
|
||||
|
||||
// Build the month
|
||||
$Calendar = new Calendar_Month_Weekdays($_GET['jahr'], $_GET['monat']);
|
||||
|
||||
echo ( '<p>The current month is '
|
||||
.$Calendar->thisMonth().' of year '.$Calendar->thisYear().'</p>');
|
||||
|
||||
$Uri = & new Calendar_Util_Uri('jahr','monat');
|
||||
$Uri->setFragments('jahr','monat');
|
||||
|
||||
echo "\"Vector\" URIs<pre>";
|
||||
echo ( "Previous Uri:\t".htmlentities($Uri->prev($Calendar, 'month'))."\n" );
|
||||
echo ( "This Uri:\t".htmlentities($Uri->this($Calendar, 'month'))."\n" );
|
||||
echo ( "Next Uri:\t".htmlentities($Uri->next($Calendar, 'month'))."\n" );
|
||||
echo "</pre>";
|
||||
|
||||
// Switch to scalar URIs
|
||||
$Uri->separator = '/'; // Default is &
|
||||
$Uri->scalar = true; // Omit variable names
|
||||
|
||||
echo "\"Scalar\" URIs<pre>";
|
||||
echo ( "Previous Uri:\t".$Uri->prev($Calendar, 'month')."\n" );
|
||||
echo ( "This Uri:\t".$Uri->this($Calendar, 'month')."\n" );
|
||||
echo ( "Next Uri:\t".$Uri->next($Calendar, 'month')."\n" );
|
||||
echo "</pre>";
|
||||
|
||||
// Restore the vector URIs
|
||||
$Uri->separator = '&';
|
||||
$Uri->scalar = false;
|
||||
?>
|
||||
<p>
|
||||
<a href="<?php echo($_SERVER['PHP_SELF'].'?'.$Uri->prev($Calendar, 'month'));?>">Prev</a> :
|
||||
<a href="<?php echo($_SERVER['PHP_SELF'].'?'.$Uri->next($Calendar, 'month'));?>">Next</a>
|
||||
</p>
|
|
@ -1,66 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: demonstrates using the Textual util
|
||||
*/
|
||||
|
||||
if (!@include 'Calendar'.DIRECTORY_SEPARATOR.'Calendar.php') {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
require_once CALENDAR_ROOT.'Month'.DIRECTORY_SEPARATOR.'Weekdays.php';
|
||||
require_once CALENDAR_ROOT.'Util'.DIRECTORY_SEPARATOR.'Textual.php';
|
||||
|
||||
// Could change language like this
|
||||
// setlocale (LC_TIME, "de_DE"); // Unix based (probably)
|
||||
// setlocale (LC_TIME, "ge"); // Windows
|
||||
|
||||
echo "<hr>Calling: Calendar_Util_Textual::monthNames('long');<pre>";
|
||||
print_r(Calendar_Util_Textual::monthNames('long'));
|
||||
echo '</pre>';
|
||||
|
||||
echo "<hr>Calling: Calendar_Util_Textual::weekdayNames('two');<pre>";
|
||||
print_r(Calendar_Util_Textual::weekdayNames('two'));
|
||||
echo '</pre>';
|
||||
|
||||
echo "<hr>Creating: new Calendar_Day(date('Y'), date('n'), date('d'));<br />";
|
||||
$Calendar = new Calendar_Day(date('Y'), date('n'), date('d'));
|
||||
|
||||
echo '<hr>Previous month is: '.Calendar_Util_Textual::prevMonthName($Calendar,'two').'<br />';
|
||||
echo 'This month is: '.Calendar_Util_Textual::thisMonthName($Calendar,'short').'<br />';
|
||||
echo 'Next month is: '.Calendar_Util_Textual::nextMonthName($Calendar).'<br /><hr />';
|
||||
echo 'Previous day is: '.Calendar_Util_Textual::prevDayName($Calendar).'<br />';
|
||||
echo 'This day is: '.Calendar_Util_Textual::thisDayName($Calendar,'short').'<br />';
|
||||
echo 'Next day is: '.Calendar_Util_Textual::nextDayName($Calendar,'one').'<br /><hr />';
|
||||
|
||||
echo "Creating: new Calendar_Month_Weekdays(date('Y'), date('n'), 6); - Saturday is first day of week<br />";
|
||||
$Calendar = new Calendar_Month_Weekdays(date('Y'), date('n'), 6);
|
||||
|
||||
?>
|
||||
<p>Rendering calendar....</p>
|
||||
<table>
|
||||
<caption><?php echo Calendar_Util_Textual::thisMonthName($Calendar).' '.$Calendar->thisYear(); ?></caption>
|
||||
<tr>
|
||||
<?php
|
||||
$dayheaders = Calendar_Util_Textual::orderedWeekdays($Calendar,'short');
|
||||
foreach ($dayheaders as $dayheader) {
|
||||
echo '<th>'.$dayheader.'</th>';
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
$Calendar->build();
|
||||
while ($Day = $Calendar->fetch()) {
|
||||
if ($Day->isFirst()) {
|
||||
echo "<tr>\n";
|
||||
}
|
||||
if ($Day->isEmpty()) {
|
||||
echo '<td> </td>';
|
||||
} else {
|
||||
echo '<td>'.$Day->thisDay().'</td>';
|
||||
}
|
||||
if ($Day->isLast()) {
|
||||
echo "</tr>\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</table>
|
|
@ -1,66 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: demonstrates using the Textual util
|
||||
*/
|
||||
|
||||
if (!@include 'Calendar'.DIRECTORY_SEPARATOR.'Calendar.php') {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
require_once CALENDAR_ROOT.'Month'.DIRECTORY_SEPARATOR.'Weekdays.php';
|
||||
require_once CALENDAR_ROOT.'Util'.DIRECTORY_SEPARATOR.'Textual.php';
|
||||
|
||||
// Could change language like this
|
||||
// setlocale (LC_TIME, "de_DE"); // Unix based (probably)
|
||||
// setlocale (LC_TIME, "ge"); // Windows
|
||||
|
||||
echo "<hr>Calling: Calendar_Util_Textual::monthNames('long');<pre>";
|
||||
print_r(Calendar_Util_Textual::monthNames('long'));
|
||||
echo '</pre>';
|
||||
|
||||
echo "<hr>Calling: Calendar_Util_Textual::weekdayNames('two');<pre>";
|
||||
print_r(Calendar_Util_Textual::weekdayNames('two'));
|
||||
echo '</pre>';
|
||||
|
||||
echo "<hr>Creating: new Calendar_Day(date('Y'), date('n'), date('d'));<br />";
|
||||
$Calendar = new Calendar_Day(date('Y'), date('n'), date('d'));
|
||||
|
||||
echo '<hr>Previous month is: '.Calendar_Util_Textual::prevMonthName($Calendar,'two').'<br />';
|
||||
echo 'This month is: '.Calendar_Util_Textual::thisMonthName($Calendar,'short').'<br />';
|
||||
echo 'Next month is: '.Calendar_Util_Textual::nextMonthName($Calendar).'<br /><hr />';
|
||||
echo 'Previous day is: '.Calendar_Util_Textual::prevDayName($Calendar).'<br />';
|
||||
echo 'This day is: '.Calendar_Util_Textual::thisDayName($Calendar,'short').'<br />';
|
||||
echo 'Next day is: '.Calendar_Util_Textual::nextDayName($Calendar,'one').'<br /><hr />';
|
||||
|
||||
echo "Creating: new Calendar_Month_Weekdays(date('Y'), date('n'), 6); - Saturday is first day of week<br />";
|
||||
$Calendar = new Calendar_Month_Weekdays(date('Y'), date('n'), 6);
|
||||
|
||||
?>
|
||||
<p>Rendering calendar....</p>
|
||||
<table>
|
||||
<caption><?php echo Calendar_Util_Textual::thisMonthName($Calendar).' '.$Calendar->thisYear(); ?></caption>
|
||||
<tr>
|
||||
<?php
|
||||
$dayheaders = Calendar_Util_Textual::orderedWeekdays($Calendar,'short');
|
||||
foreach ($dayheaders as $dayheader) {
|
||||
echo '<th>'.$dayheader.'</th>';
|
||||
}
|
||||
?>
|
||||
</tr>
|
||||
<?php
|
||||
$Calendar->build();
|
||||
while ($Day = $Calendar->fetch()) {
|
||||
if ($Day->isFirst()) {
|
||||
echo "<tr>\n";
|
||||
}
|
||||
if ($Day->isEmpty()) {
|
||||
echo '<td> </td>';
|
||||
} else {
|
||||
echo '<td>'.$Day->thisDay().'</td>';
|
||||
}
|
||||
if ($Day->isLast()) {
|
||||
echo "</tr>\n";
|
||||
}
|
||||
}
|
||||
?>
|
||||
</table>
|
|
@ -1,134 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: Performs same behaviour as 2.php but uses Month::buildWeekDays()
|
||||
* and is faster
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
$start = getmicrotime();
|
||||
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Month/Weekdays.php';
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
|
||||
if (!isset($_GET['y'])) $_GET['y'] = date('Y');
|
||||
if (!isset($_GET['m'])) $_GET['m'] = date('m');
|
||||
if (!isset($_GET['d'])) $_GET['d'] = date('d');
|
||||
|
||||
// Build the month
|
||||
$Month = new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
|
||||
|
||||
// Construct strings for next/previous links
|
||||
$PMonth = $Month->prevMonth('object'); // Get previous month as object
|
||||
$prev = $_SERVER['PHP_SELF'].'?y='.$PMonth->thisYear().'&m='.$PMonth->thisMonth().'&d='.$PMonth->thisDay();
|
||||
$NMonth = $Month->nextMonth('object');
|
||||
$next = $_SERVER['PHP_SELF'].'?y='.$NMonth->thisYear().'&m='.$NMonth->thisMonth().'&d='.$NMonth->thisDay();
|
||||
?>
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> Calendar </title>
|
||||
<style text="text/css">
|
||||
table {
|
||||
background-color: silver;
|
||||
}
|
||||
caption {
|
||||
font-family: verdana;
|
||||
font-size: 12px;
|
||||
background-color: while;
|
||||
}
|
||||
.prevMonth {
|
||||
font-size: 10px;
|
||||
text-align: left;
|
||||
}
|
||||
.nextMonth {
|
||||
font-size: 10px;
|
||||
text-align: right;
|
||||
}
|
||||
th {
|
||||
font-family: verdana;
|
||||
font-size: 11px;
|
||||
color: navy;
|
||||
text-align: right;
|
||||
}
|
||||
td {
|
||||
font-family: verdana;
|
||||
font-size: 11px;
|
||||
text-align: right;
|
||||
}
|
||||
.selected {
|
||||
background-color: yellow;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php
|
||||
$selectedDays = array (
|
||||
new Calendar_Day($_GET['y'],$_GET['m'],$_GET['d']),
|
||||
new Calendar_Day($_GET['y'],12,25),
|
||||
);
|
||||
|
||||
// Build the days in the month
|
||||
$Month->build($selectedDays);
|
||||
?>
|
||||
<h2>Built with Calendar_Month_Weekday::build()</h2>
|
||||
<table class="calendar">
|
||||
<caption>
|
||||
<?php echo ( date('F Y',$Month->getTimeStamp())); ?>
|
||||
</caption>
|
||||
<tr>
|
||||
<th>M</th>
|
||||
<th>T</th>
|
||||
<th>W</th>
|
||||
<th>T</th>
|
||||
<th>F</th>
|
||||
<th>S</th>
|
||||
<th>S</th>
|
||||
</tr>
|
||||
<?php
|
||||
while ( $Day = $Month->fetch() ) {
|
||||
|
||||
// Build a link string for each day
|
||||
$link = $_SERVER['PHP_SELF'].
|
||||
'?y='.$Day->thisYear().
|
||||
'&m='.$Day->thisMonth().
|
||||
'&d='.$Day->thisDay();
|
||||
|
||||
// isFirst() to find start of week
|
||||
if ( $Day->isFirst() )
|
||||
echo ( "<tr>\n" );
|
||||
|
||||
if ( $Day->isSelected() ) {
|
||||
echo ( "<td class=\"selected\">".$Day->thisDay()."</td>\n" );
|
||||
} else if ( $Day->isEmpty() ) {
|
||||
echo ( "<td> </td>\n" );
|
||||
} else {
|
||||
echo ( "<td><a href=\"".$link."\">".$Day->thisDay()."</a></td>\n" );
|
||||
}
|
||||
|
||||
// isLast() to find end of week
|
||||
if ( $Day->isLast() )
|
||||
echo ( "</tr>\n" );
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="<?php echo ($prev);?>" class="prevMonth"><< </a>
|
||||
</td>
|
||||
<td colspan="5"> </td>
|
||||
<td>
|
||||
<a href="<?php echo ($next);?>" class="nextMonth"> >></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' );
|
||||
?>
|
||||
</body>
|
||||
</html>
|
|
@ -1,134 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: Performs same behaviour as 2.php but uses Month::buildWeekDays()
|
||||
* and is faster
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
$start = getmicrotime();
|
||||
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Month/Weekdays.php';
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
|
||||
if (!isset($_GET['y'])) $_GET['y'] = date('Y');
|
||||
if (!isset($_GET['m'])) $_GET['m'] = date('m');
|
||||
if (!isset($_GET['d'])) $_GET['d'] = date('d');
|
||||
|
||||
// Build the month
|
||||
$Month = new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
|
||||
|
||||
// Construct strings for next/previous links
|
||||
$PMonth = $Month->prevMonth('object'); // Get previous month as object
|
||||
$prev = $_SERVER['PHP_SELF'].'?y='.$PMonth->thisYear().'&m='.$PMonth->thisMonth().'&d='.$PMonth->thisDay();
|
||||
$NMonth = $Month->nextMonth('object');
|
||||
$next = $_SERVER['PHP_SELF'].'?y='.$NMonth->thisYear().'&m='.$NMonth->thisMonth().'&d='.$NMonth->thisDay();
|
||||
?>
|
||||
<!doctype html public "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> Calendar </title>
|
||||
<style text="text/css">
|
||||
table {
|
||||
background-color: silver;
|
||||
}
|
||||
caption {
|
||||
font-family: verdana;
|
||||
font-size: 12px;
|
||||
background-color: while;
|
||||
}
|
||||
.prevMonth {
|
||||
font-size: 10px;
|
||||
text-align: left;
|
||||
}
|
||||
.nextMonth {
|
||||
font-size: 10px;
|
||||
text-align: right;
|
||||
}
|
||||
th {
|
||||
font-family: verdana;
|
||||
font-size: 11px;
|
||||
color: navy;
|
||||
text-align: right;
|
||||
}
|
||||
td {
|
||||
font-family: verdana;
|
||||
font-size: 11px;
|
||||
text-align: right;
|
||||
}
|
||||
.selected {
|
||||
background-color: yellow;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<?php
|
||||
$selectedDays = array (
|
||||
new Calendar_Day($_GET['y'],$_GET['m'],$_GET['d']),
|
||||
new Calendar_Day($_GET['y'],12,25),
|
||||
);
|
||||
|
||||
// Build the days in the month
|
||||
$Month->build($selectedDays);
|
||||
?>
|
||||
<h2>Built with Calendar_Month_Weekday::build()</h2>
|
||||
<table class="calendar">
|
||||
<caption>
|
||||
<?php echo ( date('F Y',$Month->getTimeStamp())); ?>
|
||||
</caption>
|
||||
<tr>
|
||||
<th>M</th>
|
||||
<th>T</th>
|
||||
<th>W</th>
|
||||
<th>T</th>
|
||||
<th>F</th>
|
||||
<th>S</th>
|
||||
<th>S</th>
|
||||
</tr>
|
||||
<?php
|
||||
while ( $Day = $Month->fetch() ) {
|
||||
|
||||
// Build a link string for each day
|
||||
$link = $_SERVER['PHP_SELF'].
|
||||
'?y='.$Day->thisYear().
|
||||
'&m='.$Day->thisMonth().
|
||||
'&d='.$Day->thisDay();
|
||||
|
||||
// isFirst() to find start of week
|
||||
if ( $Day->isFirst() )
|
||||
echo ( "<tr>\n" );
|
||||
|
||||
if ( $Day->isSelected() ) {
|
||||
echo ( "<td class=\"selected\">".$Day->thisDay()."</td>\n" );
|
||||
} else if ( $Day->isEmpty() ) {
|
||||
echo ( "<td> </td>\n" );
|
||||
} else {
|
||||
echo ( "<td><a href=\"".$link."\">".$Day->thisDay()."</a></td>\n" );
|
||||
}
|
||||
|
||||
// isLast() to find end of week
|
||||
if ( $Day->isLast() )
|
||||
echo ( "</tr>\n" );
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="<?php echo ($prev);?>" class="prevMonth"><< </a>
|
||||
</td>
|
||||
<td colspan="5"> </td>
|
||||
<td>
|
||||
<a href="<?php echo ($next);?>" class="nextMonth"> >></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<?php
|
||||
echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' );
|
||||
?>
|
||||
</body>
|
||||
</html>
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: shows how to perform validation with PEAR::Calendar
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(' ', microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
$start = getmicrotime();
|
||||
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Second.php';
|
||||
|
||||
if (!isset($_GET['y'])) $_GET['y'] = date('Y');
|
||||
if (!isset($_GET['m'])) $_GET['m'] = date('n');
|
||||
if (!isset($_GET['d'])) $_GET['d'] = date('j');
|
||||
if (!isset($_GET['h'])) $_GET['h'] = date('H');
|
||||
if (!isset($_GET['i'])) $_GET['i'] = date('i');
|
||||
if (!isset($_GET['s'])) $_GET['s'] = date('s');
|
||||
|
||||
$Unit = & new Calendar_Second($_GET['y'], $_GET['m'], $_GET['d'], $_GET['h'], $_GET['i'], $_GET['s']);
|
||||
|
||||
echo '<p><b>Result:</b> '.$Unit->thisYear().'-'.$Unit->thisMonth().'-'.$Unit->thisDay().
|
||||
' '.$Unit->thisHour().':'.$Unit->thisMinute().':'.$Unit->thisSecond();
|
||||
if ($Unit->isValid()) {
|
||||
echo ' is valid!</p>';
|
||||
} else {
|
||||
$V= & $Unit->getValidator();
|
||||
echo ' is invalid:</p>';
|
||||
while ($error = $V->fetch()) {
|
||||
echo $error->toString() .'<br />';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<p>Enter a date / time to validate:</p>
|
||||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
|
||||
Year: <input type="text" name="y" value="2039"><br />
|
||||
Month: <input type="text" name="m" value="13"><br />
|
||||
Day: <input type="text" name="d" value="32"><br />
|
||||
Hour: <input type="text" name="h" value="24"><br />
|
||||
Minute: <input type="text" name="i" value="-1"><br />
|
||||
Second: <input type="text" name="s" value="60"><br />
|
||||
<input type="submit" value="Validate">
|
||||
</form>
|
||||
<p><b>Note:</b> Error messages can be controlled with the constants <code>CALENDAR_VALUE_TOOSMALL</code> and <code>CALENDAR_VALUE_TOOLARGE</code> - see <code>Calendar_Validator.php</code></p>
|
||||
|
||||
<?php echo '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>'; ?>
|
|
@ -1,49 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: shows how to perform validation with PEAR::Calendar
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(' ', microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
$start = getmicrotime();
|
||||
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Second.php';
|
||||
|
||||
if (!isset($_GET['y'])) $_GET['y'] = date('Y');
|
||||
if (!isset($_GET['m'])) $_GET['m'] = date('n');
|
||||
if (!isset($_GET['d'])) $_GET['d'] = date('j');
|
||||
if (!isset($_GET['h'])) $_GET['h'] = date('H');
|
||||
if (!isset($_GET['i'])) $_GET['i'] = date('i');
|
||||
if (!isset($_GET['s'])) $_GET['s'] = date('s');
|
||||
|
||||
$Unit = & new Calendar_Second($_GET['y'], $_GET['m'], $_GET['d'], $_GET['h'], $_GET['i'], $_GET['s']);
|
||||
|
||||
echo '<p><b>Result:</b> '.$Unit->thisYear().'-'.$Unit->thisMonth().'-'.$Unit->thisDay().
|
||||
' '.$Unit->thisHour().':'.$Unit->thisMinute().':'.$Unit->thisSecond();
|
||||
if ($Unit->isValid()) {
|
||||
echo ' is valid!</p>';
|
||||
} else {
|
||||
$V= & $Unit->getValidator();
|
||||
echo ' is invalid:</p>';
|
||||
while ($error = $V->fetch()) {
|
||||
echo $error->toString() .'<br />';
|
||||
}
|
||||
}
|
||||
?>
|
||||
<p>Enter a date / time to validate:</p>
|
||||
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="get">
|
||||
Year: <input type="text" name="y" value="2039"><br />
|
||||
Month: <input type="text" name="m" value="13"><br />
|
||||
Day: <input type="text" name="d" value="32"><br />
|
||||
Hour: <input type="text" name="h" value="24"><br />
|
||||
Minute: <input type="text" name="i" value="-1"><br />
|
||||
Second: <input type="text" name="s" value="60"><br />
|
||||
<input type="submit" value="Validate">
|
||||
</form>
|
||||
<p><b>Note:</b> Error messages can be controlled with the constants <code>CALENDAR_VALUE_TOOSMALL</code> and <code>CALENDAR_VALUE_TOOLARGE</code> - see <code>Calendar_Validator.php</code></p>
|
||||
|
||||
<?php echo '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>'; ?>
|
|
@ -1,132 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: generating elements of a form with PEAR::Calendar, using
|
||||
* selections as well as validating the submission
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
$start = getmicrotime();
|
||||
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Year.php';
|
||||
require_once CALENDAR_ROOT.'Month.php';
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
require_once CALENDAR_ROOT.'Hour.php';
|
||||
require_once CALENDAR_ROOT.'Minute.php';
|
||||
require_once CALENDAR_ROOT.'Second.php';
|
||||
|
||||
// Initialize if not set
|
||||
if (!isset($_POST['y'])) $_POST['y'] = date('Y');
|
||||
if (!isset($_POST['m'])) $_POST['m'] = date('n');
|
||||
if (!isset($_POST['d'])) $_POST['d'] = date('j');
|
||||
if (!isset($_POST['h'])) $_POST['h'] = date('H');
|
||||
if (!isset($_POST['i'])) $_POST['i'] = date('i');
|
||||
if (!isset($_POST['s'])) $_POST['s'] = date('s');
|
||||
?>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> Select and Update </title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Select and Update</h1>
|
||||
<?php
|
||||
if ( isset($_POST['update']) ) {
|
||||
$Second = & new Calendar_Second($_POST['y'],$_POST['m'],$_POST['d'],$_POST['h'],$_POST['i'],$_POST['s']);
|
||||
if ( !$Second->isValid() ) {
|
||||
$V= & $Second->getValidator();
|
||||
echo ('<p>Validation failed:</p>' );
|
||||
while ( $error = $V->fetch() ) {
|
||||
echo ( $error->toString() .'<br>' );
|
||||
}
|
||||
} else {
|
||||
echo ('<p>Validation success.</p>' );
|
||||
echo ( '<p>New timestamp is: '.$Second->getTimeStamp().' which could be used to update a database, for example');
|
||||
}
|
||||
} else {
|
||||
$Year = new Calendar_Year($_POST['y']);
|
||||
$Month = new Calendar_Month($_POST['y'],$_POST['m']);
|
||||
$Day = new Calendar_Day($_POST['y'],$_POST['m'],$_POST['d']);
|
||||
$Hour = new Calendar_Hour($_POST['y'],$_POST['m'],$_POST['d'],$_POST['h']);
|
||||
$Minute = new Calendar_Minute($_POST['y'],$_POST['m'],$_POST['d'],$_POST['h'],$_POST['i']);
|
||||
$Second = new Calendar_Second($_POST['y'],$_POST['m'],$_POST['d'],$_POST['h'],$_POST['i'],$_POST['s']);
|
||||
?>
|
||||
<p><b>Set the alarm clock</p></p>
|
||||
<form action="<?php echo ( $_SERVER['PHP_SELF'] ); ?>" method="post">
|
||||
Year: <input type="text" name="y" value="<?php echo ( $_POST['y'] ); ?>" size="4">
|
||||
Month:<select name="m">
|
||||
<?php
|
||||
$selection = array($Month);
|
||||
$Year->build($selection);
|
||||
while ( $Child = & $Year->fetch() ) {
|
||||
if ( $Child->isSelected() ) {
|
||||
echo ( "<option value=\"".$Child->thisMonth()."\" selected>".$Child->thisMonth()."\n" );
|
||||
} else {
|
||||
echo ( "<option value=\"".$Child->thisMonth()."\">".$Child->thisMonth()."\n" );
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
Day:<select name="d">
|
||||
<?php
|
||||
$selection = array($Day);
|
||||
$Month->build($selection);
|
||||
while ( $Child = & $Month->fetch() ) {
|
||||
if ( $Child->isSelected() ) {
|
||||
echo ( "<option value=\"".$Child->thisDay()."\" selected>".$Child->thisDay()."\n" );
|
||||
} else {
|
||||
echo ( "<option value=\"".$Child->thisDay()."\">".$Child->thisDay()."\n" );
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
Hour:<select name="h">
|
||||
<?php
|
||||
$selection = array($Hour);
|
||||
$Day->build($selection);
|
||||
while ( $Child = & $Day->fetch() ) {
|
||||
if ( $Child->isSelected() ) {
|
||||
echo ( "<option value=\"".$Child->thisHour()."\" selected>".$Child->thisHour()."\n" );
|
||||
} else {
|
||||
echo ( "<option value=\"".$Child->thisHour()."\">".$Child->thisHour()."\n" );
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
Minute:<select name="i">
|
||||
<?php
|
||||
$selection = array($Minute);
|
||||
$Hour->build($selection);
|
||||
while ( $Child = & $Hour->fetch() ) {
|
||||
if ( $Child->isSelected() ) {
|
||||
echo ( "<option value=\"".$Child->thisMinute()."\" selected>".$Child->thisMinute()."\n" );
|
||||
} else {
|
||||
echo ( "<option value=\"".$Child->thisMinute()."\">".$Child->thisMinute()."\n" );
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
Second:<select name="s">
|
||||
<?php
|
||||
$selection = array($Second);
|
||||
$Minute->build($selection);
|
||||
while ( $Child = & $Minute->fetch() ) {
|
||||
if ( $Child->isSelected() ) {
|
||||
echo ( "<option value=\"".$Child->thisSecond()."\" selected>".$Child->thisSecond()."\n" );
|
||||
} else {
|
||||
echo ( "<option value=\"".$Child->thisSecond()."\">".$Child->thisSecond()."\n" );
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<input type="submit" name="update" value="Set Alarm"><br>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' ); ?>
|
||||
</body>
|
||||
</html>
|
|
@ -1,132 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: generating elements of a form with PEAR::Calendar, using
|
||||
* selections as well as validating the submission
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
$start = getmicrotime();
|
||||
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Year.php';
|
||||
require_once CALENDAR_ROOT.'Month.php';
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
require_once CALENDAR_ROOT.'Hour.php';
|
||||
require_once CALENDAR_ROOT.'Minute.php';
|
||||
require_once CALENDAR_ROOT.'Second.php';
|
||||
|
||||
// Initialize if not set
|
||||
if (!isset($_POST['y'])) $_POST['y'] = date('Y');
|
||||
if (!isset($_POST['m'])) $_POST['m'] = date('n');
|
||||
if (!isset($_POST['d'])) $_POST['d'] = date('j');
|
||||
if (!isset($_POST['h'])) $_POST['h'] = date('H');
|
||||
if (!isset($_POST['i'])) $_POST['i'] = date('i');
|
||||
if (!isset($_POST['s'])) $_POST['s'] = date('s');
|
||||
?>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> Select and Update </title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Select and Update</h1>
|
||||
<?php
|
||||
if ( isset($_POST['update']) ) {
|
||||
$Second = & new Calendar_Second($_POST['y'],$_POST['m'],$_POST['d'],$_POST['h'],$_POST['i'],$_POST['s']);
|
||||
if ( !$Second->isValid() ) {
|
||||
$V= & $Second->getValidator();
|
||||
echo ('<p>Validation failed:</p>' );
|
||||
while ( $error = $V->fetch() ) {
|
||||
echo ( $error->toString() .'<br>' );
|
||||
}
|
||||
} else {
|
||||
echo ('<p>Validation success.</p>' );
|
||||
echo ( '<p>New timestamp is: '.$Second->getTimeStamp().' which could be used to update a database, for example');
|
||||
}
|
||||
} else {
|
||||
$Year = new Calendar_Year($_POST['y']);
|
||||
$Month = new Calendar_Month($_POST['y'],$_POST['m']);
|
||||
$Day = new Calendar_Day($_POST['y'],$_POST['m'],$_POST['d']);
|
||||
$Hour = new Calendar_Hour($_POST['y'],$_POST['m'],$_POST['d'],$_POST['h']);
|
||||
$Minute = new Calendar_Minute($_POST['y'],$_POST['m'],$_POST['d'],$_POST['h'],$_POST['i']);
|
||||
$Second = new Calendar_Second($_POST['y'],$_POST['m'],$_POST['d'],$_POST['h'],$_POST['i'],$_POST['s']);
|
||||
?>
|
||||
<p><b>Set the alarm clock</p></p>
|
||||
<form action="<?php echo ( $_SERVER['PHP_SELF'] ); ?>" method="post">
|
||||
Year: <input type="text" name="y" value="<?php echo ( $_POST['y'] ); ?>" size="4">
|
||||
Month:<select name="m">
|
||||
<?php
|
||||
$selection = array($Month);
|
||||
$Year->build($selection);
|
||||
while ( $Child = & $Year->fetch() ) {
|
||||
if ( $Child->isSelected() ) {
|
||||
echo ( "<option value=\"".$Child->thisMonth()."\" selected>".$Child->thisMonth()."\n" );
|
||||
} else {
|
||||
echo ( "<option value=\"".$Child->thisMonth()."\">".$Child->thisMonth()."\n" );
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
Day:<select name="d">
|
||||
<?php
|
||||
$selection = array($Day);
|
||||
$Month->build($selection);
|
||||
while ( $Child = & $Month->fetch() ) {
|
||||
if ( $Child->isSelected() ) {
|
||||
echo ( "<option value=\"".$Child->thisDay()."\" selected>".$Child->thisDay()."\n" );
|
||||
} else {
|
||||
echo ( "<option value=\"".$Child->thisDay()."\">".$Child->thisDay()."\n" );
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
Hour:<select name="h">
|
||||
<?php
|
||||
$selection = array($Hour);
|
||||
$Day->build($selection);
|
||||
while ( $Child = & $Day->fetch() ) {
|
||||
if ( $Child->isSelected() ) {
|
||||
echo ( "<option value=\"".$Child->thisHour()."\" selected>".$Child->thisHour()."\n" );
|
||||
} else {
|
||||
echo ( "<option value=\"".$Child->thisHour()."\">".$Child->thisHour()."\n" );
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
Minute:<select name="i">
|
||||
<?php
|
||||
$selection = array($Minute);
|
||||
$Hour->build($selection);
|
||||
while ( $Child = & $Hour->fetch() ) {
|
||||
if ( $Child->isSelected() ) {
|
||||
echo ( "<option value=\"".$Child->thisMinute()."\" selected>".$Child->thisMinute()."\n" );
|
||||
} else {
|
||||
echo ( "<option value=\"".$Child->thisMinute()."\">".$Child->thisMinute()."\n" );
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
Second:<select name="s">
|
||||
<?php
|
||||
$selection = array($Second);
|
||||
$Minute->build($selection);
|
||||
while ( $Child = & $Minute->fetch() ) {
|
||||
if ( $Child->isSelected() ) {
|
||||
echo ( "<option value=\"".$Child->thisSecond()."\" selected>".$Child->thisSecond()."\n" );
|
||||
} else {
|
||||
echo ( "<option value=\"".$Child->thisSecond()."\">".$Child->thisSecond()."\n" );
|
||||
}
|
||||
}
|
||||
?>
|
||||
</select>
|
||||
<input type="submit" name="update" value="Set Alarm"><br>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<?php echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' ); ?>
|
||||
</body>
|
||||
</html>
|
|
@ -1,210 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: A "personal planner" with some WML for fun
|
||||
* Note this is done the stupid way - a giant if/else for WML or HTML
|
||||
* could be greatly simplified with some HTML/WML rendering classes...
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
$start = getmicrotime();
|
||||
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Month/Weekdays.php';
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
|
||||
if (!isset($_GET['y'])) $_GET['y'] = date('Y');
|
||||
if (!isset($_GET['m'])) $_GET['m'] = date('n');
|
||||
if (!isset($_GET['d'])) $_GET['d'] = date('j');
|
||||
|
||||
$Month = & new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
|
||||
$Day = & new Calendar_Day($_GET['y'],$_GET['m'],$_GET['d']);
|
||||
$selection = array($Day);
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
if ( isset($_GET['mime']) && $_GET['mime']=='wml' ) {
|
||||
header ('Content-Type: text/vnd.wap.wml');
|
||||
echo ( '<?xml version="1.0"?>' );
|
||||
?>
|
||||
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
|
||||
<wml>
|
||||
<big><strong>Personal Planner Rendered with WML</strong></big>
|
||||
<?php
|
||||
if ( isset($_GET['viewday']) ) {
|
||||
?>
|
||||
<p><strong>Viewing <?php echo ( date('l, jS of F, Y',$Day->getTimeStamp()) ); ?></strong></p>
|
||||
<p>
|
||||
<anchor>
|
||||
Back to Month View
|
||||
<go href="<?php
|
||||
echo ( "?y=".$Day->thisYear()."&m=".
|
||||
$Day->thisMonth()."&d=".$Day->thisDay()."&mime=wml" );
|
||||
?>"/>
|
||||
</anchor>
|
||||
</p>
|
||||
<table>
|
||||
<?php
|
||||
$Day->build();
|
||||
while ( $Hour = & $Day->fetch() ) {
|
||||
echo ( "<tr>\n" );
|
||||
echo ( "<td>".date('g a',$Hour->getTimeStamp())."</td><td>Free time!</td>\n" );
|
||||
echo ( "</tr>\n" );
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<p><strong><?php echo ( date('F Y',$Month->getTimeStamp()) ); ?></strong></p>
|
||||
<table>
|
||||
<tr>
|
||||
<td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td><td>S</td>
|
||||
</tr>
|
||||
<?php
|
||||
$Month->build($selection);
|
||||
while ( $Day = $Month->fetch() ) {
|
||||
if ( $Day->isFirst() ) {
|
||||
echo ( "<tr>\n" );
|
||||
}
|
||||
if ( $Day->isEmpty() ) {
|
||||
echo ( "<td></td>\n" );
|
||||
} else if ( $Day->isSelected() ) {
|
||||
echo ( "<td><anchor><strong><u>".$Day->thisDay()."</u></strong>\n<go href=\"".$_SERVER['PHP_SELF']."?viewday=true&y=".
|
||||
$Day->thisYear()."&m=".$Day->thisMonth()."&d=".$Day->thisDay().
|
||||
"&mime=wml\" />\n</anchor></td>\n" );
|
||||
} else {
|
||||
echo ( "<td><anchor>".$Day->thisDay()."\n<go href=\"?viewday=true&y=".
|
||||
$Day->thisYear()."&m=".$Day->thisMonth()."&d=".$Day->thisDay().
|
||||
"&mime=wml\" /></anchor></td>\n" );
|
||||
}
|
||||
if ( $Day->isLast() ) {
|
||||
echo ( "</tr>\n" );
|
||||
}
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<anchor>
|
||||
<<
|
||||
<go href="<?php
|
||||
echo ( "?y=".$Month->thisYear()."&m=".
|
||||
$Month->prevMonth()."&d=".$Month->thisDay()."&mime=wml" );
|
||||
?>"/>
|
||||
</anchor>
|
||||
</td>
|
||||
<td></td><td></td><td></td><td></td><td></td>
|
||||
<td>
|
||||
<anchor>
|
||||
>>
|
||||
<go href="<?php
|
||||
echo ( "?y=".$Month->thisYear()."&m=".
|
||||
$Month->nextMonth()."&d=".$Month->thisDay()."&mime=wml" );
|
||||
?>"/>
|
||||
</anchor>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<p><a href="<?php echo ( $_SERVER['PHP_SELF'] ); ?>">Back to HTML</a></p>
|
||||
<?php echo ( '<p>Took: '.(getmicrotime()-$start).' seconds</p>' ); ?>
|
||||
</wml>
|
||||
<?php
|
||||
#-----------------------------------------------------------------------------#
|
||||
} else {
|
||||
?>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> HTML (+WML) Personal Planner </title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Personal Planner Rendered with HTML</h1>
|
||||
<p>To view in WML, click <a href="<?php echo ( $_SERVER['PHP_SELF'] ); ?>?mime=wml">here</a> or place a ?mime=wml at the end of any URL.
|
||||
Note that <a href="http://www.opera.com/download">Opera</a> supports WML natively and Mozilla / Firefox has the WMLBrowser
|
||||
plugin: <a href="http://wmlbrowser.mozdev.org">wmlbrowser.mozdev.org</a></p>
|
||||
<?php
|
||||
if ( isset($_GET['viewday']) ) {
|
||||
?>
|
||||
<p><strong>Viewing <?php echo ( date('l, jS of F, Y',$Day->getTimeStamp()) ); ?></strong></p>
|
||||
<p>
|
||||
<anchor>
|
||||
<a href="<?php
|
||||
echo ( "?y=".$Day->thisYear()."&m=".
|
||||
$Day->thisMonth()."&d=".$Day->thisDay());
|
||||
?>">Back to Month View</a>
|
||||
</p>
|
||||
<table>
|
||||
<?php
|
||||
$Day->build();
|
||||
while ( $Hour = & $Day->fetch() ) {
|
||||
echo ( "<tr>\n" );
|
||||
echo ( "<td>".date('g a',$Hour->getTimeStamp())."</td><td>Free time!</td>\n" );
|
||||
echo ( "</tr>\n" );
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<p><strong><?php echo ( date('F Y',$Month->getTimeStamp()) ); ?></strong></p>
|
||||
<table>
|
||||
<tr>
|
||||
<td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td><td>S</td>
|
||||
</tr>
|
||||
<?php
|
||||
$Month->build($selection);
|
||||
while ( $Day = $Month->fetch() ) {
|
||||
if ( $Day->isFirst() ) {
|
||||
echo ( "<tr>\n" );
|
||||
}
|
||||
if ( $Day->isEmpty() ) {
|
||||
echo ( "<td></td>\n" );
|
||||
} else if ( $Day->isSelected() ) {
|
||||
echo ( "<td><a href=\"".$_SERVER['PHP_SELF']."?viewday=true&y=".
|
||||
$Day->thisYear()."&m=".$Day->thisMonth()."&d=".$Day->thisDay().
|
||||
"&wml\"><strong><u>".$Day->thisDay()."</u></strong></a></td>\n" );
|
||||
} else {
|
||||
echo ( "<td><a href=\"".$_SERVER['PHP_SELF']."?viewday=true&y=".
|
||||
$Day->thisYear()."&m=".$Day->thisMonth()."&d=".$Day->thisDay().
|
||||
"\">".$Day->thisDay()."</a></td>\n" );
|
||||
}
|
||||
if ( $Day->isLast() ) {
|
||||
echo ( "</tr>\n" );
|
||||
}
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="<?php
|
||||
echo ( "?y=".$Month->thisYear()."&m=".
|
||||
$Month->prevMonth()."&d=".$Month->thisDay() );
|
||||
?>">
|
||||
<<</a>
|
||||
</td>
|
||||
<td></td><td></td><td></td><td></td><td></td>
|
||||
<td>
|
||||
<a href="<?php
|
||||
echo ( "?y=".$Month->thisYear()."&m=".
|
||||
$Month->nextMonth()."&d=".$Month->thisDay() );
|
||||
?>">>></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<?php echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' ); ?>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
}
|
||||
?>
|
|
@ -1,210 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: A "personal planner" with some WML for fun
|
||||
* Note this is done the stupid way - a giant if/else for WML or HTML
|
||||
* could be greatly simplified with some HTML/WML rendering classes...
|
||||
*/
|
||||
function getmicrotime(){
|
||||
list($usec, $sec) = explode(" ",microtime());
|
||||
return ((float)$usec + (float)$sec);
|
||||
}
|
||||
$start = getmicrotime();
|
||||
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Month/Weekdays.php';
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
|
||||
if (!isset($_GET['y'])) $_GET['y'] = date('Y');
|
||||
if (!isset($_GET['m'])) $_GET['m'] = date('n');
|
||||
if (!isset($_GET['d'])) $_GET['d'] = date('j');
|
||||
|
||||
$Month = & new Calendar_Month_Weekdays($_GET['y'],$_GET['m']);
|
||||
$Day = & new Calendar_Day($_GET['y'],$_GET['m'],$_GET['d']);
|
||||
$selection = array($Day);
|
||||
|
||||
#-----------------------------------------------------------------------------#
|
||||
if ( isset($_GET['mime']) && $_GET['mime']=='wml' ) {
|
||||
header ('Content-Type: text/vnd.wap.wml');
|
||||
echo ( '<?xml version="1.0"?>' );
|
||||
?>
|
||||
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
|
||||
<wml>
|
||||
<big><strong>Personal Planner Rendered with WML</strong></big>
|
||||
<?php
|
||||
if ( isset($_GET['viewday']) ) {
|
||||
?>
|
||||
<p><strong>Viewing <?php echo ( date('l, jS of F, Y',$Day->getTimeStamp()) ); ?></strong></p>
|
||||
<p>
|
||||
<anchor>
|
||||
Back to Month View
|
||||
<go href="<?php
|
||||
echo ( "?y=".$Day->thisYear()."&m=".
|
||||
$Day->thisMonth()."&d=".$Day->thisDay()."&mime=wml" );
|
||||
?>"/>
|
||||
</anchor>
|
||||
</p>
|
||||
<table>
|
||||
<?php
|
||||
$Day->build();
|
||||
while ( $Hour = & $Day->fetch() ) {
|
||||
echo ( "<tr>\n" );
|
||||
echo ( "<td>".date('g a',$Hour->getTimeStamp())."</td><td>Free time!</td>\n" );
|
||||
echo ( "</tr>\n" );
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<p><strong><?php echo ( date('F Y',$Month->getTimeStamp()) ); ?></strong></p>
|
||||
<table>
|
||||
<tr>
|
||||
<td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td><td>S</td>
|
||||
</tr>
|
||||
<?php
|
||||
$Month->build($selection);
|
||||
while ( $Day = $Month->fetch() ) {
|
||||
if ( $Day->isFirst() ) {
|
||||
echo ( "<tr>\n" );
|
||||
}
|
||||
if ( $Day->isEmpty() ) {
|
||||
echo ( "<td></td>\n" );
|
||||
} else if ( $Day->isSelected() ) {
|
||||
echo ( "<td><anchor><strong><u>".$Day->thisDay()."</u></strong>\n<go href=\"".$_SERVER['PHP_SELF']."?viewday=true&y=".
|
||||
$Day->thisYear()."&m=".$Day->thisMonth()."&d=".$Day->thisDay().
|
||||
"&mime=wml\" />\n</anchor></td>\n" );
|
||||
} else {
|
||||
echo ( "<td><anchor>".$Day->thisDay()."\n<go href=\"?viewday=true&y=".
|
||||
$Day->thisYear()."&m=".$Day->thisMonth()."&d=".$Day->thisDay().
|
||||
"&mime=wml\" /></anchor></td>\n" );
|
||||
}
|
||||
if ( $Day->isLast() ) {
|
||||
echo ( "</tr>\n" );
|
||||
}
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<anchor>
|
||||
<<
|
||||
<go href="<?php
|
||||
echo ( "?y=".$Month->thisYear()."&m=".
|
||||
$Month->prevMonth()."&d=".$Month->thisDay()."&mime=wml" );
|
||||
?>"/>
|
||||
</anchor>
|
||||
</td>
|
||||
<td></td><td></td><td></td><td></td><td></td>
|
||||
<td>
|
||||
<anchor>
|
||||
>>
|
||||
<go href="<?php
|
||||
echo ( "?y=".$Month->thisYear()."&m=".
|
||||
$Month->nextMonth()."&d=".$Month->thisDay()."&mime=wml" );
|
||||
?>"/>
|
||||
</anchor>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
<p><a href="<?php echo ( $_SERVER['PHP_SELF'] ); ?>">Back to HTML</a></p>
|
||||
<?php echo ( '<p>Took: '.(getmicrotime()-$start).' seconds</p>' ); ?>
|
||||
</wml>
|
||||
<?php
|
||||
#-----------------------------------------------------------------------------#
|
||||
} else {
|
||||
?>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> HTML (+WML) Personal Planner </title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Personal Planner Rendered with HTML</h1>
|
||||
<p>To view in WML, click <a href="<?php echo ( $_SERVER['PHP_SELF'] ); ?>?mime=wml">here</a> or place a ?mime=wml at the end of any URL.
|
||||
Note that <a href="http://www.opera.com/download">Opera</a> supports WML natively and Mozilla / Firefox has the WMLBrowser
|
||||
plugin: <a href="http://wmlbrowser.mozdev.org">wmlbrowser.mozdev.org</a></p>
|
||||
<?php
|
||||
if ( isset($_GET['viewday']) ) {
|
||||
?>
|
||||
<p><strong>Viewing <?php echo ( date('l, jS of F, Y',$Day->getTimeStamp()) ); ?></strong></p>
|
||||
<p>
|
||||
<anchor>
|
||||
<a href="<?php
|
||||
echo ( "?y=".$Day->thisYear()."&m=".
|
||||
$Day->thisMonth()."&d=".$Day->thisDay());
|
||||
?>">Back to Month View</a>
|
||||
</p>
|
||||
<table>
|
||||
<?php
|
||||
$Day->build();
|
||||
while ( $Hour = & $Day->fetch() ) {
|
||||
echo ( "<tr>\n" );
|
||||
echo ( "<td>".date('g a',$Hour->getTimeStamp())."</td><td>Free time!</td>\n" );
|
||||
echo ( "</tr>\n" );
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
<?php
|
||||
} else {
|
||||
?>
|
||||
<p><strong><?php echo ( date('F Y',$Month->getTimeStamp()) ); ?></strong></p>
|
||||
<table>
|
||||
<tr>
|
||||
<td>M</td><td>T</td><td>W</td><td>T</td><td>F</td><td>S</td><td>S</td>
|
||||
</tr>
|
||||
<?php
|
||||
$Month->build($selection);
|
||||
while ( $Day = $Month->fetch() ) {
|
||||
if ( $Day->isFirst() ) {
|
||||
echo ( "<tr>\n" );
|
||||
}
|
||||
if ( $Day->isEmpty() ) {
|
||||
echo ( "<td></td>\n" );
|
||||
} else if ( $Day->isSelected() ) {
|
||||
echo ( "<td><a href=\"".$_SERVER['PHP_SELF']."?viewday=true&y=".
|
||||
$Day->thisYear()."&m=".$Day->thisMonth()."&d=".$Day->thisDay().
|
||||
"&wml\"><strong><u>".$Day->thisDay()."</u></strong></a></td>\n" );
|
||||
} else {
|
||||
echo ( "<td><a href=\"".$_SERVER['PHP_SELF']."?viewday=true&y=".
|
||||
$Day->thisYear()."&m=".$Day->thisMonth()."&d=".$Day->thisDay().
|
||||
"\">".$Day->thisDay()."</a></td>\n" );
|
||||
}
|
||||
if ( $Day->isLast() ) {
|
||||
echo ( "</tr>\n" );
|
||||
}
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
<td>
|
||||
<a href="<?php
|
||||
echo ( "?y=".$Month->thisYear()."&m=".
|
||||
$Month->prevMonth()."&d=".$Month->thisDay() );
|
||||
?>">
|
||||
<<</a>
|
||||
</td>
|
||||
<td></td><td></td><td></td><td></td><td></td>
|
||||
<td>
|
||||
<a href="<?php
|
||||
echo ( "?y=".$Month->thisYear()."&m=".
|
||||
$Month->nextMonth()."&d=".$Month->thisDay() );
|
||||
?>">>></a>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
|
||||
|
||||
<?php echo ( '<p><b>Took: '.(getmicrotime()-$start).' seconds</b></p>' ); ?>
|
||||
</body>
|
||||
</html>
|
||||
<?php
|
||||
}
|
||||
?>
|
|
@ -1,92 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: a SOAP Calendar Server
|
||||
*/
|
||||
if (!@include('SOAP'.DIRECTORY_SEPARATOR.'Server.php')) {
|
||||
die('You must have PEAR::SOAP installed');
|
||||
}
|
||||
|
||||
if (!@include 'Calendar'.DIRECTORY_SEPARATOR.'Calendar.php') {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
|
||||
class Calendar_Server
|
||||
{
|
||||
var $__dispatch_map = array();
|
||||
var $__typedef = array();
|
||||
|
||||
function Calendar_Server()
|
||||
{
|
||||
$this->__dispatch_map['getMonth'] =
|
||||
array('in' => array('year' => 'int', 'month'=>'int'),
|
||||
'out' => array('month' => '{urn:PEAR_SOAP_Calendar}Month'),
|
||||
);
|
||||
$this->__typedef['Month'] = array (
|
||||
'monthname' => 'string',
|
||||
'days' => '{urn:PEAR_SOAP_Calendar}MonthDays'
|
||||
);
|
||||
$this->__typedef['MonthDays'] = array (array ('{urn:PEAR_SOAP_Calendar}Day'));
|
||||
$this->__typedef['Day'] = array (
|
||||
'isFirst' => 'int',
|
||||
'isLast' => 'int',
|
||||
'isEmpty' => 'int',
|
||||
'day' => 'int' );
|
||||
}
|
||||
|
||||
function __dispatch($methodname)
|
||||
{
|
||||
if (isset($this->__dispatch_map[$methodname]))
|
||||
return $this->__dispatch_map[$methodname];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
function getMonth($year, $month)
|
||||
{
|
||||
require_once(CALENDAR_ROOT.'Month'.DIRECTORY_SEPARATOR.'Weekdays.php');
|
||||
$Month = & new Calendar_Month_Weekdays($year,$month);
|
||||
if (!$Month->isValid()) {
|
||||
$V = & $Month->getValidator();
|
||||
$errorMsg = '';
|
||||
while ($error = $V->fetch()) {
|
||||
$errorMsg .= $error->toString()."\n";
|
||||
}
|
||||
return new SOAP_Fault($errorMsg, 'Client');
|
||||
} else {
|
||||
$monthname = date('F Y', $Month->getTimeStamp());
|
||||
$days = array();
|
||||
$Month->build();
|
||||
while ($Day = & $Month->fetch()) {
|
||||
$day = array(
|
||||
'isFirst' => (int)$Day->isFirst(),
|
||||
'isLast' => (int)$Day->isLast(),
|
||||
'isEmpty' => (int)$Day->isEmpty(),
|
||||
'day' => (int)$Day->thisDay(),
|
||||
);
|
||||
$days[] = $day;
|
||||
}
|
||||
return array('monthname' => $monthname, 'days' => $days);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$server = new SOAP_Server();
|
||||
$server->_auto_translation = true;
|
||||
$calendar = new Calendar_Server();
|
||||
$server->addObjectMap($calendar, 'urn:PEAR_SOAP_Calendar');
|
||||
|
||||
if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') {
|
||||
$server->service($GLOBALS['HTTP_RAW_POST_DATA']);
|
||||
} else {
|
||||
require_once 'SOAP'.DIRECTORY_SEPARATOR.'Disco.php';
|
||||
$disco = new SOAP_DISCO_Server($server, "PEAR_SOAP_Calendar");
|
||||
if (isset($_SERVER['QUERY_STRING']) &&
|
||||
strcasecmp($_SERVER['QUERY_STRING'], 'wsdl')==0) {
|
||||
header("Content-type: text/xml");
|
||||
echo $disco->getWSDL();
|
||||
} else {
|
||||
echo 'This is a PEAR::SOAP Calendar Server. For client try <a href="8.php">here</a><br />';
|
||||
echo 'For WSDL try <a href="?wsdl">here</a>';
|
||||
}
|
||||
exit;
|
||||
}
|
||||
?>
|
|
@ -1,92 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: a SOAP Calendar Server
|
||||
*/
|
||||
if (!@include('SOAP'.DIRECTORY_SEPARATOR.'Server.php')) {
|
||||
die('You must have PEAR::SOAP installed');
|
||||
}
|
||||
|
||||
if (!@include 'Calendar'.DIRECTORY_SEPARATOR.'Calendar.php') {
|
||||
define('CALENDAR_ROOT', '../../');
|
||||
}
|
||||
|
||||
class Calendar_Server
|
||||
{
|
||||
var $__dispatch_map = array();
|
||||
var $__typedef = array();
|
||||
|
||||
function Calendar_Server()
|
||||
{
|
||||
$this->__dispatch_map['getMonth'] =
|
||||
array('in' => array('year' => 'int', 'month'=>'int'),
|
||||
'out' => array('month' => '{urn:PEAR_SOAP_Calendar}Month'),
|
||||
);
|
||||
$this->__typedef['Month'] = array (
|
||||
'monthname' => 'string',
|
||||
'days' => '{urn:PEAR_SOAP_Calendar}MonthDays'
|
||||
);
|
||||
$this->__typedef['MonthDays'] = array (array ('{urn:PEAR_SOAP_Calendar}Day'));
|
||||
$this->__typedef['Day'] = array (
|
||||
'isFirst' => 'int',
|
||||
'isLast' => 'int',
|
||||
'isEmpty' => 'int',
|
||||
'day' => 'int' );
|
||||
}
|
||||
|
||||
function __dispatch($methodname)
|
||||
{
|
||||
if (isset($this->__dispatch_map[$methodname]))
|
||||
return $this->__dispatch_map[$methodname];
|
||||
return NULL;
|
||||
}
|
||||
|
||||
function getMonth($year, $month)
|
||||
{
|
||||
require_once(CALENDAR_ROOT.'Month'.DIRECTORY_SEPARATOR.'Weekdays.php');
|
||||
$Month = & new Calendar_Month_Weekdays($year,$month);
|
||||
if (!$Month->isValid()) {
|
||||
$V = & $Month->getValidator();
|
||||
$errorMsg = '';
|
||||
while ($error = $V->fetch()) {
|
||||
$errorMsg .= $error->toString()."\n";
|
||||
}
|
||||
return new SOAP_Fault($errorMsg, 'Client');
|
||||
} else {
|
||||
$monthname = date('F Y', $Month->getTimeStamp());
|
||||
$days = array();
|
||||
$Month->build();
|
||||
while ($Day = & $Month->fetch()) {
|
||||
$day = array(
|
||||
'isFirst' => (int)$Day->isFirst(),
|
||||
'isLast' => (int)$Day->isLast(),
|
||||
'isEmpty' => (int)$Day->isEmpty(),
|
||||
'day' => (int)$Day->thisDay(),
|
||||
);
|
||||
$days[] = $day;
|
||||
}
|
||||
return array('monthname' => $monthname, 'days' => $days);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$server = new SOAP_Server();
|
||||
$server->_auto_translation = true;
|
||||
$calendar = new Calendar_Server();
|
||||
$server->addObjectMap($calendar, 'urn:PEAR_SOAP_Calendar');
|
||||
|
||||
if (strtoupper($_SERVER['REQUEST_METHOD'])=='POST') {
|
||||
$server->service($GLOBALS['HTTP_RAW_POST_DATA']);
|
||||
} else {
|
||||
require_once 'SOAP'.DIRECTORY_SEPARATOR.'Disco.php';
|
||||
$disco = new SOAP_DISCO_Server($server, "PEAR_SOAP_Calendar");
|
||||
if (isset($_SERVER['QUERY_STRING']) &&
|
||||
strcasecmp($_SERVER['QUERY_STRING'], 'wsdl')==0) {
|
||||
header("Content-type: text/xml");
|
||||
echo $disco->getWSDL();
|
||||
} else {
|
||||
echo 'This is a PEAR::SOAP Calendar Server. For client try <a href="8.php">here</a><br />';
|
||||
echo 'For WSDL try <a href="?wsdl">here</a>';
|
||||
}
|
||||
exit;
|
||||
}
|
||||
?>
|
|
@ -1,70 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: client for the SOAP Calendar Server
|
||||
*/
|
||||
if ( version_compare(phpversion(), "5.0.0", ">") ) {
|
||||
die('PHP 5 has problems with PEAR::SOAP Client (8.0RC3)
|
||||
- remove @ before include below to see why');
|
||||
}
|
||||
|
||||
if (!@include('SOAP'.DIRECTORY_SEPARATOR.'Client.php')) {
|
||||
die('You must have PEAR::SOAP installed');
|
||||
}
|
||||
|
||||
// Just to save manaul modification...
|
||||
$basePath = explode('/', $_SERVER['SCRIPT_NAME']);
|
||||
array_pop($basePath);
|
||||
$basePath = implode('/', $basePath);
|
||||
$url = 'http://'.$_SERVER['SERVER_NAME'].$basePath.'/7.php?wsdl';
|
||||
|
||||
if (!isset($_GET['y'])) $_GET['y'] = date('Y');
|
||||
if (!isset($_GET['m'])) $_GET['m'] = date('n');
|
||||
|
||||
$wsdl = new SOAP_WSDL ($url);
|
||||
|
||||
echo ( '<pre>'.$wsdl->generateProxyCode().'</pre>' );
|
||||
|
||||
$calendarClient = $wsdl->getProxy();
|
||||
|
||||
$month = $calendarClient->getMonth((int)$_GET['y'],(int)$_GET['m']);
|
||||
|
||||
if ( PEAR::isError($month) ) {
|
||||
die ( $month->toString() );
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> Calendar over the Wire </title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Calendar Over the Wire (featuring PEAR::SOAP)</h1>
|
||||
<table>
|
||||
<caption><b><?php echo ( $month->monthname );?></b></caption>
|
||||
<tr>
|
||||
<th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th><th>S</th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ( $month->days as $day ) {
|
||||
|
||||
if ( $day->isFirst === 1 )
|
||||
echo ( "<tr>\n" );
|
||||
if ( $day->isEmpty === 1 ) {
|
||||
echo ( "<td></td>" );
|
||||
} else {
|
||||
echo ( "<td>".$day->day."</td>" );
|
||||
}
|
||||
if ( $day->isLast === 1 )
|
||||
echo ( "</tr>\n" );
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
</table>
|
||||
<p>Enter Year and Month to View:</p>
|
||||
<form action="<?php echo ( $_SERVER['PHP_SELF'] ); ?>" method="get">
|
||||
Year: <input type="text" size="4" name="y" value="<?php echo ( $_GET['y'] ); ?>">
|
||||
Month: <input type="text" size="2" name="m" value="<?php echo ( $_GET['m'] ); ?>">
|
||||
<input type="submit" value="Fetch Calendar">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
|
@ -1,70 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: client for the SOAP Calendar Server
|
||||
*/
|
||||
if ( version_compare(phpversion(), "5.0.0", ">") ) {
|
||||
die('PHP 5 has problems with PEAR::SOAP Client (8.0RC3)
|
||||
- remove @ before include below to see why');
|
||||
}
|
||||
|
||||
if (!@include('SOAP'.DIRECTORY_SEPARATOR.'Client.php')) {
|
||||
die('You must have PEAR::SOAP installed');
|
||||
}
|
||||
|
||||
// Just to save manaul modification...
|
||||
$basePath = explode('/', $_SERVER['SCRIPT_NAME']);
|
||||
array_pop($basePath);
|
||||
$basePath = implode('/', $basePath);
|
||||
$url = 'http://'.$_SERVER['SERVER_NAME'].$basePath.'/7.php?wsdl';
|
||||
|
||||
if (!isset($_GET['y'])) $_GET['y'] = date('Y');
|
||||
if (!isset($_GET['m'])) $_GET['m'] = date('n');
|
||||
|
||||
$wsdl = new SOAP_WSDL ($url);
|
||||
|
||||
echo ( '<pre>'.$wsdl->generateProxyCode().'</pre>' );
|
||||
|
||||
$calendarClient = $wsdl->getProxy();
|
||||
|
||||
$month = $calendarClient->getMonth((int)$_GET['y'],(int)$_GET['m']);
|
||||
|
||||
if ( PEAR::isError($month) ) {
|
||||
die ( $month->toString() );
|
||||
}
|
||||
?>
|
||||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title> Calendar over the Wire </title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>Calendar Over the Wire (featuring PEAR::SOAP)</h1>
|
||||
<table>
|
||||
<caption><b><?php echo ( $month->monthname );?></b></caption>
|
||||
<tr>
|
||||
<th>M</th><th>T</th><th>W</th><th>T</th><th>F</th><th>S</th><th>S</th>
|
||||
</tr>
|
||||
<?php
|
||||
foreach ( $month->days as $day ) {
|
||||
|
||||
if ( $day->isFirst === 1 )
|
||||
echo ( "<tr>\n" );
|
||||
if ( $day->isEmpty === 1 ) {
|
||||
echo ( "<td></td>" );
|
||||
} else {
|
||||
echo ( "<td>".$day->day."</td>" );
|
||||
}
|
||||
if ( $day->isLast === 1 )
|
||||
echo ( "</tr>\n" );
|
||||
}
|
||||
?>
|
||||
<tr>
|
||||
</table>
|
||||
<p>Enter Year and Month to View:</p>
|
||||
<form action="<?php echo ( $_SERVER['PHP_SELF'] ); ?>" method="get">
|
||||
Year: <input type="text" size="4" name="y" value="<?php echo ( $_GET['y'] ); ?>">
|
||||
Month: <input type="text" size="2" name="m" value="<?php echo ( $_GET['m'] ); ?>">
|
||||
<input type="submit" value="Fetch Calendar">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: simple example on i18N
|
||||
*/
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
|
||||
$Day = & new Calendar_Day(2003,10,23);
|
||||
|
||||
setlocale (LC_TIME, "de_DE"); // Unix based (probably)
|
||||
// setlocale (LC_TIME, "ge"); // Windows
|
||||
|
||||
echo ( strftime('%A %d %B %Y',$Day->getTimeStamp()));
|
||||
?>
|
|
@ -1,16 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Description: simple example on i18N
|
||||
*/
|
||||
if ( !@include 'Calendar/Calendar.php' ) {
|
||||
define('CALENDAR_ROOT','../../');
|
||||
}
|
||||
require_once CALENDAR_ROOT.'Day.php';
|
||||
|
||||
$Day = & new Calendar_Day(2003,10,23);
|
||||
|
||||
setlocale (LC_TIME, "de_DE"); // Unix based (probably)
|
||||
// setlocale (LC_TIME, "ge"); // Windows
|
||||
|
||||
echo ( strftime('%A %d %B %Y',$Day->getTimeStamp()));
|
||||
?>
|
|
@ -1,49 +0,0 @@
|
|||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<title>PEAR::Calendar Examples</title>
|
||||
<style type="text/css">
|
||||
body {
|
||||
font-family: georgia, serif;
|
||||
}
|
||||
pre {
|
||||
background-color: silver;
|
||||
}
|
||||
code {
|
||||
color: navy;
|
||||
background-color: #e2e3e4;
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<h1>PEAR::Calendar Examples</h1>
|
||||
<p>$Id: index.html,v 1.5 2004/08/16 13:15:48 hfuecks Exp $</p>
|
||||
<ul>
|
||||
<li><a href="1.php">1.php</a> [<a href="1.phps">src</a>] - shows basic usage, passing all the way down from <code>Calendar_Year</code> to <code>Calendar_Second</code> - more of a quick test it's working</li>
|
||||
<li><a href="2.php">2.php</a> [<a href="2.phps">src</a>] - shows how to build a tabular month using <code>Calendar_Month_Weeks</code>, <code>Calendar_Week</code>, <code>Calendar_Day</code> as well as selecting some dates.</li>
|
||||
<li><a href="3.php">3.php</a> [<a href="3.phps">src</a>] - shows how to build a tabular month using <code>Calendar_Month_Weekdays</code> and <code>Calendar_Day</code>, as well as selecting some dates (this method is faster).</li>
|
||||
<li><a href="4.php">4.php</a> [<a href="4.phps">src</a>] - shows how to use PEAR::Calendar for validation.</li>
|
||||
<li><a href="5.php">5.php</a> [<a href="5.phps">src</a>] - shows PEAR::Calendar in use to help generate a form.</li>
|
||||
<li><a href="6.php">6.php</a> [<a href="6.phps">src</a>] - a month and day "planner" calendar, which can be rendered both as HTML and WML.</li>
|
||||
<li><a href="7.php">7.php</a> [<a href="7.phps">src</a>] - a simple SOAP Calendar Server, using PEAR::SOAP and PEAR::Calendar</li>
|
||||
<li><a href="8.php">8.php</a> [<a href="8.phps">src</a>] - a WSDL SOAP client for the SOAP Calendar Server</li>
|
||||
<li><a href="9.php">9.php</a> [<a href="9.phps">src</a>] - quick example of i18n with <code>setlocale</code> (not working on SF)</li>
|
||||
<li><a href="10.php">10.php</a> [<a href="10.phps">src</a>] - an example of extending <code>Calendar_Decorator</code> to modify output</li>
|
||||
<li><a href="11.php">11.php</a> [<a href="11.phps">src</a>] - attaching a "payload" (e.g. results of a DB query) to a calendar using <code>Calendar_Decorator</code> to allow the payload to be available inside the main loop.</li>
|
||||
<li><a href="12.php">12.php</a> [<a href="12.phps">src</a>] - a complete year with months.</li>
|
||||
<li><a href="13.php">13.php</a> [<a href="13.phps">src</a>] - same as 1.php but using <code>Calendar_Engine_PearDate</code>, (see <a href="http://pear.php.net/Date">PEAR::Date</a>).</li>
|
||||
<li><a href="14.php">14.php</a> [<a href="14.phps">src</a>] - same as 3.php but using <code>Calendar_Engine_PearDate</code></li>
|
||||
<li><a href="15.php">15.php</a> [<a href="15.phps">src</a>] - paging through weeks </li>
|
||||
<li><a href="16.php">16.php</a> [<a href="16.phps">src</a>] - demonstrates using the Uri decorator. <i>Note</i> you should prefer <code>Calendar_Util_Uri</code> (see below) in most cases, for performance </li>
|
||||
<li><a href="17.php">17.php</a> [<a href="17.phps">src</a>] - demonstrates using the Textual decorator</li>
|
||||
<li><a href="18.php">18.php</a> [<a href="18.phps">src</a>] - demonstrates using the Wrapper decorator</li>
|
||||
<li><a href="19.php">19.php</a> [<a href="19.phps">src</a>] - demonstrates using the Weekday decorator</li>
|
||||
<li><a href="20.php">20.php</a> [<a href="20.phps">src</a>] - shows how to attach a "payload" spanning multiple days, with more than one entry per day</li>
|
||||
<li><a href="21.php">21.php</a> [<a href="21.phps">src</a>] - same as 12.php but using <code>Calendar_Month_Weeks</code> instead of <code>Calendar_Month_Weekdays</code> to allow the week in the year or week in the month to be displayed.</li>
|
||||
<li><a href="22.php">22.php</a> [<a href="22.phps">src</a>] - demonstrates use of <code>Calendar_Util_Uri</code>.</li>
|
||||
<li><a href="22.php">23.php</a> [<a href="23.phps">src</a>] - demonstrates use of <code>Calendar_Util_Textual</code>.</li>
|
||||
</ul>
|
||||
</body>
|
||||
</html>
|
|
@ -1,90 +0,0 @@
|
|||
Abstracted Types (Stig)
|
||||
-----------------------
|
||||
|
||||
DB needs a set of types representing the most commonly used types in
|
||||
all backends. This type set could also be geared towards integration
|
||||
with things like XML-RPC/SOAP implementations, HTML form classes, etc.
|
||||
|
||||
Real Query Parser (Stig)
|
||||
------------------------
|
||||
|
||||
With a real query parser, DB can implement more of its portability
|
||||
based on the query, instead of having support functions for
|
||||
everything. One example would be LIMIT, another "INSERT
|
||||
... RETURNING".
|
||||
|
||||
Portable transactions (Stig)
|
||||
----------------------------
|
||||
|
||||
If DB can parse queries enough to determine what tables are affected
|
||||
by queries, it should be possible to make a replayable transaction
|
||||
log. GNOME uses an XML format for configuration data that lets you
|
||||
checkpoint state once in a while, and revert to that state later.
|
||||
With a similar approach for transactions in DB we can implement
|
||||
portable transactions and checkpointing even for the databases that
|
||||
don't support them.
|
||||
|
||||
|
||||
Error reporting clean-up/debug (Tomas)
|
||||
-------------------------------------
|
||||
Now each driver has its own raiseError method, common has a raiseError and
|
||||
DB has a DB_error class and its own isError() method. This error stuff
|
||||
overhead could be simplified with only one raiseError, droping the DB Error
|
||||
class and also the DB::isError() (use the PEAR.php ones instead).
|
||||
Other idea could be to add a system for allowing people access to all the
|
||||
queries sended by PEAR DB to the backend. Also a new PEAR_ERROR_DEBUG
|
||||
flag that automatically (show|triggers) debug info, perhaps
|
||||
with a new PEAR_(Warning|Debug) object.
|
||||
|
||||
Quote clean-up (Stig)
|
||||
---------------------
|
||||
1. Keep quote and quoteString, but move quoting of strings back into
|
||||
quoteString and make quote call it for strings.
|
||||
|
||||
2. Add an optional "operator" parameter to quote that is one of "=",
|
||||
"<", ">" or "<>" that will be inserted in front of the quoted value
|
||||
unless it is NULL, in which case it will be converted to "IS" (for
|
||||
"=") or "IS NOT" (for the others).
|
||||
|
||||
Auto free statements (Tomas)
|
||||
----------------------------
|
||||
By setting a param in query() or for the hole DB instance, PEAR DB
|
||||
could auto-free results in DB_result->fetch(Into|Row) when the driver
|
||||
returns false.
|
||||
|
||||
Datatypes in prepare syntax (Tomas)
|
||||
-----------------------------------
|
||||
Extend the actual prepare/execute placeholders to support data types, both
|
||||
to check the data introduced to the query and to "cast" the result
|
||||
to native php data types. Ex:
|
||||
|
||||
$sql = "INSERT INTO table VALUES ({{int(4)}}, {{bool}}, {{date('Y-m-d')}})";
|
||||
$row = $db->query($sql, array(8, 't', '2001-04-1'));
|
||||
|
||||
Format: {{<data_type>(<param1>,<param2>)}}
|
||||
|
||||
"param" could be the max lenght of the data, date formats, not_null
|
||||
checks or default values.
|
||||
|
||||
Other ideas could be:
|
||||
|
||||
1)
|
||||
$sql = "INSERT INTO table VALUES (?, ?, ?)";
|
||||
$sth = $db->prepare($sql, array('int(4)', 'bool', 'date');
|
||||
$res = $db->execute($sth, array($a, $b, $c);
|
||||
|
||||
2)
|
||||
$sql = "INSERT INTO table VALUES (?, ?, ?)";
|
||||
$params = array(
|
||||
0 => array($a, 'int(4)'),
|
||||
1 => array($b, 'bool')
|
||||
);
|
||||
$res = $db->query($sql, $params);
|
||||
|
||||
Auto connect feature (Tomas)
|
||||
----------------------------
|
||||
Add the ability to create for example a light and dump DB object which
|
||||
will only set up the connection when needed. With that people could
|
||||
create the DB object in a common prepend or default file without the
|
||||
need to waste system resources if the use of the database is finally
|
||||
not needed.
|
|
@ -1,16 +0,0 @@
|
|||
Maintainers for DB database backends/drivers:
|
||||
|
||||
dbase : Daniel Convissor <danielc@php.net>
|
||||
fbsql : Daniel Convissor <danielc@php.net>
|
||||
Frank M. Kromann <frank@kromann.info>
|
||||
ibase : Daniel Convissor <danielc@php.net>
|
||||
ifx : Daniel Convissor <danielc@php.net>
|
||||
msql : Daniel Convissor <danielc@php.net>
|
||||
mssql : Daniel Convissor <danielc@php.net>
|
||||
mysql : Daniel Convissor <danielc@php.net>
|
||||
mysqli : Daniel Convissor <danielc@php.net>
|
||||
oci8 : Daniel Convissor <danielc@php.net>
|
||||
odbc : Daniel Convissor <danielc@php.net>
|
||||
pgsql : Daniel Convissor <danielc@php.net>
|
||||
sqlite : Daniel Convissor <danielc@php.net>
|
||||
sybase : Daniel Convissor <danielc@php.net>
|
|
@ -1,93 +0,0 @@
|
|||
STATUS OF THE PEAR DB PACKAGE
|
||||
=============================
|
||||
|
||||
$Id: STATUS,v 1.33 2005/02/22 15:45:36 danielc Exp $
|
||||
------------------------------------------------------------------------
|
||||
|
||||
DB Driver Feature Matrix
|
||||
------------------------
|
||||
Symbols:
|
||||
x = implemented, but without tests
|
||||
t = implemented, but one or more tests fail
|
||||
T = implemented, passing all tests
|
||||
e = emulated, without tests
|
||||
l = emulated, but one or more tests fail
|
||||
E = emulated, passing all tests
|
||||
n = returns "not capable"
|
||||
- = no implementation of this feature or status unknown
|
||||
|
||||
fbsql ifx mssql mysqli odbc sqlite
|
||||
FEATURE dbase | ibase | msql | mysql | oci8 | pgsql | sybase
|
||||
simpleQuery - T T T T T T T T T T T T
|
||||
numCols x T T T T T T T T T T T T
|
||||
numRows x T E E T T T T E T T T T
|
||||
errorNative n T T T T T T T T T T E T
|
||||
prepare/execute e E T E E E E E T E E E E
|
||||
sequences n T T n T T T T T E T E T
|
||||
affectedRows n T E E T T T T T T E T T
|
||||
fetch modes x T T T T T T T T T T T T
|
||||
fetch row by no x x n n x x x x n x x x x
|
||||
transactions - T T T n T T T T T T n T
|
||||
auto-commit n T E E n E E E E T E n E
|
||||
error mapping - T T T T T T T T T T T T
|
||||
tableInfo x T T t T T T T T T T T T
|
||||
|
||||
getListOf() TYPES
|
||||
tables - T T T T T T T T T T T T
|
||||
views - T T - - T - - - T T - T
|
||||
users - T T - - - T T - - T - -
|
||||
databases - - - - T - T T - T T - -
|
||||
functions - T - - - - - - - - T - -
|
||||
synonyms - - - - - - - - T - - - -
|
||||
|
||||
|
||||
Test Conformance
|
||||
----------------
|
||||
Symbols:
|
||||
o = Test passed
|
||||
X = Test failed
|
||||
L = Some portions of the test failed due to limitations in PHP or DBMS
|
||||
n = Test returns "not capable"
|
||||
- = Not tested
|
||||
|
||||
fbsql ifx mssql mysqli odbc sqlite
|
||||
dbase | ibase | msql | mysql | oci8 | pgsql | sybase
|
||||
01connect o o o o o o o o o o o o o
|
||||
02fetch - o o o o o o o o o o o o
|
||||
03simplequery - o o o o o o o o o o o o
|
||||
04numcols - o o o o o o o o o o o o
|
||||
05sequences - o o o o o o o o o o o o
|
||||
06prepexec - o o o L o o o o o o o o
|
||||
08affectedrows - o o o o o o o o o o o o
|
||||
09numrows - o o o o o o o o o o o o
|
||||
10errormap - o o o o o o o o o o o o
|
||||
11transactions - o o o n o o o o o o n o
|
||||
13limit - o o o o o o o o o o o o
|
||||
14fetchmode_obje - o o o o o o o o o o o o
|
||||
15quote - o o o o o o o o o o o o
|
||||
16tableinfo - o o L o o o o o o o o o
|
||||
17query - o o o o o o o o o o o o
|
||||
18get - o o o o o o o o o o o o
|
||||
19getlistof - o o o o o o o o o o o o
|
||||
|
||||
|
||||
DBMS Versions Tested
|
||||
--------------------
|
||||
dbase n/a
|
||||
fbsql 4.1.6
|
||||
ibase Firebird 1.5.1 (PHP 5 only)
|
||||
ifx 7.2 Standard Edtition
|
||||
msql 3.6 (PHP snapshots dated 2005-02-18)
|
||||
mssql 8.0.760
|
||||
mysql 4.0.21
|
||||
mysqli 4.1.5 (PHP 5 only)
|
||||
oci8 9.2
|
||||
odbc DB2 ESE 8.1 and MS Access 2000
|
||||
pgsql 7.4.1 and 8.0.1
|
||||
sqlite PHP 5: extension. PHP 4: PECL snapshot.
|
||||
sybase ASE 12.5.3
|
||||
|
||||
Tests were performed under both of the following PHP versions
|
||||
unles otherwise noted:
|
||||
4.3.11-dev dated 2005-02-22
|
||||
5.1.0-dev dated 2005-02-22
|
|
@ -1,156 +0,0 @@
|
|||
===================
|
||||
HOW TO TEST PEAR DB
|
||||
===================
|
||||
|
||||
$Id: TESTERS,v 1.20 2005/02/16 06:33:12 danielc Exp $
|
||||
|
||||
|
||||
INTRODUCTION
|
||||
============
|
||||
|
||||
These are instructions for testing PEAR DB on a Windows machine using a
|
||||
Cygwin Bash shell. Adjust the paths and commands to match your system.
|
||||
This configuration is used because these precise steps are known to work.
|
||||
|
||||
NOTE: You must log on as a user which has permissions to modify the
|
||||
contents of your PHP executable's directory. This is necessary for both
|
||||
configuring AND running the test system.
|
||||
|
||||
|
||||
INSTALLATION
|
||||
============
|
||||
|
||||
Obtain PHP's Test Framework
|
||||
---------------------------
|
||||
If you don't have PHP's test framework, you need to obtain it. These
|
||||
steps include changing the working directory, downloading run-tests.php
|
||||
via CVS and copying the file into place. Change the revision flag in the
|
||||
CVS command as appropriate for your present version of PHP.
|
||||
|
||||
cd c:/progra~1/php
|
||||
cvs -d :pserver:cvsread@cvs.php.net:/repository login # password is phpfi
|
||||
cvs -d :pserver:cvsread@cvs.php.net:/repository co -r PHP_4_3 \
|
||||
-d test php-src/run-tests.php
|
||||
cp test/run-tests.php .
|
||||
rm -rf test
|
||||
|
||||
|
||||
Obtain DB and its Test Framework
|
||||
--------------------------------
|
||||
* IF PEAR DB IS ALREADY INSTALLED:
|
||||
|
||||
If you have PEAR DB installed already, good. The test suite
|
||||
is in place. Open up a command/shell prompt and move into
|
||||
the test directory.
|
||||
|
||||
cd <path to pear insall>/tests/DB/tests
|
||||
|
||||
* VIA A NEW INSTALLATION USING THE PEAR INSTALLER:
|
||||
|
||||
Installing PEAR has gotten fairly easy. Follow the instructions
|
||||
from the manual: http://pear.php.net/manual/en/installation.php
|
||||
Once PEAR and DB are installed, move to the test directory.
|
||||
|
||||
cd pear/tests/DB/tests
|
||||
|
||||
* VIA CVS:
|
||||
|
||||
Create a location to store the test installation of DB and its
|
||||
test scripts.
|
||||
|
||||
mkdir d:/peartest
|
||||
cd d:/peartest
|
||||
cvs -d :pserver:cvsread@cvs.php.net:/repository co -P pear/DB
|
||||
|
||||
We assume you already have the PEAR base package installed. If
|
||||
you don't, you will need to do so, but the instructions for
|
||||
doing that are beyond the scope of this document. See
|
||||
http://pear.php.net/manual/en/installation.php for more info.
|
||||
|
||||
Move to the test directory.
|
||||
|
||||
cd pear/DB/tests
|
||||
|
||||
|
||||
Copy the Starter Shell Script and Edit the Paths
|
||||
------------------------------------------------
|
||||
To make starting up each test run easier, we have included two shell
|
||||
scripts. The original files are named "run.cvs". They need to be
|
||||
renamed to "run" so CVS won't bother you with tracking them. Then,
|
||||
the paths and file names in them need to be set to those used by
|
||||
your system.
|
||||
|
||||
cp run.cvs run
|
||||
chmod 755 run
|
||||
vi run
|
||||
|
||||
cd driver
|
||||
cp run.cvs run
|
||||
chmod 755 run
|
||||
vi run
|
||||
|
||||
|
||||
Copy the Setup File and Edit the DSN's
|
||||
--------------------------------------
|
||||
The test suite contains a file that stores the DSN's needed to
|
||||
connect to your database. The original file is "setup.inc.cvs"
|
||||
and it needs to be renamed "setup.inc" so CVS won't track it.
|
||||
Then you'll need to edit the DSN's in it.
|
||||
|
||||
cp setup.inc.cvs setup.inc
|
||||
vi setup.inc
|
||||
|
||||
|
||||
RUN THE TESTS
|
||||
=============
|
||||
|
||||
To run all tests: ./run
|
||||
To run one test: ./run <test file name>
|
||||
Example: ./run db_parsedsn.phpt
|
||||
|
||||
|
||||
Test Types and Locations
|
||||
------------------------
|
||||
tests Common PEAR DB tests
|
||||
tests/driver Common tests for all the drivers
|
||||
|
||||
|
||||
Results and What To Do With Them
|
||||
--------------------------------
|
||||
Each test that fails generates a .php (which you can execute), a .exp
|
||||
(the expected output), a .out (the test output) and a .diff (a diff -u
|
||||
from the .exp and .out files).
|
||||
|
||||
If you run the tests, please report or fill the TEST CONFORMANCE table
|
||||
in the STATUS document. Before any commit to CVS be sure to run the
|
||||
tests and nothing got broken with the change.
|
||||
|
||||
If you get the message "SKIP", means that the test it's not executed.
|
||||
Look at the DB/tests/driver/skipif.inc to see what's the problem
|
||||
(probably a connection problem).
|
||||
|
||||
|
||||
DB TESTER MATRIX
|
||||
================
|
||||
fbsql ifx mssql mysqli odbc sqlite
|
||||
TESTER dbase | ibase | msql | mysql | oci8 | pgsql | sybase
|
||||
John Horton - - - X - - - - - - - - -
|
||||
Tim Zickus - - - - - - - - X - - - -
|
||||
Tim Parkin - - - - - - - - X - - - -
|
||||
Paul Gardiner - - - X - - - - - - - - -
|
||||
peterwb@iafrica.com - - - X - - - - - - - - -
|
||||
Daniel, Adam - - - - - - - - X - - - -
|
||||
szii@sziisoft.com - - - - - - - - - X¹ - - -
|
||||
jmh3@linuxfreak.com - - - - - - - - - - X - -
|
||||
Kevin Henrikson - - - - - - - - X - - - -
|
||||
Stig Bakken - - - - - - X - - - X - -
|
||||
Chuck Hagenbuch - - - - - X - - - - - - -
|
||||
Ludovico Magnocavallo - - X - - - - - - - - - -
|
||||
Daniel Convissor X X X - X X X X X X² X X X
|
||||
|
||||
MISSING TESTERS - - - - - - - - - - - - -
|
||||
|
||||
Comments:
|
||||
|
||||
[1]: ODBC using IBM DB2
|
||||
[2]: ODBC using IBM DB2 and MS Access
|
|
@ -1,154 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Example of usage for PEAR class HTML_QuickForm
|
||||
*
|
||||
* @author Adam Daniel <adaniel1@eesus.jnj.com>
|
||||
* @author Bertrand Mansion <bmansion@mamasam.com>
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @version 3.2
|
||||
*
|
||||
* $Id: elements.php,v 1.2 2004/03/22 10:05:09 mansion Exp $
|
||||
*/
|
||||
|
||||
require_once 'HTML/QuickForm.php';
|
||||
|
||||
$form =& new HTML_QuickForm('frmTest', 'get');
|
||||
|
||||
// Use a two-label template for the elements that require some comments
|
||||
$twoLabel = <<<_HTML
|
||||
<tr valign="top">
|
||||
<td align="right">
|
||||
<!-- BEGIN required --><span style="color: #F00;">*</span><!-- END required --><b>{label}</b>
|
||||
</td>
|
||||
<td align="left">
|
||||
<!-- BEGIN error --><span style="color: #F00;">{error}</span><br /><!-- END error -->{element}
|
||||
<!-- BEGIN label_2 --><br /><span style="font-size: 80%;">{label_2}</span><!-- END label_2 -->
|
||||
</td>
|
||||
</tr>
|
||||
_HTML;
|
||||
|
||||
$renderer =& $form->defaultRenderer();
|
||||
$renderer->setElementTemplate($twoLabel, 'iadvChk');
|
||||
$renderer->setElementTemplate($twoLabel, 'iautoComp');
|
||||
|
||||
// Fills with some defaults values
|
||||
$form->setDefaults(array(
|
||||
'itxtTest' => 'Test Text Box',
|
||||
'itxaTest' => 'Hello World',
|
||||
'ichkTest' => true,
|
||||
'iradTest' => 1,
|
||||
'iselTest' => array('B', 'C'),
|
||||
'name' => array('first'=>'Adam', 'last'=>'Daniel'),
|
||||
'phoneNo' => array('513', '123', '3456'),
|
||||
'iradYesNo' => 'Y',
|
||||
'ichkABC' => array('A'=>true,'B'=>true),
|
||||
'dateTest1' => array('d'=>11, 'm'=>1, 'Y'=>2003)
|
||||
));
|
||||
|
||||
$form->setConstants(array(
|
||||
'dateTest3' => time()
|
||||
));
|
||||
|
||||
// Elements will be displayed in the order they are declared
|
||||
$form->addElement('header', '', 'Normal Elements');
|
||||
// Classic form elements
|
||||
$form->addElement('hidden', 'ihidTest', 'hiddenField');
|
||||
$form->addElement('text', 'itxtTest', 'Test Text:');
|
||||
$form->addElement('textarea', 'itxaTest', 'Test TextArea:', array('rows' => 3, 'cols' => 20));
|
||||
$form->addElement('password', 'ipwdTest', 'Test Password:');
|
||||
$form->addElement('checkbox', 'ichkTest', 'Test CheckBox:', 'Check the box');
|
||||
$form->addElement('radio', 'iradTest', 'Test Radio Buttons:', 'Check the radio button #1', 1);
|
||||
$form->addElement('radio', 'iradTest', '(Not a group)', 'Check the radio button #2', 2);
|
||||
$form->addElement('button', 'ibtnTest', 'Test Button', array('onclick' => "alert('This is a test');"));
|
||||
$form->addElement('reset', 'iresTest', 'Test Reset');
|
||||
$form->addElement('submit', 'isubTest', 'Test Submit');
|
||||
$form->addElement('image', 'iimgTest', 'http://pear.php.net/gifs/pear-icon.gif');
|
||||
$select =& $form->addElement('select', 'iselTest', 'Test Select:', array('A'=>'A', 'B'=>'B','C'=>'C','D'=>'D'));
|
||||
$select->setSize(5);
|
||||
$select->setMultiple(true);
|
||||
|
||||
$form->addElement('header', '', 'Custom Elements');
|
||||
// Date elements
|
||||
$form->addElement('date', 'dateTest1', 'Date1:', array('format'=>'dmY', 'minYear'=>2010, 'maxYear'=>2001));
|
||||
$form->addElement('date', 'dateTest2', 'Date2:', array('format'=>'d-F-Y H:i', 'language'=>'de', 'optionIncrement' => array('i' => 5)));
|
||||
$form->addElement('date', 'dateTest3', 'Today is:', array('format'=>'l d M Y'));
|
||||
|
||||
$main[0] = "Pop";
|
||||
$main[1] = "Rock";
|
||||
$main[2] = "Classical";
|
||||
|
||||
$secondary[0][0] = "Belle & Sebastian";
|
||||
$secondary[0][1] = "Elliot Smith";
|
||||
$secondary[0][2] = "Beck";
|
||||
$secondary[1][3] = "Noir Desir";
|
||||
$secondary[1][4] = "Violent Femmes";
|
||||
$secondary[2][5] = "Wagner";
|
||||
$secondary[2][6] = "Mozart";
|
||||
$secondary[2][7] = "Beethoven";
|
||||
|
||||
$opts[] = $main;
|
||||
$opts[] = $secondary;
|
||||
|
||||
$hs =& $form->addElement('hierselect', 'ihsTest', 'Hierarchical select:', array('style' => 'width: 20em;'), '<br />');
|
||||
$hs->setOptions($opts);
|
||||
|
||||
$form->addElement('advcheckbox', 'iadvChk', array('Advanced checkbox:', 'Unlike standard checkbox, this element <b>has</b> a value<br />when it is not checked.'), 'Check the box', null, array('off', 'on'));
|
||||
|
||||
$form->addElement('autocomplete', 'iautoComp', array('Your favourite fruit:', 'This is autocomplete element.<br />Start typing and see how it suggests possible completions.'), array('Pear', 'Orange', 'Apple'), array('size' => 30));
|
||||
|
||||
|
||||
$form->addElement('header', '', 'Grouped Elements');
|
||||
// Grouped elements
|
||||
$name['last'] = &HTML_QuickForm::createElement('text', 'last', null, array('size' => 30));
|
||||
$name['first'] = &HTML_QuickForm::createElement('text', 'first', null, array('size' => 20));
|
||||
$form->addGroup($name, 'name', 'Name (last, first):', ', ');
|
||||
// Creates a group of text inputs
|
||||
$areaCode = &HTML_QuickForm::createElement('text', '', null, array('size' => 3, 'maxlength' => 3));
|
||||
$phoneNo1 = &HTML_QuickForm::createElement('text', '', null, array('size' => 3, 'maxlength' => 3));
|
||||
$phoneNo2 = &HTML_QuickForm::createElement('text', '', null, array('size' => 4, 'maxlength' => 4));
|
||||
$form->addGroup(array($areaCode, $phoneNo1, $phoneNo2), 'phoneNo', 'Telephone:', '-');
|
||||
|
||||
// Creates a radio buttons group
|
||||
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'Yes', 'Y');
|
||||
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'No', 'N');
|
||||
$form->addGroup($radio, 'iradYesNo', 'Yes/No:');
|
||||
|
||||
// Creates a checkboxes group
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
|
||||
$form->addGroup($checkbox, 'ichkABC', 'ABC:', '<br />');
|
||||
// Creates a group of buttons to be displayed at the bottom of the form
|
||||
$buttons[] = &HTML_QuickForm::createElement('submit', null, 'Submit');
|
||||
$buttons[] = &HTML_QuickForm::createElement('reset', null, 'Reset');
|
||||
$buttons[] = &HTML_QuickForm::createElement('image', 'iimgTest', 'http://pear.php.net/gifs/pear-icon.gif');
|
||||
$buttons[] = &HTML_QuickForm::createElement('button', 'ibutTest', 'Test Button', array('onClick' => "alert('This is a test');"));
|
||||
$form->addGroup($buttons, null, null, ' ', false);
|
||||
|
||||
|
||||
// applies new filters to the element values
|
||||
$form->applyFilter('__ALL__', 'trim');
|
||||
// Adds some validation rules
|
||||
$form->addRule('itxtTest', 'Test Text is a required field', 'required');
|
||||
$form->addRule('itxaTest', 'Test TextArea is a required field', 'required');
|
||||
$form->addRule('itxaTest', 'Test TextArea must be at least 5 characters', 'minlength', 5);
|
||||
$form->addRule('ipwdTest', 'Password must be between 8 to 10 characters', 'rangelength', array(8, 10));
|
||||
|
||||
// Tries to validate the form
|
||||
if ($form->validate()) {
|
||||
// Form is validated, then processes the data
|
||||
$form->freeze();
|
||||
$form->process('myProcess', false);
|
||||
echo "\n<HR>\n";
|
||||
}
|
||||
|
||||
// Process callback
|
||||
function myProcess($values)
|
||||
{
|
||||
echo '<pre>';
|
||||
var_dump($values);
|
||||
echo '</pre>';
|
||||
}
|
||||
|
||||
$form->display();
|
||||
?>
|
|
@ -1,61 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Example of usage for PEAR class HTML_QuickForm.
|
||||
* Using filters to clean up the submitted values.
|
||||
*
|
||||
* @version 3.2
|
||||
*
|
||||
* $Id: filters.php,v 1.1 2003/11/21 16:52:48 avb Exp $
|
||||
*/
|
||||
|
||||
require_once 'HTML/QuickForm.php';
|
||||
|
||||
function _filterAustin($value)
|
||||
{
|
||||
return strtoupper($value).', GROOVY BABY!';
|
||||
}
|
||||
|
||||
$form =& new HTML_QuickForm('frmTest', 'get');
|
||||
|
||||
$form->addElement('text', 'txtTest', 'Test Text to trim:');
|
||||
$form->addRule('txtTest', 'Test text is required', 'required');
|
||||
|
||||
$phoneGrp[] =& $form->createElement('text', '', null, array('size' => 3, 'maxlength' => 3));
|
||||
$phoneGrp[] =& $form->createElement('text', '', null, array('size' => 3, 'maxlength' => 3));
|
||||
$phoneGrp[] =& $form->createElement('text', '', null, array('size' => 4, 'maxlength' => 4));
|
||||
$form->addGroup($phoneGrp, 'phone', 'Telephone (will be converted to numbers):', '-');
|
||||
$form->addGroupRule('phone', 'The phone is required', 'required', null, 3);
|
||||
|
||||
$form->addElement('text', 'txtAustin', 'Text for custom filter:');
|
||||
$form->addRule('txtAustin', 'Custom filter text is required', 'required');
|
||||
|
||||
$form->addElement('submit', 'isubTest', 'Submit');
|
||||
|
||||
// now we apply the filters
|
||||
$form->applyFilter('txtTest', 'trim');
|
||||
// the filter will be applied recursively
|
||||
$form->applyFilter('phone', 'intval');
|
||||
|
||||
if ($form->validate()) {
|
||||
// Here the filter is applied after validation
|
||||
$form->applyFilter('txtAustin', '_filterAustin');
|
||||
|
||||
echo "<pre>\n";
|
||||
echo "Values before filter:\n\n";
|
||||
var_dump($form->getElementValue('txtTest'));
|
||||
echo "\n";
|
||||
var_dump($form->getElementValue('phone'));
|
||||
echo "\n";
|
||||
var_dump($form->getElementValue('txtAustin'));
|
||||
|
||||
echo "\n\nValues after filter:\n\n";
|
||||
var_dump($form->exportValue('txtTest'));
|
||||
echo "\n";
|
||||
var_dump($form->exportValue('phone'));
|
||||
echo "\n";
|
||||
var_dump($form->exportValue('txtAustin'));
|
||||
echo "</pre>\n";
|
||||
}
|
||||
|
||||
$form->display();
|
||||
?>
|
|
@ -1,101 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Examples of usage for HTML_QuickForm: fancy validation with addFormRule()
|
||||
*
|
||||
* $Id: formrule.php,v 1.1 2003/12/20 21:05:32 avb Exp $
|
||||
*
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @version 3.2
|
||||
*/
|
||||
|
||||
require_once 'HTML/QuickForm.php';
|
||||
|
||||
function _validate_shipping($values)
|
||||
{
|
||||
// In Real Life (tm) you will probably query your DB for these
|
||||
$profiles = array('foo', 'bar', 'baz');
|
||||
$errors = array();
|
||||
switch ($values['profile']) {
|
||||
case 'personal':
|
||||
if (empty($values['persProfileName'])) {
|
||||
$errors['persProfileName'] = 'Enter the profile name';
|
||||
} elseif (in_array($values['persProfileName'], $profiles)) {
|
||||
$errors['persProfileName'] = 'The profile already exists';
|
||||
}
|
||||
if (empty($values['persName']['first']) || empty($values['persName']['last'])) {
|
||||
$errors['persName'] = 'Name is required';
|
||||
}
|
||||
if (empty($values['persAddress'])) {
|
||||
$errors['persAddress'] = 'Address is required';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'company':
|
||||
if (empty($values['compProfileName'])) {
|
||||
$errors['compProfileName'] = 'Enter the profile name';
|
||||
} elseif (in_array($values['compProfileName'], $profiles)) {
|
||||
$errors['compProfileName'] = 'The profile already exists';
|
||||
}
|
||||
if (empty($values['compName'])) {
|
||||
$errors['compName'] = 'Company name is required';
|
||||
}
|
||||
if (empty($values['compAddress'])) {
|
||||
$errors['compAddress'] = 'Address is required';
|
||||
}
|
||||
break;
|
||||
|
||||
case 'existing':
|
||||
default:
|
||||
if (empty($values['profileName'])) {
|
||||
$errors['profileName'] = 'Enter the profile name';
|
||||
} elseif (!in_array($values['profileName'], $profiles)) {
|
||||
$errors['profileName'] = 'The profile does not exist';
|
||||
}
|
||||
break;
|
||||
} // switch
|
||||
return empty($errors)? true: $errors;
|
||||
}
|
||||
|
||||
$form =& new HTML_QuickForm('frmFancy');
|
||||
$form->setDefaults(array(
|
||||
'profile' => 'existing',
|
||||
'stuffAmount' => '1'
|
||||
));
|
||||
$renderer =& $form->defaultRenderer();
|
||||
$renderer->setElementTemplate("\n\t<tr>\n\t\t<td style=\"white-space: nowrap; background-color: #F0F0F0;\" align=\"left\" valign=\"top\" colspan=\"2\"><b>{element}</b></td>\n\t</tr>", 'profile');
|
||||
|
||||
$form->addElement('header', null, 'Choose stuff');
|
||||
$form->addElement('select', 'stuffName', 'Stuff to send:', array('' => '--select--', 'n' => 'Nuts', 'b' => 'Bolts', 'f' => 'Flotsam', 'j' => 'Jetsam'));
|
||||
$form->addElement('text', 'stuffAmount', 'Amount of stuff:', array('size' => 2, 'maxlength' => 2));
|
||||
|
||||
|
||||
$form->addElement('header', null, 'Choose shipping profile');
|
||||
$form->addElement('static', 'note', 'Note:', 'profiles \'foo\', \'bar\' and \'baz\' are considered existing');
|
||||
|
||||
$form->addElement('radio', 'profile', null, 'Use existing profile', 'existing');
|
||||
$form->addElement('text', 'profileName', 'Profile name:', array('size' => 32, 'maxlength' => 32));
|
||||
|
||||
$form->addElement('radio', 'profile', null, 'New personal profile', 'personal');
|
||||
$form->addElement('text', 'persProfileName', 'Profile name:', array('size' => 32, 'maxlength' => 32));
|
||||
$name[] =& $form->createElement('text', 'first', null, array('size' => 14, 'maxlength' => 100));
|
||||
$name[] =& $form->createElement('text', 'last', null, array('size' => 14, 'maxlength' => 100));
|
||||
$form->addGroup($name, 'persName', 'Name (first, last):', ' ');
|
||||
$form->addElement('text', 'persAddress', 'Address:', array('size' => 32, 'maxlength' => 255));
|
||||
|
||||
$form->addElement('radio', 'profile', null, 'New company profile', 'company');
|
||||
$form->addElement('text', 'compProfileName', 'Profile name:', array('size' => 32, 'maxlength' => 32));
|
||||
$form->addElement('text', 'compName', 'Company name:', array('size' => 32, 'maxlength' => 100));
|
||||
$form->addElement('text', 'compAddress', 'Address:', array('size' => 32, 'maxlength' => 255));
|
||||
|
||||
$form->addElement('submit', null, 'Send');
|
||||
|
||||
$form->addFormRule('_validate_shipping');
|
||||
|
||||
if ($form->validate()) {
|
||||
echo "<pre>\n";
|
||||
var_dump($form->exportValues());
|
||||
echo "</pre>\n";
|
||||
}
|
||||
|
||||
$form->display();
|
||||
?>
|
|
@ -1,95 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Examples of usage for grouped elements in HTML_QuickForm
|
||||
*
|
||||
* $Id: groups.php,v 1.1 2003/12/20 21:05:32 avb Exp $
|
||||
*
|
||||
* @author Bertrand Mansion <bmansion@mamasam.com>
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
* @version 3.2
|
||||
*/
|
||||
|
||||
require_once 'HTML/QuickForm.php';
|
||||
|
||||
$form =& new HTML_QuickForm('frmGroups');
|
||||
$form->setDefaults(array(
|
||||
'id' => array('lastname' => 'Mamasam', 'code' => '1234'),
|
||||
'phoneNo' => array('513', '123', '3456'),
|
||||
'ichkABC' => array('A'=>true)
|
||||
));
|
||||
|
||||
$renderer =& $form->defaultRenderer();
|
||||
|
||||
// Setting templates for form and headers
|
||||
$renderer->setFormTemplate("<form{attributes}>\n<table width=\"450\" border=\"0\" cellpadding=\"3\" cellspacing=\"2\" bgcolor=\"#CCCC99\">\n{content}\n</table>\n</form>");
|
||||
$renderer->setHeaderTemplate("\t<tr>\n\t\t<td style=\"white-space:nowrap;background:#996;color:#ffc;\" align=\"left\" colspan=\"2\"><b>{header}</b></td>\n\t</tr>");
|
||||
|
||||
// Setting a special template for id element
|
||||
$renderer->setGroupTemplate('<table><tr>{content}</tr></table>', 'id');
|
||||
$renderer->setGroupElementTemplate('<td>{element}<br /><span style="font-size:10px;"><!-- BEGIN required --><span style="color: #f00">* </span><!-- END required --><span style="color:#996;">{label}</span></span></td>', 'id');
|
||||
|
||||
|
||||
$form->addElement('header', '', 'Tests on grouped elements');
|
||||
|
||||
// Creates a group of text inputs with templates
|
||||
$id['lastname'] = &HTML_QuickForm::createElement('text', 'lastname', 'Name', array('size' => 30));
|
||||
$id['code'] = &HTML_QuickForm::createElement('text', 'code', 'Code', array('size' => 5, 'maxlength' => 4));
|
||||
$form->addGroup($id, 'id', 'ID:', ', ');
|
||||
|
||||
// Add a complex rule for id element
|
||||
$form->addGroupRule('id', array(
|
||||
'lastname' => array(
|
||||
array('Name is required', 'required', null, 'client'),
|
||||
array('Name is letters only', 'lettersonly', null, 'client')
|
||||
),
|
||||
'code' => array(
|
||||
array('Code must be numeric', 'numeric', null, 'client')
|
||||
)
|
||||
));
|
||||
|
||||
|
||||
// Creates a group of text inputs
|
||||
$areaCode = &HTML_QuickForm::createElement('text', '', null, array('size' => 4, 'maxlength' => 3));
|
||||
$phoneNo1 = &HTML_QuickForm::createElement('text', '', null, array('size' => 4, 'maxlength' => 3));
|
||||
$phoneNo2 = &HTML_QuickForm::createElement('text', '', null, array('size' => 5, 'maxlength' => 4));
|
||||
$form->addGroup(array($areaCode, $phoneNo1, $phoneNo2), 'phoneNo', 'Telephone:', '-');
|
||||
|
||||
// Adds validation rules for groups
|
||||
$form->addGroupRule('phoneNo', 'Please fill all phone fields', 'required', null, 3, 'client');
|
||||
$form->addGroupRule('phoneNo', 'Values must be numeric', 'numeric', null, 3, 'client');
|
||||
|
||||
// Creates a checkboxes group using an array of separators
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
|
||||
$form->addGroup($checkbox, 'ichkABC', 'ABCD:', array(' ', '<br />'));
|
||||
|
||||
// At least one element is required
|
||||
$form->addGroupRule('ichkABC', 'Please check at least two boxes', 'required', null, 2, 'client', true);
|
||||
|
||||
// Creates a standard radio buttons group
|
||||
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'Yes', 'Y');
|
||||
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'No', 'N');
|
||||
$form->addGroup($radio, 'iradYesNo', 'Yes/No:');
|
||||
|
||||
// Validate the radio buttons
|
||||
$form->addRule('iradYesNo', 'Check Yes or No', 'required', null, 'client');
|
||||
|
||||
// Creates a group of buttons to be displayed at the bottom of the form
|
||||
$buttons[] =& $form->createElement('submit', null, 'Submit');
|
||||
$buttons[] =& $form->createElement('reset', null, 'Reset');
|
||||
$buttons[] =& $form->createElement('checkbox', 'clientSide', null, 'use client-side validation', array('checked' => 'checked', 'onclick' => "if (this.checked) {this.form.onsubmit = validate_" . $form->getAttribute('id') . ";} else {this.form.onsubmit = null;}"));
|
||||
$form->addGroup($buttons);
|
||||
|
||||
|
||||
// Tries to validate the form
|
||||
if ($form->validate()) {
|
||||
// Form is validated, then processes the data
|
||||
$form->freeze();
|
||||
$form->process('var_dump');
|
||||
echo "\n<HR>\n";
|
||||
}
|
||||
$form->display();
|
||||
|
||||
?>
|
|
@ -1,112 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Example of usage for HTML_QuickForm Object renderer
|
||||
* with Flexy template engine and dynamic template
|
||||
*
|
||||
* @author Ron McClain <mixtli@cats.ucsc.edu>
|
||||
*
|
||||
* $Id: FlexyDynamic_example.php,v 1.2 2003/11/03 12:55:53 avb Exp $
|
||||
*/
|
||||
|
||||
require_once 'HTML/QuickForm.php';
|
||||
require_once 'HTML/QuickForm/Renderer/Object.php';
|
||||
require_once 'HTML/Template/Flexy.php';
|
||||
|
||||
$form = new HTML_QuickForm('frmTest', 'post');
|
||||
|
||||
$form->setDefaults(array(
|
||||
'itxtTest' => 'Test Text Box',
|
||||
'itxaTest' => 'Hello World',
|
||||
'iselTest' => array('B', 'C'),
|
||||
'name' => array('first' => 'Thomas', 'last' => 'Schulz'),
|
||||
'iradYesNo' => 'Y',
|
||||
'ichkABCD' => array('A'=>true,'D'=>true)
|
||||
));
|
||||
|
||||
$form->addElement('header', '', 'Normal Elements');
|
||||
|
||||
$form->addElement('hidden', 'ihidTest', 'hiddenField');
|
||||
|
||||
$form->addElement('text', 'itxtTest', 'Test Text');
|
||||
|
||||
$form->addElement('textarea', 'itxaTest', 'Test TextArea');
|
||||
|
||||
// will be later assigned to style green
|
||||
$form->addElement('password', 'ipwdTest', array('Test Password', 'Please choose a password which is hard to guess'));
|
||||
$select =& $form->addElement('select', 'iselTest', 'Test Select', array('A'=>'A', 'B'=>'B','C'=>'C','D'=>'D'));
|
||||
$select->setSize(5);
|
||||
$select->setMultiple(true);
|
||||
|
||||
$form->addElement('submit', 'isubTest', 'Test Submit');
|
||||
|
||||
$form->addElement('header', '', 'Grouped Elements');
|
||||
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
|
||||
$form->addGroup($checkbox, 'ichkABCD', 'ABCD', '<br />');
|
||||
|
||||
// will be later assigned to style fancygroup
|
||||
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'Yes', 'Y');
|
||||
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'No', 'N');
|
||||
$form->addGroup($radio, 'iradYesNo', 'Yes/No');
|
||||
|
||||
// will be later assigned to style fancygroup
|
||||
$name['first'] = &HTML_QuickForm::createElement('text', 'first', 'First:');
|
||||
$name['first']->setSize(20);
|
||||
$name['last'] = &HTML_QuickForm::createElement('text', 'last', 'Last:');
|
||||
$name['last']->setSize(30);
|
||||
$form->addGroup($name, 'name', 'Name');
|
||||
|
||||
// add some 'required' rules to show "stars" and (possible) errors...
|
||||
$form->addRule('itxtTest', 'Test Text is a required field', 'required');
|
||||
$form->addRule('itxaTest', 'Test TextArea is a required field', 'required');
|
||||
$form->addGroupRule('iradYesNo', 'Check Yes or No', 'required');
|
||||
$form->addGroupRule('name', array('last' => array(array('Last name is required', 'required'))));
|
||||
|
||||
// try to validate the form
|
||||
if ($form->validate()) {
|
||||
$form->freeze();
|
||||
}
|
||||
|
||||
$renderer =& new HTML_QuickForm_Renderer_Object(true);
|
||||
|
||||
// give some elements aditional style informations
|
||||
$renderer->setElementStyle(array(
|
||||
'ipwdTest' => 'green',
|
||||
'iradYesNo' => 'fancygroup',
|
||||
'name' => 'fancygroup'
|
||||
));
|
||||
|
||||
$form->accept($renderer);
|
||||
|
||||
|
||||
$options = &PEAR::getStaticProperty('HTML_Template_Flexy','options');
|
||||
$options = array(
|
||||
'templateDir' => './templates',
|
||||
'compileDir' => './templates/build',
|
||||
'debug' => 0
|
||||
);
|
||||
$tpl =& new HTML_Template_Flexy($options);
|
||||
|
||||
//$tpl->compile("styles/green.html");
|
||||
//$tpl->compile("styles/fancygroup.html");
|
||||
|
||||
// assign array with form data
|
||||
$view = new StdClass;
|
||||
$view->form = $renderer->toObject();
|
||||
|
||||
// capture the array stucture
|
||||
// (only for showing in sample template)
|
||||
ob_start();
|
||||
print_r($renderer->toObject());
|
||||
$view->dynamic_object = ob_get_contents();
|
||||
// XXX: dunno how to make Flexy ignore the placeholder
|
||||
$view->formdata = '{formdata}';
|
||||
ob_end_clean();
|
||||
|
||||
// render and display the template
|
||||
$tpl->compile('flexy-dynamic.html');
|
||||
$tpl->outputObject($view);
|
||||
?>
|
|
@ -1,148 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Example of usage for HTML_QuickForm Object renderer
|
||||
* with Flexy template engine and static template
|
||||
*
|
||||
* @author Ron McClain <mixtli@cats.ucsc.edu>
|
||||
*
|
||||
* $Id: FlexyStatic_example.php,v 1.4 2004/06/24 19:23:10 ths Exp $
|
||||
*/
|
||||
|
||||
require_once('HTML/Template/Flexy.php');
|
||||
require_once('HTML/QuickForm.php');
|
||||
require_once('HTML/QuickForm/Renderer/ObjectFlexy.php');
|
||||
|
||||
function myProcess($values)
|
||||
{
|
||||
echo "<pre>";
|
||||
var_dump($values);
|
||||
echo "</pre>";
|
||||
}
|
||||
|
||||
$form = new HTML_QuickForm('form', 'POST');
|
||||
|
||||
// Fills with some defaults values
|
||||
|
||||
$defaultValues['company'] = 'Devils son in law';
|
||||
$defaultValues['country'] = array();
|
||||
$defaultValues['name'] = array('first'=>'Petey', 'last'=>'Wheatstraw');
|
||||
$defaultValues['phone'] = array('513', '123', '4567');
|
||||
$form->setDefaults($defaultValues);
|
||||
|
||||
// Hidden
|
||||
|
||||
$form->addElement('hidden', 'session', '1234567890');
|
||||
|
||||
// Personal information
|
||||
|
||||
$form->addElement('header', 'personal', 'Personal Information');
|
||||
|
||||
$form->addElement('hidden', 'ihidTest', 'hiddenField');
|
||||
$form->addElement('text', 'email', 'Your email:');
|
||||
$form->addElement('password', 'pass', 'Your password:', 'size=10');
|
||||
$name['last'] = &HTML_QuickForm::createElement('text', 'first', 'First',
|
||||
'size=10');
|
||||
$name['first'] = &HTML_QuickForm::createElement('text', 'last', 'Last',
|
||||
'size=10');
|
||||
$form->addGroup($name, 'name', 'Name:', ', ');
|
||||
$areaCode = &HTML_QuickForm::createElement('text', '', null,'size=4
|
||||
maxlength=3');
|
||||
$phoneNo1 = &HTML_QuickForm::createElement('text', '', null, 'size=4
|
||||
maxlength=3');
|
||||
$phoneNo2 = &HTML_QuickForm::createElement('text', '', null, 'size=5
|
||||
maxlength=4');
|
||||
$form->addGroup(array($areaCode, $phoneNo1, $phoneNo2), 'phone',
|
||||
'Telephone:', '-');
|
||||
|
||||
// Company information
|
||||
|
||||
$form->addElement('header', 'company_info', 'Company Information');
|
||||
|
||||
$form->addElement('text', 'company', 'Company:', 'size=20');
|
||||
|
||||
$str[] = &HTML_QuickForm::createElement('text', '', null, 'size=20');
|
||||
$str[] = &HTML_QuickForm::createElement('text', '', null, 'size=20');
|
||||
$form->addGroup($str, 'street', 'Street:', '<br />');
|
||||
|
||||
$addr['zip'] = &HTML_QuickForm::createElement('text', 'zip', 'Zip', 'size=6
|
||||
maxlength=10');
|
||||
$addr['city'] = &HTML_QuickForm::createElement('text', 'city', 'City',
|
||||
'size=15');
|
||||
$form->addGroup($addr, 'address', 'Zip, city:');
|
||||
|
||||
$select = array('' => 'Please select...', 'AU' => 'Australia', 'FR' =>
|
||||
'France', 'DE' => 'Germany', 'IT' => 'Italy');
|
||||
$form->addElement('select', 'country', 'Country:', $select);
|
||||
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
|
||||
$form->addGroup($checkbox, 'destination', 'Destination:', array(' ',
|
||||
'<br />'));
|
||||
|
||||
// Other elements
|
||||
|
||||
$form->addElement('checkbox', 'news', '', " Check this box if you don't want
|
||||
to receive our newsletter.");
|
||||
|
||||
$form->addElement('reset', 'reset', 'Reset');
|
||||
$form->addElement('submit', 'submit', 'Register');
|
||||
|
||||
// Adds some validation rules
|
||||
|
||||
$form->addRule('email', 'Email address is required', 'required');
|
||||
$form->addGroupRule('name', 'Name is required', 'required');
|
||||
$form->addRule('pass', 'Password must be between 8 to 10 characters',
|
||||
'rangelength', array(8, 10),'client');
|
||||
$form->addRule('country', 'Country is a required field', 'required');
|
||||
$form->addGroupRule('destination', 'Please check at least two boxes',
|
||||
'required', null, 2);
|
||||
$form->addGroupRule('phone', 'Please fill all phone fields', 'required');
|
||||
$form->addGroupRule('phone', 'Values must be numeric', 'numeric');
|
||||
|
||||
$AddrRules['zip'][0] = array('Zip code is required', 'required');
|
||||
$AddrRules['zip'][1] = array('Zip code is numeric only', 'numeric');
|
||||
$AddrRules['city'][0] = array('City is required', 'required');
|
||||
$AddrRules['city'][1] = array('City is letters only', 'lettersonly');
|
||||
$form->addGroupRule('address', $AddrRules);
|
||||
|
||||
// Tries to validate the form
|
||||
if ($form->validate()) {
|
||||
// Form is validated, then freezes the data
|
||||
$form->freeze();
|
||||
$form->process('myProcess', false);
|
||||
echo "\n<hr>\n";
|
||||
}
|
||||
|
||||
// setup a template object
|
||||
$options = &PEAR::getStaticProperty('HTML_Template_Flexy','options');
|
||||
$options = array(
|
||||
'templateDir' => './templates',
|
||||
'compileDir' => './templates/build',
|
||||
'forceCompile' => 1,
|
||||
'debug' => 0,
|
||||
'local' => 'en'
|
||||
);
|
||||
|
||||
$template = new HTML_Template_Flexy($options);
|
||||
|
||||
$renderer =& new HTML_QuickForm_Renderer_ObjectFlexy($template);
|
||||
$renderer->setLabelTemplate("label.html");
|
||||
$renderer->setHtmlTemplate("html.html");
|
||||
|
||||
$form->accept($renderer);
|
||||
|
||||
$view = new StdClass;
|
||||
$view->form = $renderer->toObject();
|
||||
|
||||
$template->compile("flexy-static.html");
|
||||
// capture the array stucture
|
||||
ob_start();
|
||||
print_r($view->form);
|
||||
$view->static_object = ob_get_contents();
|
||||
ob_end_clean();
|
||||
|
||||
// render and display the template
|
||||
$template->outputObject($view);
|
||||
?>
|
|
@ -1,96 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Example of usage for HTML_QuickForm with ITDynamic renderer
|
||||
*
|
||||
* @author Alexey Borzov <borz_off@cs.msu.su>
|
||||
*
|
||||
* $Id: ITDynamic_example.php,v 1.3 2003/09/09 10:46:51 avb Exp $
|
||||
*/
|
||||
|
||||
require_once 'HTML/QuickForm.php';
|
||||
require_once 'HTML/QuickForm/Renderer/ITDynamic.php';
|
||||
// can use either HTML_Template_Sigma or HTML_Template_ITX
|
||||
require_once 'HTML/Template/ITX.php';
|
||||
// require_once 'HTML/Template/Sigma.php';
|
||||
|
||||
$form = new HTML_QuickForm('frmTest', 'post');
|
||||
|
||||
$form->setDefaults(array(
|
||||
'itxtTest' => 'Test Text Box',
|
||||
'itxaTest' => 'Hello World',
|
||||
'iselTest' => array('B', 'C'),
|
||||
'name' => array('first' => 'Alexey', 'last' => 'Borzov'),
|
||||
'iradYesNo' => 'Y',
|
||||
'ichkABCD' => array('A'=>true,'D'=>true)
|
||||
));
|
||||
|
||||
$form->addElement('header', '', 'Normal Elements');
|
||||
|
||||
$form->addElement('hidden', 'ihidTest', 'hiddenField');
|
||||
// will be rendered in default qf_element block
|
||||
$form->addElement('text', 'itxtTest', 'Test Text:');
|
||||
// will be rendered in qf_textarea block, as it exists in template
|
||||
$form->addElement('textarea', 'itxaTest', 'Test TextArea:', array('rows' => 5, 'cols' => 40));
|
||||
// will be later assigned to qf_green, note that an array of labels is passed
|
||||
$form->addElement('password', 'ipwdTest', array('Test Password:', 'The password is expected to be long enough.'));
|
||||
$select =& $form->addElement('select', 'iselTest', 'Test Select:', array('A'=>'A', 'B'=>'B','C'=>'C','D'=>'D'));
|
||||
$select->setSize(5);
|
||||
$select->setMultiple(true);
|
||||
$form->addElement('submit', 'isubTest', 'Test Submit');
|
||||
|
||||
$form->addElement('header', '', 'Grouped Elements');
|
||||
|
||||
// will be rendered in default qf_group block
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
|
||||
$form->addGroup($checkbox, 'ichkABCD', 'ABCD:', array(' ', '<br />'));
|
||||
|
||||
// fancygroup candidates
|
||||
// will be rendered in qf_fancygroup_radio
|
||||
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'Yes', 'Y');
|
||||
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'No', 'N');
|
||||
$form->addGroup($radio, 'iradYesNo', 'Yes/No:');
|
||||
|
||||
// will be rendered in qf_fancygroup_element
|
||||
$name['first'] = &HTML_QuickForm::createElement('text', 'first', 'First:');
|
||||
$name['first']->setSize(20);
|
||||
$name['last'] = &HTML_QuickForm::createElement('text', 'last', 'Last:');
|
||||
$name['last']->setSize(30);
|
||||
$form->addGroup($name, 'name', 'Name');
|
||||
|
||||
// add some 'required' rules to show "stars" and (possible) errors...
|
||||
$form->addRule('itxtTest', 'Test Text is a required field', 'required');
|
||||
$form->addRule('itxaTest', 'Test TextArea is a required field', 'required');
|
||||
$form->addRule('iradYesNo', 'Check Yes or No', 'required');
|
||||
$form->addGroupRule('name', array('last' => array(array('Last name is required', 'required'))));
|
||||
|
||||
// try to validate the form
|
||||
if ($form->validate()) {
|
||||
$form->freeze();
|
||||
}
|
||||
|
||||
// create a template object and load the template file
|
||||
// can use either HTML_Template_Sigma or HTML_Template_ITX
|
||||
$tpl =& new HTML_Template_ITX('./templates');
|
||||
// $tpl =& new HTML_Template_Sigma('./templates');
|
||||
|
||||
$tpl->loadTemplateFile('it-dynamic.html', true, true);
|
||||
|
||||
// create a renderer
|
||||
$renderer =& new HTML_QuickForm_Renderer_ITDynamic($tpl);
|
||||
|
||||
// assign elements to blocks
|
||||
$renderer->setElementBlock(array(
|
||||
'ipwdTest' => 'qf_green',
|
||||
'iradYesNo' => 'qf_fancygroup',
|
||||
'name' => 'qf_fancygroup'
|
||||
));
|
||||
|
||||
// Black Magic :]
|
||||
$form->accept($renderer);
|
||||
|
||||
// display the results
|
||||
$tpl->show();
|
||||
?>
|
|
@ -1,119 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
*Example of usage for HTML_QuickForm with ITDynamic renderer (2-column layout)
|
||||
*
|
||||
* @author Adam Daniel <adaniel1@eesus.jnj.com>
|
||||
* @author Bertrand Mansion <bmansion@mamasam.com>
|
||||
* @author Alexey Borzov <borz_off@cs.msu.su>
|
||||
* @version 3.0
|
||||
*/
|
||||
require_once 'HTML/QuickForm.php';
|
||||
require_once 'HTML/QuickForm/Renderer/ITDynamic.php';
|
||||
// can use either HTML_Template_Sigma or HTML_Template_ITX
|
||||
require_once 'HTML/Template/ITX.php';
|
||||
//require_once 'HTML/Template/Sigma.php';
|
||||
|
||||
$form = new HTML_QuickForm('frmTest', 'POST');
|
||||
|
||||
// Fills with some defaults values
|
||||
$defaultValues['company'] = 'Mamasam';
|
||||
$defaultValues['country'] = array();
|
||||
$defaultValues['name'] = array('first'=>'Alexey', 'last'=>'Borzov');
|
||||
$defaultValues['phone'] = array('513', '123', '4567');
|
||||
$form->setDefaults($defaultValues);
|
||||
|
||||
// Hidden
|
||||
$form->addElement('hidden', 'session', '1234567890');
|
||||
$form->addElement('hidden', 'timer', '12345');
|
||||
$form->addElement('hidden', 'ihidTest', 'hiddenField');
|
||||
|
||||
// Personal information
|
||||
$form->addElement('header', 'personal_info', 'Personal Information');
|
||||
|
||||
$name['last'] = &HTML_QuickForm::createElement('text', 'first', 'First', 'size=10');
|
||||
$name['first'] = &HTML_QuickForm::createElement('text', 'last', 'Last', 'size=10');
|
||||
$form->addGroup($name, 'name', 'Name:', ', ');
|
||||
|
||||
$areaCode = &HTML_QuickForm::createElement('text', '', null,'size=4 maxlength=3');
|
||||
$phoneNo1 = &HTML_QuickForm::createElement('text', '', null, 'size=4 maxlength=3');
|
||||
$phoneNo2 = &HTML_QuickForm::createElement('text', '', null, 'size=5 maxlength=4');
|
||||
$form->addGroup(array($areaCode, $phoneNo1, $phoneNo2), 'phone', 'Telephone:', '-');
|
||||
|
||||
$form->addElement('text', 'email', 'Your email:');
|
||||
|
||||
$form->addElement('password', 'pass', 'Your password:', 'size=10');
|
||||
|
||||
// to finish the first column:
|
||||
$form->addElement('static', null, null, 'first column');
|
||||
|
||||
|
||||
// Company information
|
||||
$form->addElement('header', 'company_info', 'Company Information');
|
||||
|
||||
$form->addElement('text', 'company', 'Company:', 'size=20');
|
||||
|
||||
$str[] = &HTML_QuickForm::createElement('text', '', null, 'size=20');
|
||||
$str[] = &HTML_QuickForm::createElement('text', '', null, 'size=20');
|
||||
$form->addGroup($str, 'street', 'Street:', '<br />');
|
||||
|
||||
|
||||
$addr['zip'] = &HTML_QuickForm::createElement('text', 'zip', 'Zip', 'size=6 maxlength=10');
|
||||
$addr['city'] = &HTML_QuickForm::createElement('text', 'city', 'City', 'size=15');
|
||||
$form->addGroup($addr, 'address', 'Zip, city:');
|
||||
|
||||
$select = array('' => 'Please select...', 'AU' => 'Australia', 'FR' => 'France', 'DE' => 'Germany', 'IT' => 'Italy');
|
||||
$form->addElement('select', 'country', 'Country:', $select);
|
||||
|
||||
// Creates a checkboxes group using an array of separators
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
|
||||
$form->addGroup($checkbox, 'destination', 'Destination:', array(' ', '<br />'));
|
||||
|
||||
// to finish the second column:
|
||||
$form->addElement('static', null, null, 'second column');
|
||||
|
||||
// can't render these elements properly, so they are in the template
|
||||
//$form->addElement('reset', 'reset', 'Reset');
|
||||
//$form->addElement('submit', 'submit', 'Register');
|
||||
|
||||
// Adds some validation rules
|
||||
$form->addRule('email', 'Email address is required', 'required');
|
||||
$form->addGroupRule('name', 'Name is required', 'required');
|
||||
$form->addRule('pass', 'Password must be between 8 to 10 characters', 'rangelength', array(8, 10));
|
||||
$form->addRule('country', 'Country is a required field', 'required');
|
||||
$form->addGroupRule('destination', 'Please check at least two boxes', 'required', null, 2);
|
||||
$form->addGroupRule('phone', 'Please fill all phone fields', 'required');
|
||||
$form->addGroupRule('phone', 'Values must be numeric', 'numeric');
|
||||
|
||||
|
||||
$AddrRules['zip'][0] = array('Zip code is required', 'required');
|
||||
$AddrRules['zip'][1] = array('Zip code is numeric only', 'numeric');
|
||||
$AddrRules['city'][0] = array('City is required', 'required');
|
||||
$AddrRules['city'][1] = array('City is letters only', 'lettersonly');
|
||||
$form->addGroupRule('address', $AddrRules);
|
||||
|
||||
// Tries to validate the form
|
||||
if ($form->validate()) {
|
||||
// Form is validated, then freezes the data
|
||||
$form->freeze();
|
||||
}
|
||||
|
||||
|
||||
// can use either HTML_Template_Sigma or HTML_Template_ITX
|
||||
$tpl =& new HTML_Template_ITX('./templates');
|
||||
// $tpl =& new HTML_Template_Sigma('./templates');
|
||||
|
||||
$tpl->loadTemplateFile('it-dynamic-2.html');
|
||||
|
||||
$renderer =& new HTML_QuickForm_Renderer_ITDynamic($tpl);
|
||||
$renderer->setElementBlock(array(
|
||||
'name' => 'qf_group_table',
|
||||
'address' => 'qf_group_table'
|
||||
));
|
||||
|
||||
$form->accept($renderer);
|
||||
|
||||
$tpl->show();
|
||||
?>
|
|
@ -1,111 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Example of usage for PEAR class HTML_QuickForm
|
||||
*
|
||||
* @author Bertrand Mansion <bmansion@mamasam.com>
|
||||
* @version 2.0
|
||||
*/
|
||||
|
||||
// $Id: ITStatic_example.php,v 1.4 2004/10/02 09:54:41 ths Exp $
|
||||
|
||||
require_once('HTML/QuickForm.php');
|
||||
require_once('HTML/QuickForm/Renderer/ITStatic.php');
|
||||
require_once('HTML/Template/ITX.php');
|
||||
|
||||
|
||||
// Form name will be used to find the placeholders.
|
||||
|
||||
$form = new HTML_QuickForm('form', 'POST');
|
||||
|
||||
// Fills with some defaults values
|
||||
|
||||
$defaultValues['company'] = 'Mamasam';
|
||||
$defaultValues['country'] = array();
|
||||
$defaultValues['name'] = array('first'=>'Bertrand', 'last'=>'Mansion');
|
||||
$defaultValues['phone'] = array('513', '123', '4567');
|
||||
$form->setDefaults($defaultValues);
|
||||
|
||||
// Hidden
|
||||
|
||||
$form->addElement('hidden', 'session', '1234567890');
|
||||
|
||||
// Personal information
|
||||
|
||||
$form->addElement('header', 'personal', 'Personal Information');
|
||||
|
||||
$form->addElement('hidden', 'ihidTest', 'hiddenField');
|
||||
$form->addElement('text', 'email', 'Your email:');
|
||||
$form->addElement('password', 'pass', 'Your password:', 'size=10');
|
||||
$name['last'] = &HTML_QuickForm::createElement('text', 'first', 'First', 'size=10');
|
||||
$name['first'] = &HTML_QuickForm::createElement('text', 'last', 'Last', 'size=10');
|
||||
$form->addGroup($name, 'name', 'Name:', ', ');
|
||||
$areaCode = &HTML_QuickForm::createElement('text', '', null,'size=4 maxlength=3');
|
||||
$phoneNo1 = &HTML_QuickForm::createElement('text', '', null, 'size=4 maxlength=3');
|
||||
$phoneNo2 = &HTML_QuickForm::createElement('text', '', null, 'size=5 maxlength=4');
|
||||
$form->addGroup(array($areaCode, $phoneNo1, $phoneNo2), 'phone', 'Telephone:', '-');
|
||||
|
||||
// Company information
|
||||
|
||||
$form->addElement('header', 'company_info', 'Company Information');
|
||||
|
||||
$form->addElement('text', 'company', 'Company:', 'size=20');
|
||||
|
||||
$str[] = &HTML_QuickForm::createElement('text', '', null, 'size=20');
|
||||
$str[] = &HTML_QuickForm::createElement('text', '', null, 'size=20');
|
||||
$form->addGroup($str, 'street', 'Street:', '<br />');
|
||||
|
||||
$addr['zip'] = &HTML_QuickForm::createElement('text', 'zip', 'Zip', 'size=6 maxlength=10');
|
||||
$addr['city'] = &HTML_QuickForm::createElement('text', 'city', 'City', 'size=15');
|
||||
$form->addGroup($addr, 'address', 'Zip, city:');
|
||||
|
||||
$select = array('' => 'Please select...', 'AU' => 'Australia', 'FR' => 'France', 'DE' => 'Germany', 'IT' => 'Italy');
|
||||
$form->addElement('select', 'country', 'Country:', $select);
|
||||
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
|
||||
$form->addGroup($checkbox, 'destination', 'Destination:', array(' ', '<br />'));
|
||||
|
||||
// Other elements
|
||||
|
||||
$form->addElement('checkbox', 'news', '', " Check this box if you don't want to receive our newsletter.");
|
||||
|
||||
$form->addElement('reset', 'reset', 'Reset');
|
||||
$form->addElement('submit', 'submit', 'Register');
|
||||
|
||||
// Adds some validation rules
|
||||
|
||||
$form->addRule('email', 'Email address is required', 'required');
|
||||
$form->addGroupRule('name', 'Name is required', 'required');
|
||||
$form->addRule('pass', 'Password must be between 8 to 10 characters', 'rangelength', array(8, 10));
|
||||
$form->addRule('country', 'Country is a required field', 'required');
|
||||
$form->addGroupRule('destination', 'Please check at least two boxes', 'required', null, 2);
|
||||
$form->addGroupRule('phone', 'Please fill all phone fields', 'required');
|
||||
$form->addGroupRule('phone', 'Values must be numeric', 'numeric');
|
||||
|
||||
$AddrRules['zip'][0] = array('Zip code is required', 'required');
|
||||
$AddrRules['zip'][1] = array('Zip code is numeric only', 'numeric');
|
||||
$AddrRules['city'][0] = array('City is required', 'required');
|
||||
$AddrRules['city'][1] = array('City is letters only', 'lettersonly');
|
||||
$form->addGroupRule('address', $AddrRules);
|
||||
|
||||
// Tries to validate the form
|
||||
if ($form->validate()) {
|
||||
// Form is validated, then freezes the data
|
||||
$form->freeze();
|
||||
}
|
||||
|
||||
// Could be HTML_Template_Sigma('./templates')
|
||||
$tpl =& new HTML_Template_ITX('./templates');
|
||||
$tpl->loadTemplateFile('it-static.html');
|
||||
|
||||
$renderer =& new HTML_QuickForm_Renderer_ITStatic($tpl);
|
||||
$renderer->setRequiredTemplate('{label}<font color="red" size="1">*</font>');
|
||||
$renderer->setErrorTemplate('<font color="orange" size="1">{error}</font><br />{html}');
|
||||
|
||||
$form->accept($renderer);
|
||||
|
||||
$tpl->show();
|
||||
|
||||
?>
|
|
@ -1,146 +0,0 @@
|
|||
<?php /** $Id: QuickHtml_example.php,v 1.1 2003/08/25 16:41:02 jrust Exp $ */ ?>
|
||||
<html>
|
||||
<title>QuickForm Using QuickHtml Renderer</title>
|
||||
<body>
|
||||
<?php
|
||||
/**
|
||||
* Another example of usage for PEAR class HTML_QuickForm using the
|
||||
* QuickHtml renderer.
|
||||
*
|
||||
* This renderer has three main distinctives: an easy way to create
|
||||
* custom-looking forms, the ability to separate the creation of form
|
||||
* elements from their display, and being able to use QuickForm in
|
||||
* widget-based template systems. See the online documentation for more
|
||||
* info.
|
||||
*
|
||||
* @author Jason Rust <jrust@rustyparts.com>
|
||||
*/
|
||||
|
||||
require_once ("HTML/QuickForm.php");
|
||||
require_once ("HTML/QuickForm/Renderer/QuickHtml.php");
|
||||
$form =& new HTML_QuickForm('tmp_form','POST');
|
||||
// get our render
|
||||
$renderer =& new HTML_QuickForm_Renderer_QuickHtml();
|
||||
// create the elements
|
||||
createElements($form);
|
||||
// set their values
|
||||
setValues($form);
|
||||
|
||||
// Do the magic of creating the form. NOTE: order is important here: this must
|
||||
// be called after creating the form elements, but before rendering them.
|
||||
$form->accept($renderer);
|
||||
|
||||
// Because radio buttons have the same name we have to pass the value
|
||||
// as well as the name in order to get the correct one.
|
||||
$tmp_radio = ' Yes: ' . $renderer->elementToHtml('tmp_radio', 'Y');
|
||||
$tmp_radio .= ' No: ' . $renderer->elementToHtml('tmp_radio', 'N');
|
||||
|
||||
$tmp_submit = $renderer->elementToHtml('tmp_reset');
|
||||
$tmp_submit .= $renderer->elementToHtml('tmp_submit');
|
||||
|
||||
// Make our form table using some of the widget functions.
|
||||
$data = '
|
||||
<table border="0" cellpadding="0" cellspacing="2" bgcolor="#eeeeee" width="500">
|
||||
<tr style="font-weight: bold;">' . createHeaderCell('QuickForm using QuickHtml Renderer', 'center', 2) . '</tr>
|
||||
<tr>' . createFormCell($renderer->elementToHtml('tmp_textarea'), 'center', 2) . '</tr>
|
||||
<tr>' . createHeaderCell('Text box (element is part of an array)', 'left') .
|
||||
createHeaderCell('Yes or no?', 'right') . '</tr>
|
||||
<tr>' . createFormCell($renderer->elementToHtml('tmp_text[array]'), 'left') .
|
||||
createFormCell($tmp_radio, 'right') . '</tr>
|
||||
<tr>' . createHeaderCell('Phone Number (a group)', 'left') .
|
||||
createHeaderCell('Advanced Check Box?', 'right') . '</tr>
|
||||
<tr>' . createFormCell($renderer->elementToHtml('phone_num'), 'left') .
|
||||
createFormCell($renderer->elementToHtml('tmp_checkbox'), 'right') . '</tr>
|
||||
<tr>' . createHeaderCell('Today is:', 'left') .
|
||||
createHeaderCell('Multiple Select', 'right') . '</tr>
|
||||
<tr>' . createFormCell($renderer->elementToHtml('tmp_date'), 'left') .
|
||||
createFormCell($renderer->elementToHtml('tmp_multipleSelect[0]'), 'right') . '</tr>
|
||||
<tr>' . createFormCell($tmp_submit, 'center', 2) . '</tr>
|
||||
</table>';
|
||||
|
||||
// Wrap the form and any remaining elements (i.e. hidden elements) into the form tags.
|
||||
echo $renderer->toHtml($data);
|
||||
|
||||
echo "\n<HR> <b>Submitted Values: </b><br />\n";
|
||||
echo "<pre>";
|
||||
print_r($_POST);
|
||||
// {{{ createElements()
|
||||
|
||||
// creates all the fields for the form
|
||||
function createElements(&$form)
|
||||
{
|
||||
// select list array
|
||||
$selectListArray = array(
|
||||
'windows' => 'Windows',
|
||||
'linux' => 'Linux',
|
||||
'irix' => 'Irix',
|
||||
'mac' => 'Mac',
|
||||
);
|
||||
|
||||
$form->addElement('text','tmp_text[array]',null,array('size' => 10));
|
||||
$form->addElement('hidden','tmp_hidden', 'value');
|
||||
$form->addElement('textarea','tmp_textarea',null,array('cols' => 50, 'rows' => 10, 'wrap' => 'virtual'));
|
||||
$form->addElement('radio','tmp_radio',null,null,'Y');
|
||||
$form->addElement('radio','tmp_radio',null,null,'N');
|
||||
$text = array();
|
||||
$text[] =& HTML_QuickForm::createElement('text','',null,array('size' => 3));
|
||||
$text[] =& HTML_QuickForm::createElement('text','',null,array('size' => 4));
|
||||
$text[] =& HTML_QuickForm::createElement('text','',null,array('size' => 3));
|
||||
$form->addGroup($text, 'phone_num', null, '-');
|
||||
$form->addElement('advcheckbox','tmp_checkbox',null,'Please Check',null,array('not checked', 'checked'));
|
||||
$form->addElement('date', 'tmp_date', null, array('format'=>'D d M Y'));
|
||||
$form->addElement('select', 'tmp_multipleSelect[0]', null, $selectListArray, array('multiple' => 'multiple', 'size' => 4));
|
||||
$form->addElement('reset','tmp_reset','Reset Form');
|
||||
$form->addElement('submit','tmp_submit','Submit Form');
|
||||
$form->addRule('tmp_text[array]','Text length must be greater than 10','minlength',10,'client');
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ setValues()
|
||||
|
||||
// sets all the default and constant values for the form
|
||||
function setValues(&$form)
|
||||
{
|
||||
// Fills with some defaults values
|
||||
$defaultValues['tmp_textarea'] = '
|
||||
Test Text Area
|
||||
|
||||
With line breaks';
|
||||
$defaultValues['phone_num'] = array('513', '123', '3456');
|
||||
$defaultValues['tmp_checkbox'] = 'checked';
|
||||
$defaultValues['tmp_multipleSelect'][0] = array('linux', 'mac');
|
||||
// Fill with some constant values.
|
||||
// Constant is not overridden by POST, GET, or defaultValues
|
||||
// when values are being filled in
|
||||
$constantValues['tmp_radio'] = 'Y';
|
||||
$constantValues['tmp_date'] = time();
|
||||
$constantValues['tmp_text']['array'] = 'constant';
|
||||
|
||||
$form->setDefaults($defaultValues);
|
||||
$form->setConstants($constantValues);
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ createHeaderCell()
|
||||
|
||||
// creates a header cell
|
||||
function createHeaderCell($text, $align, $colspan = 1)
|
||||
{
|
||||
return '<td align="' . $align . '" width="50%" bgcolor="#cccccc" colspan="' . $colspan . '">' . $text . '</td>';
|
||||
}
|
||||
|
||||
// }}}
|
||||
// {{{ createFormCell()
|
||||
|
||||
// creates a form cell based on the element name
|
||||
function createFormCell($elementHtml, $align, $colspan = 1)
|
||||
{
|
||||
return '<td align="' . $align . '" width="50%" colspan="' . $colspan . '">' .
|
||||
$elementHtml .
|
||||
'</td>';
|
||||
}
|
||||
|
||||
// }}}
|
||||
?>
|
||||
</body>
|
||||
</html>
|
|
@ -1,108 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Example of usage for HTML_QuickForm Array renderer with Smarty template engine
|
||||
*
|
||||
* @author Thomas Schulz <ths@4bconsult.de>
|
||||
* @author Alexey Borzov <borz_off@cs.msu.su>
|
||||
*
|
||||
* $Id: SmartyDynamic_example.php,v 1.4 2004/10/15 20:31:00 ths Exp $
|
||||
*/
|
||||
|
||||
require_once 'HTML/QuickForm.php';
|
||||
require_once 'HTML/QuickForm/Renderer/Array.php';
|
||||
// fix this if your Smarty is somewhere else
|
||||
require_once 'Smarty.class.php';
|
||||
|
||||
$form = new HTML_QuickForm('frmTest', 'post');
|
||||
|
||||
$form->setDefaults(array(
|
||||
'itxtTest' => 'Test Text Box',
|
||||
'itxaTest' => 'Hello World',
|
||||
'iselTest' => array('B', 'C'),
|
||||
'name' => array('first' => 'Thomas', 'last' => 'Schulz'),
|
||||
'iradYesNo' => 'Y',
|
||||
'ichkABCD' => array('A'=>true,'D'=>true)
|
||||
));
|
||||
|
||||
$form->addElement('header', '', 'Normal Elements');
|
||||
|
||||
$form->addElement('hidden', 'ihidTest', 'hiddenField');
|
||||
|
||||
$form->addElement('text', 'itxtTest', array('Test Text', 'note' => 'Note for Testtext element.'));
|
||||
|
||||
$form->addElement('textarea', 'itxaTest', 'Test TextArea', 'cols="40" rows="2"');
|
||||
|
||||
// will be later assigned to style green
|
||||
$form->addElement('password', 'ipwdTest', 'Test Password');
|
||||
$select =& $form->addElement(
|
||||
'select',
|
||||
'iselTest',
|
||||
array('Test Select', 'note' => 'We recommend to check at least two categories!'),
|
||||
array('A'=>'A * * * * (luxory)', 'B'=>'B * * *','C'=>'C * *','D'=>'D * (simple)')
|
||||
);
|
||||
$select->setSize(4);
|
||||
$select->setMultiple(true);
|
||||
|
||||
$form->addElement('submit', 'isubTest', 'Test Submit');
|
||||
|
||||
$form->addElement('header', '', 'Grouped Elements');
|
||||
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
|
||||
$form->addGroup($checkbox, 'ichkABCD', 'ABCD', array(' ', '<br />'));
|
||||
|
||||
// will be later assigned to style fancygroup
|
||||
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'Yes', 'Y');
|
||||
$radio[] = &HTML_QuickForm::createElement('radio', null, null, 'No', 'N');
|
||||
$form->addGroup($radio, 'iradYesNo', 'Yes/No');
|
||||
|
||||
// will be later assigned to style fancygroup
|
||||
$name['first'] = &HTML_QuickForm::createElement('text', 'first', 'First:');
|
||||
$name['first']->setSize(20);
|
||||
$name['last'] = &HTML_QuickForm::createElement('text', 'last', 'Last:');
|
||||
$name['last']->setSize(30);
|
||||
$form->addGroup($name, 'name', 'Name');
|
||||
|
||||
// add some 'required' rules to show "stars" and (possible) errors...
|
||||
$form->addRule('itxtTest', 'Test Text is a required field', 'required');
|
||||
$form->addRule('itxaTest', 'Test TextArea is a required field', 'required');
|
||||
$form->addGroupRule('iradYesNo', 'Check Yes or No', 'required');
|
||||
$form->addGroupRule('name', array('last' => array(array('Last name is required', 'required'))));
|
||||
|
||||
// try to validate the form
|
||||
if ($form->validate()) {
|
||||
$form->freeze();
|
||||
}
|
||||
|
||||
$renderer =& new HTML_QuickForm_Renderer_Array(true, true);
|
||||
|
||||
// give some elements aditional style informations
|
||||
$renderer->setElementStyle(array(
|
||||
'ipwdTest' => 'green',
|
||||
'iradYesNo' => 'fancygroup',
|
||||
'name' => 'fancygroup'
|
||||
));
|
||||
|
||||
$form->accept($renderer);
|
||||
|
||||
// setup a template object
|
||||
$tpl =& new Smarty;
|
||||
$tpl->template_dir = './templates';
|
||||
$tpl->compile_dir = './templates';
|
||||
|
||||
// assign array with form data
|
||||
$tpl->assign('form', $renderer->toArray());
|
||||
|
||||
// capture the array stucture
|
||||
// (only for showing in sample template)
|
||||
ob_start();
|
||||
print_r($renderer->toArray());
|
||||
$tpl->assign('dynamic_array', ob_get_contents());
|
||||
ob_end_clean();
|
||||
|
||||
// render and display the template
|
||||
$tpl->display('smarty-dynamic.tpl');
|
||||
|
||||
?>
|
|
@ -1,137 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Example of usage for HTML_QuickForm with Smarty renderer
|
||||
*
|
||||
* @author Bertrand Mansion <bmansion@mamasam.com>
|
||||
* @author Thomas Schulz <ths@4bconsult.de>
|
||||
*
|
||||
* $Id: SmartyStatic_example.php,v 1.4 2004/10/15 20:31:00 ths Exp $
|
||||
*/
|
||||
|
||||
require_once 'HTML/QuickForm.php';
|
||||
require_once 'HTML/QuickForm/Renderer/ArraySmarty.php';
|
||||
// fix this if your Smarty is somewhere else
|
||||
require_once 'Smarty.class.php';
|
||||
|
||||
// Form name will be used to find the placeholders.
|
||||
|
||||
$form = new HTML_QuickForm('form', 'POST');
|
||||
|
||||
// Fills with some defaults values
|
||||
|
||||
$defaultValues['company'] = 'Mamasam';
|
||||
$defaultValues['country'] = array();
|
||||
$defaultValues['name'] = array('first'=>'Bertrand', 'last'=>'Mansion');
|
||||
$defaultValues['phone'] = array('513', '123', '4567');
|
||||
$form->setDefaults($defaultValues);
|
||||
|
||||
// Hidden
|
||||
|
||||
$form->addElement('hidden', 'session', '1234567890');
|
||||
|
||||
// Personal information
|
||||
|
||||
$form->addElement('header', 'personal', 'Personal Information');
|
||||
|
||||
$form->addElement('hidden', 'ihidTest', 'hiddenField');
|
||||
$form->addElement('text', 'email', 'Your email:');
|
||||
$form->addElement('password', 'pass', array('Your password:', 'note'=>'Please, choose a 8-10 characters password.'), 'size=10');
|
||||
$name['last'] = &HTML_QuickForm::createElement('text', 'first', 'First', 'size=10');
|
||||
$name['first'] = &HTML_QuickForm::createElement('text', 'last', 'Last', 'size=10');
|
||||
$form->addGroup($name, 'name', 'Name:', ', ');
|
||||
$areaCode = &HTML_QuickForm::createElement('text', '', null,'size=4 maxlength=3');
|
||||
$phoneNo1 = &HTML_QuickForm::createElement('text', '', null, 'size=4 maxlength=3');
|
||||
$phoneNo2 = &HTML_QuickForm::createElement('text', '', null, 'size=5 maxlength=4');
|
||||
$form->addGroup(array($areaCode, $phoneNo1, $phoneNo2), 'phone', 'Telephone:', '-');
|
||||
|
||||
// Company information
|
||||
|
||||
$form->addElement('header', 'company_info', 'Company Information');
|
||||
|
||||
$form->addElement('text', 'company', 'Company:', 'size=20');
|
||||
|
||||
$str[] = &HTML_QuickForm::createElement('text', '', null, 'size=20');
|
||||
$str[] = &HTML_QuickForm::createElement('text', '', null, 'size=20');
|
||||
$form->addGroup($str, 'street', 'Street:', '<br />');
|
||||
|
||||
$addr['zip'] = &HTML_QuickForm::createElement('text', 'zip', 'Zip', 'size=6 maxlength=10');
|
||||
$addr['city'] = &HTML_QuickForm::createElement('text', 'city', 'City', 'size=15');
|
||||
$form->addGroup($addr, 'address', 'Zip, city:');
|
||||
|
||||
$select = array('' => 'Please select...', 'AU' => 'Australia', 'FR' => 'France', 'DE' => 'Germany', 'IT' => 'Italy');
|
||||
$form->addElement('select', 'country', 'Country:', $select);
|
||||
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'A', null, 'A');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'B', null, 'B');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'C', null, 'C');
|
||||
$checkbox[] = &HTML_QuickForm::createElement('checkbox', 'D', null, 'D');
|
||||
$form->addGroup($checkbox, 'destination', 'Destination:', array(' ', '<br />'));
|
||||
|
||||
// Other elements
|
||||
|
||||
$form->addElement('checkbox', 'news', '', " Check this box if you don't want to receive our newsletter.");
|
||||
|
||||
$form->addElement('reset', 'reset', 'Reset');
|
||||
$form->addElement('submit', 'submit', 'Register');
|
||||
|
||||
// Adds some validation rules
|
||||
|
||||
$form->addRule('email', 'Email address is required', 'required');
|
||||
$form->addGroupRule('name', 'Name is required', 'required');
|
||||
$form->addRule('pass', 'Password must be between 8 to 10 characters', 'rangelength', array(8, 10));
|
||||
$form->addRule('country', 'Country is a required field', 'required');
|
||||
$form->addGroupRule('destination', 'Please check at least two boxes', 'required', null, 2);
|
||||
$form->addGroupRule('phone', 'Please fill all phone fields', 'required');
|
||||
$form->addGroupRule('phone', 'Values must be numeric', 'numeric');
|
||||
|
||||
$AddrRules['zip'][0] = array('Zip code is required', 'required');
|
||||
$AddrRules['zip'][1] = array('Zip code is numeric only', 'numeric');
|
||||
$AddrRules['city'][0] = array('City is required', 'required');
|
||||
$AddrRules['city'][1] = array('City is letters only', 'lettersonly');
|
||||
$form->addGroupRule('address', $AddrRules);
|
||||
|
||||
// Tries to validate the form
|
||||
if ($form->validate()) {
|
||||
// Form is validated, then freezes the data
|
||||
$form->freeze();
|
||||
}
|
||||
|
||||
// setup a template object
|
||||
$tpl =& new Smarty;
|
||||
$tpl->template_dir = './templates';
|
||||
$tpl->compile_dir = './templates';
|
||||
|
||||
$renderer =& new HTML_QuickForm_Renderer_ArraySmarty($tpl, true);
|
||||
|
||||
$renderer->setRequiredTemplate(
|
||||
'{if $error}
|
||||
<font color="red">{$label|upper}</font>
|
||||
{else}
|
||||
{$label}
|
||||
{if $required}
|
||||
<font color="red" size="1">*</font>
|
||||
{/if}
|
||||
{/if}'
|
||||
);
|
||||
|
||||
$renderer->setErrorTemplate(
|
||||
'{if $error}
|
||||
<font color="orange" size="1">{$error}</font><br />
|
||||
{/if}{$html}'
|
||||
);
|
||||
|
||||
$form->accept($renderer);
|
||||
|
||||
// assign array with form data
|
||||
$tpl->assign('form', $renderer->toArray());
|
||||
|
||||
// capture the array stucture
|
||||
ob_start();
|
||||
print_r($renderer->toArray());
|
||||
$tpl->assign('static_array', ob_get_contents());
|
||||
ob_end_clean();
|
||||
|
||||
// render and display the template
|
||||
$tpl->display('smarty-static.tpl');
|
||||
|
||||
?>
|
|
@ -1,46 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Example of usage for QuickForm elements with multiple labels (using Default renderer)
|
||||
*
|
||||
* @author Jon Wood <jon@jellybob.co.uk>
|
||||
*
|
||||
* $Id: multiple-labels.php,v 1.1 2004/03/06 12:03:50 avb Exp $
|
||||
*/
|
||||
|
||||
require_once 'HTML/QuickForm.php';
|
||||
|
||||
$template =
|
||||
'<tr>
|
||||
<td align="right" valign="top">
|
||||
<!-- BEGIN required --><font color="red">*</font><!-- END required -->
|
||||
<b>{label}</b>
|
||||
</td>
|
||||
<td nowrap="nowrap" valign="top" align="left">
|
||||
{element}
|
||||
<!-- BEGIN error --><br/><font color="red">{error}</font><br/><!-- END error -->
|
||||
<!-- BEGIN label_2 --><br/><font size="-1">{label_2}</font><!-- END label_2 -->
|
||||
</td>
|
||||
</tr>';
|
||||
|
||||
// Create the form, and add a header to it.
|
||||
$form = new HTML_QuickForm('labels_example', 'post');
|
||||
$form->addHeader('QuickForm Labels Example');
|
||||
|
||||
// Do the magic! Just pass your label to the element as an array!
|
||||
$form->addElement('text', 'name', array('Name', 'The name that you would like to enter in this element.'));
|
||||
$form->addElement('checkbox', 'check', array('Check Me!', 'If you check this box, it will have tick in it.'));
|
||||
|
||||
// More boring stuff.
|
||||
$form->addElement('submit', null, 'Submit');
|
||||
|
||||
if ($form->validate()) {
|
||||
$form->freeze();
|
||||
}
|
||||
|
||||
// customize the element template
|
||||
$renderer =& $form->defaultRenderer();
|
||||
$renderer->setElementTemplate($template);
|
||||
|
||||
// output the form
|
||||
$form->display();
|
||||
?>
|
|
@ -1,129 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<!-- Id: flexy-dynamic.html,v 1.3 2003/05/21 13:27:59 avb Exp -->
|
||||
<html>
|
||||
<head>
|
||||
<title>Flexy template for Object renderer</title>
|
||||
<style type="text/css">
|
||||
body, td, th {
|
||||
font-family: sans-serif;
|
||||
color: Navy;
|
||||
background-color: #EEE;
|
||||
font-size: smaller;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.maintable {
|
||||
border: thin dashed #D0D0D0;
|
||||
background-color: #EEE;
|
||||
}
|
||||
|
||||
.header {
|
||||
color: #FFF;
|
||||
background-color: #999;
|
||||
}
|
||||
|
||||
.green {
|
||||
background-color : #CFC;
|
||||
color: black;
|
||||
}
|
||||
.error {
|
||||
color: red;
|
||||
}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
{form.javascript:h}
|
||||
|
||||
{form.outputHeader():h}
|
||||
<table border="0" class="maintable" align="center">
|
||||
{form.outputHeader():h}
|
||||
{form.hidden:h}
|
||||
|
||||
{foreach:form.sections,sec}
|
||||
<tr>
|
||||
<td class="header" colspan="2">
|
||||
<b>{sec.header}</b></td>
|
||||
</tr>
|
||||
|
||||
{foreach:sec.elements,elem}
|
||||
{if:elem.style}
|
||||
{elem.outputStyle():h}
|
||||
{else:}
|
||||
{if:elem.isButton()}
|
||||
{if:elem.notFrozen()}
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td align="left">{elem.html:h}</td>
|
||||
</tr>
|
||||
{end:}
|
||||
{else:}
|
||||
<tr>
|
||||
{if:elem.isType(#textarea#)}
|
||||
<td colspan="2">
|
||||
{if:elem.required}<span class="error">*</span>{end:}
|
||||
{if:elem.error}<span class="error">{end:}
|
||||
<b>{elem.label:h}:</b><br />
|
||||
{if:elem.error}</span>{end:}
|
||||
{else:}
|
||||
<td align="right" valign="top">
|
||||
{if:elem.required}<span class="error">*</span>{end:}
|
||||
{if:elem.error}<span class="error">{end:}
|
||||
<b>{elem.label:h}:</b>
|
||||
{if:elem.error}</span>{end:}
|
||||
</td>
|
||||
<td>
|
||||
{end:}
|
||||
{if:elem.error}<div class="error">{elem.error}</div>{end:}
|
||||
{if:elem.isType(#group#)}
|
||||
{foreach:elem.elements,gitem}
|
||||
{gitem.label:h}
|
||||
{gitem.html:h}{if:gitem.required}<span class="error">*</span>*</span>{end:}
|
||||
{if:elem.separator}{elem.separator:h}{end:}
|
||||
{end:}
|
||||
{else:}
|
||||
{elem.html:h}
|
||||
{end:}
|
||||
</td>
|
||||
</tr>
|
||||
{end:}
|
||||
{end:}
|
||||
{end:}
|
||||
{end:}
|
||||
{if:form.requirednote}
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td valign="top">{form.requirednote:h}</td>
|
||||
</tr>
|
||||
{end:}
|
||||
|
||||
</form>
|
||||
</table>
|
||||
|
||||
|
||||
<p><b>Collected Errors:</b><br />
|
||||
{foreach:form.errors,name,error}
|
||||
<span class="error">{error:h}</span> in element [{name:h}]<br />
|
||||
{end:}
|
||||
</p>
|
||||
|
||||
|
||||
<p><strong>Best Practice: </strong><br />
|
||||
Use only one dynamic form template like this for your <br />
|
||||
Flexy driven project. You include this where <br />
|
||||
to place a form with the formdata object rendered by <br />
|
||||
Object QuickForm Renderer as option:</p>
|
||||
|
||||
<pre style="font-size: 12px;">
|
||||
<strong><include file=form-dynamic.tpl form={formdata}></strong>
|
||||
</pre>
|
||||
|
||||
|
||||
<p><strong>The used "Dynamic" Object </strong></p>
|
||||
<pre style="font-size: 12px;">
|
||||
{dynamic_object}
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,154 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<!-- $Id: flexy-static.html,v 1.1 2003/08/05 09:34:48 mansion Exp $ -->
|
||||
<html>
|
||||
<head>
|
||||
<title>Flexy template : 2 column layout example</title>
|
||||
<style type="text/css">
|
||||
.errors {
|
||||
font-family: sans-serif;
|
||||
color : #000;
|
||||
background-color : #FFF;
|
||||
font-size : 12pt;
|
||||
}
|
||||
.label {
|
||||
font-family: sans-serif;
|
||||
color : Navy;
|
||||
font-size : 11px;
|
||||
text-align : right;
|
||||
vertical-align : top;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.element {
|
||||
font-family: sans-serif;
|
||||
background-color : #EEE;
|
||||
text-align : left;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.note {
|
||||
font-family: sans-serif;
|
||||
background-color : #EEE;
|
||||
text-align : center;
|
||||
font-size : 10pt;
|
||||
color : AAA;
|
||||
white-space: nowrap;
|
||||
}
|
||||
th {
|
||||
font-family: sans-serif;
|
||||
font-size : small;
|
||||
color : #FFF;
|
||||
background-color : #AAA;
|
||||
}
|
||||
.maintable {
|
||||
border : thin dashed #D0D0D0;
|
||||
background-color : #EEE;
|
||||
}
|
||||
</style>
|
||||
{form.javascript:h}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
{form.outputHeader():h}
|
||||
{form.hidden:h}
|
||||
|
||||
<table class="maintable" width="600" align="center">
|
||||
<tr>
|
||||
<td width="50%" valign="top"><!-- Personal info -->
|
||||
<table width="100%" cellpadding="4">
|
||||
<tr><th colspan="2">{form.header.personal:h}</th></tr>
|
||||
<tr>
|
||||
<td class="label">{form.name.label:h}</td>
|
||||
<td class="element">{form.name.error:h}
|
||||
<table cellspacing="0" cellpadding="1">
|
||||
<tr>
|
||||
<td>{form.name.first.html:h}</td>
|
||||
<td>{form.name.last.html:h}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><font size="1" color="grey">{form.name.first.label:h}</font></td>
|
||||
<td><font size="1" color="grey">{form.name.last.label:h}</font></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">{form.phone.label:h}</td>
|
||||
<td class="element">{form.phone.html:h}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">{form.email.label:h}</td>
|
||||
<td class="element">{form.email.html:h}</td>
|
||||
</tr>
|
||||
<tr><td colspan="2" class="note">Please, choose a 8-10 characters password.</td></tr>
|
||||
<tr>
|
||||
<td class="label">{form.pass.label:h}</td>
|
||||
<td class="element">{form.pass.html:h}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
<td width="50%" valign="top"><!-- Company info -->
|
||||
<table width="100%" cellpadding="4">
|
||||
<tr><th colspan="2">{form.header.company_info:h}</th></tr>
|
||||
<tr>
|
||||
<td class="label">{form.company.label:h}</td>
|
||||
<td class="element">{form.company.html:h}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" valign="top">{form.street.label:h}</td>
|
||||
<td class="element">{form.street.html:h}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">{form.address.label:h}</td>
|
||||
<td class="element">{form.address.error:h}
|
||||
<table cellspacing="0" cellpadding="1">
|
||||
<tr>
|
||||
<td>{form.address.zip.html:h}</td>
|
||||
<td>{form.address.city.html:h}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><font size="1" color="grey">{form.address.zip.label:h}</font></td>
|
||||
<td><font size="1" color="grey">{form.address.city.label:h}</font></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">{form.country.label:h}</td>
|
||||
<td class="element">{form.country.html:h}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">{form.destination.label:h}</td>
|
||||
<td class="element">{form.destination.html:h}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width="600" align="center">
|
||||
<tr>
|
||||
<td>{form.requirednote:h}</td>
|
||||
<td align="right">{form.reset.html:h} {form.submit.html:h}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="font-size:11px; color: navy;"><br />{form.news.html:h}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
<br />
|
||||
<b>Collected Errors:</b><br />
|
||||
{foreach:form.errors,error}
|
||||
<font color="red">{error}</font> in element [{name}]<br />
|
||||
{end:}
|
||||
|
||||
|
||||
<p><strong>The used "Static" Object</strong></p>
|
||||
<pre style="font-size: 12px;">
|
||||
{static_object}
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,4 +0,0 @@
|
|||
{if:error}
|
||||
<font color="orange" size="1">{error:h}</font><br />
|
||||
{end:}
|
||||
{html:h}
|
|
@ -1,110 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>IT dynamic renderer: 2 column layout example</title>
|
||||
<style type="text/css">
|
||||
.errors {
|
||||
font-family: sans-serif;
|
||||
color : #000;
|
||||
background-color : #FFF;
|
||||
font-size : 12pt;
|
||||
}
|
||||
.label {
|
||||
font-family: sans-serif;
|
||||
color : Navy;
|
||||
background-color : #EEE;
|
||||
font-size : 11px;
|
||||
text-align : right;
|
||||
vertical-align : top;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.element {
|
||||
font-family: sans-serif;
|
||||
background-color : #EEE;
|
||||
text-align : left;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.note {
|
||||
font-family: sans-serif;
|
||||
background-color : #EEE;
|
||||
text-align : center;
|
||||
font-size : 10pt;
|
||||
color : AAA;
|
||||
white-space: nowrap;
|
||||
}
|
||||
th {
|
||||
font-family: sans-serif;
|
||||
font-size : small;
|
||||
color : #FFC;
|
||||
background-color : #AAA;
|
||||
}
|
||||
.maintable {
|
||||
border : thin dashed #D0D0D0;
|
||||
background-color : #EEE;
|
||||
}
|
||||
</style>
|
||||
{qf_javascript}
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<!-- BEGIN qf_error_loop -->
|
||||
<font color="red">{qf_error}</font><br />
|
||||
<!-- END qf_error_loop -->
|
||||
<form {qf_attributes}>
|
||||
<!-- BEGIN qf_hidden_block -->
|
||||
<div style="display: none;">
|
||||
<!-- BEGIN qf_hidden_loop -->
|
||||
{qf_hidden}
|
||||
<!-- END qf_hidden_loop -->
|
||||
</div>
|
||||
<!-- END qf_hidden_block -->
|
||||
|
||||
<table class="maintable" width="600" align="center">
|
||||
<tr>
|
||||
<!-- BEGIN qf_main_loop -->
|
||||
<!-- BEGIN qf_header -->
|
||||
<td width="50%" valign="top">
|
||||
<table width="100%" cellpadding="4">
|
||||
<tr><th colspan="2">{qf_header}</th></tr>
|
||||
<!-- END qf_header -->
|
||||
<!-- BEGIN qf_element -->
|
||||
<tr><td class="label"><!-- BEGIN qf_element_required --><span style="color: #FF0000;">*</span> <!-- END qf_element_required -->{qf_label}</td><td class="element"><!-- BEGIN qf_element_error --><font size="1" color="red">{qf_error}</font><br /><!-- END qf_element_error -->{qf_element}</td></tr>
|
||||
<!-- END qf_element -->
|
||||
<!-- BEGIN qf_password -->
|
||||
<tr><td colspan="2" class="note">Please, choose a 8-10 characters password.</td></tr>
|
||||
<tr><td class="label"><!-- BEGIN qf_password_required --><span style="color: #FF0000;">*</span> <!-- END qf_password_required --><span style="color: green;">{qf_label}</span></td><td class="element"><!-- BEGIN qf_password_error --><font size="1" color="red">{qf_error}</font><br /><!-- END qf_password_error -->{qf_element}</td></tr>
|
||||
<!-- END qf_password -->
|
||||
<!-- BEGIN qf_group -->
|
||||
<tr>
|
||||
<td class="label"><!-- BEGIN qf_group_required --><span style="color: #FF0000;">*</span> <!-- END qf_group_required -->{qf_group_label}</td>
|
||||
<td class="element"><!-- BEGIN qf_group_loop --><!-- BEGIN qf_group_element -->{qf_separator}{qf_element}<!-- END qf_group_element --><!-- END qf_group_loop --></td>
|
||||
</tr>
|
||||
<!-- END qf_group -->
|
||||
<!-- BEGIN qf_group_table -->
|
||||
<tr>
|
||||
<td class="label"><!-- BEGIN qf_group_table_required --><span style="color: #FF0000;">*</span> <!-- END qf_group_table_required -->{qf_group_label}</td>
|
||||
<td class="element"><table cellpadding="0" cellspacing="0"><tr>
|
||||
<!-- BEGIN qf_group_table_loop --><!-- BEGIN qf_group_table_element -->
|
||||
<td>{qf_element}<br /><span style="font-size: 80%; color: #999;">{qf_label}<!-- BEGIN qf_group_table_element_required --><span style="color: #FF0000;">*</span> <!-- END qf_group_table_element_required --></span></td>
|
||||
<!-- END qf_group_table_element --><!-- END qf_group_table_loop -->
|
||||
</tr></table></td>
|
||||
</tr>
|
||||
<!-- END qf_group_table -->
|
||||
<!-- BEGIN qf_static -->
|
||||
</table>
|
||||
</td><!-- {qf_element} ends -->
|
||||
<!-- END qf_static -->
|
||||
<!-- END qf_main_loop -->
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width="600" align="center">
|
||||
<tr>
|
||||
<td>{qf_required_note}</td>
|
||||
<td align="right"><input name="reset" value="Reset" type="reset" /> <input name="submit" value="Register" type="submit" /></td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
|
@ -1,127 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<html>
|
||||
<head>
|
||||
<title>IT dynamic renderer</title>
|
||||
<style type="text/css">
|
||||
body, td, th {
|
||||
font-family: sans-serif;
|
||||
color : Navy;
|
||||
background-color : #EEE;
|
||||
font-size : smaller;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.maintable {
|
||||
border : thin dashed #D0D0D0;
|
||||
background-color : #EEE;
|
||||
}
|
||||
|
||||
.header {
|
||||
color : #FFF;
|
||||
background-color : #AAA;
|
||||
}
|
||||
|
||||
.green {
|
||||
background-color : #CFC;
|
||||
color : black;
|
||||
}
|
||||
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
{qf_javascript}
|
||||
<form {qf_attributes}>
|
||||
<!-- BEGIN qf_hidden_block -->
|
||||
<div style="display: none;">
|
||||
<!-- BEGIN qf_hidden_loop -->
|
||||
{qf_hidden}
|
||||
<!-- END qf_hidden_loop -->
|
||||
</div>
|
||||
<!-- END qf_hidden_block -->
|
||||
<table border="0" class="maintable" align="center">
|
||||
|
||||
<!-- BEGIN qf_errors -->
|
||||
<tr>
|
||||
<td align="left" valign="top" colspan="2">
|
||||
<ul>
|
||||
<!-- BEGIN qf_error_loop -->
|
||||
<li>{qf_error}</li>
|
||||
<!-- END qf_error_loop -->
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- END qf_errors -->
|
||||
|
||||
<!-- BEGIN qf_main_loop -->
|
||||
<!-- BEGIN qf_header -->
|
||||
<tr>
|
||||
<td align="left" valign="top" colspan="2" class="header"><b>{qf_header}</b></td>
|
||||
</tr>
|
||||
<!-- END qf_header -->
|
||||
|
||||
<!-- BEGIN qf_element -->
|
||||
<tr>
|
||||
<td align="right" valign="top"><!-- BEGIN qf_element_required --><span style="color: #FF0000;">*</span><!-- END qf_element_required --><b>{qf_label}</b></td>
|
||||
<td valign="top" align="left"><!-- BEGIN qf_element_error --><span style="color: #FF0000;">{qf_error}</span><br /><!-- END qf_element_error -->{qf_element}</td>
|
||||
</tr>
|
||||
<!-- END qf_element -->
|
||||
|
||||
<!-- BEGIN qf_textarea -->
|
||||
<tr>
|
||||
<td valign="top" colspan="2"><!-- BEGIN qf_textarea_required --><span style="color: #FF0000;">*</span><!-- END qf_textarea_required --><b>{qf_label}</b><br />
|
||||
<!-- BEGIN qf_textarea_error --><span style="color: #FF0000;">{qf_error}</span><br><!-- END qf_textarea_error -->{qf_element}</td>
|
||||
</tr>
|
||||
<!-- END qf_textarea -->
|
||||
|
||||
<!-- BEGIN qf_group -->
|
||||
<tr>
|
||||
<td align="right" valign="top"><!-- BEGIN qf_group_required --><span style="color: #FF0000;">*</span><!-- END qf_group_required --><b>{qf_group_label}</b></td>
|
||||
<td valign="top" align="left">
|
||||
<!-- BEGIN qf_group_error --><span style="color: #FF0000;">{qf_error}</span><br /><!-- END qf_group_error -->
|
||||
<!-- BEGIN qf_group_loop --><!-- BEGIN qf_group_element -->{qf_separator}{qf_element}<!-- END qf_group_element --><!-- END qf_group_loop -->
|
||||
</td>
|
||||
</tr>
|
||||
<!-- END qf_group -->
|
||||
|
||||
<!-- BEGIN qf_fancygroup -->
|
||||
<tr>
|
||||
<td align="right" valign="top"><span<!-- BEGIN qf_fancygroup_required --> style="font-weight: bold; color: red"<!-- END qf_fancygroup_required -->>{qf_group_label}</span></td>
|
||||
<td valign="top" align="left">
|
||||
<table cellspacing="2">
|
||||
<!-- BEGIN qf_fancygroup_loop -->
|
||||
<tr>
|
||||
<!-- BEGIN qf_fancygroup_element -->
|
||||
<td class="green" align="right"><!-- BEGIN qf_fancygroup_element_required --><span style="color: #FF0000;">*</span><!-- END qf_fancygroup_element_required -->{qf_label}</td>
|
||||
<td class="green">{qf_element}</td>
|
||||
<!-- END qf_fancygroup_element -->
|
||||
<!-- BEGIN qf_fancygroup_radio -->
|
||||
<td colspan="2" class="green">{qf_element}</td>
|
||||
<!-- END qf_fancygroup_radio -->
|
||||
</tr>
|
||||
<!-- END qf_fancygroup_loop -->
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<!-- END qf_fancygroup -->
|
||||
|
||||
<!-- BEGIN qf_green -->
|
||||
<tr>
|
||||
<td align="right" valign="top" class="green"><!-- BEGIN qf_green_required --><span style="color: #FF0000;">*</span><!-- END qf_green_required --><b>{qf_label}</b></td>
|
||||
<td valign="top" align="left" class="green"><!-- BEGIN qf_green_error --><span style="color: #FF0000;">{qf_error}</span><br /><!-- END qf_green_error -->{qf_element}
|
||||
<!-- BEGIN qf_green_label_2 --><br /><span style="font-size: 80%;">{qf_label_2}</span><!-- END qf_green_label_2 --></td>
|
||||
</tr>
|
||||
<!-- END qf_green -->
|
||||
{qf_addblock}
|
||||
<!-- END qf_main_loop -->
|
||||
|
||||
<!-- BEGIN qf_required_note -->
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td align="left" valign="top">{qf_required_note}</td>
|
||||
</tr>
|
||||
<!-- END qf_required_note -->
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
|
@ -1,102 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
|
||||
<html>
|
||||
<head>
|
||||
<title>IT static render: 2 column layout example</title>
|
||||
<style type="text/css">
|
||||
.errors {
|
||||
font-family: sans-serif;
|
||||
color : #000;
|
||||
background-color : #FFF;
|
||||
font-size : 12pt;
|
||||
}
|
||||
.label {
|
||||
font-family: sans-serif;
|
||||
color : Navy;
|
||||
font-size : 11px;
|
||||
text-align : right;
|
||||
vertical-align : top;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.element {
|
||||
font-family: sans-serif;
|
||||
background-color : #EEE;
|
||||
text-align : left;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.note {
|
||||
font-family: sans-serif;
|
||||
background-color : #EEE;
|
||||
text-align : center;
|
||||
font-size : 10pt;
|
||||
color : AAA;
|
||||
white-space: nowrap;
|
||||
}
|
||||
th {
|
||||
font-family: sans-serif;
|
||||
font-size : small;
|
||||
color : #FFF;
|
||||
background-color : #AAA;
|
||||
}
|
||||
.maintable {
|
||||
border : thin dashed #D0D0D0;
|
||||
background-color : #EEE;
|
||||
}
|
||||
</style>
|
||||
{form_javascript}
|
||||
</head>
|
||||
<body>
|
||||
<!-- BEGIN form_error_loop -->
|
||||
<font color="red">{form_error}</font><br /><!-- END form_error_loop -->
|
||||
|
||||
<form {form_attributes}>
|
||||
{form_session_html}
|
||||
|
||||
<table class="maintable" width="600" align="center">
|
||||
<tr><td width="50%" valign="top"><!-- Personal info -->
|
||||
<table width="100%" cellpadding="4"><tr><th colspan="2">{form_header_personal}</th></tr>
|
||||
<tr>
|
||||
<td class="label">{form_name_label}</td>
|
||||
<td class="element"><!-- BEGIN form_name_error -->{form_name_error}<!-- END form_name_error -->
|
||||
<table cellspacing="0" cellpadding="1">
|
||||
<tr><td>{form_name_first_html}</td><td>{form_name_last_html}</td></tr>
|
||||
<tr><td><font size="1" color="grey">{form_name_first_label}</font></td><td><font size="1" color="grey">{form_name_last_label}</font></td></tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td class="label">{form_phone_label}</td><td class="element">{form_phone_html}</td></tr>
|
||||
<tr><td class="label">{form_email_label}</td><td class="element">{form_email_html}</td></tr>
|
||||
<tr><td colspan="2" class="note">Please, choose a 8-10 characters password.</td></tr>
|
||||
<tr><td class="label">{form_pass_label}</td><td class="element">{form_pass_html}</td></tr>
|
||||
</table>
|
||||
</td><td width="50%" valign="top"><!-- Company info -->
|
||||
<table width="100%" cellpadding="4"><tr><th colspan="2">{form_header_company_info}</th></tr>
|
||||
<tr><td class="label">{form_company_label}</td><td class="element">{form_company_html}</td></tr>
|
||||
<tr><td class="label" valign="top">{form_street_label}</td><td class="element">{form_street_html}</td></tr>
|
||||
<tr>
|
||||
<td class="label">{form_address_label}</td>
|
||||
<td class="element"><!-- BEGIN form_address_error -->{form_address_error}<!-- END form_address_error -->
|
||||
<table cellspacing="0" cellpadding="1">
|
||||
<tr><td>{form_address_zip_html}</td><td>{form_address_city_html}</td></tr>
|
||||
<tr><td><font size="1" color="grey">{form_address_zip_label}</font></td><td><font size="1" color="grey">{form_address_city_label}</font></td></tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr><td class="label">{form_country_label}</td><td class="element">{form_country_html}</td></tr>
|
||||
<tr><td class="label">{form_destination_label}</td><td class="element">{form_destination_html}</td></tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
<table width="600" align="center">
|
||||
<tr>
|
||||
<td>{form_required_note}</td>
|
||||
<td align="right">{form_reset_html} {form_submit_html}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="font-size:11px; color: navy;"><br />{form_news_html}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
|
@ -1,4 +0,0 @@
|
|||
{if:required}
|
||||
<font color="red" size="1">*</font>
|
||||
{end:}
|
||||
{label:h}
|
|
@ -1,28 +0,0 @@
|
|||
<!-- $Id: smarty-dynamic-fancygroup.tpl,v 1.1 2003/04/30 19:23:35 avb Exp $ -->
|
||||
|
||||
<tr>
|
||||
<td valign="top" align="right">
|
||||
<b{if $element.error} style="color: Red;"{/if}>{if $element.required}<font color="red">*</font>{/if}{$element.label}:</b>
|
||||
</td>
|
||||
<td>
|
||||
<table cellspacing="2" border="0">
|
||||
{foreach key=gkey item=gitem from=$element.elements}
|
||||
<tr>
|
||||
{if $gitem.type eq "radio"}
|
||||
<td colspan="2" class="green">
|
||||
{$gitem.html}
|
||||
</td>
|
||||
{else}
|
||||
<td class="green" align="right">
|
||||
{if $gitem.required}<font color="red">*</font>{/if}
|
||||
{$gitem.label}
|
||||
</td>
|
||||
<td class="green">
|
||||
{$gitem.html}
|
||||
</td>
|
||||
{/if}
|
||||
</tr>
|
||||
{/foreach}
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
|
@ -1,9 +0,0 @@
|
|||
<!-- $Id: smarty-dynamic-green.tpl,v 1.1 2003/04/30 19:23:35 avb Exp $ -->
|
||||
|
||||
<tr>
|
||||
<td align="right" valign="top" class="green"><b>{$element.label}:</b></td>
|
||||
<td valign="top" align="left" class="green">
|
||||
{if $element.error}<font color="red">{$element.error}</font><br />{/if}
|
||||
{$element.html}{if $element.required}<font color="red">*</font>{/if}
|
||||
</td>
|
||||
</tr>
|
|
@ -1,134 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<!-- $Id: smarty-dynamic.tpl,v 1.5 2004/08/10 10:06:42 ths Exp $ -->
|
||||
<html>
|
||||
<head>
|
||||
<title>Smarty template for Array renderer</title>
|
||||
<style type="text/css">
|
||||
{literal}
|
||||
body, td, th {
|
||||
font-family: sans-serif;
|
||||
color: Navy;
|
||||
background-color : #EEE;
|
||||
font-size: smaller;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.maintable {
|
||||
border: thin dashed #D0D0D0;
|
||||
background-color: #EEE;
|
||||
}
|
||||
|
||||
.header {
|
||||
color: #FFF;
|
||||
background-color: #999;
|
||||
}
|
||||
|
||||
.green {
|
||||
background-color: #CFC;
|
||||
color: black;
|
||||
}
|
||||
{/literal}
|
||||
</style>
|
||||
|
||||
</head>
|
||||
<body>
|
||||
|
||||
{$form.javascript}
|
||||
|
||||
<table border="0" class="maintable" align="center">
|
||||
<form{$form.attributes}>{$form.hidden}
|
||||
|
||||
{foreach item=sec key=i from=$form.sections}
|
||||
<tr>
|
||||
<td class="header" colspan="2">
|
||||
<b>{$sec.header}</b></td>
|
||||
</tr>
|
||||
|
||||
{foreach item=element from=$sec.elements}
|
||||
|
||||
<!-- elements with alternative layout in external template file-->
|
||||
{if $element.style}
|
||||
{include file="smarty-dynamic-`$element.style`.tpl}
|
||||
|
||||
{*
|
||||
NOTE: Another way ist to have smarty template code in
|
||||
$element.style. In this case you can do:
|
||||
|
||||
{if $element.style}
|
||||
{eval var=$element.style}
|
||||
*}
|
||||
|
||||
<!-- submit or reset button (don't display on frozen forms) -->
|
||||
{elseif $element.type eq "submit" or $element.type eq "reset"}
|
||||
{if not $form.frozen}
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td align="left">{$element.html}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
|
||||
<!-- normal elements -->
|
||||
{else}
|
||||
<tr>
|
||||
{if $element.type eq "textarea"}
|
||||
<td colspan="2">
|
||||
{if $element.required}<font color="red">*</font>{/if}<b>{$element.label}</b><br />
|
||||
{else}
|
||||
<td align="right" valign="top">
|
||||
{if $element.required}<font color="red">*</font>{/if}<b>{$element.label}:</b></td>
|
||||
<td>
|
||||
{/if}
|
||||
{if $element.error}<font color="red">{$element.error}</font><br />{/if}
|
||||
{if $element.type eq "group"}
|
||||
{foreach key=gkey item=gitem from=$element.elements}
|
||||
{$gitem.label}
|
||||
{$gitem.html}{if $gitem.required}<font color="red">*</font>{/if}
|
||||
{if $element.separator}{cycle values=$element.separator}{/if}
|
||||
{/foreach}
|
||||
{else}
|
||||
{$element.html}
|
||||
{/if}
|
||||
<div style="font-size: 80%;">{$element.label_note}</div>
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
{/if}
|
||||
{/foreach}
|
||||
{/foreach}
|
||||
|
||||
{if $form.requirednote and not $form.frozen}
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td valign="top">{$form.requirednote}</td>
|
||||
</tr>
|
||||
{/if}
|
||||
|
||||
</form>
|
||||
</table>
|
||||
|
||||
|
||||
<p><b>Collected Errors:</b><br />
|
||||
{foreach key=name item=error from=$form.errors}
|
||||
<font color="red">{$error}</font> in element [{$name}]<br />
|
||||
{/foreach}
|
||||
</p>
|
||||
|
||||
|
||||
<p><strong>Best Practice: </strong><br />
|
||||
Use only one dynamic form template like this for your <br />
|
||||
Smarty driven project. You include this where <br />
|
||||
to place a form with the formdata-Array rendered by <br />
|
||||
SmartyDynamic QuickForm Renderer as option:</p>
|
||||
|
||||
<pre style="font-size: 12px;">
|
||||
<strong>{ldelim}include file=form-dynamic.tpl form=$formdata{rdelim}</strong>
|
||||
</pre>
|
||||
|
||||
|
||||
<p><strong>The used "Dynamic" Array </strong></p>
|
||||
<pre style="font-size: 12px;">
|
||||
{$dynamic_array|htmlentities}
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,156 +0,0 @@
|
|||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
||||
<!-- $Id: smarty-static.tpl,v 1.3 2004/10/15 20:30:56 ths Exp $ -->
|
||||
<html>
|
||||
<head>
|
||||
<title>Smarty template for ArraySmarty renderer: 2 column layout example</title>
|
||||
<style type="text/css">
|
||||
{literal}
|
||||
.errors {
|
||||
font-family: sans-serif;
|
||||
color : #000;
|
||||
background-color : #FFF;
|
||||
font-size : 12pt;
|
||||
}
|
||||
.label {
|
||||
font-family: sans-serif;
|
||||
color : Navy;
|
||||
font-size : 11px;
|
||||
text-align : right;
|
||||
vertical-align : top;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.element {
|
||||
font-family: sans-serif;
|
||||
background-color : #EEE;
|
||||
text-align : left;
|
||||
white-space: nowrap;
|
||||
}
|
||||
.note {
|
||||
font-family: sans-serif;
|
||||
background-color : #EEE;
|
||||
text-align : center;
|
||||
font-size : 10pt;
|
||||
color : AAA;
|
||||
white-space: nowrap;
|
||||
}
|
||||
th {
|
||||
font-family: sans-serif;
|
||||
font-size : small;
|
||||
color : #FFF;
|
||||
background-color : #AAA;
|
||||
}
|
||||
.maintable {
|
||||
border : thin dashed #D0D0D0;
|
||||
background-color : #EEE;
|
||||
}
|
||||
{/literal}
|
||||
</style>
|
||||
{$form.javascript}
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<form {$form.attributes}>
|
||||
{$form.hidden}
|
||||
|
||||
<table class="maintable" width="600" align="center">
|
||||
<tr>
|
||||
<td width="50%" valign="top"><!-- Personal info -->
|
||||
<table width="100%" cellpadding="4">
|
||||
<tr><th colspan="2">{$form.header.personal}</th></tr>
|
||||
<tr>
|
||||
<td class="label">{$form.name.label}</td>
|
||||
<td class="element">{$form.name.error}
|
||||
<table cellspacing="0" cellpadding="1">
|
||||
<tr>
|
||||
<td>{$form.name.first.html}</td>
|
||||
<td>{$form.name.last.html}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><font size="1" color="grey">{$form.name.first.label}</font></td>
|
||||
<td><font size="1" color="grey">{$form.name.last.label}</font></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">{$form.phone.label}</td>
|
||||
<td class="element">{$form.phone.html}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">{$form.email.label}</td>
|
||||
<td class="element">{$form.email.html}</td>
|
||||
</tr>
|
||||
<tr><td colspan="2" class="note">{$form.pass.label_note}</td></tr>
|
||||
<tr>
|
||||
<td class="label">{$form.pass.label}</td>
|
||||
<td class="element">{$form.pass.html}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
|
||||
<td width="50%" valign="top"><!-- Company info -->
|
||||
<table width="100%" cellpadding="4">
|
||||
<tr><th colspan="2">{$form.header.company_info}</th></tr>
|
||||
<tr>
|
||||
<td class="label">{$form.company.label}</td>
|
||||
<td class="element">{$form.company.html}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label" valign="top">{$form.street.label}</td>
|
||||
<td class="element">{$form.street.html}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">{$form.address.label}</td>
|
||||
<td class="element">{$form.address.error}
|
||||
<table cellspacing="0" cellpadding="1">
|
||||
<tr>
|
||||
<td>{$form.address.zip.html}</td>
|
||||
<td>{$form.address.city.html}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td><font size="1" color="grey">{$form.address.zip.label}</font></td>
|
||||
<td><font size="1" color="grey">{$form.address.city.label}</font></td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">{$form.country.label}</td>
|
||||
<td class="element">{$form.country.html}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td class="label">{$form.destination.label}</td>
|
||||
<td class="element">{$form.destination.html}</td>
|
||||
</tr>
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
<table width="600" align="center">
|
||||
<tr>
|
||||
<td>{$form.requirednote}</td>
|
||||
<td align="right">{$form.reset.html} {$form.submit.html}</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td colspan="2" style="font-size:11px; color: navy;"><br />{$form.news.html}</td>
|
||||
</tr>
|
||||
</table>
|
||||
|
||||
</form>
|
||||
|
||||
<br />
|
||||
<b>Collected Errors:</b><br />
|
||||
{foreach key=name item=error from=$form.errors}
|
||||
<font color="red">{$error}</font> in element [{$name}]<br />
|
||||
{/foreach}
|
||||
|
||||
|
||||
<p><strong>The used "Static" Array</strong></p>
|
||||
<pre style="font-size: 12px;">
|
||||
{$static_array|htmlentities}
|
||||
</pre>
|
||||
|
||||
</body>
|
||||
</html>
|
|
@ -1,30 +0,0 @@
|
|||
<tr>
|
||||
<td valign="top" align="right">
|
||||
{if:required}<span class="error">*</span>{end:}
|
||||
{if:error}<span class="error">{end:}
|
||||
<b>{label:h}:</b>
|
||||
{if:error}</span>{end:}
|
||||
</td>
|
||||
<td>
|
||||
{if:error}<div class="error">{error}</div>{end:}
|
||||
<table cellspacing="2" border="0">
|
||||
{foreach:elements,gitem}
|
||||
<tr>
|
||||
{if:gitem.isType(#radio#)}
|
||||
<td colspan="2" class="green">
|
||||
{gitem.html:h}
|
||||
</td>
|
||||
{else:}
|
||||
<td class="green" align="right">
|
||||
{if:gitem.required}<span class="error">*</span>{end:}
|
||||
{gitem.label:h}
|
||||
</td>
|
||||
<td class="green">
|
||||
{gitem.html:h}
|
||||
</td>
|
||||
{end:}
|
||||
</tr>
|
||||
{end:}
|
||||
</table>
|
||||
</td>
|
||||
</tr>
|
|
@ -1,10 +0,0 @@
|
|||
<!-- $Id: green.html,v 1.2 2003/11/03 12:55:52 avb Exp $ -->
|
||||
|
||||
<tr>
|
||||
<td align="right" valign="top" class="green">{if:required}<font color="red">*</font>{end:}<b>{label:h}:</b></td>
|
||||
<td valign="top" align="left" class="green">
|
||||
{if:error}<font color="red">{error:h}</font><br />{end:}
|
||||
{html:h}
|
||||
{if:label_2}<br /><span style="font-size: 75%">{label_2:h}</span>{end:}
|
||||
</td>
|
||||
</tr>
|
|
@ -1,87 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Usage example for HTML_QuickForm, built-in validation rules.
|
||||
*
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
*
|
||||
* $Id: rules-builtin.php,v 1.4 2004/11/26 10:24:54 avb Exp $
|
||||
*/
|
||||
|
||||
require_once 'HTML/QuickForm.php';
|
||||
|
||||
$form =& new HTML_QuickForm('builtin');
|
||||
|
||||
// We need an additional label below the element
|
||||
$renderer =& $form->defaultRenderer();
|
||||
$renderer->setElementTemplate(<<<EOT
|
||||
<tr>
|
||||
<td align="right" valign="top" nowrap="nowrap"><!-- BEGIN required --><span style="color: #ff0000">*</span><!-- END required --><b>{label}</b></td>
|
||||
<td valign="top" align="left">
|
||||
<!-- BEGIN error --><span style="color: #ff0000">{error}</span><br /><!-- END error -->{element}
|
||||
<!-- BEGIN label_2 --><br/><span style="font-size: 80%">{label_2}</span><!-- END label_2 -->
|
||||
</td>
|
||||
</tr>
|
||||
|
||||
EOT
|
||||
);
|
||||
|
||||
$form->addElement('header', null, 'Required rule');
|
||||
$form->addElement('text', 'rRequired', array('Required:', 'Rule type \'required\'<br />Note: when the field is not \'required\' and is empty, other validation rules will <b>not</b> be applied to it'));
|
||||
$form->addRule('rRequired', 'The field is required', 'required', null, 'client');
|
||||
|
||||
// RangeLength rules
|
||||
$form->addElement('header', null, 'Range based rules');
|
||||
$form->addElement('text', 'rMaxLength', array('Maximum length check (5):', 'Rule type \'maxlength\', $format = 5'));
|
||||
$form->addElement('text', 'rMinLength', array('Minimum length check (5):', 'Rule type \'minlength\', $format = 5'));
|
||||
$form->addElement('text', 'rRangeLength', array('Length range check (5-10):', 'Rule type \'rangelength\', $format = array(5, 10)'));
|
||||
|
||||
$form->addRule('rMaxLength', 'Should be less than or equal to 5 symbols', 'maxlength', 5, 'client');
|
||||
$form->addRule('rMinLength', 'Should be more than or equal to 5 symbols', 'minlength', 5, 'client');
|
||||
$form->addRule('rRangeLength', 'Should be between 5 and 10 symbols', 'rangelength', array(5,10), 'client');
|
||||
|
||||
// Email rule
|
||||
$form->addElement('header', null, 'Email rule');
|
||||
$form->addElement('text', 'rEmail', array('Email check:', 'Rule type \'email\''));
|
||||
$form->addRule('rEmail', 'Should contain a valid email', 'email', null, 'client');
|
||||
|
||||
// RegEx rules
|
||||
$form->addElement('header', null, 'Regex based rules');
|
||||
$form->addElement('text', 'rRegex', array('Letters \'A\', \'B\', \'C\' only:', 'Rule type \'regex\' with $format = \'/^[ABCabc]+$/\''));
|
||||
$form->addElement('text', 'rLettersOnly', array('Letters only:', 'Rule type \'lettersonly\''));
|
||||
$form->addElement('text', 'rAlphaNumeric', array('Alphanumeric:', 'Rule type \'alphanumeric\''));
|
||||
$form->addElement('text', 'rNumeric', array('Numeric:', 'Rule type \'numeric\''));
|
||||
$form->addElement('text', 'rNoPunctuation', array('No punctuation:', 'Rule type \'nopunctuation\''));
|
||||
$form->addElement('text', 'rNonZero', array('Nonzero:', 'Rule type \'nonzero\''));
|
||||
|
||||
$form->addRule('rRegex', 'Should contain letters A, B, C only', 'regex', '/^[ABCabc]+$/', 'client');
|
||||
$form->addRule('rLettersOnly', 'Should contain letters only', 'lettersonly', null, 'client');
|
||||
$form->addRule('rAlphaNumeric', 'Should be alphanumeric', 'alphanumeric', null, 'client');
|
||||
$form->addRule('rNumeric', 'Should be numeric', 'numeric', null, 'client');
|
||||
$form->addRule('rNoPunctuation', 'Should contain no punctuation', 'nopunctuation', null, 'client');
|
||||
$form->addRule('rNonZero', 'Should be nonzero', 'nonzero', null, 'client');
|
||||
|
||||
// Compare rule
|
||||
$form->addElement('header', null, 'Compare rule');
|
||||
$form->addElement('password', 'cmpPasswd', 'Password:');
|
||||
$form->addElement('password', 'cmpRepeat', array('Repeat password:', 'Rule type \'compare\', added to array(\'cmpPasswd\', \'cmpRepeat\')'));
|
||||
$form->addRule(array('cmpPasswd', 'cmpRepeat'), 'The passwords do not match', 'compare', null, 'client');
|
||||
|
||||
// File rules
|
||||
$form->addElement('header', null, 'Uploaded file rules');
|
||||
$form->addElement('file', 'tstUpload', array('Upload file:', 'Rule types: \'uploadedfile\', \'maxfilesize\' with $format = 10240, \'mimetype\' with $format = \'text/xml\', filename with $format = \'/\\.xml$/\'<br />Validation for files is obviously <b>server-side only</b>'));
|
||||
$form->addRule('tstUpload', 'Upload is required', 'uploadedfile');
|
||||
$form->addRule('tstUpload', 'File size should be less than 10kb', 'maxfilesize', 10240);
|
||||
$form->addRule('tstUpload', 'File type should be text/xml', 'mimetype', 'text/xml');
|
||||
$form->addRule('tstUpload', 'File name should be *.xml', 'filename', '/\\.xml$/');
|
||||
|
||||
$form->addElement('header', null, 'Submit the form');
|
||||
$submit[] =& $form->createElement('submit', null, 'Send');
|
||||
$submit[] =& $form->createElement('checkbox', 'clientSide', null, 'use client-side validation', array('checked' => 'checked', 'onclick' => "if (this.checked) {this.form.onsubmit = oldHandler;} else {oldHandler = this.form.onsubmit; this.form.onsubmit = null;}"));
|
||||
$form->addGroup($submit, null, null, ' ', false);
|
||||
|
||||
$form->applyFilter('__ALL__', 'trim');
|
||||
|
||||
$form->validate();
|
||||
|
||||
$form->display();
|
||||
?>
|
|
@ -1,107 +0,0 @@
|
|||
<?php
|
||||
/**
|
||||
* Usage example for HTML_QuickForm, using custom validation rules.
|
||||
*
|
||||
* @author Alexey Borzov <avb@php.net>
|
||||
*
|
||||
* $Id: rules-custom.php,v 1.2 2003/11/03 20:45:23 avb Exp $
|
||||
*/
|
||||
|
||||
require_once 'HTML/QuickForm.php';
|
||||
require_once 'HTML/QuickForm/Rule.php';
|
||||
|
||||
class RuleNumericRange extends HTML_QuickForm_Rule
|
||||
{
|
||||
function validate($value, $options)
|
||||
{
|
||||
if (isset($options['min']) && floatval($value) < $options['min']) {
|
||||
return false;
|
||||
}
|
||||
if (isset($options['max']) && floatval($value) > $options['max']) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
function getValidationScript($options = null)
|
||||
{
|
||||
$jsCheck = array();
|
||||
if (isset($options['min'])) {
|
||||
$jsCheck[] = 'Number({jsVar}) >= ' . $options['min'];
|
||||
}
|
||||
if (isset($options['max'])) {
|
||||
$jsCheck[] = 'Number({jsVar}) <= ' . $options['max'];
|
||||
}
|
||||
return array('', "{jsVar} != '' && !(" . implode(' && ', $jsCheck) . ')');
|
||||
} // end func getValidationScript
|
||||
}
|
||||
|
||||
// In case you are wondering, this checks whether there are too many
|
||||
// CAPITAL LETTERS in the string
|
||||
function countUpper($value, $limit = null)
|
||||
{
|
||||
if (empty($value)) {
|
||||
return false;
|
||||
}
|
||||
if (!isset($limit)) {
|
||||
$limit = 0.5;
|
||||
}
|
||||
$upper = array_filter(preg_split('//', $value, -1, PREG_SPLIT_NO_EMPTY), 'ctype_upper');
|
||||
return (count($upper) / strlen($value)) <= $limit;
|
||||
}
|
||||
|
||||
// BC thingie: it expects the first param to be element name
|
||||
function countUpper_old($name, $value, $limit = null)
|
||||
{
|
||||
if (empty($value)) {
|
||||
return false;
|
||||
}
|
||||
if (!isset($limit)) {
|
||||
$limit = 0.5;
|
||||
}
|
||||
$upper = array_filter(preg_split('//', $value, -1, PREG_SPLIT_NO_EMPTY), 'ctype_upper');
|
||||
return (count($upper) / strlen($value)) <= $limit;
|
||||
}
|
||||
|
||||
$form =& new HTML_QuickForm('custom');
|
||||
|
||||
$form->addElement('header', null, 'Custom rule class');
|
||||
|
||||
// registering the custom rule class
|
||||
$form->registerRule('numRange', null, 'RuleNumericRange');
|
||||
$form->addElement('text', 'rNumber_1_10', 'The number (1-10):');
|
||||
$form->addRule('rNumber_1_10', 'Enter number from 1 to 10', 'numRange', array('min' => 1, 'max' => 10), 'client');
|
||||
|
||||
// adding an instance of the custom rule class without registering
|
||||
$form->addElement('text', 'rNonnegative', 'Nonnegative number:');
|
||||
$form->addRule('rNonnegative', 'Enter nonnegative number', new RuleNumericRange(), array('min' => 0), 'client');
|
||||
|
||||
// adding a classname of the custom rule class without registering
|
||||
$form->addElement('text', 'rNonpositive', 'Nonpositive number:');
|
||||
$form->addRule('rNonpositive', 'Enter nonpositive number', 'RuleNumericRange', array('max' => 0), 'client');
|
||||
|
||||
$form->addElement('header', null, 'Using callbacks');
|
||||
|
||||
// using callback without registering
|
||||
$form->addElement('text', 'rUpper_0_5', 'Some (preferrably lowercase) text:');
|
||||
$form->addRule('rUpper_0_5', 'There are too many CAPITAL LETTERS', 'callback', 'countUpper');
|
||||
|
||||
// register with 'callback' type
|
||||
$form->registerRule('upper', 'callback', 'countUpper');
|
||||
$form->addElement('text', 'rUpper_0_25', 'Some (mostly lowercase) text:');
|
||||
$form->addRule('rUpper_0_25', 'There are too many CAPITAL LETTERS', 'upper', 0.25);
|
||||
|
||||
// BC feature: register with 'function' type
|
||||
$form->registerRule('upperOld', 'function', 'countUpper_old');
|
||||
$form->addElement('text', 'rUpper_0', 'Some lowercase text:');
|
||||
$form->addRule('rUpper_0', 'There are CAPITAL LETTERS, this is not allowed', 'upperOld', 0);
|
||||
|
||||
$form->addElement('submit', null, 'Send');
|
||||
|
||||
$form->applyFilter(array('rUpper_0_5', 'rUpper_0_25', 'rUpper_0'), 'trim');
|
||||
$form->applyFilter(array('rNumber_1_10', 'rNonnegative', 'rNonpositive'), 'floatval');
|
||||
|
||||
$form->validate();
|
||||
|
||||
$form->display();
|
||||
?>
|
|
@ -1,31 +0,0 @@
|
|||
<?PHP
|
||||
/**
|
||||
* XML_Beautifier example 1
|
||||
*
|
||||
* This example displays the basic usage.
|
||||
*
|
||||
* @author Stephan Schmidt <schst@php.net>
|
||||
*/
|
||||
error_reporting( E_ALL );
|
||||
|
||||
require_once 'XML/Beautifier.php';
|
||||
$fmt = new XML_Beautifier();
|
||||
$result = $fmt->formatFile('test.xml', 'test2.xml');
|
||||
|
||||
if (PEAR::isError($result)) {
|
||||
echo $result->getMessage();
|
||||
exit();
|
||||
}
|
||||
|
||||
echo "<h3>Original file</h3>";
|
||||
echo "<pre>";
|
||||
echo htmlspecialchars(implode("",file('test.xml')));
|
||||
echo "</pre>";
|
||||
|
||||
echo "<br><br>";
|
||||
|
||||
echo "<h3>Beautified file</h3>";
|
||||
echo "<pre>";
|
||||
echo htmlspecialchars(implode("",file('test2.xml')));
|
||||
echo "</pre>";
|
||||
?>
|
|
@ -1,30 +0,0 @@
|
|||
<?PHP
|
||||
/**
|
||||
* XML_Beautifier example 2
|
||||
*
|
||||
* This example displays the formatString()
|
||||
* method which can be used to beautify an XML string instead
|
||||
* of a file.
|
||||
*
|
||||
* @author Stephan Schmidt <schst@php.net>
|
||||
*/
|
||||
error_reporting( E_ALL );
|
||||
|
||||
$xmlString = '<xml><foo bar="tomato & Cheese"/><argh>foobar</argh></xml>';
|
||||
|
||||
require_once 'XML/Beautifier.php';
|
||||
$fmt = new XML_Beautifier();
|
||||
$result = $fmt->formatString($xmlString);
|
||||
|
||||
echo "<h3>Original string</h3>";
|
||||
echo "<pre>";
|
||||
echo htmlspecialchars($xmlString);
|
||||
echo "</pre>";
|
||||
|
||||
echo "<br><br>";
|
||||
|
||||
echo "<h3>Beautified string</h3>";
|
||||
echo "<pre>";
|
||||
echo htmlspecialchars($result);
|
||||
echo "</pre>";
|
||||
?>
|
|
@ -1,36 +0,0 @@
|
|||
<?PHP
|
||||
/**
|
||||
* XML_Beautifier example 3
|
||||
*
|
||||
* This example displays the 'caseFolding'
|
||||
* option. It can be used to convert all tags
|
||||
* and attribute names to upper case or lower
|
||||
* case. Use the 'caseFoldingTo' options to
|
||||
* to specify the case.
|
||||
*
|
||||
* @author Stephan Schmidt <schst@php.net>
|
||||
*/
|
||||
error_reporting( E_ALL );
|
||||
|
||||
require_once 'XML/Beautifier.php';
|
||||
|
||||
$options = array(
|
||||
"caseFolding" => true,
|
||||
"caseFoldingTo" => "uppercase"
|
||||
);
|
||||
|
||||
$fmt = new XML_Beautifier($options);
|
||||
$result = $fmt->formatFile('test.xml', 'test2.xml');
|
||||
|
||||
echo "<h3>Original file</h3>";
|
||||
echo "<pre>";
|
||||
echo htmlspecialchars(implode("",file('test.xml')));
|
||||
echo "</pre>";
|
||||
|
||||
echo "<br><br>";
|
||||
|
||||
echo "<h3>Beautified file</h3>";
|
||||
echo "<pre>";
|
||||
echo htmlspecialchars(implode("",file('test2.xml')));
|
||||
echo "</pre>";
|
||||
?>
|
|
@ -1,33 +0,0 @@
|
|||
<?PHP
|
||||
/**
|
||||
* XML_Beautifier example 4
|
||||
*
|
||||
* This example displays the 'normalizeComments'
|
||||
* option. If it is set to true, multiline comments will
|
||||
* be replaced by a single line comment.
|
||||
*
|
||||
* @author Stephan Schmidt <schst@php.net>
|
||||
*/
|
||||
error_reporting( E_ALL );
|
||||
|
||||
require_once 'XML/Beautifier.php';
|
||||
|
||||
$options = array(
|
||||
"normalizeComments" => true,
|
||||
);
|
||||
|
||||
$fmt = new XML_Beautifier($options);
|
||||
$result = $fmt->formatFile('test.xml', 'test2.xml');
|
||||
|
||||
echo "<h3>Original file</h3>";
|
||||
echo "<pre>";
|
||||
echo htmlspecialchars(implode("",file('test.xml')));
|
||||
echo "</pre>";
|
||||
|
||||
echo "<br><br>";
|
||||
|
||||
echo "<h3>Beautified file</h3>";
|
||||
echo "<pre>";
|
||||
echo htmlspecialchars(implode("",file('test2.xml')));
|
||||
echo "</pre>";
|
||||
?>
|
|
@ -1,37 +0,0 @@
|
|||
<?PHP
|
||||
/**
|
||||
* XML_Beautifier example 5
|
||||
*
|
||||
* This example displays the 'maxCommentLine'
|
||||
* option. It will split long comments into seperate lines
|
||||
* with a maximum length of 'maxCommentLine'.
|
||||
*
|
||||
* For the best results, you should always use this in
|
||||
* conjunction with normalizeComments.
|
||||
*
|
||||
* @author Stephan Schmidt <schst@php.net>
|
||||
*/
|
||||
error_reporting( E_ALL );
|
||||
|
||||
require_once 'XML/Beautifier.php';
|
||||
|
||||
$options = array(
|
||||
"normalizeComments" => true,
|
||||
"maxCommentLine" => 10
|
||||
);
|
||||
|
||||
$fmt = new XML_Beautifier($options);
|
||||
$result = $fmt->formatFile('test.xml', 'test2.xml');
|
||||
|
||||
echo "<h3>Original file</h3>";
|
||||
echo "<pre>";
|
||||
echo htmlspecialchars(implode("",file('test.xml')));
|
||||
echo "</pre>";
|
||||
|
||||
echo "<br><br>";
|
||||
|
||||
echo "<h3>Beautified file</h3>";
|
||||
echo "<pre>";
|
||||
echo htmlspecialchars(implode("",file('test2.xml')));
|
||||
echo "</pre>";
|
||||
?>
|
|
@ -1,29 +0,0 @@
|
|||
<?PHP
|
||||
/**
|
||||
* XML_Beautifier example 6
|
||||
*
|
||||
* This example displays the multilineTags option.
|
||||
* Furthermore it shows what happens, when no output file
|
||||
* is specified.
|
||||
*
|
||||
* @author Stephan Schmidt <schst@php.net>
|
||||
*/
|
||||
error_reporting( E_ALL );
|
||||
|
||||
require_once 'XML/Beautifier.php';
|
||||
|
||||
$fmt = new XML_Beautifier( array( "multilineTags" => true ) );
|
||||
$result = $fmt->formatFile('test.xml');
|
||||
|
||||
echo "<h3>Original file</h3>";
|
||||
echo "<pre>";
|
||||
echo htmlspecialchars(implode("",file('test.xml')));
|
||||
echo "</pre>";
|
||||
|
||||
echo "<br><br>";
|
||||
|
||||
echo "<h3>Beautified file</h3>";
|
||||
echo "<pre>";
|
||||
echo htmlspecialchars($result);
|
||||
echo "</pre>";
|
||||
?>
|
|
@ -1,46 +0,0 @@
|
|||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
<!DOCTYPE page [
|
||||
<!ENTITY foo SYSTEM "foo.xml">
|
||||
<!ENTITY bar SYSTEM "bar.xml">
|
||||
]>
|
||||
<document title="Current News">
|
||||
<meta project="none" foo="bar">
|
||||
<keywords/><description/>
|
||||
<author>Stephan Schmidt</author>
|
||||
<getMetaNav/>
|
||||
</meta>
|
||||
<page label="PHP Application Tools" sublabel="Current News">
|
||||
<?PHP
|
||||
for($i = 0; $i < count($_GET); $i++) {
|
||||
echo $_GET[$i]."<br>";
|
||||
}
|
||||
?>
|
||||
&foo;&bar;
|
||||
<intro>
|
||||
<!-- This Comment
|
||||
has more
|
||||
than one line.
|
||||
-->
|
||||
<introtitle>Welcome to PHP
|
||||
Application Tools & PEAR!</introtitle>
|
||||
<para>
|
||||
If you're new to pat, and would like
|
||||
<!-- This is a comment in a single line that contains an & -->
|
||||
to know
|
||||
|
||||
what we do
|
||||
|
||||
here, take a look at
|
||||
|
||||
<link url=
|
||||
"/about/project.xml">
|
||||
"About Pat"</link>
|
||||
or
|
||||
check out the
|
||||
<link url="/about/projectsOverview.xml">"projects overview"</link>. Otherwise, you probably know your way
|
||||
around
|
||||
the site already <smiley type="smile"/>
|
||||
</para>
|
||||
</intro>
|
||||
</page>
|
||||
</document>
|
|
@ -1,54 +0,0 @@
|
|||
<?PHP
|
||||
/**
|
||||
* example for XML_Parser_Simple
|
||||
*
|
||||
* @author Stephan Schmidt <schst@php-tools.net>
|
||||
* @package XML_Parser
|
||||
* @subpackage Examples
|
||||
*/
|
||||
|
||||
/**
|
||||
* require the parser
|
||||
*/
|
||||
require_once 'XML/Parser.php';
|
||||
|
||||
class myParser extends XML_Parser
|
||||
{
|
||||
|
||||
function myParser()
|
||||
{
|
||||
parent::XML_Parser();
|
||||
}
|
||||
|
||||
/**
|
||||
* handle start element
|
||||
*
|
||||
* @access private
|
||||
* @param resource xml parser resource
|
||||
* @param string name of the element
|
||||
* @param array attributes
|
||||
*/
|
||||
function startHandler($xp, $name, $attribs)
|
||||
{
|
||||
printf('handle start tag: %s<br />', $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* handle start element
|
||||
*
|
||||
* @access private
|
||||
* @param resource xml parser resource
|
||||
* @param string name of the element
|
||||
* @param array attributes
|
||||
*/
|
||||
function endHandler($xp, $name)
|
||||
{
|
||||
printf('handle end tag: %s<br />', $name);
|
||||
}
|
||||
}
|
||||
|
||||
$p = &new myParser();
|
||||
|
||||
$result = $p->setInputFile('xml_parser_file.xml');
|
||||
$result = $p->parse();
|
||||
?>
|
|
@ -1,5 +0,0 @@
|
|||
<foo>
|
||||
<bar>content of bar</bar>
|
||||
<empty/>
|
||||
<argh foo="bar">test</argh>
|
||||
</foo>
|
|
@ -1,50 +0,0 @@
|
|||
<?PHP
|
||||
/**
|
||||
* example for XML_Parser_Simple
|
||||
*
|
||||
* @author Stephan Schmidt <schst@php-tools.net>
|
||||
* @package XML_Parser
|
||||
* @subpackage Examples
|
||||
*/
|
||||
|
||||
/**
|
||||
* require the parser
|
||||
*/
|
||||
require_once 'XML/Parser.php';
|
||||
|
||||
class myHandler
|
||||
{
|
||||
/**
|
||||
* handle start element
|
||||
*
|
||||
* @access private
|
||||
* @param resource xml parser resource
|
||||
* @param string name of the element
|
||||
* @param array attributes
|
||||
*/
|
||||
function startHandler($xp, $name, $attribs)
|
||||
{
|
||||
printf('handle start tag: %s<br />', $name);
|
||||
}
|
||||
|
||||
/**
|
||||
* handle start element
|
||||
*
|
||||
* @access private
|
||||
* @param resource xml parser resource
|
||||
* @param string name of the element
|
||||
* @param array attributes
|
||||
*/
|
||||
function endHandler($xp, $name)
|
||||
{
|
||||
printf('handle end tag: %s<br />', $name);
|
||||
}
|
||||
}
|
||||
|
||||
$p = &new XML_Parser();
|
||||
$h = &new myHandler();
|
||||
|
||||
$result = $p->setInputFile('xml_parser_file.xml');
|
||||
$result = $p->setHandlerObj($h);
|
||||
$result = $p->parse();
|
||||
?>
|
|
@ -1,50 +0,0 @@
|
|||
<?PHP
|
||||
/**
|
||||
* example for XML_Parser_Simple
|
||||
*
|
||||
* $Id: xml_parser_simple1.php,v 1.3 2004/05/28 16:09:48 schst Exp $
|
||||
*
|
||||
* @author Stephan Schmidt <schst@php-tools.net>
|
||||
* @package XML_Parser
|
||||
* @subpackage Examples
|
||||
*/
|
||||
|
||||
/**
|
||||
* require the parser
|
||||
*/
|
||||
require_once 'XML/Parser/Simple.php';
|
||||
|
||||
class myParser extends XML_Parser_Simple
|
||||
{
|
||||
function myParser()
|
||||
{
|
||||
$this->XML_Parser_Simple();
|
||||
}
|
||||
|
||||
/**
|
||||
* handle the element
|
||||
*
|
||||
* The element will be handled, once it's closed
|
||||
*
|
||||
* @access private
|
||||
* @param string name of the element
|
||||
* @param array attributes of the element
|
||||
* @param string character data of the element
|
||||
*/
|
||||
function handleElement($name, $attribs, $data)
|
||||
{
|
||||
printf('handling %s in tag depth %d<br />', $name, $this->getCurrentDepth());
|
||||
printf('character data: %s<br />', $data );
|
||||
print 'Attributes:<br />';
|
||||
print '<pre>';
|
||||
print_r( $attribs );
|
||||
print '</pre>';
|
||||
print '<br />';
|
||||
}
|
||||
}
|
||||
|
||||
$p = &new myParser();
|
||||
|
||||
$result = $p->setInputFile('xml_parser_simple1.xml');
|
||||
$result = $p->parse();
|
||||
?>
|
|
@ -1,9 +0,0 @@
|
|||
<!-- $Id: xml_parser_simple1.xml,v 1.2 2004/05/24 21:42:33 schst Exp $ -->
|
||||
<foo>
|
||||
<bar>content of bar</bar>
|
||||
<empty/>
|
||||
<argh foo="bar">
|
||||
test
|
||||
<tomato>pizza</tomato>
|
||||
</argh>
|
||||
</foo>
|
|
@ -1,59 +0,0 @@
|
|||
<?PHP
|
||||
/**
|
||||
* example for XML_Parser_Simple
|
||||
*
|
||||
* $Id: xml_parser_simple2.php,v 1.1 2004/05/24 21:42:33 schst Exp $
|
||||
*
|
||||
* @author Stephan Schmidt <schst@php-tools.net>
|
||||
* @package XML_Parser
|
||||
* @subpackage Examples
|
||||
*/
|
||||
|
||||
/**
|
||||
* require the parser
|
||||
*/
|
||||
require_once 'XML/Parser/Simple.php';
|
||||
|
||||
class myParser2 extends XML_Parser_Simple
|
||||
{
|
||||
function myParser()
|
||||
{
|
||||
$this->XML_Parser_Simple();
|
||||
}
|
||||
|
||||
/**
|
||||
* handle the category element
|
||||
*
|
||||
* The element will be handled, once it's closed
|
||||
*
|
||||
* @access private
|
||||
* @param string name of the element
|
||||
* @param array attributes of the element
|
||||
* @param string character data of the element
|
||||
*/
|
||||
function handleElement_category($name, $attribs, $data)
|
||||
{
|
||||
printf( 'Category is %s<br />', $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* handle the name element
|
||||
*
|
||||
* The element will be handled, once it's closed
|
||||
*
|
||||
* @access private
|
||||
* @param string name of the element
|
||||
* @param array attributes of the element
|
||||
* @param string character data of the element
|
||||
*/
|
||||
function handleElement_name($name, $attribs, $data)
|
||||
{
|
||||
printf( 'Name is %s<br />', $data );
|
||||
}
|
||||
}
|
||||
|
||||
$p = &new myParser2();
|
||||
$result = $p->setInputFile('xml_parser_simple2.xml');
|
||||
$p->setMode('func');
|
||||
$result = $p->parse();
|
||||
?>
|
|
@ -1,5 +0,0 @@
|
|||
<!-- $Id: xml_parser_simple2.xml,v 1.1 2004/05/24 21:42:33 schst Exp $ -->
|
||||
<package>
|
||||
<category>XML</category>
|
||||
<name>XML_Parser</name>
|
||||
</package>
|
|
@ -1,56 +0,0 @@
|
|||
<?PHP
|
||||
/**
|
||||
* example for XML_Parser_Simple
|
||||
*
|
||||
* $Id: xml_parser_simple_handler.php,v 1.1 2004/05/25 13:26:42 schst Exp $
|
||||
*
|
||||
* @author Stephan Schmidt <schst@php-tools.net>
|
||||
* @package XML_Parser
|
||||
* @subpackage Examples
|
||||
*/
|
||||
|
||||
/**
|
||||
* require the parser
|
||||
*/
|
||||
require_once 'XML/Parser/Simple.php';
|
||||
|
||||
class myHandlerSimple
|
||||
{
|
||||
/**
|
||||
* handle the category element
|
||||
*
|
||||
* The element will be handled, once it's closed
|
||||
*
|
||||
* @access private
|
||||
* @param string name of the element
|
||||
* @param array attributes of the element
|
||||
* @param string character data of the element
|
||||
*/
|
||||
function handleElement_category($name, $attribs, $data)
|
||||
{
|
||||
printf( 'Category is %s<br />', $data );
|
||||
}
|
||||
|
||||
/**
|
||||
* handle the name element
|
||||
*
|
||||
* The element will be handled, once it's closed
|
||||
*
|
||||
* @access private
|
||||
* @param string name of the element
|
||||
* @param array attributes of the element
|
||||
* @param string character data of the element
|
||||
*/
|
||||
function handleElement_name($name, $attribs, $data)
|
||||
{
|
||||
printf( 'Name is %s<br />', $data );
|
||||
}
|
||||
}
|
||||
|
||||
$p = &new XML_Parser_Simple();
|
||||
$h = &new myHandlerSimple();
|
||||
$p->setHandlerObj($h);
|
||||
$result = $p->setInputFile('xml_parser_simple2.xml');
|
||||
$p->setMode('func');
|
||||
$result = $p->parse();
|
||||
?>
|
|
@ -1,6 +0,0 @@
|
|||
<xml>
|
||||
<test foo="bar">
|
||||
Test
|
||||
<tag>test</tag>
|
||||
</test>
|
||||
</xml>
|
|
@ -1,52 +0,0 @@
|
|||
<?PHP
|
||||
/**
|
||||
* Example to demonstrate the encodeFunction and decodeFunction
|
||||
* options.
|
||||
*
|
||||
* This allows you to apply callbacks to your data that is called
|
||||
* on all strings while serializing and unserializing.
|
||||
*
|
||||
* @author Stephan Schmidt <schst@php.net>
|
||||
*/
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require_once 'XML/Serializer.php';
|
||||
require_once 'XML/Unserializer.php';
|
||||
|
||||
// this is just to get a nested object
|
||||
$pearError = PEAR::raiseError('This is just an error object',123);
|
||||
|
||||
$options = array(
|
||||
'indent' => ' ',
|
||||
'linebreak' => "\n",
|
||||
'scalarAsAttributes' => true,
|
||||
'encodeFunction' => 'strtoupper'
|
||||
);
|
||||
|
||||
$foo = new stdClass();
|
||||
$foo->bar = new stdClass();
|
||||
$foo->bar->test = 'This is a test.';
|
||||
$foo->bar->value = 'This is a value.';
|
||||
|
||||
$serializer = &new XML_Serializer($options);
|
||||
|
||||
$result = $serializer->serialize($foo);
|
||||
|
||||
if( $result === true ) {
|
||||
$xml = $serializer->getSerializedData();
|
||||
}
|
||||
|
||||
echo "<pre>";
|
||||
print_r( htmlspecialchars($xml) );
|
||||
echo "</pre>";
|
||||
|
||||
$unserializer = &new XML_Unserializer();
|
||||
$unserializer->setOption('parseAttributes', true);
|
||||
$unserializer->setOption('decodeFunction', 'strtolower');
|
||||
|
||||
$result = $unserializer->unserialize($xml);
|
||||
|
||||
echo '<pre>';
|
||||
print_r($unserializer->getUnserializedData());
|
||||
echo '</pre>';
|
||||
?>
|
|
@ -1,27 +0,0 @@
|
|||
<?PHP
|
||||
/**
|
||||
* Example that uses the returnResult option to directly return the serialized
|
||||
* XML document in the serialize() method.
|
||||
*
|
||||
* @author Stephan Schmidt <schst@php.net>
|
||||
*/
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require_once 'XML/Serializer.php';
|
||||
|
||||
$options = array(
|
||||
'indent' => ' ',
|
||||
'linebreak' => "\n",
|
||||
'returnResult' => true
|
||||
);
|
||||
|
||||
$serializer = new XML_Serializer($options);
|
||||
|
||||
$foo = PEAR::raiseError('Just a test', 1234);
|
||||
|
||||
$result = $serializer->serialize($foo);
|
||||
|
||||
echo '<pre>';
|
||||
echo htmlspecialchars($result);
|
||||
echo '</pre>';
|
||||
?>
|
|
@ -1,47 +0,0 @@
|
|||
<?PHP
|
||||
/**
|
||||
* This example shows how to create an RDF document
|
||||
* with a few lines of code.
|
||||
* This can also be done with mode => simplexml
|
||||
*
|
||||
* @author Stephan Schmidt <schst@php.net>
|
||||
* @see serializeIndexedArray.php
|
||||
*/
|
||||
error_reporting(E_ALL);
|
||||
|
||||
require_once 'XML/Serializer.php';
|
||||
|
||||
$options = array(
|
||||
"indent" => " ",
|
||||
"linebreak" => "\n",
|
||||
"typeHints" => false,
|
||||
"addDecl" => true,
|
||||
"encoding" => "UTF-8"
|
||||
);
|
||||
|
||||
$serializer = new XML_Serializer($options);
|
||||
|
||||
$serializer->setErrorHandling(PEAR_ERROR_DIE);
|
||||
|
||||
$array = array(
|
||||
new stdClass(),
|
||||
new stdClass()
|
||||
);
|
||||
|
||||
$result = $serializer->serialize($array);
|
||||
|
||||
if( $result === true ) {
|
||||
echo "<pre>";
|
||||
echo htmlentities($serializer->getSerializedData());
|
||||
echo "</pre>";
|
||||
}
|
||||
|
||||
$result = $serializer->serialize($array, array( 'classAsTagName' => true ));
|
||||
|
||||
if( $result === true ) {
|
||||
echo "<pre>";
|
||||
echo htmlentities($serializer->getSerializedData());
|
||||
echo "</pre>";
|
||||
}
|
||||
|
||||
?>
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue