home *** CD-ROM | disk | FTP | other *** search
/ PC World 2008 February (DVD) / PCWorld_2008-02_DVD.iso / v cisle / PHP / PHP.exe / EasyPHP-2.0b1-setup.exe / {app} / sqlitemanager / include / browse.php < prev    next >
Encoding:
PHP Script  |  2006-04-18  |  6.1 KB  |  112 lines

  1. <?php
  2. /**
  3. * Web based SQLite management
  4. * Show result query with paginate, sort, modify/delete links
  5. * @package SQLiteManager
  6. * @author FrΘdΘric HENNINOT
  7. * @version $Id: browse.php,v 1.45 2006/04/14 15:16:52 freddy78 Exp $ $Revision: 1.45 $
  8. */
  9.  
  10. include_once INCLUDE_LIB.'ParsingQuery.class.php';
  11. include_once INCLUDE_LIB.'sql.class.php';
  12. if(!isset($withForm)) $withForm = true;
  13.  
  14. if(!isset($DisplayQuery) || empty($DisplayQuery)){
  15.     if($action == 'sql') {
  16.         $displayResult = false;
  17.     }
  18.     if(!empty($table) || !empty($view)) $DisplayQuery = 'SELECT * FROM '.brackets($table).brackets($view);
  19.     else $DisplayQuery = '';
  20. } else if(!isset($_FILES)) {
  21.     $DisplayQuery = urldecode($GLOBALS['DisplayQuery']);
  22. } elseif( !empty($_POST['DisplayQuery']) || !empty($_GET['DisplayQuery']) ) {
  23.   $DisplayQuery = stripslashes($DisplayQuery);    
  24. }
  25. if(!isset($displayResult)) $displayResult = true;
  26. if(!isset($sql_action)) $sql_action = '';
  27. if( ($sql_action=='explain') && !eregi('EXPLAIN', $DisplayQuery) ) $DisplayQuery = 'EXPLAIN '.$DisplayQuery;
  28. $SQLiteQuery =& new sql($workDb, $DisplayQuery);
  29. if( $sql_action != 'modify'){
  30.     $error = $SQLiteQuery->verify(false);
  31. } else {
  32.     $error = false;
  33. }
  34. if($SQLiteQuery->withReturn && !$error && $displayResult){
  35.     include_once INCLUDE_LIB.'SQLiteToGrid.class.php';
  36.     if(!empty($GLOBALS["table"])) $linkItem = 'table='.$GLOBALS["table"];
  37.     else $linkItem = 'view='.$GLOBALS["view"];
  38.     
  39.     $accessResult = $SQLiteQuery->checkAccessResult($DisplayQuery);    
  40.     
  41.     $DbGrid =& new SQLiteToGrid($workDb->connId, $SQLiteQuery->query, 'Browse', true, BROWSE_NB_RECORD_PAGE, '70%');
  42.     $DbGrid->enableSortStyle(false);
  43.     $DbGrid->setGetVars('?dbsel='.$GLOBALS['dbsel'].'&table='.$table.'&action=browseItem&DisplayQuery='.urlencode($DisplayQuery));
  44.     if($DbGrid->getNbRecord()<=BROWSE_NB_RECORD_PAGE) $DbGrid->disableNavBarre();
  45.     if($accessResult && (!$workDb->isReadOnly() && displayCondition('data'))){
  46.         if(displayCondition('del')) $deleteLink = "<a href=\"main.php?dbsel=".$GLOBALS["dbsel"]."&table=".$accessResult."&action=deleteElement&query=#%QUERY%#&pos=#%POS%#&currentPage=browseItem\" class=\"Browse\" target=\"main\">".displayPics("deleterow.png", $GLOBALS["traduct"]->get(15))."</a>";
  47.         else $deleteLink = displayPics("deleterow_off.png", $GLOBALS["traduct"]->get(15));
  48.         if(displayCondition('data')) $modifyLink = "<a href=\"main.php?dbsel=".$GLOBALS["dbsel"]."&table=".$accessResult."&action=modifyElement&query=#%QUERY%#&pos=#%POS%#&currentPage=browseItem\" class=\"Browse\" target=\"main\">".displayPics("edit.png", $GLOBALS["traduct"]->get(14))."</a>";
  49.         else $modifyLink = displayPics("edit_off.png", $GLOBALS["traduct"]->get(14));
  50.         $DbGrid->addCalcColumn($GLOBALS["traduct"]->get(33), 
  51.                 "<div class=\"BrowseImages\">".$modifyLink." ".$deleteLink."</div>", "center", 0);
  52.     }
  53.  
  54.     $showTime = '<div class="time" align="center">'.$GLOBALS['traduct']->get(213).' '.$SQLiteQuery->queryTime.' '.$GLOBALS['traduct']->get(214).'</div>';
  55.     if($allFullText) $caption = '<a href="main.php?dbsel='.$GLOBALS["dbsel"].'&'.$linkItem.'&action=browseItem&fullText=0" target="main">'.displayPics("nofulltext.png", $GLOBALS['traduct']->get(225)).'</a>';
  56.     else $caption = '<a href="?dbsel='.$GLOBALS["dbsel"].'&'.$linkItem.'&action=browseItem&fullText=1">'.displayPics("fulltext.png", $GLOBALS['traduct']->get(226)).'</a>';
  57.     if($allHTML) $capHTML = '<a href="main.php?dbsel='.$GLOBALS["dbsel"].'&'.$linkItem.'&action=browseItem&HTMLon=0" target="main">'.displayPics("HTML_on.png", "HTML").'</a>';
  58.     else $capHTML = '<a href="main.php?dbsel='.$GLOBALS["dbsel"].'&'.$linkItem.'&action=browseItem&HTMLon=1" target="main">'.displayPics("HTML_off.png", "Texte").'</a>';
  59.  
  60. //    $DbGrid->addCaption("top", '<div><div style="float: left">'.$caption.str_repeat(' ', 3).$capHTML.'</div>'.$showTime.'</div>');
  61.     $capTable = '<div><div style="float: left">'.$caption.str_repeat(' ', 3).$capHTML.'</div>'.$showTime.'</div>';
  62.     
  63.     $DbGrid->build();
  64.     
  65.     if(!isset($noDisplay) || !$noDisplay) displayQuery($DbGrid->getRealQuery());
  66.     if($DbGrid->getNbRecord()) {
  67.  
  68.         echo '<table align="center"><tr><td>'.$capTable.'</td></tr><tr><td>';
  69.         $DbGrid->show();
  70.         echo '<!-- browse.php -->'."\n";
  71.         echo '<div class="BrowseOptions">';
  72.         if(empty($view) && (!$workDb->isReadOnly() && displayCondition("properties"))){
  73.             echo '<hr width="60%">
  74.                     <form name="addView" action="main.php?dbsel='.$GLOBALS['dbsel'].'" method="POST" target="main">
  75.                     <table align="center" class="BrowseOption"><tr><td>
  76.                      » '.$GLOBALS['traduct']->get(97).'
  77.                     <input type="text" class="text" name="ViewName" value="" /> '.$GLOBALS['traduct']->get(98).'
  78.                     <input class="button" type="submit" value="'.$GLOBALS['traduct']->get(69).'" />
  79.                     </td></tr></table>
  80.                     <input type="hidden" name="action" value="save" />
  81.                     <input type="hidden" name="ViewProp" value="'.urlencode($DisplayQuery).'" />
  82.                     </form>';
  83.         }
  84.         if($accessResult && (displayCondition('export'))){
  85.             echo '<hr width="60%">';
  86.             echo '    <table class="BrowseOption"><tr><td>
  87.                     <a href="main.php?dbsel='.$GLOBALS['dbsel'].'&table='.$GLOBALS['table'].'&queryExport='.urlencode($DisplayQuery).'&action=export" class="Browse"> » '.$GLOBALS['traduct']->get(76).'</a>
  88.                     </td></tr></table>';
  89.         }
  90.         echo '</div>';
  91.         echo '</td></tr></table>';
  92.         
  93.     }
  94.     if(!$DbGrid->getNbRecord()) $SQLiteQuery->getForm($DbGrid->getRealQuery());
  95. } else {
  96.     if(!$SQLiteQuery->multipleQuery && (!isset($noDisplay) || !$noDisplay)) displayQuery($DisplayQuery, true, $SQLiteQuery->changesLine);
  97.     else $SQLiteQuery->DisplayMultipleResult();
  98.     if(!empty($DisplayQuery) && $error) {
  99.         $withForm = true;
  100.         $errorMessage = "";
  101.         if(is_array($SQLiteQuery->lineError)) $errorMessage = $GLOBALS["traduct"]->get(99)." : ".implode(", ", $SQLiteQuery->lineError)."<br>";
  102.         $errorMessage .= $SQLiteQuery->errorMessage;
  103.         displayError($errorMessage);
  104.     }
  105.     if($withForm && WITH_AUTH && isset($SQLiteManagerAuth) &&  !$SQLiteManagerAuth->getAccess("execSQL")) $withForm = false;
  106.     if($withForm) $SQLiteQuery->getForm($DisplayQuery);
  107. }
  108. ?>
  109.  
  110. </body>
  111. </html>
  112.