define('IMG_DIR' , RES_PATH."/images"); require_once(ABS_PATH . "/autoload.php"); require_once(LIBS_PATH."/third-party/smarty/libs/Smarty.class.php"); include LIBS_PATH . "/classes/core/constants.php"; include LIBS_PATH . "/classes/core/connection.php"; include LIBS_PATH . "/classes/core/database.php"; include LIBS_PATH . "/classes/core/functions.php"; require_once(ABS_PATH . '/app.php');*/ $CrudGen = new CrudGenUtility(); if ($CrudGen->writeablePathsCreated() == false) { echo "Please create and fill the following Settings on vnd_site_settings: TemplatesWriteablePath, SrcWriteablePath, ClassesWriteablePath"; exit; } $Settings = new Settings(); $table_created = isset($_SESSION['crudgen']['table_created']) ? $_SESSION['crudgen']['table_created'] : ""; if (isset($_REQUEST['doSetTable'])) { $use_table = isset($_REQUEST['use_table']) ? trim($_REQUEST['use_table'] . chr(32)) : ""; $_SESSION['crudgen']['table_created'] = $use_table; } else { if (isset($_REQUEST['doRun'])) { if (!is_writable($Settings->settings['TemplatesWriteablePath']) || !is_writable($Settings->settings['SrcWriteablePath']) || !is_writable($Settings->settings['ClassesWriteablePath'])) { echo "One of the following paths needs to be writable but is not: " . $Settings->settings['TemplatesWriteablePath'] . ", " . $Settings->settings['SrcWriteablePath'] . ", " . $Settings->settings['ClassesWriteablePath']; exit; }
<?php CrudGenUtility::createSrcPathIfNotExists($save_path); $fp = fopen($Settings->settings['SrcWriteablePath'] . $save_path, 'w'); $querystring_varspass = ""; foreach ($varsPassArr as $index => $getVar) { if ($index == 0) { $querystring_varspass = $getVar . "=" . '{$' . $getVar . '}'; } else { $querystring_varspass .= "&" . $getVar . "=" . '{$' . $getVar . '}'; } } $content = ""; $content .= "<?php \n\n"; foreach ($varsPassArr as $getVar) { $content .= '$' . $getVar . ' = Request::Field("' . $getVar . '"); ' . "\n"; } $content .= '$' . $keyLabel . "\t\t\t\t" . '= intval(Request::Field(\'' . $keyLabel . '\'));' . "\n"; foreach ($includeArr as $key) { if ($i > 0) { $content .= '$fieldsArr[\'' . $key . '\']' . "\t\t\t\t" . '= Request::Field(\'' . $key . '\');' . "\n"; } $i++; } $content .= "\n"; $content .= '$' . $className . ' = new ' . $className . '($' . $keyLabel . ');' . "\n"; $content .= 'if (FieldValidator::validateFields($fieldsArr, $' . $className . ') != 1) {' . "\n"; $content .= "\t" . 'Redirect("' . SITE_ROOT . str_replace(".php", "", $editPath) . '?Message=" . urlencode(FieldValidator::$error) . "&novalid=1&" . Request::getQueryString()); ' . "\n"; $content .= "} \n\n"; $content .= 'if ($' . $keyLabel . ' == 0) { ' . "\n\n"; $entrydate_field = "";
<?php CrudGenUtility::createSrcPathIfNotExists($editPath); $fp = fopen($Settings->settings['SrcWriteablePath'] . $editPath, 'w'); $content = '<?php' . "\n"; foreach ($varsPassArr as $getVar) { $content .= '$' . $getVar . ' = Request::Field("' . $getVar . '"); ' . "\n"; } $content .= '$' . $keyLabel . ' = intval(Request::Field("' . $keyLabel . '"));'; $content .= ' $' . $className . ' = new ' . $className . '($' . $keyLabel . '); if ($' . $keyLabel . ' < 1 && Request::Wants("novalid")) { $' . $className . '->loadFromRequest(); } $Message = Request::Field("Message"); $Message = showMessage($Message, Request::Wants("novalid")); ' . "\n"; foreach ($varsPassArr as $getVar) { $content .= '$Smarty->assign("' . $getVar . '", $' . $getVar . ');' . "\n"; } $content .= '$Smarty->assign("Message", $Message); $Smarty->assign("Get' . $className . '", $' . $className . '->data); $Smarty->assign("' . $keyLabel . '", $' . $keyLabel . '); $Smarty->display("' . substr($editTemplatePath, 1, strlen($editTemplatePath) - 1) . '"); ?>'; fwrite($fp, $content); fclose($fp);
CrudGenUtility::createTemplatesPathIfNotExists($template_path); $fp = fopen($Settings->settings['TemplatesWriteablePath'] . $template_path, 'w'); # Datalist Content # $fp1 = fopen(LIBS_PATH . "/templates/editform.tpl", 'r'); $content = fread($fp1, filesize(LIBS_PATH . "/templates/editform.tpl")); fclose($fp1); # Datalist Content # $fp2 = fopen(LIBS_PATH . "/templates/editform_fields.tpl", 'r'); $fields_content = fread($fp2, filesize(LIBS_PATH . "/templates/editform_fields.tpl")); fclose($fp2); $s_word = "s"; $content = str_replace("##KeyLabel##", $keyLabel, $content); $content = str_replace("##KeyLabel-PHP##", '{$' . $keyLabel . '}', $content); $content = str_replace("##ItemLabel##", $itemLabel, $content); $content = str_replace("##s_word##", $s_word, $content); $content = str_replace("##datalistLink", $src_path, $content); $content = str_replace("##formAction", $editform_action, $content); $fields_content_str = ""; foreach ($includeArr as $key => $value) { $get_fields_content = $fields_content; $fieldKey = CrudGenUtility::getField($key); $get_fields_content = str_replace("##FieldKey##", $fieldKey, $get_fields_content); $get_fields_content = str_replace("##Key##", $key, $get_fields_content); $get_fields_content = str_replace("##MemberKey-PHP##", '{$' . $Key . '}', $get_fields_content); $fields_content_str .= $get_fields_content; } $content = str_replace("##FieldInputs##", $fields_content_str, $content); fwrite($fp, $content); fclose($fp); echo "bbb";
$datalist_content = str_replace("##Search-Inputs##", $search_input_str, $datalist_content); if ($search_input_str != "") { $datalist_content = str_replace("##Search-Btn##", '<a href="javascript:void(0)" onclick="$(\'#frmSearch\').submit();" class="btn btn-primary">Search</a>', $datalist_content); } else { $datalist_content = str_replace("##Search-Btn##", '', $datalist_content); } ## ## Rows - Labels ## $fp4 = fopen(LIBS_PATH . "/templates/datalist-labelcolumns.tpl", 'r'); $datalist_rowlabels = fread($fp4, filesize(LIBS_PATH . "/templates/datalist-labelcolumns.tpl")); fclose($fp4); $row_labels_str = ""; foreach ($resultset[0] as $key => $value) { $rowlabels_getrow = $datalist_rowlabels; if (in_array($key, $includeArr)) { $keyField = CrudGenUtility::getField($key); $rowlabels_getrow = str_replace("##Row-Label##", $keyField, $rowlabels_getrow); $row_labels_str .= "\n" . $rowlabels_getrow; } } $datalist_content = str_replace("##Value-Columns##", $row_labels_str, $datalist_content); ## ## Rows - Values ## $fp5 = fopen(LIBS_PATH . "/templates/datalist-value-eachcolumn.tpl", 'r'); $datalist_row_eachcolumn = fread($fp5, filesize(LIBS_PATH . "/templates/datalist-value-eachcolumn.tpl")); fclose($fp5); $get_rowvalue_str = ""; foreach ($resultset[0] as $key => $value) { $get_rowvalue = $datalist_row_eachcolumn; if (in_array($key, $includeArr)) { $content .= "<td>";