Example #1
0
 /**
  *@param string $xslPath
  *@return string 
  *@desc Return the XSL with snippet to/from cache.
  */
 public function IncludeSnippet($xslPath)
 {
     $xslName = $this->_file->ToString() . '.' . strtolower($this->_context->Language()->getName()) . '.xsl';
     $cacheEngine = $this->_context->getXSLCacheEngine();
     $result = $cacheEngine->get($xslName, 7200);
     // Create a new stream representing the file to be written to,
     // and write the stream cache the stream
     // from the external location to the file (only if doesnt exist)
     if ($result === false) {
         $content = "";
         $content = file_get_contents($xslPath);
         try {
             $cacheEngine->lock($xslName);
             $iStart = strpos($content, "<xmlnuke-");
             while ($iStart !== false) {
                 $iEnd = strpos($content, ">", $iStart + 1);
                 $snippetFile = substr($content, $iStart + 9, $iEnd - $iStart - 10);
                 $snippet = new SnippetFilenameProcessor(trim($snippetFile));
                 if (!FileUtil::Exists($snippet)) {
                     throw new SnippetNotFoundException("Snippet " . $snippet->FullQualifiedNameAndPath() . " not found");
                 }
                 $sReadSnippet = file_get_contents($snippet->FullQualifiedNameAndPath());
                 $content = substr($content, 0, $iStart) . self::LF . $sReadSnippet . substr($content, $iEnd + 1);
                 $iStart = strpos($content, "<xmlnuke-");
             }
             $cacheEngine->unlock($xslName);
             $cacheEngine->set($xslName, $content);
             return $content;
         } catch (Exception $ex) {
             $cacheEngine->unlock($xslName);
             $cacheEngine->release($xslName);
             throw $ex;
         }
     } else {
         // Already in Cache
         return $result;
     }
 }
Example #2
0
 public function TransformDocumentRemote($url)
 {
     $cacheEngine = $this->_context->getXSLCacheEngine();
     $file = str_replace(".", "_", "remote-" . UsersBase::getSHAPassword($url));
     $result = $cacheEngine->get($file, 60);
     if ($result !== false) {
         return $result;
     } else {
         $xmlDoc = FileUtil::GetRemoteXMLDocument($url);
         $result = $this->TransformDocumentFromDOM($xmlDoc);
         $search = array("'&(amp|#38);gt;'i", "'&(amp|#38);lt;'i");
         $replace = array(">", "<");
         $result = preg_replace($search, $replace, $result);
         $cacheEngine->set($file, $result);
         return $result;
     }
 }
Example #3
0
 /**
  *
  * @return ICacheEngine
  */
 public function getCacheEngine()
 {
     return $this->_context->getXSLCacheEngine();
 }