Apache2-PageKit

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

        - Add de message catalog (Boris Zentner)
        ! Change default for html_clean_level to 0 (Boris Zentner)
        - Add <PKIT_NOT_ERROR> directive to seperate errors
		from messages (David Christian)
        ! Catch up with new interface in XML::LibXML 1.31 (Anton Berezin)
        - Fix eg/View/(xml|wml|pdf)/simple_page.xsl (Boris Zentner)
        - Add pkit_get_config_attr function to get config options from your
		Config.xml (Boris Zentner, Leonardo T. de Carvalho)
	- Add new <USER> section in Config/Config.xml where your own
		config data takes place (Boris Zentner)
	- Add a optional second argument for pkit_set_errorfont (Boris Zentner)
	- Add new global config option default_errorstr (Boris Zentner)
        - Add new pkit tag <PKIT_ERRORSTR> (Boris Zentner)
        - Fix _load_component to die if we can not read the
        	component file (Anton Permyakov)
        - Add new function pkit_set_errorspan. It replaced pkit_set_errorfont
		which is obsolete and should not be used anymore. (Boris Zentner)
	- Add new pkit tag <PKIT_ERRORSPAN> as replacement for
        	<PKIT_ERRORFONT> (Boris Zentner)
 	- Add new global config option 'errorspan_begin_tag' and
        	'errorspan_end_tag' (Boris Zentner)
	- Add new tags SECTIONS and SECTION for use in Config/Config.xml
        	they allow to set defaults for groups of pages
                (Boris Zentner, Ben Ausden)
        - Fix view tag attribute 'output_media' to the documented
        	'content_type'. Also test the page tag attribute

Changes  view on Meta::CPAN

		add them back if there is demand and I can find an
		clean way of doing it (using XPointers in content
		XML file???)
	- Removed support for $model->content_param, since content
		is now compiled into template and it is not possible
		to get or set the tags run time.
	- Automically converts UTF-8 Encoding to latin1 encodeing,
		if Unicode::String is loaded (Yann Kerhervé)
	- fixed bug with pre-parsing content from sub-directories
	- input_param now works with parameters containing multiple values
	- Add $model->pkit_set_errorfont($field), used mark <PKIT_ERRORFONT>
		tags for errors.
	- Added pkit_root method, gets PageKit root directory
	- no longer escape pkit_done
	- works with mod_proxy_add_uri.c apache module, using X-Original-URI
		header
	- Removed PKIT_LOGINOUT_LINK, this tag was
		not necessary and cluttered the API,
		see migration/README for details
	- removed search_engine_headers config option
	- server_id is now passed to startup, solves

docsrc/features.xml  view on Meta::CPAN

  Note, that the pages <literal><link linkend="config.global.default_page">default_page</link></literal>,
  <literal><link linkend="config.global.verify_page">verify_page</link></literal> and
  <literal><link linkend="config.global.login_page">login_page</link></literal> can not be protected in any way.
  </para>
 </sect1>
 <sect1><?dbhtml filename="validation.html"?>
  <title>Form Validation</title>
   <para>
  PageKit uses <ulink url="http://search.cpan.org/doc/MARKSTOS/Data-FormValidator-1.5/lib/Data/FormValidator.pm">Data::FormValidator</ulink> to provide easy form validation.  Highlights
fields in red that user filled incorrectly by using the
<link linkend="pkit.errorfont">PKIT_ERRORFONT</link> tag.  In addition,
error message(s) are displayed using the <link linkend="pkit.messages">PKIT_MESSAGES</link> tag.
To use, pass an input profile to the
<literal><link linkend="model.api.pkit_validate_input">pkit_validate_input</link></literal> method.
  </para>
  <para>
   In addition, you may implement your own custom error handling by using <literal><link linkend="model.api.pkit_set_errorfont">pkit_set_errorfont</link></literal> to set the <link linkend="pkit.errorfont">PKIT_ERRORFONT</link> tags.
  </para>
 </sect1>
 <sect1><?dbhtml filename="fillinform.html"?>
  <title>Sticky HTML Forms</title>
  <para>
   PageKit uses <ulink url="http://kobesearch.cpan.org/search?dist=HTML-FillInForm">HTML::FillInForm</ulink> to fill in HTML Forms with the request parameters.  You
   can turn this feature off by setting <literal><link linkend="config.page.fill_in_form">fill_in_form</link></literal> to <emphasis>no</emphasis>.
  </para>
  <para>
   One useful application is if you have set up error handling and if an user

