'', 'success' => '' ]; public function __construct() { parent::__construct(); $this->load->database(); $this->load->model('marketing_model'); } /** * Debug Controller to error_log and turn off in production * * @param mixed $data * @return void */ public function dl($key, $data) { if (ENVIRONMENT == 'development') { error_log($key . ' CONTROLLER :
' . print_r($data, TRUE) . ''); } } /** * Debug json Controller to error_log and turn off in production * * @param mixed $data * @return void */ public function dj($key, $data) { if (ENVIRONMENT == 'development') { error_log($key . ' CONTROLLER : ' . json_encode($data)); } } public function get_session() { if (!$this->_test_mode) { return $_SESSION; } $session = $this->config->item('session_test'); if (!$session) { $session = []; } return $session; } public function set_session($field, $value) { if (!$this->_test_mode) { $_SESSION[$field] = $value; } else { $session = $this->config->item('session_test'); if (!$session) { $session = []; } $session[$field] = $value; $this->config->set_item('session_test', $session); } } public function destroy_session() { if (!$this->_test_mode) { unset($_SESSION); } else { $this->config->set_item('session_test', []); } } public function get_setting() { return $this->_setting; } /** * Function to generate a slug */ public function generate_marketing_slug($str) { $delimiter = '-'; $slug = strtolower(trim(preg_replace('/[\s-]+/', $delimiter, preg_replace('/[^A-Za-z0-9-]+/', $delimiter, preg_replace('/[&]/', 'and', preg_replace('/[\']/', '', iconv('UTF-8', 'ASCII//TRANSLIT', $str))))), $delimiter)); $full_path = base_url() . 'a/'; $row = $this->marketing_model->get_by_field('slug', $full_path . $slug); if (empty($row)) { $output['slug'] = $slug; echo json_encode($output); exit; } else { $i = 1; $check_me_again = TRUE; while ($check_me_again) { $slug = $slug . '-' . $i; $row = $this->marketing_model->get_by_field('slug', $full_path . $slug); if (empty($row)) { $check_me_again = FALSE; } $i++; } $output['slug'] = $slug; echo json_encode($output); exit; } } /** * Function to return the generated page */ public function generate_custom_marketing_page($slug) { $slug_url = base_url() . 'a/'; $slug = $slug_url.$slug; $marketing_data = $this->marketing_model->get_by_field('slug',$slug); $this->_data['header'] = ''; $this->_data['footer'] = ''; $this->_data['content_template'] = ''; $this->_data['content'] = ''; $this->_data['success'] = ''; $this->_data['error'] = ''; $this->_data['layout_clean_mode'] = TRUE; $this->_data['reuse_query_string'] = TRUE; $this->_data['base_url'] = base_url(); $this->_data['total_rows'] = 25; $this->_data['per_page'] = 25; $this->_data['num_links'] = ''; $this->_data['full_tag_open'] = '