Development

Changeset 2936

You must first sign up to be able to contribute.

Changeset 2936

Show
Ignore:
Timestamp:
12/06/06 14:47:16 (3 years ago)
Author:
fabien
Message:

added xml and html parsing for fillin class

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/lib/filter/sfFillInFormFilter.class.php

    r2677 r2936  
    4444 
    4545    // fill in 
    46     $content = $fillInForm->fillIn($response->getContent(), $this->getParameter('name'), $this->getParameter('id'), $request->getParameterHolder()->getAll()); 
     46    $method  = $this->getParameter('content_type', preg_match('/xh?ml/', $response->getHttpHeader('Content-Type')) ? 'fillInXml' : 'fillInHtml'); 
     47    $content = $fillInForm->$method($response->getContent(), $this->getParameter('name'), $this->getParameter('id'), $request->getParameterHolder()->getAll()); 
    4748 
    4849    $response->setContent($content); 
  • trunk/lib/util/sfFillInForm.class.php

    r2678 r2936  
    4141  } 
    4242 
    43   public function fillIn($html, $formName, $formId, $values) 
     43  public function fillInHtml($html, $formName, $formId, $values) 
    4444  { 
    4545    $dom = new DomDocument('1.0', sfConfig::get('sf_charset', 'UTF-8')); 
     
    5151  } 
    5252 
     53  public function fillInXml($xml, $formName, $formId, $values) 
     54  { 
     55    $dom = new DomDocument('1.0', sfConfig::get('sf_charset', 'UTF-8')); 
     56    @$dom->loadXML($xml); 
     57 
     58    $dom = $this->fillInDom($dom, $formName, $formId, $values); 
     59 
     60    return $dom->saveXML(); 
     61  } 
     62 
    5363  public function fillInDom($dom, $formName, $formId, $values) 
    5464  { 
     
    7989    if (!$form) 
    8090    { 
    81       throw new sfException(sprintf('The form "%s" cannot be found', $formName ? $formName : $formId)); 
     91      if (!$formName && !$formId) 
     92      { 
     93        throw new sfException('No form found in this page'); 
     94      } 
     95      else 
     96      { 
     97        throw new sfException(sprintf('The form "%s" cannot be found', $formName ? $formName : $formId)); 
     98      } 
    8299    } 
    83100 

The Sensio Labs Network

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