mirror of
https://github.com/macintoshplus/doc-fr.git
synced 2026-03-26 09:52:17 +01:00
152 lines
4.3 KiB
XML
152 lines
4.3 KiB
XML
<?xml version="1.0" encoding="utf-8"?>
|
|
<!-- $Revision$ -->
|
|
<!-- EN-Revision: e41806c30bf6975e452c0d4ce35ab0984c2fa68c Maintainer: yannick Status: ready -->
|
|
<!-- Reviewed: no -->
|
|
|
|
<refentry xml:id="function.xdiff-string-patch" xmlns="http://docbook.org/ns/docbook">
|
|
<refnamediv>
|
|
<refname>xdiff_string_patch</refname>
|
|
<refpurpose>Patche une chaîne avec un diff unifié</refpurpose>
|
|
</refnamediv>
|
|
|
|
<refsect1 role="description">
|
|
&reftitle.description;
|
|
<methodsynopsis>
|
|
<type>string</type><methodname>xdiff_string_patch</methodname>
|
|
<methodparam><type>string</type><parameter>str</parameter></methodparam>
|
|
<methodparam><type>string</type><parameter>patch</parameter></methodparam>
|
|
<methodparam choice="opt"><type>int</type><parameter>flags</parameter></methodparam>
|
|
<methodparam choice="opt"><type>string</type><parameter role="reference">error</parameter></methodparam>
|
|
</methodsynopsis>
|
|
<para>
|
|
Patche la chaîne <parameter>str</parameter> avec un <parameter>patch</parameter>
|
|
unifié et retourne le résultat. <parameter>patch</parameter> doit être un
|
|
patch unifié créé par les fonctions
|
|
<function>xdiff_file_diff</function> et <function>xdiff_string_diff</function>.
|
|
Un paramètre optionnel <parameter>flags</parameter> spécifie le mode de
|
|
l'opération. Toutes les parties rejetées seront stockées dans la
|
|
variable <parameter>error</parameter> si elle est fournie.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="parameters">
|
|
&reftitle.parameters;
|
|
<para>
|
|
<variablelist>
|
|
<varlistentry>
|
|
<term><parameter>str</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
La chaîne originale.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>patch</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Le patch unifié. Il doit avoir été créé en utilisant les fonctions
|
|
<function>xdiff_string_diff</function>, <function>xdiff_file_diff</function>
|
|
ou tout autre outil compatible.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>flags</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
<parameter>flags</parameter> peut être soit
|
|
<constant>XDIFF_PATCH_NORMAL</constant> (mode par défaut, patch normal),
|
|
soit <constant>XDIFF_PATCH_REVERSE</constant> (patch inversé).
|
|
</para>
|
|
<para>
|
|
Depuis la version 1.5.0, vous pouvez également utiliser l'opérateur binaire
|
|
OR pour activer le drapeau <constant>XDIFF_PATCH_IGNORESPACE</constant>.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
<varlistentry>
|
|
<term><parameter>error</parameter></term>
|
|
<listitem>
|
|
<para>
|
|
Si <parameter>error</parameter> est fourni, les parties rejetées y seront
|
|
stockées.
|
|
</para>
|
|
</listitem>
|
|
</varlistentry>
|
|
</variablelist>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="returnvalues">
|
|
&reftitle.returnvalues;
|
|
<para>
|
|
Retourne la chaîne patchée, ou &false; si une erreur survient.
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="examples">
|
|
&reftitle.examples;
|
|
<para>
|
|
<example>
|
|
<title>Exemple avec <function>xdiff_string_patch</function></title>
|
|
<para>
|
|
Le code suivant applique les changements à des articles.
|
|
</para>
|
|
<programlisting role="php">
|
|
<![CDATA[
|
|
<?php
|
|
$old_article = file_get_contents('./old_article.txt');
|
|
$diff = $_SERVER['patch']; /* disons que quelqu'un a passé un patch via un formulaire html */
|
|
|
|
$errors = '';
|
|
|
|
$new_article = xdiff_string_patch($old_article, $diff, XDIFF_PATCH_NORMAL, $errors);
|
|
if (is_string($new_article)) {
|
|
echo "Nouvel article :\n";
|
|
echo $new_article;
|
|
}
|
|
|
|
if (strlen($errors)) {
|
|
echo "Rejets : \n";
|
|
echo $errors;
|
|
}
|
|
|
|
?>
|
|
]]>
|
|
</programlisting>
|
|
</example>
|
|
</para>
|
|
</refsect1>
|
|
|
|
<refsect1 role="seealso">
|
|
&reftitle.seealso;
|
|
<para>
|
|
<simplelist>
|
|
<member><function>xdiff_string_diff</function></member>
|
|
</simplelist>
|
|
</para>
|
|
</refsect1>
|
|
</refentry>
|
|
|
|
<!-- Keep this comment at the end of the file
|
|
Local variables:
|
|
mode: sgml
|
|
sgml-omittag:t
|
|
sgml-shorttag:t
|
|
sgml-minimize-attributes:nil
|
|
sgml-always-quote-attributes:t
|
|
sgml-indent-step:1
|
|
sgml-indent-data:t
|
|
indent-tabs-mode:nil
|
|
sgml-parent-document:nil
|
|
sgml-default-dtd-file:"~/.phpdoc/manual.ced"
|
|
sgml-exposed-tags:nil
|
|
sgml-local-catalogs:nil
|
|
sgml-local-ecat-files:nil
|
|
End:
|
|
vim600: syn=xml fen fdm=syntax fdl=2 si
|
|
vim: et tw=78 syn=sgml
|
|
vi: ts=1 sw=1
|
|
-->
|