Mercurial > SimpleWebPresenter
changeset 8:19dfa6f3e2be
Support for scripts.
| author | Tom Fredrik "BFG" Klaussen <bfg@blenning.no> |
|---|---|
| date | Sun, 12 Jun 2011 14:15:00 +0200 |
| parents | 350a8c63bd14 |
| children | 60e73809887a |
| files | common-functions.inc index.php |
| diffstat | 2 files changed, 31 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/common-functions.inc Fri May 20 23:34:33 2011 +0200 +++ b/common-functions.inc Sun Jun 12 14:15:00 2011 +0200 @@ -60,4 +60,16 @@ $elem=$elems->item(0); return $elem; } + +function getXmlContent($node) +{ + $text=$node->ownerDocument->saveXml($node); + $pattern="/^<".$node->tagName."[^>]*>/is"; + $text=preg_replace($pattern, '' , $text); + $pattern='/<\/'.$node->tagName.'[^>]*>$/is'; + $text=preg_replace($pattern, '' , $text); + + return $text; +} + ?> \ No newline at end of file
--- a/index.php Fri May 20 23:34:33 2011 +0200 +++ b/index.php Sun Jun 12 14:15:00 2011 +0200 @@ -128,8 +128,25 @@ } foreach ($files as $file) { - $src=$file->getAttribute("src"); - $file_content=loadFile("${lang}/${src}"); + $script=$file->getAttribute("script"); + if ($script) { + $src=""; + $cwd=getcwd(); + + $matches=array(); + preg_match('/(.*\/)/', $script, $matches); + $dirname=$matches[0]; + preg_match('/([^\/]*)$/', $script, $matches); + $filename=$matches[0]; + chdir("${lang}/${dirname}"); + $pipe=popen("php ${filename}","r"); + $file_content = stream_get_contents($pipe); + chdir("${cwd}"); + } + else { + $src=$file->getAttribute("src"); + $file_content=loadFile("${lang}/${src}"); + } if(floatval($file_content)<0) { errorPage("Resource not found '${lang}/${src}'"); }
