update wiki
29
wiki/abm.php
|
@ -1,18 +1,28 @@
|
|||
<?php require('globals.php'); ?>
|
||||
<?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');
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>MTGW</title>
|
||||
<?php echo head_tags(); ?>
|
||||
<title>View ABM :: <?php echo $GLOBALS['name']; ?></title>
|
||||
<?php include('include/head_tags.php'); ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php echo menu(); ?>
|
||||
<?php include('include/menu.php'); ?>
|
||||
<div class="container">
|
||||
|
||||
<?php
|
||||
$id = SQLite3::escapeString($_GET['id']);
|
||||
$q = $GLOBALS['db']->query('SELECT id, mod, data FROM "abm" WHERE id = "' . $id . '"');
|
||||
$q = $db->query('SELECT id, mod, data FROM "abm" WHERE id = "' . $id . '"');
|
||||
$row = $q->fetchArray();
|
||||
$data = json_decode($row['data']);
|
||||
echo '<h1>ABM</h1>';
|
||||
|
@ -24,14 +34,14 @@
|
|||
if (is_array($data->options->nodenames)) foreach ($data->options->nodenames as $nodename) {
|
||||
echo '<tr>';
|
||||
echo '<td>';
|
||||
echo item($nodename);
|
||||
echo gamewiki::item($nodename);
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
else {
|
||||
echo '<tr>';
|
||||
echo '<td>';
|
||||
echo item($data->nodenames);
|
||||
echo gamewiki::item($data->nodenames);
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
@ -46,14 +56,14 @@
|
|||
if (is_array($data->options->neighbors)) foreach ($data->options->neighbors as $neighbor) {
|
||||
echo '<tr>';
|
||||
echo '<td>';
|
||||
echo item($neighbor);
|
||||
echo gamewiki::item($neighbor);
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
else {
|
||||
echo '<tr>';
|
||||
echo '<td>';
|
||||
echo item($data->neighbors);
|
||||
echo gamewiki::item($data->neighbors);
|
||||
echo '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
|
@ -69,5 +79,6 @@
|
|||
?>
|
||||
|
||||
</div>
|
||||
<div id="footer"></div>
|
||||
</body>
|
||||
</html>
|
140
wiki/abms.php
|
@ -1,73 +1,97 @@
|
|||
<?php require('globals.php'); ?>
|
||||
<?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');
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>MTGW</title>
|
||||
<?php echo head_tags(); ?>
|
||||
<title>List ABMs :: <?php echo $GLOBALS['name']; ?></title>
|
||||
<?php include('include/head_tags.php'); ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php echo menu(); ?>
|
||||
<?php include('include/menu.php'); ?>
|
||||
<div class="container">
|
||||
<h1>ABMs</h1>
|
||||
|
||||
<?php
|
||||
$q = $GLOBALS['db']->query('SELECT id, mod, data FROM "abm" ORDER BY mod');
|
||||
echo '<table class="table">';
|
||||
echo '<tr>';
|
||||
echo '<th width="100">Mod</th>';
|
||||
echo '<th width="30%">Node Names</th>';
|
||||
echo '<th width="30%">Neighbors</th>';
|
||||
echo '<th width="100">C / I</th>';
|
||||
echo '<th width="100"> </th>';
|
||||
echo '<td>';
|
||||
while ($row = $q->fetchArray()) {
|
||||
$data = json_decode($row['data']);
|
||||
echo '<tr>';
|
||||
echo '<td>' . $row['mod'] . '</td>';
|
||||
echo '<td>';
|
||||
echo '<div class="itemgroup"><ul>';
|
||||
if (isset($data->options)) {
|
||||
if (!empty($data->options->nodenames)) {
|
||||
if (is_array($data->options->nodenames)) foreach ($data->options->nodenames as $nodename) {
|
||||
echo '<li>';
|
||||
echo item($nodename);
|
||||
echo '</li>';
|
||||
}
|
||||
elseif (isset($data->nodenames)) {
|
||||
echo '<li>';
|
||||
echo item($data->nodenames);
|
||||
echo '</li>';
|
||||
}
|
||||
}
|
||||
}
|
||||
echo '</div></ul>';
|
||||
echo '</td>';
|
||||
echo '<td>';
|
||||
echo '<div class="itemgroup"><ul>';
|
||||
if (isset($data->options)) {
|
||||
if (!empty($data->options->neighbors)) {
|
||||
if (is_array($data->options->neighbors)) foreach ($data->options->neighbors as $neighbor) {
|
||||
echo '<li>';
|
||||
echo item($neighbor);
|
||||
echo '</li>';
|
||||
}
|
||||
else {
|
||||
echo '<li>';
|
||||
echo item($data->neighbors);
|
||||
echo '</li>';
|
||||
}
|
||||
}
|
||||
}
|
||||
echo '</div></ul>';
|
||||
echo '</td>';
|
||||
echo '<td>' . (isset($data->options->chance) ? $data->options->chance : '?') . ' / ' . (isset($data->options->interval) ? $data->options->interval : '?') . '</td>';
|
||||
echo '<td><a href="abm.php?id=' . $row['id'] . '" class="btn">view abm</a></td>';
|
||||
echo '</tr>';
|
||||
$mods = gamewiki::get_mods();
|
||||
$filters = $filter_sql = $filter_join = '';
|
||||
if (isset($_GET['mod'])) {
|
||||
$filters .= '[mod:' . $_GET['mod'] . ']';
|
||||
$filter_sql .= 'AND mod="' . SQLite3::escapeString($_GET['mod']) . '" ';
|
||||
}
|
||||
?>
|
||||
|
||||
<h1>ABMs
|
||||
<small><?php echo $filters; ?></small>
|
||||
</h1>
|
||||
|
||||
<?php
|
||||
$mods = gamewiki::get_mods();
|
||||
foreach ($mods as $mod) {
|
||||
$output_mod = false;
|
||||
ob_start();
|
||||
echo '<h2>mod:' . ($mod ? $mod : 'no-mod') . '</h2>';
|
||||
$q = $db->query('SELECT id, mod, data FROM "abm" ' . $filter_join . ' WHERE mod="' . $mod . '" ' . $filter_sql . ' ORDER BY mod');
|
||||
echo '<table class="table">';
|
||||
echo '<tr>';
|
||||
echo '<th style="width:100px;">Mod</th>';
|
||||
echo '<th>Node Names</th>';
|
||||
echo '<th>Neighbors</th>';
|
||||
echo '<th style="width:100px;">C / I</th>';
|
||||
echo '<th style="width:100px;"> </th>';
|
||||
echo '<td>';
|
||||
while ($row = $q->fetchArray()) {
|
||||
$output_mod = true;
|
||||
$data = json_decode($row['data']);
|
||||
echo '<tr>';
|
||||
echo '<td>' . $row['mod'] . '</td>';
|
||||
echo '<td>';
|
||||
echo '<div class="itemgroup">';
|
||||
if (isset($data->options)) {
|
||||
if (!empty($data->options->nodenames)) {
|
||||
if (is_array($data->options->nodenames)) foreach ($data->options->nodenames as $nodename) {
|
||||
echo gamewiki::item($nodename, null, true);
|
||||
}
|
||||
elseif (isset($data->nodenames)) {
|
||||
echo gamewiki::item($data->nodenames, null, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</td>';
|
||||
echo '<td>';
|
||||
echo '<div class="itemgroup">';
|
||||
if (isset($data->options)) {
|
||||
if (!empty($data->options->neighbors)) {
|
||||
if (is_array($data->options->neighbors)) foreach ($data->options->neighbors as $neighbor) {
|
||||
echo gamewiki::item($neighbor, null, true);
|
||||
}
|
||||
else {
|
||||
echo gamewiki::item($data->neighbors, null, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
echo '</div>';
|
||||
echo '</td>';
|
||||
echo '<td>' . (isset($data->options->chance) ? $data->options->chance : '?') . ' / ' . (isset($data->options->interval) ? $data->options->interval : '?') . '</td>';
|
||||
echo '<td><a href="abm.php?id=' . $row['id'] . '" class="btn">view abm</a></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
$contents = ob_get_clean();
|
||||
if ($output_mod) echo $contents;
|
||||
}
|
||||
echo '</table>';
|
||||
?>
|
||||
|
||||
</div>
|
||||
<div id="footer"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,35 +1,66 @@
|
|||
<?php require('globals.php'); ?>
|
||||
<?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');
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>MTGW</title>
|
||||
<?php echo head_tags(); ?>
|
||||
<title>List Aliases :: <?php echo $GLOBALS['name']; ?></title>
|
||||
<?php include('include/head_tags.php'); ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php echo menu(); ?>
|
||||
<?php include('include/menu.php'); ?>
|
||||
<div class="container">
|
||||
<h1>Aliases</h1>
|
||||
|
||||
<?php
|
||||
$q = $GLOBALS['db']->query('SELECT id, mod, data FROM "alias" ORDER BY mod');
|
||||
echo '<table class="table">';
|
||||
echo '<tr>';
|
||||
echo '<th width="100">Mod</th>';
|
||||
echo '<th width="100">Alias</th>';
|
||||
echo '<th>Item</th>';
|
||||
echo '</tr>';
|
||||
while ($row = $q->fetchArray()) {
|
||||
$data = json_decode($row['data']);
|
||||
echo '<tr>';
|
||||
echo '<td>' . $row['mod'] . '</td>';
|
||||
echo '<td>' . $data->name . '</td>';
|
||||
echo '<td>' . item($data->options) . '</td>';
|
||||
echo '</tr>';
|
||||
$mods = gamewiki::get_mods();
|
||||
$filters = $filter_sql = $filter_join = '';
|
||||
if (isset($_GET['mod'])) {
|
||||
$filters .= '[mod:' . $_GET['mod'] . ']';
|
||||
$filter_sql .= 'AND mod="' . SQLite3::escapeString($_GET['mod']) . '" ';
|
||||
}
|
||||
echo '</table>';
|
||||
?>
|
||||
|
||||
<h1>Aliases
|
||||
<small><?php echo $filters; ?></small>
|
||||
</h1>
|
||||
|
||||
<?php
|
||||
foreach ($mods as $mod) {
|
||||
$output_mod = false;
|
||||
ob_start();
|
||||
echo '<h2>mod:' . ($mod ? $mod : 'no-mod') . '</h2>';
|
||||
$q = $db->query('SELECT id, mod, data FROM ' . $filter_join . ' "alias" WHERE mod="' . $mod . '" ' . $filter_sql . ' ORDER BY mod');
|
||||
echo '<table class="table">';
|
||||
echo '<tr>';
|
||||
echo '<th style="width:100px;">Mod</th>';
|
||||
echo '<th style="width:100px;">Alias</th>';
|
||||
echo '<th>Item</th>';
|
||||
echo '</tr>';
|
||||
while ($row = $q->fetchArray()) {
|
||||
$output_mod = true;
|
||||
$data = json_decode($row['data']);
|
||||
echo '<tr>';
|
||||
echo '<td>' . $row['mod'] . '</td>';
|
||||
echo '<td>' . $data->name . '</td>';
|
||||
echo '<td>' . gamewiki::item($data->options, null, true) . '</td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
$contents = ob_get_clean();
|
||||
if ($output_mod) echo $contents;
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
<div id="footer"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,102 @@
|
|||
h2 {
|
||||
border: 1px solid #ddd;
|
||||
border-width: 1px 0;
|
||||
margin: 1.5em 0 0.5em 0;
|
||||
padding: 0 0.4em;
|
||||
background: #eee;
|
||||
}
|
||||
|
||||
a.item {
|
||||
display: block;
|
||||
border: 1px solid #ccc;
|
||||
width: 345px;
|
||||
padding: 10px;
|
||||
background: #FFF;
|
||||
}
|
||||
|
||||
a.item:hover {
|
||||
text-decoration: none;
|
||||
background: #FFC;
|
||||
}
|
||||
|
||||
a.item .image {
|
||||
float: left;
|
||||
margin: 3px 4px 0 0;
|
||||
}
|
||||
|
||||
a.item .description {
|
||||
font-size: 120%;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
display: block;
|
||||
}
|
||||
|
||||
img.image {
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.home h2 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.home h2 a {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.home ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.home li {
|
||||
margin: 5px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.home li a:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.itemgroup h3 {
|
||||
border: 1px solid #ddd;
|
||||
border-width: 1px 0;
|
||||
margin: 0 0 0.5em 0;
|
||||
padding: 0 0.2em;
|
||||
background: #eee;
|
||||
}
|
||||
|
||||
.itemgroup ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.itemgroup li {
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
table.crafting {
|
||||
border: 5px solid #666;
|
||||
}
|
||||
|
||||
table.crafting td {
|
||||
width: 373px;
|
||||
border: 2px solid #666;
|
||||
height: 64px;
|
||||
}
|
||||
|
||||
table.crafting td a.item {
|
||||
margin: 0 auto;
|
||||
}
|
||||
|
||||
table.crafting-small td {
|
||||
border: 1px solid #ccc;
|
||||
margin: 1px;
|
||||
padding: 1px;
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
}
|
||||
|
||||
#footer {
|
||||
clear: both;
|
||||
height: 50px;
|
||||
}
|
|
@ -0,0 +1,3 @@
|
|||
$(function () {
|
||||
$('a[rel=tooltip]').tooltip();
|
||||
});
|
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 12 KiB |
|
@ -1,5 +1,5 @@
|
|||
/* ===================================================
|
||||
* bootstrap-transition.js v2.0.4
|
||||
* bootstrap-transition.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#transitions
|
||||
* ===================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
|
@ -36,8 +36,7 @@
|
|||
, transEndEventNames = {
|
||||
'WebkitTransition' : 'webkitTransitionEnd'
|
||||
, 'MozTransition' : 'transitionend'
|
||||
, 'OTransition' : 'oTransitionEnd'
|
||||
, 'msTransition' : 'MSTransitionEnd'
|
||||
, 'OTransition' : 'oTransitionEnd otransitionend'
|
||||
, 'transition' : 'transitionend'
|
||||
}
|
||||
, name
|
||||
|
@ -59,7 +58,7 @@
|
|||
})
|
||||
|
||||
}(window.jQuery);/* ==========================================================
|
||||
* bootstrap-alert.js v2.0.4
|
||||
* bootstrap-alert.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#alerts
|
||||
* ==========================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
|
@ -148,7 +147,7 @@
|
|||
})
|
||||
|
||||
}(window.jQuery);/* ============================================================
|
||||
* bootstrap-button.js v2.0.4
|
||||
* bootstrap-button.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#buttons
|
||||
* ============================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
|
@ -200,7 +199,7 @@
|
|||
}
|
||||
|
||||
Button.prototype.toggle = function () {
|
||||
var $parent = this.$element.parent('[data-toggle="buttons-radio"]')
|
||||
var $parent = this.$element.closest('[data-toggle="buttons-radio"]')
|
||||
|
||||
$parent && $parent
|
||||
.find('.active')
|
||||
|
@ -243,7 +242,7 @@
|
|||
})
|
||||
|
||||
}(window.jQuery);/* ==========================================================
|
||||
* bootstrap-carousel.js v2.0.4
|
||||
* bootstrap-carousel.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#carousel
|
||||
* ==========================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
|
@ -290,7 +289,7 @@
|
|||
}
|
||||
|
||||
, to: function (pos) {
|
||||
var $active = this.$element.find('.active')
|
||||
var $active = this.$element.find('.item.active')
|
||||
, children = $active.parent().children()
|
||||
, activePos = children.index($active)
|
||||
, that = this
|
||||
|
@ -312,6 +311,10 @@
|
|||
|
||||
, pause: function (e) {
|
||||
if (!e) this.paused = true
|
||||
if (this.$element.find('.next, .prev').length && $.support.transition.end) {
|
||||
this.$element.trigger($.support.transition.end)
|
||||
this.cycle()
|
||||
}
|
||||
clearInterval(this.interval)
|
||||
this.interval = null
|
||||
return this
|
||||
|
@ -328,13 +331,15 @@
|
|||
}
|
||||
|
||||
, slide: function (type, next) {
|
||||
var $active = this.$element.find('.active')
|
||||
var $active = this.$element.find('.item.active')
|
||||
, $next = next || $active[type]()
|
||||
, isCycling = this.interval
|
||||
, direction = type == 'next' ? 'left' : 'right'
|
||||
, fallback = type == 'next' ? 'first' : 'last'
|
||||
, that = this
|
||||
, e = $.Event('slide')
|
||||
, e = $.Event('slide', {
|
||||
relatedTarget: $next[0]
|
||||
})
|
||||
|
||||
this.sliding = true
|
||||
|
||||
|
@ -382,9 +387,10 @@
|
|||
var $this = $(this)
|
||||
, data = $this.data('carousel')
|
||||
, options = $.extend({}, $.fn.carousel.defaults, typeof option == 'object' && option)
|
||||
, action = typeof option == 'string' ? option : options.slide
|
||||
if (!data) $this.data('carousel', (data = new Carousel(this, options)))
|
||||
if (typeof option == 'number') data.to(option)
|
||||
else if (typeof option == 'string' || (option = options.slide)) data[option]()
|
||||
else if (action) data[action]()
|
||||
else if (options.interval) data.cycle()
|
||||
})
|
||||
}
|
||||
|
@ -411,7 +417,7 @@
|
|||
})
|
||||
|
||||
}(window.jQuery);/* =============================================================
|
||||
* bootstrap-collapse.js v2.0.4
|
||||
* bootstrap-collapse.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#collapse
|
||||
* =============================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
|
@ -479,7 +485,7 @@
|
|||
|
||||
this.$element[dimension](0)
|
||||
this.transition('addClass', $.Event('show'), 'shown')
|
||||
this.$element[dimension](this.$element[0][scroll])
|
||||
$.support.transition && this.$element[dimension](this.$element[0][scroll])
|
||||
}
|
||||
|
||||
, hide: function () {
|
||||
|
@ -556,18 +562,19 @@
|
|||
* ==================== */
|
||||
|
||||
$(function () {
|
||||
$('body').on('click.collapse.data-api', '[data-toggle=collapse]', function ( e ) {
|
||||
$('body').on('click.collapse.data-api', '[data-toggle=collapse]', function (e) {
|
||||
var $this = $(this), href
|
||||
, target = $this.attr('data-target')
|
||||
|| e.preventDefault()
|
||||
|| (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '') //strip for ie7
|
||||
, option = $(target).data('collapse') ? 'toggle' : $this.data()
|
||||
$this[$(target).hasClass('in') ? 'addClass' : 'removeClass']('collapsed')
|
||||
$(target).collapse(option)
|
||||
})
|
||||
})
|
||||
|
||||
}(window.jQuery);/* ============================================================
|
||||
* bootstrap-dropdown.js v2.0.4
|
||||
* bootstrap-dropdown.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#dropdowns
|
||||
* ============================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
|
@ -594,7 +601,7 @@
|
|||
/* DROPDOWN CLASS DEFINITION
|
||||
* ========================= */
|
||||
|
||||
var toggle = '[data-toggle="dropdown"]'
|
||||
var toggle = '[data-toggle=dropdown]'
|
||||
, Dropdown = function (element) {
|
||||
var $el = $(element).on('click.dropdown.data-api', this.toggle)
|
||||
$('html').on('click.dropdown.data-api', function () {
|
||||
|
@ -609,34 +616,82 @@
|
|||
, toggle: function (e) {
|
||||
var $this = $(this)
|
||||
, $parent
|
||||
, selector
|
||||
, isActive
|
||||
|
||||
if ($this.is('.disabled, :disabled')) return
|
||||
|
||||
selector = $this.attr('data-target')
|
||||
|
||||
if (!selector) {
|
||||
selector = $this.attr('href')
|
||||
selector = selector && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
||||
}
|
||||
|
||||
$parent = $(selector)
|
||||
$parent.length || ($parent = $this.parent())
|
||||
$parent = getParent($this)
|
||||
|
||||
isActive = $parent.hasClass('open')
|
||||
|
||||
clearMenus()
|
||||
|
||||
if (!isActive) $parent.toggleClass('open')
|
||||
if (!isActive) {
|
||||
$parent.toggleClass('open')
|
||||
$this.focus()
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
, keydown: function (e) {
|
||||
var $this
|
||||
, $items
|
||||
, $active
|
||||
, $parent
|
||||
, isActive
|
||||
, index
|
||||
|
||||
if (!/(38|40|27)/.test(e.keyCode)) return
|
||||
|
||||
$this = $(this)
|
||||
|
||||
e.preventDefault()
|
||||
e.stopPropagation()
|
||||
|
||||
if ($this.is('.disabled, :disabled')) return
|
||||
|
||||
$parent = getParent($this)
|
||||
|
||||
isActive = $parent.hasClass('open')
|
||||
|
||||
if (!isActive || (isActive && e.keyCode == 27)) return $this.click()
|
||||
|
||||
$items = $('[role=menu] li:not(.divider) a', $parent)
|
||||
|
||||
if (!$items.length) return
|
||||
|
||||
index = $items.index($items.filter(':focus'))
|
||||
|
||||
if (e.keyCode == 38 && index > 0) index-- // up
|
||||
if (e.keyCode == 40 && index < $items.length - 1) index++ // down
|
||||
if (!~index) index = 0
|
||||
|
||||
$items
|
||||
.eq(index)
|
||||
.focus()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function clearMenus() {
|
||||
$(toggle).parent().removeClass('open')
|
||||
getParent($(toggle))
|
||||
.removeClass('open')
|
||||
}
|
||||
|
||||
function getParent($this) {
|
||||
var selector = $this.attr('data-target')
|
||||
, $parent
|
||||
|
||||
if (!selector) {
|
||||
selector = $this.attr('href')
|
||||
selector = selector && /#/.test(selector) && selector.replace(/.*(?=#[^\s]*$)/, '') //strip for ie7
|
||||
}
|
||||
|
||||
$parent = $(selector)
|
||||
$parent.length || ($parent = $this.parent())
|
||||
|
||||
return $parent
|
||||
}
|
||||
|
||||
|
||||
|
@ -659,14 +714,16 @@
|
|||
* =================================== */
|
||||
|
||||
$(function () {
|
||||
$('html').on('click.dropdown.data-api', clearMenus)
|
||||
$('html')
|
||||
.on('click.dropdown.data-api touchstart.dropdown.data-api', clearMenus)
|
||||
$('body')
|
||||
.on('click.dropdown', '.dropdown form', function (e) { e.stopPropagation() })
|
||||
.on('click.dropdown.data-api', toggle, Dropdown.prototype.toggle)
|
||||
.on('click.dropdown touchstart.dropdown.data-api', '.dropdown form', function (e) { e.stopPropagation() })
|
||||
.on('click.dropdown.data-api touchstart.dropdown.data-api' , toggle, Dropdown.prototype.toggle)
|
||||
.on('keydown.dropdown.data-api touchstart.dropdown.data-api', toggle + ', [role=menu]' , Dropdown.prototype.keydown)
|
||||
})
|
||||
|
||||
}(window.jQuery);/* =========================================================
|
||||
* bootstrap-modal.js v2.0.4
|
||||
* bootstrap-modal.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#modals
|
||||
* =========================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
|
@ -693,10 +750,11 @@
|
|||
/* MODAL CLASS DEFINITION
|
||||
* ====================== */
|
||||
|
||||
var Modal = function (content, options) {
|
||||
var Modal = function (element, options) {
|
||||
this.options = options
|
||||
this.$element = $(content)
|
||||
this.$element = $(element)
|
||||
.delegate('[data-dismiss="modal"]', 'click.dismiss.modal', $.proxy(this.hide, this))
|
||||
this.options.remote && this.$element.find('.modal-body').load(this.options.remote)
|
||||
}
|
||||
|
||||
Modal.prototype = {
|
||||
|
@ -719,8 +777,9 @@
|
|||
|
||||
this.isShown = true
|
||||
|
||||
escape.call(this)
|
||||
backdrop.call(this, function () {
|
||||
this.escape()
|
||||
|
||||
this.backdrop(function () {
|
||||
var transition = $.support.transition && that.$element.hasClass('fade')
|
||||
|
||||
if (!that.$element.parent().length) {
|
||||
|
@ -734,7 +793,12 @@
|
|||
that.$element[0].offsetWidth // force reflow
|
||||
}
|
||||
|
||||
that.$element.addClass('in')
|
||||
that.$element
|
||||
.addClass('in')
|
||||
.attr('aria-hidden', false)
|
||||
.focus()
|
||||
|
||||
that.enforceFocus()
|
||||
|
||||
transition ?
|
||||
that.$element.one($.support.transition.end, function () { that.$element.trigger('shown') }) :
|
||||
|
@ -758,90 +822,98 @@
|
|||
|
||||
$('body').removeClass('modal-open')
|
||||
|
||||
escape.call(this)
|
||||
this.escape()
|
||||
|
||||
this.$element.removeClass('in')
|
||||
$(document).off('focusin.modal')
|
||||
|
||||
this.$element
|
||||
.removeClass('in')
|
||||
.attr('aria-hidden', true)
|
||||
|
||||
$.support.transition && this.$element.hasClass('fade') ?
|
||||
hideWithTransition.call(this) :
|
||||
hideModal.call(this)
|
||||
this.hideWithTransition() :
|
||||
this.hideModal()
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
/* MODAL PRIVATE METHODS
|
||||
* ===================== */
|
||||
|
||||
function hideWithTransition() {
|
||||
var that = this
|
||||
, timeout = setTimeout(function () {
|
||||
that.$element.off($.support.transition.end)
|
||||
hideModal.call(that)
|
||||
}, 500)
|
||||
|
||||
this.$element.one($.support.transition.end, function () {
|
||||
clearTimeout(timeout)
|
||||
hideModal.call(that)
|
||||
})
|
||||
}
|
||||
|
||||
function hideModal(that) {
|
||||
this.$element
|
||||
.hide()
|
||||
.trigger('hidden')
|
||||
|
||||
backdrop.call(this)
|
||||
}
|
||||
|
||||
function backdrop(callback) {
|
||||
var that = this
|
||||
, animate = this.$element.hasClass('fade') ? 'fade' : ''
|
||||
|
||||
if (this.isShown && this.options.backdrop) {
|
||||
var doAnimate = $.support.transition && animate
|
||||
|
||||
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
|
||||
.appendTo(document.body)
|
||||
|
||||
if (this.options.backdrop != 'static') {
|
||||
this.$backdrop.click($.proxy(this.hide, this))
|
||||
, enforceFocus: function () {
|
||||
var that = this
|
||||
$(document).on('focusin.modal', function (e) {
|
||||
if (that.$element[0] !== e.target && !that.$element.has(e.target).length) {
|
||||
that.$element.focus()
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
|
||||
, escape: function () {
|
||||
var that = this
|
||||
if (this.isShown && this.options.keyboard) {
|
||||
this.$element.on('keyup.dismiss.modal', function ( e ) {
|
||||
e.which == 27 && that.hide()
|
||||
})
|
||||
} else if (!this.isShown) {
|
||||
this.$element.off('keyup.dismiss.modal')
|
||||
}
|
||||
}
|
||||
|
||||
this.$backdrop.addClass('in')
|
||||
, hideWithTransition: function () {
|
||||
var that = this
|
||||
, timeout = setTimeout(function () {
|
||||
that.$element.off($.support.transition.end)
|
||||
that.hideModal()
|
||||
}, 500)
|
||||
|
||||
doAnimate ?
|
||||
this.$backdrop.one($.support.transition.end, callback) :
|
||||
callback()
|
||||
this.$element.one($.support.transition.end, function () {
|
||||
clearTimeout(timeout)
|
||||
that.hideModal()
|
||||
})
|
||||
}
|
||||
|
||||
} else if (!this.isShown && this.$backdrop) {
|
||||
this.$backdrop.removeClass('in')
|
||||
, hideModal: function (that) {
|
||||
this.$element
|
||||
.hide()
|
||||
.trigger('hidden')
|
||||
|
||||
$.support.transition && this.$element.hasClass('fade')?
|
||||
this.$backdrop.one($.support.transition.end, $.proxy(removeBackdrop, this)) :
|
||||
removeBackdrop.call(this)
|
||||
this.backdrop()
|
||||
}
|
||||
|
||||
} else if (callback) {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
, removeBackdrop: function () {
|
||||
this.$backdrop.remove()
|
||||
this.$backdrop = null
|
||||
}
|
||||
|
||||
function removeBackdrop() {
|
||||
this.$backdrop.remove()
|
||||
this.$backdrop = null
|
||||
}
|
||||
, backdrop: function (callback) {
|
||||
var that = this
|
||||
, animate = this.$element.hasClass('fade') ? 'fade' : ''
|
||||
|
||||
function escape() {
|
||||
var that = this
|
||||
if (this.isShown && this.options.keyboard) {
|
||||
$(document).on('keyup.dismiss.modal', function ( e ) {
|
||||
e.which == 27 && that.hide()
|
||||
})
|
||||
} else if (!this.isShown) {
|
||||
$(document).off('keyup.dismiss.modal')
|
||||
}
|
||||
if (this.isShown && this.options.backdrop) {
|
||||
var doAnimate = $.support.transition && animate
|
||||
|
||||
this.$backdrop = $('<div class="modal-backdrop ' + animate + '" />')
|
||||
.appendTo(document.body)
|
||||
|
||||
if (this.options.backdrop != 'static') {
|
||||
this.$backdrop.click($.proxy(this.hide, this))
|
||||
}
|
||||
|
||||
if (doAnimate) this.$backdrop[0].offsetWidth // force reflow
|
||||
|
||||
this.$backdrop.addClass('in')
|
||||
|
||||
doAnimate ?
|
||||
this.$backdrop.one($.support.transition.end, callback) :
|
||||
callback()
|
||||
|
||||
} else if (!this.isShown && this.$backdrop) {
|
||||
this.$backdrop.removeClass('in')
|
||||
|
||||
$.support.transition && this.$element.hasClass('fade')?
|
||||
this.$backdrop.one($.support.transition.end, $.proxy(this.removeBackdrop, this)) :
|
||||
this.removeBackdrop()
|
||||
|
||||
} else if (callback) {
|
||||
callback()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
@ -873,17 +945,23 @@
|
|||
|
||||
$(function () {
|
||||
$('body').on('click.modal.data-api', '[data-toggle="modal"]', function ( e ) {
|
||||
var $this = $(this), href
|
||||
, $target = $($this.attr('data-target') || (href = $this.attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|
||||
, option = $target.data('modal') ? 'toggle' : $.extend({}, $target.data(), $this.data())
|
||||
var $this = $(this)
|
||||
, href = $this.attr('href')
|
||||
, $target = $($this.attr('data-target') || (href && href.replace(/.*(?=#[^\s]+$)/, ''))) //strip for ie7
|
||||
, option = $target.data('modal') ? 'toggle' : $.extend({ remote: !/#/.test(href) && href }, $target.data(), $this.data())
|
||||
|
||||
e.preventDefault()
|
||||
$target.modal(option)
|
||||
|
||||
$target
|
||||
.modal(option)
|
||||
.one('hide', function () {
|
||||
$this.focus()
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
}(window.jQuery);/* ===========================================================
|
||||
* bootstrap-tooltip.js v2.0.4
|
||||
* bootstrap-tooltip.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#tooltips
|
||||
* Inspired by the original jQuery.tipsy by Jason Frame
|
||||
* ===========================================================
|
||||
|
@ -928,11 +1006,13 @@
|
|||
this.options = this.getOptions(options)
|
||||
this.enabled = true
|
||||
|
||||
if (this.options.trigger != 'manual') {
|
||||
eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
|
||||
if (this.options.trigger == 'click') {
|
||||
this.$element.on('click.' + this.type, this.options.selector, $.proxy(this.toggle, this))
|
||||
} else if (this.options.trigger != 'manual') {
|
||||
eventIn = this.options.trigger == 'hover' ? 'mouseenter' : 'focus'
|
||||
eventOut = this.options.trigger == 'hover' ? 'mouseleave' : 'blur'
|
||||
this.$element.on(eventIn, this.options.selector, $.proxy(this.enter, this))
|
||||
this.$element.on(eventOut, this.options.selector, $.proxy(this.leave, this))
|
||||
this.$element.on(eventIn + '.' + this.type, this.options.selector, $.proxy(this.enter, this))
|
||||
this.$element.on(eventOut + '.' + this.type, this.options.selector, $.proxy(this.leave, this))
|
||||
}
|
||||
|
||||
this.options.selector ?
|
||||
|
@ -1032,20 +1112,11 @@
|
|||
}
|
||||
}
|
||||
|
||||
, isHTML: function(text) {
|
||||
// html string detection logic adapted from jQuery
|
||||
return typeof text != 'string'
|
||||
|| ( text.charAt(0) === "<"
|
||||
&& text.charAt( text.length - 1 ) === ">"
|
||||
&& text.length >= 3
|
||||
) || /^(?:[^<]*<[\w\W]+>[^>]*$)/.exec(text)
|
||||
}
|
||||
|
||||
, setContent: function () {
|
||||
var $tip = this.tip()
|
||||
, title = this.getTitle()
|
||||
|
||||
$tip.find('.tooltip-inner')[this.isHTML(title) ? 'html' : 'text'](title)
|
||||
$tip.find('.tooltip-inner')[this.options.html ? 'html' : 'text'](title)
|
||||
$tip.removeClass('fade in top bottom left right')
|
||||
}
|
||||
|
||||
|
@ -1069,6 +1140,8 @@
|
|||
$.support.transition && this.$tip.hasClass('fade') ?
|
||||
removeWithAnimation() :
|
||||
$tip.remove()
|
||||
|
||||
return this
|
||||
}
|
||||
|
||||
, fixTitle: function () {
|
||||
|
@ -1128,6 +1201,10 @@
|
|||
this[this.tip().hasClass('in') ? 'hide' : 'show']()
|
||||
}
|
||||
|
||||
, destroy: function () {
|
||||
this.hide().$element.off('.' + this.type).removeData(this.type)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
@ -1154,11 +1231,12 @@
|
|||
, trigger: 'hover'
|
||||
, title: ''
|
||||
, delay: 0
|
||||
, html: true
|
||||
}
|
||||
|
||||
}(window.jQuery);
|
||||
/* ===========================================================
|
||||
* bootstrap-popover.js v2.0.4
|
||||
* bootstrap-popover.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#popovers
|
||||
* ===========================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
|
@ -1185,7 +1263,7 @@
|
|||
/* POPOVER PUBLIC CLASS DEFINITION
|
||||
* =============================== */
|
||||
|
||||
var Popover = function ( element, options ) {
|
||||
var Popover = function (element, options) {
|
||||
this.init('popover', element, options)
|
||||
}
|
||||
|
||||
|
@ -1202,8 +1280,8 @@
|
|||
, title = this.getTitle()
|
||||
, content = this.getContent()
|
||||
|
||||
$tip.find('.popover-title')[this.isHTML(title) ? 'html' : 'text'](title)
|
||||
$tip.find('.popover-content > *')[this.isHTML(content) ? 'html' : 'text'](content)
|
||||
$tip.find('.popover-title')[this.options.html ? 'html' : 'text'](title)
|
||||
$tip.find('.popover-content > *')[this.options.html ? 'html' : 'text'](content)
|
||||
|
||||
$tip.removeClass('fade top bottom left right in')
|
||||
}
|
||||
|
@ -1230,6 +1308,10 @@
|
|||
return this.$tip
|
||||
}
|
||||
|
||||
, destroy: function () {
|
||||
this.hide().$element.off('.' + this.type).removeData(this.type)
|
||||
}
|
||||
|
||||
})
|
||||
|
||||
|
||||
|
@ -1250,12 +1332,13 @@
|
|||
|
||||
$.fn.popover.defaults = $.extend({} , $.fn.tooltip.defaults, {
|
||||
placement: 'right'
|
||||
, trigger: 'click'
|
||||
, content: ''
|
||||
, template: '<div class="popover"><div class="arrow"></div><div class="popover-inner"><h3 class="popover-title"></h3><div class="popover-content"><p></p></div></div></div>'
|
||||
})
|
||||
|
||||
}(window.jQuery);/* =============================================================
|
||||
* bootstrap-scrollspy.js v2.0.4
|
||||
* bootstrap-scrollspy.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#scrollspy
|
||||
* =============================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
|
@ -1279,15 +1362,15 @@
|
|||
"use strict"; // jshint ;_;
|
||||
|
||||
|
||||
/* SCROLLSPY CLASS DEFINITION
|
||||
* ========================== */
|
||||
/* SCROLLSPY CLASS DEFINITION
|
||||
* ========================== */
|
||||
|
||||
function ScrollSpy( element, options) {
|
||||
function ScrollSpy(element, options) {
|
||||
var process = $.proxy(this.process, this)
|
||||
, $element = $(element).is('body') ? $(window) : $(element)
|
||||
, href
|
||||
this.options = $.extend({}, $.fn.scrollspy.defaults, options)
|
||||
this.$scrollElement = $element.on('scroll.scroll.data-api', process)
|
||||
this.$scrollElement = $element.on('scroll.scroll-spy.data-api', process)
|
||||
this.selector = (this.options.target
|
||||
|| ((href = $(element).attr('href')) && href.replace(/.*(?=#[^\s]+$)/, '')) //strip for ie7
|
||||
|| '') + ' .nav li > a'
|
||||
|
@ -1314,7 +1397,7 @@
|
|||
, href = $el.data('target') || $el.attr('href')
|
||||
, $href = /^#\w/.test(href) && $(href)
|
||||
return ( $href
|
||||
&& href.length
|
||||
&& $href.length
|
||||
&& [[ $href.position().top, href ]] ) || null
|
||||
})
|
||||
.sort(function (a, b) { return a[0] - b[0] })
|
||||
|
@ -1364,7 +1447,7 @@
|
|||
.parent('li')
|
||||
.addClass('active')
|
||||
|
||||
if (active.parent('.dropdown-menu')) {
|
||||
if (active.parent('.dropdown-menu').length) {
|
||||
active = active.closest('li.dropdown').addClass('active')
|
||||
}
|
||||
|
||||
|
@ -1377,7 +1460,7 @@
|
|||
/* SCROLLSPY PLUGIN DEFINITION
|
||||
* =========================== */
|
||||
|
||||
$.fn.scrollspy = function ( option ) {
|
||||
$.fn.scrollspy = function (option) {
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
, data = $this.data('scrollspy')
|
||||
|
@ -1397,7 +1480,7 @@
|
|||
/* SCROLLSPY DATA-API
|
||||
* ================== */
|
||||
|
||||
$(function () {
|
||||
$(window).on('load', function () {
|
||||
$('[data-spy="scroll"]').each(function () {
|
||||
var $spy = $(this)
|
||||
$spy.scrollspy($spy.data())
|
||||
|
@ -1405,7 +1488,7 @@
|
|||
})
|
||||
|
||||
}(window.jQuery);/* ========================================================
|
||||
* bootstrap-tab.js v2.0.4
|
||||
* bootstrap-tab.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#tabs
|
||||
* ========================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
|
@ -1432,7 +1515,7 @@
|
|||
/* TAB CLASS DEFINITION
|
||||
* ==================== */
|
||||
|
||||
var Tab = function ( element ) {
|
||||
var Tab = function (element) {
|
||||
this.element = $(element)
|
||||
}
|
||||
|
||||
|
@ -1539,7 +1622,7 @@
|
|||
})
|
||||
|
||||
}(window.jQuery);/* =============================================================
|
||||
* bootstrap-typeahead.js v2.0.4
|
||||
* bootstrap-typeahead.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#typeahead
|
||||
* =============================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
|
@ -1617,17 +1700,23 @@
|
|||
}
|
||||
|
||||
, lookup: function (event) {
|
||||
var that = this
|
||||
, items
|
||||
, q
|
||||
var items
|
||||
|
||||
this.query = this.$element.val()
|
||||
|
||||
if (!this.query) {
|
||||
if (!this.query || this.query.length < this.options.minLength) {
|
||||
return this.shown ? this.hide() : this
|
||||
}
|
||||
|
||||
items = $.grep(this.source, function (item) {
|
||||
items = $.isFunction(this.source) ? this.source(this.query, $.proxy(this.process, this)) : this.source
|
||||
|
||||
return items ? this.process(items) : this
|
||||
}
|
||||
|
||||
, process: function (items) {
|
||||
var that = this
|
||||
|
||||
items = $.grep(items, function (item) {
|
||||
return that.matcher(item)
|
||||
})
|
||||
|
||||
|
@ -1708,8 +1797,8 @@
|
|||
.on('keypress', $.proxy(this.keypress, this))
|
||||
.on('keyup', $.proxy(this.keyup, this))
|
||||
|
||||
if ($.browser.webkit || $.browser.msie) {
|
||||
this.$element.on('keydown', $.proxy(this.keypress, this))
|
||||
if ($.browser.chrome || $.browser.webkit || $.browser.msie) {
|
||||
this.$element.on('keydown', $.proxy(this.keydown, this))
|
||||
}
|
||||
|
||||
this.$menu
|
||||
|
@ -1717,6 +1806,40 @@
|
|||
.on('mouseenter', 'li', $.proxy(this.mouseenter, this))
|
||||
}
|
||||
|
||||
, move: function (e) {
|
||||
if (!this.shown) return
|
||||
|
||||
switch(e.keyCode) {
|
||||
case 9: // tab
|
||||
case 13: // enter
|
||||
case 27: // escape
|
||||
e.preventDefault()
|
||||
break
|
||||
|
||||
case 38: // up arrow
|
||||
e.preventDefault()
|
||||
this.prev()
|
||||
break
|
||||
|
||||
case 40: // down arrow
|
||||
e.preventDefault()
|
||||
this.next()
|
||||
break
|
||||
}
|
||||
|
||||
e.stopPropagation()
|
||||
}
|
||||
|
||||
, keydown: function (e) {
|
||||
this.suppressKeyPressRepeat = !~$.inArray(e.keyCode, [40,38,9,13,27])
|
||||
this.move(e)
|
||||
}
|
||||
|
||||
, keypress: function (e) {
|
||||
if (this.suppressKeyPressRepeat) return
|
||||
this.move(e)
|
||||
}
|
||||
|
||||
, keyup: function (e) {
|
||||
switch(e.keyCode) {
|
||||
case 40: // down arrow
|
||||
|
@ -1742,32 +1865,6 @@
|
|||
e.preventDefault()
|
||||
}
|
||||
|
||||
, keypress: function (e) {
|
||||
if (!this.shown) return
|
||||
|
||||
switch(e.keyCode) {
|
||||
case 9: // tab
|
||||
case 13: // enter
|
||||
case 27: // escape
|
||||
e.preventDefault()
|
||||
break
|
||||
|
||||
case 38: // up arrow
|
||||
if (e.type != 'keydown') break
|
||||
e.preventDefault()
|
||||
this.prev()
|
||||
break
|
||||
|
||||
case 40: // down arrow
|
||||
if (e.type != 'keydown') break
|
||||
e.preventDefault()
|
||||
this.next()
|
||||
break
|
||||
}
|
||||
|
||||
e.stopPropagation()
|
||||
}
|
||||
|
||||
, blur: function (e) {
|
||||
var that = this
|
||||
setTimeout(function () { that.hide() }, 150)
|
||||
|
@ -1805,12 +1902,13 @@
|
|||
, items: 8
|
||||
, menu: '<ul class="typeahead dropdown-menu"></ul>'
|
||||
, item: '<li><a href="#"></a></li>'
|
||||
, minLength: 1
|
||||
}
|
||||
|
||||
$.fn.typeahead.Constructor = Typeahead
|
||||
|
||||
|
||||
/* TYPEAHEAD DATA-API
|
||||
/* TYPEAHEAD DATA-API
|
||||
* ================== */
|
||||
|
||||
$(function () {
|
||||
|
@ -1822,4 +1920,108 @@
|
|||
})
|
||||
})
|
||||
|
||||
}(window.jQuery);
|
||||
/* ==========================================================
|
||||
* bootstrap-affix.js v2.1.1
|
||||
* http://twitter.github.com/bootstrap/javascript.html#affix
|
||||
* ==========================================================
|
||||
* Copyright 2012 Twitter, Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
* ========================================================== */
|
||||
|
||||
|
||||
!function ($) {
|
||||
|
||||
"use strict"; // jshint ;_;
|
||||
|
||||
|
||||
/* AFFIX CLASS DEFINITION
|
||||
* ====================== */
|
||||
|
||||
var Affix = function (element, options) {
|
||||
this.options = $.extend({}, $.fn.affix.defaults, options)
|
||||
this.$window = $(window).on('scroll.affix.data-api', $.proxy(this.checkPosition, this))
|
||||
this.$element = $(element)
|
||||
this.checkPosition()
|
||||
}
|
||||
|
||||
Affix.prototype.checkPosition = function () {
|
||||
if (!this.$element.is(':visible')) return
|
||||
|
||||
var scrollHeight = $(document).height()
|
||||
, scrollTop = this.$window.scrollTop()
|
||||
, position = this.$element.offset()
|
||||
, offset = this.options.offset
|
||||
, offsetBottom = offset.bottom
|
||||
, offsetTop = offset.top
|
||||
, reset = 'affix affix-top affix-bottom'
|
||||
, affix
|
||||
|
||||
if (typeof offset != 'object') offsetBottom = offsetTop = offset
|
||||
if (typeof offsetTop == 'function') offsetTop = offset.top()
|
||||
if (typeof offsetBottom == 'function') offsetBottom = offset.bottom()
|
||||
|
||||
affix = this.unpin != null && (scrollTop + this.unpin <= position.top) ?
|
||||
false : offsetBottom != null && (position.top + this.$element.height() >= scrollHeight - offsetBottom) ?
|
||||
'bottom' : offsetTop != null && scrollTop <= offsetTop ?
|
||||
'top' : false
|
||||
|
||||
if (this.affixed === affix) return
|
||||
|
||||
this.affixed = affix
|
||||
this.unpin = affix == 'bottom' ? position.top - scrollTop : null
|
||||
|
||||
this.$element.removeClass(reset).addClass('affix' + (affix ? '-' + affix : ''))
|
||||
}
|
||||
|
||||
|
||||
/* AFFIX PLUGIN DEFINITION
|
||||
* ======================= */
|
||||
|
||||
$.fn.affix = function (option) {
|
||||
return this.each(function () {
|
||||
var $this = $(this)
|
||||
, data = $this.data('affix')
|
||||
, options = typeof option == 'object' && option
|
||||
if (!data) $this.data('affix', (data = new Affix(this, options)))
|
||||
if (typeof option == 'string') data[option]()
|
||||
})
|
||||
}
|
||||
|
||||
$.fn.affix.Constructor = Affix
|
||||
|
||||
$.fn.affix.defaults = {
|
||||
offset: 0
|
||||
}
|
||||
|
||||
|
||||
/* AFFIX DATA-API
|
||||
* ============== */
|
||||
|
||||
$(window).on('load', function () {
|
||||
$('[data-spy="affix"]').each(function () {
|
||||
var $spy = $(this)
|
||||
, data = $spy.data()
|
||||
|
||||
data.offset = data.offset || {}
|
||||
|
||||
data.offsetBottom && (data.offset.bottom = data.offsetBottom)
|
||||
data.offsetTop && (data.offset.top = data.offsetTop)
|
||||
|
||||
$spy.affix(data)
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
}(window.jQuery);
|
|
@ -1,7 +1,18 @@
|
|||
<?php
|
||||
// this is your path to minetest:
|
||||
$GLOBALS['path'] = 'C:/minetest';
|
||||
/**
|
||||
* GameWiki for Minetest
|
||||
*
|
||||
* Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
|
||||
*
|
||||
* Source Code: https://github.com/cornernote/minetest-cornernote_game
|
||||
* License: GPLv3
|
||||
*/
|
||||
|
||||
// this is the title of your GameWiki
|
||||
$GLOBALS['name'] = 'Minetest CoRNeRNoTe\'S GaMe';
|
||||
|
||||
// the main link on the menu
|
||||
$GLOBALS['brand_url'] = 'https://github.com/cornernote/minetest-cornernote_game';
|
||||
|
||||
// this is the name of your SQLite3 database file
|
||||
$GLOBALS['db'] = new SQLite3('data/wiki.db');
|
||||
?>
|
||||
$db = new SQLite3('data/wiki.db');
|
||||
|
|
|
@ -1,29 +1,40 @@
|
|||
<?php require('globals.php'); ?>
|
||||
<?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');
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>MTGW</title>
|
||||
<?php echo head_tags(); ?>
|
||||
<title>View Craft :: <?php echo $GLOBALS['name']; ?></title>
|
||||
<?php include('include/head_tags.php'); ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php echo menu(); ?>
|
||||
<?php include('include/menu.php'); ?>
|
||||
<div class="container">
|
||||
|
||||
<?php
|
||||
$id = SQLite3::escapeString($_GET['id']);
|
||||
$q = $GLOBALS['db']->query('SELECT id, output, mod, quantity, type, data FROM "craft" WHERE id = "' . $id . '"');
|
||||
$q = $db->query('SELECT id, output, mod, quantity, type, data FROM "craft" WHERE id = "' . $id . '"');
|
||||
$row = $q->fetchArray();
|
||||
$data = json_decode($row['data']);
|
||||
|
||||
echo '<h1>Craft <small>' . ($row['type'] ? $row['type'] : 'unknown') . '</small></h1>';
|
||||
|
||||
echo '<h2>Output</h2>';
|
||||
echo item($row['output'], $row['quantity']);
|
||||
echo gamewiki::item($row['output'], $row['quantity']);
|
||||
|
||||
if (isset($data->options) && isset($data->options->recipe)) {
|
||||
echo '<h2>Recipe</h2>';
|
||||
echo craft_recipe($data->options->recipe, $row['type']);
|
||||
echo gamewiki::craft_recipe($data->options->recipe, $row['type']);
|
||||
echo '<h2>Pasteable</h2>';
|
||||
debug(gamewiki::craft_recipe_paste($row['output'] . ' ' . $row['quantity'], $data->options->recipe, $row['type']));
|
||||
}
|
||||
|
||||
echo '<h2>Data</h2>';
|
||||
|
@ -31,10 +42,9 @@
|
|||
print '<pre>';
|
||||
print_r($data);
|
||||
print '</pre>';
|
||||
|
||||
|
||||
?>
|
||||
|
||||
</div>
|
||||
<div id="footer"></div>
|
||||
</body>
|
||||
</html>
|
125
wiki/crafts.php
|
@ -1,44 +1,115 @@
|
|||
<?php require('globals.php'); ?>
|
||||
<?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');
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>MTGW</title>
|
||||
<?php echo head_tags(); ?>
|
||||
<title>List Crafts :: <?php echo $GLOBALS['name']; ?></title>
|
||||
<?php include('include/head_tags.php'); ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php echo menu(); ?>
|
||||
<?php include('include/menu.php'); ?>
|
||||
<div class="container">
|
||||
<h1>Crafts</h1>
|
||||
|
||||
<?php
|
||||
$mods = array();
|
||||
$q = $GLOBALS['db']->query('SELECT mod FROM "craft" GROUP BY mod ORDER BY mod');
|
||||
while ($row = $q->fetchArray()) {
|
||||
$mods[] = $row['mod'];
|
||||
$mods = gamewiki::get_mods();
|
||||
$filters = $filter_sql = $filter_join = '';
|
||||
if (isset($_GET['mod'])) {
|
||||
$filters .= '[mod:' . $_GET['mod'] . ']';
|
||||
$filter_sql .= 'AND mod="' . SQLite3::escapeString($_GET['mod']) . '" ';
|
||||
}
|
||||
?>
|
||||
|
||||
<h1>Crafts
|
||||
<small><?php echo $filters; ?></small>
|
||||
</h1>
|
||||
|
||||
<?php
|
||||
$mods = gamewiki::get_mods();
|
||||
foreach ($mods as $mod) {
|
||||
$q = $GLOBALS['db']->query('SELECT id, mod, type, output, quantity FROM "craft" WHERE mod="' . $mod . '" ORDER BY output');
|
||||
echo '<h2>mod:' . ($mod ? $mod : 'no-mod') . '</h2>';
|
||||
echo '<table class="table">';
|
||||
echo '<tr>';
|
||||
echo '<th width="100">Type</th>';
|
||||
echo '<th width="100">Mod</th>';
|
||||
echo '<th>Output</th>';
|
||||
echo '<th width="100"> </th>';
|
||||
echo '</tr>';
|
||||
while ($row = $q->fetchArray()) {
|
||||
echo '<tr>';
|
||||
echo '<td>' . $row['type'] . '</td>';
|
||||
echo '<td>' . $row['mod'] . '</td>';
|
||||
echo '<td>' . ($row['output'] ? item($row['output'], $row['quantity']) : 'no output') . '</td>';
|
||||
echo '<td><a href="craft.php?id=' . $row['id'] . '" class="btn">view craft</a></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
$output_mod = false;
|
||||
ob_start();
|
||||
?>
|
||||
<div class="itemgroup">
|
||||
<h2><?php echo $mod ? 'mod:' . $mod : 'unknown'; ?></h2>
|
||||
|
||||
<div class="row">
|
||||
<?php
|
||||
foreach (array(array('crafting', 'shapeless'), array('cooking'), array('fuel')) as $type) {
|
||||
$pasteable = array();
|
||||
|
||||
// format the sql as "crafting" instead of crafting
|
||||
$_type = array();
|
||||
foreach ($type as $_types) {
|
||||
$_type[] = '"' . $_types . '"';
|
||||
}
|
||||
$sql = '
|
||||
SELECT id, mod, type, data, output, quantity
|
||||
FROM "craft" ' . $filter_join . '
|
||||
WHERE "type" IN (' . implode(', ', $_type) . ') AND mod="' . $mod . '" ' . $filter_sql . '
|
||||
ORDER BY output
|
||||
';
|
||||
$q = $db->query($sql);
|
||||
$rows = array();
|
||||
while ($row = $q->fetchArray()) {
|
||||
$output_mod = true;
|
||||
$data = json_decode($row['data']);
|
||||
$rows[] = $row;
|
||||
if (isset($data->options->recipe)) {
|
||||
$pasteable[] = gamewiki::craft_recipe_paste($row['output'] . ' ' . $row['quantity'], $data->options->recipe, $row['type']);
|
||||
}
|
||||
}
|
||||
?>
|
||||
<div class="span4">
|
||||
<h3><?php echo 'types:' . implode(',', $type); ?></h3>
|
||||
<?php
|
||||
echo '<p style="text-align:right;"><a href="javascript:return false;" onclick="$(\'#pasteable_' . $type . '_' . $mod . '\').toggle();$(\'#table_' . $type . '_' . $mod . '\').toggle();">toggle pasteable</a></p>';
|
||||
echo '<pre id="pasteable_' . $type . '_' . $mod . '" style="display:none;">' . implode("\n\n", $pasteable) . '</pre>';
|
||||
echo '<table class="table" id="table_' . $type . '_' . $mod . '">';
|
||||
echo '<tr>';
|
||||
echo '<th>Recipe</th>';
|
||||
echo '<th>Output</th>';
|
||||
echo '<th style="width:100px;"> </th>';
|
||||
echo '</tr>';
|
||||
foreach ($rows as $row) {
|
||||
$data = json_decode($row['data']);
|
||||
echo '<tr>';
|
||||
echo '<td>' . (isset($data->options->recipe) ? gamewiki::craft_recipe($data->options->recipe, $row['type'], true) : $row['type']) . '</td>';
|
||||
if ($type == 'fuel') {
|
||||
echo '<td>' . gamewiki::item('default:furnace_active', null, true) . '</td>';
|
||||
}
|
||||
else {
|
||||
echo '<td>' . ($row['output'] ? gamewiki::item($row['output'], $row['quantity'], true) : 'no output') . '</td>';
|
||||
}
|
||||
echo '<td><a href="craft.php?id=' . $row['id'] . '" class="btn">view craft</a></td>';
|
||||
echo '</tr>';
|
||||
}
|
||||
echo '</table>';
|
||||
?>
|
||||
</div>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<?php
|
||||
$contents = ob_get_clean();
|
||||
if ($output_mod)
|
||||
echo $contents;
|
||||
}
|
||||
?>
|
||||
|
||||
</div>
|
||||
<div id="footer"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,450 @@
|
|||
<?php
|
||||
/**
|
||||
* GameWiki for Minetest
|
||||
*
|
||||
* Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
|
||||
*
|
||||
* Source Code: https://github.com/cornernote/minetest-gamewiki
|
||||
* License: GPLv3
|
||||
*/
|
||||
class gamewiki
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
static $paste_items = array();
|
||||
|
||||
/**
|
||||
* Return an image from an array of image files
|
||||
*
|
||||
* @param $images
|
||||
* @param array $options
|
||||
* @return string
|
||||
*/
|
||||
static function images($images, $options = array())
|
||||
{
|
||||
$_images = array();
|
||||
foreach ($images as $image) {
|
||||
$_images[md5(serialize($image))] = $image;
|
||||
}
|
||||
$output = array();
|
||||
foreach ($_images as $image) {
|
||||
if (is_scalar($image)) {
|
||||
$output[] = self::image($image, $options);
|
||||
}
|
||||
else {
|
||||
$output[] = self::image($image->name, $options);
|
||||
}
|
||||
}
|
||||
return implode(' ', $output);
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an image from a image file
|
||||
*
|
||||
* @param $image
|
||||
* @param array $options
|
||||
* @return bool|string
|
||||
*/
|
||||
static function image($image, $options = array())
|
||||
{
|
||||
if (!$image) {
|
||||
return $image;
|
||||
}
|
||||
if (!is_scalar($image)) {
|
||||
//debug($image);
|
||||
return '';
|
||||
}
|
||||
if (substr($image, 0, 14) == '[inventorycube') {
|
||||
$output = self::item_image(array('image' => $image));
|
||||
if ($output)
|
||||
return $output;
|
||||
}
|
||||
if (strpos($image, '^') !== false) {
|
||||
$images = explode('^', $image);
|
||||
$image = $images[1];
|
||||
}
|
||||
if (strpos($image, '&') !== false) {
|
||||
$images = explode('&', $image);
|
||||
$image = $images[1];
|
||||
}
|
||||
if (strpos($image, '{') !== false) {
|
||||
$images = explode('{', $image);
|
||||
$image = $images[0];
|
||||
}
|
||||
//if (!file_exists('textures/' . $image) && !empty($options['download'])) {
|
||||
// $it = new RecursiveDirectoryIterator($GLOBALS['path']);
|
||||
// foreach (new RecursiveIteratorIterator($it) as $file) {
|
||||
// if ($image == substr($file, strlen($image) * -1)) {
|
||||
// copy($file, 'textures/' . $image);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
if ($image == '[inventorycube') {
|
||||
return '';
|
||||
}
|
||||
if (!file_exists('textures/' . $image)) {
|
||||
debug('cant find: ' . $image);
|
||||
return '';
|
||||
}
|
||||
$width = $height = '';
|
||||
if (empty($options['fullsize'])) {
|
||||
$width = 'width="' . (isset($options['width']) ? $options['width'] : '32px') . '" ';
|
||||
$height = 'height="' . (isset($options['height']) ? $options['height'] : '32px') . '" ';
|
||||
}
|
||||
$class = isset($options['class']) ? 'class="' . $options['class'] . ' "' : '';
|
||||
return '<img src="textures/' . $image . '" ' . $width . $height . $class . '/>';
|
||||
}
|
||||
|
||||
/**
|
||||
* Return an image from the inventorycube or fallback to use tile image
|
||||
*
|
||||
* @param $item
|
||||
* @param array $options
|
||||
* @return bool|string
|
||||
*/
|
||||
static function item_image($item, $options = array())
|
||||
{
|
||||
$file = false;
|
||||
if (!$file && !empty($item['name'])) {
|
||||
$file = 'itemcubes/' . str_replace(':', '-', $item['name']) . '.png';
|
||||
if (!file_exists($file))
|
||||
$file = false;
|
||||
}
|
||||
if (!$file && !empty($item['image'])) {
|
||||
if (substr($item['image'], 0, 14) == '[inventorycube') {
|
||||
$file = 'itemcubes/' . $item['image'] . '.png';
|
||||
if (!file_exists($file))
|
||||
$file = false;
|
||||
}
|
||||
}
|
||||
if (!$file && !empty($item['image'])) {
|
||||
$file = 'textures/' . $item['image'];
|
||||
if (!file_exists($file))
|
||||
$file = false;
|
||||
}
|
||||
if (!$file && !empty($item['data'])) {
|
||||
$data = json_decode($item['data']);
|
||||
if (!empty($data->options->tiles)) {
|
||||
$file = 'textures/' . $data->options->tiles[0];
|
||||
if (!file_exists($file))
|
||||
$file = false;
|
||||
}
|
||||
if (!empty($data->options->tile_images)) {
|
||||
$file = 'textures/' . $data->options->tile_images[0];
|
||||
if (!file_exists($file))
|
||||
$file = false;
|
||||
}
|
||||
}
|
||||
if ($file) {
|
||||
$width = $height = '';
|
||||
if (empty($options['fullsize'])) {
|
||||
$width = 'width="' . (!empty($options['width']) ? $options['width'] : '32px') . '" ';
|
||||
$height = 'height="' . (!empty($options['height']) ? $options['height'] : '32px') . '" ';
|
||||
}
|
||||
$class = !empty($options['class']) ? 'class="' . $options['class'] . ' "' : '';
|
||||
return '<img src="' . $file . '" ' . $width . $height . $class . '/>';
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the HTML for an Item
|
||||
*
|
||||
* @param $name
|
||||
* @param null $quantity
|
||||
* @param bool $small
|
||||
* @return string
|
||||
*/
|
||||
static function item($name, $quantity = null, $small = false)
|
||||
{
|
||||
global $db;
|
||||
$output = '';
|
||||
$name = SQLite3::escapeString(self::item_name($name));
|
||||
if (!$name || in_array($name, array('air', 'default:air'))) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
// check for an alias
|
||||
$alias = $db->querySingle('SELECT itemname FROM alias WHERE name="' . $name . '"');
|
||||
if ($alias) {
|
||||
$name = $alias;
|
||||
}
|
||||
|
||||
// load the item
|
||||
$q = $db->query('SELECT id, data, type, name, image, description FROM item WHERE name="' . $name . '"');
|
||||
if ($item = $q->fetchArray()) {
|
||||
$attr = 'class="item"';
|
||||
if ($small) {
|
||||
$attr = 'rel="tooltip" title="' . $item['description'] . ' [' . $item['type'] . '][' . $item['name'] . ']' . ($quantity ? ' x' . $quantity : '') . '"';
|
||||
}
|
||||
$output .= '<a href="item.php?name=' . $item['name'] . '" ' . $attr . '>';
|
||||
$output .= '<span class="image">' . self::item_image($item) . '</span>';
|
||||
if (!$small) {
|
||||
$output .= '<span class="description">' . $item['description'] . ' </span>';
|
||||
$output .= '<span class="name">[' . $item['type'] . '][' . $item['name'] . ']' . ($quantity ? ' x' . $quantity : '') . '</span>';
|
||||
}
|
||||
$output .= '</a>';
|
||||
}
|
||||
|
||||
// no item found
|
||||
elseif (substr($name, 0, 6) == 'group:') {
|
||||
$group = substr($name, 6);
|
||||
$name = str_replace(',', ' ', $group);
|
||||
if ($small) {
|
||||
$output .= '<p style="font-size:75%;text-align:center;line-height:1.1em;margin:0;padding:0;"><a href="items.php?group=' . $group . '" rel="tooltip" title="' . $name . '">view item group</a></p>';
|
||||
}
|
||||
else {
|
||||
$output .= '<p><a href="items.php?group=' . $group . '">' . $name . '</a></p>';
|
||||
}
|
||||
}
|
||||
|
||||
// no item found
|
||||
else {
|
||||
$output .= $name . ' (missing item)';
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a unique list of items when given an item list such as a recipe input
|
||||
*
|
||||
* @param $items
|
||||
* @return array
|
||||
*/
|
||||
static function item_names($items)
|
||||
{
|
||||
$_items = array();
|
||||
if (is_array($items)) {
|
||||
foreach ($items as $name) {
|
||||
if (is_array($name)) {
|
||||
$_items = array_merge($_items, self::item_names($name));
|
||||
}
|
||||
else {
|
||||
$_items[] = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$_items[] = self::item_name($items);
|
||||
}
|
||||
foreach ($_items as $k => $v) if (!$v) unset($_items[$k]);
|
||||
return array_unique($_items);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an item name with annoying words and characters removed
|
||||
*
|
||||
* @param $name
|
||||
* @return mixed
|
||||
*/
|
||||
static function item_name($name)
|
||||
{
|
||||
$name = str_ireplace(array('tool ', 'node ', 'craft ', 'toolitem ', 'nodeitem ', 'craftitem ', '"'), '', $name);
|
||||
$name = explode(' ', $name);
|
||||
$name = $name[0];
|
||||
return $name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns an item quantity
|
||||
*
|
||||
* @param $name
|
||||
* @return mixed
|
||||
*/
|
||||
static function item_quantity($name)
|
||||
{
|
||||
$name = str_ireplace(array('tool ', 'node ', 'craft ', 'toolitem ', 'nodeitem ', 'craftitem ', '"'), '', $name);
|
||||
$name = explode(' ', $name);
|
||||
return isset($name[1]) ? $name[1] : 1;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a HTML table containing the recipe for a craft
|
||||
*
|
||||
* @param $recipe
|
||||
* @param $type
|
||||
* @param bool $small
|
||||
* @return string
|
||||
*/
|
||||
static function craft_recipe($recipe, $type, $small = false)
|
||||
{
|
||||
$class = $small ? 'crafting-small' : 'crafting';
|
||||
$output = '<table class="' . $class . '">';
|
||||
if (in_array($type, array('fuel', 'cooking'))) {
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . ($type == 'cooking' ? self::item($recipe, null, $small) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . ($type == 'fuel' ? self::item('default:furnace', null, $small) : self::item('default:furnace_active', null, $small)) . '</td>';
|
||||
$output .= '</tr>';
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . ($type == 'fuel' ? self::item($recipe, null, $small) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
}
|
||||
else {
|
||||
if (is_array($recipe)) {
|
||||
if (is_array($recipe[0])) {
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . (isset($recipe[0][0]) ? self::item($recipe[0][0], null, $small) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[0][1]) ? self::item($recipe[0][1], null, $small) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[0][2]) ? self::item($recipe[0][2], null, $small) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . (isset($recipe[1][0]) ? self::item($recipe[1][0], null, $small) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[1][1]) ? self::item($recipe[1][1], null, $small) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[1][2]) ? self::item($recipe[1][2], null, $small) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . (isset($recipe[2][0]) ? self::item($recipe[2][0], null, $small) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[2][1]) ? self::item($recipe[2][1], null, $small) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[2][2]) ? self::item($recipe[2][2], null, $small) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
}
|
||||
else {
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . (isset($recipe[0]) ? self::item($recipe[0], null, $small) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[1]) ? self::item($recipe[1], null, $small) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[2]) ? self::item($recipe[2], null, $small) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . (isset($recipe[3]) ? self::item($recipe[3], null, $small) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[4]) ? self::item($recipe[4], null, $small) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[5]) ? self::item($recipe[5], null, $small) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . (isset($recipe[6]) ? self::item($recipe[6], null, $small) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[7]) ? self::item($recipe[7], null, $small) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[8]) ? self::item($recipe[8], null, $small) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$recipe = explode(' ', $recipe);
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . (isset($recipe[0]) ? self::item($recipe[0], null, $small) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[1]) ? self::item($recipe[1], null, $small) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[2]) ? self::item($recipe[2], null, $small) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . (isset($recipe[3]) ? self::item($recipe[3], null, $small) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[4]) ? self::item($recipe[4], null, $small) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[5]) ? self::item($recipe[5], null, $small) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . (isset($recipe[6]) ? self::item($recipe[6], null, $small) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[7]) ? self::item($recipe[7], null, $small) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[8]) ? self::item($recipe[8], null, $small) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
}
|
||||
}
|
||||
$output .= '</table>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a text table containing the recipe for a craft
|
||||
*
|
||||
* @param $output
|
||||
* @param $recipe
|
||||
* @param $type
|
||||
* @return string
|
||||
*/
|
||||
static function craft_recipe_paste($output, $recipe, $type)
|
||||
{
|
||||
$output = explode(' ', $output);
|
||||
$quantity = isset($output[1]) ? $output[1] : '1';
|
||||
$quantity = ($quantity <= 1) ? '' : ' x' . $quantity;
|
||||
$output = $output[0] . $quantity;
|
||||
$return = '';
|
||||
self::$paste_items = array('empty');
|
||||
if (in_array($type, array('fuel', 'cooking'))) {
|
||||
$return .= ($type == 'cooking' ? $recipe . ' -> cooking -> ' . $output : '');
|
||||
$return .= ($type == 'fuel' ? $recipe . ' -> fuel' : '');
|
||||
}
|
||||
else {
|
||||
if (is_array($recipe)) {
|
||||
if (is_array($recipe[0])) {
|
||||
$return .= (!empty($recipe[0][0]) ? self::item_paste($recipe[0][0]) : '-');
|
||||
$return .= (!empty($recipe[0][1]) ? self::item_paste($recipe[0][1]) : '-');
|
||||
$return .= (!empty($recipe[0][2]) ? self::item_paste($recipe[0][2]) : '-');
|
||||
$return .= "\n";
|
||||
$return .= (!empty($recipe[1][0]) ? self::item_paste($recipe[1][0]) : '-');
|
||||
$return .= (!empty($recipe[1][1]) ? self::item_paste($recipe[1][1]) : '-');
|
||||
$return .= (!empty($recipe[1][2]) ? self::item_paste($recipe[1][2]) : '-');
|
||||
$return .= "\n";
|
||||
$return .= (!empty($recipe[2][0]) ? self::item_paste($recipe[2][0]) : '-');
|
||||
$return .= (!empty($recipe[2][1]) ? self::item_paste($recipe[2][1]) : '-');
|
||||
$return .= (!empty($recipe[2][2]) ? self::item_paste($recipe[2][2]) : '-');
|
||||
$return .= "\n";
|
||||
}
|
||||
else {
|
||||
$return .= (!empty($recipe[0]) ? self::item_paste($recipe[0]) : '-');
|
||||
$return .= (!empty($recipe[1]) ? self::item_paste($recipe[1]) : '-');
|
||||
$return .= (!empty($recipe[2]) ? self::item_paste($recipe[2]) : '-');
|
||||
$return .= "\n";
|
||||
$return .= (!empty($recipe[3]) ? self::item_paste($recipe[3]) : '-');
|
||||
$return .= (!empty($recipe[4]) ? self::item_paste($recipe[4]) : '-');
|
||||
$return .= (!empty($recipe[5]) ? self::item_paste($recipe[5]) : '-');
|
||||
$return .= "\n";
|
||||
$return .= (!empty($recipe[6]) ? self::item_paste($recipe[6]) : '-');
|
||||
$return .= (!empty($recipe[7]) ? self::item_paste($recipe[7]) : '-');
|
||||
$return .= (!empty($recipe[8]) ? self::item_paste($recipe[8]) : '-');
|
||||
$return .= "\n";
|
||||
}
|
||||
}
|
||||
else {
|
||||
$recipe = explode(' ', $recipe);
|
||||
$return .= (!empty($recipe[0]) ? self::item_paste($recipe[0]) : '-');
|
||||
$return .= (!empty($recipe[1]) ? self::item_paste($recipe[1]) : '-');
|
||||
$return .= (!empty($recipe[2]) ? self::item_paste($recipe[2]) : '-');
|
||||
$return .= "\n";
|
||||
$return .= (!empty($recipe[3]) ? self::item_paste($recipe[3]) : '-');
|
||||
$return .= (!empty($recipe[4]) ? self::item_paste($recipe[4]) : '-');
|
||||
$return .= (!empty($recipe[5]) ? self::item_paste($recipe[5]) : '-');
|
||||
$return .= "\n";
|
||||
$return .= (!empty($recipe[6]) ? self::item_paste($recipe[6]) : '-');
|
||||
$return .= (!empty($recipe[7]) ? self::item_paste($recipe[7]) : '-');
|
||||
$return .= (!empty($recipe[8]) ? self::item_paste($recipe[8]) : '-');
|
||||
$return .= "\n";
|
||||
}
|
||||
$return = explode("\n", $return);
|
||||
$return[0] .= ' -> ' . $output;
|
||||
unset(self::$paste_items[0]);
|
||||
foreach (self::$paste_items as $k => $paste_item) {
|
||||
if (!isset($return[$k + 1])) {
|
||||
$return[$k] = ' ';
|
||||
}
|
||||
$return[$k] .= ' ' . $k . ' = ' . $paste_item;
|
||||
}
|
||||
$return = implode("\n", $return);
|
||||
}
|
||||
return trim($return);
|
||||
}
|
||||
|
||||
static function item_paste($item)
|
||||
{
|
||||
if (!in_array($item, self::$paste_items)) {
|
||||
self::$paste_items[] = $item;
|
||||
}
|
||||
return array_search($item, self::$paste_items);
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
static function get_mods()
|
||||
{
|
||||
global $db;
|
||||
$mods = array();
|
||||
$q = $db->query('SELECT mod FROM "item" WHERE mod!="unknown" AND mod!="__builtin" AND mod!="" GROUP BY mod ORDER BY mod');
|
||||
while ($row = $q->fetchArray()) {
|
||||
$mods[] = $row['mod'];
|
||||
}
|
||||
return $mods;
|
||||
}
|
||||
|
||||
}
|
388
wiki/globals.php
|
@ -1,393 +1,9 @@
|
|||
<?php
|
||||
require('config.php');
|
||||
|
||||
require('gamewiki.class.php');
|
||||
function debug($debug)
|
||||
{
|
||||
echo '<pre>';
|
||||
print_r($debug);
|
||||
echo '</pre>';
|
||||
}
|
||||
|
||||
function images($images, $options = array())
|
||||
{
|
||||
$_images = array();
|
||||
foreach ($images as $image) {
|
||||
$_images[md5(serialize($image))] = $image;
|
||||
}
|
||||
$output = array();
|
||||
foreach ($_images as $image) {
|
||||
if (is_scalar($image)) {
|
||||
$output[] = image($image, $options);
|
||||
}
|
||||
else {
|
||||
$output[] = image($image->name, $options);
|
||||
}
|
||||
}
|
||||
return implode(' ', $output);
|
||||
}
|
||||
|
||||
function image($image, $options = array())
|
||||
{
|
||||
if (!$image) {
|
||||
return $image;
|
||||
}
|
||||
if (!is_scalar($image)) {
|
||||
//debug($image);
|
||||
return '';
|
||||
}
|
||||
if (substr($image, 0, 14) == '[inventorycube') {
|
||||
return item_image(array('image' => $image));
|
||||
}
|
||||
if (strpos($image, '^') !== false) {
|
||||
$images = explode('^', $image);
|
||||
$image = $images[1];
|
||||
}
|
||||
if (strpos($image, '&') !== false) {
|
||||
$images = explode('&', $image);
|
||||
$image = $images[1];
|
||||
}
|
||||
if (strpos($image, '{') !== false) {
|
||||
$images = explode('{', $image);
|
||||
$image = $images[0];
|
||||
}
|
||||
//if (!file_exists('textures/' . $image) && !empty($options['download'])) {
|
||||
// $it = new RecursiveDirectoryIterator($GLOBALS['path']);
|
||||
// foreach (new RecursiveIteratorIterator($it) as $file) {
|
||||
// if ($image == substr($file, strlen($image) * -1)) {
|
||||
// copy($file, 'textures/' . $image);
|
||||
// }
|
||||
// }
|
||||
//}
|
||||
if (!file_exists('textures/' . $image)) {
|
||||
debug('cant find: ' . $image);
|
||||
return '';
|
||||
}
|
||||
$width = $height = '';
|
||||
if (empty($options['fullsize'])) {
|
||||
$width = 'width="' . (isset($options['width']) ? $options['width'] : '32px') . '" ';
|
||||
$height = 'height="' . (isset($options['height']) ? $options['height'] : '32px') . '" ';
|
||||
}
|
||||
$class = isset($options['class']) ? 'class="' . $options['class'] . ' "' : '';
|
||||
return '<img src="textures/' . $image . '" ' . $width . $height . $class . '/>';
|
||||
}
|
||||
|
||||
function item_image($item, $options = array())
|
||||
{
|
||||
$file = false;
|
||||
if (!$file && !empty($item['name'])) {
|
||||
$file = 'itemcubes/' . str_replace(':', '-', $item['name']) . '.png';
|
||||
if (!file_exists($file))
|
||||
$file = false;
|
||||
}
|
||||
if (!$file && !empty($item['image'])) {
|
||||
if (substr($item['image'], 0, 14) == '[inventorycube') {
|
||||
$file = 'itemcubes/' . $item['image'] . '.png';
|
||||
if (!file_exists($file))
|
||||
return '';
|
||||
}
|
||||
}
|
||||
if ($file) {
|
||||
$width = $height = '';
|
||||
if (empty($options['fullsize'])) {
|
||||
$width = 'width="' . (!empty($options['width']) ? $options['width'] : '32px') . '" ';
|
||||
$height = 'height="' . (!empty($options['height']) ? $options['height'] : '32px') . '" ';
|
||||
}
|
||||
$class = !empty($options['class']) ? 'class="' . $options['class'] . ' "' : '';
|
||||
return '<img src="' . $file . '" ' . $width . $height . $class . '/>';
|
||||
}
|
||||
if (!empty($item['image'])) {
|
||||
return image($item['image']);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
function item($name, $quantity = null)
|
||||
{
|
||||
$output = '';
|
||||
$name = SQLite3::escapeString(item_name($name));
|
||||
if (!$name || in_array($name, array('air', 'default:air'))) {
|
||||
return $name;
|
||||
}
|
||||
|
||||
// check for an alias
|
||||
$alias = $GLOBALS['db']->querySingle('SELECT itemname FROM alias WHERE name="' . $name . '"');
|
||||
if ($alias) {
|
||||
$name = $alias;
|
||||
}
|
||||
|
||||
// load the item
|
||||
$q = $GLOBALS['db']->query('SELECT id, data, type, name, image, description FROM item WHERE name="' . $name . '"');
|
||||
if ($item = $q->fetchArray()) {
|
||||
$output .= '<a class="item" href="item.php?name=' . $item['name'] . '">';
|
||||
$output .= '<span class="image">' . item_image($item) . '</span>';
|
||||
$output .= '<span class="description">' . $item['description'] . ' </span>';
|
||||
$output .= '<span class="name">[' . $item['type'] . '][' . $item['name'] . ']' . ($quantity ? ' x' . $quantity : '') . '</span>';
|
||||
$output .= '</a>';
|
||||
}
|
||||
|
||||
// no item found
|
||||
elseif (substr($name, 0, 6) == 'group:') {
|
||||
$output .= '<a href="items.php?group=' . substr($name, 6) . '">' . $name . '</a>';
|
||||
}
|
||||
|
||||
// no item found
|
||||
else {
|
||||
$output .= $name . ' (missing item)';
|
||||
}
|
||||
|
||||
return $output;
|
||||
}
|
||||
|
||||
function head_tags()
|
||||
{
|
||||
ob_start();
|
||||
?>
|
||||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link href="bootstrap/css/bootstrap.css" rel="stylesheet">
|
||||
<style>
|
||||
body {
|
||||
padding-top: 60px; /* 60px to make the container go all the way to the bottom of the topbar */
|
||||
}
|
||||
</style>
|
||||
<link href="bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<style>
|
||||
h2 {
|
||||
border: 1px solid #ddd;
|
||||
border-width: 1px 0;
|
||||
margin: 1.5em 0 0.5em 0;
|
||||
padding: 0 0.4em;
|
||||
background: #eee;
|
||||
}
|
||||
|
||||
a.item {
|
||||
display: block;
|
||||
border: 1px solid #ccc;
|
||||
width: 345px;
|
||||
padding: 10px;
|
||||
background: #FFF;
|
||||
}
|
||||
|
||||
a.item:hover {
|
||||
text-decoration: none;
|
||||
background: #FFC;
|
||||
}
|
||||
|
||||
a.item .image {
|
||||
float: left;
|
||||
margin: 3px 4px 0 0;
|
||||
}
|
||||
|
||||
a.item .description {
|
||||
font-size: 120%;
|
||||
font-weight: bold;
|
||||
color: #333;
|
||||
display: block;
|
||||
}
|
||||
|
||||
img.image {
|
||||
border: 1px solid #ccc;
|
||||
}
|
||||
|
||||
.home h2 {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.home h2 a {
|
||||
display: block;
|
||||
}
|
||||
|
||||
.home ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.home li {
|
||||
margin: 5px;
|
||||
display: block;
|
||||
}
|
||||
|
||||
.home li a:hover {
|
||||
text-decoration: none;
|
||||
}
|
||||
|
||||
.itemgroup h3 {
|
||||
border: 1px solid #ddd;
|
||||
border-width: 1px 0;
|
||||
margin: 0 0 0.5em 0;
|
||||
padding: 0 0.2em;
|
||||
background: #eee;
|
||||
}
|
||||
|
||||
.itemgroup ul {
|
||||
list-style: none;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.itemgroup li {
|
||||
margin: 10px 0;
|
||||
}
|
||||
|
||||
table.crafting {
|
||||
border: 5px solid #666;
|
||||
}
|
||||
|
||||
table.crafting td {
|
||||
width: 373px;
|
||||
border: 2px solid #666;
|
||||
height: 64px;
|
||||
}
|
||||
|
||||
table.crafting td a.item {
|
||||
margin: 0 auto;
|
||||
}
|
||||
</style>
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
function menu()
|
||||
{
|
||||
$page = basename($_SERVER['SCRIPT_NAME']);
|
||||
ob_start();
|
||||
?>
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</a>
|
||||
<a class="brand" href="./">MineTest GameWiki</a>
|
||||
|
||||
<div class="nav-collapse">
|
||||
<ul class="nav">
|
||||
<li <?php echo in_array($page, array('items.php', 'item.php')) ? 'class="active"' : '' ?>>
|
||||
<a href="items.php">Items</a></li>
|
||||
<li <?php echo in_array($page, array('crafts.php', 'craft.php')) ? 'class="active"' : '' ?>>
|
||||
<a href="crafts.php">Crafts</a></li>
|
||||
<li <?php echo in_array($page, array('abms.php', 'abm.php')) ? 'class="active"' : '' ?>>
|
||||
<a href="abms.php">ABMs</a></li>
|
||||
<li <?php echo in_array($page, array('aliases.php')) ? 'class="active"' : '' ?>>
|
||||
<a href="aliases.php">Aliases</a></li>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<!--/.nav-collapse -->
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<?php
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
function item_names($items)
|
||||
{
|
||||
$_items = array();
|
||||
if (is_array($items)) {
|
||||
foreach ($items as $name) {
|
||||
if (is_array($name)) {
|
||||
$_items = array_merge($_items, item_names($name));
|
||||
}
|
||||
else {
|
||||
$_items[] = $name;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
$_items[] = item_name($items);
|
||||
}
|
||||
foreach ($_items as $k => $v) if (!$v) unset($_items[$k]);
|
||||
return array_unique($_items);
|
||||
}
|
||||
|
||||
function item_name($name)
|
||||
{
|
||||
$name = str_ireplace(array('tool ', 'node ', 'craft ', 'toolitem ', 'nodeitem ', 'craftitem ', '"'), '', $name);
|
||||
$name = explode(' ', $name);
|
||||
$name = $name[0];
|
||||
return $name;
|
||||
}
|
||||
|
||||
function craft_recipe($recipe, $type)
|
||||
{
|
||||
$output = '<table class="crafting">';
|
||||
if (in_array($type, array('fuel', 'cooking'))) {
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . ($type == 'cooking' ? item($recipe) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . ($type == 'fuel' ? item('default:furnace') : item('default:furnace_active')) . '</td>';
|
||||
$output .= '</tr>';
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . ($type == 'fuel' ? item($recipe) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
}
|
||||
else {
|
||||
if (is_array($recipe)) {
|
||||
if (is_array($recipe[0])) {
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . (isset($recipe[0][0]) ? item($recipe[0][0]) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[0][1]) ? item($recipe[0][1]) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[0][2]) ? item($recipe[0][2]) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . (isset($recipe[1][0]) ? item($recipe[1][0]) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[1][1]) ? item($recipe[1][1]) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[1][2]) ? item($recipe[1][2]) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . (isset($recipe[2][0]) ? item($recipe[2][0]) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[2][1]) ? item($recipe[2][1]) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[2][2]) ? item($recipe[2][2]) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
}
|
||||
else {
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . (isset($recipe[0]) ? item($recipe[0]) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[1]) ? item($recipe[1]) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[2]) ? item($recipe[2]) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . (isset($recipe[3]) ? item($recipe[3]) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[4]) ? item($recipe[4]) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[5]) ? item($recipe[5]) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . (isset($recipe[6]) ? item($recipe[6]) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[7]) ? item($recipe[7]) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[8]) ? item($recipe[8]) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
}
|
||||
}
|
||||
else {
|
||||
$recipe = explode(' ', $recipe);
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . (isset($recipe[0]) ? item($recipe[0]) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[1]) ? item($recipe[1]) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[2]) ? item($recipe[2]) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . (isset($recipe[3]) ? item($recipe[3]) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[4]) ? item($recipe[4]) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[5]) ? item($recipe[5]) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
$output .= '<tr>';
|
||||
$output .= '<td>' . (isset($recipe[6]) ? item($recipe[6]) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[7]) ? item($recipe[7]) : '') . '</td>';
|
||||
$output .= '<td>' . (isset($recipe[8]) ? item($recipe[8]) : '') . '</td>';
|
||||
$output .= '</tr>';
|
||||
}
|
||||
}
|
||||
$output .= '</table>';
|
||||
return $output;
|
||||
}
|
||||
|
||||
?>
|
||||
}
|
|
@ -1,4 +1,13 @@
|
|||
<?php
|
||||
/**
|
||||
* GameWiki for Minetest
|
||||
*
|
||||
* Copyright (c) 2012 cornernote, Brett O'Donnell <cornernote@gmail.com>
|
||||
*
|
||||
* Source Code: https://github.com/cornernote/minetest-gamewiki
|
||||
* License: GPLv3
|
||||
*/
|
||||
|
||||
$resume = empty($_GET['resume']) ? false : true;
|
||||
if(!count(glob('data/wikidata/*.json'))) $resume = true;
|
||||
|
||||
|
@ -19,12 +28,12 @@ require('globals.php');
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>MTGW</title>
|
||||
<?php echo head_tags(); ?>
|
||||
<title>Data Import :: <?php echo $GLOBALS['name']; ?></title>
|
||||
<?php include('include/head_tags.php'); ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php echo menu(); ?>
|
||||
<?php include('include/menu.php'); ?>
|
||||
<div class="container">
|
||||
<h1>Import JSON Data</h1>
|
||||
|
||||
|
@ -35,35 +44,35 @@ require('globals.php');
|
|||
// create database
|
||||
if (!$resume) {
|
||||
|
||||
$GLOBALS['db']->query('CREATE TABLE "abm" ("id" INTEGER PRIMARY KEY, "mod" TEXT, "data" TEXT)');
|
||||
$GLOBALS['db']->query('CREATE INDEX "main"."abm.mod" ON "abm" ("mod")');
|
||||
$db->query('CREATE TABLE "abm" ("id" INTEGER PRIMARY KEY, "mod" TEXT, "data" TEXT)');
|
||||
$db->query('CREATE INDEX "main"."abm.mod" ON "abm" ("mod")');
|
||||
|
||||
$GLOBALS['db']->query('CREATE TABLE "abm_to_itemname" ("abm_id" INTEGER, "name" TEXT)');
|
||||
$GLOBALS['db']->query('CREATE INDEX "main"."abm_to_itemname.name" ON "abm_to_itemname" ("name")');
|
||||
$db->query('CREATE TABLE "abm_to_itemname" ("abm_id" INTEGER, "name" TEXT)');
|
||||
$db->query('CREATE INDEX "main"."abm_to_itemname.name" ON "abm_to_itemname" ("name")');
|
||||
|
||||
$GLOBALS['db']->query('CREATE TABLE "alias" ("id" INTEGER PRIMARY KEY, "mod" TEXT, "data" TEXT, "name" TEXT, "itemname" TEXT)');
|
||||
$GLOBALS['db']->query('CREATE INDEX "main"."alias.mod" ON "alias" ("mod")');
|
||||
$GLOBALS['db']->query('CREATE INDEX "main"."alias.name" ON "alias" ("name")');
|
||||
$GLOBALS['db']->query('CREATE INDEX "main"."alias.itemname" ON "alias" ("itemname")');
|
||||
$db->query('CREATE TABLE "alias" ("id" INTEGER PRIMARY KEY, "mod" TEXT, "data" TEXT, "name" TEXT, "itemname" TEXT)');
|
||||
$db->query('CREATE INDEX "main"."alias.mod" ON "alias" ("mod")');
|
||||
$db->query('CREATE INDEX "main"."alias.name" ON "alias" ("name")');
|
||||
$db->query('CREATE INDEX "main"."alias.itemname" ON "alias" ("itemname")');
|
||||
|
||||
$GLOBALS['db']->query('CREATE TABLE "craft" ("id" INTEGER PRIMARY KEY, "mod" TEXT, "data" TEXT, "type" TEXT, "output" TEXT, "quantity" INTEGER)');
|
||||
$GLOBALS['db']->query('CREATE INDEX "main"."craft.mod" ON "craft" ("mod")');
|
||||
$GLOBALS['db']->query('CREATE INDEX "main"."craft.type" ON "craft" ("type")');
|
||||
$GLOBALS['db']->query('CREATE INDEX "main"."craft.output" ON "craft" ("output")');
|
||||
$db->query('CREATE TABLE "craft" ("id" INTEGER PRIMARY KEY, "mod" TEXT, "data" TEXT, "type" TEXT, "output" TEXT, "quantity" INTEGER)');
|
||||
$db->query('CREATE INDEX "main"."craft.mod" ON "craft" ("mod")');
|
||||
$db->query('CREATE INDEX "main"."craft.type" ON "craft" ("type")');
|
||||
$db->query('CREATE INDEX "main"."craft.output" ON "craft" ("output")');
|
||||
|
||||
$GLOBALS['db']->query('CREATE TABLE "craft_to_itemname" ("craft_id" INTEGER, "name" TEXT)');
|
||||
$GLOBALS['db']->query('CREATE INDEX "main"."craft_to_itemname.name" ON "craft_to_itemname" ("name")');
|
||||
$db->query('CREATE TABLE "craft_to_itemname" ("craft_id" INTEGER, "name" TEXT)');
|
||||
$db->query('CREATE INDEX "main"."craft_to_itemname.name" ON "craft_to_itemname" ("name")');
|
||||
|
||||
$GLOBALS['db']->query('CREATE TABLE "entity" ("id" INTEGER PRIMARY KEY, "mod" TEXT, "data" TEXT)');
|
||||
$GLOBALS['db']->query('CREATE INDEX "main"."entity.mod" ON "entity" ("mod")');
|
||||
$db->query('CREATE TABLE "entity" ("id" INTEGER PRIMARY KEY, "mod" TEXT, "data" TEXT)');
|
||||
$db->query('CREATE INDEX "main"."entity.mod" ON "entity" ("mod")');
|
||||
|
||||
$GLOBALS['db']->query('CREATE TABLE "item" ("id" INTEGER PRIMARY KEY, "mod" TEXT, "data" TEXT, "type" TEXT, "name" TEXT, "description" TEXT, "image" TEXT)');
|
||||
$GLOBALS['db']->query('CREATE INDEX "main"."item.mod" ON "item" ("mod")');
|
||||
$GLOBALS['db']->query('CREATE INDEX "main"."item.type" ON "item" ("type")');
|
||||
$GLOBALS['db']->query('CREATE INDEX "main"."item.name" ON "item" ("name")');
|
||||
$db->query('CREATE TABLE "item" ("id" INTEGER PRIMARY KEY, "mod" TEXT, "data" TEXT, "type" TEXT, "name" TEXT, "description" TEXT, "image" TEXT)');
|
||||
$db->query('CREATE INDEX "main"."item.mod" ON "item" ("mod")');
|
||||
$db->query('CREATE INDEX "main"."item.type" ON "item" ("type")');
|
||||
$db->query('CREATE INDEX "main"."item.name" ON "item" ("name")');
|
||||
|
||||
$GLOBALS['db']->query('CREATE TABLE "group_to_itemname" ("group" TEXT, "value" TEXT, "name" TEXT)');
|
||||
$GLOBALS['db']->query('CREATE INDEX "main"."group_to_itemname.name" ON "group_to_itemname" ("name")');
|
||||
$db->query('CREATE TABLE "group_to_itemname" ("group" TEXT, "value" TEXT, "name" TEXT)');
|
||||
$db->query('CREATE INDEX "main"."group_to_itemname.name" ON "group_to_itemname" ("name")');
|
||||
|
||||
}
|
||||
|
||||
|
@ -76,12 +85,12 @@ require('globals.php');
|
|||
$contents = file_get_contents($filename);
|
||||
$json = json_decode($contents);
|
||||
$data = SQLite3::escapeString($contents);
|
||||
if ($GLOBALS['db']->query("INSERT INTO abm (id, mod, data) VALUES ('" . $id . "','" . $mod . "','" . $data . "')")) {
|
||||
$abm_id = $GLOBALS['db']->lastInsertRowID();
|
||||
if (isset($json->options->nodenames)) foreach (item_names($json->options->nodenames) as $name)
|
||||
$GLOBALS['db']->query("INSERT INTO abm_to_itemname (abm_id, name) VALUES ('" . $abm_id . "','" . $name . "')");
|
||||
if (isset($json->options->neighbors)) foreach (item_names($json->options->neighbors) as $name)
|
||||
$GLOBALS['db']->query("INSERT INTO abm_to_itemname (abm_id, name) VALUES ('" . $abm_id . "','" . $name . "')");
|
||||
if ($db->query("INSERT INTO abm (id, mod, data) VALUES ('" . $id . "','" . $mod . "','" . $data . "')")) {
|
||||
$abm_id = $db->lastInsertRowID();
|
||||
if (isset($json->options->nodenames)) foreach (gamewiki::item_names($json->options->nodenames) as $name)
|
||||
$db->query("INSERT INTO abm_to_itemname (abm_id, name) VALUES ('" . $abm_id . "','" . $name . "')");
|
||||
if (isset($json->options->neighbors)) foreach (gamewiki::item_names($json->options->neighbors) as $name)
|
||||
$db->query("INSERT INTO abm_to_itemname (abm_id, name) VALUES ('" . $abm_id . "','" . $name . "')");
|
||||
unlink($filename);
|
||||
}
|
||||
}
|
||||
|
@ -97,7 +106,7 @@ require('globals.php');
|
|||
$data = SQLite3::escapeString($contents);
|
||||
$name = SQLite3::escapeString($json->name);
|
||||
$itemname = SQLite3::escapeString($json->options);
|
||||
if ($GLOBALS['db']->query("INSERT INTO alias (id, mod, data, name, itemname) VALUES ('" . $id . "','" . $mod . "','" . $data . "','" . $name . "','" . $itemname . "')")) {
|
||||
if ($db->query("INSERT INTO alias (id, mod, data, name, itemname) VALUES ('" . $id . "','" . $mod . "','" . $data . "','" . $name . "','" . $itemname . "')")) {
|
||||
unlink($filename);
|
||||
}
|
||||
}
|
||||
|
@ -112,14 +121,13 @@ require('globals.php');
|
|||
$json = json_decode($contents);
|
||||
$data = SQLite3::escapeString($contents);
|
||||
$type = isset($json->options->type) ? $json->options->type : 'crafting';
|
||||
$_output = isset($json->options->output) ? item_name($json->options->output) : '';
|
||||
$_output = explode(' ', $_output);
|
||||
$output = SQLite3::escapeString($_output[0]);
|
||||
$quantity = SQLite3::escapeString(isset($_output[1]) ? $_output[1] : 1);
|
||||
if ($GLOBALS['db']->query("INSERT INTO craft (id, mod, data, type, output, quantity) VALUES ('" . $id . "','" . $mod . "','" . $data . "','" . $type . "','" . $output . "','" . $quantity . "')")) {
|
||||
$craft_id = $GLOBALS['db']->lastInsertRowID();
|
||||
if (isset($json->options) && isset($json->options->recipe)) foreach (item_names($json->options->recipe) as $name)
|
||||
$GLOBALS['db']->query("INSERT INTO craft_to_itemname (craft_id, name) VALUES ('" . $craft_id . "','" . $name . "')");
|
||||
$output = isset($json->options->output) ? trim($json->options->output) : '';
|
||||
$quantity = gamewiki::item_quantity($output);
|
||||
$output = SQLite3::escapeString(gamewiki::item_name($output));
|
||||
if ($db->query("INSERT INTO craft (id, mod, data, type, output, quantity) VALUES ('" . $id . "','" . $mod . "','" . $data . "','" . $type . "','" . $output . "','" . $quantity . "')")) {
|
||||
$craft_id = $db->lastInsertRowID();
|
||||
if (isset($json->options) && isset($json->options->recipe)) foreach (gamewiki::item_names($json->options->recipe) as $name)
|
||||
$db->query("INSERT INTO craft_to_itemname (craft_id, name) VALUES ('" . $craft_id . "','" . gamewiki::item_name($name) . "')");
|
||||
unlink($filename);
|
||||
}
|
||||
}
|
||||
|
@ -131,7 +139,7 @@ require('globals.php');
|
|||
$pathinfo = pathinfo($filename);
|
||||
list($table, $mod, $id) = explode('.', $pathinfo['filename']);
|
||||
$data = SQLite3::escapeString(file_get_contents($filename));
|
||||
if ($GLOBALS['db']->query("INSERT INTO entity (id, mod, data) VALUES ('" . $id . "','" . $mod . "','" . $data . "')")) {
|
||||
if ($db->query("INSERT INTO entity (id, mod, data) VALUES ('" . $id . "','" . $mod . "','" . $data . "')")) {
|
||||
unlink($filename);
|
||||
}
|
||||
}
|
||||
|
@ -146,7 +154,7 @@ require('globals.php');
|
|||
$data = SQLite3::escapeString($contents);
|
||||
$json = json_decode($contents);
|
||||
$type = SQLite3::escapeString(isset($json->options) && !empty($json->options->type) ? $json->options->type : 'unknown');
|
||||
$name = SQLite3::escapeString(item_name($json->name));
|
||||
$name = SQLite3::escapeString(gamewiki::item_name($json->name));
|
||||
$name = explode(' ', $name);
|
||||
$name = isset($name[1]) ? $name[1] : $name[0];
|
||||
$description = SQLite3::escapeString((isset($json->options->description) ? $json->options->description : ''));
|
||||
|
@ -174,9 +182,9 @@ require('globals.php');
|
|||
$image = SQLite3::escapeString(isset($images[0]) ? $images[0] : '');
|
||||
}
|
||||
}
|
||||
if ($GLOBALS['db']->query("INSERT INTO item (id, mod, data, type, name, description, image) VALUES ('" . $id . "','" . $mod . "','" . $data . "','" . $type . "','" . $name . "','" . $description . "','" . $image . "')")) {
|
||||
if ($db->query("INSERT INTO item (id, mod, data, type, name, description, image) VALUES ('" . $id . "','" . $mod . "','" . $data . "','" . $type . "','" . $name . "','" . $description . "','" . $image . "')")) {
|
||||
if (isset($json->options) && isset($json->options->groups)) foreach ($json->options->groups as $group => $value)
|
||||
$GLOBALS['db']->query("INSERT INTO group_to_itemname ('group', value, name) VALUES ('" . $group . "','" . $value . "','" . $name . "')");
|
||||
$db->query("INSERT INTO group_to_itemname ('group', value, name) VALUES ('" . $group . "','" . $value . "','" . $name . "')");
|
||||
//echo 'fetching images: <b>' . print_r($images, true) . '</b><br/>';
|
||||
//images(array_merge(array($image), $images), array('download' => true));
|
||||
unlink($filename);
|
||||
|
@ -189,5 +197,6 @@ require('globals.php');
|
|||
|
||||
|
||||
</div>
|
||||
<div id="footer"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,20 @@
|
|||
<meta charset="utf-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
|
||||
<link href="bootstrap/css/bootstrap.css" rel="stylesheet">
|
||||
<style>
|
||||
/* before bootstrap-responsive set padding-top to 60px to make the container go all the way to the bottom of the topbar */
|
||||
body {
|
||||
padding-top: 60px;
|
||||
}
|
||||
</style>
|
||||
<link href="bootstrap/css/bootstrap-responsive.css" rel="stylesheet">
|
||||
<link href="assets/gamewiki.css" rel="stylesheet">
|
||||
<script type="text/javascript" src="bootstrap/js/jquery.js"></script>
|
||||
<script type="text/javascript" src="bootstrap/js/bootstrap.js"></script>
|
||||
<script type="text/javascript" src="assets/gamewiki.js"></script>
|
||||
|
||||
<!-- Le HTML5 shim, for IE6-8 support of HTML5 elements -->
|
||||
<!--[if lt IE 9]>
|
||||
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
|
||||
<![endif]-->
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
$page = basename($_SERVER['SCRIPT_NAME']);
|
||||
?>
|
||||
<div class="navbar navbar-fixed-top">
|
||||
<div class="navbar-inner">
|
||||
<div class="container">
|
||||
<a class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
<span class="icon-bar"></span>
|
||||
</a>
|
||||
<a class="brand" href="<?php echo $GLOBALS['brand_url']; ?>"><?php echo $GLOBALS['name']; ?></a>
|
||||
|
||||
<div class="nav-collapse">
|
||||
<ul class="nav">
|
||||
<li <?php echo in_array($page, array('index.php')) ? 'class="active"' : '' ?>>
|
||||
<a href="./">Home</a></li>
|
||||
<li <?php echo in_array($page, array('items.php', 'item.php')) ? 'class="active"' : '' ?>>
|
||||
<a href="items.php">Items</a></li>
|
||||
<li <?php echo in_array($page, array('crafts.php', 'craft.php')) ? 'class="active"' : '' ?>>
|
||||
<a href="crafts.php">Crafts</a></li>
|
||||
<li <?php echo in_array($page, array('abms.php', 'abm.php')) ? 'class="active"' : '' ?>>
|
||||
<a href="abms.php">ABMs</a></li>
|
||||
<li <?php echo in_array($page, array('aliases.php')) ? 'class="active"' : '' ?>>
|
||||
<a href="aliases.php">Aliases</a></li>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
|
@ -1,46 +1,78 @@
|
|||
<?php require('globals.php'); ?>
|
||||
<?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');
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>MTGW</title>
|
||||
<?php echo head_tags(); ?>
|
||||
<title><?php echo $GLOBALS['name']; ?></title>
|
||||
<?php include('include/head_tags.php'); ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php echo menu(); ?>
|
||||
<?php include('include/menu.php'); ?>
|
||||
<div class="container home">
|
||||
|
||||
<div class="hero-unit">
|
||||
<h1>MineTest GameWiki</h1>
|
||||
<h1><?php echo $GLOBALS['name']; ?></h1>
|
||||
|
||||
<p>This site contains a list of all ingame items and crafts.</p>
|
||||
</div>
|
||||
|
||||
<div class="well">
|
||||
<ul>
|
||||
<li>
|
||||
<h2><a href="items.php">Items
|
||||
<small>tools, nodes, crafts</small>
|
||||
</a></h2>
|
||||
</li>
|
||||
<li>
|
||||
<h2><a href="crafts.php">Crafts
|
||||
<small>learn to craft items</small>
|
||||
</a></h2>
|
||||
</li>
|
||||
<li>
|
||||
<h2><a href="abms.php">ABMs
|
||||
<small>active block modifiers</small>
|
||||
</a></h2>
|
||||
</li>
|
||||
<li>
|
||||
<h2><a href="aliases.php">Aliases
|
||||
<small>list of available item aliases</small>
|
||||
</a></h2>
|
||||
</li>
|
||||
</ul>
|
||||
<p>This site contains a list of all Items, Crafts, ABMs and Aliases.</p>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="span8">
|
||||
<ul>
|
||||
<li>
|
||||
<h2><a href="items.php">Items
|
||||
<small>tools, nodes, crafts</small>
|
||||
</a></h2>
|
||||
</li>
|
||||
<li>
|
||||
<h2><a href="crafts.php">Crafts
|
||||
<small>learn to craft items</small>
|
||||
</a></h2>
|
||||
</li>
|
||||
<li>
|
||||
<h2><a href="abms.php">ABMs
|
||||
<small>active block modifiers</small>
|
||||
</a></h2>
|
||||
</li>
|
||||
<li>
|
||||
<h2><a href="aliases.php">Aliases
|
||||
<small>list of available item aliases</small>
|
||||
</a></h2>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="span4">
|
||||
|
||||
<h2>Mods</h2>
|
||||
<table class="table">
|
||||
<?php
|
||||
foreach(gamewiki::get_mods() as $mod) {
|
||||
?>
|
||||
<tr>
|
||||
<th><?php echo $mod; ?></th>
|
||||
<td><a href="items.php?mod=<?php echo $mod; ?>">Items</a></td>
|
||||
<td><a href="crafts.php?mod=<?php echo $mod; ?>">Crafts</a></td>
|
||||
<td><a href="abms.php?mod=<?php echo $mod; ?>">ABMs</a></td>
|
||||
<td><a href="aliases.php?mod=<?php echo $mod; ?>">Aliases</a></td>
|
||||
</tr>
|
||||
<?php
|
||||
}
|
||||
?>
|
||||
</table>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
<div id="footer"></div>
|
||||
</body>
|
||||
</html>
|
|
@ -1,18 +1,28 @@
|
|||
<?php require('globals.php'); ?>
|
||||
<?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');
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>MTGW</title>
|
||||
<?php echo head_tags(); ?>
|
||||
<title>View Item :: <?php echo $GLOBALS['name']; ?></title>
|
||||
<?php include('include/head_tags.php'); ?>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<?php echo menu(); ?>
|
||||
<?php include('include/menu.php'); ?>
|
||||
<div class="container">
|
||||
|
||||
<?php
|
||||
$name = SQLite3::escapeString($_GET['name']);
|
||||
$q = $GLOBALS['db']->query('SELECT id, mod, type, name, description, data FROM "item" WHERE name = "' . $name . '"');
|
||||
$q = $db->query('SELECT id, mod, type, name, description, data FROM "item" WHERE name = "' . $name . '"');
|
||||
$row = $q->fetchArray();
|
||||
$data = json_decode($row['data']);
|
||||
?>
|
||||
|
@ -22,7 +32,7 @@
|
|||
<?php
|
||||
|
||||
// item
|
||||
echo item($row['name']);
|
||||
echo gamewiki::item($row['name']);
|
||||
|
||||
// images
|
||||
$images = array_merge(
|
||||
|
@ -32,38 +42,60 @@
|
|||
);
|
||||
if (!empty($images)) {
|
||||
echo '<h2>Images</h2>';
|
||||
echo images($images, array('fullsize' => true, 'class' => 'image'));
|
||||
echo gamewiki::images($images, array('fullsize' => true, 'class' => 'image'));
|
||||
}
|
||||
|
||||
// created by crafts
|
||||
$q = $GLOBALS['db']->query('SELECT id, type, data FROM "craft" WHERE output = "' . $name . '"');
|
||||
$rows = array();
|
||||
$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>';
|
||||
while ($row_c = $q->fetchArray()) {
|
||||
$data_c = json_decode($row_c['data']);
|
||||
$rows[] = '<a href="craft.php?id=' . $row_c['id'] . '" class="btn">view craft</a><br/><br/>' . craft_recipe($data_c->options->recipe, $row_c['type']);
|
||||
}
|
||||
if ($rows) {
|
||||
echo '<h2>Created By Crafts</h2>';
|
||||
echo implode('<hr/>', $rows);
|
||||
$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;
|
||||
}
|
||||
echo '</table>';
|
||||
$contents = ob_get_clean();
|
||||
if ($output) echo $contents;
|
||||
|
||||
// used for crafts
|
||||
$output = false;
|
||||
ob_start();
|
||||
echo '<h2>Used For Crafts</h2>';
|
||||
$q = $GLOBALS['db']->query('SELECT id, mod, type, output, quantity FROM "craft_to_itemname" LEFT JOIN "craft" ON "craft"."id"="craft_to_itemname"."craft_id" WHERE name = "' . $name . '" ORDER BY output');
|
||||
$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');
|
||||
echo '<table class="table">';
|
||||
echo '<tr>';
|
||||
echo '<th width="100">Mod</th>';
|
||||
echo '<th width="100">Type</th>';
|
||||
echo '<th style="width:100px">Mod</th>';
|
||||
echo '<th style="width:100px">Type</th>';
|
||||
echo '<th>Recipe</th>';
|
||||
echo '<th>Output</th>';
|
||||
echo '<th width="100"> </th>';
|
||||
echo '<th style="width:100px;"> </th>';
|
||||
echo '</tr>';
|
||||
while ($row_c = $q->fetchArray()) {
|
||||
$data = json_decode($row_c['data']);
|
||||
echo '<tr>';
|
||||
echo '<td>' . $row_c['mod'] . '</td>';
|
||||
echo '<td>' . $row_c['type'] . '</td>';
|
||||
echo '<td>' . ($row_c['output'] ? item($row_c['output'], $row_c['quantity']) : 'no output') . '</td>';
|
||||
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>';
|
||||
}
|
||||
echo '<td><a href="craft.php?id=' . $row_c['id'] . '" class="btn">view craft</a></td>';
|
||||
echo '</tr>';
|
||||
$output = true;
|
||||
|
@ -74,7 +106,7 @@
|
|||
|
||||
// used by abms
|
||||
$rows = array();
|
||||
$q = $GLOBALS['db']->query('SELECT id FROM "abm_to_itemname" LEFT JOIN "abm" ON "abm"."id"="abm_to_itemname"."abm_id" WHERE name = "' . $name . '"');
|
||||
$q = $db->query('SELECT id FROM "abm_to_itemname" LEFT JOIN "abm" ON "abm"."id"="abm_to_itemname"."abm_id" WHERE name = "' . $name . '"');
|
||||
while ($row_a = $q->fetchArray()) {
|
||||
$rows[] = '<a href="abm.php?id=' . $row_a['id'] . '" class="btn">view abm</a>';
|
||||
}
|
||||
|
@ -83,6 +115,28 @@
|
|||
echo implode(' ', $rows);
|
||||
}
|
||||
|
||||
// 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
|
||||
echo '<h2>Data</h2>';
|
||||
echo '<h3>mod:' . $row['mod'] . '</h3>';
|
||||
print '<pre>';
|
||||
|
@ -91,5 +145,6 @@
|
|||
?>
|
||||
|
||||
</div>
|
||||
<div id="footer"></div>
|
||||
</body>
|
||||
</html>
|
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 5.4 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 4.9 KiB |
After Width: | Height: | Size: 5.2 KiB |
After Width: | Height: | Size: 5.3 KiB |
After Width: | Height: | Size: 5.4 KiB |
Before Width: | Height: | Size: 6.3 KiB |
After Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 6.6 KiB |
Before Width: | Height: | Size: 2.4 KiB |
Before Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 4.2 KiB |
Before Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 5.6 KiB |
Before Width: | Height: | Size: 3.5 KiB |
Before Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 4.4 KiB |
Before Width: | Height: | Size: 4.3 KiB |
Before Width: | Height: | Size: 4.5 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 3.0 KiB |
Before Width: | Height: | Size: 2.9 KiB |
Before Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 6.0 KiB |
Before Width: | Height: | Size: 6.0 KiB |
Before Width: | Height: | Size: 4.9 KiB |
Before Width: | Height: | Size: 5.3 KiB |
Before Width: | Height: | Size: 2.8 KiB |
Before Width: | Height: | Size: 4.0 KiB |
Before Width: | Height: | Size: 6.0 KiB |
Before Width: | Height: | Size: 7.6 KiB |
Before Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 5.1 KiB |
Before Width: | Height: | Size: 5.7 KiB |
Before Width: | Height: | Size: 3.1 KiB |
Before Width: | Height: | Size: 3.8 KiB |
Before Width: | Height: | Size: 3.4 KiB |
Before Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 3.3 KiB |
Before Width: | Height: | Size: 6.5 KiB |
Before Width: | Height: | Size: 7.0 KiB |
Before Width: | Height: | Size: 4.7 KiB |
Before Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 6.9 KiB |
Before Width: | Height: | Size: 8.3 KiB |
Before Width: | Height: | Size: 7.9 KiB |
Before Width: | Height: | Size: 7.6 KiB |
Before Width: | Height: | Size: 6.7 KiB |
Before Width: | Height: | Size: 6.2 KiB |
Before Width: | Height: | Size: 6.4 KiB |
Before Width: | Height: | Size: 7.3 KiB |
Before Width: | Height: | Size: 6.1 KiB |
Before Width: | Height: | Size: 7.2 KiB |
Before Width: | Height: | Size: 7.5 KiB |
Before Width: | Height: | Size: 7.7 KiB |
Before Width: | Height: | Size: 5.9 KiB |
Before Width: | Height: | Size: 8.4 KiB |
Before Width: | Height: | Size: 7.6 KiB |
After Width: | Height: | Size: 7.0 KiB |
After Width: | Height: | Size: 7.1 KiB |
After Width: | Height: | Size: 6.7 KiB |
After Width: | Height: | Size: 5.9 KiB |
After Width: | Height: | Size: 4.4 KiB |