<?php
// NoteTaker
// Created and Coded by Bo Ahlberg
// Copyright 2008 by Bo Ahlberg ( bahlberg at mac.com )
// This code is licensed "AS-IS", No warranty is expressed or implied as to the
// suitability of this software for any purpose. Further, this code is licensed
// under the:
// Creative Commons Attribution-Share Alike 3.0 United States License
// This means you are free to:
// to Share - to copy, distribute, display, and perorm work
// to remix - to make derivative works
// Under the Following Conditions:
// Attribution - You must attribute the work in the manner
// specified by the author or licensor (but not in any way
// that suggests that they endorse you or your use of the work).
// Share Alike. If you alter, transform, or build upon this work,
// you may distribute the resulting work only under the same,
// similar or a compatible license.
// For any reuse or distribution, you must make clear to others the license
// terms of this work. The best way to do this is with a link to this web page.
// Any of the above conditions can be waived if you get permission from the
// copyright holder.
// Apart from the remix rights granted under this license, nothing in this
// license impairs or restricts the author's moral rights.
//
function note( $str ) // function from base code framework not used here... but is on my todo list.
{
//return "<SPAN CLASS=\"note\">".$str."</SPAN>\n";
return "";
}
function pageHeader( $title ) // ToDo: look at making this part of a wrapper function
{
$hdr = "<HEAD>";
$hdr.= "<TITLE>".$title."</TITLE>";
$hdr.= "<link href='Basic.css' rel='stylesheet' media='screen' />";
$hdr.= "</HEAD>";
return $hdr;
}
function pageFooter( $text )
{
$ftr = makeTable( 100, makeRow( makeCell( 1, $text, 'kanbanMessage' ) ) );
return $ftr;
}
function startBody( $title ) // ToDo: this would be the basis of the wrapper function
{
$hdr = "<BODY marginwidth='0' marginheight='0'>";
$hdr.= "<table width='75%'>";
$hdr.= makeRow( makeCell( 2, $title, 'pageTopbanner' ), 'pageTopbanner' );
return $hdr;
}
function endBody( )
{
$end = "</table></BODY>";
return $end;
}
function makeBody( $body )
{
$hdr = "<BODY marginwidth='0' marginheight='0'>". $body ."</BODY>";;
return $hdr;
}
function makePage( $page )
{
$hdr = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'";
$hdr.= " 'http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd'>";
$hdr.= "<HTML>".$page."</HTML>";
return $hdr;
}
function startPage( )
{
$hdr = "<!DOCTYPE HTML PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN'";
$hdr.= " 'http://www.w3.org/TR/1999/REC-html401-19991224/loose.dtd'>";
$hdr.= "<HTML>";
return $hdr;
}
function endPage( )
{
$end = "</HTML>";
return $end;
}
function mainMenu( $menu )
{ global $tables, $session;
$itms = "";
foreach( $menu as $index => $path )
{
if ( $path['level'] <= $session->userlevel )
$itms.= makeCell( 1, makeActionLink( $path['action'], $path['mode'], '', '', $index ), 'kanban', $path['color'] );
}
$ret = makeCell( 1, makeTable( 0, makeRow( makeCell( 1, "Functions", 'kanban' )
.$itms,'pageMenubanner')
)
).makeCell(1,userStatus( ),'pageMenubanner');
return $ret;
}
function makeTitleBar( $count, $proj )
{ global $projects;
$title ="";
if ( $count > 1 )
{
$title = makeRow( makeCell( $count,
( $proj != 0 ) ? $projects[$proj]['projName']: "<i>Please select a Project</i>",
"pageMenubanner" ), "pageMenubanner" );
}
return $title;
}
function makeHeader( $count, $header )
{
$title = makeRow( makeCell( $count, $header, 'pageMenubanner' ), "pageMenubanner" );
return $title;
}
$sevColor = array( 0 => '#FFFFFF', 1 => '#CCFFCC', 2 => '#FFFF66', 3 => '#FF9966', 4 => '#FF9999', 5 => '#FF99FF');
function Message( $sev, $text )
{ global $messages, $sevColor, $minSevLevel;
if ( $sev >= $minSevLevel )
{ $messages.= makeRow( makeCell( 1, "Sev=".$sev, "kanban" ).makeCell( 1, $text, "kanbanMessage" ), "", $sevColor[$sev] );
}
}
function displayMessages( $msgs )
{ global $messages;
$hdr.= makeRow( makeCell( 2, "Messages", 'kanbanHeading' ) );
$hdr.= makeRow( makeCell( 2, makeTable( 100, $messages ) ) );
return makeTable( 100, $hdr );
}
function loginForm( )
{ global $session, $form;
$r1 = makeRow( makeCell( 1, "Username", "", "" )
.makeCell( 1, makeUserInput( 'text', 'user', '30', $form->value("user") ), "", "" )
.makeCell( 1, $form->error("user"), "", "" ), "", "" );
$r2 = makeRow( makeCell( 1, "Password", "", "" )
.makeCell( 1, makeUserInput( 'password', 'pass', '30', $form->value("pass") ), "", "" )
.makeCell( 1, $form->error("pass"), "", "" ), "", "" );
$r3 = makeRow( makeCell( 1, makeUserInput( 'checkbox', 'remember', "", ($form->value("remember") != "")? "checked" : "" )
."Remember me next time "
.makeUserInput( 'hidden', 'sublogin', '', '1' ), "", "" ), "", "" );
$r4 = makeRow( makeCell( 1, makeActionLink( "user", "forgotpass", "", "", "Forgot Password?]" ), "", "" )
.makeCell( 1, "Not registered? ".makeActionLink( "user", "register", '', '', "Sign-Up!"), "", "" ), "", "" );
$ret.= makeForm( 'user', 'login', '', '', '', makeTable( 0, $r1.$r2.$r3.$r4 ), "Login" );
return $ret;
}
function rowMsg( $msg )
{
$ret = makeRow( makeCell( 1, $msg, 'kanban' ) );
return $ret;
}
$infields = 0;
function makeUserInput( $type, $name, $len, $value, $color )
{ global $infields;
$in = "<INPUT";
$in.= ( $type != "" )? " type='".$type."'" : " type='text'" ;
$in.= ( $name != "" )? " name='".$name."'" : "" ;
$in.= ( $len != "" )? " maxlength='".$len."' size='".$len."'" : "" ;
$in.= ( $value != "" )? " value='".$value."'" : "" ;
$in.= ( $color != "" )? " style='background: ".$color.";'" : "" ;
$in.= ">";
$infields++;
return $in;
}
function makeUserNote( $name, $label, $rows, $cols, $value, $color )
{ global $infields;
$in = "<B>".$label."</B>:<BR><TEXTAREA";
$in.= ( $rows != "" )? " type='".$rows."'" : " type='text'" ;
$in.= ( $name != "" )? " name='".$name."'" : "" ;
$in.= ( $cols != "" )? " cols='".$cols."'" : "" ;
$in.= ( $color != "" )? " style='background: ".$color.";'" : "" ;
$in.= ">";
$in.= ( $value != "" )? $value : "" ;
$in.= "</TEXTAREA>";
return $in;
}
function makeCell( $colspan, $text, $class, $color, $width )
{
$cls = ( $class != "" )? $class : "kanban" ;
$clr = ( $color != "" )? " bgcolor='".$color."'" : "" ;
$ret = "<TD";
$ret.= ($colspan > 1)? " colspan='".$colspan."'" : "";
$ret.= ( $width != "" )? " width='".$width."'" : " width='0*'";
$ret.= " class='".$cls."'";
$ret.= $clr;
$ret.= ">";
$ret.= $text;
$ret.= "</TD>";
return $ret;
}
function makeRow( $text, $class, $color )
{
$clr = ( $color != "" )? " bgcolor='".$color."'" : "";
$cls = ( $class != "" )? " class='".$class."'" : "";
$ret = "<!-- makeRow --><TR".$clr.$cls.">".$text."</TR>\n";
return $ret;
}
function makeNCell( $rowspan, $colspan, $text, $class, $color, $width )
{
$cls = ( $class != "" )? " class='".$class."'" : "kanban" ;
$clr = ( $color != "" )? " bgcolor='".$color."'" : "" ;
$rws = ( $rowspan > 1 )? " rowspan='".$rowspan."'" : "" ;
$col = ( $colspan > 1 )? " colspan='".$colspan."'" : "";
$wth = ( $width != "" )? " width='".$width."'" : " width='0*'";
$ret = "<TD".$rws.$col.$cls.$clr.$wth.">".$text."</TD>";
return $ret;
}
function makeNRow( $rows, $text, $class, $color )
{
$clr = ( $color != "" )? " bgcolor='".$color."'" : "";
$cls = ( $class != "" )? " class='".$class."'" : "";
$rws = ( $rows != 0 )? " rowspan='".$rows."'" : "" ;
$ret = "<!-- makeRow --><TR".$rws.$clr.$cls.">".$text."</TR>\n";
return $ret;
}
function makeTable( $width, $text )
{
$ret = "<!-- makeTable -->";
$ret.= "<TABLE".(($width>=0)? " width='".$width."%'" : "")." cellpadding='1px' cellspacing='1px'>";
$ret.= $text;
$ret.= "</TABLE>\n";
return $ret;
}
function makeUserSelect( $name, $property, $id, $label )
{ global $proplist;
$sel = "<SELECT name='".$name."'>";
$sel.= "<OPTION value=''>Make Selection</OPTION>";
foreach( $proplist[ $property ] as $prop )
{
$sel.= "<OPTION value='".$prop[$property.'ID'];
$sel.= ($id == $prop[$property.'ID'])? " selected " : "" ;
$sel.= "'>";
$sel.= $prop[$property.'Name'];
$sel.= "</OPTION>";
}
$sel.= "</SELECT>";
return $sel;
}
function makeUserSelectByFldName( $name, $property, $existing, $key, $field )
{ global $proplist;
$sel = "<SELECT name='".$name."'>";
$sel.= "<OPTION value=''>Make Selection</OPTION>";
foreach( $proplist[ $property ] as $prop )
{
$sel.= "<OPTION value='".$prop[$key];
$sel.= ($existing == $prop[$key])? " selected " : "" ;
$sel.= "'>";
$sel.= $prop[$field];
$sel.= "</OPTION>";
}
$sel.= "</SELECT>";
return $sel;
}
function makeSelectFromTable( $name, $table, $existing, $key, $field )
{
$sel = "<SELECT name='".$name."'>";
$sel.= "<OPTION value=''>Make Selection</OPTION>";
foreach( $table as $prop )
{
$sel.= "<OPTION value='".$prop[$key];
$sel.= ($existing == $prop[$key])? " selected " : "" ;
$sel.= "'>";
$sel.= $prop[$field];
$sel.= "</OPTION>";
}
$sel.= "</SELECT>";
return $sel;
}
function makeUserDate( $name, $label, $value )
{ global $proplist;
$date = makeCell( 1, makeUserInput( 'text', "year", '4', '2008' ) );
$date.= makeCell( 1, makeUserInput( 'text', "month", '3', '01' ) );
$date.= makeCell( 1, makeUserInput( 'text', "day", '3', '01' ) );
return makeTable( 0, makeRow( $date ) ) ;
}
function colorTable( )
{
$colorValues1 = array ( '00', '33', '66', '99', 'CC', 'FF' );
$colorValues2 = array ( '00', '33', '66', '99', 'CC', 'FF' );
$colorValues3 = array ( '00', '33', '66', '99', 'CC', 'FF' );
$table = "";
foreach( $colorValues1 as $red )
{
foreach( $colorValues2 as $grn )
{
foreach( $colorValues3 as $blu )
{ // this bit of code results in a layout the orders the colors
// by approximate brightness. While not ordered by color within the
// chart, the colors layout in a pretty good sort arrangement.
//
$color = '#'.$red.$grn.$blu;
$dsum = hexdec($red) + hexdec($grn) + hexdec($blu);
$davg = $dsum/3;
$index = (int)( $davg );
$columns[$index].= makeRow( makeCell( 1, $color, ($index > 128 )?'kanbanColorBlack':'kanbanColorWhite', $color ), 'kanbanColor' );
}
}
}
$row = "";
foreach ( $columns as $col )
{
$row.= makeCell( 1, makeTable( 0, $col ), 'kanbanColor' );
}
$ret = makeTable( 0, makeRow( $row ) );
return $ret;
}
function makeForm( $action, $mode, $id, $prop, $other, $body, $label )
{
$button = ($label != "")? $label : "Update";
$frm = "<FORM method=POST action='index.php?";
$frm.= ( $action != "" )? "action=". $action : "";
$frm.= ( $mode != "" )? "&mode=".$mode: "";
$frm.= ( $id != "" )? "&id=". $id : "";
$frm.= ( $prop != "" )? "&prop=".$prop : "";
$frm.= ( $other != "" )? "&". $other : "";
$frm.= "'>";
$frm.= $body;
$frm.= makeRow( makeCell( 1, makeUserInput( 'submit', '', '', $button ) ) );
$frm.= "</FORM>";
return $frm;
}
function makeActionLink( $action, $mode, $id, $prop, $label )
{ global $session;
if ( $action != "" )
{
$lnk = "[<A HREF='index.php?action=".$action;
$lnk.= ( $mode != "" ) ? "&mode=".$mode : "";
$lnk.= ( $id != "" ) ? "&id=". $id : "";
$lnk.= ( $prop != "" ) ? "&prop=".$prop : "";
$lnk.= "'>".$label."</A>]";
}
else
$lnk = "[<A HREF='#'>".$label."</A>]";
return $lnk;
}
function makeMenuControl( $name, $prop, $id, $label, $active, $count )
{ global $proplist;
$control = "\n<SELECT name='".$name;
//$control.= ($count != 0) ? ".".$count: "";
$control.= "'>";
foreach( $proplist[$prop] as $index => $prop )
{
$control.= "<OPTION value='".$prop[$id]."' ";
$control.= ($active == $prop[$id])? " selected " : "";
$control.=">".$prop[$label]."</OPTION>";
//$control.="<!-- ".$active." = ".$prop$id]." -->";
}
$control.= "</SELECT>";
return $control;
}
?>