docsrc/reference.xml  view on Meta::CPAN

      </para>
     </listitem>
    </varlistentry>

    <varlistentry id="config.global.default_errorstr">
     <term>default_errorstr</term>
     <listitem>
      <para>
        Default errorstr, that PageKit use for <link linkend="pkit.errorstr">PKIT_ERRORSTR</link>,
	<link linkend="model.api.pkit_set_errorspan">pkit_set_errorspan</link> and the obsolete
	<link linkend="model.api.pkit_set_errorfont">pkit_set_errorfont</link>.
      </para>
      <para>
	Defaults to <emphasis>#ff0000</emphasis>.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry id="config.global.default_input_charset">
     <term>default_input_charset</term>
     <listitem>
      <para>

docsrc/reference.xml  view on Meta::CPAN

       <emphasis>index</emphasis>.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry id="config.global.errorspan_begin_tag">
     <term>errorspan_begin_tag</term>
     <listitem>
      <para>
       Specifies the start tag for &lt;PKIT_ERRORSPAN ... &gt; and &lt;PKIT_ERRORFONT ... &gt;.
       Defaults to <emphasis>&lt;font color="&lt;PKIT_ERRORCOLOR&gt;"&gt;</emphasis>.
       <informalexample>
       <programlisting>
	errorspan_begin_tag = "&amp;lt;span class=error&amp;gt;"
        errorspan_end_tag = "&amp;lt;/span&amp;gt;"
       </programlisting>
      </informalexample>
      </para>
      <para>
      See also <literal><link linkend="config.global.errorspan_end_tag">errorspan_end_tag</link></literal>.
      </para>
     </listitem>
    </varlistentry>

    <varlistentry id="config.global.errorspan_end_tag">
     <term>errorspan_end_tag</term>
     <listitem>
      <para>
       Specifies the end tag for &lt;PKIT_ERRORSPAN ... &gt; and &lt;PKIT_ERRORFONT ... &gt;.
       Defaults to <emphasis>&lt;/font&gt;</emphasis>.
      </para>
      <para>
      See also <literal><link linkend="config.global.errorspan_begin_tag">errorspan_begin_tag</link></literal>.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry id="config.global.fop_command">
     <term>fop_command</term>
     <listitem>
      <para>

docsrc/reference.xml  view on Meta::CPAN

     <para>
It is strongly recommend that you use this method on pages where a
query that changes the state of the application is executed.  Typically
these are POST queries that update the database.
     </para>
     <para>
Note that this passes along the messages set my <link linkend="model.api.pkit_message">pkit_message</link> if applicable.
     </para>
    </refsect1>
   </refentry>
   <refentry id="model.api.pkit_set_errorfont">
    <refnamediv>
     <refname>pkit_set_errorfont</refname>
     <refpurpose>
      Sets PKIT_ERRORSPAN tags
     </refpurpose>
    </refnamediv>
    <refsynopsisdiv>
     <synopsis>
      $model->pkit_set_errorfont('state');

      # possible since version 1.08
      $model->pkit_set_errorfont( 'state', '#00ff00' );
     </synopsis>
    </refsynopsisdiv>
    <refsect1>
     <title>Description</title>
     <para>
     Superfluous since PageKit 1.08 please use <link linkend="model.api.pkit_set_errorspan">pkit_set_errorspan</link>.
     </para>
     <para>
      Sets the corresponding <link linkend="pkit.errorspan">PKIT_ERRORSPAN</link> tag in the template.  Useful
for implementing your own custom constraints. Since version 1.08 it is possible to select the errorstr. This

