function addNew() { global $filename; global $timelines; global $timelineArray; echo "new timeline create"; $info = array("name" => $_POST["lesson_title"], "line" => $_POST["items_array"]); $timelines->insert($info); $info = fixDocId($info); //Add new timeline information into $file// $timelineArray[] = $info; }
<?php require_once 'mongoSetup.php'; //Glob attempt. It technically works, in the worst way. $filename = globber(); //echo $filename; if ($filename) { $mongodoc = searchMongoByFilename($filename); $mongodoc = fixDocId($mongodoc); echo json_encode($mongodoc); } else { echo "No file found"; } function globber() { $dir_iterator = new RecursiveDirectoryIterator("../content/"); $iterator = new RecursiveIteratorIterator($dir_iterator); if (isset($_GET['search']) && $_GET['search'] != '') { foreach ($iterator as $filepath) { $filename = $filepath . '/*' . $_GET['search']; // ../content/*Classroom* foreach (ciGlob($filename . '*') as $found) { if ($found) { echo basename($found); return basename($found); } } } } return null; }
function fixDocArray($docArray) { $docCount = count($docArray); for ($i = 0; $i < $docCount; $i++) { $docArray[$i] = fixDocId($docArray[$i]); } return $docArray; }