Example #1
0
 function OneCell($text, $type_id = 'char', $dispsize = 0, $colscale = 0, $caption = false)
 {
     if ($dispsize == 0) {
         $dispsize = strlen($text);
     }
     $align = "L";
     switch ($type_id) {
         case 'char':
         case 'vchar':
             $output = str_pad(substr($text, 0, $dispsize), $dispsize) . ' ';
             break;
         case 'date':
             if (!$text) {
                 $output = '';
             } else {
                 if ($caption) {
                     $output = $text;
                 } else {
                     $output = date('m/d/Y', dEnsureTS($text)) . ' ';
                 }
             }
             break;
         case 'numb':
             if ($this->zeronumber && $text == 0) {
                 $output = '';
             } else {
                 if ($caption) {
                     $output = $text;
                 } else {
                     $output = number_format((double) $text, $colscale);
                 }
             }
             $output = ' ' . str_pad($output, $dispsize, ' ', STR_PAD_LEFT);
             $align = "R";
             break;
         case 'time':
             $output = ' ' . str_pad(trim(hTime($text)), 8, ' ', STR_PAD_LEFT);
             $align = "R";
             break;
         default:
             $output = $text;
     }
     // BEAUTY STEP 3, DROP X_PDF'S ROUTINE, DO OUR OWN.
     // The width calculation was worked out using Courier (fixed width)
     // to put out cells 10 chars long.  The value used gave perfect
     // alignment
     //$width=$this->GetStringWidth($output);
     if (strtoupper($this->fontname) == 'COURIER') {
         $width = $this->GetStringWidth($output);
     } else {
         $width = $dispsize * $this->fontsize * 0.23;
     }
     //if($align<>'L') {
     $this->Cell($width, 0, $output, 0, 0, $align);
     //}
     //else {
     //    $this->Cell($width,0,$output);
     //}
     //$this->CurrentLine.=$output.' ';
 }
