PHP Classes

File: example1_calendar.php

Recommend this page to a friend!
  Classes of Dmitry Levashov   WebWidgets   example1_calendar.php   Download  
File: example1_calendar.php
Role: Example script
Content type: text/plain
Description: Example
Class: WebWidgets
Classes for create forms and HTML documents
Author: By
Last change:
Date: 22 years ago
Size: 1,391 bytes
 

Contents

Class file image Download
<?php
/**
 * Simple example how WebWidgets can be used
 */
$start = utime();
include
'./Base.lib.php';

$Html = new Bin('html');
$Head = new Bin('head');
$Title = new Bin('title');
$Title->add(new CData('Simple calendar on '.date('F')));
$Head->add($Title);
$Html->add($Head);

$Body = new Bin('body');
$Body->setAttr('bgcolor', '#f1edc7');

$Table = new Table(7);
$Table->setAttr(array('border'=>1, 'cellpadding'=>2, 'cellspacing'=>1));

$Table->add(new CData(date('d F Y')), '', '', array('colspan'=>7), 'th');

$week_days = array(1=>'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun');

$Table->setCellAttr('bgcolor', 'yellow');

for (
$i=1; $i<=sizeof($week_days); $i++) {
   
$Table->add(new CData($week_days[$i]));
}

$Table->setCellAttr('bgcolor', '#dee3e7');

list(
$num_days, $month, $year) = explode('-', date('t-m-Y'));
$first_wd = strftime('%u', mktime(0,0,0, $month,1,$year));

if (
$first_wd > 1)
   
$Table->add(new CData('&nbsp;'), '','', array('bgcolor'=>'#dee3e7', 'colspan'=>$first_wd-1));

for (
$i=1; $i<=$num_days; $i++) {
   
$Table->add(new CData($i));
}

$Body->add($Table);
$Html->add($Body);
$Html->view();


echo
"<br>Page create in: ".(utime()-$start)." sec.<br>";

function
utime ()
{
   
$time = explode( " ", microtime());
   
$usec = (double)$time[0];
   
$sec = (double)$time[1];
    return
$sec + $usec;
}


?>