Beispiel #1
0
 /**
  * Function: inner
  * @param int $screenid - The id of the screen you wish to load
  *
  * This function differs from the index function in that this function, that is
  * /screen/inner is called by the inner IFRAME.
  */
 public function inner($screenid)
 {
     //If no parameter, redirect somewhere else
     if (!isset($screenid)) {
         redirect('/');
     }
     // Load the screen model
     $this->load->model('screen_model');
     $screen = new Screen_model();
     //Load variables of screen model type
     $screen->load_model($screenid);
     $data['id'] = $screenid;
     // Check for sleep mode to determine the view.  If the screen is asleep,
     // just use the default three_col.  If the screen should be awake, set up
     // a $data variable and set the numcols to the number of columns and the
     // zoom level to the custom zoom level.
     if ($screen->is_asleep()) {
         $data['numcols'] = 3;
         $data['template'] = 'three_col';
     } else {
         $data['numcols'] = $screen->get_num_columns();
         $data['zoom'] = $screen->zoom;
     }
     // Call the screen_template view and pass the $data variable.  Each
     // element of the $data array will become a variable, i.e. $data['id'] will
     // become $id in the views
     $this->load->view('includes/screen_template', $data);
 }
Beispiel #2
0
 /**
  * Function: json
  * @param int $screen_id - The id of the screen whose updates you need to load
  *
  * This is one of the biggest and most complicated functions in the application.
  * It generates the JSON data update for every screen.  More specifically, it
  * loads a screen, ensures that it should be awake at this moment, and gets all
  * the blocks.  For each block it finds the agency-stop pairs and calls the
  * appropriate APIs to get the real-time transit data.  It assembles all this
  * information, including the custom block data and the CaBi status and prints
  * it all out as one JSON response.
  */
 public function json($screen_id)
 {
     // Load the Update model and the screen model
     $this->load->model('update_model');
     $update = new Update_model();
     $this->load->model('screen_model');
     $screen = new Screen_model();
     // Fill this variable with the screen values.
     $screendata = $this->screen_model->get_screen_values($screen_id, true);
     //Load variable of screen model type
     $screen->load_model($screen_id);
     // We will collect all the data to publish via JSON in the $update variable,
     // so set a few of its static properties based on the screendata variable.
     $update->screen_name = $screendata['settings'][0]->name;
     $update->screen_version = $screendata['settings'][0]->screen_version;
     $wmata_key = $screendata['settings'][0]->wmata_key;
     // Update the last_checkin value for this screen.  This allows us to ensure
     // that our screens are regularly calling for updates.
     $this->_update_timestamp($screen_id);
     // If the screen should be asleep right now, print that in JSON and do not
     // bother to load any real-time data.
     if ($screen->is_asleep()) {
         $update->sleep = true;
         print json_encode($update);
     } else {
         //Gather all the necessary data into the $update variable
         //and then output the variable as JSON
         // This helper contains the fuctions that call the various agency APIs
         $this->load->helper('transit_functions');
         // Obviously this screen should be awake.
         $update->sleep = false;
         $stopname = '';
         // For every block...  (remember that one block can contain more than one
         // stop or CaBi station!)
         foreach ($screendata['blocks'] as $block) {
             $stops = $block->stop;
             //Set up (or clear) variables to handle the various data
             $vehicles = array();
             unset($bike);
             $bikes = array();
             unset($override);
             // For each of the agency-stop pairs for this block...
             foreach ($stops as $stop) {
                 // ... get the arrival predictions for each agency.
                 // Collected the line exclusions for this block
                 $exclusions = array();
                 if (isset($stop['exclusions'])) {
                     $exclusions = explode(',', $stop['exclusions']);
                 }
                 // For this agency-stop pair, check to see what mode it is and then
                 // call the approriate API function.
                 switch ($this->_get_agency_type($stop['agency'])) {
                     case 'bus':
                         $newset = array();
                         // Get the bus prediction data back.  This get_bus_predictions
                         // function covers ART, WMATA, DC Circulator, Prince George's TheBus and Shuttle UM
                         $set = get_bus_predictions($stop['stop_id'], $wmata_key, $stop['agency']);
                         if (isset($set[0])) {
                             // Loop through the results.  If the bus line is not in the
                             // exclusions array, add it to a new set.  We will abandon the
                             // excluded lines.
                             foreach ($set as $b) {
                                 if (!in_array(strtoupper($b['route']), $exclusions)) {
                                     $newset[] = $b;
                                 }
                             }
                             $vehicles[] = $newset;
                         }
                         break;
                     case 'subway':
                         // Get predictions from WMATA for rail station with id $stop['stop_id').
                         $vehicles[] = get_rail_predictions($stop['stop_id'], $wmata_key);
                         break;
                     case 'cabi':
                         // For each bike station, get the status.  Notice that the data
                         // will be put into the $bikes array since each block may have
                         // multiple CaBi stations.
                         $bikes[] = get_cabi_status($stop['stop_id']);
                         break;
                     case 'custom':
                         // This is where the custom block data goes.  There is no clean up.
                         $override = $block->custom_body;
                         break;
                 }
             }
             // Combine the different agency predictions for this stop
             // into a single array and sort by time.  Make sure you have actual
             // predictions first!
             if (count($vehicles) > 0) {
                 if ($this->_get_agency_type($stop['agency']) == 'bus') {
                     // Combine multi-agency data for buses, then combine same routes
                     $stopdata = combine_agencies($vehicles);
                     $stopdata = $this->_combine_duplicates($stopdata);
                 } elseif ($this->_get_agency_type($stop['agency']) == 'subway') {
                     // Combine same routes data for subway
                     $stopdata = $vehicles[0];
                     $stopdata = $this->_combine_duplicates($stopdata);
                 } else {
                     $stopdata = $vehicles[0];
                 }
                 // If there is a limit to the number of arrival lines to list
                 // at any bus stop, remove the extra vehicles from the array
                 if (isset($block->limit) && isset($stopdata) && count($stopdata) > $block->limit && $block->limit > 0) {
                     array_splice($stopdata, $block->limit);
                 }
                 // Set the stop name to the API stop name that comes first.  WMATA and
                 // ART will have different descriptions for the same stop, but we will
                 // just use the first name instead.  You can override this with a
                 // custom stop name in the backend, of course.
                 if (isset($vehicles[0][0]['stop_name'])) {
                     $stopname = $vehicles[0][0]['stop_name'];
                 }
             }
             // If we're working with CaBi here
             if (isset($bike)) {
                 $stopdata = $bike;
                 $stopname = $bike['stop_name'];
             }
             // Set the stop's custom name
             if (strlen(trim($block->custom_name)) > 0) {
                 $stopname = $block->custom_name;
             }
             // If we're working with bikes, put all the relevant block data into
             // an array.  Otherwise, do the same for a bus or Metro block.
             if (isset($bikes) && count($bikes) > 0) {
                 $stopdata = array('id' => $block->id, 'name' => clean_destination($stopname), 'type' => $this->_get_agency_type($stop['agency']), 'column' => (int) $block->column, 'order' => (int) $block->position, 'stations' => $bikes);
             } else {
                 $stopdata = array('id' => $block->id, 'name' => clean_destination($stopname), 'type' => $this->_get_agency_type($stop['agency']), 'column' => (int) $block->column, 'order' => (int) $block->position, 'vehicles' => $stopdata);
             }
             // If this block is a custom block, put in the data here.
             if (isset($override)) {
                 $stopdata = array('id' => $block->id, 'name' => clean_destination($stopname), 'type' => $this->_get_agency_type($stop['agency']), 'column' => (int) $block->column, 'order' => (int) $block->position, 'custom_body' => $override);
             }
             // Add all the stop data for this block to the stops array in the $update
             // variable.
             $update->stops[] = $stopdata;
         }
         // Print out the entire $update variable encoded as JSON
         print json_encode($update);
     }
 }
 /**
  * Function: save
  *
  * @param int $id - the id of the screen for which data should be saved
  *
  * This function saves configuration changes for screens.  Most of it is
  * straightforward.  Since the blocks and agency-stop pairs are stored in
  * different tables, the function pulls those data out and saves them in their
  * respective tables.
  *
  */
 public function save($id = 0)
 {
     // MSC check that a new id does not clash with an already-created ID
     // Load the screen model
     $this->load->model('screen_model');
     // Create a placeholder screen that will be filled with variables and then saved.
     $updatevals = new Screen_model();
     $updatevals->id = $id;
     // Admins can't own screens
     if (!$this->session->userdata('admin')) {
         $updatevals->user_id = $this->session->userdata('id');
     }
     // Collect all the posted variables from the HTML form into one variable for
     // easier access.  Delete the submit "variable", which is really just the
     // submit button.
     $postvars = $this->input->post();
     unset($postvars->submit);
     // For each of the variables, check to see if the variable name ends with _op (opening)
     // or _cl (closing).  If so, these variables are the sleep and wake times for the screen.
     // We only want to write them if they have values.  Beware that Code Igniter
     // may treat blank submission as an empty string, which cannot be written
     // to a timestamp type in PostgreSQL.
     foreach ($postvars as $key => $value) {
         if (substr($key, strlen($key) - 3) == '_op' || substr($key, strlen($key) - 3) == '_cl') {
             if (strlen($value) > 0) {
                 $updatevals->{$key} = $value;
             }
         } else {
             $updatevals->{$key} = $value;
         }
     }
     // Call a function that now writes these values to the database.
     $updatevals->save_screen_values($id);
     // Redirect the user back to the edit screen to see the changes he just
     // made.  If he created a new screen or changed the screen id, he may
     // be directed back to the screen listing page.
     if ($updatevals->id == $id) {
         redirect("screen_admin/edit/{$id}");
     } else {
         redirect('screen_admin');
     }
 }
