Diff for /loncom/html/adm/help/tex/Developer_Tutorial.tex between versions 1.5 and 1.6

version 1.5, 2004/05/17 22:08:56 version 1.6, 2005/04/07 06:56:22
Line 363  To send back a proper HTTP response, add Line 363  To send back a proper HTTP response, add
   
 ~~~~if~(\$r->header\_only)~\{  ~~~~if~(\$r->header\_only)~\{
   
 ~~~~~~~~if~(\$ENV\{'browser.mathml'\})~\{  ~~~~~~~~if~(\$env\{'browser.mathml'\})~\{
   
 ~~~~~~~~~~~~\$r->content\_type('text/xml');  ~~~~~~~~~~~~\$r->content\_type('text/xml');
   
Line 381  To send back a proper HTTP response, add Line 381  To send back a proper HTTP response, add
   
 ~~~~\#~Send~header,~don't~cache~this~page  ~~~~\#~Send~header,~don't~cache~this~page
   
 ~~~~if~(\$ENV\{'browser.mathml'\})~\{  ~~~~if~(\$env\{'browser.mathml'\})~\{
   
 ~~~~~~~~\$r->content\_type('text/xml');  ~~~~~~~~\$r->content\_type('text/xml');
   
Line 453  use~Apache::lonnavmaps; Line 453  use~Apache::lonnavmaps;
 Remove the {}``Hello world!'' line and replace it with this:  Remove the {}``Hello world!'' line and replace it with this:
   
 \begin{lyxcode}  \begin{lyxcode}
 \$ENV\{'form.condition'\}~=~1;  \$env\{'form.condition'\}~=~1;
   
 my~\$renderArgs~=~\{~'cols'~=>~{[}Apache::lonnavmaps::resource{]},  my~\$renderArgs~=~\{~'cols'~=>~{[}Apache::lonnavmaps::resource{]},
   
Line 470  Line by line: Line 470  Line by line:
 contains routines that help render navmaps. For more information,  contains routines that help render navmaps. For more information,
 see later in this manual or type \texttt{man Apache::lonnavmaps}.  see later in this manual or type \texttt{man Apache::lonnavmaps}.
 This ensures these routines are loaded into memory.  This ensures these routines are loaded into memory.
 \item \texttt{\textbf{\$ENV\{'form.condition'\} = 1;}}: This is an an argument  \item \texttt{\textbf{\$env\{'form.condition'\} = 1;}}: This is an an argument
 being passed to the Apache::lonnavmaps::render routine in a rather  being passed to the Apache::lonnavmaps::render routine in a rather
 unorthodox way. This will cause the navmap to render all of the resources,  unorthodox way. This will cause the navmap to render all of the resources,
 by default, except for what we explicitly exclude. Since we're not  by default, except for what we explicitly exclude. Since we're not
 going to exclude anything (which we would do with \texttt{\$ENV\{'form.filter'\}}),  going to exclude anything (which we would do with \texttt{\$env\{'form.filter'\}}),
 all resources will be shown.  all resources will be shown.
 \item \texttt{\textbf{my \$renderArgs\ldots{}\$r\};}}: Since the \texttt{render}  \item \texttt{\textbf{my \$renderArgs\ldots{}\$r\};}}: Since the \texttt{render}
 routine takes a \emph{lot} of arguments, the \texttt{render} routine  routine takes a \emph{lot} of arguments, the \texttt{render} routine
Line 524  In doing this, we'll learn: Line 524  In doing this, we'll learn:
   
 The first thing we need to do to accomplish this is to add an HTML  The first thing we need to do to accomplish this is to add an HTML
 form to the screen so we have something to submit. Just above the  form to the screen so we have something to submit. Just above the
 \texttt{\$ENV\{'form.condition'\}} line, add the following:  \texttt{\$env\{'form.condition'\}} line, add the following:
   
 \begin{lyxcode}  \begin{lyxcode}
 \$r->print(\char`\"{}<form~method='post'><input~type='hidden'~name='submission'~value='1'~/>\char`\"{});  \$r->print(\char`\"{}<form~method='post'><input~type='hidden'~name='submission'~value='1'~/>\char`\"{});
Line 549  submit button won't do much. Line 549  submit button won't do much.
 \subsubsection{Seeing The Incoming Data}  \subsubsection{Seeing The Incoming Data}
   
 LON-CAPA automatically processing incoming POST data and exposes it  LON-CAPA automatically processing incoming POST data and exposes it
 to you in the \texttt{\%ENV} hash. The data will appear in \texttt{\$ENV\{'form.\$varname'\}},  to you in the \texttt{\%env} hash. The data will appear in \texttt{\$env\{'form.\$varname'\}},
 where \texttt{\$varname} is the variable name of the HTML form element.  where \texttt{\$varname} is the variable name of the HTML form element.
 In this case, since we have an element named {}``submission'', a  In this case, since we have an element named {}``submission'', a
 {}``1'' will appear in \texttt{\$ENV\{'form.submission'\}} when  {}``1'' will appear in \texttt{\$env\{'form.submission'\}} when
 we hit the {}``Increment'' button. To see this, add the following  we hit the {}``Increment'' button. To see this, add the following
 after the \texttt{bodytag} call:  after the \texttt{bodytag} call:
   
 \begin{lyxcode}  \begin{lyxcode}
 if~(\$ENV\{'form.submission'\})~\{  if~(\$env\{'form.submission'\})~\{
   
 ~~~~\$r->print('<p>Form~submitted.</p>');  ~~~~\$r->print('<p>Form~submitted.</p>');
   
Line 572  Reload the tutorial code into the server Line 572  Reload the tutorial code into the server
 When you hit {}``Increment'', {}``Form submitted.'' will appear.  When you hit {}``Increment'', {}``Form submitted.'' will appear.
   
 Note this only applies to POST'ed data. If you use GET, the data will  Note this only applies to POST'ed data. If you use GET, the data will
 appear on the query string. For your code, this will show up in \texttt{\$ENV\{QUERY\_STRING\}}.  appear on the query string. For your code, this will show up in \texttt{\$env\{QUERY\_STRING\}}.
 If you want to invoke LON-CAPA's processing on that string, so you  If you want to invoke LON-CAPA's processing on that string, so you
 see the variables in \texttt{\%ENV}, use  see the variables in \texttt{\%env}, use
 \texttt{Apache::loncommon::get\_unprocessed\_cgi(\$ENV\{QUERY\_STRING\});}.  \texttt{Apache::loncommon::get\_unprocessed\_cgi(\$env\{QUERY\_STRING\});}.
 This is particularly useful for cases where input may be coming in via  This is particularly useful for cases where input may be coming in via
 either POST or GET.  either POST or GET.
   
Line 625  Add the following code before the \textt Line 625  Add the following code before the \textt
 code:  code:
   
 \begin{lyxcode}  \begin{lyxcode}
 foreach~(keys~\%ENV)~\{  foreach~(keys~\%env)~\{
   
 ~~~~if~(substr(\$\_,~0,~10)~eq~'form.symb.')~\{  ~~~~if~(substr(\$\_,~0,~10)~eq~'form.symb.')~\{
   
Line 658  you can't depend on being on the same sy Line 658  you can't depend on being on the same sy
   
 Let's go ahead and retrieve the hash we're going to store. If it doesn't  Let's go ahead and retrieve the hash we're going to store. If it doesn't
 already exist, it will end up getting created implicitly. Before the  already exist, it will end up getting created implicitly. Before the
 \texttt{foreach (keys \%ENV)}, add   \texttt{foreach (keys \%env)}, add 
   
 \begin{lyxcode}  \begin{lyxcode}
 my~\%countHash~=~Apache::lonnet::restore('tutorial');  my~\%countHash~=~Apache::lonnet::restore('tutorial');
Line 680  Replace the \texttt{foreach} loop that i Line 680  Replace the \texttt{foreach} loop that i
 this:  this:
   
 \begin{lyxcode}  \begin{lyxcode}
 foreach~(keys~\%ENV)~\{  foreach~(keys~\%env)~\{
   
 ~~~~if~(substr(\$\_,~0,~10)~eq~'form.symb.')~\{  ~~~~if~(substr(\$\_,~0,~10)~eq~'form.symb.')~\{
   
Line 772  in calls to \texttt{\&mt}. I see the fol Line 772  in calls to \texttt{\&mt}. I see the fol
   them for practice)    them for practice)
   
 \begin{lyxcode}  \begin{lyxcode}
 if~(\$ENV{'form.submission'})~{  if~(\$env{'form.submission'})~{
   
 ~~~~\$r->print('<p>'.\&mt('Form submitted').'</p>');  ~~~~\$r->print('<p>'.\&mt('Form submitted').'</p>');
   
Line 876  sub~handler~\{ Line 876  sub~handler~\{
   
 ~~~~if~(\$r->header\_only)~\{  ~~~~if~(\$r->header\_only)~\{
   
 ~~~~~~~~if~(\$ENV\{'browser.mathml'\})~\{  ~~~~~~~~if~(\$env\{'browser.mathml'\})~\{
   
 ~~~~~~~~~~~~\$r->content\_type('text/xml');  ~~~~~~~~~~~~\$r->content\_type('text/xml');
   
Line 894  sub~handler~\{ Line 894  sub~handler~\{
   
 ~~~~\#~Send~header,~don't~cache~this~page  ~~~~\#~Send~header,~don't~cache~this~page
   
 ~~~~if~(\$ENV\{'browser.mathml'\})~\{  ~~~~if~(\$env\{'browser.mathml'\})~\{
   
 ~~~~~~~~\$r->content\_type('text/xml');  ~~~~~~~~\$r->content\_type('text/xml');
   
Line 926  sub~handler~\{ Line 926  sub~handler~\{
   
   
   
 ~~~~if~(\$ENV\{'form.submission'\})~\{  ~~~~if~(\$env\{'form.submission'\})~\{
   
 ~~~~~~~~\$r->print('<p>'~.~\&mt('Form~submitted.')~.'</p>');  ~~~~~~~~\$r->print('<p>'~.~\&mt('Form~submitted.')~.'</p>');
   
Line 942  sub~handler~\{ Line 942  sub~handler~\{
   
 ~~~~my~\%newHash~=~();  ~~~~my~\%newHash~=~();
   
 ~~~~foreach~(keys~\%ENV)~\{  ~~~~foreach~(keys~\%env)~\{
   
 ~~~~~~~~if~(substr(\$\_,~0,~10)~eq~'form.symb.')~\{  ~~~~~~~~if~(substr(\$\_,~0,~10)~eq~'form.symb.')~\{
   
Line 976  sub~handler~\{ Line 976  sub~handler~\{
   
 ~~~~~~~~~~~~~~\char`\"{}name='submission'~value='1'~/>\char`\"{});  ~~~~~~~~~~~~~~\char`\"{}name='submission'~value='1'~/>\char`\"{});
   
 ~~~~\$ENV\{'form.condition'\}~=~1;  ~~~~\$env\{'form.condition'\}~=~1;
   
 ~~~~my~\$renderArgs~=~\{~'cols'~=>~{[}Apache::lonnavmaps::resource,  ~~~~my~\$renderArgs~=~\{~'cols'~=>~{[}Apache::lonnavmaps::resource,
   

Removed from v.1.5  
changed lines
  Added in v.1.6


FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>