Example #1
0
function processForm2()
{
    $comprobando = false;
    $nombre = $_POST["nombre"];
    $apellidos = $_POST["apellidos"];
    if (!empty($_POST["nombre"]) && !empty($_POST["apellidos"])) {
        if (preg_match("/^[-]*[0-9]+\$/", $numMenor) && preg_match("/^[-]*[0-9]+\$/", $numMayor)) {
            $comprobando = true;
        }
        if ($comprobando) {
            echo "Lista de pares de numeros de {$numMenor} y {$numMayor} <br>";
            for ($i = $numMenor, $j = $numMayor; $i <= $numMayor; $i++, $j--) {
                echo "({$i},{$j})  ";
            }
            echo "<a href='Ejer12.php'>Volver</a>";
        } else {
            if (!empty($_POST["nombre"])) {
                displayForm("Introduce correctamente el nombre");
            }
        }
        if (!empty($_POST["apellidos"])) {
            displayForm("Introduce correctamente el nombre");
        }
    }
}
Example #2
0
function inspectDatabase()
{
    $tableName = displayForm();
    if (isset($tableName) && strlen($tableName) > 0) {
        $table = pullRecords1($tableName);
        printTable($table);
    }
}
Example #3
0
function procesForm()
{
    // El formulario se ha ejecutado, así que trabajamos con sus datos
    $userName = filter_input(INPUT_POST, "userName");
    if (isset($_POST["userName"]) and !empty($_POST["userName"])) {
        print "<h2>Hola, {$userName}!</h2> \n";
    } else {
        $mensaje = "<b>No has introducido el nombre.</b>";
        displayForm($mensaje);
    }
}
Example #4
0
function procesForm()
{
    $num1 = $_POST["numero1"];
    $num2 = $_POST["numero2"];
    $num3 = $_POST["numero3"];
    if (is_numeric($num1) && is_numeric($num2) && is_numeric($num3)) {
        echo 'el numero mayor es: ';
        numMayor($num1, $num2, $num3);
    } else {
        echo "dato no numerico";
        displayForm();
    }
}
Example #5
0
function veriForm()
{
    $camposObligatorios = array("nombreUsuario", "apellidos");
    $camposPendientes = array();
    foreach ($camposObligatorios as $campoObligatorio) {
        if (!isset($_POST[$campoObligatorio]) or !$_POST[$campoObligatorio] or !preg_match("/^[a-zA-Z][a-zA-Z ]+\$/", $_POST[$campoObligatorio])) {
            $camposPendientes[] = $campoObligatorio;
        }
    }
    if ($camposPendientes) {
        displayForm($camposPendientes);
    } else {
        procesForm();
    }
}
Example #6
0
function procesForm()
{
    $camposObligatorios = array("nombre");
    $camposPendientes = array();
    foreach ($camposObligatorios as $obligatorio) {
        if (!isset($_POST["{$obligatorio}"]) or !$_POST["{$obligatorio}"] or !preg_match("/^[-]?[0-9]+\$/", $_POST["{$obligatorio}"])) {
            $camposPendientes[] = $obligatorio;
        }
    }
    if ($camposPendientes) {
        displayForm($camposPendientes);
    } else {
        displayResultado();
    }
}
Example #7
0
function processForm()
{
    $requiredFields = array("firstName", "lastName", "password1", "password2", "gender");
    $missingFields = array();
    foreach ($requiredFields as $requiredField) {
        if (!isset($_POST[$requiredField]) or !$_POST[$requiredField]) {
            $missingFields[] = $requiredField;
        }
    }
    if ($missingFields) {
        displayForm($missingFields);
    } else {
        displayThanks();
    }
}
Example #8
0
function processForm()
{
    $number = (int) $_POST["number"];
    $guessesLeft = (int) $_POST["guessesLeft"] - 1;
    $guess = (int) $_POST["guess"];
    if ($guess == $number) {
        displaySuccess($number);
    } elseif ($guessesLeft == 0) {
        displayFailure($number);
    } elseif ($guess < $number) {
        displayForm($number, $guessesLeft, "Too low - try again!");
    } else {
        displayForm($number, $guessesLeft, "Too high - try again!");
    }
}
function displayFormElements($message)
{
    $elementos = $_POST['elementos'];
    if (is_array($elementos) && checkEmptyForm($elementos)) {
        displayform("");
        $suma = 0;
        echo 'El vector tiene ' . count($elementos) . ' elementos<br>';
        for ($i = 0; $i < count($elementos); $i++) {
            echo "{$i} = {$elementos[$i]}" . '<br>';
            $suma += $elementos[$i];
        }
        echo "La suma es: {$suma}";
    } else {
        displayForm("Error!! No todos los campos del array son correctos!");
        displayElements(count($elementos));
    }
}
Example #10
0
function processForm2()
{
    $elementos = $_POST["elementos"];
    $mensaje = '';
    $suma = 0;
    if (!isset($_POST["enviar"])) {
        $mensaje = "Hubo algunos problemas con el formulario<br>";
        displayForm($mensaje);
    } else {
        displayForm($mensaje);
        echo "El vector tiene " . count($elementos) . "elementos<br>";
        for ($i = 0; $i < count($elementos); $i++) {
            echo "{$i} = {$elementos[$i]}<br>";
            $suma = $suma + $elementos[$i];
        }
        echo "la suma de los elementos es: {$suma}";
    }
}
Example #11
0
function processForm()
{
    $comprobando = false;
    $num = $_POST["num"];
    if (!empty($_POST["num"])) {
        if (preg_match("/^[-]*[0-9]+\$/", $num)) {
            $comprobando = true;
        }
        if ($comprobando) {
            echo "Tabla de multiplicar del {$num} <br>";
            for ($j = 0; $j <= 10; $j++) {
                echo "{$j} x {$num} = " . $j * $num . "<br>";
            }
            echo "<a href='Ejer11.php'>Volver</a>";
        } else {
            displayForm("Introduce correctamente el numero a multiplicar");
        }
    }
}
Example #12
0
function veriForm()
{
    $camposObligatorios = array("nombre", "apellidos", "direccion", "telefono", "email");
    $camposErroneos = array();
    $camposPendientes = array();
    foreach ($camposObligatorios as $campoObligatorio) {
        if ($campoObligatorio == "email") {
        } else {
            if (!isset($_POST[$campoObligatorio]) or !$_POST[$campoObligatorio]) {
                $camposPendientes[] = $campoObligatorio;
            }
        }
    }
    if ($camposPendientes) {
        displayForm($camposPendientes);
    } else {
        procesForm();
    }
}
Example #13
0
function procesForm()
{
    if (preg_match("/^[0-9]+\$/", $_POST["pesetas"]) && isset($_POST["moneda"])) {
        $pesetas = $_POST["pesetas"];
        $conversor = $_POST["moneda"];
        switch ($conversor) {
            case 'euros':
                echo conversorEuros($pesetas);
                break;
            case 'dolares':
                echo conversorDolares($pesetas);
                break;
            case 'yenes':
                echo conversorYenes($pesetas);
                break;
        }
    } else {
        $mensaje = "<p class='error'>Hubo algunos problemas con el formulario que usted presentó.\nPor favor, rellene el campo <b>pesetas</b> correctamente.</p>";
        displayForm($mensaje);
    }
}
Example #14
0
function processForm()
{
    $requiredFields = array("username", "password");
    $missingFields = array();
    $errorMessages = array();
    $member = new Member(array("username" => isset($_POST["username"]) ? preg_replace("/[^ \\-\\_a-zA-Z0-9]/", "", $_POST["username"]) : "", "password" => isset($_POST["password"]) ? preg_replace("/[^ \\-\\_a-zA-Z0-9]/", "", $_POST["password"]) : ""));
    foreach ($requiredFields as $requiredField) {
        if (!$member->getValue($requiredField)) {
            $missingFields[] = $requiredField;
        }
    }
    if ($missingFields) {
        $errorMessages[] = '<p class="error">There were some missing fields in the form you submitted. Please complete the fields highlighted below and click Login to resend the form.</p>';
    } elseif (!($loggedInMember = $member->authenticate())) {
        $errorMessages[] = '<p class="error">Sorry, we could not log you in with those details. Please check your username and password, and try again.</p>';
    }
    if ($errorMessages) {
        displayForm($errorMessages, $missingFields, $member);
    } else {
        $_SESSION["member"] = $loggedInMember;
        displayThanks();
    }
}
Example #15
0
function changePassword($passwordChangeType)
{
    $infos = null;
    $errors = null;
    try {
        if ($passwordChangeType == 'set' && isset($_POST['userId']) && isset($_POST['passwordOne'])) {
            if ($_POST['passwordOne'] == $_POST['passwordConfirm']) {
                WorkbenchContext::get()->getPartnerConnection()->setPassword($_POST['userId'], $_POST['passwordOne']);
                $infos[] = "Successfully set password for " . $_POST['userId'];
            } else {
                $errors[] = "Passwords must match, and don't be sneaky and turn off JavaScript";
            }
        } else {
            if ($passwordChangeType == 'reset' && isset($_POST['userId'])) {
                $changePasswordResult = WorkbenchContext::get()->getPartnerConnection()->resetPassword($_POST['userId']);
                $infos[] = "Successfully reset password for " . $_POST['userId'];
            }
        }
    } catch (Exception $e) {
        $errors[] = $e->getMessage();
    }
    displayForm($infos, $errors);
}
Example #16
0
function processForm()
{
    $comprobando = true;
    $nums = $_POST["num"];
    for ($j = 0; $j < count($nums); $j++) {
        if (!empty($_POST["num[{$j}]"])) {
            if (!preg_match("/^[-]*[0-9]+\$/", $nums[$j])) {
                $comprobando = false;
            }
        }
    }
    if ($comprobando) {
        echo "El vector tiene " . count($nums) . " elementos<br>";
        $suma = 0;
        for ($i = 0; $i < count($nums); $i++) {
            echo $i . " = " . $nums[$i] . "<br>";
            $suma = $suma + $nums[$i];
        }
        echo "La suma de los numeros es: {$suma}";
        displayForm("");
    } else {
        displayForm("Introduce correctamente los numeros");
    }
}
Example #17
0
<!--
/* 
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
/*
* Autor= Javi
* Fecha= 30-oct-2015
* Licencia= default
* Version= Expression version is undefined on line 10, column 14 in Templates/Scripting/EmptyPHP.php.
* Descripcion=
* /
-->
<html>
    <head>
        <meta charset ="UTF-8" />
        <title></title>
    </head>
    <body>
        <?php 
include_once 'funcionesRelleno.php';
include_once 'funcionesEjer1.php';
if (isset($_POST["enviar"])) {
    procesForm();
} else {
    displayForm(array());
}
?>
    </body>
</html>
//$form =& $creator->create($wikipage);
// create the needed renderer
$renderer =& patForms::createRenderer("Array");
// set the renderer
$form->setRenderer($renderer);
// use auto-validation
$form->setAutoValidate('save');
// serialize the elements
$elements = $form->renderForm();
// ERROR DISPLAY ------------------------------------------------------
if ($form->isSubmitted()) {
    displayErrors($form);
    // see patExampleGen/customFunctions.php
}
// DISPLAY FORM ------------------------------------------------------
displayForm($form, $elements);
// see patExampleGen/customFunctions.php
/**
 * Takes a patForms object, asks it if there are any validation
 * errors and displays them if need be.
 *
 * NOTE: this is just a helper method for our examples collection,
 * so that you may concentrate on the relevant parts of the examples.
 * It does in no way represent the way it should be done :)
 *
 * @access     public
 * @param      object  &$form  The patForms object to use
 */