docsrc/reference.xml  view on Meta::CPAN

    <refentry id="pkit.errorstr">
     <refnamediv>
      <refname>PKIT_ERRORSTR</refname>
      <refpurpose>
       Named field for your errorstr.
      </refpurpose>
     </refnamediv>
     <refsynopsisdiv>
      <synopsis>
       <![CDATA[<PKIT_ERRORSTR>
       <font color="<PKIT_ERRORSTR>">bla</font>
       ]]>
      </synopsis>
     </refsynopsisdiv>
     <refsect1>
      <title>Description</title>
      <para>
       This tag is replaced by the string that you define with <literal><link linkend="config.global.default_errorstr">default_errorstr</link></literal>.
       If it is not defined the default is <emphasis>#ff0000</emphasis>.
      </para>
      <para>

docsrc/reference.xml  view on Meta::CPAN

      <para>
       A <literal>PKIT_MACRO</literal> is replaced with the value of the key
       in <literal><link linkend="pkit.component">PKIT_COMPONENT</link></literal>
       that match the name of the macro.
      </para>
      <para>
       This tag is only valid inside a template that is loaded with <literal><link linkend="pkit.component">PKIT_COMPONENT</link></literal>
      </para>
     </refsect1>
    </refentry>
    <refentry id="pkit.errorfont">
     <refnamediv>
      <refname>PKIT_ERRORFONT</refname>
      <refpurpose>
       Highlights Invalid Fields
      </refpurpose>
     </refnamediv>
     <refsynopsisdiv>
      <synopsis>
       <![CDATA[<PKIT_ERRORFONT NAME="lastname"> Last Name </PKIT_ERRORFONT> <input name="lastname"> ]]>
       <![CDATA[<PKIT_ERRORFONT> new for PageKit 1.10 </PKIT_ERRORFONT> ]]>

docsrc/reference.xml  view on Meta::CPAN

      <refpurpose>
       Include the block between &lt;PKIT_HAVE_MESSAGES&gt; and &lt;/PKIT_HAVE_MESSAGES&gt; only,
       if one or more messages are avail.
      </refpurpose>
     </refnamediv>
     <refsynopsisdiv>
      <synopsis>
       <![CDATA[<PKIT_HAVE_MESSAGES>
                   Here are some messages for you: <p>
                  <PKIT_MESSAGES>
                  <PKIT_IS_ERROR><font color="<PKIT_ERRORSTR>"></PKIT_IS_ERROR>
                  <PKIT_MESSAGE>
                  <PKIT_IS_ERROR></font></PKIT_IS_ERROR>
	          <p>
         </PKIT_MESSAGES>
        </PKIT_HAVE_MESSAGES>]]>

      </synopsis>
     </refsynopsisdiv>
     <refsect1>
      <title>Description</title>
      <para>
        Include the block between &lt;PKIT_HAVE_MESSAGES&gt; and &lt;/PKIT_HAVE_MESSAGES&gt; only,

docsrc/reference.xml  view on Meta::CPAN

    <refentry id="pkit.messages">
     <refnamediv>
      <refname>PKIT_MESSAGES</refname>
      <refpurpose>
       Display messages passed to pkit_message method.
      </refpurpose>
     </refnamediv>
     <refsynopsisdiv>
      <synopsis>
       <![CDATA[<PKIT_MESSAGES>
                <PKIT_IS_ERROR><font color="<PKIT_ERRORSTR>"></PKIT_IS_ERROR>
                <PKIT_MESSAGE>
                <PKIT_IS_ERROR></font></PKIT_IS_ERROR>
	        <p>
       </PKIT_MESSAGES>]]>

      </synopsis>
      <synopsis>
       <![CDATA[<PKIT_MESSAGES>
         <PKIT_IS_ERROR><font color="<PKIT_ERRORSTR>"><PKIT_MESSAGE></font></PKIT_IS_ERROR>
       </PKIT_MESSAGES>

       <PKIT_MESSAGES>
         <PKIT_NOT_ERROR><font color="<PKIT_ERRORSTR>"><PKIT_MESSAGE></font></PKIT_NOT_ERROR>
       </PKIT_MESSAGES>]]>

      </synopsis>
     </refsynopsisdiv>
     <refsect1>
      <title>Description</title>
      <para>
	Displays messages passed to pkit_message method in the Model code.
      </para>
     </refsect1>

eg/View/Default/top.tmpl  view on Meta::CPAN

<html>
<head>
<title><CONTENT_VAR NAME="html_title"></title>

<style type="text/css">
H1, H2, H3, H4, H5, H6 {font-family: Verdana, Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ; }
</style>

</head>
<body bgcolor="<MODEL_VAR NAME="bgcolor">" link="<MODEL_VAR NAME="link_color">" vlink="<MODEL_VAR NAME="link_color">" text="<MODEL_VAR NAME="text_color">">

  <!-- Messages -->

  <PKIT_MESSAGES>
    <PKIT_IS_ERROR><font color="<PKIT_ERRORSTR>"></PKIT_IS_ERROR>
    <PKIT_MESSAGE>
    <PKIT_IS_ERROR></font></PKIT_IS_ERROR>
    <p>
  </PKIT_MESSAGES>

  <!-- /Messages -->

eg/View/pdf/media.tmpl  view on Meta::CPAN

           xsl-region-start  (usually: left margin) 
           xsl-region-end    (usually: right margin)
           ['usually' applies here to languages with left-right and top-down 
            writing direction like English]
           in this case there is only one target: xsl-region-body
        -->
    <fo:flow flow-name="xsl-region-body">

      <!-- each paragraph is encapsulated in a block element
           the attributes of the block define
           font-family and size, line-heigth etc. -->

      <!-- this defines a title -->
      <fo:block font-size="18pt" 
            font-family="sans-serif" 
            line-height="24pt"
            space-after.optimum="15pt"
            background-color="blue"
            color="white"
            text-align="center"
            padding-top="3pt">
	Media Test - PDF
      </fo:block>


      <!-- this defines normal text -->
      <fo:block font-size="12pt" 
                font-family="sans-serif" 
                line-height="15pt"
                space-after.optimum="3pt"
                text-align="justify">
	Process Number:
      </fo:block>

      <!-- this defines normal text -->
      <fo:block font-size="12pt" 
                font-family="sans-serif" 
                line-height="15pt"
                space-after.optimum="3pt"
                text-align="justify">
	<MODEL_VAR NAME="process_number">
      </fo:block>

    </fo:flow> <!-- closes the flow element-->
  </fo:page-sequence> <!-- closes the page-sequence -->
</fo:root>

eg/View/pdf/simple_page.xsl  view on Meta::CPAN

    </fo:simple-page-master>
  </fo:layout-master-set>
  <fo:page-sequence master-reference="simple">
   <fo:flow flow-name="xsl-region-body">
    <xsl:apply-templates/>
   </fo:flow>
  </fo:page-sequence>
</fo:root>
 </xsl:template>
 <xsl:template match="header">
      <fo:block font-size="18pt" 
            font-family="sans-serif" 
            line-height="24pt"
            space-after.optimum="15pt"
            background-color="blue"
            color="white"
            text-align="center"
            padding-top="3pt">
  <xsl:value-of select="."/> PDF
      </fo:block>
 </xsl:template>
 <xsl:template match="para">
      <fo:block font-size="12pt" 
                font-family="sans-serif" 
                line-height="15pt"
                space-after.optimum="3pt"
                text-align="justify">
   <xsl:apply-templates/>
      </fo:block>
 </xsl:template>
 <xsl:template match="MODEL_VAR">
  <xsl:copy>
   <xsl:copy-of select="@*"/>
   <xsl:apply-templates/>

eg/View/print/top.tmpl  view on Meta::CPAN

<html>
<head>
<title><CONTENT_VAR NAME="html_title"> | Printable Version</title>
<style type="text/css">
H1, H2, H3, H4, H5, H6 {font-family: Verdana, Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ; }
</style>

</head>
<body>

eg/contrib/locale/README  view on Meta::CPAN


msgid "Cookies must be enabled in your browser."
msgstr "Im Browser müssen Cookies eingeschaltet sein."

msgid "This page requires a login."
msgstr "Für diese Seite ist ein Login erforderlich."

msgid "Please try again."
msgstr "Bitte nocheinmal versuchen."

msgid "You did not fill out all the required fields. Please fill the <font
color=\"<PKIT_ERRORSTR>\">red</font> fields."
msgstr "Es wurden nicht alle erforderlichen Felder ausgefüllt. Bitte alle
<font color=\"<PKIT_ERRORSTR>\">roten</font> Felder ausfüllen."

