예제 #1
0
 /**
  * Stops capturing output, returning what was captured
  *
  * @return string  The captured output
  */
 public static function stopCapture()
 {
     if (!self::$capturing) {
         throw new fProgrammerException('Output capturing can not be stopped since it has not been started');
     }
     self::$capturing = FALSE;
     return ob_get_clean();
 }
예제 #2
0
 /**
  * Performs buffered replacements using a breadth-first technique
  * 
  * @return void
  */
 private function placeBuffered()
 {
     if (!$this->buffered_id) {
         return;
     }
     $contents = fBuffer::get();
     fBuffer::erase();
     // We are gonna use a regex replacement that is eval()'ed as PHP code
     $regex = '/%%fTemplating::' . $this->buffered_id . '::(.*?)::(.*?)%%/e';
     $replacement = 'fBuffer::startCapture() . $this->placeElement("$1", "$2") . fBuffer::stopCapture()';
     // Remove the buffered id, thus making any nested place() calls be executed immediately
     $this->buffered_id = NULL;
     echo preg_replace($regex, $replacement, $contents);
 }
예제 #3
0
 /**
  * Stop output buffering and save the cache to the fCache directory, and then display
  * it to the browser.
  * 
  * @return boolean 				If saving was successful
  */
 public static function save()
 {
     if (static::$authorized_override) {
         return false;
     }
     if (!static::$enabled) {
         return false;
     }
     $contents = fBuffer::get();
     fBuffer::stop();
     static::$cache->set($identifier, $contents, static::$ttl);
     return true;
 }
예제 #4
0
 /**
  * Performs a captured place of an element to use with buffer placing
  *
  * @param array $match  A regex match from ::placeBuffered()
  * @return string  The output of placing the element
  */
 private function placeBufferedCallback($match)
 {
     fBuffer::startCapture();
     $this->placeElement($match[1], $match[2]);
     return fBuffer::stopCapture();
 }
예제 #5
0
 public function tearDown()
 {
     if ($this->started_capture) {
         fBuffer::stopCapture();
         $this->started_capture = FALSE;
     }
     if ($this->started_buffer) {
         ob_clean();
         fBuffer::stop();
         $this->started_buffer = FALSE;
     }
 }