Skip to content

Commit

Permalink
Basic support for MySQL
Browse files Browse the repository at this point in the history
  • Loading branch information
KrisJordan committed Nov 22, 2008
1 parent e495024 commit 6c98232
Show file tree
Hide file tree
Showing 22 changed files with 143 additions and 215 deletions.
13 changes: 0 additions & 13 deletions apps/backend/BackEndApplication.class.php

This file was deleted.

16 changes: 0 additions & 16 deletions apps/backend/controllers/LoginController.class.php

This file was deleted.

22 changes: 10 additions & 12 deletions apps/blog/controllers/PostsController.class.php
Expand Up @@ -2,7 +2,6 @@
Library::import('blog.models.Post');
Library::import('blog.models.Comment');


/** !View Native, Prefix: home/ */
class PostsController extends Controller {

Expand All @@ -15,19 +14,18 @@ function home() {

}

/** !Route GET, posts */
function listPosts() {

echo 'hello world!';

}

/** !Route GET, alpha/ */
function alphabetical() {
/** !Route GET, new */
function newPost () { }

/** !Route POST, new */
function createNewPost () {

$this->latestPosts = Make::a('Post')->find()->orderBy('title')->range(0,5);
$post = new Post();
$post->copy($this->request->post);
$post->created = $post->modified = date( 'Y-m-d H:i:s', time() );
$post->save();

return $this->ok('home');
return $this->created('/blog/posts/' . $post->id, '/blog/');

}

Expand Down
2 changes: 2 additions & 0 deletions apps/blog/views/home/footer.php
@@ -0,0 +1,2 @@
</body>
</html>
3 changes: 3 additions & 0 deletions apps/blog/views/home/header.php
@@ -0,0 +1,3 @@
<html>
<head><title>My Weblog Application</title></head>
<body>
12 changes: 9 additions & 3 deletions apps/blog/views/home/home.php
@@ -1,3 +1,8 @@
<html>
<head></head>
<body>
<h1>My Blog</h1>
<a href="./new">Write New Post</a>
<?php

foreach($latestPosts as $post) {
Expand All @@ -7,8 +12,9 @@
echo '<p>' . $post->body . '</p>';

echo '<p><a href="comments/' . $post->id . '">' . $post->comments()->count() . ' Comments</a></p>';



}

?>
?>
</body>
</html>
13 changes: 13 additions & 0 deletions apps/blog/views/home/newPost.php
@@ -0,0 +1,13 @@
<?php include_once('header.php'); ?>

<h1>Create New Post</h1>

<form method="POST" action="./new">
<table>
<tr><td>Title</td><td><input type="text" name="title" /></td></tr>
<tr><td>Body</td><td><input type="text" name="body" /></td></tr>
<tr><td>Save</td><td><input type="submit" value="Post" /></td></tr>
</table>
</form>

<?php include_once('footer.php'); ?>
13 changes: 0 additions & 13 deletions apps/frontend/FrontEndApplication.class.php

This file was deleted.

17 changes: 0 additions & 17 deletions apps/frontend/controllers/PageController.class.php

This file was deleted.

15 changes: 0 additions & 15 deletions apps/nuevo/NuevoBlogApplication.class.php

This file was deleted.

12 changes: 0 additions & 12 deletions apps/nuevo/controllers/UserController.class.php

This file was deleted.

10 changes: 0 additions & 10 deletions apps/nuevo/models/User.class.php

This file was deleted.

75 changes: 0 additions & 75 deletions lib/recess/apps/ide/views/reflector/model.tpl

This file was deleted.

21 changes: 14 additions & 7 deletions lib/recess/diagnostics/output/exception_report.php
Expand Up @@ -52,14 +52,21 @@ function printObjectTable($var) {
print '<table class="classdetails">';
print '<thead class="subhead"><td>Member</td><td>Value</td></thead>';
$class = new ReflectionClass(get_class($var));
foreach($class->getProperties() as $property) {
if($property->isPublic()) {
print '<tr>';
print '<td>'; print $property->getName(); print '</td>';
print '<td>'; printValueOf($property->getValue($var)); print '</td>';
print '</tr>';
}
foreach(get_object_vars($var) as $key => $value) {
print '<tr>';
print '<td>'; print $key; print '</td>';
print '<td>'; printValueOf($value); print '</td>';
print '</tr>';
}

// foreach($class->getProperties() as $property) {
// if($property->isPublic()) {
// print '<tr>';
// print '<td>'; print $property->getName(); print '</td>';
// print '<td>'; printValueOf($property->getValue($var)); print '</td>';
// print '</tr>';
// }
// }
print '</table>';
}

Expand Down
5 changes: 5 additions & 0 deletions lib/recess/framework/Coordinator.class.php
Expand Up @@ -17,6 +17,9 @@ final class Coordinator {
* @static
*/
public static function main(Request $request, IPolicy $policy, array $apps, RoutingNode $routes, array $plugins = array()) {
static $callDepth = 0;
$callDepth++;
if($callDepth > 2) { echo 'too nested in main'; exit; }

$pluggedPolicy = $policy;

Expand All @@ -35,6 +38,8 @@ public static function main(Request $request, IPolicy $policy, array $apps, Rout

$view = $pluggedPolicy->getViewFor($response);

if($callDepth > 5) throw new RecessException('Forwarding depth too great.', get_defined_vars());

$view->respondWith($response);

if($response instanceof ForwardingResponse) {
Expand Down
10 changes: 6 additions & 4 deletions lib/recess/lang/RecessClass.class.php
Expand Up @@ -35,7 +35,6 @@ final function __call($name, $arguments) {
$classDescriptor = self::getClassDescriptor($this);

$attachedMethod = $classDescriptor->getAttachedMethod($name);

if($attachedMethod !== false) {
$object = $attachedMethod->object;
$method = $attachedMethod->method;
Expand All @@ -56,15 +55,18 @@ final function __call($name, $arguments) {
final static protected function getClassDescriptor($classNameOrInstance) {
if($classNameOrInstance instanceof RecessClass) {
$class = get_class($classNameOrInstance);
$instance = $classNameOrInstance;
} else {
$class = $classNameOrInstance;
$instance = new $class;
}

if(!isset(self::$descriptors[$class])) {
if(!isset(self::$descriptors[$class])) {
$cache_key = self::RECESS_CLASS_KEY_PREFIX . $class;
$descriptor = Cache::get($cache_key);
if($descriptor === false) {
if(is_subclass_of($class, __CLASS__)) {

if($descriptor === false) {
if($instance instanceof RecessClass) {
$descriptor = call_user_func(array($class, 'buildClassDescriptor'), $class);
Cache::set($cache_key, $descriptor);
self::$descriptors[$class] = $descriptor;
Expand Down
Expand Up @@ -103,12 +103,18 @@ protected function augmentSelect(PdoDataSet $select) {
$relatedClass = $this->through;
}

$relatedTable = Model::tableFor($relatedClass);
$localTable = Model::tableFor($this->localClass);
$foreignKey = $relatedTable . '.' . $this->foreignKey;
$primaryKey = Model::primaryKeyFor($this->localClass);

$select = $select
->from(Model::tableFor($relatedClass))
->innerJoin(Model::tableFor($this->localClass),
Model::tableFor($relatedClass) . '.' . $this->foreignKey,
Model::primaryKeyFor($this->localClass)
->from($relatedTable)
->innerJoin($localTable,
$foreignKey,
$primaryKey
);

$select->rowClass = $relatedClass;

if(!isset($this->through)) {
Expand Down

0 comments on commit 6c98232

Please sign in to comment.