my-simon 0.0.1 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +3 -20
- data/Rakefile +1 -1
- data/VERSION +1 -1
- data/my-simon.gemspec +3 -78
- metadata +2 -77
- data/DOC/Launch Check List.docx +0 -0
- data/DOC/Launch Check List.pdf +0 -0
- data/build/rakefile.rb +0 -12
- data/config.rb +0 -24
- data/scaffolding/simon/controller.tpl +0 -9
- data/scaffolding/simon/model.tpl +0 -10
- data/scaffolding/simon/view.tpl +0 -5
- data/scaffolding/standards/html_template.html +0 -44
- data/scaffolding/standards/html_template.php +0 -44
- data/scaffolding/standards/jquery_plugin_template.js +0 -45
- data/scaffolding/standards/js_template.js +0 -43
- data/www/.htaccess +0 -488
- data/www/404.html +0 -32
- data/www/crossdomain.xml +0 -25
- data/www/favicon.ico +0 -0
- data/www/index.php +0 -17
- data/www/lib/js/homePage.js +0 -43
- data/www/lib/js/jquery/JQbook.js +0 -809
- data/www/lib/js/jquery/jquery-1.8.0.min.js +0 -27
- data/www/lib/js/jquery/jquery.alphanumeric.js +0 -82
- data/www/lib/js/jquery/jquery.cookie.js +0 -96
- data/www/lib/js/jquery/jquery.easing.1.3.js +0 -207
- data/www/lib/js/main.js +0 -117
- data/www/lib/js/master.js +0 -6
- data/www/lib/js/plugins/handlebars-1.0.rc.1.js +0 -1920
- data/www/lib/js/plugins/modernizr-1.7.min.js +0 -2
- data/www/lib/js/plugins/swfobject.js +0 -777
- data/www/lib/js/plugins_mod/README.txt +0 -3
- data/www/lib/php/app.php +0 -53
- data/www/lib/php/controller/index.php +0 -10
- data/www/lib/php/controller/regex.php +0 -23
- data/www/lib/php/model/Book.php +0 -8
- data/www/lib/php/model/Model.php +0 -8
- data/www/lib/php/plugins/php-activerecord/ActiveRecord.php +0 -44
- data/www/lib/php/plugins/php-activerecord/lib/CallBack.php +0 -226
- data/www/lib/php/plugins/php-activerecord/lib/Column.php +0 -155
- data/www/lib/php/plugins/php-activerecord/lib/Config.php +0 -288
- data/www/lib/php/plugins/php-activerecord/lib/Connection.php +0 -456
- data/www/lib/php/plugins/php-activerecord/lib/ConnectionManager.php +0 -38
- data/www/lib/php/plugins/php-activerecord/lib/DateTime.php +0 -45
- data/www/lib/php/plugins/php-activerecord/lib/Exceptions.php +0 -137
- data/www/lib/php/plugins/php-activerecord/lib/Expressions.php +0 -183
- data/www/lib/php/plugins/php-activerecord/lib/Inflector.php +0 -115
- data/www/lib/php/plugins/php-activerecord/lib/Model.php +0 -1673
- data/www/lib/php/plugins/php-activerecord/lib/Reflections.php +0 -86
- data/www/lib/php/plugins/php-activerecord/lib/Relationship.php +0 -637
- data/www/lib/php/plugins/php-activerecord/lib/SQLBuilder.php +0 -396
- data/www/lib/php/plugins/php-activerecord/lib/Serialization.php +0 -302
- data/www/lib/php/plugins/php-activerecord/lib/Singleton.php +0 -57
- data/www/lib/php/plugins/php-activerecord/lib/Table.php +0 -547
- data/www/lib/php/plugins/php-activerecord/lib/Utils.php +0 -351
- data/www/lib/php/plugins/php-activerecord/lib/Validations.php +0 -833
- data/www/lib/php/plugins/php-activerecord/lib/adapters/MysqlAdapter.php +0 -73
- data/www/lib/php/plugins/php-activerecord/lib/adapters/OciAdapter.php +0 -121
- data/www/lib/php/plugins/php-activerecord/lib/adapters/PgsqlAdapter.php +0 -104
- data/www/lib/php/plugins/php-activerecord/lib/adapters/SqliteAdapter.php +0 -81
- data/www/lib/php/system/Config.php +0 -174
- data/www/lib/php/system/config.routes.php +0 -29
- data/www/lib/php/system/router.php +0 -220
- data/www/lib/php/template/footer.php +0 -59
- data/www/lib/php/template/header.php +0 -74
- data/www/lib/php/view/index.php +0 -5
- data/www/media/images/facebook_share.jpg +0 -0
- data/www/robots.txt +0 -5
- data/www/sandbox/readme.txt +0 -3
- data/www/sass/javascript.scss +0 -1
- data/www/sass/layout.scss +0 -128
- data/www/sass/master.scss +0 -4
- data/www/sass/reset.scss +0 -47
- data/www/sass/typography.scss +0 -24
- data/www/styles/javascript.css +0 -1
- data/www/styles/layout.css +0 -186
- data/www/styles/master.css +0 -4
- data/www/styles/reset.css +0 -60
- data/www/styles/typography.css +0 -24
@@ -1,38 +0,0 @@
|
|
1
|
-
<?php
|
2
|
-
/**
|
3
|
-
* @package ActiveRecord
|
4
|
-
*/
|
5
|
-
namespace ActiveRecord;
|
6
|
-
|
7
|
-
/**
|
8
|
-
* Singleton to manage any and all database connections.
|
9
|
-
*
|
10
|
-
* @package ActiveRecord
|
11
|
-
*/
|
12
|
-
class ConnectionManager extends Singleton
|
13
|
-
{
|
14
|
-
/**
|
15
|
-
* Array of {@link Connection} objects.
|
16
|
-
* @var array
|
17
|
-
*/
|
18
|
-
static private $connections = array();
|
19
|
-
|
20
|
-
/**
|
21
|
-
* If $name is null then the default connection will be returned.
|
22
|
-
*
|
23
|
-
* @see Config
|
24
|
-
* @param string $name Optional name of a connection
|
25
|
-
* @return Connection
|
26
|
-
*/
|
27
|
-
public static function get_connection($name=null)
|
28
|
-
{
|
29
|
-
if (!isset(self::$connections[$name]) || !self::$connections[$name]->connection)
|
30
|
-
{
|
31
|
-
$config = Config::instance();
|
32
|
-
$connection_string = $name ? $config->get_connection($name) : $config->get_default_connection();
|
33
|
-
self::$connections[$name] = Connection::instance($connection_string);
|
34
|
-
}
|
35
|
-
return self::$connections[$name];
|
36
|
-
}
|
37
|
-
};
|
38
|
-
?>
|
@@ -1,45 +0,0 @@
|
|
1
|
-
<?php
|
2
|
-
namespace ActiveRecord;
|
3
|
-
|
4
|
-
class DateTime extends \DateTime
|
5
|
-
{
|
6
|
-
private $model;
|
7
|
-
private $attribute_name;
|
8
|
-
|
9
|
-
public function attribute_of($model, $attribute_name)
|
10
|
-
{
|
11
|
-
$this->model = $model;
|
12
|
-
$this->attribute_name = $attribute_name;
|
13
|
-
}
|
14
|
-
|
15
|
-
private function flag_dirty()
|
16
|
-
{
|
17
|
-
if ($this->model)
|
18
|
-
$this->model->flag_dirty($this->attribute_name);
|
19
|
-
}
|
20
|
-
|
21
|
-
public function setDate($year, $month, $day)
|
22
|
-
{
|
23
|
-
$this->flag_dirty();
|
24
|
-
call_user_func_array(array($this,'parent::setDate'),func_get_args());
|
25
|
-
}
|
26
|
-
|
27
|
-
public function setISODate($year, $week , $day=null)
|
28
|
-
{
|
29
|
-
$this->flag_dirty();
|
30
|
-
call_user_func_array(array($this,'parent::setISODate'),func_get_args());
|
31
|
-
}
|
32
|
-
|
33
|
-
public function setTime($hour, $minute, $second=null)
|
34
|
-
{
|
35
|
-
$this->flag_dirty();
|
36
|
-
call_user_func_array(array($this,'parent::setTime'),func_get_args());
|
37
|
-
}
|
38
|
-
|
39
|
-
public function setTimestamp($unixtimestamp)
|
40
|
-
{
|
41
|
-
$this->flag_dirty();
|
42
|
-
call_user_func_array(array($this,'parent::setTimestamp'),func_get_args());
|
43
|
-
}
|
44
|
-
}
|
45
|
-
?>
|
@@ -1,137 +0,0 @@
|
|
1
|
-
<?php
|
2
|
-
/**
|
3
|
-
* @package ActiveRecord
|
4
|
-
*/
|
5
|
-
namespace ActiveRecord;
|
6
|
-
|
7
|
-
/**
|
8
|
-
* Generic base exception for all ActiveRecord specific errors.
|
9
|
-
*
|
10
|
-
* @package ActiveRecord
|
11
|
-
*/
|
12
|
-
class ActiveRecordException extends \Exception {};
|
13
|
-
|
14
|
-
/**
|
15
|
-
* Thrown when a record cannot be found.
|
16
|
-
*
|
17
|
-
* @package ActiveRecord
|
18
|
-
*/
|
19
|
-
class RecordNotFound extends ActiveRecordException {};
|
20
|
-
|
21
|
-
/**
|
22
|
-
* Thrown when there was an error performing a database operation.
|
23
|
-
*
|
24
|
-
* The error will be specific to whatever database you are running.
|
25
|
-
*
|
26
|
-
* @package ActiveRecord
|
27
|
-
*/
|
28
|
-
class DatabaseException extends ActiveRecordException
|
29
|
-
{
|
30
|
-
public function __construct($adapter_or_string_or_mystery)
|
31
|
-
{
|
32
|
-
if ($adapter_or_string_or_mystery instanceof Connection)
|
33
|
-
{
|
34
|
-
parent::__construct(
|
35
|
-
join(", ",$adapter_or_string_or_mystery->connection->errorInfo()),
|
36
|
-
intval($adapter_or_string_or_mystery->connection->errorCode()));
|
37
|
-
}
|
38
|
-
elseif ($adapter_or_string_or_mystery instanceof \PDOStatement)
|
39
|
-
{
|
40
|
-
parent::__construct(
|
41
|
-
join(", ",$adapter_or_string_or_mystery->errorInfo()),
|
42
|
-
intval($adapter_or_string_or_mystery->errorCode()));
|
43
|
-
}
|
44
|
-
else
|
45
|
-
parent::__construct($adapter_or_string_or_mystery);
|
46
|
-
}
|
47
|
-
};
|
48
|
-
|
49
|
-
/**
|
50
|
-
* Thrown by {@link Model}.
|
51
|
-
*
|
52
|
-
* @package ActiveRecord
|
53
|
-
*/
|
54
|
-
class ModelException extends ActiveRecordException {};
|
55
|
-
|
56
|
-
/**
|
57
|
-
* Thrown by {@link Expressions}.
|
58
|
-
*
|
59
|
-
* @package ActiveRecord
|
60
|
-
*/
|
61
|
-
class ExpressionsException extends ActiveRecordException {};
|
62
|
-
|
63
|
-
/**
|
64
|
-
* Thrown for configuration problems.
|
65
|
-
*
|
66
|
-
* @package ActiveRecord
|
67
|
-
*/
|
68
|
-
class ConfigException extends ActiveRecordException {};
|
69
|
-
|
70
|
-
/**
|
71
|
-
* Thrown when attempting to access an invalid property on a {@link Model}.
|
72
|
-
*
|
73
|
-
* @package ActiveRecord
|
74
|
-
*/
|
75
|
-
class UndefinedPropertyException extends ModelException
|
76
|
-
{
|
77
|
-
/**
|
78
|
-
* Sets the exception message to show the undefined property's name.
|
79
|
-
*
|
80
|
-
* @param str $property_name name of undefined property
|
81
|
-
* @return void
|
82
|
-
*/
|
83
|
-
public function __construct($class_name, $property_name)
|
84
|
-
{
|
85
|
-
if (is_array($property_name))
|
86
|
-
{
|
87
|
-
$this->message = implode("\r\n", $property_name);
|
88
|
-
return;
|
89
|
-
}
|
90
|
-
|
91
|
-
$this->message = "Undefined property: {$class_name}->{$property_name} in {$this->file} on line {$this->line}";
|
92
|
-
parent::__construct();
|
93
|
-
}
|
94
|
-
};
|
95
|
-
|
96
|
-
/**
|
97
|
-
* Thrown when attempting to perform a write operation on a {@link Model} that is in read-only mode.
|
98
|
-
*
|
99
|
-
* @package ActiveRecord
|
100
|
-
*/
|
101
|
-
class ReadOnlyException extends ModelException
|
102
|
-
{
|
103
|
-
/**
|
104
|
-
* Sets the exception message to show the undefined property's name.
|
105
|
-
*
|
106
|
-
* @param str $class_name name of the model that is read only
|
107
|
-
* @param str $method_name name of method which attempted to modify the model
|
108
|
-
* @return void
|
109
|
-
*/
|
110
|
-
public function __construct($class_name, $method_name)
|
111
|
-
{
|
112
|
-
$this->message = "{$class_name}::{$method_name}() cannot be invoked because this model is set to read only";
|
113
|
-
parent::__construct();
|
114
|
-
}
|
115
|
-
};
|
116
|
-
|
117
|
-
/**
|
118
|
-
* Thrown for validations exceptions.
|
119
|
-
*
|
120
|
-
* @package ActiveRecord
|
121
|
-
*/
|
122
|
-
class ValidationsArgumentError extends ActiveRecordException {};
|
123
|
-
|
124
|
-
/**
|
125
|
-
* Thrown for relationship exceptions.
|
126
|
-
*
|
127
|
-
* @package ActiveRecord
|
128
|
-
*/
|
129
|
-
class RelationshipException extends ActiveRecordException {};
|
130
|
-
|
131
|
-
/**
|
132
|
-
* Thrown for has many thru exceptions.
|
133
|
-
*
|
134
|
-
* @package ActiveRecord
|
135
|
-
*/
|
136
|
-
class HasManyThroughAssociationException extends RelationshipException {};
|
137
|
-
?>
|
@@ -1,183 +0,0 @@
|
|
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
|
-
?>
|
@@ -1,115 +0,0 @@
|
|
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
|
-
?>
|