Subversion Repositories Applications.papyrus

Rev

Blame | Last modification | View Log | RSS feed

<?
//------------------------------------------------------------------------------
// FICHIER : $RCSfile: page.php,v $
// AUTEUR  : $Author: jpm $
// VERSION : $Revision: 1.1 $
// DATE    : $Date: 2004-06-16 15:04:58 $
//------------------------------------------------------------------------------
// GSite - Web site management in PHP - documents application
//
// Copyright (C) 2001 COUDOUNEAU Laurent (lc@gsite.org)
// 
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
// 
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
// 
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------

//==============================================================================
//==============================================================================

function listPages ($db, $project, $locale,
                    $baseURL, $baseURLjs, $baseHidden,
                    $adminProject, $adminLocale, $adminAnnu,
                    $userLevel,
                    $menu1id, $menu2id, $upperid, $docid, $pageid,
                    $doccmd,
                    $menuview, $menu1open, $menu2open, $upperopen, $docopen, $pageopen,
                    $parentDocId) {
  //----------------------------------------------------------------------------
  // Labels.
  
  $cancelLabel  = "Annuler";
  $showLabel    = "Modifier le document";
  $deleteLabel  = "Supprimer";
  $addPageLabel = "Ajouter une page";
  $docLabel     = "Modifier les paragraphes associés";
  
  //----------------------------------------------------------------------------
  // Build full URL.
  
  $fullURL =
    $baseURL.
    '&amp;menuview='.$menuview.
    '&amp;menu1id='.$menu1id.
    '&amp;menu1open='.$menu1open.
    '&amp;menu2id='.$menu2id.
    '&amp;menu2open='.$menu2open.
    '&amp;upperid='.$upperid.
    '&amp;upperopen='.$upperopen;
  
  $fullURLjs =
    $baseURLjs.
    '&menuview='.$menuview.
    '&menu1id='.$menu1id.
    '&menu1open='.$menu1open.
    '&menu2id='.$menu2id.
    '&menu2open='.$menu2open.
    '&upperid='.$upperid.
    '&upperopen='.$upperopen;
  
  //----------------------------------------------------------------------------
  // Javascript.
  
  $goMsg = addslashes ("Supprimer");
  
  js_register ('deletePage',
    "  function deletePage (iDocId, iPageId) {"."\n".
    "    var url = '$fullURLjs'+'&doccmd=delpage&docopen=1&docid='+iDocId+'&pageid='+iPageId;"."\n".
    "    if (window.confirm ('$goMsg')) document.location = url;"."\n".
    "  }"."\n"
  );
  
  js_register ('openUpdatePar',
    "  function openUpdatePar (sURL, iWidth, iHeight) {"."\n".
    "    var sArgs = 'toolbar=0'+"."\n".
    "                ',hotkeys=0'+"."\n".
    "                ',location=1'+"."\n".
    "                ',directories=0'+"."\n".
    "                ',menubar=0'+"."\n".
    "                ',personalbar=0'+"."\n".
    "                ',status=1'+"."\n".
    "                ',scrollbars=1'+"."\n".
    "                ',resizable=1'+"."\n".
    "                ',screenX=150'+"."\n".
    "                ',screenY=20'+"."\n".
    "                ',left=150'+"."\n".
    "                ',top=20'+"."\n".
    "                ',width='+iWidth+"."\n".
    "                ',height='+iHeight;"."\n".
    "\n".
    "    var wWindow = open (sURL, 'updpar', sArgs);"."\n".
    "    wWindow.window.focus ();"."\n".
    "  }"."\n"
  );
  
  js_register ('updatePar',
    "  function updatePar (iDocId, iPageId) {"."\n".
    "    var swidth  = screen.width;"."\n".
    "    var width   = swidth * 0.80;"."\n".
    "    var height  = width  * 0.75;"."\n".
    "\n".
    "    var popsize = 0;"."\n".
    "\n".
    "    if (swidth >=  640) popsize = 0;"."\n".
    "    if (swidth >=  800) popsize = 1;"."\n".
    "    if (swidth >= 1024) popsize = 2;"."\n".
    "    if (swidth >= 1280) popsize = 3;"."\n".
    "    if (swidth >= 1600) popsize = 4;"."\n".
    "\n".
    "    var sURL ="."\n".
    "       'noyau/applications_noyau/documents/docpopup.php'+"."\n".
    "       '?project=$project'+"."\n".
    "       '&module=documents%2Fdocpopup'+"."\n".
    "       '&popsize='+popsize+"."\n".
    "       '&docid='+iDocId+"."\n".
    "       '&pageid='+iPageId+"."\n".
    "       '&admannu=$adminAnnu'+"."\n".
    "       '&admproject=$adminProject'+"."\n".
    "       '&admlocale=$adminLocale';"."\n".
    "    "."\n".
    "    openUpdatePar (sURL, width, height)"."\n".
    "  }"."\n"
  );
  
  //----------------------------------------------------------------------------
  // Begin of pages table.
  
  $outputText = '';
  
  $outputText .= "\n".'<TABLE summary="" cellspacing="3" cellpadding="0" border="0">';
  
  //----------------------------------------------------------------------------
  // Dump admin icons.
  
  $pagesMainIcons = '';
  
  $pagesMainIcons .=
    "\n".
    '<A href="'.$fullURL.'&amp;docid='.$parentDocId.'&amp;docopen=1&amp;doccmd=addpage">'.
    '<IMG src="noyau/applications_noyau/documents/presentations/images/addcross.gif" alt="'.$addPageLabel.'" width="16" height="16" border="0">'.
    '</A>';
  
  $outputText .= "\n".'      <TR>';
  $outputText .= "\n".'        <TD colspan="9" align="left" valign="middle">'.$pagesMainIcons.'</TD>';
  $outputText .= "\n".'      </TR>';
  
  //----------------------------------------------------------------------------
  // Get pages.
  
  $query =
    "select * from GEN_PAGE".
    " where GP_ID_DOCUMENT=$parentDocId".
    " order by GP_ORDRE";
  
  $PAGEresult = $db->query ($query);
  
  if (DB::isError ($PAGEresult)) {
    die ("Unable to perform query ($query / " . $PAGEresult->getMessage() . ")");
  }
  
  //----------------------------------------------------------------------------
  // Dump pages.
  
  while ($PAGErow = $PAGEresult->fetchRow(DB_FETCHMODE_OBJECT)) {
    //--------------------------------------------------------------------------
    // Page open ?
    
    /*
    To manage only one page...
    $pageIsOpen = ($pageopen == 1) && ($PAGErow->GP_ID == $pageid);
    */
    
    $pageIsOpen = true;
    
    //--------------------------------------------------------------------------
    // Get page data.
    
    $title = htmlentities ($PAGErow->GP_TITRE);
    $id    = ($userLevel == level_admin ? '('.$PAGErow->GP_ID.')&nbsp;': '');
    $appl  = htmlentities ($PAGErow->GP_APPLICATION);
    $args1 = htmlentities ($PAGErow->GP_ARGUMENT);
    
    if (strlen ($PAGErow->GP_ARGUMENT) > 40) {
      $args2 = htmlentities (substr ($PAGErow->GP_ARGUMENT, 0, 40)).'&nbsp;...';
    
    } else if ($PAGErow->GP_ARGUMENT == '') {
      $args2 = '(...)';
    
    } else {
      $args2 = $args1;
    }
    
    //-- Icons.
    $icons1 = '&nbsp;&nbsp;';
    $icons2 = '&nbsp;&nbsp;';
    $icons3 = '&nbsp;&nbsp;';
    
    //-- URL to go back to this page.
    $pageHREF =
      $fullURL.
      '&amp;docid='.$parentDocId.
      '&amp;docopen='.$docopen.
      '&amp;pageid='.$PAGErow->GP_ID;
    
    //-- Less or more icon.
    
    $pageOpenHREF = $pageHREF;
    $lessOrMore   = '';
    
    //--------------------------------------------------------------------------
    // Switch page command...
    
    if (($doccmd == 'updpagetitle') && ($PAGErow->GP_ID == $pageid)) {
      //------------------------------------------------------------------------
      // Update page title.
      
      //-- Page title.
      $title =
        '<INPUT type="text" name="page_title" size="30" maxlength="48" value="'.$title.'" class="contentDocument">'.
        '<INPUT type="hidden" name="doccmd" value="commitupdpagetitle">';
      
      //-- Page application.
      $appl =
        '<A href="'.$pageOpenHREF.'&amp;doccmd=updpageappl" class="anchor">'.
        ($PAGErow->GP_APPLICATION == '' ? '(...)' : $appl).
        '</A>';
      
      //-- Application arguments.
      $args =
        '<A href="'.$pageOpenHREF.'&amp;doccmd=updpageargs" class="anchor">'.
        $args2.
        '</A>';
      
      //-- Cancel and update icons.
      $icons1 .=
        '<INPUT type="image" src="Local/icons/validate.gif">';
      
      $icons1 .=
        '<A'."\n".'href="'.$pageOpenHREF.'">'.
        '<IMG src="noyau/applications_noyau/documents/presentations/images/cancel.gif" alt="'.$cancelLabel.'" width="16" height="16" border="0"></A>';
      
    } else if (($doccmd == 'updpageappl') && ($PAGErow->GP_ID == $pageid)) {
      //------------------------------------------------------------------------
      // Update page application.
      
      //-- Page title.
      $title =
        '<A href="'.$pageOpenHREF.'&amp;doccmd=updpagetitle" class="anchor">'.
        ($PAGErow->GP_TITRE == '' ? '(...)' : $title).
        '</A>';
      
      //-- Page application.
      $appl =
        '<INPUT type="text" name="page_appl" size="10" maxlength="32" value="'.$appl.'" class="contentDocument">'.
        '<INPUT type="hidden" name="doccmd" value="commitupdpageappl">';
      
      //-- Application arguments.
      $args =
        '<A href="'.$pageOpenHREF.'&amp;doccmd=updpageargs" class="anchor">'.
        $args2.
        '</A>';
      
      //-- Cancel and update icons.
      $icons2 .=
        '<INPUT type="image" src="noyau/applications_noyau/documents/presentations/images/validate.gif">';
      
      $icons2 .=
        '<A'."\n".'href="'.$pageOpenHREF.'">'.
        '<IMG src="noyau/applications_noyau/documents/presentations/images/cancel.gif" alt="'.$cancelLabel.'" width="16" height="16" border="0"></A>';
      
    } else if (($doccmd == 'updpageargs') && ($PAGErow->GP_ID == $pageid)) {
      //------------------------------------------------------------------------
      // Update page arguments.
      
      //-- Page title.
      $title =
        '<A href="'.$pageOpenHREF.'&amp;doccmd=updpagetitle" class="anchor">'.
        ($PAGErow->GP_TITRE == '' ? '(...)' : $title).
        '</A>';
      
      //-- Page application.
      $appl =
        '<A href="'.$pageOpenHREF.'&amp;doccmd=updpageappl" class="anchor">'.
        ($PAGErow->GP_APPLICATION == '' ? '(...)' : $appl).
        '</A>';
      
      //-- Application arguments.
      $args =
        '<INPUT type="text" name="page_args" size="48" maxlength="255" value="'.$args1.'" class="contentDocument">'.
        '<INPUT type="hidden" name="doccmd" value="commitupdpageargs">';
      
      //-- Cancel and update icons.
      $icons3 .=
        '<INPUT type="image" src="noyau/applications_noyau/documents/presentations/images/validate.gif">';
      
      $icons3 .=
        '<A'."\n".'href="'.$pageOpenHREF.'">'.
        '<IMG src="noyau/applications_noyau/documents/presentations/images/cancel.gif" alt="'.$cancelLabel.'" width="16" height="16" border="0"></A>';
      
    } else {
      //------------------------------------------------------------------------
      // Show page data.
      
      $title =
        '<A href="'.$pageOpenHREF.'&amp;doccmd=updpagetitle" class="anchor">'.
        ($PAGErow->GP_TITRE == '' ? '(...)' : $title).
        '</A>';
      
      $appl =
        '<A href="'.$pageOpenHREF.'&amp;doccmd=updpageappl" class="anchor">'.
        ($PAGErow->GP_APPLICATION == '' ? '(...)' : $appl).
        '</A>';
      
      $args =
        '<A href="'.$pageOpenHREF.'&amp;doccmd=updpageargs" class="anchor">'.
        $args2.
        '</A>';
    }
    
    //--------------------------------------------------------------------------
    // Page admin icons.
    
    $icons4 = '';
    
    if ($pageIsOpen) {
      if ($PAGErow->GP_APPLICATION == 'txt') {
        $icons4 .=
          '<A'."\n".'href="javascript:updatePar ('.$parentDocId.', '.$PAGErow->GP_ID.')">'.
          '<IMG src="noyau/applications_noyau/documents/presentations/images/doc.gif" alt="'.$docLabel.'" width="16" height="16" border="0"></A>';
      
      } else {
        $icons4 .=
          '<IMG src="noyau/applications_noyau/documents/presentations/images/vide.gif" alt="" width="16" height="16" border="0">';
      }
      
      $icons4 .=
        '<A'."\n".'href="'.$pageOpenHREF.'&amp;doccmd=showpage">'.
        '<IMG src="noyau/applications_noyau/documents/presentations/images/see.gif" alt="'.$showLabel.'" width="16" height="16" border="0"></A>';
      
      $icons4 .=
        '<A'."\n".'href="'.$pageOpenHREF.'&amp;doccmd=uppage">'.
        '<IMG src="noyau/applications_noyau/documents/presentations/images/up-arrow.gif" alt="" width="16" height="16" border="0"></A>';
      
      $icons4 .=
        '<A'."\n".'href="'.$pageOpenHREF.'&amp;doccmd=dnpage">'.
        '<IMG src="noyau/applications_noyau/documents/presentations/images/down-arrow.gif" alt="" width="16" height="16" border="0"></A>';
      
      $icons4 .=
        '<A'."\n".'href="javascript:deletePage ('.$parentDocId.', '.$PAGErow->GP_ID.');">'.
        '<IMG src="noyau/applications_noyau/documents/presentations/images/trash.gif" alt="'.$deleteLabel.'" width="16" height="16" border="0"></A>';
    }
    
    //--------------------------------------------------------------------------
    // Dump page data.
    
    $outputText .= "\n".'  <TR>';
    $outputText .= "\n".'    <TD align="left" valign="middle" class="contentDocument">'.$lessOrMore.'</TD>';
    $outputText .= "\n".'    <TD align="left" valign="top" class="contentDocument">'.$title.'</TD>';
    $outputText .= "\n".'    <TD align="left" valign="top" class="contentDocument">'.$icons1.'</TD>';
    $outputText .= "\n".'    <TD align="right" valign="top" class="contentDocument">'.$id.'</TD>';
    $outputText .= "\n".'    <TD align="left" valign="top" class="contentDocument">'.$appl.'</TD>';
    $outputText .= "\n".'    <TD align="left" valign="top" class="contentDocument">'.$icons2.'</TD>';
    $outputText .= "\n".'    <TD align="left" valign="top" class="contentDocument">'.$args.'</TD>';
    $outputText .= "\n".'    <TD align="left" valign="top" class="contentDocument">'.$icons3.'</TD>';
    $outputText .= "\n".'    <TD align="left" valign="top" class="contentDocument">'.$icons4.'</TD>';
    $outputText .= "\n".'  </TR>';
  }
  
  //----------------------------------------------------------------------------
  // End of pages table.
  
  $outputText .= "\n".'</TABLE>';
  
  return $outputText;
}

//==============================================================================
//==============================================================================

function checkPage ($db, $docid, $pageid) {
  //----------------------------------------------------------------------------
  // Get page.
  
  $query = "select * from GEN_PAGE where GP_ID=$pageid";
  
  $PAGEresult = $db->query ($query);
  
  if (DB::isError($PAGEresult)) {
    die ("Unable to perform query ($query / " . $PAGEresult->getMessage() . ")");
  }
  
  $PAGErow = $PAGEresult->fetchRow(DB_FETCHMODE_OBJECT);
  
  $PAGEresult->free() ;
  
  if (! $PAGErow) return null;
  
  //----------------------------------------------------------------------------
  // Page is OK ?
  
  if ($PAGErow->GP_ID_DOCUMENT != $docid) return null;
  
  return $PAGErow;
}

//==============================================================================
//==============================================================================

function addPage ($db,
                  $userLevel,
                  $docid) {
  //----------------------------------------------------------------------------
  // Check document.
  
  $DOCrow = checkDocument ($db, $userLevel, $docid);
  if (! $DOCrow) return;
  
  //----------------------------------------------------------------------------
  // Get max order.
  
  $query =
    "select GP_ORDRE from GEN_PAGE".
    " where GP_ID_DOCUMENT=$docid".
    " order by GP_ORDRE desc".
    " limit 1";
  
  $PAGEresult = $db->query ($query);
  
  if (DB::isError ($PAGEresult)) {
    die ("Unable to perform query ($query / " . $PAGEresult->getMessage() . ")");
  }
  
  $row = $PAGEresult->fetchRow(DB_FETCHMODE_OBJECT);
  
  $maxOrder = ($PAGEresult->numRows() == 0 ? 1 : $row->GP_ORDRE + 1);
  
  $PAGEresult->free();
  
  //----------------------------------------------------------------------------
  // Add page.
  
  $query =
    "insert into GEN_PAGE set ".
    "GP_TITRE='?????'".
    ", GP_ID_DOCUMENT=$docid".
    ", GP_ORDRE=$maxOrder";
  
  $PAGEresult = $db->query ($query);
  
  if (DB::isError ($PAGEresult)) {
    die ("Unable to perform query ($query / " . $PAGEresult->getMessage() . ")");
  }
}
  
//==============================================================================
//==============================================================================

function commitUpdatePageTitle ($db, $userLevel,
                                $docid, $pageid, $pageTitle) {
  //----------------------------------------------------------------------------
  // Check document.
  
  $DOCrow = checkDocument ($db, $userLevel, $docid);
  if (! $DOCrow) return;
  
  //----------------------------------------------------------------------------
  // Check page.
  
  $PAGErow = checkPage ($db, $docid, $pageid);
  if (! $PAGErow) return;
  
  //----------------------------------------------------------------------------
  // Update page title.
  
  $query = "update GEN_PAGE set GP_TITRE='$pageTitle' where GP_ID=$pageid";
  
  $PAGEresult = $db->query ($query);
  
  if (DB::isError ($PAGEresult)) {
    die ("Unable to perform query ($query / " . $PAGEresult->getMessage() . ")");
  }
}

//==============================================================================
//==============================================================================

function commitUpdatePageApplication ($db, $userLevel,
                                      $docid, $pageid, $pageAppl) {
  //----------------------------------------------------------------------------
  // Check document.
  
  $DOCrow = checkDocument ($db, $userLevel, $docid);
  if (! $DOCrow) return;
  
  //----------------------------------------------------------------------------
  // Check page.
  
  $PAGErow = checkPage ($db, $docid, $pageid);
  if (! $PAGErow) return;
  
  //----------------------------------------------------------------------------
  // Update page title.
  
  $query = "update GEN_PAGE set GP_APPLICATION='$pageAppl' where GP_ID=$pageid";
  
  $PAGEresult = $db->query ($query);
  
  if (DB::isError ($PAGEresult)) {
    die ("Unable to perform query ($query / " . $PAGEresult->getMessage() . ")");
  }
}

//==============================================================================
//==============================================================================

function commitUpdatePageArguments ($db, $userLevel,
                                    $docid, $pageid, $pageArgs) {
  //----------------------------------------------------------------------------
  // Check document.
  
  $DOCrow = checkDocument ($db, $userLevel, $docid);
  if (! $DOCrow) return;
  
  //----------------------------------------------------------------------------
  // Check page.
  
  $PAGErow = checkPage ($db, $docid, $pageid);
  if (! $PAGErow) return;
  
  //----------------------------------------------------------------------------
  // Update page title.
  
  $query = "update GEN_PAGE set GP_ARGUMENT='$pageArgs' where GP_ID=$pageid";
  
  $PAGEresult = $db->query ($query);
  
  if (DB::isError ($PAGEresult)) {
    die ("Unable to perform query ($query / " . $PAGEresult->getMessage() . ")");
  }
}

//==============================================================================
//==============================================================================

function movePage ($db, $userLevel,
                   $docid, $pageid,
                   $up) {
  //----------------------------------------------------------------------------
  // Check document.
  
  $DOCrow = checkDocument ($db, $userLevel, $docid);
  if (! $DOCrow) return;
  
  //----------------------------------------------------------------------------
  // Check page.
  
  $PAGErow = checkPage ($db, $docid, $pageid);
  if (! $PAGErow) return;
  
  //----------------------------------------------------------------------------
  // Get previous page.
  
  $query =
    "select * from GEN_PAGE".
    " where GP_ID_DOCUMENT=$docid".
    ($up
    ? " and GP_ORDRE < $PAGErow->GP_ORDRE order by GP_ORDRE desc"
    : " and GP_ORDRE > $PAGErow->GP_ORDRE order by GP_ORDRE asc");
  
  $PAGEresult = $db->query ($query);
  
  if (DB::isError ($PAGEresult)) {
    die ("Unable to perform query ($query / " . $PAGEresult->getMessage() . ")");
  }
  
  $NEXTPAGErow = $PAGEresult->fetchRow(DB_FETCHMODE_OBJECT);
  
  $PAGEresult->free() ;
  
  //----------------------------------------------------------------------------
  // Update pages.
  
  if (! $NEXTPAGErow) return;
  
  $query =
    "update GEN_PAGE ".
    "set GP_ORDRE=$NEXTPAGErow->GP_ORDRE".
    " where GP_ID=$PAGErow->GP_ID";
  
  $result = $db->query ($query);
  
  if (DB::isError ($result)) {
    die ("Unable to perform query ($query / " . $result->getMessage() . ")");
  }
  
  $query =
    "update GEN_PAGE ".
    "set GP_ORDRE=$PAGErow->GP_ORDRE".
    " where GP_ID=$NEXTPAGErow->GP_ID";
  
  $result = $db->query ($query);
  
  if (DB::isError ($result)) {
    die ("Unable to perform query ($query / " . $result->getMessage() . ")");
  }
}

