SourceForge.net Logo


oo.WebsiteTools is a set of basic tools which are needed on almost every website. Using these tools speeds up your www-development radically. It consist of 3 different parts; oo.Admin, oo.Sql, and oo.Ajax.


Every database driven web application normally needs an admin tool (besides phpMyAdmin). oo.Admin is designed for administrating the site, but also for users to manage their user accounts etc. Using oo.Admin you can create all the admin-pages for all your database-tables on your website with ease. It also supports relational databases, file uploads and an easy css-customization.


With oo.Sql you can build PHP/SQL applications with SQL-language independency. Database-type can be changed easily (on-the-fly) without touching your code. Supports MySQL and fSQL at the moment.


oo.Ajax is a simple ajax library made with javascript. It supports loading and updating divs plus sending forms without postback (= reloading the page). It also supports file uploading.

Included files:

conf.inc.phpMysql database settings
database_connection.phpAn includeable file which makes the connection to the database
dumb.sqlAnd SQL-dumb for creating the example database
index.phpThis file
oo\css\admin.cssCascading Style Sheet file for default admin look and feel
oo\js\oo.ajax.jsA simple Javascript Ajax library
oo\php\class.oo.Admin.phpAn Admin class for creating the admin tools
oo\php\class.oo.Sql.phpAn Sql class for handling the database operations
oo\php\suggest.phpA script which handles ajax-suggestions
example.phpThe most simple example how to use the Admin class
example_ajax.phpThe same example with Ajax functionality (without reloading the page). It also demonstrates the 'ajax suggest' function for collecting possible choises from the database (however, in this case the suggested usernames are the taken ones and not possible to register! ;)
example_relational\header.phpMenu, html-head etc.
example_relational\index.phpThe frontpage
example_relational\photos.phpAdmin tool for uploadable photos.
example_relational\posts.phpAdmin tool for simple posts (text).
example_relational\users.phpAdmin tool for adding/editing usernames
example_relational\photos\A photo folder (chmod to 755 for example)
example_dragdrop.phpDemonstrates oo.ajax.js library's nice functions for drag & drop (for example).
example_animation.phpDemonstrates oo.ajax.js library's functions for animation.
example_menu.phpDifferent kind of menus using oo.ajax.js.


Create the database (mySQL) using the included dump.sql and configure the database settings in conf.inc.php

example.phpA simple example with one database table (users) and no authentication. Please chmod (755) the document root if you want to try the uploading-feature.
example_ajax.phpThe same simple example with ajax functionality. It also supports ajax-suggest suggesting usernames, even if they are "taken", but just for an example... Please chmod (755) the document root if you want to try the uploading-feature.
example_relationalA more advanced example with 3 database tables (users, posts photos), 'paging' and an authentication. Please chmod (755) a folder called photos.
example_dragdropoo.ajax.js can also be used for pure js-functionality. This example demonstrates drag and drop and animation (please try also to doubleclick the object).
example_animationWith oo.ajax.js library you can define animations with paths - and looping (n / -1=infinite). Demonstrates also a collision detection between divs and between divs and pixels.
example_menuIt's easy and fun to create all different kind of menus with oo.ajax.js.


Use example.php as a template for your admin. You also need to include the whole folder called 'oo'.

class.oo.Admin.php properties:

