示例#1
0
function enum_showFilter($Field, $Type, $Default, $Config, $EID)
{
    $FieldTitle = df_parseCamelCase($Field);
    if (!empty($Config['_FieldTitle'][$Field])) {
        $FieldTitle = $Config['_FieldTitle'][$Field];
    }
    $Return .= '<div class="filterField" ' . $Class . '"><h2>' . $FieldTitle . '</h2>';
    // ------ //
    $result = mysql_query("SHOW COLUMNS FROM `" . $Config['_main_table'] . "`");
    if (mysql_num_rows($result) > 0) {
        while ($row = mysql_fetch_assoc($result)) {
            if ($row['Field'] == $Field) {
                $Enum = $row['Type'];
            }
        }
    } else {
        return;
    }
    preg_match_all("/'(.*?)'/", $Enum, $Vals);
    $Out .= '<select class="filterBoxes" id="filter_' . $Field . '" name="reportFilter[' . $EID . '][' . $Field . '][]" multiple="multiple" size="1">';
    $Out .= '<option value="">Select All</option>';
    foreach ($Vals[1] as $Value) {
        $Sel = '';
        if (!empty($Default[$Field])) {
            if (in_array($Value, $Default[$Field])) {
                $Sel = 'selected="selected"';
            }
        }
        $Out .= '<option value="' . $Value . '" ' . $Sel . ' >' . $Value . '</option>';
    }
    $Return .= $Out . '</select>&nbsp;&nbsp;&nbsp;</div>';
    $_SESSION['dataform']['OutScripts'] .= "\r\n        jQuery(\"#filter_" . $Field . "\").multiselect();\r\n";
    return $Return;
}
示例#2
0
function tagging_showFilter($Field, $Type, $Default, $Config, $EID)
{
    $FieldTitle = df_parseCamelCase($Field);
    if (!empty($Config['_FieldTitle'][$Field])) {
        $FieldTitle = $Config['_FieldTitle'][$Field];
    }
    $Return .= '<div class="filterField ' . $Class . '"><h2>' . $FieldTitle . '</h2>';
    $Return .= '<input type="text" id="filter_' . $Field . '" name="reportFilter[' . $EID . '][' . $Field . ']" value="' . $Default[$Field] . '" ' . $Sel . ' />&nbsp;&nbsp;&nbsp;</div>';
    $autoComplete = '';
    if (!empty($Config['_tagBase'][$Field])) {
        $autoComplete = "autocomplete_url:'?taggingAction=" . $EID . "&field=" . $Field . "',";
    }
    $_SESSION['dataform']['OutScripts'] .= "\r\n            jQuery('#filter_" . $Field . "').tagsInput({\r\n                    height: 'auto',\r\n                    width: 'auto',\r\n                    " . $autoComplete . "\r\n                    'defaultText':'" . $Config['_tagText'][$Field] . "'                    \r\n        });";
    return $Return;
}
示例#3
0
function select_showFilter($Field, $Type, $Default, $Config, $EID)
{
    $FieldTitle = '';
    if (!empty($Config['_FieldTitle'][$Field])) {
        $FieldTitle = df_parseCamelCase($Config['_FieldTitle'][$Field]);
    }
    $Class = '';
    $text = '';
    if (!empty($Default[$Field])) {
        $Class = 'class="highlight"';
        $text = $Default[$Field];
    }
    $UID = uniqid(rand(1, 999));
    $Return = '<div class="filterField ' . $Class . '"><h2>' . $FieldTitle . '</h2>';
    $Return .= '<select type="text" name="reportFilter[' . $EID . '][' . $Field . '][]" multiple="multiple" size="1" class="filterBoxes" id="filter_' . $EID . '_' . $UID . '">';
    foreach ($Config['_SelectOptions'][$Field] as $optionValue) {
        $sel = '';
        if (!empty($Default[$Field])) {
            if (in_array($optionValue, $Default[$Field])) {
                $sel = 'selected="selected"';
            }
        }
        $Return .= '<option value="' . $optionValue . '" ' . $sel . '>' . $optionValue . '</option>';
    }
    $Return .= '</select>';
    $Return .= '</div>';
    $_SESSION['dataform']['OutScripts'] .= "\r\n        jQuery(\"#filter_" . $EID . "_" . $UID . "\").multiselect();\r\n    ";
    return $Return;
}
示例#4
0
function df_reloadFormField($EID, $Field, $Default = false)
{
    global $wpdb;
    $source = explode('|', $Field);
    $Element = getelement($source[0]);
    $Config = $Element['Content'];
    $Field = $source[1];
    if (!empty($Default)) {
        parse_str($Default, $Defaults);
        foreach ($Defaults as $default) {
            $Defaults[$Field] = $default;
            break;
        }
    }
    $FieldSet = explode('_', $Config['_Field'][$Field]);
    $name = df_parseCamelCase($Field);
    if (!empty($Config['_FieldTitle'][$Field])) {
        $name = $Config['_FieldTitle'][$Field];
    }
    $Req = false;
    if (!empty($Config['_Required'][$Field])) {
        $name = '<span style="color:#ff0000;">*</span>' . $name;
        $Req = 'validate[required]';
    }
    if (!empty($Config['_Unique'][$Field])) {
        if (!empty($Req)) {
            $Req = 'validate[required, ajax[ajaxUnique]]';
        } else {
            $Req = 'validate[optional, ajax[ajaxUnique]]';
        }
    }
    ob_start();
    if (!empty($Defaults[$Field])) {
        $Val = esc_attr($Defaults[$Field]);
    } else {
        $Val = '';
    }
    if (!empty($Config['_readOnly'][$Field])) {
        $func = $FieldSet[0] . '_processValue';
        if (function_exists($func)) {
            echo $func($Val, $FieldSet[1], $Field, $Config, $Element['ID'], $Defaults);
        }
    } else {
        include WP_PLUGIN_DIR . '/db-toolkit/data_form/fieldtypes/' . $FieldSet[0] . '/input.php';
    }
    $Pre = ob_get_clean();
    $Output['html'] = $Pre;
    $Output['element'] = 'form-field-' . $Field;
    return $Output;
}
示例#5
0
function text_showFilter($Field, $Type, $Default, $Config, $EID)
{
    $FieldTitle = '';
    if (!empty($Config['_FieldTitle'][$Field])) {
        $FieldTitle = df_parseCamelCase($Config['_FieldTitle'][$Field]);
    }
    $Class = '';
    $text = '';
    if (!empty($Default[$Field])) {
        $Class = 'class="highlight"';
        $text = $Default[$Field];
    }
    $UID = uniqid(rand(1, 999));
    if (!isset($text)) {
        $Return .= '<div class="filterField ' . $Class . '"><h2>' . $FieldTitle . '</h2>';
        if ($Type == 'integer') {
            $Return .= '<input type="text" name="reportFilter[' . $EID . '][' . $Field . '][]" class="filterSearch" id="filter_' . $EID . '_' . $UID . 'from" value="' . $text[0] . '"  size="12" style="width: 100px;" /> to ';
            $Return .= '<input type="text" name="reportFilter[' . $EID . '][' . $Field . '][]" class="filterSearch" id="filter_' . $EID . '_' . $UID . 'to" value="' . $text[1] . '"  size="12" style="width: 100px;" />';
            $Return .= '</div>';
        } else {
            $Return .= '<input type="text" name="reportFilter[' . $EID . '][' . $Field . ']" class="filterSearch" id="filter_' . $EID . '_' . $UID . '" value="' . $text . '" />';
        }
    }
    return $Return;
}
示例#6
0
 $newCol = 1;
 foreach ($cols as $col => $width) {
     echo '<div class="columnView" id="viewRow' . $newRow . '_viewCol' . $newCol . '" style="padding: 0pt; margin: 0pt; width: ' . $width . '; float: left;">';
     echo '<input type="hidden" value="' . $width . '" name="Data[Content][_gridView][viewRow' . $newRow . '][viewCol' . $newCol . ']" class="viewRow' . $newRow . '_controlView" id="viewRow' . $newRow . '_viewCol' . $newCol . '_controlView">';
     //row'.$newRow.'_col'.$newCol.'';
     echo '<div style="padding: 10px; margin: 10px; " class="ui-state-error viewGridview viewColumn ui-sortable">';
     $content = array_keys($layout, $row . '_' . $col);
     if (!empty($content)) {
         $output = '';
         foreach ($content as $render) {
             //$dta = get_option($render);
             $Name = str_replace('View_', '', $render);
             if (!empty($cfg['_FieldTitle'][$render])) {
                 $name = $cfg['_FieldTitle'][$render];
             } else {
                 $name = df_parseCamelCase($Name);
             }
             if (!empty($cfg['_SectionBreak'][$render])) {
                 $output .= '<div style="padding: 3px;" class="viewportlet list_row4 table_sorter sectionBreak ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" id="SectionBreak' . $render . '"><div class="viewportlet-header ui-corner-all"><span class="ui-icon ui-icon-close"></span><img align="absmiddle" class="OrderSorter" src="data_report/arrow_out.png" style=""/><strong>Title:</strong> <input type="text" class="sectionTitle" name="Data[Content][_SectionBreak][' . $render . '][Title]" value="' . $cfg['_SectionBreak'][$render]['Title'] . 'asdasd" /></div><div style="padding:3px;"><strong>Caption:</strong> <input type="text" class="sectionTitle" name="Data[Content][_SectionBreak][' . $render . '][Caption]" value="' . $cfg['_SectionBreak'][$render]['Caption'] . '" /></div><input class="layOutview positioning" type="hidden" name="' . $render . '" id="' . $render . '" value="row' . $newRow . '_col' . $newCol . '"/></div>';
                 $_SESSION['dataview']['OutScripts'] .= "\n                                                jQuery('.viewportlet-header .ui-icon').click(function() {\n                                                        jQuery(this).toggleClass(\"ui-icon-minusthick\");\n                                                        jQuery(this).parents(\".viewportlet:first\").remove();\n                                                });\n                                            ";
             } elseif (!empty($cfg['_Tabs'][$render])) {
             } elseif (substr($render, 0, 11) == 'View_Field_') {
                 $output .= '<div class="viewportlet ui-widget ui-widget-content ui-helper-clearfix ui-corner-all" id="viewportlet_' . $render . '"><div class="viewportlet-header ui-corner-all"><span class="ui-icon ui-icon-close"></span><div><strong>' . $name . '</strong></div><span class="description">field: ' . str_replace('View_Field_', '', $render) . '</span><input class="layOutview positioning" type="hidden" name="' . $render . '" id="interface_' . $render . '" value="viewRow' . $newRow . '_viewCol' . $newCol . '"/></div></div>';
                 $_SESSION['dataview']['OutScripts'] .= "\n                                                jQuery('.viewportlet-header .ui-icon').click(function() {\n                                                        jQuery(this).toggleClass(\"ui-icon-minusthick\");\n                                                        jQuery(this).parents(\".viewportlet:first\").remove();\n                                                });\n                                            ";
             }
         }
         echo $output;
     } else {
         echo '';
     }
     echo '</div>';
示例#7
0
function date_showFilter($Field, $Type, $Default, $Config, $EID)
{
    $FieldTitle = '';
    if (!empty($Config['_FieldTitle'][$Field])) {
        $FieldTitle = df_parseCamelCase($Field);
    }
    $Class = '';
    $DateFrom = '';
    //date('Y-m-d', strtotime('last week'));
    if (!empty($Default[$Field][0])) {
        $DateFrom = $Default[$Field][0];
        $Class = 'highlight';
    }
    $DateTo = '';
    //date('Y-m-d', strtotime('next week'));
    if (!empty($Default[$Field][1])) {
        $DateTo = $Default[$Field][1];
    }
    $UID = uniqid(rand(1, 999));
    $Return = '<div class="filterField ' . $Class . '"><h2>' . $FieldTitle . '</h2>';
    $Return .= '<input type="text" name="reportFilter[' . $EID . '][' . $Field . '][]" class="filterSearch" id="startRange_' . $EID . '_' . $UID . '" value="' . $DateFrom . '" size="12" style="width: 100px;" /> to';
    $Return .= '<input type="text" class="filterSearch" name="reportFilter[' . $EID . '][' . $Field . '][]" id="endRange_' . $EID . '_' . $UID . '" value="' . $DateTo . '" size="12" style="width: 100px;" />&nbsp;';
    $Return .= '</div>';
    $_SESSION['dataform']['OutScripts'] .= "\n\t\t\t\tjQuery.getScript(\"" . DBT_URL . "/data_form/fieldtypes/date/js/bootstrap-datepicker.js\", function(data, textStatus, jqxhr) {\n\t\t\t\t\tjQuery('#startRange_" . $EID . "_" . $UID . "').datepicker({\n\t\t\t\t\t\tformat: 'yyyy-mm-dd',\n\t\t\t\t\t}).on('changeDate', function(ev){\n\t\t\t\t\t\tjQuery('#startRange_" . $EID . "_" . $UID . "').datepicker('hide');\n\t\t\t\t\t});\n\t\t\t\t\tjQuery('#endRange_" . $EID . "_" . $UID . "').datepicker({\n\t\t\t\t\t\tformat: 'yyyy-mm-dd'\n\t\t\t\t\t}).on('changeDate', function(ev){\n\t\t\t\t\t\tjQuery('#endRange_" . $EID . "_" . $UID . "').datepicker('hide');\n\t\t\t\t\t});\n\t\t\t\t});\n\t\t\t\n\t\t\t";
    return $Return;
}
示例#8
0
         }
         // Add data to template
         //echo $Config['_layoutTemplate']['_Content']['_content'][$key];
         // data
         //$row[$Field]
         $outContent = $PreReturn;
     }
     $rowIndex++;
     echo $outContent;
 }
 $preFooter = $Config['_layoutTemplate']['_Content']['_after'][$key];
 foreach ($Config['_Field'] as $footField => $type) {
     if (!empty($Config['_FieldTitle'][$footField])) {
         $name = $Config['_FieldTitle'][$footField];
     } else {
         $name = df_parseCamelCase($footField);
     }
     $preFooter = str_replace('{{_' . $footField . '_name}}', $name, $preFooter);
     $preFooter = str_replace('{{_' . $footField . '}}', $footField, $preFooter);
     $preFooter = str_replace('{{_footer_first}}', $firstpagebutton, $preFooter);
     $preFooter = str_replace('{{_footer_prev}}', $prevbutton, $preFooter);
     $preFooter = str_replace('{{_footer_next}}', $nextbutton, $preFooter);
     $preFooter = str_replace('{{_footer_last}}', $lastpagebutton, $preFooter);
     $preFooter = str_replace('{{_footer_pagecount}}', $pagecount, $preFooter);
     $preFooter = str_replace('{{_footer_pagination}}', $pagination, $preFooter);
     $preFooter = str_replace('{{_footer_page_jump}}', $pagejump, $preFooter);
     $preFooter = str_replace('{{_footer_item_count}}', $itemcount, $preFooter);
     $preFooter = str_replace('{{_footer_no_entries}}', $noentries, $preFooter);
     $preFooter = str_replace('{{_EID}}', $Media['ID'], $preFooter);
     $preHeader = ';';
 }
