Esempio n. 1
0
 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);
 }
Esempio n. 2
0
 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);
     }
 }
Esempio n. 3
0
 public function __construct()
 {
     Event::add('system.routing', array($this, 'install'));
     Event::add('system.display', array($this, 'render'));
     $modules = Kohana::config('core.modules');
     if (!is_dir(DOCROOT . 'installation')) {
         // Delete install app from Config::$include_paths
         unset($modules[0]);
     }
     $installed_mods = array();
     foreach (Module_Model::factory()->find(ALL) as $module) {
         /**
          * @todo Validate the modules via /config/[module].php or something
          */
         is_dir(MODPATH . $module->name) and $installed_mods[] = MODPATH . $module->name;
     }
     // Set module include paths
     Kohana::config_set('core.modules', array_merge($installed_mods, $modules));
     // Re-process the include paths
     Kohana::include_paths(TRUE);
     Kohana::log('debug', 'Hanami Core Hook initialized');
 }
Esempio n. 4
0
 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);
 }