progetto201 API
Functions | Variables
plans.php File Reference

PLANS: manages plans (returns paths and names). More...

Functions

 get_plans ($path)
 Returns an array with plans data (plans are stored in "/static/img/maps"). More...
 

Variables

 $response = array('errors' => array())
 Prepare default response array with no errors. More...
 
 $mapspath = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "static" . DIRECTORY_SEPARATOR . "img" . DIRECTORY_SEPARATOR . "maps"
 Plan's path (file system) More...
 

Detailed Description

PLANS: manages plans (returns paths and names).

Client perspective:

The script calls get_plans() function to get the plans that are inside the plans folder

Error codes:

Since
01_01
Author
Stefano Zenaro (https://github.com/mario33881)

Function Documentation

◆ get_plans()

get_plans (   $path)

Returns an array with plans data (plans are stored in "/static/img/maps").

The function finds the path of each file inside the maps folder and checks the mime type:

if a files is an SVG file it gets stored inside the maps array as an associative array with these properties:

  • "name": file name
  • "path": path relative to the webserver's root ("/static/img/maps/<file.svg>")

Example: GET /api/plans/plans.php

{
"errors": [],
"data": [
{
"name": "colorful",
"path": "/static/img/maps/colorful.svg"
},
{
"name": "realistic",
"path": "/static/img/maps/realistic.svg"
}
]
}

Error codes:

  • 410: scandir() error: incorrect/non existing folder on path
  • 411: Unknown error during plans extraction
  • 412: No maps where found in $path
Since
01_01
Parameters
string$pathfile system path with plans
Returns
array $action_res array with errors or plans data

Variable Documentation

◆ $mapspath

$mapspath = $_SERVER['DOCUMENT_ROOT'] . DIRECTORY_SEPARATOR . "static" . DIRECTORY_SEPARATOR . "img" . DIRECTORY_SEPARATOR . "maps"

Plan's path (file system)

◆ $response

$response = array('errors' => array())

Prepare default response array with no errors.