mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-09 00:31:45 +01:00
added Japanese translation files.
This commit is contained in:
123
docs/ja/programmers/plugins/plugins-block-functions.xml
Normal file
123
docs/ja/programmers/plugins/plugins-block-functions.xml
Normal file
@@ -0,0 +1,123 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.4 Maintainer: takagi Status: ready -->
|
||||
<!-- CREDITS: mat-sh,daichi,joe -->
|
||||
<sect1 id="plugins.block.functions"><title>ブロック関数プラグイン</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>void <function>smarty_block_<replaceable>name</replaceable></function></funcdef>
|
||||
<paramdef>array <parameter>$params</parameter></paramdef>
|
||||
<paramdef>mixed <parameter>$content</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
<paramdef>boolean <parameter>&$repeat</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
ブロック関数は、<literal>{func} .. {/func}</literal> 形式の関数です。
|
||||
この関数によって囲まれたテンプレートのブロックの内容を処理します。
|
||||
ブロック関数は、同じ名前の
|
||||
<link linkend="language.custom.functions">カスタム関数</link>
|
||||
より優先されます。つまり、テンプレート関数
|
||||
<literal>{func}</literal> とブロック関数
|
||||
<literal>{func}..{/func}</literal> の両方を定義することはできません。
|
||||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem><para>
|
||||
デフォルトでは、実装された関数はSmartyによって2度
|
||||
(1度目は開始タグ、2度目は終端タグによって)呼び出されます
|
||||
(この動作の変更方法は次の <literal>$repeat</literal> を参照)。
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
ブロック関数の開始タグのみ <link linkend="language.syntax.attributes">属性</link>
|
||||
を持つ場合があります。全ての属性はテンプレートからテンプレート関数に、
|
||||
連想配列として <parameter>$params</parameter> に格納された状態で渡されます。
|
||||
また、終端タグを処理している時に開始タグの属性にアクセスする事が可能です
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
変数 <parameter>$content</parameter> の値は、
|
||||
関数が開始タグ又は終端タグのどちらから呼ばれるかによって変わります。
|
||||
開始タグの場合は &null;、終端タグの場合はテンプレートブロックのコンテンツです。
|
||||
テンプレートブロックが Smarty によって既に処理されている事に注意して下さい。
|
||||
つまり、受け取るのはテンプレートソースではなくテンプレートの出力です。
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
<parameter>$repeat</parameter> パラメータは実装された関数に参照によって渡され、
|
||||
そのブロックが何回表示されるのかを操作する事ができます。
|
||||
デフォルトでは、最初のブロック関数の呼び出し(開始タグ)のとき
|
||||
<parameter>$repeat</parameter> は &true; で、その後に呼び出される場合(終端タグ)は、
|
||||
&false; となります。 実装された関数で <parameter>$repeat</parameter> を &true;
|
||||
とする事で、<literal>{func}...{/func}</literal> 間のコンテンツが再度評価され、
|
||||
<parameter>$content</parameter> パラメータに新しいブロックコンテンツが格納された状態で、
|
||||
再び呼び出されます。
|
||||
</para></listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
ネストしたブロック関数がある場合、変数
|
||||
<literal>$smarty->_tag_stack</literal>
|
||||
にアクセスする事で親のブロック関数を見つける事が可能です。
|
||||
<ulink url="&url.php-manual;var_dump"><varname>var_dump()</varname></ulink>
|
||||
を行い、構造をはっきりと理解すべきべきです。
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>ブロック関数プラグイン</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: block.translate.php
|
||||
* Type: block
|
||||
* Name: translate
|
||||
* Purpose: テキストブロックを翻訳する
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_block_translate($params, $content, &$smarty, &$repeat)
|
||||
{
|
||||
// 終了タグでのみ出力します
|
||||
if(!$repeat){
|
||||
if (isset($content)) {
|
||||
$lang = $params['lang'];
|
||||
// ここで $content に対する翻訳を行います
|
||||
return $translation;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
<link linkend="api.register.block"><varname>register_block()</varname></link>
|
||||
および
|
||||
<link linkend="api.unregister.block"><varname>unregister_block()</varname></link>
|
||||
も参照してください。
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
<!-- 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:"../../../../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
|
||||
-->
|
||||
98
docs/ja/programmers/plugins/plugins-compiler-functions.xml
Normal file
98
docs/ja/programmers/plugins/plugins-compiler-functions.xml
Normal file
@@ -0,0 +1,98 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.3 Maintainer: takagi Status: ready -->
|
||||
<!-- CREDITS: mat-sh,daichi,joe -->
|
||||
<sect1 id="plugins.compiler.functions"><title>コンパイラ関数プラグイン</title>
|
||||
<para>
|
||||
コンパイラ関数プラグインはテンプレートのコンパイル時にのみ呼び出されます。
|
||||
これらのプラグインは、PHPコードまたは時間に依存する静的コンテンツをテンプレートに含める時に便利です。
|
||||
コンパイラ関数と <link linkend="language.custom.functions">カスタム関数</link>
|
||||
が双方とも同じ名前で登録された場合は、コンパイラ関数が優先されます。
|
||||
</para>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>mixed <function>smarty_compiler_<replaceable>name</replaceable></function></funcdef>
|
||||
<paramdef>string <parameter>$tag_arg</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
コンパイラ関数には2つのパラメータを渡します。
|
||||
これらのパラメータは、タグ内の文字列(基本的に関数名から終端デリミタまでの全ての文字列)と、
|
||||
Smartyのオブジェクトです。戻り値には、コンパイルされたテンプレートに挿入されるPHPコードを返します。
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>シンプルなコンパイラ関数プラグイン</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: compiler.tplheader.php
|
||||
* Type: compiler
|
||||
* Name: tplheader
|
||||
* Purpose: ソースファイル名とそれがコンパイルされた時間を含む
|
||||
* ヘッダを出力する
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_compiler_tplheader($tag_arg, &$smarty)
|
||||
{
|
||||
return "\necho '" . $smarty->_current_file . " compiled at " . date('Y-m-d H:M'). "';";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
この関数はテンプレートから次のように呼ばれます。
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* この関数はコンパイル時にのみ呼び出されます *}
|
||||
{tplheader}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
コンパイルされたテンプレートの結果として生じるPHPコードは次のようになります。
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
echo 'index.tpl compiled at 2002-02-20 20:02';
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
<link linkend="api.register.compiler.function">
|
||||
<varname>register_compiler_function()</varname></link>
|
||||
および
|
||||
<link linkend="api.unregister.compiler.function">
|
||||
<varname>unregister_compiler_function()</varname></link>
|
||||
も参照してください。
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
<!-- 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:"../../../../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
|
||||
-->
|
||||
132
docs/ja/programmers/plugins/plugins-functions.xml
Normal file
132
docs/ja/programmers/plugins/plugins-functions.xml
Normal file
@@ -0,0 +1,132 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.3 Maintainer: takagi Status: ready -->
|
||||
<!-- CREDITS: mat-sh,daichi,joe -->
|
||||
<sect1 id="plugins.functions"><title>テンプレート関数プラグイン</title>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>void <function>smarty_function_<replaceable>name</replaceable></function></funcdef>
|
||||
<paramdef>array <parameter>$params</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
テンプレートからテンプレート関数に渡された全ての
|
||||
<link linkend="language.syntax.attributes">属性</link> は、
|
||||
連想配列として <parameter>$params</parameter> に格納されます。
|
||||
</para>
|
||||
<para>
|
||||
関数の出力(戻り値)はテンプレート関数のタグの部分と置き換えられます(例:
|
||||
<link linkend="language.function.fetch"><varname>{fetch}</varname></link>
|
||||
関数)。 あるいは何も出力せずに単に他のタスクを実行する事ができます(例:
|
||||
<link linkend="language.function.assign">
|
||||
<varname>{assign}</varname></link> 関数)。
|
||||
</para>
|
||||
<para>
|
||||
関数によっていくつかの変数をテンプレートに割り当てる必要がある、
|
||||
もしくは Smarty に提供された他の機能を使う必要がある場合は、
|
||||
提供された <parameter>$smarty</parameter> オブジェクトを使用して
|
||||
<literal>$smarty->foo()</literal> のようにします。
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<example>
|
||||
<title>出力ありのテンプレート関数プラグイン</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: function.eightball.php
|
||||
* Type: function
|
||||
* Name: eightball
|
||||
* Purpose: ランダムに回答を出力する
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_function_eightball($params, &$smarty)
|
||||
{
|
||||
$answers = array('はい',
|
||||
'いいえ',
|
||||
'わかりません',
|
||||
'可能性は低い',
|
||||
'今は答えられません',
|
||||
'実はもう実現しているのかも……');
|
||||
|
||||
$result = array_rand($answers);
|
||||
return $answers[$result];
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
次のようにテンプレートで使用する事ができます。
|
||||
</para>
|
||||
<programlisting>
|
||||
質問: 将来、タイムトラベルは実現可能でしょうか?
|
||||
答え: {eightball}.
|
||||
</programlisting>
|
||||
<para>
|
||||
<example>
|
||||
<title>出力なしのテンプレート関数プラグイン</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: function.assign.php
|
||||
* Type: function
|
||||
* Name: assign
|
||||
* Purpose: テンプート変数に値を割り当てる
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_function_assign($params, &$smarty)
|
||||
{
|
||||
if (empty($params['var'])) {
|
||||
$smarty->trigger_error("assign: パラメータ 'var' がありません");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!in_array('value', array_keys($params))) {
|
||||
$smarty->trigger_error("assign: パラメータ 'value' がありません");
|
||||
return;
|
||||
}
|
||||
|
||||
$smarty->assign($params['var'], $params['value']);
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
<link linkend="api.register.function"><varname>register_function()</varname></link>
|
||||
および
|
||||
<link linkend="api.unregister.function"><varname>unregister_function()</varname></link>
|
||||
も参照してください。
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<!-- 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:"../../../../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
|
||||
-->
|
||||
46
docs/ja/programmers/plugins/plugins-howto.xml
Normal file
46
docs/ja/programmers/plugins/plugins-howto.xml
Normal file
@@ -0,0 +1,46 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.2 Maintainer: takagi Status: ready -->
|
||||
<!-- CREDITS: mat-sh,daichi,joe -->
|
||||
<sect1 id="plugins.howto">
|
||||
<title>プラグインの動作原理</title>
|
||||
<para>
|
||||
プラグインは要求があると常に読み込まれます。テンプレートから呼び出された
|
||||
修飾子・関数・リソース等のプラグインだけが読み込まれます。
|
||||
さらに各プラグインは同じリクエスト内に Smarty
|
||||
の異なるインスタンスが複数実行されていても、読み込まれるのは一度だけです。
|
||||
</para>
|
||||
<para>
|
||||
プリフィルタ/ポストフィルタとアウトプットフィルタは少し特殊です。
|
||||
これらはテンプレートから呼び出されないので、テンプレートが処理される前に
|
||||
API 関数を経由して明示的に登録または読み込まれる必要があります。
|
||||
同じ種類の複数のフィルタが実行される順序は、それらが登録または読み込まれる順序によって決まります。
|
||||
</para>
|
||||
<para>
|
||||
<link linkend="variable.plugins.dir">プラグインディレクトリ</link>
|
||||
は、単一のパスを示す文字列または複数のパスを格納した配列でとなります。
|
||||
プラグインのインストールは、単にプラグインファイルをいずれかのプラグインディレクトリ内に置くだけです。
|
||||
そうすれば Smarty はそれを自動的に使用します。
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<!-- 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:"../../../../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
|
||||
-->
|
||||
72
docs/ja/programmers/plugins/plugins-inserts.xml
Normal file
72
docs/ja/programmers/plugins/plugins-inserts.xml
Normal file
@@ -0,0 +1,72 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.5 Maintainer: takagi Status: ready -->
|
||||
<!-- CREDITS: mat-sh,daichi,joe -->
|
||||
<sect1 id="plugins.inserts"><title>インサートプラグイン</title>
|
||||
<para>
|
||||
インサートプラグインは、テンプレートの
|
||||
<link linkend="language.function.insert"><varname>{insert}</varname></link>
|
||||
タグによって呼び出される関数を実装するために使用されます。
|
||||
</para>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>string <function>smarty_insert_<replaceable>name</replaceable></function></funcdef>
|
||||
<paramdef>array <parameter>$params</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
この関数の第1パラメータは、insert タグに渡される属性の連想配列です。
|
||||
</para>
|
||||
<para>
|
||||
インサートプラグイン関数は戻り値として、
|
||||
テンプレートの <varname>{insert}</varname> タグの部分を置き換える結果を返します。
|
||||
</para>
|
||||
<example>
|
||||
<title>インサートプラグイン</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: insert.time.php
|
||||
* Type: time
|
||||
* Name: time
|
||||
* Purpose: 現在の日付/時刻をフォーマットにしたがってインサートする
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_insert_time($params, &$smarty)
|
||||
{
|
||||
if (empty($params['format'])) {
|
||||
$smarty->trigger_error("insert time: missing 'format' parameter");
|
||||
return;
|
||||
}
|
||||
return strftime($params['format']);
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</sect1>
|
||||
|
||||
<!-- 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:"../../../../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
|
||||
-->
|
||||
118
docs/ja/programmers/plugins/plugins-modifiers.xml
Normal file
118
docs/ja/programmers/plugins/plugins-modifiers.xml
Normal file
@@ -0,0 +1,118 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.3 Maintainer: takagi Status: ready -->
|
||||
<!-- CREDITS: mat-sh,daichi,joe -->
|
||||
<sect1 id="plugins.modifiers"><title>修飾子プラグイン</title>
|
||||
<para>
|
||||
<link linkend="language.modifiers">修飾子プラグイン</link>
|
||||
は、テンプレートの変数が表示される前または他のコンテンツに使用される前に適用される関数です。
|
||||
</para>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>mixed <function>smarty_modifier_<replaceable>name</replaceable></function></funcdef>
|
||||
<paramdef>mixed <parameter>$value</parameter></paramdef>
|
||||
<paramdef>[mixed <parameter>$param1</parameter>, ...]</paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
修飾子プラグインへの第1パラメータは、この修飾子によって影響を受ける値です。
|
||||
残りのパラメータはどのような動作が行われるかによって任意です。
|
||||
</para>
|
||||
<para>
|
||||
修飾子プラグインは処理の結果を
|
||||
<ulink url="&url.php-manual;return">返す</ulink>
|
||||
必要があります。
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>シンプルな修飾子プラグイン</title>
|
||||
<para>
|
||||
このプラグインは、基本的に組み込みの PHP 関数の名前を変えただけのものです。
|
||||
追加のパラメータはありません。
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: modifier.capitalize.php
|
||||
* Type: modifier
|
||||
* Name: capitalize
|
||||
* Purpose: 文字列の各単語の最初の文字を大文字にする
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_modifier_capitalize($string)
|
||||
{
|
||||
return ucwords($string);
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para></para>
|
||||
<example>
|
||||
<title>更に複雑な修飾子プラグイン</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: modifier.truncate.php
|
||||
* Type: modifier
|
||||
* Name: truncate
|
||||
* Purpose: 文字列をある長さで切り捨てます。
|
||||
* 単語の真ん中で分割させたり、終端に文字列 $etc
|
||||
* を追加したりすることもできます。
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_modifier_truncate($string, $length = 80, $etc = '...',
|
||||
$break_words = false)
|
||||
{
|
||||
if ($length == 0)
|
||||
return '';
|
||||
|
||||
if (strlen($string) > $length) {
|
||||
$length -= strlen($etc);
|
||||
$fragment = substr($string, 0, $length+1);
|
||||
if ($break_words)
|
||||
$fragment = substr($fragment, 0, -1);
|
||||
else
|
||||
$fragment = preg_replace('/\s+(\S+)?$/', '', $fragment);
|
||||
return $fragment.$etc;
|
||||
} else
|
||||
return $string;
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
<link linkend="api.register.modifier"><varname>register_modifier()</varname></link>
|
||||
および
|
||||
<link linkend="api.unregister.modifier"><varname>unregister_modifier()</varname></link>
|
||||
も参照してください。
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<!-- 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:"../../../../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
|
||||
-->
|
||||
99
docs/ja/programmers/plugins/plugins-naming-conventions.xml
Normal file
99
docs/ja/programmers/plugins/plugins-naming-conventions.xml
Normal file
@@ -0,0 +1,99 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.3 Maintainer: takagi Status: ready -->
|
||||
<!-- CREDITS: mat-sh,daichi,joe -->
|
||||
<sect1 id="plugins.naming.conventions">
|
||||
<title>命名規約</title>
|
||||
<para>
|
||||
プラグインファイルとその関数が Smarty
|
||||
によって認識されるためには特有の命名規約に従わなければなりません。
|
||||
</para>
|
||||
<para>
|
||||
<emphasis role="bold">プラグインファイル</emphasis> は次のように指定します。
|
||||
<blockquote>
|
||||
<para>
|
||||
<filename>
|
||||
<replaceable>type</replaceable>.<replaceable>name</replaceable>.php
|
||||
</filename>
|
||||
</para>
|
||||
</blockquote>
|
||||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem><para>
|
||||
<literal>type</literal> は次のプラグインタイプのうちのいずれか1つです。
|
||||
<itemizedlist spacing="compact">
|
||||
<listitem><simpara>function</simpara></listitem>
|
||||
<listitem><simpara>modifier</simpara></listitem>
|
||||
<listitem><simpara>block</simpara></listitem>
|
||||
<listitem><simpara>compiler</simpara></listitem>
|
||||
<listitem><simpara>prefilter</simpara></listitem>
|
||||
<listitem><simpara>postfilter</simpara></listitem>
|
||||
<listitem><simpara>outputfilter</simpara></listitem>
|
||||
<listitem><simpara>resource</simpara></listitem>
|
||||
<listitem><simpara>insert</simpara></listitem>
|
||||
</itemizedlist>
|
||||
</para>
|
||||
</listitem>
|
||||
|
||||
<listitem><para>
|
||||
<literal>name</literal> には英数字とアンダースコアのみ使用できます。
|
||||
<ulink url="&url.php-manual;language.variables">PHP の変数</ulink>
|
||||
を参照してください。
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
例: <filename>function.html_select_date.php</filename>、
|
||||
<filename>resource.db.php</filename>、
|
||||
<filename>modifier.spacify.php</filename>。
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
|
||||
<para>
|
||||
PHP ファイル内で定義する <emphasis role="bold">プラグイン関数</emphasis>
|
||||
は次のように指定します。
|
||||
<blockquote>
|
||||
<para>
|
||||
<function>smarty_<replaceable>type</replaceable>_<replaceable>name</replaceable></function>
|
||||
</para>
|
||||
</blockquote>
|
||||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem><para>
|
||||
<literal>type</literal> および <literal>name</literal>
|
||||
の意味は前述したものと同じです。
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
たとえば <varname>foo</varname> という名前の修飾子の場合は、
|
||||
<literal>function smarty_modifier_foo()</literal> となります。
|
||||
</para></listitem>
|
||||
</itemizedlist>
|
||||
<para>
|
||||
必要なプラグインファイルが見当たらないか、
|
||||
ファイル名又はプラグイン関数名が不正な場合 Smarty は適切なエラーメッセージを出力します。
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<!-- 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:"../../../../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
|
||||
-->
|
||||
75
docs/ja/programmers/plugins/plugins-outputfilters.xml
Normal file
75
docs/ja/programmers/plugins/plugins-outputfilters.xml
Normal file
@@ -0,0 +1,75 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.3 Maintainer: takagi Status: ready -->
|
||||
<!-- CREDITS: mat-sh,daichi,joe -->
|
||||
<sect1 id="plugins.outputfilters"><title>アウトプットフィルタプラグイン</title>
|
||||
<para>
|
||||
アウトプットフィルタプラグインは、テンプレートが読み込まれて実行された後
|
||||
(しかしその出力が表示される前)にテンプレートの出力を操作します。
|
||||
</para>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>string <function>smarty_outputfilter_<replaceable>name</replaceable></function></funcdef>
|
||||
<paramdef>string <parameter>$template_output</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
アウトプットフィルタの第1パラメータは、処理を行うテンプレート出力です。
|
||||
第2パラメータは、プラグインを呼び出したSmartyのインスタンスです。
|
||||
このプラグインは戻り値に、修正されたテンプレート出力を返すようにして下さい。
|
||||
</para>
|
||||
<example>
|
||||
<title>アウトプットフィルタプラグイン</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: outputfilter.protect_email.php
|
||||
* Type: outputfilter
|
||||
* Name: protect_email
|
||||
* Purpose: email アドレスの @ を %40 に変換し、
|
||||
* スパムボットからほんの少しだけ保護する
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_outputfilter_protect_email($output, &$smarty)
|
||||
{
|
||||
return preg_replace('!(\S+)@([a-zA-Z0-9\.\-]+\.([a-zA-Z]{2,3}|[0-9]{1,3}))!',
|
||||
'$1%40$2', $output);
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
<link linkend="api.register.outputfilter">
|
||||
<varname>register_outputfilter()</varname></link>
|
||||
および
|
||||
<link linkend="api.unregister.outputfilter">
|
||||
<varname>unregister_outputfilter()</varname></link>
|
||||
も参照してください。
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<!-- 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:"../../../../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
|
||||
-->
|
||||
118
docs/ja/programmers/plugins/plugins-prefilters-postfilters.xml
Normal file
118
docs/ja/programmers/plugins/plugins-prefilters-postfilters.xml
Normal file
@@ -0,0 +1,118 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.3 Maintainer: takagi Status: ready -->
|
||||
<!-- CREDITS: mat-sh,daichi,joe -->
|
||||
<sect1 id="plugins.prefilters.postfilters">
|
||||
<title>プリフィルタ/ポストフィルタプラグイン</title>
|
||||
<para>
|
||||
プリフィルタ/ポストフィルタプラグインは概念において非常によく似ています。
|
||||
それらの違いは実行されるタイミングにあります。
|
||||
</para>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>string <function>smarty_prefilter_<replaceable>name</replaceable></function></funcdef>
|
||||
<paramdef>string <parameter>$source</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
プリフィルタは、テンプレートソースをコンパイルする直前に何らかの処理を行うために使用されます。
|
||||
プリフィルタ関数への第1パラメータはテンプレートソースであり、
|
||||
これは他のプリフィルタによって既に修正されている可能性があります。
|
||||
このプラグインは戻り値に、修正されたテンプレートソースを返すようにして下さい。
|
||||
また、このテンプレートソースはどこにも保存されず、コンパイルする目的だけに使用される事に注意して下さい。
|
||||
</para>
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>string <function>smarty_postfilter_<replaceable>name</replaceable></function></funcdef>
|
||||
<paramdef>string <parameter>$compiled</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
<para>
|
||||
ポストフィルタは、テンプレートのコンパイルが行われてファイルシステムに保存される前に、
|
||||
そのテンプレートのコンパイル結果(PHPスクリプト)に何らかの処理を行うために使用されます。
|
||||
ポストフィルタへの第1パラメータはコンパイルされたテンプレートソースであり、
|
||||
これは他のポストフィルタによって既に修正されている可能性があります。
|
||||
このプラグインは戻り値に、修正されたテンプレートソースを返すようにして下さい。
|
||||
</para>
|
||||
<example>
|
||||
<title>プリフィルタプラグイン</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: prefilter.pre01.php
|
||||
* Type: prefilter
|
||||
* Name: pre01
|
||||
* Purpose: html タグを小文字に変換する
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_prefilter_pre01($source, &$smarty)
|
||||
{
|
||||
return preg_replace('!<(\w+)[^>]+>!e', 'strtolower("$1")', $source);
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para></para>
|
||||
<example>
|
||||
<title>ポストフィルタプラグイン</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: postfilter.post01.php
|
||||
* Type: postfilter
|
||||
* Name: post01
|
||||
* Purpose: 現在のテンプレートのすべての変数をリストするスクリプトを出力する
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_postfilter_post01($compiled, &$smarty)
|
||||
{
|
||||
$compiled = "<pre>\n<?php print_r(\$this->get_template_vars()); ?>\n</pre>" . $compiled;
|
||||
return $compiled;
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
<link linkend="api.register.prefilter">
|
||||
<varname>register_prefilter()</varname></link>、
|
||||
<link linkend="api.unregister.prefilter">
|
||||
<varname>unregister_prefilter()</varname></link>、
|
||||
<link linkend="api.register.postfilter">
|
||||
<varname>register_postfilter()</varname></link>
|
||||
および
|
||||
<link linkend="api.unregister.postfilter">
|
||||
<varname>unregister_postfilter()</varname></link>
|
||||
も参照してください。
|
||||
</para>
|
||||
</sect1>
|
||||
|
||||
<!-- 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:"../../../../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
|
||||
-->
|
||||
168
docs/ja/programmers/plugins/plugins-resources.xml
Normal file
168
docs/ja/programmers/plugins/plugins-resources.xml
Normal file
@@ -0,0 +1,168 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.3 Maintainer: takagi Status: ready -->
|
||||
<!-- CREDITS: mat-sh,daichi,joe -->
|
||||
<sect1 id="plugins.resources"><title>リソースプラグイン</title>
|
||||
<para>
|
||||
リソースプラグインは、テンプレートソースやPHPスクリプトのコンポーネントを
|
||||
Smarty に提供する一般的な方法と意図されています
|
||||
(例: データベース, LDAP, 共有メモリ, ソケット等)。
|
||||
</para>
|
||||
|
||||
<para>
|
||||
各種リソースのために4つの関数を登録する必要があります。
|
||||
これらの関数の最初のパラメータには要求されたリソースが渡され、
|
||||
最後のパラメータには Smarty のオブジェクトが渡されます。
|
||||
残りのパラメータは関数によって異なります。
|
||||
</para>
|
||||
|
||||
<funcsynopsis>
|
||||
<funcprototype>
|
||||
<funcdef>bool <function>smarty_resource_<replaceable>name</replaceable>_source</function></funcdef>
|
||||
<paramdef>string <parameter>$rsrc_name</parameter></paramdef>
|
||||
<paramdef>string <parameter>&$source</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
<funcprototype>
|
||||
<funcdef>bool <function>smarty_resource_<replaceable>name</replaceable>_timestamp</function></funcdef>
|
||||
<paramdef>string <parameter>$rsrc_name</parameter></paramdef>
|
||||
<paramdef>int <parameter>&$timestamp</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
<funcprototype>
|
||||
<funcdef>bool <function>smarty_resource_<replaceable>name</replaceable>_secure</function></funcdef>
|
||||
<paramdef>string <parameter>$rsrc_name</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
<funcprototype>
|
||||
<funcdef>bool <function>smarty_resource_<replaceable>name</replaceable>_trusted</function></funcdef>
|
||||
<paramdef>string <parameter>$rsrc_name</parameter></paramdef>
|
||||
<paramdef>object <parameter>&$smarty</parameter></paramdef>
|
||||
</funcprototype>
|
||||
</funcsynopsis>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem><para>
|
||||
1つめの関数 <literal>source()</literal> ではリソースを取得します。
|
||||
第2パラメータ <parameter>$source</parameter>
|
||||
は参照で渡され、ここに結果が格納されます。
|
||||
戻り値は、リソースの取得に成功すれば &true;、
|
||||
それ以外は &false; となります。
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
2つめの関数 <literal>timestamp()</literal> は、
|
||||
要求されたリソースが最後に修正された時間(UNIXタイムスタンプ)を取得します。
|
||||
第2パラメータ <parameter>$timestamp</parameter> は参照で渡され、
|
||||
ここにタイムスタンプが格納されます。タイムスタンプが取得できれば
|
||||
&true;、それ以外は &false; を返します。
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
3つめの関数 <literal>secure()</literal> は、
|
||||
要求されたリソースがセキュアであるかどうかに応じて &true; 又は &false; を返します。
|
||||
この関数はテンプレートリソースのためにだけ用いられますが、定義する必要があります。
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
4つめの関数 <literal>trusted()</literal> は、
|
||||
要求されたリソースが信用できるかどうかに応じて &true; 又は &false; を返します。
|
||||
この関数を使用するのは、<link linkend="language.function.include.php">
|
||||
<varname>{include_php}</varname></link> タグあるいは
|
||||
<link linkend="language.function.insert"><varname>{insert}</varname></link>
|
||||
タグで <parameter>src</parameter> 属性によって要求された PHP
|
||||
スクリプトコンポーネントのみです。
|
||||
しかし、テンプレートリソースであっても定義する必要があります。
|
||||
</para></listitem>
|
||||
</itemizedlist>
|
||||
|
||||
|
||||
<example>
|
||||
<title>リソースプラグイン</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: resource.db.php
|
||||
* Type: resource
|
||||
* Name: db
|
||||
* Purpose: データベースからテンプレートを取得する
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_resource_db_source($tpl_name, &$tpl_source, &$smarty)
|
||||
{
|
||||
// ここでデータベースを呼び出し、
|
||||
// $tpl_source に代入します
|
||||
$sql = new SQL;
|
||||
$sql->query("select tpl_source
|
||||
from my_table
|
||||
where tpl_name='$tpl_name'");
|
||||
if ($sql->num_rows) {
|
||||
$tpl_source = $sql->record['tpl_source'];
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function smarty_resource_db_timestamp($tpl_name, &$tpl_timestamp, &$smarty)
|
||||
{
|
||||
// ここでデータベースを呼び出し、$tpl_timestampに代入します
|
||||
$sql = new SQL;
|
||||
$sql->query("select tpl_timestamp
|
||||
from my_table
|
||||
where tpl_name='$tpl_name'");
|
||||
if ($sql->num_rows) {
|
||||
$tpl_timestamp = $sql->record['tpl_timestamp'];
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function smarty_resource_db_secure($tpl_name, &$smarty)
|
||||
{
|
||||
// 全てのテンプレートがセキュアであるとみなします
|
||||
return true;
|
||||
}
|
||||
|
||||
function smarty_resource_db_trusted($tpl_name, &$smarty)
|
||||
{
|
||||
// テンプレートでは使用しません
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
<link linkend="api.register.resource"><varname>register_resource()</varname></link>
|
||||
および
|
||||
<link linkend="api.unregister.resource"><varname>unregister_resource()</varname></link>
|
||||
も参照してください。
|
||||
</para>
|
||||
|
||||
</sect1>
|
||||
|
||||
<!-- 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:"../../../../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
|
||||
-->
|
||||
62
docs/ja/programmers/plugins/plugins-writing.xml
Normal file
62
docs/ja/programmers/plugins/plugins-writing.xml
Normal file
@@ -0,0 +1,62 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- $Revision$ -->
|
||||
<!-- EN-Revision: 1.3 Maintainer: takagi Status: ready -->
|
||||
<!-- CREDITS: mat-sh,daichi,joe -->
|
||||
<sect1 id="plugins.writing">
|
||||
<title>プラグインの記述</title>
|
||||
<para>
|
||||
プラグインは Smarty によってファイルシステムから自動的に読み込まれるか、
|
||||
register_* API 関数のうちの1つを経由して動的に登録する事ができます。
|
||||
また、それらは unregister_* API 関数を使う事によって未登録にする事ができます。
|
||||
</para>
|
||||
<para>
|
||||
動的に登録されるプラグインについてはプラグイン関数の命名規約に従う必要はありません。
|
||||
</para>
|
||||
<para>
|
||||
Smarty にバンドルされたいくらかのプラグインに関する場合と同様に、
|
||||
プラグインが別のプラグインによって提供される機能に依存する場合は次の方法で必要とされるプラグインを読み込みます。
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
require_once $smarty->_get_plugin_filepath('function', 'html_options');
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
基本的に、Smarty のオブジェクトは常に最後のパラメータとしてプラグインに渡されます。
|
||||
ただし、例外が2つあります。
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem><para>
|
||||
変数の修飾子は Smarty オブジェクトを渡しません。
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
ブロックの場合は Smarty オブジェクトの後に <parameter>$repeat</parameter>
|
||||
が渡されます。これは、以前のバージョンの Smarty
|
||||
との後方互換性を保つためのものです。
|
||||
</para></listitem>
|
||||
</itemizedlist>
|
||||
|
||||
</sect1>
|
||||
|
||||
<!-- 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:"../../../../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
|
||||
-->
|
||||
Reference in New Issue
Block a user