示例#9
0
function onoff_showFilter($Field, $Type, $Default, $Config, $EID)
{
    $FieldTitle = df_parseCamelCase($Field);
    if (!empty($Config['_FieldTitle'][$Field])) {
        $FieldTitle = $Config['_FieldTitle'][$Field];
    }
    $Return .= '<div class="filterField ' . $Class . '"><h2>' . $FieldTitle . '</h2>';
    $Out .= '<select class="filterBoxes" id="filter_' . $Field . '" name="reportFilter[' . $EID . '][' . $Field . '][]" multiple="multiple" size="1">';
    $Out .= '<option value="">Select Both</option>';
    $Sel = '';
    if (!empty($Default[$Field])) {
        if (in_array('unchecked', $Default[$Field])) {
            $Sel = 'selected="selected"';
        }
    }
    $Out .= '<option value="unchecked" ' . $Sel . ' >Unchecked</option>';
    $Sel = '';
    if (!empty($Default[$Field])) {
        if (in_array('checked', $Default[$Field])) {
            $Sel = 'selected="selected"';
        }
    }
    $Out .= '<option value="checked" ' . $Sel . ' >Checked</option>';
    $Return .= $Out . '</select>&nbsp;&nbsp;&nbsp;</div>';
    $_SESSION['dataform']['OutScripts'] .= "\r\n        jQuery(\"#filter_" . $Field . "\").multiselect();\r\n    ";
    return $Return;
}
示例#10
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;
}
示例#11
0
function dr_loadFieldMapping($url, $root, $table, $Config = false)
{
    global $wpdb;
    $tablefields = $wpdb->get_results("SHOW COLUMNS FROM `" . $table . "`", ARRAY_N);
    $select = '<select id="Data[Content][_DataSourceFieldMap][{{Field}}]" name="Data[Content][_DataSourceFieldMap][{{Field}}]">';
    $select .= '</select>';
    $data = file_get_contents($url);
    if (strpos(substr(strtolower($data), 0, 1024), 'xml')) {
        $data = dt_xml2array($data);
    } else {
        $data = json_decode($data, true);
    }
    preg_match_all('/\\[(.*?)\\]/', $root, $matchesarray);
    foreach ($matchesarray[1] as $path) {
        $data = $data[$path];
    }
    //vardump($select);
    $Return = '<table class="widefat">';
    $Return .= '<thead>';
    $Return .= '<tr>';
    $Return .= '<th>';
    $Return .= 'Table Field';
    $Return .= '</th>';
    $Return .= '<th>';
    $Return .= 'Source Field';
    $Return .= '</th>';
    $Return .= '</tr>';
    $Return .= '</thead>';
    $Return .= '<tbody>';
    foreach ($tablefields as $column) {
        $Return .= '<tr>';
        $Return .= '<td>';
        $Return .= df_parseCamelCase($column[0]);
        $Return .= '</td>';
        if (!empty($select)) {
            $Return .= '<td>';
            $Return .= '<select id="Data[Content][_DataSourceFieldMap][' . $column[0] . ']" name="Data[Content][_DataSourceFieldMap][' . $column[0] . ']">';
            $Return .= '<option value="NULL"></option>';
            $Return .= dt_buildnodeMap($data, false, false, false, $Config['_DataSourceFieldMap'][$column[0]]);
            $Return .= '</select>';
            $Return .= '</td>';
        } else {
            $Return .= '<td>';
            $Return .= 'Node point not an array and cannot be mapped.';
            $Return .= '</td>';
        }
        $Return .= '</tr>';
    }
    $Return .= '</tbody>';
    $Return .= '</table>';
    return $Return;
}