my-simon 0.0.0 → 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/.gitignore.orig +55 -0
- data/DOC/Launch Check List.docx +0 -0
- data/DOC/Launch Check List.pdf +0 -0
- data/Gemfile +14 -0
- data/Gemfile.lock +44 -0
- data/LICENSE.txt +20 -0
- data/README.md +21 -0
- data/README.rdoc +19 -0
- data/Rakefile +46 -0
- data/VERSION +1 -0
- data/build/rakefile.rb +12 -0
- data/config.rb +24 -0
- data/lib/simon.rb +0 -5
- data/my-simon.gemspec +141 -0
- data/scaffolding/simon/controller.tpl +9 -0
- data/scaffolding/simon/model.tpl +10 -0
- data/scaffolding/simon/view.tpl +5 -0
- data/scaffolding/standards/html_template.html +44 -0
- data/scaffolding/standards/html_template.php +44 -0
- data/scaffolding/standards/jquery_plugin_template.js +45 -0
- data/scaffolding/standards/js_template.js +43 -0
- data/simon +282 -0
- data/test/helper.rb +18 -0
- data/test/test_simon.rb +7 -0
- data/www/.htaccess +488 -0
- data/www/404.html +32 -0
- data/www/crossdomain.xml +25 -0
- data/www/favicon.ico +0 -0
- data/www/index.php +17 -0
- data/www/lib/js/homePage.js +43 -0
- data/www/lib/js/jquery/JQbook.js +809 -0
- data/www/lib/js/jquery/jquery-1.8.0.min.js +27 -0
- data/www/lib/js/jquery/jquery.alphanumeric.js +82 -0
- data/www/lib/js/jquery/jquery.cookie.js +96 -0
- data/www/lib/js/jquery/jquery.easing.1.3.js +207 -0
- data/www/lib/js/main.js +117 -0
- data/www/lib/js/master.js +6 -0
- data/www/lib/js/plugins/handlebars-1.0.rc.1.js +1920 -0
- data/www/lib/js/plugins/modernizr-1.7.min.js +2 -0
- data/www/lib/js/plugins/swfobject.js +777 -0
- data/www/lib/js/plugins_mod/README.txt +3 -0
- data/www/lib/php/app.php +53 -0
- data/www/lib/php/controller/index.php +10 -0
- data/www/lib/php/controller/regex.php +23 -0
- data/www/lib/php/model/Book.php +8 -0
- data/www/lib/php/model/Model.php +8 -0
- data/www/lib/php/plugins/php-activerecord/ActiveRecord.php +44 -0
- data/www/lib/php/plugins/php-activerecord/lib/CallBack.php +226 -0
- data/www/lib/php/plugins/php-activerecord/lib/Column.php +155 -0
- data/www/lib/php/plugins/php-activerecord/lib/Config.php +288 -0
- data/www/lib/php/plugins/php-activerecord/lib/Connection.php +456 -0
- data/www/lib/php/plugins/php-activerecord/lib/ConnectionManager.php +38 -0
- data/www/lib/php/plugins/php-activerecord/lib/DateTime.php +45 -0
- data/www/lib/php/plugins/php-activerecord/lib/Exceptions.php +137 -0
- data/www/lib/php/plugins/php-activerecord/lib/Expressions.php +183 -0
- data/www/lib/php/plugins/php-activerecord/lib/Inflector.php +115 -0
- data/www/lib/php/plugins/php-activerecord/lib/Model.php +1673 -0
- data/www/lib/php/plugins/php-activerecord/lib/Reflections.php +86 -0
- data/www/lib/php/plugins/php-activerecord/lib/Relationship.php +637 -0
- data/www/lib/php/plugins/php-activerecord/lib/SQLBuilder.php +396 -0
- data/www/lib/php/plugins/php-activerecord/lib/Serialization.php +302 -0
- data/www/lib/php/plugins/php-activerecord/lib/Singleton.php +57 -0
- data/www/lib/php/plugins/php-activerecord/lib/Table.php +547 -0
- data/www/lib/php/plugins/php-activerecord/lib/Utils.php +351 -0
- data/www/lib/php/plugins/php-activerecord/lib/Validations.php +833 -0
- data/www/lib/php/plugins/php-activerecord/lib/adapters/MysqlAdapter.php +73 -0
- data/www/lib/php/plugins/php-activerecord/lib/adapters/OciAdapter.php +121 -0
- data/www/lib/php/plugins/php-activerecord/lib/adapters/PgsqlAdapter.php +104 -0
- data/www/lib/php/plugins/php-activerecord/lib/adapters/SqliteAdapter.php +81 -0
- data/www/lib/php/system/Config.php +174 -0
- data/www/lib/php/system/config.routes.php +29 -0
- data/www/lib/php/system/router.php +220 -0
- data/www/lib/php/template/footer.php +59 -0
- data/www/lib/php/template/header.php +74 -0
- data/www/lib/php/view/index.php +5 -0
- data/www/media/images/facebook_share.jpg +0 -0
- data/www/robots.txt +5 -0
- data/www/sandbox/readme.txt +3 -0
- data/www/sass/javascript.scss +1 -0
- data/www/sass/layout.scss +128 -0
- data/www/sass/master.scss +4 -0
- data/www/sass/reset.scss +47 -0
- data/www/sass/typography.scss +24 -0
- data/www/styles/javascript.css +1 -0
- data/www/styles/layout.css +186 -0
- data/www/styles/master.css +4 -0
- data/www/styles/reset.css +60 -0
- data/www/styles/typography.css +24 -0
- metadata +179 -7
@@ -0,0 +1,183 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* @package ActiveRecord
|
4
|
+
*/
|
5
|
+
namespace ActiveRecord;
|
6
|
+
|
7
|
+
/**
|
8
|
+
* Templating like class for building SQL statements.
|
9
|
+
*
|
10
|
+
* Examples:
|
11
|
+
* 'name = :name AND author = :author'
|
12
|
+
* 'id = IN(:ids)'
|
13
|
+
* 'id IN(:subselect)'
|
14
|
+
*
|
15
|
+
* @package ActiveRecord
|
16
|
+
*/
|
17
|
+
class Expressions
|
18
|
+
{
|
19
|
+
const ParameterMarker = '?';
|
20
|
+
|
21
|
+
private $expressions;
|
22
|
+
private $values = array();
|
23
|
+
private $connection;
|
24
|
+
|
25
|
+
public function __construct($connection, $expressions=null /* [, $values ... ] */)
|
26
|
+
{
|
27
|
+
$values = null;
|
28
|
+
$this->connection = $connection;
|
29
|
+
|
30
|
+
if (is_array($expressions))
|
31
|
+
{
|
32
|
+
$glue = func_num_args() > 2 ? func_get_arg(2) : ' AND ';
|
33
|
+
list($expressions,$values) = $this->build_sql_from_hash($expressions,$glue);
|
34
|
+
}
|
35
|
+
|
36
|
+
if ($expressions != '')
|
37
|
+
{
|
38
|
+
if (!$values)
|
39
|
+
$values = array_slice(func_get_args(),2);
|
40
|
+
|
41
|
+
$this->values = $values;
|
42
|
+
$this->expressions = $expressions;
|
43
|
+
}
|
44
|
+
}
|
45
|
+
|
46
|
+
/**
|
47
|
+
* Bind a value to the specific one based index. There must be a bind marker
|
48
|
+
* for each value bound or to_s() will throw an exception.
|
49
|
+
*/
|
50
|
+
public function bind($parameter_number, $value)
|
51
|
+
{
|
52
|
+
if ($parameter_number <= 0)
|
53
|
+
throw new ExpressionsException("Invalid parameter index: $parameter_number");
|
54
|
+
|
55
|
+
$this->values[$parameter_number-1] = $value;
|
56
|
+
}
|
57
|
+
|
58
|
+
public function bind_values($values)
|
59
|
+
{
|
60
|
+
$this->values = $values;
|
61
|
+
}
|
62
|
+
|
63
|
+
/**
|
64
|
+
* Returns all the values currently bound.
|
65
|
+
*/
|
66
|
+
public function values()
|
67
|
+
{
|
68
|
+
return $this->values;
|
69
|
+
}
|
70
|
+
|
71
|
+
/**
|
72
|
+
* Returns the connection object.
|
73
|
+
*/
|
74
|
+
public function get_connection()
|
75
|
+
{
|
76
|
+
return $this->connection;
|
77
|
+
}
|
78
|
+
|
79
|
+
/**
|
80
|
+
* Sets the connection object. It is highly recommended to set this so we can
|
81
|
+
* use the adapter's native escaping mechanism.
|
82
|
+
*
|
83
|
+
* @param string $connection a Connection instance
|
84
|
+
*/
|
85
|
+
public function set_connection($connection)
|
86
|
+
{
|
87
|
+
$this->connection = $connection;
|
88
|
+
}
|
89
|
+
|
90
|
+
public function to_s($substitute=false, &$options=null)
|
91
|
+
{
|
92
|
+
if (!$options) $options = array();
|
93
|
+
|
94
|
+
$values = array_key_exists('values',$options) ? $options['values'] : $this->values;
|
95
|
+
|
96
|
+
$ret = "";
|
97
|
+
$replace = array();
|
98
|
+
$num_values = count($values);
|
99
|
+
$len = strlen($this->expressions);
|
100
|
+
$quotes = 0;
|
101
|
+
|
102
|
+
for ($i=0,$n=strlen($this->expressions),$j=0; $i<$n; ++$i)
|
103
|
+
{
|
104
|
+
$ch = $this->expressions[$i];
|
105
|
+
|
106
|
+
if ($ch == self::ParameterMarker)
|
107
|
+
{
|
108
|
+
if ($quotes % 2 == 0)
|
109
|
+
{
|
110
|
+
if ($j > $num_values-1)
|
111
|
+
throw new ExpressionsException("No bound parameter for index $j");
|
112
|
+
|
113
|
+
$ch = $this->substitute($values,$substitute,$i,$j++);
|
114
|
+
}
|
115
|
+
}
|
116
|
+
elseif ($ch == '\'' && $i > 0 && $this->expressions[$i-1] != '\\')
|
117
|
+
++$quotes;
|
118
|
+
|
119
|
+
$ret .= $ch;
|
120
|
+
}
|
121
|
+
return $ret;
|
122
|
+
}
|
123
|
+
|
124
|
+
private function build_sql_from_hash(&$hash, $glue)
|
125
|
+
{
|
126
|
+
$sql = $g = "";
|
127
|
+
|
128
|
+
foreach ($hash as $name => $value)
|
129
|
+
{
|
130
|
+
if ($this->connection)
|
131
|
+
$name = $this->connection->quote_name($name);
|
132
|
+
|
133
|
+
if (is_array($value))
|
134
|
+
$sql .= "$g$name IN(?)";
|
135
|
+
else
|
136
|
+
$sql .= "$g$name=?";
|
137
|
+
|
138
|
+
$g = $glue;
|
139
|
+
}
|
140
|
+
return array($sql,array_values($hash));
|
141
|
+
}
|
142
|
+
|
143
|
+
private function substitute(&$values, $substitute, $pos, $parameter_index)
|
144
|
+
{
|
145
|
+
$value = $values[$parameter_index];
|
146
|
+
|
147
|
+
if (is_array($value))
|
148
|
+
{
|
149
|
+
if ($substitute)
|
150
|
+
{
|
151
|
+
$ret = '';
|
152
|
+
|
153
|
+
for ($i=0,$n=count($value); $i<$n; ++$i)
|
154
|
+
$ret .= ($i > 0 ? ',' : '') . $this->stringify_value($value[$i]);
|
155
|
+
|
156
|
+
return $ret;
|
157
|
+
}
|
158
|
+
return join(',',array_fill(0,count($value),self::ParameterMarker));
|
159
|
+
}
|
160
|
+
|
161
|
+
if ($substitute)
|
162
|
+
return $this->stringify_value($value);
|
163
|
+
|
164
|
+
return $this->expressions[$pos];
|
165
|
+
}
|
166
|
+
|
167
|
+
private function stringify_value($value)
|
168
|
+
{
|
169
|
+
if (is_null($value))
|
170
|
+
return "NULL";
|
171
|
+
|
172
|
+
return is_string($value) ? $this->quote_string($value) : $value;
|
173
|
+
}
|
174
|
+
|
175
|
+
private function quote_string($value)
|
176
|
+
{
|
177
|
+
if ($this->connection)
|
178
|
+
return $this->connection->escape($value);
|
179
|
+
|
180
|
+
return "'" . str_replace("'","''",$value) . "'";
|
181
|
+
}
|
182
|
+
}
|
183
|
+
?>
|
@@ -0,0 +1,115 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
* @package ActiveRecord
|
4
|
+
*/
|
5
|
+
namespace ActiveRecord;
|
6
|
+
|
7
|
+
/**
|
8
|
+
* @package ActiveRecord
|
9
|
+
*/
|
10
|
+
abstract class Inflector
|
11
|
+
{
|
12
|
+
/**
|
13
|
+
* Get an instance of the {@link Inflector} class.
|
14
|
+
*
|
15
|
+
* @return object
|
16
|
+
*/
|
17
|
+
public static function instance()
|
18
|
+
{
|
19
|
+
return new StandardInflector();
|
20
|
+
}
|
21
|
+
|
22
|
+
/**
|
23
|
+
* Turn a string into its camelized version.
|
24
|
+
*
|
25
|
+
* @param string $s string to convert
|
26
|
+
* @return string
|
27
|
+
*/
|
28
|
+
public function camelize($s)
|
29
|
+
{
|
30
|
+
$s = preg_replace('/[_-]+/','_',trim($s));
|
31
|
+
$s = str_replace(' ', '_', $s);
|
32
|
+
|
33
|
+
$camelized = '';
|
34
|
+
|
35
|
+
for ($i=0,$n=strlen($s); $i<$n; ++$i)
|
36
|
+
{
|
37
|
+
if ($s[$i] == '_' && $i+1 < $n)
|
38
|
+
$camelized .= strtoupper($s[++$i]);
|
39
|
+
else
|
40
|
+
$camelized .= $s[$i];
|
41
|
+
}
|
42
|
+
|
43
|
+
$camelized = trim($camelized,' _');
|
44
|
+
|
45
|
+
if (strlen($camelized) > 0)
|
46
|
+
$camelized[0] = strtolower($camelized[0]);
|
47
|
+
|
48
|
+
return $camelized;
|
49
|
+
}
|
50
|
+
|
51
|
+
/**
|
52
|
+
* Determines if a string contains all uppercase characters.
|
53
|
+
*
|
54
|
+
* @param string $s string to check
|
55
|
+
* @return bool
|
56
|
+
*/
|
57
|
+
public static function is_upper($s)
|
58
|
+
{
|
59
|
+
return (strtoupper($s) === $s);
|
60
|
+
}
|
61
|
+
|
62
|
+
/**
|
63
|
+
* Determines if a string contains all lowercase characters.
|
64
|
+
*
|
65
|
+
* @param string $s string to check
|
66
|
+
* @return bool
|
67
|
+
*/
|
68
|
+
public static function is_lower($s)
|
69
|
+
{
|
70
|
+
return (strtolower($s) === $s);
|
71
|
+
}
|
72
|
+
|
73
|
+
/**
|
74
|
+
* Convert a camelized string to a lowercase, underscored string.
|
75
|
+
*
|
76
|
+
* @param string $s string to convert
|
77
|
+
* @return string
|
78
|
+
*/
|
79
|
+
public function uncamelize($s)
|
80
|
+
{
|
81
|
+
$normalized = '';
|
82
|
+
|
83
|
+
for ($i=0,$n=strlen($s); $i<$n; ++$i)
|
84
|
+
{
|
85
|
+
if (ctype_alpha($s[$i]) && self::is_upper($s[$i]))
|
86
|
+
$normalized .= '_' . strtolower($s[$i]);
|
87
|
+
else
|
88
|
+
$normalized .= $s[$i];
|
89
|
+
}
|
90
|
+
return trim($normalized,' _');
|
91
|
+
}
|
92
|
+
|
93
|
+
/**
|
94
|
+
* Convert a string with space into a underscored equivalent.
|
95
|
+
*
|
96
|
+
* @param string $s string to convert
|
97
|
+
* @return string
|
98
|
+
*/
|
99
|
+
public function underscorify($s)
|
100
|
+
{
|
101
|
+
return preg_replace(array('/[_\- ]+/','/([a-z])([A-Z])/'),array('_','\\1_\\2'),trim($s));
|
102
|
+
}
|
103
|
+
|
104
|
+
abstract function variablize($s);
|
105
|
+
}
|
106
|
+
|
107
|
+
/**
|
108
|
+
* @package ActiveRecord
|
109
|
+
*/
|
110
|
+
class StandardInflector extends Inflector
|
111
|
+
{
|
112
|
+
public function tableize($s) { return Utils::pluralize(strtolower($this->underscorify($s))); }
|
113
|
+
public function variablize($s) { return str_replace(array('-',' '),array('_','_'),strtolower(trim($s))); }
|
114
|
+
}
|
115
|
+
?>
|