Code Search for Developers
 
 
  

post_process.php from SME Web Application Framework at Krugle


Show post_process.php syntax highlighted

#!/usr/bin/php -q
<?php
/**
 * This script replaces <cdata>nr</cdata> and <comment>nr</comment> 
 * by the corresponding <![CDATA[...]]> and <!--...-->
 * in the imploded xml file that is passed as argument.
 * <![CDATA[...]]> and <!--...--> are read from files where they
 * have been saved before by the script implode_strip_cdata.php
 */

if ($argc < 2)
{
  print "Usage: $argv[0] book_dir \n";
  exit(1);
}
$dir = $argv[1];

//get the contents of the file
$fname = $dir.'.xml';
$fcontents = file_get_contents($fname);

//replace <cdata>x</cdata> by the corresponding <![CDATA[...]]>
$arr_cdata = unserialize(file_get_contents("$dir/cdata.txt"));
for ($i=0; $i < sizeof($arr_cdata); $i++)
{
  $cdata = $arr_cdata[$i];
  $fcontents = str_replace("<cdata>$i</cdata>", $cdata, $fcontents);
}

//replace <comment>x</comment> by the corresponding <!--...-->
$arr_comments = unserialize(file_get_contents("$dir/comments.txt"));
for ($i=0; $i < sizeof($arr_comments); $i++)
{
  $fcontents = str_replace("<comment>$i</comment>", $arr_comments[$i], $fcontents);
}

//write back the modified xml file
$fp = fopen($fname, 'w');
fputs($fp, $fcontents);
fclose($fp);
?>




See more files for this project here

SME Web Application Framework

smewebapp intends to simplify the construction of web applications for informatization of the work of SME-s (small and medium enterprises), institutions, organizations etc.

Project homepage: http://sourceforge.net/projects/smewebapp
Programming language(s): JavaScript,PHP,Shell Script,XML
License: other

  implode.sh
  post_process.php
  pre_process.php
  section2sect.sh