├── LICENSE.md ├── README.md ├── Zebra_Form.php ├── composer.json ├── examples ├── includes │ ├── contact-custom.php │ ├── contact-horizontal.php │ ├── contact-vertical.php │ ├── container-html │ │ └── container.html │ ├── custom-templates │ │ ├── contact.php │ │ ├── divs-login.php │ │ ├── example1-dependencies.php │ │ ├── example2-dependencies.php │ │ ├── registration.php │ │ ├── reservation.php │ │ └── tables-login.php │ ├── dependencies-example1-custom.php │ ├── dependencies-example2-custom.php │ ├── fileupload-basic-image-vertical.php │ ├── fileupload-basic-vertical.php │ ├── login-divs-custom.php │ ├── login-horizontal.php │ ├── login-labels-inside.php │ ├── login-tables-custom.php │ ├── login-vertical.php │ ├── registration-custom.php │ ├── registration-horizontal.php │ ├── registration-vertical.php │ ├── reservation-autofill-vertical.php │ ├── reservation-custom.php │ ├── reservation-horizontal.php │ ├── reservation-vertical.php │ └── validation-vertical.php ├── index.html ├── index.php ├── libraries │ └── highlight │ │ └── public │ │ ├── AUTHORS.en.txt │ │ ├── LICENSE │ │ ├── css │ │ ├── dark.css │ │ ├── default.css │ │ ├── ir_black.css │ │ ├── sunburst.css │ │ └── zenburn.css │ │ ├── javascript │ │ ├── css.js │ │ ├── highlight.js │ │ ├── html-xml.js │ │ ├── javascript.js │ │ └── php.js │ │ └── readme.eng.txt └── public │ ├── css │ ├── reset.css │ └── style.css │ ├── images │ ├── comment.png │ ├── letter.png │ └── user.png │ └── javascript │ ├── core.js │ └── jquery-1.12.0.js ├── includes ├── Button.php ├── Captcha.php ├── Checkbox.php ├── Control.php ├── Date.php ├── File.php ├── Hidden.php ├── Image.php ├── Label.php ├── Note.php ├── Password.php ├── Radio.php ├── Reset.php ├── Select.php ├── Submit.php ├── Text.php ├── Textarea.php ├── Time.php ├── XSSClean.php ├── babelsans-bold.ttf └── index.html ├── index.html ├── languages ├── afrikaans.php ├── albanian.php ├── catalan.php ├── deutsch.php ├── dutch.php ├── english.php ├── espanol.php ├── francais.php ├── index.html ├── italiano.php ├── japanese.php ├── romana.php ├── russian.php └── türk.php ├── mimes.json ├── process.php └── public ├── css ├── button-background.gif ├── calendar-disabled.png ├── calendar.png ├── close.png ├── ico-close.gif ├── ico-close.png ├── ico-refresh.gif ├── ico-refresh.png ├── ico-warning.gif ├── ico-warning.png ├── index.html ├── note.gif ├── spinner.gif ├── textbox-background.gif └── zebra_form.css ├── index.html └── javascript ├── index.html ├── readme.txt ├── zebra_form.js └── zebra_form.src.js /LICENSE.md: -------------------------------------------------------------------------------- 1 | ### GNU LESSER GENERAL PUBLIC LICENSE 2 | 3 | Version 3, 29 June 2007 4 | 5 | Copyright (C) 2007 Free Software Foundation, Inc. 6 | 7 | 8 | Everyone is permitted to copy and distribute verbatim copies of this 9 | license document, but changing it is not allowed. 10 | 11 | This version of the GNU Lesser General Public License incorporates the 12 | terms and conditions of version 3 of the GNU General Public License, 13 | supplemented by the additional permissions listed below. 14 | 15 | #### 0. Additional Definitions. 16 | 17 | As used herein, "this License" refers to version 3 of the GNU Lesser 18 | General Public License, and the "GNU GPL" refers to version 3 of the 19 | GNU General Public License. 20 | 21 | "The Library" refers to a covered work governed by this License, other 22 | than an Application or a Combined Work as defined below. 23 | 24 | An "Application" is any work that makes use of an interface provided 25 | by the Library, but which is not otherwise based on the Library. 26 | Defining a subclass of a class defined by the Library is deemed a mode 27 | of using an interface provided by the Library. 28 | 29 | A "Combined Work" is a work produced by combining or linking an 30 | Application with the Library. The particular version of the Library 31 | with which the Combined Work was made is also called the "Linked 32 | Version". 33 | 34 | The "Minimal Corresponding Source" for a Combined Work means the 35 | Corresponding Source for the Combined Work, excluding any source code 36 | for portions of the Combined Work that, considered in isolation, are 37 | based on the Application, and not on the Linked Version. 38 | 39 | The "Corresponding Application Code" for a Combined Work means the 40 | object code and/or source code for the Application, including any data 41 | and utility programs needed for reproducing the Combined Work from the 42 | Application, but excluding the System Libraries of the Combined Work. 43 | 44 | #### 1. Exception to Section 3 of the GNU GPL. 45 | 46 | You may convey a covered work under sections 3 and 4 of this License 47 | without being bound by section 3 of the GNU GPL. 48 | 49 | #### 2. Conveying Modified Versions. 50 | 51 | If you modify a copy of the Library, and, in your modifications, a 52 | facility refers to a function or data to be supplied by an Application 53 | that uses the facility (other than as an argument passed when the 54 | facility is invoked), then you may convey a copy of the modified 55 | version: 56 | 57 | - a) under this License, provided that you make a good faith effort 58 | to ensure that, in the event an Application does not supply the 59 | function or data, the facility still operates, and performs 60 | whatever part of its purpose remains meaningful, or 61 | - b) under the GNU GPL, with none of the additional permissions of 62 | this License applicable to that copy. 63 | 64 | #### 3. Object Code Incorporating Material from Library Header Files. 65 | 66 | The object code form of an Application may incorporate material from a 67 | header file that is part of the Library. You may convey such object 68 | code under terms of your choice, provided that, if the incorporated 69 | material is not limited to numerical parameters, data structure 70 | layouts and accessors, or small macros, inline functions and templates 71 | (ten or fewer lines in length), you do both of the following: 72 | 73 | - a) Give prominent notice with each copy of the object code that 74 | the Library is used in it and that the Library and its use are 75 | covered by this License. 76 | - b) Accompany the object code with a copy of the GNU GPL and this 77 | license document. 78 | 79 | #### 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, taken 82 | together, effectively do not restrict modification of the portions of 83 | the Library contained in the Combined Work and reverse engineering for 84 | debugging such modifications, if you also do each of the following: 85 | 86 | - a) Give prominent notice with each copy of the Combined Work that 87 | the Library is used in it and that the Library and its use are 88 | covered by this License. 89 | - b) Accompany the Combined Work with a copy of the GNU GPL and this 90 | license document. 91 | - c) For a Combined Work that displays copyright notices during 92 | execution, include the copyright notice for the Library among 93 | these notices, as well as a reference directing the user to the 94 | copies of the GNU GPL and this license document. 95 | - d) Do one of the following: 96 | - 0) Convey the Minimal Corresponding Source under the terms of 97 | this License, and the Corresponding Application Code in a form 98 | suitable for, and under terms that permit, the user to 99 | recombine or relink the Application with a modified version of 100 | the Linked Version to produce a modified Combined Work, in the 101 | manner specified by section 6 of the GNU GPL for conveying 102 | Corresponding Source. 103 | - 1) Use a suitable shared library mechanism for linking with 104 | the Library. A suitable mechanism is one that (a) uses at run 105 | time a copy of the Library already present on the user's 106 | computer system, and (b) will operate properly with a modified 107 | version of the Library that is interface-compatible with the 108 | Linked Version. 109 | - e) Provide Installation Information, but only if you would 110 | otherwise be required to provide such information under section 6 111 | of the GNU GPL, and only to the extent that such information is 112 | necessary to install and execute a modified version of the 113 | Combined Work produced by recombining or relinking the Application 114 | with a modified version of the Linked Version. (If you use option 115 | 4d0, the Installation Information must accompany the Minimal 116 | Corresponding Source and Corresponding Application Code. If you 117 | use option 4d1, you must provide the Installation Information in 118 | the manner specified by section 6 of the GNU GPL for conveying 119 | Corresponding Source.) 120 | 121 | #### 5. Combined Libraries. 122 | 123 | You may place library facilities that are a work based on the Library 124 | side by side in a single library together with other library 125 | facilities that are not Applications and are not covered by this 126 | License, and convey such a combined library under terms of your 127 | choice, if you do both of the following: 128 | 129 | - a) Accompany the combined library with a copy of the same work 130 | based on the Library, uncombined with any other library 131 | facilities, conveyed under the terms of this License. 132 | - b) Give prominent notice with the combined library that part of it 133 | is a work based on the Library, and explaining where to find the 134 | accompanying uncombined form of the same work. 135 | 136 | #### 6. Revised Versions of the GNU Lesser General Public License. 137 | 138 | The Free Software Foundation may publish revised and/or new versions 139 | of the GNU Lesser General Public License from time to time. Such new 140 | versions will be similar in spirit to the present version, but may 141 | differ in detail to address new problems or concerns. 142 | 143 | Each version is given a distinguishing version number. If the Library 144 | as you received it specifies that a certain numbered version of the 145 | GNU Lesser General Public License "or any later version" applies to 146 | it, you have the option of following the terms and conditions either 147 | of that published version or of any later version published by the 148 | Free Software Foundation. If the Library as you received it does not 149 | specify a version number of the GNU Lesser General Public License, you 150 | may choose any version of the GNU Lesser General Public License ever 151 | published by the Free Software Foundation. 152 | 153 | If the Library as you received it specifies that a proxy can decide 154 | whether future versions of the GNU Lesser General Public License shall 155 | apply, that proxy's public statement of acceptance of any version is 156 | permanent authorization for you to choose that version for the 157 | Library. -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Zebra_Form 2 | 3 | #### A jQuery augmented PHP library for creating and validating HTML forms 4 | 5 | ---- 6 | [Packagist](https://packagist.org/) stats 7 | 8 | [![Latest Stable Version](https://poser.pugx.org/stefangabos/zebra_form/v/stable)](https://packagist.org/packages/stefangabos/zebra_form) [![Total Downloads](https://poser.pugx.org/stefangabos/zebra_form/downloads)](https://packagist.org/packages/stefangabos/zebra_form) [![Monthly Downloads](https://poser.pugx.org/stefangabos/zebra_form/d/monthly)](https://packagist.org/packages/stefangabos/zebra_form) [![Daily Downloads](https://poser.pugx.org/stefangabos/zebra_form/d/daily)](https://packagist.org/packages/stefangabos/zebra_form) [![License](https://poser.pugx.org/stefangabos/zebra_form/license)](https://packagist.org/packages/stefangabos/zebra_form) 9 | 10 | Zebra_Form is a PHP library that greatly simplifies the process of creating and validating HTML forms. Its object-oriented structure promotes rapid HTML forms development and encourages developers to write clean and easily maintainable code and it frees the developers from the repetitive task of writing the code for validating forms by offering powerful built-in client-side and server-side validation. 11 | 12 | Zebra_Form has integrated [cross-site scripting](http://en.wikipedia.org/wiki/Cross-site_scripting) (XSS) prevention mechanism that automatically strips out potentially malicious code from the submitted data, and also features protection against [cross-site request forgery](http://en.wikipedia.org/wiki/Cross-site_request_forgery) (CSRF) attacks. It also prevents automated SPAM posts, out of the box and without relying on CAPTCHA by using [honeypots](http://haacked.com/archive/2007/09/11/honeypot-captcha.aspx). 13 | 14 | Forms layout can be generated either automatically or manually – using templates. When generated automatically, the generated output validates as HTML 4.01 Strict, XHTML 1.0 Strict or HTML5, and has the same look & feel across all major browsers like Firefox, Chrome, Opera, Safari and Internet Explorer 6+. 15 | 16 | It provides all the controls you’d expect in an HTML form and, additionally, date/time pickers, CAPTCHA and advanced AJAX-like file upload controls – see the [documentation](http://stefangabos.ro/wp-content/docs/Zebra_Form/Generic/Zebra_Form_Control.html#methodset_rule) for validation rules that can be used out of the box. 17 | 18 | The client-side validation is done using jQuery 1.5.2+ 19 | 20 | Zebra\_Form's code is heavily commented and generates no warnings/errors/notices when PHP’s error reporting level is set to E_ALL. 21 | 22 | ## Features 23 | 24 | - provides protection against cross-site scripting (XSS) and cross-site request forgery (CSRF) attacks out of the box 25 | it automatically prevents automated SPAM posts using the “honeypot” technique (CAPTCHAs can also be used for even stronger protection) 26 | - provides both server-side and client-side validation (client-side validation is done using jQuery 1.5.2+) and has a lot of predefined rules that can be used out of the box; custom validation rules (including AJAX-based) can easily be added 27 | - forms’ layout can be generated either automatically or manually using templates 28 | - generated output validates as HTML 4.01 Strict, XHTML 1.0 Strict or HTML5 29 | - works in all major browsers like Firefox, Chrome, Opera, Safari and Internet Explorer 6+ 30 | - code is heavily commented and generates no warnings/errors/notices when PHP’s error reporting level is set to E_ALL 31 | - has comprehensive documentation 32 | 33 | ## Requirements 34 | 35 | PHP 5.0.2+ (preferably PHP 5.3.0 compiled with the “fileinfo” extension for more secure file uploads – read more at the change log for version 2.7.3) 36 | 37 | jQuery 1.5.2+ 38 | 39 | ## How to use 40 | 41 | ##### The HTML 42 | 43 | ```html 44 | 45 | 46 | 47 | 48 | 49 | 50 | 51 | Zebra_Form Example 52 | 53 | 54 | 55 | 56 | 57 | 58 | 59 | 60 | 61 | 62 | 63 | 64 | 65 | 66 | 67 | 68 | 69 | 70 | 71 | 72 | 73 | ``` 74 | 75 | ##### The PHP 76 | 77 | ```php 78 | // include the Zebra_Form class 79 | require 'path/to/Zebra_Form.php'; 80 | 81 | // instantiate a Zebra_Form object 82 | $form = new Zebra_Form('form'); 83 | 84 | // the label for the "email" field 85 | $form->add('label', 'label_email', 'email', 'Email'); 86 | 87 | // add the "email" field 88 | $obj = $form->add('text', 'email', '', array('autocomplete' => 'off')); 89 | 90 | // set rules 91 | $obj->set_rule(array( 92 | 93 | // error messages will be sent to a variable called "error", usable in custom templates 94 | 'required' => array('error', 'Email is required!'), 95 | 'email' => array('error', 'Email address seems to be invalid!'), 96 | 97 | )); 98 | 99 | // "password" 100 | $form->add('label', 'label_password', 'password', 'Password'); 101 | 102 | $obj = $form->add('password', 'password', '', array('autocomplete' => 'off')); 103 | 104 | $obj->set_rule(array( 105 | 106 | 'required' => array('error', 'Password is required!'), 107 | 'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters'), 108 | 109 | )); 110 | 111 | // "remember me" 112 | $form->add('checkbox', 'remember_me', 'yes'); 113 | 114 | $form->add('label', 'label_remember_me_yes', 'remember_me_yes', 'Remember me'); 115 | 116 | // "submit" 117 | $form->add('submit', 'btnsubmit', 'Submit'); 118 | 119 | // validate the form 120 | if ($form->validate()) { 121 | 122 | // do stuff here 123 | 124 | } 125 | 126 | // auto generate output, labels above form elements 127 | $form->render(); 128 | ``` 129 | 130 | For demos and more information visit the **[project's homepage](http://stefangabos.ro/php-libraries/zebra-form/)** 131 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "stefangabos/zebra_form", 3 | "type": "library", 4 | "description": "A jQuery augmented PHP library for creating and validating HTML forms", 5 | "keywords": ["form","validation", "csrf", "xss", "honeypot", "validate", "jquery validation", "client side validation", "server side validation"], 6 | "homepage": "http://stefangabos.ro/php-libraries/zebra-form/", 7 | "license": "LGPL-3.0", 8 | "authors": [ 9 | { 10 | "name": "Stefan Gabos", 11 | "email": "contact@stefangabos.ro", 12 | "homepage": "http://stefangabos.ro/", 13 | "role": "Developer" 14 | } 15 | ], 16 | "require": { 17 | "php": ">=5.3.0" 18 | }, 19 | "version": "2.9.8", 20 | "autoload": { 21 | "classmap": [ 22 | "Zebra_Form.php" 23 | ] 24 | } 25 | } 26 | -------------------------------------------------------------------------------- /examples/includes/contact-custom.php: -------------------------------------------------------------------------------- 1 |

A contact form

2 | 3 |

Note the uneditable prefixes (text and images) for some of the fields.

4 | 5 |

Check the "Template source" tab to see how it's done!

6 | 7 | add('label', 'label_name', 'name', 'Your name:'); 17 | 18 | // add the "name" element 19 | $obj = $form->add('text', 'name', '', array('style' => 'width: 195px', 'data-prefix' => 'img:public/images/user.png')); 20 | 21 | // set rules 22 | $obj->set_rule(array( 23 | 24 | // error messages will be sent to a variable called "error", usable in custom templates 25 | 'required' => array('error', 'Name is required!') 26 | 27 | )); 28 | 29 | // "email" 30 | $form->add('label', 'label_email', 'email', 'Your email address:'); 31 | $obj = $form->add('text', 'email', '', array('style' => 'width: 195px', 'data-prefix' => 'img:public/images/letter.png')); 32 | $obj->set_rule(array( 33 | 'required' => array('error', 'Email is required!'), 34 | 'email' => array('error', 'Email address seems to be invalid!'), 35 | )); 36 | $form->add('note', 'note_email', 'email', 'Your email address will not be published.'); 37 | 38 | // "website" 39 | $form->add('label', 'label_website', 'website', 'Your website:'); 40 | $obj = $form->add('text', 'website', '', array('style' => 'width: 400px', 'data-prefix' => 'http://')); 41 | $obj->set_rule(array( 42 | 'url' => array(true, 'error', 'Invalid URL specified!'), 43 | )); 44 | $form->add('note', 'note_website', 'website', 'Enter the URL of your website, if you have one.'); 45 | 46 | // "subject" 47 | $form->add('label', 'label_subject', 'subject', 'Subject'); 48 | $obj = $form->add('text', 'subject', '', array('style' => 'width: 400px', 'data-prefix' => 'img:public/images/comment.png')); 49 | $obj->set_rule(array( 50 | 'required' => array('error', 'Subject is required!') 51 | )); 52 | 53 | // "message" 54 | $form->add('label', 'label_message', 'message', 'Message:'); 55 | $obj = $form->add('textarea', 'message'); 56 | $obj->set_rule(array( 57 | 'required' => array('error', 'Message is required!'), 58 | 'length' => array(0, 140, 'error', 'Maximum length is 140 characters!', true), 59 | )); 60 | 61 | // "submit" 62 | $form->add('submit', 'btnsubmit', 'Submit'); 63 | 64 | // if the form is valid 65 | if ($form->validate()) { 66 | 67 | // show results 68 | show_results(); 69 | 70 | // otherwise 71 | } else 72 | 73 | // generate output using a custom template 74 | $form->render('includes/custom-templates/contact.php'); 75 | 76 | ?> -------------------------------------------------------------------------------- /examples/includes/contact-horizontal.php: -------------------------------------------------------------------------------- 1 |

A contact form

2 | 3 |

Note the uneditable prefixes (text and images) for some of the fields.

4 | 5 | add('label', 'label_name', 'name', 'Your name:'); 15 | 16 | // add the "name" element 17 | $obj = $form->add('text', 'name', '', array('data-prefix' => 'img:public/images/user.png')); 18 | 19 | // set rules 20 | $obj->set_rule(array( 21 | 22 | // error messages will be sent to a variable called "error", usable in custom templates 23 | 'required' => array('error', 'Name is required!') 24 | 25 | )); 26 | 27 | // "email" 28 | $form->add('label', 'label_email', 'email', 'Your email address:'); 29 | $obj = $form->add('text', 'email', '', array('data-prefix' => 'img:public/images/letter.png')); 30 | $obj->set_rule(array( 31 | 'required' => array('error', 'Email is required!'), 32 | 'email' => array('error', 'Email address seems to be invalid!'), 33 | )); 34 | $form->add('note', 'note_email', 'email', 'Your email address will not be published.'); 35 | 36 | // "website" 37 | $form->add('label', 'label_website', 'website', 'Your website:'); 38 | $obj = $form->add('text', 'website', '', array('data-prefix' => 'http://')); 39 | $obj->set_rule(array( 40 | 'url' => array(true, 'error', 'Invalid URL specified!'), 41 | )); 42 | $form->add('note', 'note_website', 'website', 'Enter the URL of your website, if you have one.'); 43 | 44 | // "subject" 45 | $form->add('label', 'label_subject', 'subject', 'Subject'); 46 | $obj = $form->add('text', 'subject', '', array('data-prefix' => 'img:public/images/comment.png')); 47 | $obj->set_rule(array( 48 | 'required' => array('error', 'Subject is required!') 49 | )); 50 | 51 | // "message" 52 | $form->add('label', 'label_message', 'message', 'Message:'); 53 | $obj = $form->add('textarea', 'message'); 54 | $obj->set_rule(array( 55 | 'required' => array('error', 'Message is required!'), 56 | 'length' => array(0, 140, 'error', 'Maximum length is 140 characters!', true), 57 | )); 58 | 59 | // "submit" 60 | $form->add('submit', 'btn_submit', 'Submit'); 61 | 62 | // if the form is valid 63 | if ($form->validate()) { 64 | 65 | // show results 66 | show_results(); 67 | 68 | // otherwise 69 | } else 70 | 71 | // generate output using a custom template 72 | $form->render('*horizontal'); 73 | 74 | ?> -------------------------------------------------------------------------------- /examples/includes/contact-vertical.php: -------------------------------------------------------------------------------- 1 |

A contact form

2 | 3 |

Note the uneditable prefixes (text and images) for some of the fields.

