Ejemplo n.º 1
0
// returns ele_handles
$cols = getAllColList($fid, $frid, $groups);
// $groups indicates that we only want columns which are visible to the current user
// handle metadata columns
$options['entry_id'] = _formulize_ENTRY_ID;
$options['creation_uid'] = _formulize_DE_CALC_CREATOR;
$options['mod_uid'] = _formulize_DE_CALC_MODIFIER;
$options['creation_datetime'] = _formulize_DE_CALC_CREATEDATE;
$options['mod_datetime'] = _formulize_DE_CALC_MODDATE;
$options['creator_email'] = _formulize_DE_CALC_CREATOR_EMAIL;
$usedvals = array();
foreach ($cols as $f => $vs) {
    foreach ($vs as $row => $values) {
        if (!in_array($values['ele_id'], $usedvals)) {
            $usedvals[] = $values['ele_handle'];
            $options[$values['ele_handle']] = $values['ele_coldhead'] != "" ? printSmart(trans($values['ele_colhead']), 75) : printSmart(trans(strip_tags($values['ele_caption'])), 75);
        }
    }
}
print "<HTML>";
print "<head>";
print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . _CHARSET . "\" />";
print "<title>" . _formulize_DE_PICKNEWCOLS . "</title>";
print "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"" . XOOPS_URL . "/xoops.css\" />\n";
$themecss = xoops_getcss();
print "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"{$themecss}\" />\n";
changeColJavascript();
print "</head>";
print "<body style=\"background: white; margin-top:20px;\"><center>";
print "<table style=\"width: 100%;\"><tr><td style=\"width: 5%;\"></td><td style=\"width: 90%;\">";
print "<form name=newcolform action=\"" . XOOPS_URL . "\" method=post>\n";
Ejemplo n.º 2
0
$returned = readQueryItems();
$cols = getAllColList($fid, $frid, $groups);
$returned = handleDelete($returned[0], $returned[1]);
// returns 1 if a deletion was made, 0 if not.
$items = $returned[0];
$hidden = $returned[1];
foreach ($cols as $f => $vs) {
    foreach ($vs as $row => $values) {
        $reqdcol = 'reqdcalc_column_' . $values['ele_id'];
        if (!in_array($values['ele_id'], $usedvals)) {
            // exclude duplicates...the array is not uniqued above because we don't want to merge it an unique it since that throws things out of order.
            $usedvals[] = $values['ele_id'];
            if ($values['ele_colhead'] != "") {
                $options[$values['ele_id']] = printSmart(trans($values['ele_colhead']), 60);
            } else {
                $options[$values['ele_id']] = printSmart(trans(strip_tags($values['ele_caption'])), 60);
            }
        }
    }
}
print "<HTML>";
print "<head>";
print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . _CHARSET . "\" />";
print "<title>" . _formulize_DE_BUILDQUERY . "</title>\n";
searchJavascript($items);
print "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"" . XOOPS_URL . "/xoops.css\" />\n";
$themecss = xoops_getcss();
//$themecss = substr($themecss, 0, -6);
//$themecss .= ".css";
print "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"{$themecss}\" />\n";
print "</head>";
 function adminPrepare($element)
 {
     $fid = !is_object($element) ? intval($_GET['fid']) : $element->getVar('id_form');
     $ele_value = $element ? $element->getVar('ele_value') : array();
     if (!$element) {
         //Assign default values
         $ele_value[2] = 1;
         $ele_value[3] = 1;
         $ele_value[9] = "entries";
     }
     $ele_value[1] = explode(",", $ele_value[1]);
     global $xoopsDB;
     global $xoopsUser;
     $uid = $xoopsUser->getVar('uid');
     $validForms1 = q("SELECT t1.fl_form1_id, t2.desc_form FROM " . $xoopsDB->prefix("formulize_framework_links") . " AS t1, " . $xoopsDB->prefix("formulize_id") . " AS t2 WHERE t1.fl_form2_id=" . intval($fid) . " AND t1.fl_unified_display=1 AND t1.fl_relationship != 1 AND t1.fl_form1_id=t2.id_form");
     $validForms2 = q("SELECT t1.fl_form2_id, t2.desc_form FROM " . $xoopsDB->prefix("formulize_framework_links") . " AS t1, " . $xoopsDB->prefix("formulize_id") . " AS t2 WHERE t1.fl_form1_id=" . intval($fid) . " AND t1.fl_unified_display=1 AND t1.fl_relationship != 1 AND t1.fl_form2_id=t2.id_form");
     $caughtfirst = false;
     foreach ($validForms1 as $vf1) {
         $validForms[$vf1['fl_form1_id']] = $vf1['desc_form'];
         if (!$caughtfirst) {
             $firstform = $vf1['fl_form1_id'];
             $caughtfirst = true;
         }
     }
     foreach ($validForms2 as $vf2) {
         if (!isset($validForms[$vf2['fl_form2_id']])) {
             $validForms[$vf2['fl_form2_id']] = $vf2['desc_form'];
             if (!$caughtfirst) {
                 $firstform = $vf2['fl_form2_id'];
                 $caughtfirst = true;
             }
         }
     }
     if (count($validForms) == 0) {
         $validForms['none'] = _AM_ELE_SUBFORM_NONE;
     }
     $subforms = $validForms;
     if ($caughtfirst) {
         $formtouse = $ele_value[0] ? $ele_value[0] : $firstform;
         // use the user's selection, unless there isn't one, then use the first form found
         $elementsq = q("SELECT ele_caption, ele_id FROM " . $xoopsDB->prefix("formulize") . " WHERE id_form=" . intval($formtouse) . " AND ele_type != \"areamodif\" AND ele_type != \"grid\" AND ele_type != \"ib\" AND ele_type != \"subform\" ORDER BY ele_order");
         foreach ($elementsq as $oneele) {
             $subformelements[$oneele['ele_id']] = printSmart($oneele['ele_caption']);
         }
     } else {
         $subformelements[0] = "";
     }
     // setup the UI for the subform conditions filter
     $subformfilter = formulize_createFilterUI($ele_value[7], "subformfilter", $ele_value[0], "form-2");
     return array('subformfilter' => $subformfilter, 'subformelements' => $subformelements, 'subforms' => $subforms, 'uid' => $uid, 'ele_value' => $ele_value);
 }
Ejemplo n.º 4
0
 function multiPageScreen_addToOptionsList($form_id, $options)
 {
     $formObject = new formulizeForm($form_id, true);
     // true causes all elements, even ones now shown to any user, to be included
     $elements = $formObject->getVar('elements');
     $elementCaptions = $formObject->getVar('elementCaptions');
     foreach ($elementCaptions as $key => $elementCaption) {
         $options[$elements[$key]] = printSmart(trans(strip_tags($elementCaption)));
         // need to pull out potential HTML tags from the caption
     }
     return $options;
 }
