Create more documentation (#7627)
* Documentation, format class, no modification.
This commit is contained in:
@@ -51,6 +51,21 @@
|
||||
$label_required = $text['label-required'];
|
||||
|
||||
//define the functions
|
||||
/**
|
||||
* Converts a multi-dimensional array to CSV format.
|
||||
*
|
||||
* This function assumes that the input array is a collection of devices,
|
||||
* where each device has an array of columns. The function will take all
|
||||
* column headers from all devices and use them as the header row in the
|
||||
* generated CSV file.
|
||||
*
|
||||
* If any duplicate column headers are found, they will be removed by
|
||||
* truncating at the pipe character (|).
|
||||
*
|
||||
* @param array &$array A multi-dimensional array of device data.
|
||||
*
|
||||
* @return string The CSV formatted data as a string. Returns null if the input array is empty.
|
||||
*/
|
||||
function array2csv(array &$array) {
|
||||
if (count($array) == 0) {
|
||||
return null;
|
||||
@@ -86,6 +101,15 @@
|
||||
return ob_get_clean();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends HTTP headers to force a file download.
|
||||
*
|
||||
* This function sets various HTTP headers to instruct the browser to download the file instead of displaying it in the browser window.
|
||||
*
|
||||
* @param string $filename The filename to use for the downloaded file.
|
||||
*
|
||||
* @return void No return value. This function only sends HTTP headers and does not generate any output.
|
||||
*/
|
||||
function download_send_headers($filename) {
|
||||
// disable caching
|
||||
$now = gmdate("D, d M Y H:i:s");
|
||||
|
||||
@@ -38,18 +38,6 @@
|
||||
$language = new text;
|
||||
$text = $language->get();
|
||||
|
||||
//built in str_getcsv requires PHP 5.3 or higher, this function can be used to reproduct the functionality but requirs PHP 5.1.0 or higher
|
||||
if (!function_exists('str_getcsv')) {
|
||||
function str_getcsv($input, $delimiter = ",", $enclosure = '"', $escape = "\\") {
|
||||
$fp = fopen("php://memory", 'r+');
|
||||
fputs($fp, $input);
|
||||
rewind($fp);
|
||||
$data = fgetcsv($fp, null, $delimiter, $enclosure, $escape);
|
||||
fclose($fp);
|
||||
return $data;
|
||||
}
|
||||
}
|
||||
|
||||
//set the max php execution time
|
||||
ini_set('max_execution_time',7200);
|
||||
|
||||
@@ -225,7 +213,15 @@
|
||||
}
|
||||
|
||||
//get the parent table
|
||||
function get_parent($schema,$table_name) {
|
||||
/**
|
||||
* Retrieves the parent table name for a given table in the schema.
|
||||
*
|
||||
* @param array $schema An associative array of schema definitions
|
||||
* @param string $table_name The name of the table to retrieve the parent for
|
||||
*
|
||||
* @return string|null The parent table name if found, otherwise null
|
||||
*/
|
||||
function get_parent($schema, $table_name) {
|
||||
foreach ($schema as $row) {
|
||||
if ($row['table'] == $table_name) {
|
||||
return $row['parent'];
|
||||
|
||||
+1491
-1357
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user