mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-09 16:51:47 +01:00
139 lines
4.5 KiB
XML
139 lines
4.5 KiB
XML
|
|
<?xml version="1.0" encoding="utf-8"?>
|
||
|
|
<!-- $Revision$ -->
|
||
|
|
<!-- EN-Revision: 1.12 Maintainer: takagi Status: ready -->
|
||
|
|
<!-- CREDITS: mat-sh,daichi,joe -->
|
||
|
|
<sect1 id="language.function.fetch">
|
||
|
|
<title>{fetch}</title>
|
||
|
|
<para>
|
||
|
|
<varname>{fetch}</varname> は、ローカルシステムやhttp, ftpからファイルを取得し、
|
||
|
|
コンテンツを表示します。
|
||
|
|
</para>
|
||
|
|
|
||
|
|
<itemizedlist>
|
||
|
|
<listitem><para>
|
||
|
|
ファイル名が <parameter>http://</parameter> から始まる場合は、web
|
||
|
|
サイト上のページを取得して表示します。
|
||
|
|
<note>
|
||
|
|
<para>
|
||
|
|
http リダイレクトはサポートしていません。
|
||
|
|
必要に応じて、最後のスラッシュをつけることを忘れないようにしましょう。
|
||
|
|
</para>
|
||
|
|
</note>
|
||
|
|
</para></listitem>
|
||
|
|
|
||
|
|
<listitem><para>
|
||
|
|
ファイル名が <parameter>ftp://</parameter> で始まる場合は、
|
||
|
|
ftp サーバからダウンロードしたファイルを表示します。
|
||
|
|
</para></listitem>
|
||
|
|
|
||
|
|
<listitem><para>
|
||
|
|
ローカルファイルの場合には、ファイルのフルパスあるいは
|
||
|
|
実行する PHP スクリプトからの相対パスを指定する必要があります。
|
||
|
|
<note>
|
||
|
|
<para>
|
||
|
|
テンプレートの <link linkend="variable.security">
|
||
|
|
<parameter>$security</parameter></link> が有効になっており、
|
||
|
|
ファイルをローカルファイルシステムから取得する場合、
|
||
|
|
<varname>{fetch}</varname> は定義済みの
|
||
|
|
<link linkend="variable.secure.dir">安全なディレクトリ</link>
|
||
|
|
のいずれかにあるファイルのみを受け付けます。
|
||
|
|
</para>
|
||
|
|
</note>
|
||
|
|
</para></listitem>
|
||
|
|
|
||
|
|
<listitem><para>
|
||
|
|
<parameter>assign</parameter> 属性を指定すると、
|
||
|
|
<varname>{fetch}</varname> 関数の出力がこのテンプレート変数に割り当てられます。
|
||
|
|
テンプレートには出力されません。
|
||
|
|
</para></listitem>
|
||
|
|
</itemizedlist>
|
||
|
|
|
||
|
|
<informaltable frame="all">
|
||
|
|
<tgroup cols="5">
|
||
|
|
<colspec colname="param" align="center" />
|
||
|
|
<colspec colname="type" align="center" />
|
||
|
|
<colspec colname="required" align="center" />
|
||
|
|
<colspec colname="default" align="center" />
|
||
|
|
<colspec colname="desc" />
|
||
|
|
<thead>
|
||
|
|
<row>
|
||
|
|
<entry>属性名</entry>
|
||
|
|
<entry>型</entry>
|
||
|
|
<entry>必須</entry>
|
||
|
|
<entry>デフォルト</entry>
|
||
|
|
<entry>概要</entry>
|
||
|
|
</row>
|
||
|
|
</thead>
|
||
|
|
<tbody>
|
||
|
|
<row>
|
||
|
|
<entry>file</entry>
|
||
|
|
<entry>string</entry>
|
||
|
|
<entry>Yes</entry>
|
||
|
|
<entry><emphasis>n/a</emphasis></entry>
|
||
|
|
<entry>取得するファイル、http あるいは ftp のサイト</entry>
|
||
|
|
</row>
|
||
|
|
<row>
|
||
|
|
<entry>assign</entry>
|
||
|
|
<entry>string</entry>
|
||
|
|
<entry>No</entry>
|
||
|
|
<entry><emphasis>n/a</emphasis></entry>
|
||
|
|
<entry>出力が割り当てられるテンプレート変数</entry>
|
||
|
|
</row>
|
||
|
|
</tbody>
|
||
|
|
</tgroup>
|
||
|
|
</informaltable>
|
||
|
|
|
||
|
|
|
||
|
|
<example>
|
||
|
|
<title>{fetch} の例</title>
|
||
|
|
<programlisting>
|
||
|
|
<![CDATA[
|
||
|
|
{* テンプレートにJavaScriptを含めます *}
|
||
|
|
{fetch file='/export/httpd/www.example.com/docs/navbar.js'}
|
||
|
|
|
||
|
|
{* 他のwebサイトからテンプレートに天候のテキストを埋め込みます *}
|
||
|
|
{fetch file='http://www.myweather.com/68502/'}
|
||
|
|
|
||
|
|
{* ftp経由でニュースヘッドラインファイルを取得します *}
|
||
|
|
{fetch file='ftp://user:password@ftp.example.com/path/to/currentheadlines.txt'}
|
||
|
|
{* 上と同じですが、変数を使用します *}
|
||
|
|
{fetch file="ftp://`$user`:`$password`@`$server`/`$path`"}
|
||
|
|
|
||
|
|
{* 取得したコンテンツをテンプレート変数に割り当てます *}
|
||
|
|
{fetch file='http://www.myweather.com/68502/' assign='weather'}
|
||
|
|
{if $weather ne ''}
|
||
|
|
<div id="weather">{$weather}</div>
|
||
|
|
{/if}
|
||
|
|
]]>
|
||
|
|
</programlisting>
|
||
|
|
</example>
|
||
|
|
<para>
|
||
|
|
<link linkend="language.function.capture"><varname>{capture}</varname></link>、
|
||
|
|
<link linkend="language.function.eval"><varname>{eval}</varname></link>、
|
||
|
|
<link linkend="language.function.assign"><varname>{assign}</varname></link>
|
||
|
|
および
|
||
|
|
<link linkend="api.fetch"><varname>fetch()</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
|
||
|
|
-->
|