farleyknight-ionize 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.rdoc +59 -0
- data/Rakefile +5 -0
- data/bin/ionize +47 -0
- data/lib/ionize.rb +75 -0
- data/lib/ionize/environment.rb +56 -0
- data/lib/ionize/environment/application.rb +58 -0
- data/lib/ionize/environment/php_array.rb +95 -0
- data/lib/ionize/parser.rb +272 -0
- data/lib/ionize/tokenizer.rb +544 -0
- data/lib/ionize/translate.rb +34 -0
- data/lib/ionize/translate/composite_string_statements.rb +79 -0
- data/lib/ionize/translate/debug.rb +16 -0
- data/lib/ionize/translate/ext.rb +47 -0
- data/lib/ionize/translate/function_args.rb +132 -0
- data/lib/ionize/translate/if_statements.rb +42 -0
- data/lib/ionize/translate/multiple_statements.rb +22 -0
- data/lib/ionize/translate/php_to_ruby.rb +40 -0
- data/lib/ionize/translate/rails_for_php.rb +191 -0
- data/lib/ionize/translate/rewritable.rb +133 -0
- data/lib/ionize/translate/rewrites.rb +51 -0
- data/lib/ionize/translate/statements.rb +622 -0
- data/lib/ionize/translate/switch_case_statements.rb +52 -0
- data/lib/ionize/translate/term_statements.rb +76 -0
- data/lib/ionize/translate/translator.rb +52 -0
- data/lib/ionize/version.rb +9 -0
- data/spec/fixtures/array_lookup.php +10 -0
- data/spec/fixtures/boolean_operators.php +5 -0
- data/spec/fixtures/boolean_operators.rb +6 -0
- data/spec/fixtures/class_def.php +34 -0
- data/spec/fixtures/class_def.rb +34 -0
- data/spec/fixtures/dangling_else.php +8 -0
- data/spec/fixtures/dangling_else.rb +12 -0
- data/spec/fixtures/drupal_1.php +663 -0
- data/spec/fixtures/drupal_2.php +1152 -0
- data/spec/fixtures/empty_string.php +12 -0
- data/spec/fixtures/for_loop.php +17 -0
- data/spec/fixtures/for_loop2.php +13 -0
- data/spec/fixtures/for_loop3.php +16 -0
- data/spec/fixtures/for_loop3.rb +17 -0
- data/spec/fixtures/for_loop4.php +5 -0
- data/spec/fixtures/for_loop4.rb +6 -0
- data/spec/fixtures/foreach.php +9 -0
- data/spec/fixtures/foreach2.php +8 -0
- data/spec/fixtures/foreach3.php +7 -0
- data/spec/fixtures/foreach3.rb +7 -0
- data/spec/fixtures/fun_def.php +9 -0
- data/spec/fixtures/fun_def2.php +30 -0
- data/spec/fixtures/fun_def2.rb +30 -0
- data/spec/fixtures/fun_def3.php +33 -0
- data/spec/fixtures/fun_def4.php +43 -0
- data/spec/fixtures/fun_def4.rb +37 -0
- data/spec/fixtures/fun_def5.php +36 -0
- data/spec/fixtures/fun_with_if.php +6 -0
- data/spec/fixtures/fun_with_if.rb +6 -0
- data/spec/fixtures/fun_with_ifs.php +12 -0
- data/spec/fixtures/fun_with_ifs.rb +14 -0
- data/spec/fixtures/hello_world.php +6 -0
- data/spec/fixtures/heredoc.php +6 -0
- data/spec/fixtures/heredoc.rb +5 -0
- data/spec/fixtures/if.php +6 -0
- data/spec/fixtures/if.rb +7 -0
- data/spec/fixtures/if_boolean.php +5 -0
- data/spec/fixtures/if_boolean.rb +5 -0
- data/spec/fixtures/if_else.php +11 -0
- data/spec/fixtures/if_else1.php +17 -0
- data/spec/fixtures/if_else2.php +8 -0
- data/spec/fixtures/if_else3.php +15 -0
- data/spec/fixtures/if_else_nested.php +14 -0
- data/spec/fixtures/if_else_nested.rb +15 -0
- data/spec/fixtures/if_else_series.php +12 -0
- data/spec/fixtures/if_else_series.rb +12 -0
- data/spec/fixtures/if_not.php +5 -0
- data/spec/fixtures/if_not.rb +5 -0
- data/spec/fixtures/if_with_brackets.php +7 -0
- data/spec/fixtures/if_with_brackets.rb +7 -0
- data/spec/fixtures/long_if_else.php +10 -0
- data/spec/fixtures/long_if_else.rb +9 -0
- data/spec/fixtures/oo.php +16 -0
- data/spec/fixtures/php_nuke/sql_layer.php +527 -0
- data/spec/fixtures/postop.php +3 -0
- data/spec/fixtures/preop.php +7 -0
- data/spec/fixtures/simple_fun_def.php +4 -0
- data/spec/fixtures/switch_case.php +13 -0
- data/spec/fixtures/switch_case.rb +14 -0
- data/spec/fixtures/switch_case2.php +25 -0
- data/spec/fixtures/switch_case3.php +40 -0
- data/spec/fixtures/switch_case3.rb +42 -0
- data/spec/fixtures/switch_case4.php +56 -0
- data/spec/fixtures/switch_case5.php +71 -0
- data/spec/fixtures/switch_case_with_rescue_nil.php +43 -0
- data/spec/fixtures/switch_case_with_rescue_nil.rb +35 -0
- data/spec/fixtures/tertiary.php +3 -0
- data/spec/helper.rb +17 -0
- data/spec/php_environment_spec.rb +83 -0
- data/spec/php_parser_spec.rb +121 -0
- data/spec/php_translator_spec.rb +358 -0
- data/spec/rails_for_php_spec.rb +303 -0
- metadata +191 -0
@@ -0,0 +1,17 @@
|
|
1
|
+
#!/usr/bin/php
|
2
|
+
|
3
|
+
srand(time());
|
4
|
+
for ($i=0; $i < 3; $i++)
|
5
|
+
{
|
6
|
+
$random = (rand()%3);
|
7
|
+
$slot[] = $random;
|
8
|
+
}
|
9
|
+
print("<td width=\"33%\"><center>$slot[0]</td>");
|
10
|
+
print("<td width=\"33%\"><center>$slot[1]</td>");
|
11
|
+
print("<td width=\"33%\"><center>$slot[2]</td>");
|
12
|
+
|
13
|
+
if($slot[0] == $slot[1] && $slot[0] == $slot[2])
|
14
|
+
{
|
15
|
+
print("</td></tr>Winner! -- Hit refresh on your browser to play again");
|
16
|
+
exit;
|
17
|
+
}
|
@@ -0,0 +1,16 @@
|
|
1
|
+
|
2
|
+
$res = array();
|
3
|
+
$nr = array();
|
4
|
+
|
5
|
+
$row = array();
|
6
|
+
$result = array();
|
7
|
+
$result = odbc_fetch_row($res, $nr);
|
8
|
+
$nf = odbc_num_fields($res); /* Field numbering starts at 1 */
|
9
|
+
|
10
|
+
for($count=1; $count < $nf+1; $count++) {
|
11
|
+
$field_name = odbc_field_name($res, $count);
|
12
|
+
$field_value = odbc_result($res, $field_name);
|
13
|
+
$row[$field_name] = $field_value;
|
14
|
+
}
|
15
|
+
|
16
|
+
|
@@ -0,0 +1,17 @@
|
|
1
|
+
|
2
|
+
res = array()
|
3
|
+
nr = array()
|
4
|
+
|
5
|
+
row = array()
|
6
|
+
result = array()
|
7
|
+
result = odbc_fetch_row(res, nr)
|
8
|
+
nf = odbc_num_fields(res)
|
9
|
+
|
10
|
+
count = 1
|
11
|
+
while count < nf + 1
|
12
|
+
field_name = odbc_field_name(res, count)
|
13
|
+
field_value = odbc_result(res, field_name)
|
14
|
+
row[field_name] = field_value
|
15
|
+
count += 1
|
16
|
+
end
|
17
|
+
|
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
function db_add_column(&$ret, $table, $column, $type, $attributes = array()) {
|
3
|
+
if (array_key_exists('not null', $attributes) and $attributes['not null']) {
|
4
|
+
$not_null = 'NOT NULL';
|
5
|
+
}
|
6
|
+
|
7
|
+
if (array_key_exists('default', $attributes)) {
|
8
|
+
if (is_null($attributes['default'])) {
|
9
|
+
$default_val = 'NULL';
|
10
|
+
$default = 'default NULL';
|
11
|
+
} elseif ($attributes['default'] === FALSE) {
|
12
|
+
$default = '';
|
13
|
+
} else {
|
14
|
+
$default_val = "$attributes[default]";
|
15
|
+
$default = "default $attributes[default]";
|
16
|
+
}
|
17
|
+
}
|
18
|
+
|
19
|
+
$ret[] = update_sql("ALTER TABLE {". $table ."} ADD $column $type");
|
20
|
+
if (!empty($default)) {
|
21
|
+
$ret[] = update_sql("ALTER TABLE {". $table ."} ALTER $column SET $default");
|
22
|
+
}
|
23
|
+
|
24
|
+
if (!empty($not_null)) {
|
25
|
+
if (!empty($default)) {
|
26
|
+
$ret[] = update_sql("UPDATE {". $table ."} SET $column = $default_val");
|
27
|
+
}
|
28
|
+
$ret[] = update_sql("ALTER TABLE {". $table ."} ALTER $column SET NOT NULL");
|
29
|
+
}
|
30
|
+
}
|
@@ -0,0 +1,30 @@
|
|
1
|
+
|
2
|
+
def db_add_column(ret, table, column, type, attributes = array())
|
3
|
+
if array_key_exists('not null', attributes) and attributes['not null']
|
4
|
+
not_null = 'NOT NULL'
|
5
|
+
end
|
6
|
+
|
7
|
+
if array_key_exists('default', attributes)
|
8
|
+
if is_null(attributes['default'])
|
9
|
+
default_val = 'NULL'
|
10
|
+
default = 'default NULL'
|
11
|
+
elsif attributes['default'] === false
|
12
|
+
default = ''
|
13
|
+
else
|
14
|
+
default_val = "#{attributes['default']}"
|
15
|
+
default = "default #{attributes['default']}"
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
ret << update_sql("ALTER TABLE {" + table + "} ADD #{column} #{type}")
|
20
|
+
if !empty(default)
|
21
|
+
ret << update_sql("ALTER TABLE {" + table + "} ALTER #{column} SET #{default}")
|
22
|
+
end
|
23
|
+
|
24
|
+
if !empty(not_null)
|
25
|
+
if !empty(default)
|
26
|
+
ret << update_sql("UPDATE {" + table + "} SET #{column} = #{default_val}")
|
27
|
+
end
|
28
|
+
ret << update_sql("ALTER TABLE {" + table + "} ALTER #{column} SET NOT NULL")
|
29
|
+
end
|
30
|
+
end
|
@@ -0,0 +1,33 @@
|
|
1
|
+
|
2
|
+
// Here's a goodie..
|
3
|
+
// Watch out for the '&' and 'and' nodes
|
4
|
+
|
5
|
+
function db_add_column(&$ret, $table, $column, $type, $attributes = array()) {
|
6
|
+
if (array_key_exists('not null', $attributes) and $attributes['not null']) {
|
7
|
+
$not_null = 'NOT NULL';
|
8
|
+
}
|
9
|
+
if (array_key_exists('default', $attributes)) {
|
10
|
+
if (is_null($attributes['default'])) {
|
11
|
+
$default_val = 'NULL';
|
12
|
+
$default = 'default NULL';
|
13
|
+
}
|
14
|
+
elseif ($attributes['default'] === FALSE) {
|
15
|
+
$default = '';
|
16
|
+
}
|
17
|
+
else {
|
18
|
+
$default_val = "$attributes[default]";
|
19
|
+
$default = "default $attributes[default]";
|
20
|
+
}
|
21
|
+
}
|
22
|
+
|
23
|
+
$ret[] = update_sql("ALTER TABLE {". $table ."} ADD $column $type");
|
24
|
+
if (!empty($default)) {
|
25
|
+
$ret[] = update_sql("ALTER TABLE {". $table ."} ALTER $column SET $default");
|
26
|
+
}
|
27
|
+
if (!empty($not_null)) {
|
28
|
+
if (!empty($default)) {
|
29
|
+
$ret[] = update_sql("UPDATE {". $table ."} SET $column = $default_val");
|
30
|
+
}
|
31
|
+
$ret[] = update_sql("ALTER TABLE {". $table ."} ALTER $column SET NOT NULL");
|
32
|
+
}
|
33
|
+
}
|
@@ -0,0 +1,43 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
function update_fix_d6_requirements() {
|
4
|
+
$ret = array();
|
5
|
+
|
6
|
+
if (drupal_get_installed_schema_version('system') < 6000 && !variable_get('update_d6_requirements', FALSE)) {
|
7
|
+
$spec = array('type' => 'int', 'size' => 'small', 'default' => 0, 'not null' => TRUE);
|
8
|
+
db_add_field($ret, 'cache', 'serialized', $spec);
|
9
|
+
db_add_field($ret, 'cache_filter', 'serialized', $spec);
|
10
|
+
db_add_field($ret, 'cache_page', 'serialized', $spec);
|
11
|
+
db_add_field($ret, 'cache_menu', 'serialized', $spec);
|
12
|
+
|
13
|
+
db_add_field($ret, 'system', 'info', array('type' => 'text'));
|
14
|
+
db_add_field($ret, 'system', 'owner', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''));
|
15
|
+
if (db_table_exists('locales_target')) {
|
16
|
+
db_add_field($ret, 'locales_target', 'language', array('type' => 'varchar', 'length' => 12, 'not null' => TRUE, 'default' => ''));
|
17
|
+
}
|
18
|
+
if (db_table_exists('locales_source')) {
|
19
|
+
db_add_field($ret, 'locales_source', 'textgroup', array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => 'default'));
|
20
|
+
db_add_field($ret, 'locales_source', 'version', array('type' => 'varchar', 'length' => 20, 'not null' => TRUE, 'default' => 'none'));
|
21
|
+
}
|
22
|
+
variable_set('update_d6_requirements', TRUE);
|
23
|
+
|
24
|
+
$schema = array();
|
25
|
+
|
26
|
+
// Create the cache_block table. See system_update_6027() for more details.
|
27
|
+
$schema['cache_block'] = array(
|
28
|
+
'fields' => array(
|
29
|
+
'cid' => array('type' => 'varchar', 'length' => 255, 'not null' => TRUE, 'default' => ''),
|
30
|
+
'data' => array('type' => 'blob', 'not null' => FALSE, 'size' => 'big'),
|
31
|
+
'expire' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
32
|
+
'created' => array('type' => 'int', 'not null' => TRUE, 'default' => 0),
|
33
|
+
'headers' => array('type' => 'text', 'not null' => FALSE),
|
34
|
+
'serialized' => array('type' => 'int', 'size' => 'small', 'not null' => TRUE, 'default' => 0)
|
35
|
+
),
|
36
|
+
'indexes' => array('expire' => array('expire')),
|
37
|
+
'primary key' => array('cid'),
|
38
|
+
);
|
39
|
+
db_create_table($ret, 'cache_block', $schema['cache_block']);
|
40
|
+
}
|
41
|
+
|
42
|
+
return $ret;
|
43
|
+
}
|
@@ -0,0 +1,37 @@
|
|
1
|
+
|
2
|
+
def update_fix_d6_requirements
|
3
|
+
ret = array()
|
4
|
+
if (drupal_get_installed_schema_version("system") < (6000 and (not variable_get("update_d6_requirements", false)))) then
|
5
|
+
spec = array("type" => "int", "size" => "small", "default" => 0, "not null" => true)
|
6
|
+
db_add_field(ret, "cache", "serialized", spec)
|
7
|
+
db_add_field(ret, "cache_filter", "serialized", spec)
|
8
|
+
db_add_field(ret, "cache_page", "serialized", spec)
|
9
|
+
db_add_field(ret, "cache_menu", "serialized", spec)
|
10
|
+
|
11
|
+
db_add_field(ret, "system", "info", array("type" => "text"))
|
12
|
+
db_add_field(ret, "system", "owner", array("type" => "varchar", "length" => 255, "not null" => true, "default" => ""))
|
13
|
+
if db_table_exists("locales_target") then
|
14
|
+
db_add_field(ret, "locales_target", "language", array("type" => "varchar", "length" => 12, "not null" => true, "default" => ""))
|
15
|
+
end
|
16
|
+
if db_table_exists("locales_source") then
|
17
|
+
db_add_field(ret, "locales_source", "textgroup", array("type" => "varchar", "length" => 255, "not null" => true, "default" => "default"))
|
18
|
+
db_add_field(ret, "locales_source", "version", array("type" => "varchar", "length" => 20, "not null" => true, "default" => "none"))
|
19
|
+
end
|
20
|
+
variable_set("update_d6_requirements", true)
|
21
|
+
|
22
|
+
schema = array()
|
23
|
+
|
24
|
+
schema["cache_block"] = array(
|
25
|
+
"fields" => array(
|
26
|
+
"cid" => array("type" => "varchar", "length" => 255, "not null" => true, "default" => ""),
|
27
|
+
"data" => array("type" => "blob", "not null" => false, "size" => "big"),
|
28
|
+
"expire" => array("type" => "int", "not null" => true, "default" => 0),
|
29
|
+
"created" => array("type" => "int", "not null" => true, "default" => 0),
|
30
|
+
"headers" => array("type" => "text", "not null" => false),
|
31
|
+
"serialized" => array("type" => "int", "size" => "small", "not null" => true, "default" => 0)),
|
32
|
+
"indexes" => array("expire" => array("expire")), "primary key" => array("cid"))
|
33
|
+
|
34
|
+
db_create_table(ret, "cache_block", schema["cache_block"])
|
35
|
+
end
|
36
|
+
return ret
|
37
|
+
end
|
@@ -0,0 +1,36 @@
|
|
1
|
+
|
2
|
+
function update_do_one($module, $number, &$context) {
|
3
|
+
// If updates for this module have been aborted
|
4
|
+
// in a previous step, go no further.
|
5
|
+
if (!empty($context['results'][$module]['#abort'])) {
|
6
|
+
return;
|
7
|
+
}
|
8
|
+
|
9
|
+
$function = $module .'_update_'. $number;
|
10
|
+
if (function_exists($function)) {
|
11
|
+
$ret = $function($context['sandbox']);
|
12
|
+
}
|
13
|
+
|
14
|
+
if (isset($ret['#finished'])) {
|
15
|
+
$context['finished'] = $ret['#finished'];
|
16
|
+
unset($ret['#finished']);
|
17
|
+
}
|
18
|
+
|
19
|
+
if (!isset($context['results'][$module])) {
|
20
|
+
$context['results'][$module] = array();
|
21
|
+
}
|
22
|
+
if (!isset($context['results'][$module][$number])) {
|
23
|
+
$context['results'][$module][$number] = array();
|
24
|
+
}
|
25
|
+
$context['results'][$module][$number] = array_merge($context['results'][$module][$number], $ret);
|
26
|
+
|
27
|
+
if (!empty($ret['#abort'])) {
|
28
|
+
$context['results'][$module]['#abort'] = TRUE;
|
29
|
+
}
|
30
|
+
// Record the schema update if it was completed successfully.
|
31
|
+
if ($context['finished'] == 1 && empty($context['results'][$module]['#abort'])) {
|
32
|
+
drupal_set_installed_schema_version($module, $number);
|
33
|
+
}
|
34
|
+
|
35
|
+
$context['message'] = 'Updating '. check_plain($module) .' module';
|
36
|
+
}
|