Example #2
0
/**
* @deprecated
*/
function jsValuesOne($ahcols, $colname, $ahcol, $name, $row, $h)
{
    // KFD 9/7/07, slip this in for mime-h columns, they are
    //             much simpler.
    if ($ahcol['type_id'] == 'mime-h' || $ahcol['type_id'] == 'mime-h-f') {
        $editor = "<textarea class=\"wysiwyg\"  style=\"width: 810px; height: 200px\" x_original_value=\"" . htmlentities(trim(ArraySafe($row, $colname, ''))) . "\" class=\"wysiwyg\" name=\"{$name}{$colname}\">" . htmlentities(trim(ArraySafe($row, $colname, ''))) . "</textarea>";
        /*
            $dir = $GLOBALS['AG']['dirs']['root'];
            @include_once($dir.'/clib/FCKeditor/fckeditor.php');
            $oFCKeditor = new FCKeditor($name.$colname);
            $oFCKeditor->BasePath   = 'clib/FCKeditor/';
            $oFCKeditor->ToolbarSet = ( $ahcol['type_id'] == 'mime-h' ? 'Basic' : 'Default' );
            $oFCKeditor->Width  = ( $ahcol['type_id'] == 'mime-h' ? '275' : '470' );
            $oFCKeditor->Height = ( $ahcol['type_id'] == 'mime-h' ? '200' : '400' );
            $oFCKeditor->Value = trim(ArraySafe($row,$colname,''));
            $hx = $oFCKeditor->CreateHtml();
        */
        $h = str_replace('--MIME-H--' . $name . $colname . '--MIME-H--', $editor, $h);
        jqDocReady("\n                \$('.wysiwyg').each(function() {\n                    \$(this).wysihtml5({html: true, color: true});\n                });\n            ");
        $herr = '';
        if (count($colerrsx) > 0) {
            $herr = "<span class=\"x2columnerr\">" . implode("<br/>", $colerrsx) . "</span>";
            $scr = "getNamedItem('x_class_base').value='err'";
            $scr = "ob('{$name}{$colname}').attributes." . $scr;
            #E*lementAdd('ajax',"_script|$scr");
            #E*lementAdd('ajax',"_script|ob('$name$colname').className='x3err'");
        }
        if (!empty($herr)) {
            $h = str_replace($name . $colname . '--ERROR--CLASS', 'error', $h);
        } else {
            $h = str_replace($name . $colname . '--ERROR--CLASS', '', $h);
        }
        $h = str_replace($name . $colname . '--ERROR--', $herr, $h);
        return $h;
    }
    // Set the value (which also sets x_value_original)
    // KFD 8/6/07, put in the TRIM.  Otherwise a user clicks on a field
    //             and it mysteriously won't accept input.  This is
    //             because it is full of blank spaces!
    $colvalue = trim(ArraySafe($row, $colname, ''));
    if ($colvalue == '' && $ahcol['mode'] == 'ins' && !is_null($ahcol['default'])) {
        $colvalue = $ahcol['default'];
    }
    // KFD 6/28/07, use formatted value for all except time, and
    //    blank numbers on lookup
    // KFD 8/2/07,  removed this entirely, was putting in zeros
    //              for key columns.  These things should be handled
    //              entirely by defaults in the data dictionary.
    // KFD 8/6/07,  put formatting for dates back in, otherwise it
    //              was coming up 2007-08-07 for dates.
    // KFD 9/7/07,  put in a clause to handle double quotes in char values.
    if ($ahcol['type_id'] == 'date') {
        $colvalue = hFormat($ahcol['type_id'], trim($colvalue));
    } elseif ($ahcol['type_id'] == 'dtime') {
        if (trim($colvalue) != '') {
            $colvalue = date('m/d/Y h:i A', dEnsureTS($colvalue));
        }
    }
    if ($ahcol['formshort'] == 'char' || $ahcol['formshort'] == 'varchar' || $ahcol['formshort'] == 'text') {
        $colvalue = str_replace('"', '&quot;', $colvalue);
    }
    /*
    if($ahcol['type_id']<>'time') {
     if(!(   $ahcol['mode']=='search'
          && in_array($ahcol['formshort'],array('int','numb'))
          && trim($colvalue)==''
          )
        ) {
        $colvalue=hFormat($ahcol['type_id'],trim($colvalue));
     }
    }
    */
    //echo "Setting $name.$colname to $colvalue<br/>";
    $h = str_replace($name . $colname . '--VALUE--', htmlentities($colvalue), $h);
    $setInScript = false;
    # KFD 4/21/08, also set in script for value_min/max
    if ($ahcol['type_id'] == 'time') {
        $setInScript = true;
    }
    if ($ahcol['type_id'] == 'cbool') {
        $setInScript = true;
    }
    if ($ahcol['type_id'] == 'gender') {
        $setInScript = true;
    }
    if ($ahcol['value_min'] != '') {
        $setInScript = true;
    }
    #if($ahcol['type_id']=='time' ||
    #    $ahcol['type_id']=='cbool' ||
    #    $ahcol['type_id']=='gender'
    # ) {
    if ($setInScript) {
        if (gp('ajxBUFFER')) {
            #E*lementAdd('ajax',"_script|ob('$name$colname').value='$colvalue'");
        } else {
            jqDocReady("ob('{$name}{$colname}').value='{$colvalue}'");
        }
    }
    // KFD 3/3/08, translate y/n columns
    $replace_y = $colvalue == 'Y' ? 'SELECTED' : '';
    $replace_n = $colvalue == 'N' ? 'SELECTED' : '';
    $h = str_replace('--SELECTED-Y--', $replace_y, $h);
    $h = str_replace('--SELECTED-N--', $replace_n, $h);
    // If it's a select, we need to grab some hforSelect
    $innerHTML = '';
    if ($ahcol['table_id_fko'] != '' && $ahcol['fkdisplay'] != 'dynamic') {
        // Generate uifiltercolumns
        $uifc = trim(ArraySafe($ahcol, 'uifiltercolumn', ''));
        $matches = array();
        if ($uifc != '') {
            $matches[$uifc] = ArraySafe($row, $uifc, '');
        }
        // KFD 10/8/07, application PROMAT needs compound foreign key
        $fkpks = explode(',', $ahcol['fk_pks']);
        $pull = true;
        $dist = '';
        if (count($fkpks) > 1) {
            // This is a compound.  The first column gets distinct, the
            // second and further columns get nothing
            if (trim($colname) == trim($fkpks[0])) {
                $dist = $colname;
                // pull distinct
            } else {
                // Don't pull.  Use ajax during runtime and make a
                // one-value dropdown now
                $pull = false;
                $innerHTML = "<option SELECTED value=\"{$colvalue}\">{$colvalue}</option>";
            }
        }
        // Pull the options
        if ($pull) {
            $innerHTML = hOptionsFromTable($ahcol['table_id_fko'], $colvalue, '', $matches, $dist);
        }
        // In some cases there should be a blank value
        if (ArraySafe($ahcol, 'allow_empty', false)) {
            if (substr($innerHTML, 0, 26) != '<OPTION VALUE="" SELECTED>') {
                $innerHTML = '<OPTION VALUE="" SELECTED></OPTION>' . $innerHTML;
            }
        }
    }
    $h = str_replace($name . $colname . '--HINNER--', $innerHTML, $h);
    // Slip in the errors if they are there.
    // Grab these for later
    $colerrs = vgfget('errorsCOL', array());
    $colerrsx = ArraySafe($colerrs, $colname, array());
    $herr = '';
    if (count($colerrsx) > 0) {
        $herr = "<span class=\"x2columnerr\">" . implode("<br/>", $colerrsx) . "</span>";
        $scr = "getNamedItem('x_class_base').value='err'";
        $scr = "ob('{$name}{$colname}').attributes." . $scr;
        #E*lementAdd('ajax',"_script|$scr");
        #E*lementAdd('ajax',"_script|ob('$name$colname').className='x3err'");
    }
    if (!empty($herr)) {
        $h = str_replace($name . $colname . '--ERROR--CLASS', 'error', $h);
    } else {
        $h = str_replace($name . $colname . '--ERROR--CLASS', '', $h);
    }
    $h = str_replace($name . $colname . '--ERROR--', $herr, $h);
    // ------------------------------------
    // Infinity plus one, register the clear
    // ------------------------------------
    $x = "ob('{$name}{$colname}')";
    #
    #ElementAdd('clearBoxes',"if($x) { $x.value='' }");
    return $h;
}
Example #3
0
    function main()
    {
        // Get top page
        $this->PageSubtitle = "Documentation";
        //$sq="SELECT pagename FROM docpageshier WHERE pagehier=1";
        //$pageroot=SQL_OneValue('pagename',$sq);
        $pageroot = 'Data Dictionary';
        $pn = gp('gppn');
        $pn = $pn == '' ? $pageroot : $pn;
        $sq = "SELECT * from docpages \n            WHERE pagename = " . sql_format('char', $pn);
        $row = SQL_oneRow($sq);
        if ($row === false) {
            echo "Page does not exist: " . $pn;
            return;
        }
        // Get one parent.  We used to get all of them, but now
        // we only want one
        $hmenu = '';
        $attop = false;
        $parents = array();
        $peers = array();
        $kids = array();
        $pparent = $pprev = $pnext = '';
        $plast = $pn;
        while ($plast != $pageroot) {
            $sq = "SELECT pagename_par FROM docpages \n               WHERE pagename = '{$plast}'";
            $rownew = SQL_AllRows($sq);
            $plast = $rownew[0]['pagename_par'];
            $parents[] = $plast;
            //if ($rownew[0]['pagename_par'] == $pageroot) {
            //   break;
            //}
        }
        if (count($parents) > 0) {
            $parents = array_reverse($parents);
            //$hmenu=adocs_makemenu($parents,'Parent Topics');
            // Grab this page's peers
            $pparent = $parents[count($parents) - 1];
            $sq = "SELECT pagename FROM docpages \n               WHERE pagename_par = '{$pparent}'\n               ORDER BY sequence";
            $rs = SQL($sq);
            while ($rowx = SQL_Fetch_Array($rs)) {
                $peers[] = $rowx['pagename'];
            }
            $peersr = array_flip($peers);
            $pprev = $peersr[$pn] == 0 ? '' : $peers[$peersr[$pn] - 1];
            $pnext = $peersr[$pn] == count($peers) - 1 ? '' : $peers[$peersr[$pn] + 1];
        }
        // Now pull out the kids
        $sq = "SELECT pagename FROM docpages \n            WHERE pagename_par = '{$pn}'\n            ORDER BY sequence";
        $rs = SQL($sq);
        while ($rowx = SQL_Fetch_Array($rs)) {
            $kids[] = $rowx['pagename'];
        }
        // Make and save a menu out of what we've discovered
        adocs_makemenu($pageroot, $pn, $parents, $peers);
        // Now format the page and save it.  No caching for now.
        $html = $row['pagetext'];
        $html = $this->WikiProcess($html);
        /*
        // Remove carriage returns, makes things much easier
        $html=str_replace("\r",'',$html);
        
        // Convert newlines to double br's, but first don't do doubles
        // after headings
        $html=str_replace("=\n\n","=\n",$html);
        $html=preg_replace("/\n\s*\n/","\n<br><br>\n",$html);
             
        // Convert bold & italitcs 
        $html=preg_replace(
           "/'{4,}(.*)'{4,}/xmsU"
           ,'<b><i>$1</i></b>'
           ,$html);
        $html=preg_replace(
           "/'{3}(.*)'{3}/xmsU"
           ,'<i>$1</i>'
           ,$html);
        $html=preg_replace(
           "/\'{2}(.*)\'{2}/xmsU"
           ,'<b>$1</b>'
           ,$html);
             
        
        // Convert 6 levels of title
        $html=preg_replace(
           "/={6}(.*)={6}/xsU"
           ,'<head6>$1</head6>'
           ,$html);
        $html=preg_replace(
           "/={5}(.*)={5}/xsU"
           ,'<head5>$1</head5>'
           ,$html);
        $html=preg_replace(
           "/={4}(.*)={4}/xsU"
           ,'<head4>$1</head4>'
           ,$html);
        $html=preg_replace(
           "/={3}(.*)={3}/xsU"
           ,'<head3>$1</head3>'
           ,$html);
        $html=preg_replace(
           "/={2}(.*)={2}/xsU"
           ,'<head2>$1</head2>'
           ,$html);
           
        $html=preg_replace(
           '/^=(.*)=$/U'
           ,'<head1>$1</head1>'
           ,$html);
        
        // convert hyperlinks and images
        $matches=array();
        while(preg_match('/\[{2,}(.*)\]{2,}/xmsU',$html,$matches)>0) {
           $search=$matches[1];
           $asearch=explode(':',$search);
           if(count($asearch)==2) {
              $type=$asearch[0];
              $match=$asearch[1];
           }
           else {
              $type='ilink';
              $match=$search;
           }
           
           switch(strtolower($type)) {
              case 'ilink': $this->Linkilink($html,$match); break;
              case 'image': $this->LinkImage($html,$match,$type); break;
           }
           
           $matches=array();
        }
        */
        // Prepare a list of parents
        if (count($parents) == 0) {
            $apars = array($pn);
        } else {
            $apars = $parents;
            $apars[] = $pn;
        }
        $hpars = '';
        foreach ($apars as $apar) {
            $hpars .= ($hpars == '' ? '' : ' &gt; ') . '<a href="?gp_page=x_docview&gppn=' . urlencode($apar) . '">' . $apar . '</a>';
        }
        // Prepare the prev, next stuff
        $hpn = '';
        if ($pprev . $pnext != '') {
            $hp = $pprev == '' ? '' : '<a href="?gp_page=x_docview&gppn=' . urlencode($pprev) . '">PREV: ' . $pprev . '</a>';
            $hn = $pnext == '' ? '' : '<a href="?gp_page=x_docview&gppn=' . urlencode($pnext) . '">NEXT: ' . $pnext . '</a>';
            $hpn = "\n\t\t\t<div class=\"row\">\n\t\t\t<div class=\"span9\">\n\t\t\t\t<div class=\"pull-left\">{$hp}</div>\n\t\t\t\t<div class=\"pull-right\">{$hn}</div>\n\t\t\t</div>\n\t\t\t</div>";
        }
        // Pull out and assemble the see-also groups
        $hsa = '';
        /*
        $hsa='';
        $sq='SELECT DISTINCT seealso FROM seealsoxpages '
           ." WHERE pagename='$pn'";
        $sas=SQL_AllRows($sq);
        foreach($sas as $sa) {
           $hsa.="<hr>";
           $seealso=$sa['seealso'];
           $hsa.="<hr><h2>See Also ($seealso):</h2><p>";
           $sq="SELECT pagename FROM seealsoxpages "
              ." WHERE seealso = '$seealso' "
              ."  AND  pagename <> '$pn'"
              ." ORDER By pagename ";
           $sarows=SQL_AllRows($sq);
           foreach($sarows as $index=>$sarow) {
              $hsa.=($index==0 ? '' : ', ')
                 .'<a href="?gppn='.urlencode($sarow['pagename']).'">'
                 .$sarow['pagename'].'</a>';
           }
           $sarows.='</p>';
        }
        */
        // Now the actual output and formatting
        //
        $this->PageSubtitle = $pn;
        echo "<div class=\"hero-unit\">Database Specification</div>";
        echo $hpars . "<br><br>";
        echo $hpn;
        echo "\n<hr>";
        echo "\n<h2>" . $pn . "</h2>\n";
        echo $html;
        if (count($kids) > 0 && $pn == 'Data Dictionary') {
            echo "\n<hr>";
            echo "\n<head2>Child Topics</head2>";
            foreach ($kids as $kid) {
                echo "\n<div><a href=\"?gp_page=x_docview&gppn=" . urlencode($kid) . "\">{$kid}</a></div>";
            }
        }
        echo $hsa;
        echo "<hr>";
        echo $hpn;
        ?>
      <hr>
      Page last modified <?php 
        echo date('r', dEnsureTS($row['ts_upd']));
        ?>
 by 
         <?php 
        echo $row['uid_upd'];
        ?>
<br><br>
      <?php 
    }