Ejemplo n.º 5
0
$i = 0;
foreach ($classFiles as $thisFile) {
    if (substr($thisFile, -11) == "Element.php") {
        $customType = substr($thisFile, 0, strpos($thisFile, "Element.php"));
        $customElementHandler = xoops_getmodulehandler($customType . "Element", "formulize");
        $customElementObject = $customElementHandler->create();
        $customElements[$i]['type'] = $customType;
        $customElements[$i]['name'] = $customElementObject->name;
        $i++;
    }
}
$i = 1;
$applications = array();
foreach ($allApps as $thisApp) {
    $applications[$i]['appid'] = $thisApp->getVar('appid');
    $applications[$i]['text'] = printSmart($thisApp->getVar('name'), 50);
    if (isset($formApplications)) {
        $applications[$i]['selected'] = in_array($thisApp->getVar('appid'), $formApplications) ? " selected" : "";
    } else {
        $applications[$i]['selected'] = "";
    }
    $i++;
}
// common values should be assigned to all tabs
$common['name'] = $formName;
$common['fid'] = $fid;
$common['aid'] = $aid;
$common['defaultform'] = $defaultform;
$common['defaultlist'] = $defaultlist;
$common['form_object'] = $formObject;
$common['note'] = $note;
 function adminPrepare($element)
 {
     $fid = $element ? $element->getVar('id_form') : intval($_GET['fid']);
     $ele_value = $element ? $element->getVar('ele_value') : array();
     if (!$element) {
         //Specify default ele_values
         $ele_value[0] = "";
         $ele_value[1] = 0;
         $ele_value[2] = "";
         $ele_value[3] = ".";
         $ele_value[4] = ",";
     }
     $derivedOptions = array();
     $allColList = getAllColList($fid);
     foreach ($allColList[$fid] as $thisCol) {
         if ($thisCol['ele_colhead'] != "") {
             $derivedOptions[trans($thisCol['ele_colhead'])] = printSmart(trans($thisCol['ele_colhead']));
         } else {
             $derivedOptions[trans(strip_tags($thisCol['ele_caption']))] = printSmart(trans(strip_tags($thisCol['ele_caption'])));
         }
     }
     $listOfElements = new XoopsFormSelect("", 'listofelementsoptions');
     $listOfElements->addOptionArray($derivedOptions);
     $listofelementsoptions = $listOfElements->render();
     return array('listofelementsoptions' => $listofelementsoptions, 'ele_value' => $ele_value);
 }
