Initial commit

This commit is contained in:
Caribana
2017-05-26 11:41:26 +02:00
commit 61c24500af
6264 changed files with 645934 additions and 0 deletions

View File

@@ -0,0 +1,76 @@
<h2>A contact form</h2>
<p>Note the uneditable prefixes (text and images) for some of the fields.</p>
<p>Check the "Template source" tab to see how it's done!</p>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form');
// the label for the "name" element
$form->add('label', 'label_name', 'name', 'Your name:');
// add the "name" element
$obj = $form->add('text', 'name', '', array('style' => 'width: 195px', 'data-prefix' => 'img:public/images/user.png'));
// set rules
$obj->set_rule(array(
// error messages will be sent to a variable called "error", usable in custom templates
'required' => array('error', 'Name is required!')
));
// "email"
$form->add('label', 'label_email', 'email', 'Your email address:');
$obj = $form->add('text', 'email', '', array('style' => 'width: 195px', 'data-prefix' => 'img:public/images/letter.png'));
$obj->set_rule(array(
'required' => array('error', 'Email is required!'),
'email' => array('error', 'Email address seems to be invalid!'),
));
$form->add('note', 'note_email', 'email', 'Your email address will not be published.');
// "website"
$form->add('label', 'label_website', 'website', 'Your website:');
$obj = $form->add('text', 'website', '', array('style' => 'width: 400px', 'data-prefix' => 'http://'));
$obj->set_rule(array(
'url' => array(true, 'error', 'Invalid URL specified!'),
));
$form->add('note', 'note_website', 'website', 'Enter the URL of your website, if you have one.');
// "subject"
$form->add('label', 'label_subject', 'subject', 'Subject');
$obj = $form->add('text', 'subject', '', array('style' => 'width: 400px', 'data-prefix' => 'img:public/images/comment.png'));
$obj->set_rule(array(
'required' => array('error', 'Subject is required!')
));
// "message"
$form->add('label', 'label_message', 'message', 'Message:');
$obj = $form->add('textarea', 'message');
$obj->set_rule(array(
'required' => array('error', 'Message is required!'),
'length' => array(0, 140, 'error', 'Maximum length is 140 characters!', true),
));
// "submit"
$form->add('submit', 'btnsubmit', 'Submit');
// if the form is valid
if ($form->validate()) {
// show results
show_results();
// otherwise
} else
// generate output using a custom template
$form->render('includes/custom-templates/contact.php');
?>

View File

@@ -0,0 +1,74 @@
<h2>A contact form</h2>
<p>Note the uneditable prefixes (text and images) for some of the fields.</p>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form');
// the label for the "name" element
$form->add('label', 'label_name', 'name', 'Your name:');
// add the "name" element
$obj = $form->add('text', 'name', '', array('data-prefix' => 'img:public/images/user.png'));
// set rules
$obj->set_rule(array(
// error messages will be sent to a variable called "error", usable in custom templates
'required' => array('error', 'Name is required!')
));
// "email"
$form->add('label', 'label_email', 'email', 'Your email address:');
$obj = $form->add('text', 'email', '', array('data-prefix' => 'img:public/images/letter.png'));
$obj->set_rule(array(
'required' => array('error', 'Email is required!'),
'email' => array('error', 'Email address seems to be invalid!'),
));
$form->add('note', 'note_email', 'email', 'Your email address will not be published.');
// "website"
$form->add('label', 'label_website', 'website', 'Your website:');
$obj = $form->add('text', 'website', '', array('data-prefix' => 'http://'));
$obj->set_rule(array(
'url' => array(true, 'error', 'Invalid URL specified!'),
));
$form->add('note', 'note_website', 'website', 'Enter the URL of your website, if you have one.');
// "subject"
$form->add('label', 'label_subject', 'subject', 'Subject');
$obj = $form->add('text', 'subject', '', array('data-prefix' => 'img:public/images/comment.png'));
$obj->set_rule(array(
'required' => array('error', 'Subject is required!')
));
// "message"
$form->add('label', 'label_message', 'message', 'Message:');
$obj = $form->add('textarea', 'message');
$obj->set_rule(array(
'required' => array('error', 'Message is required!'),
'length' => array(0, 140, 'error', 'Maximum length is 140 characters!', true),
));
// "submit"
$form->add('submit', 'btn_submit', 'Submit');
// if the form is valid
if ($form->validate()) {
// show results
show_results();
// otherwise
} else
// generate output using a custom template
$form->render('*horizontal');
?>

View File

@@ -0,0 +1,74 @@
<h2>A contact form</h2>
<p>Note the uneditable prefixes (text and images) for some of the fields.</p>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form');
// the label for the "name" element
$form->add('label', 'label_name', 'name', 'Your name:');
// add the "name" element
$obj = $form->add('text', 'name', '', array('data-prefix' => 'img:public/images/user.png'));
// set rules
$obj->set_rule(array(
// error messages will be sent to a variable called "error", usable in custom templates
'required' => array('error', 'Name is required!')
));
// "email"
$form->add('label', 'label_email', 'email', 'Your email address:');
$obj = $form->add('text', 'email', '', array('data-prefix' => 'img:public/images/letter.png'));
$obj->set_rule(array(
'required' => array('error', 'Email is required!'),
'email' => array('error', 'Email address seems to be invalid!'),
));
$form->add('note', 'note_email', 'email', 'Your email address will not be published.');
// "website"
$form->add('label', 'label_website', 'website', 'Your website:');
$obj = $form->add('text', 'website', '', array('data-prefix' => 'http://'));
$obj->set_rule(array(
'url' => array(true, 'error', 'Invalid URL specified!'),
));
$form->add('note', 'note_website', 'website', 'Enter the URL of your website, if you have one.');
// "subject"
$form->add('label', 'label_subject', 'subject', 'Subject');
$obj = $form->add('text', 'subject', '', array('style' => 'width:400px', 'data-prefix' => 'img:public/images/comment.png'));
$obj->set_rule(array(
'required' => array('error', 'Subject is required!')
));
// "message"
$form->add('label', 'label_message', 'message', 'Message:');
$obj = $form->add('textarea', 'message');
$obj->set_rule(array(
'required' => array('error', 'Message is required!'),
'length' => array(0, 140, 'error', 'Maximum length is 140 characters!', true)
));
// "submit"
$form->add('submit', 'btnsubmit', 'Submit');
// if the form is valid
if ($form->validate()) {
// show results
show_results();
// otherwise
} else
// generate output using a custom template
$form->render();
?>

View File

@@ -0,0 +1,36 @@
<!-- must be in strict mode! -->
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Zebra_Form Example</title>
<!-- load Zebra_Form's stylesheet file -->
<link rel="stylesheet" href="path/to/zebra_form.css">
</head>
<body>
<!--
the content from the "PHP Source" tab goes here
-->
<!-- we're loading the JavaScript files at the bottom of the page so we don't delay page rendering -->
<!-- try to load jQuery from CDN server and fallback to local source if not available -->
<script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script>window.jQuery || document.write('<script src="path/to/jquery-1.9.1.min.js"><\/script>')</script>
<!-- load Zebra_Form's JavaScript file -->
<script src="path/to/zebra_form.js"></script>
</body>
</html>

View File

@@ -0,0 +1,27 @@
<?php
// don't forget about this for custom templates, or errors will not show for server-side validation
// $zf_error is automatically created by the library and it holds messages about SPAM or CSRF errors
// $error is the name of the variable used with the set_rule method
echo (isset($zf_error) ? $zf_error : (isset($error) ? $error : ''));
?>
<!-- elements are grouped in "rows" -->
<div class="row">
<!-- things that need to be side-by-side go in "cells" and will be floated to the left -->
<div class="cell"><?php echo $label_name . $name?></div>
<div class="cell"><?php echo $label_email . $email . $note_email?></div>
</div>
<!-- notice the "even" class which is used to highlight even rows differently
from the odd rows -->
<div class="row even"><?php echo $label_website . $website . $note_website?></div>
<div class="row"><?php echo $label_subject . $subject?></div>
<div class="row even"><?php echo $label_message . $message?></div>
<!-- the submit button goes in the last row; also, notice the "last" class which
removes the bottom border which is otherwise present for any row -->
<div class="row last"><?php echo $btnsubmit?></div>

View File

@@ -0,0 +1,28 @@
<?php
// don't forget about this for custom templates, or errors will not show for server-side validation
// $zf_error is automatically created by the library and it holds messages about SPAM or CSRF errors
// $error is the name of the variable used with the set_rule method
echo (isset($zf_error) ? $zf_error : (isset($error) ? $error : ''));
?>
<!-- elements are grouped in "rows" -->
<div class="row">
<!-- things that need to be side-by-side go in "cells" and will be floated to the left -->
<div class="cell"><?php echo $label_email . $email?></div>
<div class="cell"><?php echo $label_password . $password?></div>
<div class="clear" style="margin-bottom:10px"></div>
<!-- on the same row, but beneath the email and the password fields,
we place the "remember me" checkbox and attached label -->
<div class="cell"><?php echo $remember_me_yes?></div>
<div class="cell"><?php echo $label_remember_me_yes?></div>
</div>
<!-- the submit button goes in the last row; notice the "even" class which
is used to highlight even rows differently from the odd rows; also, notice
the "last" class which removes the bottom border which is otherwise present
for any row -->
<div class="row even last"><?php echo $btnsubmit?></div>

View File

@@ -0,0 +1,73 @@
<!--
in reality you'd have this in an external stylesheet;
i am using it like this for the sake of the example
-->
<style type="text/css">
.Zebra_Form .optional { padding: 10px 50px; display: none }
</style>
<!--
again, in reality you'd have this in an external JavaScript file;
i am using it like this for the sake of the example
-->
<script type="text/javascript">
var mycallback = function(value, segment) {
$segment = $('.optional' + segment);
if (value) $segment.show();
else $segment.hide();
}
</script>
<?php echo (isset($zf_error) ? $zf_error : (isset($error) ? $error : ''))?>
<div class="row">
<?php echo $label_name . $name?>
</div>
<div class="row">
<?php echo $label_notifications?>
<div class="cell"><?php echo $notifications_yes?></div>
<div class="cell"><?php echo $label_notifications_yes?></div>
<div class="clear"></div>
<div class="optional optional1">
<?php echo $label_method?>
<div class="cell"><?php echo $method_email?></div>
<div class="cell"><?php echo $label_method_email?></div>
<div class="clear"></div>
<div class="optional optional2">
<?php echo $label_email . $email . $note_email?>
</div>
<div class="cell"><?php echo $method_phone?></div>
<div class="cell"><?php echo $label_method_phone?></div>
<div class="clear"></div>
<div class="optional optional3">
<?php echo $label_phone . $phone . $note_phone?>
</div>
<div class="cell"><?php echo $method_post?></div>
<div class="cell"><?php echo $label_method_post?></div>
<div class="clear"></div>
<div class="optional optional4">
<?php echo $label_post . $post . $note_post?>
</div>
</div>
<div class="cell"><?php echo $notifications_no?></div>
<div class="cell"><?php echo $label_notifications_no?></div>
<div class="clear"></div>
<div class="optional optional5">
<?php echo $label_why . $why?>
</div>
</div>
<div class="row last"><?php echo $btnsubmit?></div>

View File

@@ -0,0 +1,15 @@
<?php echo (isset($zf_error) ? $zf_error : (isset($error) ? $error : ''))?>
<div class="row">
<div class="cell"><?php echo $label_name . $name?></div>
<div class="cell"><?php echo $label_surname . $surname?></div>
</div>
<div class="row even">
<h6><strong>Add new person</strong></h6><br>
<div class="cell"><?php echo $label_add_name . $add_name?></div>
<div class="cell"><?php echo $label_add_surname . $add_surname?></div>
<div class="cell"><br><?php echo $btnadd?></div>
</div>
<div class="row last"><?php echo $btnsubmit?></div>

View File

@@ -0,0 +1,32 @@
<?php
// don't forget about this for custom templates, or errors will not show for server-side validation
// $zf_error is automatically created by the library and it holds messages about SPAM or CSRF errors
// $error is the name of the variable used with the set_rule method
echo (isset($zf_error) ? $zf_error : (isset($error) ? $error : ''));
?>
<!-- elements are grouped in "rows" -->
<div class="row">
<!-- things that need to be side-by-side go in "cells" and will be floated to the left -->
<div class="cell"><?php echo $label_firstname . $firstname?></div>
<div class="cell"><?php echo $label_lastname . $lastname?></div>
</div>
<!-- notice the "even" class which is used to highlight even rows differently
from the odd rows -->
<div class="row even"><?php echo $label_email . $email . $note_email?></div>
<div class="row">
<div class="cell"><?php echo $label_password . $password . $note_password?></div>
<div class="cell"><?php echo $label_confirm_password . $confirm_password?></div>
</div>
<div class="row even">
<?php echo $captcha_image . $label_captcha_code . $captcha_code . $note_captcha?>
</div>
<!-- the submit button goes in the last row; also, notice the "last" class which
removes the bottom border which is otherwise present for any row -->
<div class="row even last"><?php echo $btnsubmit?></div>

