cvs: smarty /docs/ru/appendixes bugs.xml resources.xml tips.xml troubleshooting.xml
"Mehdi Achour" <[email protected]>
| Newsgroups | gmane.comp.php.cvs.smarty |
|---|---|
| Message-ID | <cvsdidou1080637536@cvsserver> |
didou Tue Mar 30 04:05:36 2004 EDT
Added files:
/smarty/docs/ru/appendixes bugs.xml resources.xml tips.xml
troubleshooting.xml
Log:
add RU docs
# work from Sergei Suslenkov
--
Smarty CVS Mailing List (http://cvs.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
didou-20040330040536.txt
(text/plain, 16.5 KB)
http://cvs.php.net/co.php/smarty/docs/ru/appendixes/bugs.xml?r=1.1&p=1
Index: smarty/docs/ru/appendixes/bugs.xml
+++ smarty/docs/ru/appendixes/bugs.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<chapter id="bugs">
<title>BUGS</title>
<para>
Check the BUGS file that comes with the latest distribution of Smarty, or
check the website.
</para>
</chapter>
<!-- 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
-->
http://cvs.php.net/co.php/smarty/docs/ru/appendixes/resources.xml?r=1.1&p=1
Index: smarty/docs/ru/appendixes/resources.xml
+++ smarty/docs/ru/appendixes/resources.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<chapter id="resources">
<title>Èñòî÷íèêè</title>
<para>
Äîìàøíÿÿ ñòðàíèöà Smarty: <ulink
url="&url.smarty;">&url.smarty;</ulink>
Äëÿ ïîäïèñêè íà íîâîñòè, íàäî ïîñëàòü ïèñüìî íà
&ml.general.sub;.
Àðõèâ ïîäïèñêè äîñòóïåí íà
<ulink url="&url.ml.archive;">&url.ml.archive;</ulink>.
</para>
</chapter>
<!-- 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
-->
http://cvs.php.net/co.php/smarty/docs/ru/appendixes/tips.xml?r=1.1&p=1
Index: smarty/docs/ru/appendixes/tips.xml
+++ smarty/docs/ru/appendixes/tips.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<chapter id="tips">
<title>Óëîâêè</title>
<para>
</para>
<sect1 id="tips.blank.var.handling">
<title>Îáðàáîòêà ïóñòûõ ïåðåìåííûõ</title>
<para>
Èíîãäà, íàïðèìåð, äëÿ òîãî ÷òîáû ôîí òàáëèöû ðàáîòàë êîððåêòíî,
íåîáõîäèìî âûâåñòè âìåñòî ïóñòîãî çíà÷åíèÿ ïåðåìåííîé, çíà÷åíèå
ïî óìîë÷àíèþ "&nbsp;". Ìíîãèå áû èñïîëüçîâàëè êîíñòðóêöèþ {if},
íî åñòü áîëåå êîðîòêèé ïóòü â Smatry èñïîëüçóÿ <emphasis>default</emphasis>
ìîäèôèêàòîð ïåðåìåííîé.
</para>
<example>
<title>Âûâîä &nbsp; êîãäà ïåðåìåííàÿ ïóñòà</title>
<programlisting>
{* äëèííûé ïóòü *}
{if $title eq ""}
&nbsp;
{else}
{$title}
{/if}
{* êîðîòêèé ïóòü *}
{$title|default:"&nbsp;"}</programlisting>
</example>
</sect1>
<sect1 id="tips.default.var.handling">
<title>Îáðàáîòêà ïåðåìåííûõ ïî óìëî÷àíèþ</title>
<para>
Åñëè ïåðåìåííàÿ âñòðå÷àåòñÿ ÷àñòî, òî èñïîëüçîâàíèå ìîäèôèêàòîðà
default êàæäûé ðàç ìîæíî èçáåæàòü, èñïîëüçóÿ ôóíêöèþ
<link linkend="language.function.assign">assign</link>.
</para>
<example>
<title>Íàçíà÷åíèå ïåðåìåííîé øàáëîíà çíà÷åíèÿ ïî óìîë÷àíèþ</title>
<programlisting>
{* ââåðõó øàáëîíà *}
{assign var="title" value=$title|default:"no title"}
{* åñëè ïåðåìåííàÿ $title áûëà ïóñòîé, òî ñåé÷àñ îíà ñîäåðæèò "no title" *}
{$title}</programlisting>
</example>
</sect1>
<sect1 id="tips.passing.vars">
<title>Ïðèñâîåíèå ïåðåìåííîé çàãîëîâêà (title) çàãîëîâêó øàáëîíà.</title>
<para>
Rîãäà áîëüøèíñòâî âàøèõ øàáëîíîâ èìåþò ïîõîæèå âåðõíèå ÷àñòè
è íèæíèå, òî èìååò ñìûñë âûíåñòè èõ â îòäåëüíûå ôàéëû. Íî åñëè
øàïêà äîëæíà èìåòü ðàçëè÷íûå çàãîëîâêè íà ðàçëè÷íûõ ñòðàíèöàõ?
Âû ìîæåòå ïåðåäàòü çàãîëîâîê â øàïêó, êîãäà îíà ïðèñîåäèíÿåòüñÿ.
</para>
<example>
<title>Ïðèñâîåíèå ïåðåìåííîé çàãîëîâêà (title) çàãîëîâêó øàáëîíà.</title>
<programlisting>
mainpage.tpl
------------
{include file="header.tpl" title="Main Page"}
{* òåëî øàáëîíà *}
{include file="footer.tpl"}
archives.tpl
------------
{config_load file="archive_page.conf"}
{include file="header.tpl" title=#archivePageTitle#}
{* òåëî øàáëîíàe *}
{include file="footer.tpl"}
header.tpl
----------
<HTML>
<HEAD>
<TITLE>{$title|default:"BC News"}</TITLE>
</HEAD>
<BODY>
footer.tpl
----------
</BODY>
</HTML></programlisting>
</example>
<para>
Åñëè âûâîäèòñÿ ãëàâíàÿ ñòðàíèöà, òî çàãîëîâîê áóäåò "Main Page",
åñëè àðõèâû, òî çàãîëîâê áåðåòñÿ èç ôàéëà êîíôèãóðàöèè. Åñëè
çàãîëîâîê áóäåò ïóñòîé, òî âûâåäåòüñÿ çíà÷åíèå ïî óìîë÷àíèþ "BC News".
</para>
</sect1>
<sect1 id="tips.dates">
<title>Äàòû</title>
<para>
Îáû÷íî äàòû â Smarty âñåãäà ïåðåäàþòñÿ êàê timestamps, ÷òî
ïîçâîëÿåò ïðîåêòèðîâùèêàì øàáëîíà èñïîëüçîâàòü <link
linkend="language.modifier.date.format">date_format</link>
äëÿ ïîëíîãî íàä ôîðìàòèðîâàíèåì äàòû, è òàêæå äåëàåò ëåãêèì
ñðàâíåíèå äàò åñëè íåîáõîäèìî.
</para>
<para>
ÇÀÌÅ×ÀÍÈÅ: Îò Smarty 1.4.0 âû ìîæåòå ïåðåäàâàòü äàòû êàê unix
timestamps, mysql timestamps, èëè ëþáûå äðóãèå äàòû, êîòîðûå
îáðàáîòàþòñÿ strtotime().
</para>
<example>
<title>èñïîëüçîâàíèå date_format</title>
<programlisting>
{$startDate|date_format}
ÂÛÂÎÄ:
Jan 4, 2001
{$startDate|date_format:"%Y/%m/%d"}
ÂÛÂÎÄ:
2001/01/04
{if $date1 < $date2}
...
{/if}</programlisting>
</example>
<para>
Êîãäà {html_select_date} èñïîëüçóåòñÿ â øàáëîíå, ïðîãðàììèñòû îáû÷íî
õîòÿò ïîëó÷èòü äàòó âèäå timestamp. Ôîò ôóíêöèÿ, êîòîðàÿ ïîìîæåò ýòî
ñäåëàòü.
</para>
<example>
<title>Ïðåîáðàçîâàíèå ýëåìåíòîâ ôîðìû ââîäà äàòû íàçàä ê timestamp</title>
<programlisting>
// Ïðåäïîëàãàåòñÿ, ÷òî âàøè ýëåìåíòû ôîðìû íàçâàíû
// startDate_Day, startDate_Month, startDate_Year
$startDate = makeTimeStamp($startDate_Year,$startDate_Month,$startDate_Day);
function makeTimeStamp($year="",$month="",$day="")
{
if(empty($year))
$year = strftime("%Y");
if(empty($month))
$month = strftime("%m");
if(empty($day))
$day = strftime("%d");
return mktime(0,0,0,$month,$day,$year);
}</programlisting>
</example>
</sect1>
<sect1 id="tips.wap">
<title>WAP/WML</title>
<para>
WAP/WML øàáëîíû òðåáóþò, ÷òîáû PHP content-type çàãîëîâêè áûëè
ïåðåäàíû âìåñòå ñ øàáëîíîì. Ïðîñòåéøèé ïóòü - íàïèñàòü
ïîëüçîâàòåëüñêóþ ôóíêöèþ, êîòîðàÿ áóäåò âûâîäèòü çàãîëîâêè.
Òàê êàê ìû áóäåì ïîëüçîâàòüñÿ òýãàìè insert òî çàãîëîâêè íå áóäóò
êýøèðîâàòüñÿ. Òàê æå íè÷åãî íå äîëæíî âûâîäèòüñÿ â áðàóçåð äî
øàáëîíà, èíà÷å çàãîëîâêè ìîãóò áûòü íåïðàâèëüíî âîñïðèíÿòû.
</para>
<example>
<title>Bñïîëüçîâàíèå insert äëÿ çàïèñè WML Content-Type çàãîëîâêîâ</title>
<programlisting>
// Apache äîëæåí áûòü ñêîíôèãóðèðîâàí ñ .wml ðàñøèðåíèåì!
// ïîìåñòèòå ýòó ôóíêöèþ â ïðèëîæåíèå, èëè â Smarty.addons.php
function insert_header() {
// this function expects $content argument
extract(func_get_arg(0));
if(empty($content))
return;
header($content);
return;
}
// øàáëîí ÄÎËÆÅÍ íà÷èíàòüñÿ ñ òýãà insert. Ïðèìåð:
{insert name=header content="Content-Type: text/vnd.wap.wml"}
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.1//EN" "http://www.wapforum.org/DTD/wml_1.1.xml">
<!-- begin new wml deck -->
<wml>
<!-- begin first card -->
<card>
<do type="accept">
<go href="#two"/>
</do>
<p>
Welcome to WAP with Smarty!
Press OK to continue...
</p>
</card>
<!-- begin second card -->
<card id="two">
<p>
Pretty easy isn't it?
</p>
</card>
</wml></programlisting>
</example>
</sect1>
<sect1 id="tips.componentized.templates">
<title>Ñîñòàâíûå øàáëîíû</title>
<para>
This tip is a bit of a hack, but still a neat idea. Use at your own
risk. ;-)
</para>
<para>
Traditionally, programming templates into your applications goes as
follows: First, you accumulate your variables within your PHP
application, (maybe with database queries.) Then, you instantiate your
Smarty object, assign the variables and display the template. So lets
say for example we have a stock ticker on our template. We would
collect the stock data in our application, then assign these variables
in the template and display it. Now wouldn't it be nice if you could
add this stock ticker to any application by merely including the
template, and not worry about fetching the data up front?
</para>
<para>
You can embed PHP into your templates with the {php}{/php} tags.
With this, you can setup self contained templates with their own
data structures for assigning their own variables. With the logic
embedded like this, you can keep the template & logic together. This
way no matter where the template source is coming from, it is always
together as one component.
</para>
<example>
<title>componentized template</title>
<programlisting>
{* Smarty *}
{php}
// setup our function for fetching stock data
function fetch_ticker($symbol,&$ticker_name,&$ticker_price) {
// put logic here that fetches $ticker_name
// and $ticker_price from some resource
}
// call the function
fetch_ticker("YHOO",$ticker_name,$ticker_price);
// assign template variables
$this->assign("ticker_name",$ticker_name);
$this->assign("ticker_price",$ticker_price);
{/php}
Stock Name: {$ticker_name} Stock Price: {$ticker_price}</programlisting>
</example>
<para>
As of Smarty 1.5.0, there is even a cleaner way. You can include php in
your templates with the {include_php ...} tag. This way you can keep
your PHP logic separated from the template logic. See the <link
linkend="language.function.include.php">include_php</link> function for
more information.
</para>
<example>
<title>componentized template with include_php</title>
<programlisting>
load_ticker.php
---------------
<?php
// setup our function for fetching stock data
function fetch_ticker($symbol,&$ticker_name,&$ticker_price) {
// put logic here that fetches $ticker_name
// and $ticker_price from some resource
}
// call the function
fetch_ticker("YHOO",$ticker_name,$ticker_price);
// assign template variables
$this->assign("ticker_name",$ticker_name);
$this->assign("ticker_price",$ticker_price);
?>
index.tpl
---------
{* Smarty *}
{include_php file="load_ticker.php"}
Stock Name: {$ticker_name} Stock Price: {$ticker_price}</programlisting>
</example>
</sect1>
<sect1 id="tips.obfuscating.email">
<title>Obfuscating E-mail Addresses</title>
<para>
Do you ever wonder how your E-mail address gets on so many spam mailing
lists? One way spammers collect E-mail addresses is from web pages. To
help combat this problem, you can make your E-mail address show up in
scrambled javascript in the HTML source, yet it it will look and work
correctly in the browser. This is done with the mailto plugin.
</para>
<example>
<title>Example of Obfuscating an E-mail Address</title>
<programlisting>
index.tpl
---------
Send inquiries to
{mailto address=$EmailAddress encode="javascript" subject="Hello"}
</programlisting>
</example>
<note>
<title>Technical Note</title>
<para>
This method isn't 100% foolproof. A spammer could conceivably program his
e-mail collector to decode these values, but not likely.
</para>
</note>
</sect1>
</chapter>
<!-- 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
-->
http://cvs.php.net/co.php/smarty/docs/ru/appendixes/troubleshooting.xml?r=1.1&p=1
Index: smarty/docs/ru/appendixes/troubleshooting.xml
+++ smarty/docs/ru/appendixes/troubleshooting.xml
<?xml version="1.0" encoding="iso-8859-1"?>
<!-- $Revision: 1.1 $ -->
<chapter id="troubleshooting">
<title>Troubleshooting</title>
<para></para>
<sect1 id="smarty.php.errors">
<title>Smarty/PHP errors</title>
<para>
Smarty ìîæåò ðàñïîçíàòü ìíîãî îøèáîê òèïà îòñóòñòâóþùèõ ïðèçíàêîâ ïðèçíàêà
Èëè óðîäëèâûå ïåðåìåííûå íàçâàíèÿ(èìåíà). Åñëè ýòî ñëó÷àåòñÿ, Âû áóäåòå âèäåòü îøèáêó
Ïîäîáíûé ñëåäóþùåìó:
Smarty can catch many errors such as missing tag attributes
or malformed variable names. If this happens, you will see an error
similar to the following:
</para>
<example>
<title>Smarty errors</title>
<programlisting>
Warning: Smarty: [in index.tpl line 4]: syntax error: unknown tag - '%blah'
in /path/to/smarty/Smarty.class.php on line 1041
Fatal error: Smarty: [in index.tpl line 28]: syntax error: missing section name
in /path/to/smarty/Smarty.class.php on line 1041</programlisting>
</example>
<para>
Smarty shows you the template name, the line number and the error.
After that, the error consists of the actual line number in the Smarty
class that the error occured.
</para>
<para>
There are certain errors that Smarty cannot catch, such as missing
close tags. These types of errors usually end up in PHP compile-time
parsing errors.
</para>
<example>
<title>PHP parsing errors</title>
<programlisting>
Parse error: parse error in /path/to/smarty/templates_c/index.tpl.php on line 75</programlisting>
</example>
<para>
When you encounter a PHP parsing error, the error line number will
correspond to the compiled PHP script, not the template itself. Usually
you can look at the template and spot the syntax error. Here are some
common things to look for: missing close tags for {if}{/if} or
{section}{/section}, or syntax of logic within an {if} tag. If you
can't find the error, you might have to open the compiled PHP file and
go to the line number to figure out where the corresponding error is in
the template.
</para>
</sect1>
</chapter>
<!-- 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
-->