Ejemplo n.º 7
0
function printResults($masterResults, $blankSettings, $groupingSettings, $groupingValues, $masterResultsRaw, $filename = "", $title = "")
{
    $output = "";
    foreach ($masterResults as $elementId => $calcs) {
        $output .= "<tr><td class=head colspan=2>\n";
        $output .= printSmart(trans(getCalcHandleText($elementId)), 100);
        $output .= "\n</td></tr>\n";
        foreach ($calcs as $calc => $groups) {
            $countGroups = count($groups);
            $rowspan = ($countGroups > 1 and $calc != "count" and $calc != "sum") ? $countGroups : 1;
            $output .= "<tr><td class=even rowspan={$rowspan}>\n";
            // start of row with calculation results (possibly first row among many)
            switch ($calc) {
                case "sum":
                    $calc_name = _formulize_DE_CALC_SUM;
                    break;
                case "avg":
                    $calc_name = _formulize_DE_CALC_AVG;
                    break;
                case "min":
                    $calc_name = _formulize_DE_CALC_MIN;
                    break;
                case "max":
                    $calc_name = _formulize_DE_CALC_MAX;
                    break;
                case "count":
                    $calc_name = _formulize_DE_CALC_COUNT;
                    break;
                case "per":
                    $calc_name = _formulize_DE_CALC_PER;
                    break;
            }
            $output .= "<p><b>{$calc_name}</b></p>\n";
            switch ($blankSettings[$elementId][$calc]) {
                case "all":
                    $bsetting = _formulize_DE_INCLBLANKS;
                    break;
                case "noblanks":
                    $bsetting = _formulize_DE_EXCLBLANKS;
                    break;
                case "onlyblanks":
                    $bsetting = _formulize_DE_INCLONLYBLANKS;
                    break;
                case "justnoblanks":
                    $bsetting = _formulize_DE_EXCLONLYBLANKS;
                    break;
                case "justnozeros":
                    $bsetting = _formulize_DE_EXCLONLYZEROS;
                    break;
                default:
                    // must be custom
                    $bsetting = _formulize_DE_EXCLCUSTOM;
                    $setting = explode(",", substr(str_replace("!@^%*", ",", $blankSettings[$elementId][$calc]), 6));
                    // replace back the commas and remove the word custom from the front, and explode it into an array
                    $start = 1;
                    foreach ($setting as $thissetting) {
                        if (!$start) {
                            $bsetting .= ", ";
                        }
                        $start = 0;
                        if (substr($thissetting, 0, 1) == "!") {
                            $notText = strtolower(_formulize_NOT) . " ";
                            $thissetting = substr($thissetting, 1);
                        } else {
                            $notText = "";
                        }
                        $bsetting .= $notText . $thissetting;
                    }
                    break;
            }
            $output .= "<p class='formulize_blank_setting'>{$bsetting}</p>\n</td>\n";
            // start of right hand column for calculation results
            if ($calc == "count") {
                $output .= "<td class=odd>\n";
                // start of cell with calculations results
                if ($countGroups > 1) {
                    $theseGroupSettings = explode("!@^%*", $groupingSettings[$elementId][$calc]);
                    $firstGroupSettingText = printSmart(trans(getCalcHandleText($theseGroupSettings[0], true)));
                    $output .= "<table style='width: auto;'><tr><th>{$firstGroupSettingText}</th><td class='count-total' style='padding-left: 2em;'><center><b>" . _formulize_DE_CALC_NUMENTRIES . "</b><center></td><td class='count-unique' style='padding-left: 2em;'><center><b>" . _formulize_DE_CALC_NUMUNIQUE . "</b><center></td></tr>\n";
                    $totalCount = 0;
                    $totalUnique = 0;
                    foreach ($masterResultsRaw[$elementId][$calc] as $group => $rawResult) {
                        foreach ($theseGroupSettings as $id => $thisGroupSetting) {
                            if ($thisGroupSetting === "none") {
                                continue;
                            }
                            $elementMetaData = formulize_getElementMetaData($thisGroupSetting, false);
                            $groupText = formulize_swapUIText($groupingValues[$elementId][$calc][$group][$id], unserialize($elementMetaData['ele_uitext']));
                            $output .= "<tr><td>" . printSmart(trans($groupText)) . "</td><td class='count-total' style='text-align: right;'>" . $rawResult['count'] . "</td><td class='count-unique' style='text-align: right;'>" . $rawResult['countunique'] . "</td></tr>";
                            $totalCount += $rawResult['count'];
                            $totalUnique += $rawResult['countunique'];
                        }
                    }
                    $output .= "<tr><td style='border-top: 1px solid black;'><b>" . _formulize_DE_CALC_GRANDTOTAL . "</b></td><td style='border-top: 1px solid black; text-align: right;' class='count-total'><b>{$totalCount}</b></td><td style='border-top: 1px solid black; text-align: right;' class='count-unique'><b>{$totalUnique}</b></td></tr>\n";
                    $output .= "</table>";
                } else {
                    $rawResult = $masterResultsRaw[$elementId][$calc][0];
                    $output .= "<div class='count-total'><p><b>" . _formulize_DE_CALC_NUMENTRIES . " . . . " . $rawResult['count'] . "</b></p></div><div class='count-unique'><p><b>" . _formulize_DE_CALC_NUMUNIQUE . " . . . " . $rawResult['countunique'] . "</b></p></div>\n";
                }
                $output .= "</td></tr>";
                // end of the main row, and the specific cell with the calculations results
            } elseif ($calc == "sum") {
                $output .= "<td class=odd>\n";
                // start of cell with calculations results
                $handle = convertElementIdsToElementHandles($elementId);
                // returns an array, since it might be passed multiple values
                $handle = $handle[0];
                if ($countGroups > 1) {
                    $theseGroupSettings = explode("!@^%*", $groupingSettings[$elementId][$calc]);
                    $firstGroupSettingText = printSmart(trans(getCalcHandleText($theseGroupSettings[0], true)));
                    $output .= "<table style='width: auto;'><tr><th>{$firstGroupSettingText}</th><td class='sum-total' style='padding-left: 2em;'><center><b>" . _formulize_DE_CALC_SUM . "</b><center></td></tr>\n";
                    $totalSum = 0;
                    foreach ($masterResultsRaw[$elementId][$calc] as $group => $rawResult) {
                        foreach ($theseGroupSettings as $id => $thisGroupSetting) {
                            if ($thisGroupSetting === "none") {
                                continue;
                            }
                            $elementMetaData = formulize_getElementMetaData($thisGroupSetting, false);
                            $groupText = formulize_swapUIText($groupingValues[$elementId][$calc][$group][$id], unserialize($elementMetaData['ele_uitext']));
                            $output .= "<tr><td>" . printSmart(trans($groupText)) . "</td><td class='sum-total' style='text-align: right;'>" . formulize_numberFormat($rawResult['sum'], $handle) . "</td></tr>";
                            $totalSum += $rawResult['sum'];
                        }
                    }
                    $output .= "<tr><td style='border-top: 1px solid black;'><b>" . _formulize_DE_CALC_GRANDTOTAL . "</b></td><td style='border-top: 1px solid black; text-align: right;' class='sum-total'><b>" . formulize_numberFormat($totalSum, $handle) . "</b></td></tr>\n";
                    $output .= "</table>";
                } else {
                    $rawResult = $masterResultsRaw[$elementId][$calc][0];
                    $output .= "<div class='sum-total'><p><b>" . _formulize_DE_CALC_SUM . " . . . " . formulize_numberFormat($rawResult['sum'], $handle) . "</b></p></div>\n";
                }
                $output .= "</td></tr>";
                // end of the main row, and the specific cell with the calculations results
            } else {
                $start = 1;
                foreach ($groups as $group => $result) {
                    //foreach($result as $resultID=>$thisResult) {
                    if (!$start) {
                        $output .= "<tr>\n";
                    }
                    $start = 0;
                    $output .= "<td class=odd>\n";
                    //if(count($groups)>1) { // OR count($groups)>1) { // output the heading section for this group of results
                    $output .= "<p><b>";
                    $start2 = true;
                    foreach (explode("!@^%*", $groupingSettings[$elementId][$calc]) as $id => $thisGroupSetting) {
                        if ($thisGroupSetting === "none") {
                            continue;
                        }
                        if (!$start2) {
                            $output .= "<br>\n";
                        }
                        $start2 = false;
                        $elementMetaData = formulize_getElementMetaData($thisGroupSetting, false);
                        $groupText = formulize_swapUIText($groupingValues[$elementId][$calc][$group][$id], unserialize($elementMetaData['ele_uitext']));
                        $output .= printSmart(trans(getCalcHandleText($thisGroupSetting, true))) . ": " . printSmart(trans($groupText)) . "\n";
                    }
                    $output .= "</b></p>\n";
                    //}
                    $output .= "<p>{$result}</p>\n";
                    $output .= "</td></tr>\n";
                    //}
                }
            }
        }
    }
    print $output;
    // addition of calculation download, August 22 2006
    if ($filename) {
        // get the current CSS values for head, even and odd
        global $xoopsConfig;
        $head = "";
        $odd = "";
        $even = "";
        formulize_benchmark("before reading stylesheet");
        if (file_exists(XOOPS_ROOT_PATH . "/themes/" . $xoopsConfig['theme_set'] . "/style.css")) {
            if (!class_exists('csstidy')) {
                // use supplied csstidy in parent if one exists...
                if (file_exists(XOOPS_ROOT_PATH . "/plugins/csstidy/class.csstidy.php")) {
                    include_once XOOPS_ROOT_PATH . "/plugins/csstidy/class.csstidy.php";
                } else {
                    include_once XOOPS_ROOT_PATH . "/modules/formulize/class/class.csstidy.php";
                }
            }
            $css = new csstidy();
            $css->set_cfg('merge_selectors', 0);
            $css->parse_from_url(XOOPS_ROOT_PATH . "/themes/" . $xoopsConfig['theme_set'] . "/style.css");
            $parsed_css = $css->css;
            // parsed_css seems to have only one key when looking at the default template...key is the number of styles?
            foreach ($parsed_css as $thiscss) {
                $head = isset($thiscss['.head']['background-color']) ? $thiscss['.head']['background-color'] : isset($thiscss['.head']['background']) ? $thiscss['.head']['background'] : "";
                $even = isset($thiscss['.even']['background-color']) ? $thiscss['.even']['background-color'] : isset($thiscss['.even']['background']) ? $thiscss['.even']['background'] : "";
                $odd = isset($thiscss['.odd']['background-color']) ? $thiscss['.odd']['background-color'] : isset($thiscss['.odd']['background']) ? $thiscss['.odd']['background'] : "";
            }
        }
        formulize_benchmark("after reading stylesheet");
        unset($css);
        // if we couldn't find any values, use these:
        $head = $head ? $head : "#c2cdd6";
        $even = $even ? $even : "#dee3e7";
        $odd = $odd ? $odd : "#E9E9E9";
        // create the file
        formulize_benchmark("before creating file");
        $outputfile = "<HTML>\n<head>\n<meta name=\"generator\" content=\"Formulize -- form creation and data management for XOOPS\" />\n<title>" . _formulize_DE_EXPORTCALC_TITLE . " '{$title}'</title>\n<style type=\"text/css\">\n.outer {border: 1px solid silver;}\n.head { background-color: {$head}; padding: 5px; font-weight: bold; }\n.even { background-color: {$even}; padding: 5px; }\t\t\n.odd { background-color: {$odd}; padding: 5px; }\nbody {color: black; background: white; margin-top: 30px; margin-bottom: 30px; margin-left: 30px; margin-right: 30px; padding: 0; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 10pt;}\ntd { vertical-align: top; }\n</style>\n</head>\n<body>\n<h1>" . _formulize_DE_EXPORTCALC_TITLE . " '{$title}'</h1>\n<table class=outer>\n{$output}\n</table>\n</body>\n</html>";
        // output the file
        $exfilename = strrchr($filename, "/");
        $wpath = XOOPS_ROOT_PATH . SPREADSHEET_EXPORT_FOLDER . "{$exfilename}";
        $exportfile = fopen($wpath, "w");
        fwrite($exportfile, $outputfile);
        fclose($exportfile);
    }
    formulize_benchmark("after creating file");
}
Ejemplo n.º 8
0
/**
 * Helper method to draw bar graph
 * parameters have same meaning as displayGraph's parameters
 */
function displayBarGraph($fid, $frid, $labelElement, $dataElement, $operation, $graphOptions)
{
    // getting data from DB
    if (is_int($frid) && $frid > 0) {
        $dbData = getData($frid, $fid);
    } else {
        $dbData = getData("", $fid);
    }
    foreach ($dbData as $entry) {
        // mayor - OR array of mayors if there's more than one in the dataset, depending on the one-to-may in a relationship
        $dataRawValue = display($entry, $dataElement);
        // city_name;
        $labelRawValue = display($entry, $labelElement);
        if (!is_array($dataRawValue) && $dataRawValue) {
            $dataRawValue = array($dataRawValue);
        }
        if (!is_array($labelRawValue)) {
            $labelRawValue = array($labelRawValue);
        }
        foreach ($labelRawValue as $thisLabelValue) {
            if ($dataPoints[$thisLabelValue]) {
                $dataPoints[$thisLabelValue] = array_merge($dataPoints[$thisLabelValue], $dataRawValue);
            } else {
                $dataPoints[$thisLabelValue] = $dataRawValue;
            }
        }
    }
    // Oct 29 Update for column heading for graphs:
    $elementHandler = xoops_getmodulehandler('elements', 'formulize');
    $elementObject = $elementHandler->get($labelElement);
    $labelElement = $elementObject->getVar('ele_colhead') ? $elementObject->getVar('ele_colhead') : printSmart($elementObject->getVar('ele_caption'));
    $elementObject = $elementHandler->get($dataElement);
    $dataElement = $elementObject->getVar('ele_colhead') ? $elementObject->getVar('ele_colhead') : printSmart($elementObject->getVar('ele_caption'));
    // end of Update
    switch ($operation) {
        case "count":
            // count the values in each label of the array
            foreach (array_keys($dataPoints) as $key) {
                if (!empty($dataPoints[$key])) {
                    $dataPoints[$key] = count($dataPoints[$key]);
                } else {
                    $dataPoints[$key] = 0;
                }
            }
            if ($labelElement == $dataElement) {
                $dataElement = "count of " . $labelElement;
            } else {
                $dataElement = "count of " . $dataElement;
            }
            break;
        case "sum":
        case "display":
            // TODO: Check this!
            foreach ($dataPoints as $thisLabel => $theseValues) {
                $dataPoints[$thisLabel] = array_sum($theseValues);
            }
            $dataElement = ($operation == "display" ? "number of " : "sum of ") . $dataElement;
            break;
        case "count-unique":
            foreach ($dataPoints as $thisLabel => $theseValues) {
                $dataPoints[$thisLabel] = count(array_unique($theseValues));
            }
            if ($dataElement == $labelElement) {
                $dataElement = "count of unique " . $labelElement;
            } else {
                $dataElement = "count of unique " . $dataElement;
            }
            break;
        default:
            echo "Sorry, the operation \"{$operation}\" for Bar graph is not supported at the moment!";
            return;
    }
    // print("dataElement: ".$dataElement." ");
    // print("labelElement: ".$labelElement." ");
    // process the graph options
    // these defaults will be used, unless overwritten by values from the $graphOptions array
    $sizeMultiplier = sizeof(array_keys($dataPoints));
    $BAR_THICKNESS = 40;
    $IMAGE_WIDTH = 600;
    $IMAGE_DEFAULT_WIDTH = $IMAGE_WIDTH;
    if ($sizeMultiplier > 1) {
        $IMAGE_HEIGHT = $BAR_THICKNESS * $sizeMultiplier / 0.5;
    } else {
        $IMAGE_HEIGHT = $BAR_THICKNESS * 4;
    }
    $IMAGE_DEFAULT_HEIGHT = $IMAGE_HEIGHT;
    $IMAGE_ORIENTATION = "vertical";
    $BACKGROUND_R = 141;
    $BACKGROUND_G = 189;
    $BACKGROUND_B = 225;
    $BARCOLOR_R = 143;
    $BARCOLOR_G = 190;
    $BARCOLOR_B = 88;
    if (sizeof($graphOptions) > 0) {
        foreach ($graphOptions as $graphoption => $value) {
            switch ($graphoption) {
                case "width":
                    $IMAGE_WIDTH = $value;
                    break;
                case "height":
                    $IMAGE_HEIGHT = $value;
                    break;
                case "orientation":
                    $IMAGE_ORIENTATION = $value;
                    if ($IMAGE_ORIENTATION == "horizontal") {
                        if ($IMAGE_HEIGHT == $IMAGE_DEFAULT_HEIGHT) {
                            $IMAGE_HEIGHT = 500;
                        } else {
                            if ($IMAGE_WIDTH == $IMAGE_DEFAULT_WIDTH) {
                                $IMAGE_WIDTH = $BAR_THICKNESS * $sizeMultiplier / 0.5;
                            }
                        }
                    }
                    break;
                case "backgroundcolor":
                    // print_r($value);
                    foreach ($value as $RGB => $colorvalue) {
                        switch ($RGB) {
                            case "R":
                                $BACKGROUND_R = $colorvalue;
                                break;
                            case "G":
                                $BACKGROUND_G = $colorvalue;
                                break;
                            case "B":
                                $BACKGROUND_B = $colorvalue;
                                break;
                            default:
                                echo "Please follow the correct format of backgroundcolor.";
                                break;
                        }
                    }
                    break;
                case "barcolor":
                    // print_r($value);
                    foreach ($value as $RGB => $colorvalue) {
                        switch ($RGB) {
                            case "R":
                                $BARCOLOR_R = $colorvalue;
                                break;
                            case "G":
                                $BARCOLOR_G = $colorvalue;
                                break;
                            case "B":
                                $BARCOLOR_B = $colorvalue;
                                break;
                            default:
                                echo "Please follow the correct format of backgroundcolor.";
                                break;
                        }
                    }
                    break;
                default:
                    echo "Sorry, the graph option \"{$graphoption}\" for Bar graph is not supported at the moment!<br>";
                    break;
            }
        }
    }
    // reset width/height of the image in case the label is too long
    if (strlen($labelElement) * 4.5 >= $IMAGE_HEIGHT and $IMAGE_ORIENTATION == "vertical") {
        if ($IMAGE_HEIGHT == $IMAGE_DEFAULT_HEIGHT) {
            $IMAGE_HEIGHT = strlen($labelElement) * 5;
        } else {
            $labelElement = substr($labelElement, 0, $IMAGE_HEIGHT / 4.5 - 3) . "...";
        }
    } elseif (strlen($dataElement) * 4.5 >= $IMAGE_HEIGHT and $IMAGE_ORIENTATION == "horizontal") {
        if ($IMAGE_HEIGHT == $IMAGE_DEFAULT_HEIGHT) {
            $IMAGE_HEIGHT = strlen($dataElement) * 5;
        } else {
            $dataElement = substr($dataElement, 0, $IMAGE_HEIGHT / 4.5 - 3) . "...";
        }
    } elseif (strlen($labelElement) * 4.5 >= $IMAGE_WIDTH and $IMAGE_ORIENTATION == "horizontal") {
        if ($IMAGE_WIDTH == $IMAGE_DEFAULT_WIDTH) {
            $IMAGE_WIDTH = strlen($labelElement) * 5;
        } else {
            $labelElement = substr($labelElement, 0, $IMAGE_HEIGHT / 4.5 - 3) . "...";
        }
    } elseif (strlen($dataElement) * 4.5 >= $IMAGE_WIDTH and $IMAGE_ORIENTATION == "vertical") {
        if ($IMAGE_WIDTH == $IMAGE_DEFAULT_WIDTH) {
            $IMAGE_WIDTH = strlen($dataElement) * 5;
        } else {
            $dataElement = substr($dataElement, 0, $IMAGE_HEIGHT / 4.5 - 3) . "...";
        }
    }
    // Code straightly copied from pChart documentation to draw the graph
    $myData = new pData();
    $myData->addPoints(array_values($dataPoints), $dataElement);
    $myData->setAxisName(0, $dataElement);
    $myData->addPoints(array_keys($dataPoints), $labelElement);
    $myData->setSerieDescription($labelElement, $labelElement);
    $myData->setAbscissa($labelElement);
    $myData->setAbscissaName($labelElement);
    // $myData -> setAxisDisplay(0, AXIS_FORMAT_CUSTOM, "YAxisFormat");
    /* Create the pChart object */
    $myPicture = new pImage($IMAGE_WIDTH, $IMAGE_HEIGHT, $myData);
    $myPicture->drawGradientArea(0, 0, $IMAGE_WIDTH, $IMAGE_HEIGHT, DIRECTION_VERTICAL, array("StartR" => $BACKGROUND_R, "StartG" => $BACKGROUND_G, "StartB" => $BACKGROUND_B, "EndR" => $BACKGROUND_R, "EndG" => $BACKGROUND_G, "EndB" => $BACKGROUND_B, "Alpha" => 100));
    $myPicture->drawGradientArea(0, 0, 500, 500, DIRECTION_HORIZONTAL, array("StartR" => 240, "StartG" => 240, "StartB" => 240, "EndR" => 180, "EndG" => 180, "EndB" => 180, "Alpha" => 30));
    $myPicture->setFontProperties(array("FontName" => "modules/formulize/libraries/pChart/fonts/arial.ttf", "FontSize" => 8));
    $paddingtoLeft = $IMAGE_WIDTH * 0.15;
    $paddingtoTop = $IMAGE_HEIGHT * 0.2;
    if ($paddingtoTop > 50) {
        $paddingtoTop = 50;
    }
    /* Draw the chart scale */
    $myPicture->setGraphArea($paddingtoLeft, $paddingtoTop, $IMAGE_WIDTH * 0.9, $IMAGE_HEIGHT * 0.88);
    if ($IMAGE_ORIENTATION == "vertical") {
        $myPicture->drawScale(array("CycleBackground" => TRUE, "DrawSubTicks" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "Pos" => SCALE_POS_TOPBOTTOM, "Mode" => SCALE_MODE_ADDALL_START0, "Decimal" => 0, "MinDivHeight" => 50));
    } else {
        $myPicture->drawScale(array("CycleBackground" => TRUE, "DrawSubTicks" => TRUE, "GridR" => 0, "GridG" => 0, "GridB" => 0, "GridAlpha" => 10, "Mode" => SCALE_MODE_ADDALL_START0, "Decimal" => 0, "MinDivHeight" => 50));
    }
    /* Turn on shadow computing */
    $myPicture->setShadow(TRUE, array("X" => 1, "Y" => 1, "R" => 0, "G" => 0, "B" => 0, "Alpha" => 10));
    $Palette = array("0" => array("R" => $BARCOLOR_R, "G" => $BARCOLOR_G, "B" => $BARCOLOR_B, "Alpha" => 100));
    for ($i = 1; $i < $sizeMultiplier; $i++) {
        $Palette[$i] = array("R" => $BARCOLOR_R, "G" => $BARCOLOR_G, "B" => $BARCOLOR_B, "Alpha" => 100);
    }
    // print_r($Palette);
    $myPicture->drawBarChart(array("OverrideColors" => $Palette));
    /* Draw the chart */
    $myPicture->drawBarChart(array("DisplayPos" => LABEL_POS_INSIDE, "DisplayValues" => TRUE, "Rounded" => TRUE, "Surrounding" => 30, "OverrideColors" => $Palette));
    renderGraph($myPicture, $fid, $frid, $labelElement, $dataElement, $operation, $graphOptions);
    return;
}
Ejemplo n.º 9
0
 function formatFrameworksAsRelationships($frameworks)
 {
     $relationships = array();
     $relationshipIndices = array();
     $i = 1;
     foreach ($frameworks as $framework) {
         $frid = $framework->getVar('frid');
         if (isset($relationshipIndices[$frid])) {
             continue;
         }
         $relationships[$i]['name'] = $framework->getVar('name');
         $relationships[$i]['content']['frid'] = $frid;
         $frameworkLinks = $framework->getVar('links');
         $li = 1;
         $links = array();
         foreach ($frameworkLinks as $link) {
             $links[$li]['form1'] = printSmart(getFormTitle($link->getVar('form1')));
             $links[$li]['form2'] = printSmart(getFormTitle($link->getVar('form2')));
             switch ($link->getVar('relationship')) {
                 case 1:
                     $relationship = _AM_FRAME_ONETOONE;
                     break;
                 case 2:
                     $relationship = _AM_FRAME_ONETOMANY;
                     break;
                 case 3:
                     $relationship = _AM_FRAME_MANYTOONE;
                     break;
             }
             $links[$li]['relationship'] = printSmart($relationship);
             $li++;
         }
         $relationships[$i]['content']['links'] = $links;
         $relationshipIndices[$frid] = true;
         $i++;
     }
     return $relationships;
 }
Ejemplo n.º 10
0
            // publishing permission is taken to be all that we need, but it's actually the disused update report permissions that should probably be trotted out for this
            $plainSpecGroups = "," . implode(",", array_intersect($groups, $specificgroups)) . ",";
        } else {
            $plainSpecGroups = substr($_GET['currentview'], 17);
        }
        $memberonlySpecGroups = $_GET['currentview'];
    } else {
        $plainSpecGroups = $_GET['currentview'];
        $memberonlySpecGroups = ",onlymembergroups" . $_GET['currentview'];
    }
    if ($publish_reports or $publish_globalscope) {
        $scope->addOption($plainSpecGroups, $s4 . printSmart($groupNames, 100) . "<br>");
        $scope->addOption($memberonlySpecGroups, $s5 . printSmart($groupNames, 100));
        // add special flag that is used to control whether to include only groups that the viewer is a member of
    } else {
        $scope->addOption($plainSpecGroups, $s4 . printSmart($groupNames, 100));
    }
}
//$scopeoptions->addElement($scope1);
//if($scope2) { $scopeoptions->addElement($scope2); }
//if($scope3) { $scopeoptions->addElement($scope3); }
//if($scope4) { $scopeoptions->addElement($scope4); }
$saveform->addElement($savelist);
$saveform->addElement($scope);
// add in list of groups if they have publishing options
// 1. get list of groups they can publish to
// 2. get publishing option for the lastloaded, if any
// 3. set defaults in list to the defaults
$publishgroups['donotpub'] = _formulize_DE_SAVE_NOPUB;
if ($publish_reports) {
    foreach ($groups as $key => $groupid) {
Ejemplo n.º 11
0
function multiPageScreen_addToOptionsList($fid, $options)
{
    $formObject = new formulizeForm($fid);
    $elements = $formObject->getVar('elements');
    $elementCaptions = $formObject->getVar('elementCaptions');
    foreach ($elementCaptions as $key => $elementCaption) {
        $options[$elements[$key]] = printSmart(trans(strip_tags($elementCaption)));
        // need to pull out potential HTML tags from the caption
    }
    return $options;
}
             print 'valuenotfound';
         }
     } else {
         print 'invalidelement';
     }
     break;
 case 'get_element_option_list':
     include_once XOOPS_ROOT_PATH . "/modules/formulize/include/functions.php";
     $elementsq = q("SELECT ele_caption, ele_id FROM " . $xoopsDB->prefix("formulize") . " WHERE id_form=" . intval($_GET['fid']) . " AND ele_type != \"ib\" AND ele_type != \"subform\" ORDER BY ele_order");
     $json = "{ \"options\": [";
     $start = true;
     foreach ($elementsq as $oneele) {
         if (!$start) {
             $json .= ", ";
         }
         $json .= "{\"id\": \"" . $oneele['ele_id'] . "\", \"value\": \"" . printSmart($oneele['ele_caption']) . "\"}";
         $start = false;
     }
     $json .= "]}";
     print $json;
     break;
 case 'delete_uploaded_file':
     $folderName = $_GET['param1'];
     $element_id = $_GET['param2'];
     $entry_id = $_GET['param3'];
     $element_handler = xoops_getmodulehandler('elements', 'formulize');
     $elementObject = $element_handler->get($element_id);
     $fid = $elementObject->getVar('id_form');
     include_once XOOPS_ROOT_PATH . "/modules/formulize/class/data.php";
     $data_handler = new formulizeDataHandler($fid);
     $fileInfo = $data_handler->getElementValueInEntry($entry_id, $elementObject);
