setSpreadsheetKey('0AuPh9cI948YxdGkxdFMzQmdiamZKWnFQdW9ZbkFyUWc');
$query->setWorksheetId('od6');
$wsEntry = $service->getWorksheetEntry($query);
} catch (Exception $e) {
die('ERROR: ' . $e->getMessage());
}
$glossary_php_last_updated = strtotime($wsEntry->updated); // Dynamic
$glossary_html_last_updated = strtotime(date("F d Y H:i:s.", filemtime('glossary.html'))); // Static
// Make sure no glossary user activated functions are called
if (empty($study_set) && empty($glossary_term_ids) && empty($study_mode)) {
// Redirect to previously generated static html page if no recent Google Spreadsheets update
if ($glossary_php_last_updated < $glossary_html_last_updated) {
header('Location: glossary.html');
exit;
}
// Else the rest of the php script below will run and overwrite glossary.html file
}
?>
setSpreadsheetKey("0AuPh9cI948YxdGkxdFMzQmdiamZKWnFQdW9ZbkFyUWc");
$query->setWorksheetId("od6");
} catch (Exception $e) {
die('ERROR: ' . $e->getMessage());
}
// Get a list of the 2nd, 3rd, and 4th rows (glossary_media, glossary_name, glossary_definition) and put into big arrays
$query->setReturnEmpty(true);
$query->setMinCol(2);
$query->setMaxCol(4);
$query->setMinRow(2);
$cellFeed = $service->getCellFeed($query);
// Populate the data_arrays to generate the Javascript data
$array_counter = 1;
$special_chars = array("\n");
$replace_special_chars = array(" ");
foreach ($cellFeed as $cellEntry) {
if ($array_counter == 1) {
$glossary_medias[] = str_replace(" ", "", $cellEntry->getCell()->getText());
} elseif ($array_counter == 2) {
$glossary_names[] = $cellEntry->getCell()->getText();
} elseif ($array_counter == 3) {
$glossary_definitions[] = str_replace($special_chars, $replace_special_chars, $cellEntry->getCell()->getText());
}
// Reset array counter when all of row data is entered
$array_counter < 3 ? $array_counter++ : $array_counter = 1;
}
// Autocomplete search function
$all_glossary_tags = "
\n";
// Write/overwrite to all_glossary_tags.inc
file_put_contents("./glossary_terms/all_glossary_tags.inc", $all_glossary_tags);
// Output javascript autocomplete array and function
echo $all_glossary_tags;
?>