Location: PHPKode > scripts > FuseBox Manager > fusebox-manager/index.php
<?
error_reporting(E_ALL & ~E_NOTICE & ~E_WARNING); //kinds of errors to track

//include "dBug.php";
require "Error.class.php";
require "FileUploadHandler.class.php";
require "FuseBoxManager.class.php";

$Error = new Error();

$simleXML_available = function_exists('simplexml_load_string');

if($simleXML_available)
{
  $show_log   = ( empty($_POST["Go"]) ? 1 : isset($_POST["show_log"]));
  $auto_files = ( empty($_POST["Go"]) ? 1 : isset($_POST["auto_files"]));
  $default_fa = ( empty($_POST["Go"]) ? 'auto' : $_POST["default_fa"]);
  
  if(!empty($_POST["Go"])) //form was submited
  {
    $target_folder = $_POST["target_folder"];
    $architect_name  = $_POST["architect_name"];
    $architect_email = $_POST["architect_email"];
    $xml_format = $_POST["xml_format"];
    $custom_fa  = $_POST["custom_fa"];
    
    $oFileUploadHandler = new FileUploadHandler("xml_source");
    
    if( !$oFileUploadHandler->ok )
    {
        $Error->text = 'Error while getting uploading file contents: ' . $oFileUploadHandler->get_error_text();
    }
    elseif(empty($target_folder) )
    {
      $Error->text = "Please define target folder";
    }
    else //OK
    {
      $xml_source = $oFileUploadHandler->get_file();
      $is_file = is_file($xml_source);
      
      if($is_file)
      {
        $xml = file_get_contents($xml_source);
      }
      
      if(!$is_file)
      {
        $Error->text = "Cannot read the uploaded file";
      }
      elseif(empty($xml))
      {
        $Error->text = "No data avaiable in the uploaded file";
      }
      else //OK
      {
        try
        {
          $oFBManager = new FuseBoxManager($xml_format, $xml, getcwd() . DIRECTORY_SEPARATOR .'src', $target_folder, $auto_files, $show_log);
          if($auto_files)
          {
            $oFBManager->set_architect_contacts($architect_name, $architect_email);
          }
          if('custom'== $default_fa && !empty($custom_fa))
          {
            $oFBManager->default_fuseaction = $custom_fa;
          }
          $oFBManager->create_project();
        }
        catch (Exception $e)
        {
          $Error->text =  "Error! " . $e->getMessage();
        }
      }
    }
  }
}
else
{
  $Error->text = 'No <a href="http://php.net/SimpleXML">SimpleXML</a> package available. Please add its support';
}
?>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
	<title>FuseBox manager :: <?=$oFBManager->project_name?></title>
<!--  <script src="js/dBug.js"></script>
  <link href="style/dBug.css"  rel="stylesheet" type="text/css" /> -->
  <script>
    function check_form()
    {
      var obj_inputs = {xml_source: 'Define XML source!', target_folder: 'Target folder cannot be empty'};
      for(id in obj_inputs) 
      {
        var inp=document.getElementById(id);
        if(null!=inp && ''==inp.value)
        {
          alert(obj_inputs[id]);
          inp.focus();
          inp.click(); //in IE this will open a file dialog for 'file' input
          return false;
        }
      }
      return true;
    }
    
    function disable_inp(id, checked)
    {
      var inp=document.getElementById(id);
      if(null!=inp)
      {
        inp.disabled = !checked;
      }
    }
  </script>
  <style>
  .edt
  {
  background:#ffffff; 
  border:3px double #aaaaaa; 
  -moz-border-left-colors:  #aaaaaa #ffffff #aaaaaa; 
  -moz-border-right-colors: #aaaaaa #ffffff #aaaaaa; 
  -moz-border-top-colors:   #aaaaaa #ffffff #aaaaaa; 
  -moz-border-bottom-colors:#aaaaaa #ffffff #aaaaaa; 
  width: 350px;
  }
  </style>