Beispiel #4
0
                    

                
    <div class="center_content">  
    
    
    
<div class="left_content">
    
   <!--              
 <div class="sidebarmenu">
            
            
 <?php 
$this->load->model('screen_model');
$screen_model = new Screen_model();
$screen_modules = $screen_model->get_all_module();
foreach ($screen_modules as $module) {
    $module_id = $module->id;
    if ($this->lang->lang() == 'ar') {
        $module_name = $module->name_ar;
    } else {
        $module_name = $module->name;
    }
    $module_url = base_url() . $this->lang->lang() . '/' . $module->url;
    echo "<a class='menuitem submenuheader'  href='{$module_url}'>{$module_name}</a>";
    $screen_screens = $screen_model->get_all_screen($module_id);
    $count_screens = count($screen_screens);
    if ($count_screens > 0) {
        echo "<div class='submenu'><ul>";
        foreach ($screen_screens as $screen) {
Beispiel #5
0
 public function drpdwn_screen_module($selected_id = 0, $drpdwn_name, $are_disabled = '')
 {
     $drpdwn = "<select  class='input_pr'  name='{$drpdwn_name}' id='{$drpdwn_name}' {$are_disabled}>";
     $drpdwn = $drpdwn . "<option value='0'></option>";
     $screen_model = new Screen_model();
     $arr = $screen_model->get_all_module();
     foreach ($arr as $record) {
         $are_selected = "";
         if ($selected_id == $record->id) {
             $are_selected = "selected='selected'";
         }
         $drpdwn = $drpdwn . "<option value='" . $record->id . "' {$are_selected}>" . $record->name . "</option>";
     }
     $drpdwn = $drpdwn . "</select>";
     echo $drpdwn;
 }
Beispiel #6
0
						<li><a class="ajax-link" href="chart.html"><i class="icon-list-alt"></i><span class="hidden-tablet"> Charts</span></a></li>
						<li><a class="ajax-link" href="typography.html"><i class="icon-font"></i><span class="hidden-tablet"> Typography</span></a></li>
						<li><a class="ajax-link" href="gallery.html"><i class="icon-picture"></i><span class="hidden-tablet"> Gallery</span></a></li>
						<li class="nav-header hidden-tablet">Sample Section</li>
						<li><a class="ajax-link" href="table.html"><i class="icon-align-justify"></i><span class="hidden-tablet"> Tables</span></a></li>
						<li><a class="ajax-link" href="calendar.html"><i class="icon-calendar"></i><span class="hidden-tablet"> Calendar</span></a></li>
						<li><a class="ajax-link" href="grid.html"><i class="icon-th"></i><span class="hidden-tablet"> Grid</span></a></li>
						<li><a class="ajax-link" href="file-manager.html"><i class="icon-folder-open"></i><span class="hidden-tablet"> File Manager</span></a></li>
						<li><a href="tour.html"><i class="icon-globe"></i><span class="hidden-tablet"> Tour</span></a></li>
						<li><a class="ajax-link" href="icon.html"><i class="icon-star"></i><span class="hidden-tablet"> Icons</span></a></li>
						<li><a href="error.html"><i class="icon-ban-circle"></i><span class="hidden-tablet"> Error Page</span></a></li>
						<li><a href="login.html"><i class="icon-lock"></i><span class="hidden-tablet"> Login Page</span></a></li>
						 -->
				<?php 
$this->load->model('screen_model');
$screen_model = new Screen_model();
$screen_modules = $screen_model->get_all_module();
foreach ($screen_modules as $module) {
    $module_id = $module->id;
    if ($this->lang->lang() == 'ar') {
        $module_name = $module->name_ar;
    } else {
        $module_name = $module->name;
    }
    $module_url = base_url() . $this->lang->lang() . '/' . ADMIN . '/' . $module->url;
    echo "\t\t\t\t\t\t<li><a class='ajax-link' href='{$module_url}'><span class='hidden-tablet'> {$module_name}</span></a></li>";
    $screen_screens = $screen_model->get_all_screen($module_id);
    $count_screens = count($screen_screens);
    if ($count_screens > 0) {
        echo "<ul>";
        foreach ($screen_screens as $screen) {