php-doc-en/reference/bbcode/functions/bbcode-set-flags.xml
Peter Cowburn 4d81bf2025 typofix "aly"
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@325727 c90b9560-bf6c-de11-be94-00142212c4b1
2012-05-16 19:35:11 +00:00

141 lines
3.8 KiB
XML

<?xml version="1.0" encoding="utf-8"?>
<!-- $Revision$ -->
<refentry xml:id="function.bbcode-set-flags" xmlns="http://docbook.org/ns/docbook">
<refnamediv>
<refname>bbcode_set_flags</refname>
<refpurpose>Set or alter parser options</refpurpose>
</refnamediv>
<refsect1 role="description">
&reftitle.description;
<methodsynopsis>
<type>bool</type><methodname>bbcode_set_flags</methodname>
<methodparam><type>resource</type><parameter>bbcode_container</parameter></methodparam>
<methodparam><type>int</type><parameter>flags</parameter></methodparam>
<methodparam choice="opt"><type>int</type><parameter>mode</parameter><initializer>BBCODE_SET_FLAGS_SET</initializer></methodparam>
</methodsynopsis>
<para>
Set or alter parser options
</para>
</refsect1>
<refsect1 role="parameters">
&reftitle.parameters;
<para>
<variablelist>
<varlistentry>
<term><parameter>bbcode_container</parameter></term>
<listitem>
<para>
BBCode_Container resource, returned by <function>bbcode_create</function>.
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>flags</parameter></term>
<listitem>
<para>
The flag set that must be applied to the bbcode_container options
</para>
</listitem>
</varlistentry>
<varlistentry>
<term><parameter>mode</parameter></term>
<listitem>
<para>
One of the BBCODE_SET_FLAGS_* constant to set, unset
a specific flag set or to replace the flag set by flags.
</para>
</listitem>
</varlistentry>
</variablelist>
</para>
</refsect1>
<refsect1 role="returnvalues">
&reftitle.returnvalues;
<para>
&return.success;
</para>
</refsect1>
<refsect1 role="examples">
&reftitle.examples;
<para>
<example>
<title><function>bbcode_set_flags</function> usage example</title>
<programlisting role="php">
<![CDATA[
<?php
/*
* Preparing RuleSet
*/
$arrayBBCode=array(
'b'=> array('type'=>BBCODE_TYPE_NOARG,
'open_tag'=>'<b>', 'close_tag'=>'</b>'),
'u'=> array('type'=>BBCODE_TYPE_NOARG,
'open_tag'=>'<u>', 'close_tag'=>'</u>'),
'i'=> array('type'=>BBCODE_TYPE_NOARG,
'open_tag'=>'<i>', 'close_tag'=>'</i>'),
);
/*
* Paired incorrectly nested BBCode
*/
$text="[i] Parser [b] Auto Correction [/i] at work [/b]\n";
$BBHandler=bbcode_create($arrayBBCode);
echo bbcode_parse($BBHandler,$text);
// Enabling reopening of automatically closed elements
bbcode_set_flags($BBHandler,BBCODE_CORRECT_REOPEN_TAGS,
BBCODE_SET_FLAGS_SET);
echo bbcode_parse($BBHandler,$text);
/*
* Unpaired incorrectly nested BBCode
*/
$text="[i] Parser [b] Auto Correction [/i] at work\n";
echo bbcode_parse($BBHandler,$text);
// Enabling automatic close of pending tags
bbcode_set_flags($BBHandler,
BBCODE_CORRECT_REOPEN_TAGS|BBCODE_AUTO_CORRECT,
BBCODE_SET_FLAGS_SET);
echo bbcode_parse($BBHandler,$text);
?>
]]>
</programlisting>
&example.outputs;
<screen>
<![CDATA[
<i> Parser <b> Auto Correction </b></i> at work
<i> Parser <b> Auto Correction </b></i><b> at work </b>
<i> Parser [b] Auto Correction </i> at work
<i> Parser <b> Auto Correction </b></i><b> at work
</b>
]]>
</screen>
</example>
</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
-->