Required for the constructor during the creation of an object
PropertyDefault valueDescription
$sql-A Sql-object created from included Sql-class
$db_table-Name of the database table
$fields-An array holding the fields (with default values) of the database table
$key-The primary key (normally 'id') for the database table
Optional properties which can be edited
PropertyDefault valueDescription
$uploadpathimgs/A directory, where customs files will be uploaded (chmod!)
$imagewidth150Width of the representation of the uploaded image
$deletePrevioustrueDelete previous image/file when uploading the new one (for specific field and row)
$renameIfExiststrueRename uploaded file, if one with the same name exists
$namesaveforms name
$ajaxfalsein conjunction with the included ajax-library (js)
$ajaxdivadminThe name of the html form
$afterAddheader(\"Location: {\$_SERVER[\"PHP_SELF\"]}?mode=edit&{\$this->key}={\$this->afterAddValue}\");Will be 'executed' after adding (eval).
$afterAddValue-The 'value' (for key) after addin, normally an id
$fields-The actual fields of the admin form, please see more below.
Defening the $fields for the form
PropertyPossible valuesDescription
typeempty|title|text|textarea|select|file|submitDefines the type of the input field. Special values are: title; just a title; empty; totally hidden way to set data;select: options needs to set using $options array [ $options=array(1=>"title for item 1","value for 2"=>"title for item 2"); ]
value?Default value for the input field.
modeadd|edit|bothWill be used in add, edit or both modes
required0|1Weather it's a required field or not.
unique0|1The entered value will be unique, and if one already exists, an error will be thrown.
title?Title (on the left side) of the input-field.
comment?The comment (on the right side) of the input-field.
extra?The value will be added inside the input-tag, so it can include for example onclick="" or onmouseover="" etc.

class.oo.Sql.php methods and properties:

Sql($dbType,$dbPath)Constructor method for Sql
PropertyDefault valueDescription
$dbTypemysqlType of SQL-database: mySQL and fSQL supported at the moment
$dbPath-Filepath in flat-file-based databases
connect$server,$user,$password,$databaseMethod for creating a database connection
PropertyDefault valueDescription
$user-Username for database
$password-It's password
$database-Name of the database
select$table,$condition,$sqlParameters,$fieldsSql select statement
PropertyDefault valueDescription
$table-Name of the database table for select statement
$condition-Condition, for example id>0
$sqlParameters-Extra parameters, for example 'order by id desc limit 1'
$fields*List of desired fields, or * for all
add$table,$variablesFor adding new rows to the database
PropertyDefault valueDescription
$table-Name of the database table
$variables-An array of data to be added, for example ("name"=>"oo","t"=>time())
edit$table,$condition,$variablesFor updating database-rows
PropertyDefault valueDescription
$table-Name of the database table
$condition-For example "id=3"
$variables-An array of data to be added, for example ("name"=>"oo","t"=>time())
delete$table,$conditionFor deleting rows on the database
PropertyDefault valueDescription
$table-Name of the database table
$condition-For example "id=3"

oo.ajax.js functions:

getHTML: getHTML('url.php','parameters=here','targetdiv');
postForm: <form action="javascript:postForm('url.php?parameters=here',document.getElementById('myform'),'targetdiv');" name="myform" id="myform">
getHTMLurl,pars,divLoad content from server to a specified div without a postback.
PropertyDefault valueDescription
url-Name of the script, for example 'script.php'
pars-Get-parameters, for example 'name=oowebsitetools&type=os'
div-Id of div where content will be loaded.
postFormurl,obj,divFor posting a form without a postback (reloading).
PropertyDefault valueDescription
url-Url of the script, for example 'url.php'
obj-Object of the form, for example document.getElementById('myform')
div-Id of div where content will be loaded.
In order to use these commands, you need to define absolute position and size to the div.
For example style="position:absolute;left:200px;top:200px;width:400px;height:300px">hello world!
animateTodiv,x,y,w,h,a,time,stepsFor animating divs.
animateBydiv,x,y,w,h,a,time,stepsFor animating divs relatively.
moveTodiv,x,yFor moving divs.
moveBydiv,x,yFor moving divs relatively.
scaleTodiv,w,hFor scaling divs.
scaleBydiv,w,hFor scaling divs relatively.
fadeTodiv,aFor setting div's transparency (alpha, opacity).
fadeBydiv,aFor setting div's transparency relatively.
PropertyDefault valueDescription
div-The id of the desired div.
x-X (pixels from left edge, 0) of the div.
y-Y (pixels from top edge, 0) of the div.
w-Width of the div in pixels.
h-Height of the div in pixels.
a100Div's opacity from 0 to 100.
time-Time for the animation in milliseconds (1000 = 1 sec.).
steps-How many steps during the 'time' in animation (the more steps, the smoother animation).
collisionTodiv,div2Checks if there's a collision between div1 and div2.
collisionBydivDetects if a div is colliding with any other divs - returning its id.
collisionToPixeldiv,x,yChecks if there's a collision between div1 and a pixel at x,y.
collisionByPixelx,yDetects if any div is colliding with a pixel at x,y - and returns its id.
PropertyDefault valueDescription
div-Div's id.
div2-Id of the other div.
x-X (pixels from left edge, 0) of the div.
y-Y (pixels from top edge, 0) of the div.
visibilityToggledivToggles div's visibility on/off.
visibilityOndivSets div's visibility on.
visibilityOffdivSets div's visibility off.