shop.balmet.com

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | README

developer.php (3185B)


      1 <?php
      2 class ControllerCommonDeveloper extends Controller {
      3 	public function index() {
      4 		$this->load->language('common/developer');
      5 		
      6 		$data['user_token'] = $this->session->data['user_token'];
      7 		
      8 		$data['developer_theme'] = $this->config->get('developer_theme');
      9 		$data['developer_sass'] = $this->config->get('developer_sass');	
     10 				
     11 		$eval = false;
     12 		
     13 		$eval = '$eval = true;';
     14 
     15 		eval($eval);		
     16 		
     17 		if ($eval === true) {
     18 			$data['eval'] = true;
     19 		} else {
     20 			$this->load->model('setting/setting');
     21 
     22 			$this->model_setting_setting->editSetting('developer', array('developer_theme' => 1), 0);
     23 		
     24 			$data['eval'] = false;			
     25 		}
     26 	
     27 		$this->response->setOutput($this->load->view('common/developer', $data));
     28 	}
     29 	
     30 	public function edit() {
     31 		$this->load->language('common/developer');
     32 
     33 		$json = array();
     34 
     35 		if (!$this->user->hasPermission('modify', 'common/developer')) {
     36 			$json['error'] = $this->language->get('error_permission');
     37 		} else {
     38 			$this->load->model('setting/setting');
     39 
     40 			$this->model_setting_setting->editSetting('developer', $this->request->post, 0);
     41 
     42 			$json['success'] = $this->language->get('text_success');
     43 		}
     44 
     45 		$this->response->addHeader('Content-Type: application/json');
     46 		$this->response->setOutput(json_encode($json));		
     47 	}
     48 		
     49 	public function theme() {
     50 		$this->load->language('common/developer');
     51 		
     52 		$json = array();
     53 		
     54 		if (!$this->user->hasPermission('modify', 'common/developer')) {
     55 			$json['error'] = $this->language->get('error_permission');
     56 		} else {
     57 			$directories = glob(DIR_CACHE . '*', GLOB_ONLYDIR);
     58 
     59 			if ($directories) {
     60 				foreach ($directories as $directory) {
     61 					$files = glob($directory . '/*');
     62 					
     63 					foreach ($files as $file) { 
     64 						if (is_file($file)) {
     65 							unlink($file);
     66 						}
     67 					}
     68 					
     69 					if (is_dir($directory)) {
     70 						rmdir($directory);
     71 					}
     72 				}
     73 			}
     74 						
     75 			$json['success'] = sprintf($this->language->get('text_cache'), $this->language->get('text_theme'));
     76 		}
     77 		
     78 		$this->response->addHeader('Content-Type: application/json');
     79 		$this->response->setOutput(json_encode($json));			
     80 	}
     81 		
     82 	public function sass() {
     83 		$this->load->language('common/developer');
     84 		
     85 		$json = array();
     86 		
     87 		if (!$this->user->hasPermission('modify', 'common/developer')) {
     88 			$json['error'] = $this->language->get('error_permission');
     89 		} else {
     90 			// Before we delete we need to make sure there is a sass file to regenerate the css
     91 			$file = DIR_APPLICATION  . 'view/stylesheet/bootstrap.css';
     92 			
     93 			if (is_file($file) && is_file(DIR_APPLICATION . 'view/stylesheet/sass/_bootstrap.scss')) {
     94 				unlink($file);
     95 			}
     96 			 
     97 			$files = glob(DIR_CATALOG  . 'view/theme/*/stylesheet/sass/_bootstrap.scss');
     98 			 
     99 			foreach ($files as $file) {
    100 				$file = substr($file, 0, -21) . '/bootstrap.css';
    101 				
    102 				if (is_file($file)) {
    103 					unlink($file);
    104 				}
    105 			}
    106 			
    107 			$json['success'] = sprintf($this->language->get('text_cache'), $this->language->get('text_sass'));
    108 		}	
    109 		
    110 		$this->response->addHeader('Content-Type: application/json');
    111 		$this->response->setOutput(json_encode($json));					
    112 	}
    113 }