mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-11 17:43:50 +01:00
Typos correction and all translated now.
This commit is contained in:
168
docs/id/programmers/plugins/plugins-resources.xml
Normal file
168
docs/id/programmers/plugins/plugins-resources.xml
Normal file
@@ -0,0 +1,168 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.resources"><title>Sumber daya</title>
|
||||
<para>
|
||||
Plugin sumber daya diartikan sebagai cara umum atas penyediaan sumber
|
||||
template atau komponen naskah PHP untuk Smarty. Beberapa contoh
|
||||
sumber daya:
|
||||
database, LDAP, memori berbagi, soket, dan seterusnya.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
Ada empat fungsi yang perlu didaftarkan untuk setiap tipe sumber daya.
|
||||
Setiap fungsi akan menerima sumber daya yang diminta sebagai paramneter
|
||||
pertama dan obyek Smarty sebagai parameter terkahir. Parameter sisanya
|
||||
tergantung pada fungsi.
|
||||
</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>
|
||||
Fungsi pertama, <literal>source()</literal> is supposed to retrieve
|
||||
the resource. Its second parameter <parameter>$source</parameter> is a
|
||||
variable passed by reference where the result should be
|
||||
stored. The function is supposed to return &true; if
|
||||
it was able to successfully retrieve the resource and &false; otherwise.
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
Fungsi kedua, <literal>timestamp()</literal> is supposed to
|
||||
retrieve the last modification time of the requested resource, as a UNIX
|
||||
timestamp. The second parameter <parameter>$timestamp</parameter>
|
||||
is a variable passed by reference where the timestamp should be stored.
|
||||
The function is supposed to return &true; if the timestamp could be
|
||||
succesfully determined, or &false; otherwise.
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
Fungsi ketiga, <literal>secure()</literal>is supposed to return
|
||||
&true; or &false;, depending on whether the requested resource is secure
|
||||
or not. This function is used only for template resources but
|
||||
should still be defined.
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
Fungsi keempat, <literal>trusted()</literal> seharusnya mengembalikan
|
||||
&true; atau &false;, tergantung pada apakah sumber daya yang diminta
|
||||
dipercaya atau tidak. Fungsi ini dipakai hanya untuk komponen naskah PHP
|
||||
yang diminta oleh tag <link linkend="language.function.include.php">
|
||||
<varname>{include_php}</varname></link> atau tag
|
||||
<link linkend="language.function.insert"><varname>{insert}</varname></link>
|
||||
dengan atribut <parameter>src</parameter>. Akan tetapi, ini masih harus
|
||||
didefinisikan meskipun untuk sumber daya template.
|
||||
</para></listitem>
|
||||
</itemizedlist>
|
||||
|
||||
|
||||
<example>
|
||||
<title>plugin sumber daya</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: resource.db.php
|
||||
* Tipe: sumber daya
|
||||
* Nama: db
|
||||
* Kegunaan: Mengambil template dari database
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_resource_db_source($tpl_name, &$tpl_source, &$smarty)
|
||||
{
|
||||
// lakukan pemanggilan database di sini untuk mengambil template anda,
|
||||
// mempopulasikan $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)
|
||||
{
|
||||
// lakukan pemanggilan database di sini untuk mempopulasikan $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)
|
||||
{
|
||||
// menganggap semua template aman
|
||||
return true;
|
||||
}
|
||||
|
||||
function smarty_resource_db_trusted($tpl_name, &$smarty)
|
||||
{
|
||||
// tidak dipakai untuk template
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
LIhat juga
|
||||
<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
|
||||
-->
|
||||
Reference in New Issue
Block a user