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.
conf.inc.php | Mysql database settings |
database_connection.php | An includeable file which makes the connection to the database |
dumb.sql | And SQL-dumb for creating the example database |
index.php | This file |
oo\css\admin.css | Cascading Style Sheet file for default admin look and feel |
oo\js\oo.ajax.js | A simple Javascript Ajax library |
oo\php\class.oo.Admin.php | An Admin class for creating the admin tools |
oo\php\class.oo.Sql.php | An Sql class for handling the database operations |
oo\php\suggest.php | A script which handles ajax-suggestions |
example.php | The most simple example how to use the Admin class |
example_ajax.php | The 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.php | Menu, html-head etc. |
example_relational\index.php | The frontpage |
example_relational\photos.php | Admin tool for uploadable photos. |
example_relational\posts.php | Admin tool for simple posts (text). |
example_relational\users.php | Admin tool for adding/editing usernames |
example_relational\photos\ | A photo folder (chmod to 755 for example) |
example_dragdrop.php | Demonstrates oo.ajax.js library's nice functions for drag & drop (for example). |
example_animation.php | Demonstrates oo.ajax.js library's functions for animation. |
example_menu.php | Different 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.php | A 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.php | The 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_relational | A more advanced example with 3 database tables (users, posts photos), 'paging' and an authentication. Please chmod (755) a folder called photos. |
example_dragdrop | oo.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_animation | With 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 | It's easy and fun to create all different kind of menus with oo.ajax.js. |
Required for the constructor during the creation of an object | ||
Property | Default value | Description |
$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 | ||
Property | Default value | Description |
$uploadpath | imgs/ | A directory, where customs files will be uploaded (chmod!) |
$imagewidth | 150 | Width of the representation of the uploaded image |
$deletePrevious | true | Delete previous image/file when uploading the new one (for specific field and row) |
$renameIfExists | true | Rename uploaded file, if one with the same name exists |
$name | save | forms name |
$ajax | false | in conjunction with the included ajax-library (js) |
$ajaxdiv | admin | The name of the html form |
$afterAdd | header(\"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 | ||
Property | Possible values | Description |
type | empty|title|text|textarea|select|file|submit | Defines 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. |
mode | add|edit|both | Will be used in add, edit or both modes |
behavior | static|forced | |
required | 0|1 | Weather it's a required field or not. |
unique | 0|1 | The 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. |
Sql->Sql($dbType,$dbPath) | ||
Method | Parameters | Description |
Sql | ($dbType,$dbPath) | Constructor method for Sql |
Property | Default value | Description |
$dbType | mysql | Type of SQL-database: mySQL and fSQL supported at the moment |
$dbPath | - | Filepath in flat-file-based databases |
Sql->connect($server,$user,$password,$database) | ||
Method | Parameters | Description |
connect | $server,$user,$password,$database | Method for creating a database connection |
Property | Default value | Description |
$server | localhost | Database-server |
$user | - | Username for database |
$password | - | It's password |
$database | - | Name of the database |
Sql->select($table,$condition,$sqlParameters,$fields) | ||
Method | Parameters | Description |
select | $table,$condition,$sqlParameters,$fields | Sql select statement |
Property | Default value | Description |
$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) | ||
Method | Parameters | Description |
add | $table,$variables | For adding new rows to the database |
Property | Default value | Description |
$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) | ||
Method | Parameters | Description |
edit | $table,$condition,$variables | For updating database-rows |
Property | Default value | Description |
$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) | ||
Method | Parameters | Description |
delete | $table,$condition | For deleting rows on the database |
Property | Default value | Description |
$table | - | Name of the database table |
$condition | - | For example "id=3" |
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) | ||
Method | Parameters | Description |
getHTML | url,pars,div | Load content from server to a specified div without a postback. |
Property | Default value | Description |
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) | ||
Method | Parameters | Description |
postForm | url,obj,div | For posting a form without a postback (reloading). |
Property | Default value | Description |
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. |
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 style="position:absolute;left:200px;top:200px;width:400px;height:300px">hello world! |
||
Method | Parameters | Description |
animateTo | div,x,y,w,h,a,time,steps | For animating divs. |
animateBy | div,x,y,w,h,a,time,steps | For animating divs relatively. |
moveTo | div,x,y | For moving divs. |
moveBy | div,x,y | For moving divs relatively. |
scaleTo | div,w,h | For scaling divs. |
scaleBy | div,w,h | For scaling divs relatively. |
fadeTo | div,a | For setting div's transparency (alpha, opacity). |
fadeBy | div,a | For setting div's transparency relatively. |
Property | Default value | Description |
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. |
a | 100 | Div'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) | ||
Method | Parameters | Description |
collisionTo | div,div2 | Checks if there's a collision between div1 and div2. |
collisionBy | div | Detects if a div is colliding with any other divs - returning its id. |
collisionToPixel | div,x,y | Checks if there's a collision between div1 and a pixel at x,y. |
collisionByPixel | x,y | Detects if any div is colliding with a pixel at x,y - and returns its id. |
Property | Default value | Description |
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) | ||
Method | Parameters | Description |
visibilityToggle | div | Toggles div's visibility on/off. |
visibilityOn | div | Sets div's visibility on. |
visibilityOff | div | Sets div's visibility off. |