Example #4
0
 function ehBrowse_Data(&$rows)
 {
     // Generate the table header as sortable columns
     echo "\n";
     $cols = asliceValsFromKeys($this->table['flat'], 'description', $this->projections['_uisearch']);
     echo hTableSortable($this->table_id, $cols);
     // Retrieve the rows
     if (count($rows) > 0) {
         vgfSet('HTML_focus', 'browse_row0');
         $hrows = array();
         $j = 0;
         foreach ($rows as $row) {
             $j++;
             $i = 0;
             $newrow = array();
             foreach ($cols as $colname => $coldesc) {
                 if ($i != 0) {
                     switch ($this->table['flat'][$colname]['type_id']) {
                         case 'time':
                             $newrow[] = hTime($row[$colname]);
                             break;
                         case 'dtime':
                             $newrow[] = date('m/d/Y - h:i A', dEnsureTS($row[$colname]));
                             break;
                         case 'date':
                             if (is_null($row[$colname])) {
                                 $newrow[] = '';
                             } else {
                                 $newrow[] = hDate(strtotime($row[$colname]));
                             }
                             //$newrow[]=$row[$colname];
                             break;
                         default:
                             $newrow[] = $row[$colname];
                     }
                 } else {
                     $hName = $j == 1 ? ' id="browse_row0" ' : '';
                     $js = "SetAction('gp_page','" . $this->table_id . "'" . ",'gp_skey','" . $row['skey'] . "')";
                     $value = '<a tabindex=' . $j . $hName . ' ' . 'href="javascript:' . $js . '">' . $row[$colname] . '</a>';
                     $newrow[] = $value;
                     $i = 1;
                 }
             }
             $hrows[] = $newrow;
         }
         echo hTBodyFromRows('dlite', $hrows);
     } else {
         echo "\n<tr><td colspan=99 class='dlite'>" . "<b>There are no records to display</b>" . "</td></tr>\n";
     }
     // Wrap up by closing the table.
     echo "\n<tr><td colspan=99 class='dhead'>&nbsp;</td></tr>";
     echo "\n</table>";
 }