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,351 @@
|
|
1
|
+
<?php
|
2
|
+
/**
|
3
|
+
*
|
4
|
+
* @package ActiveRecord
|
5
|
+
*/
|
6
|
+
|
7
|
+
/*
|
8
|
+
* Thanks to http://www.eval.ca/articles/php-pluralize (MIT license)
|
9
|
+
* http://dev.rubyonrails.org/browser/trunk/activesupport/lib/active_support/inflections.rb (MIT license)
|
10
|
+
* http://www.fortunecity.com/bally/durrus/153/gramch13.html
|
11
|
+
* http://www2.gsu.edu/~wwwesl/egw/crump.htm
|
12
|
+
*
|
13
|
+
* Changes (12/17/07)
|
14
|
+
* Major changes
|
15
|
+
* --
|
16
|
+
* Fixed irregular noun algorithm to use regular expressions just like the original Ruby source.
|
17
|
+
* (this allows for things like fireman -> firemen
|
18
|
+
* Fixed the order of the singular array, which was backwards.
|
19
|
+
*
|
20
|
+
* Minor changes
|
21
|
+
* --
|
22
|
+
* Removed incorrect pluralization rule for /([^aeiouy]|qu)ies$/ => $1y
|
23
|
+
* Expanded on the list of exceptions for *o -> *oes, and removed rule for buffalo -> buffaloes
|
24
|
+
* Removed dangerous singularization rule for /([^f])ves$/ => $1fe
|
25
|
+
* Added more specific rules for singularizing lives, wives, knives, sheaves, loaves, and leaves and thieves
|
26
|
+
* Added exception to /(us)es$/ => $1 rule for houses => house and blouses => blouse
|
27
|
+
* Added excpetions for feet, geese and teeth
|
28
|
+
* Added rule for deer -> deer
|
29
|
+
*
|
30
|
+
* Changes:
|
31
|
+
* Removed rule for virus -> viri
|
32
|
+
* Added rule for potato -> potatoes
|
33
|
+
* Added rule for *us -> *uses
|
34
|
+
*/
|
35
|
+
namespace ActiveRecord;
|
36
|
+
|
37
|
+
use \Closure;
|
38
|
+
|
39
|
+
function classify($class_name, $singularize=false)
|
40
|
+
{
|
41
|
+
if ($singularize)
|
42
|
+
{
|
43
|
+
$parts = explode('_', Inflector::instance()->uncamelize($class_name));
|
44
|
+
$class_name = '';
|
45
|
+
foreach ($parts as $name)
|
46
|
+
$class_name .= '_' . Utils::singularize($name);
|
47
|
+
|
48
|
+
$class_name = ltrim($class_name, '_');
|
49
|
+
}
|
50
|
+
|
51
|
+
$class_name = Inflector::instance()->camelize($class_name);
|
52
|
+
|
53
|
+
return ucfirst($class_name);
|
54
|
+
}
|
55
|
+
|
56
|
+
// http://snippets.dzone.com/posts/show/4660
|
57
|
+
function array_flatten(array $array)
|
58
|
+
{
|
59
|
+
$i = 0;
|
60
|
+
$n = count($array);
|
61
|
+
|
62
|
+
while ($i < $n)
|
63
|
+
{
|
64
|
+
if (is_array($array[$i]))
|
65
|
+
array_splice($array,$i,1,$array[$i]);
|
66
|
+
else
|
67
|
+
++$i;
|
68
|
+
|
69
|
+
$n = count($array);
|
70
|
+
}
|
71
|
+
return $array;
|
72
|
+
}
|
73
|
+
|
74
|
+
/**
|
75
|
+
* Somewhat naive way to determine if an array is a hash.
|
76
|
+
*/
|
77
|
+
function is_hash(&$array)
|
78
|
+
{
|
79
|
+
if (!is_array($array))
|
80
|
+
return false;
|
81
|
+
|
82
|
+
$keys = array_keys($array);
|
83
|
+
return @is_string($keys[0]) ? true : false;
|
84
|
+
}
|
85
|
+
|
86
|
+
/**
|
87
|
+
* Strips a class name of any namespaces and namespace operator.
|
88
|
+
*
|
89
|
+
* @param string $class
|
90
|
+
* @return string stripped class name
|
91
|
+
* @access public
|
92
|
+
*/
|
93
|
+
function denamespace($class_name)
|
94
|
+
{
|
95
|
+
if (is_object($class_name))
|
96
|
+
$class_name = get_class($class_name);
|
97
|
+
|
98
|
+
if (has_namespace($class_name))
|
99
|
+
{
|
100
|
+
$parts = explode('\\', $class_name);
|
101
|
+
return end($parts);
|
102
|
+
}
|
103
|
+
return $class_name;
|
104
|
+
}
|
105
|
+
|
106
|
+
function get_namespaces($class_name)
|
107
|
+
{
|
108
|
+
if (has_namespace($class_name))
|
109
|
+
return explode('\\', $class_name);
|
110
|
+
return null;
|
111
|
+
}
|
112
|
+
|
113
|
+
function has_namespace($class_name)
|
114
|
+
{
|
115
|
+
if (strpos($class_name, '\\') !== false)
|
116
|
+
return true;
|
117
|
+
return false;
|
118
|
+
}
|
119
|
+
|
120
|
+
/**
|
121
|
+
* Returns true if all values in $haystack === $needle
|
122
|
+
* @param $needle
|
123
|
+
* @param $haystack
|
124
|
+
* @return unknown_type
|
125
|
+
*/
|
126
|
+
function all($needle, array $haystack)
|
127
|
+
{
|
128
|
+
foreach ($haystack as $value)
|
129
|
+
{
|
130
|
+
if ($value !== $needle)
|
131
|
+
return false;
|
132
|
+
}
|
133
|
+
return true;
|
134
|
+
}
|
135
|
+
|
136
|
+
function collect(&$enumerable, $name_or_closure)
|
137
|
+
{
|
138
|
+
$ret = array();
|
139
|
+
|
140
|
+
foreach ($enumerable as $value)
|
141
|
+
{
|
142
|
+
if (is_string($name_or_closure))
|
143
|
+
$ret[] = is_array($value) ? $value[$name_or_closure] : $value->$name_or_closure;
|
144
|
+
elseif ($name_or_closure instanceof Closure)
|
145
|
+
$ret[] = $name_or_closure($value);
|
146
|
+
}
|
147
|
+
return $ret;
|
148
|
+
}
|
149
|
+
|
150
|
+
/**
|
151
|
+
* Some internal utility functions.
|
152
|
+
*
|
153
|
+
* @package ActiveRecord
|
154
|
+
*/
|
155
|
+
class Utils
|
156
|
+
{
|
157
|
+
public static function extract_options($options)
|
158
|
+
{
|
159
|
+
return is_array(end($options)) ? end($options) : array();
|
160
|
+
}
|
161
|
+
|
162
|
+
public static function add_condition(&$conditions=array(), $condition, $conjuction='AND')
|
163
|
+
{
|
164
|
+
if (is_array($condition))
|
165
|
+
{
|
166
|
+
if (empty($conditions))
|
167
|
+
$conditions = array_flatten($condition);
|
168
|
+
else
|
169
|
+
{
|
170
|
+
$conditions[0] .= " $conjuction " . array_shift($condition);
|
171
|
+
$conditions[] = array_flatten($condition);
|
172
|
+
}
|
173
|
+
}
|
174
|
+
elseif (is_string($condition))
|
175
|
+
$conditions[0] .= " $conjuction $condition";
|
176
|
+
|
177
|
+
return $conditions;
|
178
|
+
}
|
179
|
+
|
180
|
+
public static function human_attribute($attr)
|
181
|
+
{
|
182
|
+
$inflector = Inflector::instance();
|
183
|
+
$inflected = $inflector->variablize($attr);
|
184
|
+
$normal = $inflector->uncamelize($inflected);
|
185
|
+
|
186
|
+
return ucfirst(str_replace('_', ' ', $normal));
|
187
|
+
}
|
188
|
+
|
189
|
+
public static function is_odd($number)
|
190
|
+
{
|
191
|
+
return $number & 1;
|
192
|
+
}
|
193
|
+
|
194
|
+
public static function is_a($type, $var)
|
195
|
+
{
|
196
|
+
switch($type)
|
197
|
+
{
|
198
|
+
case 'range':
|
199
|
+
if (is_array($var) && (int)$var[0] < (int)$var[1])
|
200
|
+
return true;
|
201
|
+
|
202
|
+
}
|
203
|
+
|
204
|
+
return false;
|
205
|
+
}
|
206
|
+
|
207
|
+
public static function is_blank($var)
|
208
|
+
{
|
209
|
+
return 0 === strlen($var);
|
210
|
+
}
|
211
|
+
|
212
|
+
private static $plural = array(
|
213
|
+
'/(quiz)$/i' => "$1zes",
|
214
|
+
'/^(ox)$/i' => "$1en",
|
215
|
+
'/([m|l])ouse$/i' => "$1ice",
|
216
|
+
'/(matr|vert|ind)ix|ex$/i' => "$1ices",
|
217
|
+
'/(x|ch|ss|sh)$/i' => "$1es",
|
218
|
+
'/([^aeiouy]|qu)y$/i' => "$1ies",
|
219
|
+
'/(hive)$/i' => "$1s",
|
220
|
+
'/(?:([^f])fe|([lr])f)$/i' => "$1$2ves",
|
221
|
+
'/(shea|lea|loa|thie)f$/i' => "$1ves",
|
222
|
+
'/sis$/i' => "ses",
|
223
|
+
'/([ti])um$/i' => "$1a",
|
224
|
+
'/(tomat|potat|ech|her|vet)o$/i'=> "$1oes",
|
225
|
+
'/(bu)s$/i' => "$1ses",
|
226
|
+
'/(alias)$/i' => "$1es",
|
227
|
+
'/(octop)us$/i' => "$1i",
|
228
|
+
'/(ax|test)is$/i' => "$1es",
|
229
|
+
'/(us)$/i' => "$1es",
|
230
|
+
'/s$/i' => "s",
|
231
|
+
'/$/' => "s"
|
232
|
+
);
|
233
|
+
|
234
|
+
private static $singular = array(
|
235
|
+
'/(quiz)zes$/i' => "$1",
|
236
|
+
'/(matr)ices$/i' => "$1ix",
|
237
|
+
'/(vert|ind)ices$/i' => "$1ex",
|
238
|
+
'/^(ox)en$/i' => "$1",
|
239
|
+
'/(alias)es$/i' => "$1",
|
240
|
+
'/(octop|vir)i$/i' => "$1us",
|
241
|
+
'/(cris|ax|test)es$/i' => "$1is",
|
242
|
+
'/(shoe)s$/i' => "$1",
|
243
|
+
'/(o)es$/i' => "$1",
|
244
|
+
'/(bus)es$/i' => "$1",
|
245
|
+
'/([m|l])ice$/i' => "$1ouse",
|
246
|
+
'/(x|ch|ss|sh)es$/i' => "$1",
|
247
|
+
'/(m)ovies$/i' => "$1ovie",
|
248
|
+
'/(s)eries$/i' => "$1eries",
|
249
|
+
'/([^aeiouy]|qu)ies$/i' => "$1y",
|
250
|
+
'/([lr])ves$/i' => "$1f",
|
251
|
+
'/(tive)s$/i' => "$1",
|
252
|
+
'/(hive)s$/i' => "$1",
|
253
|
+
'/(li|wi|kni)ves$/i' => "$1fe",
|
254
|
+
'/(shea|loa|lea|thie)ves$/i'=> "$1f",
|
255
|
+
'/(^analy)ses$/i' => "$1sis",
|
256
|
+
'/((a)naly|(b)a|(d)iagno|(p)arenthe|(p)rogno|(s)ynop|(t)he)ses$/i' => "$1$2sis",
|
257
|
+
'/([ti])a$/i' => "$1um",
|
258
|
+
'/(n)ews$/i' => "$1ews",
|
259
|
+
'/(h|bl)ouses$/i' => "$1ouse",
|
260
|
+
'/(corpse)s$/i' => "$1",
|
261
|
+
'/(us)es$/i' => "$1",
|
262
|
+
'/s$/i' => ""
|
263
|
+
);
|
264
|
+
|
265
|
+
private static $irregular = array(
|
266
|
+
'move' => 'moves',
|
267
|
+
'foot' => 'feet',
|
268
|
+
'goose' => 'geese',
|
269
|
+
'sex' => 'sexes',
|
270
|
+
'child' => 'children',
|
271
|
+
'man' => 'men',
|
272
|
+
'tooth' => 'teeth',
|
273
|
+
'person' => 'people'
|
274
|
+
);
|
275
|
+
|
276
|
+
private static $uncountable = array(
|
277
|
+
'sheep',
|
278
|
+
'fish',
|
279
|
+
'deer',
|
280
|
+
'series',
|
281
|
+
'species',
|
282
|
+
'money',
|
283
|
+
'rice',
|
284
|
+
'information',
|
285
|
+
'equipment'
|
286
|
+
);
|
287
|
+
|
288
|
+
public static function pluralize( $string )
|
289
|
+
{
|
290
|
+
// save some time in the case that singular and plural are the same
|
291
|
+
if ( in_array( strtolower( $string ), self::$uncountable ) )
|
292
|
+
return $string;
|
293
|
+
|
294
|
+
// check for irregular singular forms
|
295
|
+
foreach ( self::$irregular as $pattern => $result )
|
296
|
+
{
|
297
|
+
$pattern = '/' . $pattern . '$/i';
|
298
|
+
|
299
|
+
if ( preg_match( $pattern, $string ) )
|
300
|
+
return preg_replace( $pattern, $result, $string);
|
301
|
+
}
|
302
|
+
|
303
|
+
// check for matches using regular expressions
|
304
|
+
foreach ( self::$plural as $pattern => $result )
|
305
|
+
{
|
306
|
+
if ( preg_match( $pattern, $string ) )
|
307
|
+
return preg_replace( $pattern, $result, $string );
|
308
|
+
}
|
309
|
+
|
310
|
+
return $string;
|
311
|
+
}
|
312
|
+
|
313
|
+
public static function singularize( $string )
|
314
|
+
{
|
315
|
+
// save some time in the case that singular and plural are the same
|
316
|
+
if ( in_array( strtolower( $string ), self::$uncountable ) )
|
317
|
+
return $string;
|
318
|
+
|
319
|
+
// check for irregular plural forms
|
320
|
+
foreach ( self::$irregular as $result => $pattern )
|
321
|
+
{
|
322
|
+
$pattern = '/' . $pattern . '$/i';
|
323
|
+
|
324
|
+
if ( preg_match( $pattern, $string ) )
|
325
|
+
return preg_replace( $pattern, $result, $string);
|
326
|
+
}
|
327
|
+
|
328
|
+
// check for matches using regular expressions
|
329
|
+
foreach ( self::$singular as $pattern => $result )
|
330
|
+
{
|
331
|
+
if ( preg_match( $pattern, $string ) )
|
332
|
+
return preg_replace( $pattern, $result, $string );
|
333
|
+
}
|
334
|
+
|
335
|
+
return $string;
|
336
|
+
}
|
337
|
+
|
338
|
+
public static function pluralize_if($count, $string)
|
339
|
+
{
|
340
|
+
if ($count == 1)
|
341
|
+
return $string;
|
342
|
+
else
|
343
|
+
return self::pluralize($string);
|
344
|
+
}
|
345
|
+
|
346
|
+
public static function squeeze($char, $string)
|
347
|
+
{
|
348
|
+
return preg_replace("/$char+/",$char,$string);
|
349
|
+
}
|
350
|
+
};
|
351
|
+
?>
|