示例#1
0
function displayElement($item, $route)
{
    echo '<li class="dd-item" data-id="' . $item->id . '">';
    echo '<div class="dd-handle"><span class="title">' . $item->title . '</span></div>';
    if (count($item->children) > 0) {
        echo '<ol class="dd-list">';
        foreach ($item->children as $subitem) {
            displayElement($subitem, $route);
        }
        echo '</ol>';
    }
    echo '</li>';
}
示例#2
0
function compileElements($fid, $form, $formulize_mgr, $prevEntry, $entry, $go_back, $parentLinks, $owner_groups, $groups, $overrideValue = "", $elements_allowed = "", $profileForm = "", $frid = "", $mid, $sub_entries, $sub_fids, $member_handler, $gperm_handler, $title, $screen = null, $printViewPages = "", $printViewPageTitles = "")
{
    include_once XOOPS_ROOT_PATH . '/modules/formulize/include/elementdisplay.php';
    $entryForDEElements = is_numeric($entry) ? $entry : "new";
    // if there is no entry, ie: a new entry, then $entry is "" so when writing the entry value into decue_ and other elements that go out to the HTML form, we need to use the keyword "new"
    global $xoopsDB, $xoopsUser;
    $elementsAvailableToUser = array();
    // set criteria for matching on display
    // set the basics that everything has to match
    $criteriaBase = new CriteriaCompo();
    $criteriaBase->add(new Criteria('ele_display', 1), 'OR');
    foreach ($groups as $thisgroup) {
        $criteriaBase->add(new Criteria('ele_display', '%,' . $thisgroup . ',%', 'LIKE'), 'OR');
    }
    if (is_array($elements_allowed) and count($elements_allowed) > 0) {
        // if we're limiting the elements, then add a criteria for that (multiple criteria are joined by AND unless you specify OR manually when adding them (as in the base above))
        $criteria = new CriteriaCompo();
        $criteria->add(new Criteria('ele_id', "(" . implode(",", $elements_allowed) . ")", "IN"));
        $criteria->add($criteriaBase);
    } else {
        $criteria = $criteriaBase;
        // otherwise, just use the base
    }
    $criteria->setSort('ele_order');
    $criteria->setOrder('ASC');
    $elements =& $formulize_mgr->getObjects($criteria, $fid, true);
    // true makes the keys of the returned array be the element ids
    $count = 0;
    global $gridCounter;
    $gridCounter = array();
    $inGrid = 0;
    formulize_benchmark("Ready to loop elements.");
    // set the array to be used as the structure of the loop, either the passed in elements in order, or the elements as gathered from the DB
    // ignore passed in element order if there's a screen in effect, since we assume that official element order is authoritative when screens are involved
    // API should still allow arbitrary ordering, so $element_allowed can still be set manually as part of a displayForm call, and the order will be respected then
    if (!is_array($elements_allowed) or $screen) {
        $element_order_array = $elements;
    } else {
        $element_order_array = $elements_allowed;
    }
    // if this is a printview page,
    foreach ($element_order_array as $thisElement) {
        if (is_numeric($thisElement)) {
            // if we're doing the order based on passed in element ids...
            if (isset($elements[$thisElement])) {
                $i = $elements[$thisElement];
                // set the element object for this iteration of the loop
            } else {
                continue;
                // do not try to render elements that don't exist in the form!! (they might have been deleted from a multipage definition, or who knows what)
            }
            $this_ele_id = $thisElement;
            // set the element ID number
        } else {
            // else...we're just looping through the elements directly from the DB
            $i = $thisElement;
            // set the element object
            $this_ele_id = $i->getVar('ele_id');
            // get the element ID number
        }
        // check if we're at the start of a page, when doing a printable view of all pages (only situation when printViewPageTitles and printViewPages will be present), and if we are, then put in a break for the page titles
        if ($printViewPages) {
            if (!$currentPrintViewPage) {
                $currentPrintViewPage = 1;
            }
            while (!in_array($this_ele_id, $printViewPages[$currentPrintViewPage]) and $currentPrintViewPage <= count($printViewPages)) {
                $currentPrintViewPage++;
            }
            if ($this_ele_id == $printViewPages[$currentPrintViewPage][0]) {
                $form->insertBreak("<div id=\"formulize-printpreview-pagetitle\">" . $printViewPageTitles[$currentPrintViewPage] . "</div>", "head");
            }
        }
        // check if this element is included in a grid, and if so, skip it
        // $inGrid will be a number indicating how many times we have to skip things
        if ($inGrid or isset($gridCounter[$this_ele_id])) {
            if (!$inGrid) {
                $inGrid = $gridCounter[$this_ele_id];
            }
            $inGrid--;
            continue;
        }
        $uid = is_object($xoopsUser) ? $xoopsUser->getVar('uid') : 0;
        $owner = getEntryOwner($entry, $fid);
        $ele_type = $i->getVar('ele_type');
        $ele_value = $i->getVar('ele_value');
        if ($go_back['form']) {
            // if there's a parent form...
            // check here to see if we need to initialize the value of a linked selectbox when it is the key field for a subform
            // although this is setup as a loop through all found parentLinks, only the last one will be used, since ele_value[2] is overwritten each time.
            // assumption is there will only be one parent link for this form
            for ($z = 0; $z < count($parentLinks['source']); $z++) {
                if ($this_ele_id == $parentLinks['self'][$z]) {
                    // this is the element
                    $ele_value[2] = $go_back['entry'];
                    // 3.0 datastructure...needs to be tested!! -- now updated for 5.0
                }
            }
        } elseif ($overrideValue) {
            // used to force a default setting in a form element, other than the normal default
            if (!is_array($overrideValue)) {
                //convert a string to an array so that strings don't screw up logic below (which is designed for arrays)
                $temp = $overrideValue;
                unset($overrideValue);
                $overrideValue[0] = $temp;
            }
            // currently only operative for select boxes
            switch ($ele_type) {
                case "select":
                    foreach ($overrideValue as $ov) {
                        if (array_key_exists($ov, $ele_value[2])) {
                            $ele_value[2][$ov] = 1;
                        }
                    }
                    break;
                case "date":
                    // debug
                    //var_dump($overrideValue);
                    foreach ($overrideValue as $ov) {
                        //if(ereg ("([0-9]{4})-([0-9]{2})-([0-9]{2})", $ov, $regs)) {
                        if (ereg("([0-9]{4})-([0-9]{1,2})-([0-9]{1,2})", $ov, $regs)) {
                            $ele_value[0] = $ov;
                        }
                    }
                    break;
            }
        }
        if ($ele_type != "subform" and $ele_type != 'grid') {
            // "" is framework, ie: not applicable
            // $i is element object
            // $entry is entry_id
            // false is "nosave" param...only used to force element to not be picked up by readelements.php after saving
            // $screen is the screen object
            // false means don't print it out to screen, return it here
            $GLOBALS['formulize_sub_fids'] = $sub_fids;
            // set here so we can pick it up in the render method of elements, if necessary (only necessary for subforms?);
            $deReturnValue = displayElement("", $i, $entry, false, $screen, $prevEntry, false, $profileForm, $groups);
            if (is_array($deReturnValue)) {
                $form_ele = $deReturnValue[0];
                $isDisabled = $deReturnValue[1];
            } else {
                $form_ele = $deReturnValue;
                $isDisabled = false;
            }
            $elementsAvailableToUser[$this_ele_id] = true;
            if ($form_ele == "not_allowed" or $form_ele == "hidden") {
                if (isset($GLOBALS['formulize_renderedElementHasConditions']["de_" . $fid . "_" . $entryForDEElements . "_" . $this_ele_id])) {
                    // need to add a tr container for elements that are not allowed, since if it was a condition that caused them to not show up, they might appear later on asynchronously, and we'll need the row to attach them to
                    if ($ele_type == "ib" and $form_ele == "not_allowed") {
                        $rowHTML = "<tr style='display: none' id='formulize-de_" . $fid . "_" . $entryForDEElements . "_" . $this_ele_id . "'></tr>";
                    } elseif ($form_ele == "not_allowed") {
                        $rowHTML = "<tr style='display: none' id='formulize-de_" . $fid . "_" . $entryForDEElements . "_" . $this_ele_id . "' valign='top' align='" . _GLOBAL_LEFT . "'></tr>";
                    }
                    // need to also get the validation code for this element, wrap it in a check for the table row being visible, and assign that to the global array that contains all the validation javascript that we need to add to the form
                    // following code follows the pattern set in elementdisplay.php for actually creating rendered element objects
                    if ($ele_type != "ib") {
                        $conditionalValidationRenderer = new formulizeElementRenderer($i);
                        if ($prevEntry or $profileForm === "new") {
                            $data_handler = new formulizeDataHandler($i->getVar('id_form'));
                            $ele_value = loadValue($prevEntry, $i, $ele_value, $data_handler->getEntryOwnerGroups($entry), $groups, $entry, $profileForm);
                            // get the value of this element for this entry as stored in the DB -- and unset any defaults if we are looking at an existing entry
                        }
                        $conditionalElementForValidiationCode = $conditionalValidationRenderer->constructElement("de_" . $fid . "_" . $entryForDEElements . "_" . $this_ele_id, $ele_value, $entry, $isDisabled, $screen);
                        if ($js = $conditionalElementForValidiationCode->renderValidationJS()) {
                            $GLOBALS['formulize_renderedElementsValidationJS'][$GLOBALS['formulize_thisRendering']][$conditionalElementForValidiationCode->getName()] = "if(window.document.getElementById('formulize-" . $conditionalElementForValidiationCode->getName() . "').style.display != 'none') {\n" . $js . "\n}\n";
                        }
                        unset($conditionalElementForValidiationCode);
                        unset($conditionalValidationRenderer);
                    }
                    $form->addElement($rowHTML);
                    // since it was treated as a conditional element, and the user might interact with it, then we don't consider it a not-available-to-user element
                    unset($elementsAvailableToUser[$this_ele_id]);
                }
                continue;
            }
        }
        $req = !$isDisabled ? intval($i->getVar('ele_req')) : 0;
        $GLOBALS['sub_entries'] = $sub_entries;
        if ($ele_type == "subform") {
            $thissfid = $ele_value[0];
            if (!$thissfid) {
                continue;
            }
            // can't display non-specified subforms!
            $deReturnValue = displayElement("", $i, $entry, false, $screen, $prevEntry, false, $profileForm, $groups);
            // do this just to evaluate any conditions...it won't actually render anything, but will return "" for the first key in the array, if the element is allowed
            if (is_array($deReturnValue)) {
                $form_ele = $deReturnValue[0];
                $isDisabled = $deReturnValue[1];
            } else {
                $form_ele = $deReturnValue;
                $isDisabled = false;
            }
            if ($passed = security_check($thissfid) and $form_ele == "") {
                $GLOBALS['sfidsDrawn'][] = $thissfid;
                $customCaption = $i->getVar('ele_caption');
                $customElements = $ele_value[1] ? explode(",", $ele_value[1]) : "";
                if (isset($GLOBALS['formulize_inlineSubformFrid'])) {
                    $newLinkResults = checkForLinks($GLOBALS['formulize_inlineSubformFrid'][0], array($fid), $fid, array($fid => array($entry)), null, $owner_groups, $mid, null, $owner, true);
                    // final true means only include entries from unified display linkages
                    $sub_entries = $newLinkResults['sub_entries'];
                }
                // 2 is the number of default blanks, 3 is whether to show the view button or not, 4 is whether to use captions as headings or not, 5 is override owner of entry, $owner is mainform entry owner, 6 is hide the add button, 7 is the conditions settings for the subform element, 8 is the setting for showing just a row or the full form, 9 is text for the add entries button
                $subUICols = drawSubLinks($thissfid, $sub_entries, $uid, $groups, $frid, $mid, $fid, $entry, $customCaption, $customElements, intval($ele_value[2]), $ele_value[3], $ele_value[4], $ele_value[5], $owner, $ele_value[6], $ele_value[7], $this_ele_id, $ele_value[8], $ele_value[9], $thisElement);
                if (isset($subUICols['single'])) {
                    $form->insertBreak($subUICols['single'], "even");
                } else {
                    $subLinkUI = new XoopsFormLabel($subUICols['c1'], $subUICols['c2']);
                    $form->addElement($subLinkUI);
                }
                unset($subLinkUI);
            }
        } elseif ($ele_type == "grid") {
            // we are going to have to store some kind of flag/counter with the id number of the starting element in the table, and the number of times we need to ignore things
            // we need to then listen for this up above and skip those elements as they come up.  This is why grids must come before their elements in the form definition
            include_once XOOPS_ROOT_PATH . "/modules/formulize/include/griddisplay.php";
            list($grid_title, $grid_row_caps, $grid_col_caps, $grid_background, $grid_start, $grid_count) = compileGrid($ele_value, $title, $i);
            $headingAtSide = ($ele_value[5] and $grid_title) ? true : false;
            // if there is a value for ele_value[5], then the heading should be at the side, otherwise, grid spans form width as it's own chunk of HTML
            $gridCounter[$grid_start] = $grid_count;
            $gridContents = displayGrid($fid, $entry, $grid_row_caps, $grid_col_caps, $grid_title, $grid_background, $grid_start, "", "", true, $screen, $headingAtSide);
            if ($headingAtSide) {
                // grid contents is the two bits for the xoopsformlabel when heading is at side, otherwise, it's just the contents for the break
                $form->addElement(new XoopsFormLabel($gridContents[0], $gridContents[1]));
            } else {
                $form->insertBreak($gridContents, "head");
                // head is the css class of the cell
            }
        } elseif ($ele_type == "ib" or is_array($form_ele)) {
            // if it's a break, handle it differently...$form_ele may be an array if it's a non-interactive element such as a grid
            if (is_object($thisElement)) {
                // final param is used as id name in the table row where this element exists, so we can interact with it for showing and hiding
                $form->insertBreakFormulize("<div class=\"formulize-subform-heading\">" . trans(stripslashes($form_ele[0])) . "</div>", $form_ele[1], 'de_' . $fid . '_' . $entryForDEElements . '_' . $this_ele_id, $thisElement->getVar("ele_handle"));
            }
        } else {
            $form->addElement($form_ele, $req);
        }
        $count++;
        unset($hidden);
        unset($form_ele);
        // apparently necessary for compatibility with PHP 4.4.0 -- suggested by retspoox, sept 25, 2005
    }
    formulize_benchmark("Done looping elements.");
    // find any hidden elements in the form, that aren't available to the user in this rendering of the form...
    unset($criteria);
    $notAllowedCriteria = new CriteriaCompo();
    $notAllowedCriteria->add(new Criteria('ele_forcehidden', 1));
    foreach ($elementsAvailableToUser as $availElementId => $boolean) {
        $notAllowedCriteria->add(new Criteria('ele_id', $availElementId, '!='));
    }
    $notAllowedCriteria->setSort('ele_order');
    $notAllowedCriteria->setOrder('ASC');
    $notAllowedElements =& $formulize_mgr->getObjects($notAllowedCriteria, $fid);
    $hiddenElements = generateHiddenElements($notAllowedElements, $entryForDEElements);
    // in functions.php, keys in returned array will be the element ids
    foreach ($hiddenElements as $element_id => $thisHiddenElement) {
        $form->addElement(new xoopsFormHidden("decue_" . $fid . "_" . $entryForDEElements . "_" . $element_id, 1));
        if (is_array($thisHiddenElement)) {
            // could happen for checkboxes
            foreach ($thisHiddenElement as $thisIndividualHiddenElement) {
                $form->addElement($thisIndividualHiddenElement);
            }
        } else {
            $form->addElement($thisHiddenElement);
        }
        unset($thisHiddenElement);
        // some odd reference thing going on here...$thisHiddenElement is being added by reference or something like that, so that when $thisHiddenElement changes in the next run through, every previous element that was created by adding it is updated to point to the next element.  So if you unset at the end of the loop, it forces each element to be added as you would expect.
    }
    if ($entry and !is_a($form, 'formulize_elementsOnlyForm')) {
        // two hidden fields encode the main entry id, the first difficult-to-use format is a legacy thing
        // the 'lastentry' format is more sensible, but is only available when there was a real entry, not 'new' (also a legacy convention)
        $form->addElement(new XoopsFormHidden('entry' . $fid, $entry));
        if (is_numeric($entry)) {
            $form->addElement(new XoopsFormHidden('lastentry', $entry));
        }
    }
    if ($_POST['parent_form']) {
        // if we just came back from a parent form, then if they click save, we DO NOT want an override condition, even though we are now technically editing an entry that was previously saved when we went to the subform in the first place.  So the override logic looks for this hidden value as an exception.
        $form->addElement(new XoopsFormHidden('back_from_sub', 1));
    }
    // add a hidden element to carry all the validation javascript that might be associated with elements rendered with elementdisplay.php...only relevant for elements rendered inside subforms or grids...the validation code comes straight from the element, doesn't have a check around it for the conditional table row id, like the custom form classes at the top of the file use, since those elements won't render as hidden and show/hide in the same way
    if (isset($GLOBALS['formulize_renderedElementsValidationJS'][$GLOBALS['formulize_thisRendering']])) {
        $formulizeHiddenValidation = new XoopsFormHidden('validation', '');
        foreach ($GLOBALS['formulize_renderedElementsValidationJS'][$GLOBALS['formulize_thisRendering']] as $thisValidation) {
            // grab all the validation code we stored in the elementdisplay.php file and attach it to this element
            foreach (explode("\n", $thisValidation) as $thisValidationLine) {
                $formulizeHiddenValidation->customValidationCode[] = $thisValidationLine;
            }
        }
        $form->addElement($formulizeHiddenValidation, 1);
    }
    if (get_class($form) == "formulize_elementsOnlyForm") {
        // forms of this class are ones that we're rendering just the HTML for the elements, and we need to preserve any validation javascript to stick in the final, parent form when it's finished
        $validationJS = $form->renderValidationJS();
        if (trim($validationJS) != "") {
            $GLOBALS['formulize_elementsOnlyForm_validationCode'][] = $validationJS . "\n\n";
        }
    } elseif (count($GLOBALS['formulize_elementsOnlyForm_validationCode']) > 0) {
        $elementsonlyvalidation = new XoopsFormHidden('elementsonlyforms', '');
        $elementsonlyvalidation->customValidationCode = $GLOBALS['formulize_elementsOnlyForm_validationCode'];
        $form->addElement($elementsonlyvalidation, 1);
    }
    return $form;
}
function drawEntries($fid, $cols, $searches = "", $frid = "", $scope, $standalone = "", $currentURL, $gperm_handler, $uid, $mid, $groups, $settings, $member_handler, $screen, $data, $wq, $regeneratePageNumbers, $hiddenQuickSearches, $cResults)
{
    // , $loadview="") { // -- loadview removed from this function sept 24 2005
    // determine if the query reached a limit in the number of entries to return
    $LOE_limit = 0;
    if (!is_array($data)) {
        $LOE_limit = is_numeric($data) ? $data : 0;
        $data = array();
    }
    global $xoopsDB;
    $useScrollBox = true;
    $useHeadings = true;
    $repeatHeaders = 5;
    $columnWidth = 0;
    $textWidth = 35;
    $useCheckboxes = 0;
    $useViewEntryLinks = 1;
    $useSearch = 1;
    $deColumns = array();
    $useSearchCalcMsgs = 1;
    $listTemplate = false;
    $inlineButtons = array();
    $hiddenColumns = array();
    $formulize_LOEPageSize = 10;
    if ($screen) {
        $useScrollBox = $screen->getVar('usescrollbox');
        $useHeadings = $screen->getVar('useheadings');
        $repeatHeaders = $screen->getVar('repeatheaders');
        $columnWidth = $screen->getVar('columnwidth');
        $textWidth = $screen->getVar('textwidth');
        if ($textWidth == 0) {
            $textWidth = 10000;
        }
        $useCheckboxes = $screen->getVar('usecheckboxes');
        $useViewEntryLinks = $screen->getVar('useviewentrylinks');
        $useSearch = $screen->getVar('usesearch');
        $hiddenColumns = $screen->getVar('hiddencolumns');
        $deColumns = $screen->getVar('decolumns');
        $deDisplay = $screen->getVar('dedisplay');
        $useSearchCalcMsgs = $screen->getVar('usesearchcalcmsgs');
        $listTemplate = $screen->getTemplate("listtemplate");
        foreach ($screen->getVar('customactions') as $caid => $thisCustomAction) {
            if ($thisCustomAction['appearinline'] == 1) {
                list($caCode) = processCustomButton($caid, $thisCustomAction);
                if ($caCode) {
                    $inlineButtons[$caid] = $thisCustomAction;
                }
            }
        }
        $formulize_LOEPageSize = $screen->getVar('entriesperpage');
    }
    $filename = "";
    // $settings['xport'] no longer set by a page load, except if called as part of the import process to create a template for updating
    if (!$settings['xport']) {
        $settings['xport'] = $settings['hlist'] ? "calcs" : "comma";
        $xportDivText1 = "<div id=exportlink style=\"display: none;\">";
        // export button turns this link on and off now
        $xportDivText2 = "</div>";
    } else {
        $xportDivText1 = "";
        $xportDivText2 = "";
    }
    if (@$_POST['advcalc_acid']) {
        if ($_POST['acid'] > 0) {
            $result = formulize_runAdvancedCalculation(intval($_POST['acid']));
            // result will be an array with two or three keys: 'text' and 'output', and possibly 'groupingMap'.  Text is for display on screen "raw" and Output is a variable that can be used by a dev.  The output variable will be an array if groupings are in effect.  The keys of the array will be the various grouping values in effect.  The groupingMap will be present if there's a set of groupings in effect.  It is an array that contains all the grouping choices, their text equivalents and their data values (which are the keys in the output array) -- groupingMap is still to be developed/added to the mix....will be necessary when we are integrating with Drupal or other API uses.
            print "<br/>" . $result['text'] . "<br/><br/>";
        }
    }
    // export of Data is moved out to a popup
    // Calculations still handled in the old way for now
    if ($settings['xport'] == "calcs") {
        $filename = prepExport($headers, $cols, $data, $settings['xport'], $settings['xport_cust'], $settings['title'], false, $fid, $groups);
        $linktext = $_POST['xport'] == "update" ? _formulize_DE_CLICKSAVE_TEMPLATE : _formulize_DE_CLICKSAVE;
        print "{$xportDivText1}<center><p><a href='{$filename}' target=\"_blank\">{$linktext}</a></p></center>";
        print "<br>{$xportDivText2}";
    }
    $scrollBoxWasSet = false;
    if ($useScrollBox and count($data) > 0) {
        print "<div class=scrollbox id=resbox>\n";
        $scrollBoxWasSet = true;
    }
    // perform calculations...
    // calc_cols is the columns requested (separated by / -- ele_id for each, also metadata is indicated with uid, proxyid, creation_date, mod_date)
    // calc_calcs is the calcs for each column, columns separated by / and calcs for a column separated by ,. possible calcs are sum, avg, min, max, count, per
    // calc_blanks is the blank setting for each calculation, setup the same way as the calcs, possible settings are all,  noblanks, onlyblanks
    // calc_grouping is the grouping option.  same format as calcs.  possible values are ele_ids or the uid, proxyid, creation_date and mod_date metadata terms
    // 1. extract data from four settings into arrays
    // 2. loop through the array and perform all the requested calculations
    if ($settings['calc_cols'] and !$settings['hcalc']) {
        //		print "<p><input type=button style=\"width: 140px;\" name=cancelcalcs1 value='" . _formulize_DE_CANCELCALCS . "' onclick=\"javascript:cancelCalcs();\"></input></p>\n";
        //		print "<div";
        //		if($totalcalcs>4) { print " class=scrollbox"; }
        //		print " id=calculations>
        $calc_cols = $settings['calc_cols'];
        $calc_calcs = $settings['calc_calcs'];
        $calc_blanks = $settings['calc_blanks'];
        $calc_grouping = $settings['calc_grouping'];
        print "<table class=outer>";
        if ($useHeadings) {
            $headers = getHeaders($cols, true);
            // second param indicates we're using element headers and not ids
            drawHeaders($headers, $cols, $useCheckboxes, $useViewEntryLinks, count($inlineButtons), $settings['lockedColumns']);
        }
        if ($useSearch) {
            drawSearches($searches, $cols, $useCheckboxes, $useViewEntryLinks, count($inlineButtons), false, $hiddenQuickSearches);
        }
        print "</table>";
        print "<table class=outer><tr><th colspan=2>" . _formulize_DE_CALCHEAD . "</th></tr>\n";
        if (!$settings['lockcontrols'] and ($useSearchCalcMsgs == 1 or $useSearchCalcMsgs == 3)) {
            // AND !$loadview) { // -- loadview removed from this function sept 24 2005
            print "<tr><td class=head colspan=2><input type=button style=\"width: 140px;\" name=mod_calculations value='" . _formulize_DE_MODCALCS . "' onclick=\"javascript:showPop('" . XOOPS_URL . "/modules/formulize/include/pickcalcs.php?fid={$fid}&frid={$frid}&calc_cols=" . urlencode($calc_cols) . "&calc_calcs=" . urlencode($calc_calcs) . "&calc_blanks=" . urlencode($calc_blanks) . "&calc_grouping=" . urlencode($calc_grouping) . "&cols=" . urlencode(implode(",", $cols)) . "');\"></input>&nbsp;&nbsp;" . "<input type=button style=\"width: 140px;\" name=cancelcalcs value='" . _formulize_DE_CANCELCALCS . "' onclick=\"javascript:cancelCalcs();\"></input>&nbsp;&nbsp" . "<input type=button style=\"width: 140px;\" name=showlist value='" . _formulize_DE_SHOWLIST . "' onclick=\"javascript:showList();\"></input></td></tr>";
        }
        $exportFilename = $settings['xport'] == "calcs" ? $filename : "";
        //formulize_benchmark("before printing results");
        // 0 is the masterresults, 1 is the blanksettings, 2 is grouping settings -- exportFilename is the name of the file that we need to create and into which we need to dump a copy of the calcs
        printResults($cResults[0], $cResults[1], $cResults[2], $cResults[3], $cResults[4], $exportFilename, $settings['title']);
        //formulize_benchmark("after printing results");
        print "</table>\n";
    }
    // MASTER HIDELIST CONDITIONAL...
    if (!$settings['hlist'] and !$listTemplate) {
        print "<div class=\"list-of-entries-container\"><table class=\"outer\">";
        $count_colspan = count($cols) + 1;
        if ($useViewEntryLinks or $useCheckboxes != 2) {
            $count_colspan_calcs = $count_colspan;
        } else {
            $count_colspan_calcs = $count_colspan - 1;
        }
        $count_colspan_calcs = $count_colspan_calcs + count($inlineButtons);
        // add to the column count for each inline custom button
        $count_colspan_calcs++;
        // add one more for the hidden floating column
        if (!$screen) {
            print "<tr><th colspan={$count_colspan_calcs}>" . _formulize_DE_DATAHEADING . "</th></tr>\n";
        }
        if ($settings['calc_cols'] and !$settings['lockcontrols'] and ($useSearchCalcMsgs == 1 or $useSearchCalcMsgs == 3)) {
            // AND !$loadview) { // -- loadview removed from this function sept 24 2005
            $calc_cols = $settings['calc_cols'];
            $calc_calcs = $settings['calc_calcs'];
            $calc_blanks = $settings['calc_blanks'];
            $calc_grouping = $settings['calc_grouping'];
            print "<tr><td class=head colspan={$count_colspan_calcs}><input type=button style=\"width: 140px;\" name=mod_calculations value='" . _formulize_DE_MODCALCS . "' onclick=\"javascript:showPop('" . XOOPS_URL . "/modules/formulize/include/pickcalcs.php?fid={$fid}&frid={$frid}&calc_cols={$calc_cols}&calc_calcs={$calc_calcs}&calc_blanks={$calc_blanks}&calc_grouping=" . urlencode($calc_grouping) . "&cols=" . urlencode(implode(",", $cols)) . "');\"></input>&nbsp;&nbsp;<input type=button style=\"width: 140px;\" name=cancelcalcs value='" . _formulize_DE_CANCELCALCS . "' onclick=\"javascript:cancelCalcs();\"></input>&nbsp;&nbsp;<input type=button style=\"width: 140px;\" name=hidelist value='" . _formulize_DE_HIDELIST . "' onclick=\"javascript:hideList();\"></input></td></tr>";
        }
        // draw advanced search notification
        if ($settings['as_0'] and ($useSearchCalcMsgs == 1 or $useSearchCalcMsgs == 2)) {
            $writable_q = writableQuery($wq);
            $minus1colspan = $count_colspan - 1 + count($inlineButtons);
            if (!$asearch_parse_error) {
                print "<tr>";
                if ($useViewEntryLinks or $useCheckboxes != 2) {
                    // only include this column if necessary
                    print "<td class=head></td>";
                }
                print "<td colspan={$minus1colspan} class=head>" . _formulize_DE_ADVSEARCH . ": {$writable_q}";
            } else {
                print "<tr>";
                if ($useViewEntryLinks or $useCheckboxes != 2) {
                    print "<td class=head></td>";
                }
                print "<td colspan={$minus1colspan} class=head><span style=\"font-weight: normal;\">" . _formulize_DE_ADVSEARCH_ERROR . "</span>";
            }
            if (!$settings['lockcontrols']) {
                // AND !$loadview) { // -- loadview removed from this function sept 24 2005
                print "<br><input type=button style=\"width: 140px;\" name=advsearch value='" . _formulize_DE_MOD_ADVSEARCH . "' onclick=\"javascript:showPop('" . XOOPS_URL . "/modules/formulize/include/advsearch.php?fid={$fid}&frid={$frid}";
                foreach ($settings as $k => $v) {
                    if (substr($k, 0, 3) == "as_") {
                        $v = str_replace("'", "&#39;", $v);
                        $v = stripslashes($v);
                        print "&{$k}=" . urlencode($v);
                    }
                }
                print "');\"></input>&nbsp;&nbsp;<input type=button style=\"width: 140px;\" name=cancelasearch value='" . _formulize_DE_CANCELASEARCH . "' onclick=\"javascript:killSearch();\"></input>";
            }
            print "</td></tr>\n";
        }
        if ($useHeadings) {
            $headers = getHeaders($cols, true);
            // second param indicates we're using element headers and not ids
            drawHeaders($headers, $cols, $useCheckboxes, $useViewEntryLinks, count($inlineButtons), $settings['lockedColumns']);
        }
        if ($useSearch) {
            drawSearches($searches, $cols, $useCheckboxes, $useViewEntryLinks, count($inlineButtons), false, $hiddenQuickSearches);
        }
        if (count($data) == 0) {
            // kill an empty dataset so there's no rows drawn
            unset($data);
        } else {
            // get form handles in use
            $mainFormHandle = key($data[key($data)]);
        }
        $headcounter = 0;
        $blankentries = 0;
        $GLOBALS['formulize_displayElement_LOE_Used'] = false;
        $formulize_LOEPageStart = (isset($_POST['formulize_LOEPageStart']) and !$regeneratePageNumbers) ? intval($_POST['formulize_LOEPageStart']) : 0;
        // adjust formulize_LOEPageSize if the actual count of entries is less than the page size
        $formulize_LOEPageSize = $GLOBALS['formulize_countMasterResultsForPageNumbers'] < $formulize_LOEPageSize ? $GLOBALS['formulize_countMasterResultsForPageNumbers'] : $formulize_LOEPageSize;
        $actualPageSize = $formulize_LOEPageSize ? $formulize_LOEPageStart + $formulize_LOEPageSize : $GLOBALS['formulize_countMasterResultsForPageNumbers'];
        if (isset($data)) {
            foreach ($data as $id => $entry) {
                formulize_benchmark("starting to draw one row of results");
                // check to make sure this isn't an unset entry (ie: one that was blanked by the extraction layer just prior to sending back results
                // Since the extraction layer is unsetting entries to blank them, this condition should never be met?
                // If this condition is ever met, it may very well screw up the paging of results!
                // NOTE: this condition is met on the last page of a paged set of results, unless the last page as exactly the same number of entries on it as the limit of entries per page
                if ($entry != "") {
                    if ($headcounter == $repeatHeaders and $repeatHeaders > 0) {
                        if ($useHeadings) {
                            drawHeaders($headers, $cols, $useCheckboxes, $useViewEntryLinks, count($inlineButtons));
                        }
                        $headcounter = 0;
                    }
                    $headcounter++;
                    print "<tr>\n";
                    if ($class == "even") {
                        $class = "odd";
                    } else {
                        $class = "even";
                    }
                    unset($linkids);
                    $linkids = internalRecordIds($entry, $mainFormHandle);
                    // draw in the margin column where the links and metadata goes
                    if ($useViewEntryLinks or $useCheckboxes != 2) {
                        print "<td class=\"head formulize-controls\">\n";
                    }
                    if (!$settings['lockcontrols']) {
                        //  AND !$loadview) { // -- loadview removed from this function sept 24 2005
                        // check to see if we should draw in the delete checkbox
                        // 2 is none, 1 is all
                        if ($useCheckboxes != 2 and ($useCheckboxes == 1 or formulizePermHandler::user_can_delete_entry($fid, $uid, $linkids[0]))) {
                            print "<input type=checkbox title='" . _formulize_DE_DELBOXDESC . "' class='formulize_selection_checkbox' name='delete_" . $linkids[0] . "' id='delete_" . $linkids[0] . "' value='delete_" . $linkids[0] . "'>";
                        }
                        if ($useViewEntryLinks) {
                            print "<a href='" . $currentURL;
                            if (strstr($currentURL, "?")) {
                                // if params are already part of the URL...
                                print "&";
                            } else {
                                print "?";
                            }
                            print "ve=" . $linkids[0] . "' onclick=\"javascript:goDetails('" . $linkids[0] . "');return false;\" " . " class=\"loe-edit-entry\" alt=\"" . _formulize_DE_VIEWDETAILS . "\" title=\"" . _formulize_DE_VIEWDETAILS . "\" >";
                            print "&nbsp;</a>";
                        }
                    }
                    // end of IF NO LOCKCONTROLS
                    if ($useViewEntryLinks or $useCheckboxes != 2) {
                        print "</td>\n";
                    }
                    $column_counter = 0;
                    if ($columnWidth) {
                        $columnWidthParam = "style=\"width: {$columnWidth}" . "px\"";
                    } else {
                        $columnWidthParam = "";
                    }
                    for ($i = 0; $i < count($cols); $i++) {
                        //formulize_benchmark("drawing one column");
                        $col = $cols[$i];
                        $colhandle = $settings['columnhandles'][$i];
                        $classToUse = $class . " column column" . $i;
                        $cellRowAddress = $id + 2;
                        if ($i == 0) {
                            print "<td {$columnWidthParam} class=\"{$class} floating-column\" id='floatingcelladdress_{$cellRowAddress}'>\n";
                        }
                        print "<td {$columnWidthParam} class=\"{$classToUse}\" id=\"celladdress_" . $cellRowAddress . "_" . $i . "\">\n";
                        if ($col == "creation_uid" or $col == "mod_uid") {
                            $userObject = $member_handler->getUser(display($entry, $col));
                            if ($userObject) {
                                $nameToDisplay = $userObject->getVar('name') ? $userObject->getVar('name') : $userObject->getVar('uname');
                            } else {
                                $nameToDisplay = _FORM_ANON_USER;
                            }
                            $value = "<a href=\"" . XOOPS_URL . "/userinfo.php?uid=" . display($entry, $col) . "\" target=_blank>" . $nameToDisplay . "</a>";
                        } else {
                            $value = display($entry, $col);
                        }
                        // set in the display function, corresponds to the entry id of the record in the form where the current value was retrieved from.  If there is more than one local entry id, because of a one to many framework, then this will be an array that corresponds to the order of the values returned by display.
                        $currentColumnLocalId = $GLOBALS['formulize_mostRecentLocalId'];
                        // if we're supposed to display this column as an element... (only show it if they have permission to update this entry)
                        if (in_array($colhandle, $deColumns) and formulizePermHandler::user_can_edit_entry($fid, $uid, $entry)) {
                            include_once XOOPS_ROOT_PATH . "/modules/formulize/include/elementdisplay.php";
                            if ($frid) {
                                // need to work out which form this column belongs to, and use that form's entry ID.  Need to loop through the entry to find all possible internal IDs, since a subform situation would lead to multiple values appearing in a single cell, so multiple displayElement calls would be made each with their own internal ID.
                                foreach ($entry as $entryFormHandle => $entryFormData) {
                                    foreach ($entryFormData as $internalID => $entryElements) {
                                        $deThisIntId = false;
                                        foreach ($entryElements as $entryHandle => $values) {
                                            if ($entryHandle == $col) {
                                                // we found the element that we're trying to display
                                                if ($deThisIntId) {
                                                    print "\n<br />\n";
                                                }
                                                // could be a subform so we'd display multiple values
                                                if ($deDisplay) {
                                                    print '<div id="deDiv_' . $colhandle . '_' . $internalID . '">';
                                                    print getHTMLForList($values, $colhandle, $internalID, $deDisplay, $textWidth, $currentColumnLocalId, $fid, $cellRowAddress, $i);
                                                    print "</div>";
                                                } else {
                                                    displayElement("", $colhandle, $internalID);
                                                }
                                                $deThisIntId = true;
                                            }
                                        }
                                    }
                                }
                            } else {
                                // display based on the mainform entry id
                                if ($deDisplay) {
                                    print '<div id="deDiv_' . $colhandle . '_' . $linkids[0] . '">';
                                    print getHTMLForList($value, $colhandle, $linkids[0], $deDisplay, $textWidth, $currentColumnLocalId, $fid, $cellRowAddress, $i);
                                    print "</div>";
                                } else {
                                    displayElement("", $colhandle, $linkids[0]);
                                    // works for mainform only!  To work on elements from a framework, we need to figure out the form the element is from, and the entry ID in that form, which is done above
                                }
                            }
                            $GLOBALS['formulize_displayElement_LOE_Used'] = true;
                        } elseif ($col != "creation_uid" and $col != "mod_uid" and $col != "entry_id") {
                            print getHTMLForList($value, $col, $linkids[0], 0, $textWidth, $currentColumnLocalId, $fid, $cellRowAddress, $i);
                        } else {
                            // no special formatting on the uid columns:
                            print $value;
                        }
                        print "</td>\n";
                        $column_counter++;
                    }
                    // handle inline custom buttons
                    foreach ($inlineButtons as $caid => $thisCustomAction) {
                        list($caCode) = processCustomButton($caid, $thisCustomAction, $linkids[0], $entry);
                        // only bother with the code, since we already processed any clicked button above
                        if ($caCode) {
                            print "<td {$columnWidthParam} class={$class}>\n";
                            print "<center>{$caCode}</center>\n";
                            print "</td>\n";
                        }
                    }
                    // handle hidden elements for passing back to custom buttons
                    foreach ($hiddenColumns as $thisHiddenCol) {
                        print "\n<input type=\"hidden\" name=\"hiddencolumn_" . $linkids[0] . "_{$thisHiddenCol}\" value=\"" . htmlspecialchars(display($entry, $thisHiddenCol)) . "\"></input>\n";
                    }
                    print "</tr>\n";
                } else {
                    // this is a blank entry
                    $blankentries++;
                }
                // end of not "" check
            }
            // end of foreach data as entry
        }
        // end of if there is any data to draw
        print "</table></div>";
    } elseif ($listTemplate and !$settings['hlist']) {
        // USING A CUSTOM LIST TEMPLATE SO DO EVERYTHING DIFFERENTLY
        // print str_replace("\n", "<br />", $listTemplate); // debug code
        $mainFormHandle = key($data[key($data)]);
        $formulize_LOEPageStart = (isset($_POST['formulize_LOEPageStart']) and !$regeneratePageNumbers) ? intval($_POST['formulize_LOEPageStart']) : 0;
        $actualPageSize = $formulize_LOEPageSize ? $formulize_LOEPageStart + $formulize_LOEPageSize : $GLOBALS['formulize_countMasterResultsForPageNumbers'];
        if (strstr($listTemplate, "displayElement")) {
            include_once XOOPS_ROOT_PATH . "/modules/formulize/include/elementdisplay.php";
        }
        if (isset($data)) {
            //for($entryCounter=$formulize_LOEPageStart;$entryCounter<$actualPageSize;$entryCounter++) {
            // setup the view name variables, with true only set for the last loaded view
            $viewNumber = 1;
            foreach ($settings['publishedviewnames'] as $id => $thisViewName) {
                $thisViewName = str_replace(" ", "_", $thisViewName);
                if ($id == $settings['lastloaded']) {
                    ${$thisViewName} = true;
                    ${'view' . $viewNumber} = true;
                } else {
                    ${$thisViewName} = false;
                    $view['view' . $viewNumber] = false;
                }
                $viewNumber++;
            }
            foreach ($data as $id => $entry) {
                //$entry = $data[$entryCounter];
                //$id=$entryCounter;
                // check to make sure this isn't an unset entry (ie: one that was blanked by the extraction layer just prior to sending back results
                // Since the extraction layer is unsetting entries to blank them, this condition should never be met?
                // If this condition is ever met, it may very well screw up the paging of results!
                // NOTE: this condition is met on the last page of a paged set of results, unless the last page as exactly the same number of entries on it as the limit of entries per page
                if ($entry != "") {
                    // Set up the variables for the link to the current entry, and the checkbox that can be used to select the current entry
                    $linkids = internalRecordIds($entry, $mainFormHandle);
                    $entry_id = $linkids[0];
                    // make a nice way of referring to this for in the eval'd code
                    $form_id = $fid;
                    // make a nice way of referring to this for in the eval'd code
                    if (!$settings['lockcontrols']) {
                        //  AND !$loadview) { // -- loadview removed from this function sept 24 2005
                        $viewEntryLinkCode = "<a href='" . $currentURL;
                        if (strstr($currentURL, "?")) {
                            // if params are already part of the URL...
                            $viewEntryLinkCode .= "&";
                        } else {
                            $viewEntryLinkCode .= "?";
                        }
                        $viewEntryLinkCode .= "ve=" . $entry_id . "' onclick=\"javascript:goDetails('" . $entry_id . "');return false;\">";
                        $GLOBALS['formulize_viewEntryId'] = $entry_id;
                        // put into global scope so the function 'viewEntryLink' can pick it up if necessary
                        $GLOBALS['formulize_viewEntryLinkCode'] = $viewEntryLinkCode;
                        // check to see if we should draw in the delete checkbox
                        // 2 is none, 1 is all
                        if ($useCheckboxes != 2 and ($useCheckboxes == 1 or formulizePermHandler::user_can_delete_entry($fid, $uid, $entry_id))) {
                            $selectionCheckbox = "<input type=checkbox title='" . _formulize_DE_DELBOXDESC . "' class='formulize_selection_checkbox' name='delete_" . $entry_id . "' id='delete_" . $entry_id . "' value='delete_" . $entry_id . "'>";
                        } else {
                            $selectionCheckbox = "";
                        }
                    }
                    // end of IF NO LOCKCONTROLS
                    $ids = internalRecordIds($entry, $mainFormHandle);
                    foreach ($inlineButtons as $caid => $thisCustomAction) {
                        list($caCode) = processCustomButton($caid, $thisCustomAction, $ids[0], $entry);
                        // only bother with the code, since we already processed any clicked button above
                        if ($caCode) {
                            ${$thisCustomAction['handle']} = $caCode;
                            // assign the button code that was returned
                        }
                    }
                    // handle hidden elements for passing back to custom buttons
                    foreach ($hiddenColumns as $thisHiddenCol) {
                        print "\n<input type=\"hidden\" name=\"hiddencolumn_" . $linkids[0] . "_{$thisHiddenCol}\" value=\"" . htmlspecialchars(display($entry, $thisHiddenCol)) . "\"></input>\n";
                    }
                    include XOOPS_ROOT_PATH . "/modules/formulize/templates/screens/default/" . $screen->getVar('sid') . "/listtemplate.php";
                }
            }
        }
    }
    // END OF MASTER HIDELIST CONDITIONAL
    if ((!isset($data) or count($data) == $blankentries) and !$LOE_limit) {
        // if no data was returned, or the dataset was empty...
        print "<p><b>" . _formulize_DE_NODATAFOUND . "</b></p>\n";
    } elseif ($LOE_limit) {
        print "<p>" . _formulize_DE_LOE_LIMIT_REACHED1 . " <b>" . $LOE_limit . "</b> " . _formulize_DE_LOE_LIMIT_REACHED2 . " <a href=\"\" onclick=\"javascript:forceQ();return false;\">" . _formulize_DE_LOE_LIMIT_REACHED3 . "</a></p>\n";
    }
    if ($scrollBoxWasSet) {
        print "</div>";
    }
    formulize_benchmark("We're done");
}
示例#4
0
function displayGrid($fid, $entry = "", $rowcaps, $colcaps, $title = "", $orientation = "horizontal", $startID = "first", $finalCell = "", $finalRow = "", $calledInternal = false, $screen = null, $headingAtSide = "")
{
    include_once XOOPS_ROOT_PATH . '/modules/formulize/include/functions.php';
    include_once XOOPS_ROOT_PATH . '/modules/formulize/include/elementdisplay.php';
    include_once XOOPS_ROOT_PATH . '/modules/formulize/class/data.php';
    global $xoopsUser, $xoopsDB;
    $numcols = count($colcaps);
    if (is_array($finalCell)) {
        $numcols = $numcols + 2;
    } else {
        $numcols = $numcols + 1;
    }
    $numrows = count($rowcaps);
    $actual_numrows = count(array_filter($rowcaps));
    # count non-null row captions
    if ($title == "{FORMTITLE}") {
        $title = trans(getFormTitle($fid));
    } else {
        $title = trans($title);
    }
    $currentURL = getCurrentURL();
    $uid = $xoopsUser ? $xoopsUser->getVar('uid') : '0';
    $mid = getFormulizeModId();
    $gperm_handler =& xoops_gethandler('groupperm');
    $owner = getEntryOwner($entry, $fid);
    $member_handler =& xoops_gethandler('member');
    //$owner_groups = $owner ? $member_handler->getGroupsByUser($owner, FALSE) : array(0=>XOOPS_GROUP_ANONYMOUS);
    $data_handler = new formulizeDataHandler($fid);
    $owner_groups = $owner ? $data_handler->getEntryOwnerGroups($entry) : array(0 => XOOPS_GROUP_ANONYMOUS);
    $groups = $xoopsUser ? $xoopsUser->getGroups() : array(0 => XOOPS_GROUP_ANONYMOUS);
    if (!$calledInternal) {
        if (!($scheck = security_check($fid, $entry, $uid, $owner, $groups, $mid, $gperm_handler))) {
            print "<p>" . _NO_PERM . "</p>";
            return;
        }
    }
    // determine if the form is a single entry form and so whether an entry already exists for this form...
    $single_result = getSingle($fid, $uid, $groups, $member_handler, $gperm_handler, $mid);
    $single = $single_result['flag'];
    if ($single and !$entry) {
        $entry = $single_result['entry'];
    }
    if (!$entry) {
        $entry = "new";
    }
    // figure out where we are supposed to start in the form
    if (!is_numeric($startID) and $startID !== "first") {
        $order_query = q("SELECT ele_order FROM " . $xoopsDB->prefix("formulize") . " WHERE ele_caption = \"{$startID}\" AND id_form=\"{$fid}\"");
    } elseif ($startID === "first") {
        // get the ele_id of the element with the lowest weight
        $order_query = q("SELECT ele_order FROM " . $xoopsDB->prefix("formulize") . " WHERE id_form=\"{$fid}\" ORDER BY ele_order LIMIT 0,1");
    } else {
        $order_query = q("SELECT ele_order FROM " . $xoopsDB->prefix("formulize") . " WHERE id_form=\"{$fid}\" AND ele_id =\"{$startID}\"");
    }
    $starting_order = $order_query[0]['ele_order'];
    // gather the element IDs that are to be displayed, in order (include to the end of the form, whereas we actually only will display until we run out of cells)
    $element_ids_query = q("SELECT ele_id FROM " . $xoopsDB->prefix("formulize") . " WHERE ele_order >= '{$starting_order}' AND id_form='{$fid}' AND ele_type != 'subform' ORDER BY ele_order");
    // initialize form
    if (!$calledInternal) {
        print $GLOBALS['xoopsSecurity']->getTokenHTML();
    }
    // start buffering the output
    ob_start();
    // set the title row
    if ($headingAtSide) {
        $gridContents[0] = $title;
        $class = "even";
        print "<table class='outer'>\n<tr>";
        if ($actual_numrows > 0) {
            echo "<td class=head></td>";
        }
    } else {
        print "<table class=outer>\n";
        $class = "head";
        if ($title) {
            print "<tr><th colspan='{$numcols}'>{$title}</th></tr>\n";
        }
        print "<tr>\n<td class=\"head\">&nbsp;</td>\n";
    }
    // draw top row
    foreach ($colcaps as $thiscap) {
        if ($headingAtSide) {
            print "<td class=head>{$thiscap}</td>\n";
        } else {
            if ($orientation == "vertical" and $class == "even" and !$headingAtSide) {
                // only alternate rows
                $class = "odd";
            } elseif ($orientation == "vertical") {
                $class = "even";
            }
            print "<td class={$class}>{$thiscap}</td>\n";
        }
    }
    if (is_array($finalCell)) {
        // draw blank header for last column if there is such a thing
        print "<td class=head>&nbsp;</td>\n";
    }
    print "</tr>\n";
    // draw regular rows
    $class = "head";
    $row_index = 0;
    $ele_index = 0;
    foreach ($rowcaps as $thiscap) {
        if ($orientation == "horizontal" and $class == "even") {
            $class = "odd";
        } elseif ($orientation == "horizontal") {
            $class = "even";
        } else {
            $class = "head";
        }
        print "<tr>\n";
        if ($headingAtSide) {
            if ($actual_numrows > 0) {
                print "<td class=\"head\">{$thiscap}</td>\n";
            }
        } else {
            print "<td class={$class}>{$thiscap}</td>\n";
        }
        foreach ($colcaps as $thiscolcap) {
            if ($orientation == "vertical" and $class == "even") {
                $class = "odd";
            } elseif ($orientation == "vertical") {
                $class = "even";
            }
            print "<td class={$class}>\n";
            // display the element starting with the initial one.  Keep trying to display something until we're successful (displaying the element might fail if the user does not have permission to view (based on which groups are allowed to view this element)
            $rendered = "start";
            while ($rendered != "rendered" and $rendered != "rendered-disabled" and isset($element_ids_query[$ele_index])) {
                $rendered = displayElement("", $element_ids_query[$ele_index]['ele_id'], $entry, false, $screen);
                $ele_index++;
            }
            if ($rendered != "rendered" and $rendered != "rendered-disabled") {
                print "&nbsp;";
            }
            print "</td>\n";
        }
        if (is_array($finalCell)) {
            // draw final cell values if they exist
            if ($orientation == "vertical") {
                $class = "head";
            }
            if ($finalCell[$row_index]) {
                print "<td class={$class}>" . $finalCell[$row_index] . "</td>\n";
            } else {
                print "<td class={$class}>&nbsp;</td>\n";
            }
        }
        print "</tr>\n";
        $row_index++;
    }
    // draw final row if necessary
    if ($finalRow) {
        print "<tr>{$finalRow}</tr>\n";
    }
    print "</table>";
    $gridContents[1] = trans(ob_get_clean());
    if ($headingAtSide === "") {
        // if $headingAtSide is "" (not false) then we print out the grid contents here.  Only pass back contents if $headingAtSide is specified as true or false (presumably by the formdisplay.php file), since otherwise for backwards compatibility we need to printout contents here because that's what the behaviour used to be.
        print $gridContents[1];
    } elseif ($headingAtSide) {
        return $gridContents;
    } else {
        return $gridContents[1];
    }
}
         $GLOBALS['formulize_asynchronousFormDataInAPIFormat'][$passedEntryId][$handle] = $apiFormatValue;
     }
 }
 $elementObject = $element_handler->get($elementId);
 $html = "";
 if ($onetoonekey) {
     // the onetoonekey is what changed, not a regular conditional element, so in that case, we need to re-determine the entryId that we should be displaying
     // rebuild entries and fids so it only has the main form entry in it, since we want to get the correct other one-to-one entries back
     $onetooneentries = array($onetoonefid => array($onetooneentries[$onetoonefid][0]));
     $onetoonefids = array($onetoonefid);
     $checkForLinksResults = checkForLinks($onetoonefrid, $onetoonefids, $onetoonefid, $onetooneentries);
     $entryId = $checkForLinksResults['entries'][$elementObject->getVar('id_form')][0];
 }
 if (security_check($fid, $entryId)) {
     // "" is framework, ie: not applicable
     $deReturnValue = displayElement("", $elementObject, $entryId, false, null, null, false);
     // false, null, null, false means it's not a noSave element, no screen, no prevEntry data passed in, and do not render the element on screen
     if (is_array($deReturnValue)) {
         $form_ele = $deReturnValue[0];
         $isDisabled = $deReturnValue[1];
         $label_class = " formulize-label-" . $elementObject->getVar("ele_handle");
         $input_class = " formulize-input-" . $elementObject->getVar("ele_handle");
         // rendered HTML code below is taken from the formulize classes at the top of include/formdisplay.php
         if ($elementObject->getVar('ele_type') == "ib") {
             // if it's a break, handle it differently...
             $class = $form_ele[1] != '' ? " class='" . $form_ele[1] . "'" : '';
             if ($form_ele[0]) {
                 $html = "<td colspan='2' {$class}><div style=\"font-weight: normal;\">" . trans(stripslashes($form_ele[0])) . "</div></td>";
             } else {
                 $html = "<td colspan='2' {$class}>&nbsp;</td>";
             }
示例#6
0
function htmlForElement($elementHandle, $nameForHTML = "orphaned_formulize_element", $entry_id = "new")
{
    include_once XOOPS_ROOT_PATH . "/modules/formulize/include/elementdisplay.php";
    // 0 is the element HTML, 1 is the disabled flag
    $renderedElementArray = displayElement("", $elementHandle, $entry_id, $nameForHTML, null, null, false);
    if (is_array($renderedElementArray) and $renderedElementArray[1]) {
        return "This form element cannot be displayed because it is disabled.";
    } elseif (is_array($renderedElementArray)) {
        return $renderedElementArray[0]->render();
    } else {
        return $renderedElementArray;
    }
}
function displayFormPages($formframe, $entry = "", $mainform = "", $pages, $conditions = "", $introtext = "", $thankstext = "", $done_dest = "", $button_text = "", $settings = "", $overrideValue = "", $printall = 0, $screen = null, $saveAndContinueButtonText = null)
{
    // nmc 2007.03.24 - added 'printall'
    formulize_benchmark("Start of displayFormPages.");
    // extract the optional page titles from the $pages array for use in the jump to box
    // NOTE: pageTitles array must start with key 1, not 0.  Page 1 is the first page of the form
    $pageTitles = array();
    if (isset($pages['titles'])) {
        $pageTitles = $pages['titles'];
        unset($pages['titles']);
    }
    if (!$saveAndContinueButtonText and isset($_POST['formulize_saveAndContinueButtonText'])) {
        $saveAndContinueButtonText = unserialize($_POST['formulize_saveAndContinueButtonText']);
    }
    if (!$done_dest and $_POST['formulize_doneDest']) {
        $done_dest = $_POST['formulize_doneDest'];
    }
    if (!$button_text and $_POST['formulize_buttonText']) {
        $button_text = $_POST['formulize_buttonText'];
    }
    list($fid, $frid) = getFormFramework($formframe, $mainform);
    $thankstext = $thankstext ? $thankstext : _formulize_DMULTI_THANKS;
    $introtext = $introtext ? $introtext : "";
    global $xoopsUser;
    $mid = getFormulizeModId();
    $groups = $xoopsUser ? $xoopsUser->getGroups() : array(0 => XOOPS_GROUP_ANONYMOUS);
    $uid = $xoopsUser ? $xoopsUser->getVar('uid') : 0;
    $gperm_handler =& xoops_gethandler('groupperm');
    $member_handler =& xoops_gethandler('member');
    $single_result = getSingle($fid, $uid, $groups, $member_handler, $gperm_handler, $mid);
    // if this function was called without an entry specified, then assume the identity of the entry we're editing (unless this is a new save, in which case no entry has been made yet)
    // no handling of cookies here, so anonymous multi-page surveys will not benefit from that feature
    // this emphasizes how we need to standardize a lot of these interfaces with a real class system
    if (!$entry and $_POST['entry' . $fid]) {
        $entry = $_POST['entry' . $fid];
    } elseif (!$entry) {
        // or check getSingle to see what the real entry is
        $entry = $single_result['flag'] ? $single_result['entry'] : 0;
    }
    // formulize_newEntryIds is set when saving data
    if (!$entry and isset($GLOBALS['formulize_newEntryIds'][$fid])) {
        $entry = $GLOBALS['formulize_newEntryIds'][$fid][0];
    }
    $owner = getEntryOwner($entry, $fid);
    $prevPage = isset($_POST['formulize_prevPage']) ? $_POST['formulize_prevPage'] : 1;
    // last page that the user was on, not necessarily the previous page numerically
    $currentPage = isset($_POST['formulize_currentPage']) ? $_POST['formulize_currentPage'] : 1;
    $thanksPage = count($pages) + 1;
    // debug control:
    $currentPage = (isset($_GET['debugpage']) and is_numeric($_GET['debugpage'])) ? $_GET['debugpage'] : $currentPage;
    $usersCanSave = formulizePermHandler::user_can_edit_entry($fid, $uid, $entry);
    if ($pages[$prevPage][0] !== "HTML" and $pages[$prevPage][0] !== "PHP") {
        // remember prevPage is the last page the user was on, not the previous page numerically
        if (isset($_POST['form_submitted']) and $usersCanSave) {
            include_once XOOPS_ROOT_PATH . "/modules/formulize/include/formread.php";
            include_once XOOPS_ROOT_PATH . "/modules/formulize/include/functions.php";
            include_once XOOPS_ROOT_PATH . "/modules/formulize/class/data.php";
            //$owner_groups =& $member_handler->getGroupsByUser($owner, FALSE);
            $data_handler = new formulizeDataHandler($fid);
            $owner_groups = $data_handler->getEntryOwnerGroups($entry);
            $entries[$fid][0] = $entry;
            if ($frid) {
                $linkResults = checkForLinks($frid, array(0 => $fid), $fid, $entries, $gperm_handler, $owner_groups, $mid, $member_handler, $owner);
                unset($entries);
                $entries = $linkResults['entries'];
            }
            $entries = $GLOBALS['formulize_allWrittenEntryIds'];
            // set in readelements.php
            // if there has been no specific entry specified yet, then assume the identity of the entry that was just saved -- assumption is it will be a new save
            // from this point forward in time, this is the only entry that should be involved, since the 'entry'.$fid condition above will put this value into $entry even if this function was called with a blank entry value
            if (!$entry) {
                $entry = $entries[$fid][0];
            }
            synchSubformBlankDefaults($fid, $entry);
        }
    }
    // there are several points above where $entry is set, and now that we have a final value, store in ventry
    if ($entry > 0) {
        $settings['ventry'] = $entry;
    }
    // check to see if there are conditions on this page, and if so are they met
    // if the conditions are not met, move on to the next page and repeat the condition check
    // conditions only checked once there is an entry!
    $pagesSkipped = false;
    if (is_array($conditions) and $entry) {
        $conditionsMet = false;
        while (!$conditionsMet) {
            if (isset($conditions[$currentPage]) and count($conditions[$currentPage][0]) > 0) {
                // conditions on the current page
                $thesecons = $conditions[$currentPage];
                $elements = $thesecons[0];
                $ops = $thesecons[1];
                $terms = $thesecons[2];
                $types = $thesecons[3];
                // indicates if the term is part of a must or may set, ie: boolean and or or
                $filter = "";
                $oomfilter = "";
                $blankORSearch = "";
                foreach ($elements as $i => $thisElement) {
                    if ($ops[$i] == "NOT") {
                        $ops[$i] = "!=";
                    }
                    if ($terms[$i] == "{BLANK}") {
                        // NOTE...USE OF BLANKS WON'T WORK CLEANLY IN ALL CASES DEPENDING WHAT OTHER TERMS HAVE BEEN SPECIFIED!!
                        if ($ops[$i] == "!=" or $ops[$i] == "NOT LIKE") {
                            if ($types[$i] != "oom") {
                                // add to the main filter, ie: entry id = 1 AND x=5 AND y IS NOT "" AND y IS NOT NULL
                                if (!$filter) {
                                    $filter = $entry . "][" . $elements[$i] . "/**//**/!=][" . $elements[$i] . "/**//**/IS NOT NULL";
                                } else {
                                    $filter .= "][" . $elements[$i] . "/**//**/!=][" . $elements[$i] . "/**//**/IS NOT NULL";
                                }
                            } else {
                                // Add to the OOM filter, ie: entry id = 1 AND (x=5 OR y IS NOT "" OR y IS NOT NULL)
                                if (!$oomfilter) {
                                    $oomfilter = $elements[$i] . "/**//**/=][" . $elements[$i] . "/**//**/IS NULL";
                                } else {
                                    $oomfilter .= "][" . $elements[$i] . "/**//**/=][" . $elements[$i] . "/**//**/IS NULL";
                                }
                            }
                        } else {
                            if ($types[$i] != "oom") {
                                // add to its own OR filter, since we MUST match this condition, but we don't care if it's "" OR NULL
                                // ie: entry id = 1 AND (x=5 OR y=10) AND (z = "" OR z IS NULL)
                                if (!$blankORSearch) {
                                    $blankORSearch = $elements[$i] . "/**//**/=][" . $elements[$i] . "/**//**/IS NULL";
                                } else {
                                    $blankORSearch .= "][" . $elements[$i] . "/**//**/=][" . $elements[$i] . "/**//**/IS NULL";
                                }
                            } else {
                                // it's part of the oom filters anyway, so we put it there, because we don't care if it's null or "" or neither
                                if (!$oomfilter) {
                                    $oomfilter = $elements[$i] . "/**//**/=][" . $elements[$i] . "/**//**/IS NULL";
                                } else {
                                    $oomfilter .= "][" . $elements[$i] . "/**//**/=][" . $elements[$i] . "/**//**/IS NULL";
                                }
                            }
                        }
                    } elseif ($types[$i] == "oom") {
                        if (!$oomfilter) {
                            $oomfilter = $elements[$i] . "/**/" . trans($terms[$i]) . "/**/" . $ops[$i];
                        } else {
                            $oomfilter .= "][" . $elements[$i] . "/**/" . trans($terms[$i]) . "/**/" . $ops[$i];
                        }
                    } else {
                        if (!$filter) {
                            $filter = $entry . "][" . $elements[$i] . "/**/" . trans($terms[$i]) . "/**/" . $ops[$i];
                        } else {
                            $filter .= "][" . $elements[$i] . "/**/" . trans($terms[$i]) . "/**/" . $ops[$i];
                        }
                    }
                }
                if ($oomfilter and $filter) {
                    $finalFilter = array();
                    $finalFilter[0][0] = "AND";
                    $finalFilter[0][1] = $filter;
                    $finalFilter[1][0] = "OR";
                    $finalFilter[1][1] = $oomfilter;
                    if ($blankORSearch) {
                        $finalFilter[2][0] = "OR";
                        $finalFilter[2][1] = $blankORSearch;
                    }
                } elseif ($oomfilter) {
                    // need to add the $entry as a separate filter from the oom, so the entry and oom get an AND in between them
                    $finalFilter = array();
                    $finalFilter[0][0] = "AND";
                    $finalFilter[0][1] = $entry;
                    $finalFilter[1][0] = "OR";
                    $finalFilter[1][1] = $oomfilter;
                    if ($blankORSearch) {
                        $finalFilter[2][0] = "OR";
                        $finalFilter[2][1] = $blankORSearch;
                    }
                } else {
                    if ($blankORSearch) {
                        $finalFilter[0][0] = "AND";
                        $finalFilter[0][1] = $filter ? $filter : $entry;
                        $finalFilter[1][0] = "OR";
                        $finalFilter[1][1] = $blankORSearch;
                    } else {
                        $finalFilter = $filter;
                    }
                }
                $masterBoolean = "AND";
                include_once XOOPS_ROOT_PATH . "/modules/formulize/include/extract.php";
                $data = getData($frid, $fid, $finalFilter, $masterBoolean, "", "", "", "", "", false, 0, false, "", false, true);
                if (!$data) {
                    if ($prevPage <= $currentPage) {
                        $currentPage++;
                    } else {
                        $currentPage--;
                    }
                    $pagesSkipped = true;
                } else {
                    $conditionsMet = true;
                }
            } else {
                // no conditions on the current page
                $conditionsMet = true;
            }
        }
    }
    if ($currentPage > 1) {
        $previousPage = $currentPage - 1;
        // previous page numerically
    } else {
        $previousPage = "none";
    }
    $nextPage = $currentPage + 1;
    $done_dest = $done_dest ? $done_dest : getCurrentURL();
    $done_dest = substr($done_dest, 0, 4) == "http" ? $done_dest : "http://" . $done_dest;
    // Set up the javascript that we need for the form-submit functionality to work
    // note that validateAndSubmit calls the form validation function again, but obviously it will pass if it passed here.  The validation needs to be called prior to setting the pages, or else you can end up on the wrong page after clicking an ADD button in a subform when you've missed a required field.
    // savedPage and savedPrevPage are used to pick up the page and prevpage only when a two step validation, such as checking for uniqueness, returns and calls validateAndSubmit again
    ?>
	
	<script type='text/javascript'>
	var savedPage;
	var savedPrevPage;
	function submitForm(page, prevpage) {
		var validate = xoopsFormValidate_formulize();
		if(validate) {
			savedPage = 0;
			savedPrevPage = 0;
			multipageSetHiddenFields(page, prevpage);
			if (formulizechanged) {
        validateAndSubmit();
      } else {
        jQuery("#formulizeform").animate({opacity:0.4}, 200, "linear");
        jQuery("input[name^='decue_']").remove();
        // 'rewritePage' will trigger the page to change after the locks have been removed
        removeEntryLocks('rewritePage');
      }
    } else {
			savedPage = page;
			savedPrevPage = prevpage;
		}
  }

	function multipageSetHiddenFields(page, prevpage) {
		<?php 
    // neuter the ventry which is the key thing that keeps us on the form page,
    //  if in fact we just came from a list screen of some kind.
    // need to use an unusual selector, because something about selecting by id wasn't working,
    //  apparently may be related to setting actions on forms with certain versions of jQuery?
    print "\r\n\t\t\tif(page == {$thanksPage}) {\r\n\t\t\t\twindow.document.formulize.ventry.value = '';\r\n\t\t\t\tjQuery('form[name=formulize]').attr('action', '{$done_dest}');\r\n      }\r\n";
    ?>
      window.document.formulize.formulize_currentPage.value = page;
      window.document.formulize.formulize_prevPage.value = prevpage;
      window.document.formulize.formulize_doneDest.value = '<?php 
    print $done_dest;
    ?>
';
      window.document.formulize.formulize_buttonText.value = '<?php 
    print $button_text;
    ?>
';
	}

	function pageJump(options, prevpage) {
		for (var i=0; i < options.length; i++) {
			if (options[i].selected) {
				submitForm(options[i].value, prevpage);
				return false;
			}
		}
	}
	
	</script><noscript>
	<h1>You do not have javascript enabled in your web browser.  This form will not work with your web browser.  Please contact the webmaster for assistance.</h1>
	</noscript>
	<?php 
    if ($currentPage == $thanksPage) {
        if ($screen and $screen->getVar('finishisdone')) {
            print "<script type='text/javascript'>location = '{$done_dest}';</script>";
            return;
            // if we've ended up on the thanks page via conditions (last page was not shown) then we should just bail if there is not supposed to be a thanks page
        }
        if (is_array($thankstext)) {
            if ($thankstext[0] === "PHP") {
                eval($thankstext[1]);
            } else {
                print $thankstext[1];
            }
        } else {
            // HTML
            print html_entity_decode($thankstext);
        }
        print "<br><hr><br><div id=\"thankYouNavigation\"><p><center>\n";
        if ($pagesSkipped) {
            print _formulize_DMULTI_SKIP . "</p><p>\n";
        }
        $button_text = $button_text ? $button_text : _formulize_DMULTI_ALLDONE;
        if ($button_text != "{NOBUTTON}") {
            print "<a href='{$done_dest}'";
            if (is_array($settings)) {
                print " onclick=\"javascript:window.document.calreturnform.submit();return false;\"";
            }
            print ">" . $button_text . "</a>\n";
        }
        print "</center></p></div>";
        if (is_array($settings)) {
            print "<form name=calreturnform action=\"{$done_dest}\" method=post>\n";
            writeHiddenSettings($settings);
            print "</form>";
        }
    }
    if ($currentPage == 1 and $pages[1][0] !== "HTML" and $pages[1][0] !== "PHP" and !$_POST['goto_sfid']) {
        // only show intro text on first page if there's actually a form there
        print html_entity_decode(html_entity_decode($introtext));
    }
    unset($_POST['form_submitted']);
    // display an HTML or PHP page if that's what this page is...
    if ($currentPage != $thanksPage and ($pages[$currentPage][0] === "HTML" or $pages[$currentPage][0] === "PHP")) {
        // PHP
        if ($pages[$currentPage][0] === "PHP") {
            eval($pages[$currentPage][1]);
            // HTML
        } else {
            print $pages[$currentPage][1];
        }
        // put in the form that passes the entry, page we're going to and page we were on
        include_once XOOPS_ROOT_PATH . "/modules/formulize/include/functions.php";
        ?>
	
		
		<form name=formulize id=formulize action=<?php 
        print getCurrentURL();
        ?>
 method=post>
		<input type=hidden name=entry<?php 
        print $fid;
        ?>
 id=entry<?php 
        print $fid;
        ?>
 value=<?php 
        print $entry;
        ?>
>
		<input type=hidden name=formulize_currentPage id=formulize_currentPage value="">
		<input type=hidden name=formulize_prevPage id=formulize_prevPage value="">
		writeHiddenSettings($settings);
		</form>
	
		<script type="text/javascript">
			function validateAndSubmit() {
				window.document.formulize.submit();
			}
		</script>
	
		<?php 
    }
    // display a form if that's what this page is...
    if ($currentPage != $thanksPage and $pages[$currentPage][0] !== "HTML" and $pages[$currentPage][0] !== "PHP") {
        $buttonArray = array(0 => "{NOBUTTON}", 1 => "{NOBUTTON}");
        foreach ($pages[$currentPage] as $element) {
            $elements_allowed[] = $element;
        }
        $forminfo['elements'] = $elements_allowed;
        $forminfo['formframe'] = $formframe;
        $titleOverride = isset($pageTitles[$currentPage]) ? trans($pageTitles[$currentPage]) : "all";
        // we can pass in any text value as the titleOverride, and it will have the same effect as "all", but the alternate text will be used as the title for the form
        $GLOBALS['nosubforms'] = true;
        // subforms cannot have a view button on multipage forms, since moving to a sub causes total confusion of which entry and fid you are looking at
        $settings['formulize_currentPage'] = $currentPage;
        $settings['formulize_prevPage'] = $currentPage;
        // now that we're done everything else, we can send the current page as the previous page when initializing the form.  Javascript will set the true value prior to submission.
        formulize_benchmark("Before drawing nav.");
        $previousButtonText = (is_array($saveAndContinueButtonText) and isset($saveAndContinueButtonText['previousButtonText'])) ? $saveAndContinueButtonText['previousButtonText'] : _formulize_DMULTI_PREV;
        if ($usersCanSave and $nextPage == $thanksPage) {
            $nextButtonText = (is_array($saveAndContinueButtonText) and $saveAndContinueButtonText['saveButtonText']) ? $saveAndContinueButtonText['saveButtonText'] : _formulize_DMULTI_SAVE;
        } else {
            $nextButtonText = (is_array($saveAndContinueButtonText) and $saveAndContinueButtonText['nextButtonText']) ? $saveAndContinueButtonText['nextButtonText'] : _formulize_DMULTI_NEXT;
        }
        $previousPageButton = generatePrevNextButtonMarkup("prev", $previousButtonText, $usersCanSave, $nextPage, $previousPage, $thanksPage);
        $nextPageButton = generatePrevNextButtonMarkup("next", $nextButtonText, $usersCanSave, $nextPage, $previousPage, $thanksPage);
        $savePageButton = generatePrevNextButtonMarkup("save", _formulize_SAVE, $usersCanSave, $nextPage, $previousPage, $thanksPage);
        $totalPages = count($pages);
        $skippedPageMessage = $pagesSkipped ? _formulize_DMULTI_SKIP : "";
        $pageSelectionList = pageSelectionList($currentPage, $totalPages, $pageTitles, "above");
        // calling for the 'above' drawPageNav
        // setting up the basic templateVars for all templates
        $templateVariables = array('previousPageButton' => $previousPageButton, 'nextPageButton' => $nextPageButton, 'savePageButton' => $savePageButton, 'totalPages' => $totalPages, 'currentPage' => $currentPage, 'skippedPageMessage' => $skippedPageMessage, 'pageSelectionList' => $pageSelectionList, 'pageTitles' => $pageTitles, 'entry_id' => $entry, 'form_id' => $fid, 'owner' => $owner);
        print "<form name=\"pageNavOptions_above\" id=\"pageNavOptions_above\">\n";
        if ($screen and $toptemplate = $screen->getTemplate('toptemplate')) {
            formulize_renderTemplate('toptemplate', $templateVariables, $screen->getVar('sid'));
        } else {
            drawPageNav($usersCanSave, $currentPage, $totalPages, "above", $nextPageButton, $previousPageButton, $skippedPageMessage, $pageSelectionList);
        }
        print "</form>";
        formulize_benchmark("After drawing nav/before displayForm.");
        // need to check for the existence of an elementtemplate property in the screen, like we did with the top and bottom templates
        // if there's an eleemnt template, then do this loop, otherwise, do the displayForm call like normal
        if ($screen and $elementtemplate = $screen->getTemplate('elementtemplate')) {
            // Code added by Julian 2012-09-04 and Gordon Woodmansey 2012-09-05 to render the elementtemplate
            if (!security_check($fid, $entry)) {
                exit;
            }
            // start the form manually...
            $formObjectForRequiredJS = new formulize_themeForm('form object for required js', 'formulize', getCurrentURL(), "post", true);
            $element_handler = xoops_getmodulehandler('elements', 'formulize');
            print "<div id='formulizeform'><form id='formulize' name='formulize' action='" . getCurrentURL() . "' method='post' onsubmit='return xoopsFormValidate_formulize();' enctype='multipart/form-data'>";
            foreach ($elements_allowed as $thisElement) {
                // entry is a recordid, $thisElement is the element id
                // to get the conditional logic to be captured, we should buffer the drawing of the displayElement, and then output that later, because when displayElement does NOT return an object, then we get conditional logic -- subform rendering does it this way
                unset($form_ele);
                // previously set elements may linger when added to the form object, due to assignment of objects by reference or something odd like that...legacy of old code in the form class I think
                $deReturnValue = displayElement("", $thisElement, $entry, false, $screen, null, false);
                if (is_array($deReturnValue)) {
                    $form_ele = $deReturnValue[0];
                    $isDisabled = $deReturnValue[1];
                    if (isset($deReturnValue[2])) {
                        $hiddenElements = $deReturnValue[2];
                    }
                } else {
                    $form_ele = $deReturnValue;
                    $isDisabled = false;
                }
                if ($form_ele == "not_allowed") {
                    continue;
                } elseif ($form_ele == "hidden") {
                    $cueEntryValue = $entry ? $entry : "new";
                    $cueElement = new xoopsFormHidden("decue_" . $fid . "_" . $cueEntryValue . "_" . $thisElement, 1);
                    print $cueElement->render();
                    if (is_array($hiddenElements)) {
                        foreach ($hiddenElements as $thisHiddenElement) {
                            if ($is_object($thisHiddenElement)) {
                                print $thisHiddenElement->render() . "\n";
                            }
                        }
                    } elseif (is_object($hiddenElements)) {
                        print $hiddenElements->render() . "\n";
                    }
                    continue;
                } else {
                    $thisElementObject = $element_handler->get($thisElement);
                    $req = !$isDisabled ? intval($thisElementObject->getVar('ele_req')) : 0;
                    $formObjectForRequiredJS->addElement($form_ele, $req);
                    $elementMarkup = $form_ele->render();
                    $elementCaption = displayCaption("", $thisElement);
                    $elementDescription = displayDescription("", $thisElement);
                    $templateVariables['elementObjectForRendering'] = $form_ele;
                    $templateVariables['elementCaption'] = $elementCaption;
                    // here we can assume that the $previousPageButton etc has not be changed before rendering
                    $templateVariables['elementMarkup'] = $elementMarkup;
                    $templateVariables['elementDescription'] = $elementDescription;
                    $templateVariables['element_id'] = $thisElement;
                    formulize_renderTemplate('elementtemplate', $templateVariables, $screen->getVar('sid'));
                }
            }
            // now we also need to add in some bits that are necessary for the form submission logic to work...borrowed from parts of formdisplay.php mostly...this should be put together into a more distinct rendering system for forms, so we can call the pieces as needed
            print "<input type=hidden name=formulize_currentPage value='" . $settings['formulize_currentPage'] . "'>";
            print "<input type=hidden name=formulize_prevPage value='" . $settings['formulize_prevPage'] . "'>";
            print "<input type=hidden name=formulize_doneDest value='" . $settings['formulize_doneDest'] . "'>";
            print "<input type=hidden name=formulize_buttonText value='" . $settings['formulize_buttonText'] . "'>";
            print "<input type=hidden name=ventry value='" . $settings['ventry'] . "'>";
            print $GLOBALS['xoopsSecurity']->getTokenHTML();
            if ($entry) {
                print "<input type=hidden name=entry" . $fid . " value=" . intval($entry) . ">";
                // need this to persist the entry that the user is
            }
            print "</form></div>";
            print "<div id=savingmessage style=\"display: none; position: absolute; width: 100%; right: 0px; text-align: center; padding-top: 50px;\">\n";
            if (file_exists(XOOPS_ROOT_PATH . "/modules/formulize/images/saving-" . $xoopsConfig['language'] . ".gif")) {
                print "<img src=\"" . XOOPS_URL . "/modules/formulize/images/saving-" . $xoopsConfig['language'] . ".gif\">\n";
            } else {
                print "<img src=\"" . XOOPS_URL . "/modules/formulize/images/saving-english.gif\">\n";
            }
            print "</div>\n";
            drawJavascript();
            // need to create the form object, and add all the rendered elements to it, and then we'll have working required elements if we render the validation logic for the form
            print $formObjectForRequiredJS->renderValidationJS(true, true);
            // with tags, true, skip the extra js that checks for the formulize theme form divs around the elements so that conditional animation works, true
            // print "<script type=\"text/javascript\">function xoopsFormValidate_formulize(){return true;}</script>"; // shim for the validation javascript that is created by the xoopsThemeForms, and which our saving logic currently references...saving won't work without this...we should actually render the proper validation logic at some point, but not today.
        } else {
            displayForm($forminfo, $entry, $mainform, "", $buttonArray, $settings, $titleOverride, $overrideValue, "", "", 0, 0, $printall, $screen);
            // nmc 2007.03.24 - added empty params & '$printall'
        }
        formulize_benchmark("After displayForm.");
    }
    if ($currentPage != $thanksPage and !$_POST['goto_sfid']) {
        // have to get the new value for $pageSelection list if the user requires it on the users view.
        $pageSelectionList = pageSelectionList($currentPage, $totalPages, $pageTitles, "below");
        print "<form name=\"pageNavOptions_below\" id=\"pageNavOptions_below\">\n";
        if ($screen and $bottomtemplate = $screen->getTemplate('bottomtemplate')) {
            $templateVariables['pageSelectionList'] = $pageSelectionList;
            // assign the new pageSelectionList, since it was redone for the bottom section
            formulize_renderTemplate('bottomtemplate', $templateVariables, $screen->getVar('sid'));
        } else {
            drawPageNav($usersCanSave, $currentPage, $totalPages, "below", $nextPageButton, $previousPageButton, $skippedPageMessage, $pageSelectionList);
        }
        print "</form>";
    }
    formulize_benchmark("End of displayFormPages.");
}