コード例 #1
0
ファイル: NightlyData.php プロジェクト: jsnshrmn/Suma
 /**
  * Get list of active initiatives and populate $locations array
  * @return array
  * @access private
  */
 private function activeInitiatives()
 {
     $active = array();
     try {
         $io = new ServerIO();
         $inits = $io->getInitiatives();
         foreach ($inits as $key => $init) {
             if ($init['enabled'] == 1) {
                 $id = $init['id'];
                 $title = $init['title'];
                 $active[$id] = $title;
                 foreach ($init['dictionary']['locations'] as $key => $locData) {
                     $locID = $locData['id'];
                     $locTitle = $locData['title'];
                     $this->locations[$id][$locID] = $locTitle;
                 }
             }
         }
     } catch (Exception $e) {
         throw $e;
     }
     return $active;
 }
コード例 #2
0
ファイル: initiatives.php プロジェクト: jsnshrmn/Suma
<?php

header('Content-type: application/json');
require_once 'ServerIO.php';
require_once 'setHttpCode.php';
try {
    $io = new ServerIO();
    $initiatives = $io->getInitiatives();
    echo json_encode($initiatives);
} catch (Exception $e) {
    $message = (string) $e->getMessage();
    $code = (int) $e->getCode();
    $header = setHttpCode($code);
    // Set Header
    header($header);
    // Return JSON with display data
    die(json_encode(array('message' => $message)));
}