</head>
<body bgcolor="#f2f2f2">
  <h2 align="center">FuseBox manager</h2>
  <form method="POST" enctype="multipart/form-data">
    <table border="0" align="center">
      <tr>
      	<td><label for="xml_source" title="Choose an XML file on your disk. The file is exported from a mind-mapping program or site.">XML source:</label></td>
      	<td width="10px">&nbsp;</td>
      	<td><input type="file" title="Choose a file exported from a mind-mapping program or site on your disk." name="xml_source" id="xml_source" class="edt" value="<?=$xml_source?>" <?=($simleXML_available?'':'disabled="true"')?>/></td>
      </tr>
      <tr>
      	<td><label for="xml_format" title="List of currently supported formats.">XML format:</label></td>
      	<td width="10px">&nbsp;</td>
      	<td>
          <select name="xml_format" title="List of currently supported formats." id="xml_format" class="edt" <?=($simleXML_available?'':'disabled="true"')?>>
          <?php
            foreach($arr_supported_formats as $id=>$format)
            {
          ?>
            <option value="<?php echo $id?>" <?php echo ($xml_format==$id? 'selected="true"' : '') ?>><?php echo htmlspecialchars($format)?></option>
          <?php
            }
          ?>
          </select>
        </td>
      </tr>
      <tr>
      	<td><label for="target_folder" title="Define a folder to generate files to.">Target folder:</label></td>
      	<td width="10px">&nbsp;</td>
      	<td><input type="text" name="target_folder" title="Define a folder to generate files to." id="target_folder" class="edt" value="<?=(!empty($target_folder) ? $target_folder : 'c:\\temp\\FuseBoxProject')?>" <?=($simleXML_available?'':'disabled="true"')?>/></td>
      </tr>
      <tr>
      	<td colspan="3">&nbsp;</td>
      </tr>
      <tr>
      	<td rowspan="2"><label for="default_fa">Default fuseaction:</label></td>
      	<td rowspan="2">&nbsp;</td>
      	<td align="left">
          <input type="radio" name="default_fa" id="default_fa_auto" value="auto" onclick="disable_inp('custom_fa', this.selected);" <?=("auto"==$default_fa ? 'checked="true"' : '')?>" <?=($simleXML_available?'':'disabled="true"')?>/>
          <label for="default_fa_auto" title="Will be used first appeared circuit and fuse">Auto detect the default fuseaction</label>
        </td>
      </tr>
      <tr>
      	<td>
          <input type="radio" name="default_fa" id="default_fa_custom" value="custom" onclick="disable_inp('custom_fa', !this.selected);" <?=("custom"==$default_fa ? 'checked="true"' : '')?> <?=($simleXML_available || $auto_detect?'':'disabled="true"')?>/>
          <input type="text" name="custom_fa" id="custom_fa" title="Type custom fuseaction here. Example: home.main" class="edt" value="<?=(isset($custom_fa) ? $custom_fa : '')?>" <?=($simleXML_available && "auto"!=$default_fa?'':'disabled="true"')?>/>
        </td>
      </tr>
      <tr>
      	<td colspan="3">&nbsp;</td>
      </tr>
      <tr>
      	<td>&nbsp;</td>
      	<td colspan="2" align="left">
          <input type="checkbox" name="auto_files" id="auto_files" onclick="disable_inp('architect_name', this.checked);disable_inp('architect_email', this.checked);" <?=($auto_files ? 'checked="true"' : '')?>" <?=($simleXML_available?'':'disabled="true"')?>/>
          <label for="auto_files" title="Template files will be created corresponding to fuseactions list">Auto create the template files</label>
        </td>
      </tr>
      <tr>
      	<td><label for="architect_name" title="Name used in FuseDoc (template header)">Architect name:</label></td>
      	<td width="10px">&nbsp;</td>
      	<td><input type="text" name="architect_name" title="Name used in FuseDoc (template header)" id="architect_name" class="edt" value="<?=(isset($architect_name) ? $architect_name : 'Skakunov Alexander')?>" <?=($simleXML_available || !$auto_files?'':'disabled="true"')?>/></td>
      </tr>
      <tr>
      	<td><label for="architect_email" title="Email address used in FuseDoc (template header)">Architect email:</label></td>
      	<td width="10px">&nbsp;</td>
      	<td><input type="text" name="architect_email" title="Email address used in FuseDoc (template header)" id="architect_email" class="edt" value="<?=(isset($architect_email) ? $architect_email : 'hide@address.com')?>" <?=($simleXML_available || !$auto_files?'':'disabled="true"')?>/></td>
      </tr>
      <tr>
      	<td colspan="3">&nbsp;</td>
      </tr>
      <tr>
      	<td>&nbsp;</td>
      	<td colspan="2" align="left">
          <input type="checkbox" name="show_log" id="show_log" <?=($show_log ? 'checked="true"' : '')?>" <?=($simleXML_available?'':'disabled="true"')?>/>
          <label for="show_log" title="Debug messages will be shown below this form">Show log</label>
        </td>
      </tr>
      <tr>
      	<td colspan="3">&nbsp;</td>
      </tr>
      <tr>
      	<td colspan="3" align="center">
          <input type="Submit" name="Go" value="Generate a project" onclick="return check_form()" <?=($simleXML_available?'':'disabled="true"')?>/>
        </td>
      </tr>
    </table>

      <br>
      <br><br>
      
      
  </form>
  
<?php
echo $Error->display();
?>

<?
if(is_object($oFBManager))
{
  $oFBManager->show_verbose();
}
?>
</body>

</html>
Return current item: FuseBox Manager