4 | 5 | add('label', 'label_name', 'name', 'Your name:'); 15 | 16 | // add the "name" element 17 | $obj = $form->add('text', 'name', '', array('data-prefix' => 'img:public/images/user.png')); 18 | 19 | // set rules 20 | $obj->set_rule(array( 21 | 22 | // error messages will be sent to a variable called "error", usable in custom templates 23 | 'required' => array('error', 'Name is required!') 24 | 25 | )); 26 | 27 | // "email" 28 | $form->add('label', 'label_email', 'email', 'Your email address:'); 29 | $obj = $form->add('text', 'email', '', array('data-prefix' => 'img:public/images/letter.png')); 30 | $obj->set_rule(array( 31 | 'required' => array('error', 'Email is required!'), 32 | 'email' => array('error', 'Email address seems to be invalid!'), 33 | )); 34 | $form->add('note', 'note_email', 'email', 'Your email address will not be published.'); 35 | 36 | // "website" 37 | $form->add('label', 'label_website', 'website', 'Your website:'); 38 | $obj = $form->add('text', 'website', '', array('data-prefix' => 'http://')); 39 | $obj->set_rule(array( 40 | 'url' => array(true, 'error', 'Invalid URL specified!'), 41 | )); 42 | $form->add('note', 'note_website', 'website', 'Enter the URL of your website, if you have one.'); 43 | 44 | // "subject" 45 | $form->add('label', 'label_subject', 'subject', 'Subject'); 46 | $obj = $form->add('text', 'subject', '', array('style' => 'width:400px', 'data-prefix' => 'img:public/images/comment.png')); 47 | $obj->set_rule(array( 48 | 'required' => array('error', 'Subject is required!') 49 | )); 50 | 51 | // "message" 52 | $form->add('label', 'label_message', 'message', 'Message:'); 53 | $obj = $form->add('textarea', 'message'); 54 | $obj->set_rule(array( 55 | 'required' => array('error', 'Message is required!'), 56 | 'length' => array(0, 140, 'error', 'Maximum length is 140 characters!', true) 57 | )); 58 | 59 | // "submit" 60 | $form->add('submit', 'btnsubmit', 'Submit'); 61 | 62 | // if the form is valid 63 | if ($form->validate()) { 64 | 65 | // show results 66 | show_results(); 67 | 68 | // otherwise 69 | } else 70 | 71 | // generate output using a custom template 72 | $form->render(); 73 | 74 | ?> -------------------------------------------------------------------------------- /examples/includes/container-html/container.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | Zebra_Form Example 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | -------------------------------------------------------------------------------- /examples/includes/custom-templates/contact.php: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 |
10 | 11 | 12 |
13 |
14 | 15 |
16 | 17 | 19 |
20 | 21 |
22 | 23 |
24 | 25 | 27 |
-------------------------------------------------------------------------------- /examples/includes/custom-templates/divs-login.php: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 |
10 | 11 | 12 |
13 |
14 | 15 |
16 | 17 | 19 |
20 |
21 | 22 |
23 | 24 | 28 |
29 | -------------------------------------------------------------------------------- /examples/includes/custom-templates/example1-dependencies.php: -------------------------------------------------------------------------------- 1 | 5 | 8 | 9 | 13 | 20 | 21 | 22 | 23 |
24 | 25 |
26 | 27 |
28 | 29 | 30 |
31 |
32 |
33 | 34 |
35 | 36 | 37 |
38 |
39 |
40 | 41 |
42 | 43 |
44 | 45 |
46 |
47 |
48 | 49 |
50 | 51 |
52 | 53 |
54 |
55 |
56 | 57 |
58 | 59 |
60 | 61 |
62 | 63 |
64 |
65 |
66 | 67 |
68 | 69 |
70 | 71 |
72 | 73 |
-------------------------------------------------------------------------------- /examples/includes/custom-templates/example2-dependencies.php: -------------------------------------------------------------------------------- 1 | 2 | 3 |
4 |
5 |
6 |
7 | 8 |
9 |
Add new person

10 |
11 |
12 |

13 |
14 | 15 |
-------------------------------------------------------------------------------- /examples/includes/custom-templates/registration.php: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 |
10 | 11 | 12 |
13 |
14 | 15 |
16 | 17 | 19 |
20 | 21 |
22 |
23 |
24 |
25 | 26 |
27 | 28 |
29 | 30 | 32 |
-------------------------------------------------------------------------------- /examples/includes/custom-templates/reservation.php: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 |
10 | 11 | 12 |
13 |
14 | 15 |
16 | 17 | 19 |
20 | 21 |
22 | 23 |
24 | 25 |
26 | 27 | 28 | 29 | 31 |
32 |
33 |
34 | 35 |
36 |
37 |
38 | 39 |
40 |
41 |
42 | 43 |
44 | 45 |
46 | 47 | 48 | 49 |
50 |
51 |
52 | 53 |
54 |
55 |
56 | 57 |
58 |
59 |
60 | 61 |
62 | 63 |
64 | 65 |
66 |
67 |
68 |
69 | 70 | 72 |
-------------------------------------------------------------------------------- /examples/includes/custom-templates/tables-login.php: -------------------------------------------------------------------------------- 1 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 36 | 37 | 38 | 40 | 41 | 42 | 43 | 44 | 45 |
26 | 27 | 29 |
30 |
31 | 32 | 33 |
34 | 35 |
-------------------------------------------------------------------------------- /examples/includes/dependencies-example1-custom.php: -------------------------------------------------------------------------------- 1 |

Dependencies

2 | 3 |

Showcasing how elements can be validated only if other elements meet certain conditions and how callback functions for the "dependencies" rule work.

4 | 5 | add('label', 'label_name', 'name', 'Your name'); 15 | $obj = $form->add('text', 'name'); 16 | 17 | // set rules 18 | $obj->set_rule(array( 19 | 'required' => array('error', 'Name is required!'), 20 | )); 21 | 22 | // "notifications" 23 | $form->add('label', 'label_notifications', 'notifications', 'Would you like to be informed about promotional offers?'); 24 | $obj = $form->add('radios', 'notifications', array( 25 | 'yes' => 'Yes', 26 | 'no' => 'No', 27 | )); 28 | $obj->set_rule(array( 29 | 'required' => array('error', 'Please select an answer!'), 30 | )); 31 | 32 | // "method" 33 | $form->add('label', 'label_method', 'method', 'Please specify how you would like to be notified about promotional offers:'); 34 | $obj = $form->add('checkboxes', 'method[]', array( 35 | 'email' => 'By e-mail', 36 | 'phone' => 'By phone', 37 | 'post' => 'By land mail', 38 | )); 39 | $obj->set_rule(array( 40 | 'required' => array('error', 'Please specify how you would like to be notified about promotional offers!'), 41 | 'dependencies' => array(array( 42 | 'notifications' => 'yes', 43 | // whenever the value of "notification" changes, call this function and pass as second argument the value "1" 44 | ), 'mycallback, 1'), 45 | )); 46 | 47 | // "email" 48 | $form->add('label', 'label_email', 'email', 'Your email address:'); 49 | $obj = $form->add('text', 'email'); 50 | $obj->set_rule(array( 51 | 'required' => array('error', 'Email is required!'), 52 | 'email' => array('error', 'Email address seems to be invalid!'), 53 | 'dependencies' => array(array( 54 | 'method' => 'email', 55 | ), 'mycallback, 2'), 56 | )); 57 | $form->add('note', 'note_email', 'email', 'Your email address will not be published.'); 58 | 59 | // "phone" 60 | $form->add('label', 'label_phone', 'phone', 'Your telephone number:'); 61 | $obj = $form->add('text', 'phone'); 62 | $obj->set_rule(array( 63 | 'required' => array('error', 'Phone number is required!'), 64 | 'digits' => array('', 'error', 'Phone number must contain only digits!'), 65 | 'dependencies' => array(array( 66 | 'method' => 'phone', 67 | ), 'mycallback, 3'), 68 | )); 69 | $form->add('note', 'note_phone', 'phone', 'Enter your phone number using digits only'); 70 | 71 | // "post" 72 | $form->add('label', 'label_post', 'post', 'Your postal address:'); 73 | $obj = $form->add('text', 'post'); 74 | $obj->set_rule(array( 75 | 'required' => array('error', 'Postal address is required!'), 76 | 'dependencies' => array(array( 77 | 'method' => 'post', 78 | ), 'mycallback, 4'), 79 | )); 80 | $form->add('note', 'note_post', 'post', 'Enter the address where the notifications about promotional offers should be delivered'); 81 | 82 | // "why" 83 | $form->add('label', 'label_why', 'why', 'Please tell us why:'); 84 | $obj = $form->add('textarea', 'why'); 85 | $obj->set_rule(array( 86 | 'required' => array('error', 'Please leave us a message!'), 87 | 'dependencies' => array(array( 88 | 'notifications' => 'no', 89 | ), 'mycallback, 5'), 90 | )); 91 | 92 | // "submit" 93 | $form->add('submit', 'btnsubmit', 'Submit'); 94 | 95 | // if the form is valid 96 | if ($form->validate()) { 97 | 98 | // show results 99 | show_results(); 100 | 101 | // otherwise 102 | } else 103 | 104 | $form->render('includes/custom-templates/example1-dependencies.php'); 105 | 106 | ?> 107 | -------------------------------------------------------------------------------- /examples/includes/dependencies-example2-custom.php: -------------------------------------------------------------------------------- 1 |

Dependencies

2 | 3 |

Notice how the elements from the "Add new person" section are validated *only* when the "Add new" button is clicked

4 | 5 | add('label', 'label_name', 'name', 'Name'); 15 | $obj = $form->add('text', 'name'); 16 | 17 | // set rules 18 | $obj->set_rule(array( 19 | 'required' => array('error', 'Name is required!'), 20 | )); 21 | 22 | // add the "surname" element 23 | $form->add('label', 'label_surname', 'surname', 'Surname'); 24 | $obj = $form->add('text', 'surname'); 25 | 26 | // set rules 27 | $obj->set_rule(array( 28 | 'required' => array('error', 'Surname is required!'), 29 | )); 30 | 31 | // elements for adding a new person 32 | 33 | // add the "name" element 34 | $form->add('label', 'label_add_name', 'add_name', 'Name'); 35 | $obj = $form->add('text', 'add_name'); 36 | 37 | // set rules 38 | // validate *only* if the "Add new" button is clicked 39 | $obj->set_rule(array( 40 | 'required' => array('error', 'Name is required!'), 41 | 'dependencies' => array( 42 | 'btnadd' => 'click', 43 | ), 44 | )); 45 | 46 | // add the "surname" element 47 | $form->add('label', 'label_add_surname', 'add_surname', 'Surame'); 48 | $obj = $form->add('text', 'add_surname'); 49 | 50 | // set rules 51 | $obj->set_rule(array( 52 | 'required' => array('error', 'Surname is required!'), 53 | 'dependencies' => array( 54 | 'btnadd' => 'click', 55 | ), 56 | )); 57 | 58 | // "add" 59 | $form->add('submit', 'btnadd', 'Add new'); 60 | 61 | // "submit" 62 | $form->add('submit', 'btnsubmit', 'Finish'); 63 | 64 | // if the form is valid 65 | if ($form->validate()) { 66 | 67 | // show results 68 | show_results(); 69 | 70 | // otherwise 71 | } else 72 | 73 | $form->render('includes/custom-templates/example2-dependencies.php'); 74 | 75 | ?> 76 | -------------------------------------------------------------------------------- /examples/includes/fileupload-basic-image-vertical.php: -------------------------------------------------------------------------------- 1 |

Basic image upload

2 | 3 |

We're checking for file types

4 | 5 | add('label', 'label_file', 'file', 'Upload an image'); 15 | 16 | // add the "file" element 17 | $obj = $form->add('file', 'file'); 18 | 19 | // set rules 20 | $obj->set_rule(array( 21 | 22 | // error messages will be sent to a variable called "error", usable in custom templates 23 | 'required' => array('error', 'An image is required!'), 24 | 'upload' => array('tmp', ZEBRA_FORM_UPLOAD_RANDOM_NAMES, 'error', 'Could not upload file!
Check that the "tmp" folder exists inside the "examples" folder and that it is writable'), 25 | 26 | // notice how we use the "image" rule instead of the "filetype" rule (used in previous example); 27 | // the "image" rule does a thorough checking aimed specially for images 28 | 'image' => array('error', 'File must be a jpg, png or gif image!'), 29 | 'filesize' => array(102400, 'error', 'File size must not exceed 100Kb!'), 30 | 31 | )); 32 | 33 | // attach a note 34 | $form->add('note', 'note_file', 'file', 'File must have the .jpg, .jpeg, png or .gif extension, and no more than 100Kb!'); 35 | 36 | // "submit" 37 | $form->add('submit', 'btnsubmit', 'Submit'); 38 | 39 | // validate the form 40 | if ($form->validate()) { 41 | 42 | // do stuff here 43 | print_r('
');
44 |         print_r($form->file_upload);
45 |         die();
46 | 
47 |     }
48 | 
49 |     // auto generate output, labels above form elements
50 |     $form->render();
51 | 
52 | ?>


--------------------------------------------------------------------------------
/examples/includes/fileupload-basic-vertical.php:
--------------------------------------------------------------------------------
 1 | 

Basic file upload

2 | 3 |

Once you upload the file, don't forget to look into the "tmp" folder inside the "examples" folder for the result.

4 | 5 | add('label', 'label_file', 'file', 'Upload Microsoft Word document'); 15 | 16 | // add the "file" element 17 | $obj = $form->add('file', 'file'); 18 | 19 | // set rules 20 | $obj->set_rule(array( 21 | 22 | // error messages will be sent to a variable called "error", usable in custom templates 23 | 'required' => array('error', 'A Microsoft Word document is required!'), 24 | 'upload' => array('tmp', ZEBRA_FORM_UPLOAD_RANDOM_NAMES, 'error', 'Could not upload file!
Check that the "tmp" folder exists inside the "examples" folder and that it is writable'), 25 | 'filetype' => array('doc, docx', 'error', 'File must be a Microsoft Word document!'), 26 | 'filesize' => array(102400, 'error', 'File size must not exceed 100Kb!'), 27 | 28 | )); 29 | 30 | // attach a note 31 | $form->add('note', 'note_file', 'file', 'File must have the .doc or .docx extension, and no more than 100Kb!'); 32 | 33 | // "submit" 34 | $form->add('submit', 'btnsubmit', 'Submit'); 35 | 36 | // validate the form 37 | if ($form->validate()) { 38 | 39 | // do stuff here 40 | print_r('
');
41 |         print_r($form->file_upload);
42 |         die();
43 | 
44 |     }
45 | 
46 |     // auto generate output, labels above form elements
47 |     $form->render();
48 | 
49 | ?>


--------------------------------------------------------------------------------
/examples/includes/login-divs-custom.php:
--------------------------------------------------------------------------------
 1 | 

A login form

2 | 3 |

In this demo we're creating a custom template using only divs; this is suitable for creating "vertical" templates (when 4 | a control's label is above the control), but when we want some elements to be side-by-side. Don't forget to check the 5 | "Template source" tab to see how it's done.

6 | 7 | 'off')); 14 | 15 | // the label for the "email" element 16 | $form->add('label', 'label_email', 'email', 'Email'); 17 | 18 | // add the "email" element 19 | $obj = $form->add('text', 'email'); 20 | 21 | // set rules 22 | $obj->set_rule(array( 23 | 24 | // error messages will be sent to a variable called "error", usable in custom templates 25 | 'required' => array('error', 'Email is required!'), 26 | 'email' => array('error', 'Email address seems to be invalid!'), 27 | 28 | )); 29 | 30 | // "password" 31 | $form->add('label', 'label_password', 'password', 'Password'); 32 | 33 | $obj = $form->add('password', 'password'); 34 | 35 | $obj->set_rule(array( 36 | 37 | 'required' => array('error', 'Password is required!'), 38 | 'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters!'), 39 | 40 | )); 41 | 42 | // "remember me" 43 | $form->add('checkbox', 'remember_me', 'yes'); 44 | 45 | $form->add('label', 'label_remember_me_yes', 'remember_me_yes', 'Remember me', array('style' => 'font-weight:normal')); 46 | 47 | // "submit" 48 | $form->add('submit', 'btnsubmit', 'Submit'); 49 | 50 | // if the form is valid 51 | if ($form->validate()) { 52 | 53 | // show results 54 | show_results(); 55 | 56 | // otherwise 57 | } else 58 | 59 | // generate output using a custom template 60 | $form->render('includes/custom-templates/divs-login.php'); 61 | 62 | ?> 63 | -------------------------------------------------------------------------------- /examples/includes/login-horizontal.php: -------------------------------------------------------------------------------- 1 |

A login form

2 | 3 | 'off')); 10 | 11 | // the label for the "email" element 12 | $form->add('label', 'label_email', 'email', 'Email'); 13 | 14 | // add the "email" element 15 | $obj = $form->add('text', 'email'); 16 | 17 | // set rules 18 | $obj->set_rule(array( 19 | 20 | // error messages will be sent to a variable called "error", usable in custom templates 21 | 'required' => array('error', 'Email is required!'), 22 | 'email' => array('error', 'Email address seems to be invalid!'), 23 | 24 | )); 25 | 26 | // "password" 27 | $form->add('label', 'label_password', 'password', 'Password'); 28 | $obj = $form->add('password', 'password'); 29 | $obj->set_rule(array( 30 | 'required' => array('error', 'Password is required!'), 31 | 'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters!'), 32 | )); 33 | 34 | // "remember me" 35 | $form->add('checkbox', 'remember_me', 'yes'); 36 | $form->add('label', 'label_remember_me_yes', 'remember_me_yes', 'Remember me', array('style' => 'font-weight:normal')); 37 | 38 | // "submit" 39 | $form->add('submit', 'btnsubmit', 'Submit'); 40 | 41 | // if the form is valid 42 | if ($form->validate()) { 43 | 44 | // show results 45 | show_results(); 46 | 47 | // otherwise 48 | } else 49 | 50 | // generate output using a custom template 51 | $form->render('*horizontal'); 52 | 53 | ?> 54 | -------------------------------------------------------------------------------- /examples/includes/login-labels-inside.php: -------------------------------------------------------------------------------- 1 |

A login form

2 | 3 | 'off')); 10 | 11 | // the label for the "email" element 12 | $form->add('label', 'label_email', 'email', 'Email address', array('inside' => true)); 13 | 14 | // add the "email" element 15 | $obj = $form->add('text', 'email'); 16 | 17 | // set rules 18 | $obj->set_rule(array( 19 | 20 | // error messages will be sent to a variable called "error", usable in custom templates 21 | 'required' => array('error', 'Email is required!'), 22 | 'email' => array('error', 'Email address seems to be invalid!'), 23 | 24 | )); 25 | 26 | // "password" 27 | $form->add('label', 'label_password', 'password', 'Password', array('inside' => true)); 28 | $obj = $form->add('password', 'password'); 29 | $obj->set_rule(array( 30 | 'required' => array('error', 'Password is required!'), 31 | 'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters!'), 32 | )); 33 | 34 | // "remember me" 35 | $form->add('checkbox', 'remember_me', 'yes'); 36 | $form->add('label', 'label_remember_me_yes', 'remember_me_yes', 'Remember me', array('style' => 'font-weight:normal')); 37 | 38 | // "submit" 39 | $form->add('submit', 'btnsubmit', 'Submit'); 40 | 41 | // if the form is valid 42 | if ($form->validate()) { 43 | 44 | // show results 45 | show_results(); 46 | 47 | // otherwise 48 | } else 49 | 50 | // generate output using a custom template 51 | $form->render(); 52 | 53 | ?> 54 | -------------------------------------------------------------------------------- /examples/includes/login-tables-custom.php: -------------------------------------------------------------------------------- 1 |

A login form

2 | 3 |

In this demo we're creating a custom template using tables; this is suitable for creating "horizontal" templates (when 4 | a control's label is to the left of the control). Don't forget to check the "Template source" tab to see how it's done.

5 | 6 | 'off')); 13 | 14 | // the label for the "email" element 15 | $form->add('label', 'label_email', 'email', 'Email'); 16 | 17 | // add the "email" element 18 | $obj = $form->add('text', 'email'); 19 | 20 | // set rules 21 | $obj->set_rule(array( 22 | 23 | // error messages will be sent to a variable called "error", usable in custom templates 24 | 'required' => array('error', 'Email is required!'), 25 | 'email' => array('error', 'Email address seems to be invalid!'), 26 | 27 | )); 28 | 29 | // "password" 30 | $form->add('label', 'label_password', 'password', 'Password'); 31 | $obj = $form->add('password', 'password'); 32 | $obj->set_rule(array( 33 | 'required' => array('error', 'Password is required!'), 34 | 'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters!'), 35 | )); 36 | 37 | // "remember me" 38 | $form->add('checkbox', 'remember_me', 'yes'); 39 | $form->add('label', 'label_remember_me_yes', 'remember_me_yes', 'Remember me', array('style' => 'font-weight:normal')); 40 | 41 | // "submit" 42 | $form->add('submit', 'btnsubmit', 'Submit'); 43 | 44 | // if the form is valid 45 | if ($form->validate()) { 46 | 47 | // show results 48 | show_results(); 49 | 50 | // otherwise 51 | } else 52 | 53 | // generate output using a custom template 54 | $form->render('includes/custom-templates/tables-login.php'); 55 | 56 | ?> 57 | -------------------------------------------------------------------------------- /examples/includes/login-vertical.php: -------------------------------------------------------------------------------- 1 |

A login form

2 | 3 | 'off')); 10 | 11 | // the label for the "email" element 12 | $form->add('label', 'label_email', 'email', 'Email'); 13 | 14 | // add the "email" element 15 | $obj = $form->add('text', 'email'); 16 | 17 | // set rules 18 | $obj->set_rule(array( 19 | 20 | // error messages will be sent to a variable called "error", usable in custom templates 21 | 'required' => array('error', 'Email is required!'), 22 | 'email' => array('error', 'Email address seems to be invalid!'), 23 | 24 | )); 25 | 26 | // "password" 27 | $form->add('label', 'label_password', 'password', 'Password'); 28 | $obj = $form->add('password', 'password'); 29 | $obj->set_rule(array( 30 | 'required' => array('error', 'Password is required!'), 31 | 'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters!'), 32 | )); 33 | 34 | // "remember me" 35 | $form->add('checkbox', 'remember_me', 'yes'); 36 | $form->add('label', 'label_remember_me_yes', 'remember_me_yes', 'Remember me', array('style' => 'font-weight:normal')); 37 | 38 | // "submit" 39 | $form->add('submit', 'btnsubmit', 'Submit'); 40 | 41 | // if the form is valid 42 | if ($form->validate()) { 43 | 44 | // show results 45 | show_results(); 46 | 47 | // otherwise 48 | } else 49 | 50 | // auto generate output, labels above form elements 51 | $form->render(); 52 | 53 | ?> 54 | -------------------------------------------------------------------------------- /examples/includes/registration-custom.php: -------------------------------------------------------------------------------- 1 |

A registration form

2 | 3 |

Check the "Template source" tab to see how it's done!

4 | 5 | 'off')); 12 | 13 | // the label for the "first name" element 14 | $form->add('label', 'label_firstname', 'firstname', 'First name:'); 15 | 16 | // add the "first name" element 17 | $obj = $form->add('text', 'firstname'); 18 | 19 | // set rules 20 | $obj->set_rule(array( 21 | 22 | // error messages will be sent to a variable called "error", usable in custom templates 23 | 'required' => array('error', 'First name is required!'), 24 | 25 | )); 26 | 27 | // "last name" 28 | $form->add('label', 'label_lastname', 'lastname', 'Last name:'); 29 | $obj = $form->add('text', 'lastname'); 30 | $obj->set_rule(array( 31 | 'required' => array('error', 'Last name is required!') 32 | )); 33 | 34 | // "email" 35 | $form->add('label', 'label_email', 'email', 'Email address:'); 36 | $obj = $form->add('text', 'email'); 37 | $obj->set_rule(array( 38 | 'required' => array('error', 'Email is required!'), 39 | 'email' => array('error', 'Email address seems to be invalid!') 40 | )); 41 | 42 | // attach a note to the email element 43 | $form->add('note', 'note_email', 'email', 'Please enter a valid email address. An email will be sent to this 44 | address with a link you need to click on in order to activate your account', array('style'=>'width:200px')); 45 | 46 | // "password" 47 | $form->add('label', 'label_password', 'password', 'Choose a password:'); 48 | $obj = $form->add('password', 'password'); 49 | $obj->set_rule(array( 50 | 'required' => array('error', 'Password is required!'), 51 | 'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters'), 52 | )); 53 | $form->add('note', 'note_password', 'password', 'Password must be have between 6 and 10 characters.', array('style' => 'width: 180px')); 54 | 55 | // "confirm password" 56 | $form->add('label', 'label_confirm_password', 'confirm_password', 'Confirm password:'); 57 | $obj = $form->add('password', 'confirm_password'); 58 | $obj->set_rule(array( 59 | 'compare' => array('password', 'error', 'Password not confirmed correctly!') 60 | )); 61 | 62 | // "captcha" 63 | $form->add('captcha', 'captcha_image', 'captcha_code'); 64 | $form->add('label', 'label_captcha_code', 'captcha_code', 'Are you human?'); 65 | $obj = $form->add('text', 'captcha_code'); 66 | $form->add('note', 'note_captcha', 'captcha_code', 'You must enter the characters with black color that stand 67 | out from the other characters', array('style'=>'width: 200px')); 68 | $obj->set_rule(array( 69 | 'required' => array('error', 'Enter the characters from the image above!'), 70 | 'captcha' => array('error', 'Characters from image entered incorrectly!') 71 | )); 72 | 73 | // "submit" 74 | $form->add('submit', 'btnsubmit', 'Submit'); 75 | 76 | // if the form is valid 77 | if ($form->validate()) { 78 | 79 | // show results 80 | show_results(); 81 | 82 | // otherwise 83 | } else 84 | 85 | // generate output using a custom template 86 | $form->render('includes/custom-templates/registration.php'); 87 | 88 | ?> -------------------------------------------------------------------------------- /examples/includes/registration-horizontal.php: -------------------------------------------------------------------------------- 1 |

