Skip to content

Instantly share code, notes, and snippets.

@zaherg
Created May 22, 2012 12:58
Show Gist options
  • Save zaherg/2768888 to your computer and use it in GitHub Desktop.
Save zaherg/2768888 to your computer and use it in GitHub Desktop.
using this file your error pages will be localized , but the error folder must contain folders like : english , arabic ... etc
<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class MY_Exceptions extends CI_Exceptions {
var $ob_level;
public function __construct()
{
parent::__construct();
}
function show_error($heading, $message, $template = 'error_general', $status_code = 500)
{
set_status_header($status_code);
$message = '<p>'.implode('</p><p>', ( ! is_array($message)) ? array($message) : $message).'</p>';
$idiom = $this->_get_idiom();
if (ob_get_level() > $this->ob_level + 1)
{
ob_end_flush();
}
ob_start();
include(APPPATH.'errors/'.$idiom.'/'.$template.'.php');
$buffer = ob_get_contents();
ob_end_clean();
return $buffer;
}
function show_php_error($severity, $message, $filepath, $line)
{
$severity = ( ! isset($this->levels[$severity])) ? $severity : $this->levels[$severity];
$filepath = str_replace("\\", "/", $filepath);
$idiom = $this->_get_idiom();
// For safety reasons we do not show the full file path
if (FALSE !== strpos($filepath, '/'))
{
$x = explode('/', $filepath);
$filepath = $x[count($x)-2].'/'.end($x);
}
if (ob_get_level() > $this->ob_level + 1)
{
ob_end_flush();
}
ob_start();
include(APPPATH.'errors/'.$idiom.'/error_php.php');
$buffer = ob_get_contents();
ob_end_clean();
echo $buffer;
}
function _get_idiom(){
$config =& get_config();
$deft_lang = ( ! isset($config['language'])) ? 'english' : $config['language'];
$idiom = ($deft_lang == '') ? 'english' : $deft_lang;
return $idiom;
}
}
// END Exceptions Class
/* End of file MY_Exceptions.php */
/* Location: ./application/core/MY_Exceptions.php */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment