Go to most recent revision | Blame | Last modification | View Log | RSS feed
<?
//------------------------------------------------------------------------------
// FICHIER : $RCSfile: adsi_squelette.fonct.php,v $
// AUTEUR : $Author: jpm $
// VERSION : $Revision: 1.1 $
// DATE : $Date: 2004-06-16 14:28:53 $
//------------------------------------------------------------------------------
// GSite - Web site management in PHP - gus module
//
// 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 updatePresentation ($db, $link, $project, $locale,
$baseURL, $baseURLjs, $baseHidden,
$managedProject) {
//----------------------------------------------------------------------------
// JavaScript.
$not_empty = gs_getLabel ($db, $link, 'not_empty', $locale, false);
js_register ('validateAndSubmit',
" function validateAndSubmit (oForm) {"."\n".
" if (oForm.guspresP_LOOK_NAME.value == '') {"."\n".
" alert ('P_LOOK_NAME : $not_empty');"."\n".
" return;"."\n".
" }"."\n".
" "."\n".
" oForm.submit ();"."\n".
" }"."\n"
);
//----------------------------------------------------------------------------
// Query project : get presentation.
$query = "select * from $db.PROJECT where GS_PROJECT='$managedProject'";
$result = mysql_query ($query, $link);
if (! $result) {
die ("Unable to perform query ($query / " . mysql_error ($link) . ")");
}
$button = '';
$text = '';
$pres = '';
$msg = '';
$title = '';
if (mysql_num_rows ($result) != 1) {
//--------------------------------------------------------------------------
// Unknown project.
$msg = gs_getLabel ($db, $link, 'gus_unknown_prj', $locale, 'gus')." ($managedProject)";
$button =
gs_genericButtons ($db, $link, $locale,
array (
array (
'text' => 'back',
'appl' => 'gsite',
'url' => $baseURL)),
false);
} else {
//--------------------------------------------------------------------------
// Get row.
$row = mysql_fetch_object ($result);
$pres = $row->GS_PRESENTATION;
//--------------------------------------------------------------------------
// Get presentation.
$query = "select * from $db.".$pres."_PRESENTATION where P_LOOK_NAME='$row->GS_LOOK_NAME'";
$PRESresult = mysql_query ($query, $link);
if (! $PRESresult) {
die ("Unable to perform query ($query / " . mysql_error ($link) . ")");
}
$numFields = mysql_num_fields ($PRESresult);
//-- We already have a presentation ?
$title .= ' : ';
if (mysql_num_rows ($PRESresult) == 0) {
$title .= gs_getLabel ($db, $link, 'gus_title5_not_exist', $locale, 'gus');
} else {
$title .= gs_getLabel ($db, $link, 'gus_title5_exist', $locale, 'gus');
}
//-- Get infos about fields.
$metaArray = array ();
for ($i = 0; $i < $numFields; $i++) {
$metaArray[$i] = mysql_fetch_field ($PRESresult);
}
//-- Get result.
$PRESrow = mysql_fetch_row ($PRESresult);
$dataArray = array ();
for ($i = 0; $i < $numFields; $i++) {
$dataArray[$i] = $PRESrow[$i];
}
//--------------------------------------------------------------------------
// Dump form.
$text = '';
$text .= "\n".'<FORM name="gform" action="document.php" method="post">';
$text .= "\n".' <TABLE cellspacing="0" cellpadding="0" border="0" summary="">';
for ($i = 0; $i < $numFields; $i++) {
$text .= "\n".' <TR>';
$text .= "\n".' <TD class="gusLabel">'.htmlentities ($metaArray[$i]->name).' : </TD>';
$text .= "\n".' <TD class="gusInput"><INPUT';
$text .= "\n".' class="gusInput"';
$text .= "\n".' type="text"';
$text .= "\n".' name="guspres'.$metaArray[$i]->name.'"';
$text .= "\n".' size="48"';
$text .= "\n".' maxlength="255"';
$text .= "\n".' value="'.htmlentities ((($dataArray[$i] == '') && ($metaArray[$i]->name == 'P_LOOK_NAME')
? $row->GS_LOOK_NAME
: $dataArray[$i])).'"></TD>';
$text .= "\n".' </TR>';
}
$text .= "\n".' <TR>';
$text .= "\n".' <TD align="center" colspan="2"><TABLE border="0" summary="" width="100%" cellpadding="0" cellspacing="0">';
$text .= "\n".' <TR>';
$text .= "\n".' <TD align="center"><INPUT type="image" src="Local/icons/validate.gif"></TD>';
$text .= "\n".' <TD align="center"><A href="'.$baseURL.'"><IMG '.
'border="0" src="Local/icons/cancel.gif" alt="" width="16" height="16"></A></TD>';
$text .= "\n".' </TR>';
$text .= "\n".' </TABLE></TD>';
$text .= "\n".' </TR>';
$text .= "\n".' </TABLE>';
$text .= "\n".' <INPUT type="hidden" name="gusprjid" value="'.htmlentities ($managedProject).'">';
$text .= "\n".' <INPUT type="hidden" name="gusprsid" value="'.htmlentities ($row->GS_LOOK_NAME).'">';
$text .= "\n".' <INPUT type="hidden" name="gusprjpres" value="'.htmlentities ($row->GS_PRESENTATION).'">';
$text .= "\n".' <INPUT type="hidden" name="guscmd" value="commitupdpres">';
$text .= $baseHidden;
$text .= "\n".'</FORM>';
}
mysql_free_result ($result);
//----------------------------------------------------------------------------
// Build page.
$title =
$managedProject.
(empty ($pres) ? '' : ' / '.$pres).
$title;
return
buildPage (
$button, '',
$title,
$text,
$msg);
}
//==============================================================================
//==============================================================================
function commitUpdatePresentation ($db, $link, $project, $locale,
$userLevel, $adminProject,
$baseURL, $baseURLjs) {
global $gusprjid;
global $gusprsid;
global $gusprjpres;
global $guspresP_LOOK_NAME;
//----------------------------------------------------------------------------
// Look name set ?
$msg = '';
if (isset ($guspresP_LOOK_NAME) && ($guspresP_LOOK_NAME != '')) {
//--------------------------------------------------------------------------
// This look name already exist ?
$query = "select * from $db.$gusprjpres"."_PRESENTATION where P_LOOK_NAME='$gusprsid'";
$result = mysql_query ($query, $link);
if (! $result) {
die ("Unable to perform query ($query / " . mysql_error ($link) . ")");
}
$presExist = (mysql_num_rows ($result) == 1);
mysql_free_result ($result);
//--------------------------------------------------------------------------
// We have a look name. We get others informations, and build request.
global $HTTP_POST_VARS;
$query = '';
reset ($HTTP_POST_VARS);
while (list ($key, $val) = each ($HTTP_POST_VARS)) {
if (substr ($key, 0, strlen ('guspres')) == 'guspres') {
if ($query != '') $query .= ', ';
$query .= substr ($key, strlen ('guspres'), strlen ($key) - strlen ('guspres'))."='$val'";
}
}
if ($presExist) {
$query = "update $db.$gusprjpres"."_PRESENTATION set ".$query." where P_LOOK_NAME='$gusprsid'";
} else {
$query = "insert into $db.$gusprjpres"."_PRESENTATION set ".$query;
}
//--------------------------------------------------------------------------
// Execute query.
$result = mysql_query ($query, $link);
if (! $result) {
die ("Unable to perform query ($query / " . mysql_error ($link) . ")");
}
} else {
$msg = gs_getLabel ($db, $link, 'gus_pres_noname', $locale, 'gus');
}
//----------------------------------------------------------------------------
// List all projects.
return
listProjects ($db, $link, $project, $locale,
$userLevel, $adminProject,
$baseURL, $baseURLjs,
$msg);
}
//------------------------------------------------------------------------------
// $Log: not supported by cvs2svn $
// Revision 1.1 2003/10/10 09:58:21 alex
// installation
//
// Revision 1.1.1.1 2002/10/02 07:32:21 root
// initialisation site de Tela
//
// Revision 1.2 2002/06/14 07:22:38 lc
// Bug LC0021 : use js_register
//
// Revision 1.1 2002/02/25 16:35:57 lc
// First revision.
//
//-- End of source ------------------------------------------------------------
?>