A registration form

2 | 3 | 'off')); 10 | 11 | // the label for the "first name" element 12 | $form->add('label', 'label_firstname', 'firstname', 'First name:'); 13 | 14 | // add the "first name" element 15 | $obj = $form->add('text', 'firstname'); 16 | 17 | // set rules 18 | $obj->set_rule(array( 19 | 20 | // error messages will be sent to a variable called "error", usable in custom templates 21 | 'required' => array('error', 'First name is required!'), 22 | 23 | )); 24 | 25 | // "last name" 26 | $form->add('label', 'label_lastname', 'lastname', 'Last name:'); 27 | $obj = $form->add('text', 'lastname'); 28 | $obj->set_rule(array( 29 | 'required' => array('error', 'Last name is required!') 30 | )); 31 | 32 | // "email" 33 | $form->add('label', 'label_email', 'email', 'Email address:'); 34 | $obj = $form->add('text', 'email'); 35 | $obj->set_rule(array( 36 | 'required' => array('error', 'Email is required!'), 37 | 'email' => array('error', 'Email address seems to be invalid!') 38 | )); 39 | 40 | // attach a note to the email element 41 | $form->add('note', 'note_email', 'email', 'Please enter a valid email address. An email will be sent to this 42 | address with a link you need to click on in order to activate your account', array('style'=>'width:200px')); 43 | 44 | // "password" 45 | $form->add('label', 'label_password', 'password', 'Choose a password:'); 46 | $obj = $form->add('password', 'password'); 47 | $obj->set_rule(array( 48 | 'required' => array('error', 'Password is required!'), 49 | 'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters'), 50 | )); 51 | $form->add('note', 'note_password', 'password', 'Password must be have between 6 and 10 characters.'); 52 | 53 | // "confirm password" 54 | $form->add('label', 'label_confirm_password', 'confirm_password', 'Confirm password:'); 55 | $obj = $form->add('password', 'confirm_password'); 56 | $obj->set_rule(array( 57 | 'compare' => array('password', 'error', 'Password not confirmed correctly!') 58 | )); 59 | 60 | // "captcha" 61 | $form->add('captcha', 'captcha_image', 'captcha_code'); 62 | $form->add('label', 'label_captcha_code', 'captcha_code', 'Are you human?'); 63 | $obj = $form->add('text', 'captcha_code'); 64 | $form->add('note', 'note_captcha', 'captcha_code', 'You must enter the characters with black color that stand 65 | out from the other characters', array('style'=>'width: 200px')); 66 | $obj->set_rule(array( 67 | 'required' => array('error', 'Enter the characters from the image above!'), 68 | 'captcha' => array('error', 'Characters from image entered incorrectly!') 69 | )); 70 | 71 | // "submit" 72 | $form->add('submit', 'btnsubmit', 'Submit'); 73 | 74 | // if the form is valid 75 | if ($form->validate()) { 76 | 77 | // show results 78 | show_results(); 79 | 80 | // otherwise 81 | } else 82 | 83 | // generate output using a custom template 84 | $form->render('*horizontal'); 85 | 86 | ?> -------------------------------------------------------------------------------- /examples/includes/registration-vertical.php: -------------------------------------------------------------------------------- 1 |

A registration form

2 | 3 | 'off')); 10 | 11 | // the label for the "first name" element 12 | $form->add('label', 'label_firstname', 'firstname', 'First name:'); 13 | 14 | // add the "first name" element 15 | $obj = $form->add('text', 'firstname'); 16 | 17 | // set rules 18 | $obj->set_rule(array( 19 | 20 | // error messages will be sent to a variable called "error", usable in custom templates 21 | 'required' => array('error', 'First name is required!'), 22 | 23 | )); 24 | 25 | // "last name" 26 | $form->add('label', 'label_lastname', 'lastname', 'Last name:'); 27 | $obj = $form->add('text', 'lastname'); 28 | $obj->set_rule(array( 29 | 'required' => array('error', 'Last name is required!') 30 | )); 31 | 32 | // "email" 33 | $form->add('label', 'label_email', 'email', 'Email address:'); 34 | $obj = $form->add('text', 'email'); 35 | $obj->set_rule(array( 36 | 'required' => array('error', 'Email is required!'), 37 | 'email' => array('error', 'Email address seems to be invalid!') 38 | )); 39 | 40 | // attach a note to the email element 41 | $form->add('note', 'note_email', 'email', 'Please enter a valid email address. An email will be sent to this 42 | address with a link you need to click on in order to activate your account', array('style'=>'width:200px')); 43 | 44 | // "password" 45 | $form->add('label', 'label_password', 'password', 'Choose a password:'); 46 | $obj = $form->add('password', 'password'); 47 | $obj->set_rule(array( 48 | 'required' => array('error', 'Password is required!'), 49 | 'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters'), 50 | )); 51 | $form->add('note', 'note_password', 'password', 'Password must be have between 6 and 10 characters.'); 52 | 53 | // "confirm password" 54 | $form->add('label', 'label_confirm_password', 'confirm_password', 'Confirm password:'); 55 | $obj = $form->add('password', 'confirm_password'); 56 | $obj->set_rule(array( 57 | 'compare' => array('password', 'error', 'Password not confirmed correctly!') 58 | )); 59 | 60 | // "captcha" 61 | $form->add('captcha', 'captcha_image', 'captcha_code'); 62 | $form->add('label', 'label_captcha_code', 'captcha_code', 'Are you human?'); 63 | $obj = $form->add('text', 'captcha_code'); 64 | $form->add('note', 'note_captcha', 'captcha_code', 'You must enter the characters with black color that stand 65 | out from the other characters', array('style'=>'width: 200px')); 66 | $obj->set_rule(array( 67 | 'required' => array('error', 'Enter the characters from the image above!'), 68 | 'captcha' => array('error', 'Characters from image entered incorrectly!') 69 | )); 70 | 71 | // "submit" 72 | $form->add('submit', 'btnsubmit', 'Submit'); 73 | 74 | // if the form is valid 75 | if ($form->validate()) { 76 | 77 | // show results 78 | show_results(); 79 | 80 | // otherwise 81 | } else 82 | 83 | // generate output using a custom template 84 | $form->render(); 85 | 86 | ?> -------------------------------------------------------------------------------- /examples/includes/reservation-autofill-vertical.php: -------------------------------------------------------------------------------- 1 |

A meeting room reservation form

2 | 3 |

All fields will be automatically filled with random values - very useful for when debugging forms. The random values will obey the rules set for each element!

4 | 5 | auto_fill(); 16 | 17 | // the label for the "name" element 18 | $form->add('label', 'label_name', 'name', 'Your name:'); 19 | 20 | // add the "name" element 21 | $obj = $form->add('text', 'name'); 22 | 23 | // set rules 24 | $obj->set_rule(array( 25 | 26 | // error messages will be sent to a variable called "error", usable in custom templates 27 | 'required' => array('error', 'Name is required!') 28 | 29 | )); 30 | 31 | // "email" 32 | $form->add('label', 'label_email', 'email', 'Your email address:'); 33 | $obj = $form->add('text', 'email'); 34 | $obj->set_rule(array( 35 | 'required' => array('error', 'Email is required!'), 36 | 'email' => array('error', 'Email address seems to be invalid!'), 37 | )); 38 | 39 | // "department" 40 | $form->add('label', 'label_department', 'department', 'Department:'); 41 | $obj = $form->add('select', 'department', '', array('other' => true)); 42 | $obj->add_options(array( 43 | 'Marketing', 44 | 'Operations', 45 | 'Customer Service', 46 | 'Human Resources', 47 | 'Sales Department', 48 | 'Accounting Department', 49 | 'Legal Department', 50 | )); 51 | $obj->set_rule(array( 52 | 'required' => array('error', 'Department is required!') 53 | )); 54 | 55 | // "room" 56 | $form->add('label', 'label_room', 'room', 'Which room would you like to reserve:'); 57 | $obj = $form->add('radios', 'room', array( 58 | 'A' => 'Room A', 59 | 'B' => 'Room B', 60 | 'C' => 'Room C', 61 | )); 62 | $obj->set_rule(array( 63 | 'required' => array('error', 'Room selection is required!') 64 | )); 65 | 66 | // "extra" 67 | $form->add('label', 'label_extra', 'extra', 'Extra requirements:'); 68 | $obj = $form->add('checkboxes', 'extra[]', array( 69 | 'flipchard' => 'Flipchard and pens', 70 | 'plasma' => 'Plasma TV screen', 71 | 'beverages' => 'Coffee, tea and mineral water', 72 | )); 73 | 74 | // "date" 75 | $form->add('label', 'label_date', 'date', 'Reservation date'); 76 | $date = $form->add('date', 'date'); 77 | $date->set_rule(array( 78 | 'required' => array('error', 'Date is required!'), 79 | 'date' => array('error', 'Date is invalid!'), 80 | )); 81 | 82 | // date format 83 | // don't forget to use $date->get_date() if the form is valid to get the date in YYYY-MM-DD format ready to be used 84 | // in a database or with PHP's strtotime function! 85 | $date->format('M d, Y'); 86 | 87 | $form->add('note', 'note_date', 'date', 'Date format is M d, Y'); 88 | 89 | // "time" 90 | $form->add('label', 'label_time', 'time', 'Reservation time :'); 91 | $obj = $form->add('time', 'time', '', array( 92 | 'format' => 'hm', 93 | 'hours' => array(9, 10, 11, 12, 13, 14, 15, 16, 17), 94 | 'minutes' => array(0, 30), 95 | )); 96 | 97 | $obj->set_rule(array( 98 | 'required' => array('error', 'Time is required!'), 99 | )); 100 | 101 | // "submit" 102 | $form->add('submit', 'btnsubmit', 'Submit'); 103 | 104 | // if the form is valid 105 | if ($form->validate()) { 106 | 107 | // show results 108 | show_results(); 109 | 110 | // otherwise 111 | } else 112 | 113 | // generate output using a custom template 114 | $form->render(); 115 | 116 | ?> -------------------------------------------------------------------------------- /examples/includes/reservation-custom.php: -------------------------------------------------------------------------------- 1 |

A meeting room reservation form

2 | 3 |

Check the "Template source" tab to see how it's done!

4 | 5 | add('label', 'label_name', 'name', 'Your name:'); 15 | 16 | // add the "name" element 17 | $obj = $form->add('text', 'name'); 18 | 19 | // set rules 20 | $obj->set_rule(array( 21 | 22 | // error messages will be sent to a variable called "error", usable in custom templates 23 | 'required' => array('error', 'Name is required!') 24 | 25 | )); 26 | 27 | // "email" 28 | $form->add('label', 'label_email', 'email', 'Your email address:'); 29 | $obj = $form->add('text', 'email'); 30 | $obj->set_rule(array( 31 | 'required' => array('error', 'Email is required!'), 32 | 'email' => array('error', 'Email address seems to be invalid!'), 33 | )); 34 | 35 | // "department" 36 | $form->add('label', 'label_department', 'department', 'Department:'); 37 | $obj = $form->add('select', 'department', '', array('other' => true)); 38 | $obj->add_options(array( 39 | 'Marketing', 40 | 'Operations', 41 | 'Customer Service', 42 | 'Human Resources', 43 | 'Sales Department', 44 | 'Accounting Department', 45 | 'Legal Department', 46 | )); 47 | $obj->set_rule(array( 48 | 'required' => array('error', 'Department is required!') 49 | )); 50 | 51 | // "room" 52 | $form->add('label', 'label_room', 'room', 'Which room would you like to reserve:'); 53 | $obj = $form->add('radios', 'room', array( 54 | 'A' => 'Room A', 55 | 'B' => 'Room B', 56 | 'C' => 'Room C', 57 | )); 58 | $obj->set_rule(array( 59 | 'required' => array('error', 'Room selection is required!') 60 | )); 61 | 62 | // "extra" 63 | $form->add('label', 'label_extra', 'extra', 'Extra requirements:'); 64 | $obj = $form->add('checkboxes', 'extra[]', array( 65 | 'flipchard' => 'Flipchard and pens', 66 | 'plasma' => 'Plasma TV screen', 67 | 'beverages' => 'Coffee, tea and mineral water', 68 | )); 69 | 70 | // "date" 71 | $form->add('label', 'label_date', 'date', 'Reservation date'); 72 | $date = $form->add('date', 'date'); 73 | $date->set_rule(array( 74 | 'required' => array('error', 'Date is required!'), 75 | 'date' => array('error', 'Date is invalid!'), 76 | )); 77 | 78 | // date format 79 | // don't forget to use $date->get_date() if the form is valid to get the date in YYYY-MM-DD format ready to be used 80 | // in a database or with PHP's strtotime function! 81 | $date->format('M d, Y'); 82 | 83 | // selectable dates are starting with the current day 84 | $date->direction(1); 85 | 86 | $form->add('note', 'note_date', 'date', 'Date format is M d, Y'); 87 | 88 | // "time" 89 | $form->add('label', 'label_time', 'time', 'Reservation time :'); 90 | $form->add('time', 'time', '', array( 91 | 'hours' => array(9, 10, 11, 12, 13, 14, 15, 16, 17), 92 | 'minutes' => array(0, 30), 93 | )); 94 | 95 | // "submit" 96 | $form->add('submit', 'btnsubmit', 'Submit'); 97 | 98 | // if the form is valid 99 | if ($form->validate()) { 100 | 101 | // show results 102 | show_results(); 103 | 104 | // otherwise 105 | } else 106 | 107 | // generate output using a custom template 108 | $form->render('includes/custom-templates/reservation.php'); 109 | 110 | ?> -------------------------------------------------------------------------------- /examples/includes/reservation-horizontal.php: -------------------------------------------------------------------------------- 1 |

A meeting room reservation form

2 | 3 | add('label', 'label_name', 'name', 'Your name:'); 13 | 14 | // add the "name" element 15 | $obj = $form->add('text', 'name'); 16 | 17 | // set rules 18 | $obj->set_rule(array( 19 | 20 | // error messages will be sent to a variable called "error", usable in custom templates 21 | 'required' => array('error', 'Name is required!') 22 | 23 | )); 24 | 25 | // "email" 26 | $form->add('label', 'label_email', 'email', 'Your email address:'); 27 | $obj = $form->add('text', 'email'); 28 | $obj->set_rule(array( 29 | 'required' => array('error', 'Email is required!'), 30 | 'email' => array('error', 'Email address seems to be invalid!'), 31 | )); 32 | 33 | // "department" 34 | $form->add('label', 'label_department', 'department', 'Department:'); 35 | $obj = $form->add('select', 'department', '', array('other' => true)); 36 | $obj->add_options(array( 37 | 'Marketing', 38 | 'Operations', 39 | 'Customer Service', 40 | 'Human Resources', 41 | 'Sales Department', 42 | 'Accounting Department', 43 | 'Legal Department', 44 | )); 45 | $obj->set_rule(array( 46 | 'required' => array('error', 'Department is required!') 47 | )); 48 | 49 | // "room" 50 | $form->add('label', 'label_room', 'room', 'Which room would you like to reserve:'); 51 | $obj = $form->add('radios', 'room', array( 52 | 'A' => 'Room A', 53 | 'B' => 'Room B', 54 | 'C' => 'Room C', 55 | )); 56 | $obj->set_rule(array( 57 | 'required' => array('error', 'Room selection is required!') 58 | )); 59 | 60 | // "extra" 61 | $form->add('label', 'label_extra', 'extra', 'Extra requirements:'); 62 | $obj = $form->add('checkboxes', 'extra[]', array( 63 | 'flipchard' => 'Flipchard and pens', 64 | 'plasma' => 'Plasma TV screen', 65 | 'beverages' => 'Coffee, tea and mineral water', 66 | )); 67 | 68 | // "date" 69 | $form->add('label', 'label_date', 'date', 'Reservation date'); 70 | $date = $form->add('date', 'date'); 71 | $date->set_rule(array( 72 | 'required' => array('error', 'Date is required!'), 73 | 'date' => array('error', 'Date is invalid!'), 74 | )); 75 | 76 | // date format 77 | // don't forget to use $date->get_date() if the form is valid to get the date in YYYY-MM-DD format ready to be used 78 | // in a database or with PHP's strtotime function! 79 | $date->format('M d, Y'); 80 | 81 | // selectable dates are starting with the current day 82 | $date->direction(1); 83 | 84 | $form->add('note', 'note_date', 'date', 'Date format is M d, Y'); 85 | 86 | // "time" 87 | $form->add('label', 'label_time', 'time', 'Reservation time :'); 88 | $form->add('time', 'time', '', array( 89 | 'hours' => array(9, 10, 11, 12, 13, 14, 15, 16, 17), 90 | 'minutes' => array(0, 30), 91 | )); 92 | 93 | // "submit" 94 | $form->add('submit', 'btnsubmit', 'Submit'); 95 | 96 | // if the form is valid 97 | if ($form->validate()) { 98 | 99 | // show results 100 | show_results(); 101 | 102 | // otherwise 103 | } else 104 | 105 | // generate output using a custom template 106 | $form->render('*horizontal'); 107 | 108 | ?> -------------------------------------------------------------------------------- /examples/includes/reservation-vertical.php: -------------------------------------------------------------------------------- 1 |

A meeting room reservation form

2 | 3 | add('label', 'label_name', 'name', 'Your name:'); 13 | 14 | // add the "name" element 15 | $obj = $form->add('text', 'name'); 16 | 17 | // set rules 18 | $obj->set_rule(array( 19 | 20 | // error messages will be sent to a variable called "error", usable in custom templates 21 | 'required' => array('error', 'Name is required!') 22 | 23 | )); 24 | 25 | // "email" 26 | $form->add('label', 'label_email', 'email', 'Your email address:'); 27 | $obj = $form->add('text', 'email'); 28 | $obj->set_rule(array( 29 | 'required' => array('error', 'Email is required!'), 30 | 'emails' => array('error', 'Email address seems to be invalid!'), 31 | )); 32 | 33 | // "department" 34 | $form->add('label', 'label_department', 'department', 'Department:'); 35 | $obj = $form->add('select', 'department', '', array('other' => true)); 36 | $obj->add_options(array( 37 | 'Marketing', 38 | 'Operations', 39 | 'Customer Service', 40 | 'Human Resources', 41 | 'Sales Department', 42 | 'Accounting Department', 43 | 'Legal Department', 44 | )); 45 | $obj->set_rule(array( 46 | 'required' => array('error', 'Department is required!') 47 | )); 48 | 49 | // "room" 50 | $form->add('label', 'label_room', 'room', 'Which room would you like to reserve:'); 51 | $obj = $form->add('radios', 'room', array( 52 | 'A' => 'Room A', 53 | 'B' => 'Room B', 54 | 'C' => 'Room C', 55 | )); 56 | $obj->set_rule(array( 57 | 'required' => array('error', 'Room selection is required!') 58 | )); 59 | 60 | // "extra" 61 | $form->add('label', 'label_extra', 'extra', 'Extra requirements:'); 62 | $obj = $form->add('checkboxes', 'extra[]', array( 63 | 'flipchard' => 'Flipchard and pens', 64 | 'plasma' => 'Plasma TV screen', 65 | 'beverages' => 'Coffee, tea and mineral water', 66 | )); 67 | 68 | // "date" 69 | $form->add('label', 'label_date', 'date', 'Reservation date'); 70 | $date = $form->add('date', 'date'); 71 | $date->set_rule(array( 72 | 'required' => array('error', 'Date is required!'), 73 | 'date' => array('error', 'Date is invalid!'), 74 | )); 75 | 76 | // date format 77 | // don't forget to use $date->get_date() if the form is valid to get the date in YYYY-MM-DD format ready to be used 78 | // in a database or with PHP's strtotime function! 79 | $date->format('M d, Y'); 80 | 81 | $form->add('note', 'note_date', 'date', 'Date format is M d, Y'); 82 | 83 | // "time" 84 | $form->add('label', 'label_time', 'time', 'Reservation time :'); 85 | $obj = $form->add('time', 'time', '', array( 86 | 'format' => 'hm', 87 | 'hours' => array(9, 10, 11, 12, 13, 14, 15, 16, 17), 88 | 'minutes' => array(0, 30), 89 | )); 90 | 91 | $obj->set_rule(array( 92 | 'required' => array('error', 'Time is required!'), 93 | )); 94 | 95 | // "submit" 96 | $form->add('submit', 'btnsubmit', 'Submit'); 97 | 98 | // if the form is valid 99 | if ($form->validate()) { 100 | 101 | // show results 102 | show_results(); 103 | 104 | // otherwise 105 | } else 106 | 107 | // generate output using a custom template 108 | $form->render(); 109 | 110 | ?> -------------------------------------------------------------------------------- /examples/includes/validation-vertical.php: -------------------------------------------------------------------------------- 1 |

More validation rules

