"Closes #3295, Centralize encoding / charset setting in one Configure setting"

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6253 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
phpnut 2007-12-25 09:08:36 +00:00
parent fbf5330fd8
commit f9c1058a20
5 changed files with 23 additions and 3 deletions

View file

@ -41,6 +41,10 @@
* In development mode, you need to click the flash message to continue.
*/
Configure::write('debug', 2);
/**
* Application wide charset encoding
*/
Configure::write('App.encoding', 'UTF-8');
/**
* To configure CakePHP *not* to use mod_rewrite and to
* use CakePHP pretty URLs, remove these .htaccess

View file

@ -273,7 +273,10 @@ class EmailComponent extends Object{
* @access public
*/
function startup(&$controller) {
$this->Controller = & $controller;
$this->Controller =& $controller;
if (Configure::read('App.encoding') !== null) {
$this->charset = Configure::read('App.encoding');
}
}
/**
* Send an email using the specified content, template and layout

View file

@ -520,9 +520,15 @@ class RequestHandlerComponent extends Object {
* @see RequestHandlerComponent::respondAs()
*/
function renderAs(&$controller, $type) {
$options = array('charset' => 'UTF-8');
if (Configure::read('App.encoding') !== null) {
$options = array('charset' => Configure::read('App.encoding'));
}
if ($type == 'ajax') {
$controller->layout = $this->ajaxLayout;
return $this->respondAs('html', array('charset' => 'UTF-8'));
return $this->respondAs('html', $options);
}
$controller->ext = '.ctp';
@ -535,7 +541,7 @@ class RequestHandlerComponent extends Object {
$controller->layoutPath = $type;
if (in_array($type, array_keys($this->__requestContent))) {
$this->respondAs($type);
$this->respondAs($type, $options);
}
$helper = ucfirst($type);

View file

@ -88,6 +88,9 @@ class XmlHelper extends AppHelper {
* @return string XML header
*/
function header($attrib = array()) {
if (Configure::read('App.encoding') !== null) {
$this->encoding = Configure::read('App.encoding');
}
$attrib = array_merge(array('version' => '1.0', 'encoding' => $this->encoding), $attrib);
return $this->output('<' . '?xml' . $this->__composeAttributes($attrib) . ' ?' . '>');
}

View file

@ -506,6 +506,10 @@ class XML extends XMLNode {
}
}
if (Configure::read('App.encoding') !== null) {
$this->encoding = Configure::read('App.encoding');
}
foreach ($options as $key => $val) {
switch ($key) {
case 'version':