Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 4e06de0c authored by VIEVILLE Thierry's avatar VIEVILLE Thierry
Browse files

from makefile

parent d00a8062
Branches
Tags
No related merge requests found
This diff is collapsed.
all : all :
php update.php php update.php
make -C ../..
...@@ -34,9 +34,24 @@ ...@@ -34,9 +34,24 @@
$data_sheets_fields_index = array(); $data_sheets_fields_index = array();
// Loads the sheets and generates the indexes // Loads the sheets and generates the indexes
{ {
// Gets a CSV file and properly manages \n in enclosure
function file_get_csv_contents($location, $delimiter = ',', $enclosure = '"', $escape = '\\') {
$text = file_get_contents($location);
for($in = false, $ii = 0; $ii < strlen($text); $ii++) {
if (!$in && $text[$ii] == $enclosure) {
$in = true;
} else if ($in && $text[$ii] == $enclosure && ($ii > 0 && $text[$ii-1] != $escape)) {
$in = false;
}
if ($in && $text[$ii] == "\n") $text[$ii] = "\v";
}
$data = array_map('str_getcsv', explode("\n", $text));
foreach($data as &$row) foreach($row as &$cell) $cell = str_replace("\v", "\n", $cell);
return $data;
}
foreach($data_sheets_IDS as $sheetName => $sheetID) { foreach($data_sheets_IDS as $sheetName => $sheetID) {
// Loads the contents // Loads the contents
$data_csv_contents[$sheetName] = array_map("str_getcsv", explode("\n", file_get_contents("https://docs.google.com/spreadsheets/d/".$sheetID."/export?exportFormat=csv"))); $data_csv_contents[$sheetName] = file_get_csv_contents("https://docs.google.com/spreadsheets/d/".$sheetID."/export?exportFormat=csv");
$data_sheets_fields_index[$sheetName] = array(); $data_sheets_fields_index[$sheetName] = array();
foreach($data_sheets_fields[$sheetName] as $fieldName) foreach($data_sheets_fields[$sheetName] as $fieldName)
for($index = 0; $index < count($data_csv_contents[$sheetName][0]); $index++) for($index = 0; $index < count($data_csv_contents[$sheetName][0]); $index++)
...@@ -47,9 +62,9 @@ ...@@ -47,9 +62,9 @@
// Now displays all data as HTML file // Now displays all data as HTML file
{ {
$html = "<html><head><meta charset='UTF-8'/></head><body>\n"; $html = "<html><head><meta charset='UTF-8'/></head><body style='max-width:1100px;'>\n";
foreach($data_sheets_fields as $sheetName => $fieldNames) { foreach($data_sheets_fields as $sheetName => $fieldNames) {
$html .= "<h2> Table des <a target='_blank' href='https://docs.google.com/spreadsheets/d/".$data_sheets_IDS[$sheetName]."'>". $sheetName."</a></h2><table style='max-width:1000px;border:1px'>\n <tr>"; $html .= "<h2> Table des <a target='_blank' href='https://docs.google.com/spreadsheets/d/".$data_sheets_IDS[$sheetName]."'>". $sheetName."</a></h2><table style='max-width:1100px;'>\n <tr>";
foreach($fieldNames as $fieldName) foreach($fieldNames as $fieldName)
$html .= "<th>".$fieldName."</th>"; $html .= "<th>".$fieldName."</th>";
$html .= "</tr>\n"; $html .= "</tr>\n";
...@@ -59,7 +74,7 @@ ...@@ -59,7 +74,7 @@
if (preg_match("/^URL/", $fieldName) && get_data($sheetName, $fieldName, $index) != "") if (preg_match("/^URL/", $fieldName) && get_data($sheetName, $fieldName, $index) != "")
$html .= "<td><a target='_blank'' href='".get_data($sheetName, $fieldName, $index)."'>url</a></td>"; $html .= "<td><a target='_blank'' href='".get_data($sheetName, $fieldName, $index)."'>url</a></td>";
else else
$html .= "<td>".get_data($sheetName, $fieldName, $index)."</td>"; $html .= "<td style='word-wrap: break-word'>".get_data($sheetName, $fieldName, $index)."</td>";
$html .= "</tr>\n"; $html .= "</tr>\n";
} }
$html .= "</table>"; $html .= "</table>";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment