2007-04-21 12:13:34 +00:00
|
|
|
<?xml version="1.0" encoding="utf-8"?>
|
|
|
|
|
<!-- $Revision$ -->
|
2008-05-26 08:47:23 +00:00
|
|
|
<!-- EN-Revision: 2593 Maintainer: takagi Status: ready -->
|
2007-04-21 12:13:34 +00:00
|
|
|
<!-- CREDITS: mat-sh,daichi,joe -->
|
|
|
|
|
<refentry id="api.register.resource">
|
|
|
|
|
<refnamediv>
|
|
|
|
|
<refname>register_resource()</refname>
|
|
|
|
|
<refpurpose>リソースプラグインを動的に登録します。</refpurpose>
|
|
|
|
|
</refnamediv>
|
|
|
|
|
<refsect1>
|
|
|
|
|
<title>説明</title>
|
|
|
|
|
<methodsynopsis>
|
|
|
|
|
<type>void</type><methodname>register_resource</methodname>
|
|
|
|
|
<methodparam><type>string</type><parameter>name</parameter></methodparam>
|
|
|
|
|
<methodparam><type>array</type><parameter>resource_funcs</parameter></methodparam>
|
|
|
|
|
</methodsynopsis>
|
|
|
|
|
<para>
|
|
|
|
|
<link linkend="template.resources">リソースプラグイン</link>
|
|
|
|
|
を動的に登録します。パラメータとして、
|
|
|
|
|
リソース名および実行する PHP ユーザ定義関数の名前を格納した配列を渡します。
|
|
|
|
|
テンプレートを取得するための関数の定義の仕方は、
|
|
|
|
|
<link linkend="template.resources">テンプレートリソース</link>
|
|
|
|
|
の項を参照してください。
|
|
|
|
|
<note>
|
|
|
|
|
<title>テクニカルノート</title>
|
|
|
|
|
<para>
|
|
|
|
|
リソース名の長さは少なくとも2文字以上である必要があります。
|
|
|
|
|
1文字のリソース名は無視され、<literal>$smarty->display('c:/path/to/index.tpl');</literal>
|
|
|
|
|
のようにファイルパスの一部として使用されます。
|
|
|
|
|
</para>
|
|
|
|
|
</note>
|
|
|
|
|
|
|
|
|
|
</para>
|
|
|
|
|
|
|
|
|
|
<itemizedlist>
|
|
|
|
|
<listitem><para>
|
|
|
|
|
PHP関数名が含まれる配列 <parameter>resource_funcs</parameter>
|
|
|
|
|
には4つまたは5つの要素が必要です。
|
|
|
|
|
</para></listitem>
|
|
|
|
|
<listitem><para>
|
|
|
|
|
要素が4つの場合は、<literal>source</literal>、
|
|
|
|
|
<literal>timestamp</literal>、<literal>secure</literal> および
|
|
|
|
|
<literal>trusted</literal> がリソースの関数としてそれぞれコールバックされます。
|
|
|
|
|
</para></listitem>
|
|
|
|
|
<listitem><para>
|
|
|
|
|
要素が5つの場合は、最初の要素はリソースを実装するオブジェクトの参照または
|
|
|
|
|
オブジェクトのクラス名またはクラスである必要があり、続く4つの要素は
|
|
|
|
|
<literal>source</literal>、<literal>timestamp</literal>、<literal>secure</literal>
|
|
|
|
|
および <literal>trusted</literal> を実装したメソッド名である必要があります。
|
|
|
|
|
</para></listitem>
|
|
|
|
|
</itemizedlist>
|
|
|
|
|
<example>
|
|
|
|
|
<title>register_resource()</title>
|
|
|
|
|
<programlisting role="php">
|
|
|
|
|
<![CDATA[
|
|
|
|
|
<?php
|
|
|
|
|
$smarty->register_resource('db', array(
|
|
|
|
|
'db_get_template',
|
|
|
|
|
'db_get_timestamp',
|
|
|
|
|
'db_get_secure',
|
|
|
|
|
'db_get_trusted')
|
|
|
|
|
);
|
|
|
|
|
?>
|
|
|
|
|
]]>
|
|
|
|
|
</programlisting>
|
|
|
|
|
</example>
|
|
|
|
|
|
|
|
|
|
<para>
|
|
|
|
|
<link linkend="api.unregister.resource"><varname>unregister_resource()</varname></link>
|
|
|
|
|
および
|
|
|
|
|
<link linkend="template.resources">テンプレートリソース</link>
|
|
|
|
|
も参照してください。
|
|
|
|
|
</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:"../../../../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
|
|
|
|
|
-->
|