#
# MyPageKit::Common
#

msgid "Your login/password is invalid. Please try again."
msgstr "Das Passwort oder der Login ist ungültig. Bitte nocheinmal versuchen"

msgid "You did not fill all of the fields. Please try again."
msgstr "Es wurden nicht all Felder ausgefüllt, bitte nocheinmal versuchen"

eg/contrib/locale/templates/empty/empty.po  view on Meta::CPAN


msgid "Cookies must be enabled in your browser."
msgstr ""

msgid "This page requires a login."
msgstr ""

msgid "Please try again."
msgstr ""

msgid "You did not fill out all the required fields. Please fill the <font color=\"<PKIT_ERRORSTR>\">red</font> fields."
msgstr ""

#
# MyPageKit::Common
#

msgid "Your login/password is invalid. Please try again."
msgstr ""

msgid "You did not fill all of the fields.  Please try again."

eg/contrib/locale/templates/po/de.po  view on Meta::CPAN


msgid "Cookies must be enabled in your browser."
msgstr "Im Browser müssen Cookies eingeschaltet sein."

msgid "This page requires a login."
msgstr "Für diese Seite ist ein Login erforderlich."

msgid "Please try again."
msgstr "Bitte nocheinmal versuchen."

msgid "You did not fill out all the required fields. Please fill the <font color=\"<PKIT_ERRORSTR>\">red</font> fields."
msgstr "Es wurden nicht alle erforderlichen Felder ausgefüllt. Bitte alle <font color=\"<PKIT_ERRORSTR>\">roten</font> Felder ausfüllen."

#
# MyPageKit::Common
#

msgid "Your login/password is invalid. Please try again."
msgstr "Das Passwort oder der Login ist ungültig. Bitte nocheinmal versuchen"

msgid "You did not fill all of the fields.  Please try again."
msgstr "Es wurden nicht all Felder ausgefüllt, bitte nocheinmal versuchen"

eg/contrib/locale/templates/po/fr.po  view on Meta::CPAN


msgid "Cookies must be enabled in your browser."
msgstr "Votre browser doit accepter les cookies"

msgid "This page requires a login."
msgstr "Vous devez être connecté pour accèder à cette page"

msgid "Please try again."
msgstr "Essayer encore, s'il vous plait"

msgid "You did not fill out all the required fields. Please fill the <font color=\"<PKIT_ERRORSTR>\">red</font> fields."
msgstr "Vous n'avez pas rempli tous les champs obligatoires. S'il vous plaît veuillez remplir tous les champs en <font color=\"<PKIT_ERRORSTR>\">rouge</font>"

#
# MyPageKit::Common
#

msgid "Your login/password is invalid. Please try again."
msgstr "Login et Mot de passe incorrect. S'il vous plait, réessayé"

msgid "You did not fill all of the fields. Please try again."
msgstr "Vous n'avez pas remplis tous les champs. S'il vous plait, réessayé"

eg/contrib/locale/templates/po/pt.po  view on Meta::CPAN


msgid "Cookies must be enabled in your browser."
msgstr "Seu browser deve estar com a opção de cookies habilitada."

msgid "This page requires a login."
msgstr "Está página requer que você se conecte com uma senha válida"

msgid "Please try again."
msgstr "Por favor tente novamente"

msgid "You did not fill out all the required fields. Please fill the <font color=\"<PKIT_ERRORSTR>\">red</font> fields."
msgstr "Você não preencheu todos os campos. Favor preencher os campos em <font color =\"<PKIT_ERRORSTR>\">vermelho</font>"

#
# MyPageKit::Common
#

msgid "Your login/password is invalid. Please try again."
msgstr "Sua identificação/senha é inválida. Tente novamente"

msgid "You did not fill all of the fields. Please try again."
msgstr "Você não preencheu todos os campos. Tente novamente"

