From e5cb515146fdb78dc81726d93341af39a57be27c Mon Sep 17 00:00:00 2001 From: kylekatarnls Date: Mon, 24 Mar 2014 15:26:29 +0100 Subject: [PATCH] Save the parsed file name --- src/sbp/sbp.php | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/src/sbp/sbp.php b/src/sbp/sbp.php index af3cd76..9675551 100644 --- a/src/sbp/sbp.php +++ b/src/sbp/sbp.php @@ -23,6 +23,7 @@ class sbp const SAME_DIR = 0x01; static protected $destination = self::SAME_DIR; + static protected $lastParsedFile = null; static public function writeIn($directory = self::SAME_DIR) { @@ -224,7 +225,10 @@ static public function fileParse($from, $to = null) throw new sbpException($dir." is not writable, try :\nchmod ".static::fileMatchnigLetter($dir)."+w ".$dir, 1); return false; } - return file_put_contents($to, self::parse(file_get_contents($from))); + static::$lastParsedFile = $from; + $writed = file_put_contents($to, self::parse(file_get_contents($from))); + static::$lastParsedFile = null; + return $writed; } static public function fileExists($file, &$phpFile = null) @@ -254,6 +258,14 @@ static public function fileExists($file, &$phpFile = null) return false; } + static public function sbpFromFile($file) + { + if(preg_match('#/*:(.+):*/#U', file_get_contents($file), $match)) + { + return $match[1]; + } + } + static public function includeFile($file) { if(!self::fileExists($file, $phpFile)) @@ -280,7 +292,7 @@ static public function parse($content) $GLOBALS['commentStrings'] = array(); $content = str_replace(self::SUBST, self::SUBST.self::SUBST, $content); $content = preg_replace('#<\?(?!php)#', '.*<\?php#sU', array(get_class(), 'replaceString'), $content); //$validsubst = self::validSubst(); $validComments = self::validSubst('(?:'.implode('|', $GLOBALS['commentStrings']).')');