diff --git a/bilder.pot b/bilder.pot new file mode 100644 index 0000000..1e4f411 --- /dev/null +++ b/bilder.pot @@ -0,0 +1,87 @@ +# SOME DESCRIPTIVE TITLE. +# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# FIRST AUTHOR , YEAR. +# +#, fuzzy +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2007-10-08 03:09+0200\n" +"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" +"Last-Translator: FULL NAME \n" +"Language-Team: LANGUAGE \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=CHARSET\n" +"Content-Transfer-Encoding: 8bit\n" + +#: templates/personAdmin/personSearch1.tpl.php:37 +msgid "search" +msgstr "" + +#: templates/personAdmin/personSearch1.tpl.php:45 +#: templates/personAdmin/personInUp.tpl.php:86 +msgid "surname" +msgstr "" + +#: templates/personAdmin/personSearch1.tpl.php:56 +#: templates/personAdmin/personInUp.tpl.php:80 +msgid "firstname" +msgstr "" + +#: templates/personAdmin/personInUp.tpl.php:47 +msgid "update" +msgstr "" + +#: templates/personAdmin/personInUp.tpl.php:54 +msgid "insert" +msgstr "" + +#: templates/personAdmin/personInUp.tpl.php:57 +msgid "submit" +msgstr "" + +#: templates/personAdmin/personInUp.tpl.php:63 +msgid "personal data" +msgstr "" + +#: templates/personAdmin/personInUp.tpl.php:92 +msgid "company" +msgstr "" + +#: templates/personAdmin/personInUp.tpl.php:98 +msgid "email" +msgstr "" + +#: templates/personAdmin/personInUp.tpl.php:104 +msgid "url" +msgstr "" + +#: templates/personAdmin/personInUp.tpl.php:117 +msgid "photographer" +msgstr "" + +#: templates/personAdmin/personInUp.tpl.php:124 +msgid "cameraId" +msgstr "" + +#: templates/personAdmin/personInUp.tpl.php:137 +msgid "owner" +msgstr "" + +#: templates/personAdmin/personInUp.tpl.php:144 +msgid "watermark width" +msgstr "" + +#: templates/personAdmin/personInUp.tpl.php:150 +msgid "watermark height" +msgstr "" + +#: templates/personAdmin/personInUp.tpl.php:156 +msgid "watermark xPos" +msgstr "" + +#: templates/personAdmin/personInUp.tpl.php:162 +msgid "watermark yPos" +msgstr "" diff --git a/components/personAdmin.php b/components/personAdmin.php new file mode 100644 index 0000000..e976317 --- /dev/null +++ b/components/personAdmin.php @@ -0,0 +1,12 @@ +show (); + +?> diff --git a/config.php b/config.php new file mode 100644 index 0000000..7bf2a52 --- /dev/null +++ b/config.php @@ -0,0 +1,35 @@ + diff --git a/css/background-colors.css b/css/background-colors.css new file mode 100644 index 0000000..9c27f93 --- /dev/null +++ b/css/background-colors.css @@ -0,0 +1,20 @@ +/* ======================================================================= + * Styles for components + * ======================================================================= */ +.bgc-bg1 { background-color: #888888 } +/* ======================================================================= */ + +/* ======================================================================= + * Styles for logical groups. A group is defined by a bounding box "grp*" + * containing one or more header lines "head*" and content-boxes "box*" + * ======================================================================= */ +.bgc-grp1 { background-color: #aaaaaa } +.bgc-box1 { background-color: #ffb400 } +.bgc-head1 { background-color: #e5a200 } +/* ======================================================================= */ + +/* ======================================================================= + * Styles for tooltips + * ======================================================================= */ +.bgc-tt1 { background-color: #eeeeee } +/* ======================================================================= */ diff --git a/css/displays.css b/css/displays.css new file mode 100644 index 0000000..fc3bae2 --- /dev/null +++ b/css/displays.css @@ -0,0 +1,58 @@ +/* ======================================================================= + * Styles for components + * ======================================================================= */ +.d-bg1 { + padding: 2px +} +/* ======================================================================= */ + +/* ======================================================================= + * Styles for logical groups. A group is defined by a bounding box "grp*" + * containing one or more header lines "head*" and content-boxes "box*" + * ======================================================================= */ +.d-grp1 { + padding: 2px; + padding-top: 1px; + padding-bottom: 1px +} +.d-box1 { + padding: 3px; + margin-top: 1px; + margin-bottom: 1px +} +.d-head1 { + padding: 3px; + margin-top: 1px; + margin-bottom: 1px +} +/* ======================================================================= */ + +/* ======================================================================= + * Styles for tooltips + * ======================================================================= */ +div.d-tt1 { + border: 1px solid black; + padding: 2px; + visibility: hidden; + z-index: 100 +} +ul.d-tt1 { + list-style-type: none; + margin: 0px; + padding: 0px +} +/* ======================================================================= */ + +/* ======================================================================= + * common changes to tag defaults + * ======================================================================= */ +form { + padding: 0px; + margin: 0px; +} + +td { + padding: 0px; + margin: 0px; +} +/* ======================================================================= */ diff --git a/css/fonts.css b/css/fonts.css new file mode 100644 index 0000000..9ded16a --- /dev/null +++ b/css/fonts.css @@ -0,0 +1,33 @@ +/* ======================================================================= + * Styles for components + * ======================================================================= */ +.f-bg1 { + font-family: verdana, sans-serif; + font-size: 8pt; + font-weight: normal; + color: #000000 +} +/* ======================================================================= */ + +/* ======================================================================= + * Styles for logical groups. A group is defined by a bounding box "grp*" + * containing one or more header lines "head*" and content-boxes "box*" + * ======================================================================= */ +.f-box1 { + font-family: verdana, sans-serif; + font-size: 8pt; + font-weight: normal; + color: #000000 +} +.f-head1 { + font-family: verdana, sans-serif; + font-size: 10pt; + font-weight: bold; + color: #000000 +} +/* ======================================================================= */ + +/* ======================================================================= + * Styles for tooltips + * ======================================================================= */ +/* ======================================================================= */ diff --git a/img/circDblArrDownBlk.png b/img/circDblArrDownBlk.png new file mode 100644 index 0000000..7309931 Binary files /dev/null and b/img/circDblArrDownBlk.png differ diff --git a/img/circDblArrLeftBlk.png b/img/circDblArrLeftBlk.png new file mode 100644 index 0000000..81de79b Binary files /dev/null and b/img/circDblArrLeftBlk.png differ diff --git a/img/circDblArrRightBlk.png b/img/circDblArrRightBlk.png new file mode 100644 index 0000000..5c76013 Binary files /dev/null and b/img/circDblArrRightBlk.png differ diff --git a/img/circDblArrUpBlk.png b/img/circDblArrUpBlk.png new file mode 100644 index 0000000..8ce5d84 Binary files /dev/null and b/img/circDblArrUpBlk.png differ diff --git a/img/patterns1.xcf b/img/patterns1.xcf new file mode 100644 index 0000000..c93a9c9 Binary files /dev/null and b/img/patterns1.xcf differ diff --git a/js/fittingStrings.js b/js/fittingStrings.js new file mode 100644 index 0000000..1fbab71 --- /dev/null +++ b/js/fittingStrings.js @@ -0,0 +1,48 @@ +/* + * requires levenshtein.js to be loaded first + */ + +function distsort (_a, _b) +{ + var a = _a.substring (0, _a.indexOf('::')); + var b = _b.substring (0, _b.indexOf('::')); + + return a - b; +} + +function fittingStrings (search, strings, cs) +{ + var dists = new Array (); + + if (search.length <= 0) + return dists; + + if (cs == false) + _search = search.toUpperCase (); + else + _search = search; + + /* + * hier suche ich die zur Eingabe am besten passenden Eintraege + * in der Datenbank. Neben der eigentlichen distance ermittle ich noch + * einen Wert distance - Ueberhang(Datenbankstring zu Suchstring) + * Zweiter eignet sich besser zum Vergleich der Ergebnisse untereinander. + */ + for (str in strings) + { + if (cs == false) + _str = strings[str].toUpperCase (); + else + _str = strings[str]; + + var dist = levenshtein (_search, _str); + var delta = _str.length - _search.length; + var subDist = (delta > 0)? dist - delta: dist; + + dists.push (subDist + '::' + dist + '::' + strings[str]); + } + + dists.sort(distsort); + + return dists; +} diff --git a/js/levenshtein.js b/js/levenshtein.js new file mode 100644 index 0000000..113d685 --- /dev/null +++ b/js/levenshtein.js @@ -0,0 +1,52 @@ +/* + Copyright (c) 2006. All Rights reserved. + + If you use this script, please email me and let me know, thanks! + Andrew Hedges + andrew (at) hedges (dot) name + If you want to hire me to write JavaScript for you, see my resume. + + http://andrew.hedges.name/resume/ +*/ + +// return the smallest of the three values passed in +function minimum (x, y, z) +{ + if (x < y && x < z) return x; + if (y < x && y < z) return y; + return z; +} + +// calculate the Levenshtein distance between a and b, +function levenshtein (a, b) +{ + var cost; + var m = a.length; + var n = b.length; + + // make sure a.length >= b.length to use O(min(n,m)) space + if (m < n) + { + var c=a; a=b; b=c; + var o=m; m=n; n=o; + } + + var r = new Array(); + r[0] = new Array(); + for (var c = 0; c < n+1; c++) + r[0][c] = c; + + for (var i = 1; i < m+1; i++) + { + r[i] = new Array(); + r[i][0] = i; + + for (var j = 1; j < n+1; j++) + { + cost = (a.charAt(i-1) == b.charAt(j-1))? 0: 1; + r[i][j] = minimum (r[i-1][j]+1, r[i][j-1]+1, r[i-1][j-1]+cost); + } + } + + return r[r.length-1][r[r.length-1].length-1]; +} diff --git a/js/personAdmin/person.js b/js/personAdmin/person.js new file mode 100644 index 0000000..75dd7b9 --- /dev/null +++ b/js/personAdmin/person.js @@ -0,0 +1,70 @@ +function c_person (personId, photographerId, ownerId, firstname, surname, + company, email, url, cameraId, wmWidth, wmHeight, wmXPos, wmYPos) +{ + this.personId = personId; + this.photographerId = photographerId; + this.ownerId = ownerId; + this.firstname = firstname; + this.surname = surname; + this.company = company; + this.email = email; + this.url = url; + this.cameraId = cameraId; + this.wmWidth = wmWidth; + this.wmHeight = wmHeight; + this.wmXPos = wmXPos; + this.wmYPos = wmYPos; + + this.personForm = null; + + this.connect = function (personForm) + { + this.personForm = personForm; + } + + this.reset = function () + { + if (this.personId != -1) + { + this.personId = -1; + this.photographerId = -1; + this.ownerId = -1; + this.firstname = ''; + this.surname = ''; + this.company = ''; + this.email = ''; + this.url = ''; + this.cameraId = -1; + this.wmWidth = ''; + this.wmHeight = ''; + this.wmXPos = ''; + this.wmYPos = ''; + + if (this.personForm != null) + this.personForm.updateForm (); + } + } + + this.update = function (p) + { + if (this.personId != p.personId) + { + this.personId = p.personId; + this.photographerId = p.photographerId; + this.ownerId = p.ownerId; + this.firstname = p.firstname; + this.surname = p.surname; + this.company = p.company; + this.email = p.email; + this.url = p.url; + this.cameraId = p.cameraId; + this.wmWidth = p.wmWidth; + this.wmHeight = p.wmHeight; + this.wmXPos = p.wmXPos; + this.wmYPos = p.wmYPos; + + if (this.personForm != null) + this.personForm.updateForm (); + } + } +} diff --git a/js/personAdmin/personInUp.js b/js/personAdmin/personInUp.js new file mode 100644 index 0000000..7ec65e6 --- /dev/null +++ b/js/personAdmin/personInUp.js @@ -0,0 +1,209 @@ +/* + * requires fittingStrings.js to be loaded first + */ + + +/* + * controls input/update formular for person insert + * + * Arguments: + * upId / ID of the insert checkbox + * inId / ID of the update checkbox + * persons / Array containing all persons already existant in DB + * + * Methods: + * de_activate / de/activate the formular fields for input + * updateForm / calls de_activate and controls the checkboxes + */ +function personInUp ( + upId, inId, submitId, person, newPerson, arrRight, arrDown) +{ + this.updBox = upId; + this.insBox = inId; + this.submitButton = submitId; + this.arrRight = arrRight; + this.arrDown = arrDown; + this.person = person; + this.newPerson = newPerson; + + person.connect (this); + + this.de_activate = function (field) + { + var updBox = document.getElementById (this.updBox); + var insBox = document.getElementById (this.insBox); + + if (updBox.checked == true || insBox.checked == true) + field.disabled = false; + else + field.disabled = true; + + return false; + } + + this.un_fold = function (id, element) + { + title = element.parentNode.getElementsByTagName ('div')[0]; + img = title.getElementsByTagName ('img')[0]; + + if (id != -1) + { + element.style.display = 'block'; + img.src = this.arrDown.getImgUrl (title); + } + else + { + element.style.display = 'none'; + img.src = this.arrRight.getImgUrl (title); + } + } + + this.updateFields = function (person) + { + for (p in person) + { + if (p == 'personForm') + break; + + var field = document.getElementById (p); + + if (field != null) + { + field.value = person[p]; + this.de_activate (field); + } + + switch (p) + { + case 'photographerId': + this.un_fold (person[p], + document.getElementById ('cameraId').parentNode.parentNode); + break; + case 'ownerId': + this.un_fold (person[p], + document.getElementById ('wmWidth').parentNode.parentNode); + } + } + } + + this.updateForm = function () + { + var updBox = document.getElementById (this.updBox); + var insBox = document.getElementById (this.insBox); + var submitButton = document.getElementById (this.submitButton); + var person; + + if (this.person.personId != -1) + { + if (insBox.checked == false) + { + person = this.person; + updBox.disabled = false; + } + else + { + person = this.newPerson; + updBox.checked = false; + updBox.disabled = true; + } + } + else + { + person = this.newPerson; + updBox.checked = false; + updBox.disabled = true; + } + + if (updBox.checked == true || insBox.checked == true) + submitButton.disabled = false; + else + submitButton.disabled = true; + + this.updateFields (person); + + return false; + } + + this.selectPerson = function () + { + var insBox = document.getElementById (this.insBox); + var person; + + if (insBox.checked == true) + person = this.newPerson; + else + person = this.person; + + return person; + } + + this.setFirstname = function (value) + { + this.selectPerson ().firstname = value; + } + + this.setSurname = function (value) + { + this.selectPerson ().surname = value; + } + + this.setCompany = function (value) + { + this.selectPerson ().company = value; + } + + this.setEmail = function (value) + { + this.selectPerson ().email = value; + } + + this.setUrl = function (value) + { + this.selectPerson ().url = value; + } + + this.setCameraId = function (value) + { + var person = this.selectPerson (); + + person.cameraId = value; + if (person == this.newPerson) + person.photographerId = 0; + } + + this.setWmWidth = function (value) + { + var person = this.selectPerson (); + + person.wmWidth = value; + if (person == this.newPerson) + person.ownerId = 0; + } + + this.setWmHeight = function (value) + { + var person = this.selectPerson (); + + person.wmHeight = value; + if (person == this.newPerson) + person.ownerId = 0; + } + + this.setWmXPos = function (value) + { + var person = this.selectPerson (); + + person.wmXPos = value; + if (person == this.newPerson) + person.ownerId = 0; + } + + this.setWmYPos = function (value) + { + var person = this.selectPerson (); + + person.wmYPos = value; + if (person == this.newPerson) + person.ownerId = 0; + } +} diff --git a/js/personAdmin/personSearch1.js b/js/personAdmin/personSearch1.js new file mode 100644 index 0000000..90e19db --- /dev/null +++ b/js/personAdmin/personSearch1.js @@ -0,0 +1,179 @@ +/* + * requires fittingStrings.js to be loaded first + */ + + +/* + * provide alternative Names already existent in DB to given names in + * input text fields: + * + * Arguments: + * fname / ID of the input text field with firstname + * sname / ID of the input text field with surname + * fnameAlt / ID of the list that recieves the alternative firstnames + * snameAlt / ID of the list that receives the alternative surnames + * names / Array containing the already existing names and persons. + * + * Methods: + * updField / exact match(no-case) found => update input field + * genAlternativesList / generate List of alternative Strings + * altSurnames / fill the list of alternative surnames + * altFirstnames / fill the list of alternative firstnames + */ +function c_personSearch1 (fname, sname, fnameAlt, snameAlt, names, person) +{ + this.firstname = fname; + this.surname = sname; + this.fNameAlt = fnameAlt; + this.sNameAlt = snameAlt; + + this.surnames = new Array (); + this.firstnames = new Array (); + this.persons = new Array (); + for (sn in names) + { + this.surnames.push (sn); + this.firstnames[sn] = new Array (); + this.persons[sn] = new Array (); + for (d in names[sn]) + { + this.firstnames[sn].push (names[sn][d][0]); + this.persons[sn][names[sn][d][0]] = names[sn][d][1]; + } + } + this.person = person; + + this.sNameBest = new Array (-1, -1, null); + this.fNameBest = new Array (-1, -1, null); + + this.show = function (id) + { + var node = document.getElementById (id); + node.parentNode.style.visibility = 'visible'; + + return false; + } + + this.hide = function (id) + { + var node = document.getElementById (id); + node.parentNode.style.visibility = 'hidden'; + + return false; + } + + this.updField = function (field, alternative, altId) + { + if (alternative[1] == 0) + field.value = alternative[2]; + else + if (alternative[1] >= 0) + return this.show (altId); + + return this.hide (altId); + } + + this.genAlternativesList = function (bestFit, dists) + { + if (dists.length > 0) + // there are caculated distances for surnames + { + var i = 0; + var bestMatch = dists[0].split ('::'); // infos for best match + + // reset matches select + while ((child = bestFit.firstChild) != null) + bestFit.removeChild (child); + + for (match in dists) + // walk through all matches + { + // get infos for match + var sMatch = dists[match].split ('::'); + + // create list entries + newLi = document.createElement ('li'); + liTxt = document.createTextNode (sMatch[2]); + newLi.appendChild (liTxt); + bestFit.appendChild (newLi); + i=i+1; + + if (i >= bestMatch[1]) + // dont show more than best match distance matches. + break; + } + } + else + // there are no caculated distances for surnames + { + // reset matches select + while ((child = bestFit.firstChild) != null) + bestFit.removeChild (child); + return new Array (-1, -1, ''); + } + + return bestMatch; + } + + this.altSurnames = function () + { + var surname = document.getElementById (this.surname); + var sNameAlt = document.getElementById (this.sNameAlt); + var dists = fittingStrings (surname.value, this.surnames, false); + + this.sNameBest = this.genAlternativesList (sNameAlt, dists); + this.updField (surname, this.sNameBest, this.sNameAlt) + + if (this.sNameBest[1] == 0) + { + var firstname = document.getElementById (this.firstname); + var dists = fittingStrings ( + firstname.value, this.firstnames[this.sNameBest[2]], false); + + if (dists.length > 0) + this.fNameBest = dists[0].split ('::'); + + if (this.person != null) + if (this.fNameBest[1] == 0) + this.person.update ( + this.persons[this.sNameBest[2]][this.fNameBest[2]]); + else + this.person.reset (); + } + else + { + this.fNameBest = new Array (-1, -1, null); + if (this.person != null) + this.person.reset (); + } + + return false; + } + + this.altFirstnames = function (person) + { + var firstname = document.getElementById (this.firstname); + var fNameAlt = document.getElementById (this.fNameAlt); + + if (this.sNameBest[1] == 0) + { + var surname = document.getElementById (this.surname); + var dists = fittingStrings ( + firstname.value, this.firstnames[this.sNameBest[2]], false); + } + else + dists = new Array (); + + this.fNameBest = this.genAlternativesList (fNameAlt, dists); + this.updField (firstname, this.fNameBest, this.fNameAlt) + + if (this.person != null) + if (this.sNameBest[1] == 0 && this.fNameBest[1] == 0) + this.person.update ( + this.persons[this.sNameBest[2]][this.fNameBest[2]]); + else + this.person.reset (); + + return false; + } +} diff --git a/js/transPngBg.js b/js/transPngBg.js new file mode 100644 index 0000000..af73d3f --- /dev/null +++ b/js/transPngBg.js @@ -0,0 +1,81 @@ +function transPngBg (img, libUrl) +{ + this.img = img; + this.libUrl = libUrl; + + this.RGBtoHex = function (color) + { + color = color.replace (/^rgb\((.*)\)$/, '$1'); + color = color.replace (/ /g, '').split (','); + + return this.toHex (color[0]) + + this.toHex (color[1]) + + this.toHex(color[2]); + } + + this.toHex = function (N) + { + if (N == null) + return "00"; + + N = parseInt(N); + if (N == 0 || isNaN(N)) + return "00"; + + N = Math.max (0, N); + N = Math.min (N, 255); + N = Math.round(N); + + return "0123456789ABCDEF".charAt ((N-N % 16) / 16) + + "0123456789ABCDEF".charAt (N % 16); + } + + this.getImgUrl = function (posElement) + { + var cNames = posElement.className.split (' '); + var color = posElement.style.backgroundImage; + + // try to get the background color of the given element from class + // ---------------------------------------------------------------- + if (color == '') + { + var cName; + + for (var cN in cNames) + { + if (cNames[cN].indexOf ('bgc') != -1) + { + cName = cNames[cN]; + break; + } + } + + loop: for (var i=0; i 'assign() parameters not correct', + SAVANT2_ERROR_ASSIGNREF => 'assignRef() parameters not correct', + SAVANT2_ERROR_COMPILER => 'compiler not an object or has no compile() method', + SAVANT2_ERROR_NOFILTER => 'filter file not found', + SAVANT2_ERROR_NOPLUGIN => 'plugin file not found', + SAVANT2_ERROR_NOSCRIPT => 'compiled template script file not found', + SAVANT2_ERROR_NOTEMPLATE => 'template source file not found', + SAVANT2_ERROR_COMPILE_FAIL => 'template source failed to compile' + ); +} + +class Savant2_Error { + + var $code = null; + var $info = array(); + var $text = null; + var $backtrace = null; + + function Savant2_Error($conf = array()) + { + // set public properties + foreach ($conf as $key => $val) { + $this->$key = $val; + } + + // generate a backtrace + if (function_exists('debug_backtrace')) { + $this->backtrace = debug_backtrace(); + } + + // extended behaviors + $this->_genError(); + } + + function _genError() + { + } +} + + +/** +* +* This is totally based on Savent by Paul M. Jones . +* But is made much smaller... +*/ + +class SavantSmall { + + var $_error = null; + var $_escape = array('htmlspecialchars'); + var $_output = null; + + var $_path = array( + 'resource' => array(), + 'template' => array() + ); + + var $_restrict = false; + + var $_template = null; + + + // ----------------------------------------------------------------- + // + // Constructor and general property setters + // + // ----------------------------------------------------------------- + + + function __construct($conf = array()) + { + // set the default template search dirs + if (isset($conf['template_path'])) { + // user-defined dirs + $this->setPath('template', $conf['template_path']); + } else { + // default directory only + $this->setPath('template', null); + } + + // set the error class + if (isset($conf['error'])) { + $this->setError($conf['error']); + } + + // set the restrict flag + if (isset($conf['restrict'])) { + $this->setRestrict($conf['restrict']); + } + + // set the default template + if (isset($conf['template'])) { + $this->setTemplate($conf['template']); + } + + // set the output escaping callbacks + if (isset($config['escape'])) { + call_user_func_array( + array($this, 'setEscape'), + (array) $config['escape'] + ); + } + } + + function setError($error) + { + if (! $error) { + $this->_error = null; + } else { + $this->_error = $error; + } + } + + function setRestrict($flag = false) + { + if ($flag) { + $this->_restrict = true; + } else { + $this->_restrict = false; + } + } + + function setTemplate($template) + { + $this->_template = $template; + } + + + // ----------------------------------------------------------------- + // + // Output escaping and management. + // + // ----------------------------------------------------------------- + + function setEscape() + { + $this->_escape = func_get_args(); + } + + function addEscape() + { + $args = func_get_args(); + $this->_escape = array_merge($this->_escape, $args); + } + + function getEscape() + { + return $this->_escape; + } + + function escape($value) + { + // if value is not set return + if (! isset ($value)) + return $value; + + // were custom callbacks passed? + if (func_num_args() == 1) { + + // no, only a value was passed. + // loop through the predefined callbacks. + foreach ($this->_escape as $func) { + $value = call_user_func($func, $value); + } + + } else { + + // yes, use the custom callbacks instead. + $callbacks = func_get_args(); + + // drop $value + array_shift($callbacks); + + // loop through custom callbacks. + foreach ($callbacks as $func) { + $value = call_user_func($func, $value); + } + + } + + return $value; + } + + function eprint($value) + { + $args = func_get_args(); + echo call_user_func_array( + array($this, 'escape'), + $args + ); + } + + function _($value) + { + $args = func_get_args(); + return call_user_func_array( + array($this, 'eprint'), + $args + ); + } + + + + // ----------------------------------------------------------------- + // + // Path management and file finding + // + // ----------------------------------------------------------------- + + function setPath($type, $new) + { + // clear out the prior search dirs + $this->_path[$type] = array(); + + // convert from string to path + if (is_string($new) && ! strpos('://', $new)) { + // the search config is a string, and it's not a stream + // identifier (the "://" piece), add it as a path + // string. + $new = explode(PATH_SEPARATOR, $new); + } else { + // force to array + settype($new, 'array'); + } + + // always add the fallback directories as last resort + switch (strtolower($type)) { + case 'template': + $this->addPath($type, '.'); + break; + case 'resource': + $this->addPath($type, dirname(__FILE__) . '/Savant2/'); + break; + } + + // actually add the user-specified directories + foreach ($new as $dir) { + $this->addPath($type, $dir); + } + } + + function addPath($type, $dir) + { + // no surrounding spaces allowed! + $dir = trim($dir); + + // add trailing separators as needed + if (strpos($dir, '://') && substr($dir, -1) != '/') { + // stream + $dir .= '/'; + } elseif (substr($dir, -1) != DIRECTORY_SEPARATOR) { + // directory + $dir .= DIRECTORY_SEPARATOR; + } + + // add to the top of the search dirs + array_unshift($this->_path[$type], $dir); + } + + function getPath($type = null) + { + if (! $type) { + return $this->_path; + } else { + return $this->_path[$type]; + } + } + + function findFile($type, $file) + { + // get the set of paths + $set = $this->getPath($type); + + // start looping through them + foreach ($set as $path) { + + // get the path to the file + $fullname = $path . $file; + + // are we doing path checks? + if (! $this->_restrict) { + + // no. this is faster but less secure. + if (file_exists($fullname) && is_readable($fullname)) { + return $fullname; + } + + } else { + + // yes. this is slower, but attempts to restrict + // access only to defined paths. + + // is the path based on a stream? + if (strpos('://', $path) === false) { + // not a stream, so do a realpath() to avoid + // directory traversal attempts on the local file + // system. Suggested by Ian Eure, initially + // rejected, but then adopted when the secure + // compiler was added. + $path = realpath($path); // needed for substr() later + $fullname = realpath($fullname); + } + + // the substr() check added by Ian Eure to make sure + // that the realpath() results in a directory registered + // with Savant so that non-registered directores are not + // accessible via directory traversal attempts. + if (file_exists($fullname) && is_readable($fullname) && + substr($fullname, 0, strlen($path)) == $path) { + return $fullname; + } + } + } + + // could not find the file in the set of paths + return false; + } + + + // ----------------------------------------------------------------- + // + // Variable and reference assignment + // + // ----------------------------------------------------------------- + + function assign() + { + // this method is overloaded. + $arg = func_get_args(); + + // must have at least one argument. no error, just do nothing. + if (! isset($arg[0])) { + return; + } + + // assign by object + if (is_object($arg[0])) { + // assign public properties + foreach (get_object_vars($arg[0]) as $key => $val) { + if (substr($key, 0, 1) != '_') { + $this->$key = $val; + } + } + return; + } + + // assign by associative array + if (is_array($arg[0])) { + foreach ($arg[0] as $key => $val) { + if (substr($key, 0, 1) != '_') { + $this->$key = $val; + } + } + return; + } + + // assign by string name and mixed value. + // + // we use array_key_exists() instead of isset() becuase isset() + // fails if the value is set to null. + if (is_string($arg[0]) && + substr($arg[0], 0, 1) != '_' && + array_key_exists(1, $arg)) { + $this->$arg[0] = $arg[1]; + } else { + return $this->_genError(SAVANT2_ERROR_ASSIGN, $arg); + } + } + + function assignRef($key, &$val) + { + if (is_string($key) && substr($key, 0, 1) != '_') { + $this->$key =& $val; + } else { + return $this->_genError( + SAVANT2_ERROR_ASSIGNREF, + array('key' => $key, 'val' => $val) + ); + } + } + + function clear($var = null) + { + if (is_null($var)) { + // clear all variables + $var = array_keys(get_object_vars($this)); + } else { + // clear specific variables + settype($var, 'array'); + } + + // clear out the selected variables + foreach ($var as $name) { + if (substr($name, 0, 1) != '_' && isset($this->$name)) { + unset($this->$name); + } + } + } + + function getVars($key = null) + { + if (is_null($key)) { + $key = array_keys(get_object_vars($this)); + } + + if (is_array($key)) { + // return a series of vars + $tmp = array(); + foreach ($key as $var) { + if (substr($var, 0, 1) != '_' && isset($this->$var)) { + $tmp[$var] = $this->$var; + } + } + return $tmp; + } else { + // return a single var + if (substr($key, 0, 1) != '_' && isset($this->$key)) { + return $this->$key; + } + } + } + + + // ----------------------------------------------------------------- + // + // Template processing + // + // ----------------------------------------------------------------- + + function loadTemplate($tpl = null, $setScript = false) + { + // set to default template if none specified. + if (is_null($tpl)) { + $tpl = $this->_template; + } + + // find the template source. + $file = $this->findFile('template', $tpl); + if (! $file) { + return $this->_genError( + SAVANT2_ERROR_NOTEMPLATE, + array('template' => $tpl) + ); + } + + // no compiling requested, return the source path + $this->_script = $file; + return $file; + } + + function findTemplate($tpl = null) + { + return $this->loadTemplate($tpl, false); + } + + function fetch($_tpl = null) + { + // clear prior output + $this->_output = null; + + // load the template script + $_result = $this->loadTemplate($_tpl, true); + + // is there a template script to be processed? + if ($this->isError($_result)) { + return $_result; + } + + // unset so as not to introduce into template scope + unset($_tpl); + unset($_result); + + // never allow a 'this' property + if (isset($this->this)) { + unset($this->this); + } + + // start capturing output into a buffer + ob_start(); + + // include the requested template filename in the local scope + // (this will execute the view logic). + include $this->_script; + + // done with the requested template; get the buffer and + // clear it. + $this->_output = ob_get_contents(); + ob_end_clean(); + + // done! + return $this->_output; + } + + function display($tpl = null) + { + $result = $this->fetch($tpl); + if ($this->isError($result)) { + return $result; + } else { + echo $result; + } + } + + // ----------------------------------------------------------------- + // + // Error handling + // + // ----------------------------------------------------------------- + + function &_genError($code, $info = array()) + { + // the error config array + $conf = array( + 'code' => $code, + 'text' => 'Savant2: ', + 'info' => (array) $info + ); + + // set an error message from the globals + if (isset($GLOBALS['_SAVANT2']['error'][$code])) { + $conf['text'] .= $GLOBALS['_SAVANT2']['error'][$code]; + } else { + $conf['text'] .= '???'; + } + + // set up the error class name + if ($this->_error) { + $class = 'Savant2_Error_' . $this->_error; + } else { + $class = 'Savant2_Error'; + } + + // set up the error class file name + $file = $class . '.php'; + + // is it loaded? + if (! class_exists($class)) { + + // find the error class + $result = $this->findFile('resource', $file); + if (! $result) { + // could not find the custom error class, revert to + // Savant_Error base class. + $class = 'Savant2_Error'; + $result = dirname(__FILE__) . '/Savant2/Error.php'; + } + + // include the error class + include_once $result; + } + + // instantiate and return the error class + $err = new $class($conf); + return $err; + } + + function isError(&$obj) + { + if (is_object($obj)) { + if ($obj instanceof Savant2_Error || + is_subclass_of($obj, 'Savant2_Error')) { + return true; + } + } + + return false; + } +} +?> diff --git a/libs/c_mysqlDb.php b/libs/c_mysqlDb.php new file mode 100644 index 0000000..1c8707f --- /dev/null +++ b/libs/c_mysqlDb.php @@ -0,0 +1,226 @@ +query = $query; + } + + function __toString () + { + $retStr = "Fehler in Query: \n"; + $retStr .= $this->query . "\n\n"; + $retStr .= $this->message . "\n\n"; + $retStr .= 'Datei: ' . $this->file . "\n"; + $retStr .= 'Zeile: ' . $this->line . "\n\n"; + + if ($this->errContext != NULL) + { + $retStr .= "Fehler Context: \n"; + $retStr .= print_r ($this->errContext, TRUE) . "\n"; + } + + $retStr .= "Aufruf Stack: \n"; + $retStr .= $this->getTraceAsString () . "\n"; + + return $retStr; + } +} + +/*** + * This class depends on errException.php, as it does not handle any + * error at all, except it catches exceptions. + */ +class c_mysqlDb +{ + private $connectRes; + private $host; + private $user; + private $pass; + private $database; + + private $result = array (); + private $resCount = 0; + + private function getAllData ($resId, $method, $class = NULL, $parm = NULL) + { + $ret = array (); + + if (isset ($this->result[$resId]) && $this->result[$resId] != FALSE) + { + try + { + mysql_data_seek ($this->result[$resId], 0); + } + catch (Exception $e) + { + if ($e->getCode () != 2) + throw ($e); + // wenn der Fehlercode gleich 2 ist war das resultset nur leer + // und ich mache weiter. + } + + if ($class === NULL) + $row = $method ($this->result[$resId]); + else + $row = $method ($this->result[$resId], $class, $parm); + + while ($row != FALSE) + { + $ret[] = $row; + if ($class === NULL) + $row = $method ($this->result[$resId]); + else + $row = $method ($this->result[$resId], $class, $parm); + } + } + + return $ret; + } + + function __construct ($host, $user, $pass, $db) + { + /* init member */ + $this->host = $host; + $this->user = $user; + $this->pass = $pass; + $this->database = $db; + + /* connect and select db */ + $this->connectRes = mysql_pconnect ( + $this->host, + $this->user, + $this->pass); + mysql_select_db ($this->database); + mysql_query ('set character set utf8'); + } + + function __destruct () + { + /* close connection */ + mysql_close ($this->connectRes); + } + + function query ($query) + { + try + { + for ($i = 0; $i < $this->resCount; $i++) + if (! isset ($this->result[$i])) + break; + + if ($i == $this->resCount) + $i = $this->resCount = $this->resCount + 1; + + $this->result[$i] = mysql_query ($query); + + if ($this->result[$i] === FALSE) + throw new Exception (mysql_error (), mysql_errno ()); + + return $i; + } + catch (errException $e) + { + throw new mysqlQueryException ( + $e->getMessage (), + $e->getCode (), + $e->getFile (), + $e->getLine (), + $e->getErrContext (), + $query); + } + catch (Exception $e) + { + throw new mysqlQueryException ( + $e->getMessage (), + $e->getCode (), + $e->getFile (), + $e->getLine (), + NULL, + $query); + } + } + + function freeResult ($resId) + { + if (is_resource ($this->result[$resId])) + mysql_free_result ($this->result[$resId]); + unset ($this->result[$resId]); + } + + function resetResult ($resId) + { + mysql_data_seek ($this->result[$resId], 0); + } + + function getResult ($resId) + { + return $this->result[$resId]; + } + + function getAssoc ($resId) + { + return $this->getAllData ($resId, 'mysql_fetch_assoc'); + } + + function getArray ($resId) + { + return $this->getAllData ($resId, 'mysql_fetch_row'); + } + + function getObject ($resId, $class, $parm = NULL) + { + return $this->getAllData ($resId, 'mysql_fetch_object', $class, $parm); + } + + function rows ($resId) + { + return mysql_num_rows ($this->result[$resId]); + } + + function get ($resId, $row, $col) + { + if ($row > mysql_num_rows ($this->result[$resId])) + return NULL; + + mysql_data_seek ($this->result[$resId], $row); + + if (is_int ($col) && $col > mysql_num_fields ($this->result[$resId])) + return NULL; + + if (is_string ($col)) + { + $rowData = mysql_fetch_assoc ($this->result[$resId]); + + if (! array_key_exists ($col, $rowData)) + return NULL; + } + + return mysql_result ($this->result[$resId], $row, $col); + } + + // === einige nuetzlich Sachen ======================================== + function setLocale ($locale) + { + $resId = $this->query ('set @LANG=\'' . $locale . '\''); + $this->freeResult ($resId); + } +}; + +/* quote string (und pack ' herum) */ +function quoteS ($var) +{ + if ($var === NULL) + return 'NULL'; + + return "'" . addslashes ($var) . "'"; +} + +?> diff --git a/libs/c_person.php b/libs/c_person.php new file mode 100644 index 0000000..15bd789 --- /dev/null +++ b/libs/c_person.php @@ -0,0 +1,42 @@ +personId; } + function get_photographerId () { return $this->photographerId; } + function get_ownerId () { return $this->ownerId; } + function get_firstname () { return $this->firstname; } + function get_surname () { return $this->surname; } + function get_company () { return $this->company; } + function get_email () { return $this->email; } + function get_url () { return $this->url; } + function get_cameraId () { return $this->cameraId; } + function get_wmWidth () { return $this->wmWidth; } + function get_wmHeight () { return $this->wmHeight; } + function get_wmXPos () { return $this->wmXPos; } + function get_wmYPos () { return $this->wmYPos; } +}; + +?> diff --git a/libs/c_personAdmin.php b/libs/c_personAdmin.php new file mode 100644 index 0000000..b94f96a --- /dev/null +++ b/libs/c_personAdmin.php @@ -0,0 +1,114 @@ +dbHandle = new c_mysqlDb ( + self::DBHOST, self::DBUSER, self::DBPASS, self::DBNAME); + + if (is_string ($locale)) + $this->dbHandle->setLocale ($locale); + } + catch (Exception $e) + { + if ($this->dbHandle !== NULL) + unset ($this->dbHandle); + + print "
\n";
+			print "Konnte Datenbank nicht initialisieren!\n";
+			print $e;
+			print "
\n"; + exit (1); + } + + resetErrExceptionMapping (); + + $this->_persons = $this->getPersons (); + } + + function __destruct () + { + if (isset ($this->persons)) + unset ($this->persons); + + if ($this->dbHandle !== NULL) + unset ($this->dbHandle); + } + + private function getPersons () + { + $result = NULL; + + setErrExceptionMapping (); + try + { + $resId = $this->dbHandle->query ( + 'SELECT * from personsView ORDER BY surname, firstname'); + $_result = $this->dbHandle->getObject ( + $resId, 'c_person', array (NULL)); + $this->dbHandle->freeResult ($resId); + } + catch (Exception $e) + { + print "jokus
"; + if (isset ($_result)) + unset ($_result); + if (isset ($resId)) + $this->dbHandle->freeResult ($resId); + + print "
";
+			print $e;
+			print "
"; + } + resetErrExceptionMapping (); + + foreach ($_result as $res) + $result[$res->get_personId ()] = $res; + unset ($_result); + + return $result; + } + + function personSearch1 () + { + $names = array (); + + foreach ($this->_persons as $person) + $names[$person->get_surname ()][] = + array ($person->get_firstname (), $person); + + $this->assign ('names', $names); + + return $this->fetch ('personAdmin/personSearch1.tpl.php'); + } + + function personInUp () + { + return $this->fetch ('personAdmin/personInUp.tpl.php'); + } + + function show () + { + $this->assign ('personSearch1', $this->personSearch1 ()); + $this->assign ('personInUp', $this->personInUp ()); + + $this->display ('personAdmin/personAdmin.tpl.php'); + } +}; + +?> diff --git a/libs/c_picToolSavant.php b/libs/c_picToolSavant.php new file mode 100644 index 0000000..064f5cd --- /dev/null +++ b/libs/c_picToolSavant.php @@ -0,0 +1,27 @@ +addPath ('template', TPLDIR); + } + + function is_set($varname) + { + if ($this->getVars($varname)) + return true; + return false; + } +} + +?> diff --git a/libs/c_xmlify.php b/libs/c_xmlify.php new file mode 100644 index 0000000..fec102a --- /dev/null +++ b/libs/c_xmlify.php @@ -0,0 +1,249 @@ +isEmptyElement == TRUE) + return NULL; + + $ret = NULL; + + while ($xr->read () && + ! ($xr->nodeType == 15 && + $xr->name == 'variable')) + { + if ($xr->nodeType == 3 && $xr->hasValue == TRUE) + // der iconv is nur drin weil evolver ihre Seiten dummer weise + // als latin1 verschicken, aus der Datenbank aber utf-8 kommt. + $ret = iconv ("UTF-8", "ISO-8859-1", $xr->value); + } + + return $ret; +} + +function xmlToArray ($xr) +{ + $ret = array (); + + if ($xr->isEmptyElement == TRUE) + return $ret; + + while ($xr->read () && + ! ($xr->nodeType == 15 && + $xr->name == 'array')) + { + if ($xr->nodeType == 1 && + $xr->name == 'item') + { + $key = $xr->getAttribute ('key'); + + while ($xr->read () && + ! ($xr->nodeType == 15 && + $xr->name == 'item')) + { + if ($xr->nodeType == 1) + { + switch ($xr->name) + { + case 'variable': + $ret[$key] = xmlToVar ($xr); + $type = $xr->getAttribute ('type'); + settype ($ret[$key], $type); + break; + + case 'array': + $ret[$key] = xmlToArray ($xr); + break; + + case 'class': + $class = $xr->getAttribute ('class'); + $ret[$key] = new $class ($xr); + } + } + } + } + } + + return $ret; +} + +/* + * native vars to xml stream + */ +function varToXml ($xw, $name, $val) +{ + $xw->startElement ('variable'); + + if ($name !== NULL) + $xw->writeAttribute ('name', $name); + + $xw->writeAttribute ('type', gettype ($val)); + + $xw->text ($val); + + $xw->endElement (); +} + +function arrayToXml ($xw, $name, $arr) +{ + $xw->startElement ('array'); + + if ($name !== NULL) + $xw->writeAttribute ('name', $name); + + foreach ($arr as $key => $val) + { + $xw->startElement ('item'); + $xw->writeAttribute ('key', $key); + + if (is_array ($val)) + { + arrayToXml ($xw, NULL, $val); + } + else if (is_object ($val)) + { + if (in_array ('toXml', get_class_methods ($val)) == TRUE) + { + $val->toXml ($xw); + } + } + else + { + varToXml ($xw, NULL, $val); + } + + $xw->endElement (); + } + + $xw->endElement (); +} + +function xmlify ($val) +{ + $xw = new xmlWriter (); + $xw->openMemory (); + $xw->setIndent (TRUE); + $xw->startDocument ('1.0', 'UTF-8'); + + if (is_array ($val)) + { + arrayToXml ($xw, NULL, $val); + } + else if (is_object ($val)) + { + if (in_array ('toXml', get_class_methods ($val)) == TRUE) + { + $val->toXml ($xw); + } + } + else + { + varToXml ($xw, NULL, $val); + } + + $res = $xw->outputMemory(TRUE); + unset ($xw); + + return $res; +} + +function deXmlify ($xmldata) +{ + $ret = NULL; + +// print "
";
+//	var_dump (str_replace (
+//				array ("<", ">"), array ("<", ">") , $xmldata));
+//	print "
"; +// exit (1); + + $xr = new XMLReader (); + $xr->XML ($xmldata); + + $xr->read (); + + switch ($xr->name) + { + case 'variable': $ret = xmlToVar ($xr); break; + case 'array': $ret = xmlToArray ($xr); break; + case 'class': + $class = $xr->getAttribute ('class'); + $ret = new $class ($xr); + } + + $xr->close (); + + return $ret; +} + +class c_xmlify +{ + function __construct ($xr) + { + if ($xr->isEmptyElement == TRUE) + return; + + while ($xr->read () && + ! ($xr->nodeType == 15 && + $xr->name == 'class')) + { + if ($xr->nodeType == 1) + { + $name = $xr->getAttribute ('name'); + + switch ($xr->name) + { + case 'variable': + $this->$name = xmlToVar ($xr); + $type = $xr->getAttribute ('type'); + settype ($this->$name, $type); + break; + + case 'array': + $this->$name = xmlToArray ($xr); + break; + + case 'class': + $class = $xr->getAttribute ('class'); + $this->$name = new $class ($xr); + } + } + } + } + + function toXml ($xw, $name = NULL) + { + $xw->startElement ('class'); + + if ($name !== NULL) + $xw->writeAttribute ('name', $name); + + $xw->writeAttribute ('class', get_class ($this)); + + foreach (get_object_vars ($this) as $var => $val) + { + if (is_array ($val)) + { + arrayToXml ($xw, $var, $val); + continue; + } + + if (is_object ($val)) + { + if (in_array ('toXml', get_class_methods ($val)) == TRUE) + { + $val->toXml ($xw, $var); + } + continue; + } + + varToXml ($xw, $var, $val); + } + + $xw->endElement(); + } +}; + +?> diff --git a/libs/errException.php b/libs/errException.php new file mode 100644 index 0000000..7c11dda --- /dev/null +++ b/libs/errException.php @@ -0,0 +1,67 @@ +file = $file; + $this->line = $line; + $this->errContext = $context; + } + + function __toString () + { + $retStr = "Laufzeitfehler (" . $this->code . "): \n"; + $retStr .= $this->message . "\n\n"; + $retStr .= 'Datei: ' . $this->file . "\n"; + $retStr .= 'Zeile: ' . $this->line . "\n"; + + if ($this->errContext != NULL) + { + $retStr .= "Fehler Context: \n"; + $retStr .= print_r ($this->errContext, TRUE) . "\n"; + } + + $retStr .= "Aufruf Stack: \n"; + $retStr .= $this->getTraceAsString () . "\n"; + + return $retStr; + } + + function getErrContext () + { + return $this->errContext; + } +} + +function mapErrToExc ($no, $msg, $file, $line, $con) +{ + throw new errException ($msg, $no, $file, $line, $con); +} + +function setErrExceptionMapping () +{ + global $oldErrHandler; + + if ($oldErrHandler == NULL) + $oldErrHandler = set_error_handler ('mapErrToExc'); +} + +function resetErrExceptionMapping () +{ + global $oldErrHandler; + + if ($oldErrHandler != NULL) + { + set_error_handler ($oldErrHandler); + $oldErrHandler = NULL; + } +} + +?> diff --git a/libs/gd_bgMerge.php b/libs/gd_bgMerge.php new file mode 100644 index 0000000..7527ffc --- /dev/null +++ b/libs/gd_bgMerge.php @@ -0,0 +1,55 @@ + diff --git a/libs/initLocale.php b/libs/initLocale.php new file mode 100644 index 0000000..ee42175 --- /dev/null +++ b/libs/initLocale.php @@ -0,0 +1,62 @@ + $value) + { + foreach ($locales as $l) + { + if (isset ($key) && "" !== $key && strpos ($l, $key) !== FALSE) + { + $locale = $l; + break; + } + } + if ('C' !== $locale) break; + } + + $l = setlocale (LC_MESSAGES, $locale); + if ($l !== $locale) + { + $locale = 'C'; + setlocale (LC_MESSAGES, $locale); + } + setlocale (LC_TIME, $locale); + bindtextdomain ("bilder", LOCALEDIR); + bind_textdomain_codeset ("bilder", "UTF-8"); + textdomain ("bilder"); + +?> diff --git a/locale/de/LC_MESSAGES/bilder.mo b/locale/de/LC_MESSAGES/bilder.mo new file mode 100644 index 0000000..ee4d41e Binary files /dev/null and b/locale/de/LC_MESSAGES/bilder.mo differ diff --git a/po/de.po b/po/de.po new file mode 100644 index 0000000..a82d18c --- /dev/null +++ b/po/de.po @@ -0,0 +1,88 @@ +# German translations for PACKAGE package +# German messages for PACKAGE. +# Copyright (C) 2007 THE PACKAGE'S COPYRIGHT HOLDER +# This file is distributed under the same license as the PACKAGE package. +# , 2007. +# +msgid "" +msgstr "" +"Project-Id-Version: PACKAGE VERSION\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2007-10-08 03:09+0200\n" +"PO-Revision-Date: 2007-10-07 15:45+0200\n" +"Last-Translator: \n" +"Language-Team: German\n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" +"Plural-Forms: nplurals=2; plural=(n != 1);\n" + +#: templates/personAdmin/personSearch1.tpl.php:37 +msgid "search" +msgstr "Suche" + +#: templates/personAdmin/personSearch1.tpl.php:45 +#: templates/personAdmin/personInUp.tpl.php:86 +msgid "surname" +msgstr "Vorname" + +#: templates/personAdmin/personSearch1.tpl.php:56 +#: templates/personAdmin/personInUp.tpl.php:80 +msgid "firstname" +msgstr "Nachname" + +#: templates/personAdmin/personInUp.tpl.php:47 +msgid "update" +msgstr "aktualisieren" + +#: templates/personAdmin/personInUp.tpl.php:54 +msgid "insert" +msgstr "einfügen" + +#: templates/personAdmin/personInUp.tpl.php:57 +msgid "submit" +msgstr "abschicken" + +#: templates/personAdmin/personInUp.tpl.php:63 +msgid "personal data" +msgstr "Perönliche Daten" + +#: templates/personAdmin/personInUp.tpl.php:92 +msgid "company" +msgstr "Firma" + +#: templates/personAdmin/personInUp.tpl.php:98 +msgid "email" +msgstr "eMail" + +#: templates/personAdmin/personInUp.tpl.php:104 +msgid "url" +msgstr "Homepage" + +#: templates/personAdmin/personInUp.tpl.php:117 +msgid "photographer" +msgstr "Fotograf" + +#: templates/personAdmin/personInUp.tpl.php:124 +msgid "cameraId" +msgstr "Kamera ID" + +#: templates/personAdmin/personInUp.tpl.php:137 +msgid "owner" +msgstr "Besitzer" + +#: templates/personAdmin/personInUp.tpl.php:144 +msgid "watermark width" +msgstr "Wasserzeichen Breite" + +#: templates/personAdmin/personInUp.tpl.php:150 +msgid "watermark height" +msgstr "Wasserzeichen Höhe" + +#: templates/personAdmin/personInUp.tpl.php:156 +msgid "watermark xPos" +msgstr "Wasserzeichen X" + +#: templates/personAdmin/personInUp.tpl.php:162 +msgid "watermark yPos" +msgstr "Wasserzeichen Y" diff --git a/sql/create.sql b/sql/create.sql new file mode 100644 index 0000000..a0a1e7a --- /dev/null +++ b/sql/create.sql @@ -0,0 +1,1053 @@ +DROP DATABASE bilder_new; +DROP USER 'picadmin'@'localhost'; + +CREATE USER 'picadmin'@'localhost' IDENTIFIED BY '1Rz3ftb.'; + +--GRANT USAGE ON *.* TO 'picadmin'@ 'localhost' IDENTIFIED BY '********' WITH MAX_QUERIES_PER_HOUR 0 MAX_CONNECTIONS_PER_HOUR 0 MAX_UPDATES_PER_HOUR 0 MAX_USER_CONNECTIONS 0 ; + +CREATE DATABASE bilder_new CHARACTER SET utf8 DEFAULT COLLATE utf8_unicode_ci; +GRANT ALL PRIVILEGES ON bilder_new.* TO 'picadmin'@'localhost'; + +SET storage_engine=InnoDB; +USE bilder_new; + +CREATE TABLE language +( + languageId BIGINT UNSIGNED NOT NULL auto_increment, + languageCode VARCHAR(3) NOT NULL, + countryCode VARCHAR(2) NULL, + + PRIMARY KEY (languageId), + UNIQUE KEY (languageCode, countryCode) +); + +CREATE TABLE i18n +( + textId BIGINT UNSIGNED NOT NULL, + language BIGINT UNSIGNED NOT NULL, + text TEXT NOT NULL, + + PRIMARY KEY (textId, language), + CONSTRAINT FOREIGN KEY (language) + REFERENCES language (languageId) + ON UPDATE CASCADE + ON DELETE CASCADE +); + +CREATE TABLE watermark +( + watermarkId BIGINT UNSIGNED NOT NULL auto_increment, + width SMALLINT UNSIGNED NOT NULL, + height SMALLINT UNSIGNED NOT NULL, + xpos SMALLINT NOT NULL, + ypos SMALLINT NOT NULL, + + PRIMARY KEY (watermarkId) +); + +-- Das sollte noch aufgeteilt werden, eine Person kann ein Fotograph, der +-- Besitzer eines Bildes (Copyrighthalter) oder ein user des Bildertools sein. +CREATE TABLE person +( + personId BIGINT UNSIGNED NOT NULL auto_increment, + firstname VARCHAR(30) NULL, + surname VARCHAR(30) NULL, + company VARCHAR(30) NULL, + email VARCHAR(30) NULL, + url VARCHAR(30) NULL, + + PRIMARY KEY (personId), + UNIQUE KEY (firstname, surname) +); + +CREATE TABLE photographer +( + photographerId BIGINT UNSIGNED NOT NULL auto_increment, + personId BIGINT UNSIGNED NOT NULL, + cameraId BIGINT UNSIGNED NULL, + + PRIMARY KEY (photographerId), + UNIQUE KEY (personId), + CONSTRAINT FOREIGN KEY (personId) + REFERENCES person (personId) + ON UPDATE CASCADE + ON DELETE CASCADE +); + +CREATE TABLE owner +( + ownerId BIGINT UNSIGNED NOT NULL auto_increment, + personId BIGINT UNSIGNED NOT NULL, + watermarkId BIGINT UNSIGNED NULL, + + PRIMARY KEY (ownerId), + UNIQUE KEY (personId), + CONSTRAINT FOREIGN KEY (personId) + REFERENCES person (personId) + ON UPDATE CASCADE + ON DELETE CASCADE, + CONSTRAINT FOREIGN KEY (watermarkId) + REFERENCES watermark (watermarkId) + ON UPDATE CASCADE + ON DELETE SET NULL +); + +CREATE TABLE format +( + formatId BIGINT UNSIGNED NOT NULL auto_increment, + width SMALLINT UNSIGNED NOT NULL, + height SMALLINT UNSIGNED NOT NULL, + quality TINYINT UNSIGNED NOT NULL, + + PRIMARY KEY (formatId) +); + +CREATE TABLE picture +( + pictureId BIGINT UNSIGNED NOT NULL auto_increment, + title BIGINT UNSIGNED NULL, + photographerId BIGINT UNSIGNED NULL, + ownerId BIGINT UNSIGNED NULL, + origWidth SMALLINT UNSIGNED NOT NULL, + origHeight SMALLINT UNSIGNED NOT NULL, + trade ENUM('download', + 'buy') NOT NULL default 'download', + createDate TIMESTAMP NULL DEFAULT CURRENT_TIMESTAMP(), + `lock` BOOLEAN NOT NULL DEFAULT FALSE, + + PRIMARY KEY (pictureId), + CONSTRAINT FOREIGN KEY (title) + REFERENCES i18n (textId) + ON UPDATE CASCADE + ON DELETE SET NULL, + CONSTRAINT FOREIGN KEY (photographerId) + REFERENCES photographer (photographerId) + ON UPDATE CASCADE + ON DELETE SET NULL, + CONSTRAINT FOREIGN KEY (ownerId) + REFERENCES owner (ownerId) + ON UPDATE CASCADE + ON DELETE SET NULL +); + +CREATE TABLE pictureDetail +( + pictureId BIGINT UNSIGNED NOT NULL, + textId BIGINT UNSIGNED NOT NULL, + ident VARCHAR(30) NOT NULL DEFAULT "", + + PRIMARY KEY (pictureId, textId), + UNIQUE KEY (pictureId,ident), + CONSTRAINT FOREIGN KEY (pictureId) + REFERENCES picture (pictureId) + ON UPDATE CASCADE + ON DELETE CASCADE, + CONSTRAINT FOREIGN KEY (textId) + REFERENCES i18n (textId) + ON UPDATE CASCADE + ON DELETE CASCADE +); + +CREATE TABLE pictureLog +( + pictureId BIGINT UNSIGNED NOT NULL, + `date` DATE NOT NULL, + views BIGINT UNSIGNED NOT NULL DEFAULT 0, + downloads BIGINT UNSIGNED NOT NULL DEFAULT 0, + downlSize BIGINT UNSIGNED NOT NULL DEFAULT 0, + brokeDownl BIGINT UNSIGNED NOT NULL DEFAULT 0, + brokeSize BIGINT UNSIGNED NOT NULL DEFAULT 0, + + PRIMARY KEY (pictureId,`date`), + CONSTRAINT FOREIGN KEY (pictureId) + REFERENCES picture (pictureId) + ON UPDATE CASCADE + ON DELETE CASCADE +); + +CREATE TRIGGER picLogDateDefault_t +BEFORE INSERT ON pictureLog +FOR EACH ROW + SET NEW.`date` = CURDATE (); + +CREATE TABLE picture_format +( + pictureId BIGINT UNSIGNED NOT NULL, + formatId BIGINT UNSIGNED NOT NULL, + + PRIMARY KEY (pictureId,formatId), + CONSTRAINT FOREIGN KEY (pictureId) + REFERENCES picture (pictureId) + ON UPDATE CASCADE + ON DELETE CASCADE, + CONSTRAINT FOREIGN KEY (formatId) + REFERENCES format (formatId) + ON UPDATE CASCADE + ON DELETE CASCADE +); + +CREATE TABLE location +( + locationId BIGINT UNSIGNED NOT NULL auto_increment, + zip VARCHAR(5) NULL, + city VARCHAR(30) NULL, + street VARCHAR(30) NULL, + hno VARCHAR(5) NULL, + name VARCHAR(30) NULL, + + PRIMARY KEY (locationId), + UNIQUE KEY (zip,city,street,hno) +); + +CREATE TABLE section +( + sectionId BIGINT UNSIGNED NOT NULL auto_increment, + title BIGINT UNSIGNED NULL, + locationId BIGINT UNSIGNED NULL, + `lock` BOOLEAN NOT NULL DEFAULT FALSE, + + PRIMARY KEY (sectionId), + CONSTRAINT FOREIGN KEY (title) + REFERENCES i18n (textId) + ON UPDATE CASCADE + ON DELETE SET NULL, + CONSTRAINT FOREIGN KEY (locationId) + REFERENCES location (locationId) + ON UPDATE CASCADE + ON DELETE SET NULL +); + +CREATE TABLE sectionDetail +( + sectionId BIGINT UNSIGNED NOT NULL, + textId BIGINT UNSIGNED NOT NULL, + ident VARCHAR(30) NOT NULL DEFAULT "", + + PRIMARY KEY (sectionId, textId), + UNIQUE KEY (sectionId,ident), + CONSTRAINT FOREIGN KEY (sectionId) + REFERENCES section (sectionId) + ON UPDATE CASCADE + ON DELETE CASCADE, + CONSTRAINT FOREIGN KEY (textId) + REFERENCES i18n (textId) + ON UPDATE CASCADE + ON DELETE CASCADE +); + +CREATE TABLE picture_section +( + pictureId BIGINT UNSIGNED NOT NULL, + sectionId BIGINT UNSIGNED NOT NULL, + validFrom TIMESTAMP NULL, + validTo TIMESTAMP NULL, + prio SMALLINT UNSIGNED NOT NULL DEFAULT 0, + + PRIMARY KEY (pictureId,sectionId), + CONSTRAINT FOREIGN KEY (pictureId) + REFERENCES picture (pictureId) + ON UPDATE CASCADE + ON DELETE CASCADE, + CONSTRAINT FOREIGN KEY (sectionId) + REFERENCES section (sectionId) + ON UPDATE CASCADE + ON DELETE CASCADE +); + +CREATE PROCEDURE lockEmptySection (IN oldId BIGINT(20)) + UPDATE section SET `lock` = TRUE + WHERE + sectionId IN ( + SELECT sectionId + FROM picture_section + INNER JOIN picture USING (pictureId) + WHERE `lock` = FALSE + GROUP BY sectionId + HAVING + COUNT(*) = 1 AND + MAX(pictureId) = oldId); + +CREATE TRIGGER lockEmptySectionD_t +BEFORE DELETE ON picture +FOR EACH ROW + CALL lockEmptySection (OLD.pictureId); + +CREATE TRIGGER lockEmptySectionU_t +BEFORE UPDATE ON picture +FOR EACH ROW + CALL lockEmptySection (OLD.pictureId); + +CREATE TABLE gallery +( + galleryId BIGINT UNSIGNED NOT NULL auto_increment, + title BIGINT UNSIGNED NULL, + creator BIGINT UNSIGNED NOT NULL, + createDate TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP(), + `lock` BOOLEAN NOT NULL DEFAULT FALSE, + + PRIMARY KEY (galleryId), + UNIQUE KEY (creator,createDate), + CONSTRAINT FOREIGN KEY (title) + REFERENCES i18n (textId) + ON UPDATE CASCADE + ON DELETE SET NULL, + CONSTRAINT FOREIGN KEY (creator) + REFERENCES person (personId) + ON UPDATE CASCADE +); + +CREATE TABLE galleryDetail +( + galleryId BIGINT UNSIGNED NOT NULL, + textId BIGINT UNSIGNED NOT NULL, + ident VARCHAR(30) NOT NULL DEFAULT "", + + PRIMARY KEY (galleryId, textId), + UNIQUE KEY (galleryId,ident), + CONSTRAINT FOREIGN KEY (galleryId) + REFERENCES gallery (galleryId) + ON UPDATE CASCADE + ON DELETE CASCADE, + CONSTRAINT FOREIGN KEY (textId) + REFERENCES i18n (textId) + ON UPDATE CASCADE + ON DELETE CASCADE +); + +CREATE TABLE section_gallery +( + sectionId BIGINT UNSIGNED NOT NULL, + galleryId BIGINT UNSIGNED NOT NULL, + validFrom TIMESTAMP NULL, + validTo TIMESTAMP NULL, + prio SMALLINT UNSIGNED NOT NULL DEFAULT 0, + + PRIMARY KEY (sectionId,galleryId), + CONSTRAINT FOREIGN KEY (sectionId) + REFERENCES section (sectionId) + ON UPDATE CASCADE + ON DELETE CASCADE, + CONSTRAINT FOREIGN KEY (galleryId) + REFERENCES gallery (galleryId) + ON UPDATE CASCADE + ON DELETE CASCADE +); + +CREATE PROCEDURE lockEmptyGallery (IN oldId BIGINT(20)) + UPDATE gallery SET `lock` = TRUE + WHERE + galleryId IN ( + SELECT galleryId + FROM section_gallery + INNER JOIN section USING (sectionId) + WHERE `lock` = FALSE + GROUP BY galleryId + HAVING + COUNT(*) = 1 AND + MAX(sectionId) = oldId); + +CREATE TRIGGER lockEmptyGalleryD_t +BEFORE DELETE ON section +FOR EACH ROW + CALL lockEmptyGallery (OLD.sectionId); + +CREATE TRIGGER lockEmptyGalleryU_t +BEFORE UPDATE ON section +FOR EACH ROW + CALL lockEmptyGallery (OLD.sectionId); + +CREATE TABLE template +( + templateId BIGINT UNSIGNED NOT NULL auto_increment, + name VARCHAR(100) NOT NULL, + + PRIMARY KEY (templateId), + UNIQUE KEY (name) +); + +CREATE TABLE category +( + categoryId BIGINT UNSIGNED NOT NULL auto_increment, + title BIGINT UNSIGNED NULL, + templateId BIGINT UNSIGNED NOT NULL, + `lock` BOOLEAN NOT NULL DEFAULT FALSE, + + PRIMARY KEY (categoryId), + CONSTRAINT FOREIGN KEY (title) + REFERENCES i18n (textId) + ON UPDATE CASCADE + ON DELETE SET NULL, + CONSTRAINT FOREIGN KEY (templateId) + REFERENCES template (templateId) + ON UPDATE CASCADE +); + +CREATE TABLE categoryDetail +( + categoryId BIGINT UNSIGNED NOT NULL, + textId BIGINT UNSIGNED NOT NULL, + ident VARCHAR(30) NOT NULL DEFAULT "", + + PRIMARY KEY (categoryId, textId), + UNIQUE KEY (categoryId,ident), + CONSTRAINT FOREIGN KEY (categoryId) + REFERENCES category (categoryId) + ON UPDATE CASCADE + ON DELETE CASCADE, + CONSTRAINT FOREIGN KEY (textId) + REFERENCES i18n (textId) + ON UPDATE CASCADE + ON DELETE CASCADE +); + +CREATE TABLE gallery_category +( + galleryId BIGINT UNSIGNED NOT NULL, + categoryId BIGINT UNSIGNED NOT NULL, + validFrom TIMESTAMP NULL, + validTo TIMESTAMP NULL, + prio SMALLINT UNSIGNED NOT NULL DEFAULT 0, + + PRIMARY KEY (galleryId,categoryId), + CONSTRAINT FOREIGN KEY (galleryId) + REFERENCES gallery (galleryId) + ON UPDATE CASCADE + ON DELETE CASCADE, + CONSTRAINT FOREIGN KEY (categoryId) + REFERENCES category (categoryId) + ON UPDATE CASCADE + ON DELETE CASCADE +); + +CREATE TABLE subCategory +( + categoryId BIGINT UNSIGNED NOT NULL, + subId BIGINT UNSIGNED NOT NULL, + + PRIMARY KEY (categoryId,subId), + CONSTRAINT FOREIGN KEY (categoryId) + REFERENCES category (categoryId) + ON UPDATE CASCADE + ON DELETE CASCADE, + CONSTRAINT FOREIGN KEY (subId) + REFERENCES category (categoryId) + ON UPDATE CASCADE + ON DELETE CASCADE +); + +CREATE VIEW i18nView AS + SELECT + textId, languageCode, countryCode, text + FROM i18n _1 + INNER JOIN language ON language = languageId; + +DELIMITER // +CREATE FUNCTION gettextFunc (tId BIGINT(20)) +RETURNS TEXT +READS SQL DATA +COMMENT 'This function nees the Variable @LANG set to the current locale.' +BEGIN + DECLARE lText TEXT; + DECLARE lc VARCHAR(3); + DECLARE cc VARCHAR(2); + + SET lc = SUBSTRING(@LANG, 1, + CASE LOCATE('_', @LANG) + WHEN 0 THEN CHAR_LENGTH(@LANG) + ELSE LOCATE('_', @LANG)-1 + END); + SET lc = CASE WHEN lc IS NOT NULL THEN lc ELSE 'en' END; + + SET cc = SUBSTR(@LANG, + CASE LOCATE('_', @LANG) + WHEN 0 THEN NULL + ELSE LOCATE('_', @LANG)+1 + END); + + SELECT `text` INTO lText + FROM i18nView + WHERE + textId = tId AND + languageCode = lc AND + countryCode = cc; + IF lText IS NULL THEN + SELECT `text` INTO lText + FROM i18nView + WHERE + textId = tId AND + languageCode = lc AND + countryCode IS NULL; + END If; + IF lText IS NULL THEN + SELECT `text` INTO lText + FROM i18nView + WHERE + textId = tId AND + languageCode = 'en' AND + countryCode IS NULL ; + END If; + + RETURN lText; +END// +DELIMITER ; + +CREATE VIEW personsView AS + SELECT + personId, photographerId, ownerId, + firstname, surname, company, email, url, cameraId, + width AS wmWidth, height AS wmHeight, xpos AS wmXPos, ypos AS wmYPos + FROM person + LEFT JOIN photographer USING (personId) + LEFT JOIN owner USING (personId) + LEFT JOIN watermark USING (watermarkId); + +CREATE VIEW photographerView AS + SELECT + photographerId, + firstname AS pFirstname, surname AS pSurname, company AS pCompany, + email AS pEmail, url AS pUrl, cameraId + FROM photographer + LEFT JOIN person USING (personId); + +CREATE VIEW ownerView AS + SELECT + ownerId, + firstname AS oFirstname, surname AS oSurname, company AS oCompany, + email AS oEmail, url AS oUrl, + width AS wmWidth, height AS wmHeight, xpos AS wmXPos, ypos AS wmYPos + FROM owner + LEFT JOIN person USING (personId) + LEFT JOIN watermark USING (watermarkId); + +CREATE VIEW picturesView AS + SELECT + _1.pictureId, + gettextFunc(title) AS pTitle, + gettextFunc(textId) AS pDetails, ident AS pDetailIdent, + pFirstname, pSurname, pCompany, pEmail, pUrl, cameraId, + oFirstname, oSurname, oCompany, oEmail, oUrl, + wmWidth, wmHeight, wmXPos, wmYPos, + origWidth, origHeight, trade, createDate AS pCreateDate, + width, height, quality, + `date` AS vDate, views, downloads, downlSize, brokeDownl, brokeSize + FROM picture _1 + LEFT JOIN pictureDetail USING (pictureId) + LEFT JOIN photographerView USING (photographerId) + LEFT JOIN ownerView USING (ownerId) + LEFT JOIN pictureLog USING (pictureId) + INNER JOIN picture_format _2 ON + _1.pictureId = _2.pictureId AND + _1.`lock` = FALSE + INNER JOIN format USING (formatId); + +CREATE VIEW pictureCountsSumView AS + SELECT + pictureId, pTitle, pDetails, pDetailIdent, + pFirstname, pSurname, pCompany, pEmail, pUrl, cameraId, + oFirstname, oSurname, oCompany, oEmail, oUrl, + wmWidth, wmHeight, wmXPos, wmYPos, + origWidth, origHeight, trade, pCreateDate, width, height, quality, + CAST(SUM(views) AS UNSIGNED) AS views, + CAST(SUM(downloads) AS UNSIGNED) AS downloads, + CAST(SUM(downlSize) AS UNSIGNED) AS downlSize, + CAST(SUM(brokeDownl) AS UNSIGNED) AS brokeDownl, + CAST(SUM(brokeSize) AS UNSIGNED) AS brokeSize + FROM picturesView + GROUP BY + pictureId, pTitle, pDetails, pDetailIdent, + pCreateDate, origWidth, origHeight, trade, width, height, quality, + pFirstname, pSurname, pCompany, pEmail, pUrl, cameraId, + oFirstname, oSurname, oCompany, oEmail, oUrl, + wmWidth, wmHeight, wmXPos, wmYPos; + +CREATE VIEW sectionsView AS + SELECT + sectionId, gettextFunc(title) AS sTitle, + gettextFunc(_3.textId) AS sDetails, _3.ident AS sDetailIdent, + zip, city, street, hno + FROM section _1 + LEFT JOIN location _2 USING (locationId) + LEFT JOIN sectionDetail _3 USING (sectionId) + WHERE + _1.`lock` = FALSE; + +CREATE VIEW sectionPicturesView AS + SELECT + sectionId, sTitle, sDetails, sDetailIdent, + zip, city, street, hno, + pictureId, pTitle, pDetails, pDetailIdent, + pFirstname, pSurname, pCompany, pEmail, pUrl, cameraId, + oFirstname, oSurname, oCompany, oEmail, oUrl, + wmWidth, wmHeight, wmXPos, wmYPos, + origWidth, origHeight, trade, pCreateDate, width, height, quality, + vDate, views, downloads, downlSize, brokeDownl, brokeSize + FROM sectionsView + INNER JOIN picture_section USING (sectionId) + INNER JOIN picturesView USING (pictureId); + +CREATE VIEW sectionCountsView AS + SELECT + sectionId, sTitle, sDetails, sDetailIdent, + zip, city, street, hno, vDate, + CAST(SUM(views) AS UNSIGNED) AS views, + CAST(SUM(downloads) AS UNSIGNED) AS downloads, + CAST(SUM(downlSize) AS UNSIGNED) AS downlSize, + CAST(SUM(brokeDownl) AS UNSIGNED) AS brokeDownl, + CAST(SUM(brokeSize) AS UNSIGNED) AS brokeSize + FROM sectionPicturesView + GROUP BY + sectionId, sTitle, sDetails, sDetailIdent, + zip, city, street, hno, vDate; + +CREATE VIEW sectionCountsSumView AS + SELECT + sectionId, sTitle, sDetails, sDetailIdent, + zip, city, street, hno, + CAST(SUM(views) AS UNSIGNED) AS views, + CAST(SUM(downloads) AS UNSIGNED) AS downloads, + CAST(SUM(downlSize) AS UNSIGNED) AS downlSize, + CAST(SUM(brokeDownl) AS UNSIGNED) AS brokeDownl, + CAST(SUM(brokeSize) AS UNSIGNED) AS brokeSize + FROM sectionPicturesView + GROUP BY + sectionId, sTitle, sDetails, sDetailIdent, + zip, city, street, hno; + +CREATE VIEW galleriesView AS + SELECT + galleryId, + gettextFunc(title) AS gTitle, + gettextFunc(_4.textId) AS gDetails, _4.ident AS gDetailIdent, + createDate AS sCreateDate, + creator, firstname AS cFirstname, surname AS cSurname, + company AS cCompany, email AS cEmail, url AS cUrl + FROM gallery _1 + INNER JOIN person _2 ON + _1.creator = _2.personId AND + _1.`lock` = FALSE + LEFT JOIN galleryDetail _4 USING (galleryId); + +CREATE VIEW galleryPicturesView AS + SELECT + galleryId, gTitle, gDetails, gDetailIdent, + sCreateDate, creator, cFirstname, cSurname, cCompany, cEmail, cUrl, + sectionId, sTitle, sDetails, sDetailIdent, + zip, city, street, hno, + pictureId, pTitle, pDetails, pDetailIdent, + pFirstname, pSurname, pCompany, pEmail, pUrl, cameraId, + oFirstname, oSurname, oCompany, oEmail, oUrl, + wmWidth, wmHeight, wmXPos, wmYPos, + origWidth, origHeight, trade, pCreateDate, width, height, quality, + vDate, views, downloads, downlSize, brokeDownl, brokeSize + FROM galleriesView _1 + INNER JOIN section_gallery _2 USING (galleryId) + INNER JOIN sectionPicturesView _3 USING (sectionId); + +CREATE VIEW galleryCountsView AS + SELECT + galleryId, gTitle, gDetails, gDetailIdent, sCreateDate, + creator, cFirstname, cSurname, cCompany, cEmail, cUrl, vDate, + CAST(SUM(views) AS UNSIGNED) AS views, + CAST(SUM(downloads) AS UNSIGNED) AS downloads, + CAST(SUM(downlSize) AS UNSIGNED) AS downlSize, + CAST(SUM(brokeDownl) AS UNSIGNED) AS brokeDownl, + CAST(SUM(brokeSize) AS UNSIGNED) AS brokeSize + FROM galleryPicturesView + GROUP BY + galleryId, gTitle, gDetails, gDetailIdent, sCreateDate, + creator, cFirstname, cSurname, cCompany, cEmail, cUrl, vDate; + +CREATE VIEW galleryCountsSumView AS + SELECT + galleryId, gTitle, gDetails, gDetailIdent, sCreateDate, + creator, cFirstname, cSurname, cCompany, cEmail, cUrl, + CAST(SUM(views) AS UNSIGNED) AS views, + CAST(SUM(downloads) AS UNSIGNED) AS downloads, + CAST(SUM(downlSize) AS UNSIGNED) AS downlSize, + CAST(SUM(brokeDownl) AS UNSIGNED) AS brokeDownl, + CAST(SUM(brokeSize) AS UNSIGNED) AS brokeSize + FROM galleryPicturesView + GROUP BY + galleryId, gTitle, gDetails, gDetailIdent, sCreateDate, + creator, cFirstname, cSurname, cCompany, cEmail, cUrl; + +CREATE VIEW gallerySectionsView AS + SELECT + galleryId, gTitle, gDetails, gDetailIdent, + sCreateDate, creator, cFirstname, cSurname, cCompany, cEmail, cUrl, + sectionId, sTitle, sDetails, sDetailIdent, + zip, city, street, hno + FROM galleriesView _1 + INNER JOIN section_gallery _2 USING (galleryId) + INNER JOIN sectionsView _3 USING (sectionId); + +CREATE VIEW categoriesView AS + SELECT + categoryId, + gettextFunc(title) AS cTitle, + gettextFunc(_5.textId) AS cDetails, _5.ident AS cDetailIdent, + _2.templateId, _2.name AS templateName, + _4.subId + FROM category _1 + INNER JOIN template _2 ON + _1.templateId = _2.templateId AND + _1.`lock` = FALSE + LEFT JOIN categoryDetail _5 USING (categoryId) + LEFT JOIN subCategory _4 USING (categoryId); + +CREATE VIEW catPicturesView AS + SELECT + categoryId, cTitle, cDetails, cDetailIdent, + templateId, templateName, subId, + galleryId, gTitle, gDetails, gDetailIdent, + sCreateDate, creator, cFirstname, cSurname, cCompany, cEmail, cUrl, + sectionId, sTitle, sDetails, sDetailIdent, + zip, city, street, hno, + pictureId, pTitle, pDetails, pDetailIdent, + origWidth, origHeight, trade, pCreateDate, width, height, quality, + pFirstname, pSurname, pCompany, pEmail, pUrl, cameraId, + oFirstname, oSurname, oCompany, oEmail, oUrl, + wmWidth, wmHeight, wmXPos, wmYPos, + vDate, views, downloads, downlSize, brokeDownl, brokeSize + FROM categoriesView + INNER JOIN gallery_category USING (categoryId) + INNER JOIN galleryPicturesView USING (galleryId); + +CREATE VIEW categoryCountsView AS + SELECT + categoryId, cTitle, cDetails, cDetailIdent, + templateId, templateName, subId, vDate, + CAST(SUM(views) AS UNSIGNED) AS views, + CAST(SUM(downloads) AS UNSIGNED) AS downloads, + CAST(SUM(downlSize) AS UNSIGNED) AS downlSize, + CAST(SUM(brokeDownl) AS UNSIGNED) AS brokeDownl, + CAST(SUM(brokeSize) AS UNSIGNED) AS brokeSize + FROM catPicturesView + GROUP BY + categoryId, cTitle, cDetails, cDetailIdent, + templateId, templateName, subId, vDate; + +CREATE VIEW categoryCountsSumView AS + SELECT + categoryId, cTitle, cDetails, cDetailIdent, + templateId, templateName, subId, + CAST(SUM(views) AS UNSIGNED) AS views, + CAST(SUM(downloads) AS UNSIGNED) AS downloads, + CAST(SUM(downlSize) AS UNSIGNED) AS downlSize, + CAST(SUM(brokeDownl) AS UNSIGNED) AS brokeDownl, + CAST(SUM(brokeSize) AS UNSIGNED) AS brokeSize + FROM catPicturesView + GROUP BY + categoryId, cTitle, cDetails, cDetailIdent, + templateId, templateName, subId; + +CREATE VIEW catSectionsView AS + SELECT + categoryId, cTitle, cDetails, cDetailIdent, + templateId, templateName, subId, + galleryId, gTitle, gDetails, gDetailIdent, + sCreateDate, creator, cFirstname, cSurname, cCompany, cEmail, cUrl, + sectionId, sTitle, sDetails, sDetailIdent, + zip, city, street, hno + FROM categoriesView + INNER JOIN gallery_category USING (categoryId) + INNER JOIN gallerySectionsView USING (galleryId); + +CREATE VIEW catGalleriesView AS + SELECT + categoryId, cTitle, cDetails, cDetailIdent, + templateId, templateName, subId, + galleryId, gTitle, gDetails, gDetailIdent, + sCreateDate, creator, cFirstname, cSurname, cCompany, cEmail, cUrl + FROM categoriesView + INNER JOIN gallery_category USING (categoryId) + INNER JOIN galleriesView USING (galleryId); + +DELIMITER // +CREATE PROCEDURE updateOwner (IN pid BIGINT, + IN _width SMALLINT UNSIGNED, IN _height SMALLINT UNSIGNED, + IN _xpos SMALLINT, IN _ypos SMALLINT) +BEGIN + DECLARE wid, oid BIGINT DEFAULT NULL; + + IF _width IS NOT NULL AND _height IS NOT NULL AND + _xpos IS NOT NULL AND _ypos IS NOT NULL + THEN + SELECT ownerId, watermarkId INTO oid, wid + FROM owner + WHERE personId = pid; + + IF oid IS NULL + THEN + SELECT watermarkId INTO wid + FROM watermark + WHERE + height = _height AND + width = _width AND + xpos = _xpos AND + ypos = _ypos; + + IF wid IS NULL + THEN + INSERT INTO watermark (width, height, xpos, ypos) + VALUES (_width, _height, _xpos, _ypos); + SELECT LAST_INSERT_ID() INTO wid; + END IF; + + INSERT INTO owner (personId, watermarkId) + VALUES (pid, wid); + ELSE + IF wid IS NULL + THEN + INSERT INTO watermark (width, height, xpos, ypos) + VALUES (_width, _height, _xpos, _ypos); + SELECT LAST_INSERT_ID() INTO wid; + ELSE + UPDATE watermark + SET + width = _width, + height = _height, + xpos = _xpos, + ypos = _ypos + WHERE watermarkId = wid; + END IF; + + UPDATE owner + SET watermarkId = wid + WHERE ownerId = oid; + END IF; + END IF; + + SELECT oid, wid; +END// +DELIMITER ; + +DELIMITER // +CREATE PROCEDURE updatePhotographer (IN pid BIGINT, IN _camId BIGINT) +BEGIN + DECLARE phid BIGINT DEFAULT NULL; + + IF _camId IS NOT NULL + THEN + SELECT photographerId INTO phid + FROM photographer + WHERE personId = pid; + + IF phid IS NULL + THEN + INSERT INTO photographer (personId, cameraId) + VALUES (pid, _camId); + SELECT LAST_INSERT_ID() INTO phid; + ELSE + UPDATE photographer + SET cameraId = _camId + WHERE photographerId = phid; + END IF; + END IF; + + SELECT phid; +END// +DELIMITER ; + +DELIMITER // +CREATE PROCEDURE updatePerson (IN _firstname VARCHAR(30), + IN _surname VARCHAR(30), IN _company VARCHAR(30), IN _email VARCHAR(30), + IN _url VARCHAR(30), IN _camId BIGINT, + IN _width SMALLINT UNSIGNED, IN _height SMALLINT UNSIGNED, + IN _xpos SMALLINT, IN _ypos SMALLINT) +BEGIN + DECLARE pid BIGINT DEFAULT NULL; + + IF _firstname IS NOT NULL AND _surname IS NOT NULL + THEN + SELECT personId INTO pid + FROM person + WHERE + UPPER(firstname) = UPPER(_firstname) AND + UPPER(surname) = UPPER(_surname); + + IF pid IS NOT NULL + THEN + UPDATE person + SET + firstname = _firstname, + surname = _surname, + company = _company, + email = _email, + url = _url + WHERE + personId = pid; + ELSE + INSERT INTO person (firstname, surname, company, email, url) + VALUES (_firstname, _surname, _company, _email, _url); + SELECT LAST_INSERT_ID() INTO pid; + END IF; + + CALL updateOwner (pid, _width, _height, _xpos, _ypos); + CALL updatePhotographer (pid, _camId); + END IF; + + SELECT pid; +END// +DELIMITER ; + +INSERT INTO language + (languageCode, countryCode) +VALUES + ('de', NULL), + ('de', 'DE'), + ('en', NULL), + ('en', 'GB'), + ('en', 'US'); + +INSERT INTO person + (firstname, surname) +VALUES + ('Elisabeth', 'Steffers'), + ('Mechtild', 'Steffers'), + ('Wilhelm', 'Steffers'), + ('Markus', 'Engbers'), + ('Jens', 'Rautenberg'), + ('Achim', 'Krämer'), + ('Lambert', 'Herrgesell'), + ('Jochen', 'Bilek'), + ('Holger', 'Böking'), + ('Torsten', 'Böking'), + ('Georg', 'Steffers'), + ('Donald', 'von Entenhausen'), + ('Dagobert', 'von Entenhausen'); + +INSERT INTO watermark + (width, height, xpos, ypos) +VALUES + (22, 22, -5, -5); + +INSERT INTO photographer + (personId, cameraId) +VALUES + (2, 3); + +INSERT INTO owner + (personId, watermarkId) +VALUES + (1, 1), + (2, 1); + +INSERT INTO i18n + (textId, language, text) +VALUES + (1, 1, 'Das erste Bild'), + (1, 2, 'Das erste Bild'), + (1, 3, 'The first picture'), + (2, 1, 'Der erste Testeintrag in der DB'), + (2, 2, 'Der erste Testeintrag in der DB'), + (2, 3, 'The first testentry in the DB'), + (3, 1, 'Pictures von Zuhause'), + (3, 2, 'Pictures von Zuhause'), + (3, 3, 'Pictures from home'), + (4, 1, 'So wohn ich nunmal und basta.'), + (4, 2, 'So wohn ich nunmal und basta.'), + (4, 3, 'That\'s the way i live. End of story.'), + (5, 1, 'Daheim'), + (5, 3, 'Home'), + (6, 1, 'Diese Sektion zeigt mein Zuhause'), + (6, 3, 'This section shows my home'), + (7, 1, 'dummy'), + (7, 3, 'dummy'), + (8, 1, 'Eine Dummy-Sektion'), + (8, 3, 'A dummy-section'), + (9, 1, 'Galerie 1'), + (9, 3, 'Gallery 1'), + (10, 1, 'Die erste Galerie'), + (10, 3, 'The first gallery'), + (11, 1, 'Kategorie 1'), + (11, 3, 'Category 1'), + (12, 1, 'Die erste Kategorie'), + (12, 3, 'The first category'); + +INSERT INTO format + (width, height, quality) +VALUES + (1024, 768, 100), + (800, 600, 100); + +INSERT INTO picture + (title, photographerId, ownerId, origWidth, origHeight) +VALUES + (1, 1, 2, 2835, 1212), + (3, 1, 1, 2135, 1100), + (1, 1, 2, 1024, 915); + +INSERT INTO pictureDetail + (pictureId, textId) +VALUES + (1, 2), + (2, 4), + (3, 2); + +INSERT INTO picture_format + (pictureId, formatId) +VALUES + (1, 1), + (1, 2), + (2, 1), + (3, 1); + +INSERT INTO location + (zip, city, street, hno, name) +VALUES + ('48145', 'Münster', 'Warendorfer Str.', '75', 'Daheim'); + +INSERT INTO section + (title, locationId) +VALUES + (5, 1), + (7, 1); + +INSERT INTO sectionDetail + (sectionId, textId) +VALUES + (1, 6), + (2, 8); + +INSERT INTO picture_section + (pictureId, sectionId, prio) +VALUES + (1, 1, 1), + (2, 1, 1), + (1, 2, 1); + +INSERT INTO gallery + (title, creator) +VALUES + (9, 1); + +INSERT INTO galleryDetail + (galleryId, textId) +VALUES + (1, 10); + +INSERT INTO section_gallery + (sectionId, galleryId, prio) +VALUES + (1, 1, 1); + +INSERT INTO template + (templateId, name) +VALUES + (1, 'Template 1'); + +INSERT INTO category + (title, templateId) +VALUES + (11, 1); + +INSERT INTO categoryDetail + (categoryId, textId) +VALUES + (1, 12); + +INSERT INTO gallery_category + (galleryId, categoryId, prio) +VALUES + (1, 1, 1); diff --git a/templates/personAdmin/personAdmin.tpl.php b/templates/personAdmin/personAdmin.tpl.php new file mode 100644 index 0000000..ac45ec6 --- /dev/null +++ b/templates/personAdmin/personAdmin.tpl.php @@ -0,0 +1,43 @@ + + + + Nur zum testen + + + + + + + + + + + + + + + + + +
+ personSearch1?> +
 
+ personInUp?> +
+ + diff --git a/templates/personAdmin/personInUp.tpl.php b/templates/personAdmin/personInUp.tpl.php new file mode 100644 index 0000000..bdf8424 --- /dev/null +++ b/templates/personAdmin/personInUp.tpl.php @@ -0,0 +1,173 @@ + + +
+
+
+ + + + + + + +
+ +    + + + +
+
+
+
+ +
+
+
+ +
+
+ +
+
+ +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+ + +
+
+
+ +
+
+ + +
+ +
+ +
+
+ + +
+ +
+
+
+ + diff --git a/templates/personAdmin/personSearch1.tpl.php b/templates/personAdmin/personSearch1.tpl.php new file mode 100644 index 0000000..eabd432 --- /dev/null +++ b/templates/personAdmin/personSearch1.tpl.php @@ -0,0 +1,65 @@ + + +
+
+
+
+ +
+
+
+ + +
+
    +
+
+
+ + +
+
    +
+
+
+
+
+