/[corp_html]/back/phormation/displaytable.php
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Diff of /back/phormation/displaytable.php

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.3 by dpavlin, Mon Jul 2 20:00:47 2001 UTC revision 1.13 by ravilov, Mon Sep 17 10:35:27 2001 UTC
# Line 24  Line 24 
24   *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.   *  Foundation, Inc., 59 Temple Street #330, Boston, MA 02111-1307, USA.
25   */   */
26    
27    if (!isset($phescape)) $phescape = true;
28    
29  include_once( "$phormationdir/dbi.php" );  include_once( "$phormationdir/dbi.php" );
30    
31  // these variables will be preserved, as long as makephself is used to  // these variables will be preserved, as long as makephself is used to
# Line 102  function displayresult( $result, $fields Line 104  function displayresult( $result, $fields
104      $startrecord = $pagelength * $pagenum;      $startrecord = $pagelength * $pagenum;
105      $endrecord = min( $pagelength * ( $pagenum + 1 ) - 1, $numrows - 1 );      $endrecord = min( $pagelength * ( $pagenum + 1 ) - 1, $numrows - 1 );
106      $numpages = ceil( $numrows / $pagelength );      $numpages = ceil( $numrows / $pagelength );
107    
108        $rows = array();
109        for ($i = 0; $i < $numrows; $i++) $rows[$i] = dbi_fetch_array($result, $i);
110    
111      if( $pagenum > 0 ) {      if( $pagenum > 0 ) {
112          echo '<a href="' . makephpself( "pagenum=" . ($pagenum - 1) ) .  '">Previous Page</A> - ';          echo '<a href="' . makephpself( "pagenum=" . ($pagenum - 1) ) .  '">Previous Page</A> - ';
113      } else {      } else {
# Line 114  function displayresult( $result, $fields Line 120  function displayresult( $result, $fields
120      } else {      } else {
121          echo ' - Next Page';          echo ' - Next Page';
122      }      }
123        if ( $params["quickjump"] ) {
124            $tmp = array();
125            for( $i = 0; $i < count( $rows ); $i++ ) {
126                if ( empty( $rows[$i][$params["quickjump"]] ) ) continue;
127                $url = "#".sprintf( "%03d", $i );
128                if ( $i < $startrecord || $i > $endrecord )
129                    $url = makephpself( "pagenum=".intval( $i / $pagelength ) ) . $url;
130                array_push($tmp, '<OPTION VALUE="' . $url . '">' .
131                    HTMLSpecialChars( $rows[$i][$params["quickjump"]] ) . '</OPTION>');
132            }
133            if ( count( $tmp ) > 0 ) {
134                    array_unshift( $tmp, "<OPTION VALUE=\"\">&nbsp;</OPTION>" );
135                    echo "\n<FORM><SMALL><FONT FACE=\"sans-serif\">QuickJump:</FONT> <SELECT STYLE=\"font-size:12px\" ONCHANGE=\"if(this.value)self.location.href=this.value;\">\n" . implode("\n", $tmp) . "</SELECT></FORM></SMALL>";
136            }
137        }
138      echo '<P>';      echo '<P>';
139    
140      echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=3 BGCOLOR="' . $tableheadercol .'" FGCOLOR="#FFFFFF">';      echo '<TABLE BORDER=0 CELLSPACING=1 CELLPADDING=3 BGCOLOR="' . $tableheadercol .'" FGCOLOR="#FFFFFF">';
141      echo '<TH bgcolor="#ffffff">&nbsp;</TH>';      echo '<TH bgcolor="#ffffff">&nbsp;</TH>';
142      echo '<TH bgcolor="#ffffff">&nbsp;</TH>';      echo '<TH bgcolor="#ffffff">&nbsp;</TH>';
143      for( $i = 0; ! empty( $names[$i] ); $i += 1 ) {      for( $i = 0; ! empty( $names[$i] ); $i += 1 ) {
144            if ( empty ( $fields[$i] ) ) continue;
145          echo '<TH bgcolor=' . $tableheadercol . '><A HREF="' . makephpself( "pagenum=0&sort=" . $fields[$i] ) . '">' . $names[$i] . '</A></TH>';          echo '<TH bgcolor=' . $tableheadercol . '><A HREF="' . makephpself( "pagenum=0&sort=" . $fields[$i] ) . '">' . $names[$i] . '</A></TH>';
146      }      }
147      $row = 0;      $row = 0;
148      for( $i = $startrecord; $i <= $endrecord; $i += 1 ) {      for( $i = $startrecord; $i <= $endrecord; $i += 1 ) {
149          $array = dbi_fetch_array( $result, $i );          $array = $rows[$i];
150          echo "<TR BGCOLOR=" . $colour[ $i % 2 ] . ">";          echo "<TR BGCOLOR=" . $colour[ $i % 2 ] . ">";
151          echo '<TD bgcolor="#ffffff">';          echo '<TD bgcolor="#ffffff" VALIGN=top>';
152          echo '<a href="' . makephpself( "action=delete&record_id=" . $array[$key] ) . '" onClick="return confirmdelete()">';          echo '<a href="' . makephpself( "action=delete&record_id=" . $array[$key] ) . '" onClick="return confirmdelete()">';
153          echo '<img src="' . $phormationdir . '/delete.gif" alt="delete record" border="0"></a></TD>';          echo '<img src="' . $phormationdir . '/delete.gif" alt="delete" border="0"></a></TD>';
154          echo '<TD bgcolor="#ffffff"><a href="' . $editlink . 'record_id=' . $array[$key] . '">';          echo '<TD bgcolor="#ffffff" VALIGN=top><a href="' . $editlink . 'record_id=' . $array[$key] . '">';
155          echo '<img src="' . $phormationdir . '/edit.gif" alt="edit record" border="0"></a></TD>';          echo '<img src="' . $phormationdir . '/edit.gif" alt="edit" border="0"></a></TD>';
156          for( $j = 0; ! empty( $fields[$j] ); $j += 1 ) {          for( $j = 0; ! empty( $names[$j] ); $j += 1 ) {
157              echo "<TD>\n";              if ( empty ( $fields[$j] ) ) continue;
158              if( empty( $array[ $fields[$j]] ) ) {              echo "<TD VALIGN=top>\n";
159                  echo "&nbsp;";              if ($params["quickjump"] && $j == 0) echo '<A NAME="' . sprintf("%03d", $i) . '"></A>';
160              } else {              $vals = array();
161                  echo $array[$fields[$j]];              $flds = split(",", $fields[$j]);
162                while (list($k, $v) = each($flds)) {
163                    $x = $array[trim($v)];
164                    # if (!$x) $x = $array[$j + 1];
165                    array_push($vals, $x);
166              }              }
167              echo "</TD>\n";              $vals = implode(", ", $vals);
168                if ($phescape) $vals = htmlspecialchars($vals);
169                if (!empty($params["display_hook"]))
170                    $vals = $params["display_hook"]($fields[$j], $vals);
171                if ($vals == "") $vals = "&nbsp;";
172                echo "$vals</TD>\n";
173          }          }
174          echo "</TR>\n";          echo "</TR>\n";
175      }      }
# Line 152  function table_index( $fields, $names, $ Line 183  function table_index( $fields, $names, $
183    
184      // get params      // get params
185      $title = $params["title"];      $title = $params["title"];
186        $charset = $params["charset"];
187    
188      if( $action == "delete" ) {      if( $action == "delete" ) {
189          // if a record should be deleted          // if a record should be deleted
# Line 159  function table_index( $fields, $names, $ Line 191  function table_index( $fields, $names, $
191              // call the hook function if it exists,              // call the hook function if it exists,
192              $params["predelete_hook"]( $record_id );              $params["predelete_hook"]( $record_id );
193          }          }
194          $query = $params["delquery"] . $record_id;          $query = $params["delquery"] . "'" . $record_id . "'";
195          dbi_exec( $conn, $query );          dbi_exec( $conn, $query );
196          header( "Location: " . makephpself( 'action=nothing' ) );          header( "Location: " . makephpself( 'action=nothing' ) );
197          return;          return;
# Line 168  function table_index( $fields, $names, $ Line 200  function table_index( $fields, $names, $
200      ?>      ?>
201      <HTML>      <HTML>
202      <HEAD>      <HEAD>
203        <? if ($charset): ?><META HTTP-EQUIV="Content-Type" CONTENT="text/html;charset=<? echo $charset ?>"><? endif; ?>
204      <TITLE><? echo $title ?></TITLE>      <TITLE><? echo $title ?></TITLE>
205      </HEAD>      </HEAD>
206      <BODY BGCOLOR="#FFFFFF" LINK="#000090" VLINK="#000090" ALINK="#FF0000" >      <BODY BGCOLOR="#FFFFFF" LINK="#000090" VLINK="#000090" ALINK="#FF0000" >
207      <script>      <script type="text/javascript">
208        <!-- // begin
209          function confirmdelete() {          function confirmdelete() {
210              $result = confirm( "Do you really want to delete this record?" );              $result = confirm( "Do you really want to delete this record?" );
211              if( $result ) {              if( $result ) {
# Line 180  function table_index( $fields, $names, $ Line 214  function table_index( $fields, $names, $
214                  return false;                  return false;
215              }              }
216          }          }
217        // end -->
218      </script>      </script>
219      <h1><? echo $title ?></h1>      <h1><?= $title ?></h1>
220      <?        <?  
221          if( function_exists( html_before_table ) ) {          if( function_exists( html_before_table ) ) {
222              html_before_table();              html_before_table();
# Line 199  function table_index( $fields, $names, $ Line 234  function table_index( $fields, $names, $
234          if( !empty( $params["addmultiplelink"] ) ) {          if( !empty( $params["addmultiplelink"] ) ) {
235              echo ' - <a href="' . $params["addmultiplelink"] . '">Create Several Records</A>';              echo ' - <a href="' . $params["addmultiplelink"] . '">Create Several Records</A>';
236          }          }
237            if (!empty($params["back"])) {
238                echo ' - <a href="'.$params["back"].'">Back to Index</a>';
239            }
240          echo "<P>";          echo "<P>";
241          echo $params["instr"];          echo $params["instr"];
242            

Legend:
Removed from v.1.3  
changed lines
  Added in v.1.13

  ViewVC Help
Powered by ViewVC 1.1.26