Author: Nathan Macnamara (nathan.macnamara@outlook.com)
示例#1
0
 /**
  * Store a newly created resource in storage.
  *
  * @return Response
  */
 public function store()
 {
     $file = Request::file('xmlfile');
     $type = Input::get('type');
     $userid = Input::get('userid');
     $alpha = Input::get('alpha');
     $extension = $file->getClientOriginalExtension();
     $oname = $file->getClientOriginalName();
     Storage::disk('local')->put("uploads/" . $file->getClientOriginalName(), File::get($file));
     $parser = new Parser();
     $contents = Storage::get("uploads/" . $file->getClientOriginalName());
     $rawxml = $parser->xml($contents);
     $importer = new Importer();
     if ($type == 'recipes') {
         $importer->parseRecipe($rawxml, $userid, $alpha, 1);
     }
     if ($type == 'blocks') {
         $importer->parseBlocks($rawxml, $userid, $alpha, 1);
     }
     if ($type == 'materials') {
         $importer->parseMaterial($rawxml, $userid, $alpha, 1);
     }
     if ($type == 'items') {
         $importer->parseItems($rawxml, $userid, $alpha, 1);
     }
     //Flash::success('You successfully imported a '.$type.' xml file for 7 Days to Die Alpha '.$alpha.'!');
     return view('pages.import');
 }
示例#2
0
 /** @test */
 public function format_detection_xml()
 {
     $parser = new Parser();
     $_SERVER['HTTP_CONTENT_TYPE'] = "application/xml";
     $this->assertEquals('xml', $parser->getFormat());
     $_SERVER['HTTP_CONTENT_TYPE'] = "text/xml";
     $this->assertEquals('xml', $parser->getFormat());
 }
示例#3
0
 /**
  * Parse the xml document and extract the needed data
  * @method parseDocument
  * @return [type]        [description]
  */
 public function parse()
 {
     $xml_path = storage_path() . DIRECTORY_SEPARATOR . 'documents' . DIRECTORY_SEPARATOR;
     $xml_file = $this->raw_file_path;
     $xml_raw_text = file_get_contents($xml_path . $xml_file);
     $parser = new Parser();
     $this->parsed = $parser->xml($xml_raw_text);
     $this->params = ['file_name' => $this->getFileName(), 'description' => $this->getDescription(), 'file_type' => $this->getFileType(), 'geometry_type' => $this->getGeometryType(), 'attributes' => $this->getAttributes(), 'responsible_parties' => $this->getResponsibleParties(), 'construction_procedures' => $this->getContstructionProcedures(), 'coverage_area' => $this->getCoverageArea(), 'dates' => $this->getDates(), 'date_last_updated' => @$this->parsed['mdDateSt'] ?: ''];
     return $this->params;
 }
示例#4
0
 /** @test */
 public function format_detection_json()
 {
     $parser = new Parser();
     $_SERVER['HTTP_CONTENT_TYPE'] = "application/json";
     $this->assertEquals('json', $parser->getFormat());
     $_SERVER['HTTP_CONTENT_TYPE'] = "application/x-javascript";
     $this->assertEquals('json', $parser->getFormat());
     $_SERVER['HTTP_CONTENT_TYPE'] = "text/javascript";
     $this->assertEquals('json', $parser->getFormat());
     $_SERVER['HTTP_CONTENT_TYPE'] = "text/x-javascript";
     $this->assertEquals('json', $parser->getFormat());
     $_SERVER['HTTP_CONTENT_TYPE'] = "text/x-json";
     $this->assertEquals('json', $parser->getFormat());
 }
 /** @test */
 public function format_detection_query_string()
 {
     $parser = new Parser();
     $_SERVER['HTTP_CONTENT_TYPE'] = "application/x-www-form-urlencoded";
     $this->assertEquals('querystr', $parser->getFormat());
 }
示例#6
0
<?php

require "../vendor/autoload.php";
use Nathanmac\Utilities\Parser\Parser;
$parser = new Parser();
echo "<h1>POST/PUT Payload AutoDetect - Example</h1>";
$parsed = $parser->payload('application/xml');
echo "<pre>";
print_r($parsed);
echo "</pre>";
示例#7
0
<?php