###############################################################################
// this file handles saving of submissions from the relationship_settings page of the new admin UI
// if we aren't coming from what appears to be save.php, then return nothing
if (!isset($processedValues)) {
    return;
}
$op = $_POST['formulize_admin_op'];
$relationship_id = $_POST['formulize_admin_key'];
if ($relationship_id == "new") {
    // create the framework first
    $framework_handler = xoops_getmodulehandler('frameworks', 'formulize');
    $frameworkObject = $framework_handler->create();
    $form_handler = xoops_getmodulehandler('forms', 'formulize');
    $form1Object = $form_handler->get($processedValues['relationships']['fid1']);
    $form2Object = $form_handler->get($processedValues['relationships']['fid2']);
    $frameworkObject->setVar('name', printSmart($form1Object->getVar('title')) . " + " . printSmart($form2Object->getVar('title')));
    if (!($relationship_id = $framework_handler->insert($frameworkObject))) {
        print "Error: could not create the framework";
    }
    $redirectionURL = XOOPS_URL . "/modules/formulize/admin/ui.php?page=relationship&aid=" . intval($_POST['aid']) . "&frid={$relationship_id}";
    if (isset($_POST['fid'])) {
        $redirectionURL .= "&fid=" . intval($_POST['fid']);
    }
    if (isset($_POST['sid'])) {
        $redirectionURL .= "&sid=" . intval($_POST['sid']);
    }
}
// save all changes, the user could have modified links and then clicked add or
// remove which causes a page reload, so preserve all user changes
updateframe($relationship_id);
switch ($op) {
Ejemplo n.º 14
0
 function formulize_setupPreviousEntryUI($screen, $element_id, $type, $owner, $de = false, $entryId = "", $ele_handle, $fid)
 {
     // 1. need to get and cache the values of the entry for this screen
     // 2. need to put the values into a dropdown list with an onchange event that populates the actual form element
     // this should be cached in some other way, since every instance of the renderer will need to cache this.  If it were a GLOBAL or this whole thing were in some other function, that would work.
     static $cachedEntries = array();
     if (!isset($cachedEntries[$screen->getVar('sid')])) {
         // identify the entry belonging to this user's group(s) in the other form.  Currently only group correspondence is supported.
         global $xoopsUser;
         $groups = $xoopsUser ? $xoopsUser->getGroups() : array(0 => XOOPS_GROUP_ANONYMOUS);
         $member_handler =& xoops_gethandler('member');
         $gperm_handler =& xoops_gethandler('groupperm');
         $mid = getFormulizeModId();
         $owner_groups =& $member_handler->getGroupsByUser($owner, FALSE);
         // in this particular case, it's okay to make the owner_groups based on the users's memberships, since we want to present the single entry that belongs to whichever groups the user is a member of...I think.  :-)
         $singleData = getSingle($screen->getVar('paraentryform'), $owner, $owner_groups, $member_handler, $gperm_handler, $mid);
         if ($singleData['flag'] == "group" and $singleData['entry'] > 0) {
             // only proceed if there is a one-entry-per-group situation in the target form
             formulize_benchmark("Ready to do previous entry query.");
             $cachedEntries[$screen->getVar('sid')] = getData("", $screen->getVar('paraentryform'), $singleData['entry']);
             formulize_benchmark("Done query.");
         } else {
             return "";
         }
     }
     $entries = $cachedEntries[$screen->getVar('sid')];
     // big assumption below is corresponding captions.  In future there will be more ad hoc ways of describing which elements align to which other ones.
     // 1. figure out the corresponding element ID based on matching captions
     // 2. grab the previous value from the $entry/entries
     // 3. create the dropdown list with these values, including javascript
     $formHandler =& xoops_getmodulehandler('forms', 'formulize');
     $currentForm = $formHandler->get($screen->getVar('fid'));
     $previousForm = $formHandler->get($screen->getVar('paraentryform'));
     $currentCaptions = $currentForm->getVar('elementCaptions');
     $captionToMatch = $currentCaptions[$ele_handle];
     $previousCaptions = $previousForm->getVar('elementCaptions');
     $previousElementHandle = array_search($captionToMatch, $previousCaptions);
     if (!$previousElementHandle) {
         return "";
     }
     $elementName = $de ? "de_" . $fid . "_" . $entryId . "_" . $element_id : "ele_" . $element_id;
     // displayElement elements have different names from regular elements
     $previousElementId = formulize_getIdFromElementHandle($previousElementHandle);
     // function is in extract.php
     // setup the javascript based on the type of question, and setup other data that is required
     switch ($type) {
         case "text":
         case "date":
             $javascript = "onchange='javascript:this.form." . $elementName . ".value=this.form.prev_" . $element_id . ".value;'";
             break;
         case "radio":
             // need to get the options of the question so we know what to match
             $prevElementMetaData = formulize_getElementMetaData($previousElementId);
             // use this function in extract instead of the get element method in handler, since this is guaranteed to be already be cached in memory
             $prevElement_ele_value = unserialize($prevElementMetaData['ele_value']);
             $prevElementOptions = array_keys($prevElement_ele_value);
             $javascript = "onchange='javascript:if(this.form.prev_" . $element_id . ".value !== \"\") { this.form." . $elementName . "[this.form.prev_" . $element_id . ".value].checked=true; }'";
             break;
         case "yn":
             $javascript = "onchange='javascript:if(this.form.prev_" . $element_id . ".value !== \"\") { this.form." . $elementName . "[this.form.prev_" . $element_id . ".value].checked=true; }'";
             break;
     }
     $previousOptions = array();
     $prevOptionsExist = false;
     foreach ($entries as $id => $entry) {
         $value = htmlspecialchars(strip_tags(display($entry, $previousElementHandle)));
         if (is_array($value)) {
             $value = printSmart(implode(", ", $value));
         }
         if (trim($value) === "" or trim($value) == "0000-00-00") {
             continue;
         }
         $prevOptionsExist = true;
         switch ($type) {
             case "text":
             case "date":
                 $previousOptions[$value] = $value;
                 break;
             case "radio":
                 $prevElementPosition = array_search($value, $prevElementOptions);
                 // need to figure out which option matches the text of the value
                 if ($prevElementPosition !== false) {
                     $previousOptions[$prevElementPosition] = $value;
                     // for radio buttons, we need to pass the position of the option
                 }
                 break;
             case "yn":
                 if ($value == _formulize_TEMP_QYES) {
                     $previousOptions[0] = $value;
                 } elseif ($value == _formulize_TEMP_QNO) {
                     $previousOptions[1] = $value;
                 }
                 break;
         }
     }
     if (!$prevOptionsExist) {
         return "";
     }
     $prevUI = new xoopsFormSelect('', 'prev_' . $element_id, '123qweasdzxc', 1, false);
     // 123qweasdzxc is meant to be a unique value that will never be selected, since we don't ever want a previous selection showing by default
     $prevUI->addOption('', _AM_FORMULIZE_PREVIOUS_OPTION);
     $prevUI->addOptionArray($previousOptions);
     $prevUI->setExtra($javascript);
     return $prevUI;
 }
Ejemplo n.º 15
0
function drawMenuSection($application, $menulinks, $forceOpen, $form_handler)
{
    if ($application == 0) {
        $aid = 0;
        $name = _AM_CATGENERAL;
        $forms = $form_handler->getFormsByApplication(0, true);
        // true forces ids, not objects, to be returned
    } else {
        $aid = intval($application->getVar('appid'));
        $name = printSmart($application->getVar('name'), 200);
        $forms = $application->getVar('forms');
    }
    static $topwritten = false;
    $itemurl = XOOPS_URL . "/modules/formulize/application.php?id={$aid}";
    if (!$topwritten) {
        $block = "<a class=\"menuTop\" href=\"{$itemurl}\">{$name}</a>";
        $topwritten = 1;
    } else {
        $block = "<a class=\"menuMain\" href=\"{$itemurl}\">{$name}</a>";
    }
    $isThisSubMenu = false;
    foreach ($menulinks as $menulink) {
        if ($menulink->getVar("menu_id") == $_GET['menuid']) {
            $isThisSubMenu = true;
        }
    }
    if ($forceOpen or isset($_GET['id']) and strstr(getCurrentURL(), "/modules/formulize/application.php") and $aid == $_GET['id'] or strstr(getCurrentURL(), "/modules/formulize/index.php?fid=") and in_array($_GET['fid'], $forms) or $isThisSubMenu) {
        // if we're viewing this application or a form in this application, or this is the being forced open (only application)...
        foreach ($menulinks as $menulink) {
            $suburl = XOOPS_URL . "/modules/formulize/index.php?" . $menulink->getVar("screen");
            $url = $menulink->getVar("url");
            $target = "";
            if (strlen($url) > 0) {
                $target = " target='_blank' ";
                $pos = strpos($url, "://");
                if ($pos === false) {
                    $url = "http://" . $url;
                }
                $suburl = $url;
            }
            $block .= "<a class=\"menuSub\" {$target} href='{$suburl}'>" . $menulink->getVar("text") . "</a>";
        }
    }
    return $block;
}
Ejemplo n.º 16
0
            if (!in_array($values['ele_id'], $usedvals)) {
                // exclude duplicates...the array is not uniqued above because we don't want to merge it an unique it since that throws things out of order.
                $usedvals[] = $values['ele_id'];
                if (!$_POST[$reqdcol] and !in_array($values['ele_id'], $_POST['column'])) {
                    // Also exclude columns that have been used already.
                    if ($values['ele_colhead'] != "") {
                        $options[$values['ele_id']] = printSmart(trans($values['ele_colhead']), 60);
                    } else {
                        $options[$values['ele_id']] = printSmart(trans(strip_tags($values['ele_caption'])), 60);
                    }
                }
                // used for the grouping list box
                if ($values['ele_colhead'] != "") {
                    $options2[$values['ele_id']] = "Group by: " . printSmart(trans($values['ele_colhead']));
                } else {
                    $options2[$values['ele_id']] = "Group by: " . printSmart(trans(strip_tags($values['ele_caption'])));
                }
            }
        }
    }
}
include_once XOOPS_ROOT_PATH . "/class/xoopsformloader.php";
print "<HTML>";
print "<head>";
print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=" . _CHARSET . "\" />";
print "<title>" . _formulize_DE_PICKCALCS . "</title>\n";
calcJavascript();
print "<link rel=\"stylesheet\" type=\"text/css\" media=\"screen\" href=\"" . XOOPS_URL . "/xoops.css\" />\n";
$themecss = xoops_getcss();
//$themecss = substr($themecss, 0, -6);
//$themecss .= ".css";
Ejemplo n.º 17
0
function buildNotOptionList($sql, $type)
{
    global $xoopsDB;
    $res = $xoopsDB->query($sql);
    $options = array();
    $noOptionText = $type == "elementuid" ? _formulize_DE_SETNOT_NOELEMENTOPTIONS : _formulize_DE_SETNOT_NOLINKCREATOROPTIONS;
    if ($res) {
        while ($array = $xoopsDB->fetchArray($res)) {
            $options[$array['ele_id']] = $array['ele_colhead'] ? printSmart(trans($array['ele_colhead'])) : printSmart(trans($array['ele_caption']));
        }
        if (count($options) == 0) {
            $options[0] = $noOptionText;
        }
    } else {
        $options[0] = $noOptionText;
    }
    return $options;
}
 function adminPrepare($element)
 {
     $ele_value = $element ? $element->getVar('ele_value') : array();
     $fid = $element ? $element->getVar('id_form') : intval($_GET['fid']);
     if (!$element) {
         $ele_value[3] = "horizontal";
         $ele_value[5] = 1;
         $ele_value[0] = "caption";
     }
     $background = $ele_value[3];
     $sideortop = $ele_value[5] == 1 ? "side" : "above";
     $heading = $ele_value[0];
     $grid_elements_criteria = new Criteria();
     $grid_elements_criteria->setSort('ele_order');
     $grid_elements_criteria->setOrder('ASC');
     $element_handler = xoops_getmodulehandler('elements', 'formulize');
     $grid_elements = $element_handler->getObjects($grid_elements_criteria, $fid);
     foreach ($grid_elements as $this_element) {
         $grid_start_options[$this_element->getVar('ele_id')] = $this_element->getVar('ele_colhead') ? printSmart(trans($this_element->getVar('ele_colhead'))) : printSmart(trans($this_element->getVar('ele_caption')));
     }
     return array('grid_start_options' => $grid_start_options, 'background' => $background, 'sideortop' => $sideortop, 'heading' => $heading, 'ele_value' => $ele_value);
 }