View File

@@ -0,0 +1,72 @@
<?php
// don't forget about this for custom templates, or errors will not show for server-side validation
// $zf_error is automatically created by the library and it holds messages about SPAM or CSRF errors
// $error is the name of the variable used with the set_rule method
echo (isset($zf_error) ? $zf_error : (isset($error) ? $error : ''));
?>
<!-- elements are grouped in "rows" -->
<div class="row">
<!-- things that need to be side-by-side go in "cells" and will be floated to the left -->
<div class="cell"><?php echo $label_name . $name?></div>
<div class="cell"><?php echo $label_email . $email?></div>
</div>
<!-- notice the "even" class which is used to highlight even rows differently
from the odd rows -->
<div class="row even">
<?php echo $label_department . $department . $department_other?>
</div>
<div class="row">
<div class="cell">
<?php echo $label_room?>
<!-- this is the preffered way of displaying checkboxes and
radio buttons and their associated label -->
<div class="cell"><?php echo $room_A?></div>
<div class="cell"><?php echo $label_room_A?></div>
<div class="clear"></div>
<div class="cell"><?php echo $room_B?></div>
<div class="cell"><?php echo $label_room_B?></div>
<div class="clear"></div>
<div class="cell"><?php echo $room_C?></div>
<div class="cell"><?php echo $label_room_C?></div>
<div class="clear"></div>
</div>
<div class="cell" style="margin-left: 20px">
<?php echo $label_extra?>
<div class="cell"><?php echo $extra_flipchard?></div>
<div class="cell"><?php echo $label_extra_flipchard?></div>
<div class="clear"></div>
<div class="cell"><?php echo $extra_plasma?></div>
<div class="cell"><?php echo $label_extra_plasma?></div>
<div class="clear"></div>
<div class="cell"><?php echo $extra_beverages?></div>
<div class="cell"><?php echo $label_extra_beverages?></div>
<div class="clear"></div>
</div>
</div>
<div class="row even">
<div class="cell"><?php echo $label_date . $date?></div>
<div class="cell" style="margin-left: 10px"><?php echo $label_time . $time?></div>
</div>
<!-- the submit button goes in the last row; also, notice the "last" class which
removes the bottom border which is otherwise present for any row -->
<div class="row last"><?php echo $btnsubmit?></div>

View File

@@ -0,0 +1,45 @@
<?php
// don't forget about this for custom templates, or errors will not show for server-side validation
// $zf_error is automatically created by the library and it holds messages about SPAM or CSRF errors
// $error is the name of the variable used with the set_rule method
echo (isset($zf_error) ? $zf_error : (isset($error) ? $error : ''));
?>
<table cellspacing="0" cellpadding="0">
<!-- elements are grouped in "rows" -->
<tr class="row">
<td><?php echo $label_email?></td>
<td><?php echo $email?></td>
</tr>
<!-- notice the "even" class which is used to highlight even rows differently
from the odd rows -->
<tr class="row even">
<td><?php echo $label_password?></td>
<td><?php echo $password?></td>
</tr>
<tr class="row">
<td></td>
<td>
<!-- this is the preffered way of displaying checkboxes and
radio buttons and their associated label -->
<div class="cell"><?php echo $remember_me_yes?></div>
<div class="cell"><?php echo $label_remember_me_yes?></div>
<!-- once we're done with "cells" we *must* place a "clear" div -->
<div class="clear"></div>
</td>
</tr>
<!-- the submit button goes in the last row; also, notice the "last" class which
removes the bottom border which is otherwise present for any row -->
<tr class="row even last">
<td></td>
<td><?php echo $btnsubmit?></td>
</tr>
</table>

View File

@@ -0,0 +1,106 @@
<h2>Dependencies</h2>
<p>Showcasing how elements can be validated only if other elements meet certain conditions and how callback functions for the "dependencies" rule work.</p>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form');
// add the "name" element
$form->add('label', 'label_name', 'name', 'Your name');
$obj = $form->add('text', 'name');
// set rules
$obj->set_rule(array(
'required' => array('error', 'Name is required!'),
));
// "notifications"
$form->add('label', 'label_notifications', 'notifications', 'Would you like to be informed about promotional offers?');
$obj = $form->add('radios', 'notifications', array(
'yes' => 'Yes',
'no' => 'No',
));
$obj->set_rule(array(
'required' => array('error', 'Please select an answer!'),
));
// "method"
$form->add('label', 'label_method', 'method', 'Please specify how you would like to be notified about promotional offers:');
$obj = $form->add('checkboxes', 'method[]', array(
'email' => 'By e-mail',
'phone' => 'By phone',
'post' => 'By land mail',
));
$obj->set_rule(array(
'required' => array('error', 'Please specify how you would like to be notified about promotional offers!'),
'dependencies' => array(array(
'notifications' => 'yes',
// whenever the value of "notification" changes, call this function and pass as second argument the value "1"
), 'mycallback, 1'),
));
// "email"
$form->add('label', 'label_email', 'email', 'Your email address:');
$obj = $form->add('text', 'email');
$obj->set_rule(array(
'required' => array('error', 'Email is required!'),
'email' => array('error', 'Email address seems to be invalid!'),
'dependencies' => array(array(
'method' => 'email',
), 'mycallback, 2'),
));
$form->add('note', 'note_email', 'email', 'Your email address will not be published.');
// "phone"
$form->add('label', 'label_phone', 'phone', 'Your telephone number:');
$obj = $form->add('text', 'phone');
$obj->set_rule(array(
'required' => array('error', 'Phone number is required!'),
'digits' => array('', 'error', 'Phone number must contain only digits!'),
'dependencies' => array(array(
'method' => 'phone',
), 'mycallback, 3'),
));
$form->add('note', 'note_phone', 'phone', 'Enter your phone number using digits only');
// "post"
$form->add('label', 'label_post', 'post', 'Your postal address:');
$obj = $form->add('text', 'post');
$obj->set_rule(array(
'required' => array('error', 'Postal address is required!'),
'dependencies' => array(array(
'method' => 'post',
), 'mycallback, 4'),
));
$form->add('note', 'note_post', 'post', 'Enter the address where the notifications about promotional offers should be delivered');
// "why"
$form->add('label', 'label_why', 'why', 'Please tell us why:');
$obj = $form->add('textarea', 'why');
$obj->set_rule(array(
'required' => array('error', 'Please leave us a message!'),
'dependencies' => array(array(
'notifications' => 'no',
), 'mycallback, 5'),
));
// "submit"
$form->add('submit', 'btnsubmit', 'Submit');
// if the form is valid
if ($form->validate()) {
// show results
show_results();
// otherwise
} else
$form->render('includes/custom-templates/example1-dependencies.php');
?>

View File

@@ -0,0 +1,75 @@
<h2>Dependencies</h2>
<p>Notice how the elements from the "Add new person" section are validated *only* when the "Add new" button is clicked</p>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form');
// add the "name" element
$form->add('label', 'label_name', 'name', 'Name');
$obj = $form->add('text', 'name');
// set rules
$obj->set_rule(array(
'required' => array('error', 'Name is required!'),
));
// add the "surname" element
$form->add('label', 'label_surname', 'surname', 'Surname');
$obj = $form->add('text', 'surname');
// set rules
$obj->set_rule(array(
'required' => array('error', 'Surname is required!'),
));
// elements for adding a new person
// add the "name" element
$form->add('label', 'label_add_name', 'add_name', 'Name');
$obj = $form->add('text', 'add_name');
// set rules
// validate *only* if the "Add new" button is clicked
$obj->set_rule(array(
'required' => array('error', 'Name is required!'),
'dependencies' => array(
'btnadd' => 'click',
),
));
// add the "surname" element
$form->add('label', 'label_add_surname', 'add_surname', 'Surame');
$obj = $form->add('text', 'add_surname');
// set rules
$obj->set_rule(array(
'required' => array('error', 'Surname is required!'),
'dependencies' => array(
'btnadd' => 'click',
),
));
// "add"
$form->add('submit', 'btnadd', 'Add new');
// "submit"
$form->add('submit', 'btnsubmit', 'Finish');
// if the form is valid
if ($form->validate()) {
// show results
show_results();
// otherwise
} else
$form->render('includes/custom-templates/example2-dependencies.php');
?>

View File

@@ -0,0 +1,52 @@
<h2>Basic image upload</h2>
<p>We're checking for file types </p>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form');
// the label for the "file" element
$form->add('label', 'label_file', 'file', 'Upload an image');
// add the "file" element
$obj = $form->add('file', 'file');
// set rules
$obj->set_rule(array(
// error messages will be sent to a variable called "error", usable in custom templates
'required' => array('error', 'An image is required!'),
'upload' => array('tmp', ZEBRA_FORM_UPLOAD_RANDOM_NAMES, 'error', 'Could not upload file!<br>Check that the "tmp" folder exists inside the "examples" folder and that it is writable'),
// notice how we use the "image" rule instead of the "filetype" rule (used in previous example);
// the "image" rule does a thorough checking aimed specially for images
'image' => array('error', 'File must be a jpg, png or gif image!'),
'filesize' => array(102400, 'error', 'File size must not exceed 100Kb!'),
));
// attach a note
$form->add('note', 'note_file', 'file', 'File must have the .jpg, .jpeg, png or .gif extension, and no more than 100Kb!');
// "submit"
$form->add('submit', 'btnsubmit', 'Submit');
// validate the form
if ($form->validate()) {
// do stuff here
print_r('<pre>');
print_r($form->file_upload);
die();
}
// auto generate output, labels above form elements
$form->render();
?>

View File

@@ -0,0 +1,49 @@
<h2>Basic file upload</h2>
<p>Once you upload the file, don't forget to look into the "tmp" folder inside the "examples" folder for the result.</p>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form');
// the label for the "file" element
$form->add('label', 'label_file', 'file', 'Upload Microsoft Word document');
// add the "file" element
$obj = $form->add('file', 'file');
// set rules
$obj->set_rule(array(
// error messages will be sent to a variable called "error", usable in custom templates
'required' => array('error', 'A Microsoft Word document is required!'),
'upload' => array('tmp', ZEBRA_FORM_UPLOAD_RANDOM_NAMES, 'error', 'Could not upload file!<br>Check that the "tmp" folder exists inside the "examples" folder and that it is writable'),
'filetype' => array('doc, docx', 'error', 'File must be a Microsoft Word document!'),
'filesize' => array(102400, 'error', 'File size must not exceed 100Kb!'),
));
// attach a note
$form->add('note', 'note_file', 'file', 'File must have the .doc or .docx extension, and no more than 100Kb!');
// "submit"
$form->add('submit', 'btnsubmit', 'Submit');
// validate the form
if ($form->validate()) {
// do stuff here
print_r('<pre>');
print_r($form->file_upload);
die();
}
// auto generate output, labels above form elements
$form->render();
?>

View File

@@ -0,0 +1,62 @@
<h2>A login form</h2>
<p>In this demo we're creating a custom template using only divs; this is suitable for creating "vertical" templates (when
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
"Template source" tab to see how it's done.</p>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form', 'post', '', array('autocomplete' => 'off'));
// the label for the "email" element
$form->add('label', 'label_email', 'email', 'Email');
// add the "email" element
$obj = $form->add('text', 'email');
// set rules
$obj->set_rule(array(
// error messages will be sent to a variable called "error", usable in custom templates
'required' => array('error', 'Email is required!'),
'email' => array('error', 'Email address seems to be invalid!'),
));
// "password"
$form->add('label', 'label_password', 'password', 'Password');
$obj = $form->add('password', 'password');
$obj->set_rule(array(
'required' => array('error', 'Password is required!'),
'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters!'),
));
// "remember me"
$form->add('checkbox', 'remember_me', 'yes');
$form->add('label', 'label_remember_me_yes', 'remember_me_yes', 'Remember me', array('style' => 'font-weight:normal'));
// "submit"
$form->add('submit', 'btnsubmit', 'Submit');
// if the form is valid
if ($form->validate()) {
// show results
show_results();
// otherwise
} else
// generate output using a custom template
$form->render('includes/custom-templates/divs-login.php');
?>

View File

