/**
  * Returns a DOMDocument with this view's processed structure and Style 
  * Stylesheets, the result is expected to be an XSL-FO document portion, if
  * we are using <i>children</i> nodes for this node in config i.e. a tree 
  * hierarchy report defnition, or a complete XSL-FO document of this composite 
  * is the root CompositeView Object.
  * 
  * In the Recursive Step2 render process the Root stylesheet first calls it's 
  * child Stylesheets which in turn does the same. Then, when all child are rendered
  * the Stylesheet's <b><child_view name="ChildName"/></b> Tags get replaced by the
  * XSL-FO part generated by <b>"ChildName"</b> Stylesheet. The result being the 
  * complete XSL-FO representation of the report, delivered by Step2.
  * 
  * This method 1st calls every child BasicView object to render itself. Then
  * render this CompositeView's stylesheets and in the rendered XSL-FO documents
  * it looks for every <b><child_view name="ChildName"/></b> and replaces it 
  * with the corresponding rendered child using name attribute to match them.
  * 
  * @see BasicView, BasicView::_renderedDom
  * @return DOMDocument
  */
 public function render()
 {
     $xQuery = '//' . self::$childViewNodeName;
     $childFo = array();
     $childNodes = $this->_structure->xpath($xQuery);
     reset($childNodes);
     while (list($key, $ch) = each($childNodes)) {
         /* @var $ch SimpleXMLElement */
         $name = (string) $ch->attributes()->name;
         // renders every child present in $_structure xslt and in $_children
         if (isset($this->children[$name])) {
             $childView = $this->children[$name];
             $childFo[$name] = $childView->render();
         } else {
             $ch->addAttribute('child_not_found', 1);
         }
     }
     $structTran = parent::render();
     self::$_xPath = new DOMXPath($structTran);
     $childDomNodes = self::$_xPath->query($xQuery);
     foreach ($childDomNodes as $childDn) {
         /* Replace every $this->childNiewNodeName node by its rendered
          * subview.
          */
         $name = $childDn->getAttribute('name');
         $replacementNodes = $childFo[$name]->childNodes;
         /* @var $replacementNodes DOMElement */
         foreach ($replacementNodes as $replaceNode) {
             $newChildNode = $structTran->importNode($replaceNode, true);
             $childDn->parentNode->insertBefore($newChildNode, $childDn);
         }
         $childDn->parentNode->removeChild($childDn);
     }
     $this->_renderedDom = $structTran;
     return $this->_renderedDom;
 }
 public function __construct()
 {
     parent::__construct();
 }
Example #3
0
 /**
  * This is the final Step in this 3 steps process:
  * <ol> 
  * <li>Step 1 consists in generating the XML bsaed raw data for the report. </li>
  * <li>Step 2 consists in merging this raw data with a XSL-FO template to give it
  * the presentation information. XSL-FO acts as an intermediate language used 
  * to render the final repor in any format with a last transformation. </li>
  * <li>Step 3 consists on rendering the XSL-FO representtion (the intermediate 
  * language) of the report to the desired output fromat.</li>
  * </ol>
  * Here I implement tha basic behaviour, assuming we need only a last XSLT 
  * transformation, and reusing BasicView::render() for that. The XSLT that 
  * renders the XSL-FO representation should be set in the contructor.
  * 
  * @param DOMDocument   $xslFo    The XSL-FO representation of the processed 
  * report, as we get it just after step 2 in this 3 steps process.
  * @param sfWebResponse $response The Response Object, should be passed all 
  * the way down from the action. So we can change some headers, i.e. ContentType
  * 
  * @see %sf_plugins_dir%/NeatReports/config/sfExportGlobals.yml
  * @return String With the rendered report content. Might be plain text or 
  * binary data.
  */
 public function renderReport(DOMDocument $xslFo, sfWebResponse $response = null)
 {
     $this->setReportFo($xslFo);
     return parent::render()->saveXML();
 }