Exemplo n.º 1
0
 /**
  * Save the image to a file
  *
  * @param $filename
  *
  * @return static
  */
 public function save($filename, $overwrite = false)
 {
     if ($this->html) {
         $this->snappy->generateFromHtml($this->html, $filename, $this->options, $overwrite);
     } elseif ($this->file) {
         $this->snappy->generate($this->file, $filename, $this->options, $overwrite);
     }
     return $this;
 }
Exemplo n.º 2
0
 public function saveModule($data)
 {
     $this->load->helper('file');
     $docNameNew = uniqid('', true);
     $docName = $docNameNew . '.php';
     $category = $data['category'];
     if (!write_file($this->config->item('moduleDir') . $category . '/files/' . $docName, $data['html'])) {
         $msg = array('status' => 'error', 'msg' => 'There was an error writing the new module to a file.');
         echo json_encode($msg);
         exit;
     } else {
         $image = new Image($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/' . $docNameNew . '.jpg';
         $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();
         $module = array('category' => $category, 'owner' => $this->session->id, 'description' => $data['description'], 'created' => date('Y-m-d H:i:s'), 'publishable' => 1, 'location' => $docName);
         $this->db->insert('modules', $module);
         $msg = array('status' => 'success', 'msg' => 'We successfully created the new module, and inserted the data into the database.');
         echo json_encode($msg);
     }
 }