[phpwebapp-commits] CVS: web_app/convert convert.php,1.1,1.2 class.Render.php,1.1,1.2 README,1.1,1.2
Brought to you by:
dashohoxha
From: Dashamir H. <das...@us...> - 2004-07-21 17:04:44
|
Update of /cvsroot/phpwebapp/web_app/convert In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv2634/convert Modified Files: convert.php class.Render.php README Log Message: Index: convert.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/convert/convert.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** convert.php 20 Jul 2004 16:51:14 -0000 1.1 --- convert.php 21 Jul 2004 17:04:31 -0000 1.2 *************** *** 37,41 **** //handle empty tags $empty_tag = '(br|hr|img|input|meta|link|include|parameter)'; ! $pattern = '#(<'.$empty_tag.'([^>]*[^/])?)>#'; $str = preg_replace($pattern, '$1 />', $str); --- 37,41 ---- //handle empty tags $empty_tag = '(br|hr|img|input|meta|link|include|parameter)'; ! $pattern = '#(<'.$empty_tag.'([^>]*[^/-])?)>#'; $str = preg_replace($pattern, '$1 />', $str); *************** *** 45,50 **** //replace {{checked}} by checked="{{checked}}" ! $pattern = '#(<input[^<>]+type=.checkbox[^<>]+\s)(\{\{[^\}]+\}\})#'; ! $str = preg_replace($pattern, '${1}checked="$2"', $str); //replace {{selected}} by selected="{{selected}}" --- 45,50 ---- //replace {{checked}} by checked="{{checked}}" ! $pattern = '#(<input[^<>]+type=.(checkbox|radio)[^<>]+\s)(\{\{[^\}]+\}\})#'; ! $str = preg_replace($pattern, '${1}checked="$3"', $str); //replace {{selected}} by selected="{{selected}}" *************** *** 52,55 **** --- 52,66 ---- $str = preg_replace($pattern, '${1}selected="$2"', $str); + //replace compact attributes by their xhtml equivalent + $compact = '(nowrap|checked|disabled|readonly|selected|noresize)'; + $pattern = '#(<\w+[^<>]+\s+)'.$compact.'(?!\s*=)#'; + $str = preg_replace($pattern, '${1}$2="$2"', $str); + + //replace the xml builtin entities + $str = preg_replace('#&(lt|gt|quot|apos);#', '&$1;', $str); + //convert also & but not those that are + //the result of a previous conversion + $str = preg_replace('#&(?!(amp|lt|gt|apos);)#', '&amp;', $str); + return $str; } Index: class.Render.php =================================================================== RCS file: /cvsroot/phpwebapp/web_app/convert/class.Render.php,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** class.Render.php 20 Jul 2004 16:51:14 -0000 1.1 --- class.Render.php 21 Jul 2004 17:04:31 -0000 1.2 *************** *** 47,73 **** function render_RepeatTpl($tpl) { - //decrease the indentation of header $header = $tpl->header; - for ($i=0; $i < sizeof($header->content); $i++) - { - $line = $header->content[$i]; - $line = ereg_replace('^ ', '', $line); - $header->content[$i] = $line; - } - //decrease the indentation of footer $footer = $tpl->footer; ! for ($i=0; $i < sizeof($footer->content); $i++) ! { ! $line = $footer->content[$i]; ! $line = ereg_replace('^ ', '', $line); ! $footer->content[$i] = $line; ! } ! //increase the indentation of <Repeat> and <RepeatBody> ! for ($i=0; $i < sizeof($tpl->content); $i++) { ! $line = $tpl->content[$i]; ! if (ereg('^ *</?Repeat', $line)) { ! $tpl->content[$i] = ' '.$line; } } --- 47,76 ---- function render_RepeatTpl($tpl) { $header = $tpl->header; $footer = $tpl->footer; ! if (sizeof($header->content) > 0 or sizeof($footer->content) > 0) { ! //decrease the indentation of header ! for ($i=0; $i < sizeof($header->content); $i++) { ! $line = $header->content[$i]; ! $line = ereg_replace('^ ', '', $line); ! $header->content[$i] = $line; ! } ! //decrease the indentation of footer ! for ($i=0; $i < sizeof($footer->content); $i++) ! { ! $line = $footer->content[$i]; ! $line = ereg_replace('^ ', '', $line); ! $footer->content[$i] = $line; ! } ! //increase the indentation of <Repeat> and <RepeatBody> ! for ($i=0; $i < sizeof($tpl->content); $i++) ! { ! $line = $tpl->content[$i]; ! if (ereg('^ *</?Repeat', $line)) ! { ! $tpl->content[$i] = ' '.$line; ! } } } Index: README =================================================================== RCS file: /cvsroot/phpwebapp/web_app/convert/README,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** README 20 Jul 2004 16:51:14 -0000 1.1 --- README 21 Jul 2004 17:04:31 -0000 1.2 *************** *** 5,9 **** version of the framework. ! What is does is this: - Removes the elements <Header> and <Footer> from the <Repeat> element and puts their contents respectivly before and after --- 5,9 ---- version of the framework. ! What it does is this: - Removes the elements <Header> and <Footer> from the <Repeat> element and puts their contents respectivly before and after *************** *** 17,22 **** It can be used like this: ! $ ./convert.sh ../templates/*.html ! $ find ../templates/ -name '*.html' | xargs ./convert.sh After a template is converted, it is saved with the same name, --- 17,22 ---- It can be used like this: ! $ ./convert.sh ../templates/*.html ! $ find ../templates/ -name '*.html' | xargs ./convert.sh After a template is converted, it is saved with the same name, *************** *** 26,31 **** After making sure that all the templates are converted successfully, the backup files can be deleted with the command: ! $ find ../templates/ -name '*.html.orig' -exec rm {} \; All the backup files can be restored like this: ! $ find ../templates/ -name '*.html' -exec cp {}.orig {} \; --- 26,31 ---- After making sure that all the templates are converted successfully, the backup files can be deleted with the command: ! $ find ../templates/ -name '*.html.orig' -exec rm {} \; All the backup files can be restored like this: ! $ find ../templates/ -name '*.html' -exec cp {}.orig {} \; |