require "../vendor/autoload.php";
use Nathanmac\Utilities\Parser\Parser;
$parser = new Parser();
echo "<h1>YAML Example</h1>";
$parsed = $parser->yaml('---
message:
    to: "Jack Smith"
    from: "Jane Doe"
    subject: "Hello World"
    body: "Hello, whats going on..."
');
echo "<pre>";
print_r($parsed);
echo "</pre>";
示例#8
0
 /** @test */
 public function format_detection_bson()
 {
     $parser = new Parser();
     $_SERVER['HTTP_CONTENT_TYPE'] = "application/bson";
     $this->assertEquals('bson', $parser->getFormat());
 }
 public function geo($id)
 {
     $municipality = Municipality::find(intval($id));
     $parser = new Parser();
     return response()->json($parser->json($municipality['geo']));
 }
示例#10
0
<?php

require "../vendor/autoload.php";
use Nathanmac\Utilities\Parser\Parser;
$parser = new Parser();
echo "<h1>Serialised Object Example</h1>";
$parsed = $parser->serialize('a:1:{s:7:"message";a:4:{s:2:"to";s:10:"Jack Smith";s:4:"from";s:8:"Jane Doe";s:7:"subject";s:11:"Hello World";s:4:"body";s:24:"Hello, whats going on...";}}');
echo "<pre>";
print_r($parsed);
echo "</pre>";
 public function geo($id)
 {
     $village = Village::find(intval($id));
     $parser = new Parser();
     return response()->json($parser->json($village['geo']));
 }
 public function geo($id)
 {
     $county = County::find(intval($id));
     $parser = new Parser();
     return response()->json($parser->json($county['geo']));
 }
示例#13
0
 /** @test */
 public function format_detection_serialized()
 {
     $parser = new Parser();
     $_SERVER['HTTP_CONTENT_TYPE'] = "application/vnd.php.serialized";
     $this->assertEquals('serialize', $parser->getFormat());
 }
示例#14
0
<?php

require "../vendor/autoload.php";
use Nathanmac\Utilities\Parser\Parser;
$parser = new Parser();
echo "<h1>JSON Example</h1>";
$parsed = $parser->json('
    {
        "message": {
            "to": "Jack Smith",
            "from": "Jane Doe",
            "subject": "Hello World",
            "body": "Hello, whats going on..."
        }
    }');
echo "<pre>";
print_r($parsed);
echo "</pre>";
示例#15
0
<?php

require "../vendor/autoload.php";
use Nathanmac\Utilities\Parser\Parser;
$parser = new Parser();
echo "<h1>Query String Example</h1>";
$parsed = $parser->querystr('to=Jack Smith&from=Jane Doe&subject=Hello World&body=Hello, whats going on...');
echo "<pre>";
print_r($parsed);
echo "</pre>";
 public function geo($id)
 {
     $region = Region::find(intval($id));
     $parser = new Parser();
     return response()->json($parser->json($region['geo']));
 }
示例#17
0
<?php

require "../vendor/autoload.php";
use Nathanmac\Utilities\Parser\Parser;
$parser = new Parser();
echo "<h1>XML Example</h1>";
$parsed = $parser->xml("<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n                        <xml>\n                            <message>\n                                <to>Jack Smith</to>\n                                <from>Jane Doe</from>\n                                <subject>Hello World</subject>\n                                <body>Hello, whats going on...</body>\n                            </message>\n                        </xml>");
echo "<pre>";
print_r($parsed);
echo "</pre>";
示例#18
0
 /** @test */
 public function format_detection_defaults_to_json()
 {
     $parser = new Parser();
     $_SERVER['HTTP_CONTENT_TYPE'] = "somerandomstuff";
     $this->assertEquals('json', $parser->getFormat());
     $_SERVER['CONTENT_TYPE'] = "somerandomstuff";
     $this->assertEquals('json', $parser->getFormat());
 }