lib/Apache2/ErrorReport.pm  view on Meta::CPAN

    my $color = $_[1] eq 'WARN' ? 'blue' : 'red';

    HTML::Entities::encode_entities( $stacktrace, '<>&"' );

    my $bytes_sent = $r->bytes_sent;
    my $repeat = ( 512 < $bytes_sent ) ? 0 : 512 - $bytes_sent ;

    # send a large comment in front of the page so MSIE displays it too.
    my $html_msg =
        '<!-- ' . ( ' ' ) x $repeat . " -->\n"
	. qq{<pre><font color="$color">$_[1]: $stacktrace</font></pre><br>};

    if ( $bytes_sent ) {
      print $html_msg;
    }
    else {
      $r->custom_response( 500, $html_msg );
    }
  }
}

lib/Apache2/PageKit.pm  view on Meta::CPAN

  my $default_lang = $config->get_global_attr('default_lang') || 'en';
  my $default_input_charset = $config->get_global_attr('default_input_charset') || 'ISO-8859-1';
  my $default_output_charset = $config->get_global_attr('default_output_charset') || 'ISO-8859-1';
  my $html_clean_level = $config->get_server_attr('html_clean_level') || 0;
  my $can_edit = $config->get_server_attr('can_edit') || 'no';
  my $reload = $config->get_server_attr('reload') || 'no';

  my $cache_dir = $config->get_global_attr('cache_dir');
  my $view_cache_dir = $cache_dir ? $cache_dir . '/pkit_cache' : $pkit_root . '/View/pkit_cache';
  my $relaxed_parser = $config->get_global_attr('relaxed_parser') || 'no';
  my $errorspan_begin_tag = $config->get_global_attr('errorspan_begin_tag') || q{<font color="<PKIT_ERRORSTR>">};
  my $errorspan_end_tag   = $config->get_global_attr('errorspan_end_tag')   || q{</font>};
  my $default_errorstr   = $config->get_global_attr('default_errorstr')   || '#ff0000';

  my $uri_prefix = $config->get_global_attr('uri_prefix') || '';

  my $template_class = $config->get_global_attr('template_class')
    || 'HTML::Template';
  my $view_class = $template_class =~ /^HTML::Template/ ? 'Apache2::PageKit::View' : 'Apache2::PageKit::View::TT2';
  $self->{view} = $view_class->new(
					     root_dir => $pkit_root,
  					     view_dir => "$pkit_root/View",

lib/Apache2/PageKit/Edit.pm  view on Meta::CPAN


    my $include_mtimes = $record->{include_mtimes};

    my $abs_uri_prefix = $view->{uri_prefix} ? '/' . $view->{uri_prefix} : '';

    # add edit link for main template file
    my $filename = $record->{filename};

    die "Filename ($filename) points outside PKIT_ROOT ($pkit_root)" if ( $filename and $filename !~ s!^$pkit_root/!! );

    my $edit_html = $filename ? qq{<font size="-1"><a href="$abs_uri_prefix/pkit_edit/open_file?file=$filename&pkit_done=$pkit_done">(edit $filename)</a></font><br>}:qq{};

    for my $filename (grep /\.(xml|xsl)$/, keys %$include_mtimes){
      # add edit link content XML files and XSLT files
      die "Filename ($filename) points outside PKIT_ROOT ($pkit_root)" unless ( $filename =~ s!^$pkit_root/!! );

      $edit_html .= qq{<font size="-1"><a href="$abs_uri_prefix/pkit_edit/open_file?file=$filename&pkit_done=$pkit_done">(edit $filename)</a></font><br>};
    }

    for my $filename (grep !/\.xml$/, keys %$include_mtimes){
      # add edit links for components in the location right before where the
      # the component is included
      die "Filename ($filename) points outside PKIT_ROOT ($pkit_root)" unless ( $filename =~ s!^$pkit_root/!! );

      (my $component_id = $filename) =~ s!(?:[^/]+/+){2}(.*?)\.(?:tmpl|xsl)$!$1!;
      $$output_ref =~ s!<PKIT_EDIT_COMPONENT NAME="/?$component_id">!<font size="-1"><a href="$abs_uri_prefix/pkit_edit/open_file?file=$filename&pkit_done=$pkit_done">(edit $filename)</a></font><br>!g;
    }
    $$output_ref = $edit_html . $$output_ref;
#    $$output_ref =~ s/<\s*BODY($key_value_pattern)*\s*>/<BODY$1>$edit_html/i;
  } else {
    $$output_ref =~ s!<PKIT_EDIT_COMPONENT NAME=".*?">!!sig;
  }
}

