#!/usr/bin/env php
<?php 
error_reporting(E_ALL);
require_once '../KvzHTML.php';
// These are the default options, so might
// as well have initialized KvzHTML with an
// empty first argument
$H = new KvzHTML(array('xhtml' => true, 'track_toc' => false, 'link_toc' => true, 'indentation' => 4, 'newlines' => true, 'echo' => false, 'buffer' => false, 'xml' => false, 'tidy' => false));
echo $H->html($H->head($H->title('My page')) . $H->body($H->h1('Important website') . $H->p('Welcome to our website.') . $H->h2('Users') . $H->p('Here\'s a list of current users:') . $H->table($H->tr($H->th('id') . $H->th('name') . $H->th('age')) . $H->tr($H->td('#1') . $H->td('Kevin van Zonneveld') . $H->td('26')) . $H->tr($H->td('#2') . $H->td('Foo Bar') . $H->td('28')))));
Example #2
0
<?php

error_reporting(E_ALL);
if (!defined('DIR_KVZLIB')) {
    define('DIR_KVZLIB', dirname(dirname(dirname(dirname(dirname(__FILE__))))));
}
?>
// Sample starts here
<?php 
require_once DIR_KVZLIB . '/php/classes/KvzHTML.php';
// I find it easy to work with 2 instances.
//     One that will echo directly: $E
// and One that supports nesting: $H
$H = new KvzHTML();
$E = new KvzHTML(array('echo' => true, 'buffer' => true, 'tidy' => true));
// To save you even more typing. The following tags
// have an inconsistent interface:
// a, img, css, js
$E->html();
$E->head($H->title('Report') . $H->style('
            div.page {
                font-family: helvetica;
                font-size: 12px;
                page-break-after: always;
                min-height: 1220px;
                width: 830px;
            }
        ') . $H->css('/css/style.js') . $H->js('/js/jquery.js'));
// Page 1
$E->page(true, array('style' => array('page-break-before' => 'always')));
$E->h1('Report') . $E->p($H->a('http://true.nl', 'Visit our homepage') . $H->img('http://true.truestatic.nl/pivotx/templates/true/img/logo.gif'));
Example #3
0
 public function generate()
 {
     switch ($this->_type) {
         case 'html':
             $Html = new KvzHTML();
             $photovirt = $this->getOption('photovirt');
             $head = $Html->title('Movies') . $Html->css('moviexplore.css') . $Html->js('http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js') . $Html->js('moviexplore.js');
             $body = '';
             $index = '';
             $prevdirname = '';
             $dircontent = '';
             ksort($this->_movies);
             foreach ($this->_movies as $file => $movie) {
                 if (empty($movie)) {
                     echo 'Skipping ' . $file . '. Invalid movie information' . "\n";
                     continue;
                 }
                 if ($separate_on_dir = $this->getOption('separate_on_dir')) {
                     $parts = explode(DIRECTORY_SEPARATOR, $file);
                     $dirname = $parts[$separate_on_dir - 1];
                 }
                 $imgFile = Movie::imageFromFile($file, $photovirt);
                 if (!file_exists(realpath($this->getOption('outputdir') . '/' . $imgFile))) {
                     $imgFile = 'title_noposter.gif';
                 }
                 if (!is_array($movie['cast'])) {
                     $movie['cast'] = array();
                 }
                 if (!is_array($movie['genres'])) {
                     $movie['genres'] = array();
                 }
                 // 4 --- 9
                 //	 7
                 // 1 --- 6 -3
                 //
                 $rateColor = statusColor(6 - ($movie['rating'] - 3.5) . '/6');
                 $movie['cast'] = array_slice($movie['cast'], 0, 3);
                 $castar = array();
                 foreach ($movie['cast'] as $actor) {
                     $castar[] = $Html->span($actor['name'], array('class' => 'actor'));
                 }
                 foreach ($movie['director'] as $director) {
                     $castar[] = $Html->span($director['name'], array('class' => 'director'));
                 }
                 foreach ($movie['writing'] as $writter) {
                     $castar[] = $Html->span($writter['name'], array('class' => 'writer'));
                 }
                 $cast = implode(', ', $castar);
                 if ($separate_on_dir) {
                     if ($prevdirname != $dirname) {
                         $index .= $Html->div(ucwords($dirname), array('class' => 'directory'));
                         $index .= $Html->hr(null);
                     }
                 }
                 $movie['tagline'] = strip_tags($movie['tagline']);
                 $movie['plotoutline'] = strip_tags($movie['plotoutline']);
                 $index .= $Html->div($Html->div($Html->a($movie['main_url'], $Html->img($imgFile, array('class' => 'poster'))) . $Html->p($movie['rating'], array('class' => 'rating', 'style' => '"color:' . $rateColor . ';"')) . $Html->p($movie['runtime'] ? $movie['runtime'] . 'm' : '', 'runtime'), array('class' => 'left')) . $Html->div($Html->h1($movie['title'], array('class' => 'title')) . $Html->h2($movie['tagline'], array('class' => 'tagline')) . $Html->p($movie['plotoutline'], array('class' => 'plotoutline')) . $Html->p(implode(', ', $movie['genres']), array('class' => 'genres')) . $Html->p($cast, array('class' => 'cast')), array('class' => 'right')) . $Html->div('', array('class' => 'end')), array('class' => 'movie'));
                 if ($separate_on_dir) {
                     $prevdirname = $dirname;
                 }
             }
             $body .= $Html->div($index, array('class' => 'index'));
             $this->_output = $Html->html($Html->head($head) . $Html->body($body));
             break;
     }
 }
<?php

error_reporting(E_ALL);
if (!defined('DIR_KVZLIB')) {
    define('DIR_KVZLIB', dirname(dirname(dirname(dirname(dirname(__FILE__))))));
}
?>
// LANG::xml
// Sample starts here
<?php 
require_once DIR_KVZLIB . '/php/classes/KvzHTML.php';
$H = new KvzHTML(array('xml' => true));
echo $H->xml($H->auth($H->username('kvz') . $H->api_key(sha1('xxxxxxxxxxxxxxxx'))) . $H->server_reboot($H->dry_run(null) . $H->hostname('www1.example.com') . $H->server_id(888)));
Example #5
0
error_reporting(E_ALL);
if (!defined('DIR_KVZLIB')) {
    define('DIR_KVZLIB', dirname(dirname(dirname(dirname(dirname(__FILE__))))));
}
?>
// Sample starts here
<?php 
require_once DIR_KVZLIB . '/php/classes/KvzHTML.php';
// Some options:
// - create a ToC
// - don't automatically create links for ToC navigation
// - echo output, don't return
// - save all echoed output in a buffer
// - Don't automatically Tidy the output (btw, only works with buffer on)
$E = new KvzHTML(array('track_toc' => true, 'link_toc' => false, 'echo' => true, 'buffer' => true, 'tidy' => false));
$E->h1('New application');
$E->p($E->loremIpsum);
$E->h2('Users');
$E->blockquote($E->loremIpsum);
$E->h3('Permissions');
$E->p($E->loremIpsum);
$E->h4('General Concept');
$E->p($E->loremIpsum);
$E->h4('Exceptions');
$E->p($E->loremIpsum);
$E->h3('Usability');
$E->ul();
// An empty body will just open the tag: <ul>
$E->li('Point 1');
$E->li('Point 2');
Example #6
0
<?php

error_reporting(E_ALL);
if (!defined('DIR_KVZLIB')) {
    define('DIR_KVZLIB', dirname(dirname(dirname(dirname(dirname(__FILE__))))));
}
?>
// Sample starts here
<?php 
require_once DIR_KVZLIB . '/php/classes/KvzHTML.php';
$E = new KvzHTML(array('echo' => true));
$E->p();
$E->span('You dont need to nest tags if you dont want to.');
$E->br(null);
$E->span('KvzHTML is flexible.');
$E->p(false);
$E->ul();
$E->li('Leaving a tag empty will just result in an open tag in HTML');
$E->li('Close tags with FALSE');
$E->li('For selfclosing tags like BR, use NULL');
$E->ul(false);
Example #7
0
<?php

error_reporting(E_ALL);
if (!defined('DIR_KVZLIB')) {
    define('DIR_KVZLIB', dirname(dirname(dirname(dirname(dirname(__FILE__))))));
}
?>
// LANG::xml
// Sample starts here
<?php 
require_once DIR_KVZLIB . '/php/classes/KvzHTML.php';
$H = new KvzHTML(array('xml' => true));
$cdataOpts = array('__cdata' => true);
$H->setOption('echo', true);
$H->xml(true, array('version' => '2.0', 'encoding' => 'UTF-16'));
$H->setOption('echo', false);
echo $H->auth($H->username('kvz', $cdataOpts) . $H->api_key(sha1('xxxxxxxxxxxxxxxx'), $cdataOpts));
echo $H->users_list(true);
echo $H->users(true, array('type' => 'array'));
echo $H->user($H->id(442, $cdataOpts) . $H->name('Jason Shellen', $cdataOpts) . $H->screen_name('shellen', $cdataOpts) . $H->location('iPhone: 37.889321,-122.173345', $cdataOpts) . $H->description('CEO and founder of Thing Labs, makers of Brizzly! Former Blogger/Google dude, father of two little dudes.', $cdataOpts));
echo $H->users(false);
echo $H->users_list(false);