public function saveModuleChanges($data) { $this->load->helper('file'); $modData = new Module_Model($data['module']); $category = $modData->getCategory(); $location = $modData->getLocation(); $baseName = $modData->getBaseName(); if (!write_file($this->config->item('moduleDir') . $category . '/files/' . $location, $data['html'])) { $msg = array('status' => 'error', 'msg' => 'There was an error writing the update to the module to a file.'); echo json_encode($msg); exit; } else { $this->image->setBinary($this->config->item('image_binary')); $options = array('format' => 'jpg', 'user-style-sheet' => FCPATH . 'assets/css/bootstrap.css', 'load-error-handling' => 'skip'); $newImage = $this->config->item('moduleDir') . $category . '/files/thumbnails/' . $baseName . '.jpg'; $this->image->generateFromHtml($data['html'], $newImage, $options, true); $config['source_image'] = $newImage; $config['maintain_ratio'] = true; $config['height'] = 200; $this->load->library('image_lib', $config); $this->image_lib->resize(); $this->updateDocument($data['docId']); $msg = array('status' => 'success', 'msg' => 'We successfully created the new module, and inserted the data into the database.'); echo json_encode($msg); } }
public function getModules($category) { $query = $this->db->select()->where('category', $category)->where('publishable', 1)->get('modules'); $data = array(); foreach ($query->result() as $row) { $modData = new Module_Model($row->id); $loc = $modData->getLocation(); $file = $modData->getBaseName(); $thumbnail = $this->checkThumbnail($category, $file); $data[] = array('id' => $row->id, 'owner' => $modData->getOwner(), 'fileLink' => $this->config->item('moduleDir') . $category . '/files/' . $loc, 'description' => $modData->getDescription(), 'thumbnail' => $thumbnail); } return json_encode($data); }