<commit_before><?php
// Copyright: All contributers to the Umple Project
// This file is made available subject to the open source license found at:
// http://umple.org/license
require_once("compiler_config.php");

if (isset($_REQUEST["save"]))
{
  $input = $_REQUEST["umpleCode"];
  $filename = saveFile($input);
  echo $filename;
}
else if (isset($_REQUEST["load"]))
{
  $filename = $_REQUEST["filename"];
  $outputUmple = readTemporaryFile($filename);
  echo $outputUmple;
}
else if (isset($_REQUEST["action"]))
{
  handleUmpleTextChange();
}
else if (isset($_REQUEST["umpleCode"]))
{
  $input = $_REQUEST["umpleCode"];
  $language = $_REQUEST["language"];
  $outputErr = isset($_REQUEST["error"])?$_REQUEST["error"]:false;
 
  
  if ($language == "javadoc")
  {
     $language = "Java";
     $javadoc = True;
  }
  else
  {
    $javadoc = False;
  }
  
  if ($language == "Simulate")
  {
    $filename = saveFile("generate Php \"./\" --override-all;\n" . $input);
    executeCommand("java -jar umple.jar {$filename}");
    $filename = saveFile("generate Simulate \"./\" --override-all;\n" . $input);
    executeCommand("java -jar umple.jar {$filename}");
    $modelId = getFilenameId($filename);
    echo $modelId;
    return;
  }
  elseif (!in_array($language,array("Php","Java","Ruby","Cpp")))
  {  
    $filename = saveFile($input);
    $errorFilename = "{$filename}.erroroutput";
    
    $sourceCode = executeCommand("java -jar umplesync.jar -generate {$language} {$filename} 2> {$errorFilename}");
    $errors = getErrorHtml($errorFilename, 0);
    
    if ($language != "Json")
    {
      $sourceCode = htmlspecialchars($sourceCode);
    }
    
    if($outputErr == "true")
    	echo $errors ."<p>URL_SPLIT";
    	
    echo $sourceCode;
    return;
  }

  // Generate the Java, PHP, Ruby or Cpp and put it into the right directory
  $filename = saveFile("generate {$language} \"./{$language}/\" --override-all;\n" . $input);
  
  $outputFilename = "{$filename}.output";
  $errorFilename = "{$filename}.erroroutput";
  
  // Clean up any pre-existing java. php, ruby or cpp files
  $thedir = dirname($outputFilename);
  $toRemove = False;
  $rmcommand = "rm -rf ";
  foreach (glob("$thedir/{$language}") as $afile) {
    $rmcommand = $rmcommand . " " . $afile;
    $toRemove = True;
  }    
  if($toRemove) { exec($rmcommand); }
  
  $command = "java -jar umplesync.jar -source {$filename} 1> {$outputFilename} 2> {$errorFilename}";    
  exec($command);
  
  $sourceCode = readTemporaryFile($outputFilename);
  
  $sourceCode = str_replace("<?php","",$sourceCode);
  $sourceCode = str_replace("?>","",$sourceCode);
  $sourceCode = htmlspecialchars($sourceCode);
  
  $errhtml = getErrorHtml($errorFilename);
  
  if ($sourceCode == "")
  {
    $html = "
        // An error occurred interpreting your Umple code, please review it and try again.
        // If the problem persists, please email the Umple code to
        // the umple-help google group: <EMAIL>
        // or post an issue at http://bugs.umple.org -- the Umple issues page
        // We are aware that error messages are not useful or nonexistent and
        // we are working to fix that.";
        
    echo $errhtml ."<p>URL_SPLIT" . $html;
    
  }
  else
  {
    if ($javadoc)
    {
       $thedir = dirname($outputFilename);
       $theurldir = "ump/" . basename($thedir);
       exec("rm -rf " . $thedir . "/javadoc");
       
        $command = "/usr/bin/javadoc -d " . $thedir . "/javadoc -footer \"Generated by Umple\" " ;
              
      foreach (glob("$thedir/{$language}/*/*/*/*.java") as $afile) {
          $command = $command . " " . $afile;
       }
       
       foreach (glob("$thedir/{$language}/*/*/*.java") as $afile) {<commit_msg>Removing message that said there are no error messages<commit_after><?php
// Copyright: All contributers to the Umple Project
// This file is made available subject to the open source license found at:
// http://umple.org/license
require_once("compiler_config.php");

if (isset($_REQUEST["save"]))
{
  $input = $_REQUEST["umpleCode"];
  $filename = saveFile($input);
  echo $filename;
}
else if (isset($_REQUEST["load"]))
{
  $filename = $_REQUEST["filename"];
  $outputUmple = readTemporaryFile($filename);
  echo $outputUmple;
}
else if (isset($_REQUEST["action"]))
{
  handleUmpleTextChange();
}
else if (isset($_REQUEST["umpleCode"]))
{
  $input = $_REQUEST["umpleCode"];
  $language = $_REQUEST["language"];
  $outputErr = isset($_REQUEST["error"])?$_REQUEST["error"]:false;
 
  
  if ($language == "javadoc")
  {
     $language = "Java";
     $javadoc = True;
  }
  else
  {
    $javadoc = False;
  }
  
  if ($language == "Simulate")
  {
    $filename = saveFile("generate Php \"./\" --override-all;\n" . $input);
    executeCommand("java -jar umple.jar {$filename}");
    $filename = saveFile("generate Simulate \"./\" --override-all;\n" . $input);
    executeCommand("java -jar umple.jar {$filename}");
    $modelId = getFilenameId($filename);
    echo $modelId;
    return;
  }
  elseif (!in_array($language,array("Php","Java","Ruby","Cpp")))
  {  
    $filename = saveFile($input);
    $errorFilename = "{$filename}.erroroutput";
    
    $sourceCode = executeCommand("java -jar umplesync.jar -generate {$language} {$filename} 2> {$errorFilename}");
    $errors = getErrorHtml($errorFilename, 0);
    
    if ($language != "Json")
    {
      $sourceCode = htmlspecialchars($sourceCode);
    }
    
    if($outputErr == "true")
    	echo $errors ."<p>URL_SPLIT";
    	
    echo $sourceCode;
    return;
  }

  // Generate the Java, PHP, Ruby or Cpp and put it into the right directory
  $filename = saveFile("generate {$language} \"./{$language}/\" --override-all;\n" . $input);
  
  $outputFilename = "{$filename}.output";
  $errorFilename = "{$filename}.erroroutput";
  
  // Clean up any pre-existing java. php, ruby or cpp files
  $thedir = dirname($outputFilename);
  $toRemove = False;
  $rmcommand = "rm -rf ";
  foreach (glob("$thedir/{$language}") as $afile) {
    $rmcommand = $rmcommand . " " . $afile;
    $toRemove = True;
  }    
  if($toRemove) { exec($rmcommand); }
  
  $command = "java -jar umplesync.jar -source {$filename} 1> {$outputFilename} 2> {$errorFilename}";    
  exec($command);
  
  $sourceCode = readTemporaryFile($outputFilename);
  
  $sourceCode = str_replace("<?php","",$sourceCode);
  $sourceCode = str_replace("?>","",$sourceCode);
  $sourceCode = htmlspecialchars($sourceCode);
  
  $errhtml = getErrorHtml($errorFilename);
  
  if ($sourceCode == "")
  {
    $html = "
        // An error occurred interpreting your Umple code, please review it and try again.
        // If the problem persists, please email the Umple code to
        // the umple-help google group: <EMAIL>";
        
    echo $errhtml ."<p>URL_SPLIT" . $html;
    
  }
  else
  {
    if ($javadoc)
    {
       $thedir = dirname($outputFilename);
       $theurldir = "ump/" . basename($thedir);
       exec("rm -rf " . $thedir . "/javadoc");
       
        $command = "/usr/bin/javadoc -d " . $thedir . "/javadoc -footer \"Generated by Umple\" " ;
              
      foreach (glob("$thedir/{$language}/*/*/*/*.java") as $afile) {
          $command = $command . " " . $afile;
       }
       
       foreach (glob("$thedir/{$language}/*/*/*.java") as $afile) {
{'fraction_non_alphanumeric': 0.17819076250341623, 'fraction_numerical': 0.0010931948619841486, 'mean_word_length': 3.0615982241953383, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4802115', 'n_tokens_mistral': 2430, 'n_tokens_neox': 2393, 'n_words': 556}