mirror of
https://github.com/Znote/ZnoteAAC.git
synced 2025-04-29 10:49:23 +02:00
Update itemlistparser (#336)
* Improve itemlistparser. Remove ugly cache file * Convert item id to int, remove items variable
This commit is contained in:
parent
590dc37d28
commit
f79a48fc06
@ -1,14 +1,34 @@
|
|||||||
<?php
|
<?php
|
||||||
|
|
||||||
/* Returns a PHP array $id => 'name'
|
/* Returns a PHP array $id => 'name'
|
||||||
$items = getItemList();
|
$items = getItemList();
|
||||||
echo $items[2160]; // Returns 'Crystal Coin'
|
echo $items[2160]; // Returns 'Crystal Coin'
|
||||||
*/
|
*/
|
||||||
function getItemList() {
|
|
||||||
$item_list = explode(PHP_EOL, file_get_contents('item_list.txt'));
|
function getItemList() {
|
||||||
$ia = array();
|
return parseItems();
|
||||||
for ($i = 0; $i < count($item_list) - 1; $i++) {
|
}
|
||||||
$it = explode('@', $item_list[$i]);
|
|
||||||
$ia[(int)$it[0]] = ucfirst($it[1]);
|
function getItemById($id) {
|
||||||
|
$items = parseItems();
|
||||||
|
if(isset($items[$id])) {
|
||||||
|
return $items[$id];
|
||||||
}
|
}
|
||||||
return $ia;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function parseItems() {
|
||||||
|
global $config;
|
||||||
|
|
||||||
|
$items = simplexml_load_file($config['server_path'].'/data/items/items.xml');
|
||||||
|
$out = array();
|
||||||
|
|
||||||
|
// Create our parsed item list
|
||||||
|
foreach ($items->children() as $item) {
|
||||||
|
if ($item['id'] && $item['name'] != NULL) {
|
||||||
|
$out[(int)$item['id']] = (string)$item['name'];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return $out;
|
||||||
|
}
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
$items = simplexml_load_file($config['server_path'].'/data/items/items.xml');
|
|
||||||
|
|
||||||
// Create our parsed item list
|
|
||||||
$item_list = fopen('item_list.txt', 'w');
|
|
||||||
|
|
||||||
foreach ($items->children() as $item) {
|
|
||||||
|
|
||||||
if ($item['id'] && $item['name'] != NULL) {
|
|
||||||
|
|
||||||
fwrite($item_list, $item['id'].'@'.$item['name'].PHP_EOL);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fclose($item_list);
|
|
||||||
|
|
||||||
|
|
6398
item_list.txt
6398
item_list.txt
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user