Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

initial checkin

Signed-off-by: Chris Granger <chris@wrenchlabs.com>
  • Loading branch information...
commit a955373b3b0e90df7c0bc28531e42d5e981689d1 1 parent 951796d
Chris Granger authored
Showing with 871 additions and 187 deletions.
  1. +8 −45 bindings/bindings.php
  2. +37 −0 components/gallery.php
  3. +4 −4 components/test.php
  4. +90 −0 components/tests/ormObjectHandling_test.php
  5. +120 −0 components/tests/ormSQLGeneration_test.php
  6. +0 −13 components/tests/super_test.php
  7. +0 −18 components/tests/test_test.php
  8. +0 −13 components/tests/user_test.php
  9. +3 −3 components/user.php
  10. BIN  helpers/orm/.orm.php.swo
  11. BIN  helpers/orm/.orm.php.swp
  12. +319 −55 helpers/orm/orm.php
  13. +12 −4 helpers/unit/unit.php
  14. BIN  out/.DS_Store
  15. +90 −1 out/assets/css/default.css
  16. +3 −0  out/assets/css/slider.css
  17. BIN  out/assets/images/apartment/P2080144.jpg
  18. BIN  out/assets/images/apartment/P2080145.jpg
  19. BIN  out/assets/images/apartment/P2080146.jpg
  20. BIN  out/assets/images/apartment/P2080147.jpg
  21. BIN  out/assets/images/apartment/P2080148.jpg
  22. BIN  out/assets/images/apartment/P2080149.jpg
  23. BIN  out/assets/images/apartment/P2080150.jpg
  24. BIN  out/assets/images/apartment/P2080151.jpg
  25. BIN  out/assets/images/apartment/P2080152.jpg
  26. BIN  out/assets/images/apartment/P2080153.jpg
  27. BIN  out/assets/images/apartment/P2080154.jpg
  28. BIN  out/assets/images/apartment/P2080155.jpg
  29. BIN  out/assets/images/apartment/P2080156.jpg
  30. BIN  out/assets/images/apartment/P2080157.jpg
  31. BIN  out/assets/images/apartment/P2080158.jpg
  32. BIN  out/assets/images/apartment/P2080159.jpg
  33. BIN  out/assets/images/apartment/P2080160.jpg
  34. BIN  out/assets/images/apartment/P2080161.jpg
  35. BIN  out/assets/images/apartment/P2080162.jpg
  36. BIN  out/assets/images/apartment/P2080163.jpg
  37. BIN  out/assets/images/apartment/P2080164.jpg
  38. BIN  out/assets/images/apartment/P2080165.jpg
  39. BIN  out/assets/images/apartment/P2080166.jpg
  40. BIN  out/assets/images/apartment/P2080167.jpg
  41. BIN  out/assets/images/apartment/P2080168.jpg
  42. BIN  out/assets/images/apartment/P2080169.jpg
  43. BIN  out/assets/images/apartment/P2080170.jpg
  44. BIN  out/assets/images/featuredpostbg.jpg
  45. BIN  out/assets/images/headerbg.gif
  46. BIN  out/assets/images/headerbg.jpg
  47. BIN  out/assets/images/headerbg.png
  48. BIN  out/assets/images/openedtext.gif
  49. BIN  out/assets/images/subheaderbg.jpg
  50. BIN  out/assets/images/subheadertext1.gif
  51. BIN  out/assets/images/subheadertext2.gif
  52. +9 −0 out/assets/js/blog.js
  53. +27 −0 out/layouts/default.php
  54. +12 −0 out/layouts/lang.php
  55. +23 −7 out/layouts/test.php
  56. +34 −9 out/views/index.php
  57. +39 −0 out/views/lang.php
  58. +11 −0 out/views/pics/group.php
  59. +9 −0 out/views/pics/index.php
  60. 0  out/views/pics/single.php
  61. +17 −0 out/views/projects.php
  62. BIN  sys/.DS_Store
  63. +1 −1  sys/config/base.php
  64. BIN  sys/core/.event.php.swp
  65. +2 −12 sys/core/bm.php
  66. +1 −2  sys/core/event.php
