public function index() { $docId = $this->uri->segment(2); $docObj = new Document_Model($docId); $modules = $docObj->getModules(); if (!is_array($modules)) { $location = FCPATH . $this->config->item('dataDir') . $docObj->getLocation(); if (is_file($location)) { $data = array('id' => $docId, 'file' => $location); $this->load->view('editor/editor_view', $data); } else { $this->session->set_flashdata('error', 'There was an error trying to open this file for editing.'); redirect($_SERVER['HTTP_REFERER']); } } $mods = array(); foreach ($modules as $mod) { $modObj = new Module_Model($mod->id); $category = $modObj->getCategory(); $loc = $modObj->getLocation(); $location = FCPATH . $this->config->item('moduleDir') . $category . '/files/' . $loc; $mods[] = array('id' => $mod->id, 'category' => $category, 'location' => $location); } $data = array('id' => $docId, 'modules' => $mods); $this->load->view('editor/editor_view', $data); }