Esempio n. 1
0
 /**
  * Add a template module to certain group
  *
  * @access public
  * @return string
  */
 public function add_template_module()
 {
     //load the module parent class
     load_front_library('module.php');
     //load language resources
     $this->lang->db_load('modules-boxes');
     $code = $this->input->post('code');
     $group = $this->input->post('group');
     $templates_id = $this->input->post('templates_id');
     //get module configuration params and insert default value into database
     $path_array = array(store_front_path() . 'local/modules/', store_front_path() . 'system/tomatocart/modules/');
     $result = FALSE;
     $data = array();
     foreach ($path_array as $path) {
         $directories = directory_map($path, 1, TRUE);
         foreach ($directories as $directory) {
             $file = $path . $directory . '/' . $directory . '.php';
             if (file_exists($file) && $code == $directory) {
                 require_once $file;
                 $class_name = 'Mod_' . $directory;
                 $class = new $class_name(array());
                 $result = $class->install($templates_id, $group);
                 if ($result !== FALSE) {
                     $data = array('id' => $result, 'templates_id' => $templates_id, 'title' => $class->get_title(), 'module' => $code, 'status' => 0, 'content_page' => '*', 'content_group' => $group, 'sort_order' => 0, 'page_specific' => 0, 'params' => $class->get_params());
                     break;
                 }
             }
         }
     }
     if ($result !== FALSE) {
         $response = array('success' => true, 'data' => $data);
     } else {
         $response = array('success' => false, 'feedback' => lang('ms_error_action_not_performed'));
     }
     return $this->output->set_output(json_encode($response));
 }
Esempio n. 2
0
 function load_front($class, $type = 'libraries')
 {
     $path = store_front_path() . 'system/tomatocart/' . $type . '/' . $class;
     if (file_exists($path)) {
         require_once $path;
         return TRUE;
     }
     return FALSE;
 }
Esempio n. 3
0
 function get_module_title($code)
 {
     //load the module parent class
     load_front_library('module.php');
     //modules paths
     $path_array = array(store_front_path() . 'local/modules/', store_front_path() . 'system/tomatocart/modules/');
     $params = array();
     foreach ($path_array as $path) {
         $file = $path . $code . '/' . $code . '.php';
         if (file_exists($file)) {
             require_once $file;
             $class_name = 'Mod_' . $code;
             $class = new $class_name(array());
             return $class->get_title();
         }
     }
     return NULL;
 }