View
53 bindings/bindings.php
@@ -1,6 +1,6 @@
<?php
-config::set('profiler.display', true);
+config::set('profiler.display', false);
config::set('profiler.showErrors', true);
config::set('unit.url', '/test');
@@ -9,48 +9,6 @@
config::set('validator.form.default', 'validate');
-config::set('database.config.group', 'localhost');
-config::set('database.config.localhost', array(
- 'username' => 'root',
- 'password' => 'root',
- 'hostname' => 'localhost',
- 'database' => 'test'
-));
-
-config::set('schema.company.has_one', array('companytype', 'user'));
-config::set('schema.user.has_one', array('usertype', 'email'));
-config::set('schema.email.has_one', array('emailtype'));
-config::set('schema.companytype.belongs_to_many', 'company');
-
-$yes = ORM::factory('company')->with('companytype', array('user', 'usertype', array('email', 'emailtype')))->order('user.name DESC')->fetch('massive');
-
-/*$yes = ORM::factory('company')
- ->with('companytype', 'user')
- ->where('company.name = "?"', 'woot')
- ->fetch('skookum');
- */
-
-
-/*
-class Company_Model extends orm {}
-class Project_Model extends orm {}
-
-
-profiler::start('test');
-$comp = ORM::factory('company');
-
-$comp->select('value')->find(1);
-//$comp->find(2);
-
-//$projects = ORM::factory('project');
-//$projects->select('name')->find_all();
-profiler::end('test');
-//var_dump($projects);
-*/
-
-//url listeners
-$this->event->register('url::/index','test::event');
-$this->event->register('url::/index', 'test::event2');
/*
access::restrict('/admin', array(
@@ -59,12 +17,19 @@ class Project_Model extends orm {}
));
*/
+//url listeners
+$this->event->register('url::/index','test::event');
+$this->event->register('url::/index', 'test::event2');
+
+
+
$this->event->register('url::/cool/test', 'test::event');
//form listeners
$this->event->register('submit::login', 'user::login');
$this->event->register('submit::login', 'test::event');
+
//custom
$this->event->register('kaboom', 'test::bombsquad');
@@ -73,5 +38,3 @@ class Project_Model extends orm {}
$this->event->register('sys::preForm', 'validator::dispatch');
$this->event->register('url::'.config::get('unit.url'), 'unit::runUnits');
-
-?>
View
37 components/gallery.php
@@ -0,0 +1,37 @@
+<?php
+
+class gallery extends trigger_component {
+
+ const IMAGEDIR = 'out/assets/images/';
+
+ function gallery() {
+ parent::__construct();
+
+ $this->OUTPUTDIR = FOLDER.'/assets/images/';
+
+ $this->group = $this->event->segment(1);
+ $this->picName = $this->event->segment(2);
+ }
+
+ public function pics() {
+
+ $pics = array();
+
+ if(!$this->picName) {
+ foreach (new DirectoryIterator(self::IMAGEDIR.$this->group) as $pic) {
+ if(substr($pic, 0, 1) != '.') {
+ $pics[] = $this->OUTPUTDIR."$this->group/$pic";
+ }
+ }
+ } else {
+ $pics[] = $this->OUTPUTDIR.$this->group.'/'.$this->picName;
+ }
+
+ return $pics;
+ }
+
+ public function group() {
+ return $this->group;
+ }
+
+}
View
8 components/test.php
@@ -10,16 +10,16 @@ function test() {
function event() {
//profiler::debug($this->event);
- echo 'responding to an event<br/>';
+ //echo 'responding to an event<br/>';
}
function event2($info) {
- echo 'second response to "event" - with info: '.$info.'<br/>';
+ //echo 'second response to "event" - with info: '.$info.'<br/>';
$this->event->trigger('kaboom');
}
function bombsquad() {
- echo 'bomb diffused<br/>';
+ //echo 'bomb diffused<br/>';
}
function info() {
@@ -53,4 +53,4 @@ function aggregate($node) {
}
-?>
+?>
View
90 components/tests/ormObjectHandling_test.php
@@ -0,0 +1,90 @@
+<?php
+
+class ormObjectHandling_test extends unit_test {
+
+ public function setup() {
+
+ config::set('database.config.group', 'localhost');
+ config::set('database.config.localhost', array(
+ 'username' => 'root',
+ 'password' => 'root',
+ 'hostname' => 'localhost',
+ 'database' => 'test'
+ ));
+
+ config::set('schema.company.has_one', array('companytype'));
+ config::set('schema.company.has_many', array('user'));
+ config::set('schema.company.has_and_belongs_to_many', array('category'));
+ config::set('schema.user.has_one', array('usertype', 'email'));
+ config::set('schema.email.has_one', array('emailtype'));
+ config::set('schema.companytype.belongs_to_many', 'company');
+
+ config::set('schema.company.fields', array('ID', 'name', 'companytype_ID', 'created_ts', 'modified_ts'));
+ config::set('schema.companytype.fields', array('ID', 'value', 'created_ts', 'modified_ts'));
+
+ config::set('schema.company.secondaryKey', 'name');
+
+ }
+
+ private function standardAssumptionForCompanyQuery($query) {
+ $this->assertTrue(is_object($query));
+ $this->assertEquals($query->count(), 2);
+
+ $this->assertEquals($query[0]->name, 'skookum');
+ $this->assertEquals($query[1]->name, 'wrenchlabs');
+ }
+
+ public function basic_test() {
+
+ $query = ORM::factory('company');
+ $this->assertTrue(is_object($query));
+
+ }
+
+ public function basicQuery_test() {
+
+ $query = ORM::factory('company')->fetch();
+
+ $this->standardAssumptionForCompanyQuery($query);
+ }
+
+ public function has_one_WithQuery_test() {
+
+ $query = ORM::factory('company')->with('companytype')->fetch();
+
+ $this->standardAssumptionForCompanyQuery($query);
+
+ $this->assertEquals($query[0]->companytype->value, 'small');
+
+
+
+ /*
+ $query->companytype = ORM::object('companytype');
+ $query->companytype->ID = '5';
+ $query->companytype->name = 'woot';
+ /*
+ $query->ID = 3;
+ $query->name = 'chris';
+ $query->category = ORM::factory('category')->fetch('super');
+
+ $query[1] = clone $query[0];
+ $query[1]->ID = 1;
+ $query[1]->name = 'robert';
+
+
+ foreach($query as $key=>$value) {
+ profiler::debug($value);
+ }
+
+ profiler::debug($query);
+ */
+ //$query->save();
+
+ /*$query = ORM::factory('company')
+ ->with('companytype', 'user')
+ ->where('company.name = "?"', 'woot')
+ ->fetch('skookum');
+ */
+ }
+
+}
View
120 components/tests/ormSQLGeneration_test.php
@@ -0,0 +1,120 @@
+<?php
+
+class ormSQLGeneration_test extends unit_test {
+
+ public function setup() {
+
+ config::set('database.config.group', 'localhost');
+ config::set('database.config.localhost', array(
+ 'username' => 'root',
+ 'password' => 'root',
+ 'hostname' => 'localhost',
+ 'database' => 'test'
+ ));
+
+ config::set('schema.company.has_one', array('companytype'));
+ config::set('schema.company.has_many', array('user'));
+ config::set('schema.company.has_and_belongs_to_many', array('category'));
+ config::set('schema.user.has_one', array('usertype', 'email'));
+ config::set('schema.email.has_one', array('emailtype'));
+ config::set('schema.companytype.belongs_to_many', 'company');
+
+ config::set('schema.company.secondaryKey', 'name');
+
+ }
+
+ public function basic_test() {
+
+ $query = ORM::factory('company');
+ $this->assertTrue(is_object($query));
+
+ }
+
+ public function basicQuery_test() {
+
+ $query = ORM::factory('company')->sqlMode(true)->fetch();
+ $this->assertEquals($query, 'SELECT company.* FROM company');
+
+ }
+
+ public function basicOrder_test() {
+ $query = ORM::factory('company')->order('company.name DESC')->sqlMode(true)->fetch();
+ $this->assertEquals($query, 'SELECT company.* FROM company ORDER BY company.name DESC');
+ }
+
+ public function multiOrder_test() {
+ $query = ORM::factory('company')->order('company.name ASC')->order('company.ID DESC')->sqlMode(true)->fetch();
+ $this->assertEquals($query, 'SELECT company.* FROM company ORDER BY company.name ASC, company.ID DESC');
+ }
+
+ public function basicGroup_test() {
+ $query = ORM::factory('company')->group('company.name')->sqlMode(true)->fetch();
+ $this->assertEquals($query, 'SELECT company.* FROM company GROUP BY company.name');
+ }
+
+ public function multiGroup_test() {
+ $query = ORM::factory('company')->group('company.name')->group('company.ID')->sqlMode(true)->fetch();
+ $this->assertEquals($query, 'SELECT company.* FROM company GROUP BY company.name, company.ID');
+ }
+
+ public function distinctQuery_test() {
+ $query = ORM::factory('company')->distinct()->sqlMode(true)->fetch();
+ $this->assertEquals($query, 'SELECT DISTINCT company.* FROM company');
+ }
+
+ public function calcFoundQuery_test() {
+ $query = ORM::factory('company')->calcFound()->sqlMode(true)->fetch();
+ $this->assertEquals($query, 'SELECT SQL_CALC_FOUND_ROWS company.* FROM company');
+ }
+
+ public function has_one_WithQuery_test() {
+
+ $query = ORM::factory('company')->with('companytype')->sqlMode(true)->fetch();
+ //single join created for the many-to-one or one-to-one relationship
+ $this->assertEquals($query, 'SELECT company.*, companytype.* FROM company LEFT JOIN companytype ON company.companytype_ID = companytype.ID');
+
+ }
+
+ public function has_many_WithQuery_test() {
+
+ $query = ORM::factory('company')->with('user')->sqlMode(true)->fetch();
+ //single join created for the one-to-many relationship
+ $this->assertEquals($query, 'SELECT company.*, user.* FROM company LEFT JOIN user ON company.ID = user.company_ID');
+
+ }
+
+ public function belongs_to_many_WithQuery_test() {
+
+ $query = ORM::factory('companytype')->with('company')->sqlMode(true)->fetch();
+ //single join created for the one-to-many relationship
+ $this->assertEquals($query, 'SELECT companytype.*, company.* FROM companytype LEFT JOIN company ON company.companytype_ID = companytype.ID');
+
+ }
+
+ public function has_and_belongs_to_many_WithQuery_test() {
+
+ $query = ORM::factory('company')->with('category')->sqlMode(true)->fetch();
+ //should use a junction table and then join through that
+ //two joins created.
+ $this->assertEquals($query, 'SELECT company.*, category.* FROM company LEFT JOIN category_company ON company.ID = category_company.company_ID LEFT JOIN category ON category_company.category_ID = category.ID');
+
+ }
+
+ public function multiWith_test() {
+ $query = ORM::factory('company')->with('companytype', 'category', 'user')->sqlMode(true)->fetch();
+ $this->assertEquals($query, 'SELECT company.*, companytype.*, category.*, user.* FROM company LEFT JOIN companytype ON company.companytype_ID = companytype.ID LEFT JOIN category_company ON company.ID = category_company.company_ID LEFT JOIN category ON category_company.category_ID = category.ID LEFT JOIN user ON company.ID = user.company_ID');
+ }
+
+ public function nestedWith_test() {
+ $query = ORM::factory('company')->with(array('user', 'usertype'))->sqlMode(true)->fetch();
+ $this->assertEquals($query, 'SELECT company.*, user.*, usertype.* FROM company LEFT JOIN user ON company.ID = user.company_ID LEFT JOIN usertype ON user.usertype_ID = usertype.ID');
+ }
+
+ public function fullQuery_test() {
+
+ $query = ORM::factory('company')->with('companytype', 'category', array('user', 'usertype', array('email', 'emailtype')))->order('user.name DESC')->calcFound()->sqlMode(true)->fetch('massive');
+ $this->assertEquals($query, 'SELECT SQL_CALC_FOUND_ROWS company.*, companytype.*, category.*, user.*, usertype.*, email.*, emailtype.* FROM company LEFT JOIN companytype ON company.companytype_ID = companytype.ID LEFT JOIN category_company ON company.ID = category_company.company_ID LEFT JOIN category ON category_company.category_ID = category.ID LEFT JOIN user ON company.ID = user.company_ID LEFT JOIN usertype ON user.usertype_ID = usertype.ID LEFT JOIN email ON user.email_ID = email.ID LEFT JOIN emailtype ON email.emailtype_ID = emailtype.ID WHERE company.name = "massive" ORDER BY user.name DESC');
+
+ }
+
+}
View
13 components/tests/super_test.php
@@ -1,13 +0,0 @@
-<?php
-
-class super_test extends unit_test {
-
- function woot_test() {
- $this->assertTrue(true);
- }
-
- function super_awesome_test() {
- $this->assertFalse(true);
- }
-
-}
View
18 components/tests/test_test.php
@@ -1,18 +0,0 @@
-<?php
-
-class test_test extends unit_test {
-
- function addA_test() {
- $str = 'look';
- $this->assertEquals($this->event->call('test::addA', $str), 'lookA!');
- }
-
- function super_awesome_test() {
- $this->assertFalse(true);
- }
-
- function woot() {
- echo 'yay';
- }
-
-}
View
13 components/tests/user_test.php
@@ -1,13 +0,0 @@
-<?php
-
-class user_test extends unit_test {
-
- function woot_test() {
- $this->assertTrue(true);
- }
-
- function super_awesome_test() {
- $this->assertFalse(true);
- }
-
-}
View
6 components/user.php
@@ -9,12 +9,12 @@ function login() {
//$this->event->preventTrigger('sys::preOutput');
$this->event->revert();
} else {
- echo 'you tried to login!<br/>';
- echo $this->get('test::info').'<br />';
+ //echo 'you tried to login!<br/>';
+ //echo $this->get('test::info').'<br />';
}
}
}
-?>
+?>
View
BIN  helpers/orm/.orm.php.swo
Binary file not shown
View
BIN  helpers/orm/.orm.php.swp
Binary file not shown
View
374 helpers/orm/orm.php
@@ -4,15 +4,20 @@ class ORM {
static $link = false;
- private $table = '';
- private $order = array();
- private $where = array();
- private $join = array();
- private $values = array();
- private $from = array();
- private $selectModifiers = array();
- private $limit = '';
- private $offset = '';
+ private $_sql = "";
+
+ private $_from = array();
+ private $_order = array();
+ private $_where = array();
+ private $_joins = array();
+ private $_modifiers = array();
+ private $_limit = '';
+ private $_offset = '';
+
+ private $_select = array();
+ private $_selectOrder = array();
+
+ private $relationships = array();
private $getCount = false;
@@ -24,13 +29,17 @@ class ORM {
private $objectTree;
private $primaryKey = 'ID';
- private $secondaryKey = 'name';
+ private $secondaryKey = false;
static function factory($table) {
return new ORM($table);
}
+ static function object($table) {
+ return new resultObject($table, array( (object) null ));
+ }
+
public function __construct($table) {
if( !self::$link ) {
@@ -39,6 +48,7 @@ public function __construct($table) {
$this->table = $table;
$this->from($table);
+ $this->defaultValues[] = $table.'.*';
$this->objectTree = (object) NULL;
$this->result = (object) NULL;
@@ -50,21 +60,27 @@ public function fetch($ID = false) {
$this->limitByKey($ID);
- $sql = "SELECT ";
+ $sql = "SELECT";
- $sql .= $this->concatSection('selectModifiers', '', ' ');
- $sql .= $this->concatSection('values', ' ', ', ');
- $sql .= $this->concatSection('from', ' FROM ', ', ').' ';
+ $sql .= $this->concatSection('selectModifiers', ' ', ' ');
+
+ if(!empty($this->values)) {
+ $sql .= $this->concatSection('values', ' ', ', ');
+ } else {
+ $sql .= $this->concatSection('defaultValues', ' ', ', ');
+ }
+
+ $sql .= $this->concatSection('from', ' FROM ', ', ');
if( !empty( $this->join ) ) {
foreach($this->join as $join) {
- $sql .= $join[0]. ' JOIN '.$join[1] .' ON '.$join[2].' ';
+ $sql .= ' '.$join[0]. ' JOIN '.$join[1] .' ON '.$join[2];
}
}
- $sql .= $this->concatSection('where', 'WHERE ');
- $sql .= $this->concatSection('group', ' GROUP BY ');
- $sql .= $this->concatSection('order', ' ORDER BY ');
+ $sql .= $this->concatSection('where', ' WHERE ');
+ $sql .= $this->concatSection('group', ' GROUP BY ', ', ');
+ $sql .= $this->concatSection('order', ' ORDER BY ', ', ');
if( !empty( $this->limit ) ) {
$sql .= " LIMIT $this->limit ";
@@ -74,36 +90,153 @@ public function fetch($ID = false) {
$sql .= " OFFSET $this->offset ";
}
- profiler::debug($sql);
- profiler::debug($this);
- }
-
- public function save($ID = false) {
-
- if( !$this->changed ) {
- return $this;
- }
+ $sql = trim($sql);
- if(!$this->ID && $ID === false) {
- $add = true;
+ if(!$this->sqlMode) {
+ $result = $this->query($sql);
+ return new resultObject($this->table, $result);
} else {
- $this->limitByKey($ID);
+ return $sql;
}
- //perform an add or an update as appropriate
-
}
public function delete($ID = false) {
}
- public function update($ID = false) {
+ private function recursiveSave($field, $value) {
+
+ //check the relationship type
+ $relationship = $this->findRelationship($this->table, $field);
+
+ switch( $relationship ) {
+
+ case 'has_one':
+
+ $cur = $value->as_array();
+ $cur = $cur[0];
+
+ if( !isset($cur->ID) ) {
+ //add it
+ $orm = ORM::factory($field);
+ //TODO:: account for non-result objects
+ $orm->add($cur);
+ $cur->ID = $this->lastInsertID();
+ } else {
+ //TODO:: call an update here, has ones might change with the object
+ }
+
+ return array(
+ 'fieldName' => "$this->table.{$field}_ID",
+ 'fieldValue' => $cur->ID
+ );
+
+ break;
+
+ case 'has_many':
+
+ //delete and add?
+
+ break;
+
+ case 'has_and_belongs_to_many':
+
+ //delete all
+ //add them in
+
+ break;
+
+ }
+
+ return '';
+
+ }
+
+ public function update($object) {
+
+ $sql = "UPDATE $this->table SET ";
+
+ foreach($object as $field => $value) {
+ if(!is_object($value) && !is_array($value)) {
+ $sql .= "$this->table.$field = '$value', ";
+ } else {
+
+ $parts = $this->recursiveSave($field, $value);
+ if( !empty( $parts ) ) {
+ $sql .= "$parts[fieldName] = '$parts[fieldValue]', ";
+ }
+
+ }
+ }
+ $sql = substr($sql, 0, -2);
+ $sql .= " WHERE $this->table.ID = '$object->ID'";
+
+ if(!$this->sqlMode) {
+ //TODO: perform query
+ } else {
+ return $sql;
+ }
}
public function add($objectsToAdd) {
+ if( !is_array($objectsToAdd) ) {
+
+ $objectsToAdd = array($objectsToAdd);
+
+ }
+
+ $firstObject = $objectsToAdd[0];
+
+ $fields = array_keys( get_object_vars( $firstObject ) );
+ $fieldsString = '';
+
+ foreach($fields as $field) {
+ if( is_object( $firstObject->$field ) || is_array( $firstObject->$field ) ) {
+
+ $type = $this->findRelationship($this->table, $field);
+ if($type == 'has_one') {
+ $fieldsString .= "`{$field}_ID`, ";
+ }
+
+ } else {
+ $fieldsString .= "`$field`, ";
+ }
+ }
+
+ $fieldsString = substr($fieldsString, 0, -2);
+
+ $sql = "INSERT INTO $this->table ($fieldsString) VALUES ";
+ foreach($objectsToAdd as $object) {
+ $sql .= "( ";
+ foreach($fields as $curField) {
+
+ $value = $object->$curField;
+
+ if( !is_object($value) && !is_array($value) ) {
+ $sql .= "'$value', ";
+ } else {
+
+ $parts = $this->recursiveSave($curField, $value);
+
+ if( !empty( $parts ) ) {
+ $sql .= "'$parts[fieldValue]', ";
+ }
+
+ }
+ }
+ $sql = substr($sql, 0, -2) . ' ), ';
+ }
+ $sql = substr($sql, 0, -2);
+
+ if(!$this->sqlMode) {
+ //TODO: perform query
+ } else {
+ return $sql;
+ }
+
}
public function getNumFound() {
@@ -154,14 +287,11 @@ private function internalWith($tables, $curTable, $curBranch) {
$rel = $cur;
$recurse = true;
}
-
- $curBranch->$rel = (object) NULL;
-
- $relationships = config::get('schema.'.$curTable);
- if($key = $this->recursive_array_search($rel, $relationships)) {
+ if($key = $this->findRelationship($curTable, $rel)) {
$this->$key($rel, $curTable);
+ $curBranch->$rel = (object) NULL;
}
@@ -173,45 +303,66 @@ private function internalWith($tables, $curTable, $curBranch) {
}
+ private function findRelationship($curTable, $relatedTable) {
+
+ $relationships = config::get('schema.'.$curTable);
+ return $this->recursive_array_search($relatedTable, $relationships);
+
+ }
+
private function recursive_array_search($needle, $haystack) {
foreach($haystack as $key => $value) {
+
if( is_array( $value ) ) {
+
$found = $this->recursive_array_search($needle, $value);
if($found !== false) {
return $key;
}
+
} else {
+
if( $value == $needle) {
return $key;
}
+
}
+
}
return false;
}
private function has_one($tableToJoin, $origTable) {
+
$this->leftJoin($tableToJoin, "$origTable.{$tableToJoin}_ID = $tableToJoin.ID");
+
}
private function belongs_to_many($tableToJoin, $origTable) {
- $this->leftJoin($tableToJoin, "$tableToJoin.{$origTable}_ID = $tableToJoin.ID");
+
+ $this->leftJoin($tableToJoin, "$tableToJoin.{$origTable}_ID = $origTable.ID");
+
}
private function has_many($tableToJoin, $origTable) {
+
$this->leftJoin($tableToJoin, "$origTable.ID = $tableToJoin.{$origTable}_ID");
+
}
private function has_and_belongs_to_many($tableToJoin, $origTable) {
- if($tableToJoin[0] > $origTable[0]) {
+
+ if($tableToJoin > $origTable) {
$junctionName = $origTable.'_'.$tableToJoin;
} else {
$junctionName = $tableToJoin.'_'.$origTable;
}
- $this->leftJoin($junctionName, "$origTable.ID = $junctionName.{$origTable}_ID");
+ $this->join('LEFT', $junctionName, "$origTable.ID = $junctionName.{$origTable}_ID", false);
$this->leftJoin($tableToJoin, "$junctionName.{$tableToJoin}_ID = $tableToJoin.ID");
+
}
private function limitByKey($key) {
@@ -226,13 +377,18 @@ private function limitByKey($key) {
$this->andWhere($this->table.'.'.$this->primaryKey . ' = "?"', $key);
//otherwise see if a secondary key is set
- } else if( $this->secondaryKey && is_string( $this->secondaryKey ) ) {
+ } else {
- $this->andWhere($this->table . '.' . $this->secondaryKey . ' = "?"', $key);
+ if(!$this->secondaryKey) {
+ $this->secondaryKey = config::get("schema.$this->table.secondaryKey");
+ }
+
+ if( $this->secondaryKey && is_string( $key ) ) {
+ $this->andWhere($this->table . '.' . $this->secondaryKey . ' = "?"', $key);
+ }
}
-
}
public function from() {
@@ -266,7 +422,7 @@ public function where($where, $value = false) {
foreach($value as $val) {
$valString = '"'.$this->escape($val).'", ';
}
- $valString = rtrim($valString, ', ');
+ $valString = substr($valString, 0, -2);
} else {
@@ -308,6 +464,12 @@ public function order($order) {
return $this;
}
+ public function group($group) {
+ $this->group[] = $group;
+
+ return $this;
+ }
+
public function limit($limit) {
$this->limit = $limit;
@@ -320,7 +482,12 @@ public function offset($offset) {
return $this;
}
- public function join($type, $table, $on) {
+ public function join($type, $table, $on, $addValues = true) {
+
+ if( $addValues ) {
+ $this->defaultValues[] = $table.'.*';
+ }
+
$this->join[] = array($type, $table, $on);
return $this;
@@ -344,12 +511,23 @@ public function escape($text) {
return mysql_real_escape_string($text);
}
+ public function lastInsertID() {
+ return mysql_insert_id();
+ }
+
public function calcFound() {
$this->selectModifiers[] = 'SQL_CALC_FOUND_ROWS ';
+ return $this;
}
public function distinct() {
$this->selectModifiers[] = 'DISTINCT ';
+ return $this;
+ }
+
+ public function sqlMode($onOff) {
+ $this->sqlMode = $onOff;
+ return $this;
}
public function query($sql) {
@@ -361,24 +539,32 @@ public function query($sql) {
$ob = array();
if (!$result) {
- trigger_error('mysql: ['.mysql_errno().'] '.mysql_error().(PROFILER ? ' <a href="#queries'.($querynum + 1).'">(see profiler query '.($querynum + 1).')</a>' : ''), E_USER_WARNING);
+ trigger_error('mysql: ['.mysql_errno().'] '.mysql_error().(config::get('profiler.display') ? ' <a href="#queries'.($querynum + 1).'">(see profiler query '.($querynum + 1).')</a>' : ''), E_USER_WARNING);
profiler::failedQuery('ERROR '.mysql_errno().': '.mysql_error());
} else {
if( is_resource($result) ) {
- while($row = mysql_fetch_object($result)) {
+ //TODO: make this build objects recursively.
+ while($row = mysql_fetch_array($result)) {
$ob[] = $row;
}
}
$this->numRows = mysql_num_rows($result);
-
+
}
return $ob;
}
+ public function buildObject($array) {
+
+ //given a 0 indexed array of results
+
+
+ }
+
public function connect() {
$group = config::get('database.config.group');
@@ -390,21 +576,99 @@ public function connect() {
}
+}
+
+class resultObject implements ArrayAccess, Countable, Iterator {
+
+ private $__tablename;
+ private $__results;
+ private $__position = 0;
+ private $__changed = false;
+
+ function __construct($tablename, $results = array()) {
+ $this->__tablename = $tablename;
+ $this->__results = $results;
+ }
+
public function __set($name, $value) {
- if( !isset($this->result->$name) || $this->result->$name != $value) {
- $this->changed = true;
+ $cur =& $this->current();
+
+ if( !isset($cur->$name) || $cur->$name != $value) {
+ $this->__changed = true;
}
- $this->result->$name = $value;
+ $cur->$name = $value;
return true;
}
public function __get($name) {
- if( isset($this->result->$name) ) {
- return $this->result->$name;
+
+ $cur = $this->current();
+
+ if( isset($cur->$name) ) {
+ return $cur->$name;
}
return false;
}
-}
+ public function as_array() {
+ return $this->__results;
+ }
+
+ public function save() {
+ if( !isset($this->current()->ID) ) {
+ ORM::factory($this->__tablename)->add($this->__results);
+ } else {
+ foreach($this->__results as $res) {
+ ORM::factory($this->__tablename)->update($res);
+ }
+ }
+ }
+
+ public function isEmpty() {
+ return empty($this->__results);
+ }
+
+ public function rewind() {
+ $this->__position = 0;
+ }
+
+ public function current() {
+ return $this->__results[$this->key()];
+ }
+
+ public function key() {
+ return $this->__position;
+ }
+
+ public function next() {
+ ++$this->__position;
+ }
+
+ public function valid() {
+ return isset($this->__results[$this->__position]);
+ }
+
+ public function count() {
+ return count($this->__results);
+ }
+
+ public function offsetSet($offset, $value) {
+ $this->__changed = true;
+ $this->__results[$offset] = $value;
+ }
+
+ public function offsetExists($offset) {
+ return isset($this->__results[$offset]);
+ }
+
+ public function offsetUnset($offset) {
+ unset($this->__results[$offset]);
+ }
+
+ public function offsetGet($offset) {
+ return isset($this->__results[$offset]) ? $this->__results[$offset] : null;
+ }
+
+}
View
16 helpers/unit/unit.php
@@ -5,6 +5,7 @@ class unit_test {
public $errors;
public $numtests;
public $failedtests;
+ private $curTestFunc;
public function __construct() {
$this->event =& getEventObject();
@@ -24,6 +25,7 @@ public function run() {
call_user_func(array(&$this, 'setup'), array());
}
$this->numtests++;
+ $this->curTestFunc = $m;
call_user_func(array(&$this, $m), array());
}
}
@@ -55,10 +57,16 @@ public function assertEquals($a1, $a2) {
public function throwError($msg) {
$stack = debug_backtrace();
$curfunction = $stack[2]["function"];
+
+ if($curfunction != $this->curTestFunc) {
+ //display the test name
+ $curfunction = $this->curTestFunc." ($curfunction)";
+ }
+
$curline = $stack[1]["line"];
$this->errors[] = array("line"=>$curline, "function"=>$curfunction, "msg"=>$msg);
- if(!in_array($curfunction, $this->failedtests)) {
- $this->failedtests[] = $curfunction;
+ if(!in_array($this->curTestFunc, $this->failedtests)) {
+ $this->failedtests[] = $this->curTestFunc;
}
}
}
@@ -107,7 +115,7 @@ static function results() {
foreach($object->passedtests as $e) {
$str .= "<span style='padding-left:15px; color:#3b3; font:bold 110% Arial, serif;'>$e</span><br/>";
}
- $str .= "}";
+ $str .= "}</br></br>";
} else {
$num = count($object->errors);
$passed = $object->numtests - count($object->failedtests);
@@ -118,7 +126,7 @@ static function results() {
foreach($object->passedtests as $e) {
$str .= "<span style='padding-left:15px; color:#3b3; font:bold 110% Arial, serif;'>$e</span><br/>";
}
- $str .= "}<br/>";
+ $str .= "}<br/></br>";
}
}
View
BIN  out/.DS_Store
Binary file not shown
View
91 out/assets/css/default.css
@@ -1 +1,90 @@
-body {background:#222; color:#ccc;}
+/* Reset browser styles: get to a known state. */
+html, body, h1, h2, h3, h4, h5, h6, table, tr, th, td, form, fieldset, select, input, textarea, dl, dt, dd, ul, ol, li, address, blockquote, pre, code { margin: 0; padding: 0; }
+body { font: normal 62.5% Verdana, sans-serif; }
+h1, h2, h3, h4, h5, h6 { font-size: 100%; }
+
+a { outline: none; }
+img { border: none; }
+
+p { margin: 1em 0; }
+* html p { margin: .83333em 0; }
+
+/* Doc flow. */
+.block { display: block !important; }
+.inline { display: inline !important; }
+.left { float: left !important; display: inline !important; }
+.right { float: right !important; display: inline !important; }
+.clear { clear: both !important; }
+
+/* Margins. */
+.collapse { margin: 0 !important; }
+.first { margin-left: 0 !important; }
+.last { margin-right: 0 !important; }
+.top { margin-top: 0 !important; }
+.bottom { margin-bottom: 0 !important; }
+
+/* Site specific styles. */
+
+body { padding:0; margin:0; background: #09283D; color:#ddd; font-family: Verdana;}
+div { margin:0; padding:0;}
+div.content div { padding:15px; }
+div.content { overflow:hidden;}
+div.header {padding-top:20px; padding-bottom:0; height:50px; background:url('/assets/images/headerbg.jpg') repeat-x; margin-bottom:0;}
+div.header h1 { margin-top:15px; font-size:23pt; display:inline; float:left;}
+div.header ul {list-style:none; list-style-position:outside; font:normal 10pt Verdana; float:right; display:inline; margin-top:30px; }
+div.header ul li {float:left; display:inline; padding-left:10px; margin-left:10px; }
+div.header ul li+li {border-left:1px solid #666;}
+
+div.content div.subhead { padding:25px 20px; background: #92CC47 url('/assets/images/subheaderbg.jpg'); color:#204757; font:bold 12pt Verdana; margin:0;}
+div.subhead p {padding:0; margin:0; text-align:left; margin-top:5px;}
+div.subhead span {display:block; color:#3C6C6E; font:normal 10pt Verdana;}
+
+a { color:#75CC04; text-decoration:none; }
+
+span.date { font-weight:normal; font-size:80%; }
+
+div.content div.boxes { background:transparent; min-height:400px; padding:0; font:normal 10pt Verdana;}
+div.boxes div.one, div.boxes div.two, div.boxes div.three {min-height:400px; padding:0; padding-bottom:2000px; margin-bottom:-2000px; }
+div.boxes ul {list-style:none;}
+
+
+div.boxes .one { float:left; display:inline; width:45%; background:#204757; }
+div.boxes .one li { padding:10px; margin:10px; background:#09283D;}
+div.boxes .one li h2 { text-align:right; }
+div.boxes div.one div.admin { padding:20px; }
+div.boxes div.one div.admin textarea {width:100%; height:200px;}
+div.boxes div.one div.admin input.text {width:70%;}
+
+div.boxes .extended { width:73%; }
+
+div.boxes .two { float:left; display:inline; background:#3C6C6E; width:27%; }
+div.boxes .two h3 { margin-left:10px; margin-top:30px; padding:5px; background:#204757; width:45%;}
+div.boxes .two ul { margin-top:10px;}
+div.boxes .two li a {display:block; padding:5px; background:#204757; margin:0 10px 2px 10px; text-align:center;}
+* html div.boxes .two li a {margin:0; padding:0;}
+div.boxes .two li a:hover { background: #09283D; }
+
+div.boxes .three { float:left; display:inline; width:28%; background:#325566;}
+div.boxes .spec {background:#061724; margin-bottom:10px;}
+
+div.spec { width:500px; margin-bottom:10px; font-size:130%; font-weight:normal; font-family:Verdana; float:left; display:inline; }
+div.spec p { margin-top: 0; }
+div.spec ul { padding-left:30px; list-style:disc; }
+div.spec ul li { margin-bottom:5px; }
+ul.posts { width: 600; float:left; display:inline; padding: 0px 0pt; }
+li.post { float:left; display:inline; width:100%; margin-bottom:20px; }
+li.post div.side {float: left; display: inline; width: 80px; font-family: Skia, Trebuchet MS, Verdana; }
+li.post h1 { font-size:170%; font-weight:normal; color: #9bd;}
+li.post h2 { font-size:120%; font-weight:normal; color:#579; }
+body.empty {background:#0c0f12; margin-bottom:10px;}
+div.outerwrapper { padding: 50px 100px; }
+
+div.nav { float:left; display:inline; margin-left:40px;}
+div.nav ul { list-style:none; text-align:right;}
+div.nav ul li { margin-bottom:10px; }
+div.nav a { color: #55b9ff; font-size: 110%; }
+div.nav a:hover {}
+
+a.internal { color: #55b9ff; }
+
+div.navi { position: fixed; top:50%; width:10px; width:25; background:#15191f; height:90px; border: 1px solid #444; border-left:none; }
View
3  out/assets/css/slider.css
@@ -0,0 +1,3 @@
+
+body { padding:0; margin:0; background: #09283D; color:#ddd; font-family: Verdana;}
+div { margin:0; padding:0;}
View
BIN  out/assets/images/apartment/P2080144.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080145.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080146.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080147.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080148.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080149.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080150.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080151.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080152.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080153.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080154.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080155.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080156.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080157.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080158.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080159.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080160.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080161.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080162.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080163.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080164.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080165.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080166.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080167.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080168.jpg
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN  out/assets/images/apartment/P2080169.jpg
Diff not rendered
View
BIN  out/assets/images/apartment/P2080170.jpg
Diff not rendered
View
BIN  out/assets/images/featuredpostbg.jpg
Diff not rendered
View
BIN  out/assets/images/headerbg.gif
Diff not rendered
View
BIN  out/assets/images/headerbg.jpg
Diff not rendered
View
BIN  out/assets/images/headerbg.png
Diff not rendered
View
BIN  out/assets/images/openedtext.gif
Diff not rendered
View
BIN  out/assets/images/subheaderbg.jpg
Diff not rendered
View
BIN  out/assets/images/subheadertext1.gif
Diff not rendered
View
BIN  out/assets/images/subheadertext2.gif
Diff not rendered
View
9 out/assets/js/blog.js
@@ -0,0 +1,9 @@
+
+$(document).ready( function() {
+
+ $("a.hider").click( function(event) {
+ $(this).next().toggle("woot");
+ return false;
+ });
+
+});
View
27 out/layouts/default.php
@@ -0,0 +1,27 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+ <head>
+ <title>Opened. - <?php echo config::get('site.title'); ?></title>
+ <?php echo tag::style('default'); ?>
+ </head>
+ <body>
+ <div class="content">
+ <div class="header">
+ <h1><a href="/"><img src="/stateful/assets/images/openedtext.gif" alt="Opened." /></a></h1>
+ <ul>
+ <li><?php echo tag::a('blog/', 'blog'); ?></li>
+ <li><?php echo tag::a('links/', 'links'); ?></li>
+ <li><?php echo tag::a('creative/', 'creative'); ?></li>
+ <li><?php echo tag::a('projects/', 'projects'); ?></li>
+ <li><?php echo tag::a('admin/', 'admin'); ?></li>
+ </ul>
+ </div>
+ <div class="subhead">
+ <p><img src="/stateful/assets/images/subheadertext1.gif" alt="We are what we make of ourselves..." />
+ <span><img src="/stateful/assets/images/subheadertext2.gif" alt="and this is what I've made: musings, ramblings, technology, poetry, music, life." /></span></p>
+ </div>
+
+ <?php echo $yield; ?>
+ </div>
+ </body>
+</html>
View
12 out/layouts/lang.php
@@ -0,0 +1,12 @@
+<html>
+ <head>
+ <title>Slider - <?php echo isset($title) ? $title : ''; ?></title>
+ <?php echo tag::style('slider'); ?>
+ </head>
+ <body>
+ <div>
+ <p>Try me.. I dare you</p>
+ <?php echo $yield; ?>
+ </div>
+ </body>
+</html>
View
30 out/layouts/test.php
@@ -1,12 +1,28 @@
<html>
<head>
- <title>this is a test layout - <?php echo isset($title) ? $title : ''; ?></title>
+ <script type="text/javascript"
+ src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.js"> </script>
<?php echo tag::style('default'); ?>
+ <?php echo tag::script('blog'); ?>
</head>
- <body>
- <div>
- <p>welcome to the layout</p>
- <?php echo $yield; ?>
- </div>
+ <body class="empty">
+ <div class="navi">
+ <a href="">Filter</a>
+ </div>
+ <div class="outerwrapper">
+ <?php echo $yield; ?>
+ <div class="nav">
+ <ul>
+ <li><a href="/lang">blog</a></li>
+ <li><a href="/links">links</a></li>
+ <li><a href="/creative">creative</a></li>
+ <li><a href="/projects">projects</a></li>
+ </ul>
+ <div class="navi">
+ <a href="">Prev</a>
+ <a href="">Next</a>
+ </div>
+ </div>
+ </div>
</body>
-</html>
+</html>
View
43 out/views/index.php
@@ -1,9 +1,34 @@
-<?php $this->useTemplate('test'); ?>
-<form action="/cool/test" method="post">
- <input type="hidden" name="formName" value="login" />
- <dl>
- <dt>username</dt>
- <dd><input name="username" type="text" /></dd>
- </dl>
- <input type="submit" />
-</form>
+<?php config::set('site.title', 'main page'); $this->useTemplate('default'); ?>
+<div class="boxes">
+ <div class="one">
+ <div class="spec">
+ <p>Imagine something much bigger than anything you've ever dreamed of
+ before... and then pretend that you could somehow achieve that with
+ unquestionable certainty.</p>
+ <p><a href="">Lorem</a> ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+ </div>
+ <p><a href="">Lorem</a> ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+ </div>
+ <div class="two">
+ <ul>
+ <li><?php echo tag::a('blog', 'Main Page'); ?></li>
+ <li><?php echo tag::a('blog-filter/', 'Filter'); ?></li>
+ <li><?php echo tag::a('blog-prev/', 'Older Posts'); ?></li>
+ </ul>
+
+
+ <h3>New in Links:</h3>
+ <ul>
+ <?php $links = array(); foreach($links as $link) { ?>
+ <li><a href="<?php echo 'http://'.$link->url; ?>" target="_blank" title="<?php echo $link->description; ?>"><?php echo $link->text; ?></a></li>
+ <?php } ?>
+ </ul>
+ </div>
+ <div class="three">
+ <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+ </div>
+</div>
View
39 out/views/lang.php
@@ -0,0 +1,39 @@
+<?php config::set('site.title', 'main page'); $this->useTemplate('test'); ?>
+<ul class="posts">
+ <li class="post">
+ <div class="side">
+ <h1>7/21/09</h1>
+ <h2>11:08pm</h2>
+ <span>3 comments</span>
+ </div>
+ <div class="spec">
+ <p><a href="">Every once</a> in a while you just want something simple and easy to make, and
+ what's a better comfort food than spaghetti? That doesn't mean, though, that
+ you have to settle for something straight out of a jar. We're all adults, and
+ I think it's worth putting just a tad bit more effort into making some
+ sophisticated food. The nice part is that this won't take you any longer than
+ it normally would, but the result will be truly incomparable to prego. I'm not
+ into recipes, since I do everything by smell and taste - so I'm not going to
+ give you a recipe. Instead, I'll share with you the things I learned while
+ trying to take a "tired" dish like spaghetti and make it something to get
+ excited about again. </p>
+ <a href="#" class="internal hider">read more</a>
+ <ul style="display:none;"><li>Use the simplest tomato sauce you can find. This means either getting something like the plain flavored Ragu sauce (I highly recommend this as a good starting base) or plain tomato sauce out of a can. If you use the canned tomato sauce, though, I would add some olive oil to the mix to give it a bit of richness.</li><li>Always heat your sauce. If you don't believe me that it makes a difference, try this sometime: put a little sauce in a pan and heat it up for about 5 minutes, now pour a little cold sauce in next to it. Notice how differently colored they are? There's a reason for that... you're releasing the flavor in the sauce.</li><li>If you're making spaghetti with meat sauce (Bolognese) cook the meat (I use ground turkey, personally) with a couple cloves of garlic and about half an onion diced. I really like to use red onion (red sauce, red onion right?), but yellow would work just as well.</li><li>If you're not making meat sauce, saute some onion and some garlic together anyway, and then add your tomato sauce to the pan.</li><li>One of the best things you can do to really make your spaghetti pop is to use red pepper flakes. Now, before you get worried, you don't have to put in enough that you actually make it hot (although that's really good), just enough that you get some of the pepper flavor in the sauce. Black pepper is useful here too, but if you're making a red sauce, you absolutely should have some red in there - it's a very different flavor.</li><li>Given that most italian dishes are tomato, cream, or wine based, why not add all of them to your sauce? I add a bit of red wine to my sauce to give it a deeper flavor (color too!) and I put some sour cream in my sauce (a spoonfull or two) to add richness to it. Do both, you won't regret it.</li><li>Balsamic vinegar is all the rage these days - and for good reason. It has a unique flavor, and I add a little bit to my sauce to infuse some of that nuance that is so powerfully linked with italian food. The key here is "a little bit."</li><li>Everyone knows parmesan is usually put over the pasta at the end, but put a little bit in your sauce and let it dissolve away completely - it'll help you use a little less salt (season salt is best) and further add to the rich feel.</li><li>Basil basil basil. People tend to put a ton of oregano in their sauce, but I think if they put less in and substituted some of it for basil they would find they have a much more balanced flavor. Oregano has a very powerful taste and can easily take over the sauce from its more subtle ingredients. Basil on the other hand, is much milder and adds more of that earthiness we look for from the Italian herbs.</li><li>Cumin is, indeed, a great addition to a spaghetti sauce. You have to be really careful not to use too much though, or it will end up tasting too earthy; almost like chili.</li><li>Paprika is your friend... it has a very fruity taste to it and will round out some of the acid in the sauce. Only a little though, otherwise it will end up tasting very odd (try it in a small sample some time).</li><li>Cinammon and nutmeg are cool, but if you really want to go for the gold, give allspice a try. It will add even more dimension to those two and keep people guessing how you got such a complex flavor into your dish. Just a dash.</li><li>Last but not least, once your pasta is done cooking (give whole-wheat a try sometime, it's a nice change) let it simmer in the pan with the sauce for a minute or two, get it good and covered. Having both components with a little heat under them will help them come together better in the end.</li></ul>
+ <p><a href="">Lorem</a> ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+ </div>
+ </li>
+ <li class="post">
+ <div class="side">
+ <h1>7/21/09</h1>
+ <h2>11:08pm</h2>
+ </div>
+ <div class="spec">
+ <p>Imagine something much bigger than anything you've ever dreamed of
+ before... and then pretend that you could somehow achieve that with
+ unquestionable certainty.</p>
+ <p><a href="">Lorem</a> ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+ </div>
+ </li>
+</ul>
+
+
View
11 out/views/pics/group.php
@@ -0,0 +1,11 @@
+<html>
+ <head>
+ <title>Pics - <?php echo $this->get('gallery::group'); ?></title>
+ <?php echo tag::style('default'); ?>
+ </head>
+ <body>
+ <?php foreach($this->get('gallery::pics') as $pic) { ?>
+ <img src='<?php echo $pic; ?>' />
+ <?php } ?>
+ </body>
+</html>
View
9 out/views/pics/index.php
@@ -0,0 +1,9 @@
+<html>
+ <head>
+ <title>Wrong turn</title>
+ <?php echo tag::style('default'); ?>
+ </head>
+ <body>
+ <h2>Well... you really aren't supposed to be here.</h2>
+ </body>
+</html>
View
0  out/views/pics/single.php
No changes.
View
17 out/views/projects.php
@@ -0,0 +1,17 @@
+<?php config::set('site.title', 'main page'); $this->useTemplate('test'); ?>
+<ul class="posts">
+ <li class="post">
+ <div class="side">
+ <h1>7/21/09</h1>
+ <h2>11:08pm</h2>
+ <span>1 comment</span>
+ </div>
+ <div class="spec">
+ <p>Imagine something much bigger than anything you've ever dreamed of
+ before... and then pretend that you could somehow achieve that with
+ unquestionable certainty.</p>
+ <p><a href="">Lorem</a> ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.</p>
+ </div>
+ </li>
+</ul>
+
View
BIN  sys/.DS_Store
Binary file not shown
View
2  sys/config/base.php
@@ -108,4 +108,4 @@ function triggerExceptionHandler($exception) {
}
-?>
+?>
View
BIN  sys/core/.event.php.swp
Binary file not shown
View
14 sys/core/bm.php
@@ -31,7 +31,7 @@ class trigger_bm {
* @author Chris
*/
public function start($name) {
- $this->marks[$name][0] = $this->microtime_float();
+ $this->marks[$name][0] = microtime(true);
}
/**
@@ -41,7 +41,7 @@ public function start($name) {
* @author Chris
*/
public function end($name) {
- $this->marks[$name][1] = $this->microtime_float();
+ $this->marks[$name][1] = microtime(true);
}
/**
@@ -76,16 +76,6 @@ public function handled($handler, $trigger) {
$this->events['handled'][] = array($handler, $trigger);
}
-
- /**
- * This utility function returns the float version of microtime()
- *
- * @return float of current microtime
- */
- public function microtime_float() {
- list($usec, $sec) = explode(" ", microtime());
- return ((float)$usec + (float)$sec);
- }
}
View
3  sys/core/event.php
@@ -75,7 +75,7 @@ public function postedForm() {
}
function segment($num) {
- return $this->requestSegments[$num-1];
+ return isset($this->requestSegments[$num-1]) ? $this->requestSegments[$num-1] : false;
}
function revert() {
@@ -187,4 +187,3 @@ function parseListener($path) {
}
-?>
Please sign in to comment.
Something went wrong with that request. Please try again.