//==============================================================================
//==============================================================================

function deletePage ($db, $locale,
                     $userLevel,
                     $docid, $pageid) {
  //----------------------------------------------------------------------------
  // Check document.
  
  $DOCrow = checkDocument ($db, $userLevel, $docid);
  if (! $DOCrow) return;
  
  //----------------------------------------------------------------------------
  // Check page.
  
  $PAGErow = checkPage ($db, $docid, $pageid);
  if (! $PAGErow) return;
  
  //----------------------------------------------------------------------------
  // We have linked paragraphs ?
  
  $query =
    "select count(P_INDEX) as COUNT ".
    "from txt_PARAGRAPH ".
    "where P_PAGE=$PAGErow->GP_ID";
  
  $result = $db->query ($query);
  
  if (DB::isError ($result)) {
    die ("Unable to perform query ($query / " . $result->getMessage() . ")");
  }
  
  $row = $result->fetchRow(DB_FETCHMODE_OBJECT);
  
  if ($row && ($row->COUNT > 0)) {
    return "Il reste des paragraphes attachés à cette page";
  }
  
  //----------------------------------------------------------------------------
  // Delete page.
  
  $query = "delete from GEN_PAGE where GP_ID=$PAGErow->GP_ID";
  
  $result = $db->query ($query);
  
  if (DB::isError ($result)) {
    die ("Unable to perform query ($query / " . $result->getMessage() . ")");
  }
  
  return '';
}

