/** * Index Page for this controller. * * Maps to the following URL * http://example.com/index.php/welcome * - or - * http://example.com/index.php/welcome/index * - or - * Since this controller is set as the default controller in * config/routes.php, it's displayed at http://example.com/ * * So any other public methods not prefixed with an underscore will * map to /index.php/welcome/<method_name> * @see http://codeigniter.com/user_guide/general/urls.html */ public function index($page = 'main') { $data = array(); $docs_path = $this->config->item('docs_path') ? $this->config->item('docs_path') : 'https://raw.githubusercontent.com/GSA/project-open-data-dashboard/master/documentation/'; $docs_path = $docs_path . $page . '.md'; $docs = @file_get_contents($docs_path); if ($docs) { $markdown_extra = new Michelf\MarkdownExtra(); $markdown_text = $docs; $markdown_text = $markdown_extra->transform($markdown_text); $markdown_text = linkToAnchor($markdown_text); $data['docs_html'] = $markdown_text; } else { $data['docs_html'] = "The documentation file is unavailable"; } $this->load->view('docs', $data); }
public function detail($id, $milestone = null, $status = null, $status_id = null) { $this->load->helper('api'); $this->load->model('campaign_model', 'campaign'); $markdown_extra = new Michelf\MarkdownExtra(); $milestones = $this->campaign->milestones_model(); $selected_milestone = $this->input->get_post('milestone', TRUE) ? $this->input->get_post('milestone', TRUE) : $milestone; $selected_category = $this->input->get_post('highlight', TRUE) ? $this->input->get_post('highlight', TRUE) : null; $milestone = $this->campaign->milestone_filter($selected_milestone, $milestones); $view_data = array(); // pass milestones data model $view_data['milestone'] = $milestone; // pass tracker data model $view_data['tracker_model'] = $this->campaign->tracker_model(); $this->db->select('*'); $this->db->where('id', $id); $query = $this->db->get('offices'); if ($query->num_rows() > 0) { $view_data['office'] = $query->row(); // Get note data $notes = $this->campaign->get_notes($view_data['office']->id, $milestone->selected_milestone); $view_data['note_model'] = $this->campaign->note_model(); if ($notes->num_rows() > 0) { $note_list = array(); foreach ($notes->result() as $note) { $note_field = 'note_' . $note->field_name; $note_list[$note_field] = json_decode($note->note); if (!empty($note_list[$note_field]->current->note)) { $note_html = $note_list[$note_field]->current->note; $note_html = $markdown_extra->transform($note_html); $note_html = linkToAnchor($note_html); $note_list[$note_field]->current->note_html = $note_html; } else { $note_list[$note_field]->current->note_html = null; } } $view_data['notes'] = $note_list; } // Get crawler data $view_data['office_campaign'] = $this->campaign->datagov_office($view_data['office']->id, $milestone->selected_milestone, null, $status_id); // Get the IDs of daily crawls before and after this date $crawls_before = $this->campaign->datagov_office_crawls($view_data['office']->id, $milestone->selected_milestone, $view_data['office_campaign']->status_id, '<', '5'); $crawls_after = $this->campaign->datagov_office_crawls($view_data['office']->id, $milestone->selected_milestone, $view_data['office_campaign']->status_id, '>', '5'); $view_data['nearby_crawls'] = array_merge(array_reverse($crawls_before), $crawls_after); // If we have a blank slate, populate the data model if (empty($view_data['office_campaign'])) { $view_data['office_campaign'] = $this->campaign->datagov_model(); } // Make sure tracker data uses full tracker model if (isset($view_data['office_campaign']->tracker_fields)) { $tracker_fields = $view_data['office_campaign']->tracker_fields ? json_decode($view_data['office_campaign']->tracker_fields) : new stdClass(); foreach ($view_data['tracker_model'] as $field_name => $value) { $tracker_fields->{$field_name} = isset($tracker_fields->{$field_name}) ? $tracker_fields->{$field_name} : null; } $view_data['office_campaign']->tracker_fields = json_encode($tracker_fields); } if (!empty($view_data['office_campaign']->datajson_status)) { $view_data['office_campaign']->expected_datajson_url = !empty($view_data['office_campaign']->datajson_status['url']) ? $view_data['office_campaign']->datajson_status['url'] : ''; $view_data['office_campaign']->expected_datajson_status = (object) json_decode($view_data['office_campaign']->datajson_status); } if ($this->config->item('show_all_offices')) { // Get sub offices $this->db->select('*'); $this->db->from('offices'); $this->db->join('datagov_campaign', 'datagov_campaign.office_id = offices.id', 'left'); $this->db->where('offices.parent_office_id', $view_data['office']->id); $this->db->order_by("offices.name", "asc"); $query = $this->db->get(); if ($query->num_rows() > 0) { $view_data['child_offices'] = $query->result(); } } } // selected tab $view_data['selected_category'] = $selected_category; // pass tracker section breakdown model $view_data['section_breakdown'] = $this->campaign->tracker_sections_model(); // pass config variable $view_data['config'] = array('max_remote_size' => $this->config->item('max_remote_size'), 'archive_dir' => $this->config->item('archive_dir')); //var_dump($view_data['office_campaign']); exit; $this->load->view('office_detail', $view_data); }
public function detail($id, $milestone = null, $status = null, $status_id = null) { $this->load->helper('api'); $this->load->model('campaign_model', 'campaign'); $markdown_extra = new Michelf\MarkdownExtra(); $milestones = $this->campaign->milestones_model(); if ($this->session->userdata('permissions') !== 'admin') { $selected_milestone = $this->get_default_milestone(); } else { $selected_milestone = $this->input->get_post('milestone', TRUE) ? $this->input->get_post('milestone', TRUE) : $milestone; } $selected_category = $this->input->get_post('highlight', TRUE) ? $this->input->get_post('highlight', TRUE) : null; $milestone = $this->campaign->milestone_filter($selected_milestone, $milestones); $selected_milestone_index = array_search($selected_milestone, array_keys($milestones)) + 1; $view_data = array(); // pass milestones data model $view_data['milestone'] = $milestone; // pass tracker data model $view_data['tracker_model'] = $this->campaign->tracker_model($selected_milestone); // indicate "tracker fields" that are placeholders for tables, not actual fields $view_data['tracker_field_tables'] = array('pa_bureau_it_leadership_table', 'pa_cio_governance_board_table', ''); $this->db->select('*'); $this->db->where('id', $id); $query = $this->db->get('offices'); if ($query->num_rows() > 0) { $view_data['office'] = $query->row(); // Get note data $notes = $this->campaign->get_notes($view_data['office']->id, $milestone->selected_milestone); $view_data['note_model'] = $this->campaign->note_model(); if ($notes->num_rows() > 0) { $note_list = array(); foreach ($notes->result() as $note) { $note_field = 'note_' . $note->field_name; $note_list[$note_field] = json_decode($note->note); if (!empty($note_list[$note_field]->current->note)) { $note_html = $note_list[$note_field]->current->note; $note_html = $markdown_extra->transform($note_html); $note_html = linkToAnchor($note_html); $note_list[$note_field]->current->note_html = $note_html; } else { $note_list[$note_field]->current->note_html = null; } } $view_data['notes'] = $note_list; } // Get crawler data $view_data['office_campaign'] = $this->campaign->ciogov_office($view_data['office']->id, $milestone->selected_milestone, null, $status_id); // Get the IDs of daily crawls before and after this date $crawls_before = $this->campaign->ciogov_office_crawls($view_data['office']->id, $milestone->selected_milestone, $view_data['office_campaign']->status_id, '<', '5'); $crawls_after = $this->campaign->ciogov_office_crawls($view_data['office']->id, $milestone->selected_milestone, $view_data['office_campaign']->status_id, '>', '5'); $view_data['nearby_crawls'] = array_merge(array_reverse($crawls_before), $crawls_after); // If we have a blank slate, populate the data model if (empty($view_data['office_campaign'])) { $view_data['office_campaign'] = $this->campaign->ciogov_model(); } // Make sure tracker data uses full tracker model if (isset($view_data['office_campaign']->tracker_fields)) { $tracker_fields = $view_data['office_campaign']->tracker_fields ? json_decode($view_data['office_campaign']->tracker_fields) : new stdClass(); $clone_tracker_model = clone $view_data['tracker_model']; foreach ($view_data['tracker_model'] as $field_name => $value) { //disable tracker field in data+model if not in correct milestone if (isset($value->active) && intval($selected_milestone_index) < intval($value->active)) { unset($tracker_fields->{$field_name}); unset($clone_tracker_model->{$field_name}); } else { $tracker_fields->{$field_name} = isset($tracker_fields->{$field_name}) ? $tracker_fields->{$field_name} : null; } } $view_data['tracker_model'] = $clone_tracker_model; //updates model if any tracker fields were disabled $view_data['office_campaign']->tracker_fields = json_encode($tracker_fields); } //$view_data['bureau_governance_detail'] = $this->getBureauGovernanceDetail(); $view_data = $this->getRecommendationDetail($view_data, $milestone->selected_milestone); if ($this->config->item('show_all_offices')) { // Get sub offices $this->db->select('*'); $this->db->from('offices'); $this->db->join('ciogov_campaign', 'ciogov_campaign.office_id = offices.id', 'left'); $this->db->where('offices.parent_office_id', $view_data['office']->id); $this->db->order_by("offices.name", "asc"); $query = $this->db->get(); if ($query->num_rows() > 0) { $view_data['child_offices'] = $query->result(); } } } // selected tab $view_data['selected_category'] = $selected_category; // pass tracker section breakdown model $view_data['section_breakdown'] = $this->campaign->tracker_sections_model($selected_milestone); // pass config variable $view_data['config'] = array('max_remote_size' => $this->config->item('max_remote_size'), 'archive_dir' => $this->config->item('archive_dir')); //var_dump($view_data) exit; $this->load->view('office_detail', $view_data); }