sub add_component_edit_stubs {
  my ( $view, $page_id, $html_code_ref, $pkit_view ) = @_;

lib/Apache2/PageKit/Edit.pm  view on Meta::CPAN

  # insert edit stubs (PKIT_EDIT_COMPONENT), before each PKIT_COMPONENT tag,
  # for online editing tools to use
  
  if ( $view->{relaxed_parser} eq 'yes' ) {
    $$html_code_ref =~
      s%<(!--)?\s*PKIT_COMPONENT($key_value_pattern+)\s*/?(?(1)--)?>(?:<(!--)?\s*/PKIT_COMPONENT\s*(?(1)--)>)?%_build_component_edit_stub($view, $pkit_view, $page_id, $2)%eig;
  } else {
    $$html_code_ref =~
      s%<\s*PKIT_COMPONENT($key_value_pattern+)\s*/?>(<\s*/PKIT_COMPONENT\s*>)?%_build_component_edit_stub($view, $pkit_view, $page_id, $1)%eig;
  }
    ###$$html_code_ref =~ s!(<[^>]*)?(<PKIT_COMPONENT $key_value_pattern>)!<font size="-1"><a href="/pkit_edit/open_file?file=$3">(edit $3)</a></font><br>$2!sig;

  sub _build_component_edit_stub {
    my ( $view, $pkit_view, $page_id, $params ) = @_;
    my %params;

    while ( $params =~ m!$key_value_pattern!g ) {
      my $value = $3 || $4 || $5;
      if ( $value ) {
        $params{ uc($2) } = $value;
      } else {

lib/Apache2/PageKit/Model.pm  view on Meta::CPAN

sub pkit_lang {
  my $model = shift;
  return $model->{pkit_pk}->{lang};
}

sub pkit_user {
  my $model = shift;
  return $model->{pkit_pk}->{apr}->user;
}

sub pkit_set_errorfont {
  my ( $model, $field, $color_str) = @_;
  $color_str ||= $model->pkit_get_config_attr( GLOBAL => 'default_errorstr' ) || "#ff0000";
  my $begin_name = "PKIT_ERRORSPAN_BEGIN_$field";
  my $begin_value = $model->pkit_get_config_attr( GLOBAL => 'errorspan_begin_tag' ) || qq{<font color="$color_str">};
  $begin_value =~ s/<(!--)?\s*PKIT_ERRORSTR\s*(?(1)--)>/$color_str/gi;
  my $end_name = "PKIT_ERRORSPAN_END_$field";
  my $end_value = $model->pkit_get_config_attr( GLOBAL => 'errorspan_end_tag' ) || q{</font>};
  
  $model->output($begin_name => $begin_value);
  $model->output($end_name => $end_value);
}

# for now both are the same this may change.
# but only pkit_set_errorspan should change.
*pkit_set_errorspan = \&pkit_set_errorfont;

sub pkit_validate_input {
  my ($model, $input_profile) = @_;

  my $messages = delete $input_profile->{messages};

  my $validator = Data::FormValidator->new({default => $input_profile});

  # put the data from input into a %fdat hash so Data::FormValidator can read it
  my $input_hashref = $model->pkit_input_hashref;

lib/Apache2/PageKit/Model.pm  view on Meta::CPAN


        $msg = $model->pkit_gettext($msg);

	# substitutes the value the user entered in the error message
	$msg =~ s/\%\%VALUE\%\%/$value/g;
	$model->pkit_message($msg, is_error => 1);
      }
      $model->pkit_gettext_message('Please try again.', is_error => 1);
    } else {
      # no invalid data, just missing fields
      $model->pkit_gettext_message(qq{You did not fill out all the required fields. Please fill the <font color="<PKIT_ERRORSTR>">red</font> fields.});
    }
    return;
  }
  if ($valids){
    return 1;
  }
}

sub pkit_component_params_hashref {
  return $_[0]->{pkit_pk}->{component_params_hashref};



( run in 0.870 second using v1.01-cache-2.11-cpan-5735350b133 )