Development

Changeset 8708

You must first sign up to be able to contribute.

Changeset 8708

Show
Ignore:
Timestamp:
05/01/08 12:08:01 (1 year ago)
Author:
FabianLange
Message:

fixed ajax response fillin, which does not include a doctype because it is returned without layout. fixes #1687

Files:

Legend:

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

    r8697 r8708  
    5454  { 
    5555    $dom = new DomDocument('1.0', sfConfig::get('sf_charset', 'UTF-8')); 
     56    if (strpos($xml,'<!DOCTYPE') === false) 
     57    { 
     58      $xml = '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" '. 
     59             '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">'. 
     60             $xml; 
     61    } 
    5662    @$dom->loadXML($xml); 
    5763 
     
    7480    } 
    7581 
     82    // find our form 
     83    if ($formName) 
     84    { 
     85      $xpath_query = '//'.$ns.'form[@name="'.$formName.'"]'; 
     86    } 
     87    elseif ($formId) 
     88    { 
     89      $xpath_query = '//'.$ns.'form[@id="'.$formId.'"]'; 
     90    } 
     91    else 
     92    { 
     93      $xpath_query = '//'.$ns.'form'; 
     94    } 
     95 
     96    $form = $xpath->query($xpath_query)->item(0); 
     97    if (!$form) 
     98    { 
     99      if (!$formName && !$formId) 
     100      { 
     101        throw new sfException('No form found in this page.'); 
     102      } 
     103      else 
     104      { 
     105        throw new sfException(sprintf('The form "%s" cannot be found.', $formName ? $formName : $formId)); 
     106      } 
     107    } 
     108 
    76109    $query = 'descendant::'.$ns.'input[@name and (not(@type)'; 
    77110    foreach ($this->types as $type) 
     
    80113    } 
    81114    $query .= ')] | descendant::'.$ns.'textarea[@name] | descendant::'.$ns.'select[@name]'; 
    82  
    83     // find our form 
    84     if ($formName) 
    85     { 
    86       $xpath_query = '//'.$ns.'form[@name="'.$formName.'"]'; 
    87     } 
    88     elseif ($formId) 
    89     { 
    90       $xpath_query = '//'.$ns.'form[@id="'.$formId.'"]'; 
    91     } 
    92     else 
    93     { 
    94       $xpath_query = '//'.$ns.'form'; 
    95     } 
    96  
    97     $form = $xpath->query($xpath_query)->item(0); 
    98     if (!$form) 
    99     { 
    100       if (!$formName && !$formId) 
    101       { 
    102         throw new sfException('No form found in this page.'); 
    103       } 
    104       else 
    105       { 
    106         throw new sfException(sprintf('The form "%s" cannot be found.', $formName ? $formName : $formId)); 
    107       } 
    108     } 
    109115 
    110116    foreach ($xpath->query($query, $form) as $element) 

The Sensio Labs Network

Since 1998, Sensio Labs has been promoting the Open-Source software movement by providing quality web application development, training, consulting, and supporting several large Open-Source projects.