//==============================================================================
//==============================================================================

function showPage ($db, $locale,
                   $baseURL, $baseURLjs, $baseHidden,
                   $userLevel,
                   $menu1id, $menu2id, $upperid, $docid, $pageid,
                   $menuview, $menu1open, $menu2open, $upperopen, $docopen, $pageopen) {
  //----------------------------------------------------------------------------
  // Labels.
  
  $cancelLabel = "Supprimer";
  
  //----------------------------------------------------------------------------
  // Check document.
  
  $DOCrow = checkDocument ($db, $userLevel, $docid);
  if (! $DOCrow) return '';
  
  //----------------------------------------------------------------------------
  // Check page.
  
  $PAGErow = checkPage ($db, $docid, $pageid);
  if (! $PAGErow) return '';
  
  //----------------------------------------------------------------------------
  // Dump form.
  
  $outputText = '';
  
  $outputText .= "\n".'<TR>';
  $outputText .= "\n".'  <TD>';
  $outputText .= "\n".'    <FORM name="updform" action="index.php" method="POST">';
  $outputText .= "\n".'      <TABLE summary="" cellspacing="0" cellpadding="0" border="0" align="center">';
  
  $titleLabel = "Titre";
  $applLabel  = "Application";
  $argsLabel  = "Arguments";
  $setLabel   = "Set";
  $ndxLabel   = "Indexé";
  
  $outputText .= "\n".'<TR>';
  $outputText .= "\n".'  <TD class="contentLabel">'.$titleLabel.'&nbsp;:&nbsp;</TD>';
  $outputText .= "\n".'  <TD class="contentInput"><INPUT';
  $outputText .= "\n".'     class="contentInput" type="text" name="page_title" size="48" maxlength="48"';
  $outputText .= "\n".'     value="'.htmlentities ($PAGErow->GP_TITRE).'"></TD>';
  $outputText .= "\n".'</TR>';
  
  $outputText .= "\n".'<TR>';
  $outputText .= "\n".'  <TD class="contentLabel">'.$applLabel.'&nbsp;:&nbsp;</TD>';
  $outputText .= "\n".'  <TD class="contentInput"><INPUT';
  $outputText .= "\n".'     class="contentInput" type="text" name="page_appl" size="32" maxlength="32"';
  $outputText .= "\n".'     value="'.htmlentities ($PAGErow->GP_APPLICATION).'"></TD>';
  $outputText .= "\n".'</TR>';
  
  $outputText .= "\n".'<TR>';
  $outputText .= "\n".'  <TD class="contentLabel">'.$argsLabel.'&nbsp;:&nbsp;</TD>';
  $outputText .= "\n".'  <TD class="contentInput"><TEXTAREA';
  $outputText .= "\n".'     class="contentInput" name="page_args" rows="10" cols="64">'.htmlentities ($PAGErow->GP_ARGUMENT).'</TEXTAREA></TD>';
  $outputText .= "\n".'</TR>';
  
  $outputText .= "\n".'<TR>';
  $outputText .= "\n".'  <TD class="contentLabel">'.$setLabel.'&nbsp;:&nbsp;</TD>';
  $outputText .= "\n".'  <TD class="contentInput"><INPUT';
  $outputText .= "\n".'     class="contentInput" type="text" name="page_set" size="32" maxlength="32"';
  $outputText .= "\n".'     value="'.htmlentities ($PAGErow->GP_SET).'"></TD>';
  $outputText .= "\n".'</TR>';
  
  $outputText .= "\n".'<TR>';
  $outputText .= "\n".'  <TD class="contentLabel">'.$ndxLabel.'&nbsp;:&nbsp;</TD>';
  $outputText .= "\n".'  <TD class="contentInput"><INPUT';
  $outputText .= "\n".'     class="contentInput" type="checkbox" name="page_ndx"';
  if ($PAGErow->GP_INDEXE) $outputText .= "\n".'     checked';
  $outputText .= "\n".'     ></TD>';
  $outputText .= "\n".'</TR>';
  
  //----------------------------------------------------------------------------
  // Icons.
  
  $outputText .= "\n".'<TR><TD colspan="2">&nbsp;</TD></TR>';
  
  $closeURL =
    $baseURL.
    '&amp;menuview='.$menuview.
    '&amp;menu1id='.$menu1id.
    '&amp;menu1open='.$menu1open.
    '&amp;menu2id='.$menu2id.
    '&amp;menu2open='.$menu2open.
    '&amp;upperid='.$upperid.
    '&amp;upperopen='.$upperopen.
    '&amp;docid='.$docid.
    '&amp;pageid='.$pageid.
    '&amp;docopen='.$docopen.
    '&amp;pageopen='.$pageopen;
  
  $goIcon     = '<INPUT type="image" src="noyau/applications_noyau/documents/presentations/images/validate.gif">';
  $cancelIcon = '<A href="'.$closeURL.'">'.
                '<IMG src="noyau/applications_noyau/documents/presentations/images/cancel.gif" alt="'.$cancelLabel.'" width="16" height="16" border="0">'.
                '</A>';
  
  $outputText .= "\n".'<TR>';
  $outputText .= "\n".'  <TD colspan="2" align="center"><TABLE summary="" width="100%" border="0" cellpadding="0" cellspacing="0">';
  $outputText .= "\n".'      <TR>';
  $outputText .= "\n".'        <TD align="center">'.$goIcon.'</TD>';
  $outputText .= "\n".'        <TD align="center">'.$cancelIcon.'</TD>';
  $outputText .= "\n".'      </TR>';
  $outputText .= "\n".'    </TABLE></TD>';
  $outputText .= "\n".'</TR>';
  
  $outputText .= "\n".'      </TABLE>';
  
  //----------------------------------------------------------------------------
  // Hidden values.
  
  $outputText .= "\n".'  <INPUT type="hidden" name="menuview"  value="'.$menuview.'">';
  $outputText .= "\n".'  <INPUT type="hidden" name="menu1id"   value="'.$menu1id.'">';
  $outputText .= "\n".'  <INPUT type="hidden" name="menu2id"   value="'.$menu2id.'">';
  $outputText .= "\n".'  <INPUT type="hidden" name="upperid"   value="'.$upperid.'">';
  $outputText .= "\n".'  <INPUT type="hidden" name="docid"     value="'.$docid.'">';
  $outputText .= "\n".'  <INPUT type="hidden" name="pageid"    value="'.$pageid.'">';
  $outputText .= "\n".'  <INPUT type="hidden" name="menu1open" value="'.$menu1open.'">';
  $outputText .= "\n".'  <INPUT type="hidden" name="menu2open" value="'.$menu2open.'">';
  $outputText .= "\n".'  <INPUT type="hidden" name="upperopen" value="'.$upperopen.'">';
  $outputText .= "\n".'  <INPUT type="hidden" name="docopen"   value="'.$docopen.'">';
  $outputText .= "\n".'  <INPUT type="hidden" name="pageopen"  value="'.$pageopen.'">';
  $outputText .= "\n".'  <INPUT type="hidden" name="doccmd"   value="commitupdpage">';
  $outputText .= $baseHidden;
  
  $outputText .= "\n".'    </FORM>';
  $outputText .= "\n".'  </TD>';
  $outputText .= "\n".'</TR>';
  
  return $outputText;
}

//==============================================================================
//==============================================================================

function commitUpdatePage ($db, $userLevel,
                           $docid, $pageid) {
  //----------------------------------------------------------------------------
  // Check document.
  
  $DOCrow = checkDocument ($db, $userLevel, $docid);
  if (! $DOCrow) return;
  
  //----------------------------------------------------------------------------
  // Check page.
  
  $PAGErow = checkPage ($db, $docid, $pageid);
  if (! $PAGErow) return;
  
  //----------------------------------------------------------------------------
  // Update page.
  
  global $page_title;
  global $page_appl;
  global $page_args;
  global $page_set;
  global $page_ndx;
  
  $pageindexed = (isset ($page_ndx) ? 1 : 0);
  
  $query =
    "update GEN_PAGE ".
    "set GP_TITRE='$page_title'".
    ", GP_APPLICATION='$page_appl'".
    ", GP_ARGUMENT='$page_args'".
    ", GP_SET='$page_set'".
    ", GP_INDEXE=$pageindexed".
    " where GP_ID=$pageid";
  
  $result = $db->query ($query);
  
  if (DB::isError ($result)) {
    die ("Unable to perform query ($query / " . $result->getMessage() . ")");
  }
}


?>