@@ -0,0 +1,53 @@
<h2>A login form</h2>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form', 'post', '', array('autocomplete' => 'off'));
// the label for the "email" element
$form->add('label', 'label_email', 'email', 'Email');
// add the "email" element
$obj = $form->add('text', 'email');
// set rules
$obj->set_rule(array(
// error messages will be sent to a variable called "error", usable in custom templates
'required' => array('error', 'Email is required!'),
'email' => array('error', 'Email address seems to be invalid!'),
));
// "password"
$form->add('label', 'label_password', 'password', 'Password');
$obj = $form->add('password', 'password');
$obj->set_rule(array(
'required' => array('error', 'Password is required!'),
'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters!'),
));
// "remember me"
$form->add('checkbox', 'remember_me', 'yes');
$form->add('label', 'label_remember_me_yes', 'remember_me_yes', 'Remember me', array('style' => 'font-weight:normal'));
// "submit"
$form->add('submit', 'btnsubmit', 'Submit');
// if the form is valid
if ($form->validate()) {
// show results
show_results();
// otherwise
} else
// generate output using a custom template
$form->render('*horizontal');
?>

View File

@@ -0,0 +1,53 @@
<h2>A login form</h2>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form', 'post', '', array('autocomplete' => 'off'));
// the label for the "email" element
$form->add('label', 'label_email', 'email', 'Email address', array('inside' => true));
// add the "email" element
$obj = $form->add('text', 'email');
// set rules
$obj->set_rule(array(
// error messages will be sent to a variable called "error", usable in custom templates
'required' => array('error', 'Email is required!'),
'email' => array('error', 'Email address seems to be invalid!'),
));
// "password"
$form->add('label', 'label_password', 'password', 'Password', array('inside' => true));
$obj = $form->add('password', 'password');
$obj->set_rule(array(
'required' => array('error', 'Password is required!'),
'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters!'),
));
// "remember me"
$form->add('checkbox', 'remember_me', 'yes');
$form->add('label', 'label_remember_me_yes', 'remember_me_yes', 'Remember me', array('style' => 'font-weight:normal'));
// "submit"
$form->add('submit', 'btnsubmit', 'Submit');
// if the form is valid
if ($form->validate()) {
// show results
show_results();
// otherwise
} else
// generate output using a custom template
$form->render();
?>

View File

@@ -0,0 +1,56 @@
<h2>A login form</h2>
<p>In this demo we're creating a custom template using tables; this is suitable for creating "horizontal" templates (when
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.</p>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form', 'post', '', array('autocomplete' => 'off'));
// the label for the "email" element
$form->add('label', 'label_email', 'email', 'Email');
// add the "email" element
$obj = $form->add('text', 'email');
// set rules
$obj->set_rule(array(
// error messages will be sent to a variable called "error", usable in custom templates
'required' => array('error', 'Email is required!'),
'email' => array('error', 'Email address seems to be invalid!'),
));
// "password"
$form->add('label', 'label_password', 'password', 'Password');
$obj = $form->add('password', 'password');
$obj->set_rule(array(
'required' => array('error', 'Password is required!'),
'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters!'),
));
// "remember me"
$form->add('checkbox', 'remember_me', 'yes');
$form->add('label', 'label_remember_me_yes', 'remember_me_yes', 'Remember me', array('style' => 'font-weight:normal'));
// "submit"
$form->add('submit', 'btnsubmit', 'Submit');
// if the form is valid
if ($form->validate()) {
// show results
show_results();
// otherwise
} else
// generate output using a custom template
$form->render('includes/custom-templates/tables-login.php');
?>

View File

@@ -0,0 +1,53 @@
<h2>A login form</h2>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form', 'post', '', array('autocomplete' => 'off'));
// the label for the "email" element
$form->add('label', 'label_email', 'email', 'Email');
// add the "email" element
$obj = $form->add('text', 'email');
// set rules
$obj->set_rule(array(
// error messages will be sent to a variable called "error", usable in custom templates
'required' => array('error', 'Email is required!'),
'email' => array('error', 'Email address seems to be invalid!'),
));
// "password"
$form->add('label', 'label_password', 'password', 'Password');
$obj = $form->add('password', 'password');
$obj->set_rule(array(
'required' => array('error', 'Password is required!'),
'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters!'),
));
// "remember me"
$form->add('checkbox', 'remember_me', 'yes');
$form->add('label', 'label_remember_me_yes', 'remember_me_yes', 'Remember me', array('style' => 'font-weight:normal'));
// "submit"
$form->add('submit', 'btnsubmit', 'Submit');
// if the form is valid
if ($form->validate()) {
// show results
show_results();
// otherwise
} else
// auto generate output, labels above form elements
$form->render();
?>

View File

