The directory ' . $_POST['outputdir'] . ' did not exist.
'; } elseif(isset($_POST["Submit"]) && $_POST["Submit"] == "Generate Circuit") { $tablename = str_replace('_', '', strtolower($_POST['circuitname'])); /* if( strlen($_POST['table_name_override']) ) { //if the automatic name is same as the override, ignore the override if($tablename == $_POST['table_name_override']) { $_POST['table_name_override'] = ''; } else { $tablename = $_POST['table_name_override']; } } */ $pkfieldname = $tablename.'_id'; //if( $_POST['outputdir'] ///checking whether last character is a slash//// if( !isset($_POST['useIncludeInControl']) ) { $_POST['useIncludeInControl'] = 0; } if(strlen($_POST["contentvariable"]) > 0){ $cvname = stripslashes($_POST["contentvariable"]); } else { $cvname = null; } $circuitResults = array(); //We'll do the model circuit(s) first, because other circuits rely upon it. //First, the generic Model circuit $model = new ModelCircuit($_POST['outputdir'] . MODEL_FOLDER . DIRSEP . $_POST['circuitname'], MODEL_PREFIX . CIRCUIT_SEP . $_POST['circuitname'], $_POST['useIncludeInControl']); if(isset($_POST['fuseactions'])) { foreach($_POST['fuseactions'] as $fa) { switch($fa) { case 'select': $modelQuery = new ModelCircuit($_POST['outputdir'] . MODEL_FOLDER . DIRSEP . '_query', MODEL_PREFIX . CIRCUIT_SEP . 'query', $_POST['useIncludeInControl']); //figure out the name of the rs so we can use it in the model file $rsName = 'rsSelect'.ucfirst($_POST['circuitname']).'_byId'; //Only add actPrepareCreateEditForm if it's going to be used later by the add or edit control fuseactions if( in_array('add', $_POST['fuseactions']) || in_array('edit', $_POST['fuseactions']) ) { $content = file_get_contents('templates/PrepareCreateEditForm.php'); $content = str_replace('$PHPOPENTAG$', PHPOPENTAG, $content); $content = str_replace('$PHPCLOSETAG$', PHPCLOSETAG, $content); $content = str_replace('$RSNAME$', '$'.$rsName, $content); $content = str_replace('$PKFIELDNAME$', $pkfieldname, $content); $model->addFa(ACTPREFIX . 'PrepareCreateEditForm', array( $model->includeTag(ACTPREFIX . 'PrepareCreateEditForm', $content) ) ); } //setup the select model sub circuit $m_select = new ModelCircuit($model->folder . DIRSEP . $fa, MODEL_PREFIX . CIRCUIT_SEP . $_POST['circuitname'] . CIRCUIT_SEP . $fa, $_POST['useIncludeInControl']); //create the prefuseaction for the sub-circuit $m_select->addPrefuseaction(); /*setup prefuseaction */ //setup debugging options in the prefuseaction $show_query = (isset($_POST['select_show_query']) ? 'true' : 'false'); $show_resultSet = (isset($_POST['select_show_resultSet']) ? 'true' : 'false'); $run_query = (isset($_POST['select_run_query']) ? 'true' : 'false'); //setup manual overrides $short_name = (isset($_POST['select_short_name']) ? $_POST['select_short_name'] : ''); $table_name = (isset($_POST['table_name_override']) ? $_POST['table_name_override'] : ''); /*save prefuseaction*/ //add manual overrides to the object $m_select->addToLastTag( $m_select->setTag('short_name', $short_name) ); $m_select->addToLastTag( $m_select->setTag('table_name', $table_name) ); $m_select->addToLastTag( $m_select->setTag('rsDefault', '') ); //add debugging options to the object $m_select->addToLastTag($m_select->setTag('show_query', $show_query )); $m_select->addToLastTag($m_select->setTag('show_resultSet', $show_resultSet)); $m_select->addToLastTag($m_select->setTag('run_query', $run_query)); /*create and save postfuseaction */ $m_select->addPostfuseaction(array( //Fusebox 4: //$m_select->setTag('query_circuit', '{$myFusebox[\'thisCircuit\']}'), //$m_select->setTag('query_name', '{$myFusebox[\'thisFuseaction\']}'), //Fusebox 5: $m_select->setTag('query_circuit', '{$myFusebox->thisCircuit}'), $m_select->setTag('query_name', '{$myFusebox->thisFuseaction}'), $m_select->doTag('_query', 'runQuery') ) ); //create query all records for the sub-circuit $content = file_get_contents('templates/qryAll.php'); $content = str_replace('$PHPOPENTAG$', PHPOPENTAG, $content); $content = str_replace('$PHPCLOSETAG$', PHPCLOSETAG, $content); $m_select->addFa('all', array( $m_select->includeTag('all', $content) ) ); //create query by Id for the sub-circuit $content = file_get_contents('templates/qryById.php'); $content = str_replace('$PHPOPENTAG$', PHPOPENTAG, $content); $content = str_replace('$PHPCLOSETAG$', PHPCLOSETAG, $content); $content = str_replace('$PKFIELDNAME$', $pkfieldname, $content); $m_select->addFa('byId', array( $m_select->includeTag('byId', $content) ) ); //creates first step of select query automation for the sub-circuit $content = file_get_contents('templates/goQuery.php'); $content = str_replace('$PHPOPENTAG$', PHPOPENTAG, $content); $content = str_replace('$PHPCLOSETAG$', PHPCLOSETAG, $content); $content = str_replace('$MODEL_PREFIX$', MODEL_PREFIX, $content); $content = str_replace('$CIRCUIT_SEP$', CIRCUIT_SEP, $content); $modelQuery->addFa('goQuery', array( $modelQuery->includeTag('goQuery', $content) ) ); //creates second step of select query automation for the sub-circuit $content = file_get_contents('templates/goDebug.php'); $content = str_replace('$PHPOPENTAG$', PHPOPENTAG, $content); $content = str_replace('$PHPCLOSETAG$', PHPCLOSETAG, $content); $modelQuery->addFa('goDebug', array( $modelQuery->includeTag('goDebug', $content) ) ); //creates second step of select query automation for the sub-circuit $content = file_get_contents('templates/goCleanUp.php'); $content = str_replace('$PHPOPENTAG$', PHPOPENTAG, $content); $content = str_replace('$PHPCLOSETAG$', PHPCLOSETAG, $content); $modelQuery->addFa('goCleanUp', array( $modelQuery->includeTag('goCleanUp', $content) ) ); $circuitResults[] = $m_select->save(); $circuitResults[] = $modelQuery->save(); break; case 'insert': $m_insert = new ModelCircuit($model->folder . DIRSEP . $fa, MODEL_PREFIX . CIRCUIT_SEP . $_POST['circuitname'] . CIRCUIT_SEP . $fa, $_POST['useIncludeInControl']); //create query to insert record for the sub-circuit $content = file_get_contents('templates/qryInsert.php'); $content = str_replace('$PHPOPENTAG$', PHPOPENTAG, $content); $content = str_replace('$PHPCLOSETAG$', PHPCLOSETAG, $content); $content = str_replace('$TABLENAME$', $tablename, $content); $content = str_replace('$QUERYVARIABLENAME$', QUERYVARIABLENAME, $content); $content = str_replace('$CIRCUITNAME$', ucfirst($_POST['circuitname']), $content); $content = str_replace('$DBEXECUTIONSTRING$', DBEXECUTIONSTRING, $content); $m_insert->addFa('record', array( $m_insert->includeTag('record', $content) ) ); $circuitResults[] = $m_insert->save(); break; case 'update': $m_update = new ModelCircuit($model->folder . DIRSEP . $fa, MODEL_PREFIX . CIRCUIT_SEP . $_POST['circuitname'] . CIRCUIT_SEP . $fa, $_POST['useIncludeInControl']); //create query to update records for the sub-circuit $content = file_get_contents('templates/qryUpdate.php'); $content = str_replace('$PHPOPENTAG$', PHPOPENTAG, $content); $content = str_replace('$PHPCLOSETAG$', PHPCLOSETAG, $content); $content = str_replace('$QUERYVARIABLENAME$', QUERYVARIABLENAME, $content); $content = str_replace('$PKFIELDNAME$', $pkfieldname, $content); $content = str_replace('$TABLENAME$', $tablename, $content); $content = str_replace('$CIRCUITNAME$', ucfirst($_POST['circuitname']), $content); $content = str_replace('$DBEXECUTIONSTRING$', DBEXECUTIONSTRING, $content); $m_update->addFa('byId', array( $m_update->includeTag('byId', $content) ) ); $circuitResults[] = $m_update->save(); break; case 'delete': $m_delete = new ModelCircuit($model->folder . DIRSEP . $fa, MODEL_PREFIX . CIRCUIT_SEP . $_POST['circuitname'] . CIRCUIT_SEP . $fa, $_POST['useIncludeInControl']); //create query to delete records for the sub-circuit $content = file_get_contents('templates/qryDelete.php'); $content = str_replace('$PHPOPENTAG$', PHPOPENTAG, $content); $content = str_replace('$PHPCLOSETAG$', PHPCLOSETAG, $content); $content = str_replace('$QUERYVARIABLENAME$', QUERYVARIABLENAME, $content); $content = str_replace('$PKFIELDNAME$', $pkfieldname, $content); $content = str_replace('$TABLENAME$', $tablename, $content); $content = str_replace('$CIRCUITNAME$', ucfirst($_POST['circuitname']), $content); $content = str_replace('$DBEXECUTIONSTRING$', DBEXECUTIONSTRING, $content); $m_delete->addFa('byId', array( $m_delete->includeTag('byId', $content) ) ); $circuitResults[] = $m_delete->save(); break; } //end switch on fuseaction name } //end foreach on standard Model fuseactions } $circuitResults[] = $model->save(); $control = new ControlCircuit($_POST['outputdir'], $_POST['circuitname'], $_POST['useIncludeInControl']); $view = new ViewCircuit($_POST['outputdir'], $_POST['circuitname'], $_POST['useIncludeInControl']); if(isset($_POST['fuseactions'])) { if( in_array('add', $_POST['fuseactions']) || in_array('edit', $_POST['fuseactions']) ) { //figure out the name of the rs so we can use it in the view files $rsName = 'rsSelect'.ucfirst($_POST['circuitname']).'_byId'; //create view file & fuseaction $content = file_get_contents('templates/tplDspCreateEditForm.html'); $content = str_replace('$RS$', '$'.$rsName.DBRESULTSTRING, $content); $content = str_replace('$CIRCUITNAME$', ucfirst($_POST['circuitname']), $content); $content = str_replace('$PKFIELDNAME$', $pkfieldname, $content); $view->addFa(DSPPREFIX.'CreateEditForm', array( $view->includeTag(DSPPREFIX.'CreateEditForm', $content) ) ); } foreach($_POST['fuseactions'] as $fa) { switch($fa) { case 'list': //figure out the name of the rs so we can use it in the view files $rsName = 'rsSelect'.ucfirst($_POST['circuitname']).'_all'; //create view file & fuseaction $content = file_get_contents('templates/tplDspList.html'); $content = str_replace('$RS$', '$'.$rsName.DBRESULTSTRING, $content); $content = str_replace('$CIRCUITNAME$', ucfirst($_POST['circuitname']), $content); $content = str_replace('$PKFIELDNAME$', $pkfieldname, $content); $view->addFa(DSPPREFIX.'List', array( $view->includeTag(DSPPREFIX.'List', $content) ) ); //create control fuseaction $control->addFa('list'); //we put the "action" in "exit fuseactions" if( in_array('add', $_POST['fuseactions']) ) { $control->addToLastTag($control->xfaTag('newForm', $control->name.'.newForm')); } if( in_array('edit', $_POST['fuseactions']) ) { $control->addToLastTag($control->xfaTag('editForm', $control->name.'.editForm')); } if( in_array('remove', $_POST['fuseactions']) ) { $control->addToLastTag($control->xfaTag('delete', $control->name.'.delete')); } if( in_array('select', $_POST['fuseactions']) ) { $control->addToLastTag($control->doTag($m_select->name, 'all')); } $controlQuery = new ControlCircuit($_POST['outputdir'], '_query', $_POST['useIncludeInControl']); $controlQuery->addFa('runQuery'); $controlQuery->addToLastTag($controlQuery->doTag($modelQuery->name, 'goQuery')); $controlQuery->addToLastTag($controlQuery->doTag($modelQuery->name, 'goDebug')); $controlQuery->addToLastTag($controlQuery->doTag($modelQuery->name, 'goCleanUp')); $control->addToLastTag($control->doTag($view->name, DSPPREFIX . 'List', $cvname)); break; case 'add': //display the form $control->addFa('newForm', array( $control->xfaTag('submit', $control->name.'.insert'), $control->doTag($model->name, ACTPREFIX . 'PrepareCreateEditForm'), $control->doTag($view->name, DSPPREFIX . 'CreateEditForm', $cvname) ) ); //insert the record $control->addFa('insert', array( $control->doTag($m_insert->name, 'record'), $control->relocateTag('list') ) ); break; case 'edit': //display the form $control->addFa('editForm', array( $control->xfaTag('submit', $control->name.'.update'), $control->doTag($m_select->name, 'byId'), $control->doTag($model->name, ACTPREFIX . 'PrepareCreateEditForm'), $control->doTag($view->name, DSPPREFIX . 'CreateEditForm', $cvname) ) ); //update the record $control->addFa('update', array( $control->doTag($m_update->name, 'byId'), $control->relocateTag('list') ) ); break; case 'remove': //delete the record $control->addFa('delete', array( $control->doTag($m_delete->name, 'byId'), $control->relocateTag('list') ) ); break; } //end switch on fuseaction name } //end foreach on standard Control+View fuseactions } if(isset($_POST['custom'])) { foreach($_POST['custom'] as $fa) { if('' != $fa) { $control->addFa($fa, array( $control->doTag($view->name, DSPPREFIX . 'List', $cvname) ) ); } } //end foreach on custom Control fuseactions } $circuitResults[] = $control->save(); $circuitResults[] = $view->save(); if(isset($controlQuery)) { $circuitResults[] = $controlQuery->save(); } ?> <?php echo DOCTITLE; ?>

