mirror of
https://github.com/smarty-php/smarty.git
synced 2025-11-08 16:21:39 +01:00
Typos correction and all translated now.
This commit is contained in:
127
docs/id/programmers/plugins/plugins-block-functions.xml
Normal file
127
docs/id/programmers/plugins/plugins-block-functions.xml
Normal file
@@ -0,0 +1,127 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.block.functions"><title>Fungsi Blok</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>
|
||||
Fungsi blok adalah fungsi dari bentuk:
|
||||
<literal>{func} .. {/func}</literal>. Dengan kata lain, ia ditutupi
|
||||
blok template dan beroperasi pada isi dari blok ini. Fungsi blok
|
||||
mendahului
|
||||
<link linkend="language.custom.functions">fungsi kustom</link> pada
|
||||
nama yang sama, yaitu anda tidak bisa mempunyai kedua fungsi kustom
|
||||
<literal>{func}</literal> dan fungsi blok
|
||||
<literal>{func}..{/func}</literal>.
|
||||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem><para>
|
||||
Standarnya implementasi fungsi anda dipanggil dua kali oleh
|
||||
Smarty: sekali untuk membuka tag, dan sekali untuk meneutup tag.
|
||||
(Lihat <literal>$repeat</literal> di bawah untuk bagaimana mengubah ini.)
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
Hanya tag terbuka terhadap fungsi blok boleh memiliki
|
||||
<link linkend="language.syntax.attributes">atribut</link>. Semua
|
||||
atribut dikirimkan ke fungsi template dari template diisikan dalam
|
||||
variabel <parameter>$params</parameter> sebagai array asosiatif.
|
||||
Atribut tag terbuka juga dapat diakses oleh fungsi anda saat memproses
|
||||
tag penutup.
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
Nilai variabel <parameter>$content</parameter> tergantung pada apakah
|
||||
fungsi anda dipanggil untuk membuka atau menutup tag. Dalam hal
|
||||
membuka tag, ia akan menjadi &null;, dan dalam hal menutup tag
|
||||
ia akan menjadi isi dari blok template.
|
||||
Catatan bahwa blok template sudah diproses oleh Smarty, semua yang
|
||||
akan anda terima adalah output template, bukan sumber template.
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
Parameter <parameter>$repeat</parameter> dikirimkan dengan
|
||||
referensi ke implementasi fungsi dan menyediakan sebuah kemungkinan
|
||||
untuk mengontrol berapa kali blok ditampilkan. Standarnya
|
||||
<parameter>$repeat</parameter> adalah &true; pada panggilan pertama
|
||||
fungsi-blok(tag pembuka) dan and &false; pada panggilan berikutnya
|
||||
ke fungsi blok (tag penutup blok).
|
||||
Setiap kali implementasi fungsi kembali dengan
|
||||
<parameter>$repeat</parameter> menjadi &true;, isi antara
|
||||
<literal>{func}...{/func}</literal> dievaluasi dan implementasi fungsi
|
||||
dipanggil lagi dengan isi blok baru dalam parameter
|
||||
<parameter>$content</parameter>.
|
||||
</para></listitem>
|
||||
</itemizedlist>
|
||||
|
||||
<para>
|
||||
Jika anda mempunyai fungsi blok berulang, dimungkinkan untuk mencari fungsi
|
||||
blok leluhur apa dengan mengakses variabel
|
||||
<literal>$smarty->_tag_stack</literal>. Cukup lakukan
|
||||
<ulink url="&url.php-manual;var_dump"><varname>var_dump()</varname></ulink>
|
||||
padanya dan struktur menjadi terlihat.
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>fungsi blok</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: block.translate.php
|
||||
* Type: block
|
||||
* Name: translate
|
||||
* Purpose: translate a block of text
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_block_translate($params, $content, &$smarty, &$repeat)
|
||||
{
|
||||
// hanya output pada tag penutup
|
||||
if(!$repeat){
|
||||
if (isset($content)) {
|
||||
$lang = $params['lang'];
|
||||
// lakukan beberapa terjemahan puntar di sini dengan $content
|
||||
return $translation;
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
Lihat juga:
|
||||
<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
|
||||
-->
|
||||
97
docs/id/programmers/plugins/plugins-compiler-functions.xml
Normal file
97
docs/id/programmers/plugins/plugins-compiler-functions.xml
Normal file
@@ -0,0 +1,97 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.compiler.functions"><title>Fungsi Kompilator</title>
|
||||
<para>
|
||||
Fungsi kompilator dipanggil hanya selama kompilasi template.
|
||||
Ini berguna untuk menginjeksi kode PHP atau isi statis sensitif-waktu
|
||||
ke dalam template. Jika ada kedua fungsi kompilator dan
|
||||
<link linkend="language.custom.functions">fungsi kustom</link> terdaftar
|
||||
dengan nama sama, fungsi kompilator yang lebih tinggi.
|
||||
</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>
|
||||
Fungsi kompilator diberi dua parameter: argumen string tag - pada
|
||||
dasarnya, apapun dari nama fungsi sampai akhir pemisah, dan obyek
|
||||
Smarty. Ia seharusnya mengembalikan kode PHP yang disisipkan ke dalam
|
||||
template terkompilasi.
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>Fungsi kompilator sederhana</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: compiler.tplheader.php
|
||||
* Tipe: kompilator
|
||||
* Nama: tplheader
|
||||
* Kegunaan: Output header berisi nama file sumber dan waktu
|
||||
* dikompilasinya.
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_compiler_tplheader($tag_arg, &$smarty)
|
||||
{
|
||||
return "\necho '" . $smarty->_current_file . " compiled at " . date('Y-m-d H:M'). "';";
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Fungsi ini dipanggil dari template sebagai:
|
||||
</para>
|
||||
<programlisting>
|
||||
<![CDATA[
|
||||
{* fungsi ini dijalankan hanya saat waktu kompilasi *}
|
||||
{tplheader}
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Kode PHP yang dihasilkan dalam template terkompilasi akan menjadi seperti ini:
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
echo 'index.tpl compiled at 2002-02-20 20:02';
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
|
||||
<para>
|
||||
Lihat juga
|
||||
<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
|
||||
-->
|
||||
130
docs/id/programmers/plugins/plugins-functions.xml
Normal file
130
docs/id/programmers/plugins/plugins-functions.xml
Normal file
@@ -0,0 +1,130 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.functions"><title>Fungsi Template</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>
|
||||
Semua <link linkend="language.syntax.attributes">atribut</link> yang
|
||||
dikirimkan ke fungsi template dari template yang berisi
|
||||
<parameter>$params</parameter> sebagai array asosiatif.
|
||||
</para>
|
||||
<para>
|
||||
Output (nilai hasil) atas fungsi akan diganti di tempat tag fungsi dalam
|
||||
template, misalnya fungsi
|
||||
<link linkend="language.f unction.fetch"><varname>{fetch}</varname></link>.
|
||||
Alternatif lain, fungsi bisa hanya melakukan beberapa tugas tanpa output
|
||||
apapun, misalnya fugnsi <link linkend="language.function.assign">
|
||||
<varname>{assign}</varname></link>.
|
||||
</para>
|
||||
<para>
|
||||
Jika fungsi perlu menempatkan beberapa variabel ke template atau gunakan
|
||||
beberapa fungsionalitas lain yang disediakan-Smarty, ini dapat menggunakan
|
||||
obyek <parameter>$smarty</parameter> yang disertakan untuk melakukannya
|
||||
misaslnya <literal>$smarty->foo()</literal>.
|
||||
</para>
|
||||
|
||||
<para>
|
||||
<example>
|
||||
<title>plugin fungsi dengan output</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: function.eightball.php
|
||||
* Tipe: fungsi
|
||||
* Nama: eightball
|
||||
* Kegunaan: menampilkan jawaban acak magis
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_function_eightball($params, &$smarty)
|
||||
{
|
||||
$answers = array('Yes',
|
||||
'No',
|
||||
'No way',
|
||||
'Outlook not so good',
|
||||
'Ask again soon',
|
||||
'Maybe in your reality');
|
||||
|
||||
$result = array_rand($answers);
|
||||
return $answers[$result];
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
yang dapat digunakan dalam template sebagai:
|
||||
</para>
|
||||
<programlisting>
|
||||
Question: Will we ever have time travel?
|
||||
Answer: {eightball}.
|
||||
</programlisting>
|
||||
<para>
|
||||
<example>
|
||||
<title>plugin fungsi tanpa output</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: function.assign.php
|
||||
* Tipe: fungsi
|
||||
* Nama: assign
|
||||
* Kegunaan: menempatkan nilai ke varabel template
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_function_assign($params, &$smarty)
|
||||
{
|
||||
if (empty($params['var'])) {
|
||||
$smarty->trigger_error("assign: missing 'var' parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!in_array('value', array_keys($params))) {
|
||||
$smarty->trigger_error("assign: missing 'value' parameter");
|
||||
return;
|
||||
}
|
||||
|
||||
$smarty->assign($params['var'], $params['value']);
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
</para>
|
||||
<para>
|
||||
Lihat juga:
|
||||
<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
|
||||
-->
|
||||
45
docs/id/programmers/plugins/plugins-howto.xml
Normal file
45
docs/id/programmers/plugins/plugins-howto.xml
Normal file
@@ -0,0 +1,45 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.howto">
|
||||
<title>Bagaimana Plugin Bekerja</title>
|
||||
<para>
|
||||
Plugin selalu diambil saat dibutuhkan. Hanya pengubah tertentu,
|
||||
fungsi, sumber daya, dll yang diminta dalam naskah template akan diambil.
|
||||
Selanjutnya, setiap plugin diambil hanya sekali, meskipun anda mempunyai
|
||||
beberapa turunan Smarty yang berjalan dalam permintaan yang sama.
|
||||
</para>
|
||||
<para>
|
||||
Pre/postfilters dan filter output sedikit dari hal khusus. Karena tidak
|
||||
disetbutkan dalam template, ini harus didaftarkan atau diambil secara
|
||||
eksplisit melalui fungis API sebelum template diproses.
|
||||
Urutan di mana multipel filter dengan tipe sama dijalankan tergantung
|
||||
pada urutan di mana ia didaftarkan atau diambil.
|
||||
</para>
|
||||
<para>
|
||||
<link linkend="variable.plugins.dir">Direktori plugin</link>
|
||||
dapat berupa string yang berisi path atau array yang berisi multipel
|
||||
path. Untuk menginstalasi sebuah plugin, cukup tempatkan dalam salah satu
|
||||
direktori dan Smarty akan menggunakannya secara otomatis.
|
||||
</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
|
||||
-->
|
||||
71
docs/id/programmers/plugins/plugins-inserts.xml
Normal file
71
docs/id/programmers/plugins/plugins-inserts.xml
Normal file
@@ -0,0 +1,71 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.inserts"><title>Inserts</title>
|
||||
<para>
|
||||
Plugin insert dipakai untuk mengimplementasikan fungsi yang diminta oleh
|
||||
tag <link linkend="language.function.insert"><varname>{insert}</varname></link>
|
||||
dalam template.
|
||||
</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>
|
||||
Parameter pertama ke fungsi adalah array asosiatif dari atribut yang
|
||||
dikirimkan ke insert.
|
||||
</para>
|
||||
<para>
|
||||
Fungsi insert seharusnya mengembalikan hasil yang akan di tempatkan pada
|
||||
tag <varname>{insert}</varname> dalam template.
|
||||
</para>
|
||||
<example>
|
||||
<title>plugin insert</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: insert.time.php
|
||||
* Tipe: time
|
||||
* Nama: time
|
||||
* Kegunaan: Menyisipkan tanggak/jam saat ini berdasarkan format
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
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
|
||||
-->
|
||||
116
docs/id/programmers/plugins/plugins-modifiers.xml
Normal file
116
docs/id/programmers/plugins/plugins-modifiers.xml
Normal file
@@ -0,0 +1,116 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.modifiers"><title>Pengubah</title>
|
||||
<para>
|
||||
<link linkend="language.modifiers">Pengubah</link> adalah fungsi kecil
|
||||
yang diterapkan ke variabel dalam template sebelum ia ditampilkan atau
|
||||
digunakan dalam beberapa konteks lain. Pengubah dapat dirangkai bersama.
|
||||
</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>
|
||||
Parameter pertama pada plugin pengubah adalah nilai di mana pengubah
|
||||
beroperasi. Parameter sisanya adalah opsional, tergantung pada
|
||||
jenis operasi apa yang dilakukan.
|
||||
</para>
|
||||
<para>
|
||||
Pengubah harus <ulink url="&url.php-manual;return">mengembalikan</ulink>
|
||||
hasil dari prosesnya.
|
||||
</para>
|
||||
|
||||
<example>
|
||||
<title>Plugin pengubah sederhana</title>
|
||||
<para>
|
||||
Plugin ini pada dasarnya alias dari salah satu fungsi built-in PHP.
|
||||
Ini tidak mempunyai parameter tambahan.
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: modifier.capitalize.php
|
||||
* Tipe: pengubah
|
||||
* Nama: capitalize
|
||||
* Kegunaan: membesarkan kata dalam string
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_modifier_capitalize($string)
|
||||
{
|
||||
return ucwords($string);
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para></para>
|
||||
<example>
|
||||
<title>Plugin pengubah lebih kompleks</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: modifier.truncate.php
|
||||
* Tipe: pengubah
|
||||
* Nama: truncate
|
||||
* Kegunaan: Potong string ke panjang tertentu bila perlu,
|
||||
* secara opsional memisahkan di tengah kata, dan
|
||||
* menambahkan string $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>
|
||||
Lihat juga
|
||||
<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
|
||||
-->
|
||||
95
docs/id/programmers/plugins/plugins-naming-conventions.xml
Normal file
95
docs/id/programmers/plugins/plugins-naming-conventions.xml
Normal file
@@ -0,0 +1,95 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.naming.conventions">
|
||||
<title>Konvensi Penamaan</title>
|
||||
<para>
|
||||
File plugin dan fungsi harus mengikuti konvensi penamaan khusus agar
|
||||
dapat ditempatkan oleh Smarty.
|
||||
</para>
|
||||
<para>
|
||||
<emphasis role="bold">file plugin</emphasis> harus dinamai sebagai berikut:
|
||||
<blockquote>
|
||||
<para>
|
||||
<filename>
|
||||
<replaceable>type</replaceable>.<replaceable>name</replaceable>.php
|
||||
</filename>
|
||||
</para>
|
||||
</blockquote>
|
||||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem><para>
|
||||
Di mana <literal>type</literal> salah satu tipe plugin ini:
|
||||
<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>
|
||||
Dan <literal>name</literal> harus pengenal yang benar; huruf,
|
||||
angka, dan hanya garis bawah, lihat
|
||||
<ulink url="&url.php-manual;language.variables">variabel php</ulink>.
|
||||
</para></listitem>
|
||||
|
||||
<listitem><para>
|
||||
Beberapa contoh: <filename>function.html_select_date.php</filename>,
|
||||
<filename>resource.db.php</filename>,
|
||||
<filename>modifier.spacify.php</filename>.
|
||||
</para>
|
||||
</listitem>
|
||||
</itemizedlist>
|
||||
|
||||
|
||||
<para>
|
||||
<emphasis role="bold">fungsi plugin</emphasis> di dalam file PHP harus dinamai sebagai berikut:
|
||||
<blockquote>
|
||||
<para>
|
||||
<function>smarty_<replaceable>type</replaceable>_<replaceable>name</replaceable></function>
|
||||
</para>
|
||||
</blockquote>
|
||||
</para>
|
||||
|
||||
<itemizedlist>
|
||||
<listitem><para>
|
||||
Arti dari <literal>type</literal> dan <literal>name</literal> sama seperti di atas.
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
Contoh nama pengubah <varname>foo</varname> akan menjadi <literal>function smarty_modifier_foo()</literal>.
|
||||
</para></listitem>
|
||||
</itemizedlist>
|
||||
<para>
|
||||
Smarty akan menampilkan pesan kesalahan terkait jika file plugin yang
|
||||
dibutuhkan tidak ditemukan, atau jika file atau fungsi plugin dinamai
|
||||
secara tidak benar.
|
||||
</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
|
||||
-->
|
||||
73
docs/id/programmers/plugins/plugins-outputfilters.xml
Normal file
73
docs/id/programmers/plugins/plugins-outputfilters.xml
Normal file
@@ -0,0 +1,73 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.outputfilters"><title>Filter Output</title>
|
||||
<para>
|
||||
Plugin filter output beroperasi pada output template, setelah template
|
||||
diambil dan dijalankan, tapi sebelum output ditampilkan.
|
||||
</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>
|
||||
Parameter pertama pada fungsi filter output adalah output template
|
||||
yang perlu diproses, dan parameter kedua adalah turunan dari Smarty
|
||||
yang meminta plugin. Plugin seharusnya melakukan proses dan
|
||||
mengembalikan hasilnya.
|
||||
</para>
|
||||
<example>
|
||||
<title>Plugin filter output</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: outputfilter.protect_email.php
|
||||
* Tipe: outputfilter
|
||||
* Nama: protect_email
|
||||
* Kegunaan: Mengubah tanda @ dalam alamat email menjadi %40
|
||||
* sebagai proteksi sedarhana terhadap spambots
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
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>
|
||||
Lihat juga
|
||||
<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
|
||||
-->
|
||||
117
docs/id/programmers/plugins/plugins-prefilters-postfilters.xml
Normal file
117
docs/id/programmers/plugins/plugins-prefilters-postfilters.xml
Normal file
@@ -0,0 +1,117 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.prefilters.postfilters">
|
||||
<title>Prefilters/Postfilters</title>
|
||||
<para>
|
||||
Plugin prefilter dan postfilter sangat mirip dalam konsep; di mana
|
||||
keduanya berbeda dalam eksekusi -- lebih tepatnya waktu eksekusinya.
|
||||
</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>
|
||||
Prefilters dipakai untuk memproses sumber template segera sebelum
|
||||
kompilasi. Parameter pertama ke fungsi prefilter adalah sumber
|
||||
template, kemungkinan diubah oleh beberapa prefilters lain. Plugin
|
||||
seharusnya mengembalikan sumber yang diubah. Catatan bahwa sumber
|
||||
ini tidak disimpan di mana pun, hanya dipakai untuk kompilasi.
|
||||
</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>
|
||||
Postfilters dipakai untuk memproses output terkompilasi dari template
|
||||
(kode PHP) segera setelah kompilasi dikerjakan sebelum template
|
||||
terkompilasi disimpan ke sistem file. Parameter pertama ke fungsi
|
||||
postfilter adalah kode template terkompilasi, kemungkinan diubah oleh
|
||||
postfilters lainnya. Plugin seharusnya mengembalikan versi yang diubah
|
||||
atas kode ini.
|
||||
</para>
|
||||
<example>
|
||||
<title>plugin prefilter</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: prefilter.pre01.php
|
||||
* Tipe: prefilter
|
||||
* Nama: pre01
|
||||
* Kegunaan: Mengubah tag html ke huruf kecil.
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_prefilter_pre01($source, &$smarty)
|
||||
{
|
||||
return preg_replace('!<(\w+)[^>]+>!e', 'strtolower("$1")', $source);
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para></para>
|
||||
<example>
|
||||
<title>plugin postfilter</title>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
/*
|
||||
* Smarty plugin
|
||||
* -------------------------------------------------------------
|
||||
* File: postfilter.post01.php
|
||||
* Tipe: postfilter
|
||||
* Nama: post01
|
||||
* Kegunaan: Kode output yang mendaftarkan semua var template saat
|
||||
* ini.
|
||||
* -------------------------------------------------------------
|
||||
*/
|
||||
function smarty_postfilter_post01($compiled, &$smarty)
|
||||
{
|
||||
$compiled = "<pre>\n<?php print_r(\$this->get_template_vars()); ?>\n</pre>" . $compiled;
|
||||
return $compiled;
|
||||
}
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
</example>
|
||||
<para>
|
||||
Lihat juga
|
||||
<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/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
|
||||
-->
|
||||
64
docs/id/programmers/plugins/plugins-writing.xml
Normal file
64
docs/id/programmers/plugins/plugins-writing.xml
Normal file
@@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision$ -->
|
||||
<sect1 id="plugins.writing">
|
||||
<title>Menulis Plugin</title>
|
||||
<para>
|
||||
Plugin dapat diambil baik oleh Smarty secara otomatis dari sistem
|
||||
file ataupun didaftarkan saat runtime via salah satu fungsi API
|
||||
register_*. Juga dapat dibatalkan registrasinya dengan menggunakan
|
||||
fungsi API unregister_*.
|
||||
</para>
|
||||
<para>
|
||||
Untuk plugin yang terdaftar saat runtime, nama fungsi plugin tidak
|
||||
harus mengikuti konvensi penamaan.
|
||||
</para>
|
||||
<para>
|
||||
Jika sebuah plugin tergantung pada beberapa fungsionalitas yang
|
||||
disediakan oleh plugin lainnya (seperti dengan beberapa plugin
|
||||
yang dibundel dengan Smarty), maka cara yang benar untuk mengambil
|
||||
plugin yang dibutuhkan ialah:
|
||||
</para>
|
||||
<programlisting role="php">
|
||||
<![CDATA[
|
||||
<?php
|
||||
require_once $smarty->_get_plugin_filepath('function', 'html_options');
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
Sebagai aturan umum, obyek Smarty selalu dikirimkan ke plugin sebagai
|
||||
parameter terakhir dengan dua kekecualian:
|
||||
</para>
|
||||
<itemizedlist>
|
||||
<listitem><para>
|
||||
pengubah tidak mendapatkan obyek Smarty sama sekali
|
||||
</para></listitem>
|
||||
<listitem><para>
|
||||
blok mendapatkan kirim
|
||||
<parameter>$repeat</parameter> setelah obyek Smarty untuk memelihara
|
||||
kompatibilitas mundur dengan versi Smarty sebelumnya.
|
||||
</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