@@ -0,0 +1,88 @@
<h2>A registration form</h2>
<p>Check the "Template source" tab to see how it's done!</p>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form', 'post', '', array('autocomplete' => 'off'));
// the label for the "first name" element
$form->add('label', 'label_firstname', 'firstname', 'First name:');
// add the "first name" element
$obj = $form->add('text', 'firstname');
// set rules
$obj->set_rule(array(
// error messages will be sent to a variable called "error", usable in custom templates
'required' => array('error', 'First name is required!'),
));
// "last name"
$form->add('label', 'label_lastname', 'lastname', 'Last name:');
$obj = $form->add('text', 'lastname');
$obj->set_rule(array(
'required' => array('error', 'Last name is required!')
));
// "email"
$form->add('label', 'label_email', 'email', 'Email address:');
$obj = $form->add('text', 'email');
$obj->set_rule(array(
'required' => array('error', 'Email is required!'),
'email' => array('error', 'Email address seems to be invalid!')
));
// attach a note to the email element
$form->add('note', 'note_email', 'email', 'Please enter a valid email address. An email will be sent to this
address with a link you need to click on in order to activate your account', array('style'=>'width:200px'));
// "password"
$form->add('label', 'label_password', 'password', 'Choose a password:');
$obj = $form->add('password', 'password');
$obj->set_rule(array(
'required' => array('error', 'Password is required!'),
'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters'),
));
$form->add('note', 'note_password', 'password', 'Password must be have between 6 and 10 characters.', array('style' => 'width: 180px'));
// "confirm password"
$form->add('label', 'label_confirm_password', 'confirm_password', 'Confirm password:');
$obj = $form->add('password', 'confirm_password');
$obj->set_rule(array(
'compare' => array('password', 'error', 'Password not confirmed correctly!')
));
// "captcha"
$form->add('captcha', 'captcha_image', 'captcha_code');
$form->add('label', 'label_captcha_code', 'captcha_code', 'Are you human?');
$obj = $form->add('text', 'captcha_code');
$form->add('note', 'note_captcha', 'captcha_code', 'You must enter the characters with black color that stand
out from the other characters', array('style'=>'width: 200px'));
$obj->set_rule(array(
'required' => array('error', 'Enter the characters from the image above!'),
'captcha' => array('error', 'Characters from image entered incorrectly!')
));
// "submit"
$form->add('submit', 'btnsubmit', 'Submit');
// if the form is valid
if ($form->validate()) {
// show results
show_results();
// otherwise
} else
// generate output using a custom template
$form->render('includes/custom-templates/registration.php');
?>

View File

@@ -0,0 +1,86 @@
<h2>A registration form</h2>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form', 'post', '', array('autocomplete' => 'off'));
// the label for the "first name" element
$form->add('label', 'label_firstname', 'firstname', 'First name:');
// add the "first name" element
$obj = $form->add('text', 'firstname');
// set rules
$obj->set_rule(array(
// error messages will be sent to a variable called "error", usable in custom templates
'required' => array('error', 'First name is required!'),
));
// "last name"
$form->add('label', 'label_lastname', 'lastname', 'Last name:');
$obj = $form->add('text', 'lastname');
$obj->set_rule(array(
'required' => array('error', 'Last name is required!')
));
// "email"
$form->add('label', 'label_email', 'email', 'Email address:');
$obj = $form->add('text', 'email');
$obj->set_rule(array(
'required' => array('error', 'Email is required!'),
'email' => array('error', 'Email address seems to be invalid!')
));
// attach a note to the email element
$form->add('note', 'note_email', 'email', 'Please enter a valid email address. An email will be sent to this
address with a link you need to click on in order to activate your account', array('style'=>'width:200px'));
// "password"
$form->add('label', 'label_password', 'password', 'Choose a password:');
$obj = $form->add('password', 'password');
$obj->set_rule(array(
'required' => array('error', 'Password is required!'),
'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters'),
));
$form->add('note', 'note_password', 'password', 'Password must be have between 6 and 10 characters.');
// "confirm password"
$form->add('label', 'label_confirm_password', 'confirm_password', 'Confirm password:');
$obj = $form->add('password', 'confirm_password');
$obj->set_rule(array(
'compare' => array('password', 'error', 'Password not confirmed correctly!')
));
// "captcha"
$form->add('captcha', 'captcha_image', 'captcha_code');
$form->add('label', 'label_captcha_code', 'captcha_code', 'Are you human?');
$obj = $form->add('text', 'captcha_code');
$form->add('note', 'note_captcha', 'captcha_code', 'You must enter the characters with black color that stand
out from the other characters', array('style'=>'width: 200px'));
$obj->set_rule(array(
'required' => array('error', 'Enter the characters from the image above!'),
'captcha' => array('error', 'Characters from image entered incorrectly!')
));
// "submit"
$form->add('submit', 'btnsubmit', 'Submit');
// if the form is valid
if ($form->validate()) {
// show results
show_results();
// otherwise
} else
// generate output using a custom template
$form->render('*horizontal');
?>

View File

@@ -0,0 +1,86 @@
<h2>A registration form</h2>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form', 'post', '', array('autocomplete' => 'off'));
// the label for the "first name" element
$form->add('label', 'label_firstname', 'firstname', 'First name:');
// add the "first name" element
$obj = $form->add('text', 'firstname');
// set rules
$obj->set_rule(array(
// error messages will be sent to a variable called "error", usable in custom templates
'required' => array('error', 'First name is required!'),
));
// "last name"
$form->add('label', 'label_lastname', 'lastname', 'Last name:');
$obj = $form->add('text', 'lastname');
$obj->set_rule(array(
'required' => array('error', 'Last name is required!')
));
// "email"
$form->add('label', 'label_email', 'email', 'Email address:');
$obj = $form->add('text', 'email');
$obj->set_rule(array(
'required' => array('error', 'Email is required!'),
'email' => array('error', 'Email address seems to be invalid!')
));
// attach a note to the email element
$form->add('note', 'note_email', 'email', 'Please enter a valid email address. An email will be sent to this
address with a link you need to click on in order to activate your account', array('style'=>'width:200px'));
// "password"
$form->add('label', 'label_password', 'password', 'Choose a password:');
$obj = $form->add('password', 'password');
$obj->set_rule(array(
'required' => array('error', 'Password is required!'),
'length' => array(6, 10, 'error', 'The password must have between 6 and 10 characters'),
));
$form->add('note', 'note_password', 'password', 'Password must be have between 6 and 10 characters.');
// "confirm password"
$form->add('label', 'label_confirm_password', 'confirm_password', 'Confirm password:');
$obj = $form->add('password', 'confirm_password');
$obj->set_rule(array(
'compare' => array('password', 'error', 'Password not confirmed correctly!')
));
// "captcha"
$form->add('captcha', 'captcha_image', 'captcha_code');
$form->add('label', 'label_captcha_code', 'captcha_code', 'Are you human?');
$obj = $form->add('text', 'captcha_code');
$form->add('note', 'note_captcha', 'captcha_code', 'You must enter the characters with black color that stand
out from the other characters', array('style'=>'width: 200px'));
$obj->set_rule(array(
'required' => array('error', 'Enter the characters from the image above!'),
'captcha' => array('error', 'Characters from image entered incorrectly!')
));
// "submit"
$form->add('submit', 'btnsubmit', 'Submit');
// if the form is valid
if ($form->validate()) {
// show results
show_results();
// otherwise
} else
// generate output using a custom template
$form->render();
?>

View File

@@ -0,0 +1,116 @@
<h2>A meeting room reservation form</h2>
<p>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!</p>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form');
// auto-fill fields with random values
// very useful for when debugging forms
$form->auto_fill();
// the label for the "name" element
$form->add('label', 'label_name', 'name', 'Your name:');
// add the "name" element
$obj = $form->add('text', 'name');
// set rules
$obj->set_rule(array(
// error messages will be sent to a variable called "error", usable in custom templates
'required' => array('error', 'Name is required!')
));
// "email"
$form->add('label', 'label_email', 'email', 'Your email address:');
$obj = $form->add('text', 'email');
$obj->set_rule(array(
'required' => array('error', 'Email is required!'),
'email' => array('error', 'Email address seems to be invalid!'),
));
// "department"
$form->add('label', 'label_department', 'department', 'Department:');
$obj = $form->add('select', 'department', '', array('other' => true));
$obj->add_options(array(
'Marketing',
'Operations',
'Customer Service',
'Human Resources',
'Sales Department',
'Accounting Department',
'Legal Department',
));
$obj->set_rule(array(
'required' => array('error', 'Department is required!')
));
// "room"
$form->add('label', 'label_room', 'room', 'Which room would you like to reserve:');
$obj = $form->add('radios', 'room', array(
'A' => 'Room A',
'B' => 'Room B',
'C' => 'Room C',
));
$obj->set_rule(array(
'required' => array('error', 'Room selection is required!')
));
// "extra"
$form->add('label', 'label_extra', 'extra', 'Extra requirements:');
$obj = $form->add('checkboxes', 'extra[]', array(
'flipchard' => 'Flipchard and pens',
'plasma' => 'Plasma TV screen',
'beverages' => 'Coffee, tea and mineral water',
));
// "date"
$form->add('label', 'label_date', 'date', 'Reservation date');
$date = $form->add('date', 'date');
$date->set_rule(array(
'required' => array('error', 'Date is required!'),
'date' => array('error', 'Date is invalid!'),
));
// date format
// 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
// in a database or with PHP's strtotime function!
$date->format('M d, Y');
$form->add('note', 'note_date', 'date', 'Date format is M d, Y');
// "time"
$form->add('label', 'label_time', 'time', 'Reservation time :');
$obj = $form->add('time', 'time', '', array(
'format' => 'hm',
'hours' => array(9, 10, 11, 12, 13, 14, 15, 16, 17),
'minutes' => array(0, 30),
));
$obj->set_rule(array(
'required' => array('error', 'Time is required!'),
));
// "submit"
$form->add('submit', 'btnsubmit', 'Submit');
// if the form is valid
if ($form->validate()) {
// show results
show_results();
// otherwise
} else
// generate output using a custom template
$form->render();
?>

View File

@@ -0,0 +1,110 @@
<h2>A meeting room reservation form</h2>
<p>Check the "Template source" tab to see how it's done!</p>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form');
// the label for the "name" element
$form->add('label', 'label_name', 'name', 'Your name:');
// add the "name" element
$obj = $form->add('text', 'name');
// set rules
$obj->set_rule(array(
// error messages will be sent to a variable called "error", usable in custom templates
'required' => array('error', 'Name is required!')
));
// "email"
$form->add('label', 'label_email', 'email', 'Your email address:');
$obj = $form->add('text', 'email');
$obj->set_rule(array(
'required' => array('error', 'Email is required!'),
'email' => array('error', 'Email address seems to be invalid!'),
));
// "department"
$form->add('label', 'label_department', 'department', 'Department:');
$obj = $form->add('select', 'department', '', array('other' => true));
$obj->add_options(array(
'Marketing',
'Operations',
'Customer Service',
'Human Resources',
'Sales Department',
'Accounting Department',
'Legal Department',
));
$obj->set_rule(array(
'required' => array('error', 'Department is required!')
));
// "room"
$form->add('label', 'label_room', 'room', 'Which room would you like to reserve:');
$obj = $form->add('radios', 'room', array(
'A' => 'Room A',
'B' => 'Room B',
'C' => 'Room C',
));
$obj->set_rule(array(
'required' => array('error', 'Room selection is required!')
));
// "extra"
$form->add('label', 'label_extra', 'extra', 'Extra requirements:');
$obj = $form->add('checkboxes', 'extra[]', array(
'flipchard' => 'Flipchard and pens',
'plasma' => 'Plasma TV screen',
'beverages' => 'Coffee, tea and mineral water',
));
// "date"
$form->add('label', 'label_date', 'date', 'Reservation date');
$date = $form->add('date', 'date');
$date->set_rule(array(
'required' => array('error', 'Date is required!'),
'date' => array('error', 'Date is invalid!'),
));
// date format
// 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
// in a database or with PHP's strtotime function!
$date->format('M d, Y');
// selectable dates are starting with the current day
$date->direction(1);
$form->add('note', 'note_date', 'date', 'Date format is M d, Y');
// "time"
$form->add('label', 'label_time', 'time', 'Reservation time :');
$form->add('time', 'time', '', array(
'hours' => array(9, 10, 11, 12, 13, 14, 15, 16, 17),
'minutes' => array(0, 30),
));
// "submit"
$form->add('submit', 'btnsubmit', 'Submit');
// if the form is valid
if ($form->validate()) {
// show results
show_results();
// otherwise
} else
// generate output using a custom template
$form->render('includes/custom-templates/reservation.php');
?>

View File

@@ -0,0 +1,108 @@
<h2>A meeting room reservation form</h2>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form');
// the label for the "name" element
$form->add('label', 'label_name', 'name', 'Your name:');
// add the "name" element
$obj = $form->add('text', 'name');
// set rules
$obj->set_rule(array(
// error messages will be sent to a variable called "error", usable in custom templates
'required' => array('error', 'Name is required!')
));
// "email"
$form->add('label', 'label_email', 'email', 'Your email address:');
$obj = $form->add('text', 'email');
$obj->set_rule(array(
'required' => array('error', 'Email is required!'),
'email' => array('error', 'Email address seems to be invalid!'),
));
// "department"
$form->add('label', 'label_department', 'department', 'Department:');
$obj = $form->add('select', 'department', '', array('other' => true));
$obj->add_options(array(
'Marketing',
'Operations',
'Customer Service',
'Human Resources',
'Sales Department',
'Accounting Department',
'Legal Department',
));
$obj->set_rule(array(
'required' => array('error', 'Department is required!')
));
// "room"
$form->add('label', 'label_room', 'room', 'Which room would you like to reserve:');
$obj = $form->add('radios', 'room', array(
'A' => 'Room A',
'B' => 'Room B',
'C' => 'Room C',
));
$obj->set_rule(array(
'required' => array('error', 'Room selection is required!')
));
// "extra"
$form->add('label', 'label_extra', 'extra', 'Extra requirements:');
$obj = $form->add('checkboxes', 'extra[]', array(
'flipchard' => 'Flipchard and pens',
'plasma' => 'Plasma TV screen',
'beverages' => 'Coffee, tea and mineral water',
));
// "date"
$form->add('label', 'label_date', 'date', 'Reservation date');
$date = $form->add('date', 'date');
$date->set_rule(array(
'required' => array('error', 'Date is required!'),
'date' => array('error', 'Date is invalid!'),
));
// date format
// 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
// in a database or with PHP's strtotime function!
$date->format('M d, Y');
// selectable dates are starting with the current day
$date->direction(1);
$form->add('note', 'note_date', 'date', 'Date format is M d, Y');
// "time"
$form->add('label', 'label_time', 'time', 'Reservation time :');
$form->add('time', 'time', '', array(
'hours' => array(9, 10, 11, 12, 13, 14, 15, 16, 17),
'minutes' => array(0, 30),
));
// "submit"
$form->add('submit', 'btnsubmit', 'Submit');
// if the form is valid
if ($form->validate()) {
// show results
show_results();
// otherwise
} else
// generate output using a custom template
$form->render('*horizontal');
?>

View File

@@ -0,0 +1,110 @@
<h2>A meeting room reservation form</h2>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form');
// the label for the "name" element
$form->add('label', 'label_name', 'name', 'Your name:');
// add the "name" element
$obj = $form->add('text', 'name');
// set rules
$obj->set_rule(array(
// error messages will be sent to a variable called "error", usable in custom templates
'required' => array('error', 'Name is required!')
));
// "email"
$form->add('label', 'label_email', 'email', 'Your email address:');
$obj = $form->add('text', 'email');
$obj->set_rule(array(
'required' => array('error', 'Email is required!'),
'emails' => array('error', 'Email address seems to be invalid!'),
));
// "department"
$form->add('label', 'label_department', 'department', 'Department:');
$obj = $form->add('select', 'department', '', array('other' => true));
$obj->add_options(array(
'Marketing',
'Operations',
'Customer Service',
'Human Resources',
'Sales Department',
'Accounting Department',
'Legal Department',
));
$obj->set_rule(array(
'required' => array('error', 'Department is required!')
));
// "room"
$form->add('label', 'label_room', 'room', 'Which room would you like to reserve:');
$obj = $form->add('radios', 'room', array(
'A' => 'Room A',
'B' => 'Room B',
'C' => 'Room C',
));
$obj->set_rule(array(
'required' => array('error', 'Room selection is required!')
));
// "extra"
$form->add('label', 'label_extra', 'extra', 'Extra requirements:');
$obj = $form->add('checkboxes', 'extra[]', array(
'flipchard' => 'Flipchard and pens',
'plasma' => 'Plasma TV screen',
'beverages' => 'Coffee, tea and mineral water',
));
// "date"
$form->add('label', 'label_date', 'date', 'Reservation date');
$date = $form->add('date', 'date');
$date->set_rule(array(
'required' => array('error', 'Date is required!'),
'date' => array('error', 'Date is invalid!'),
));
// date format
// 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
// in a database or with PHP's strtotime function!
$date->format('M d, Y');
$form->add('note', 'note_date', 'date', 'Date format is M d, Y');
// "time"
$form->add('label', 'label_time', 'time', 'Reservation time :');
$obj = $form->add('time', 'time', '', array(
'format' => 'hm',
'hours' => array(9, 10, 11, 12, 13, 14, 15, 16, 17),
'minutes' => array(0, 30),
));
$obj->set_rule(array(
'required' => array('error', 'Time is required!'),
));
// "submit"
$form->add('submit', 'btnsubmit', 'Submit');
// if the form is valid
if ($form->validate()) {
// show results
show_results();
// otherwise
} else
// generate output using a custom template
$form->render();
?>

View File

@@ -0,0 +1,107 @@
<h2>More validation rules</h2>
<?php
// include the Zebra_Form class
require '../Zebra_Form.php';
// instantiate a Zebra_Form object
$form = new Zebra_Form('form');
// "alphabet"
$form->add('label', 'label_alphabet', 'alphabet', 'Alphabet:');
$obj = $form->add('text', 'alphabet');
// set rules
$obj->set_rule(array(
// error messages will be sent to a variable called "error", usable in custom templates
'required' => array('error', 'This field is required!'),
'alphabet' => array('', 'error', 'Accepts only characters from the alphabet (case-insensitive a to z)')
));
// attach a note
$form->add('note', 'note_alphabet', 'alphabet', 'Accepts only characters from the alphabet (case-insensitive a to z)');
// "alphanumeric"
$form->add('label', 'label_alphanumeric', 'alphanumeric', 'Alphanumeric:');
$obj = $form->add('text', 'alphanumeric');
$obj->set_rule(array(
'required' => array('error', 'This field is required!'),
'alphanumeric' => array('', 'error', 'Accepts only characters from the alphabet (case-insensitive a to z) and digits (0 to 9)')
));
$form->add('note', 'note_alphanumeric', 'alphanumeric', 'Accepts only characters from the alphabet (case-insensitive a to z) and digits (0 to 9)');
// "digits"
$form->add('label', 'label_digits', 'digits', 'Digits:');
$obj = $form->add('text', 'digits');
$obj->set_rule(array(
'required' => array('error', 'This field is required!'),
'digits' => array('', 'error', 'Accepts only digits (0 to 9)')
));
$form->add('note', 'note_digits', 'digits', 'Accepts only digits (0 to 9)');
// "float"
$form->add('label', 'label_float', 'float', 'Float:');
$obj = $form->add('text', 'float');
$obj->set_rule(array(
'required' => array('error', 'This field is required!'),
'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)')
));
$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)');
// "length"
$form->add('label', 'label_length', 'length', 'Length:');
$obj = $form->add('text', 'length');
$obj->set_rule(array(
'required' => array('error', 'This field is required!'),
'length' => array(6, 12, 'error', 'Must contain between 6 and 12 characters!')
));
$form->add('note', 'note_length', 'length', 'Must contain between 6 and 12 characters');
// "number"
$form->add('label', 'label_number', 'number', 'Number:');
$obj = $form->add('text', 'number');
$obj->set_rule(array(
'required' => array('error', 'This field is required!'),
'number' => array('', 'error', 'Accepts only digits (0 to 9) and/or one minus sign (but only if it is the very first character)')
));
$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)');
// "regular expression"
$form->add('label', 'label_regexp', 'regexp', 'Regular expression:');
$obj = $form->add('text', 'regexp');
$obj->set_rule(array(
'required' => array('error', 'This field is required!'),
'regexp' => array('^07[0-9]{8}$', 'error', 'Validates only if the value matches the following regular expression: ^07[0-9]{8}$')
));
$form->add('note', 'note_regexp', 'regexp', 'Validates if the value satisfies the following regular expression: ^07[0-9]{8}$');
// "change case"
$form->add('label', 'label_case', 'case', 'Change case:');
$obj = $form->add('text', 'case');
$obj->set_rule(array(
'required' => array('error', 'This field is required!'),
));
// force all characters to be upper-case
$obj->change_case('upper');
$form->add('note', 'note_case', 'case', 'All entered characters will be upper-case');
// "submit"
$form->add('submit', 'btnsubmit', 'Submit');
// if the form is valid
if ($form->validate()) {
// show results
show_results();
// otherwise
} else
// generate output using a custom template
$form->render();
?>

