oo.WebsiteTools

SourceForge.net Logo

Description:

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.

oo.Admin

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.

oo.Sql

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

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\js\oo.tips.jsShow popup-tips with ajax.
oo\js\oo.dragdrop.jsA small library for drag & drop function
oo\js\oo.trigonometry.jsUsable functions for radians and degrees.
oo\js\oo.sound.jsFunctions for playing sounds.
oo\js\oo.key.jsFunctions for keyboard detection.
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.htmlDemonstrates oo.dragdrop.js in practise.
example_animation.phpDemonstrates oo.ajax.js library's functions for animation.
example_menu.phpDifferent kind of menus using oo.ajax.js.
example_tips.htmlExamples wow to use oo.tips.js.
example_sequencerA funny example how you can use oo.Websitetools in a creative way.
example_sound.phpExample use of oo.sound.js.
example_trigonometryExamples of oo.trigonometry.js.
example_trigonometry/radians_and_degrees.htmlExamples for radians and degrees.
example_trigonometry/orbit.htmlAn example how to animate paths, like a circle and an ellipse.
example_trigonometry/planets.htmlAn example how to animate orbits (by parent object).
example_commandline.htmlTry oo.Websitetools interactively.

Examples:

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_dragdrop.htmloo.ajax.js and it's oo.dragdrop.js can also be used for pure js-functionality. This example demonstrates drag and drop (please try also to resize the div with SHIFT-key, scale it (keeping the aspect ratio) with CONTROL-key or just to doubleclick it).
example_animation.phpWith 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_menu.phpIt's easy and fun to create all different kind of menus with oo.ajax.js.
example_tips.htmlTooltips etc. can be easily created with oo.tips.js.
example_sequencerAn audio-sequencer created with oo.Websitetools.
example_sound.phpPlay drumsounds with your keyboard.
example_trigonometry/radians_and_degrees.htmlRadians and degrees.
example_trigonometry/orbit.htmlAnimate orbit-movements and a collision detection based on 'the distance'.
example_trigonometry/planets.htmlThe Solar system animated based on correct speeds and distances .
example_commandline.htmlPlay with oo.Websitetools' functions in realtime.

Usage:

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
behaviorstatic|forced
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->Sql($dbType,$dbPath)
MethodParametersDescription
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
Sql->connect($server,$user,$password,$database)
MethodParametersDescription
connect$server,$user,$password,$databaseMethod for creating a database connection
PropertyDefault valueDescription
$serverlocalhostDatabase-server
$user-Username for database
$password-It's password
$database-Name of the database
Sql->select($table,$condition,$sqlParameters,$fields)
MethodParametersDescription
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
Sql->add($table,$variables)
MethodParametersDescription
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())
Sql->edit($table,$condition,$variables)
MethodParametersDescription
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())
Sql->delete($table,$condition)
MethodParametersDescription
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:

Usage:
getHTML: getHTML('url.php','parameters=here','targetdiv');
postForm: <form action="javascript:postForm('url.php?parameters=here',document.getElementById('myform'),'targetdiv');" name="myform" id="myform">
getHTML(url,pars,div)
MethodParametersDescription
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.
postForm(url,obj,div)
MethodParametersDescription
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.
setHTML(div,html)
MethodParametersDescription
setHTMLdiv,htmlChanges the content of a div.
PropertyDefault valueDescription
div-Id of the desired div.
html-HTML-string to be set.
animateTo(div,x,y,w,h,a,time,steps)
Note:
In order to use these commands, you need to define absolute position and size to the div.
For example <div style="position:absolute;left:200px;top:200px;width:400px;height:300px">hello world!</div>
MethodParametersDescription
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).
collisionTo(div,div2)
MethodParametersDescription
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.
visibilityToggle(div)
MethodParametersDescription
visibilityToggledivToggles div's visibility on/off.
visibilityOndivSets div's visibility on.
visibilityOffdivSets div's visibility off.