tigermouse-svn Mailing List for Tigermouse - AJAX framework for PHP (Page 6)
Status: Alpha
Brought to you by:
strongier
You can subscribe to this list here.
2007 |
Jan
|
Feb
|
Mar
(10) |
Apr
(11) |
May
(24) |
Jun
(15) |
Jul
(3) |
Aug
(10) |
Sep
(9) |
Oct
(18) |
Nov
(12) |
Dec
(3) |
---|---|---|---|---|---|---|---|---|---|---|---|---|
2008 |
Jan
(12) |
Feb
(4) |
Mar
(3) |
Apr
(9) |
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
2009 |
Jan
|
Feb
(1) |
Mar
(5) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
From: <str...@us...> - 2007-05-07 10:48:40
|
Revision: 92 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=92&view=rev Author: strongier Date: 2007-05-07 03:48:36 -0700 (Mon, 07 May 2007) Log Message: ----------- Base64 done different way, SessionResetFilter fix Modified Paths: -------------- filters/SessionResetFilter.class.php index.php view/core-views/ValueReadableView.class.php view/core-views/ValueReadableView.js Modified: filters/SessionResetFilter.class.php =================================================================== --- filters/SessionResetFilter.class.php 2007-05-06 22:13:28 UTC (rev 91) +++ filters/SessionResetFilter.class.php 2007-05-07 10:48:36 UTC (rev 92) @@ -4,8 +4,8 @@ - public function preProcess(HTTPRequest $request) { - if (isset($_GET['r'])) { + public function preProcess(HTTPRequest $request, HTTPResponse $response) { + if (array_key_exists('r', $_GET)) { session_destroy(); session_start(); } @@ -13,7 +13,7 @@ - public function postProcess(HTTPResponse $response) { + public function postProcess(HTTPRequest $request, HTTPResponse $response) { } Modified: index.php =================================================================== --- index.php 2007-05-06 22:13:28 UTC (rev 91) +++ index.php 2007-05-07 10:48:36 UTC (rev 92) @@ -11,6 +11,9 @@ $fc = new FrontCtrl(); +require 'filters/SessionResetFilter.class.php'; +$fc->addFilter(new SessionResetFilter()); + require 'filters/RequestSetupFilter.class.php'; $fc->addFilter(new RequestSetupFilter('MainCtrl/show')); Modified: view/core-views/ValueReadableView.class.php =================================================================== --- view/core-views/ValueReadableView.class.php 2007-05-06 22:13:28 UTC (rev 91) +++ view/core-views/ValueReadableView.class.php 2007-05-07 10:48:36 UTC (rev 92) @@ -12,7 +12,7 @@ public function valueReader() { - return "ValueReadableView.getValue('{$this->id}')"; + return "Base64.encode(ValueReadableView.getValue('{$this->id}'))"; } Modified: view/core-views/ValueReadableView.js =================================================================== --- view/core-views/ValueReadableView.js 2007-05-06 22:13:28 UTC (rev 91) +++ view/core-views/ValueReadableView.js 2007-05-07 10:48:36 UTC (rev 92) @@ -1,7 +1,7 @@ ValueReadableView = { getValue: function(id) { - return Base64.encode(document.getElementById(id).value); + return document.getElementById(id).value; }, errorMessage: function(id, message) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-05-06 22:13:28
|
Revision: 91 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=91&view=rev Author: strongier Date: 2007-05-06 15:13:28 -0700 (Sun, 06 May 2007) Log Message: ----------- Events are now serialized with __toString(), sanity check in ValueReadableView valueReader javascript Modified Paths: -------------- lib/events/Action.class.php lib/events/ActionAggregate.class.php lib/events/Behaviour.class.php lib/events/EventSerializer.class.php lib/events/HotKey.class.php lib/events/IActionAdapter.interface.php lib/events/Listener.class.php lib/model/active-record/ManyToManyRelation.class.php view/core-views/ValueReadableView.js Modified: lib/events/Action.class.php =================================================================== --- lib/events/Action.class.php 2007-05-06 18:07:12 UTC (rev 90) +++ lib/events/Action.class.php 2007-05-06 22:13:28 UTC (rev 91) @@ -6,7 +6,7 @@ * Produces a Javascript code that calls controller on event occurence.. * * @author Michal Slaby - * @version DR1.4 + * @version DR1.4.2-20070506 */ class Action implements IActionAdapter { @@ -24,7 +24,7 @@ - public function serialize() { + public function __toString() { $a = implode(', ', $this->args); return "call('{$this->actionString}', [$a]);"; } Modified: lib/events/ActionAggregate.class.php =================================================================== --- lib/events/ActionAggregate.class.php 2007-05-06 18:07:12 UTC (rev 90) +++ lib/events/ActionAggregate.class.php 2007-05-06 22:13:28 UTC (rev 91) @@ -14,10 +14,10 @@ - public function serialize() { + public function __toString() { $out = ''; foreach ($this->adapters() as $adapter) - $out .= $adapter->serialize() . ';'; + $out .= $adapter->__toString() . ';'; return $out; } Modified: lib/events/Behaviour.class.php =================================================================== --- lib/events/Behaviour.class.php 2007-05-06 18:07:12 UTC (rev 90) +++ lib/events/Behaviour.class.php 2007-05-06 22:13:28 UTC (rev 91) @@ -28,7 +28,7 @@ - public function serialize() { + public function __toString() { return $this->js; } Modified: lib/events/EventSerializer.class.php =================================================================== --- lib/events/EventSerializer.class.php 2007-05-06 18:07:12 UTC (rev 90) +++ lib/events/EventSerializer.class.php 2007-05-06 22:13:28 UTC (rev 91) @@ -7,7 +7,7 @@ * and outputs serialized action for each event. Returns serialized output for one or all events. * * @author Michal Slaby - * @version DR1.4 + * @version DR1.4.2-20070506 */ class EventSerializer { Modified: lib/events/HotKey.class.php =================================================================== --- lib/events/HotKey.class.php 2007-05-06 18:07:12 UTC (rev 90) +++ lib/events/HotKey.class.php 2007-05-06 22:13:28 UTC (rev 91) @@ -6,7 +6,7 @@ public static function register(IActionAdapter $a, $key, $modifier = null) { $response = HTTPResponse::getInstance(); - $response->HotKey->register($key, $modifier, $a->serialize()); + $response->HotKey->register($key, $modifier, $a->__toString()); } Modified: lib/events/IActionAdapter.interface.php =================================================================== --- lib/events/IActionAdapter.interface.php 2007-05-06 18:07:12 UTC (rev 90) +++ lib/events/IActionAdapter.interface.php 2007-05-06 22:13:28 UTC (rev 91) @@ -9,7 +9,7 @@ * * @return string */ - public function serialize(); + public function __toString(); Modified: lib/events/Listener.class.php =================================================================== --- lib/events/Listener.class.php 2007-05-06 18:07:12 UTC (rev 90) +++ lib/events/Listener.class.php 2007-05-06 22:13:28 UTC (rev 91) @@ -7,7 +7,7 @@ * When event occurs executes defined IActionAdapter. * * @author Michal Slaby - * @version DR1.4 + * @version DR1.4.2-20070506 */ abstract class Listener { @@ -24,7 +24,7 @@ * * @param IActionAdapter $adapter, default NULL */ - public function __construct(IActionAdapter $adapter = NULL) { + public function __construct(IActionAdapter $adapter = null) { $this->adapter = $adapter; } @@ -72,7 +72,7 @@ * @return string */ public function getSerializedAction() { - return $this->adapter ? $this->adapter->serialize() : ''; + return $this->adapter ? $this->adapter->__toString() : ''; } Modified: lib/model/active-record/ManyToManyRelation.class.php =================================================================== --- lib/model/active-record/ManyToManyRelation.class.php 2007-05-06 18:07:12 UTC (rev 90) +++ lib/model/active-record/ManyToManyRelation.class.php 2007-05-06 22:13:28 UTC (rev 91) @@ -41,7 +41,7 @@ public function getIterator() { - $items = new ArrayObject; + $items = new ArrayObject(); if (!$this->subject->getPrimaryKeyValue()) { $this->subject->save(); } Modified: view/core-views/ValueReadableView.js =================================================================== --- view/core-views/ValueReadableView.js 2007-05-06 18:07:12 UTC (rev 90) +++ view/core-views/ValueReadableView.js 2007-05-06 22:13:28 UTC (rev 91) @@ -6,17 +6,21 @@ errorMessage: function(id, message) { var e = document.getElementById(id); - e.style.backgroundColor = Palette.ERROR_BG; - e.onmouseover = function() { overlib('<div class="Tooltip"><div>' + message + '</div></div>', ABOVE, SNAPX, 2, SNAPY, 2, FULLHTML); }; - e.onmouseout = function() { nd(); }; + if (e != undefined) { + e.style.backgroundColor = Palette.ERROR_BG; + e.onmouseover = function() { overlib('<div class="Tooltip"><div>' + message + '</div></div>', ABOVE, SNAPX, 2, SNAPY, 2, FULLHTML); }; + e.onmouseout = function() { nd(); }; + } }, clearError: function(id) { nd(); var e = document.getElementById(id); - e.style.backgroundColor = Palette.TEXT_BG; - e.onmouseover = null; - e.onmouseout = null; + if (e != undefined) { + e.style.backgroundColor = Palette.TEXT_BG; + e.onmouseover = null; + e.onmouseout = null; + } } }; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-05-06 18:07:40
|
Revision: 90 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=90&view=rev Author: strongier Date: 2007-05-06 11:07:12 -0700 (Sun, 06 May 2007) Log Message: ----------- Base64 encoding, Menu CCS fix for IE7 Modified Paths: -------------- lib/model/db-adapter/PDOAdapter.class.php lib/model/db-adapter/PEARDBAdapter.class.php lib/view/FormContext.class.php view/core-menu/Menu.css view/core-views/Index.tpl view/core-views/ValueReadableView.js Added Paths: ----------- var/http/base64.js Modified: lib/model/db-adapter/PDOAdapter.class.php =================================================================== --- lib/model/db-adapter/PDOAdapter.class.php 2007-04-27 01:38:57 UTC (rev 89) +++ lib/model/db-adapter/PDOAdapter.class.php 2007-05-06 18:07:12 UTC (rev 90) @@ -1,5 +1,11 @@ <?php +/** + * Database access adapter for PDO library + * + * @author Michal Slaby + * @version DR1.4.1 + */ class PDOAdapter extends DBAdapter { Modified: lib/model/db-adapter/PEARDBAdapter.class.php =================================================================== --- lib/model/db-adapter/PEARDBAdapter.class.php 2007-04-27 01:38:57 UTC (rev 89) +++ lib/model/db-adapter/PEARDBAdapter.class.php 2007-05-06 18:07:12 UTC (rev 90) @@ -7,7 +7,7 @@ * * @author Michal Slaby * @author Pablo F. Vasquez - * @version DR1.4 + * @version DR1.4.1 */ class PEARDBAdapter extends DBAdapter { Modified: lib/view/FormContext.class.php =================================================================== --- lib/view/FormContext.class.php 2007-04-27 01:38:57 UTC (rev 89) +++ lib/view/FormContext.class.php 2007-05-06 18:07:12 UTC (rev 90) @@ -7,7 +7,7 @@ * Form valueReader. * * @author Michal Slaby - * @version DR1 + * @version DR1.4.1-20070430 */ class FormContext implements IteratorAggregate { @@ -20,10 +20,10 @@ /** * Constructor */ - public function __construct($fd = NULL) { + public function __construct($fd = null) { if ($fd) { foreach ($fd as $field => $value) { - $this->_formData[$field] = $value; + $this->_formData[$field] = base64_decode($value); } } } Added: var/http/base64.js =================================================================== --- var/http/base64.js (rev 0) +++ var/http/base64.js 2007-05-06 18:07:12 UTC (rev 90) @@ -0,0 +1,154 @@ +/** +* +* Base64 encode / decode +* http://www.webtoolkit.info/ +* +**/ + +var Base64 = { + + // private property + _keyStr : + "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", + + // public method for encoding + encode : function (input) { + var output = ""; + var chr1, chr2, chr3, enc1, enc2, enc3, enc4; + var i = 0; + + input = Base64._utf8_encode(input); + + while (i < input.length) { + + chr1 = input.charCodeAt(i++); + chr2 = input.charCodeAt(i++); + chr3 = input.charCodeAt(i++); + + enc1 = chr1 >> 2; + enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); + enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); + enc4 = chr3 & 63; + + if (isNaN(chr2)) { + enc3 = enc4 = 64; + } else if (isNaN(chr3)) { + enc4 = 64; + } + + output = output + + this._keyStr.charAt(enc1) + + this._keyStr.charAt(enc2) + + this._keyStr.charAt(enc3) + + this._keyStr.charAt(enc4); + + } + + return output; + }, + + // public method for decoding + decode : function (input) { + var output = ""; + var chr1, chr2, chr3; + var enc1, enc2, enc3, enc4; + var i = 0; + + input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); + + while (i < input.length) { + + enc1 = this._keyStr.indexOf(input.charAt(i++)); + enc2 = this._keyStr.indexOf(input.charAt(i++)); + enc3 = this._keyStr.indexOf(input.charAt(i++)); + enc4 = this._keyStr.indexOf(input.charAt(i++)); + + chr1 = (enc1 << 2) | (enc2 >> 4); + chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); + chr3 = ((enc3 & 3) << 6) | enc4; + + output = output + String.fromCharCode(chr1); + + if (enc3 != 64) { + output = output + + String.fromCharCode(chr2); + } + if (enc4 != 64) { + output = output + + String.fromCharCode(chr3); + } + + } + + output = Base64._utf8_decode(output); + + return output; + + }, + + // private method for UTF-8 encoding + _utf8_encode : function (string) { + string = string.replace(/\r\n/g,"\n"); + var utftext = ""; + + for (var n = 0; n < string.length; n++) { + + var c = string.charCodeAt(n); + + if (c < 128) { + utftext += String.fromCharCode(c); + } + else if((c > 127) && (c < 2048)) { + utftext += String.fromCharCode((c >> 6) + | 192); + utftext += String.fromCharCode((c & 63) + | 128); + } + else { + utftext += String.fromCharCode((c >> 12) + | 224); + utftext += String.fromCharCode(((c >> 6) + & 63) | 128); + utftext += String.fromCharCode((c & 63) + | 128); + } + + } + + return utftext; + }, + + // private method for UTF-8 decoding + _utf8_decode : function (utftext) { + var string = ""; + var i = 0; + var c = c1 = c2 = 0; + + while ( i < utftext.length ) { + + c = utftext.charCodeAt(i); + + if (c < 128) { + string += String.fromCharCode(c); + i++; + } + else if((c > 191) && (c < 224)) { + c2 = utftext.charCodeAt(i+1); + string += String.fromCharCode(((c & 31) + << 6) | (c2 & 63)); + i += 2; + } + else { + c2 = utftext.charCodeAt(i+1); + c3 = utftext.charCodeAt(i+2); + string += String.fromCharCode(((c & 15) + << 12) | ((c2 & 63) << 6) | (c3 & 63)); + i += 3; + } + + } + + return string; + } + +}; Modified: view/core-menu/Menu.css =================================================================== --- view/core-menu/Menu.css 2007-04-27 01:38:57 UTC (rev 89) +++ view/core-menu/Menu.css 2007-05-06 18:07:12 UTC (rev 90) @@ -18,7 +18,7 @@ padding: 0 1em; position: relative; color: {{$TEXT}}; - display: inline; + float: left; list-style-type: none; white-space: nowrap; } Modified: view/core-views/Index.tpl =================================================================== --- view/core-views/Index.tpl 2007-04-27 01:38:57 UTC (rev 89) +++ view/core-views/Index.tpl 2007-05-06 18:07:12 UTC (rev 90) @@ -6,6 +6,7 @@ <script language="Javascript" type="text/javascript" src="var/http/AJAX.js"></script> <script language="Javascript" type="text/javascript" src="var/http/handlers.js"></script> <script language="Javascript" type="text/javascript" src="var/palette.js"></script> +<script language="Javascript" type="text/javascript" src="var/http/base64.js"></script> <script language="Javascript" type="text/javascript" src="var/http/HotKey.js"></script> <script language="Javascript" type="text/javascript" src="js.php"></script> <link rel="stylesheet" type="text/css" href="css.php"/> Modified: view/core-views/ValueReadableView.js =================================================================== --- view/core-views/ValueReadableView.js 2007-04-27 01:38:57 UTC (rev 89) +++ view/core-views/ValueReadableView.js 2007-05-06 18:07:12 UTC (rev 90) @@ -1,7 +1,7 @@ ValueReadableView = { getValue: function(id) { - return document.getElementById(id).value; + return Base64.encode(document.getElementById(id).value); }, errorMessage: function(id, message) { This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-04-27 01:39:19
|
Revision: 89 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=89&view=rev Author: strongier Date: 2007-04-26 18:38:57 -0700 (Thu, 26 Apr 2007) Log Message: ----------- Incorrect order in receiving and handling response fixed Modified Paths: -------------- var/http/AJAX.js Modified: var/http/AJAX.js =================================================================== --- var/http/AJAX.js 2007-04-25 21:08:42 UTC (rev 88) +++ var/http/AJAX.js 2007-04-27 01:38:57 UTC (rev 89) @@ -38,8 +38,8 @@ } clearInterval(AJAX.job); AJAX.callInProgress = false; + AJAX.receive(AJAX.http.responseText); AJAX.execute(); - AJAX.receive(AJAX.http.responseText); }, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-04-25 21:08:53
|
Revision: 88 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=88&view=rev Author: strongier Date: 2007-04-25 14:08:42 -0700 (Wed, 25 Apr 2007) Log Message: ----------- Alias support in FormContext Modified Paths: -------------- ctrl/Login/LoginCtrl.class.php view/core-forms/Form.class.php view/core-views/View.class.php Modified: ctrl/Login/LoginCtrl.class.php =================================================================== --- ctrl/Login/LoginCtrl.class.php 2007-04-25 00:58:06 UTC (rev 87) +++ ctrl/Login/LoginCtrl.class.php 2007-04-25 21:08:42 UTC (rev 88) @@ -8,12 +8,12 @@ $f = new Form('LoginForm'); $f->template = 'app/Login/LoginForm.tpl'; - $login = new Input('login'); - $f->add($login); + $login = new Input('loginScreen_loginBox'); + $f->add($login, 'login'); - $passwd = new Input('passwd'); + $passwd = new Input('loginScreen_passwdBox'); $passwd->secret = TRUE; - $f->add($passwd); + $f->add($passwd, 'passwd'); $rg = new RadioGroup('rg'); $f->add($rg); Modified: view/core-forms/Form.class.php =================================================================== --- view/core-forms/Form.class.php 2007-04-25 00:58:06 UTC (rev 87) +++ view/core-forms/Form.class.php 2007-04-25 21:08:42 UTC (rev 88) @@ -11,9 +11,9 @@ public function valueReader() { $out = array(); $family = $this->getFamily(); - foreach ($family as $child) { + foreach ($family as $id => $child) { if ($child instanceof IReadableView) { - $out[] = $child->getId().": "' + ".$child->valueReader()." + '"'"; + $out[] = $id . ": "' + " . $child->valueReader() . " + '"'"; } } return "'{" . implode(" + ', ", $out) . " + '}'"; Modified: view/core-views/View.class.php =================================================================== --- view/core-views/View.class.php 2007-04-25 00:58:06 UTC (rev 87) +++ view/core-views/View.class.php 2007-04-25 21:08:42 UTC (rev 88) @@ -136,8 +136,8 @@ } else { $iterator = $this->getIterator(); } - foreach ($iterator as $child) { - $family[] = $child; + foreach ($iterator as $id => $child) { + $family[$id] = $child; if ($child->hasChildren()) { $family = array_merge($family, $child->getFamily($filtered)); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-04-25 00:59:03
|
Revision: 87 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=87&view=rev Author: strongier Date: 2007-04-24 17:58:06 -0700 (Tue, 24 Apr 2007) Log Message: ----------- Duplicate Id guard filter and its Javascript implementation Modified Paths: -------------- index.php var/http/handlers.js Added Paths: ----------- filters/DuplicateIdGuard.class.php Added: filters/DuplicateIdGuard.class.php =================================================================== --- filters/DuplicateIdGuard.class.php (rev 0) +++ filters/DuplicateIdGuard.class.php 2007-04-25 00:58:06 UTC (rev 87) @@ -0,0 +1,31 @@ +<?php + +/** + * Performs duplicate id check in DOM tree on AJAX calls + * + * @author Michal Slaby + * @version DR1.4.2 + */ +class DuplicateIdGuard implements InterceptingFilter { + + + + public function preProcess(HTTPRequest $request, HTTPResponse $response) { + + } + + + + public function postProcess(HTTPRequest $request, HTTPResponse $response) { + try { + $response->checkDuplicateId(0); + } catch (Exception $e) { + + } + } + + + +} // class DuplicateIdGuard + +?> \ No newline at end of file Modified: index.php =================================================================== --- index.php 2007-04-19 21:25:32 UTC (rev 86) +++ index.php 2007-04-25 00:58:06 UTC (rev 87) @@ -20,6 +20,9 @@ require 'filters/LoggingFilter.class.php'; $fc->addFilter(new LoggingFilter()); +require 'filters/DuplicateIdGuard.class.php'; +$fc->addFilter(new DuplicateIdGuard()); + $fc->dispatch(); $fc->finalize(); Modified: var/http/handlers.js =================================================================== --- var/http/handlers.js 2007-04-19 21:25:32 UTC (rev 86) +++ var/http/handlers.js 2007-04-25 00:58:06 UTC (rev 87) @@ -14,3 +14,26 @@ } element.parentNode.innerHTML = response.replace(/^<span>(.*)/i, '$1').replace(/(.*)<\/span>$/, '$1'); }; + + +checkDuplicateId = function () { + recursiveIdCheck(document.body, new Array()); +}; + + +recursiveIdCheck = function (element, map) { + for (var i = 0; i < element.childNodes.length; ++i) { + var e = element.childNodes[i]; + if (e == undefined || e.nodeType != 1) { + continue; + } + if (e.id != '') { + if (map[e.id] != undefined) { + alert('duplicate identifier detected \'' + e.id + '\''); + } else { + map[e.id] = true; + } + } + recursiveIdCheck(e, map); + } +}; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-04-19 21:25:54
|
Revision: 86 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=86&view=rev Author: strongier Date: 2007-04-19 14:25:32 -0700 (Thu, 19 Apr 2007) Log Message: ----------- Keyboard shortcuts prof of concept Modified Paths: -------------- ctrl/PhoneBook/FormCtrl.class.php var/cache/autoload.map view/core-views/Index.tpl Added Paths: ----------- lib/events/HotKey.class.php var/http/HotKey.js Modified: ctrl/PhoneBook/FormCtrl.class.php =================================================================== --- ctrl/PhoneBook/FormCtrl.class.php 2007-04-13 21:03:34 UTC (rev 85) +++ ctrl/PhoneBook/FormCtrl.class.php 2007-04-19 21:25:32 UTC (rev 86) @@ -30,8 +30,10 @@ public function open($id = NULL) { $f = $this->getForm(); - $f['ok']->addListener(new ClickListener(new Action('PhoneBook/FormCtrl/save', array($f->valueReader(), $id)))); + $f['ok']->addListener(new ClickListener($a = new Action('PhoneBook/FormCtrl/save', array($f->valueReader(), $id)))); + HotKey::register($a, 49); + $w = $this->getWindow(); $w->add($f); if ($id) { Added: lib/events/HotKey.class.php =================================================================== --- lib/events/HotKey.class.php (rev 0) +++ lib/events/HotKey.class.php 2007-04-19 21:25:32 UTC (rev 86) @@ -0,0 +1,23 @@ +<?php + +class HotKey { + + + + public static function register(IActionAdapter $a, $key, $modifier = null) { + $response = HTTPResponse::getInstance(); + $response->HotKey->register($key, $modifier, $a->serialize()); + } + + + + public static function unregister($key, $modifier = null) { + $response = HTTPResponse::getInstance(); + $response->HotKey->unregister($key, $modifier); + } + + + +} // class HotKey + +?> \ No newline at end of file Modified: var/cache/autoload.map =================================================================== --- var/cache/autoload.map 2007-04-13 21:03:34 UTC (rev 85) +++ var/cache/autoload.map 2007-04-19 21:25:32 UTC (rev 86) @@ -1 +1 @@ -a:60:{s:23:"HTTPResponseAjaxBackend";s:42:"lib/http/HTTPResponseAjaxBackend.class.php";s:29:"HTTPResponseAjaxBackendJsHook";s:48:"lib/http/HTTPResponseAjaxBackendJsHook.class.php";s:23:"HTTPResponseHTMLBackend";s:42:"lib/http/HTTPResponseHTMLBackend.class.php";s:12:"SQL92Dialect";s:36:"lib/model/sql/SQL92Dialect.class.php";s:19:"MicrosoftSQLDialect";s:43:"lib/model/sql/MicrosoftSQLDialect.class.php";s:10:"SQLDialect";s:34:"lib/model/sql/SQLDialect.class.php";s:13:"PEARDBAdapter";s:44:"lib/model/db-adapter/PEARDBAdapter.class.php";s:10:"PDOAdapter";s:41:"lib/model/db-adapter/PDOAdapter.class.php";s:9:"DBAdapter";s:40:"lib/model/db-adapter/DBAdapter.class.php";s:18:"ManyToManyRelation";s:52:"lib/model/active-record/ManyToManyRelation.class.php";s:12:"ActiveRecord";s:46:"lib/model/active-record/ActiveRecord.class.php";s:17:"OneToManyRelation";s:51:"lib/model/active-record/OneToManyRelation.class.php";s:13:"SQLDataSource";s:45:"lib/model/data-source/SQLDataSource.class.php";s:19:"DataSourceDecorator";s:51:"lib/model/data-source/DataSourceDecorator.class.php";s:17:"CachingDataSource";s:49:"lib/model/data-source/CachingDataSource.class.php";s:10:"DataSource";s:42:"lib/model/data-source/DataSource.class.php";s:15:"ArrayDataSource";s:47:"lib/model/data-source/ArrayDataSource.class.php";s:15:"MouseUpListener";s:36:"lib/events/MouseUpListener.class.php";s:14:"ChangeListener";s:35:"lib/events/ChangeListener.class.php";s:15:"KeyDownListener";s:36:"lib/events/KeyDownListener.class.php";s:14:"ToggleListener";s:35:"lib/events/ToggleListener.class.php";s:12:"BlurListener";s:33:"lib/events/BlurListener.class.php";s:16:"KeyPressListener";s:37:"lib/events/KeyPressListener.class.php";s:13:"KeyUpListener";s:34:"lib/events/KeyUpListener.class.php";s:17:"DragStartListener";s:38:"lib/events/DragStartListener.class.php";s:13:"CloseListener";s:34:"lib/events/CloseListener.class.php";s:13:"FocusListener";s:34:"lib/events/FocusListener.class.php";s:16:"DropOntoListener";s:37:"lib/events/DropOntoListener.class.php";s:17:"MouseDownListener";s:38:"lib/events/MouseDownListener.class.php";s:13:"ClickListener";s:34:"lib/events/ClickListener.class.php";s:8:"MoreCtrl";s:39:"view/core-containers/MoreCtrl.class.php";s:9:"TabFolder";s:40:"view/core-containers/TabFolder.class.php";s:3:"Box";s:34:"view/core-containers/Box.class.php";s:8:"FieldSet";s:39:"view/core-containers/FieldSet.class.php";s:4:"More";s:35:"view/core-containers/More.class.php";s:4:"HBox";s:35:"view/core-containers/HBox.class.php";s:3:"Tab";s:34:"view/core-containers/Tab.class.php";s:6:"Window";s:37:"view/core-containers/Window.class.php";s:4:"VBox";s:35:"view/core-containers/VBox.class.php";s:7:"TabView";s:38:"view/core-containers/TabView.class.php";s:13:"TabFolderCtrl";s:44:"view/core-containers/TabFolderCtrl.class.php";s:7:"HintBox";s:35:"view/experimental/HintBox.class.php";s:8:"MenuItem";s:33:"view/core-menu/MenuItem.class.php";s:4:"Menu";s:29:"view/core-menu/Menu.class.php";s:4:"Tree";s:29:"view/core-tree/Tree.class.php";s:8:"TreeCtrl";s:33:"view/core-tree/TreeCtrl.class.php";s:8:"TreeNode";s:33:"view/core-tree/TreeNode.class.php";s:4:"Form";s:30:"view/core-forms/Form.class.php";s:5:"Image";s:31:"view/core-forms/Image.class.php";s:11:"RadioButton";s:37:"view/core-forms/RadioButton.class.php";s:6:"Select";s:32:"view/core-forms/Select.class.php";s:5:"Input";s:31:"view/core-forms/Input.class.php";s:10:"RadioGroup";s:36:"view/core-forms/RadioGroup.class.php";s:6:"Button";s:32:"view/core-forms/Button.class.php";s:8:"TextArea";s:34:"view/core-forms/TextArea.class.php";s:9:"TableCtrl";s:35:"view/core-table/TableCtrl.class.php";s:8:"TableRow";s:34:"view/core-table/TableRow.class.php";s:5:"Table";s:31:"view/core-table/Table.class.php";s:9:"TableCell";s:35:"view/core-table/TableCell.class.php";s:11:"TableColumn";s:37:"view/core-table/TableColumn.class.php";} \ No newline at end of file +a:62:{s:23:"HTTPResponseAjaxBackend";s:42:"lib/http/HTTPResponseAjaxBackend.class.php";s:29:"HTTPResponseAjaxBackendJsHook";s:48:"lib/http/HTTPResponseAjaxBackendJsHook.class.php";s:23:"HTTPResponseHTMLBackend";s:42:"lib/http/HTTPResponseHTMLBackend.class.php";s:12:"SQL92Dialect";s:36:"lib/model/sql/SQL92Dialect.class.php";s:19:"MicrosoftSQLDialect";s:43:"lib/model/sql/MicrosoftSQLDialect.class.php";s:10:"SQLDialect";s:34:"lib/model/sql/SQLDialect.class.php";s:13:"PEARDBAdapter";s:44:"lib/model/db-adapter/PEARDBAdapter.class.php";s:10:"PDOAdapter";s:41:"lib/model/db-adapter/PDOAdapter.class.php";s:9:"DBAdapter";s:40:"lib/model/db-adapter/DBAdapter.class.php";s:18:"ManyToManyRelation";s:52:"lib/model/active-record/ManyToManyRelation.class.php";s:17:"ActiveRecordsPool";s:51:"lib/model/active-record/ActiveRecordsPool.class.php";s:12:"ActiveRecord";s:46:"lib/model/active-record/ActiveRecord.class.php";s:17:"OneToManyRelation";s:51:"lib/model/active-record/OneToManyRelation.class.php";s:13:"SQLDataSource";s:45:"lib/model/data-source/SQLDataSource.class.php";s:19:"DataSourceDecorator";s:51:"lib/model/data-source/DataSourceDecorator.class.php";s:17:"CachingDataSource";s:49:"lib/model/data-source/CachingDataSource.class.php";s:10:"DataSource";s:42:"lib/model/data-source/DataSource.class.php";s:15:"ArrayDataSource";s:47:"lib/model/data-source/ArrayDataSource.class.php";s:15:"MouseUpListener";s:36:"lib/events/MouseUpListener.class.php";s:14:"ChangeListener";s:35:"lib/events/ChangeListener.class.php";s:15:"KeyDownListener";s:36:"lib/events/KeyDownListener.class.php";s:14:"ToggleListener";s:35:"lib/events/ToggleListener.class.php";s:12:"BlurListener";s:33:"lib/events/BlurListener.class.php";s:16:"KeyPressListener";s:37:"lib/events/KeyPressListener.class.php";s:13:"KeyUpListener";s:34:"lib/events/KeyUpListener.class.php";s:17:"DragStartListener";s:38:"lib/events/DragStartListener.class.php";s:6:"HotKey";s:27:"lib/events/HotKey.class.php";s:13:"CloseListener";s:34:"lib/events/CloseListener.class.php";s:13:"FocusListener";s:34:"lib/events/FocusListener.class.php";s:16:"DropOntoListener";s:37:"lib/events/DropOntoListener.class.php";s:17:"MouseDownListener";s:38:"lib/events/MouseDownListener.class.php";s:13:"ClickListener";s:34:"lib/events/ClickListener.class.php";s:8:"MoreCtrl";s:39:"view/core-containers/MoreCtrl.class.php";s:9:"TabFolder";s:40:"view/core-containers/TabFolder.class.php";s:3:"Box";s:34:"view/core-containers/Box.class.php";s:8:"FieldSet";s:39:"view/core-containers/FieldSet.class.php";s:4:"More";s:35:"view/core-containers/More.class.php";s:4:"HBox";s:35:"view/core-containers/HBox.class.php";s:3:"Tab";s:34:"view/core-containers/Tab.class.php";s:6:"Window";s:37:"view/core-containers/Window.class.php";s:4:"VBox";s:35:"view/core-containers/VBox.class.php";s:7:"TabView";s:38:"view/core-containers/TabView.class.php";s:13:"TabFolderCtrl";s:44:"view/core-containers/TabFolderCtrl.class.php";s:7:"HintBox";s:35:"view/experimental/HintBox.class.php";s:8:"MenuItem";s:33:"view/core-menu/MenuItem.class.php";s:4:"Menu";s:29:"view/core-menu/Menu.class.php";s:4:"Tree";s:29:"view/core-tree/Tree.class.php";s:8:"TreeCtrl";s:33:"view/core-tree/TreeCtrl.class.php";s:8:"TreeNode";s:33:"view/core-tree/TreeNode.class.php";s:4:"Form";s:30:"view/core-forms/Form.class.php";s:5:"Image";s:31:"view/core-forms/Image.class.php";s:11:"RadioButton";s:37:"view/core-forms/RadioButton.class.php";s:6:"Select";s:32:"view/core-forms/Select.class.php";s:5:"Input";s:31:"view/core-forms/Input.class.php";s:10:"RadioGroup";s:36:"view/core-forms/RadioGroup.class.php";s:6:"Button";s:32:"view/core-forms/Button.class.php";s:8:"TextArea";s:34:"view/core-forms/TextArea.class.php";s:9:"TableCtrl";s:35:"view/core-table/TableCtrl.class.php";s:8:"TableRow";s:34:"view/core-table/TableRow.class.php";s:5:"Table";s:31:"view/core-table/Table.class.php";s:9:"TableCell";s:35:"view/core-table/TableCell.class.php";s:11:"TableColumn";s:37:"view/core-table/TableColumn.class.php";} \ No newline at end of file Added: var/http/HotKey.js =================================================================== --- var/http/HotKey.js (rev 0) +++ var/http/HotKey.js 2007-04-19 21:25:32 UTC (rev 86) @@ -0,0 +1,34 @@ +HotKey = { + + + keys: new Array(), + + + register: function (key, modifier, js) { + HotKey.keys.push( [key, js] ); + }, + + + unregister: function (key, modifier) { + for (var i = 0; i < HotKey.keys.length; ++i) { + if (HotKey.keys[i][0] == event.keyCode) { + HotKey.keys[i] = undefined; + } + } + }, + + + onKeyDown: function (event) { + for (var i = 0; i < HotKey.keys.length; ++i) { + if (HotKey.keys[i][0] == event.keyCode) { + eval(HotKey.keys[i][1].replace(/"/g, '\"')); + return false; + } + } + return true; + } + + +}; + +window.onkeydown = HotKey.onKeyDown; Modified: view/core-views/Index.tpl =================================================================== --- view/core-views/Index.tpl 2007-04-13 21:03:34 UTC (rev 85) +++ view/core-views/Index.tpl 2007-04-19 21:25:32 UTC (rev 86) @@ -6,6 +6,7 @@ <script language="Javascript" type="text/javascript" src="var/http/AJAX.js"></script> <script language="Javascript" type="text/javascript" src="var/http/handlers.js"></script> <script language="Javascript" type="text/javascript" src="var/palette.js"></script> +<script language="Javascript" type="text/javascript" src="var/http/HotKey.js"></script> <script language="Javascript" type="text/javascript" src="js.php"></script> <link rel="stylesheet" type="text/css" href="css.php"/> </head> This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-04-13 21:03:58
|
Revision: 85 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=85&view=rev Author: strongier Date: 2007-04-13 14:03:34 -0700 (Fri, 13 Apr 2007) Log Message: ----------- SPAN bug fixed, cleaner view output, minor tweaks here and there Modified Paths: -------------- README index.php js.php lib/routing/ActionService.class.php var/http/AJAX.js var/http/handlers.js view/core-views/View.class.php Modified: README =================================================================== --- README 2007-04-12 23:21:21 UTC (rev 84) +++ README 2007-04-13 21:03:34 UTC (rev 85) @@ -25,22 +25,3 @@ var/ temporary files, locks, logs, template compiles, images view/ place your application views here view/core-* core view classes provided by Tigermouse by default - - - -CODING CONVENTIONS ------------------- -If you wish to contribute please try to stay close to this few rules -regarding coding style: -- class names in PascalCase (e.g. FrontCtrl) -- interface names in PascalCase prefixed by 'I' letter (e.g. IDataSource) -- only one class/interface per file -- class files <class name>.class.php and interface files <interface name>.interface.php -- methods and properties and local varriables names in camelCase (e.g. selectTab() ) -- "{" in the same line as its respective if, for, function, class, etc. -- use "\t" as tab character -- use triple "\n" to separate methods -- set ERROR_REPORTING to E_ALL | E_STRICT in php.ini for both CGI and CLI -And please remember not to save any data in session unless it's absolutely necessary. -Debugging session data is difficult and Tigermouse is intended to be simple and stateless -as much as it's possible. Modified: index.php =================================================================== --- index.php 2007-04-12 23:21:21 UTC (rev 84) +++ index.php 2007-04-13 21:03:34 UTC (rev 85) @@ -1,7 +1,7 @@ <?php ini_set('display_errors', 'on'); -error_reporting(2047); +error_reporting(E_ALL); ob_start(); session_start(); Modified: js.php =================================================================== --- js.php 2007-04-12 23:21:21 UTC (rev 84) +++ js.php 2007-04-13 21:03:34 UTC (rev 85) @@ -11,12 +11,12 @@ if (empty($_GET)) { readfile($filename); } else { - print("\n--- $filename ---\n\n"); + print("\n// --- $filename ---\n\n"); $f = file($filename); foreach ($f as $localLine => $l) { ++$line; $ll = $localLine + 1; - print("$line ($ll) |\t$l"); + print("/* $line ($ll) */ \t$l"); } } } Modified: lib/routing/ActionService.class.php =================================================================== --- lib/routing/ActionService.class.php 2007-04-12 23:21:21 UTC (rev 84) +++ lib/routing/ActionService.class.php 2007-04-13 21:03:34 UTC (rev 85) @@ -7,7 +7,7 @@ * and calls one of its methods. Forwards value returned by controller. * * @author Michal Slaby - * @version DR1.4 + * @version DR1.4.1 */ class ActionService { Modified: var/http/AJAX.js =================================================================== --- var/http/AJAX.js 2007-04-12 23:21:21 UTC (rev 84) +++ var/http/AJAX.js 2007-04-13 21:03:34 UTC (rev 85) @@ -114,7 +114,7 @@ var msg = 'ajax=42&action=' + action; if (args != null) { for (i=0; i<args.length; i++) { - msg += '&args[]=' + args[i]; + msg += '&args[]=' + ((args[i] == null || args[i] == undefined) ? '' : args[i]); } } var throbber = document.getElementById('throbber'); Modified: var/http/handlers.js =================================================================== --- var/http/handlers.js 2007-04-12 23:21:21 UTC (rev 84) +++ var/http/handlers.js 2007-04-13 21:03:34 UTC (rev 85) @@ -12,5 +12,5 @@ alert('Element ' + id + ' not found'); return false; } - element.parentNode.innerHTML = response.replace(/(^<span>)(.*)(<\/span>$)/i, '$2'); + element.parentNode.innerHTML = response.replace(/^<span>(.*)/i, '$1').replace(/(.*)<\/span>$/, '$1'); }; Modified: view/core-views/View.class.php =================================================================== --- view/core-views/View.class.php 2007-04-12 23:21:21 UTC (rev 84) +++ view/core-views/View.class.php 2007-04-13 21:03:34 UTC (rev 85) @@ -1,5 +1,13 @@ <?php +/** + * Base View class + * + * Represents a View to be displayed. + * + * @author Michal Slaby + * @version DR1.4.1 + */ class View implements IteratorAggregate, ArrayAccess { @@ -200,7 +208,7 @@ } } $out = $smarty->fetch($f); - return $this->id ? '<span>'.$out.'</span>' : $out; + return trim($this->id ? '<span>'.$out.'</span>' : $out); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-04-12 23:21:20
|
Revision: 84 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=84&view=rev Author: strongier Date: 2007-04-12 16:21:21 -0700 (Thu, 12 Apr 2007) Log Message: ----------- Default error reporting, typo in ActionService Modified Paths: -------------- index.php lib/routing/ActionService.class.php Modified: index.php =================================================================== --- index.php 2007-04-12 20:13:40 UTC (rev 83) +++ index.php 2007-04-12 23:21:21 UTC (rev 84) @@ -1,5 +1,7 @@ <?php +ini_set('display_errors', 'on'); +error_reporting(2047); ob_start(); session_start(); Modified: lib/routing/ActionService.class.php =================================================================== --- lib/routing/ActionService.class.php 2007-04-12 20:13:40 UTC (rev 83) +++ lib/routing/ActionService.class.php 2007-04-12 23:21:21 UTC (rev 84) @@ -38,7 +38,7 @@ } require_once $pathName; if (!class_exists($class)) { - throw new Excpetion("class $class not found in file $fileName for action $action"); + throw new Exception("class $class not found in file $fileName for action $action"); } $c = new $class(); return call_user_func_array(array($c, $method), $args); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-04-12 20:13:40
|
Revision: 83 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=83&view=rev Author: strongier Date: 2007-04-12 13:13:40 -0700 (Thu, 12 Apr 2007) Log Message: ----------- PDO adapter record set fetch fix Modified Paths: -------------- lib/model/db-adapter/PDOAdapter.class.php Modified: lib/model/db-adapter/PDOAdapter.class.php =================================================================== --- lib/model/db-adapter/PDOAdapter.class.php 2007-04-12 19:41:05 UTC (rev 82) +++ lib/model/db-adapter/PDOAdapter.class.php 2007-04-12 20:13:40 UTC (rev 83) @@ -23,7 +23,7 @@ if (preg_match('/^SELECT/i', $sql)) { $out = $this->pdo->query($sql); if ($out instanceof PDOStatement) { - $this->result = new ArrayObject($out->fetchAll()); + $this->result = new ArrayObject($out->fetchAll(PDO::FETCH_ASSOC)); $out->closeCursor(); } else { $this->result = new ArrayObject(); @@ -34,7 +34,7 @@ if (!$out) { return false; } - if (!$sequenceName or !preg_match('/^INSERT/', $sql)) { + if (!$sequenceName or !preg_match('/^INSERT/i', $sql)) { return true; } return $this->pdo->lastInsertId($sequenceName); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-04-12 19:41:28
|
Revision: 82 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=82&view=rev Author: strongier Date: 2007-04-12 12:41:05 -0700 (Thu, 12 Apr 2007) Log Message: ----------- ActiveRecord::loadByFieldValue now returns a collection of fetched objects Modified Paths: -------------- lib/model/active-record/ActiveRecord.class.php Modified: lib/model/active-record/ActiveRecord.class.php =================================================================== --- lib/model/active-record/ActiveRecord.class.php 2007-04-12 19:19:23 UTC (rev 81) +++ lib/model/active-record/ActiveRecord.class.php 2007-04-12 19:41:05 UTC (rev 82) @@ -72,20 +72,11 @@ /** * Loads data from database table record by any field value */ - public function loadByFieldValue($k, $v = null) { - if (is_array($k)) { - $c = new ArrayObject(); - foreach ($k as $kk => $vv) { - $c[] = "$kk = '$vv'"; - } - $condition = implode(' AND ', $c); - } else { - $condition = "$k = '$v'"; - } + public function loadByFieldValue($k, $v) { $className = get_class($this); $sql = " SELECT * FROM {$this->tableName} - WHERE $condition + WHERE $k = '$v' "; $this->dbAdapter->execute($sql); $i = 0; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-04-12 19:19:22
|
Revision: 81 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=81&view=rev Author: strongier Date: 2007-04-12 12:19:23 -0700 (Thu, 12 Apr 2007) Log Message: ----------- Fixed PEAR::DB adapter Modified Paths: -------------- lib/model/db-adapter/PEARDBAdapter.class.php Modified: lib/model/db-adapter/PEARDBAdapter.class.php =================================================================== --- lib/model/db-adapter/PEARDBAdapter.class.php 2007-04-12 18:38:16 UTC (rev 80) +++ lib/model/db-adapter/PEARDBAdapter.class.php 2007-04-12 19:19:23 UTC (rev 81) @@ -1,5 +1,14 @@ <?php +/** + * Database access adapter for PEAR::DB library + * + * @note this class has not been tested with PostgreSQL RDBMS + * + * @author Michal Slaby + * @author Pablo F. Vasquez + * @version DR1.4 + */ class PEARDBAdapter extends DBAdapter { @@ -10,8 +19,7 @@ - public function __construct(DBConnection $connection, SQLDialect $dialect) { -throw new Exception('this class is broken, please fix it or do not use it'); + public function __construct(MDB2_Driver_Common $connection, SQLDialect $dialect) { $this->connection = $connection; $this->dialect = $dialect; $this->result = new ArrayObject(); @@ -21,13 +29,23 @@ public function execute($sql, $sequenceName = null) { $sql = trim($sql); + if (preg_match('/^SELECT/i', $sql)) { + $out = $this->connection->query($sql); + if (PEAR::isError($out)) { + $this->result = new ArrayObject(); + } else { + $this->result = new ArrayObject($out->fetchAll(MDB2_FETCHMODE_ASSOC)); + } + return true; + } $out = $this->connection->query($sql); if (PEAR::isError($out)) { - $this->result = new ArrayObject(); - } else { - $this->result = new ArrayObject($out->fetchAll()); - $out->freeResult(); + return false; } + if (!$sequenceName or !preg_match('/^INSERT/i', $sql)) { + return true; + } + return $this->connection->lastInsertID(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-04-12 18:38:56
|
Revision: 80 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=80&view=rev Author: strongier Date: 2007-04-12 11:38:16 -0700 (Thu, 12 Apr 2007) Log Message: ----------- Multiple criteria for ActiveRecord selection Modified Paths: -------------- lib/model/active-record/ActiveRecord.class.php Modified: lib/model/active-record/ActiveRecord.class.php =================================================================== --- lib/model/active-record/ActiveRecord.class.php 2007-04-01 12:58:38 UTC (rev 79) +++ lib/model/active-record/ActiveRecord.class.php 2007-04-12 18:38:16 UTC (rev 80) @@ -24,9 +24,6 @@ protected $dbAdapter; protected static $cache = array(); // FIXME - protected $inheritsFrom = array(); // FIXME - protected $ancestor; - protected $hasOne = array(); // array(field => array(className, foreignKey)) protected $properties = array(); @@ -57,7 +54,7 @@ * * @param DBAdapter $dbAdapter */ - public function setDBAdapter($dbAdapter) { + public function setDBAdapter(DBAdapter $dbAdapter) { $this->dbAdapter = $dbAdapter; } @@ -75,19 +72,36 @@ /** * Loads data from database table record by any field value */ - public function loadByFieldValue($k, $v) { + public function loadByFieldValue($k, $v = null) { + if (is_array($k)) { + $c = new ArrayObject(); + foreach ($k as $kk => $vv) { + $c[] = "$kk = '$vv'"; + } + $condition = implode(' AND ', $c); + } else { + $condition = "$k = '$v'"; + } $className = get_class($this); $sql = " SELECT * FROM {$this->tableName} - WHERE $k = '$v' + WHERE $condition "; $this->dbAdapter->execute($sql); + $i = 0; + $currentSelection = new ArrayObject(); foreach ($this->dbAdapter as $row) { - if (empty($this->data)) { - $this->data = $row; + $pkey = $row[$this->primaryKey]; + if (!$i) { + self::$cache[$className][$pkey] = $this; + } else { + self::$cache[$className][$pkey] = clone $this; } - self::$cache[$className][$row[$this->primaryKey]] = $this; + self::$cache[$className][$pkey]->data = $row; + $currentSelection[] = self::$cache[$className][$pkey]; + ++$i; } + return $currentSelection;; } @@ -112,9 +126,6 @@ } $this->modified = false; } - if ($this->ancestor) { - $this->ancestor->save(); - } foreach ($this->properties as $property) { $property->save(); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-04-01 12:59:01
|
Revision: 79 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=79&view=rev Author: strongier Date: 2007-04-01 05:58:38 -0700 (Sun, 01 Apr 2007) Log Message: ----------- Info about includes.php in README file Modified Paths: -------------- README Modified: README =================================================================== --- README 2007-03-31 01:08:42 UTC (rev 78) +++ README 2007-04-01 12:58:38 UTC (rev 79) @@ -3,12 +3,12 @@ Make sure Tigermouse can write to var/smarty/compile, var/log and var/cache directories. Executing - chmod 777 var/smarty/compile - chmod 777 var/log - chmod 777 var/cache + chmod 1777 var/smarty/compile + chmod 1777 var/log + chmod 1777 var/cache will do it for you. -No other configuration is needed. +You might also need to alter path to your Smarty installation. Modify file includes.php to do so. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-03-31 01:08:43
|
Revision: 78 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=78&view=rev Author: strongier Date: 2007-03-30 18:08:42 -0700 (Fri, 30 Mar 2007) Log Message: ----------- model directory moved under lib to make room for user toys Modified Paths: -------------- Tigermouse.php autobuild.php var/cache/autoload.map Added Paths: ----------- lib/model/ lib/model/active-record/ lib/model/active-record/ActiveRecord.class.php lib/model/active-record/ManyToManyRelation.class.php lib/model/active-record/OneToManyRelation.class.php lib/model/data-source/ lib/model/data-source/ArrayDataSource.class.php lib/model/data-source/CachingDataSource.class.php lib/model/data-source/DataSource.class.php lib/model/data-source/DataSourceDecorator.class.php lib/model/data-source/IDataSource.interface.php lib/model/data-source/SQLDataSource.class.php lib/model/db-adapter/ lib/model/db-adapter/DBAdapter.class.php lib/model/db-adapter/PDOAdapter.class.php lib/model/db-adapter/PEARDBAdapter.class.php lib/model/sql/ lib/model/sql/MicrosoftSQLDialect.class.php lib/model/sql/SQL92Dialect.class.php lib/model/sql/SQLDialect.class.php Modified: Tigermouse.php =================================================================== --- Tigermouse.php 2007-03-31 01:05:53 UTC (rev 77) +++ Tigermouse.php 2007-03-31 01:08:42 UTC (rev 78) @@ -29,6 +29,6 @@ require 'lib/events/Listener.class.php'; // Model -require 'model/data-source/IDataSource.interface.php'; +require 'lib/model/data-source/IDataSource.interface.php'; ?> \ No newline at end of file Modified: autobuild.php =================================================================== --- autobuild.php 2007-03-31 01:05:53 UTC (rev 77) +++ autobuild.php 2007-03-31 01:08:42 UTC (rev 78) @@ -2,7 +2,7 @@ <?php -$dirs = array('lib', 'model', 'view'); +$dirs = array('lib', 'view'); require 'Tigermouse.php'; $output = "var/cache/autoload.map"; Added: lib/model/active-record/ActiveRecord.class.php =================================================================== --- lib/model/active-record/ActiveRecord.class.php (rev 0) +++ lib/model/active-record/ActiveRecord.class.php 2007-03-31 01:08:42 UTC (rev 78) @@ -0,0 +1,296 @@ +<?php + +/** + * Active Record + * + * Persistent object stored in database table record. + * Handles 1-to-1, 1-to-many and many-to-many relations, as well as Class Table Inheritance. + * See Martin Fowler's Active Record design pattern for details. + * + * @author Michal Slaby + * @version DR1.4 + */ +abstract class ActiveRecord { + + + + protected $tableName; + protected $primaryKey = 'id'; + protected $sequenceName = ''; + + protected $data = array(); + protected $modified = false; + + protected $dbAdapter; + protected static $cache = array(); // FIXME + + protected $inheritsFrom = array(); // FIXME + protected $ancestor; + + protected $hasOne = array(); // array(field => array(className, foreignKey)) + protected $properties = array(); + + protected $hasMany = array(); // array(field => array(className, foreignKey)) + protected $propertiesCollections = array(); + + protected $belongsToOne = array(); // array(field => array(className, foreignKey)) + protected $owners = array(); + + protected $belongsToMany = array(); // array(field => array(className, foreignKey)) + protected $ownersCollections = array(); + + protected $manyToMany = array(); // array(field => array(className, mapName, mapPrimaryKey, mapForeignKey)) + protected $m2mCollections = array(); + + + + public function __construct() { + if (!$this->sequenceName) { + $this->sequenceName = $this->tableName . '_' . $this->primaryKey . '_seq'; + } + } + + + + /** + * Sets database access adapter + * + * @param DBAdapter $dbAdapter + */ + public function setDBAdapter($dbAdapter) { + $this->dbAdapter = $dbAdapter; + } + + + + /** + * Loads data from database table record by primary key + */ + public function loadById($id) { + $this->loadByFieldValue($this->primaryKey, $id); + } + + + + /** + * Loads data from database table record by any field value + */ + public function loadByFieldValue($k, $v) { + $className = get_class($this); + $sql = " + SELECT * FROM {$this->tableName} + WHERE $k = '$v' + "; + $this->dbAdapter->execute($sql); + foreach ($this->dbAdapter as $row) { + if (empty($this->data)) { + $this->data = $row; + } + self::$cache[$className][$row[$this->primaryKey]] = $this; + } + } + + + + /** + * Stores internal data and relations into database table record + */ + public function save() { + if ($this->modified) { + $dialect = $this->dbAdapter->getDialect(); + if (array_key_exists($this->primaryKey, $this->data) and $this->data[$this->primaryKey]) { + $sql = $dialect->getUpdate($this->tableName, $this->data, $this->primaryKey, $this->data[$this->primaryKey]); + $out = $this->dbAdapter->execute($sql); + } else { + $sql = $dialect->getInsert($this->tableName, $this->data); + if ($out = $this->dbAdapter->execute($sql, $this->sequenceName)) { + $this->data[$this->primaryKey] = $out; + } + } + if (!$out) { + throw new Exception('saving ' . get_class($this) . ' failed: ' . $sql); + } + $this->modified = false; + } + if ($this->ancestor) { + $this->ancestor->save(); + } + foreach ($this->properties as $property) { + $property->save(); + } + foreach ($this->owners as $owner) { + $owner->save(); + } + foreach ($this->propertiesCollections as $collection) { + foreach ($collection as $item) { + $item->save(); + } + } + foreach ($this->ownersCollections as $collection) { + foreach ($collection as $item) { + $item->save(); + } + } + } + + + + public function getPrimaryKeyName() { + return $this->primaryKey; + } + + + + public function getPrimaryKeyValue() { + return (array_key_exists($this->primaryKey, $this->data)) + ? $this->data[$this->primaryKey] + : null; + } + + + + public function getTableName() { + return $this->tableName; + } + + + + public function __get($field) { + if (array_key_exists($field, $this->hasOne)) { + return $this->getHasOne($field); + } + if (array_key_exists($field, $this->belongsToOne)) { + return $this->getBelongsToOne($field); + } + if (array_key_exists($field, $this->hasMany)) { + return $this->getHasMany($field); + } + if (array_key_exists($field, $this->belongsToMany)) { + return $this->getBelongsToMany($field); + } + if (array_key_exists($field, $this->manyToMany)) { + return $this->getM2M($field); + } + if (array_key_exists($field, $this->data)) { + return $this->data[$field]; + } + return null; + } + + + + public function __set($field, $value) { + if (array_key_exists($field, $this->hasOne)) { + $this->setHasOne($field, $value); + } elseif (array_key_exists($field, $this->belongsToOne)) { + $this->setBelongsToOne($field, $value); + } elseif (array_key_exists($field, $this->hasMany) + or array_key_exists($field, $this->belongsToMany) + or array_key_exists($field, $this->manyToMany)) { + throw new Exception('use add() to add item to hasMany or belongsToMany relation'); + } else { + $this->data[$field] = $value; + } + $this->modified = true; + } + + + + protected function getHasOne($field) { + if (!array_key_exists($field, $this->properties)) { + list($className, $foreignKey) = $this->hasOne[$field]; + $property = new $className(); + $property->setDBAdapter($this->dbAdapter); + $property->loadById($this->data[$foreignKey]); + $this->properties[$field] = $property; + } + return $this->properties[$field]; + } + + + + protected function setHasOne($field, ActiveRecord $ar) { + list($className, $foreignKey) = $this->hasOne[$field]; + if (!($ar instanceof $className)) { + throw new Exception("expected $className while setting property, got " . get_class($ar)); + } + if (!$this->getPrimaryKeyValue()) { + $this->save(); + } + if (!$ar->getPrimaryKeyValue()) { + $ar->save(); + } + $this->data[$foreignKey] = $ar->getPrimaryKeyValue(); + } + + + + protected function getHasMany($field) { + if (!array_key_exists($field, $this->ownersCollections)) { + list($className, $foreignKey) = $this->hasMany[$field]; + $this->ownersCollections[$field] = OneToManyRelation::getInstance($this, $className, $foreignKey, $this->dbAdapter); + } + return $this->ownersCollections[$field]; + } + + + + protected function getBelongsToOne($field) { + if (!array_key_exists($field, $this->owners)) { + list($className, $foreignKey) = $this->belongsToOne[$field]; + $owner = new $className(); + $owner->setDBAdapter($this->dbAdapter); + $owner->loadByFieldValue($foreignKey, $this->getPrimaryKeyValue()); + $this->owners[$field] = $owner; + } + return $this->owners[$field]; + } + + + + protected function setBelongsToOne($field, ActiveRecord $ar) { + list($className, $foreignKey) = $this->belongsToOne[$field]; + if (!($ar instanceof $className)) { + throw new Exception("expected $className while setting owner, got " . get_class($ar)); + } + if (!$this->getPrimaryKeyValue()) { + $this->save(); + } + if (!$ar->getPrimaryKeyValue()) { + $ar->save(); + } + $owner = $this->getBelongsToOne($field); + $owner->$foreignKey = $this->getPrimaryKeyValue(); + } + + + + protected function getBelongsToMany($field) { + if (!array_key_exists($field, $this->ownersCollections)) { + list($className, $foreignKey) = $this->belongsToMany[$field]; + $this->ownersCollections[$field] = OneToManyRelation::getInstance($this, $className, $foreignKey, $this->dbAdapter); + } + return $this->ownersCollections[$field]; + } + + + + protected function getM2M($field) { + if (!array_key_exists($field, $this->m2mCollections)) { + $this->m2mCollections[$field] = new ManyToManyRelation( + $this, + $this->manyToMany[$field][0], + $this->manyToMany[$field][1], + $this->manyToMany[$field][2], + $this->manyToMany[$field][3] + ); + $this->m2mCollections[$field]->setDBAdapter($this->dbAdapter); + } + return $this->m2mCollections[$field]; + } + + + +} // class ActiveRecord + +?> \ No newline at end of file Added: lib/model/active-record/ManyToManyRelation.class.php =================================================================== --- lib/model/active-record/ManyToManyRelation.class.php (rev 0) +++ lib/model/active-record/ManyToManyRelation.class.php 2007-03-31 01:08:42 UTC (rev 78) @@ -0,0 +1,104 @@ +<?php + +class ManyToManyRelation implements IteratorAggregate { + + + protected $items = array(); + protected $map = array(); + protected $subject; + protected $className; + protected $mapName; + protected $mapKey; + protected $mapForeignKey; + protected $orderKey; + + protected $dbAdapter; + protected $foreignDBAdapter; + + + + public function __construct(ActiveRecord $subject, $className, $mapName, $mapKey, $mapForeignKey, $orderKey = null) { + $this->subject = $subject; + $this->className = $className; + $this->mapName = $mapName; + $this->mapKey = $mapKey; + $this->mapForeignKey = $mapForeignKey; + $this->orderKey = $orderKey; + } + + + + public function setDBAdapter(DBAdapter $dbAdapter) { + $this->dbAdapter = $dbAdapter; + } + + + + public function setForeignDBAdapter(DBAdapter $dbAdapter) { + $this->foreignDBAdapter = $dbAdapter; + } + + + + public function getIterator() { + $items = new ArrayObject; + if (!$this->subject->getPrimaryKeyValue()) { + $this->subject->save(); + } + $className = $this->className; + $target = new $className(); + $sql = " + SELECT * FROM {$this->mapName} + WHERE {$this->mapKey} = {$this->subject->getPrimaryKeyValue()} + "; + if ($this->orderKey) { + $sql .= " ORDER BY {$this->orderKey} ASC "; + } + $this->dbAdapter->execute($sql); + $this->items = array(); + $i = 0; + foreach ($this->dbAdapter as $row) { + $items[$i] = new $className(); + if ($this->foreignDBAdapter) { + $titems[$i]->setDBAdapter($this->foreignDBAdapter); + } else { + $items[$i]->setDBAdapter($this->dbAdapter); + } + $items[$i]->loadById($row[$this->mapForeignKey]); + ++$i; + } + return $items->getIterator(); + } + + + + public function add(ActiveRecord $ar) { + if (!$ar->getPrimaryKeyValue()) { + $ar->save(); + } + $dialect = $this->dbAdapter->getDialect(); + $sql = $dialect->getInsert( + $this->mapName, array( + $this->mapKey => $this->subject->getPrimaryKeyValue(), + $this->mapForeignKey => $ar->getPrimaryKeyValue() + ) + ); + $this->dbAdapter->execute($sql); + } + + + + public function remove(ActiveRecord $ar) { + $sql = " + DELETE FROM {$this->mapName} + WHERE {$this->mapKey} = '{$this->subject->getPrimaryKeyValue()}' + AND {$this->mapForeignKey} = '{$ar->getPrimaryKeyValue}' + "; + $this->dbAdapter->execute($sql); + } + + + +} // class ManyToManyRelation + +?> \ No newline at end of file Added: lib/model/active-record/OneToManyRelation.class.php =================================================================== --- lib/model/active-record/OneToManyRelation.class.php (rev 0) +++ lib/model/active-record/OneToManyRelation.class.php 2007-03-31 01:08:42 UTC (rev 78) @@ -0,0 +1,76 @@ +<?php + +class OneToManyRelation implements IteratorAggregate { + + + + protected $one; + protected $className; + protected $mappedKey; + protected $dbAdapter; + + protected static $cache; + + + + protected function __construct(ActiveRecord $one, $className, $mappedKey) { + $this->one = $one; + $this->className = $className; + $this->mappedKey = $mappedKey; + } + + + + public static function getInstance(ActiveRecord $one, $className, $mappedKey, DBAdapter $dbAdapter) { + $cachedRelation = &self::$cache[$one->getTableName()][$one->getPrimaryKeyValue()][$className]; + if (!$cachedRelation) { + $cachedRelation = new OneToManyRelation($one, $className, $mappedKey); + $cachedRelation->dbAdapter = $dbAdapter; + } + return $cachedRelation; + } + + + + public function getIterator() { + $className = $this->className; + $target = new $className(); + $targetPrimaryKeyName = $target->getPrimaryKeyName(); + $targetTableName = $target->getTableName(); + $sql = " + SELECT $targetPrimaryKeyName FROM $targetTableName + WHERE {$this->mappedKey} = '{$this->one->getPrimaryKeyValue()}' + "; + $this->dbAdapter->execute($sql); + $i = 0; + $many = new ArrayObject(); + foreach ($this->dbAdapter as $row) { + $many[$i] = new $className(); + $many[$i]->setDBAdapter($this->dbAdapter); + $many[$i]->loadById($row[$targetPrimaryKeyName]); // this is cached by ActiveRecord + ++$i; + } + return $many->getIterator(); + } + + + + public function add(ActiveRecord $ar) { + $ar->{$this->mappedKey} = $this->one->getPrimaryKeyValue(); + $ar->save(); + } + + + + public function remove(ActiveRecord $ar) { + if ($ar->{$this->mappedKey} == $this->one->getPrimaryKeyValue()) { + $ar->{$this->mappedKey} = null; + $ar->save(); + } + } + + + +} // class OneToManyRelation + +?> \ No newline at end of file Added: lib/model/data-source/ArrayDataSource.class.php =================================================================== --- lib/model/data-source/ArrayDataSource.class.php (rev 0) +++ lib/model/data-source/ArrayDataSource.class.php 2007-03-31 01:08:42 UTC (rev 78) @@ -0,0 +1,34 @@ +<?php + +class ArrayDataSource extends DataSource { + + + + protected $id; + public $data; + + + + public function fetch() { + $orderColumn = $this->getOrder(); + if (!$orderColumn) + return $this->data; + + $keys = array(); + foreach ($this->data as $i => $row) { + $keys[$i] = $row[$orderColumn]; + } + + $this->isDescending() ? krsort($keys) : ksort($keys); + $out = array(); + foreach ($keys as $k => $v) { + $out[] = $this->data[$k]; + } + return $out; + } + + + +} // class ArrayDataSource + +?> \ No newline at end of file Added: lib/model/data-source/CachingDataSource.class.php =================================================================== --- lib/model/data-source/CachingDataSource.class.php (rev 0) +++ lib/model/data-source/CachingDataSource.class.php 2007-03-31 01:08:42 UTC (rev 78) @@ -0,0 +1,21 @@ +<?php + +class CachingDataSource extends DataSourceDecorator { + + + + protected $cache = NULL; + + + + public function fetch() { + if ($this->cache === NULL) + $this->cache = parent::fetch(); + return $this->cache; + } + + + +} // class CachingDataSource + +?> \ No newline at end of file Added: lib/model/data-source/DataSource.class.php =================================================================== --- lib/model/data-source/DataSource.class.php (rev 0) +++ lib/model/data-source/DataSource.class.php 2007-03-31 01:08:42 UTC (rev 78) @@ -0,0 +1,76 @@ +<?php + +abstract class DataSource implements IDataSource { + + + + protected $id; + + public $defaultOrder; + public $defaultDescending = FALSE; + public $defaultOffset = 0; + public $defaultLimit = NULL; + + + + public function __construct($id) { + $this->id = $id; + if (!array_key_exists($this->id, $_SESSION)) { + $_SESSION[$this->id] = array(); + } + } + + + + public function fetch() { + throw new Exception('overwrite this method'); + } + + + + public function setOrder($column, $descending = false) { + $_SESSION[$this->id]['order'] = $column; + $_SESSION[$this->id]['descending'] = $descending; + } + + + + public function getOrder() { + return array_key_exists('order', $_SESSION[$this->id]) ? $_SESSION[$this->id]['order'] : $this->defaultOrder; + } + + + + public function isDescending() { + return array_key_exists('descending', $_SESSION[$this->id]) ? $_SESSION[$this->id]['descending'] : $this->defaultDescending; + } + + + + public function setOffset($offset) { + $_SESSION[$this->id]['offset'] = $offset; + } + + + + public function getOffset() { + return array_key_exists('offset', $_SESSION[$this->id]) ? $_SESSION[$this->id]['offset'] : $this->defaultOffset; + } + + + + public function setLimit($limit) { + $_SESSION[$this->id]['limit'] = $limit; + } + + + + public function getLimit() { + return array_key_exists('limit', $_SESSION[$this->id]) ? $_SESSION[$this->id]['limit'] : $this->defaultLimit; + } + + + +} // class DataSource + +?> \ No newline at end of file Added: lib/model/data-source/DataSourceDecorator.class.php =================================================================== --- lib/model/data-source/DataSourceDecorator.class.php (rev 0) +++ lib/model/data-source/DataSourceDecorator.class.php 2007-03-31 01:08:42 UTC (rev 78) @@ -0,0 +1,39 @@ +<?php + +abstract class DataSourceDecorator extends DataSource { + + + + protected $dataSource; + + + + public function __construct(IDataSource $dataSource) { + $this->dataSource = $dataSource; + } + + + + public function __call($method, $args) { + if (!is_callable($this->dataSource, $method)) + throw new Exception("no such method $method in decorated class ". get_class($this->dataSource)); + return call_user_func(array($this->dataSource, $method), $args); + } + + + + public function __get($property) { + return $this->dataSource->$property; + } + + + + public function __set($property, $value) { + $this->dataSource->$property = $value; + } + + + +} // class DataSourceDecorator + +?> \ No newline at end of file Added: lib/model/data-source/IDataSource.interface.php =================================================================== --- lib/model/data-source/IDataSource.interface.php (rev 0) +++ lib/model/data-source/IDataSource.interface.php 2007-03-31 01:08:42 UTC (rev 78) @@ -0,0 +1,41 @@ +<?php + +interface IDataSource { + + + + public function fetch(); + + + + public function setOrder($column, $descending = FALSE); + + + + public function getOrder(); + + + + public function isDescending(); + + + + public function setOffset($offset); + + + + public function getOffset(); + + + + public function setLimit($limit); + + + + public function getLimit(); + + + +} // interface IDataSource + +?> \ No newline at end of file Added: lib/model/data-source/SQLDataSource.class.php =================================================================== --- lib/model/data-source/SQLDataSource.class.php (rev 0) +++ lib/model/data-source/SQLDataSource.class.php 2007-03-31 01:08:42 UTC (rev 78) @@ -0,0 +1,36 @@ +<?php + +class SQLDataSource extends DataSource { + + + + protected $adapter; + protected $sql; + + + + public function __construct($id, DBAdapter $adapter, $sql) { + parent::__construct($id); + $this->adapter = $adapter; + $this->sql = $sql; + } + + + + public function fetch() { + $this->adapter->execute($this->getSQL()); + return $this->adapter->getIterator(); + } + + + + public function getSQL() { + $dialect = $this->adapter->getDialect(); + return $dialect->getSQL($this->sql, $this->getOrder(), $this->isDescending(), $this->getOffset(), $this->getLimit()); + } + + + +} // class SQLDataSource + +?> \ No newline at end of file Added: lib/model/db-adapter/DBAdapter.class.php =================================================================== --- lib/model/db-adapter/DBAdapter.class.php (rev 0) +++ lib/model/db-adapter/DBAdapter.class.php 2007-03-31 01:08:42 UTC (rev 78) @@ -0,0 +1,23 @@ +<?php + +abstract class DBAdapter implements IteratorAggregate{ + + + + abstract public function execute($sql, $sequenceName = null); + + + + public function getIterator() { + throw new Exception('overwrite this method'); + } + + + + abstract public function getDialect(); + + + +} // class DBAdapter + +?> \ No newline at end of file Added: lib/model/db-adapter/PDOAdapter.class.php =================================================================== --- lib/model/db-adapter/PDOAdapter.class.php (rev 0) +++ lib/model/db-adapter/PDOAdapter.class.php 2007-03-31 01:08:42 UTC (rev 78) @@ -0,0 +1,59 @@ +<?php + +class PDOAdapter extends DBAdapter { + + + + protected $pdo; + protected $dialect; + protected $result; + + + + public function __construct(PDO $pdo, SQLDialect $dialect) { + $this->pdo = $pdo; + $this->dialect = $dialect; + $this->result = new ArrayObject(); + } + + + + public function execute($sql, $sequenceName = null) { + $sql = trim($sql); + if (preg_match('/^SELECT/i', $sql)) { + $out = $this->pdo->query($sql); + if ($out instanceof PDOStatement) { + $this->result = new ArrayObject($out->fetchAll()); + $out->closeCursor(); + } else { + $this->result = new ArrayObject(); + } + return true; + } + $out = $this->pdo->exec($sql); + if (!$out) { + return false; + } + if (!$sequenceName or !preg_match('/^INSERT/', $sql)) { + return true; + } + return $this->pdo->lastInsertId($sequenceName); + } + + + + public function getIterator() { + return new ArrayIterator($this->result); + } + + + + public function getDialect() { + return $this->dialect; + } + + + +} // class PDOAdapter + +?> \ No newline at end of file Added: lib/model/db-adapter/PEARDBAdapter.class.php =================================================================== --- lib/model/db-adapter/PEARDBAdapter.class.php (rev 0) +++ lib/model/db-adapter/PEARDBAdapter.class.php 2007-03-31 01:08:42 UTC (rev 78) @@ -0,0 +1,49 @@ +<?php + +class PEARDBAdapter extends DBAdapter { + + + + protected $connection; + protected $dialect; + protected $result; + + + + public function __construct(DBConnection $connection, SQLDialect $dialect) { +throw new Exception('this class is broken, please fix it or do not use it'); + $this->connection = $connection; + $this->dialect = $dialect; + $this->result = new ArrayObject(); + } + + + + public function execute($sql, $sequenceName = null) { + $sql = trim($sql); + $out = $this->connection->query($sql); + if (PEAR::isError($out)) { + $this->result = new ArrayObject(); + } else { + $this->result = new ArrayObject($out->fetchAll()); + $out->freeResult(); + } + } + + + + public function getIterator() { + return new ArrayIterator($this->result); + } + + + + public function getDialect() { + return $this->dialect; + } + + + +} // class PEARDBAdapter + +?> \ No newline at end of file Added: lib/model/sql/MicrosoftSQLDialect.class.php =================================================================== --- lib/model/sql/MicrosoftSQLDialect.class.php (rev 0) +++ lib/model/sql/MicrosoftSQLDialect.class.php 2007-03-31 01:08:42 UTC (rev 78) @@ -0,0 +1,42 @@ +<?php + +/** + * SQL Dialect for Microsoft SQL Server and Access databases + * + * @author Michal Slaby + * @version DR1.4 + */ +class MicrosoftSQLDialect extends SQLDialect { + + + + public function getSQL($sql, $order, $descending, $offset, $limit) { + if ($order) { + $asc = $descending ? 'DESC' : 'ASC'; + $sql .= stristr($sql, 'ORDER') + ? ", $order $asc" + : " ORDER BY $order $asc"; + } + } + if ($offset) { + if (stristr($sql, 'OFFSET')) { + $sql = preg_replace('/OFFSET.*/', " OFFSET $offset", $sql); + } else { + $sql .= " OFFSET $offset"; + } + } + if ($limit) { + if (stristr($sql, 'SELECT TOP')) { + $sql = preg_replace('/SELECT TOP \d/', "SELECT TOP $limit ", $sql); + } else { + $sql = str_ireplace('SELECT ', "SELECT TOP $limit ", $sql); + } + } + return $sql; + } + + + +} // class MicrosoftSQLDialect + +?> \ No newline at end of file Added: lib/model/sql/SQL92Dialect.class.php =================================================================== --- lib/model/sql/SQL92Dialect.class.php (rev 0) +++ lib/model/sql/SQL92Dialect.class.php 2007-03-31 01:08:42 UTC (rev 78) @@ -0,0 +1,43 @@ +<?php + +/** + * SQL Dialect for SQL92 compatible RDBMS + * + * Works fine with PostgreSQL. Should work with Oracle, DB2 and Informix as well. + * + * @author Michal Slaby + * @version DR1.4 + */ +class SQL92Dialect extends SQLDialect { + + + + public function getSQL($sql, $order, $descending, $offset, $limit) { + if ($order) { + $asc = $descending ? 'DESC' : 'ASC'; + $sql .= stristr($sql, 'ORDER') + ? ", $order $asc" + : " ORDER BY $order $asc"; + } + if ($offset) { + if (stristr($sql, 'OFFSET')) { + $sql = preg_replace('/OFFSET.*/', " OFFSET $offset", $sql); + } else { + $sql .= " OFFSET $offset"; + } + } + if ($limit) { + if (stristr($sql, 'LIMIT')) { + $sql = preg_replace('/LIMIT.*/', " LIMIT $limit", $sql); + } else { + $sql .= " LIMIT $limit"; + } + } + return $sql; + } + + + +} // class SQL92Dialect + +?> \ No newline at end of file Added: lib/model/sql/SQLDialect.class.php =================================================================== --- lib/model/sql/SQLDialect.class.php (rev 0) +++ lib/model/sql/SQLDialect.class.php 2007-03-31 01:08:42 UTC (rev 78) @@ -0,0 +1,48 @@ +<?php + +/** + * SQL Dialect abstraction + * + * Abstracts out and hermetises SQL implementation differences. + * + * @author Michal Slaby + * @version DR1.4 + */ +abstract class SQLDialect { + + + + abstract public function getSQL($sql, $order, $descending, $offset, $limit); + + + + public function getInsert($tableName, $record) { + $keysList = implode(', ', array_keys($record)); + $vals = array(); + foreach ($record as $key => $value) { + $vals[] = ($value === null) + ? 'NULL' + : "'$value'"; + } + $valsList = implode(', ', $vals); + return "INSERT INTO $tableName ($keysList) VALUES ($valsList)"; + } + + + + public function getUpdate($tableName, $record, $primaryKey, $keyValue) { + $updates = array(); + foreach ($record as $key => $value) { + $updates[] = ($value === null) + ? "$key = NULL" + : "$key = '$value'"; + } + $updatesList = implode(', ', $updates); + return "UPDATE $tableName SET $updatesList WHERE $primaryKey = '$keyValue'"; + } + + + +} // class SQLDialect + +?> \ No newline at end of file Modified: var/cache/autoload.map =================================================================== --- var/cache/autoload.map 2007-03-31 01:05:53 UTC (rev 77) +++ var/cache/autoload.map 2007-03-31 01:08:42 UTC (rev 78) @@ -1 +1 @@ -a:60:{s:23:"HTTPResponseAjaxBackend";s:42:"lib/http/HTTPResponseAjaxBackend.class.php";s:29:"HTTPResponseAjaxBackendJsHook";s:48:"lib/http/HTTPResponseAjaxBackendJsHook.class.php";s:23:"HTTPResponseHTMLBackend";s:42:"lib/http/HTTPResponseHTMLBackend.class.php";s:15:"MouseUpListener";s:36:"lib/events/MouseUpListener.class.php";s:14:"ChangeListener";s:35:"lib/events/ChangeListener.class.php";s:15:"KeyDownListener";s:36:"lib/events/KeyDownListener.class.php";s:14:"ToggleListener";s:35:"lib/events/ToggleListener.class.php";s:12:"BlurListener";s:33:"lib/events/BlurListener.class.php";s:16:"KeyPressListener";s:37:"lib/events/KeyPressListener.class.php";s:13:"KeyUpListener";s:34:"lib/events/KeyUpListener.class.php";s:17:"DragStartListener";s:38:"lib/events/DragStartListener.class.php";s:13:"CloseListener";s:34:"lib/events/CloseListener.class.php";s:13:"FocusListener";s:34:"lib/events/FocusListener.class.php";s:16:"DropOntoListener";s:37:"lib/events/DropOntoListener.class.php";s:17:"MouseDownListener";s:38:"lib/events/MouseDownListener.class.php";s:13:"ClickListener";s:34:"lib/events/ClickListener.class.php";s:12:"SQL92Dialect";s:32:"model/sql/SQL92Dialect.class.php";s:19:"MicrosoftSQLDialect";s:39:"model/sql/MicrosoftSQLDialect.class.php";s:10:"SQLDialect";s:30:"model/sql/SQLDialect.class.php";s:13:"PEARDBAdapter";s:40:"model/db-adapter/PEARDBAdapter.class.php";s:10:"PDOAdapter";s:37:"model/db-adapter/PDOAdapter.class.php";s:9:"DBAdapter";s:36:"model/db-adapter/DBAdapter.class.php";s:18:"ManyToManyRelation";s:48:"model/active-record/ManyToManyRelation.class.php";s:12:"ActiveRecord";s:42:"model/active-record/ActiveRecord.class.php";s:17:"OneToManyRelation";s:47:"model/active-record/OneToManyRelation.class.php";s:13:"SQLDataSource";s:41:"model/data-source/SQLDataSource.class.php";s:19:"DataSourceDecorator";s:47:"model/data-source/DataSourceDecorator.class.php";s:17:"CachingDataSource";s:45:"model/data-source/CachingDataSource.class.php";s:10:"DataSource";s:38:"model/data-source/DataSource.class.php";s:15:"ArrayDataSource";s:43:"model/data-source/ArrayDataSource.class.php";s:8:"MoreCtrl";s:39:"view/core-containers/MoreCtrl.class.php";s:9:"TabFolder";s:40:"view/core-containers/TabFolder.class.php";s:3:"Box";s:34:"view/core-containers/Box.class.php";s:8:"FieldSet";s:39:"view/core-containers/FieldSet.class.php";s:4:"More";s:35:"view/core-containers/More.class.php";s:4:"HBox";s:35:"view/core-containers/HBox.class.php";s:3:"Tab";s:34:"view/core-containers/Tab.class.php";s:6:"Window";s:37:"view/core-containers/Window.class.php";s:4:"VBox";s:35:"view/core-containers/VBox.class.php";s:7:"TabView";s:38:"view/core-containers/TabView.class.php";s:13:"TabFolderCtrl";s:44:"view/core-containers/TabFolderCtrl.class.php";s:7:"HintBox";s:35:"view/experimental/HintBox.class.php";s:8:"MenuItem";s:33:"view/core-menu/MenuItem.class.php";s:4:"Menu";s:29:"view/core-menu/Menu.class.php";s:4:"Tree";s:29:"view/core-tree/Tree.class.php";s:8:"TreeCtrl";s:33:"view/core-tree/TreeCtrl.class.php";s:8:"TreeNode";s:33:"view/core-tree/TreeNode.class.php";s:4:"Form";s:30:"view/core-forms/Form.class.php";s:5:"Image";s:31:"view/core-forms/Image.class.php";s:11:"RadioButton";s:37:"view/core-forms/RadioButton.class.php";s:6:"Select";s:32:"view/core-forms/Select.class.php";s:5:"Input";s:31:"view/core-forms/Input.class.php";s:10:"RadioGroup";s:36:"view/core-forms/RadioGroup.class.php";s:6:"Button";s:32:"view/core-forms/Button.class.php";s:8:"TextArea";s:34:"view/core-forms/TextArea.class.php";s:9:"TableCtrl";s:35:"view/core-table/TableCtrl.class.php";s:8:"TableRow";s:34:"view/core-table/TableRow.class.php";s:5:"Table";s:31:"view/core-table/Table.class.php";s:9:"TableCell";s:35:"view/core-table/TableCell.class.php";s:11:"TableColumn";s:37:"view/core-table/TableColumn.class.php";} \ No newline at end of file +a:60:{s:23:"HTTPResponseAjaxBackend";s:42:"lib/http/HTTPResponseAjaxBackend.class.php";s:29:"HTTPResponseAjaxBackendJsHook";s:48:"lib/http/HTTPResponseAjaxBackendJsHook.class.php";s:23:"HTTPResponseHTMLBackend";s:42:"lib/http/HTTPResponseHTMLBackend.class.php";s:12:"SQL92Dialect";s:36:"lib/model/sql/SQL92Dialect.class.php";s:19:"MicrosoftSQLDialect";s:43:"lib/model/sql/MicrosoftSQLDialect.class.php";s:10:"SQLDialect";s:34:"lib/model/sql/SQLDialect.class.php";s:13:"PEARDBAdapter";s:44:"lib/model/db-adapter/PEARDBAdapter.class.php";s:10:"PDOAdapter";s:41:"lib/model/db-adapter/PDOAdapter.class.php";s:9:"DBAdapter";s:40:"lib/model/db-adapter/DBAdapter.class.php";s:18:"ManyToManyRelation";s:52:"lib/model/active-record/ManyToManyRelation.class.php";s:12:"ActiveRecord";s:46:"lib/model/active-record/ActiveRecord.class.php";s:17:"OneToManyRelation";s:51:"lib/model/active-record/OneToManyRelation.class.php";s:13:"SQLDataSource";s:45:"lib/model/data-source/SQLDataSource.class.php";s:19:"DataSourceDecorator";s:51:"lib/model/data-source/DataSourceDecorator.class.php";s:17:"CachingDataSource";s:49:"lib/model/data-source/CachingDataSource.class.php";s:10:"DataSource";s:42:"lib/model/data-source/DataSource.class.php";s:15:"ArrayDataSource";s:47:"lib/model/data-source/ArrayDataSource.class.php";s:15:"MouseUpListener";s:36:"lib/events/MouseUpListener.class.php";s:14:"ChangeListener";s:35:"lib/events/ChangeListener.class.php";s:15:"KeyDownListener";s:36:"lib/events/KeyDownListener.class.php";s:14:"ToggleListener";s:35:"lib/events/ToggleListener.class.php";s:12:"BlurListener";s:33:"lib/events/BlurListener.class.php";s:16:"KeyPressListener";s:37:"lib/events/KeyPressListener.class.php";s:13:"KeyUpListener";s:34:"lib/events/KeyUpListener.class.php";s:17:"DragStartListener";s:38:"lib/events/DragStartListener.class.php";s:13:"CloseListener";s:34:"lib/events/CloseListener.class.php";s:13:"FocusListener";s:34:"lib/events/FocusListener.class.php";s:16:"DropOntoListener";s:37:"lib/events/DropOntoListener.class.php";s:17:"MouseDownListener";s:38:"lib/events/MouseDownListener.class.php";s:13:"ClickListener";s:34:"lib/events/ClickListener.class.php";s:8:"MoreCtrl";s:39:"view/core-containers/MoreCtrl.class.php";s:9:"TabFolder";s:40:"view/core-containers/TabFolder.class.php";s:3:"Box";s:34:"view/core-containers/Box.class.php";s:8:"FieldSet";s:39:"view/core-containers/FieldSet.class.php";s:4:"More";s:35:"view/core-containers/More.class.php";s:4:"HBox";s:35:"view/core-containers/HBox.class.php";s:3:"Tab";s:34:"view/core-containers/Tab.class.php";s:6:"Window";s:37:"view/core-containers/Window.class.php";s:4:"VBox";s:35:"view/core-containers/VBox.class.php";s:7:"TabView";s:38:"view/core-containers/TabView.class.php";s:13:"TabFolderCtrl";s:44:"view/core-containers/TabFolderCtrl.class.php";s:7:"HintBox";s:35:"view/experimental/HintBox.class.php";s:8:"MenuItem";s:33:"view/core-menu/MenuItem.class.php";s:4:"Menu";s:29:"view/core-menu/Menu.class.php";s:4:"Tree";s:29:"view/core-tree/Tree.class.php";s:8:"TreeCtrl";s:33:"view/core-tree/TreeCtrl.class.php";s:8:"TreeNode";s:33:"view/core-tree/TreeNode.class.php";s:4:"Form";s:30:"view/core-forms/Form.class.php";s:5:"Image";s:31:"view/core-forms/Image.class.php";s:11:"RadioButton";s:37:"view/core-forms/RadioButton.class.php";s:6:"Select";s:32:"view/core-forms/Select.class.php";s:5:"Input";s:31:"view/core-forms/Input.class.php";s:10:"RadioGroup";s:36:"view/core-forms/RadioGroup.class.php";s:6:"Button";s:32:"view/core-forms/Button.class.php";s:8:"TextArea";s:34:"view/core-forms/TextArea.class.php";s:9:"TableCtrl";s:35:"view/core-table/TableCtrl.class.php";s:8:"TableRow";s:34:"view/core-table/TableRow.class.php";s:5:"Table";s:31:"view/core-table/Table.class.php";s:9:"TableCell";s:35:"view/core-table/TableCell.class.php";s:11:"TableColumn";s:37:"view/core-table/TableColumn.class.php";} \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-03-31 01:05:51
|
Revision: 77 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=77&view=rev Author: strongier Date: 2007-03-30 18:05:53 -0700 (Fri, 30 Mar 2007) Log Message: ----------- Removed Paths: ------------- model/active-record/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-03-31 00:54:50
|
Revision: 76 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=76&view=rev Author: strongier Date: 2007-03-30 17:54:23 -0700 (Fri, 30 Mar 2007) Log Message: ----------- Removed Paths: ------------- model/data-source/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-03-31 00:50:45
|
Revision: 75 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=75&view=rev Author: strongier Date: 2007-03-30 17:50:47 -0700 (Fri, 30 Mar 2007) Log Message: ----------- Removed Paths: ------------- model/db-adapter/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-03-31 00:49:34
|
Revision: 74 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=74&view=rev Author: strongier Date: 2007-03-30 17:49:35 -0700 (Fri, 30 Mar 2007) Log Message: ----------- Removed Paths: ------------- model/sql/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-03-30 18:12:33
|
Revision: 73 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=73&view=rev Author: strongier Date: 2007-03-30 11:12:34 -0700 (Fri, 30 Mar 2007) Log Message: ----------- Removed exception throwing from View::__toString() method Modified Paths: -------------- var/cache/autoload.map view/core-views/View.class.php Removed Paths: ------------- Tigermouse.php-no-autoload Deleted: Tigermouse.php-no-autoload =================================================================== --- Tigermouse.php-no-autoload 2007-03-30 18:11:36 UTC (rev 72) +++ Tigermouse.php-no-autoload 2007-03-30 18:12:34 UTC (rev 73) @@ -1,47 +0,0 @@ -<?php - -// View -require 'lib/view/IReadableView.interface.php'; -require 'lib/view/FormContext.class.php'; -require 'lib/view/ViewFilterIterator.class.php'; -require 'view/core-views/View.class.php'; -require 'view/core-views/Label.class.php'; -require 'view/core-views/Index.class.php'; -require 'view/core-views/ValueReadableView.class.php'; - -// Routing -require 'lib/routing/InterceptingFilter.interface.php'; -require 'lib/routing/Ctrl.class.php'; -require 'lib/routing/ActionService.class.php'; -require 'lib/routing/FrontCtrl.class.php'; - -// HTTP -require 'lib/http/HTTPRequest.class.php'; -require 'lib/http/HTTPResponse.class.php'; -require 'lib/http/HTTPResponseBackend.class.php'; - -// Events -require 'lib/events/EventSerializer.class.php'; -require 'lib/events/IActionAdapter.interface.php'; -require 'lib/events/Action.class.php'; -require 'lib/events/ActionAggregate.class.php'; -require 'lib/events/Behaviour.class.php'; -require 'lib/events/Listener.class.php'; -require 'lib/events/ClickListener.class.php'; -require 'lib/events/CloseListener.class.php'; -require 'lib/events/DragStartListener.class.php'; -require 'lib/events/DropOntoListener.class.php'; -require 'lib/events/KeyPressListener.class.php'; -require 'lib/events/ToggleListener.class.php'; - -// Model -require 'model/db-adapter/DBAdapter.class.php'; -require 'model/db-adapter/PDOAdapter.class.php'; -require 'model/data-source/IDataSource.interface.php'; -require 'model/data-source/DataSource.class.php'; -require 'model/data-source/ArrayDataSource.class.php'; -require 'model/data-source/SQLDataSource.class.php'; -require 'model/data-source/DataSourceDecorator.class.php'; -require 'model/data-source/CachingDataSource.class.php'; - -?> \ No newline at end of file Modified: var/cache/autoload.map =================================================================== --- var/cache/autoload.map 2007-03-30 18:11:36 UTC (rev 72) +++ var/cache/autoload.map 2007-03-30 18:12:34 UTC (rev 73) @@ -1 +1 @@ -a:63:{s:23:"HTTPResponseAjaxBackend";s:42:"lib/http/HTTPResponseAjaxBackend.class.php";s:29:"HTTPResponseAjaxBackendJsHook";s:48:"lib/http/HTTPResponseAjaxBackendJsHook.class.php";s:23:"HTTPResponseHTMLBackend";s:42:"lib/http/HTTPResponseHTMLBackend.class.php";s:13:"ActionCommand";s:35:"lib/routing/ActionCommand.class.php";s:15:"MouseUpListener";s:36:"lib/events/MouseUpListener.class.php";s:14:"ChangeListener";s:35:"lib/events/ChangeListener.class.php";s:15:"KeyDownListener";s:36:"lib/events/KeyDownListener.class.php";s:14:"ToggleListener";s:35:"lib/events/ToggleListener.class.php";s:12:"BlurListener";s:33:"lib/events/BlurListener.class.php";s:16:"KeyPressListener";s:37:"lib/events/KeyPressListener.class.php";s:13:"KeyUpListener";s:34:"lib/events/KeyUpListener.class.php";s:17:"DragStartListener";s:38:"lib/events/DragStartListener.class.php";s:13:"CloseListener";s:34:"lib/events/CloseListener.class.php";s:13:"FocusListener";s:34:"lib/events/FocusListener.class.php";s:16:"DropOntoListener";s:37:"lib/events/DropOntoListener.class.php";s:17:"MouseDownListener";s:38:"lib/events/MouseDownListener.class.php";s:13:"ClickListener";s:34:"lib/events/ClickListener.class.php";s:12:"SQL92Dialect";s:32:"model/sql/SQL92Dialect.class.php";s:19:"MicrosoftSQLDialect";s:39:"model/sql/MicrosoftSQLDialect.class.php";s:10:"SQLDialect";s:30:"model/sql/SQLDialect.class.php";s:13:"PEARDBAdapter";s:40:"model/db-adapter/PEARDBAdapter.class.php";s:10:"PDOAdapter";s:37:"model/db-adapter/PDOAdapter.class.php";s:9:"DBAdapter";s:36:"model/db-adapter/DBAdapter.class.php";s:18:"ManyToManyRelation";s:47:"model/experimental/ManyToManyRelation.class.php";s:12:"ActiveRecord";s:41:"model/experimental/ActiveRecord.class.php";s:17:"OneToManyRelation";s:46:"model/experimental/OneToManyRelation.class.php";s:13:"SQLDataSource";s:41:"model/data-source/SQLDataSource.class.php";s:19:"DataSourceDecorator";s:47:"model/data-source/DataSourceDecorator.class.php";s:17:"CachingDataSource";s:45:"model/data-source/CachingDataSource.class.php";s:10:"DataSource";s:38:"model/data-source/DataSource.class.php";s:15:"ArrayDataSource";s:43:"model/data-source/ArrayDataSource.class.php";s:8:"MoreCtrl";s:39:"view/core-containers/MoreCtrl.class.php";s:9:"TabFolder";s:40:"view/core-containers/TabFolder.class.php";s:3:"Box";s:34:"view/core-containers/Box.class.php";s:8:"FieldSet";s:39:"view/core-containers/FieldSet.class.php";s:4:"More";s:35:"view/core-containers/More.class.php";s:4:"HBox";s:35:"view/core-containers/HBox.class.php";s:3:"Tab";s:34:"view/core-containers/Tab.class.php";s:6:"Window";s:37:"view/core-containers/Window.class.php";s:4:"VBox";s:35:"view/core-containers/VBox.class.php";s:7:"TabView";s:38:"view/core-containers/TabView.class.php";s:13:"TabFolderCtrl";s:44:"view/core-containers/TabFolderCtrl.class.php";s:14:"FileUploadCtrl";s:42:"view/experimental/FileUploadCtrl.class.php";s:7:"HintBox";s:35:"view/experimental/HintBox.class.php";s:10:"FileUpload";s:38:"view/experimental/FileUpload.class.php";s:8:"MenuItem";s:33:"view/core-menu/MenuItem.class.php";s:4:"Menu";s:29:"view/core-menu/Menu.class.php";s:4:"Tree";s:29:"view/core-tree/Tree.class.php";s:8:"TreeCtrl";s:33:"view/core-tree/TreeCtrl.class.php";s:8:"TreeNode";s:33:"view/core-tree/TreeNode.class.php";s:4:"Form";s:30:"view/core-forms/Form.class.php";s:5:"Image";s:31:"view/core-forms/Image.class.php";s:11:"RadioButton";s:37:"view/core-forms/RadioButton.class.php";s:6:"Select";s:32:"view/core-forms/Select.class.php";s:5:"Input";s:31:"view/core-forms/Input.class.php";s:10:"RadioGroup";s:36:"view/core-forms/RadioGroup.class.php";s:6:"Button";s:32:"view/core-forms/Button.class.php";s:8:"TextArea";s:34:"view/core-forms/TextArea.class.php";s:9:"TableCtrl";s:35:"view/core-table/TableCtrl.class.php";s:8:"TableRow";s:34:"view/core-table/TableRow.class.php";s:5:"Table";s:31:"view/core-table/Table.class.php";s:9:"TableCell";s:35:"view/core-table/TableCell.class.php";s:11:"TableColumn";s:37:"view/core-table/TableColumn.class.php";} \ No newline at end of file +a:60:{s:23:"HTTPResponseAjaxBackend";s:42:"lib/http/HTTPResponseAjaxBackend.class.php";s:29:"HTTPResponseAjaxBackendJsHook";s:48:"lib/http/HTTPResponseAjaxBackendJsHook.class.php";s:23:"HTTPResponseHTMLBackend";s:42:"lib/http/HTTPResponseHTMLBackend.class.php";s:15:"MouseUpListener";s:36:"lib/events/MouseUpListener.class.php";s:14:"ChangeListener";s:35:"lib/events/ChangeListener.class.php";s:15:"KeyDownListener";s:36:"lib/events/KeyDownListener.class.php";s:14:"ToggleListener";s:35:"lib/events/ToggleListener.class.php";s:12:"BlurListener";s:33:"lib/events/BlurListener.class.php";s:16:"KeyPressListener";s:37:"lib/events/KeyPressListener.class.php";s:13:"KeyUpListener";s:34:"lib/events/KeyUpListener.class.php";s:17:"DragStartListener";s:38:"lib/events/DragStartListener.class.php";s:13:"CloseListener";s:34:"lib/events/CloseListener.class.php";s:13:"FocusListener";s:34:"lib/events/FocusListener.class.php";s:16:"DropOntoListener";s:37:"lib/events/DropOntoListener.class.php";s:17:"MouseDownListener";s:38:"lib/events/MouseDownListener.class.php";s:13:"ClickListener";s:34:"lib/events/ClickListener.class.php";s:12:"SQL92Dialect";s:32:"model/sql/SQL92Dialect.class.php";s:19:"MicrosoftSQLDialect";s:39:"model/sql/MicrosoftSQLDialect.class.php";s:10:"SQLDialect";s:30:"model/sql/SQLDialect.class.php";s:13:"PEARDBAdapter";s:40:"model/db-adapter/PEARDBAdapter.class.php";s:10:"PDOAdapter";s:37:"model/db-adapter/PDOAdapter.class.php";s:9:"DBAdapter";s:36:"model/db-adapter/DBAdapter.class.php";s:18:"ManyToManyRelation";s:48:"model/active-record/ManyToManyRelation.class.php";s:12:"ActiveRecord";s:42:"model/active-record/ActiveRecord.class.php";s:17:"OneToManyRelation";s:47:"model/active-record/OneToManyRelation.class.php";s:13:"SQLDataSource";s:41:"model/data-source/SQLDataSource.class.php";s:19:"DataSourceDecorator";s:47:"model/data-source/DataSourceDecorator.class.php";s:17:"CachingDataSource";s:45:"model/data-source/CachingDataSource.class.php";s:10:"DataSource";s:38:"model/data-source/DataSource.class.php";s:15:"ArrayDataSource";s:43:"model/data-source/ArrayDataSource.class.php";s:8:"MoreCtrl";s:39:"view/core-containers/MoreCtrl.class.php";s:9:"TabFolder";s:40:"view/core-containers/TabFolder.class.php";s:3:"Box";s:34:"view/core-containers/Box.class.php";s:8:"FieldSet";s:39:"view/core-containers/FieldSet.class.php";s:4:"More";s:35:"view/core-containers/More.class.php";s:4:"HBox";s:35:"view/core-containers/HBox.class.php";s:3:"Tab";s:34:"view/core-containers/Tab.class.php";s:6:"Window";s:37:"view/core-containers/Window.class.php";s:4:"VBox";s:35:"view/core-containers/VBox.class.php";s:7:"TabView";s:38:"view/core-containers/TabView.class.php";s:13:"TabFolderCtrl";s:44:"view/core-containers/TabFolderCtrl.class.php";s:7:"HintBox";s:35:"view/experimental/HintBox.class.php";s:8:"MenuItem";s:33:"view/core-menu/MenuItem.class.php";s:4:"Menu";s:29:"view/core-menu/Menu.class.php";s:4:"Tree";s:29:"view/core-tree/Tree.class.php";s:8:"TreeCtrl";s:33:"view/core-tree/TreeCtrl.class.php";s:8:"TreeNode";s:33:"view/core-tree/TreeNode.class.php";s:4:"Form";s:30:"view/core-forms/Form.class.php";s:5:"Image";s:31:"view/core-forms/Image.class.php";s:11:"RadioButton";s:37:"view/core-forms/RadioButton.class.php";s:6:"Select";s:32:"view/core-forms/Select.class.php";s:5:"Input";s:31:"view/core-forms/Input.class.php";s:10:"RadioGroup";s:36:"view/core-forms/RadioGroup.class.php";s:6:"Button";s:32:"view/core-forms/Button.class.php";s:8:"TextArea";s:34:"view/core-forms/TextArea.class.php";s:9:"TableCtrl";s:35:"view/core-table/TableCtrl.class.php";s:8:"TableRow";s:34:"view/core-table/TableRow.class.php";s:5:"Table";s:31:"view/core-table/Table.class.php";s:9:"TableCell";s:35:"view/core-table/TableCell.class.php";s:11:"TableColumn";s:37:"view/core-table/TableColumn.class.php";} \ No newline at end of file Modified: view/core-views/View.class.php =================================================================== --- view/core-views/View.class.php 2007-03-30 18:11:36 UTC (rev 72) +++ view/core-views/View.class.php 2007-03-30 18:12:34 UTC (rev 73) @@ -195,7 +195,8 @@ $f = $this->package . '/' . $this->template; if (!file_exists($smarty->template_dir . '/' . $f)) { if (!file_exists($smarty->template_dir . '/' . ($f = $this->template))) { - throw new Exception("cannot open file '$f' for view " . get_class($this)); + debug_print_backtrace(); + trigger_error("cannot open file '$f' for view " . get_class($this), E_USER_ERROR); } } $out = $smarty->fetch($f); This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-03-30 18:11:36
|
Revision: 72 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=72&view=rev Author: strongier Date: 2007-03-30 11:11:36 -0700 (Fri, 30 Mar 2007) Log Message: ----------- Moved ActiveRecord to main line Added Paths: ----------- model/active-record/ model/active-record/ActiveRecord.class.php model/active-record/ManyToManyRelation.class.php model/active-record/OneToManyRelation.class.php Added: model/active-record/ActiveRecord.class.php =================================================================== --- model/active-record/ActiveRecord.class.php (rev 0) +++ model/active-record/ActiveRecord.class.php 2007-03-30 18:11:36 UTC (rev 72) @@ -0,0 +1,296 @@ +<?php + +/** + * Active Record + * + * Persistent object stored in database table record. + * Handles 1-to-1, 1-to-many and many-to-many relations, as well as Class Table Inheritance. + * See Martin Fowler's Active Record design pattern for details. + * + * @author Michal Slaby + * @version DR1.4 + */ +abstract class ActiveRecord { + + + + protected $tableName; + protected $primaryKey = 'id'; + protected $sequenceName = ''; + + protected $data = array(); + protected $modified = false; + + protected $dbAdapter; + protected static $cache = array(); // FIXME + + protected $inheritsFrom = array(); // FIXME + protected $ancestor; + + protected $hasOne = array(); // array(field => array(className, foreignKey)) + protected $properties = array(); + + protected $hasMany = array(); // array(field => array(className, foreignKey)) + protected $propertiesCollections = array(); + + protected $belongsToOne = array(); // array(field => array(className, foreignKey)) + protected $owners = array(); + + protected $belongsToMany = array(); // array(field => array(className, foreignKey)) + protected $ownersCollections = array(); + + protected $manyToMany = array(); // array(field => array(className, mapName, mapPrimaryKey, mapForeignKey)) + protected $m2mCollections = array(); + + + + public function __construct() { + if (!$this->sequenceName) { + $this->sequenceName = $this->tableName . '_' . $this->primaryKey . '_seq'; + } + } + + + + /** + * Sets database access adapter + * + * @param DBAdapter $dbAdapter + */ + public function setDBAdapter($dbAdapter) { + $this->dbAdapter = $dbAdapter; + } + + + + /** + * Loads data from database table record by primary key + */ + public function loadById($id) { + $this->loadByFieldValue($this->primaryKey, $id); + } + + + + /** + * Loads data from database table record by any field value + */ + public function loadByFieldValue($k, $v) { + $className = get_class($this); + $sql = " + SELECT * FROM {$this->tableName} + WHERE $k = '$v' + "; + $this->dbAdapter->execute($sql); + foreach ($this->dbAdapter as $row) { + if (empty($this->data)) { + $this->data = $row; + } + self::$cache[$className][$row[$this->primaryKey]] = $this; + } + } + + + + /** + * Stores internal data and relations into database table record + */ + public function save() { + if ($this->modified) { + $dialect = $this->dbAdapter->getDialect(); + if (array_key_exists($this->primaryKey, $this->data) and $this->data[$this->primaryKey]) { + $sql = $dialect->getUpdate($this->tableName, $this->data, $this->primaryKey, $this->data[$this->primaryKey]); + $out = $this->dbAdapter->execute($sql); + } else { + $sql = $dialect->getInsert($this->tableName, $this->data); + if ($out = $this->dbAdapter->execute($sql, $this->sequenceName)) { + $this->data[$this->primaryKey] = $out; + } + } + if (!$out) { + throw new Exception('saving ' . get_class($this) . ' failed: ' . $sql); + } + $this->modified = false; + } + if ($this->ancestor) { + $this->ancestor->save(); + } + foreach ($this->properties as $property) { + $property->save(); + } + foreach ($this->owners as $owner) { + $owner->save(); + } + foreach ($this->propertiesCollections as $collection) { + foreach ($collection as $item) { + $item->save(); + } + } + foreach ($this->ownersCollections as $collection) { + foreach ($collection as $item) { + $item->save(); + } + } + } + + + + public function getPrimaryKeyName() { + return $this->primaryKey; + } + + + + public function getPrimaryKeyValue() { + return (array_key_exists($this->primaryKey, $this->data)) + ? $this->data[$this->primaryKey] + : null; + } + + + + public function getTableName() { + return $this->tableName; + } + + + + public function __get($field) { + if (array_key_exists($field, $this->hasOne)) { + return $this->getHasOne($field); + } + if (array_key_exists($field, $this->belongsToOne)) { + return $this->getBelongsToOne($field); + } + if (array_key_exists($field, $this->hasMany)) { + return $this->getHasMany($field); + } + if (array_key_exists($field, $this->belongsToMany)) { + return $this->getBelongsToMany($field); + } + if (array_key_exists($field, $this->manyToMany)) { + return $this->getM2M($field); + } + if (array_key_exists($field, $this->data)) { + return $this->data[$field]; + } + return null; + } + + + + public function __set($field, $value) { + if (array_key_exists($field, $this->hasOne)) { + $this->setHasOne($field, $value); + } elseif (array_key_exists($field, $this->belongsToOne)) { + $this->setBelongsToOne($field, $value); + } elseif (array_key_exists($field, $this->hasMany) + or array_key_exists($field, $this->belongsToMany) + or array_key_exists($field, $this->manyToMany)) { + throw new Exception('use add() to add item to hasMany or belongsToMany relation'); + } else { + $this->data[$field] = $value; + } + $this->modified = true; + } + + + + protected function getHasOne($field) { + if (!array_key_exists($field, $this->properties)) { + list($className, $foreignKey) = $this->hasOne[$field]; + $property = new $className(); + $property->setDBAdapter($this->dbAdapter); + $property->loadById($this->data[$foreignKey]); + $this->properties[$field] = $property; + } + return $this->properties[$field]; + } + + + + protected function setHasOne($field, ActiveRecord $ar) { + list($className, $foreignKey) = $this->hasOne[$field]; + if (!($ar instanceof $className)) { + throw new Exception("expected $className while setting property, got " . get_class($ar)); + } + if (!$this->getPrimaryKeyValue()) { + $this->save(); + } + if (!$ar->getPrimaryKeyValue()) { + $ar->save(); + } + $this->data[$foreignKey] = $ar->getPrimaryKeyValue(); + } + + + + protected function getHasMany($field) { + if (!array_key_exists($field, $this->ownersCollections)) { + list($className, $foreignKey) = $this->hasMany[$field]; + $this->ownersCollections[$field] = OneToManyRelation::getInstance($this, $className, $foreignKey, $this->dbAdapter); + } + return $this->ownersCollections[$field]; + } + + + + protected function getBelongsToOne($field) { + if (!array_key_exists($field, $this->owners)) { + list($className, $foreignKey) = $this->belongsToOne[$field]; + $owner = new $className(); + $owner->setDBAdapter($this->dbAdapter); + $owner->loadByFieldValue($foreignKey, $this->getPrimaryKeyValue()); + $this->owners[$field] = $owner; + } + return $this->owners[$field]; + } + + + + protected function setBelongsToOne($field, ActiveRecord $ar) { + list($className, $foreignKey) = $this->belongsToOne[$field]; + if (!($ar instanceof $className)) { + throw new Exception("expected $className while setting owner, got " . get_class($ar)); + } + if (!$this->getPrimaryKeyValue()) { + $this->save(); + } + if (!$ar->getPrimaryKeyValue()) { + $ar->save(); + } + $owner = $this->getBelongsToOne($field); + $owner->$foreignKey = $this->getPrimaryKeyValue(); + } + + + + protected function getBelongsToMany($field) { + if (!array_key_exists($field, $this->ownersCollections)) { + list($className, $foreignKey) = $this->belongsToMany[$field]; + $this->ownersCollections[$field] = OneToManyRelation::getInstance($this, $className, $foreignKey, $this->dbAdapter); + } + return $this->ownersCollections[$field]; + } + + + + protected function getM2M($field) { + if (!array_key_exists($field, $this->m2mCollections)) { + $this->m2mCollections[$field] = new ManyToManyRelation( + $this, + $this->manyToMany[$field][0], + $this->manyToMany[$field][1], + $this->manyToMany[$field][2], + $this->manyToMany[$field][3] + ); + $this->m2mCollections[$field]->setDBAdapter($this->dbAdapter); + } + return $this->m2mCollections[$field]; + } + + + +} // class ActiveRecord + +?> \ No newline at end of file Added: model/active-record/ManyToManyRelation.class.php =================================================================== --- model/active-record/ManyToManyRelation.class.php (rev 0) +++ model/active-record/ManyToManyRelation.class.php 2007-03-30 18:11:36 UTC (rev 72) @@ -0,0 +1,104 @@ +<?php + +class ManyToManyRelation implements IteratorAggregate { + + + protected $items = array(); + protected $map = array(); + protected $subject; + protected $className; + protected $mapName; + protected $mapKey; + protected $mapForeignKey; + protected $orderKey; + + protected $dbAdapter; + protected $foreignDBAdapter; + + + + public function __construct(ActiveRecord $subject, $className, $mapName, $mapKey, $mapForeignKey, $orderKey = null) { + $this->subject = $subject; + $this->className = $className; + $this->mapName = $mapName; + $this->mapKey = $mapKey; + $this->mapForeignKey = $mapForeignKey; + $this->orderKey = $orderKey; + } + + + + public function setDBAdapter(DBAdapter $dbAdapter) { + $this->dbAdapter = $dbAdapter; + } + + + + public function setForeignDBAdapter(DBAdapter $dbAdapter) { + $this->foreignDBAdapter = $dbAdapter; + } + + + + public function getIterator() { + $items = new ArrayObject; + if (!$this->subject->getPrimaryKeyValue()) { + $this->subject->save(); + } + $className = $this->className; + $target = new $className(); + $sql = " + SELECT * FROM {$this->mapName} + WHERE {$this->mapKey} = {$this->subject->getPrimaryKeyValue()} + "; + if ($this->orderKey) { + $sql .= " ORDER BY {$this->orderKey} ASC "; + } + $this->dbAdapter->execute($sql); + $this->items = array(); + $i = 0; + foreach ($this->dbAdapter as $row) { + $items[$i] = new $className(); + if ($this->foreignDBAdapter) { + $titems[$i]->setDBAdapter($this->foreignDBAdapter); + } else { + $items[$i]->setDBAdapter($this->dbAdapter); + } + $items[$i]->loadById($row[$this->mapForeignKey]); + ++$i; + } + return $items->getIterator(); + } + + + + public function add(ActiveRecord $ar) { + if (!$ar->getPrimaryKeyValue()) { + $ar->save(); + } + $dialect = $this->dbAdapter->getDialect(); + $sql = $dialect->getInsert( + $this->mapName, array( + $this->mapKey => $this->subject->getPrimaryKeyValue(), + $this->mapForeignKey => $ar->getPrimaryKeyValue() + ) + ); + $this->dbAdapter->execute($sql); + } + + + + public function remove(ActiveRecord $ar) { + $sql = " + DELETE FROM {$this->mapName} + WHERE {$this->mapKey} = '{$this->subject->getPrimaryKeyValue()}' + AND {$this->mapForeignKey} = '{$ar->getPrimaryKeyValue}' + "; + $this->dbAdapter->execute($sql); + } + + + +} // class ManyToManyRelation + +?> \ No newline at end of file Added: model/active-record/OneToManyRelation.class.php =================================================================== --- model/active-record/OneToManyRelation.class.php (rev 0) +++ model/active-record/OneToManyRelation.class.php 2007-03-30 18:11:36 UTC (rev 72) @@ -0,0 +1,76 @@ +<?php + +class OneToManyRelation implements IteratorAggregate { + + + + protected $one; + protected $className; + protected $mappedKey; + protected $dbAdapter; + + protected static $cache; + + + + protected function __construct(ActiveRecord $one, $className, $mappedKey) { + $this->one = $one; + $this->className = $className; + $this->mappedKey = $mappedKey; + } + + + + public static function getInstance(ActiveRecord $one, $className, $mappedKey, DBAdapter $dbAdapter) { + $cachedRelation = &self::$cache[$one->getTableName()][$one->getPrimaryKeyValue()][$className]; + if (!$cachedRelation) { + $cachedRelation = new OneToManyRelation($one, $className, $mappedKey); + $cachedRelation->dbAdapter = $dbAdapter; + } + return $cachedRelation; + } + + + + public function getIterator() { + $className = $this->className; + $target = new $className(); + $targetPrimaryKeyName = $target->getPrimaryKeyName(); + $targetTableName = $target->getTableName(); + $sql = " + SELECT $targetPrimaryKeyName FROM $targetTableName + WHERE {$this->mappedKey} = '{$this->one->getPrimaryKeyValue()}' + "; + $this->dbAdapter->execute($sql); + $i = 0; + $many = new ArrayObject(); + foreach ($this->dbAdapter as $row) { + $many[$i] = new $className(); + $many[$i]->setDBAdapter($this->dbAdapter); + $many[$i]->loadById($row[$targetPrimaryKeyName]); // this is cached by ActiveRecord + ++$i; + } + return $many->getIterator(); + } + + + + public function add(ActiveRecord $ar) { + $ar->{$this->mappedKey} = $this->one->getPrimaryKeyValue(); + $ar->save(); + } + + + + public function remove(ActiveRecord $ar) { + if ($ar->{$this->mappedKey} == $this->one->getPrimaryKeyValue()) { + $ar->{$this->mappedKey} = null; + $ar->save(); + } + } + + + +} // class OneToManyRelation + +?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-03-30 18:07:47
|
Revision: 71 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=71&view=rev Author: strongier Date: 2007-03-30 11:07:22 -0700 (Fri, 30 Mar 2007) Log Message: ----------- Removed experimental model files Removed Paths: ------------- model/experimental/ This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-03-28 21:08:14
|
Revision: 70 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=70&view=rev Author: strongier Date: 2007-03-28 14:08:12 -0700 (Wed, 28 Mar 2007) Log Message: ----------- Includes moved to external file, ActiveRecord tuned, DBAdapter interface change, DnD listeners allowed only for Action, spring clean. Modified Paths: -------------- Tigermouse.php Tigermouse.php-no-autoload autoload.php css.php index.php js.php lib/events/DragStartListener.class.php lib/events/DropOntoListener.class.php model/db-adapter/DBAdapter.class.php model/db-adapter/PEARDBAdapter.class.php model/experimental/ActiveRecord.class.php Added Paths: ----------- includes.php Removed Paths: ------------- model/experimental/test.php Modified: Tigermouse.php =================================================================== --- Tigermouse.php 2007-03-28 00:26:35 UTC (rev 69) +++ Tigermouse.php 2007-03-28 21:08:12 UTC (rev 70) @@ -1,12 +1,5 @@ <?php -/*** 3rd party libraries ***/ - -require 'JSON.php'; -require 'Smarty.class.php'; - -/*** Tigermouse ***/ - // View require 'lib/view/IReadableView.interface.php'; require 'lib/view/FormContext.class.php'; @@ -36,7 +29,6 @@ require 'lib/events/Listener.class.php'; // Model - require 'model/data-source/IDataSource.interface.php'; ?> \ No newline at end of file Modified: Tigermouse.php-no-autoload =================================================================== --- Tigermouse.php-no-autoload 2007-03-28 00:26:35 UTC (rev 69) +++ Tigermouse.php-no-autoload 2007-03-28 21:08:12 UTC (rev 70) @@ -1,12 +1,5 @@ <?php -/*** 3rd party libraries ***/ - -require_once 'JSON.php'; -require 'Smarty.class.php'; - -/*** Tigermouse ***/ - // View require 'lib/view/IReadableView.interface.php'; require 'lib/view/FormContext.class.php'; Modified: autoload.php =================================================================== --- autoload.php 2007-03-28 00:26:35 UTC (rev 69) +++ autoload.php 2007-03-28 21:08:12 UTC (rev 70) @@ -5,9 +5,7 @@ if (!$map) { $map = unserialize(file_get_contents('var/cache/autoload.map')); } - $fn = array_key_exists($className, $map) - ? $map[$className] - : NULL; + $fn = array_key_exists($className, $map) ? $map[$className] : null; if ($fn and file_exists($fn)) { include $fn; } Modified: css.php =================================================================== --- css.php 2007-03-28 00:26:35 UTC (rev 69) +++ css.php 2007-03-28 21:08:12 UTC (rev 70) @@ -1,14 +1,13 @@ <?php -require 'JSON.php'; -require 'Smarty.class.php'; +require 'includes.php'; $smarty = new Smarty(); $smarty->template_dir = 'view'; $smarty->compile_dir = 'var/smarty/compile'; $smarty->config_dir = 'var/smarty/config'; $smarty->cache_dir = 'var/smarty/cache'; -$smarty->use_sub_dirs = FALSE; +$smarty->use_sub_dirs = false; $smarty->left_delimiter = '{{'; $smarty->right_delimiter = '}}'; Added: includes.php =================================================================== --- includes.php (rev 0) +++ includes.php 2007-03-28 21:08:12 UTC (rev 70) @@ -0,0 +1,6 @@ +<?php + +require 'JSON.php'; +require 'Smarty.class.php'; + +?> \ No newline at end of file Modified: index.php =================================================================== --- index.php 2007-03-28 00:26:35 UTC (rev 69) +++ index.php 2007-03-28 21:08:12 UTC (rev 70) @@ -3,6 +3,7 @@ ob_start(); session_start(); +require 'includes.php'; require 'Tigermouse.php'; require 'autoload.php'; Modified: js.php =================================================================== --- js.php 2007-03-28 00:26:35 UTC (rev 69) +++ js.php 2007-03-28 21:08:12 UTC (rev 70) @@ -2,23 +2,21 @@ header('Content-type: text/javascript'); -$dirs = array('lib/view', 'view'); +$dir = 'view'; $line = 0; -foreach ($dirs as $dir) { - foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir)) as $entry) { - if (!$entry->isDir()) { - $filename = $entry->getPathname(); - if (preg_match('/.*\.js$/', $filename)) { - if (empty($_GET)) { - readfile($filename); - } else { - print("\n--- $filename ---\n\n"); - $f = file($filename); - foreach ($f as $localLine => $l) { - ++$line; - $ll = $localLine + 1; - print("$line ($ll) |\t$l"); - } +foreach (new RecursiveIteratorIterator(new RecursiveDirectoryIterator($dir)) as $entry) { + if (!$entry->isDir()) { + $filename = $entry->getPathname(); + if (preg_match('/.*\.js$/', $filename)) { + if (empty($_GET)) { + readfile($filename); + } else { + print("\n--- $filename ---\n\n"); + $f = file($filename); + foreach ($f as $localLine => $l) { + ++$line; + $ll = $localLine + 1; + print("$line ($ll) |\t$l"); } } } Modified: lib/events/DragStartListener.class.php =================================================================== --- lib/events/DragStartListener.class.php 2007-03-28 00:26:35 UTC (rev 69) +++ lib/events/DragStartListener.class.php 2007-03-28 21:08:12 UTC (rev 70) @@ -11,7 +11,7 @@ - public function __construct($protocol, IActionAdapter $adapter = NULL, $stay = FALSE) { + public function __construct($protocol, Action $adapter = NULL, $stay = FALSE) { parent::__construct($adapter); $this->protocol = $protocol; $this->stay = $stay; Modified: lib/events/DropOntoListener.class.php =================================================================== --- lib/events/DropOntoListener.class.php 2007-03-28 00:26:35 UTC (rev 69) +++ lib/events/DropOntoListener.class.php 2007-03-28 21:08:12 UTC (rev 70) @@ -10,7 +10,7 @@ - public function __construct($protocol, IActionAdapter $adapter = NULL) { + public function __construct($protocol, Action $adapter = NULL) { parent::__construct($adapter); $this->protocol = $protocol; } Modified: model/db-adapter/DBAdapter.class.php =================================================================== --- model/db-adapter/DBAdapter.class.php 2007-03-28 00:26:35 UTC (rev 69) +++ model/db-adapter/DBAdapter.class.php 2007-03-28 21:08:12 UTC (rev 70) @@ -4,7 +4,7 @@ - abstract public function execute($sql); + abstract public function execute($sql, $sequenceName = null); Modified: model/db-adapter/PEARDBAdapter.class.php =================================================================== --- model/db-adapter/PEARDBAdapter.class.php 2007-03-28 00:26:35 UTC (rev 69) +++ model/db-adapter/PEARDBAdapter.class.php 2007-03-28 21:08:12 UTC (rev 70) @@ -11,6 +11,7 @@ public function __construct(DBConnection $connection, SQLDialect $dialect) { +throw new Exception('this class is broken, please fix it or do not use it'); $this->connection = $connection; $this->dialect = $dialect; $this->result = new ArrayObject(); @@ -18,10 +19,8 @@ - public function execute($sql) { + public function execute($sql, $sequenceName = null) { $sql = trim($sql); -// $this->result = $this->pdo->exec($sql); - $out = $this->connection->query($sql); if (PEAR::isError($out)) { $this->result = new ArrayObject(); Modified: model/experimental/ActiveRecord.class.php =================================================================== --- model/experimental/ActiveRecord.class.php 2007-03-28 00:26:35 UTC (rev 69) +++ model/experimental/ActiveRecord.class.php 2007-03-28 21:08:12 UTC (rev 70) @@ -111,6 +111,7 @@ if (!$out) { throw new Exception('saving ' . get_class($this) . ' failed: ' . $sql); } + $this->modified = false; // echo "\n\n$sql\n\n"; } if ($this->ancestor) { Deleted: model/experimental/test.php =================================================================== --- model/experimental/test.php 2007-03-28 00:26:35 UTC (rev 69) +++ model/experimental/test.php 2007-03-28 21:08:12 UTC (rev 70) @@ -1,97 +0,0 @@ -<?php - -require '../db-adapter/DBAdapter.class.php'; -require '../db-adapter/PDOAdapter.class.php'; -require '../sql/SQLDialect.class.php'; -require '../sql/SQL92Dialect.class.php'; - -require 'ActiveRecord.class.php'; -require 'ManyToManyRelation.class.php'; -require 'OneToManyRelation.class.php'; - -$dsn = 'pgsql:dbname=test;user=mifau'; -$pdo = new PDO($dsn); -$db = new PDOAdapter($pdo, new SQL92Dialect()); - - - -// ----- - -class MyActiveRecord extends ActiveRecord { - public function __toString() { return get_class($this) . ' ' . $this->name . "\n"; } -} - -class User extends MyActiveRecord { - protected $tableName = 'users'; - protected $hasMany = array('emails' => array('Email', 'user_id')); - protected $hasOne = array( - 'accessLevel' => array('AccLevel', 'access_level_id'), - 'position' => array('Position', 'position_id') - ); - protected $manyToMany = array('roles' => array('Role', 'users_to_roles', 'user_id', 'role_id')); -} - -class Email extends MyActiveRecord { - protected $tableName = 'emails'; - protected $hasOne = array('user' => array('User', 'user_id')); -} - -class AccLevel extends MyActiveRecord { - protected $tableName = 'access_levels'; - protected $belongsToMany = array('users' => array('User', 'access_level_id')); -} - -class Role extends MyActiveRecord { - protected $tableName = 'roles'; - protected $manyToMany = array('users' => array('User', 'users_to_roles', 'role_id', 'user_id')); -} - -class Position extends MyActiveRecord { - protected $tableName = 'positions'; - protected $belongsToOne = array('user' => array('User', 'position_id')); -} - -// ----- -echo "\n\n\n\n\n * * * * * * * * * * *\n\n\n"; - - -$user = new User(); -$user->setDBAdapter($db); -$user->loadById(1); - -echo "\n\n=== one-to-many test\n"; -echo $user; -foreach ($user->emails as $email) { - echo $email; -} - -$al = new AccLevel(); -$al->setDBAdapter($db); -$al->loadById(1); -echo "\n\n=== many-to-one test\n"; -echo $al; -foreach ($al->users as $u) { - echo $u; -} - -echo "\n\n=== one-to-one test (has)\n"; -echo $user; -echo $user->accessLevel; -echo $user->position; - -echo "\n\n=== one-to-one test (belongsTo)\n"; -$p = new Position(); -$p->setDBAdapter($db); -$p->loadById(3); -echo $p; -echo $p->user; - echo $email; - echo $email->user; - -echo "\n\n=== many-to-many test\n"; -echo $user; -foreach ($user->roles as $r) { - echo $r; -} - -?> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <str...@us...> - 2007-03-28 00:26:35
|
Revision: 69 http://tigermouse.svn.sourceforge.net/tigermouse/?rev=69&view=rev Author: strongier Date: 2007-03-27 17:26:35 -0700 (Tue, 27 Mar 2007) Log Message: ----------- Pablo's patch for dnd. Patching utility Modified Paths: -------------- cleanup.sh lib/events/DragStartListener.class.php lib/events/DropOntoListener.class.php view/core-js/UITDraggable.js Added Paths: ----------- patch/ patch/apply.sh Modified: cleanup.sh =================================================================== --- cleanup.sh 2007-03-25 22:41:15 UTC (rev 68) +++ cleanup.sh 2007-03-28 00:26:35 UTC (rev 69) @@ -2,3 +2,5 @@ rm -f var/smarty/compile/* rm -f var/log/requests.log +rm -f patch/*.diff* + Modified: lib/events/DragStartListener.class.php =================================================================== --- lib/events/DragStartListener.class.php 2007-03-25 22:41:15 UTC (rev 68) +++ lib/events/DragStartListener.class.php 2007-03-28 00:26:35 UTC (rev 69) @@ -22,7 +22,7 @@ public function getSerializedAction() { $action = addslashes(parent::getSerializedAction()); $s = $this->stay ? 'true' : 'false'; - return "UITDraggabble.registerDragEnd('{$this->protocol}', '$action', $s)"; + return "UITDrag.init(event, this);UITDraggable.registerDragEnd('{$this->protocol}', '$action', $s)"; } Modified: lib/events/DropOntoListener.class.php =================================================================== --- lib/events/DropOntoListener.class.php 2007-03-25 22:41:15 UTC (rev 68) +++ lib/events/DropOntoListener.class.php 2007-03-28 00:26:35 UTC (rev 69) @@ -19,7 +19,7 @@ public function getSerializedAction() { $action = addslashes(parent::getSerializedAction()); - return "UITDraggabble.registerDropOnto('{$this->protocol}', '$action', $s)"; + return "if (UITDrag.isDragged()) {UITDraggable.registerDropOnto('{$this->protocol}', '$action');UITDraggable.trigger(); };"; } Added: patch/apply.sh =================================================================== --- patch/apply.sh (rev 0) +++ patch/apply.sh 2007-03-28 00:26:35 UTC (rev 69) @@ -0,0 +1,15 @@ +#!/bin/bash + +if [ "$1" == "" ]; then + echo "$0: diff file missing" + exit 1 +fi + +ORIG=`echo $1 | sed 's/\.diff$//'` +F=`find .. -name $ORIG | egrep -v '\.svn' | grep -v 'patch'` + +if [ ! -f $F ]; then + echo "$0: file $F not found" +fi + +patch -p0 $F < $1 Property changes on: patch/apply.sh ___________________________________________________________________ Name: svn:executable + * Modified: view/core-js/UITDraggable.js =================================================================== --- view/core-js/UITDraggable.js 2007-03-25 22:41:15 UTC (rev 68) +++ view/core-js/UITDraggable.js 2007-03-28 00:26:35 UTC (rev 69) @@ -8,29 +8,51 @@ UITDraggable.drops = new Array(); }, - registerDragEnd: function(protocol, action, args) { - UITDraggable.drags.push({protocol: protocol, action: action, args: args}); + registerDragEnd: function(protocol, action) { + UITDraggable.drags.push({protocol: protocol, action: action}); }, - registerDropOnto: function(protocol, action, args) { - UITDraggable.drops.push({protocol: protocol, action: action, args: args}); + registerDropOnto: function(protocol, action) { + UITDraggable.drops.push({protocol: protocol, action: action}); }, trigger: function() { + + for (var dragIndex = 0; dragIndex < UITDraggable.drags.length; ++dragIndex) { var drag = UITDraggable.drags[dragIndex]; for (var dropIndex = 0; dropIndex < UITDraggable.drops.length; ++dropIndex) { var drop = UITDraggable.drops[dropIndex]; if (drag.protocol == drop.protocol) { + var expreg = new RegExp (/^call\('(.*)', \[(.*)\]\);$/i); + if (expreg.test(drop.action) ) { + drop.action = RegExp.$1; + drop.args = RegExp.$2; + } + if(expreg.test(drag.action)){ + drag.action = RegExp.$1; + drag.args = RegExp.$2; + } var action = drop.action ? drop.action : drag.action; - call(action, drop.args.concat(drag.args)); -//alert(action + ' args=' + drop.args.concat(drag.args).join(',')); - UITDraggable.clear(); - return; + str ='['; + if (drop.args != ''){ + str = str+drop.args; + } + if (drop.args != '' && drag.args != ''){ + str = str+','; + } + + if (drag.args != ''){ + str = str+drag.args; + } + str =str+']'; + args = eval (str); + call(action, args); + //alert('['+drop.args.concat(drag.args)+']'); } + UITDraggable.clear(); + return; } } - UITDraggable.clear(); } - -}; +}; \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |