<?php
/**
* Another example on using this class <br>
* ----------------------------------- <br><br>
*
* last review: 07.02.07 <br>
*
* @author Wagner O. Wutzke <hide@address.com>
*
* @version 2.0
*
* @link http://www.phpclasses.org/browse/package/3704.html
*
* @package phpSortable
*
* */
require_once "../class.phpSortable.php";
# creates a new phpSortable Object with the database connectios
# parameter and work with the table "tb_event"
$yourHost = "localhost";
$yourDB = "usr_web314_1";
$yourUser = "root";
$yourPass = "";
$dbtype = "mysql"; # see activeDBLib documentation
# for others DB types (manual.html)
$sql =
"SELECT DISTINCT " .
"a.*, b.name AS tutor, c.name AS ersteller " .
"FROM event a, tutorium b, user c " .
"WHERE " .
"a.user_id = c.user_id AND " .
"a.tutorium_id = b.id";
# create a new activeDBLib object with the desired db
$db = new activeDBLib($dbtype);
# catch all errors and exit the application if any
$db->debug();
# connect to the db
$db->connect($yourHost, $yourUser, $yourPass, $yourDB);
# execute the sql query
$db->execute($sql);
/**
* $col = new phpSortColumn($name,$title,$formatFunction,$link,$img,$appendDataToLink,$target);
*/
# creates a new phpSortColumn object for ID´s
$col_0 = new phpSortColumn("id", "ID");
# creates a new phpSortColumn object for Tutors
$col_1 = new phpSortColumn("tutor", "Tutors");
# creates a new phpSortColumn object for Authors
$col_2 = new phpSortColumn("ersteller", "Author");
# creates a new phpSortColumn object for Descriptions and format it with the function printShortString.
# printShortString must output the formated string with echo!
$col_3 = new phpSortColumn("titel", "Description", "\$this->printShortString(\$readVal, 200);");
# creates a new phpSortColumn object for Date. This will be as Date (dd.mm.yyyy) formated
$col_4 = new phpSortColumn("datum", "Date", "", "date");
# creates a new phpSortColumn object for Galleries. It will displayed as a link with an image.
# In this case, the defined Table Key will be appended to this link. Not the Data from the Table.
$col_5 = new phpSortColumn("gallery_id", "Gallery", "", "link", "verwaltung_list.php?class=gallery&id=", $appendDataToLink=false);
# creates a new phpSortColumn object. This is also a link without an image.
# With "appendDataToLink = true" we append the data for this column to the link.
$col_6 = new phpSortColumn("user_id", "User", "", "link", "http://verwaltung_edit.php?class=users&user_id=", $img="", $target="_blank", $appendDataToLink=true);
# add the columns to an array
$columns = array(0=>$col_0, 1=>$col_1, 2=>$col_2, 3=>$col_3, 4=>$col_4, 5=>$col_5, 6=>$col_6);
# create a new phpSortable object with the abstracted db object
# and the array of column object
$sortable = new phpSortable($db, $columns);
# define the table format: cellpadding, cellspacing, border
$sortable->setTableFormat ("2", "2", "0");
# define the table title
$sortable->tableTitle = "Events Liste von Tutoren";
# define the link for edit of entries
$sortable->editLink = "verwaltung_edit.php";
# open the edit page in a new window
$sortable->editTarget = "_blank";
# window format for the edit page
$sortable->editWindowFormat = "'width=300,height=400'";
# define the link for delete of entries
$sortable->deleteLink = "verwaltung_delete.php";
# define the link for add new entries
$sortable->addLink = "verwaltung_edit.php?class=events&id=0";
# define the hint to be displyed over the add button
$sortable->addText = "Neuer Event";
# define the key name to be attached to links
$sortable->urlKeyName = "id";
# define the column name of to be attached to links as key value
$sortable->tableKeyName = "id";
# define the prompt message to be diplayed on clicking the edit button
$sortable->editPromptMsg = "Möchtest du den Eintrag wirklich ändern?";
# define the prompt message to be diplayed on clicking the delete button
$sortable->deletePromptMsg = "Möchtest du den Eintrag wirklich löschen?";
# define the message to be diplayed if there are no results found
$sortable->emptyMsg = "Kein Event eingetragen...";
#define the deafult row number to be displayed
$sortable->defaultRowsNum = "5";
#define the path for the css file
$sortable->cssFilePath = "../phpSortable.css";
#define the path for of the images directory
$sortable->imgFilePath = "../img/";
# print the table
$sortable->printTable();
?>