function repairAmpersands(&$xml)
 {
     $xml = trim($xml);
     $startIndex = -1;
     $processing = true;
     $illegalChar = '&';
     while ($processing) {
         $startIndex = strpos($xml, $illegalChar, $startIndex + 1);
         if ($startIndex !== false) {
             $xml = XMLRepair::evaluateCharacter($xml, $illegalChar, $startIndex + 1);
         } else {
             $processing = false;
         }
     }
     return $xml;
 }
Example #2
0
 function render($param)
 {
     $doctor = new XMLRepair();
     $cDate = new SymDate($this->getConfigVar("time_zone", "region"), "Y-m-d");
     if (!is_array($param)) {
         $param = array();
     }
     if (is_array($this->_env["url"])) {
         $param = array_merge($param, $this->_env["url"]);
     }
     if (is_array($param)) {
         $param = array_merge($param, $this->_param);
     } else {
         $param = $this->_param;
     }
     ## Depending on the page type, generate appropriate headers
     if ($this->_page_type == 'error') {
         $this->addHeaderToPage("HTTP/1.0 404 Not Found");
     } elseif ($this->_page_type == 'xml') {
         $this->addHeaderToPage("Content-Type", "text/xml; charset=utf-8");
     }
     ####
     # Delegate: PreRender
     # Description: Prior to anything being rendered. Both profiler and XSL params are passed as references.
     #              Altering the param arry will effect the page XSL
     $this->_CampfireManager->notifyMembers('PreRender', '/frontend/', array('page-param' => &$param, 'profiler' => &$this->_profiler));
     $this->buildXSL(NULL, NULL, $param);
     ####
     # Delegate: XSLRender
     # Description: XSL has been rendered and can be manipulated
     $this->_CampfireManager->notifyMembers('XSLRender', '/frontend/', array('xsl' => &$this->_xsl_final));
     $this->_profiler->sample("XSL Creation", PROFILE_LAP);
     $this->_xml_final = $doctor->entities2hexadecimal($this->buildXML(NULL, NULL, true, $this->getConfigVar("caching", "public") == 'on' ? true : false));
     ####
     # Delegate: XMLRender
     # Description: XML has been rendered and can be manipulated
     $this->_CampfireManager->notifyMembers('XMLRender', '/frontend/', array('xml' => &$this->_xml_final));
     $this->_profiler->sample("XML Creation", PROFILE_LAP);
     $output =& new XsltProcess($this->_xml_final, $this->_xsl_final);
     $this->_result = $output->process(null, null, $param);
     if ($this->_verbose && $output->isErrors()) {
         $message = "<p>Some errors were encountered while trying to render this page. Please see the list below for details.</p><dl>" . CRLF;
         while ($e = $output->getError()) {
             $message .= "<dt>" . ($e["type"] != NULL ? strtoupper($e["type"]) . " processing error:" : "") . "</dt><dd>" . $e["message"] . "</dd>" . CRLF;
         }
         $message .= "</dl>" . CRLF;
         $this->fatalError($message . ($this->isLoggedIn() ? '<p>Check the <a href="?debug">page debug information here</a></p>' : ""), "Symphony XSLT Processing Error");
     }
     $this->_profiler->sample("XSLT Transformation", PROFILE_LAP);
     #Record the render time
     $this->_profiler->sample("Total Page Render Time");
     if ($this->getConfigVar("status", "public") == "offline" && $this->isLoggedIn()) {
         $this->_result .= "\n <!-- \n\nPROFILER INFO \n\n";
         foreach ($this->_profiler->retrieve() as $x) {
             list($msg, $time, $start) = $x;
             $this->_result .= "> {$msg}: {$time} sec\n";
         }
         $this->_result .= "\n\n Page Parameters \n\n";
         foreach ($param as $key => $val) {
             $this->_result .= "{$key} => {$val} \n";
         }
         $this->_result .= "\n\n\nEvents XML\n\n" . $this->_events->generate(true) . "\n\n -->\n";
     }
     ####
     # Delegate: PostRender
     # Description: Page code has been created and can me manipulated. Page parameters and profiler are also provided.
     $this->_CampfireManager->notifyMembers('PostRender', '/frontend/', array('page-param' => $param, 'profiler' => $this->_profiler, 'output' => &$this->_result));
 }