View File

@@ -0,0 +1,8 @@
<html>
<head>
<title>403 Forbidden</title>
</head>
<body>
<p>Directory access is forbidden.</p>
</body>
</html>

View File

@@ -0,0 +1,310 @@
<?php
error_reporting(E_ALL);
session_start()
?>
<?php
/**
* Dumps information about a variable in a human readable format
*
* @param mixed $variable Variable to print information about
*
* @param boolean $stop Whether to stop script execution after outputting the variable.
*
* Default is FALSE
*
* @return void
*/
function dump()
{
// get the arguments passed to the function
$arguments = func_get_args();
// if last argument is boolean TRUE
if ($arguments[count($arguments) - 1] === true)
// set a flag telling the script that it needs to die() after output
$stop = array_pop($arguments);
// iterate through the arguments
foreach ($arguments as $argument) {
// print each argument
print_r('<pre style="text-align:left">');
print_r($argument);
print_r('</pre>');
}
// if script needs to die() after output, die
if (isset($stop)) die();
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Zebra_Form, a jQuery augmented PHP library for HTML form building and validation</title>
<link rel="stylesheet" href="libraries/highlight/public/css/ir_black.css" type="text/css">
<link rel="stylesheet" href="public/css/reset.css" type="text/css">
<link rel="stylesheet" href="public/css/style.css" type="text/css">
<link rel="stylesheet" href="../public/css/zebra_form.css" type="text/css">
</head>
<body>
<div class="header"><a href="http://stefangabos.ro/">Stefan Gabos | <span>webdeveloper</span></a></div>
<div class="example">
Example for: <a href="http://stefangabos.ro/php-libraries/zebra-form/">Zebra_Form, a jQuery augmented PHP
library for HTML form building and validation</a>
</div>
<table>
<tr>
<td valign="top">
<?php
function show_results() {
echo '<table class="results"><thead><tr><td colspan="2">Submitted values</td></tr></thead>';
foreach ($_POST as $key => $value) {
if (strpos($key, 'name_') !== 0 && strpos($key, 'timer_') !== 0 && strpos($key, 'response_') !== 0)
echo '<tr><th>' . $key . '</th><td>' . (is_array($value) ? '<pre>' . print_r($value, true) . '</pre>' : $value) . '</td></tr>';
}
echo '</table>';
}
$demos = array(
'A login form' => array('login', array(
'Auto template, vertical' => 'vertical',
'Auto template, horizontal' => 'horizontal',
'Auto template, labels inside' => 'labels-inside',
'Custom template - divs' => 'divs-custom',
'Custom template - tables' => 'tables-custom',
)),
'A contact form' => array('contact', array(
'Auto template, vertical' => 'vertical',
'Auto template, horizontal' => 'horizontal',
'Custom template' => 'custom',
)),
'A registration form' => array('registration', array(
'Auto template, vertical' => 'vertical',
'Auto template, horizontal' => 'horizontal',
'Custom template' => 'custom',
)),
'A reservation form' => array('reservation', array(
'Auto template, vertical' => 'vertical',
'Auto template, horizontal' => 'horizontal',
'Custom template' => 'custom',
'Auto-fill' => 'autofill-vertical',
)),
'Dependencies' => array('dependencies', array(
'Example 1' => 'example1-custom',
'Example 2' => 'example2-custom',
)),
'File upload' => array('fileupload', array(
'Basic file upload' => 'basic-vertical',
'Basic image upload' => 'basic-image-vertical',
)),
'More rules' => array('validation', array(
'Auto template, vertical' => 'vertical',
)),
);
$current_template = isset($_GET['template']) ? strtolower($_GET['template']) : '';
if (isset($_GET['example']) && is_file('includes/' . $_GET['example'] . '-' . $current_template . '.php')) {
$current_example = strtolower($_GET['example']);
} else {
$current_template = 'vertical';
$current_example = 'login';
}
?>
<ul class="navigation default">
<?php foreach ($demos as $title => $values):?>
<li><?php echo $title?>
<ul>
<?php foreach ($values[1] as $example => $template):?>
<li>
<a href="?example=<?php echo $values[0]?>&amp;template=<?php echo $template?>"<?php echo ($current_example == $values[0] && $current_template == $template ? ' class="selected"' : '')?>><?php echo $example?></a>
</li>
<?php endforeach?>
</ul>
</li>
<?php endforeach?>
</ul>
</td>
<td valign="top">
<?php if ($example != ''):?>
<ul class="tabs float clearfix">
<li><a href="javascript:void(0)" class="selected">Demo</a></li>
<li><a href="javascript:void(0)">PHP source</a></li>
<li><a href="javascript:void(0)">Template source</a></li>
<li><a href="javascript:void(0)">Container HTML</a></li>
</ul>
<?php for ($i = 0; $i < 5; $i++):?>
<div class="tab clearfix"<?php echo $i == 0 ? ' style="display:block"' : ''?>>
<?php if ($i == 0):?>
<?php require 'includes/' . $current_example . '-' . $current_template . '.php'?>
<?php elseif ($i == 1):?>
<?php
$php_source = file_get_contents('includes/' . $current_example . '-' . $current_template . '.php');
$patterns = array(
'/^.*?\<\?php/is',
'/require \'.*?Zebra\_Form\.php\'/',
'/\$form\-\>render\(\'includes\/custom\-templates\/.*?\'\)\;/',
);
$replacements = array(
'<?php',
'require \'path/to/Zebra_Form.php\'',
'$form->render(\'path/to/custom-template.php\');',
);
$php_source = preg_replace($patterns, $replacements, $php_source);
?>
<pre><code><?php
echo trim(htmlentities($php_source));
?></code></pre>
<?php elseif ($i == 2):?>
<?php if (strpos($current_template, 'custom') === false):?>
<p>In this example, the output is automatically generated by Zebra_Form's <strong>render</strong> method.</p>
<?php elseif (is_file('includes/custom-templates/' . str_replace('custom-', '', $current_template . '-' . $current_example) . '.php')):?>
<pre><code><?php
echo trim(htmlentities(file_get_contents('includes/custom-templates/' . str_replace('custom-', '', $current_template . '-' . $current_example) . '.php')));
?></code></pre>
<?php else:?>
<?php echo 'includes/custom-templates/' . str_replace('custom-', '', $current_template . '-' . $current_example) . '.php' ?>
<?php endif?>
<?php elseif ($i == 3):?>
<?php
$html_container_source = file_get_contents('includes/container-html/container.html');
?>
<pre><code><?php
echo trim(htmlentities($html_container_source));
?></code></pre>
<?php endif?>
<?php if ($i == 0):?>
<ul class="notes default">
<li>
try clicking on the submit button without filling the form and then, as you fill the form, to see the
JavaScript validation in action
</li>
<li>for each example, notice how the PHP code of the form remains basically unchanged, despite the template variations</li>
<li>
disable JavaScript to see the server-side validation in action
</li>
<li>
although in all my examples I use HTML output, you can switch to XHTML output by using the
<strong>doctye</strong> method
</li>
<li>
try the example in another browser and see that it works, out of the box. including IE6!
</li>
</ul>
<?php endif?>
</div>
<?php endfor?>
<?php else:?>
Use the links to the left to navigate between examples.
<?php endif?>
</td>
</tr>
</table>
<div class="clear"></div>
<script type="text/javascript" src="libraries/highlight/public/javascript/highlight.js"></script>
<script type="text/javascript" src="public/javascript/jquery-1.12.0.js"></script>
<script type="text/javascript" src="../public/javascript/zebra_form.js"></script>
<script type="text/javascript" src="public/javascript/core.js"></script>
</body>
</html>

View File

@@ -0,0 +1,38 @@
Syntax highlighting with language autodetection.
URL: http://softwaremaniacs.org/soft/highlight/en/
Original author and current maintainer:
Ivan Sagalaev <Maniac@SoftwareManiacs.Org>
Contributors:
- Peter Leonov <gojpeg@gmail.com>
- Victor Karamzin <Victor.Karamzin@enterra-inc.com>
- Vsevolod Solovyov <vsevolod.solovyov@gmail.com>
- Anton Kovalyov <anton@kovalyov.net>
- Nikita Ledyaev <lenikita@yandex.ru>
- Konstantin Evdokimenko <qewerty@gmail.com>
- Dmitri Roudakov <dmitri@roudakov.ru>
- Yuri Ivanov <ivanov@supersoft.ru>
- Vladimir Ermakov <vooon341@mail.ru>
- Vladimir Gubarkov <xonixx@gmail.com>
- Brian Beck <exogen@gmail.com>
- MajestiC <majestic2k@gmail.com>
- Vasily Polovnyov <vast@whiteants.net>
- Vladimir Epifanov <voldmar@voldmar.ru>
- Alexander Makarov (http://rmcreative.ru/)
- Vah <vahtenberg@gmail.com>
- Shuen-Huei Guan <drake.guan@gmail.com>
- Jason Diamond <jason@diamond.name>
- Michal Gabrukiewicz <mgabru@gmail.com>
- Ruslan Keba <rukeba@gmail.com>
- Sergey Baranov <segyrn@yandex.ru>
- Zaripov Yura <yur4ik7@ukr.net>
- Oleg Volchkov <oleg@volchkov.net>
- Vasily Mikhailitchenko <vaskas@programica.ru>
- Jan Berkel <jan.berkel@gmail.com>
- Vladimir Moskva <vladmos@gmail.com>
- Loren Segal <lsegal@soen.ca>
- Andrew Fedorov <dmmdrs@mail.ru>
- Igor Kalnitsky <igor.kalnitsky@gmail.com>

View File

@@ -0,0 +1,24 @@
Copyright (c) 2006, Ivan Sagalaev
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
* Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of highlight.js nor the names of its contributors
may be used to endorse or promote products derived from this software
without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE REGENTS AND CONTRIBUTORS BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

View File

@@ -0,0 +1,100 @@
/*
Dark style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac@SoftwareManiacs.Org>
*/
pre code {
display: block; padding: 0.5em;
background: #444;
}
pre .keyword,
pre .literal,
pre .change,
pre .winutils,
pre .flow,
pre .lisp .title,
pre .tex .special {
color: white;
}
pre code,
pre .ruby .subst {
color: #DDD;
}
pre .string,
pre .function .title,
pre .class .title,
pre .ini .title,
pre .tag .value,
pre .css .rules .value,
pre .preprocessor,
pre .ruby .symbol,
pre .ruby .symbol .string,
pre .ruby .symbol .keyword,
pre .ruby .symbol .keymethods,
pre .ruby .instancevar,
pre .ruby .class .parent,
pre .built_in,
pre .sql .aggregate,
pre .django .template_tag,
pre .django .variable,
pre .smalltalk .class,
pre .javadoc,
pre .ruby .string,
pre .django .filter .argument,
pre .smalltalk .localvars,
pre .smalltalk .array,
pre .attr_selector,
pre .pseudo,
pre .addition,
pre .stream,
pre .envvar,
pre .apache .tag,
pre .apache .cbracket,
pre .tex .command {
color: #D88;
}
pre .comment,
pre .java .annotation,
pre .python .decorator,
pre .template_comment,
pre .pi,
pre .doctype,
pre .deletion,
pre .shebang,
pre .apache .sqbracket,
pre .tex .formula {
color: #777;
}
pre .keyword,
pre .literal,
pre .css .id,
pre .phpdoc,
pre .function .title,
pre .class .title,
pre .vbscript .built_in,
pre .sql .aggregate,
pre .rsl .built_in,
pre .smalltalk .class,
pre .xml .tag .title,
pre .diff .header,
pre .chunk,
pre .winutils,
pre .bash .variable,
pre .lisp .title,
pre .apache .tag,
pre .tex .special {
font-weight: bold;
}
pre .html .css,
pre .html .javascript,
pre .html .vbscript,
pre .tex .formula {
opacity: 0.5;
}

View File

@@ -0,0 +1,115 @@
/*
Original style from softwaremaniacs.org (c) Ivan Sagalaev <Maniac@SoftwareManiacs.Org>
*/
pre code {
display: block; padding: 0.5em;
background: #F0F0F0;
}
pre code,
pre .ruby .subst,
pre .tag .title,
pre .lisp .title {
color: black;
}
pre .string,
pre .title,
pre .constant,
pre .parent,
pre .tag .value,
pre .rules .value,
pre .rules .value .number,
pre .preprocessor,
pre .ruby .symbol,
pre .ruby .symbol .string,
pre .ruby .symbol .keyword,
pre .ruby .symbol .keymethods,
pre .instancevar,
pre .aggregate,
pre .template_tag,
pre .django .variable,
pre .smalltalk .class,
pre .addition,
pre .flow,
pre .stream,
pre .bash .variable,
pre .apache .tag,
pre .apache .cbracket,
pre .tex .command,
pre .tex .special {
color: #800;
}
pre .comment,
pre .annotation,
pre .template_comment,
pre .diff .header,
pre .chunk {
color: #888;
}
pre .number,
pre .date,
pre .regexp,
pre .literal,
pre .smalltalk .symbol,
pre .smalltalk .char,
pre .change {
color: #080;
}
pre .label,
pre .javadoc,
pre .ruby .string,
pre .decorator,
pre .filter .argument,
pre .localvars,
pre .array,
pre .attr_selector,
pre .important,
pre .pseudo,
pre .pi,
pre .doctype,
pre .deletion,
pre .envvar,
pre .shebang,
pre .apache .sqbracket,
pre .nginx .built_in,
pre .tex .formula {
color: #88F;
}
pre .javadoctag,
pre .phpdoc,
pre .yardoctag {
font-weight: bold;
}
pre .keyword,
pre .id,
pre .phpdoc,
pre .title,
pre .built_in,
pre .aggregate,
pre .smalltalk .class,
pre .winutils,
pre .bash .variable,
pre .apache .tag,
pre .tex .command {
font-weight: bold;
}
pre .nginx .built_in {
font-weight: normal;
}
pre .html .css,
pre .html .javascript,
pre .html .vbscript,
pre .tex .formula {
opacity: 0.5;
}

View File

@@ -0,0 +1,103 @@
/*
IR_Black style (c) Vasily Mikhailitchenko <vaskas@programica.ru>
*/
pre code {
display: block; padding: 0.5em;
background: #222; color: #f8f8f8;
font-size: 11px
}
pre .shebang,
pre .comment,
pre .template_comment,
pre .javadoc {
color: #7c7c7c;
}
pre .keyword,
pre .tag,
pre .ruby .function .keyword,
pre .tex .command {
color: #96CBFE;
}
pre .function .keyword,
pre .sub .keyword,
pre .method,
pre .list .title {
color: #FFFFB6;
}
pre .string,
pre .tag .value,
pre .cdata,
pre .filter .argument,
pre .attr_selector,
pre .apache .cbracket,
pre .date {
color: #A8FF60;
}
pre .subst {
color: #DAEFA3;
}
pre .regexp {
color: #E9C062;
}
pre .function .title,
pre .sub .identifier,
pre .pi,
pre .decorator,
pre .ini .title,
pre .tex .special {
color: #FFFFB6;
}
pre .class .title,
pre .constant,
pre .smalltalk .class,
pre .javadoctag,
pre .yardoctag,
pre .phpdoc,
pre .nginx .built_in {
color: #FFFFB6;
}
pre .symbol,
pre .ruby .symbol .string,
pre .ruby .symbol .keyword,
pre .ruby .symbol .keymethods,
pre .number,
pre .variable,
pre .vbscript,
pre .literal {
color: #C6C5FE;
}
pre .css .keyword {
color: #96CBFE;
}
pre .css .rule .keyword,
pre .css .id {
color: #FFFFB6;
}
pre .css .class {
color: #FFF;
}
pre .hexcolor {
color: #C6C5FE;
}
pre .number {
color:#FF73FD;
}
pre .tex .formula {
opacity: 0.7;
}

View File

@@ -0,0 +1,145 @@
/*
Sunburst-like style (c) Vasily Polovnyov <vast@whiteants.net>
*/
pre code {
display: block; padding: 0.5em;
font: 1em / 1.3em 'Lucida Console', 'courier new', monospace;
background: #000; color: #f8f8f8;
}
pre .comment,
pre .template_comment,
pre .javadoc {
color: #aeaeae;
font-style: italic;
}
pre .keyword,
pre .ruby .function .keyword {
color: #E28964;
}
pre .function .keyword,
pre .sub .keyword,
pre .method,
pre .list .title {
color: #99CF50;
}
pre .string,
pre .tag .value,
pre .cdata,
pre .filter .argument,
pre .attr_selector,
pre .apache .cbracket,
pre .date,
pre .tex .command {
color: #65B042;
}
pre .subst {
color: #DAEFA3;
}
pre .regexp {
color: #E9C062;
}
pre .function .title,
pre .sub .identifier,
pre .pi,
pre .tag,
pre .tag .keyword,
pre .decorator,
pre .ini .title,
pre .shebang {
color: #89BDFF;
}
pre .class .title,
pre .smalltalk .class,
pre .javadoctag,
pre .yardoctag,
pre .phpdoc {
text-decoration: underline;
}
pre .symbol,
pre .ruby .symbol .string,
pre .ruby .symbol .keyword,
pre .ruby .symbol .keymethods,
pre .number {
color: #3387CC;
}
pre .params,
pre .variable {
color: #3E87E3;
}
pre .css .keyword,
pre .pseudo,
pre .tex .special {
color: #CDA869;
}
pre .css .class {
color: #9B703F;
}
pre .rules .keyword {
color: #C5AF75;
}
pre .rules .value {
color: #CF6A4C;
}
pre .css .id {
color: #8B98AB;
}
pre .annotation,
pre .apache .sqbracket,
pre .nginx .built_in {
color: #9B859D;
}
pre .preprocessor {
color: #8996A8;
}
pre .hexcolor,
pre .css .value .number {
color: #DD7B3B;
}
pre .css .function {
color: #DAD085;
}
pre .diff .header,
pre .chunk,
pre .tex .formula {
background-color: #0E2231;
color: #F8F8F8;
font-style: italic;
}
pre .diff .change {
background-color: #4A410D;
color: #F8F8F8;
}
pre .addition {
background-color: #253B22;
color: #F8F8F8;
}
pre .deletion {
background-color: #420E09;
color: #F8F8F8;
}

View File

@@ -0,0 +1,112 @@
/*
Zenburn style from voldmar.ru (c) Vladimir Epifanov <voldmar@voldmar.ru>
based on dark.css by Ivan Sagalaev
*/
pre code {
display: block; padding: 0.5em;
background: #3F3F3F;
color: #DCDCDC;
}
pre .keyword,
pre .tag,
pre .django .tag,
pre .django .keyword,
pre .css .class,
pre .css .id,
pre .lisp .title {
color: #E3CEAB;
}
pre .django .template_tag,
pre .django .variable,
pre .django .filter .argument {
color: #DCDCDC;
}
pre .number,
pre .date {
color: #8CD0D3;
}
pre .dos .envvar,
pre .dos .stream,
pre .variable,
pre .apache .sqbracket {
color: #EFDCBC;
}
pre .dos .flow,
pre .diff .change,
pre .python .exception,
pre .python .built_in,
pre .literal,
pre .tex .special {
color: #EFEFAF;
}
pre .diff .chunk,
pre .ruby .subst {
color: #8F8F8F;
}
pre .dos .keyword,
pre .python .decorator,
pre .class .title,
pre .function .title,
pre .ini .title,
pre .diff .header,
pre .ruby .class .parent,
pre .apache .tag,
pre .nginx .built_in,
pre .tex .command {
color: #efef8f;
}
pre .dos .winutils,
pre .ruby .symbol,
pre .ruby .symbol .string,
pre .ruby .symbol .keyword,
pre .ruby .symbol .keymethods,
pre .ruby .string,
pre .ruby .instancevar {
color: #DCA3A3;
}
pre .diff .deletion,
pre .string,
pre .tag .value,
pre .preprocessor,
pre .built_in,
pre .sql .aggregate,
pre .javadoc,
pre .smalltalk .class,
pre .smalltalk .localvars,
pre .smalltalk .array,
pre .css .rules .value,
pre .attr_selector,
pre .pseudo,
pre .apache .cbracket,
pre .tex .formula {
color: #CC9393;
}
pre .shebang,
pre .diff .addition,
pre .comment,
pre .java .annotation,
pre .template_comment,
pre .pi,
pre .doctype {
color: #7F9F7F;
}
pre .html .css,
pre .html .javascript,
pre .tex .formula {
opacity: 0.5;
}

View File

@@ -0,0 +1,90 @@
/*
Language: CSS
Requires: html-xml.js
*/
hljs.LANGUAGES.css = {
defaultMode: {
contains: ['at_rule', 'id', 'class', 'attr_selector', 'pseudo', 'rules', 'comment'],
keywords: hljs.HTML_TAGS,
lexems: [hljs.IDENT_RE],
illegal: '='
},
case_insensitive: true,
modes: [
{
className: 'at_rule',
begin: '@', end: '[{;]',
excludeEnd: true,
lexems: [hljs.IDENT_RE],
keywords: {'import': 1, 'page': 1, 'media': 1, 'charset': 1, 'font-face': 1},
contains: ['function', 'string', 'number', 'pseudo']
},
{
className: 'id',
begin: '\\#[A-Za-z0-9_-]+', end: hljs.IMMEDIATE_RE
},
{
className: 'class',
begin: '\\.[A-Za-z0-9_-]+', end: hljs.IMMEDIATE_RE,
relevance: 0
},
{
className: 'attr_selector',
begin: '\\[', end: '\\]',
illegal: '$'
},
{
className: 'pseudo',
begin: ':(:)?[a-zA-Z0-9\\_\\-\\+\\(\\)\\"\\\']+', end: hljs.IMMEDIATE_RE
},
{
className: 'rules',
begin: '{', end: '}',
contains: [
{
className: 'rule',
begin: '[A-Z\\_\\.\\-]+\\s*:', end: ';', endsWithParent: true,
lexems: ['[A-Za-z-]+'],
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},
contains: [
{
className: 'value',
begin: hljs.IMMEDIATE_RE, endsWithParent: true, excludeEnd: true,
contains: ['function', 'number', 'hexcolor', 'string', 'important', 'comment']
}
]
},
'comment'
],
illegal: '[^\\s]'
},
hljs.C_BLOCK_COMMENT_MODE,
{
className: 'number',
begin: hljs.NUMBER_RE, end: hljs.IMMEDIATE_RE
},
{
className: 'hexcolor',
begin: '\\#[0-9A-F]+', end: hljs.IMMEDIATE_RE
},
{
className: 'function',
begin: hljs.IDENT_RE + '\\(', end: '\\)',
contains: [
{
className: 'params',
begin: hljs.IMMEDIATE_RE, endsWithParent: true, excludeEnd: true,
contains: ['number', 'string']
}
]
},
{
className: 'important',
begin: '!important', end: hljs.IMMEDIATE_RE
},
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
hljs.BACKSLASH_ESCAPE
]
};

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,164 @@
/*
Language: HTML, XML
*/
(function(){
var XML_IDENT_RE = '[A-Za-z0-9\\._:-]+';
var PI = {
className: 'pi',
begin: '<\\?', end: '\\?>',
relevance: 10
};
var DOCTYPE = {
className: 'doctype',
begin: '<!DOCTYPE', end: '>',
relevance: 10
};
var COMMENT = {
className: 'comment',
begin: '<!--', end: '-->'
};
var TAG = {
className: 'tag',
begin: '</?', end: '/?>',
contains: ['title', 'tag_internal']
};
var TITLE = {
className: 'title',
begin: XML_IDENT_RE, end: hljs.IMMEDIATE_RE
};
var TAG_INTERNAL = {
className: 'tag_internal',
begin: hljs.IMMEDIATE_RE, endsWithParent: true, noMarkup: true,
contains: ['attribute', 'value_container'],
relevance: 0
};
var ATTR = {
className: 'attribute',
begin: XML_IDENT_RE, end: hljs.IMMEDIATE_RE,
relevance: 0
};
var VALUE_CONTAINER_QUOT = {
className: 'value_container',
begin: '="', returnBegin: true, end: '"', noMarkup: true,
contains: [{
className: 'value',
begin: '"', endsWithParent: true
}]
};
var VALUE_CONTAINER_APOS = {
className: 'value_container',
begin: '=\'', returnBegin: true, end: '\'', noMarkup: true,
contains: [{
className: 'value',
begin: '\'', endsWithParent: true
}]
};
hljs.LANGUAGES.xml = {
defaultMode: {
contains: ['pi', 'doctype', 'comment', 'cdata', 'tag']
},
case_insensitive: true,
modes: [
{
className: 'cdata',
begin: '<\\!\\[CDATA\\[', end: '\\]\\]>',
relevance: 10
},
PI,
DOCTYPE,
COMMENT,
TAG,
hljs.inherit(TITLE, {relevance: 1.75}),
TAG_INTERNAL,
ATTR,
VALUE_CONTAINER_QUOT,
VALUE_CONTAINER_APOS
]
};
var HTML_TAGS = {
'code': 1, 'kbd': 1, 'font': 1, 'noscript': 1, 'style': 1, 'img': 1,
'title': 1, 'menu': 1, 'tt': 1, 'tr': 1, 'param': 1, 'li': 1, 'tfoot': 1,
'th': 1, 'input': 1, 'td': 1, 'dl': 1, 'blockquote': 1, 'fieldset': 1,
'big': 1, 'dd': 1, 'abbr': 1, 'optgroup': 1, 'dt': 1, 'button': 1,
'isindex': 1, 'p': 1, 'small': 1, 'div': 1, 'dir': 1, 'em': 1, 'frame': 1,
'meta': 1, 'sub': 1, 'bdo': 1, 'label': 1, 'acronym': 1, 'sup': 1, 'body': 1,
'basefont': 1, 'base': 1, 'br': 1, 'address': 1, 'strong': 1, 'legend': 1,
'ol': 1, 'script': 1, 'caption': 1, 's': 1, 'col': 1, 'h2': 1, 'h3': 1,
'h1': 1, 'h6': 1, 'h4': 1, 'h5': 1, 'table': 1, 'select': 1, 'noframes': 1,
'span': 1, 'area': 1, 'dfn': 1, 'strike': 1, 'cite': 1, 'thead': 1,
'head': 1, 'option': 1, 'form': 1, 'hr': 1, 'var': 1, 'link': 1, 'b': 1,
'colgroup': 1, 'ul': 1, 'applet': 1, 'del': 1, 'iframe': 1, 'pre': 1,
'frameset': 1, 'ins': 1, 'tbody': 1, 'html': 1, 'samp': 1, 'map': 1,
'object': 1, 'a': 1, 'xmlns': 1, 'center': 1, 'textarea': 1, 'i': 1, 'q': 1,
'u': 1, 'section': 1, 'nav': 1, 'article': 1, 'aside': 1, 'hgroup': 1,
'header': 1, 'footer': 1, 'figure': 1, 'figurecaption': 1, 'time': 1,
'mark': 1, 'wbr': 1, 'embed': 1, 'video': 1, 'audio': 1, 'source': 1,
'canvas': 1, 'datalist': 1, 'keygen': 1, 'output': 1, 'progress': 1,
'meter': 1, 'details': 1, 'summary': 1, 'command': 1
};
hljs.LANGUAGES.html = {
defaultMode: {
contains: ['comment', 'pi', 'doctype', 'vbscript', 'tag']
},
case_insensitive: true,
modes: [
{
className: 'tag',
begin: '<style', end: '>',
lexems: [hljs.IDENT_RE], keywords: {'style': 1},
contains: ['tag_internal'],
starts: 'css'
},
{
className: 'tag',
begin: '<script', end: '>',
lexems: [hljs.IDENT_RE], keywords: {'script': 1},
contains: ['tag_internal'],
starts: 'javascript'
},
{
className: 'css',
end: '</style>', returnEnd: true,
subLanguage: 'css'
},
{
className: 'javascript',
end: '</script>', returnEnd: true,
subLanguage: 'javascript'
},
{
className: 'vbscript',
begin: '<%', end: '%>',
subLanguage: 'vbscript'
},
COMMENT,
PI,
DOCTYPE,
hljs.inherit(TAG),
hljs.inherit(TITLE, {
lexems: [hljs.IDENT_RE], keywords: HTML_TAGS
}),
hljs.inherit(TAG_INTERNAL),
ATTR,
VALUE_CONTAINER_QUOT,
VALUE_CONTAINER_APOS,
{
className: 'value_container',
begin: '=', end: hljs.IMMEDIATE_RE,
contains: [
{
className: 'unquoted_value', displayClassName: 'value',
begin: '[^\\s/>]+', end: hljs.IMMEDIATE_RE
}
]
}
]
};
})();

View File

@@ -0,0 +1,53 @@
/*
Language: Javascript
*/
hljs.LANGUAGES.javascript = {
defaultMode: {
lexems: [hljs.UNDERSCORE_IDENT_RE],
contains: ['string', 'comment', 'number', 'regexp_container', 'function'],
keywords: {
'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},
'literal': {'true': 1, 'false': 1, 'null': 1}
}
},
modes: [
hljs.C_LINE_COMMENT_MODE,
hljs.C_BLOCK_COMMENT_MODE,
hljs.C_NUMBER_MODE,
hljs.APOS_STRING_MODE,
hljs.QUOTE_STRING_MODE,
hljs.BACKSLASH_ESCAPE,
{
className: 'regexp_container',
begin: '(' + hljs.RE_STARTERS_RE + '|case|return|throw)\\s*', end: hljs.IMMEDIATE_RE, noMarkup: true,
lexems: [hljs.IDENT_RE],
keywords: {'return': 1, 'throw': 1, 'case': 1},
contains: [
'comment',
{
className: 'regexp',
begin: '/.*?[^\\\\/]/[gim]*', end: hljs.IMMEDIATE_RE
}
],
relevance: 0
},
{
className: 'function',
begin: '\\bfunction\\b', end: '{',
lexems: [hljs.UNDERSCORE_IDENT_RE],
keywords: {'function': 1},
contains: [
{
className: 'title',
begin: '[A-Za-z$_][0-9A-Za-z$_]*', end: hljs.IMMEDIATE_RE
},
{
className: 'params',
begin: '\\(', end: '\\)',
contains: ['string', 'comment']
}
]
}
]
};

View File

@@ -0,0 +1,68 @@
/*
Language: PHP
Author: Victor Karamzin <Victor.Karamzin@enterra-inc.com>
*/
hljs.LANGUAGES.php = {
defaultMode: {
lexems: [hljs.IDENT_RE],
contains: ['comment', 'number', 'string', 'variable', 'preprocessor'],
keywords: {
'and': 1, 'include_once': 1, 'list': 1, 'abstract': 1, 'global': 1,
'private': 1, 'echo': 1, 'interface': 1, 'as': 1, 'static': 1,
'endswitch': 1, 'array': 1, 'null': 1, 'if': 1, 'endwhile': 1, 'or': 1,
'const': 1, 'for': 1, 'endforeach': 1, 'self': 1, 'var': 1, 'while': 1,
'isset': 1, 'public': 1, 'protected': 1, 'exit': 1, 'foreach': 1,
'throw': 1, 'elseif': 1, 'extends': 1, 'include': 1, '__FILE__': 1,
'empty': 1, 'require_once': 1, 'function': 1, 'do': 1, 'xor': 1,
'return': 1, 'implements': 1, 'parent': 1, 'clone': 1, 'use': 1,
'__CLASS__': 1, '__LINE__': 1, 'else': 1, 'break': 1, 'print': 1,
'eval': 1, 'new': 1, 'catch': 1, '__METHOD__': 1, 'class': 1, 'case': 1,
'exception': 1, 'php_user_filter': 1, 'default': 1, 'die': 1,
'require': 1, '__FUNCTION__': 1, 'enddeclare': 1, 'final': 1, 'try': 1,
'this': 1, 'switch': 1, 'continue': 1, 'endfor': 1, 'endif': 1,
'declare': 1, 'unset': 1, 'true': 1, 'false': 1, 'namespace': 1
}
},
case_insensitive: true,
modes: [
hljs.C_LINE_COMMENT_MODE,
hljs.HASH_COMMENT_MODE,
{
className: 'comment',
begin: '/\\*', end: '\\*/',
contains: [{
className: 'phpdoc',
begin: '\\s@[A-Za-z]+', end: hljs.IMMEDIATE_RE,
relevance: 10
}]
},
hljs.C_NUMBER_MODE,
{
className: 'string',
begin: '\'', end: '\'',
contains: ['escape'],
relevance: 0
},
{
className: 'string',
begin: '"', end: '"',
contains: ['escape'],
relevance: 0
},
hljs.BACKSLASH_ESCAPE,
{
className: 'variable',
begin: '\\$[a-zA-Z_\x7f-\xff][a-zA-Z0-9_\x7f-\xff]*', end: hljs.IMMEDIATE_RE
},
{
className: 'preprocessor',
begin: '<\\?php', end: hljs.IMMEDIATE_RE,
relevance: 10
},
{
className: 'preprocessor',
begin: '\\?>', end: hljs.IMMEDIATE_RE
}
]
};

View File

@@ -0,0 +1,508 @@
# Highlight.js
Highlight.js highlights syntax in code examples on blogs, forums and
in fact on any web pages. It's very easy to use because it works
automatically: finds blocks of code, detects a language, highlights it.
Autodetection can be fine tuned when it fails by itself (see "Heuristics").
## Installation and usage
Downloaded package includes file "highlight.pack.js" which is a full compressed
version of the library intended to use in production. All uncompressed source
files are also available, feel free to look into them!
The script is installed by linking to a single file and making a single
initialization call:
<script type="text/javascript" src="highlight.pack.js"></script>
<script type="text/javascript">
hljs.initHighlightingOnLoad();
</script>
Also you can replaces TAB ('\x09') characters used for indentation in your code
with some fixed number of spaces or with a `<span>` to set them special styling:
<script type="text/javascript">
hljs.tabReplace = ' '; // 4 spaces
// ... or
hljs.tabReplace = '<span class="indent">\t</span>';
hljs.initHighlightingOnLoad();
</script>
Then the script looks in your page for fragments `<pre><code>...</code></pre>`
that are used traditionally to mark up code examples. Their content is
marked up by logical pieces with defined class names.
### Custom initialization
If you use different markup for code blocks you can initialize them manually
with `highlightBlock(code, tabReplace)` function. It takes a DOM element
containing the code to highlight and optionally a string with which to replace
TAB characters.
Initialization using for example jQuery might look like this:
$(document).ready(function() {
$('pre code').each(function(i, e) {hljs.highlightBlock(e, ' ')});
});
If your code container relies on `<br>` tags instead of line breaks (i.e. if
it's not `<pre>`) pass `true` into third parameter of `highlightBlock`:
$('div.code').each(function(i, e) {hljs.highlightBlock(e, null, true)});
### Styling
Elements of code marked up with classes can be styled as desired:
.comment {
color: gray;
}
.keyword {
font-weight: bold;
}
.python .string {
color: blue;
}
.html .atribute .value {
color: green;
}
Highligt.js comes with several style themes located in "styles" directory that
can be used directly or as a base for your own experiments.
A full list of available classes is below ("Languages").
## Export
File export.html contains a little program that shows and allows to copy and paste
an HTML code generated by the highlighter for any code snippet. This can be useful
in situations when one can't use the script itself on a site.
## Languages
This is a full list of available classes corresponding to languages'
syntactic structures. In parentheses after language names are identifiers
used as class names in `<code>` element.
Python ("python"):
keyword keyword
built_in built-in objects (None, False, True and Ellipsis)
number number
string string (of any type)
comment comment
decorator @-decorator for functions
function function header "def some_name(...):"
class class header "class SomeName(...):"
title name of a function or a class inside a header
params everything inside parentheses in a function's or class' header
Python profiler results ("profile"):
number number
string string
builtin builtin function entry
filename filename in an entry
summary profiling summary
header header of table of results
keyword column header
function function name in an entry (including parentheses)
title actual name of a function in an entry (excluding parentheses)
Ruby ("ruby"):
keyword keyword
string string
subst in-string substitution (#{...})
comment comment
yardoctag YARD tag
function function header "def some_name(...):"
class class header "class SomeName(...):"
title name of a function or a class inside a header
parent name of a parent class
symbol symbol
instancevar instance variable
Perl ("perl"):
keyword keyword
comment comment
number number
string string
regexp regular expression
sub subroutine header (from "sub" till "{")
variable variable starting with "$", "%", "@"
operator operator
pod plain old doc
PHP ("php"):
keyword keyword
number number
string string (of any type)
comment comment
phpdoc phpdoc params in comments
variable variable starting with "$"
preprocessor preprocessor marks: "<?php" and "?>"
Scala ("scala"):
keyword keyword
number number
string string
comment comment
annotaion annotation
javadoc javadoc comment
javadoctag @-tag in javadoc
class class header
title class name inside a header
params everything in parentheses inside a class header
inheritance keywords "extends" and "with" inside class header
XML ("xml"):
tag any tag from "<" till ">"
comment comment
pi processing instruction (<? ... ?>)
cdata CDATA section
attribute attribute
value attribute's value
HTML ("html"):
keyword HTML tag
tag any tag from "<" till ">"
comment comment
doctype <!DOCTYPE ... > declaration
attribute tag's attribute with or without value
value attribute's value
CSS ("css"):
keyword HTML tag when in selectors, CSS keyword when in rules
id #some_name in selectors
class .some_name in selectors
at_rule @-rule till first "{" or ";"
attr_selector attribute selector (square brackets in a[href^=http://])
pseudo pseudo classes and elemens (:after, ::after etc.)
comment comment
rules everything from "{" till "}"
value property's value inside a rule, from ":" till ";" or
till the end of rule block
number number within a value
string string within a value
hexcolor hex color (#FFFFFF) within a value
function CSS function within a value
params everything between "(" and ")" within a function
important "!important" symbol
Django ("django"):
keyword HTML tag in HTML, default tags and default filters in templates
tag any tag from "<" till ">"
comment comment
doctype <!DOCTYPE ... > declaration
attribute tag's attribute with or withou value
value attribute's value
template_tag template tag {% .. %}
variable template variable {{ .. }}
template_comment template comment, both {# .. #} and {% comment %}
filter filter from "|" till the next filter or the end of tag
argument filter argument
Javascript ("javascript"):
keyword keyword
comment comment
number number
literal special literal: "true", "false" and "null"
string string
regexp regular expression
function header of a function
title name of a function inside a header
params everything inside parentheses in a function's header
VBScript ("vbscript"):
keyword keyword
number number
string string
comment comment
built_in built-in function
Lua ("lua"):
keyword keyword
number number
string string
comment comment
built_in built-in operator
function header of a function
title name of a function inside a header
params everything inside parentheses in a function's header
long_brackets multiline string in [=[ .. ]=]
Delphi ("delphi"):
keyword keyword
comment comment (of any type)
number number
string string
function header of a function, procedure, constructor and destructor
title name of a function, procedure, constructor or destructor
inside a header
params everything inside parentheses in a function's header
class class' body from "= class" till "end;"
Java ("java"):
keyword keyword
number number
string string
comment commment
annotaion annotation
javadoc javadoc comment
class class header from "class" till "{"
title class name inside a header
params everything in parentheses inside a class header
inheritance keywords "extends" and "implements" inside class header
C++ ("cpp"):
keyword keyword
number number
string string and character
comment comment
preprocessor preprocessor directive
stl_container instantiation of STL containers ("vector<...>")
C# ("cs"):
keyword keyword
number number
string string
comment commment
xmlDocTag xmldoc tag ("///", "<!--", "-->", "<..>")
RenderMan RSL ("rsl"):
keyword keyword
number number
string string (including @"..")
comment comment
preprocessor preprocessor directive
shader sahder keywords
shading shading keywords
built_in built-in function
RenderMan RIB ("rib"):
keyword keyword
number number
string string
comment comment
commands command
Maya Embedded Language ("mel"):
keyword keyword
number number
string string
comment comment
variable variable
SQL ("sql"):
keyword keyword (mostly SQL'92 and SQL'99)
number number
string string (of any type: "..", '..', `..`)
comment comment
aggregate aggregate function
Smalltalk ("smalltalk"):
keyword keyword
number number
string string
comment commment
symbol symbol
array array
class name of a class
char char
localvars block of local variables
Lisp ("lisp"):
keyword keyword
number number
string string
comment commment
variable variable
literal b, t and nil
list non-quoted list
title first symbol in a non-quoted list
body remainder of the non-quoted list
quoted_list quoted list, both "(quote .. )" and "'(..)"
Ini ("ini"):
title title of a section
value value of a setting of any type
string string
number number
keyword boolean value keyword
Apache ("apache"):
keyword keyword
number number
comment commment
literal On and Off
sqbracket variables in rewrites "%{..}"
cbracket options in rewrites "[..]"
tag begin and end of a configuration section
Nginx ("nginx"):
keyword keyword
string string
number number
comment comment
built_in built-in constant
variable $-variable
Diff ("diff"):
header file header
chunk chunk header within a file
addition added lines
deletion deleted lines
change changed lines
DOS ("dos"):
keyword keyword
flow batch control keyword
stream DOS special files ("con", "prn", ...)
winutils some commands (see dos.js specifically)
envvar environment variables
Bash ("bash"):
keyword keyword
string string
number number
comment comment
literal special literal: "true" и "false"
variable variable
shebang script interpreter header
CMake ("cmake")
keyword keyword
number number
string string
comment commment
envvar $-variable
Axapta ("axapta"):
keyword keyword
number number
string string
comment commment
class class header from "class" till "{"
title class name inside a header
params everything in parentheses inside a class header
inheritance keywords "extends" and "implements" inside class header
preprocessor preprocessor directive
1C ("1c"):
keyword keyword
number number
date date
string string
comment commment
function header of function or procudure
title function name inside a header
params everything in parentheses inside a function header
preprocessor preprocessor directive
AVR assembler ("avrasm"):
keyword keyword
built_in pre-defined register
number number
string string
comment commment
label label
preprocessor preprocessor directive
localvars substitution in .macro
VHDL ("vhdl")
keyword keyword
number number
string string
comment commment
literal signal logical value
Parser3 ("parser3"):
keyword keyword
number number
comment commment
variable variable starting with "$"
preprocessor preprocessor directive
title user-defined name starting with "@"
TeX ("tex"):
comment comment
number number
command command
parameter parameter
formula formula
special special symbol
## Heuristics
Autodetection of a code's language is done with a simple heuristics:
the program tries to highlight a fragment with all available languages and
counts all syntactic structures that it finds along the way. The language
with greatest count wins.
This means that in short fragments the probability of an error is high
(and it really happens sometimes). In this cases you can set the fragment's
language explicitly by assigning a class to the `<code>` element:
<pre><code class="html">...</code></pre>
You can use class names recommended in HTML5: "language-html",
"language-php". Classes also can be assigned to the `<pre>` element.
To disable highlighting of a fragment altogether use "no-highlight" class:
<pre><code class="no-highlight">...</code></pre>
## Contacts
Version: 5.16
URL: http://softwaremaniacs.org/soft/highlight/en/
Author: Ivan Sagalaev (Maniac@SoftwareManiacs.Org)
For the license terms see LICENSE files.
For the list of contributors see AUTHORS.en.txt file.

View File

@@ -0,0 +1,102 @@
/* = FONT STACKS
----------------------------------------------------------------------------------------------------------------------*/
body { font-family: Geneva, 'Lucida Sans', 'Lucida Grande', 'Lucida Sans Unicode', Verdana, sans-serif } /* "wide" sans serif */
/*body { font-family: Tahoma, Arial, Helvetica, sans-serif } /* "narrow" sans serif */
/*body { font-family: Georgia, Utopia, Palatino, 'Palatino Linotype', serif } /* "wide" serif */
/*body { font-family: 'Times New Roman', Times, serif } /* "narrow" serif */
/* transform the font size so that 1em is 10px so that you can use em's
but think in pixels as now 1em is 10px, 1.2em is 12px and so on */
html { font-size: 62.5% }
body {
font-size: 1.3em;
margin: 0;
padding: 0;
outline: 0;
border: 0;
text-align: center; /* this is for IE6 so that it will center the main wrapper */
line-height: 1.2; /* unit-less line-height does not inherit a percentage value of its parent element */
/* but instead is based on a multiplier of the font-size */
}
div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, aabbr, acronym, address,
big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i,
center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td {
margin: 0;
padding: 0;
outline: 0;
border: 0;
font-family: inherit;
font-weight: inherit;
font-style: inherit;
line-height: inherit;
}
a, blockquote, dd, div, dl, dt, fieldset, form, h1, h2, h3, h4, h5, h6, img, input, label, li, ol, p, pre, span, table, ul {
position: relative
}
h1, h2, h3, h4, h5, h6 { font-weight: normal; line-height: 1 }
p { font-size: 100% }
h1 { font-size: 220% }
h2 { font-size: 200% }
h3 { font-size: 180% }
h4 { font-size: 160% }
h5 { font-size: 140% }
h6 { font-size: 120% }
small,
sup,
sub { font-size: 70% }
p small { display: block; line-height: 1 }
strong, b { font-weight: bold }
em, i { font-style: italic }
/* = CLEARFIX
----------------------------------------------------------------------------------------------------------------------*/
.clearfix:before,
.clearfix:after { content: "\0020"; display: block; height: 0; visibility: hidden; font-size: 0 }
.clearfix:after { clear: both }
.clearfix { *zoom: 1 } /* for IE only */
/* = TABLES
----------------------------------------------------------------------------------------------------------------------*/
table {
border-collapse: collapse;
border-spacing: 0;
/* tables still need cellspacing="0" */
}
/* = LISTS
----------------------------------------------------------------------------------------------------------------------*/
ul, ol { list-style: none }
ul.float li,
ol.float li { float: left }
ul.default,
ol.default,
ol.default ul,
ul.default ul,
ul.default ol,
ol.default ol { padding-left: 1.5em }
ul.default,
ol.default ul,
ul.default ul { list-style-type: square }
ol.default,
ul.default ol,
ol.default ol { list-style-type: decimal }

View File

@@ -0,0 +1,62 @@
body { text-align: left; margin: 20px }
.header { background: #888; padding: 10px 5px; font-weight: bold }
.header a { color: #FFF; text-decoration: none }
.header span { font-weight: normal }
.example { background: #ABCDEF; padding: 10px 5px; font-weight: bold; margin: 0 0 20px }
.example a { color: #123456; font-weight: normal }
h1 { margin-bottom: 1em }
h1 span { display: block; font-size: 11px; color: #666 }
.navigation { border-right: 1px solid #DEDEDE; padding-right: 20px; margin-right: 20px }
.navigation li { font-weight: bold; margin: 0 }
.navigation li ul { color: #AAA; margin: 10px 0 }
.navigation a { color: #000066; white-space: nowrap; font-weight: normal; text-decoration: none; display: block; padding: 2px }
.navigation a.selected { color: #DDD; background: #222 }
.tabs { }
.tabs a { display: block; background: #000; color: #FFF; padding: 4px 10px; text-decoration: none; margin-right: 1px; font-weight: bold }
.tabs a:hover,
.tabs a.selected { background: #DEDEDE; color: #222 }
.tab { border: 1px solid #DEDEDE; padding: 20px; display: none }
.tab h2 { font-weight: bold; margin: 0 0 20px }
.tab p { color: #999; margin: 0 0 20px; font-size: 12px }
ul.notes { color: #999; font-size: 11px; margin: 20px 0 0 }
table.results { border-collapse: collapse }
table.results th,
table.results td { padding: 5px; border: 1px solid #DEDEDE }
table.results th { font-weight: bold }
table.results thead td { background: #666; color: #FFF; font-weight: bold }
img.Zebra_Form_Input_Prefix { width: 16px; height: 16px }
.tab a { color: #0000FF; text-decoration: none }
/* = MISCELLANEOUS
----------------------------------------------------------------------------------------------------------------------*/
.align-center { text-align: center }
.align-left { text-align: left }
.align-right { text-align: right }
.block { display: block }
.bottom { margin-bottom: 0; padding-bottom: 0 }
.center { text-align: center }
.clear { clear: both }
.first { margin-left: 0; padding-left: 0 }
.hidden { visibility: hidden }
.highlight { background: #ccf }
.inline { display: inline }
.last { margin-right: 0; padding-right: 0 }
.left { float: left }
.none { display: none }
.nowrap { white-space: nowrap }
.right { float: right }
.stretch { width: 100% }
.top { margin-top: 0; padding-top: 0 }
.visible { visibility: visible }
img.Zebra_Form_prefix { width: 16px; height: 16px }

Binary file not shown.

After

Width:  |  Height:  |  Size: 469 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 416 B

View File

@@ -0,0 +1,25 @@
$(document).ready(function() {
hljs.initHighlightingOnLoad();
$('a').bind('click', function() { this.blur() });
var tab_selectors = $('.tabs a');
var tabs = $('.tab');
tab_selectors.each(function(index, selector) {
$(selector).bind('click', function(e) {
e.preventDefault();
tab_selectors.removeClass('selected');
$(this).addClass('selected');
tabs.css('display', 'none');
$(tabs[index]).css({
'opacity': 0,
'display': 'block'
});
$(tabs[index]).animate({'opacity': 1}, 250);
});
});
});

File diff suppressed because one or more lines are too long