2 | 3 | add('label', 'label_alphabet', 'alphabet', 'Alphabet:'); 13 | 14 | $obj = $form->add('text', 'alphabet'); 15 | 16 | // set rules 17 | $obj->set_rule(array( 18 | 19 | // error messages will be sent to a variable called "error", usable in custom templates 20 | 'required' => array('error', 'This field is required!'), 21 | 'alphabet' => array('', 'error', 'Accepts only characters from the alphabet (case-insensitive a to z)') 22 | 23 | )); 24 | 25 | // attach a note 26 | $form->add('note', 'note_alphabet', 'alphabet', 'Accepts only characters from the alphabet (case-insensitive a to z)'); 27 | 28 | // "alphanumeric" 29 | $form->add('label', 'label_alphanumeric', 'alphanumeric', 'Alphanumeric:'); 30 | $obj = $form->add('text', 'alphanumeric'); 31 | $obj->set_rule(array( 32 | 'required' => array('error', 'This field is required!'), 33 | 'alphanumeric' => array('', 'error', 'Accepts only characters from the alphabet (case-insensitive a to z) and digits (0 to 9)') 34 | )); 35 | $form->add('note', 'note_alphanumeric', 'alphanumeric', 'Accepts only characters from the alphabet (case-insensitive a to z) and digits (0 to 9)'); 36 | 37 | // "digits" 38 | $form->add('label', 'label_digits', 'digits', 'Digits:'); 39 | $obj = $form->add('text', 'digits'); 40 | $obj->set_rule(array( 41 | 'required' => array('error', 'This field is required!'), 42 | 'digits' => array('', 'error', 'Accepts only digits (0 to 9)') 43 | )); 44 | $form->add('note', 'note_digits', 'digits', 'Accepts only digits (0 to 9)'); 45 | 46 | // "float" 47 | $form->add('label', 'label_float', 'float', 'Float:'); 48 | $obj = $form->add('text', 'float'); 49 | $obj->set_rule(array( 50 | 'required' => array('error', 'This field is required!'), 51 | 'float' => array('', 'error', 'Accepts only digits (0 to 9) and/or one dot (but not as the very first character) and/or one minus sign (but only if it is the very first character)') 52 | )); 53 | $form->add('note', 'note_float', 'float', 'Accepts only digits (0 to 9) and/or one dot (but not as the very first character) and/or one minus sign (but only if it is the very first character)'); 54 | 55 | // "length" 56 | $form->add('label', 'label_length', 'length', 'Length:'); 57 | $obj = $form->add('text', 'length'); 58 | $obj->set_rule(array( 59 | 'required' => array('error', 'This field is required!'), 60 | 'length' => array(6, 12, 'error', 'Must contain between 6 and 12 characters!') 61 | )); 62 | $form->add('note', 'note_length', 'length', 'Must contain between 6 and 12 characters'); 63 | 64 | // "number" 65 | $form->add('label', 'label_number', 'number', 'Number:'); 66 | $obj = $form->add('text', 'number'); 67 | $obj->set_rule(array( 68 | 'required' => array('error', 'This field is required!'), 69 | 'number' => array('', 'error', 'Accepts only digits (0 to 9) and/or one minus sign (but only if it is the very first character)') 70 | )); 71 | $form->add('note', 'note_number', 'number', 'Accepts only digits (0 to 9) and/or one minus sign (but only if it is the very first character)'); 72 | 73 | // "regular expression" 74 | $form->add('label', 'label_regexp', 'regexp', 'Regular expression:'); 75 | $obj = $form->add('text', 'regexp'); 76 | $obj->set_rule(array( 77 | 'required' => array('error', 'This field is required!'), 78 | 'regexp' => array('^07[0-9]{8}$', 'error', 'Validates only if the value matches the following regular expression: ^07[0-9]{8}$') 79 | )); 80 | $form->add('note', 'note_regexp', 'regexp', 'Validates if the value satisfies the following regular expression: ^07[0-9]{8}$'); 81 | 82 | // "change case" 83 | $form->add('label', 'label_case', 'case', 'Change case:'); 84 | $obj = $form->add('text', 'case'); 85 | $obj->set_rule(array( 86 | 'required' => array('error', 'This field is required!'), 87 | )); 88 | // force all characters to be upper-case 89 | $obj->change_case('upper'); 90 | $form->add('note', 'note_case', 'case', 'All entered characters will be upper-case'); 91 | 92 | // "submit" 93 | $form->add('submit', 'btnsubmit', 'Submit'); 94 | 95 | // if the form is valid 96 | if ($form->validate()) { 97 | 98 | // show results 99 | show_results(); 100 | 101 | // otherwise 102 | } else 103 | 104 | // generate output using a custom template 105 | $form->render(); 106 | 107 | ?> -------------------------------------------------------------------------------- /examples/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 |

Directory access is forbidden.

