public function testErase() { fBuffer::start(); $this->started_buffer = TRUE; echo 'testing erase'; fBuffer::erase(); $this->assertEquals('', fBuffer::get()); }
/** * 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); }
/** * 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 . '::(.*?)::(.*?)%%/'; // Remove the buffered id, thus making any nested place() calls be executed immediately $this->buffered_id = NULL; echo preg_replace_callback($regex, array($this, 'placeBufferedCallback'), $contents); }
/** * 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; }