Ejemplo n.º 19
0
 function formatDataForList($value)
 {
     global $myts;
     if ($this->length == 0) {
         $this->length = 35;
     }
     if ($this->striphtml !== false) {
         // want to do this all the time, no matter what, unless the user specifically turns it off, because it's a security precaution
         $value = $myts->htmlSpecialChars($value, ENT_QUOTES);
     }
     $value = printSmart(trans($value), $this->length);
     if ($this->clickable) {
         $value = $myts->makeClickable($value);
     }
     return $value;
 }
Ejemplo n.º 20
0
     $options['subform_screens'][0] = "(Use Default Screen)";
     foreach ($screen_options as $screen_option) {
         $options['subform_screens'][$screen_option["sid"]] = $screen_option["title"];
     }
     // setup the UI for the subform conditions filter
     $options['subformfilter'] = formulize_createFilterUI($ele_value[7], "subformfilter", $ele_value[0], "form-2");
 } elseif ($ele_type == "grid") {
     $options['background'] = $ele_value[3];
     $options['heading'] = $ele_value[0];
     $options['sideortop'] = $ele_value[5] == 1 ? "side" : "above";
     $grid_elements_criteria = new Criteria();
     $grid_elements_criteria->setSort('ele_order');
     $grid_elements_criteria->setOrder('ASC');
     $grid_elements = $element_handler->getObjects($grid_elements_criteria, $fid);
     foreach ($grid_elements as $this_element) {
         $grid_start_options[$this_element->getVar('ele_id')] = $this_element->getVar('ele_colhead') ? printSmart(trans($this_element->getVar('ele_colhead'))) : printSmart(trans($this_element->getVar('ele_caption')));
     }
     $options['grid_start_options'] = $grid_start_options;
 } elseif ($ele_type == "radio") {
     $ele_value = formulize_mergeUIText($ele_value, $ele_uitext);
     $options['useroptions'] = $ele_value;
 } elseif ($ele_type == "checkbox") {
     $ele_value = formulize_mergeUIText($ele_value, $ele_uitext);
     $options['useroptions'] = $ele_value;
 } elseif ($ele_type == "select") {
     if ($ele_id == "new") {
         $options['listordd'] = 0;
         $options['multiple'] = 0;
         $ele_value[0] = 6;
         $options['islinked'] = 0;
         $options['formlink_scope'] = array(0 => 'all');
Ejemplo n.º 21
0
function getExistingFilter($filterSettings, $filterName, $formWithSourceElements, $formName, $defaultTypeIfNoFilterTypeGiven = "all", $groups = false, $filterAllText = _formulize_GENERIC_FILTER_ALL, $filterConText = _formulize_GENERIC_FILTER_CON, $filterButtonText = _formulize_GENERIC_FILTER_ADDBUTTON)
{
    if (!$filterName or !$formWithSourceElements or !$formName) {
        return false;
    }
    // set all the elements that we want to show the user
    $cols = "";
    if ($groups) {
        $cols = getAllColList($formWithSourceElements, "", $groups);
    } else {
        $cols = getAllColList($formWithSourceElements);
    }
    $options = array('creation_uid' => _formulize_DE_CALC_CREATOR, 'creation_datetime' => _formulize_DE_CALC_CREATEDATE, 'mod_uid' => _formulize_DE_CALC_MODIFIER, 'mod_datetime' => _formulize_DE_CALC_MODDATE);
    if (is_array($cols)) {
        // setup the options array for form elements
        foreach ($cols as $f => $vs) {
            foreach ($vs as $row => $values) {
                if ($values['ele_colhead'] != "") {
                    $options[$values['ele_handle']] = printSmart(trans($values['ele_colhead']), 40);
                } else {
                    $options[$values['ele_handle']] = printSmart(trans(strip_tags($values['ele_caption'])), 40);
                }
            }
        }
    }
    // process existing conditions...setup needed variables
    $oldElementsName = $filterName . "_elements";
    $oldOpsName = $filterName . "_ops";
    $oldTermsName = $filterName . "_terms";
    $oldTypesName = $filterName . "_types";
    // unpack existing conditions
    if (is_array($filterSettings)) {
        ${$oldElementsName} = $filterSettings[0];
        ${$oldOpsName} = $filterSettings[1];
        ${$oldTermsName} = $filterSettings[2];
        if (isset($filterSettings[3])) {
            ${$oldTypesName} = $filterSettings[3];
        } else {
            if (is_array($filterSettings[0])) {
                foreach ($filterSettings[0] as $i => $thisFilterSettingsZero) {
                    ${$oldTypesName}[$i] = $defaultTypeIfNoFilterTypeGiven;
                }
            }
        }
    }
    // setup needed variables for the all or oom
    // > match all of these
    $conditionlist = array();
    // > match one or more of these
    $conditionlistOOM = array();
    if (is_array(${$oldElementsName})) {
        $i = 0;
        foreach (${$oldElementsName} as $x => $thisOldElementsName) {
            // need to add [$i] to the generation of the hidden values here, so the hidden condition keys equal the flag on the deletion X
            // $x will be the order based on the filter settings that were passed in, might not start at 0.  $i will always start at 0, so this way we'll catch/correct any malformed arrays as people edit/save them
            if (${$oldTypesName}[$x] == "all") {
                array_push($conditionlist, $options[${$oldElementsName}[$x]] . " " . ${$oldOpsName}[$x] . " " . ${$oldTermsName}[$x]);
            } else {
                array_push($conditionlistOOM, $options[${$oldElementsName}[$x]] . " " . ${$oldOpsName}[$x] . " " . ${$oldTermsName}[$x]);
            }
            $i++;
        }
    }
    $existingConditions = array();
    $existingConditions['all'] = $conditionlist;
    $existingConditions['oom'] = $conditionlistOOM;
    return $existingConditions;
}