Remplacer espace par tiret dans formulaire
milllo
Messages postés
19
Date d'inscription
Statut
Membre
Dernière intervention
-
Brachior Messages postés 613 Date d'inscription Statut Membre Dernière intervention -
Brachior Messages postés 613 Date d'inscription Statut Membre Dernière intervention -
Bonjour,
Bonjour,
Ci dessous je vous montre le code de mon formulaire de soumission de sites.
Je souhaiterais que l'utilisateur qui soumet un site, losqu'il met les tags dans le champ de texte >> "input type="text" id="tags" name="tags" les espaces soient remplacé automatiquement par des tirets ( - ), et seulement pour la ligne type="text des tags .
Je suis débutant si vous pouvez m'aider en montrant l'endroit ou je doit faire les modifications Merci
Voici le code editbookmarks.tpl.php de mon formulaire :
<?php
$this->includeTemplate($GLOBALS['top_include']);
$accessPublic = '';
$accessShared = '';
$accessPrivate = '';
switch ($row['bStatus']) {
case 0 :
$accessPublic = ' selected="selected"';
break;
case 1 :
$accessShared = ' selected="selected"';
break;
case 2 :
$accessPrivate = ' selected="selected"';
break;
}
?>
<script type="text/javascript">
window.onload = function() {
document.getElementById("address").focus();
}
</script>
<form action="<?php echo $formaction; ?>" method="post">
<table>
<tr>
<th align="left"><?php echo T_('Address'); ?></th>
<td><input type="text" id="address" name="address" size="75" maxlength="65535" value="<?php echo filter($row['bAddress'], 'xml'); ?>" onblur="useAddress(this)" /></td>
<td>← <?php echo T_('Required'); ?></td>
</tr>
<tr>
<th align="left"><?php echo T_('Title'); ?></th>
<td><input type="text" id="titleField" name="title" size="75" maxlength="255" value="<?php echo filter($row['bTitle'], 'xml'); ?>" onkeypress="this.style.backgroundImage = 'none';" /></td>
<td>← <?php echo T_('Required'); ?></td>
</tr>
<tr>
<th align="left"><?php echo T_('Description'); ?></th>
<td><input type="text" name="description" size="75" maxlength="255" value="<?php echo filter($row['bDescription'], 'xml'); ?>" /></td>
<td></td>
</tr>
<tr>
<th align="left"><?php echo T_('Tags'); ?></th>
<td><input type="text" id="tags" name="tags" size="75" value="<?php echo filter(implode(', ', $row['tags']), 'xml'); ?>" /></td>
<td>← <?php echo T_('Comma-separated'); ?></td>
</tr>
<tr>
<th></th>
<td align="right"><small><?php echo T_('Note: use ">" to include one tag in another. e.g.: europe>france>paris')?><small></td>
</tr>
<tr>
<th></th>
<td align="right"><small><?php echo T_('Note: use "=" to make synonym two tags. e.g.: france=frenchcountry')?><small></td>
</tr>
<tr>
<th align="left"><?php echo T_('Privacy'); ?></th>
<td>
<select name="status">
<option value="0"<?php echo $accessPublic ?>><?php echo T_('Public'); ?></option>
<option value="1"<?php echo $accessShared ?>><?php echo T_('Shared with Watch List'); ?></option>
<option value="2"<?php echo $accessPrivate ?>><?php echo T_('Private'); ?></option>
</select>
</td>
<td></td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="submitted" value="<?php echo $btnsubmit; ?>" />
<?php
if ($showdelete) {
?>
<input type="submit" name="delete" value="<?php echo T_('Delete Bookmark'); ?>" />
<?php
}
if ($popup) {
?>
<input type="hidden" name="popup" value="1" />
<?php
} elseif ($referrer) {
?>
<input type="hidden" name="referrer" value="<?php echo $referrer; ?>" />
<?php
}
?>
</td>
<td></td>
</tr>
</table>
</form>
<?php
// Dynamic tag selection
$this->includeTemplate('dynamictags.inc');
// Bookmarklets and import links
if (empty($_REQUEST['popup']) && !$showdelete) {
?>
<h3><?php echo T_('Bookmarklet'); ?></h3>
<p><?php echo sprintf(T_("Drag one of the following bookmarklets to your browser's bookmarks and click it whenever you want to add the page you are on to %s"), $GLOBALS['sitename']); ?>:</p>
<script type="text/javascript">
var selection = '';
if (window.getSelection) {
selection = 'window.getSelection()';
} else if (document.getSelection) {
selection = 'document.getSelection()';
} else if (document.selection) {
selection = 'document.selection.createRange().text';
}
document.write('<ul>');
document.write('<li><a href="javascript:x=document;a=encodeURIComponent(x.location.href);t=encodeURIComponent(x.title);d=encodeURIComponent('+selection+');location.href=\'<?php echo createURL('bookmarks', $GLOBALS['user']); ?>?action=add&address=\'+a+\'&title=\'+t+\'&description=\'+d;void 0;"><?php echo sprintf(T_('Post to %s'), $GLOBALS['sitename']); ?><\/a><\/li>');
document.write('<li><a href="javascript:x=document;a=encodeURIComponent(x.location.href);t=encodeURIComponent(x.title);d=encodeURIComponent('+selection+');open(\'<?php echo createURL('bookmarks', $GLOBALS['user']); ?>?action=add&popup=1&address=\'+a+\'&title=\'+t+\'&description=\'+d,\'<?php echo $GLOBALS['sitename']; ?>\',\'modal=1,status=0,scrollbars=1,toolbar=0,resizable=1,width=730,height=465,left=\'+(screen.width-730)/2+\',top=\'+(screen.height-425)/2);void 0;"><?php echo sprintf(T_('Post to %s (Pop-up)'), $GLOBALS['sitename']); ?><\/a><\/li>');
document.write('<\/ul>');
</script>
<h3><?php echo T_('Import'); ?></h3>
<ul>
<li><a href="<?php echo createURL('importNetscape'); ?>"><?php echo T_('Import bookmarks from bookmark file'); ?></a> (<?php echo T_('Internet Explorer, Mozilla Firefox and Netscape'); ?>)</li>
<li><a href="<?php echo createURL('import'); ?>"><?php echo T_('Import bookmarks from del.icio.us'); ?></a></li>
</ul>
<?php
}
$this->includeTemplate($GLOBALS['bottom_include']);
?>
Et voici la partis PHP du formulaire edit.php :
<?php
require_once('header.inc.php');
$bookmarkservice = & ServiceFactory :: getServiceInstance('BookmarkService');
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
$userservice = & ServiceFactory :: getServiceInstance('UserService');
// Header variables
$tplVars['subtitle'] = T_('Edit Bookmark');
$tplVars['loadjs'] = true;
list ($url, $bookmark) = explode('/', $_SERVER['PATH_INFO']);
if (!($row = $bookmarkservice->getBookmark(intval($bookmark), true))) {
$tplVars['error'] = sprintf(T_('Bookmark with id %s not was not found'), $bookmark);
$templateservice->loadTemplate('error.404.tpl', $tplVars);
exit();
} else {
if (!$bookmarkservice->editAllowed($row)) {
$tplVars['error'] = T_('You are not allowed to edit this bookmark');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();
} else if ($_POST['submitted']) {
if (!$_POST['title'] || !$_POST['address']) {
$tplVars['error'] = T_('Your bookmark must have a title and an address');
} else {
// Update bookmark
$bId = intval($bookmark);
$address = trim($_POST['address']);
$title = trim($_POST['title']);
$description = trim($_POST['description']);
$status = intval($_POST['status']);
$tags = trim($_POST['tags']);
$logged_on_user = $userservice->getCurrentUser();
if (!$bookmarkservice->updateBookmark($bId, $address, $title, $description, $status, $tags)) {
$tplvars['error'] = T_('Error while saving your bookmark');
} else {
if (isset($_POST['popup'])) {
$tplVars['msg'] = (isset($_POST['popup'])) ? '<script type="text/javascript">window.close();</script>' : T_('Bookmark saved');
} elseif (isset($_POST['referrer'])) {
header('Location: '. $_POST['referrer']);
} else {
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
}
}
}
} else {
if ($_POST['delete']) {
// Delete bookmark
if ($bookmarkservice->deleteBookmark($bookmark)) {
$logged_on_user = $userservice->getCurrentUser();
if (isset($_POST['referrer'])) {
header('Location: '. $_POST['referrer']);
} else {
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
}
exit();
} else {
$tplVars['error'] = T_('Failed to delete bookmark');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();
}
}
}
$tplVars['popup'] = (isset($_GET['popup'])) ? $_GET['popup'] : null;
$tplVars['row'] =& $row;
$tplVars['formaction'] = createURL('edit', $bookmark);
$tplVars['btnsubmit'] = T_('Save Changes');
$tplVars['showdelete'] = true;
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
$templateservice->loadTemplate('editbookmark.tpl', $tplVars);
}
?>
Merci d'avance
Bonjour,
Ci dessous je vous montre le code de mon formulaire de soumission de sites.
Je souhaiterais que l'utilisateur qui soumet un site, losqu'il met les tags dans le champ de texte >> "input type="text" id="tags" name="tags" les espaces soient remplacé automatiquement par des tirets ( - ), et seulement pour la ligne type="text des tags .
Je suis débutant si vous pouvez m'aider en montrant l'endroit ou je doit faire les modifications Merci
Voici le code editbookmarks.tpl.php de mon formulaire :
<?php
$this->includeTemplate($GLOBALS['top_include']);
$accessPublic = '';
$accessShared = '';
$accessPrivate = '';
switch ($row['bStatus']) {
case 0 :
$accessPublic = ' selected="selected"';
break;
case 1 :
$accessShared = ' selected="selected"';
break;
case 2 :
$accessPrivate = ' selected="selected"';
break;
}
?>
<script type="text/javascript">
window.onload = function() {
document.getElementById("address").focus();
}
</script>
<form action="<?php echo $formaction; ?>" method="post">
<table>
<tr>
<th align="left"><?php echo T_('Address'); ?></th>
<td><input type="text" id="address" name="address" size="75" maxlength="65535" value="<?php echo filter($row['bAddress'], 'xml'); ?>" onblur="useAddress(this)" /></td>
<td>← <?php echo T_('Required'); ?></td>
</tr>
<tr>
<th align="left"><?php echo T_('Title'); ?></th>
<td><input type="text" id="titleField" name="title" size="75" maxlength="255" value="<?php echo filter($row['bTitle'], 'xml'); ?>" onkeypress="this.style.backgroundImage = 'none';" /></td>
<td>← <?php echo T_('Required'); ?></td>
</tr>
<tr>
<th align="left"><?php echo T_('Description'); ?></th>
<td><input type="text" name="description" size="75" maxlength="255" value="<?php echo filter($row['bDescription'], 'xml'); ?>" /></td>
<td></td>
</tr>
<tr>
<th align="left"><?php echo T_('Tags'); ?></th>
<td><input type="text" id="tags" name="tags" size="75" value="<?php echo filter(implode(', ', $row['tags']), 'xml'); ?>" /></td>
<td>← <?php echo T_('Comma-separated'); ?></td>
</tr>
<tr>
<th></th>
<td align="right"><small><?php echo T_('Note: use ">" to include one tag in another. e.g.: europe>france>paris')?><small></td>
</tr>
<tr>
<th></th>
<td align="right"><small><?php echo T_('Note: use "=" to make synonym two tags. e.g.: france=frenchcountry')?><small></td>
</tr>
<tr>
<th align="left"><?php echo T_('Privacy'); ?></th>
<td>
<select name="status">
<option value="0"<?php echo $accessPublic ?>><?php echo T_('Public'); ?></option>
<option value="1"<?php echo $accessShared ?>><?php echo T_('Shared with Watch List'); ?></option>
<option value="2"<?php echo $accessPrivate ?>><?php echo T_('Private'); ?></option>
</select>
</td>
<td></td>
</tr>
<tr>
<td></td>
<td>
<input type="submit" name="submitted" value="<?php echo $btnsubmit; ?>" />
<?php
if ($showdelete) {
?>
<input type="submit" name="delete" value="<?php echo T_('Delete Bookmark'); ?>" />
<?php
}
if ($popup) {
?>
<input type="hidden" name="popup" value="1" />
<?php
} elseif ($referrer) {
?>
<input type="hidden" name="referrer" value="<?php echo $referrer; ?>" />
<?php
}
?>
</td>
<td></td>
</tr>
</table>
</form>
<?php
// Dynamic tag selection
$this->includeTemplate('dynamictags.inc');
// Bookmarklets and import links
if (empty($_REQUEST['popup']) && !$showdelete) {
?>
<h3><?php echo T_('Bookmarklet'); ?></h3>
<p><?php echo sprintf(T_("Drag one of the following bookmarklets to your browser's bookmarks and click it whenever you want to add the page you are on to %s"), $GLOBALS['sitename']); ?>:</p>
<script type="text/javascript">
var selection = '';
if (window.getSelection) {
selection = 'window.getSelection()';
} else if (document.getSelection) {
selection = 'document.getSelection()';
} else if (document.selection) {
selection = 'document.selection.createRange().text';
}
document.write('<ul>');
document.write('<li><a href="javascript:x=document;a=encodeURIComponent(x.location.href);t=encodeURIComponent(x.title);d=encodeURIComponent('+selection+');location.href=\'<?php echo createURL('bookmarks', $GLOBALS['user']); ?>?action=add&address=\'+a+\'&title=\'+t+\'&description=\'+d;void 0;"><?php echo sprintf(T_('Post to %s'), $GLOBALS['sitename']); ?><\/a><\/li>');
document.write('<li><a href="javascript:x=document;a=encodeURIComponent(x.location.href);t=encodeURIComponent(x.title);d=encodeURIComponent('+selection+');open(\'<?php echo createURL('bookmarks', $GLOBALS['user']); ?>?action=add&popup=1&address=\'+a+\'&title=\'+t+\'&description=\'+d,\'<?php echo $GLOBALS['sitename']; ?>\',\'modal=1,status=0,scrollbars=1,toolbar=0,resizable=1,width=730,height=465,left=\'+(screen.width-730)/2+\',top=\'+(screen.height-425)/2);void 0;"><?php echo sprintf(T_('Post to %s (Pop-up)'), $GLOBALS['sitename']); ?><\/a><\/li>');
document.write('<\/ul>');
</script>
<h3><?php echo T_('Import'); ?></h3>
<ul>
<li><a href="<?php echo createURL('importNetscape'); ?>"><?php echo T_('Import bookmarks from bookmark file'); ?></a> (<?php echo T_('Internet Explorer, Mozilla Firefox and Netscape'); ?>)</li>
<li><a href="<?php echo createURL('import'); ?>"><?php echo T_('Import bookmarks from del.icio.us'); ?></a></li>
</ul>
<?php
}
$this->includeTemplate($GLOBALS['bottom_include']);
?>
Et voici la partis PHP du formulaire edit.php :
<?php
require_once('header.inc.php');
$bookmarkservice = & ServiceFactory :: getServiceInstance('BookmarkService');
$templateservice = & ServiceFactory :: getServiceInstance('TemplateService');
$userservice = & ServiceFactory :: getServiceInstance('UserService');
// Header variables
$tplVars['subtitle'] = T_('Edit Bookmark');
$tplVars['loadjs'] = true;
list ($url, $bookmark) = explode('/', $_SERVER['PATH_INFO']);
if (!($row = $bookmarkservice->getBookmark(intval($bookmark), true))) {
$tplVars['error'] = sprintf(T_('Bookmark with id %s not was not found'), $bookmark);
$templateservice->loadTemplate('error.404.tpl', $tplVars);
exit();
} else {
if (!$bookmarkservice->editAllowed($row)) {
$tplVars['error'] = T_('You are not allowed to edit this bookmark');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();
} else if ($_POST['submitted']) {
if (!$_POST['title'] || !$_POST['address']) {
$tplVars['error'] = T_('Your bookmark must have a title and an address');
} else {
// Update bookmark
$bId = intval($bookmark);
$address = trim($_POST['address']);
$title = trim($_POST['title']);
$description = trim($_POST['description']);
$status = intval($_POST['status']);
$tags = trim($_POST['tags']);
$logged_on_user = $userservice->getCurrentUser();
if (!$bookmarkservice->updateBookmark($bId, $address, $title, $description, $status, $tags)) {
$tplvars['error'] = T_('Error while saving your bookmark');
} else {
if (isset($_POST['popup'])) {
$tplVars['msg'] = (isset($_POST['popup'])) ? '<script type="text/javascript">window.close();</script>' : T_('Bookmark saved');
} elseif (isset($_POST['referrer'])) {
header('Location: '. $_POST['referrer']);
} else {
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
}
}
}
} else {
if ($_POST['delete']) {
// Delete bookmark
if ($bookmarkservice->deleteBookmark($bookmark)) {
$logged_on_user = $userservice->getCurrentUser();
if (isset($_POST['referrer'])) {
header('Location: '. $_POST['referrer']);
} else {
header('Location: '. createURL('bookmarks', $logged_on_user[$userservice->getFieldName('username')]));
}
exit();
} else {
$tplVars['error'] = T_('Failed to delete bookmark');
$templateservice->loadTemplate('error.500.tpl', $tplVars);
exit();
}
}
}
$tplVars['popup'] = (isset($_GET['popup'])) ? $_GET['popup'] : null;
$tplVars['row'] =& $row;
$tplVars['formaction'] = createURL('edit', $bookmark);
$tplVars['btnsubmit'] = T_('Save Changes');
$tplVars['showdelete'] = true;
$tplVars['referrer'] = $_SERVER['HTTP_REFERER'];
$templateservice->loadTemplate('editbookmark.tpl', $tplVars);
}
?>
Merci d'avance
A voir également:
- Excel remplacer espace par tiret
- Espace insécable - Guide
- Remplacer disque dur par ssd - Guide
- Liste déroulante excel - Guide
- Excel trier par ordre croissant chiffre - Guide
- Espace de stockage gmail plein - Guide