Location: PHPKode > scripts > Property sheets drawing engine > property-sheets-drawing-engine/as_propsheet.rus.htm
<HTML>
<HEAD><TITLE>as_propsheet: Êëàññû äëÿ âûâîäà Property Sheet-ñòðàíèö</TITLE>
<META http-equiv="Content-Type" Content="text/html; charset=windows-1251">
<STYLE TYPE="text/css">
<!--
  body     { font-family:arial,helvetica;font-size:12px; }
  pre { color:#0000FF; }
  td   { font-family:arial,helvetica;font-size:12px;}
  tr.head  { background-color: #D0D0FF; color:#000000; font-size:13px; font-weight:bold; }
  tr.odd   { background-color: #F0F0F8; color:#000000; }
  tr.even  { background-color: #E0E0F0; color:#000000; }
  h4       { background-color: #E0E0F0; color:#000000;
           text-align: left; }
  h5       { background-color: #E0E0F0; color:#000000;
           text-align: center; }
  pre    { font-family:arial,helvetica;font-size:12px; color:#000080; font-weight:bold;}
-->
</STYLE>

</head>
<BODY>
<H3>as_propsheet: Êëàññû äëÿ âûâîäà Property Sheet-ñòðàíèö</H3>

<div align=right><a href="as_propsheet.htm">English version</a><br><br></div>

<p>
Äàííûé ìîäóëü ñëóæèò äëÿ ïîñòðîåíèÿ ìóëüòè-ñòðàíè÷íûõ ýêðàíîâ ââîäà äàííûõ,
èçâåñòíûõ "â ìèðó" êàê Property Sheet.
<br>as_propsheet ìîæåò âûâîäèòü äâà òèïà ìíîãîñòðàíè÷íûõ ýêðàíîâ: "TAB-style" ýêðàíû
(äëÿ ïåðåêëþ÷åíèÿ ñòðàíèö ñëóæàò "çàêëàäêè" â âåðõíåé ÷àñòè),
 è "WIZARD-style" ýêðàíû (ïîñëåäîâàòåëüíûé ïåðåõîä îò ñòðàíèöû ê ñòðàíèöå, ñ ïîìîùüþ êíîïîê
 "Ñëåäóþùèé","ïðåäûäóùèé", è "Finish").

<p><b>ÂÍÈÌÀÍÈÅ</b>: äëÿ âûâîäà èñïîëüçóþòñÿ JavaScript è âîçìîæíîñòè DHTML, òàê ÷òî íóæíî
ïîìíèòü î ñîâìåñòèìîñòè ñ ïðåäïîëàãàåìûìè âåðñèÿìè áðàóçåðîâ,
ïðè ðàçâåðòûâàíèè ôèíàëüíîãî ïðîåêòà â èíòðà- èëè èíòåðíåò.

<p>
Íèæå ïðèâîäèòñÿ îïèñàíèå ðàáîòû ñ êëàññàìè ìîäóëÿ as_propsheet.

<br>
<H4>Óñòàíîâêà as_propsheet íà Âàøåì ñàéòå</H4>

<ol>
  <li>Çàãðóçèòå äèñòðèáóòèâíûé zip ôàéë è ðàñïàêóéòå â ëþáîé êàòàëîã.
  Åñëè "äâèæîê" Property Sheet áóäåò èñïîëüçîâàòüñÿ âî ìíîãèõ ôàéëàõ, öåëåñîîáðàçíî ïîìåñòèòü
  ôàéë as_propsheet.php â îäíó èç ïàïîê, ïåðå÷èñëåííûõ â ôàéëå PHP.ini, ïåðåìåííîé "include_path".
   ïðîòèâíîì ñëó÷àå äîñòàòî÷íî ïîëîæèòü åãî â îäíó ïàïêó ñî ñâîèì ïðîåêòîì.
  </li>
  <li>  íà÷àëå ñâîåãî PHP-ñêðèïòà âñòàâèòü ñòðîêó ïîëäêëþ÷åíèÿ ìîäóëÿ:<br>
    <b>require_once('as_propsheet.php');</b>
  </li>
  <li>Ïîäãîòîâèòü íåñêîëüêî CSS-êëàññîâ, èñïîëüçóåìûõ â as_propsheet äëÿ ïðàâèëüíîãî îòîáðàæåíèÿ
  ýëåìåíòîâ íà ýêðàíå (ñì.ñëåäóþùóþ ÷àñòü)</li>
</ol>

<br>
<H4>Ïîäãîòîâêà CSS ñòèëåé äëÿ ðàáîòû ñ Property sheet</H4>
as_propsheet èñïîëüçóåò ïðåäîïðåäåëåííûå è îïèñàííûå âíå ñàìîãî ìîäóëÿ css-êëàññû.
Îáðàçåö èõ ìîæåò áûòü âçÿò â ðàáî÷åì ïðèìåðå - as_propsheet_sample.php.
<br>Âû ìîæåòå çàìåíèòü èìåíà êëàññîâ "ïî óìîë÷àíèþ" íà ñâîè, äîáàâèâ äî âûçîâà ôóíêöèè ðèñîâàíèÿ (Draw())
îïåðàòîðû âèäà <b>$as_cssclass['textfield']='mycssname';</b>
<br>
Ñïèñîê èìåí êëàññîâ çàäàåòñÿ â ãëîáàëüíîé ïåðåìåííîé-ìàññèâå $as_cssclass:
<ul>
<li><b>$as_cssclass['textfield']</b> (ïî óìîë÷. - 'ibox') - ñòèëü äëÿ âûâîäà òåêñòîâûõ ïîëåé ââîäà (input type=text|password|textarea)
<li><b>$as_cssclass['button']</b>  (ïî óìîë÷. - 'button') - ñòèëü äëÿ âûâîäà ýëåìåíòà "êíîïêà" (input type=submit, &ly;button..&gt;
<li><b>$as_cssclass['tactive']</b> (ïî óìîë÷. - 'tblactive') - ñòèëü äëÿ "ÿçû÷êà" òåêóùåé àêòèâíîé ñòðàíèöû
<li><b>$as_cssclass['tinactive']</b> (ïî óìîë÷. - 'tblinactive') - ñòèëü äëÿ íåàêòèâíûõ ÿçû÷êîâ
  Îáðàòèòå âíèìàíèå, ýòè äâà ñòèëÿ äîëæíû èìåòü íóëåâóþ íèæíþþ ãðàíèöó (border-bottom), äëÿ îáåñïå÷åíèÿ ïðàâèëüíîãî âèäà.
<li><b>$as_cssclass['pagebody']</b> (ïî óìîë÷. - 'pagebody') - ôîíîâûé ñòèëü äëÿ âñåõ ñòðàíèö (property pages).
  Ó ýòîãî ñòèëÿ íå äîëæíî áûòü âåðõíåé ãðàíèöû (border-top), äëÿ îáåñïå÷åíèÿ ïðàâèëüíîãî âèäà.
<li><b>$as_cssclass['pagebodywiz']</b> (ïî óìîë÷. - 'pagebodywiz') - òàêîé æå êàê 'pagebody', çà èñêëþ÷åíèåì
 óñëîâèÿ ïî âåðõíåé ãðàíèöå - åå çäåñü íàîáîðîò íàäî âûâîäèòü, ò.ê. ýòîò ñòèëü èñïîëüçóåòñÿ â ðåæèìå WIZARD-style,
  êîãäà âåðõíèõ "ÿçû÷êîâ" íå áóäåò.
<li><b>$as_cssclass['row_header']</b> (ïî óìîë÷. - 'head') - Ýòîò ñòèëü ïîíàäîáèòñÿ, åñëè Âû èñïîëüçóåòå çàãîëîâî÷íûå áëîêè
âíóòðè îäíîé ñòðàíèöû (ðåàëèçóþòñÿ çàíåñåíèåì â ñïèñîê ïîëåé ïñåâäî-ïîëÿ òèïà 'head')
</ul>

<H4>Ñîçäàíèå TAB-style ýêðàíà</H4>
<p>

Ñîçäàåì îáúåêò êëàññà CPropertySheet:
<pre>
require_once('as_propsheet.php');
$sheet = new CPropertySheet('mysheet',800,200);
</pre>

Òåïåðü çàðåãèñòðèðóåì â íåì íàøè ñòðàíèöû ñâîéñòâ (property pages).<br>
Äëÿ âûâîäà ñîäåðæèìîãî ñòðàíèöû ïåðåäàåòñÿ ëèáî ñïèñîê ïîëåé, ëèáî äðóãîé îáúåêò êëàññà CPropertySheet,
(âëîæåííûé ìóëüòè-ñòðàíè÷íûé ýêðàí), ëèáî íàøà ñîáñòâåííàÿ ôóíêöèÿ íà PHP.

<p><b>Ïðèìåð 1</b>: ðåãèñòðàöèÿ ñòðàíèöû ñî ñïèñêîì ïîëåé
<pre>
$fd = array();
$curvalue = isset($cfg['title'])? $cfg['title']: 'My nice site';
$fd[] = new CFormField('title','text','Your site main title',$curvalue,0,100,300);

$curvalue = isset($cfg['siteurl'])? $cfg['siteurl']: 'http://www.MyNiceSyte.net';
$fd[] = new CFormField('siteurl','text','URL for your site',$curvalue,0,100,300);

$curvalue = isset($cfg['shownews'])? $cfg['shownews']: 0;
$fd[] = new CFormField('shownews','checkbox','Show news on main page',$curvalue);
$sheet->AddPage('Page 1: basic parameters',$fd);
</pre>

<br><b>Ïðèìåð 2</b>: Ìîæíî â âíóòðè îäíîé ñòðàíèöû âûâîäèòü âëîæåííûé ìóëüòè-ñòðàíè÷íûé áëîê:
<pre>
...
$sheet2 = new CPropertySheet('nested2',600,100);
$flds = array();
$flds[] = new CFormField('f11','text','sub-field 1','initial value',0,100,200);
$flds[] = new CFormField('f12','checkbox','check box 12',0);
$sheet2->AddPage('sub-params-1',$flds);
...
$sheet->AddPage('nested property sheet...', $sheet2);
</pre>

<br><br>
<b>Ïðèìåð 3</b>: Ñëåäóþùóþ ñòðàíèöó áóäåò ðèñîâàòü íàøà ôóíêöèÿ (â íàøåì ïðèìåðå - <b>UdfvarPage()</b>).
<pre>
$sheet->AddPage('User defined parameters','UdfvarPage');
</pre>

Òåïåðü ìîæíî ñãåíåðèðîâàòü è âûâåñòè HTML-êîä:
<pre>
$sheet->Draw();
</pre>

Åñòâåñòâåííî, ñòàðòîâûé òåã ôîðìû (&lt;FORM ...&gt;) íóæíî âûâîäèòü äî âûçîâà Draw(),
à çàêðûâàþùèé &lt;/FORM&gt; - ïîñëå.

<p>Ïåðåäàííûå ñïèñêè ïîëåé âûâîäÿòñÿ îäíî çà îäíèì, ïî ïîëþ íà ñòðîêå (çàãîëîâîê ñëåâà, ïîëå-ñïðàâà),
è åñëè òàêîé âèä íå ïîäõîäèò, íàäî èñïîëüçîâàòü ñâîþ ôóíêöèþ âûâîäà.

<H4>Ñîçäàíèå WIZARD-style ýêðàíîâ</H4>

<p>
Ñîçäàíèå Âèçàðäîâ ìàëî ÷åì îòëè÷àåòñÿ - íóæíî ëèøü ïðè ñîçäàíèè îáúåêòà CPropertySheet
èñïîëüçîâàòü êîíñòàíòó WIZARDSTYLE, à òàêæå âûçâàòü ôóíêöèþ ðåãèñòðàöèè êíîïêè "Ôèíèø":

<pre>
require_once('as_propsheet.php');
$sheet = new CPropertySheet('mysheet',800,200,WIZARDSTYLE);

$sheet->SetFinishButton('FinishWizard()','Ôèíèø!',false);
</pre>

<H4>Îïèñàíèå êëàññîâ è èõ ìåòîäîâ ìîäóëÿ as_propsheet</H4>
<p>
Íèæå ïðèâîäèòñÿ ïîëíûé ñïèñîê êëàññîâ è èõ ìåòîäîâ.<br><br>
<table border=0 _bgcolor='#5050E0' width='100%' cellspacing=1>
<tr class='head'><td colspan=2>Êëàññ: CPropertySheet</tr></tr>
<tr class='odd'>
 <td valign=top>constructor: CPropertySheet($id, $width='',$height='',$sheetstyle=TABSTYLE)</td>
  <td><b>$id</b> - óíèêàëüíûé ñèìâîëüíûé èäåíòèôèêàòîð òàáëèöû, (óíèêàëüíîñòü íåîáõîäèìà, åñëè íà îäíîé HTML ñòðàíèöå
  âûâîäèòñÿ áîëåå îäíîãî îáúåêòà CPropertySheet).
  <br><b>$width</b> - "ìèíèìàëüíàÿ" øèðèíà òàáëèöû ñî ñïèñêîì ñòðàíèö, 800 ïî óìîë÷àíèþ.
  <br><b>$height</b> - "ìèíèìàëüíàÿ" âûñîòà òàáëèöû ñî ñïèñêîì ñòðàíèö, 120 ïî óìîë÷àíèþ.
  <br><b>$sheetstyle</b> - òèï òàáëèöû, TABSTYLE (ïî óìîë÷àíèþ) èëè WIZARDSTYLE.
  <br><br><b>Ïðèìåð: $sheet = new CPropertySheet('mysheet',800,200);</b>
</td></tr>
<tr class='even'>
 <td valign=top>AddPage($tabtitle,$drawobject, $jsfunc_next='')</td>
  <td>Ðåãèñòðèðóåò â òàáëèöå îäíó ñòðàíèöó (Property Page).
  <br><b>$tabtitle</b> - ñòðîêà ñ çàãîëîâêîì, âûâîäèìûì íà "ÿçû÷êå" ñòðàíèöû
  <br><b>$drawobject</b> - ìàññèâ ñî ñïèñêîì ïîëåé (îáúåêòîâ êëàññà CFormField), ëèáî
  äðóãîé îáúåêò êëàññà CPropertySheet? ëèáî èìÿ ñâîåé ôóíêöèè îòðèñîâêè HTML-êîäà ñòðàíèöû.
  (Ñì. ïîäðîáíîñòè âûçîâîâ â propsheet_sample.php)
  <br><b>$jsfunc_next</b> - Ýòà javascript ôóíêöèÿ íóæíà â ðåæèìå WIZARDSTYLE è âûçûâàåòñÿ ïåðåä
  ïåðåõîäîì íà ñëåäóþùóþ ñòðàíèöó (ïðè íàæàòèè íà êíîïêó "ñëåäóþùèé").
  Ñ åå ïîìîùüþ ìîæíî äèíàìè÷åñêè îáíîâèòü çíà÷åíèÿ ïîëåé íà ñëåäóþùèõ ñòðàíèöàõ â çàâèñèìîñòè
  îò ââåäåííûõ ðàíåå, ëèáî ïðîâåðèòü êîððåêòíîñòü çàâåäåííûõ äàííûõ è ïðè íåîáõîäèìîñòè áëîêèðîâàòü óõîä ñî ñòðàíèöû
  (â ýòîì ñëó÷àå ôóíêöèÿ äîëäæíà âåðíóòü çíà÷åíèå <b>false</b>)
  <br>Ñì. <b>propsheet_sample.php</b> - ïåðåêëþ÷èòåñü â ðåæèì WIZARDSTYLE, è ïîïðîáóéòå
  ïîïåðåêëþ÷àòü êíîïêó 'Next'.
  <br><br><b>Ïðèìåð: $sheet->AddPage('basic parameters',$fieldlist);</b>
</td></tr>
<tr class='odd'>
 <td valign=top>SetFinishButton($function,$caption='',$enabled=false)</td>
  <td>Ýòîò ìåòîä âûçûâàåòñÿ òîëüêî â ðåæèìå WIZARDSTYLE, ÷òîáû áûëà ñôîðìèðîâàíà êíîïêà FINISH.
  <br><b>$function</b> - javascript ôóíêöèÿ, îòðàáàòûâàåìàÿ ïðè íàæàòèè íà ôèíàëüíóþ êíîïêó.
  <br><b>$caption</b> - Òåêñò íà êíîïêå, "Finish" ïî óìîë÷.
  <br><b>$enabled</b> (ïî óìîë÷. 0), åñëè 0, êíîïêà Finish áóäåò â âûâåäåíà ñ àòðèáóòîì disabled.
  Òîãäà â Âàøèõ javascript ôóíêöèÿõ äîëæåí áûòü ðàçáëîêèðóþùèé êîä (íàïðèìåð, â ôóíêöèè ïåðåõîäà
  ñ ïðåäïîñëåäíåé íà ïîñëåäíþþ ñòðàíèöó).
  <br><br><b>Ïðèìåð: $sheet->SetFinishButton('FinishPressed()','Finish setup',true);</b>
</td></tr>

<tr class='head'><td colspan=2>Êëàññ: CPropertyPage, îïèñàíèå îäíîé ñòðàíèöû "property-page")</tr></tr>
<tr class='odd'>
 <td valign=top>constructor: CPropertyPage($title,$drawfunc,$evtnext='')</td>
  <td><b>$title</b> - òåêñò â çàêëàäêå
  <br><b>$drawfunc</b> - ñïèñîê ïîëåé|îáúåêò CPropertySheet|èìÿ ôóíêöèè
  <br><b>$evtnext</b> - èìÿ javascript ôóíêöèè íà ñîáûòèå "Next" (WIZARDSTYLE)
  <br><br><b>êîíñòðóêòîð âûçûâàåòñÿ àâòîìàòè÷åñêè ïðè âûïîëíåíèè CPropertySheet::AddPage()</b>
</td></tr>

<tr class='head'><td colspan=2>Êëàññ: CFormField, îïèñàíèå îäíîãî ðåäàêòèðóåìîãî ïîëÿ</tr></tr>
<tr class='even'>
 <td valign=top>constructor: CFormField($name,$type='text',$prompt='',$initvalue='',$vlist='',
            $maxlength=10,$width=0,$title='',$onchange='',$addprm='')</td>
  <td>
    <b>$type</b> - îäèí èç äîïóñòèìûõ òèïîâ: <b>text|password|textarea|head|select|checkbox</b>
  <br><b>$prompt</b> - ñîïðîâîäèòåëüíûé òåêñò ïåðåä ïîëåì (îïèñàíèå)
  <br><b>$initvalue</b> - íà÷àëüíîå çíà÷åíèå
  <br><b>$vlist</b> - ñïèñîê äîñòóïíûõ çíà÷åíèé äëÿ ïîëÿ òèïà SELECT.
  Ìîæåò áûòü çàäàí êàê àññîöèàòèâíûé ìàññèâ - array('key'=>value,...)
     èëè äâóìåðíûé ìàññèâ : $v[0]=array($key0,$value0); $v[1]=array($key1,$value1),...
  <br><b>$maxlength</b> - çíà÷åíèå òåãà MAXLENGTH äëÿ ïîëåé òèïà text/password
  <br><b>$width</b> - åñëè ïåðåäàí, â àòðèáóòàõ ïîëÿ áóäåò âñòàâëåí äîïîëíèòåëüíûé css-êîä : style='width:NNN'
  <br><b>$title</b> - âñïëûâàþùàÿ ïîäñêàçêà (òåëî òåãà TITLE='...' )
  <br><b>$onchange</b> - êîä äëÿ ñîáûòèé onChange/onClick äëÿ ïîëÿ.
  <br><b>$addprm</b> - ïðî÷èé äîïîëíèòåëüíûé HTML-êîä ñ àòðèáóòàìè, âñòàâëÿåòñÿ â òåëî òåãà &lt;input...&gt;
  <br><br><b>Ïðèìåð: $fields[] = new CFormField('shownews','checkbox','Show news on main page',1);  </b>
  <br>Åñëè íóæíî çàäàòü style-àòðèáóòû äëÿ øèðèíû è âûñîòû, ('width','height'), èñïîëüçóéòå ïîñëåäíèé ïàðàìåòð, $addprm
  (íàïðèìåð, äëÿ âûâîäà ïîëÿ TEXTAREA íóæíîãî ðàçìåðà):
  <br><b>$addprm = "style='width:100%; height:120px;' ";</b>
</td></tr>

</table>

<p>
 êîíöå - ïðîñòîé ïðèìåð. Áîëåå ïîëíûé ñì. â <b>propsheet_sample.php</b> file

<pre>
require_once('as_propsheet.php');
$sheet = new CPropertySheet('mysheet',800,200);
$fields = array();
$fields[] = new CFormField('siteurl','text','URL for your site',$initvalue,0,100,300);
$fields[] = new CFormField('shownews','checkbox','Show news on main page',1);
$sheet->AddPage('main parameters', $fields);
$sheet->AddPage('UDF parameters', 'DrawMyUDFPage');
$sheet->Draw();
</pre>

<H4>Version History</H4>
<b>1.0.001 (2006-10-24)</b>
<ul>
  <li>Ïåðâûé ïóáëè÷íûé ðåëèç íà <a href='http://www.phpclasses.org' target='_blank'>phpclasses.org</a></li>
</ul>

<br>
<!--
<H4>Links</H4>
<ul>
  <li><a href="http://as-works.narod.ru/en/php/">as_propsheet and other PHP scripts collection on the author's homepage</a></li>
</ul>
<br><br><br><p>
-->
<hr>
<div align=center><font size=-2>Copyright &copy; Alexander Selifonov, 2006<a href="http://as-works.narod.ru">as-works.narod.ru</a>
</font></div>
</HTML></BODY>
Return current item: Property sheets drawing engine