function displayErrors(&$form)
{
    // get the errors from the form object - if there are none,
Example #19
0
 /**
  * displayFacebookRegister 
  * 
  * @return void
  */
 function handleFacebookRegister()
 {
     $fbData = getFacebookConfigData();
     $fbProfile = '';
     if (empty($fbData['fb_app_id']) && empty($fbData['fb_secret'])) {
         $this->displayHeader();
         $this->displayHtmlForm(T_('Facebook isn\'t Configured Yet.'));
         $this->displayFooter();
         return;
     }
     $facebook = new Facebook(array('appId' => $fbData['fb_app_id'], 'secret' => $fbData['fb_secret']));
     // Check if the user is logged in and authed
     $fbUser = $facebook->getUser();
     if ($fbUser) {
         try {
             $fbProfile = $facebook->api('/me');
         } catch (FacebookApiException $e) {
             $fbUser = null;
         }
     }
     // the user's auth went away or logged out of fb, send them back to register form
     if (!$fbUser) {
         displayForm();
         return;
     }
     // Register new user
     $accessToken = $facebook->getAccessToken();
     $params = array('fname' => $fbProfile['first_name'], 'lname' => $fbProfile['last_name'], 'email' => $fbProfile['email'], 'sex' => $fbProfile['gender'] == 'male' ? 'M' : 'F', 'username' => $fbProfile['email'], 'password' => 'FACEBOOK', 'accessToken' => $accessToken);
     displaySubmit($params);
 }
                    displayForm("success", "", "", "", "");
                } else {
                    unlink('../../images/' . basename($_FILES["imgUpload"]["name"]));
                    displayForm("fail_submit", $_POST["title"], $_POST["description"], $_POST["date"], $_POST["imgDescription"]);
                }
            } else {
                displayForm("fail_upload", $_POST["title"], $_POST["description"], $_POST["date"], $_POST["imgDescription"]);
            }
        } else {
            displayForm("fail_image_ext", $_POST["title"], $_POST["description"], $_POST["date"], $_POST["imgDescription"]);
        }
    } else {
        displayForm("fail_image_exist", $_POST["title"], $_POST["description"], $_POST["date"], $_POST["imgDescription"]);
    }
} else {
    displayForm("", "", "", date("Y-m-d"), "");
}
function checkExtension($fileExtension)
{
    if (strcasecmp($fileExtension, "jpg") != 0) {
        if (strcasecmp($fileExtension, "jpeg") != 0) {
            if (strcasecmp($fileExtension, "png") != 0) {
                if (strcasecmp($fileExtension, "gif") != 0) {
                    return FALSE;
                }
            } else {
                return TRUE;
            }
        } else {
            return TRUE;
        }
Example #21
0
    $backlogField = Config::getInstance()->getValue(Config::id_customField_backlog);
    $fieldList = array('project_id', 'category_id', 'custom_' . $customField_type, 'codevtt_elapsed', 'custom_' . $backlogField, 'codevtt_drift');
    $serialized = serialize($fieldList);
    Config::setValue('issue_tooltip_fields', $serialized, Config::configType_string, 'fields to be displayed in issue tooltip');
    // Add custom fields to existing projects
    echo "DEBUG 15/16 Prepare existing projects<br/>";
    if (isset($_POST['projects']) && !empty($_POST['projects'])) {
        $selectedProjects = $_POST['projects'];
        foreach ($selectedProjects as $projectid) {
            $project = ProjectCache::getInstance()->getProject($projectid);
            echo "DEBUG prepare project: " . $project->getName() . "<br/>";
            Project::prepareProjectToCodev($projectid);
        }
    }
    echo "DEBUG 16/16 Install Mantis plugins<br/>";
    installMantisPlugin('CodevTT', true);
    installMantisPlugin('FilterBugList', false);
    echo "DEBUG done.<br/>";
    // load homepage
    #echo ("<script type='text/javascript'> alert('install done.'); </script>");
    echo "<script type='text/javascript'> parent.location.replace('install_step4.php'); </script>";
}
// ----- DISPLAY PAGE
#displayStepInfo();
#echo "<hr align='left' width='20%'/>\n";
$extIdCustomFieldCandidates = getExtIdCustomFieldCandidates();
displayForm($originPage, $codevOutputDir, $checkReportsDirError, $isJob2, $isJob3, $isJob4, $isJob5, $job2, $job3, $job4, $job5, $job_support, $job_sideTasks, $jobSupport_color, $jobNA_color, $job2_color, $job3_color, $job4_color, $job5_color, $projectList, $groupExtID, $extIdCustomFieldCandidates, $extIdCustomField, $userList, $admin_id, $statusList, $status_new, $status_feedback, $status_open, $status_closed, $is_modified);
?>

</div>
Example #22
0
function processForm()
{
    $requiredFields = array("email", "pass");
    $missingFields = array();
    $errorMessages = array();
    $cliente = new Cliente(array("email" => isset($_POST["email"]) ? preg_replace("/[^ \\@\\.\\-\\_a-zA-Z0-9]/", "", $_POST["email"]) : "", "pass" => isset($_POST["pass"]) ? preg_replace("/[^ \\-\\_a-zA-Z0-9]/", "", $_POST["pass"]) : ""));
    foreach ($requiredFields as $requiredField) {
        if (!$cliente->getValue($requiredField)) {
            $missingFields[] = $requiredField;
        }
    }
    if ($missingFields) {
        $errorMessages[] = '<p>Rellena todos los formularios con los datos correctos</p>';
    } elseif (!($loggedInCliente = $cliente->authenticate())) {
        $errorMessages[] = '<p>Lo sentimos, no te encontramos en nuestra base de datos, email o contraseña incorrecta</p>';
    }
    if ($errorMessages) {
        displayForm($errorMessages, $missingFields, $cliente);
    } else {
        $_SESSION["cliente"] = $loggedInCliente;
        displayThanks();
    }
}
Example #23
0
        echo $user;
        ?>
&index=<?php 
        echo $k;
        ?>
"><?php 
        echo $v['details']['metadata']['game'];
        ?>
</a> - <a href="http://net-chess.com/viewgame.cgi?p1=<?php 
        echo $v['details']['metadata']['game'];
        ?>
" target="_blank">Open</a> <span id="sel_<?php 
        echo $v['details']['metadata']['game'];
        ?>
" class="selected" style="font-weight:bold;"></span><?php 
        echo displayForm($v['details']['metadata']['game']);
        ?>
</li>
</li>
<?php 
    }
}
?>
</ul>
</div>
<meta http-equiv="refresh" content="600;URL='/chess/analyse/manishGames.php?user=<?php 
echo $user;
?>
'">
<?php 
/*
Example #24
0
                    displayForm("success", "");
                } else {
                    unlink(TARGET_DIR . basename($_FILES["fileUpload"]["name"]));
                    displayForm("fail_submit", $_POST["formName"]);
                }
            } else {
                displayForm("fail_upload", $_POST["formName"]);
            }
        } else {
            displayForm("fail_file_ext", $_POST["formName"]);
        }
    } else {
        displayForm("fail_file_exist", $_POST["formName"]);
    }
} else {
    displayForm("", "");
}
function checkExtension($fileExtension)
{
    if (strcasecmp($fileExtension, "doc") != 0) {
        if (strcasecmp($fileExtension, "docx") != 0) {
            if (strcasecmp($fileExtension, "pdf") != 0) {
                return FALSE;
            } else {
                return TRUE;
            }
        } else {
            return TRUE;
        }
    } else {
        return TRUE;
Example #25
0
<?php

include 'includes.php';
?>
<!DOCTYPE html>
<html>
<head>
	<title>GVSU MIP Library Traffic</title>
	<!-- <link rel="stylesheet" type="text/css" href="http://gvsu.edu/cms3/assets/741ECAAE-BD54-A816-71DAF591D1D7955C/libui.css" /> -->
	<link rel="stylesheet" type="text/css" href="css/styles.css" />
</head>
<body>
	<h1>GVSU MIP Library Use <small><a href="traffic.php">Traffic Form</a></small></h1>

	<?php 
displayForm("spaceUse");
?>
	<script src="//code.jquery.com/jquery.js"></script>
	<script src="js/jquery.validate.js"></script>
    <script src="js/jquery.swap.js"></script>
	<script src="js/scripts.js"></script>
</body>
</html>
Example #26
0
function processForm()
{
    $requiredFields = array("username", "password", "emailAddress", "firstName", "lastName", "gender");
    $missingFields = array();
    $errorMessages = array();
    $member = new Member(array("username" => isset($_POST["username"]) ? preg_replace("/[^ \\-\\_a-zA-Z0-9]/", "", $_POST["username"]) : "", "password" => (isset($_POST["password1"]) and isset($_POST["password2"]) and $_POST["password1"] == $_POST["password2"]) ? preg_replace("/[^ \\-\\_a-zA-Z0-9]/", "", $_POST["password1"]) : "", "firstName" => isset($_POST["firstName"]) ? preg_replace("/[^ \\'\\-a-zA-Z0-9]/", "", $_POST["firstName"]) : "", "lastName" => isset($_POST["lastName"]) ? preg_replace("/[^ \\'\\-a-zA-Z0-9]/", "", $_POST["lastName"]) : "", "gender" => isset($_POST["gender"]) ? preg_replace("/[^mf]/", "", $_POST["gender"]) : "", "favoriteGenre" => isset($_POST["favoriteGenre"]) ? preg_replace("/[^a-zA-Z]/", "", $_POST["favoriteGenre"]) : "", "emailAddress" => isset($_POST["emailAddress"]) ? preg_replace("/[^ \\@\\.\\-\\_a-zA-Z0-9]/", "", $_POST["emailAddress"]) : "", "otherInterests" => isset($_POST["otherInterests"]) ? preg_replace("/[^ \\'\\,\\.\\-a-zA-Z0-9]/", "", $_POST["otherInterests"]) : "", "joinDate" => date("Y-m-d")));
    foreach ($requiredFields as $requiredField) {
        if (!$member->getValue($requiredField)) {
            $missingFields[] = $requiredField;
        }
    }
    if ($missingFields) {
        $errorMessages[] = '<p class="error">There were some missing fields in the form you submitted. Please complete the fields highlighted below and click Send Details to resend the form.</p>';
    }
    if (!isset($_POST["password1"]) or !isset($_POST["password2"]) or !$_POST["password1"] or !$_POST["password2"] or $_POST["password1"] != $_POST["password2"]) {
        $errorMessages[] = '<p class="error">Please make sure you enter your password correctly in both password fields.</p>';
    }
    if (Member::getByUsername($member->getValue("username"))) {
        $errorMessages[] = '<p class="error">A member with that username already exists in the database. Please choose another username.</p>';
    }
    if (Member::getByEmailAddress($member->getValue("emailAddress"))) {
        $errorMessages[] = '<p class="error">A member with that email address already exists in the database. Please choose another email address, or contact the webmaster to retrieve your password.</p>';
    }
    if ($errorMessages) {
        displayForm($errorMessages, $missingFields, $member);
    } else {
        $member->insert();
        displayThanks();
    }
}
Example #27
0
/*
* Autor= Javi
* Fecha= 18-nov-2015
* Licencia= default
* Version= Expression version is undefined on line 10, column 14 in Templates/Scripting/EmptyPHP.php.
* Descripcion=
* /
 /*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
?>

<html>
    <head>
        <meta charset="UTF-8">
        <title></title>
    </head>
    <body>
        <?php 
$fotos = array("foto1", "foto2", "foto3");
require_once "funcionesEjer6.php";
if (isset($_POST["enviarFoto"])) {
    procesForm($fotos);
} else {
    displayForm($fotos);
}
?>
    </body>
</html>
function displayCalendar($formframes, $mainforms = "", $viewHandles, $dateHandles, $filters, $viewPrefixes, $scopes, $hidden, $type = "month", $start = "", $multiPageData = "")
{
    global $xoopsDB, $xoopsUser;
    global $xoopsTpl;
    // Set some required variables
    $mid = getFormulizeModId();
    for ($i = 0; $i < count($formframes); $i++) {
        unset($fid);
        unset($frid);
        if ($mainforms[$i]) {
            list($fid, $frid) = getFormFramework($formframes[$i], $mainforms[$i]);
        } else {
            list($fid, $frid) = getFormFramework($formframes[$i]);
        }
        $fids[] = $fid;
        $frids[] = $frid;
    }
    $gperm_handler =& xoops_gethandler('groupperm');
    $member_handler =& xoops_gethandler('member');
    $groups = $xoopsUser ? $xoopsUser->getGroups() : array(0 => XOOPS_GROUP_ANONYMOUS);
    $uid = $xoopsUser ? $xoopsUser->getVar('uid') : 0;
    foreach ($fids as $thisFid) {
        // check that the user is allowed to see all the fids
        if (!($scheck = security_check($thisFid, "", $uid, "", $groups, $mid, $gperm_handler))) {
            print "<p>" . _NO_PERM . "</p>";
            return;
        }
    }
    $currentURL = getCurrentURL();
    // get the current view, ie: the month
    if ($_POST['calview']) {
        // if we're recieving a view from a form submission...
        $settings['calview'] = $_POST['calview'];
    } else {
        if (!$start) {
            // nothing passed from form, and no default value specified, so use current date
            $today = getDate();
            if ($today['mon'] < 10) {
                $today['mon'] = "0" . $today['mon'];
            }
            $settings['calview'] = $today['year'] . "-" . $today['mon'];
        } else {
            $settings['calview'] = $start;
        }
    }
    $settings['calfrid'] = $_POST['calfrid'];
    $settings['calfid'] = $_POST['calfid'];
    $settings['calhidden'] = $hidden;
    // check to see if a switch to a form has been requested
    $settings['ventry'] = $_POST['ventry'];
    if ($settings['ventry']) {
        if ($_POST['ventry'] == "addnew") {
            $this_ent = "";
            $dateOverride = $_POST['adddate'];
        } elseif ($_POST['ventry'] == "proxy") {
            // support for proxies not currently written
            $this_ent = "proxy";
        } else {
            $this_ent = $_POST['ventry'];
        }
        if ($_POST['calfrid']) {
            if (isset($multiPageData[$_POST['calfid']])) {
                if (is_numeric($multiPageData[$_POST['calfid']])) {
                    // numeric value indicates a screen id
                    $screenData = readScreenId($multiPageData[$_POST['calfid']], $_POST['calfid']);
                    if (is_array($screenData)) {
                        $multiPageData = $screenData;
                    }
                }
                include_once XOOPS_ROOT_PATH . "/modules/formulize/include/formdisplaypages.php";
                displayFormPages($_POST['calfrid'], $this_ent, $_POST['calfid'], $multiPageData[$_POST['calfid']]['pages'], $multiPageData[$_POST['calfid']]['conditions'], $multiPageData[$_POST['calfid']]['introtext'], $multiPageData[$_POST['calfid']]['thankstext'], $currentURL, _formulize_CAL_RETURNFROMMULTI, $settings, $dateOverride, $multiPageData[$_POST['calfid']]['printall']);
            } else {
                displayForm($_POST['calfrid'], $this_ent, $_POST['calfid'], $currentURL, "", $settings, "", $dateOverride, 1, 1);
                // first "" is the done text, second is the onetoonetitles, last two 1s are the overrides for multi form behaviour
            }
            return;
        } else {
            if (isset($multiPageData[$_POST['calfid']])) {
                if (is_numeric($multiPageData[$_POST['calfid']])) {
                    // numeric value indicates a screen id
                    $screenData = readScreenId($multiPageData[$_POST['calfid']], $_POST['calfid']);
                    if (is_array($screenData)) {
                        $multiPageData = $screenData;
                    }
                }
                include_once XOOPS_ROOT_PATH . "/modules/formulize/include/formdisplaypages.php";
                displayFormPages($_POST['calfid'], $this_ent, "", $multiPageData[$_POST['calfid']]['pages'], $multiPageData[$_POST['calfid']]['conditions'], $multiPageData[$_POST['calfid']]['introtext'], $multiPageData[$_POST['calfid']]['thankstext'], $currentURL, _formulize_CAL_RETURNFROMMULTI, $settings, $dateOverride, $multiPageData[$_POST['calfid']]['printall']);
            } else {
                displayForm($_POST['calfid'], $this_ent, "", $currentURL, "", $settings, "", $dateOverride, 1, 1);
                // "" is the done text
            }
            return;
        }
    }
    // handle deletion if requested, added sept 18 2005
    if ($_POST['delentry']) {
        deleteEntry($_POST['delentry'], $_POST['delfrid'], $_POST['delfid'], $gperm_handler, $member_handler, $mid);
    }
    // get the data for all the fids
    // 1. convert the scopes for each one
    // 2. do the extraction (filter by calview)
    include_once XOOPS_ROOT_PATH . "/modules/formulize/include/extract.php";
    for ($i = 0; $i < count($fids); $i++) {
        $scope = "";
        if ($scopes[$i]) {
            list($scope, $throwAwayCurrentView) = buildScope($scopes[$i], $member_handler, $gperm_handler, $uid, $groups, $fids[$i], $mid);
        }
        if (is_array($dateHandles[$i])) {
            $dateField = $dateHandles[$i][0];
            $dateField2 = $dateHandles[$i][1];
        } else {
            $dateField = $dateHandles[$i];
            $dateField2 = "";
        }
        if (!$frids[$i]) {
            $filterDH = $dateField;
            $filterDH2 = $dateField2;
        } else {
            $filterDH = $dateField;
            $filterDH2 = $dateField2;
        }
        // new, complex filter format is:
        // $filter[0][0] -- andor setting for filter 0
        // $filter[0][1] -- filter for filter 0
        $filter = array();
        $filter[0][0] = "OR";
        $filter[0][1] = $filterDH . "/**/" . $settings['calview'];
        if ($filterDH2) {
            $filter[0][1] .= "][" . $filterDH2 . "/**/" . $settings['calview'];
        }
        if ($filters[$i]) {
            $filter[1][0] = "AND";
            $filter[1][1] = $filters[$i];
        }
        $data[$i] = getData($frids[$i], $fids[$i], $filter, "AND", $scope);
        $data[$i] = resultSort($data[$i], $dateField);
    }
    // need the formatting magic to go here, to whip it all into a nice calendar
    // basic display of data is below
    // demonstrates linking to a form for updating/viewing that entry
    // demonstrates altering the calview setting to change months
    // need to do something a little more complex for adding a new entry, since we have to know for which fid/frid pair the add operation is being requested.
    // probably best to leave out adding for now and leave it as a future feature.  It can always be custom added within a pageworks page if necessary for a particular calendar
    $rights = $gperm_handler->checkRight("add_own_entry", $fid, $groups, $mid);
    // information to pass to the template
    global $calendarData;
    // initialize language constants
    global $arrayMonthNames;
    global $arrayWeekNames;
    global $dateMonthStartDay;
    $arrayMonthNames = array(_formulize_CAL_MONTH_01, _formulize_CAL_MONTH_02, _formulize_CAL_MONTH_03, _formulize_CAL_MONTH_04, _formulize_CAL_MONTH_05, _formulize_CAL_MONTH_06, _formulize_CAL_MONTH_07, _formulize_CAL_MONTH_08, _formulize_CAL_MONTH_09, _formulize_CAL_MONTH_10, _formulize_CAL_MONTH_11, _formulize_CAL_MONTH_12);
    if ($type == "mini_month") {
        $arrayWeekNames = array(_formulize_CAL_WEEK_1_3ABRV, _formulize_CAL_WEEK_2_3ABRV, _formulize_CAL_WEEK_3_3ABRV, _formulize_CAL_WEEK_4_3ABRV, _formulize_CAL_WEEK_5_3ABRV, _formulize_CAL_WEEK_6_3ABRV, _formulize_CAL_WEEK_7_3ABRV);
    } else {
        $arrayWeekNames = array(_formulize_CAL_WEEK_1, _formulize_CAL_WEEK_2, _formulize_CAL_WEEK_3, _formulize_CAL_WEEK_4, _formulize_CAL_WEEK_5, _formulize_CAL_WEEK_6, _formulize_CAL_WEEK_7);
    }
    // convert string date into parts
    $arrayDate = getdate(strtotime($settings['calview'] . "-01"));
    $dateMonth = $arrayDate["mon"];
    $dateDay = $arrayDate["mday"];
    $dateYear = $arrayDate["year"];
    // get the number of days in the month.
    $dateMonthDays = days_in_month($dateMonth, $dateYear);
    // get the month's first week start day.
    $dateMonthStartDay = $arrayDate["wday"];
    // get the number of weeks.
    $dateMonthWeeks = week_in_month($dateMonthDays) + 1;
    // intialize MONTH template information
    // each cell is an array:
    // [0] - is control information, where each entry is an array:
    //     [0] - day number
    //     [1] - send date
    // [1] - is an array containing all items, where each item is also an array:
    //     [0] - $ids[0]
    //     [1] - $frids[$i]
    //     [2] - $fids[$i]
    //     [3] - $textToDisplay
    //     [4] - true/false based on user's right to delete this item (based on either delete own, or delete others permission)
    if ($type == "month" || $type == "mini_month" || $type == "micro_month") {
        // initialize grid: convert the data set into a grid of 7 columns for
        //  days and a row for each week
        $displayDay = "";
        for ($intWeeks = 0; $intWeeks < $dateMonthWeeks; $intWeeks++) {
            $calendarData[$intWeeks] = array();
            for ($intDays = 0; $intDays < 7; $intDays++) {
                // check to see if the processing day is the start day.
                if ($intWeeks == 0 && $displayDay == "") {
                    if ($intDays == $dateMonthStartDay) {
                        $displayDay = 1;
                    }
                } else {
                    if ($displayDay != "") {
                        $displayDay++;
                        if ($displayDay > $dateMonthDays) {
                            $displayDay = "";
                        }
                    }
                }
                $calendarData[$intWeeks][$intDays] = array();
                $calendarData[$intWeeks][$intDays][0][0] = $displayDay;
                $calendarData[$intWeeks][$intDays][0][1] = $dateYear . "-" . $dateMonth . "-" . ($displayDay < 10 ? "0" . $displayDay : $displayDay);
                //$calendarData[$intWeeks][$intDays][1] = array();
            }
        }
        // Initialize template variables
        $xoopsTpl->assign('previousMonth', $dateMonth - 1 < 1 ? $dateYear - 1 . "-12" : $dateYear . "-" . ($dateMonth - 1 < 10 ? "0" . ($dateMonth - 1) : $dateMonth - 1));
        $xoopsTpl->assign('nextMonth', $dateMonth + 1 > 12 ? $dateYear + 1 . "-01" : $dateYear . "-" . ($dateMonth + 1 < 10 ? "0" . ($dateMonth + 1) : $dateMonth + 1));
        $monthSelector = array();
        $numberOfMonths = count($arrayMonthNames);
        for ($intMonth = 0; $intMonth < $numberOfMonths; $intMonth++) {
            $monthName = $arrayMonthNames[$intMonth];
            $monthSelector[$intMonth + 1 < 10 ? "0" . ($intMonth + 1) : $intMonth + 1] = $monthName;
        }
        $xoopsTpl->assign('monthSelector', $monthSelector);
        $yearSelector = array();
        $startYear = $dateYear - 4;
        $endYear = $dateYear + 3;
        for ($intYear = $startYear; $intYear <= $endYear; $intYear++) {
            $yearSelector[] = $intYear;
        }
        $xoopsTpl->assign('yearSelector', $yearSelector);
    }
    // process data set(s)
    for ($i = 0; $i < count($data); $i++) {
        foreach ($data[$i] as $id => $entry) {
            if (!$frids[$i]) {
                if (is_array($viewHandles[$i])) {
                    $formhandle = getFormHandleFromEntry($entry, $viewHandles[$i][0]);
                } else {
                    $formhandle = getFormHandleFromEntry($entry, $viewHandles[$i]);
                }
            } else {
                $formhandle = $mainforms[$i];
            }
            $ids = internalRecordIds($entry, $formhandle);
            if (is_array($viewHandles[$i])) {
                $needsep = 0;
                // make sure that no data is keep from previous processing
                $textToDisplay = "";
                foreach ($viewHandles[$i] as $thisVH) {
                    if ($needsep) {
                        $textToDisplay .= ", ";
                    }
                    $needsep = 1;
                    $textToDisplay .= display($entry, $thisVH);
                }
            } else {
                $textToDisplay = display($entry, $viewHandles[$i]);
            }
            if ($viewPrefixes[$i]) {
                $textToDisplay = $viewPrefixes[$i] . $textToDisplay;
            }
            $calendarDataItem = array();
            $calendarDataItem[0] = $ids[0];
            $calendarDataItem[1] = $frids[$i];
            $calendarDataItem[2] = $fids[$i];
            $calendarDataItem[3] = $textToDisplay;
            $calendarDataItem[4] = ($i == 0 and formulizePermHandler::user_can_delete_entry($fids[$i], display($entry, "uid"), $ids[0]));
            if ($type == "month" || $type == "mini_month" || $type == "micro_month") {
                if (is_array($dateHandles[$i])) {
                    $startValue = display($entry, $dateHandles[$i][0]);
                    $endValue = display($entry, $dateHandles[$i][1]);
                    if ($startValue && $endValue) {
                        $startDate = strtotime($startValue);
                        $endDate = strtotime($endValue);
                        for ($x = $startDate; $x <= $endDate; $x = $x + 86400) {
                            $arrayDate = getdate($x);
                            if ($arrayDate["mon"] == $dateMonth) {
                                $calendarData = assignItem($arrayDate, $calendarDataItem, $calendarData);
                            }
                        }
                    } else {
                        if ($startValue) {
                            $startDate = strtotime($startValue);
                            $arrayDate = getdate($startDate);
                            $calendarData = assignItem($arrayDate, $calendarDataItem, $calendarData);
                        } else {
                            $endDate = strtotime($endValue);
                            $arrayDate = getdate($endDate);
                            $calendarData = assignItem($arrayDate, $calendarDataItem, $calendarData);
                        }
                    }
                } else {
                    $currentDate = display($entry, $dateHandles[$i]);
                    $arrayDate = getdate(strtotime($currentDate));
                    $calendarData = assignItem($arrayDate, $calendarDataItem, $calendarData);
                }
            }
        }
    }
    // Initialize common template variables
    $xoopsTpl->assign('cal_type', $type);
    $xoopsTpl->assign('rights', $rights);
    $xoopsTpl->assign('frids', $frids[0]);
    $xoopsTpl->assign('fids', $fids[0]);
    $xoopsTpl->assign('addItem', _formulize_CAL_ADD_ITEM);
    $xoopsTpl->assign('rowStyleEven', true);
    $xoopsTpl->assign('MonthNames', $arrayMonthNames);
    $xoopsTpl->assign('WeekNames', $arrayWeekNames);
    $xoopsTpl->assign('dateMonthZeroIndex', $dateMonth - 1);
    $xoopsTpl->assign('dateMonth', $dateMonth);
    $xoopsTpl->assign('dateYear', $dateYear);
    $xoopsTpl->assign('currentURL', $currentURL);
    $xoopsTpl->assign('hidden', $hidden);
    $xoopsTpl->assign('calview', $settings['calview']);
    $xoopsTpl->assign('calendarData', $calendarData);
    $xoopsTpl->assign('delete', _formulize_DELETE);
    $xoopsTpl->assign('delconf', _formulize_DELCONF);
    // force template to be drawn
    $xoopsTpl->display("db:calendar_" . $type . ".html");
}
Example #29
0
        echo $firstnum . " * " . $secondnum . " = " . $firstnum * $secondnum . "<br>";
        echo $firstnum . " / " . $secondnum . " = " . $firstnum / $secondnum . "<br>";
    } else {
        echo "Please only enter numbers into form";
    }
    displayForm();
    echo '</article>
			</section>';
    include 'footer.php';
} else {
    include 'head.php';
    echo '<title>Projects - Spencer Haney</title>';
    include 'sidebar.php';
    echo '<section>
					<article>';
    displayForm();
    echo '</article>
				</section>';
    include 'footer.php';
}
function displayForm()
{
    echo '<h1>Math</h1>
				<form name="math" action="math.php" method="post">
					<table>
						<tr>
							<td>First number: </td>
							<td><input type="text" name="firstnum"></td>
						</tr>
						<tr>
							<td>Second number: </td>
Example #30
0
function drawSubLinks($subform_id, $sub_entries, $uid, $groups, $frid, $mid, $fid, $entry, $customCaption = "", $customElements = "", $defaultblanks = 0, $showViewButtons = 1, $captionsForHeadings = 0, $overrideOwnerOfNewEntries = "", $mainFormOwner = 0, $hideaddentries = "", $subformConditions = null, $subformElementId = 0, $rowsOrForms = 'row', $addEntriesText = _formulize_ADD_ENTRIES, $subform_element_object = null)
{
    $nestedSubform = false;
    if (isset($GLOBALS['formulize_inlineSubformFrid'])) {
        $frid = $GLOBALS['formulize_inlineSubformFrid'];
        $nestedSubform = true;
    }
    $member_handler = xoops_gethandler('member');
    $gperm_handler = xoops_gethandler('groupperm');
    $addEntriesText = $addEntriesText ? $addEntriesText : _formulize_ADD_ENTRIES;
    global $xoopsDB, $nosubforms;
    $GLOBALS['framework'] = $frid;
    $form_handler = xoops_getmodulehandler('forms', 'formulize');
    // limit the sub_entries array to just the entries that match the conditions, if any
    if (is_array($subformConditions) and is_array($sub_entries[$subform_id])) {
        list($conditionsFilter, $conditionsFilterOOM, $curlyBracketFormFrom) = buildConditionsFilterSQL($subformConditions, $subform_id, $entry, $mainFormOwner, $fid);
        // pass in mainFormOwner as the comparison ID for evaluating {USER} so that the included entries are consistent when an admin looks at a set of entries made by someone else.
        $subformObject = $form_handler->get($subform_id);
        $sql = "SELECT entry_id FROM " . $xoopsDB->prefix("formulize_" . $subformObject->getVar('form_handle')) . "{$curlyBracketFormFrom} WHERE entry_id IN (" . implode(", ", $sub_entries[$subform_id]) . ") {$conditionsFilter} {$conditionsFilterOOM}";
        $sub_entries[$subform_id] = array();
        if ($res = $xoopsDB->query($sql)) {
            while ($array = $xoopsDB->fetchArray($res)) {
                $sub_entries[$subform_id][] = $array['entry_id'];
            }
        }
    }
    include_once XOOPS_ROOT_PATH . "/modules/formulize/include/extract.php";
    $target_sub_to_use = (isset($_POST['target_sub']) and $_POST['target_sub'] != 0) ? $_POST['target_sub'] : $subform_id;
    $elementq = q("SELECT fl_key1, fl_key2, fl_common_value, fl_form2_id FROM " . $xoopsDB->prefix("formulize_framework_links") . " WHERE fl_frame_id=" . intval($frid) . " AND fl_form2_id=" . intval($fid) . " AND fl_form1_id=" . intval($target_sub_to_use));
    // element_to_write is used below in writing results of "add x entries" clicks, plus it is used for defaultblanks on first drawing blank entries, so we need to get this outside of the saving routine
    if (count($elementq) > 0) {
        $element_to_write = $elementq[0]['fl_key1'];
        $value_source = $elementq[0]['fl_key2'];
        $value_source_form = $elementq[0]['fl_form2_id'];
    } else {
        $elementq = q("SELECT fl_key2, fl_key1, fl_common_value, fl_form1_id FROM " . $xoopsDB->prefix("formulize_framework_links") . " WHERE fl_frame_id=" . intval($frid) . " AND fl_form1_id=" . intval($fid) . " AND fl_form2_id=" . intval($target_sub_to_use));
        $element_to_write = $elementq[0]['fl_key2'];
        $value_source = $elementq[0]['fl_key1'];
        $value_source_form = $elementq[0]['fl_form1_id'];
    }
    if (0 == strlen($element_to_write)) {
        error_log("Relationship {$frid} for subform {$subform_id} on form {$fid} is invalid.");
        $to_return = array("c1" => "", "c2" => "", "sigle" => "");
        global $xoopsUser;
        if (is_object($xoopsUser) and in_array(XOOPS_GROUP_ADMIN, $xoopsUser->getGroups())) {
            if (0 == $frid) {
                $to_return['single'] = "This subform cannot be shown because no relationship is active.";
            } else {
                $to_return['single'] = "This subform cannot be shown because relationship {$frid} for subform " . "{$subform_id} on form {$fid} is invalid.";
            }
        }
        return $to_return;
    }
    // check for adding of a sub entry, and handle accordingly -- added September 4 2006
    static $subformInstance;
    $subformInstance = !isset($subformInstance) ? 100 : $subformInstance;
    $subformInstance++;
    if ($_POST['target_sub'] and $_POST['target_sub'] == $subform_id and $_POST['target_sub_instance'] == $subformElementId . $subformInstance) {
        // important we only do this on the run through for that particular sub form (hence target_sub == sfid), and also only for the specific instance of this subform on the page too, since not all entries may apply to all subform instances any longer with conditions in effect now
        // need to handle things differently depending on whether it's a common value or a linked selectbox type of link
        // uid links need to result in a "new" value in the displayElement boxes -- odd things will happen if people start adding linked values to entries that aren't theirs!
        if ($element_to_write != 0) {
            if ($elementq[0]['fl_common_value']) {
                // grab the value from the parent element -- assume that it is a textbox of some kind!
                if (isset($_POST['de_' . $value_source_form . '_' . $entry . '_' . $value_source])) {
                    $value_to_write = $_POST['de_' . $value_source_form . '_' . $entry . '_' . $value_source];
                } else {
                    // get this entry and see what the source value is
                    $data_handler = new formulizeDataHandler($value_source_form);
                    $value_to_write = $data_handler->getElementValueInEntry($entry, $value_source);
                }
            } else {
                $value_to_write = $entry;
            }
            $sub_entry_new = "";
            for ($i = 0; $i < $_POST['numsubents']; $i++) {
                // actually goahead and create the requested number of new sub entries...start with the key field, and then do all textboxes with defaults too...
                //$subEntWritten = writeElementValue($_POST['target_sub'], $element_to_write, "new", $value_to_write, "", "", true); // Last param is override that allows direct writing to linked selectboxes if we have prepped the value first!
                if ($overrideOwnerOfNewEntries) {
                    $creation_user_touse = $mainFormOwner;
                } else {
                    $creation_user_touse = "";
                }
                $subEntWritten = writeElementValue($_POST['target_sub'], $element_to_write, "new", $value_to_write, $creation_user_touse, "", true);
                // Last param is override that allows direct writing to linked selectboxes if we have prepped the value first!
                $element_handler = xoops_getmodulehandler('elements', 'formulize');
                if (!isset($elementsForDefaults)) {
                    $criteria = new CriteriaCompo();
                    $criteria->add(new Criteria('ele_type', 'text'), 'OR');
                    $criteria->add(new Criteria('ele_type', 'textarea'), 'OR');
                    $criteria->add(new Criteria('ele_type', 'date'), 'OR');
                    $criteria->add(new Criteria('ele_type', 'radio'), 'OR');
                    $elementsForDefaults = $element_handler->getObjects($criteria, $_POST['target_sub']);
                    // get all the text or textarea elements in the form
                }
                foreach ($elementsForDefaults as $thisDefaultEle) {
                    // need to write in any default values for any text boxes or text areas that are in the subform.  Perhaps other elements could be included too, but that would take too much work right now. (March 9 2009)
                    $defaultTextToWrite = "";
                    $ele_value_for_default = $thisDefaultEle->getVar('ele_value');
                    switch ($thisDefaultEle->getVar('ele_type')) {
                        case "text":
                            $defaultTextToWrite = getTextboxDefault($ele_value_for_default[2], $_POST['target_sub'], $subEntWritten);
                            // position 2 is default value for text boxes
                            break;
                        case "textarea":
                            $defaultTextToWrite = getTextboxDefault($ele_value_for_default[0], $_POST['target_sub'], $subEntWritten);
                            // position 0 is default value for text boxes
                            break;
                        case "date":
                            $defaultTextToWrite = getDateElementDefault($ele_value_for_default[0]);
                            if (false === $defaultTextToWrite) {
                                $defaultTextToWrite = "";
                            } else {
                                $defaultTextToWrite = date("c", $defaultTextToWrite);
                            }
                            break;
                        case "radio":
                            $thisDefaultEleValue = $thisDefaultEle->getVar('ele_value');
                            $defaultTextToWrite = array_search(1, $thisDefaultEleValue);
                    }
                    if ($defaultTextToWrite) {
                        writeElementValue($_POST['target_sub'], $thisDefaultEle->getVar('ele_id'), $subEntWritten, $defaultTextToWrite);
                    }
                }
                $sub_entry_written[] = $subEntWritten;
            }
        } else {
            $sub_entry_new = "new";
            // this happens in uid-link situations?
            $sub_entry_written = "";
        }
        // need to also enforce any equals conditions that are on the subform element, if any, and assign those values to the entries that were just added
        if (is_array($subformConditions)) {
            $filterValues = array();
            foreach ($subformConditions[1] as $i => $thisOp) {
                if ($thisOp == "=" and $subformConditions[3][$i] != "oom" and $subformConditions[2][$i] != "{BLANK}") {
                    $conditionElementObject = $element_handler->get($subformConditions[0][$i]);
                    $filterValues[$subformConditions[0][$i]] = prepareLiteralTextForDB($conditionElementObject, $subformConditions[2][$i]);
                }
            }
            if (count($filterValues) > 0) {
                foreach ($sub_entry_written as $thisSubEntry) {
                    formulize_writeEntry($filterValues, $thisSubEntry);
                }
            }
        }
    }
    // need to do a number of checks here, including looking for single status on subform, and not drawing in add another if there is an entry for a single
    $sub_single_result = getSingle($subform_id, $uid, $groups, $member_handler, $gperm_handler, $mid);
    $sub_single = $sub_single_result['flag'];
    if ($sub_single) {
        unset($sub_entries);
        $sub_entries[$subform_id][0] = $sub_single_result['entry'];
    }
    if (!is_array($sub_entries[$subform_id])) {
        $sub_entries[$subform_id] = array();
    }
    if ($sub_entry_new and !$sub_single and $_POST['target_sub'] == $subform_id) {
        for ($i = 0; $i < $_POST['numsubents']; $i++) {
            array_unshift($sub_entries[$subform_id], $sub_entry_new);
        }
    }
    if (is_array($sub_entry_written) and !$sub_single and $_POST['target_sub'] == $subform_id) {
        foreach ($sub_entry_written as $sew) {
            array_unshift($sub_entries[$subform_id], $sew);
        }
    }
    if (!$customCaption) {
        // get the title of this subform
        // help text removed for F4.0 RC2, this is an experiment
        $subtitle = q("SELECT desc_form FROM " . $xoopsDB->prefix("formulize_id") . " WHERE id_form = {$subform_id}");
        $col_one = "<p id=\"subform-caption-f{$fid}-sf{$subform_id}\" class=\"subform-caption\"><b>" . trans($subtitle[0]['desc_form']) . "</b></p>";
        // <p style=\"font-weight: normal;\">" . _formulize_ADD_HELP;
    } else {
        $col_one = "<p id=\"subform-caption-f{$fid}-sf{$subform_id}\" class=\"subform-caption\"><b>" . trans($customCaption) . "</b></p>";
        // <p style=\"font-weight: normal;\">" . _formulize_ADD_HELP;
    }
    /*if(intval($sub_entries[$subform_id][0]) != 0 OR $sub_entry_new OR is_array($sub_entry_written)) {
    		if(!$nosubforms) { $col_one .= "<br>" . _formulize_ADD_HELP2; }
    		$col_one .= "<br>" . _formulize_ADD_HELP3;
    	} */
    // list the entries, including links to them and delete checkboxes
    // get the headerlist for the subform and convert it into handles
    // note big assumption/restriction that we are only using the first header found (ie: only specify one header for a sub form!)
    // setup the array of elements to draw
    if (is_array($customElements)) {
        $headingDescriptions = array();
        $headerq = q("SELECT ele_caption, ele_colhead, ele_desc, ele_id FROM " . $xoopsDB->prefix("formulize") . " WHERE ele_id IN (" . implode(", ", $customElements) . ") ORDER BY ele_order");
        foreach ($headerq as $thisHeaderResult) {
            $elementsToDraw[] = $thisHeaderResult['ele_id'];
            $headingDescriptions[] = $thisHeaderResult['ele_desc'] ? $thisHeaderResult['ele_desc'] : "";
            if ($captionsForHeadings) {
                $headersToDraw[] = $thisHeaderResult['ele_caption'];
            } else {
                $headersToDraw[] = $thisHeaderResult['ele_colhead'] ? $thisHeaderResult['ele_colhead'] : $thisHeaderResult['ele_caption'];
            }
        }
    } else {
        $subHeaderList = getHeaderList($subform_id);
        $subHeaderList1 = getHeaderList($subform_id, true);
        if (isset($subHeaderList[0])) {
            $headersToDraw[] = trans($subHeaderList[0]);
        }
        if (isset($subHeaderList[1])) {
            $headersToDraw[] = trans($subHeaderList[1]);
        }
        if (isset($subHeaderList[2])) {
            $headersToDraw[] = trans($subHeaderList[2]);
        }
        $elementsToDraw = array_slice($subHeaderList1, 0, 3);
    }
    $need_delete = 0;
    $drawnHeadersOnce = false;
    if ($rowsOrForms == "row" or $rowsOrForms == '') {
        $col_two = "<table id=\"formulize-subform-table-{$subform_id}\" class=\"formulize-subform-table\">";
    } else {
        $col_two = "";
        if (!strstr($_SERVER['PHP_SELF'], "formulize/printview.php")) {
            $col_two .= "<div id=\"subform-{$subformElementId}\" class=\"subform-accordion-container\" subelementid=\"{$subformElementId}\" style=\"display: none;\">";
        }
        $col_two .= "<input type='hidden' name='subform_entry_" . $subformElementId . "_active' id='subform_entry_" . $subformElementId . "_active' value='' />";
        include_once XOOPS_ROOT_PATH . "/modules/formulize/class/data.php";
        $data_handler = new formulizeDataHandler($subform_id);
    }
    $deFrid = $frid ? $frid : "";
    // need to set this up so we can pass it as part of the displayElement function, necessary to establish the framework in case this is a framework and no subform element is being used, just the default draw-in-the-one-to-many behaviour
    // if there's been no form submission, and there's no sub_entries, and there are default blanks to show, then do everything differently -- sept 8 2007
    if (!$_POST['form_submitted'] and count($sub_entries[$subform_id]) == 0 and $defaultblanks > 0 and ($rowsOrForms == "row" or $rowsOrForms == '')) {
        for ($i = 0; $i < $defaultblanks; $i++) {
            // nearly same header drawing code as in the 'else' for drawing regular entries
            if (!$drawnHeadersOnce) {
                $col_two .= "<tr><td>\n";
                $col_two .= "<input type=\"hidden\" name=\"formulize_subformValueSource_{$subform_id}\" value=\"{$value_source}\">\n";
                $col_two .= "<input type=\"hidden\" name=\"formulize_subformValueSourceForm_{$subform_id}\" value=\"{$value_source_form}\">\n";
                $col_two .= "<input type=\"hidden\" name=\"formulize_subformValueSourceEntry_{$subform_id}\" value=\"{$entry}\">\n";
                $col_two .= "<input type=\"hidden\" name=\"formulize_subformElementToWrite_{$subform_id}\" value=\"{$element_to_write}\">\n";
                $col_two .= "<input type=\"hidden\" name=\"formulize_subformSourceType_{$subform_id}\" value=\"" . $elementq[0]['fl_common_value'] . "\">\n";
                $col_two .= "<input type=\"hidden\" name=\"formulize_subformId_{$subform_id}\" value=\"{$subform_id}\">\n";
                // this is probably redundant now that we're tracking sfid in the names of the other elements
                $col_two .= "</td>\n";
                foreach ($headersToDraw as $x => $thishead) {
                    if ($thishead) {
                        $headerHelpLinkPart1 = $headingDescriptions[$i] ? "<a href=\"#\" onclick=\"return false;\" alt=\"" . $headingDescriptions[$x] . "\" title=\"" . $headingDescriptions[$x] . "\">" : "";
                        $headerHelpLinkPart2 = $headerHelpLinkPart1 ? "</a>" : "";
                        $col_two .= "<th><p>{$headerHelpLinkPart1}<b>{$thishead}</b>{$headerHelpLinkPart2}</p></th>\n";
                    }
                }
                $col_two .= "</tr>\n";
                $drawnHeadersOnce = true;
            }
            $col_two .= "<tr>\n<td>";
            $col_two .= "</td>\n";
            include_once XOOPS_ROOT_PATH . "/modules/formulize/include/elementdisplay.php";
            foreach ($elementsToDraw as $thisele) {
                if ($thisele) {
                    ob_start();
                    // critical that we *don't* ask for displayElement to return the element object, since this way the validation logic is passed back through the global space also (ugh).  Otherwise, no validation logic possible for subforms.
                    $renderResult = displayElement($deFrid, $thisele, "subformCreateEntry_" . $i . "_" . $subformElementId);
                    $col_two_temp = ob_get_contents();
                    ob_end_clean();
                    if ($col_two_temp or $renderResult == "rendered") {
                        // only draw in a cell if there actually is an element rendered (some elements might be rendered as nothing (such as derived values)
                        $col_two .= "<td>{$col_two_temp}</td>\n";
                    } else {
                        $col_two .= "<td>******</td>";
                    }
                }
            }
            $col_two .= "</tr>\n";
        }
    } elseif (count($sub_entries[$subform_id]) > 0) {
        // need to figure out the proper order for the sub entries based on the properties set for this form
        // for now, hard code to the word number field to suit the map site only
        // if it's the word subform, then sort the entries differently
        /*if($subform_id == 281) {
        			$sortClause = " fas_281, block_281, word_number ";
        		} 
        		elseif ($subform_id == 283) {
        			$sortClause = " fas_283 ";
        		}
        		else {*/
        $sortClause = " entry_id ";
        //}
        $sformObject = $form_handler->get($subform_id);
        $subEntriesOrderSQL = "SELECT entry_id FROM " . $xoopsDB->prefix("formulize_" . $sformObject->getVar('form_handle')) . " WHERE entry_id IN (" . implode(",", $sub_entries[$subform_id]) . ") ORDER BY {$sortClause}";
        if ($subEntriesOrderRes = $xoopsDB->query($subEntriesOrderSQL)) {
            $sub_entries[$subform_id] = array();
            while ($subEntriesOrderArray = $xoopsDB->fetchArray($subEntriesOrderRes)) {
                $sub_entries[$subform_id][] = $subEntriesOrderArray['entry_id'];
            }
        }
        $currentSubformInstance = $subformInstance;
        foreach ($sub_entries[$subform_id] as $sub_ent) {
            if ($sub_ent != "") {
                if ($rowsOrForms == 'row' or $rowsOrForms == '') {
                    if (!$drawnHeadersOnce) {
                        $col_two .= "<tr><th></th>\n";
                        foreach ($headersToDraw as $i => $thishead) {
                            if ($thishead) {
                                $headerHelpLinkPart1 = $headingDescriptions[$i] ? "<a href=\"#\" onclick=\"return false;\" alt=\"" . $headingDescriptions[$i] . "\" title=\"" . $headingDescriptions[$i] . "\">" : "";
                                $headerHelpLinkPart2 = $headerHelpLinkPart1 ? "</a>" : "";
                                $col_two .= "<th><p>{$headerHelpLinkPart1}<b>{$thishead}</b>{$headerHelpLinkPart2}</p></th>\n";
                            }
                        }
                        $col_two .= "</tr>\n";
                        $drawnHeadersOnce = true;
                    }
                    $col_two .= "<tr>\n<td>";
                    // check to see if we draw a delete box or not
                    if ($sub_ent !== "new" and "hideaddentries" != $hideaddentries and formulizePermHandler::user_can_delete_entry($subform_id, $uid, $sub_ent) and !strstr($_SERVER['PHP_SELF'], "formulize/printview.php")) {
                        // note: if the add/delete entry buttons are hidden, then these delete checkboxes are hidden as well
                        $need_delete = 1;
                        $col_two .= "<input type=checkbox name=delbox{$sub_ent} value={$sub_ent}></input>";
                    }
                    $col_two .= "</td>\n";
                    include_once XOOPS_ROOT_PATH . "/modules/formulize/include/elementdisplay.php";
                    foreach ($elementsToDraw as $thisele) {
                        if ($thisele) {
                            ob_start();
                            // critical that we *don't* ask for displayElement to return the element object, since this way the validation logic is passed back through the global space also (ugh).  Otherwise, no validation logic possible for subforms.
                            $renderResult = displayElement($deFrid, $thisele, $sub_ent);
                            $col_two_temp = ob_get_contents();
                            ob_end_clean();
                            if ($col_two_temp or $renderResult == "rendered") {
                                // only draw in a cell if there actually is an element rendered (some elements might be rendered as nothing (such as derived values)
                                $col_two .= "<td>{$col_two_temp}</td>\n";
                            } else {
                                $col_two .= "<td>******</td>";
                            }
                        }
                    }
                    if (!$nosubforms and $showViewButtons and !strstr($_SERVER['PHP_SELF'], "formulize/printview.php")) {
                        $col_two .= "<td><input type=button name=view" . $sub_ent . " value='" . _formulize_SUBFORM_VIEW . "' onclick=\"javascript:goSub('{$sub_ent}', '{$subform_id}');return false;\"></input></td>\n";
                    }
                    $col_two .= "</tr>\n";
                } else {
                    // display the full form
                    $headerValues = array();
                    foreach ($elementsToDraw as $thisele) {
                        $value = $data_handler->getElementValueInEntry($sub_ent, $thisele);
                        $element_object = _getElementObject($thisele);
                        $value = prepvalues($value, $element_object->getVar("ele_handle"), $sub_ent);
                        if (is_array($value)) {
                            $value = implode(" - ", $value);
                        }
                        // may be an array if the element allows multiple selections (checkboxes, multiselect list boxes, etc)
                        $headerValues[] = $value;
                    }
                    $headerToWrite = implode(" &mdash; ", $headerValues);
                    if (str_replace(" &mdash; ", "", $headerToWrite) == "") {
                        $headerToWrite = _AM_ELE_SUBFORM_NEWENTRY_LABEL;
                    }
                    // check to see if we draw a delete box or not
                    $deleteBox = "";
                    if ($sub_ent !== "new" and formulizePermHandler::user_can_delete_entry($subform_id, $uid, $sub_ent) and !strstr($_SERVER['PHP_SELF'], "formulize/printview.php")) {
                        $need_delete = 1;
                        $deleteBox = "<input type=checkbox name=delbox{$sub_ent} value={$sub_ent}></input>&nbsp;&nbsp;";
                    }
                    if (!strstr($_SERVER['PHP_SELF'], "formulize/printview.php")) {
                        $col_two .= "<div class=\"subform-deletebox\">{$deleteBox}</div><div class=\"subform-entry-container\" id=\"subform-" . $subform_id . "-" . "{$sub_ent}\">\r\n\t<p class=\"subform-header\"><a href=\"#\"><span class=\"accordion-name\">" . $headerToWrite . "</span></a></p>\r\n\t<div class=\"accordion-content content\">";
                    }
                    ob_start();
                    $GLOBALS['formulize_inlineSubformFrid'] = $frid;
                    if ($display_screen = get_display_screen_for_subform($subform_element_object)) {
                        $subScreen_handler = xoops_getmodulehandler('formScreen', 'formulize');
                        $subScreenObject = $subScreen_handler->get($display_screen);
                        $subScreen_handler->render($subScreenObject, $sub_ent, null, true);
                    } else {
                        // SHOULD CHANGE THIS TO USE THE DEFAULT SCREEN FOR THE FORM!!!!!!????
                        $renderResult = displayForm($subform_id, $sub_ent, "", "", "", "", "formElementsOnly");
                    }
                    if (!$nestedSubform) {
                        unset($GLOBALS['formulize_inlineSubformFrid']);
                    }
                    $col_two_temp = ob_get_contents();
                    ob_end_clean();
                    $col_two .= $col_two_temp;
                    if (!strstr($_SERVER['PHP_SELF'], "formulize/printview.php")) {
                        $col_two .= "</div>\n</div>\n";
                    }
                }
            }
        }
        $subformInstance = $currentSubformInstance;
        // instance counter might have changed because the form could include other subforms
    }
    if ($rowsOrForms == 'row' or $rowsOrForms == '') {
        // complete the table if we're drawing rows
        $col_two .= "</table>";
    } else {
        if (!strstr($_SERVER['PHP_SELF'], "formulize/printview.php")) {
            $col_two .= "</div>";
            // close of the subform-accordion-container
        }
        static $jqueryUILoaded = false;
        if (!$jqueryUILoaded) {
            $col_two .= "<script type=\"text/javascript\" src=\"" . XOOPS_URL . "/modules/formulize/libraries/jquery/jquery-ui-1.8.2.custom.min.js\"></script>\n";
            $col_two .= "<link rel=\"stylesheet\" type=\"text/css\" href=\"" . XOOPS_URL . "/modules/formulize/libraries/jquery/css/start/jquery-ui-1.8.2.custom.css\">\n";
            $jqueryUILoaded = true;
        }
        $col_two .= "\n\r\n<script type=\"text/javascript\">\r\n\tjQuery(document).ready(function() {\r\n\t\tjQuery(\"#subform-{$subformElementId}\").accordion({\r\n\t\t\tautoHeight: false, // no fixed height for sections\r\n\t\t\tcollapsible: true, // sections can be collapsed\r\n\t\t\tactive: ";
        if ($_POST['target_sub_instance'] == $subformElementId . $subformInstance and $_POST['target_sub'] == $subform_id) {
            $col_two .= count($sub_entries[$subform_id]) - $_POST['numsubents'];
        } elseif (is_numeric($_POST['subform_entry_' . $subformElementId . '_active'])) {
            $col_two .= $_POST['subform_entry_' . $subformElementId . '_active'];
        } else {
            $col_two .= 'false';
        }
        $col_two .= ",\r\n\t\t\theader: \"> div > p.subform-header\"\r\n\t\t});\r\n\t\tjQuery(\"#subform-{$subformElementId}\").fadeIn();\r\n\t});\r\n</script>";
    }
    // end of if we're closing the subform inferface where entries are supposed to be collapsable forms
    $deleteButton = "";
    if ((count($sub_entries[$subform_id]) > 0 and $sub_entries[$subform_id][0] != "" or $sub_entry_new or is_array($sub_entry_written)) and $need_delete) {
        $deleteButton = "&nbsp;&nbsp;&nbsp;<input type=button name=deletesubs value='" . _formulize_DELETE_CHECKED . "' onclick=\"javascript:sub_del('{$subform_id}');\">";
        static $deletesubsflagIncluded = false;
        if (!$deletesubsflagIncluded) {
            $col_one .= "\n<input type=hidden name=deletesubsflag value=''>\n";
            $deletesubsflagIncluded = true;
        }
    }
    // if the 'add x entries button' should be hidden or visible
    if ("hideaddentries" != $hideaddentries) {
        $allowed_to_add_entries = false;
        if ("subform" == $hideaddentries or 1 == $hideaddentries) {
            // for compatability, accept '1' which is the old value which corresponds to the new use-subform-permissions (saved as "subform")
            // user can add entries if they have permission on the sub form
            $allowed_to_add_entries = $gperm_handler->checkRight("add_own_entry", $subform_id, $groups, $mid);
        } else {
            // user can add entries if they have permission on the main form
            // the user should only be able to add subform entries if they can *edit* the main form entry, since adding a subform entry
            //  is like editing the main form entry. otherwise they could add subform entries on main form entries owned by other users
            $allowed_to_add_entries = formulizePermHandler::user_can_edit_entry($fid, $uid, $entry);
        }
        if ($allowed_to_add_entries and !strstr($_SERVER['PHP_SELF'], "formulize/printview.php")) {
            if (count($sub_entries[$subform_id]) == 1 and $sub_entries[$subform_id][0] === "" and $sub_single) {
                $col_two .= "<p><input type=button name=addsub value='" . _formulize_ADD_ONE . "' onclick=\"javascript:add_sub('{$subform_id}', 1, " . $subformElementId . $subformInstance . ");\"></p>";
            } elseif (!$sub_single) {
                $use_simple_add_one_button = isset($subform_element_object->ele_value["simple_add_one_button"]) ? 1 == $subform_element_object->ele_value["simple_add_one_button"] : false;
                $col_two .= "<p><input type=button name=addsub value='" . ($use_simple_add_one_button ? trans($subform_element_object->ele_value['simple_add_one_button_text']) : _formulize_ADD) . "' onclick=\"javascript:add_sub('{$subform_id}', window.document.formulize.addsubentries{$subform_id}{$subformElementId}{$subformInstance}.value, " . $subformElementId . $subformInstance . ");\">";
                if ($use_simple_add_one_button) {
                    $col_two .= "<input type=\"hidden\" name=addsubentries{$subform_id}{$subformElementId}{$subformInstance} id=addsubentries{$subform_id}{$subformElementId}{$subformInstance} value=\"1\">";
                } else {
                    $col_two .= "<input type=text name=addsubentries{$subform_id}{$subformElementId}{$subformInstance} id=addsubentries{$subform_id}{$subformElementId}{$subformInstance} value=1 size=2 maxlength=2>";
                    $col_two .= $addEntriesText;
                }
                $col_two .= $deleteButton . "</p>";
            }
        }
    }
    $to_return['c1'] = $col_one;
    $to_return['c2'] = $col_two;
    $to_return['single'] = $col_one . $col_two;
    if (is_object($subform_element_object)) {
        global $xoopsUser;
        $show_element_edit_link = (is_object($xoopsUser) and in_array(XOOPS_GROUP_ADMIN, $xoopsUser->getGroups()));
        $edit_link = "";
        if ($show_element_edit_link) {
            $edit_link = "<a class=\"formulize-element-edit-link\" tabindex=\"-1\" href=\"" . XOOPS_URL . "/modules/formulize/admin/ui.php?page=element&aid=0&ele_id=" . $subform_element_object->getVar("ele_id") . "\" target=\"_blank\">edit element</a>";
        }
        $to_return['single'] = "<div class=\"formulize-subform-" . $subform_element_object->getVar("ele_handle") . "\">{$edit_link} {$col_one} {$col_two}</div>";
    }
    return $to_return;
}