Пример #1
0
function df_BuildCaptureForm($Element, $Defaults = false, $ViewOnly = false)
{
    global $wpdb;
    include_once DB_TOOLKIT . '/data_form/phpscaffold.php';
    //vardump($_GET);
    $Script = '';
    $Config = $Element['Content'];
    //vardump($Config);
    if (!empty($Config['_FormLayout'])) {
        parse_str($Config['_FormLayout'], $Columns);
    }
    if (!empty($Config['_Edit_Element_Reference'])) {
        $Element = getelement($Config['_Edit_Element_Reference']);
        $Config = $Element['Content'];
    }
    if (!empty($Defaults) && !empty($Config['_Show_Edit'])) {
        $EditID = $Defaults;
        // userbase lockdown
        $hardFilter = '';
        if (!empty($Config['_UserBaseFilter'])) {
            global $user_ID;
            if (!empty($user_ID)) {
                $harfilter = '';
                foreach ($Config['_UserBaseFilter'] as $userField => $yes) {
                    $hardFilter .= ' AND `' . $userField . '` = \'' . $user_ID . '\' ';
                }
            } else {
                // return hahaha no change matee!
                $Output['width'] = 220;
                $Output['html'] = '<div style="warning">That does not belong to you!</div>';
                return $Output;
            }
        }
        $defRes = mysql_query("SELECT * FROM `" . $Config['_main_table'] . "` WHERE `" . $Config['_ReturnFields'][0] . "` = '" . $EditID . "' " . $hardFilter . ";");
        $Query = "SELECT * FROM `" . $Config['_main_table'] . "` WHERE `" . $Config['_ReturnFields'][0] . "` = '" . $EditID . "' " . $hardFilter . ";";
        if (mysql_num_rows($defRes) == 0) {
            $Output['width'] = 220;
            $Output['html'] = '<div style="warning">That does not belong to you!</div>';
            return $Output;
        }
        //$Defaults = mysql_fetch_assoc($defRes);
        $Defaults = $wpdb->get_results($Query, ARRAY_A);
        $Defaults = $Defaults[0];
    } else {
        unset($Defaults);
    }
    // check for a failed insert
    if (!empty($_SESSION['failedProcess'][$Element['ID']]) && empty($Defaults)) {
        $Defaults = $_SESSION['failedProcess'][$Element['ID']]['Data'];
        $psudoDefault = true;
    }
    $Row = 'list_row2';
    $formID = rand(0, 999);
    $SubmitURL = getdocument($Element['ParentDocument']);
    if (!empty($Config['_FormMode']) && !empty($Config['_ItemViewPage'])) {
        $SubmitURL = getdocument($Config['_ItemViewPage']);
    }
    $customClass = '';
    if (!empty($Config['_FormClass'])) {
        $customClass = $Config['_FormClass'];
    }
    /// attempt to place in here
    ### DONT FORGET VALIDATION!!!!
    if (!empty($Config['_Required'])) {
        $_SESSION['dataform']['OutScripts'] .= "\n\t\t\tjQuery('#data_form_" . $Element['ID'] . "').validationEngine({\n\t\t\t  success :  false,\n\t\t\t  failure : function() {}\n\t\t\t });\n\n\t\t";
    }
    $Form = '';
    // Build Form layout
    $formStack = 'form-vertical';
    if (empty($Config['_grid']) || !empty($Config['_disableLayoutEngineform'])) {
        $formStack = 'form-horizontal';
        $Config['_grid']['row1']['col1'] = '100%';
        $Config['_gridLayout'] = '';
        $Layout = array();
        foreach ($Config['_Field'] as $Key => $val) {
            $Layout[$Key] = 'row1_col1';
        }
        $Config['_gridLayout'] = true;
    }
    if (!empty($Config['_gridLayout']) && !empty($Config['_grid'])) {
        if (empty($Layout)) {
            parse_str($Config['_gridLayout'], $Layout);
        }
        $Hidden = '<div class="formular"><form enctype="multipart/form-data" method="post" action="' . $_SERVER['REQUEST_URI'] . '" class="' . $formStack . ' ' . $customClass . '" id="data_form_' . $Element['ID'] . '" >';
        if (empty($_SESSION['processKey'])) {
            $_SESSION['processKey'] = uniqid(rand(100, 999) . '_processKey_');
        }
        $Hidden .= '<input type="hidden" name="processKey" id="processKey" value="' . $_SESSION['processKey'] . '" />';
        $Hidden .= '<input type="hidden" name="action" id="action" value="true" />';
        $Hidden .= '<input type="hidden" name="dataForm[' . $Element['ID'] . '][_control_' . uniqid() . ']" id="processKey_inner" value="' . $_SESSION['processKey'] . '" />';
        $FormLayout = new Layout('fluid');
        //$FormLayout->debug();
        $tmpLayout = array();
        $fildLocations = array();
        $columnCounter = 1;
        $rowIndex = 1;
        $layoutData = array();
        //apply validation script
        if (!empty($Config['_Required'])) {
            $_SESSION['dataform']['OutScripts'] .= "\n                jQuery('#data_form_" . $Element['ID'] . "').validationEngine({\n                  success :  false,\n                  failure : function() {}\n                 });\n            ";
        }
        foreach ($Config['_grid'] as $Columns) {
            $tmpStr = array();
            $columnIndex = 1;
            foreach ($Columns as $Column) {
                $tabs = '';
                $sections = '';
                $columnSpan = round($Column * 12 / 100);
                $tmpStr[] = $columnSpan;
                $Fields = array_keys($Layout, 'row' . $rowIndex . '_col' . $columnIndex);
                // insert input fields
                // check the config for visibility
                if (!empty($Fields)) {
                    $fieldIndex = 1;
                    foreach ($Fields as $Field) {
                        $Return = '';
                        if (empty($Config['_FormFieldWidth'][$Field])) {
                            $Config['_FormFieldWidth'][$Field] = 'input-medium';
                        }
                        $Field = str_replace('Field_', '', $Field);
                        $Req = false;
                        if (!empty($Config['_Required'][$Field])) {
                            $Req = 'validate[required]';
                        }
                        if (!empty($Config['_Unique'][$Field])) {
                            if (!empty($Req)) {
                                $Req = 'validate[required, ajax[ajaxUnique]]';
                            } else {
                                $Req = 'validate[optional, ajax[ajaxUnique]]';
                            }
                        }
                        $FieldSet = explode('_', $Config['_Field'][$Field]);
                        $name = $Config['_FieldTitle'][$Field];
                        if (file_exists(WP_PLUGIN_DIR . '/db-toolkit/data_form/fieldtypes/' . $FieldSet[0] . '/conf.php') && count($FieldSet) == 2) {
                            include WP_PLUGIN_DIR . '/db-toolkit/data_form/fieldtypes/' . $FieldSet[0] . '/conf.php';
                            if (!empty($Defaults[$Field])) {
                                $Val = esc_attr($Defaults[$Field]);
                            } else {
                                $Val = '';
                            }
                            if (!empty($FieldTypes[$FieldSet[1]]['visible']) && (empty($Config['_CloneField'][$Field]) || !empty($FieldTypes[$FieldSet[1]]['cloneview']))) {
                                $isValid = '';
                                if (!empty($_SESSION['failedProcess'][$Element['ID']]['Fields'][$Field])) {
                                    $isValid = 'fail';
                                }
                                ob_start();
                                include WP_PLUGIN_DIR . '/db-toolkit/data_form/fieldtypes/' . $FieldSet[0] . '/input.php';
                                $inputField = '<div class="control-group ' . $isValid . '">';
                                $inputField .= '<label class="control-label">' . $name . '</label>';
                                if (empty($Config['_placeHolderTitle'][$Field])) {
                                    $placeholder = '';
                                } else {
                                    $placeholder = $name;
                                }
                                $inputField .= '<div class="controls" id="form-field-' . $Field . '">';
                                $inputField .= ob_get_clean();
                                if (!empty($Config['_placeHolderTitle'][$Field])) {
                                    if (strpos($inputField, 'type="text') !== false) {
                                        $inputField = str_replace('<input', '<input placeholder="' . $name . '"', $inputField);
                                        $inputField = str_replace('<label class="control-label">' . $name . '</label>', '', $inputField);
                                    }
                                }
                                if (!empty($Config['_FieldCaption'][$Field])) {
                                    $inputField .= '<p class="help-block">' . $Config['_FieldCaption'][$Field] . '</p>';
                                }
                                $inputField .= '</div>';
                                $inputField .= '</div>';
                                $FormLayout->append($inputField, $columnCounter);
                            }
                            if (!empty($FieldTypes[$FieldSet[1]]['hidden'])) {
                                ob_start();
                                include WP_PLUGIN_DIR . '/db-toolkit/data_form/fieldtypes/' . $FieldSet[0] . '/input.php';
                                $Hidden .= ob_get_clean();
                            }
                        } else {
                            // Check for tabs and section breaks
                            // remember to close them before form renders.
                            if (substr($Field, 0, 4) == '_tab') {
                                //its a tab!
                                if (empty($tabStarted)) {
                                    $tabs = '<div id="tabs_row_' . $rowIndex . '_col_' . $columnCounter . '"><ul>';
                                    $tabStarted = true;
                                }
                                $tabs .= '<li><a href="#' . $Field . '">' . $Config['_Tab'][$Field]['Title'] . '</a></li>';
                                // start tab content
                                if (!empty($tabContentStarted)) {
                                    $FormLayout->append('</div>', $columnCounter);
                                }
                                $FormLayout->append('<div id="' . $Field . '">', $columnCounter);
                                $tabContentStarted = true;
                            } elseif (substr($Field, 0, 5) == '_html') {
                                //$FormLayout->append(, $columnCounter);
                                foreach ($Config['_Field'] as $fieldKey => $type) {
                                    if (!empty($Defaults)) {
                                        $Config['_html'][$Field]['Title'] = str_replace('{{' . $fieldKey . '}}', $Defaults[$fieldKey], $Config['_html'][$Field]['Title']);
                                    } else {
                                        $Config['_html'][$Field]['Title'] = str_replace('{{' . $fieldKey . '}}', '', $Config['_html'][$Field]['Title']);
                                    }
                                }
                                $FormLayout->append($Config['_html'][$Field]['Title'], $columnCounter);
                            }
                        }
                        $fieldIndex++;
                    }
                }
                if (!empty($tabStarted)) {
                    // end off tabs
                    $tabs .= '</ul>';
                    $tabStarted = false;
                    // send tab headers to top of column
                    $FormLayout->prepend($tabs, $columnCounter);
                    //end last tab content
                    $FormLayout->append('</div>', $columnCounter);
                    $tabContentStarted = false;
                    // send ending of tabs to end of column
                    $FormLayout->append('</div>', $columnCounter);
                    // Send Out Script to activate tabs
                    $_SESSION['dataform']['OutScripts'] .= "\n                        jQuery(\"#tabs_row_" . $rowIndex . "_col_" . $columnCounter . "\" ).tabs();\n                    ";
                }
                $columnCounter++;
                $columnIndex++;
            }
            $tmpLayout[] = implode(':', $tmpStr);
            $rowIndex++;
        }
        $FormLayout->setLayout(implode('|', $tmpLayout));
        // check for a failed insert
        if (!empty($_SESSION['failedProcess'][$Element['ID']])) {
            unset($_SESSION['failedProcess'][$Element['ID']]);
        }
        if (!empty($psudoDefault)) {
            unset($Defaults);
        }
        $buttonBar = '';
        if (!empty($Config['_FormMode']) || ($Config['_ViewMode'] == 'form' || empty($Config['_grid']))) {
            $ButtonText = 'Submit';
            if (!empty($Config['_SubmitButtonText'])) {
                $ButtonText = $Config['_SubmitButtonText'];
            }
            if (!empty($_GET[$Config['_ReturnFields'][0]])) {
                if (!empty($Config['_UpdateButtonText'])) {
                    $ButtonText = $Config['_UpdateButtonText'];
                }
            }
            $ButtonClass = '';
            if (!empty($Config['_SubmitButtonClass'])) {
                $ButtonClass = $Config['_SubmitButtonClass'];
            }
            if (!empty($_GET[$Config['_ReturnFields'][0]])) {
                if (!empty($Config['_UpdateButtonClass'])) {
                    $ButtonClass = $Config['_UpdateButtonClass'];
                }
            }
            $ButtonAlign = 'center';
            if (!empty($Config['_SubmitAlignment'])) {
                $ButtonAlign = $Config['_SubmitAlignment'];
            }
            $buttonBar .= '<div style="text-align: ' . $ButtonAlign . ';" class="form-actions">';
            $buttonBar .= '<button type="submit" name="captureEntry" id="submit_' . $Element['ID'] . '" class="btn ' . $ButtonClass . '">' . $ButtonText . '</button>';
            if (!empty($Config['_ShowReset'])) {
                $buttonBar .= ' <button type="reset" name="Reset" id="reset_' . $Element['ID'] . '" class="btn ' . $ButtonClass . '">Reset</button>';
            }
            $buttonBar .= '</div>';
        }
        if (!empty($Defaults)) {
            $Hidden .= '<input type="hidden" name="processKey" id="processKey" value="' . $_SESSION['processKey'] . '" />';
            $Hidden .= '<input type="hidden" name="dr_update" value="1" />';
            $Hidden .= '<input type="hidden" name="dataForm[EID]" value="' . $Element['ID'] . '" />';
            $Hidden .= '<input type="hidden" name="dataForm[' . $Config['_ReturnFields'][0] . ']" value="' . $EditID . '" />';
        }
        //vardump($layoutString);
        //vardump($layoutData);
        //vardump($Config['_grid']);
        $Form = $FormLayout->renderLayout();
        $Output['width'] = $Config['_popupWidth'];
        $Output['html'] = $Hidden . $Form . $buttonBar . '</form></div>';
        $Output['script'] = $Script;
        return $Output;
    }
}
Пример #2
0
function di_showItem($EID, $Item, $Setup = false)
{
    $Element = getelement($EID);
    $Config = $Element['Content'];
    $queryJoin = '';
    $queryWhere = array();
    $queryLimit = '';
    $querySelects = array();
    $WhereTag = '';
    $groupBy = '';
    $orderStr = '';
    $countSelect = '';
    // setup columns
    if (!empty($Config['_FormLayout'])) {
        parse_str($Config['_FormLayout'], $Columns);
        if (empty($Columns['FieldList_left'])) {
            unset($Columns);
            unset($Config['_FormLayout']);
        }
    }
    //setup Field Types
    foreach ($Config['_Field'] as $Field => $Type) {
        // explodes to:
        // [0] = Field plugin dir
        // [1] = Field plugin type
        $Config['_Field'][$Field] = explode('_', $Type);
    }
    // field type filters
    $joinIndex = 'a';
    foreach ($Config['_IndexType'] as $Field => $Type) {
        $querySelects[$Field] = 'prim.`' . $Field . '`';
    }
    if (!empty($Config['_CloneField'])) {
        foreach ($Config['_CloneField'] as $CloneKey => $Clone) {
            //echo 'BEFORE';
            //vardump($querySelects);
            foreach ($querySelects as $selectKey => $selectScan) {
                $queryJoin = str_replace($CloneKey, $Clone['Master'], $queryJoin);
                $WhereTag = str_replace($CloneKey, $Clone['Master'], $WhereTag);
                if (strstr($selectScan, " AS ") === false) {
                    //echo $Clone['Master'].' - concat <br />';
                    if (strstr($selectScan, "_sourceid_") === false) {
                        $querySelects[$selectKey] = str_replace($CloneKey, $Clone['Master'] . '` AS `' . $CloneKey, $selectScan);
                    }
                }
            }
            //echo 'After';
            //vardump($querySelects);
        }
    }
    // Build Query
    foreach ($Config['_Field'] as $Field => $Type) {
        // Run Filters that have been set through each field type
        if (file_exists(WP_PLUGIN_DIR . '/db-toolkit/data_form/fieldtypes/' . $Type[0] . '/queryfilter.php')) {
            include WP_PLUGIN_DIR . '/db-toolkit/data_form/fieldtypes/' . $Type[0] . '/queryfilter.php';
        }
        //apply a generic keyword filter to each field is a key word has been sent
        if (!empty($_SESSION['reportFilters'][$EID]['_keywords'])) {
            if ($WhereTag == '') {
                $WhereTag = " WHERE ";
            }
            $keyField = 'prim.' . $Field;
            if (strpos($querySelects[$Field], ' AS ') !== false) {
                $keyField = strtok($querySelects[$Field], ' AS ');
            }
            $preWhere[] = $keyField . " LIKE '%" . $_SESSION['reportFilters'][$EID]['_keywords'] . "%' ";
            //dump($_SESSION['reportFilters'][$EID]);
        }
        $joinIndex++;
    }
    //post clone fixes
    foreach ($querySelects as $fieldToFix => $select) {
        if (!empty($Config['_CloneField'][$fieldToFix])) {
            $cloneReturns[$fieldToFix] = explode(' AS ', $select);
        }
    }
    if (!empty($cloneReturns)) {
        foreach ($cloneReturns as $cloneKey => $cloneField) {
            $pureName = trim(str_replace('prim.', '', $cloneField[0]), '`');
            if (!empty($cloneReturns[$pureName])) {
                $cloneReturns[$cloneKey][0] = $cloneReturns[$pureName][0];
                $querySelects[$cloneKey] = implode(' AS ', $cloneReturns[$cloneKey]);
            }
        }
    }
    // create Query Selects and Where clause string
    $querySelect = implode(',', $querySelects);
    if (!empty($Setup)) {
        $queryWhere = 'prim.' . $Setup['_filterField'] . ' = \'' . $Item . '\'';
    } else {
        $queryWhere = 'prim.' . $Config['_ReturnFields'][0] . ' = \'' . $Item . '\'';
    }
    if (!empty($queryWhere)) {
        $WhereTag = " WHERE ";
    } else {
        $WhereTag = "";
    }
    if (is_array($groupBy)) {
        $groupBy = 'GROUP BY (' . implode(',', $groupBy) . ')';
        $countLimit = '';
        $entryCount = true;
        //add totals selects to count
        if (is_array($countSelect)) {
            $countSelect = ',' . implode(',', $countSelect);
        }
    }
    $Query = "SELECT " . $querySelect . " FROM `" . $Config['_main_table'] . "` AS prim \n " . $queryJoin . " \n " . $WhereTag . " \n " . $queryWhere . "\n " . $groupBy . " \n " . $orderStr . " \n LIMIT 1;";
    // Wrap fields with ``
    //foreach($querySelects as $Field=>$FieldValue){
    //   $Query = str_replace($Field, '`'.$Field.'`', $Query);
    //}
    // Query Results
    //$Res = mysql_query($Query);
    //echo $Query.'<br /><br /><br />';
    //echo mysql_error();
    //vardump($Config['_ReturnFields']);
    //$Data = mysql_fetch_assoc($Res);
    $Data = dr_BuildReportGrid($EID, false, false, false, 'data', false, array($Config['_ReturnFields'][0] => $Item));
    if (!empty($Config['_UseViewTemplate'])) {
        //dump($Config);
        $PreReturn = $Config['_ViewTemplateContentWrapperStart'];
        $PreReturn .= $Config['_ViewTemplatePreContent'];
        $PreReturn .= $Config['_ViewTemplateContent'];
        $PreReturn .= $Config['_ViewTemplatePostContent'];
        $PreReturn .= $Config['_ViewTemplateContentWrapperEnd'];
        //echo $Config['_ViewTemplateContent'];
        $newTitle = 'View Item';
        if (!empty($Config['_ViewFormText'])) {
            $newTitle = $Config['_ViewFormText'];
        }
        foreach ($Config['_Field'] as $Field => $Types) {
            if (!empty($Config['_ViewFormText'])) {
                //dump($Data);
                if (!empty($Data['_outvalue'][$Field])) {
                    $newTitle = str_replace('{{' . $Field . '}}', $Data['_outvalue'][$Field], $newTitle);
                } else {
                    $newTitle = str_replace('{{' . $Field . '}}', $Data[$Field], $newTitle);
                }
            }
            //	dump($Type);
            if (file_exists(WP_PLUGIN_DIR . '/db-toolkit/data_form/fieldtypes/' . $Types[0] . '/conf.php')) {
                if (!empty($Config['_FieldTitle'][$Field])) {
                    $name = $Config['_FieldTitle'][$Field];
                } else {
                    $name = df_parseCamelCase($Field);
                }
                $PreReturn = str_replace('{{_' . $Field . '_name}}', $name, $PreReturn);
                if (file_exists(WP_PLUGIN_DIR . '/db-toolkit/data_form/fieldtypes/' . $Types[0] . '/output.php')) {
                    $Out = false;
                    include WP_PLUGIN_DIR . '/db-toolkit/data_form/fieldtypes/' . $Types[0] . '/output.php';
                    $PreReturn = str_replace('{{' . $Field . '}}', $Out, $PreReturn);
                }
                $PreReturn = str_replace('{{_PageID}}', $Element['ParentDocument'], $PreReturn);
                $PreReturn = str_replace('{{_PageName}}', getdocument($Element['ParentDocument']), $PreReturn);
                $PreReturn = str_replace('{{_EID}}', $EID, $PreReturn);
            }
        }
        $Output['title'] = $newTitle;
        $Output['width'] = $Config['_popupWidthview'];
        $Output['html'] = $PreReturn;
        return $Output;
    }
    //dump($Data);
    $Row = 'list_row2';
    $LeftColumn = '';
    $RightColumn = '';
    $FarRightColumn = '';
    //vardump($Config);
    //dump($Config['_Field']);
    if (!empty($Config['_gridViewLayout'])) {
        //$Config['_gridViewLayout'] = str_replace('=viewrow', '=row', $Config['_gridLayoutView']);
        parse_str($Config['_gridViewLayout'], $Layout);
        //vardump($Config['_gridView']);
        //vardump($Layout);
        $Form = '';
        $CurrRow = '0';
        $CurrCol = '0';
        $Index = 0;
        $newTitle = 'View Item';
        if (!empty($Config['_ViewFormText'])) {
            $newTitle = $Config['_ViewFormText'];
        }
        //dump($Setup);
        foreach ($Config['_gridView'] as $row => $cols) {
            $Form .= "<div style=\"clear: both;\" class=\"view-gen-row\" id=\"pg-view-" . $row . "\">\n";
            foreach ($cols as $col => $width) {
                $Form .= "<div class=\"view-" . $row . "-" . $col . "\" style=\"float: left; overflow: hidden; width: " . $width . ";\">\n";
                $Form .= "<div id=\"pg-view-" . $row . "-" . $col . "\" class=\"view-gen-row view-gen-col view-col-" . $col . "\">\n";
                // check for section breaks
                $contentKeys = array_keys($Layout, $row . '_' . $col);
                foreach ($contentKeys as $Field) {
                    $Field = str_replace('View_Field_', '', $Field);
                    $FieldSet = $Config['_Field'][$Field];
                    if (file_exists(WP_PLUGIN_DIR . '/db-toolkit/data_form/fieldtypes/' . $FieldSet[0] . '/conf.php') && count($FieldSet) == 2) {
                        include WP_PLUGIN_DIR . '/db-toolkit/data_form/fieldtypes/' . $FieldSet[0] . '/conf.php';
                        if (!empty($FieldTypes[$FieldSet[1]]['visible']) && (empty($Config['_CloneField'][$Field]) || !empty($FieldTypes[$FieldSet[1]]['cloneview']))) {
                            // Check if is visible or not
                            $Out = false;
                            $Type = $FieldSet[1];
                            $Types = $FieldSet;
                            $Form .= "<label class=\"view-gen-lable singletext\" for=\"entry_" . $Element['ID'] . "_" . $Field . "\" id=\"lable_" . $Element['ID'] . "_" . $Field . "\">" . $Config['_FieldTitle'][$Field] . "</label>\n";
                            $Form .= "<div class=\"view-gen-field-data-wrapper\" id=\"view-data-" . $Field . "\">\n";
                            //$Val = $Defaults[$Field];]
                            include WP_PLUGIN_DIR . '/db-toolkit/data_form/fieldtypes/' . $FieldSet[0] . '/output.php';
                            //$Form = str_replace('{{'.$Field.'}}', $Out, $Form);
                            $Form .= $Out;
                            $Form .= "&nbsp;</div>\n";
                            $Form .= "<span class=\"description\" id=\"caption_" . $Element['ID'] . "_" . $Field . "\">\n";
                            $Form .= $Config['_FieldCaption'][$Field] . '&nbsp';
                            $Form .= "</span>\n";
                        } else {
                            if (empty($FieldTypes[$FieldSet[1]]['visible'])) {
                                ob_start();
                                $Val = $Defaults[$Field];
                                include WP_PLUGIN_DIR . '/db-toolkit/data_form/fieldtypes/' . $FieldSet[0] . '/input.php';
                                $Hidden .= ob_get_clean();
                            }
                        }
                    } else {
                        if (!empty($Config['_SectionBreak'][$Field])) {
                            $Form .= "<div class=\"sectionbreak\">\n";
                            $Form .= "<h2>" . $Config['_SectionBreak'][$Field]['Title'] . "</h2>\n";
                            if (!empty($Config['_SectionBreak'][$Field]['Caption'])) {
                                $Form .= "<span class=\"description\">" . $Config['_SectionBreak'][$Field]['Caption'] . "</span>\n";
                            }
                            $Form .= "</div>\n";
                        }
                        $Form .= '&nbsp;';
                    }
                }
                if (empty($contentKeys)) {
                    $Form .= '&nbsp;';
                }
                $Form .= "</div>\n";
                $Form .= "</div>\n";
            }
            $Form .= "</div>\n";
        }
        $Form .= '<div style="clear:left;"></div>';
        $Shown = '';
        // add title
        if (!empty($Config['_ViewFormText'])) {
            //dump($Data);
            if (!empty($Data['_outvalue'][$Field])) {
                $newTitle = str_replace('{{' . $Field . '}}', $Data['_outvalue'][$Field], $newTitle);
            } else {
                $newTitle = str_replace('{{' . $Field . '}}', $Data[$Field], $newTitle);
            }
            $Output['title'] = $newTitle;
        }
        $Output['width'] = '420';
        if (!empty($Config['_popupWidthview'])) {
            $Output['width'] = $Config['_popupWidthview'];
        }
        $Output['html'] = '<div class="formular">' . $Form . '</div>';
        if (!empty($Config['_Show_Edit'])) {
            $OutPut['edit'] = true;
        }
        return $Output;
    }
    if (!empty($Config['_FormLayout'])) {
        parse_str($Config['_FormLayout'], $Columns);
        if (empty($Columns['FieldList_left'])) {
            unset($Columns);
            unset($Config['_FormLayout']);
        }
    }
    if (!empty($Columns)) {
        foreach ($Columns as $Key => $Side) {
            if ($Key == 'FieldList_Main') {
                $ColumnSet = 'LeftColumn';
            }
            if ($Key == 'FieldList_left') {
                $ColumnSet = 'RightColumn';
            }
            if ($Key == 'FieldList_right') {
                $ColumnSet = 'FarRightColumn';
            }
            foreach ($Side as $Entry) {
                if (substr($Entry, 0, 12) != 'SectionBreak') {
                    $Row = dais_rowSwitch($Row);
                    $Field = $Entry;
                    $Types = $Config['_Field'][$Field];
                    ${$ColumnSet} .= $FieldSet[1];
                    //ob_start();
                    //dump($Config['_Field']);
                    //$$ColumnSet = ob_get_clean();
                    //$$ColumnSet .= $FieldSet[0].'<br />';
                    if (!empty($Config['_FieldTitle'][$Field])) {
                        $FieldTitle = $Config['_FieldTitle'][$Field];
                    } else {
                        $FieldTitle = df_parsecamelcase($Field);
                    }
                    if (!empty($Types[1])) {
                        include WP_PLUGIN_DIR . '/db-toolkit/data_form/fieldtypes/' . $Types[0] . '/conf.php';
                        if ($FieldTypes[$Types[1]]['visible'] == true) {
                            $Out = false;
                            $Out = '<div id="lable_' . $Element['ID'] . '_' . $Field . '" for="entry_' . $Element['ID'] . '_' . $Field . '" class="view-gen-lable"><strong>' . $FieldTitle . '</strong></div>';
                            include WP_PLUGIN_DIR . '/db-toolkit/data_form/fieldtypes/' . $Types[0] . '/output.php';
                            ${$ColumnSet} .= $Out;
                        }
                    }
                } else {
                    ${$ColumnSet} .= '<h3>' . $Config['_SectionBreak']['_' . $Entry] . '</h3>';
                }
            }
        }
    } else {
        foreach ($Config['_Field'] as $Field => $Types) {
            $Row = dais_rowswitch($Row);
            if (!empty($Types[1])) {
                if (!empty($Config['_FieldTitle'][$Field])) {
                    $FieldTitle = $Config['_FieldTitle'][$Field];
                } else {
                    $FieldTitle = df_parsecamelcase($Field);
                }
                include WP_PLUGIN_DIR . '/db-toolkit/data_form/fieldtypes/' . $Types[0] . '/conf.php';
                if ($FieldTypes[$Types[1]]['visible'] == true) {
                    $Out = false;
                    $Out = '<div id="lable_' . $Element['ID'] . '_' . $Field . '" for="entry_' . $Element['ID'] . '_' . $Field . '" class="view-gen-lable"><strong>' . $FieldTitle . '</strong></div>';
                    include WP_PLUGIN_DIR . '/db-toolkit/data_form/fieldtypes/' . $Types[0] . '/output.php';
                    //echo $Out;
                    if (!empty($Columns)) {
                        if (in_array($Field, $Columns['FieldList_Main'])) {
                            $LeftColumn .= $Out;
                        } elseif (in_array($Field, $Columns['FieldList_left'])) {
                            $RightColumn .= $Out;
                        }
                    } else {
                        $RightColumn .= $Out;
                    }
                }
            }
        }
    }
    if (!empty($Config['_titleField'])) {
        //infobox($Setup['_Prefix'].$Data[$Setup['_titleField']].$Setup['Suffix']);
        $OutPut['title'] = $Config['_Prefix'] . $Data[$Config['_titleField']] . $Config['Suffix'];
    } else {
        //echo '<h2>View Entry</h2>';
        $OutPut['title'] = 'View Entry';
        //$Setup['_Prefix'].$Data[$Setup['_titleField']].$Setup['Suffix'];
    }
    $Return = '<table width="100%" border="0" cellspacing="0" cellpadding="2">
		<tr>';
    $OutPut['width'] = 300;
    if (!empty($LeftColumn)) {
        $ColWidth = '33';
        if (empty($FarRightColumn)) {
            $ColWidth = '50';
        }
        $Return .= '<td width="' . $ColWidth . '%" valign="top">' . $LeftColumn . '</td>';
        $OutPut['width'] = $OutPut['width'] + 100;
    }
    if (!empty($RightColumn)) {
        $Return .= '<td valign="top">' . $RightColumn . '</td>';
        $OutPut['width'] = $OutPut['width'] + 100;
    }
    if (!empty($FarRightColumn)) {
        $Return .= '<td width="33%" valign="top">' . $FarRightColumn . '</td>';
        $OutPut['width'] = $OutPut['width'] + 100;
    }
    $Return .= '</tr>';
    $Return .= '</table>';
    if (!empty($Config['_Show_Edit'])) {
        $OutPut['edit'] = true;
        //$Return .= '<input type="button" value="Edit" class="close" onclick="dr_BuildUpDateForm('.$EID.', '.$Item.');" />';
    }
    if (!empty($Config['_EnableAudit'])) {
        $revres = mysql_query("SELECT count(_ID) as Rev FROM `_audit_" . $Config['_main_table'] . "` WHERE `" . $Config['_ReturnFields'][0] . "` = '" . $Data[$Config['_ReturnFields'][0]] . "';");
        if ($revres) {
            if (mysql_num_rows($revres) == 1) {
                $R = mysql_fetch_assoc($revres);
                $Return .= '<div class="captions">Revision ' . $R['Rev'] . '</div>';
            }
        }
    }
    $OutPut['html'] = $Return;
    return $OutPut;
}