Exemplo n.º 1
0
function augmentName($name, $var, $tabl, $where)
{
    $augN = 0;
    $strng = $name;
    $whereAs = $where ? array_merge($where, array($var => $strng)) : array($var => $strng);
    while ($strng == getValueFromDB($tabl, $var, $whereAs)) {
        $augN++;
        $strng = $name . '_' . "{$augN}";
    }
    return $strng;
}
Exemplo n.º 2
0
 function manageListing($thisFileName, $idAr, $varOrder)
 {
     $gofor = $_REQUEST['gofor'];
     if ($gofor == 'Submit') {
         $gofor = 'Insert';
     }
     $indx = $this->getIndx();
     $idName = $this->getDisplayText();
     $colInfo = $this->getItemInfo();
     $rIndx = $this->getRIndx($gofor, 'indx');
     if (!$gofor and $rIndx) {
         $gofor = 'Edit';
     }
     $hiddenVars = $idAr ? $idAr : array();
     if ($rIndx) {
         $ar = $this->getDbRow($rIndx);
         $varName = $this->getDisplayText();
         echo "<p><strong>Editing data for ", $ar["{$varName}"], "</strong></p>\n";
         $hiddenVars['indx'] = $rIndx;
     } else {
         //$hiddenVars=array();
     }
     //echo "<p>Looking for gofor=*$gofor* with index=*$rIndx*; part=",
     //URLParts(1),"</p>\n";
     if ($gofor) {
         if ($gofor == 'Delete?') {
             $this->cmsForm('Delete ' . $ar["{$idName}"] . ' (are you sure)', '', $thisFileName, 'POST', '1', 'OK, Delete', $hiddenVars);
             $this->cmsForm('NO ', '', $thisFileName, 'POST', '1', 'Cancel', '');
         } else {
             if ($gofor == 'OK, Delete') {
                 $nid = $this->deleteObs($rIndx);
                 $ar = array();
                 $rIndx = 0;
             } else {
                 if ($gofor == 'Update' or $gofor == 'Insert' or $gofor == 'Continue' or $gofor == 'Replace' or $gofor == 'Include' or $gofor == 'Duplicate') {
                     $varlist = array_diff(array_keys($colInfo), array($indx));
                     $vars = arrayFromInput($varlist, '1', '');
                     if ($this->arTextFlds) {
                         $this->removeParaMarks($vars);
                     }
                     if ($ckVar = $this->checkDuplicate() and ($gofor == 'Insert' or $gofor == 'Duplicate') and $cIndx = getValueFromDB($this->tabl, $this->indx, array($ckVar => $vars["{$ckVar}"]))) {
                         echo "<p><strong>Warning ({$cIndx}): {$ckVar} = ", $vars["{$ckVar}"], " exists in database</strong></p>\n";
                         echo "<p>Choose <strong>Replace</strong> to Overwrite entry<br />", "or <strong>Continue</strong> to add as an ", "additional entry with or without further changes</p>\n";
                         $disp = 'Continue';
                         $ar = $vars;
                         $hiddenVars['indx'] = $cIndx;
                     } elseif ($gofor == 'Include') {
                         $ar = $vars;
                     } else {
                         if ($gofor == 'Update' or $gofor == 'Replace') {
                             $nid = $this->updateObs($rIndx, $vars);
                             echo "<!-- Ready to notify -->\n";
                             $this->updNotify($vars);
                         } elseif ($gofor == 'Insert' or $gofor == 'Continue' or $gofor == 'Duplicate') {
                             $rIndx = $this->createObs($vars);
                             $hiddenVars['indx'] = $rIndx;
                         }
                         $ar = $this->getDbRow($rIndx);
                     }
                 }
             }
         }
         if ($gofor == 'Edit' or $gofor == 'Update' or $gofor == 'Insert' or $gofor == 'Add' or $gofor == 'Continue' or $gofor == 'Replace' or $gofor == 'Include' or $gofor == 'Duplicate') {
             $disp2 = '';
             if ($gofor == 'Add' or $gofor == 'Include') {
                 $disp = 'Insert';
                 $this->upLoadButton();
             } elseif ($disp == 'Continue') {
                 $disp2 = 'Replace';
             } else {
                 $disp = 'Update';
                 $disp2 = 'Duplicate';
                 $this->cmsForm('Delete this entry', '', $thisFileName, 'POST', '1', 'Delete?', $hiddenVars);
             }
             echo "<p>&nbsp;</p>\n";
             echo $this->closerButton($rIndx);
             $this->cmsForm('', $this->formid, $thisFileName, 'POST', '', '', $hiddenVars);
             //echo "<p>Checkpoint</p>\n";
             //echo "<p>There are ",sizeof($colInfo)," items</p>\n";
             $this->fillFields();
             foreach ($colInfo as $key => $val) {
                 if ($key != $indx) {
                     echo $this->formItem($val, $key, $ar["{$key}"]);
                 }
                 //!$indx
             }
             //$cols
             echo "<p>&nbsp;</p>\n";
             closeForm($disp, 'Reset', $disp2);
         }
         echo "<hr />\n";
         $strng = "Edit another entry";
     } else {
         $strng = "Edit this entry";
     }
     $hiddenVars = $idAr ? $idAr : array();
     $this->cmsForm('', 'editThisEntry', $thisFileName, 'POST', '', '', $hiddenVars);
     echo "<p><strong>{$strng}</strong></p>\n";
     if ($this->xQueryInfo) {
         $this->extendedBrowse();
     }
     $rowList = $this->getRowList();
     echo "<p><strong>View list as </strong>";
     radioInputWScript('pullTabl', 'pull', 1, "togglePullTabl('viewAsPopup','viewAsTable')");
     echo "Pull-down\n";
     radioInputWScript('pullTabl', 'tabl', 0, "togglePullTabl('viewAsTable','viewAsPopup')");
     echo "Table</p>\n";
     echo "<div id=\"editList\">\n";
     echo "<p id=\"viewAsPopup\">";
     //selectFromArray('indx',array_keys($rowList),'',
     //    array_values($rowList),'--','','');
     selectFromArray('indx', array_keys($rowList), '', cImplode(':', array_values($rowList), 30, 5, 'array'), '--', '', '');
     echo "</p>\n";
     echo "<table id=\"viewAsTable\" style=\"display: none\" " . "border=\"1\" width=\"100%\">\n";
     $i = 1;
     echo "<tr><td>";
     addGofor('Edit');
     echo "</td></tr>\n";
     foreach ($rowList as $k => $rLine) {
         $tar = explode(':', $rLine);
         echo "<tr>";
         echo "<td><input type=\"radio\" name=\"alt_indx\" ", "onClick=\"tookie({$i},'indx','editThisEntry');\" /></td>";
         foreach ($tar as $rItem) {
             echo "<td>{$rItem}</td>";
         }
         echo "</tr>\n";
         $i++;
     }
     echo "</table>\n";
     echo "</div>\n";
     echo "<p>";
     //hiddenInput('gofor','Edit');
     closeForm('Edit', '', '');
     pg_free_result($r);
     echo "<p><strong>OR</strong></p>\n";
     $this->cmsForm('Add an entry', '', $thisFileName, 'POST', '1', 'Add', $hiddenVars);
     return 1;
 }