fusebox.xml

Add the following lines to your fusebox.xml file.

Under control:

	<circuit alias="name; ?>" path="folder); ?>" parent="c" />
	<circuit alias="name; ?>" path="folder); ?>" parent="c" />

Under model:

	<circuit alias="name; ?>" path="folder); ?>" parent="name; ?>" />

	<circuit alias="name; ?>" path="folder); ?>" parent="m" />

		<circuit alias="name; ?>" path="folder); ?>" parent="name; ?>" />

		<circuit alias="name; ?>" path="folder); ?>" parent="name; ?>" />

		<circuit alias="name; ?>" path="folder); ?>" parent="name; ?>" />

		<circuit alias="name; ?>" path="folder); ?>" parent="name; ?>" />

Under view:

	<circuit alias="name; ?>" path="folder, strlen($_POST['outputdir'])) ?>" parent="v" />


Results

'; foreach($circuitMsgs as $msg) { foreach($msg as $msgType => $msgText) //only happens once, so a foreach() isn't necessary just convenient { switch($msgType) { case 'circuitname': echo '
'.$msgText.'
'; break; case 'mkdir': echo '
Created Directory: '.$msgText.'
'; break; case 'circuitfile': echo '
Circuit file: '.$msgText.'
'; break; case 'includefile': echo '
Include file: '.$msgText.'
'; break; case 'error': echo '
Error: '.$msgText.'
'; break; default: echo '
'.$msgType.': '.$msgText.'
'; } //end switch } } //each message echo ''; } //each circuit ?>