7 | 8 | -------------------------------------------------------------------------------- /examples/libraries/highlight/public/AUTHORS.en.txt: -------------------------------------------------------------------------------- 1 | Syntax highlighting with language autodetection. 2 | 3 | URL: http://softwaremaniacs.org/soft/highlight/en/ 4 | 5 | Original author and current maintainer: 6 | Ivan Sagalaev 7 | 8 | Contributors: 9 | 10 | - Peter Leonov 11 | - Victor Karamzin 12 | - Vsevolod Solovyov 13 | - Anton Kovalyov 14 | - Nikita Ledyaev 15 | - Konstantin Evdokimenko 16 | - Dmitri Roudakov 17 | - Yuri Ivanov 18 | - Vladimir Ermakov 19 | - Vladimir Gubarkov 20 | - Brian Beck 21 | - MajestiC 22 | - Vasily Polovnyov 23 | - Vladimir Epifanov 24 | - Alexander Makarov (http://rmcreative.ru/) 25 | - Vah 26 | - Shuen-Huei Guan 27 | - Jason Diamond 28 | - Michal Gabrukiewicz 29 | - Ruslan Keba 30 | - Sergey Baranov 31 | - Zaripov Yura 32 | - Oleg Volchkov 33 | - Vasily Mikhailitchenko 34 | - Jan Berkel 35 | - Vladimir Moskva 36 | - Loren Segal 37 | - Andrew Fedorov 38 | - Igor Kalnitsky 39 | -------------------------------------------------------------------------------- /examples/libraries/highlight/public/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright (c) 2006, Ivan Sagalaev 2 | All rights reserved. 3 | Redistribution and use in source and binary forms, with or without 4 | modification, are permitted provided that the following conditions are met: 5 | 6 | * Redistributions of source code must retain the above copyright 7 | notice, this list of conditions and the following disclaimer. 8 | * Redistributions in binary form must reproduce the above copyright 9 | notice, this list of conditions and the following disclaimer in the 10 | documentation and/or other materials provided with the distribution. 11 | * Neither the name of highlight.js nor the names of its contributors 12 | may be used to endorse or promote products derived from this software 13 | without specific prior written permission. 14 | 15 | THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY 16 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 | DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY 19 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 | -------------------------------------------------------------------------------- /examples/libraries/highlight/public/css/dark.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Dark style from softwaremaniacs.org (c) Ivan Sagalaev 4 | 5 | */ 6 | 7 | pre code { 8 | display: block; padding: 0.5em; 9 | background: #444; 10 | } 11 | 12 | pre .keyword, 13 | pre .literal, 14 | pre .change, 15 | pre .winutils, 16 | pre .flow, 17 | pre .lisp .title, 18 | pre .tex .special { 19 | color: white; 20 | } 21 | 22 | pre code, 23 | pre .ruby .subst { 24 | color: #DDD; 25 | } 26 | 27 | pre .string, 28 | pre .function .title, 29 | pre .class .title, 30 | pre .ini .title, 31 | pre .tag .value, 32 | pre .css .rules .value, 33 | pre .preprocessor, 34 | pre .ruby .symbol, 35 | pre .ruby .symbol .string, 36 | pre .ruby .symbol .keyword, 37 | pre .ruby .symbol .keymethods, 38 | pre .ruby .instancevar, 39 | pre .ruby .class .parent, 40 | pre .built_in, 41 | pre .sql .aggregate, 42 | pre .django .template_tag, 43 | pre .django .variable, 44 | pre .smalltalk .class, 45 | pre .javadoc, 46 | pre .ruby .string, 47 | pre .django .filter .argument, 48 | pre .smalltalk .localvars, 49 | pre .smalltalk .array, 50 | pre .attr_selector, 51 | pre .pseudo, 52 | pre .addition, 53 | pre .stream, 54 | pre .envvar, 55 | pre .apache .tag, 56 | pre .apache .cbracket, 57 | pre .tex .command { 58 | color: #D88; 59 | } 60 | 61 | pre .comment, 62 | pre .java .annotation, 63 | pre .python .decorator, 64 | pre .template_comment, 65 | pre .pi, 66 | pre .doctype, 67 | pre .deletion, 68 | pre .shebang, 69 | pre .apache .sqbracket, 70 | pre .tex .formula { 71 | color: #777; 72 | } 73 | 74 | pre .keyword, 75 | pre .literal, 76 | pre .css .id, 77 | pre .phpdoc, 78 | pre .function .title, 79 | pre .class .title, 80 | pre .vbscript .built_in, 81 | pre .sql .aggregate, 82 | pre .rsl .built_in, 83 | pre .smalltalk .class, 84 | pre .xml .tag .title, 85 | pre .diff .header, 86 | pre .chunk, 87 | pre .winutils, 88 | pre .bash .variable, 89 | pre .lisp .title, 90 | pre .apache .tag, 91 | pre .tex .special { 92 | font-weight: bold; 93 | } 94 | 95 | pre .html .css, 96 | pre .html .javascript, 97 | pre .html .vbscript, 98 | pre .tex .formula { 99 | opacity: 0.5; 100 | } 101 | -------------------------------------------------------------------------------- /examples/libraries/highlight/public/css/default.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Original style from softwaremaniacs.org (c) Ivan Sagalaev 4 | 5 | */ 6 | 7 | pre code { 8 | display: block; padding: 0.5em; 9 | background: #F0F0F0; 10 | } 11 | 12 | pre code, 13 | pre .ruby .subst, 14 | pre .tag .title, 15 | pre .lisp .title { 16 | color: black; 17 | } 18 | 19 | pre .string, 20 | pre .title, 21 | pre .constant, 22 | pre .parent, 23 | pre .tag .value, 24 | pre .rules .value, 25 | pre .rules .value .number, 26 | pre .preprocessor, 27 | pre .ruby .symbol, 28 | pre .ruby .symbol .string, 29 | pre .ruby .symbol .keyword, 30 | pre .ruby .symbol .keymethods, 31 | pre .instancevar, 32 | pre .aggregate, 33 | pre .template_tag, 34 | pre .django .variable, 35 | pre .smalltalk .class, 36 | pre .addition, 37 | pre .flow, 38 | pre .stream, 39 | pre .bash .variable, 40 | pre .apache .tag, 41 | pre .apache .cbracket, 42 | pre .tex .command, 43 | pre .tex .special { 44 | color: #800; 45 | } 46 | 47 | pre .comment, 48 | pre .annotation, 49 | pre .template_comment, 50 | pre .diff .header, 51 | pre .chunk { 52 | color: #888; 53 | } 54 | 55 | pre .number, 56 | pre .date, 57 | pre .regexp, 58 | pre .literal, 59 | pre .smalltalk .symbol, 60 | pre .smalltalk .char, 61 | pre .change { 62 | color: #080; 63 | } 64 | 65 | pre .label, 66 | pre .javadoc, 67 | pre .ruby .string, 68 | pre .decorator, 69 | pre .filter .argument, 70 | pre .localvars, 71 | pre .array, 72 | pre .attr_selector, 73 | pre .important, 74 | pre .pseudo, 75 | pre .pi, 76 | pre .doctype, 77 | pre .deletion, 78 | pre .envvar, 79 | pre .shebang, 80 | pre .apache .sqbracket, 81 | pre .nginx .built_in, 82 | pre .tex .formula { 83 | color: #88F; 84 | } 85 | 86 | pre .javadoctag, 87 | pre .phpdoc, 88 | pre .yardoctag { 89 | font-weight: bold; 90 | } 91 | 92 | pre .keyword, 93 | pre .id, 94 | pre .phpdoc, 95 | pre .title, 96 | pre .built_in, 97 | pre .aggregate, 98 | pre .smalltalk .class, 99 | pre .winutils, 100 | pre .bash .variable, 101 | pre .apache .tag, 102 | pre .tex .command { 103 | font-weight: bold; 104 | } 105 | 106 | pre .nginx .built_in { 107 | font-weight: normal; 108 | } 109 | 110 | pre .html .css, 111 | pre .html .javascript, 112 | pre .html .vbscript, 113 | pre .tex .formula { 114 | opacity: 0.5; 115 | } 116 | -------------------------------------------------------------------------------- /examples/libraries/highlight/public/css/ir_black.css: -------------------------------------------------------------------------------- 1 | /* 2 | IR_Black style (c) Vasily Mikhailitchenko 3 | */ 4 | 5 | pre code { 6 | display: block; padding: 0.5em; 7 | background: #222; color: #f8f8f8; 8 | font-size: 11px 9 | } 10 | 11 | pre .shebang, 12 | pre .comment, 13 | pre .template_comment, 14 | pre .javadoc { 15 | color: #7c7c7c; 16 | } 17 | 18 | pre .keyword, 19 | pre .tag, 20 | pre .ruby .function .keyword, 21 | pre .tex .command { 22 | color: #96CBFE; 23 | } 24 | 25 | pre .function .keyword, 26 | pre .sub .keyword, 27 | pre .method, 28 | pre .list .title { 29 | color: #FFFFB6; 30 | } 31 | 32 | pre .string, 33 | pre .tag .value, 34 | pre .cdata, 35 | pre .filter .argument, 36 | pre .attr_selector, 37 | pre .apache .cbracket, 38 | pre .date { 39 | color: #A8FF60; 40 | } 41 | 42 | pre .subst { 43 | color: #DAEFA3; 44 | } 45 | 46 | pre .regexp { 47 | color: #E9C062; 48 | } 49 | 50 | pre .function .title, 51 | pre .sub .identifier, 52 | pre .pi, 53 | pre .decorator, 54 | pre .ini .title, 55 | pre .tex .special { 56 | color: #FFFFB6; 57 | } 58 | 59 | pre .class .title, 60 | pre .constant, 61 | pre .smalltalk .class, 62 | pre .javadoctag, 63 | pre .yardoctag, 64 | pre .phpdoc, 65 | pre .nginx .built_in { 66 | color: #FFFFB6; 67 | } 68 | 69 | pre .symbol, 70 | pre .ruby .symbol .string, 71 | pre .ruby .symbol .keyword, 72 | pre .ruby .symbol .keymethods, 73 | pre .number, 74 | pre .variable, 75 | pre .vbscript, 76 | pre .literal { 77 | color: #C6C5FE; 78 | } 79 | 80 | pre .css .keyword { 81 | color: #96CBFE; 82 | } 83 | 84 | pre .css .rule .keyword, 85 | pre .css .id { 86 | color: #FFFFB6; 87 | } 88 | 89 | pre .css .class { 90 | color: #FFF; 91 | } 92 | 93 | pre .hexcolor { 94 | color: #C6C5FE; 95 | } 96 | 97 | pre .number { 98 | color:#FF73FD; 99 | } 100 | 101 | pre .tex .formula { 102 | opacity: 0.7; 103 | } 104 | -------------------------------------------------------------------------------- /examples/libraries/highlight/public/css/sunburst.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Sunburst-like style (c) Vasily Polovnyov 4 | 5 | */ 6 | 7 | pre code { 8 | display: block; padding: 0.5em; 9 | font: 1em / 1.3em 'Lucida Console', 'courier new', monospace; 10 | background: #000; color: #f8f8f8; 11 | } 12 | 13 | pre .comment, 14 | pre .template_comment, 15 | pre .javadoc { 16 | color: #aeaeae; 17 | font-style: italic; 18 | } 19 | 20 | pre .keyword, 21 | pre .ruby .function .keyword { 22 | color: #E28964; 23 | } 24 | 25 | pre .function .keyword, 26 | pre .sub .keyword, 27 | pre .method, 28 | pre .list .title { 29 | color: #99CF50; 30 | } 31 | 32 | pre .string, 33 | pre .tag .value, 34 | pre .cdata, 35 | pre .filter .argument, 36 | pre .attr_selector, 37 | pre .apache .cbracket, 38 | pre .date, 39 | pre .tex .command { 40 | color: #65B042; 41 | } 42 | 43 | pre .subst { 44 | color: #DAEFA3; 45 | } 46 | 47 | pre .regexp { 48 | color: #E9C062; 49 | } 50 | 51 | pre .function .title, 52 | pre .sub .identifier, 53 | pre .pi, 54 | pre .tag, 55 | pre .tag .keyword, 56 | pre .decorator, 57 | pre .ini .title, 58 | pre .shebang { 59 | color: #89BDFF; 60 | } 61 | 62 | pre .class .title, 63 | pre .smalltalk .class, 64 | pre .javadoctag, 65 | pre .yardoctag, 66 | pre .phpdoc { 67 | text-decoration: underline; 68 | } 69 | 70 | pre .symbol, 71 | pre .ruby .symbol .string, 72 | pre .ruby .symbol .keyword, 73 | pre .ruby .symbol .keymethods, 74 | pre .number { 75 | color: #3387CC; 76 | } 77 | 78 | pre .params, 79 | pre .variable { 80 | color: #3E87E3; 81 | } 82 | 83 | pre .css .keyword, 84 | pre .pseudo, 85 | pre .tex .special { 86 | color: #CDA869; 87 | } 88 | 89 | pre .css .class { 90 | color: #9B703F; 91 | } 92 | 93 | pre .rules .keyword { 94 | color: #C5AF75; 95 | } 96 | 97 | pre .rules .value { 98 | color: #CF6A4C; 99 | } 100 | 101 | pre .css .id { 102 | color: #8B98AB; 103 | } 104 | 105 | pre .annotation, 106 | pre .apache .sqbracket, 107 | pre .nginx .built_in { 108 | color: #9B859D; 109 | } 110 | 111 | pre .preprocessor { 112 | color: #8996A8; 113 | } 114 | 115 | pre .hexcolor, 116 | pre .css .value .number { 117 | color: #DD7B3B; 118 | } 119 | 120 | pre .css .function { 121 | color: #DAD085; 122 | } 123 | 124 | pre .diff .header, 125 | pre .chunk, 126 | pre .tex .formula { 127 | background-color: #0E2231; 128 | color: #F8F8F8; 129 | font-style: italic; 130 | } 131 | 132 | pre .diff .change { 133 | background-color: #4A410D; 134 | color: #F8F8F8; 135 | } 136 | 137 | pre .addition { 138 | background-color: #253B22; 139 | color: #F8F8F8; 140 | } 141 | 142 | pre .deletion { 143 | background-color: #420E09; 144 | color: #F8F8F8; 145 | } 146 | -------------------------------------------------------------------------------- /examples/libraries/highlight/public/css/zenburn.css: -------------------------------------------------------------------------------- 1 | /* 2 | 3 | Zenburn style from voldmar.ru (c) Vladimir Epifanov 4 | based on dark.css by Ivan Sagalaev 5 | 6 | */ 7 | 8 | pre code { 9 | display: block; padding: 0.5em; 10 | background: #3F3F3F; 11 | color: #DCDCDC; 12 | } 13 | 14 | pre .keyword, 15 | pre .tag, 16 | pre .django .tag, 17 | pre .django .keyword, 18 | pre .css .class, 19 | pre .css .id, 20 | pre .lisp .title { 21 | color: #E3CEAB; 22 | } 23 | 24 | pre .django .template_tag, 25 | pre .django .variable, 26 | pre .django .filter .argument { 27 | color: #DCDCDC; 28 | } 29 | 30 | pre .number, 31 | pre .date { 32 | color: #8CD0D3; 33 | } 34 | 35 | pre .dos .envvar, 36 | pre .dos .stream, 37 | pre .variable, 38 | pre .apache .sqbracket { 39 | color: #EFDCBC; 40 | } 41 | 42 | pre .dos .flow, 43 | pre .diff .change, 44 | pre .python .exception, 45 | pre .python .built_in, 46 | pre .literal, 47 | pre .tex .special { 48 | color: #EFEFAF; 49 | } 50 | 51 | pre .diff .chunk, 52 | pre .ruby .subst { 53 | color: #8F8F8F; 54 | } 55 | 56 | pre .dos .keyword, 57 | pre .python .decorator, 58 | pre .class .title, 59 | pre .function .title, 60 | pre .ini .title, 61 | pre .diff .header, 62 | pre .ruby .class .parent, 63 | pre .apache .tag, 64 | pre .nginx .built_in, 65 | pre .tex .command { 66 | color: #efef8f; 67 | } 68 | 69 | pre .dos .winutils, 70 | pre .ruby .symbol, 71 | pre .ruby .symbol .string, 72 | pre .ruby .symbol .keyword, 73 | pre .ruby .symbol .keymethods, 74 | pre .ruby .string, 75 | pre .ruby .instancevar { 76 | color: #DCA3A3; 77 | } 78 | 79 | pre .diff .deletion, 80 | pre .string, 81 | pre .tag .value, 82 | pre .preprocessor, 83 | pre .built_in, 84 | pre .sql .aggregate, 85 | pre .javadoc, 86 | pre .smalltalk .class, 87 | pre .smalltalk .localvars, 88 | pre .smalltalk .array, 89 | pre .css .rules .value, 90 | pre .attr_selector, 91 | pre .pseudo, 92 | pre .apache .cbracket, 93 | pre .tex .formula { 94 | color: #CC9393; 95 | } 96 | 97 | pre .shebang, 98 | pre .diff .addition, 99 | pre .comment, 100 | pre .java .annotation, 101 | pre .template_comment, 102 | pre .pi, 103 | pre .doctype { 104 | color: #7F9F7F; 105 | } 106 | 107 | pre .html .css, 108 | pre .html .javascript, 109 | pre .tex .formula { 110 | opacity: 0.5; 111 | } 112 | 113 | -------------------------------------------------------------------------------- /examples/libraries/highlight/public/javascript/css.js: -------------------------------------------------------------------------------- 1 | /* 2 | Language: CSS 3 | Requires: html-xml.js 4 | */ 5 | 6 | hljs.LANGUAGES.css = { 7 | defaultMode: { 8 | contains: ['at_rule', 'id', 'class', 'attr_selector', 'pseudo', 'rules', 'comment'], 9 | keywords: hljs.HTML_TAGS, 10 | lexems: [hljs.IDENT_RE], 11 | illegal: '=' 12 | }, 13 | case_insensitive: true, 14 | modes: [ 15 | { 16 | className: 'at_rule', 17 | begin: '@', end: '[{;]', 18 | excludeEnd: true, 19 | lexems: [hljs.IDENT_RE], 20 | keywords: {'import': 1, 'page': 1, 'media': 1, 'charset': 1, 'font-face': 1}, 21 | contains: ['function', 'string', 'number', 'pseudo'] 22 | }, 23 | { 24 | className: 'id', 25 | begin: '\\#[A-Za-z0-9_-]+', end: hljs.IMMEDIATE_RE 26 | }, 27 | { 28 | className: 'class', 29 | begin: '\\.[A-Za-z0-9_-]+', end: hljs.IMMEDIATE_RE, 30 | relevance: 0 31 | }, 32 | { 33 | className: 'attr_selector', 34 | begin: '\\[', end: '\\]', 35 | illegal: '$' 36 | }, 37 | { 38 | className: 'pseudo', 39 | begin: ':(:)?[a-zA-Z0-9\\_\\-\\+\\(\\)\\"\\\']+', end: hljs.IMMEDIATE_RE 40 | }, 41 | { 42 | className: 'rules', 43 | begin: '{', end: '}', 44 | contains: [ 45 | { 46 | className: 'rule', 47 | begin: '[A-Z\\_\\.\\-]+\\s*:', end: ';', endsWithParent: true, 48 | lexems: ['[A-Za-z-]+'], 49 | keywords: {'play-during': 1, 'counter-reset': 1, 'counter-increment': 1, 'min-height': 1, 'quotes': 1, 'border-top': 1, 'pitch': 1, 'font': 1, 'pause': 1, 'list-style-image': 1, 'border-width': 1, 'cue': 1, 'outline-width': 1, 'border-left': 1, 'elevation': 1, 'richness': 1, 'speech-rate': 1, 'border-bottom': 1, 'border-spacing': 1, 'background': 1, 'list-style-type': 1, 'text-align': 1, 'page-break-inside': 1, 'orphans': 1, 'page-break-before': 1, 'text-transform': 1, 'line-height': 1, 'padding-left': 1, 'font-size': 1, 'right': 1, 'word-spacing': 1, 'padding-top': 1, 'outline-style': 1, 'bottom': 1, 'content': 1, 'border-right-style': 1, 'padding-right': 1, 'border-left-style': 1, 'voice-family': 1, 'background-color': 1, 'border-bottom-color': 1, 'outline-color': 1, 'unicode-bidi': 1, 'max-width': 1, 'font-family': 1, 'caption-side': 1, 'border-right-width': 1, 'pause-before': 1, 'border-top-style': 1, 'color': 1, 'border-collapse': 1, 'border-bottom-width': 1, 'float': 1, 'height': 1, 'max-height': 1, 'margin-right': 1, 'border-top-width': 1, 'speak': 1, 'speak-header': 1, 'top': 1, 'cue-before': 1, 'min-width': 1, 'width': 1, 'font-variant': 1, 'border-top-color': 1, 'background-position': 1, 'empty-cells': 1, 'direction': 1, 'border-right': 1, 'visibility': 1, 'padding': 1, 'border-style': 1, 'background-attachment': 1, 'overflow': 1, 'border-bottom-style': 1, 'cursor': 1, 'margin': 1, 'display': 1, 'border-left-width': 1, 'letter-spacing': 1, 'vertical-align': 1, 'clip': 1, 'border-color': 1, 'list-style': 1, 'padding-bottom': 1, 'pause-after': 1, 'speak-numeral': 1, 'margin-left': 1, 'widows': 1, 'border': 1, 'font-style': 1, 'border-left-color': 1, 'pitch-range': 1, 'background-repeat': 1, 'table-layout': 1, 'margin-bottom': 1, 'speak-punctuation': 1, 'font-weight': 1, 'border-right-color': 1, 'page-break-after': 1, 'position': 1, 'white-space': 1, 'text-indent': 1, 'background-image': 1, 'volume': 1, 'stress': 1, 'outline': 1, 'clear': 1, 'z-index': 1, 'text-decoration': 1, 'margin-top': 1, 'azimuth': 1, 'cue-after': 1, 'left': 1, 'list-style-position': 1}, 50 | contains: [ 51 | { 52 | className: 'value', 53 | begin: hljs.IMMEDIATE_RE, endsWithParent: true, excludeEnd: true, 54 | contains: ['function', 'number', 'hexcolor', 'string', 'important', 'comment'] 55 | } 56 | ] 57 | }, 58 | 'comment' 59 | ], 60 | illegal: '[^\\s]' 61 | }, 62 | hljs.C_BLOCK_COMMENT_MODE, 63 | { 64 | className: 'number', 65 | begin: hljs.NUMBER_RE, end: hljs.IMMEDIATE_RE 66 | }, 67 | { 68 | className: 'hexcolor', 69 | begin: '\\#[0-9A-F]+', end: hljs.IMMEDIATE_RE 70 | }, 71 | { 72 | className: 'function', 73 | begin: hljs.IDENT_RE + '\\(', end: '\\)', 74 | contains: [ 75 | { 76 | className: 'params', 77 | begin: hljs.IMMEDIATE_RE, endsWithParent: true, excludeEnd: true, 78 | contains: ['number', 'string'] 79 | } 80 | ] 81 | }, 82 | { 83 | className: 'important', 84 | begin: '!important', end: hljs.IMMEDIATE_RE 85 | }, 86 | hljs.APOS_STRING_MODE, 87 | hljs.QUOTE_STRING_MODE, 88 | hljs.BACKSLASH_ESCAPE 89 | ] 90 | }; 91 | -------------------------------------------------------------------------------- /examples/libraries/highlight/public/javascript/html-xml.js: -------------------------------------------------------------------------------- 1 | /* 2 | Language: HTML, XML 3 | */ 4 | 5 | (function(){ 6 | 7 | var XML_IDENT_RE = '[A-Za-z0-9\\._:-]+'; 8 | 9 | var PI = { 10 | className: 'pi', 11 | begin: '<\\?', end: '\\?>', 12 | relevance: 10 13 | }; 14 | var DOCTYPE = { 15 | className: 'doctype', 16 | begin: '', 17 | relevance: 10 18 | }; 19 | var COMMENT = { 20 | className: 'comment', 21 | begin: '' 22 | }; 23 | var TAG = { 24 | className: 'tag', 25 | begin: '', 26 | contains: ['title', 'tag_internal'] 27 | }; 28 | var TITLE = { 29 | className: 'title', 30 | begin: XML_IDENT_RE, end: hljs.IMMEDIATE_RE 31 | }; 32 | var TAG_INTERNAL = { 33 | className: 'tag_internal', 34 | begin: hljs.IMMEDIATE_RE, endsWithParent: true, noMarkup: true, 35 | contains: ['attribute', 'value_container'], 36 | relevance: 0 37 | }; 38 | var ATTR = { 39 | className: 'attribute', 40 | begin: XML_IDENT_RE, end: hljs.IMMEDIATE_RE, 41 | relevance: 0 42 | }; 43 | var VALUE_CONTAINER_QUOT = { 44 | className: 'value_container', 45 | begin: '="', returnBegin: true, end: '"', noMarkup: true, 46 | contains: [{ 47 | className: 'value', 48 | begin: '"', endsWithParent: true 49 | }] 50 | }; 51 | var VALUE_CONTAINER_APOS = { 52 | className: 'value_container', 53 | begin: '=\'', returnBegin: true, end: '\'', noMarkup: true, 54 | contains: [{ 55 | className: 'value', 56 | begin: '\'', endsWithParent: true 57 | }] 58 | }; 59 | 60 | hljs.LANGUAGES.xml = { 61 | defaultMode: { 62 | contains: ['pi', 'doctype', 'comment', 'cdata', 'tag'] 63 | }, 64 | case_insensitive: true, 65 | modes: [ 66 | { 67 | className: 'cdata', 68 | begin: '<\\!\\[CDATA\\[', end: '\\]\\]>', 69 | relevance: 10 70 | }, 71 | PI, 72 | DOCTYPE, 73 | COMMENT, 74 | TAG, 75 | hljs.inherit(TITLE, {relevance: 1.75}), 76 | TAG_INTERNAL, 77 | ATTR, 78 | VALUE_CONTAINER_QUOT, 79 | VALUE_CONTAINER_APOS 80 | ] 81 | }; 82 | 83 | var HTML_TAGS = { 84 | 'code': 1, 'kbd': 1, 'font': 1, 'noscript': 1, 'style': 1, 'img': 1, 85 | 'title': 1, 'menu': 1, 'tt': 1, 'tr': 1, 'param': 1, 'li': 1, 'tfoot': 1, 86 | 'th': 1, 'input': 1, 'td': 1, 'dl': 1, 'blockquote': 1, 'fieldset': 1, 87 | 'big': 1, 'dd': 1, 'abbr': 1, 'optgroup': 1, 'dt': 1, 'button': 1, 88 | 'isindex': 1, 'p': 1, 'small': 1, 'div': 1, 'dir': 1, 'em': 1, 'frame': 1, 89 | 'meta': 1, 'sub': 1, 'bdo': 1, 'label': 1, 'acronym': 1, 'sup': 1, 'body': 1, 90 | 'basefont': 1, 'base': 1, 'br': 1, 'address': 1, 'strong': 1, 'legend': 1, 91 | 'ol': 1, 'script': 1, 'caption': 1, 's': 1, 'col': 1, 'h2': 1, 'h3': 1, 92 | 'h1': 1, 'h6': 1, 'h4': 1, 'h5': 1, 'table': 1, 'select': 1, 'noframes': 1, 93 | 'span': 1, 'area': 1, 'dfn': 1, 'strike': 1, 'cite': 1, 'thead': 1, 94 | 'head': 1, 'option': 1, 'form': 1, 'hr': 1, 'var': 1, 'link': 1, 'b': 1, 95 | 'colgroup': 1, 'ul': 1, 'applet': 1, 'del': 1, 'iframe': 1, 'pre': 1, 96 | 'frameset': 1, 'ins': 1, 'tbody': 1, 'html': 1, 'samp': 1, 'map': 1, 97 | 'object': 1, 'a': 1, 'xmlns': 1, 'center': 1, 'textarea': 1, 'i': 1, 'q': 1, 98 | 'u': 1, 'section': 1, 'nav': 1, 'article': 1, 'aside': 1, 'hgroup': 1, 99 | 'header': 1, 'footer': 1, 'figure': 1, 'figurecaption': 1, 'time': 1, 100 | 'mark': 1, 'wbr': 1, 'embed': 1, 'video': 1, 'audio': 1, 'source': 1, 101 | 'canvas': 1, 'datalist': 1, 'keygen': 1, 'output': 1, 'progress': 1, 102 | 'meter': 1, 'details': 1, 'summary': 1, 'command': 1 103 | }; 104 | 105 | hljs.LANGUAGES.html = { 106 | defaultMode: { 107 | contains: ['comment', 'pi', 'doctype', 'vbscript', 'tag'] 108 | }, 109 | case_insensitive: true, 110 | modes: [ 111 | { 112 | className: 'tag', 113 | begin: '', 114 | lexems: [hljs.IDENT_RE], keywords: {'style': 1}, 115 | contains: ['tag_internal'], 116 | starts: 'css' 117 | }, 118 | { 119 | className: 'tag', 120 | begin: '', 121 | lexems: [hljs.IDENT_RE], keywords: {'script': 1}, 122 | contains: ['tag_internal'], 123 | starts: 'javascript' 124 | }, 125 | { 126 | className: 'css', 127 | end: '', returnEnd: true, 128 | subLanguage: 'css' 129 | }, 130 | { 131 | className: 'javascript', 132 | end: '', returnEnd: true, 133 | subLanguage: 'javascript' 134 | }, 135 | { 136 | className: 'vbscript', 137 | begin: '<%', end: '%>', 138 | subLanguage: 'vbscript' 139 | }, 140 | COMMENT, 141 | PI, 142 | DOCTYPE, 143 | hljs.inherit(TAG), 144 | hljs.inherit(TITLE, { 145 | lexems: [hljs.IDENT_RE], keywords: HTML_TAGS 146 | }), 147 | hljs.inherit(TAG_INTERNAL), 148 | ATTR, 149 | VALUE_CONTAINER_QUOT, 150 | VALUE_CONTAINER_APOS, 151 | { 152 | className: 'value_container', 153 | begin: '=', end: hljs.IMMEDIATE_RE, 154 | contains: [ 155 | { 156 | className: 'unquoted_value', displayClassName: 'value', 157 | begin: '[^\\s/>]+', end: hljs.IMMEDIATE_RE 158 | } 159 | ] 160 | } 161 | ] 162 | }; 163 | 164 | })(); 165 | -------------------------------------------------------------------------------- /examples/libraries/highlight/public/javascript/javascript.js: -------------------------------------------------------------------------------- 1 | /* 2 | Language: Javascript 3 | */ 4 | 5 | hljs.LANGUAGES.javascript = { 6 | defaultMode: { 7 | lexems: [hljs.UNDERSCORE_IDENT_RE], 8 | contains: ['string', 'comment', 'number', 'regexp_container', 'function'], 9 | keywords: { 10 | 'keyword': {'in': 1, 'if': 1, 'for': 1, 'while': 1, 'finally': 1, 'var': 1, 'new': 1, 'function': 1, 'do': 1, 'return': 1, 'void': 1, 'else': 1, 'break': 1, 'catch': 1, 'instanceof': 1, 'with': 1, 'throw': 1, 'case': 1, 'default': 1, 'try': 1, 'this': 1, 'switch': 1, 'continue': 1, 'typeof': 1, 'delete': 1}, 11 | 'literal': {'true': 1, 'false': 1, 'null': 1} 12 | } 13 | }, 14 | modes: [ 15 | hljs.C_LINE_COMMENT_MODE, 16 | hljs.C_BLOCK_COMMENT_MODE, 17 | hljs.C_NUMBER_MODE, 18 | hljs.APOS_STRING_MODE, 19 | hljs.QUOTE_STRING_MODE, 20 | hljs.BACKSLASH_ESCAPE, 21 | { 22 | className: 'regexp_container', 23 | begin: '(' + hljs.RE_STARTERS_RE + '|case|return|throw)\\s*', end: hljs.IMMEDIATE_RE, noMarkup: true, 24 | lexems: [hljs.IDENT_RE], 25 | keywords: {'return': 1, 'throw': 1, 'case': 1}, 26 | contains: [ 27 | 'comment', 28 | { 29 | className: 'regexp', 30 | begin: '/.*?[^\\\\/]/[gim]*', end: hljs.IMMEDIATE_RE 31 | } 32 | ], 33 | relevance: 0 34 | }, 35 | { 36 | className: 'function', 37 | begin: '\\bfunction\\b', end: '{', 38 | lexems: [hljs.UNDERSCORE_IDENT_RE], 39 | keywords: {'function': 1}, 40 | contains: [ 41 | { 42 | className: 'title', 43 | begin: '[A-Za-z$_][0-9A-Za-z$_]*', end: hljs.IMMEDIATE_RE 44 | }, 45 | { 46 | className: 'params', 47 | begin: '\\(', end: '\\)', 48 | contains: ['string', 'comment'] 49 | } 50 | ] 51 | } 52 | ] 53 | }; 54 | -------------------------------------------------------------------------------- /examples/libraries/highlight/public/javascript/php.js: -------------------------------------------------------------------------------- 1 | /* 2 | Language: PHP 3 | Author: Victor Karamzin 4 | */ 5 | 6 | hljs.LANGUAGES.php = { 7 | defaultMode: { 8 | lexems: [hljs.IDENT_RE], 9 | contains: ['comment', 'number', 'string', 'variable', 'preprocessor'], 10 | keywords: { 11 | 'and': 1, 'include_once': 1, 'list': 1, 'abstract': 1, 'global': 1, 12 | 'private': 1, 'echo': 1, 'interface': 1, 'as': 1, 'static': 1, 13 | 'endswitch': 1, 'array': 1, 'null': 1, 'if': 1, 'endwhile': 1, 'or': 1, 14 | 'const': 1, 'for': 1, 'endforeach': 1, 'self': 1, 'var': 1, 'while': 1, 15 | 'isset': 1, 'public': 1, 'protected': 1, 'exit': 1, 'foreach': 1, 16 | 'throw': 1, 'elseif': 1, 'extends': 1, 'include': 1, '__FILE__': 1, 17 | 'empty': 1, 'require_once': 1, 'function': 1, 'do': 1, 'xor': 1, 18 | 'return': 1, 'implements': 1, 'parent': 1, 'clone': 1, 'use': 1, 19 | '__CLASS__': 1, '__LINE__': 1, 'else': 1, 'break': 1, 'print': 1, 20 | 'eval': 1, 'new': 1, 'catch': 1, '__METHOD__': 1, 'class': 1, 'case': 1, 21 | 'exception': 1, 'php_user_filter': 1, 'default': 1, 'die': 1, 22 | 'require': 1, '__FUNCTION__': 1, 'enddeclare': 1, 'final': 1, 'try': 1, 23 | 'this': 1, 'switch': 1, 'continue': 1, 'endfor': 1, 'endif': 1, 24 | 'declare': 1, 'unset': 1, 'true': 1, 'false': 1, 'namespace': 1 25 | } 26 | }, 27 | case_insensitive: true, 28 | modes: [ 29 | hljs.C_LINE_COMMENT_MODE, 30 | hljs.HASH_COMMENT_MODE, 31 | { 32 | className: 'comment', 33 | begin: '/\\*', end: '\\*/', 34 | contains: [{ 35 | className: 'phpdoc', 36 | begin: '\\s@[A-Za-z]+', end: hljs.IMMEDIATE_RE, 37 | relevance: 10 38 | }] 39 | }, 40 | hljs.C_NUMBER_MODE, 41 | { 42 | className: 'string', 43 | begin: '\'', end: '\'', 44 | contains: ['escape'], 45 | relevance: 0 46 | }, 47 | { 48 | className: 'string', 49 | begin: '"', end: '"', 50 | contains: ['escape'], 51 | relevance: 0 52 | }, 53 | hljs.BACKSLASH_ESCAPE, 54 | { 55 | className: 'variable', 56 | begin: '\\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*', end: hljs.IMMEDIATE_RE 57 | }, 58 | { 59 | className: 'preprocessor', 60 | begin: '<\\?php', end: hljs.IMMEDIATE_RE, 61 | relevance: 10 62 | }, 63 | { 64 | className: 'preprocessor', 65 | begin: '\\?>', end: hljs.IMMEDIATE_RE 66 | } 67 | ] 68 | }; 69 | -------------------------------------------------------------------------------- /examples/public/css/reset.css: -------------------------------------------------------------------------------- 1 | /* = FONT STACKS 2 | ----------------------------------------------------------------------------------------------------------------------*/ 3 | body { font-family: Geneva, 'Lucida Sans', 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif } /* "wide" sans serif */ 4 | /*body { font-family: Tahoma, Arial, Helvetica, sans-serif } /* "narrow" sans serif */ 5 | /*body { font-family: Georgia, Utopia, Palatino, 'Palatino Linotype', serif } /* "wide" serif */ 6 | /*body { font-family: 'Times New Roman', Times, serif } /* "narrow" serif */ 7 | 8 | 9 | /* transform the font size so that 1em is 10px so that you can use em's 10 | but think in pixels as now 1em is 10px, 1.2em is 12px and so on */ 11 | 12 | html { font-size: 62.5% } 13 | 14 | body { 15 | font-size: 1.3em; 16 | margin: 0; 17 | padding: 0; 18 | outline: 0; 19 | border: 0; 20 | text-align: center; /* this is for IE6 so that it will center the main wrapper */ 21 | line-height: 1.2; /* unit-less line-height does not inherit a percentage value of its parent element */ 22 | /* but instead is based on a multiplier of the font-size */ 23 | } 24 | 25 | div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, aabbr, acronym, address, 26 | big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, 27 | center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td { 28 | 29 | margin: 0; 30 | padding: 0; 31 | outline: 0; 32 | border: 0; 33 | font-family: inherit; 34 | font-weight: inherit; 35 | font-style: inherit; 36 | line-height: inherit; 37 | 38 | } 39 | 40 | a, blockquote, dd, div, dl, dt, fieldset, form, h1, h2, h3, h4, h5, h6, img, input, label, li, ol, p, pre, span, table, ul { 41 | 42 | position: relative 43 | 44 | } 45 | 46 | h1, h2, h3, h4, h5, h6 { font-weight: normal; line-height: 1 } 47 | 48 | p { font-size: 100% } 49 | h1 { font-size: 220% } 50 | h2 { font-size: 200% } 51 | h3 { font-size: 180% } 52 | h4 { font-size: 160% } 53 | h5 { font-size: 140% } 54 | h6 { font-size: 120% } 55 | 56 | small, 57 | sup, 58 | sub { font-size: 70% } 59 | 60 | p small { display: block; line-height: 1 } 61 | 62 | strong, b { font-weight: bold } 63 | em, i { font-style: italic } 64 | 65 | /* = CLEARFIX 66 | ----------------------------------------------------------------------------------------------------------------------*/ 67 | .clearfix:before, 68 | .clearfix:after { content: "\0020"; display: block; height: 0; visibility: hidden; font-size: 0 } 69 | .clearfix:after { clear: both } 70 | .clearfix { *zoom: 1 } /* for IE only */ 71 | 72 | /* = TABLES 73 | ----------------------------------------------------------------------------------------------------------------------*/ 74 | table { 75 | 76 | border-collapse: collapse; 77 | border-spacing: 0; 78 | /* tables still need cellspacing="0" */ 79 | 80 | } 81 | 82 | /* = LISTS 83 | ----------------------------------------------------------------------------------------------------------------------*/ 84 | ul, ol { list-style: none } 85 | 86 | ul.float li, 87 | ol.float li { float: left } 88 | 89 | ul.default, 90 | ol.default, 91 | ol.default ul, 92 | ul.default ul, 93 | ul.default ol, 94 | ol.default ol { padding-left: 1.5em } 95 | 96 | ul.default, 97 | ol.default ul, 98 | ul.default ul { list-style-type: square } 99 | 100 | ol.default, 101 | ul.default ol, 102 | ol.default ol { list-style-type: decimal } -------------------------------------------------------------------------------- /examples/public/css/style.css: -------------------------------------------------------------------------------- 1 | body { text-align: left; margin: 20px } 2 | 3 | .header { background: #888; padding: 10px 5px; font-weight: bold } 4 | .header a { color: #FFF; text-decoration: none } 5 | .header span { font-weight: normal } 6 | .example { background: #ABCDEF; padding: 10px 5px; font-weight: bold; margin: 0 0 20px } 7 | .example a { color: #123456; font-weight: normal } 8 | 9 | h1 { margin-bottom: 1em } 10 | h1 span { display: block; font-size: 11px; color: #666 } 11 | 12 | .navigation { border-right: 1px solid #DEDEDE; padding-right: 20px; margin-right: 20px } 13 | .navigation li { font-weight: bold; margin: 0 } 14 | .navigation li ul { color: #AAA; margin: 10px 0 } 15 | .navigation a { color: #000066; white-space: nowrap; font-weight: normal; text-decoration: none; display: block; padding: 2px } 16 | .navigation a.selected { color: #DDD; background: #222 } 17 | 18 | .tabs { } 19 | .tabs a { display: block; background: #000; color: #FFF; padding: 4px 10px; text-decoration: none; margin-right: 1px; font-weight: bold } 20 | .tabs a:hover, 21 | .tabs a.selected { background: #DEDEDE; color: #222 } 22 | 23 | .tab { border: 1px solid #DEDEDE; padding: 20px; display: none } 24 | 25 | .tab h2 { font-weight: bold; margin: 0 0 20px } 26 | .tab p { color: #999; margin: 0 0 20px; font-size: 12px } 27 | 28 | ul.notes { color: #999; font-size: 11px; margin: 20px 0 0 } 29 | 30 | table.results { border-collapse: collapse } 31 | table.results th, 32 | table.results td { padding: 5px; border: 1px solid #DEDEDE } 33 | table.results th { font-weight: bold } 34 | table.results thead td { background: #666; color: #FFF; font-weight: bold } 35 | 36 | img.Zebra_Form_Input_Prefix { width: 16px; height: 16px } 37 | 38 | .tab a { color: #0000FF; text-decoration: none } 39 | 40 | /* = MISCELLANEOUS 41 | ----------------------------------------------------------------------------------------------------------------------*/ 42 | .align-center { text-align: center } 43 | .align-left { text-align: left } 44 | .align-right { text-align: right } 45 | .block { display: block } 46 | .bottom { margin-bottom: 0; padding-bottom: 0 } 47 | .center { text-align: center } 48 | .clear { clear: both } 49 | .first { margin-left: 0; padding-left: 0 } 50 | .hidden { visibility: hidden } 51 | .highlight { background: #ccf } 52 | .inline { display: inline } 53 | .last { margin-right: 0; padding-right: 0 } 54 | .left { float: left } 55 | .none { display: none } 56 | .nowrap { white-space: nowrap } 57 | .right { float: right } 58 | .stretch { width: 100% } 59 | .top { margin-top: 0; padding-top: 0 } 60 | .visible { visibility: visible } 61 | 62 | img.Zebra_Form_prefix { width: 16px; height: 16px } -------------------------------------------------------------------------------- /examples/public/images/comment.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefangabos/Zebra_Form/8012285955ad311a0bc8ea13572b971e4aed5e74/examples/public/images/comment.png -------------------------------------------------------------------------------- /examples/public/images/letter.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefangabos/Zebra_Form/8012285955ad311a0bc8ea13572b971e4aed5e74/examples/public/images/letter.png -------------------------------------------------------------------------------- /examples/public/images/user.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefangabos/Zebra_Form/8012285955ad311a0bc8ea13572b971e4aed5e74/examples/public/images/user.png -------------------------------------------------------------------------------- /examples/public/javascript/core.js: -------------------------------------------------------------------------------- 1 | $(document).ready(function() { 2 | 3 | hljs.initHighlightingOnLoad(); 4 | 5 | $('a').bind('click', function() { this.blur() }); 6 | 7 | var tab_selectors = $('.tabs a'); 8 | 9 | var tabs = $('.tab'); 10 | 11 | tab_selectors.each(function(index, selector) { 12 | $(selector).bind('click', function(e) { 13 | e.preventDefault(); 14 | tab_selectors.removeClass('selected'); 15 | $(this).addClass('selected'); 16 | tabs.css('display', 'none'); 17 | $(tabs[index]).css({ 18 | 'opacity': 0, 19 | 'display': 'block' 20 | }); 21 | $(tabs[index]).animate({'opacity': 1}, 250); 22 | }); 23 | }); 24 | 25 | }); -------------------------------------------------------------------------------- /includes/Button.php: -------------------------------------------------------------------------------- 1 | 7 | * @copyright (c) 2006 - 2016 Stefan Gabos 8 | * @package Controls 9 | */ 10 | class Zebra_Form_Button extends Zebra_Form_Control 11 | { 12 | 13 | /** 14 | * Constructor of the class 15 | * 16 | * Adds an '; 145 | 146 | } 147 | 148 | } 149 | 150 | ?> -------------------------------------------------------------------------------- /includes/Captcha.php: -------------------------------------------------------------------------------- 1 | 7 | * @copyright (c) 2006 - 2016 Stefan Gabos 8 | * @package Controls 9 | */ 10 | 11 | class Zebra_Form_Captcha extends Zebra_Form_Control 12 | { 13 | 14 | /** 15 | * Adds a CAPTCHA image to the form. 16 | * 17 | * Do not instantiate this class directly! Use the {@link Zebra_Form::add() add()} method instead! 18 | * 19 | * You must also place a {@link Zebra_Form_Text textbox} control on the form and set the "captcha" rule to it! 20 | * (through {@link set_rule()}) 21 | * 22 | * Properties of the CAPTCHA image can be altered by editing the file includes/captcha.php. 23 | * 24 | * By default, captcha values are triple md5 hashed and stored in cookies, and when the user enters the captcha 25 | * value the value is also triple md5 hashed and the two values are then compared. Sometimes, your users may have 26 | * a very restrictive cookie policy and so cookies will not be set, and therefore they will never be able to get 27 | * past the CAPTCHA control. If it's the case, call the {@link Zebra_Form::captcha_storage() captcha_storage} 28 | * method and set the storage method to "session". 29 | * 30 | * 31 | * // create a new form 32 | * $form = new Zebra_Form('my_form'); 33 | * 34 | * // add a CAPTCHA image 35 | * $form->add('captcha', 'my_captcha', 'my_text'); 36 | * 37 | * // add a label for the textbox 38 | * $form->add('label', 'label_my_text', 'my_text', 'Are you human?'); 39 | * 40 | * // add a CAPTCHA to the form 41 | * $obj = $form->add('text', 'my_text'); 42 | * 43 | * // set the "captcha" rule to the textbox 44 | * $obj->set_rule(array( 45 | * 'captcha' => array('error', 'Characters not entered correctly!') 46 | * )); 47 | * 48 | * // don't forget to always call this method before rendering the form 49 | * if ($form->validate()) { 50 | * // put code here 51 | * } 52 | * 53 | * // output the form using an automatically generated template 54 | * $form->render(); 55 | * 56 | * 57 | * @param string $id Unique name to identify the control in the form. 58 | * 59 | * This is the name of the variable to be used in the template file, containing 60 | * the generated HTML for the control. 61 | * 62 | * 63 | * // in a template file, in order to print the generated HTML 64 | * // for a control named "my_captcha", one would use: 65 | * echo $my_captcha; 66 | * 67 | * 68 | * @param string $attach_to The id attribute of the {@link Zebra_Form_Text textbox} control to attach 69 | * the CAPTCHA image to. 70 | * 71 | * @return void 72 | */ 73 | function __construct($id, $attach_to, $storage = 'cookie') 74 | { 75 | 76 | // call the constructor of the parent class 77 | parent::__construct(); 78 | 79 | // set the private attributes of this control 80 | // these attributes are private for this control and are for internal use only 81 | // and will not be rendered by the _render_attributes() method 82 | $this->private_attributes = array( 83 | 84 | 'disable_xss_filters', 85 | 'for', 86 | 'locked', 87 | 88 | ); 89 | 90 | // set the default attributes for the text control 91 | // put them in the order you'd like them rendered 92 | $this->set_attributes( 93 | 94 | array( 95 | 96 | 'type' => 'captcha', 97 | 'name' => $id, 98 | 'id' => $id, 99 | 'for' => $attach_to, 100 | 101 | ) 102 | 103 | ); 104 | 105 | } 106 | 107 | /** 108 | * Generates the control's HTML code. 109 | * 110 | * This method is automatically called by the {@link Zebra_Form::render() render()} method! 111 | * 112 | * @return string The control's HTML code 113 | */ 114 | function toHTML() 115 | { 116 | 117 | return '
form_properties['doctype'] == 'xhtml' ? '/' : '') . '>' . $this->form_properties['language']['new_captcha'] . '
'; 118 | 119 | } 120 | 121 | } 122 | 123 | ?> 124 | -------------------------------------------------------------------------------- /includes/File.php: -------------------------------------------------------------------------------- 1 | 7 | * @copyright (c) 2006 - 2016 Stefan Gabos 8 | * @package Controls 9 | */ 10 | class Zebra_Form_File extends Zebra_Form_Control 11 | { 12 | 13 | /** 14 | * Adds an control to the form. 15 | * 16 | * Do not instantiate this class directly! Use the {@link Zebra_Form::add() add()} method instead! 17 | * 18 | * 19 | * // create a new form 20 | * $form = new Zebra_Form('my_form'); 21 | * 22 | * // add a file upload control to the form 23 | * $obj = $form->add('file', 'my_file_upload'); 24 | * 25 | * // don't forget to always call this method before rendering the form 26 | * if ($form->validate()) { 27 | * 28 | * // all the information about the uploaded file will be 29 | * // available in the "file_upload" property 30 | * print_r('
');
 31 |      *      print_r($form->file_upload['my_file_upload']);
 32 |      *
 33 |      *  }
 34 |      *
 35 |      *  // output the form using an automatically generated template
 36 |      *  $form->render();
 37 |      *  
 38 |      *
 39 |      *  @param  string  $id             Unique name to identify the control in the form.
 40 |      *
 41 |      *                                  The control's name attribute will be the same as the id attribute!
 42 |      *
 43 |      *                                  This is the name to be used when referring to the control's value in the
 44 |      *                                  POST/GET superglobals, after the form is submitted.
 45 |      *
 46 |      *                                  This is also the name of the variable to be used in custom template files, in
 47 |      *                                  order to display the control.
 48 |      *
 49 |      *                                  
 50 |      *                                  // in a template file, in order to print the generated HTML
 51 |      *                                  // for a control named "my_file_upload", one would use:
 52 |      *                                  echo $my_file_upload;
 53 |      *                                  
 54 |      *
 55 |      *  @param  array   $attributes     (Optional) An array of attributes valid for
 56 |      *                                  {@link http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.4 input}
 57 |      *                                  controls (size, readonly, style, etc)
 58 |      *
 59 |      *                                  Must be specified as an associative array, in the form of attribute => value.
 60 |      *                                  
 61 |      *                                  // setting the "disabled" attribute
 62 |      *                                  $obj = $form->add(
 63 |      *                                      'file',
 64 |      *                                      'my_file_upload',
 65 |      *                                      '',
 66 |      *                                      array(
 67 |      *                                          'disabled' => 'disabled'
 68 |      *                                      )
 69 |      *                                  );
 70 |      *                                  
 71 |      *
 72 |      *                                  See {@link Zebra_Form_Control::set_attributes() set_attributes()} on how to set
 73 |      *                                  attributes, other than through the constructor.
 74 |      *
 75 |      *                                  The following attributes are automatically set when the control is created and
 76 |      *                                  should not be altered manually:
77 | * 78 | * type, id, name, class 79 | * 80 | * @return void 81 | */ 82 | function __construct($id, $attributes = '') 83 | { 84 | 85 | // call the constructor of the parent class 86 | parent::__construct(); 87 | 88 | // set the private attributes of this control 89 | // these attributes are private for this control and are for internal use only 90 | // and will not be rendered by the _render_attributes() method 91 | $this->private_attributes = array( 92 | 93 | 'disable_xss_filters', 94 | 'locked', 95 | 'files', 96 | 97 | ); 98 | 99 | // set the default attributes for the text control 100 | // put them in the order you'd like them rendered 101 | $this->set_attributes( 102 | 103 | array( 104 | 105 | 'type' => 'file', 106 | 'name' => $id, 107 | 'id' => str_replace(array('[', ']'), '', $id), 108 | 'class' => 'control file', 109 | 110 | ) 111 | 112 | ); 113 | 114 | // if "class" is amongst user specified attributes 115 | if (is_array($attributes) && isset($attributes['class'])) { 116 | 117 | // we need to set the "class" attribute like this, so it doesn't overwrite previous values 118 | $this->set_attributes(array('class' => $attributes['class']), false); 119 | 120 | // make sure we don't set it again below 121 | unset($attributes['class']); 122 | 123 | } 124 | 125 | // sets user specified attributes for the control 126 | $this->set_attributes($attributes); 127 | 128 | } 129 | 130 | /** 131 | * Generates the control's HTML code. 132 | * 133 | * This method is automatically called by the {@link Zebra_Form::render() render()} method! 134 | * 135 | * @return string The control's HTML code 136 | */ 137 | function toHTML() 138 | { 139 | 140 | // all file upload controls must have the "upload" rule set or we trigger an error 141 | if (!isset($this->rules['upload'])) _zebra_form_show_error('The control named "' . $this->attributes['name'] . '" in form "' . $this->form_properties['name'] . '" must have the "upload" rule set', E_USER_ERROR); 142 | 143 | // if the "image" rule is set 144 | if (isset($this->rules['image'])) 145 | 146 | // these are the allowed file extensions 147 | $allowed_file_types = array('jpe', 'jpg', 'jpeg', 'png', 'gif'); 148 | 149 | // if the "filetype" rule is set 150 | elseif (isset($this->rules['filetype'])) 151 | 152 | // get the array of allowed file extensions 153 | $allowed_file_types = array_map('trim', explode(',', $this->rules['filetype'][0])); 154 | 155 | // if file selection should be restricted to certain file types 156 | if (isset($allowed_file_types)) { 157 | 158 | $mimes = array(); 159 | 160 | // iterate through allowed extensions 161 | foreach ($allowed_file_types as $extension) 162 | 163 | // get the mime type for each extension 164 | if (isset($this->form_properties['mimes'][$extension])) 165 | 166 | $mimes = array_merge($mimes, (array)$this->form_properties['mimes'][$extension]); 167 | 168 | // set the "accept" attribute 169 | // see http://www.whatwg.org/specs/web-apps/current-work/multipage/states-of-the-type-attribute.html#file-upload-state-%28type=file%29 170 | // at the time of writing, on December 30, 2012, this was only working on Chrome 23 and IE 10 171 | $this->set_attributes(array('accept' => '.' . implode(',.', $allowed_file_types) . ',' . implode(',', $mimes))); 172 | 173 | } 174 | 175 | // show the file upload control 176 | $output = '_render_attributes() . ($this->form_properties['doctype'] == 'xhtml' ? '/' : '') . '>'; 177 | 178 | // return the generated output 179 | return $output; 180 | 181 | } 182 | 183 | } 184 | 185 | ?> 186 | -------------------------------------------------------------------------------- /includes/Hidden.php: -------------------------------------------------------------------------------- 1 | 7 | * @copyright (c) 2006 - 2016 Stefan Gabos 8 | * @package Controls 9 | */ 10 | class Zebra_Form_Hidden extends Zebra_Form_Control 11 | { 12 | 13 | /** 14 | * Adds an control to the form. 15 | * 16 | * Do not instantiate this class directly! Use the {@link Zebra_Form::add() add()} method instead! 17 | * 18 | * 19 | * // create a new form 20 | * $form = new Zebra_Form('my_form'); 21 | * 22 | * // add a hidden control to the form 23 | * $obj = $form->add('hidden', 'my_hidden', 'Secret value'); 24 | * 25 | * // don't forget to always call this method before rendering the form 26 | * if ($form->validate()) { 27 | * // put code here 28 | * } 29 | * 30 | * // output the form using an automatically generated template 31 | * $form->render(); 32 | * 33 | * 34 | * @param string $id Unique name to identify the control in the form. 35 | * 36 | * The control's name attribute will be the same as the id attribute! 37 | * 38 | * This is the name to be used when referring to the control's value in the 39 | * POST/GET superglobals, after the form is submitted. 40 | * 41 | * Hidden controls are automatically rendered when the {@link Zebra_Form::render() render()} 42 | * method is called!
43 | * Do not print them in template files! 44 | * 45 | * @param string $default (Optional) Default value of the text box. 46 | * 47 | * @return void 48 | */ 49 | function __construct($id, $default = '') 50 | { 51 | 52 | // call the constructor of the parent class 53 | parent::__construct(); 54 | 55 | // set the private attributes of this control 56 | // these attributes are private for this control and are for internal use only 57 | // and will not be rendered by the _render_attributes() method 58 | $this->private_attributes = array( 59 | 60 | 'disable_xss_filters', 61 | 'locked', 62 | 63 | ); 64 | 65 | // set the default attributes for the hidden control 66 | // put them in the order you'd like them rendered 67 | 68 | // notice that if control's name is 'MAX_FILE_SIZE' we'll generate a random ID attribute for the control 69 | // as, with multiple forms having upload controls on them, this hidden control appears as many times as the 70 | // forms do and we don't want to have the same ID assigned to multiple controls 71 | $this->set_attributes( 72 | 73 | array( 74 | 75 | 'type' => 'hidden', 76 | 'name' => $id, 77 | 'id' => ($id != 'MAX_FILE_SIZE' ? str_replace(array('[', ']'), '', $id) : 'mfs_' . rand(0, 100000)), 78 | 'value' => $default, 79 | 80 | ) 81 | 82 | ); 83 | 84 | } 85 | 86 | /** 87 | * Generates the control's HTML code. 88 | * 89 | * This method is automatically called by the {@link Zebra_Form::render() render()} method! 90 | * 91 | * @return string The control's HTML code 92 | */ 93 | function toHTML() 94 | { 95 | 96 | return '_render_attributes() . ($this->form_properties['doctype'] == 'xhtml' ? '/' : '') . '>'; 97 | 98 | } 99 | 100 | } 101 | 102 | ?> 103 | -------------------------------------------------------------------------------- /includes/Image.php: -------------------------------------------------------------------------------- 1 | 7 | * @copyright (c) 2006 - 2016 Stefan Gabos 8 | * @package Controls 9 | */ 10 | class Zebra_Form_Image extends Zebra_Form_Control 11 | { 12 | 13 | /** 14 | * Adds an control to the form. 15 | * 16 | * Do not instantiate this class directly! Use the {@link Zebra_Form::add() add()} method instead! 17 | * 18 | * 19 | * // create a new form 20 | * $form = new Zebra_Form('my_form'); 21 | * 22 | * // add an image control to the form 23 | * $obj = $form->add('image', 'my_image', 'path/to/image'); 24 | * 25 | * // don't forget to always call this method before rendering the form 26 | * if ($form->validate()) { 27 | * // put code here 28 | * } 29 | * 30 | * // output the form using an automatically generated template 31 | * $form->render(); 32 | * 33 | * 34 | * @param string $id Unique name to identify the control in the form. 35 | * 36 | * The control's name attribute will be the same as the id attribute! 37 | * 38 | * This is the name to be used when referring to the control's value in the 39 | * POST/GET superglobals, after the form is submitted. 40 | * 41 | * This is also the name of the variable to be used in custom template files, in 42 | * order to display the control. 43 | * 44 | * 45 | * // in a template file, in order to print the generated HTML 46 | * // for a control named "my_image", one would use: 47 | * echo $my_image; 48 | * 49 | * 50 | * @param string $src (Optional) Path to an image file. 51 | * 52 | * @param array $attributes (Optional) An array of attributes valid for 53 | * {@link http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.4 input} 54 | * controls (size, readonly, style, etc) 55 | * 56 | * Must be specified as an associative array, in the form of attribute => value. 57 | * 58 | * // setting the "alt" attribute 59 | * $obj = $form->add( 60 | * 'image', 61 | * 'my_image', 62 | * 'path/to/image', 63 | * array( 64 | * 'alt' => 'Click to submit form' 65 | * ) 66 | * ); 67 | * 68 | * 69 | * See {@link Zebra_Form_Control::set_attributes() set_attributes()} on how to set 70 | * attributes, other than through the constructor. 71 | * 72 | * The following attributes are automatically set when the control is created and 73 | * should not be altered manually:
74 | * 75 | * type, id, name, src, class 76 | * 77 | * @return void 78 | */ 79 | function __construct($id, $src, $attributes = '') 80 | { 81 | 82 | // call the constructor of the parent class 83 | parent::__construct(); 84 | 85 | // set the private attributes of this control 86 | // these attributes are private for this control and are for internal use only 87 | // and will not be rendered by the _render_attributes() method 88 | $this->private_attributes = array( 89 | 90 | 'disable_xss_filters', 91 | 'locked', 92 | 93 | ); 94 | 95 | // set the default attributes for the image control 96 | // put them in the order you'd like them rendered 97 | $this->set_attributes( 98 | 99 | array( 100 | 101 | 'alt' => $id, 102 | 'class' => 'image', 103 | 'id' => $id, 104 | 'name' => $id, 105 | 'src' => $src, 106 | 'type' => 'image', 107 | 108 | ) 109 | 110 | ); 111 | 112 | // if "class" is amongst user specified attributes 113 | if (is_array($attributes) && isset($attributes['class'])) { 114 | 115 | // we need to set the "class" attribute like this, so it doesn't overwrite previous values 116 | $this->set_attributes(array('class' => $attributes['class']), false); 117 | 118 | // make sure we don't set it again below 119 | unset($attributes['class']); 120 | 121 | } 122 | 123 | // sets user specified attributes for the table cell 124 | $this->set_attributes($attributes); 125 | 126 | } 127 | 128 | /** 129 | * Generates the control's HTML code. 130 | * 131 | * This method is automatically called by the {@link Zebra_Form::render() render()} method! 132 | * 133 | * @return string The control's HTML code 134 | */ 135 | function toHTML() 136 | { 137 | 138 | return '_render_attributes() . ($this->form_properties['doctype'] == 'xhtml' ? '/' : '') . '>'; 139 | 140 | } 141 | 142 | } 143 | 144 | ?> 145 | -------------------------------------------------------------------------------- /includes/Note.php: -------------------------------------------------------------------------------- 1 | 7 | * @copyright (c) 2006 - 2016 Stefan Gabos 8 | * @package Controls 9 | */ 10 | class Zebra_Form_Note extends Zebra_Form_Control 11 | { 12 | 13 | /** 14 | * Adds a "note" to the form, attached to a control. 15 | * 16 | * Do not instantiate this class directly! Use the {@link Zebra_Form::add() add()} method instead! 17 | * 18 | * 19 | * // create a new form 20 | * $form = new Zebra_Form('my_form'); 21 | * 22 | * // add a text control to the form 23 | * $obj = $form->add('text', 'my_text'); 24 | * 25 | * // attach a note to the textbox control 26 | * $form->add('note', 'note_my_text', 'my_text', 'Enter some text in the field above'); 27 | * 28 | * // don't forget to always call this method before rendering the form 29 | * if ($form->validate()) { 30 | * // put code here 31 | * } 32 | * 33 | * // output the form using an automatically generated template 34 | * $form->render(); 35 | * 36 | * 37 | * @param string $id Unique name to identify the control in the form. 38 | * 39 | * This is the name of the variable to be used in the template file, containing 40 | * the generated HTML for the control. 41 | * 42 | * 43 | * // in a template file, in order to print the generated HTML 44 | * // for a control named "my_note", one would use: 45 | * echo $my_note; 46 | * 47 | * 48 | * @param string $attach_to The id attribute of the control to attach the note to. 49 | * 50 | * Notice that this must be the "id" attribute of the control you are attaching 51 | * the label to, and not the "name" attribute! 52 | * 53 | * This is important as while most of the controls have their id attribute 54 | * set to the same value as their name attribute, for {@link Zebra_Form_Checkbox checkboxes}, 55 | * {@link Zebra_Form_Select selects} and {@link Zebra_Form_Radio radio buttons} this 56 | * is different. 57 | * 58 | * Exception to the rule: 59 | * 60 | * Just like in the case of {@link Zebra_Form_Label labels}, if you want a master 61 | * note, a note that is attached to a group of checkboxes/radio buttons rather than 62 | * individual controls, this attribute must instead refer to the name of the 63 | * controls (which, for groups of checkboxes/radio buttons, is one and the same). 64 | * 65 | * @param string $caption Content of the note (can be both plain text and/or HTML) 66 | * 67 | * @param array $attributes (Optional) An array of attributes valid for 68 | * {@link http://www.w3.org/TR/REC-html40/struct/global.html#h-7.5.4 div} 69 | * elements (style, etc) 70 | * 71 | * Must be specified as an associative array, in the form of attribute => value. 72 | * 73 | * // setting the "style" attribute 74 | * $obj = $form->add( 75 | * 'note', 76 | * 'note_my_text', 77 | * 'my_text', 78 | * array( 79 | * 'style' => 'width:250px' 80 | * ) 81 | * ); 82 | * 83 | * 84 | * See {@link Zebra_Form_Control::set_attributes() set_attributes()} on how to set 85 | * attributes, other than through the constructor. 86 | * 87 | * The following attributes are automatically set when the control is created and 88 | * should not be altered manually:
89 | * class 90 | * 91 | * @return void 92 | */ 93 | function __construct($id, $attach_to, $caption, $attributes = '') 94 | { 95 | 96 | // call the constructor of the parent class 97 | parent::__construct(); 98 | 99 | // set the private attributes of this control 100 | // these attributes are private for this control and are for internal use only 101 | $this->private_attributes = array( 102 | 103 | 'caption', 104 | 'disable_xss_filters', 105 | 'locked', 106 | 'for', 107 | 'name', 108 | 'type', 109 | 110 | ); 111 | 112 | 113 | // set the default attributes for the HTML control 114 | $this->set_attributes( 115 | 116 | array( 117 | 118 | 'class' => 'note', 119 | 'caption' => $caption, 120 | 'for' => $attach_to, 121 | 'id' => $id, 122 | 'name' => $id, 123 | 'type' => 'note', 124 | 125 | ) 126 | 127 | ); 128 | 129 | // if "class" is amongst user specified attributes 130 | if (is_array($attributes) && isset($attributes['class'])) { 131 | 132 | // we need to set the "class" attribute like this, so it doesn't overwrite previous values 133 | $this->set_attributes(array('class' => $attributes['class']), false); 134 | 135 | // make sure we don't set it again below 136 | unset($attributes['class']); 137 | 138 | } 139 | 140 | // sets user specified attributes for the control 141 | $this->set_attributes($attributes); 142 | 143 | } 144 | 145 | /** 146 | * Generates the control's HTML code. 147 | * 148 | * This method is automatically called by the {@link Zebra_Form::render() render()} method! 149 | * 150 | * @return string The control's HTML code 151 | */ 152 | function toHTML() 153 | { 154 | 155 | $attributes = $this->get_attributes('caption'); 156 | 157 | return '
_render_attributes() . '>' . $attributes['caption'] . '
'; 158 | 159 | } 160 | 161 | } 162 | 163 | ?> 164 | -------------------------------------------------------------------------------- /includes/Password.php: -------------------------------------------------------------------------------- 1 | 7 | * @copyright (c) 2006 - 2016 Stefan Gabos 8 | * @package Controls 9 | */ 10 | class Zebra_Form_Password extends Zebra_Form_Control 11 | { 12 | 13 | /** 14 | * Adds an control to the form. 15 | * 16 | * Do not instantiate this class directly! Use the {@link Zebra_Form::add() add()} method instead! 17 | * 18 | * 19 | * // create a new form 20 | * $form = new Zebra_Form('my_form'); 21 | * 22 | * // add a password control to the form 23 | * $obj = $form->add('password', 'my_password'); 24 | * 25 | * // don't forget to always call this method before rendering the form 26 | * if ($form->validate()) { 27 | * // put code here 28 | * } 29 | * 30 | * // output the form using an automatically generated template 31 | * $form->render(); 32 | * 33 | * 34 | * @param string $id Unique name to identify the control in the form. 35 | * 36 | * The control's name attribute will be the same as the id attribute! 37 | * 38 | * This is the name to be used when referring to the control's value in the 39 | * POST/GET superglobals, after the form is submitted. 40 | * 41 | * This is also the name of the variable to be used in custom template files, in 42 | * order to display the control. 43 | * 44 | * 45 | * // in a template file, in order to print the generated HTML 46 | * // for a control named "my_password", one would use: 47 | * echo $my_password; 48 | * 49 | * 50 | * @param string $default (Optional) Default value of the password field. 51 | * 52 | * @param array $attributes (Optional) An array of attributes valid for 53 | * {@link http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.4 input} 54 | * controls (size, readonly, style, etc) 55 | * 56 | * Must be specified as an associative array, in the form of attribute => value. 57 | * 58 | * // setting the "disabled" attribute 59 | * $obj = $form->add( 60 | * 'password', 61 | * 'my_password', 62 | * '', 63 | * array( 64 | * 'disabled' => 'disabled' 65 | * ) 66 | * ); 67 | * 68 | * 69 | * There's a special data-prefix attribute that you can use to add uneditable 70 | * prefixes to input fields (text, images, or plain HTML), as seen in the image 71 | * below. It works by injecting an absolutely positioned element into the DOM, right 72 | * after the parent element, and then positioning it on the left side of the parent 73 | * element and adjusting the width and the left padding of the parent element, so it 74 | * looks like the prefix is part of the parent element. 75 | * 76 | * If the prefix is plain text or HTML code, it will be contained in a
tag 77 | * having the class Zebra_Form_Input_Prefix; if the prefix is a path to an 78 | * image, it will be an tag having the class Zebra_Form_Input_Prefix. 79 | * 80 | * For anything other than plain text, you must use CSS to set the width and 81 | * height of the prefix, or it will not be correctly positioned because when the image 82 | * is not cached by the browser the code taking care of centering the image will 83 | * be executed before the image is loaded by the browser and it will not know the 84 | * image's width and height! 85 | * 86 | * {@img src=../media/zebra-form-prefix.jpg class=graphic} 87 | * 88 | * 89 | * // add simple text 90 | * // style the text through the Zebra_Form_Input_Prefix class 91 | * $form->add('password', 'my_password', '', array('data-prefix' => 'Hash:')); 92 | * 93 | * // add images 94 | * // set the image's width and height through the img.Zebra_Form_Input_Prefix class 95 | * // in your CSS or the image will not be correctly positioned! 96 | * $form->add('password', 'my_password', '', array('data-prefix' => 'img:path/to/image')); 97 | * 98 | * // add html - useful when using sprites 99 | * // again, make sure that you set somewhere the width and height of the prefix! 100 | * $form->add('password', 'my_password', '', array('data-prefix' => '
')); 101 | * $form->add('password', 'my_password', '', array('data-prefix' => '
')); 102 | *
103 | * 104 | * See {@link Zebra_Form_Control::set_attributes() set_attributes()} on how to set 105 | * attributes, other than through the constructor. 106 | * 107 | * The following attributes are automatically set when the control is created and 108 | * should not be altered manually:
109 | * 110 | * type, id, name, value, class 111 | * 112 | * @return void 113 | */ 114 | function __construct($id, $default = '', $attributes = '') 115 | { 116 | 117 | // call the constructor of the parent class 118 | parent::__construct(); 119 | 120 | // set the private attributes of this control 121 | // these attributes are private for this control and are for internal use only 122 | // and will not be rendered by the _render_attributes() method 123 | $this->private_attributes = array( 124 | 125 | 'default_value', 126 | 'disable_xss_filters', 127 | 'locked', 128 | 129 | ); 130 | 131 | // set the default attributes for the button control 132 | $this->set_attributes( 133 | 134 | array( 135 | 136 | 'type' => 'password', 137 | 'name' => $id, 138 | 'id' => $id, 139 | 'value' => $default, 140 | 'class' => 'control password', 141 | 142 | ) 143 | 144 | ); 145 | 146 | // if "class" is amongst user specified attributes 147 | if (is_array($attributes) && isset($attributes['class'])) { 148 | 149 | // we need to set the "class" attribute like this, so it doesn't overwrite previous values 150 | $this->set_attributes(array('class' => $attributes['class']), false); 151 | 152 | // make sure we don't set it again below 153 | unset($attributes['class']); 154 | 155 | } 156 | 157 | // sets user specified attributes for the control 158 | $this->set_attributes($attributes); 159 | 160 | } 161 | 162 | /** 163 | * Generates the control's HTML code. 164 | * 165 | * This method is automatically called by the {@link Zebra_Form::render() render()} method! 166 | * 167 | * @return string The control's HTML code 168 | */ 169 | function toHTML() 170 | { 171 | 172 | return '_render_attributes() . ($this->form_properties['doctype'] == 'xhtml' ? '/' : '') . '>'; 173 | 174 | } 175 | 176 | } 177 | 178 | ?> 179 | -------------------------------------------------------------------------------- /includes/Reset.php: -------------------------------------------------------------------------------- 1 | 7 | * @copyright (c) 2006 - 2016 Stefan Gabos 8 | * @package Controls 9 | */ 10 | class Zebra_Form_Reset extends Zebra_Form_Control 11 | { 12 | 13 | /** 14 | * Adds an control to the form. 15 | * 16 | * Do not instantiate this class directly! Use the {@link Zebra_Form::add() add()} method instead! 17 | * 18 | * 19 | * // create a new form 20 | * $form = new Zebra_Form('my_form'); 21 | * 22 | * // add a reset control to the form 23 | * $obj = $form->add('reset', 'my_reset', 'Reset'); 24 | * 25 | * // don't forget to always call this method before rendering the form 26 | * if ($form->validate()) { 27 | * // put code here 28 | * } 29 | * 30 | * // output the form using an automatically generated template 31 | * $form->render(); 32 | * 33 | * 34 | * @param string $id Unique name to identify the control in the form. 35 | * 36 | * The control's name attribute will be the same as the id attribute! 37 | * 38 | * This is the name to be used when referring to the control's value in the 39 | * POST/GET superglobals, after the form is submitted. 40 | * 41 | * This is also the name of the variable to be used in custom template files, in 42 | * order to display the control. 43 | * 44 | * 45 | * // in a template file, in order to print the generated HTML 46 | * // for a control named "my_reset", one would use: 47 | * echo $my_reset; 48 | * 49 | * 50 | * @param string $caption Caption of the reset button control. 51 | * 52 | * @param array $attributes (Optional) An array of attributes valid for 53 | * {@link http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.4 input} 54 | * controls (size, readonly, style, etc) 55 | * 56 | * Must be specified as an associative array, in the form of attribute => value. 57 | * 58 | * // setting the "alt" attribute 59 | * $obj = $form->add( 60 | * 'reset', 61 | * 'my_reset', 62 | * 'Reset', 63 | * array( 64 | * 'alt' => 'Click to reset values' 65 | * ) 66 | * ); 67 | * 68 | * 69 | * See {@link Zebra_Form_Control::set_attributes() set_attributes()} on how to set 70 | * attributes, other than through the constructor. 71 | * 72 | * The following attributes are automatically set when the control is created and 73 | * should not be altered manually:
74 | * type, id, name, value, class 75 | * 76 | * @return void 77 | */ 78 | function __construct($id, $caption, $attributes = '') 79 | { 80 | 81 | // call the constructor of the parent class 82 | parent::__construct(); 83 | 84 | // set the private attributes of this control 85 | // these attributes are private for this control and are for internal use only 86 | // and will not be rendered by the _render_attributes() method 87 | $this->private_attributes = array( 88 | 89 | 'disable_xss_filters', 90 | 'locked', 91 | 92 | ); 93 | 94 | // set the default attributes for the reset button control 95 | // put them in the order you'd like them rendered 96 | $this->set_attributes( 97 | 98 | array( 99 | 100 | 'type' => 'reset', 101 | 'name' => $id, 102 | 'id' => $id, 103 | 'value' => $caption, 104 | 'class' => 'reset', 105 | 106 | ) 107 | 108 | ); 109 | 110 | // if "class" is amongst user specified attributes 111 | if (is_array($attributes) && isset($attributes['class'])) { 112 | 113 | // we need to set the "class" attribute like this, so it doesn't overwrite previous values 114 | $this->set_attributes(array('class' => $attributes['class']), false); 115 | 116 | // make sure we don't set it again below 117 | unset($attributes['class']); 118 | 119 | } 120 | 121 | // sets user specified attributes for the control 122 | $this->set_attributes($attributes); 123 | 124 | } 125 | 126 | /** 127 | * Generates the control's HTML code. 128 | * 129 | * This method is automatically called by the {@link Zebra_Form::render() render()} method! 130 | * 131 | * @return string The control's HTML code 132 | */ 133 | function toHTML() 134 | { 135 | 136 | return '_render_attributes() . ($this->form_properties['doctype'] == 'xhtml' ? '/' : '') . '>'; 137 | 138 | } 139 | 140 | } 141 | 142 | ?> 143 | -------------------------------------------------------------------------------- /includes/Submit.php: -------------------------------------------------------------------------------- 1 | 7 | * @copyright (c) 2006 - 2016 Stefan Gabos 8 | * @package Controls 9 | */ 10 | class Zebra_Form_Submit extends Zebra_Form_Control 11 | { 12 | 13 | /** 14 | * Adds an control to the form. 15 | * 16 | * Do not instantiate this class directly! Use the {@link Zebra_Form::add() add()} method instead! 17 | * 18 | * 19 | * // create a new form 20 | * $form = new Zebra_Form('my_form'); 21 | * 22 | * // add a submit control to the form 23 | * $obj = $form->add('submit', 'my_submit', 'Submit'); 24 | * 25 | * // don't forget to always call this method before rendering the form 26 | * if ($form->validate()) { 27 | * // put code here 28 | * } 29 | * 30 | * // output the form using an automatically generated template 31 | * $form->render(); 32 | * 33 | * 34 | * @param string $id Unique name to identify the control in the form. 35 | * 36 | * The control's name attribute will be the same as the id attribute! 37 | * 38 | * This is the name to be used when referring to the control's value in the 39 | * POST/GET superglobals, after the form is submitted. 40 | * 41 | * This is also the name of the variable to be used in custom template files, in 42 | * order to display the control. 43 | * 44 | * 45 | * // in a template file, in order to print the generated HTML 46 | * // for a control named "my_submit", one would use: 47 | * echo $my_submit; 48 | * 49 | * 50 | * @param string $caption Caption of the submit button control. 51 | * 52 | * @param array $attributes (Optional) An array of attributes valid for 53 | * {@link http://www.w3.org/TR/REC-html40/interact/forms.html#h-17.4 input} 54 | * controls (size, readonly, style, etc) 55 | * 56 | * Must be specified as an associative array, in the form of attribute => value. 57 | * 58 | * // setting the "alt" attribute 59 | * $obj = $form->add( 60 | * 'submit', 61 | * 'my_submit', 62 | * 'Submit', 63 | * array( 64 | * 'alt' => 'Click to submit values' 65 | * ) 66 | * ); 67 | * 68 | * 69 | * See {@link Zebra_Form_Control::set_attributes() set_attributes()} on how to set 70 | * attributes, other than through the constructor. 71 | * 72 | * The following attributes are automatically set when the control is created and 73 | * should not be altered manually:
74 | * type, id, name, value, class 75 | * 76 | * @return void 77 | */ 78 | function __construct($id, $caption, $attributes = '') 79 | { 80 | 81 | // call the constructor of the parent class 82 | parent::__construct(); 83 | 84 | // set the private attributes of this control 85 | // these attributes are private for this control and are for internal use only 86 | // and will not be rendered by the _render_attributes() method 87 | $this->private_attributes = array( 88 | 89 | 'disable_xss_filters', 90 | 'locked', 91 | 92 | ); 93 | 94 | // set the default attributes for the submit button control 95 | // put them in the order you'd like them rendered 96 | $this->set_attributes( 97 | 98 | array( 99 | 100 | 'type' => 'submit', 101 | 'name' => $id, 102 | 'id' => $id, 103 | 'value' => $caption, 104 | 'class' => 'submit', 105 | 106 | ) 107 | 108 | ); 109 | 110 | // if "class" is amongst user specified attributes 111 | if (is_array($attributes) && isset($attributes['class'])) { 112 | 113 | // we need to set the "class" attribute like this, so it doesn't overwrite previous values 114 | $this->set_attributes(array('class' => $attributes['class']), false); 115 | 116 | // make sure we don't set it again below 117 | unset($attributes['class']); 118 | 119 | } 120 | 121 | // sets user specified attributes for the control 122 | $this->set_attributes($attributes); 123 | 124 | } 125 | 126 | /** 127 | * Generates the control's HTML code. 128 | * 129 | * This method is automatically called by the {@link Zebra_Form::render() render()} method! 130 | * 131 | * @return string The control's HTML code 132 | */ 133 | function toHTML() 134 | { 135 | 136 | return '_render_attributes() . ($this->form_properties['doctype'] == 'xhtml' ? '/' : '') . '>'; 137 | 138 | } 139 | 140 | } 141 | 142 | ?> 143 | -------------------------------------------------------------------------------- /includes/Textarea.php: -------------------------------------------------------------------------------- 1 | 7 | * @copyright (c) 2006 - 2016 Stefan Gabos 8 | * @package Controls 9 | */ 10 | class Zebra_Form_Textarea extends Zebra_Form_Control 11 | { 12 | 13 | /** 14 | * Adds an '; 146 | 147 | } 148 | 149 | } 150 | 151 | ?> 152 | -------------------------------------------------------------------------------- /includes/babelsans-bold.ttf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefangabos/Zebra_Form/8012285955ad311a0bc8ea13572b971e4aed5e74/includes/babelsans-bold.ttf -------------------------------------------------------------------------------- /includes/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 |

Directory access is forbidden.

7 | 8 | -------------------------------------------------------------------------------- /index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 |

Directory access is forbidden.

7 | 8 | -------------------------------------------------------------------------------- /languages/afrikaans.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | 9 | $this->language = array( 10 | 11 | 'clear_date' => 'Maak datum skoon', 12 | 'csrf_detected' => 'Daar was "n probleem met jou voorlegging !
Moontlike oorsake kan wees dat die voorlegging te lank geneem het , of dit word dubbel versoek.
Probeer asseblief weer..', 13 | 'days' => array('Sondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrydag','Saterdag'), 14 | 'days_abbr' => false, // sal die eerste 2 letters te gebruik van die volle naam 15 | 'months' => array('Januarie','Februarie','Maart','April','Mei','Junie','Julie','Augustus','September','Oktober','November','Desember'), 16 | 'months_abbr' => false, // sal gebruik om die eerste 3 letters van die volle naam 17 | 'new_captcha' => 'Kry nuwe kode', 18 | 'other' => 'Ander...', 19 | 'select' => '- Kies Opsie -', 20 | 'spam_detected' => 'Moontlike plapos poging opgemerk . Die geposte vorm data is verwerp.', 21 | 'today' => 'Vandag', 22 | 23 | ); 24 | 25 | ?> 26 | -------------------------------------------------------------------------------- /languages/albanian.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | 9 | $this->language = array( 10 | 11 | 'clear_date' => 'Clear', 12 | 'csrf_detected' => 'There was a problem with your submission!
Possible causes may be that the submission has taken too long, or it represents a duplicate request.
Please try again.', 13 | 'days' => array('Diele','Hene','Marte','Merkure','Enjte','Premte','Shtune'), 14 | 'days_abbr' => false, // will use the first 2 letters from the full name 15 | 'months' => array('Janar','Shkurt','Mars','Prill','Maj','Qershor','Korrik','Gusht','Shtator','Tetor','Nentor','Dhjetor'), 16 | 'months_abbr' => false, // will use the first 3 letters from the full name 17 | 'new_captcha' => 'Get a new code', 18 | 'other' => 'Te tjere...', 19 | 'select' => '- zgjedh opcionin -', 20 | 'spam_detected' => 'Possible spam attempt detected. The posted form data was rejected.', 21 | 'today' => 'Sot', 22 | 23 | ); 24 | 25 | ?> -------------------------------------------------------------------------------- /languages/catalan.php: -------------------------------------------------------------------------------- 1 | language = array( 11 | 12 | 'clear_date' => 'Netejar', 13 | 'csrf_detected' => 'Hi va haver un problema amb el teu enviament!
Probablement l\'enviament és massa gran o és una petició duplicada.
Si us plau, torneu a provar.', 14 | 'days' => array('Diumenge','Dilluns','Dimarts','Dimecres','Dijous','Divendres','Dissabte'), 15 | 'days_abbr' => false, // will use the first 2 letters from the full name 16 | 'months' => array('Gener','Febrer','Març','Abril','Maig','Juny','Julio','Agost','Setembre','Octubre','Novembre','Desembre'), 17 | 'months_abbr' => false, // will use the first 3 letters from the full name 18 | 'new_captcha' => 'Obtenir nou codi', 19 | 'other' => 'Altres...', 20 | 'select' => '- Seleccionar -', 21 | 'spam_detected' => 'Possible intent d\'spam detectat. El formulari enviat va ser rebutjat.', 22 | 'today' => 'Avui', 23 | 24 | ); 25 | 26 | ?> -------------------------------------------------------------------------------- /languages/deutsch.php: -------------------------------------------------------------------------------- 1 | language = array( 10 | 11 | 'clear_date' => 'Löschen', 12 | 'csrf_detected' => 'Beim Absenden des Formulars ist ein Problem aufgetreten.
Es kann sein, dass zu viel Zeit vergangen ist, oder dass Ihre Anfrage bereits gesendet wurde.
Bitte versuchen Sie es später noch einmal.', 13 | 'days' => array ('Sonntag', 'Montag', 'Dienstag', 'Mittwoch', 'Donnerstag', 'Freitag', 'Samstag'), 14 | 'days_abbr' => false, // will use the first 2 letters from the full name 15 | 'months' => array('Januar','Februar', 'März', 'April', 'Mai', 'Juni', 'Juli', 'August', 'September', 'Oktober', 'November', 'Dezember'), 16 | 'months_abbr' => false, // will use the first 3 letters from the full name 17 | 'new_captcha' => 'Einen neuen Code erhalten', 18 | 'other' => 'Sonstige...', 19 | 'select' => '- wählen -', 20 | 'spam_detected' => 'Es besteht der Verdacht auf einen Spamversuch. Ihre Anfrage wird ignoriert.', 21 | 'today' => 'Heute', 22 | ); 23 | 24 | ?> -------------------------------------------------------------------------------- /languages/dutch.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | 9 | $this->language = array( 10 | 11 | 'clear_date' => 'Wissen', 12 | 'csrf_detected' => 'Er was een probleem met het verzenden van het formulier
Of het versturen duurde te lang of uw formulier was inmiddels al verstuurd.
Probeer het later nog een keer.', 13 | 'days' => array('Zondag','Maandag','Dinsdag','Woensdag','Donderdag','Vrijdag','Zaterdag'), 14 | 'days_abbr' => true, // will use the first 2 letters from the full name 15 | 'months' => array('Januari','Februari','Maart','April','Mei','Juni','Juli','Augustus','September','Oktober','November','December'), 16 | 'months_abbr' => false, // will use the first 3 letters from the full name 17 | 'new_captcha' => 'Toon een nieuwe code', 18 | 'other' => 'Anders...', 19 | 'select' => '- maak een keuze -', 20 | 'spam_detected' => 'Er is mogelijk spam gedetecteerd, uw ingevoerde gegevens zijn geweigerd', 21 | 'today' => 'Vandaag', 22 | 23 | ); 24 | 25 | ?> -------------------------------------------------------------------------------- /languages/english.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | 9 | $this->language = array( 10 | 11 | 'clear_date' => 'Clear date', 12 | 'csrf_detected' => 'There was a problem with your submission!
Possible causes may be that the submission has taken too long, or it represents a duplicate request.
Please try again.', 13 | 'days' => array('Sunday','Monday','Tuesday','Wednesday','Thursday','Friday','Saturday'), 14 | 'days_abbr' => false, // will use the first 2 letters from the full name 15 | 'months' => array('January','February','March','April','May','June','July','August','September','October','November','December'), 16 | 'months_abbr' => false, // will use the first 3 letters from the full name 17 | 'new_captcha' => 'Get a new code', 18 | 'other' => 'Other...', 19 | 'select' => '- select -', 20 | 'spam_detected' => 'Possible spam attempt detected. The posted form data was rejected.', 21 | 'today' => 'Today', 22 | 23 | ); 24 | 25 | ?> -------------------------------------------------------------------------------- /languages/espanol.php: -------------------------------------------------------------------------------- 1 | language = array( 11 | 12 | 'clear_date' => 'Limpiar', 13 | 'csrf_detected' => '¡Hubo un problema con tu envio!
Probablemente el envio es demasido grande o es una petición duplicada.
Por favor, inténtalo de nuevo.', 14 | 'days' => array('Domingo','Lunes','Martes','Miércoles','Jueves','Viernes','Sábado'), 15 | 'days_abbr' => false, // will use the first 2 letters from the full name 16 | 'months' => array('Enero','Febrero','Marzo','Abril','Mayo','Junio','Julio','Agosto','Septiembre','Octubre','Noviembre','Diciembre'), 17 | 'months_abbr' => false, // will use the first 3 letters from the full name 18 | 'new_captcha' => 'Obtener nuevo codigo', 19 | 'other' => 'Otro...', 20 | 'select' => '- Seleccionar -', 21 | 'spam_detected' => 'Posible intento de spam detectado. El formulario enviado fue rechazado.', 22 | 'today' => 'Hoy', 23 | 24 | ); 25 | 26 | ?> 27 | -------------------------------------------------------------------------------- /languages/francais.php: -------------------------------------------------------------------------------- 1 | language = array( 11 | 12 | 'clear_date' => 'Vider', 13 | 'csrf_detected' =>' Il y a eu un problème avec cette requête
Cela peut être causé par une inactivité de votre part, ou par un double envoi du formulaire.
Merci de réessayer plus tard. ', 14 | 'days' => array('Dimanche','Lundi','Mardi','Mercredi','Jeudi','Vendredi','Samedi'), 15 | 'days_abbr' => false, // will use the first 2 letters from the full name 16 | 'months' => array('Janvier','Février','Mars','Avril','Mai','Juin','Juillet','Août','Septembre','Octobre','Novembre','Décembre'), 17 | 'months_abbr' => false, // will use the first 3 letters from the full name 18 | 'new_captcha' => 'Obtenir un nouveau code', 19 | 'other' => 'Autre...', 20 | 'select' => '- Sélectionner -', 21 | 'spam_detected' => 'Une tentative de SPAM à été détectée. Votre requête est ignorée. ', 22 | 'today' => 'Aujourd\'hui', 23 | 24 | ); 25 | 26 | ?> -------------------------------------------------------------------------------- /languages/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 |

Directory access is forbidden.

7 | 8 | -------------------------------------------------------------------------------- /languages/italiano.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | 9 | $this->language = array( 10 | 11 | 'clear_date' => 'Rimuovi', 12 | 'csrf_detected' => 'Si è presentato un problema col vostro invio!
Tra le possibili cause l\'invio può aver richiesto troppo tempo, o la richiesta è stata duplicata.
Riprovare, per favore.', 13 | 'days' => array('Domenica','Lunedì','Martedì','Mercoledì','Giovedì','Venerdì','Sabato'), 14 | 'days_abbr' => array('D','L','Ma','Me','G','V','S'), 15 | 'months' => array('Gennaio','Febbraio','Marzo','Aprile','Maggio','Giugno','Luglio','Agosto','Settembre','Ottobre','Novembre','Dicembre'), 16 | 'months_abbr' => false, // will use the first 3 letters from the full name 17 | 'new_captcha' => 'Genera un nuovo codice', 18 | 'other' => 'Altro...', 19 | 'select' => '- Selezionare -', 20 | 'spam_detected' => 'Rilevato possibile tentativo di spam. Il modulo inviato è stato rifiutato.', 21 | 'today' => 'Oggi', 22 | 23 | ); 24 | 25 | ?> -------------------------------------------------------------------------------- /languages/japanese.php: -------------------------------------------------------------------------------- 1 | language = array( 4 | 5 | 'clear_date' => '日付を消す', 6 | 'csrf_detected' => '送信に問題がありました。送信するまでの時間が長すぎるかもしれません。もしくは今送った送信リクエストが重複している為こちらのメッセージが表示されているかもしれません。また送信して下さい', 7 | 'days' => array('日','月','火','水','木','金','土'), 8 | 'days_abbr' => false, // Japanese has different abbreviations (used above) so this is set to false 9 | 'months' => array('1月','2月','3月','4月','5月','6月','7月','8月','9月','10月','11月','12月'), 10 | 'months_abbr' => false, // Japanese has no month abbreviations 11 | 'new_captcha' => '新しい承認記号に変える', 12 | 'other' => 'その他...', 13 | 'select' => '《 選択して下さい 》', 14 | 'spam_detected' => '先程送信したメッセージはスパム行為の恐れがありましたので、送信しませんでした', 15 | 'today' => '今日', 16 | ); 17 | 18 | ?> -------------------------------------------------------------------------------- /languages/romana.php: -------------------------------------------------------------------------------- 1 | 8 | */ 9 | 10 | $this->language = array( 11 | 12 | 'clear_date' => 'Sterge', 13 | 'csrf_detected' => 'A existat o problema la trimitearea formularului!
Posibile cauze pot fi durata prea mare de timp folosita pentru completarea formularului sau incercarea de retrimitere a formularului.
Te rugam sa incerci din nou.', 14 | 'days' => array('Duminica','Luni','Marti','Miercuri','Joi','Vineri','Sambata'), 15 | 'days_abbr' => false, // will use the first 2 letters from the full name 16 | 'months' => array('Ianuarie','Februarie','Martie','Aprilie','Mai','Iunie','Iulie','August','Septembrie','Octombrie','Noiembrie','Decembrie'), 17 | 'months_abbr' => false, // will use the first 3 letters from the full name 18 | 'new_captcha' => 'Genereaza un cod nou', 19 | 'other' => 'Alta...', 20 | 'select' => '- alege -', 21 | 'spam_detected' => 'Posibila incercare de spam detectata. Datele trimise in formular au fost respinse.', 22 | 'today' => 'Astazi', 23 | 24 | ); 25 | 26 | ?> -------------------------------------------------------------------------------- /languages/russian.php: -------------------------------------------------------------------------------- 1 | 7 | */ 8 | 9 | $this->language = array( 10 | 11 | 'clear_date' => 'Дата очистки', 12 | 'csrf_detected' => 'При выполнении вашего запроса возникла проблема.
Возможно, ваш запрос занял слишком много времени или дублируется.
Попробуйте еще раз.', 13 | 'days' => array('Воскресенье','Понедельник','Вторник','Среда','Четверг','Пятница','Суббота'), 14 | 'days_abbr' => false, 15 | 'months' => array('Январь','Февраль','Март','Апрель','Май','Июнь','Июль','Август','Сентябрь','Октябрь','Ноябрь','Декабрь'), 16 | 'months_abbr' => false, 17 | 'new_captcha' => 'Обновить капчу', 18 | 'other' => 'Еще...', 19 | 'select' => '- не выбрано -', 20 | 'spam_detected' => 'Выявлена возможная попытка отправить спам-сообщение. Отправленные в форме данные отклонены.', 21 | 'today' => 'Сегодня', 22 | 23 | ); 24 | 25 | ?> -------------------------------------------------------------------------------- /languages/türk.php: -------------------------------------------------------------------------------- 1 | language = array( 10 | 11 | 'clear_date' => 'Temizle', 12 | 'csrf_detected' => 'Gönderinizle ilgili bir sorun çıktı!
Olası nedenler arasında form gönderiminin çok uzun sürmesi ya da aynı işlemden ikinci kere yapılması olabilir.
Lütfen yeniden deneyiniz.', 13 | 'days' => array('Pazar','Pazartesi','Salı','Çarsamba','Perşembe','Cuma','Cumartesi'), 14 | 'days_abbr' => false, // will use the first 2 letters from the full name 15 | 'months' => array('Ocak','Şubat','Mart','Nisan','Mayıs','Haziran','Temmuz','Ağustos','Eylül','Ekim','Kasım','Aralık'), 16 | 'months_abbr' => false, // will use the first 3 letters from the full name 17 | 'new_captcha' => 'Yeni bir kod', 18 | 'other' => 'Diğer...', 19 | 'select' => '- seçiniz -', 20 | 'spam_detected' => 'SPAM denemesi olabilir. Gönderilen form verisi reddedildi.', 21 | 'today' => 'Bugün', 22 | 23 | ); 24 | 25 | ?> 26 | -------------------------------------------------------------------------------- /mimes.json: -------------------------------------------------------------------------------- 1 | { 2 | 3 | "3g2" : "video\/3gpp2", 4 | "3gp" : "video\/3gp", 5 | "7zip" : ["application\/x-compressed", "application\/x-zip-compressed", "application\/zip", "multipart\/x-zip"], 6 | "aac" : "audio\/x-acc", 7 | "ac3" : "audio\/ac3", 8 | "ai" : ["application\/pdf", "application\/postscript"], 9 | "aif" : ["audio\/x-aiff", "audio\/aiff"], 10 | "aifc" : "audio\/x-aiff", 11 | "aiff" : ["audio\/x-aiff", "audio\/aiff"], 12 | "au" : "audio\/x-au", 13 | "avi" : ["video\/x-msvideo", "video\/msvideo", "video\/avi", "application\/x-troff-msvideo"], 14 | "bin" : ["application\/macbinary", "application\/mac-binary", "application\/octet-stream", "application\/x-binary", "application\/x-macbinary"], 15 | "bmp" : ["image\/bmp", "image\/x-windows-bmp"], 16 | "cdr" : ["application\/cdr", "application\/coreldraw", "application\/x-cdr", "application\/x-coreldraw", "image\/cdr", "image\/x-cdr", "zz-application\/zz-winassoc-cdr"], 17 | "cer" : ["application\/pkix-cert", "application\/x-x509-ca-cert"], 18 | "class" : "application\/octet-stream", 19 | "crl" : ["application\/pkix-crl", "application\/pkcs-crl"], 20 | "crt" : ["application\/x-x509-ca-cert", "application\/x-x509-user-cert", "application\/pkix-cert"], 21 | "csr" : "application\/octet-stream", 22 | "css" : ["text\/css", "text\/plain"], 23 | "csv" : ["text\/x-comma-separated-values", "text\/comma-separated-values", "application\/octet-stream", "application\/vnd.ms-excel", "application\/x-csv", "text\/x-csv", "text\/csv", "application\/csv", "application\/excel", "application\/vnd.msexcel", "text\/plain"], 24 | "dcr" : "application\/x-director", 25 | "der" : "application\/x-x509-ca-cert", 26 | "dir" : "application\/x-director", 27 | "dll" : "application\/octet-stream", 28 | "dms" : "application\/octet-stream", 29 | "doc" : ["application\/msword", "application\/vnd.ms-office"], 30 | "docx" : ["application\/vnd.openxmlformats-officedocument.wordprocessingml.document", "application\/zip", "application\/msword", "application\/x-zip"], 31 | "dot" : ["application\/msword", "application\/vnd.ms-office"], 32 | "dotx" : ["application\/vnd.openxmlformats-officedocument.wordprocessingml.document", "application\/zip", "application\/msword"], 33 | "dvi" : "application\/x-dvi", 34 | "dxr" : "application\/x-director", 35 | "eml" : "message\/rfc822", 36 | "eps" : "application\/postscript", 37 | "exe" : ["application\/octet-stream", "application\/x-msdownload"], 38 | "f4v" : "video\/mp4", 39 | "flac" : "audio\/x-flac", 40 | "gif" : "image\/gif", 41 | "gpg" : "application\/gpg-keys", 42 | "gtar" : "application\/x-gtar", 43 | "gz" : "application\/x-gzip", 44 | "gzip" : "application\/x-gzip", 45 | "htm" : ["text\/html", "text\/plain"], 46 | "html" : ["text\/html", "text\/plain"], 47 | "ics" : "text\/calendar", 48 | "jar" : ["application\/java-archive", "application\/x-java-application", "application\/x-jar", "application\/x-compressed"], 49 | "jpe" : ["image\/jpeg", "image\/pjpeg"], 50 | "jpeg" : ["image\/jpeg", "image\/pjpeg"], 51 | "jpg" : ["image\/jpeg", "image\/pjpeg"], 52 | "js" : ["application\/x-javascript", "text\/plain"], 53 | "json" : ["application\/json", "text\/json"], 54 | "kdb" : "application\/octet-stream", 55 | "kml" : ["application\/vnd.google-earth.kml+xml", "application\/xml", "text\/xml"], 56 | "kmz" : ["application\/vnd.google-earth.kmz", "application\/zip", "application\/x-zip"], 57 | "lha" : "application\/octet-stream", 58 | "log" : ["text\/plain", "text\/x-log"], 59 | "lzh" : "application\/octet-stream", 60 | "m3u" : "text\/plain", 61 | "m4a" : "audio\/x-m4a", 62 | "m4u" : "application\/vnd.mpegurl", 63 | "mid" : "audio\/midi", 64 | "midi" : "audio\/midi", 65 | "mif" : "application\/vnd.mif", 66 | "mov" : "video\/quicktime", 67 | "movie" : "video\/x-sgi-movie", 68 | "mp2" : "audio\/mpeg", 69 | "mp3" : ["audio\/mpeg", "audio\/mpg", "audio\/mpeg3", "audio\/mp3"], 70 | "mp4" : "video\/mp4", 71 | "mpe" : "video\/mpeg", 72 | "mpeg" : "video\/mpeg", 73 | "mpg" : "video\/mpeg", 74 | "mpga" : "audio\/mpeg", 75 | "oda" : "application\/oda", 76 | "ogg" : "audio\/ogg", 77 | "p10" : ["application\/x-pkcs10", "application\/pkcs10"], 78 | "p12" : "application\/x-pkcs12", 79 | "p7a" : "application\/x-pkcs7-signature", 80 | "p7c" : ["application\/pkcs7-mime", "application\/x-pkcs7-mime"], 81 | "p7m" : ["application\/pkcs7-mime", "application\/x-pkcs7-mime"], 82 | "p7r" : "application\/x-pkcs7-certreqresp", 83 | "p7s" : "application\/pkcs7-signature", 84 | "pdf" : ["application\/pdf", "application\/force-download", "application\/x-download", "binary\/octet-stream", "application\/x-pdf"], 85 | "pem" : ["application\/x-x509-user-cert", "application\/x-pem-file", "application\/octet-stream"], 86 | "pgp" : "application\/pgp", 87 | "php" : ["application\/x-httpd-php", "application\/php", "application\/x-php", "text\/php", "text\/x-php", "application\/x-httpd-php-source"], 88 | "php3" : "application\/x-httpd-php", 89 | "php4" : "application\/x-httpd-php", 90 | "phps" : "application\/x-httpd-php-source", 91 | "phtml" : "application\/x-httpd-php", 92 | "png" : ["image\/png", "image\/x-png"], 93 | "ppt" : ["application\/powerpoint", "application\/vnd.ms-powerpoint"], 94 | "pptx" : ["application\/vnd.openxmlformats-officedocument.presentationml.presentation", "application\/x-zip", "application\/zip"], 95 | "ps" : "application\/postscript", 96 | "psd" : ["application\/x-photoshop", "image\/vnd.adobe.photoshop"], 97 | "qt" : "video\/quicktime", 98 | "ra" : "audio\/x-realaudio", 99 | "ram" : "audio\/x-pn-realaudio", 100 | "rar" : ["application\/x-rar", "application\/rar", "application\/x-rar-compressed"], 101 | "rm" : "audio\/x-pn-realaudio", 102 | "rpm" : "audio\/x-pn-realaudio-plugin", 103 | "rsa" : "application\/x-pkcs7", 104 | "rtf" : "text\/rtf", 105 | "rtx" : "text\/richtext", 106 | "rv" : "video\/vnd.rn-realvideo", 107 | "sea" : "application\/octet-stream", 108 | "shtml" : ["text\/html", "text\/plain"], 109 | "sit" : "application\/x-stuffit", 110 | "smi" : "application\/smil", 111 | "smil" : "application\/smil", 112 | "so" : "application\/octet-stream", 113 | "sst" : "application\/octet-stream", 114 | "swf" : "application\/x-shockwave-flash", 115 | "tar" : "application\/x-tar", 116 | "text" : "text\/plain", 117 | "tgz" : ["application\/x-tar", "application\/x-gzip-compressed"], 118 | "tif" : "image\/tiff", 119 | "tiff" : "image\/tiff", 120 | "txt" : "text\/plain", 121 | "vlc" : "application\/videolan", 122 | "wav" : ["audio\/x-wav", "audio\/wave", "audio\/wav"], 123 | "wbxml" : "application\/wbxml", 124 | "webm" : "video\/webm", 125 | "wma" : ["audio\/x-ms-wma", "video\/x-ms-asf"], 126 | "wmlc" : "application\/wmlc", 127 | "wmv" : ["video\/x-ms-wmv", "video\/x-ms-asf"], 128 | "word" : ["application\/msword", "application\/octet-stream"], 129 | "xht" : "application\/xhtml+xml", 130 | "xhtml" : "application\/xhtml+xml", 131 | "xl" : "application\/excel", 132 | "xls" : ["application\/vnd.ms-excel", "application\/msexcel", "application\/x-msexcel", "application\/x-ms-excel", "application\/x-excel", "application\/x-dos_ms_excel", "application\/xls", "application\/x-xls", "application\/excel", "application\/download", "application\/vnd.ms-office", "application\/msword"], 133 | "xlsx" : ["application\/vnd.openxmlformats-officedocument.spreadsheetml.sheet", "application\/zip", "application\/vnd.ms-excel", "application\/msword", "application\/x-zip"], 134 | "xml" : ["application\/xml", "text\/xml", "text\/plain"], 135 | "xsl" : ["application\/xml", "text\/xsl", "text\/xml"], 136 | "xspf" : "application\/xspf+xml", 137 | "zip" : ["application\/x-zip", "application\/zip", "application\/x-zip-compressed", "application\/s-compressed", "multipart\/x-zip"], 138 | "zsh" : "text\/x-scriptzsh" 139 | 140 | } -------------------------------------------------------------------------------- /process.php: -------------------------------------------------------------------------------- 1 | $char, 90 | 'size' => $charSize, 91 | 'angle' => $charAngle, 92 | 'box' => $bbox 93 | 94 | ); 95 | 96 | } 97 | 98 | // encode value 99 | $value = md5(md5(md5($resultString))); 100 | 101 | // if storage is "session", store the value in session 102 | if ($storage == 'session') $_SESSION['captcha'] = $value; 103 | 104 | // otherwise, store the value in a cookie 105 | else setcookie('captcha', $value, time() + 3600, '/'); 106 | 107 | // either ways, the value will later be read by the form generator 108 | // and used to see if the user entered the correct characters 109 | 110 | // create the image 111 | $img = imagecreatetruecolor($imageWidth, $imageHeight); 112 | 113 | // allocate some colors 114 | $white = imagecolorallocate($img, 255, 255, 255); 115 | 116 | $black = imagecolorallocate($img, 0, 0, 0); 117 | 118 | // fill the canvas to white 119 | imagefilledrectangle($img, 0, 0, $imageWidth, $imageHeight, $white); 120 | 121 | // write some random characters in the background 122 | for ($i = 0; $i <10; $i++) { 123 | 124 | // ...having random washed-out colors 125 | $color = imagecolorallocate($img, rand(150, 200), rand(150, 200), rand(150, 200)); 126 | 127 | imagettftext( 128 | $img, 129 | 20, 130 | rand($fontAngleVariation[0], 131 | $fontAngleVariation[1]), 132 | rand(0, $imageWidth), 133 | rand(20, $imageHeight) , 134 | $color, 135 | $font, 136 | chr(rand(65, 90)) 137 | ); 138 | 139 | } 140 | 141 | // draw a bounding rectangle 142 | // imagerectangle($img, 0, 0, $imageWidth - 1, $imageHeight - 1, $black); 143 | 144 | // this is to keep the word centered in the box 145 | $left = (($imageWidth - $totalWidth) / 2); 146 | 147 | // iterate through the chosen characters 148 | foreach ($captcha as $values) { 149 | 150 | // print each character 151 | imagettftext( 152 | $img, 153 | $values['size'], 154 | $values['angle'], 155 | $left , 156 | ($imageHeight + $values['box']['height']) / 2 , 157 | $black, 158 | $font, 159 | $values['char'] 160 | ); 161 | 162 | // compute the position of the next character 163 | $left += $values['box']['width'] + $characterSpacing; 164 | 165 | } 166 | 167 | // and finally output the image at the specified quality 168 | imagejpeg($img, null, $imageQuality); 169 | 170 | // free memory 171 | imagedestroy($img); 172 | 173 | // if we're performing a file upload 174 | } elseif ( 175 | 176 | isset($_FILES) && 177 | is_array($_FILES) && 178 | !empty($_FILES) && 179 | isset($_GET['form']) && 180 | isset($_GET['control']) && 181 | isset($_FILES[$_GET['control']]) 182 | 183 | ) { 184 | 185 | function process() { 186 | 187 | // the form that initiated the request 188 | $form = $_GET['form']; 189 | 190 | // the file upload control on the form that initiated the request 191 | $control = $_GET['control']; 192 | 193 | // if file could be uploaded 194 | if (isset($_FILES[$_GET['control']])) { 195 | 196 | // save some information about the uploaded file 197 | $file['name'] = $_FILES[$control]['name']; 198 | $file['type'] = $_FILES[$control]['type']; 199 | $file['error'] = $_FILES[$control]['error']; 200 | $file['size'] = $_FILES[$control]['size']; 201 | 202 | // if there were problems uploading the file 203 | } elseif (empty($_POST) && empty($_FILES) && isset($_SERVER['CONTENT_LENGTH']) && isset($_SERVER['CONTENT_TYPE']) && (strpos($_SERVER['CONTENT_TYPE'], 'multipart/form-data') !== false || strpos($_SERVER['CONTENT_TYPE'], 'application/x-www-form-urlencoded') !== false)) { 204 | 205 | // send these values 206 | $file['name'] = ''; 207 | $file['type'] = 'unknown'; 208 | $file['error'] = 1; 209 | $file['size'] = $_SERVER['CONTENT_LENGTH']; 210 | } 211 | 212 | ob_start(); 213 | 214 | ?> 215 | 216 | 222 | 223 | 249 | -------------------------------------------------------------------------------- /public/css/button-background.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefangabos/Zebra_Form/8012285955ad311a0bc8ea13572b971e4aed5e74/public/css/button-background.gif -------------------------------------------------------------------------------- /public/css/calendar-disabled.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefangabos/Zebra_Form/8012285955ad311a0bc8ea13572b971e4aed5e74/public/css/calendar-disabled.png -------------------------------------------------------------------------------- /public/css/calendar.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefangabos/Zebra_Form/8012285955ad311a0bc8ea13572b971e4aed5e74/public/css/calendar.png -------------------------------------------------------------------------------- /public/css/close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefangabos/Zebra_Form/8012285955ad311a0bc8ea13572b971e4aed5e74/public/css/close.png -------------------------------------------------------------------------------- /public/css/ico-close.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefangabos/Zebra_Form/8012285955ad311a0bc8ea13572b971e4aed5e74/public/css/ico-close.gif -------------------------------------------------------------------------------- /public/css/ico-close.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefangabos/Zebra_Form/8012285955ad311a0bc8ea13572b971e4aed5e74/public/css/ico-close.png -------------------------------------------------------------------------------- /public/css/ico-refresh.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefangabos/Zebra_Form/8012285955ad311a0bc8ea13572b971e4aed5e74/public/css/ico-refresh.gif -------------------------------------------------------------------------------- /public/css/ico-refresh.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefangabos/Zebra_Form/8012285955ad311a0bc8ea13572b971e4aed5e74/public/css/ico-refresh.png -------------------------------------------------------------------------------- /public/css/ico-warning.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefangabos/Zebra_Form/8012285955ad311a0bc8ea13572b971e4aed5e74/public/css/ico-warning.gif -------------------------------------------------------------------------------- /public/css/ico-warning.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefangabos/Zebra_Form/8012285955ad311a0bc8ea13572b971e4aed5e74/public/css/ico-warning.png -------------------------------------------------------------------------------- /public/css/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 |

Directory access is forbidden.

7 | 8 | -------------------------------------------------------------------------------- /public/css/note.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefangabos/Zebra_Form/8012285955ad311a0bc8ea13572b971e4aed5e74/public/css/note.gif -------------------------------------------------------------------------------- /public/css/spinner.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefangabos/Zebra_Form/8012285955ad311a0bc8ea13572b971e4aed5e74/public/css/spinner.gif -------------------------------------------------------------------------------- /public/css/textbox-background.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/stefangabos/Zebra_Form/8012285955ad311a0bc8ea13572b971e4aed5e74/public/css/textbox-background.gif -------------------------------------------------------------------------------- /public/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 |

Directory access is forbidden.

7 | 8 | -------------------------------------------------------------------------------- /public/javascript/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 403 Forbidden 4 | 5 | 6 |

Directory access is forbidden.

7 | 8 | -------------------------------------------------------------------------------- /public/javascript/readme.txt: -------------------------------------------------------------------------------- 1 | The minimized JavaScript file contains the minimized version of the "zebra_form.src.js" file and the minimized version of the Zebra_DatePicker (http://stefangabos.ro/jquery/zebra-datepicker/) plugin! 2 | 3 | The source file contains *only* the JavaScript source for the Zebra_Form! --------------------------------------------------------------------------------