本文整理汇总了PHP中FileHandler::path方法的典型用法代码示例。如果您正苦于以下问题:PHP FileHandler::path方法的具体用法?PHP FileHandler::path怎么用?PHP FileHandler::path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FileHandler
的用法示例。
在下文中一共展示了FileHandler::path方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: save
public static function save($filename, $data = array())
{
$base = array('version' => null, 'data' => null);
$version = AppData::first();
$base['version'] = array('schema' => $version->schema_version, 'data' => $version->data_version, 'seq' => $version->data_sequence_no, 'built' => date('Y-m-d H:i:s'));
$base['data'] = $data;
file_put_contents(FileHandler::path() . $filename . '.json', json_encode($base));
}
示例2: run
public function run()
{
// Relevant XIVDB files
$locations = json_decode(file_get_contents(FileHandler::path() . 'locations.json'));
$gn = json_decode(file_get_contents(FileHandler::path() . 'gathering_nodes.json'));
$gni = json_decode(file_get_contents(FileHandler::path() . 'gathering_node_item.json'));
// Relevant Libra files
$maps = json_decode(file_get_contents(FileHandler::path() . 'maps.json'));
$placenames = FileHandler::get_data('PlaceName');
// We want Placenames to be the "system of record", so we're making everything else conform
// Let's link up our PlaceName and locations.json
$location_to_placename = [];
foreach ($locations as $l) {
foreach ($placenames as $p) {
if (strtolower($l->name) == strtolower($p->name->en)) {
$location_to_placename[$l->id] = $p->id;
continue 2;
}
}
}
// And we need to link up PlaceName to Map ID
$map_to_placename = [];
// Some weren't found, but they were inconsequential
foreach ($maps as $id => $regions) {
foreach ($regions as $region) {
foreach ($placenames as $p) {
if (strtolower($region->REGION) == strtolower($p->name->en)) {
$map_to_placename[$id] = $p->id;
continue 3;
}
}
}
}
// Regions have Clusters
// Clusters have Nodes
// Clusters have Items
// - Nodes semantically have Items, but they're all the same in a Cluster
$clusters = $icons = [];
$action_list = array('Logging' => 'mature tree', 'Harvesting' => 'lush vegetation', 'Quarrying' => 'rocky outcrop', 'Mining' => 'mineral deposit');
// $gn defines out clusters
foreach ($gn as $cluster) {
$cluster->placename_id = $location_to_placename[$cluster->location_id];
// Figure out the cluster nodes
$cluster->icon = '';
$cluster->nodes = [];
foreach ($maps->{$cluster->placename_id} as $map_id => $section) {
if (!is_array($section->{substr($cluster->class, 0, 1) . 'POINT'})) {
continue;
}
foreach ($section->{substr($cluster->class, 0, 1) . 'POINT'} as $node) {
if ($node->description == '') {
continue;
}
if (preg_match('/bugged/', $node->description)) {
continue;
}
// Get the type and level
preg_match('/^lv(\\.?\\s?)?(\\d+)\\b(.*)$/', strtolower($node->description), $matches);
if (count($matches) != 4) {
// handle special cases
// Description may be junk, but it'll be kicked out later
$type = $node->description;
$level = 50;
} else {
list($ignore, $ignore, $level, $type) = $matches;
}
// Compare Levels
if ($level != $cluster->level) {
continue;
}
$type = trim(ltrim($type, ' -'));
// Tie Action to Type
// Rule out bad apples, nonmatching types
$continue = true;
foreach ($action_list as $a => $t) {
if ($cluster->action == $a && preg_match('/' . $t . '/', $type)) {
$continue = false;
}
}
if ($continue) {
continue;
}
// We've passed all tests, this node point belongs to this cluster
// $icons[] = $node->iconUrl;
$cluster->icon = preg_replace('/^.*\\/(\\d+\\.png)$/', '$1', $node->iconUrl);
$cluster->nodes[] = array('id' => $node->id, 'description' => ucwords($type), 'x' => number_format($node->locX, 4, '.', ','), 'y' => number_format($node->locY, 4, '.', ','));
}
}
// Find out the "center" of the nodes, and the radius
$xs = $ys = [];
$radius = $center_x = $center_y = 0;
foreach ($cluster->nodes as $n) {
$xs[] = $n['x'];
$ys[] = $n['y'];
}
// sort($xs);
// sort($ys);
$cluster->center_x = count($xs) ? number_format(array_sum($xs) / count($xs), 4, '.', ',') : 0;
$cluster->center_y = count($ys) ? number_format(array_sum($ys) / count($ys), 4, '.', ',') : 0;
// var_dump(
//.........这里部分代码省略.........