Example #1
0
$gscs_array = gscsQuery();
$cnt_gscs = count($gscs_array);
$ft_array = fileTypeQuery();
$cnt_ft = count($ft_array);
$final_array = array();
// Create foor loop to merge the query arrays and search mongo
for ($i = 0; $i < $cnt_gscs; $i++) {
    for ($j = 0; $j < $cnt_ft; $j++) {
        if (empty($ft_array[$j])) {
            $gscs_ft_array = $gscs_array[$i];
        } else {
            $gscs_ft_array = array_merge($gscs_array[$i], $ft_array[$j]);
        }
        $mongo_doc_arrays = queryMongo($gscs_ft_array);
        for ($k = 0; $k < count($mongo_doc_arrays); $k++) {
            $mongo_doc_arrays[$i] = fixDocArray($mongo_doc_arrays[$i]);
        }
        if ($i == 0) {
            $final_array["chapters"] = $mongo_doc_arrays[0];
        } else {
            if ($i == 1) {
                $final_array["textbooks"] = $mongo_doc_arrays[1];
            } else {
                if ($i == 2) {
                    $final_array["activities"] = $mongo_doc_arrays[2];
                } else {
                    if ($i == 3) {
                        $final_array["dictionary"] = $mongo_doc_arrays[3];
                    }
                }
            }
Example #2
0
<?php

/*
 * File:			openTimeline.php
 *
 * Description:		This script accepts the MongoId of a timeline as a GET request 
 *					and retrieves all of the associated timeline elements in the form of an 
 *					associative array. 
 *					Once retrieving the elements, the array is "fixed" via the utility function
 *					fixDocArray() and then returned.
*/
require_once 'mongoSetup.php';
$timelineID = $_GET['$id'];
// the post is coming from index2.js
$timelineElementsArray = getTimelineElements($timelineID);
$timelineElementsArray = fixDocArray($timelineElementsArray);
echo json_encode($timelineElementsArray);