[ PHPXref.com ] [ Generated: Sun Jul 20 17:52:21 2008 ] [ Focus/SIS 1.0 ]
[ Index ]     [ Variables ]     [ Functions ]     [ Classes ]     [ Constants ]     [ Statistics ]

title

Body

[close]

/functions/ -> ListOutput.fnc.php (source)

   1  <?
   2  /**
   3  * @file ListOutput.fnc.php 2006-04-17 andrew $
   4  * @package Focus/SIS
   5  * @copyright Copyright (C) 2006 Andrew Schmadeke. All rights reserved.
   6  * @license http://www.gnu.org/copyleft/gpl.html GNU/GPL, see LICENSE.txt
   7  * Focus/SIS is free software. This version may have been modified pursuant
   8  * to the GNU General Public License, and as distributed it includes or
   9  * is derivative of works licensed under the GNU General Public License or
  10  * other free or open source software licenses.
  11  * See COPYRIGHT.txt for copyright notices and details.
  12  */
  13  
  14  function ListOutput($result,$column_names,$singular='',$plural='',$link=false,$group=false,$options=false)
  15  {
  16      if(!isset($options['save']))
  17          $options['save'] = true;
  18      if(!isset($options['print']))
  19          $options['print'] = true;
  20      if(!isset($options['search']))
  21          $options['search'] = true;
  22      if(!isset($options['center']))
  23          $options['center'] = true;
  24      if(!isset($options['count']))
  25          $options['count'] = true;
  26      if(!isset($options['sort']))
  27          $options['sort'] = true;
  28      if(!$link)
  29          $link = array();
  30  
  31      if(!isset($options['add']))
  32      {
  33          if(!AllowEdit())
  34          {
  35              if($link)
  36              {
  37                  unset($link['add']);
  38                  unset($link['remove']);
  39              }
  40          }
  41      }
  42  
  43      // PREPARE LINKS ---
  44      $result_count = $display_count = count($result);
  45      $num_displayed = 100000;
  46      $extra = "page=$_REQUEST[page]&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST['LO_search']);
  47      
  48      $tmp_REQUEST = $_REQUEST;
  49      unset($tmp_REQUEST['page']);
  50      unset($tmp_REQUEST['LO_sort']);
  51      unset($tmp_REQUEST['LO_direction']);
  52      unset($tmp_REQUEST['LO_search']);
  53      unset($tmp_REQUEST['remove_prompt']);
  54      unset($tmp_REQUEST['remove_name']);
  55      unset($tmp_REQUEST['LO_save']);
  56      unset($tmp_REQUEST['PHPSESSID']);
  57  
  58      $PHP_tmp_SELF = PreparePHP_SELF($tmp_REQUEST);
  59          
  60      // END PREPARE LINKS ---
  61  
  62      // UN-GROUPING
  63      $group_count = count($group);
  64      if(!is_array($group))
  65          $group_count = false;
  66      
  67      $side_color = Preferences('COLOR');
  68  
  69      if($group_count && $result_count)
  70      {
  71          $color = 'F8F8F9';
  72          $group_result = $result;
  73          unset($result);
  74          $result[0] = '';
  75  
  76          foreach($group_result as $item1)
  77          {
  78              if($group_count==1)
  79              {
  80                  if($color=='F8F8F9')
  81                      $color = $side_color;
  82                  else
  83                      $color = 'F8F8F9';
  84              }
  85              
  86              foreach($item1 as $item2)
  87              {
  88                  if($group_count==1)
  89                  {
  90                      $i++;
  91                      if(count($group[0]) && $i!=1)
  92                      {
  93                          foreach($group[0] as $column)
  94                              $item2[$column] = str_replace('<!-- <!--','<!--','<!-- '.str_replace('-->','--><!--',$item2[$column])).' -->';
  95                      }
  96                      $item2['row_color'] = $color;
  97                      $result[] = $item2;
  98                  }
  99                  else
 100                  {
 101                      if($group_count==2)
 102                      {
 103                          if($color=='F8F8F9')
 104                              $color = $side_color;
 105                          else
 106                              $color = 'F8F8F9';
 107                      }
 108                      
 109                      foreach($item2 as $item3)
 110                      {
 111                          if($group_count==2)
 112                          {
 113                              $i++;
 114                              if(count($group[0]) && $i!=1)
 115                              {
 116                                  foreach($group[0] as $column)
 117                                      $item3[$column] = '<!-- '.$item3[$column].' -->';
 118                              }
 119                              if(count($group[1]) && $i!=1)
 120                              {
 121                                  foreach($group[1] as $column)
 122                                      $item3[$column] = '<!-- '.$item3[$column].' -->';
 123                              }
 124                              $item3['row_color'] = $color;
 125                              $result[] = $item3;
 126                          }
 127                          else
 128                          {
 129                              if($group_count==3)
 130                              {
 131                                  if($color=='F8F8F9')
 132                                      $color = $side_color;
 133                                  else
 134                                      $color = 'F8F8F9';
 135                              }
 136  
 137                              foreach($item3 as $item4)
 138                              {
 139                                  if($group_count==3)
 140                                  {
 141                                      $i++;
 142                                      if(count($group[2]) && $i!=1)
 143                                      {
 144                                          foreach($group[2] as $column)
 145                                              unset($item4[$column]);
 146                                      }
 147                                      $item4['row_color'] = $color;
 148                                      $result[] = $item4;
 149                                  }
 150                              }
 151                          }
 152                      }
 153                  }
 154              }
 155              $i = 0;    
 156          }
 157          unset($result[0]);
 158          $result_count = count($result);
 159      
 160          unset($_REQUEST['LO_sort']);
 161      }
 162      // END UN-GROUPING
 163      $_LIST['output'] = true;
 164  
 165      
 166      // PRINT HEADINGS, PREPARE PDF, AND SORT THE LIST ---        
 167      if($_LIST['output']!=false)
 168      {
 169          if($result_count != 0)
 170          {
 171              $count = 0;
 172              $remove = count($link['remove']['variables']);
 173              $cols = count($column_names);
 174  
 175              // HANDLE SEARCHES ---
 176              if($result_count && $_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search')
 177              {
 178                  $_REQUEST['LO_search'] = $search_term = str_replace('\\\"','"',$_REQUEST['LO_search']);
 179                  $_REQUEST['LO_search'] = $search_term = ereg_replace('[^a-zA-Z0-9 _"]*','',strtolower($search_term));    
 180          
 181                  if(substr($search_term,0,0)!='"' && substr($search_term,-1)!='"')
 182                  {    
 183                      $search_term = ereg_replace('"','',$search_term);
 184                      while($space_pos = strpos($search_term,' '))
 185                      {
 186                          $terms[strtolower(substr($search_term,0,$space_pos))] = 1;
 187                          $search_term =  substr($search_term,($space_pos+1));
 188                      }
 189                      $terms[trim($search_term)] = 1;
 190                  }
 191                  else
 192                  {
 193                      $search_term = ereg_replace('"','',$search_term);
 194                      $terms[trim($search_term)] = 1;
 195                  }
 196                  
 197                  unset($terms['of']); unset($terms['the']); unset($terms['a']); unset($terms['an']); unset($terms['in']);
 198                  
 199                  foreach($result as $key=>$value)
 200                  {
 201                      $values[$key] = 0;
 202                      foreach($value as $name=>$val)
 203                      {
 204                          $val = ereg_replace('[^a-zA-Z0-9 _]+','',strtolower($val));
 205                          if(strtolower($_REQUEST['LO_search'])==$val)
 206                              $values[$key] += 25;
 207                          foreach($terms as $term=>$one)
 208                          {
 209                              if(ereg($term,$val))
 210                                  $values[$key] += 3;
 211                          }
 212                      }    
 213                      if($values[$key]==0)
 214                      {
 215                          unset($values[$key]);
 216                          unset($result[$key]);
 217                          $result_count--;
 218                          $display_count--;
 219                      }
 220                  }
 221                  if($result_count)
 222                  {
 223                      array_multisort($values,SORT_DESC,$result);
 224                      $result = ReindexResults($result);       
 225                      $values = ReindexResults($values);
 226                      
 227                      $last_value = 1;
 228                      $scale = (100/$values[$last_value]);
 229                      
 230                      for($i=$last_value;$i<=$result_count;$i++)
 231                          $result[$i]['RELEVANCE'] = '<!--' . ((int) ($values[$i]*$scale)) . '--><IMG SRC="assets/pixel_grey.gif" width=' . ((int) ($values[$i]*$scale)) . ' height=10>';
 232                  }
 233                  $column_names['RELEVANCE'] = "Relevance";
 234  
 235                  if(is_array($group) && count($group))
 236                  {
 237                      $options['count'] == false;
 238                      $display_zero = true;
 239                  }
 240              }
 241              
 242              // END SEARCHES ---            
 243  
 244              if($_REQUEST['LO_sort'])
 245              {
 246                  foreach($result as $sort)
 247                  {    
 248                      if(substr($sort[$_REQUEST['LO_sort']],0,4)!='<!--')
 249                          $sort_array[] = $sort[$_REQUEST['LO_sort']];
 250                      else
 251                          $sort_array[] = substr($sort[$_REQUEST['LO_sort']],4,strpos($sort[$_REQUEST['LO_sort']],'-->')-5);
 252                  }
 253                  if($_REQUEST['LO_direction']==-1)
 254                      $dir = SORT_DESC;
 255                  else
 256                      $dir = SORT_ASC;
 257                  
 258                  if($result_count>1)    
 259                  {
 260                      if(is_int($sort_array[1]) || is_double($sort_array[1]))    
 261                          array_multisort($sort_array,$dir,SORT_NUMERIC,$result);         
 262                      else
 263                          array_multisort($sort_array,$dir,$result);
 264                      for($i=$result_count-1;$i>=0;$i--)
 265                          $result[$i+1] = $result[$i];
 266                      unset($result[0]);
 267                  }
 268              }
 269          }
 270          // HANDLE SAVING THE LIST ---
 271      
 272          if($_REQUEST['LO_save']=='1')
 273          {
 274              if(!$options['save_delimiter'] && Preferences('DELIMITER')=='CSV')
 275                  $options['save_delimiter'] = 'comma';
 276              switch($options['save_delimiter'])
 277              {
 278                  case 'comma':
 279                      $extension = 'csv';
 280                  break;
 281                  case 'xml':
 282                      $extension = 'xml';
 283                  break;
 284                  default:
 285                      $extension = 'xls';
 286                  break;
 287              }
 288              if($options['extension'])
 289                  $extension = $options['extension'];
 290  
 291              ob_end_clean();
 292              if($options['save_delimiter']!='xml')
 293              {
 294                  foreach($column_names as $key=>$value)
 295                      $output .= str_replace('&nbsp;',' ',eregi_replace('<BR>',' ',ereg_replace('<!--.*-->','',$value))) . ($options['save_delimiter']=='comma'?',':"\t");
 296                  if($options['save_delimiter']=='comma' && $extension=='txt')
 297                      $output = substr($output,0,-1);
 298                  $output .= "\n";
 299              }
 300              foreach($result as $item)
 301              {
 302                  foreach($column_names as $key=>$value)
 303                  {
 304                      if($options['save_delimiter']=='comma' && !$options['save_quotes'])
 305                          $item[$key] = str_replace(',',';',$item[$key]);
 306                      $item[$key] = eregi_replace('<SELECT.*SELECTED\>([^<]+)<.*</SELECT\>','\\1',$item[$key]);
 307                      $item[$key] = eregi_replace('<SELECT.*</SELECT\>','',$item[$key]);
 308                      $output .= ($options['save_quotes']?'"':'') . ($options['save_delimiter']=='xml'?'<'.str_replace(' ','',$value).'>':'') . ereg_replace('<[^>]+>','',ereg_replace("<div onclick='[^']+'>",'',ereg_replace(' +',' ',ereg_replace('&[^;]+;','',str_replace('<BR>&middot;',' : ',str_replace('&nbsp;',' ',$item[$key])))))) . ($options['save_delimiter']=='xml'?'</'.str_replace(' ','',$value).'>'."\n":'') . ($options['save_quotes']?'"':'') . ($options['save_delimiter']=='comma'?',':"\t");
 309                  }
 310                  if($options['save_delimiter']=='comma' && $extension=='txt')
 311                      $output = substr($output,0,-1);
 312                  $output .= "\n";
 313              }
 314              header("Cache-Control: public");
 315              header("Pragma: ");
 316              header("Content-Type: application/$extension");
 317              header("Content-Disposition: inline; filename=\"".ProgramTitle().".$extension\"\n");
 318              if($options['save_eval'])
 319                  eval($options['save_eval']);
 320              echo $output;
 321              exit();
 322          }
 323          // END SAVING THE LIST ---        
 324          if($options['center'])
 325              echo '<CENTER>';
 326          
 327          if(($result_count > $num_displayed) || (($options['count'] || $display_zero) && ((($result_count==0 || $display_count==0) && $plural) || ($result_count==0 || $display_count==0))))
 328          {
 329              echo "<TABLE border=0";
 330              if(isset($_REQUEST['_FOCUS_PDF']))
 331                  echo " width=100%";
 332              echo "><TR><TD align=center>";
 333          }
 334          
 335          if($options['count'] || $display_zero)
 336          {
 337              if(($result_count==0 || $display_count==0) && $plural)
 338                  echo "<b>No $plural were found.</b> &nbsp; &nbsp;";
 339              elseif($result_count==0 || $display_count==0)
 340                  echo '<b>None were found.</b> &nbsp; &nbsp;';
 341          }
 342          if($result_count != 0 || ($_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search'))
 343          {
 344              if(!isset($_REQUEST['_FOCUS_PDF']))
 345              {
 346                  if(!$_REQUEST['page'])
 347                      $_REQUEST['page'] = 1;
 348                  if(!$_REQUEST['LO_direction'])
 349                      $_REQUEST['LO_direction'] = 1;
 350                  $start = ($_REQUEST['page'] - 1) * $num_displayed + 1;
 351                  $stop = $start + ($num_displayed-1);
 352                  if($stop > $result_count)
 353                      $stop = $result_count;
 354      
 355                  if($result_count > $num_displayed)
 356                  {
 357                      $where_message = "<SMALL>Displaying $start through $stop</SMALL>";
 358                      echo "Go to Page ";
 359                      if(ceil($result_count/$num_displayed) <= 10)
 360                      {
 361                          for($i=1;$i<=ceil($result_count/$num_displayed);$i++)
 362                          {
 363                              if($i!=$_REQUEST[page])
 364                                  $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST[LO_search])."&page=$i>$i</A>, ";
 365                              else
 366                                  $pages .= "$i, ";
 367                          }
 368                          $pages = substr($pages,0,-2) . "<BR>";
 369                      }
 370                      else
 371                      {
 372                          for($i=1;$i<=7;$i++)
 373                          {
 374                              if($i!=$_REQUEST[page])
 375                                  $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST[LO_search])."&page=$i>$i</A>, ";
 376                              else
 377                                  $pages .= "$i, ";                    
 378                          }
 379                          $pages = substr($pages,0,-2) . " ... ";
 380                          for($i=ceil($result_count/$num_displayed)-2;$i<=ceil($result_count/$num_displayed);$i++)
 381                          {
 382                              if($i!=$_REQUEST[page])
 383                                  $pages .= "<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST[LO_search])."&page=$i>$i</A>, ";
 384                              else
 385                                  $pages .= "$i, ";                    
 386                          }    
 387                          $pages = substr($pages,0,-2) . " &nbsp;<A HREF=$PHP_tmp_SELF&LO_sort=$_REQUEST[LO_sort]&LO_direction=$_REQUEST[LO_direction]&LO_search=".urlencode($_REQUEST[LO_search])."&page=" . ($_REQUEST[page] +1) . ">Next Page</A><BR>";        
 388                      }
 389                      echo $pages;
 390                      echo '</TD></TR></TABLE>';
 391                      echo '<BR>';
 392                  }
 393              }
 394              else
 395              {
 396                  $start = 1;
 397                  $stop = $result_count;
 398                  if($cols>8 || $_REQUEST['expanded_view'])
 399                  {    
 400                      $_SESSION['orientation'] = 'landscape';
 401                      $repeat_headers = 17;
 402                  }
 403                  else
 404                      $repeat_headers = 28;
 405                  if($options['print'])
 406                  {
 407                      $html = explode('<!-- new page -->',strtolower(ob_get_contents()));
 408                      $html = $html[count($html)-1];
 409                      echo '</TD></TR></TABLE>';
 410                      $br = (substr_count($html,'<br>')) + (substr_count($html,'</p>')) + (substr_count($html,'</tr>')) + (substr_count($html,'</h1>')) + (substr_count($html,'</h2>')) + (substr_count($html,'</h3>')) + (substr_count($html,'</h4>')) + (substr_count($html,'</h5>'));
 411                      if($br%2!=0)
 412                      {
 413                          $br++;
 414                          echo '<BR>';
 415                      }
 416                  }
 417                  else
 418                      echo '</TD></TR></TABLE>';
 419              }
 420              // END MISC ---
 421  
 422              // WIDTH = 100%
 423              echo '<TABLE cellspacing=0 cellpadding=1 width=100%><TR>';
 424                  
 425              // SEARCH BOX & MORE HEADERS
 426              if($where_message || ($singular && $plural) || (!isset($_REQUEST['_FOCUS_PDF']) && $options['search']))
 427              {
 428                  echo '<TD width=100% >';
 429                  echo '<TABLE cellpadding=1 width=100%>';
 430                  echo "<TR><TD align=left>";
 431                  if($singular && $plural && $options['count'])
 432                  {
 433                      if($display_count > 1)
 434                          echo "<b>$display_count $plural were found.</b> &nbsp; &nbsp;";
 435                      elseif($display_count==1)
 436                          echo "<b>1 $singular was found.</b> &nbsp; &nbsp;";
 437                      if($where_message)
 438                          echo '<BR>'.$where_message;
 439                  }
 440                  if($options['save'] && !isset($_REQUEST['_FOCUS_PDF']) && $result_count > 0)
 441                      echo "<A HREF=$PHP_tmp_SELF&$extra&LO_save=1&_FOCUS_PDF=true><IMG SRC=assets/download.gif border=0 vspace=0 hspace=0></A>";
 442                  echo '</TD>';
 443                  $colspan = 1;
 444                  if(!isset($_REQUEST['_FOCUS_PDF']) && $options['search'])
 445                  {
 446                      $tmp_REQUEST = $_REQUEST;
 447                      unset($tmp_REQUEST['LO_search']);
 448                      unset($tmp_REQUEST['page']);
 449                      echo '<TD align=right>';
 450                      echo "<INPUT type=text id=LO_search name=LO_search value='".(($_REQUEST['LO_search'] && $_REQUEST['LO_search']!='Search')?$_REQUEST['LO_search']:'Search\' style=\'color:BBBBBB\''),"' onfocus='if(this.value==\"Search\") this.value=\"\"; this.style.color=\"000000\";' onblur='if(this.value==\"\") {this.value=\"Search\"; this.style.color=\"BBBBBB\";}' onkeypress='if(event.keyCode==13){document.location.href=\"".PreparePHP_SELF($tmp_REQUEST)."&LO_search=\"+this.value; return false;} '><INPUT type=button value=Go onclick='document.location.href=\"".PreparePHP_SELF($tmp_REQUEST)."&LO_search=\"+document.getElementById(\"LO_search\").value;'></TD>";
 451                      $colspan++;
 452                  }
 453                  echo "</TR>";
 454                  echo '<TR style="height:0;"><TD width=100% style="height:0;" height=0 align=right colspan='.$colspan.'><DIV id=LOx'.(count($column_names)+(($result_count!=0 && $cols && !isset($_REQUEST['_FOCUS_PDF']))?1:0)+(($remove && !isset($_REQUEST['_FOCUS_PDF']))?1:0)).' style="width:0; position: relative; height:0;"></DIV></TD></TR></TABLE>';
 455              }
 456              else
 457                  echo '<TD width=100% align=right><DIV id=LOx'.(count($column_names)+(($result_count!=0 && $cols && !isset($_REQUEST['_FOCUS_PDF']))?1:0)+(($remove && !isset($_REQUEST['_FOCUS_PDF']))?1:0)).' style="width:0; position: relative; height:0;"></DIV>';
 458              // END SEARCH BOX ----
 459              echo '</TD></TR><TR><TD>';
 460              
 461              // SHADOW
 462              if(!isset($_REQUEST['_FOCUS_PDF']))
 463                  echo '<TABLE width=100% cellpadding=0 cellspacing=0><TR><TD background=assets/left_shadow.gif width=4 height=100% rowspan=2>&nbsp;</TD><TD></TD><TD background=assets/right_shadow.gif width=4 height=100% rowspan=2></TD></TR><TR><TD>';
 464              echo "<TABLE cellpadding=6 width=100%>";
 465              if(!isset($_REQUEST['_FOCUS_PDF']) && ($stop-$start)>10)
 466                  echo '<THEAD>';
 467              if(!isset($_REQUEST['_FOCUS_PDF']))
 468                  echo '<TR>';
 469  
 470              $i =1;
 471              if($remove && !isset($_REQUEST['_FOCUS_PDF']) && $result_count!=0)
 472              {
 473                  echo "<TD bgcolor=#333366><DIV id=LOx$i style='position: relative;'></DIV></TD>";
 474                  $i++;
 475              }
 476              
 477              if($result_count!=0 && $cols && !isset($_REQUEST['_FOCUS_PDF']))
 478              {
 479                  foreach($column_names as $key=>$value)
 480                  {
 481                      if($_REQUEST['LO_sort'] == $key)
 482                          $direction = -1 * $_REQUEST['LO_direction'];
 483                      else
 484                          $direction = 1;
 485                      echo "<TD bgcolor=#333366><DIV id=LOx$i style='position: relative;'></DIV>";
 486                      echo "<A ";
 487                      if($options['sort'])
 488                          echo "HREF=$PHP_tmp_SELF&page=$_REQUEST[page]&LO_sort=$key&LO_direction=$direction&LO_search=".urlencode($_REQUEST['LO_search']);
 489                      echo " class=column_heading><b>$value</b></A>";
 490                      if($i==1)
 491                          echo "<DIV id=LOy0 style='position: relative;'></DIV>";
 492                      echo "</TD>";
 493                      $i++;
 494                  }
 495                  //echo '<TD width=0><DIV id=LO'.$i.'></DIV></TD>';
 496                  echo "</TR>";
 497              }
 498  
 499              $color = 'F8F8F9';
 500              //style="height: 300px; overflow: auto; padding-right: 16px;"
 501              if(!isset($_REQUEST['_FOCUS_PDF']) && ($stop-$start)>10)
 502                  echo '</THEAD><TBODY>';
 503  
 504              for($i=$start;$i<=$stop;$i++)
 505              {
 506                  $item = $result[$i];
 507                  if(isset($_REQUEST['_FOCUS_PDF']) && $options['print'] && count($item))
 508                  {
 509                      foreach($item as $key=>$value)
 510                      {
 511                          $value = eregi_replace('<SELECT.*SELECTED\>([^<]+)<.*</SELECT\>','\\1',$value);
 512                          $value = eregi_replace('<SELECT.*</SELECT\>','',$value);
 513                          
 514                          if(strpos($value,'LO_field')===false)
 515                              $item[$key] = str_replace(' ','&nbsp;',ereg_replace("<div onclick='[^']+'>",'',$value));
 516                          else
 517                              $item[$key] = ereg_replace("<div onclick='[^']+'>",'',$value);
 518                      }
 519                  }
 520                      
 521                  if($item['row_color'])
 522                      $color = $item['row_color'];            
 523                  elseif($color=='F8F8F9')
 524                      $color = $side_color;
 525                  else
 526                      $color = 'F8F8F9';
 527                      //$color = 'EDF3FE';
 528                  if(isset($_REQUEST['_FOCUS_PDF']) && $count%$repeat_headers==0)
 529                  {
 530                      if($count!=0)
 531                      {
 532                          echo '</TABLE><TABLE cellpadding=6 width=100%>';
 533                          echo '<!-- NEW PAGE -->';
 534                      }
 535                      echo "<TR>";
 536                      if($remove && !isset($_REQUEST['_FOCUS_PDF']))
 537                          echo "<TD bgcolor=#333366></TD>";
 538                                      
 539                      if($cols)
 540                      {
 541                          foreach($column_names as $key=>$value)
 542                          {
 543                              echo "<TD bgcolor=#333366 class=LO_field><FONT color=#FFFFFF size=-1><b>" . str_replace(' ','&nbsp;',$value) . "</b></FONT></TD>";
 544                          }
 545                      }
 546                      echo "</TR>";
 547                  }
 548                  if($count==0)
 549                      $count = $br;
 550      
 551                  echo "<TR bgcolor=#$color>";
 552                  $count++;
 553                  if($remove && !isset($_REQUEST['_FOCUS_PDF']))
 554                  {
 555                      $button_title = $link['remove']['title'];
 556                      //if(!$button_title)
 557                          //$button_title = 'Remove';
 558                      $button_link = $link['remove']['link'];
 559                      if(count($link['remove']['variables']))
 560                      {
 561                          foreach($link['remove']['variables'] as $var=>$val)
 562                              $button_link .= "&$var=" . urlencode($item[$val]);
 563                      }
 564                      
 565                      echo "<TD bgcolor=#$color>" . button('remove',$button_title,$button_link) . "</TD>";
 566                  }
 567                  if($cols)
 568                  {
 569                      foreach($column_names as $key=>$value)
 570                      {
 571                          if($link[$key] && !isset($_REQUEST['_FOCUS_PDF']))
 572                          {
 573                              echo "<TD bgcolor=#$color class=LO_field>";
 574                              if($key=='FULL_NAME')
 575                                  echo '<DIV id=LOy'.($count-$br).' height=100% style="height: 100%; min-height: 100%; position: relative;">';
 576                              if($link[$key]['js']===true)
 577                              {
 578                                  echo "<A HREF=# onclick='window.open(\"{$link[$key][link]}";
 579                                  if(count($link[$key]['variables']))
 580                                  {
 581                                      foreach($link[$key]['variables'] as $var=>$val)
 582                                          echo "&$var=".urlencode($item[$val]);
 583                                  }
 584                                  echo "\",\"\",\"scrollbars=yes,resizable=yes,width=800,height=400\");'";
 585                                  if($link[$key]['extra'])
 586                                      echo ' '.$link[$key]['extra'];
 587                                  echo ">";
 588                              }
 589                              else
 590                              {
 591                                  echo "<A HREF={$link[$key][link]}";
 592                                  if(count($link[$key]['variables']))
 593                                  {
 594                                      foreach($link[$key]['variables'] as $var=>$val)
 595                                          echo "&$var=".urlencode($item[$val]);
 596                                  }
 597                                  if($link[$key]['extra'])
 598                                      echo ' '.$link[$key]['extra'];
 599                                  echo ">";
 600                              }
 601                              if($color==Preferences('HIGHLIGHT'))
 602                                  echo '<font color=#FFFFFF>';
 603                              else
 604                                  echo '<font color=#0000FF>';
 605                              echo $item[$key];
 606                              echo '</font>';
 607                              if(!$item[$key])
 608                                  echo '***';
 609                              echo "</A>";
 610                              if($key=='FULL_NAME')
 611                                  echo '</DIV>';
 612                              echo "</TD>";
 613                          }
 614                          else
 615                          {
 616                              echo "<TD bgcolor=#$color class=LO_field>";
 617                              if($key=='FULL_NAME')
 618                                  echo '<DIV id=LOy'.($count-$br).' height=100% style="position: relative;">';
 619                              if($color==Preferences('HIGHLIGHT'))
 620                                  echo '<font color=white>';
 621                              echo $item[$key];
 622                              if(!$item[$key])
 623                                  echo '&nbsp;';
 624                              if($key=='FULL_NAME')
 625                                  echo '<DIV>';
 626                              echo "</TD>";
 627                          }
 628                      }
 629                  }
 630                  echo "</TR>";
 631              }
 632              
 633              if($result_count!=0)
 634              {
 635                  if($remove && !isset($_REQUEST['_FOCUS_PDF']))
 636                      $cols++;
 637                  if($link['add']['link'] && !isset($_REQUEST['_FOCUS_PDF']))
 638                      echo "<TR><TD colspan=$cols align=left bgcolor=#FFFFFF>".button('add',$link['add']['title'],$link['add']['link'])."</TD></TR>";
 639                  elseif($link['add']['span'] && !isset($_REQUEST['_FOCUS_PDF']))
 640                      echo "<TR><TD colspan=$cols align=left bgcolor=#FFFFFF>".button('add').$link['add']['span']."</TD></TR>";
 641                  elseif($link['add']['html'] && $cols)
 642                  {
 643                      if($count%2)
 644                          $color = 'F8F8F9';
 645                      else
 646                          $color = $side_color;
 647                          
 648                      echo "<TR bgcolor=#$color>";
 649                      if($remove && !isset($_REQUEST['_FOCUS_PDF']) && $link['add']['html']['remove'])
 650                          echo "<TD bgcolor=#$color>".$link['add']['html']['remove']."</TD>";
 651                      elseif($remove && !isset($_REQUEST['_FOCUS_PDF']))
 652                          echo "<TD bgcolor=#$color>".button('add')."</TD>";                        
 653      
 654                      foreach($column_names as $key=>$value)
 655                      {
 656                          echo "<TD bgcolor=#$color class=LO_field>".$link['add']['html'][$key]."</TD>";
 657                      }
 658                      echo "</TR>";
 659                  }
 660                  if(!isset($_REQUEST['_FOCUS_PDF']) && ($stop-$start)>10)
 661                      echo '</TBODY>';
 662                  echo "</TABLE>";
 663                  // SHADOW
 664                  if(!isset($_REQUEST['_FOCUS_PDF']))
 665                      echo '</TD></TR><TR><TD background=assets/left_corner_shadow.gif height=6 width=4></TD><TD background=assets/bottom_shadow.gif height=6></TD><TD height=6 width=4 background=assets/right_corner_shadow.gif></TD></TR></TABLE>';
 666                  echo "</TD></TR>";
 667                  echo "</TABLE>";
 668              
 669                  if($options['center'])
 670                      echo '</CENTER>';
 671              }
 672  
 673          // END PRINT THE LIST ---
 674          }
 675          if($result_count==0)
 676          {
 677              echo '</TD></TR></TABLE>';
 678              if($link['add']['link'] && !isset($_REQUEST['_FOCUS_PDF']))
 679                  echo '<center>' . button('add',$link['add']['title'],$link['add']['link']) . '</center>';
 680              elseif(($link['add']['html'] || $link['add']['span']) && count($column_names) && !isset($_REQUEST['_FOCUS_PDF']))
 681              {
 682                  $color = $side_color;
 683                  
 684                  if($options['center'])
 685                      echo '<CENTER>';
 686                  // WIDTH=100%
 687                  echo "<TABLE cellpadding=1 bgcolor=#f8f8f9 width=100%><TR><TD>";
 688                  // SHADOW
 689                  echo '<TABLE width=100% cellpadding=0 cellspacing=0><TR><TD background=assets/left_shadow.gif width=4 height=100% rowspan=2></TD><TD></TD><TD background=assets/right_shadow.gif width=4 height=100% rowspan=2></TD></TR><TR><TD>';            
 690                  if($link['add']['html'])
 691                  {
 692                      echo "<TABLE cellpadding=6 width=100%><TR><TD bgcolor=#333366></TD>";
 693                      foreach($column_names as $key=>$value)
 694                      {
 695                          echo "<TD bgcolor=#333366><A class=column_heading><b>" . str_replace(' ','&nbsp;',$value) . "</b></A></TD>";
 696                      }
 697                      echo "</TR>";
 698      
 699                      echo "<TR bgcolor=#$color>";
 700      
 701                      if($link['add']['html']['remove'])
 702                          echo "<TD bgcolor=#$color>".$link['add']['html']['remove']."</TD>";
 703                      else
 704                          echo "<TD bgcolor=#$color>".button('add')."</TD>";
 705                      
 706                      foreach($column_names as $key=>$value)
 707                      {
 708                          echo "<TD bgcolor=#$color class=LO_field>".$link['add']['html'][$key]."</TD>";
 709                      }
 710                      echo "</TR>";
 711                      echo "</TABLE>";
 712                  }
 713                  elseif($link['add']['span'] && !isset($_REQUEST['_FOCUS_PDF']))
 714                      echo "<TABLE><TR><TD align=left>".button('add').$link['add']['span']."</TD></TR></TABLE>";
 715                  
 716                  // SHADOW
 717                  echo '</TD></TR><TR><TD background=assets/left_corner_shadow.gif height=6 width=4></TD><TD background=assets/bottom_shadow.gif height=6></TD><TD height=6 width=4 background=assets/right_corner_shadow.gif></TD></TR></TABLE>';
 718                  echo "</TD></TR></TABLE>";
 719                  if($options['center'])
 720                      echo '</CENTER>';
 721              }
 722          }
 723          if($result_count!=0)
 724          {
 725              if($options['yscroll'])
 726              {
 727                  echo '<div id="LOy_layer" style="position: absolute; top: 0; left: 0; visibility:hidden;">';
 728                  echo '<TABLE cellpadding=6 id=LOy_table>';
 729                  $i = 1;
 730                  
 731                  if($cols && !isset($_REQUEST['_FOCUS_PDF']))
 732                  {
 733                      $color = $side_color;
 734                      foreach($result as $item)
 735                      {    
 736                          echo "<TR><TD bgcolor=#$color class=LO_field id=LO_row$i>";
 737                          if($color==Preferences('HIGHLIGHT'))
 738                              echo '<font color=white>';
 739                          echo $item['FULL_NAME'];
 740                          if(!$item['FULL_NAME'])
 741                              echo '&nbsp;';
 742                          if($color==Preferences('HIGHLIGHT'))
 743                              echo '</font>';                        
 744                          echo "</TD></TR>";                    
 745                          $i++;
 746                          
 747                          if($item['row_color'])
 748                              $color = $item['row_color'];            
 749                          elseif($color=='F8F8F9')
 750                              $color = $side_color;
 751                          else
 752                              $color = 'F8F8F9';
 753                      }
 754                  }
 755                  echo '</TABLE>';
 756                  echo '</div>';
 757              }
 758              
 759              echo '<div id="LOx_layer" style="position: absolute; top: 0; left: 0; visibility:hidden;">';
 760              echo '<TABLE cellpadding=6 id=LOx_table><TR>';
 761              $i = 1;
 762              if($remove && !isset($_REQUEST['_FOCUS_PDF']) && $result_count!=0)
 763              {
 764                  echo "<TD bgcolor=#333366 id=LO_col$i></TD>";
 765                  $i++;
 766              }
 767              
 768              if($cols && !isset($_REQUEST['_FOCUS_PDF']))
 769              {
 770                  foreach($column_names as $key=>$value)
 771                  {
 772                      echo '<TD bgcolor=#333366 id=LO_col'.$i.'><A class=column_heading><b>'.str_replace('controller','',$value).'</b></A></TD>';
 773                      $i++;
 774                  }
 775              }
 776              echo '</TR></TABLE>';
 777              echo '</div>';
 778          }
 779      }
 780  }
 781  ?>


[ Powered by PHPXref - Served by Debian GNU/Linux ]