Development

Changeset 8717

You must first sign up to be able to contribute.

Changeset 8717

Show
Ignore:
Timestamp:
05/02/08 10:31:17 (4 months ago)
Author:
FabianLange
Message:

patched sfFillInForm so that in html mode it adds a content-type meta if non present so that dom->loadHTML works correctly. (closes #2653)

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.1/lib/plugins/sfCompat10Plugin/lib/util/sfFillInForm.class.php

    r8710 r8717  
    4444  { 
    4545    $dom = new DomDocument('1.0', sfConfig::get('sf_charset', 'UTF-8')); 
     46 
     47    $noHead = strpos($html,'<head>') === false; 
     48    if ($noHead){ 
     49      //loadHTML needs the conent-type meta for the charset 
     50      $html = '<meta http-equiv="Content-Type" content="text/html; charset='.sfConfig::get('sf_charset').'"/>'.$html; 
     51    } 
     52 
    4653    @$dom->loadHTML($html); 
    47  
    4854    $dom = $this->fillInDom($dom, $formName, $formId, $values); 
    4955 
     56    if($noHead){ 
     57      //remove the head element that was created by adding the meta tag. 
     58      $headElement = $dom->getElementsByTagName('head')->item(0); 
     59      if ($headElement) 
     60      { 
     61        $dom->getElementsByTagName('html')->item(0)->removeChild($headElement); 
     62      } 
     63    } 
    5064    return $dom->saveHTML(); 
    5165  }