2012-09-22 08:26:34 -07:00
< ? php
/**
* GameWiki for Minetest
*
* Copyright ( c ) 2012 cornernote , Brett O ' Donnell < cornernote @ gmail . com >
*
* Source Code : https :// github . com / cornernote / minetest - gamewiki
* License : GPLv3
*/
require ( 'globals.php' );
?>
2012-08-17 05:40:50 -07:00
<! DOCTYPE html >
< html lang = " en " >
< head >
2012-09-22 08:26:34 -07:00
< title > View Item :: < ? php echo $GLOBALS [ 'name' ]; ?> </title>
< ? php include ( 'include/head_tags.php' ); ?>
2012-08-17 05:40:50 -07:00
</ head >
< body >
2012-09-22 08:26:34 -07:00
< ? php include ( 'include/menu.php' ); ?>
2012-08-17 05:40:50 -07:00
< div class = " container " >
< ? php
$name = SQLite3 :: escapeString ( $_GET [ 'name' ]);
2012-09-22 08:26:34 -07:00
$q = $db -> query ( 'SELECT id, mod, type, name, description, data FROM "item" WHERE name = "' . $name . '"' );
2012-08-17 05:40:50 -07:00
$row = $q -> fetchArray ();
$data = json_decode ( $row [ 'data' ]);
?>
< h1 >< ? php echo $row [ 'description' ] ? $row [ 'description' ] : $row [ 'name' ]; ?>
< small >< ? php echo '[' . $row [ 'type' ] . '][' . $row [ 'name' ] . ']' ; ?> </small>
</ h1 >
< ? php
// item
2012-09-22 08:26:34 -07:00
echo gamewiki :: item ( $row [ 'name' ]);
2012-08-17 05:40:50 -07:00
// images
$images = array_merge (
isset ( $data -> options -> inventory_image ) ? is_array ( $data -> options -> inventory_image ) ? $data -> options -> inventory_image : array ( $data -> options -> inventory_image ) : array (),
isset ( $data -> options -> tiles ) ? ( array ) $data -> options -> tiles : array (),
isset ( $data -> options -> tile_images ) ? ( array ) $data -> options -> tile_images : array ()
);
if ( ! empty ( $images )) {
echo '<h2>Images</h2>' ;
2012-09-22 08:26:34 -07:00
echo gamewiki :: images ( $images , array ( 'fullsize' => true , 'class' => 'image' ));
2012-08-17 05:40:50 -07:00
}
// created by crafts
2012-09-22 08:26:34 -07:00
$output = false ;
ob_start ();
echo '<h2>Created By Crafts</h2>' ;
$q = $db -> query ( 'SELECT id, mod, type, output, quantity, data FROM "craft" WHERE output = "' . $name . '"' );
echo '<table class="table">' ;
echo '<tr>' ;
echo '<th style="width:100px">Mod</th>' ;
echo '<th style="width:100px">Type</th>' ;
echo '<th>Recipe</th>' ;
echo '<th style="width:100px;"> </th>' ;
echo '</tr>' ;
2012-08-17 05:40:50 -07:00
while ( $row_c = $q -> fetchArray ()) {
2012-09-22 08:26:34 -07:00
$data = json_decode ( $row_c [ 'data' ]);
echo '<tr>' ;
echo '<td>' . $row_c [ 'mod' ] . '</td>' ;
echo '<td>' . $row_c [ 'type' ] . '</td>' ;
echo '<td>' . ( isset ( $data -> options -> recipe ) ? gamewiki :: craft_recipe ( $data -> options -> recipe , $row_c [ 'type' ], true ) : $row_c [ 'type' ]) . '</td>' ;
echo '<td><a href="craft.php?id=' . $row_c [ 'id' ] . '" class="btn">view craft</a></td>' ;
echo '</tr>' ;
$output = true ;
2012-08-17 05:40:50 -07:00
}
2012-09-22 08:26:34 -07:00
echo '</table>' ;
$contents = ob_get_clean ();
if ( $output ) echo $contents ;
2012-08-17 05:40:50 -07:00
// used for crafts
$output = false ;
ob_start ();
echo '<h2>Used For Crafts</h2>' ;
2012-09-22 08:26:34 -07:00
$q = $db -> query ( 'SELECT id, mod, type, output, quantity, data FROM "craft_to_itemname" LEFT JOIN "craft" ON "craft"."id"="craft_to_itemname"."craft_id" WHERE name = "' . $name . '" ORDER BY output' );
2012-08-17 05:40:50 -07:00
echo '<table class="table">' ;
echo '<tr>' ;
2012-09-22 08:26:34 -07:00
echo '<th style="width:100px">Mod</th>' ;
echo '<th style="width:100px">Type</th>' ;
echo '<th>Recipe</th>' ;
2012-08-17 05:40:50 -07:00
echo '<th>Output</th>' ;
2012-09-22 08:26:34 -07:00
echo '<th style="width:100px;"> </th>' ;
2012-08-17 05:40:50 -07:00
echo '</tr>' ;
while ( $row_c = $q -> fetchArray ()) {
2012-09-22 08:26:34 -07:00
$data = json_decode ( $row_c [ 'data' ]);
2012-08-17 05:40:50 -07:00
echo '<tr>' ;
echo '<td>' . $row_c [ 'mod' ] . '</td>' ;
echo '<td>' . $row_c [ 'type' ] . '</td>' ;
2012-09-22 08:26:34 -07:00
echo '<td>' . ( isset ( $data -> options -> recipe ) ? gamewiki :: craft_recipe ( $data -> options -> recipe , $row_c [ 'type' ], true ) : $row_c [ 'type' ]) . '</td>' ;
if ( $row_c [ 'type' ] == 'fuel' ) {
echo '<td>' . gamewiki :: item ( 'default:furnace_active' , null , true ) . '</td>' ;
}
else {
echo '<td>' . ( $row_c [ 'output' ] ? gamewiki :: item ( $row_c [ 'output' ], $row_c [ 'quantity' ], true ) : 'no output' ) . '</td>' ;
}
2012-08-17 05:40:50 -07:00
echo '<td><a href="craft.php?id=' . $row_c [ 'id' ] . '" class="btn">view craft</a></td>' ;
echo '</tr>' ;
$output = true ;
}
echo '</table>' ;
$contents = ob_get_clean ();
if ( $output ) echo $contents ;
// used by abms
$rows = array ();
2012-09-22 08:26:34 -07:00
$q = $db -> query ( 'SELECT id FROM "abm_to_itemname" LEFT JOIN "abm" ON "abm"."id"="abm_to_itemname"."abm_id" WHERE name = "' . $name . '"' );
2012-08-17 05:40:50 -07:00
while ( $row_a = $q -> fetchArray ()) {
$rows [] = '<a href="abm.php?id=' . $row_a [ 'id' ] . '" class="btn">view abm</a>' ;
}
if ( $rows ) {
echo '<h2>Used By ABMs</h2>' ;
echo implode ( ' ' , $rows );
}
2012-09-22 08:26:34 -07:00
// used by aliases
$output = false ;
ob_start ();
echo '<h2>Used By Aliases</h2>' ;
$q = $db -> query ( 'SELECT id, name, mod FROM "alias" WHERE itemname = "' . $name . '"' );
echo '<table class="table">' ;
echo '<tr>' ;
echo '<th style="width:100px;">Mod</th>' ;
echo '<th style="width:100px;">Alias</th>' ;
echo '</tr>' ;
while ( $row_a = $q -> fetchArray ()) {
$output = true ;
echo '<tr>' ;
echo '<td>' . $row_a [ 'mod' ] . '</td>' ;
echo '<td>' . $row_a [ 'name' ] . '</td>' ;
echo '</tr>' ;
}
echo '</table>' ;
$contents = ob_get_clean ();
if ( $output ) echo $contents ;
// other data
2012-08-17 05:40:50 -07:00
echo '<h2>Data</h2>' ;
echo '<h3>mod:' . $row [ 'mod' ] . '</h3>' ;
print '<pre>' ;
print_r ( $data );
print '</pre>' ;
?>
</ div >
2012-09-22 08:26:34 -07:00
< div id = " footer " ></ div >
2012-08-17 05:40:50 -07:00
</ body >
</ html >