Apache2-PageKit

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

		and no content_var's are used. affects only perl < 5.8.0
		( Boris Zentner )
	- Add: Basic testsuite ( Boris Zentner )
	- Remove setup_eg.pl this file is obsolete ( Boris Zentner )
	- Fix: Fresh created session cookie headers are wrongly not send
		for pkit_redirect pages this is fixed now. ( Boris Zentner )
	- Add: Experimental support for Template Toolkit. Enabled with
                template_class = "Template" in your Config.xml
                ( Boris Zentner)
	- Fix: with pkit_admin=on and perl 5.8.x the input data is 
		converted to your default_input_charset.
		( Boris Zentner, Sean Lee )
	- Send Content-Length header for static files. ( Boris Zentner )
	- Fix: eg/dbfile needs rw permission even for nobody or nouser
		if apache is started as root. 
		( Boris Zentner, Shawn Poulson )
1.14
	- Fix: parse for xsl-params again in the xsl files. This was 
		broken in 1.13. ( Ben Ausden )
	- Fix: add use Apache::PageKit::Model to eg/Model/MyPageKit.Common.pm
		since it is possible that the application class is loaded
		before Apache::PageKit ( Boris Zentner )
        - the eg site use DBD::SQLite now. This obsoletes
		DBD::CSV, SQL::Statement and Text::CSV_XS.
		( Boris Zentner )
	- fop_command can be disabled with fop_command = ""
		( Boris Zentner, Shimon Rura )
	- Remove Apache->request calls from Apache::PageKit::Edit
		just to make apache 2 changes smaller ( Boris Zentner )
	- Fix: Parse Accept-Charsets more pettier ( Boris Zentner )
	! If the client browser has no accept charset header or no good one,
		deliver in the default_output_charset and set the charset
		in the content_type header. ( Erik Günther )
	- Fix uri_prefix in conjunction with can_edit
		( Boris Zentner, Erik Günther ) 
1.13
	- Add support for Apache2 ( Boris Zentner )
	- Add scripts/pkit_rename_app.pl it helps to start new applications
		fast ( Boris Zentner )
	- Add <PKIT_COMMENT> and </PKIT_COMMENT> tags. ( Boris Zentner )
	- Fix filetest for upload_tmp_dir ( Boris Zentner )
	- Fix locale support. One message was twice in the .po files.

Changes  view on Meta::CPAN

		(Boris Zentner, Gabriel Burca)
	- Add new server option cookie_postfix. To name cookies just for the
                case, that multiple pkit applications run  in the same
                apache server. (Boris Zentner, David Raimbault)
	- Fix: write the session data and destroy the db connection
		even if an error transpires (Boris Zentner)
	- Fix: defer delivery of static pages if parameters are attached to
		the URI. This allows to login/logout even with a static
		default page (Boris Zentner)
	- Fix iconv conversion: it is perfect legal to convert an empty
		string '' to another charset (Boris Zentner)
	- Add new tags <PKIT_HAVE_MESSAGES> and <PKIT_HAVE_NOT_MESSAGES>
		(Boris Zentner, Sebastian Feuerstack)
1.09
	- Fix: case where something.xml was added to the mtimes hash even
		if it does not exists (only if all your content came from
		another file via xpath document() function) this result in a
		slowdown for the page unless reload="no" (Boris Zentner)
	- Fix: die with the error from the fop command.
        	So the errors show up in your browser or log (Boris Zentner)
	- Fix content_encoding header. If unsure, play save and send
        	the page NOT gzipped (Boris Zentner)
	- Fix fop example pages (John Robinson)
	- Add new global option protect_static (Boris Zentner)
	- Remove some mystery chars (0xA0) (Boris Zentner)
	- Add new hook pkit_on_error to catch and maybe repair fatal errors
		(Boris Zentner)
	! Simplified and more robust startup (Boris Zentner)
	- Clear missing server section on reload (Boris Zentner)
	- Die if a conversion from one charset to another is not possible.
		Maybe a char is not part of the target charset.
		(Boris Zentner, Gabriel Burca)
	! Add protection of static pages with the require_login config
		attribute. (Boris Zentner)
	- Fix two cases where a filehandle can be used even if open failed
		(Boris Zentner)
	- Fix uri_prefix so that the url did not grow anymore (Boris Zentner)
	- Remove unused modules Data::Dumper and Carp from View.pm (Boris Zentner)
	- Fix to deliver static pages unzipped if desired (Anton Permyakov)
	- Fix case where wrong cached file is used for xsl files with
		reload="no" and first called without parameters in the

Changes  view on Meta::CPAN

1.04
	- PageKit now uses Data::FormValidator instead of HTML::FormValidator
		(Mark Stosberg)
	- Sessions cookies only set when session is actually created
	- Fixed content handler for case where there is a loop containing
		and document() func, and vars don't contain document() func,
		and no other top-level tags without document() func (Boris Zentner)
	- Fixed recent_login session (Boris Zentner, David Raimbault)
	- Added pkit_startup class method (Boris Zentner)
	- Charset fixes, now should deal with PageKit templates
		and default_input_charset correctly.

1.03
	- PageKit now supports general charset conversions using Text::Iconv,
		removed workaround for european charsets in XML::XPathTemplate
		(Boris Zentner)
	- PageKit Templates are converted to default_output_charset from
		default_input_charset (Boris Zentner)
	- Added charset translation support with output_charset method in
		Model (Boris Zentner)
	- PageKit Template file cache is now dependant on mtime of Config.xml
	- fixed bug with pkit_lang (Ben Ausden)
	- Added pkit_cleanup_code to main request handler (Boris Zentner)
	- input and pnotes methods in Model now work outside of mod_perl
	- PageKit templates no longer pre-parsed on server startup
	- Multiple input request paramaters now not reset by FormValidator.pm
		output, since FormValidator doesn't support multiple input
		request params.
	- Fixed errors in pkit_input_hashref and PKIT_ERRORFONT tags

Changes  view on Meta::CPAN

	- Sessions only generated with something is written to session
		hash (uses lazy option of Apache::PageKit::Session)
	- Added content_type, supports different media outputs, including
		XML, WML, and PDF
	- Supports on-the-fly generation of PDF using Apache XML FOP
	- Static content is passed through HTML::Clean before it is
		gzipped (Boris Zentner)
	- PageKit Template has now XML-style tags of the form <MODEL_VAR />
		(Boris Zentner)
	- Fixed bug with uri_match
	- Fixed bug with charset conversions in CONTENT_LOOP (Boris Zentner)
	- PageKit now returns gzipped output if Accept-Encoding includes the
		string "zip" (Boris Zentner)
	- PageKit removes all cache files before startup if reload global
		config option is set to "no".
	- Updated Makefile.PL to require lastest version of HTML::FillInForm
	- $uri_with_query now includes uri_prefix (Ben Ausden)
	- PKIT_SELFURL now omits pkit_messages, pkit_error_messages and
		pkit_lang (Ben Ausden)
	- XSL files now located in View/pkit_view directory instead of
		View/pkit_view/XSL

MANIFEST  view on Meta::CPAN

Changes
docsrc/features.xml
docsrc/manual.xml
docsrc/README
docsrc/reference.xml
eg/Config/Config.xml
eg/Config/PageKit_Config-0.97.dtd
eg/Content/charset.xml
eg/Content/content_loop.xml
eg/Content/customize.xml
eg/Content/form_validation.xml
eg/Content/index.xml
eg/Content/language.xml
eg/Content/license.xml
eg/Content/login1.xml
eg/Content/media_xslt.xml
eg/Content/newacct1.xml
eg/Content/restricted.xml

MANIFEST  view on Meta::CPAN

eg/contrib/locale/README
eg/contrib/locale/templates/empty/empty.po
eg/contrib/locale/templates/po/de.po
eg/contrib/locale/templates/po/fr.po
eg/contrib/locale/templates/po/pt.po
eg/Model/MyPageKit/Common.pm
eg/Model/MyPageKit/MyModel.pm
eg/README
eg/View/Default/begin_cell.tmpl
eg/View/Default/bottom.tmpl
eg/View/Default/charset.tmpl
eg/View/Default/charset_tmpl.tmpl
eg/View/Default/content_loop.tmpl
eg/View/Default/customize.tmpl
eg/View/Default/demo_desc.tmpl
eg/View/Default/end_cell.tmpl
eg/View/Default/form_validation.tmpl
eg/View/Default/index.tmpl
eg/View/Default/language.tmpl
eg/View/Default/license.tmpl
eg/View/Default/login1.tmpl
eg/View/Default/media.tmpl

MANIFEST  view on Meta::CPAN

migration/migrate_pagekit_0.96_to_0.97.pl
migration/migrate_pagekit_0.98_to_0.99.pl
migration/migrate_pagekit_0.99_to_1.00.pl
migration/migrate_pagekit_1.05_to_1.06.pl
migration/README
README
scripts/pkit_rename_app.pl
scripts/pkit_setup_sqlite_dbfile.pl
t/01_dummy.t
t/02_language.t
t/03_charset.t
t/04_anon_cookies.t
t/05_account.t
t/06_login.t
t/07_restricted.t
t/08_fresh_cookie_redirect.t
t/09_charset_tmpl.t
t/10_pkit_comment.t
t/conf/extra.last.conf.in
t/TEST.PL

README  view on Meta::CPAN

		- Model is user supplied Perl Classes
		- View is set of PageKit Templates and/or XSLT files
		- Content is set of XML Files
		- Controller is PageKit

	This allows your programmers, designers and content editors to work
	independently with clean well-defined interfaces.

	PageKit provides the following features:
		- Component-based architecture
		- Language Localization and charset translation
		- Session Management
		- Input Validation
		- Sticky HTML Forms
		- Authentication
		- Co-branding and XML,WML, and PDF output
		- Automatic Dispatching of URIs
		- Easy Error Handling
		- Online Editing Tools
		- Page based sessions
		- Localized error/messages

docsrc/features.xml  view on Meta::CPAN

    To use the language settings from the Model, simply use the
    <literal><link linkend="model.api.pkit_lang">pkit_lang</link></literal> method.
   </para>
   <para>
    This can be useful for selecting content from the database based on language.
   </para>
  </sect2>
  <sect2>
  <title>Character set translation</title>
   <para>
    By default, PageKit attempts to output using <link linkend="config.global.default_output_charset">default_output_charset</link>.
    PageKit will attempt to translate the PageKit Templates and output passed
    to <link linkend="model.api.output_convert">output_convert</link> from
    <link linkend="config.global.default_input_charset">default_input_charset</link> to
    <link linkend="config.global.default_output_charset">default_output_charset</link>.
   </para>
   <para>
    Note: This also applies also to the message catalog if any. So write your message catalog files in
    <link linkend="config.global.default_input_charset">default_input_charset</link>.
   </para>
   <para>
    PageKit attempts to translate the output to a character set that is specified in the <literal>Accept-Charset</literal> header. If this is not possible,
    PageKit delivers the page in the <link linkend="config.global.default_output_charset">default_output_charset</link>.
   </para>
  </sect2>
 </sect1>
 <sect1>
  <title>Caching</title>
  <para>
   Currently PageKit supports on-disk caching of compiled PageKit Templates.
   Future versions should also include in-memory caching and caching
   of Model output.
  </para>

docsrc/reference.xml  view on Meta::CPAN

      <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>
        Default charset that PageKit Templates and Model output are encoded in.
	Defaults to
       <emphasis>ISO-8859-1</emphasis>.  PageKit uses this to convert the
        PageKit templates and output from <link linkend="model.api.output_convert">output_convert</link> to UTF-8.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry id="config.global.default_output_charset">
     <term>default_output_charset</term>
     <listitem>
      <para>
        Default charset that PageKit templates compiled to.
	Defaults to
       <emphasis>ISO-8859-1</emphasis>.  This should be the charset that
       supports your <link linkend="config.global.default_input_charset">default_input_charset</link> and has good support among the client's browsers.
      </para>
     </listitem>
    </varlistentry>
    <varlistentry id="config.global.default_lang">
     <term>default_lang</term>
     <listitem>
      <para>
       Default language outputed when no language is specified
       or request language is not available.  Defaults to
       <emphasis>en</emphasis>.

docsrc/reference.xml  view on Meta::CPAN

	  <entry role="th"><para><emphasis role="bold">Special Handing</emphasis></para></entry>
	 </row>
         <row>
	  <entry>text/html</entry>
	  <entry>
 	   HTML output.  This is for traditional screen browsers such as
           Netscape and Internet Explorer.
          </entry>
	  <entry>This is the default content_type for all views except for
             those listed below</entry>
	  <entry>PageKit translates sets the charset in the Content-Type headers and translates the output according
             to the <literal>Accept-Charset</literal> header.</entry>
         </row>
         <row>
	  <entry>application/pdf</entry>
	  <entry>
	   PDF Output, for display in Acrobat Reader.  Uses Apache XML FOP
          </entry>
	  <entry>pdf</entry>
	  <entry>PageKit uses Apache XML FOP to generate the PDF, if
            <link linkend="config.global.fop_command">fop_command</link>

docsrc/reference.xml  view on Meta::CPAN

  }

     </synopsis>
    </refsynopsisdiv>
    <refsect1>
     <title>Description</title>
     <para>

pkit_on_error main purpose is to catch errors for some reason. Maybe you can not
 get a database connection or your page can not be delivered in a special
 charset or anywhere inside your modelcode an uncatched die "for unknown
 reason"; is executed.
</para>
<para>
If nowhere else in your code this error is handled, pkit_on_error is called
 with the error message as second parameter and model as the first. This is
 your chance to deliver a working page. At best with pkit_redirect or pkit_send.
</para>
<para>
If an error happened inside pkit_on_error it is passed thru Apache and you get the internal server
 error as before. pkit_on_error returns the error_msg that is logged. So you

docsrc/reference.xml  view on Meta::CPAN

     <para>
In the example above the <literal>user_id</literal> is set when the user
gets authenticated.
     </para>
    </refsect1>
   </refentry>
   <refentry id="model.api.output_convert">
    <refnamediv>
     <refname>output_convert</refname>
     <refpurpose>
      Outputs data for display, converting charset.
     </refpurpose>
    </refnamediv>
    <refsynopsisdiv>
     <synopsis>
      $model->output_convert(output => {foo => $utf8_text},
			     input_charset => 'UTF-8');
     </synopsis>
    </refsynopsisdiv>
    <refsect1>
     <title>Description</title>
     <para>
      This is a wrapper to the <link linkend="model.api.output">output</link>
      method.  It converts the output from the character set specified by
      the charset argument to <link linkend="config.global.default_output_charset">default_output_charset</link>.  If the character set is not specified, then
      <link linkend="config.global.default_input_charset">default_input_charset</link> is used.
     </para>
    </refsect1>
    <refsect1>
     <title>Examples</title>
     <informalexample>
      <programlisting>
      # converts from UTF-8
      $model->output_convert(output => { key => $utf8_text },
			     charset => 'UTF-8');
      # converts from default_input_charset
      $model->output_convert(key => $text)
      </programlisting>
     </informalexample>
    </refsect1>
   </refentry>
   <refentry id="model.api.output">
    <refnamediv>
     <refname>output</refname>
     <refpurpose>
      Outputs data for display.

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

  <li>Using PageKit Templates generated using XSLT
  <ul>
   <li><a href="media_xslt">HTML</a>
   <li><a href="media_xslt?pkit_view=xml">XML</a>
   <li><a href="media_xslt?pkit_view=wml">WML</a>
   <li><a href="media_xslt?pkit_view=pdf">PDF</a> (uses Apache XML FOP)
  </ul>
 </ul>
 <li><a href="form_validation">Form Validation</a> (also demonstrates sticky HTML forms)
 <li><a href="content_loop">HTML::Template::XPath</a> (CONTENT_LOOP, CONTENT_VAR, etc)
 <li><a href="charset">Charset Translation</a>
 <li><a href="restricted">Page that requires login</a>
</ul>
You are currenting running the <MODEL_VAR NAME="pkit_server_id"> server.
Your session ID is <MODEL_VAR NAME="session_id">.
<PKIT_COMPONENT NAME="/bottom">

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


  # set expires to now so prevent caching
  #$apr->no_cache(1) if $apr->param('pkit_logout') || $config->get_page_attr($pk->{page_id},'template_cache') eq 'no';
  # see http://support.microsoft.com/support/kb/articles/Q234/0/67.ASP
  # and http://www.pacificnet.net/~johnr/meta.html
  my $browser_cache =  $config->get_page_attr($page_id,'browser_cache') || $pk->{browser_cache} || 'yes';
  $apr->headers_out->{'Expires'} = '-1' if $apr->param('pkit_logout') || $browser_cache eq 'no' || $apr->user;

  my $content_type = $output_media;
  
  my $default_output_charset = $view->{default_output_charset};
  my @charsets = ();
  if($output_media eq 'text/html'){
    # first get accepted charsets from incoming Accept-Charset HTTP header
    if(my $accept_charset = $apr->headers_in->{'Accept-Charset'}){
      my @quality = split(/\s*;\s*/, $accept_charset);
      my @accept_charsets = split(/\s*,\s*/, shift @quality);
      my $pos = 0;
      for ( @accept_charsets ) {
        s/^(iso|utf)/\U$1/;
        s/^(us\-)?ascii/US-ASCII/;
	$quality[$pos] =~ /^q=(\d+(?:\.\d+)?)/;
	push @charsets, [ $_, $1 || '0.1', $pos++ ];
      }
      @charsets = sort {$b->[1] <=> $a->[1] || $a->[2] <=> $b->[2] } @charsets;
     
     # set a content-type perhaps we overwrite this later if we know about the charset for the output pages
    }
  } elsif ($output_media eq 'application/pdf'){
    
    my $fop_command = $config->get_server_attr('fop_command') 
      || $config->get_global_attr('fop_command');

    if ( $fop_command ) {
      # write output_media to file, using process number of Apache child process
      my $view_cache_dir = $view->{cache_dir};
      my $fo_file = "$view_cache_dir/$$.fo";

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

  # for a head request
  if ($apr->header_only) {
    $apr->content_type($content_type);
    return;
  }

  # call output filter, if applicable
  $model->pkit_output_filter($output_ref)
    if $model->can('pkit_output_filter');

  my ( $converted_data, $retcharset );
  if ($output_media eq 'text/html'){
    my $data;
    while (@charsets){
      $retcharset = (shift @charsets)->[0];
      eval {
        $converted_data = Encode::encode($retcharset, $$output_ref, Encode::FB_CROAK );
      };
      last unless ($@);
      $retcharset = undef;
    }

    ## here no action is needed, if we did not convert the data to anything usefull.
    ## we deliver in our default_output_charset.

    # correct the header
    if ($retcharset) {
      $content_type = "text/html; charset=$retcharset";
    }
    else {
      $content_type = "text/html; charset=$default_output_charset";
      $converted_data = Encode::encode( $default_output_charset, $$output_ref,Encode::FB_DEFAULT );
    }
    # it is already "text/html"
  }

  # only pages with propper $retcharset are tranfered gzipped.
  # this can maybe changed!? Needs some tests
  my $send_gzipped = ( $retcharset && $pk->{use_gzip} eq 'all' );
  $apr->content_encoding('gzip') if ($send_gzipped);

  $apr->content_type($content_type) unless $apr->main;

  if ($send_gzipped) {
    $apr->print(Compress::Zlib::memGzip($converted_data || $$output_ref));
  } else {
    $apr->print($converted_data || $$output_ref);
  }
}

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

    unless($model_base_class){
      die "model_base_class not specified";
    } else {
      die "Model class $model_base_class has no new method ($@)";
    }
  }

  $self->{dbh} = $model->pkit_dbi_connect if $model->can('pkit_dbi_connect');

  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';

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


  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",
					     content_dir => "$pkit_root/Content",
					     cache_dir => $view_cache_dir,
					     default_lang => $default_lang,
					     default_input_charset => $default_input_charset,
					     default_output_charset => $default_output_charset,
					     reload => $reload,
					     html_clean_level => $html_clean_level,
					     input_param_object => $apr,
					     output_param_object => $self->{output_param_object},
					     can_edit => $can_edit,
                                             relaxed_parser => $relaxed_parser,
                                             errorspan_begin_tag => $errorspan_begin_tag,
                                             errorspan_end_tag => $errorspan_end_tag,
                                             default_errorstr => $default_errorstr,
                                             template_class => $template_class,

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

  }

  my $file = $model->input('file') || die "No input filename!";

  $model->output(file => $file);

  $file = _build_path( $model->pkit_root, $file ) || die "Illegal input chars ($file)" ;

  $model->output( read_only => 1 ) if ( ! -w $file );

  my $default_input_charset = $model->{pkit_pk}->{view}->{default_input_charset};
  open my $fh, $file or die $!;
  binmode $fh, ":encoding($default_input_charset)";
  local $/;

# we need to escape HTML tags to avoid </textarea>
# my $content = Apache2::Util::escape_html(<PAGE> || "");
  my $content = <$fh>;
  close $fh;

  # we need to escape all & chars so that for example &nbsp; is
  # &nbsp; and not ' ' 
  #<textarea> holds #PCDATA

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

    $model->pkit_internal_redirect($model->pkit_get_default_page);
    return;
  }

  my $file = $model->input('file') || die "No input filename!";
  $file = _build_path( $model->pkit_root, $file ) || die "Illegal input chars ($file)" ;

  my $pkit_done = $model->input('pkit_done');
  my $content = $model->input('content');

  my $default_input_charset = $model->{pkit_pk}->{view}->{default_input_charset};
  open my $fh, ">$file" or die $!;
  binmode $fh, ":encoding($default_input_charset)";
  print $fh $content;
  close $fh;

  if($pkit_done){
    $model->pkit_redirect($pkit_done);
  }
}

sub add_edit_links {
  my ($view, $record, $output_ref) = @_;

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

  }
  $model->{pkit_input_hashref} = $input_hashref;
}

sub pkit_message {
  my $model = shift;
  my $message = shift;

  my $options = {@_};

  # translate from default_input_charset to default_output_charset if needed
  my $view = $model->{pkit_pk}->{view};
  my $input_charset = $view->{default_input_charset};
  $message = Encode::decode($input_charset, $message );
  
  my $default_error_str = $model->pkit_get_config_attr( GLOBAL => 'default_errorstr' ) || "#ff0000";
  $message  =~ s/<(!--)?\s*PKIT_ERRORSTR\s*(?(1)--)>/$default_error_str/gi;

  my $array_ref = $model->output('pkit_messages') || [];
  push @$array_ref, {pkit_message  => $message,
		    pkit_is_error  => $options->{'is_error'}};

  $model->output('pkit_messages',$array_ref);
}

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

sub pkit_status_code {
  my $pk = shift->{pkit_pk};
  my $old_status_code = $pk->{status_code};
  $pk->{status_code} = $_[0] if ( @_ );
  return $old_status_code;
}

sub output_convert {
  my ($model, %p) = @_;
  my $view = $model->{pkit_pk}->{view};
  my $input_charset = exists $p{input_charset} ? $p{input_charset} : $view->{default_input_charset};
    &_change_params($input_charset, $p{output} ? %{$p{output}} : %p );
  $model->output( $p{output} || %p );
}

sub pnotes {
  my $model = shift;
  my $apr = $model->{pkit_pk}->{apr};
  if($apr->can('pnotes')){
    $apr->pnotes(@_);
  } else {
    # if running outside of mod_perl

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

      unless ( $apr->sendfile($ref_or_fname) == APR::Const::SUCCESS ) {
        warn "can not open file: $ref_or_fname ($!)";
        return NOT_FOUND;
      }
    }
  }
  return DONE;
}

# helper function for output_convert
# it converts all hash values to the desired charset INPLACE
# is this a good idea or better clone it?
sub _change_params {

  sub _change_array {
    my ($charset, $aref)  = @_;
    foreach (@$aref) {
      my $type = ref $_;
      if ( $type eq 'HASH' ) {
        _change_hash( $charset, $_ );
      } elsif ( $type eq 'ARRAY' ) {
        _change_array( $charset, $_ );
      } else {
        $_ = Encode::decode($charset, $_);
      }
    }
  }

  sub _change_hash {
    my ($charset, $href)  = @_;
    foreach ( values %$href ) {
      my $type = ref $_;
      if ( $type eq 'HASH' ) {
        _change_hash( $charset, $_ );
      } elsif ( $type eq 'ARRAY' ) {
        _change_array( $charset, $_ );
      } else {
        $_ = Encode::decode($charset, $_);
      }
    }
  }
  my $charset = shift;
  for ( my $i = 1 ; $i <= $#_ ; $i += 2 ) {
    my $type = ref $_[$i];
    if ( $type eq 'HASH' ) {
      _change_hash( $charset, $_[$i] );
    } elsif ( $type eq 'ARRAY' ) {
      _change_array( $charset, $_[$i] );
    } else {
      $_[$i] = Encode::decode($charset, $_[$i]);
    }
  }
}

1;

__END__

=head1 NAME

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


  my $template_file = $view->_find_template($pkit_view, $component_id);
  my $template_ref;

  unless($template_file){
    # no template file exists, attempt to generate from XML and XSL files
    # currently only XML::LibXSLT is supported
    $template_ref = $view->{content}->generate_template($page_id, $component_id, $pkit_view, $view->{input_param_object}, $component_params);
  } else {
      open my $template_fh, "<$template_file" or die "can not read $template_file";
      my $default_input_charset = $view->{default_input_charset};
      binmode $template_fh, ":encoding($default_input_charset)";
      local $/;
      my $template = <$template_fh>;
      close $template_fh;

    # expand PKIT_MACRO tags
    $template =~ s!<\s*PKIT_MACRO$key_value_pattern\s*/?>!$component_params->{uc($+)} || ''!egi;

    $template_ref = \$template;

    my $mtime = (stat(_))[9];

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

						     default_lang => $view->{default_lang},
                                                     relaxed_parser => $view->{relaxed_parser},
                                                     template_class => $view->{template_class},
                                                     );

  $view->{lang_tmpl} = $content->{lang_tmpl} = {};
  $content->{include_mtimes} = {};
  $view->{component_ids_hash} = {};

  # we add Config.xml to the hash of files to be checked for mtimes,
  # in case default_input_charset or default_output_charset changes!
  (my $config_file = $view->{view_dir}) =~ s!/View$!/Config/Config.xml!;
  my $config_mtime = ( stat($config_file) )[9];
  $view->{include_mtimes} = {$config_file => $config_mtime};

  my $template_file = $view->_find_template($pkit_view, $page_id);
  my $template_ref = $view->_load_component($page_id,$page_id,$pkit_view);

  # remove PKIT_COMMENT parts.
  my $pkit_comment_re = $re_helper{ $view->{relaxed_parser} eq 'yes' ? 'relaxed_parser' : 'std_parser' }->{pkit_comment_re};
  $$template_ref =~ s/$pkit_comment_re//sgi;

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

                                                                    default_lang   => $view->{default_lang},
                                                                    relaxed_parser => $view->{relaxed_parser},
                                                                    template_class => $content_template_class,
  );

  $view->{lang_tmpl} = $content->{lang_tmpl} = {};
  $content->{include_mtimes}  = {};
  $view->{component_ids_hash} = {};

  # we add Config.xml to the hash of files to be checked for mtimes,
  # in case default_input_charset or default_output_charset changes!
  ( my $config_file = $view->{view_dir} ) =~ s!/View$!/Config/Config.xml!;
  my $config_mtime = ( stat($config_file) )[9];
  $view->{include_mtimes} = { $config_file => $config_mtime };

  my $template_file = $view->_find_template( $pkit_view, $page_id );
  my $template_ref = $view->_load_component( $page_id, $page_id, $pkit_view );

  # remove PKIT_COMMENT parts.
  my $pkit_comment_re = $re_helper{ $view->{relaxed_parser} eq 'yes' ? 'relaxed_parser' : 'std_parser' }->{pkit_comment_re};
  $$template_ref =~ s/$pkit_comment_re//sgi;

migration/README  view on Meta::CPAN

Please remember to BACK UP YOUR FILES before attempting to run migration
scripts.
=============================================================
Migration from 1.11 to 1.12

1. It is important to note that if PageKit runs in a perl 5.6.x environment
	all internal pages are in default_output_charset. For perl 5.8.x
	all these pages are in perl's own unicode format. This change should
	be transparent to the user but many libraries do not support perl's
	new character handling.

=============================================================
Migration from 1.10 to 1.11

=============================================================
Migration from 1.09 to 1.10

t/03_charset.t  view on Meta::CPAN

      require encoding;
      encoding->import('latin1');
    }
  };
}

# simple load test
ok 1;

# check if we can request a page
my $url = '/charset';
my $s1  = 'index.tmpl: stra&#223;e   straße ööäöüäüöüü';
my $s2  = 'straße ßßöäöäöüäöäüü';

# preform the test twice, the first time to fill the cache and a
# second time to use the results.
for ( 1 .. 2 ) {
  my $data = GET_BODY $url, 'Accept-Charset', 'iso-8859-1';
  ok t_cmp( $data, qr~$s1~, "street ok? (iso-8859-1)" );
  ok t_cmp( $data, qr~$s2~, "street from content_var ok? (iso-8859-1)" );
}

t/09_charset_tmpl.t  view on Meta::CPAN

      require encoding;
      encoding->import('latin1');
    }
  };
}

# simple load test
ok 1;

# check if we can request a page
my $url = '/charset_tmpl';
my $s1  = 'index.tmpl: stra&#223;e   straße ööäöüäüöüü';

# preform the test twice, the first time to fill the cache and a
# second time to use the results.
for ( 1 .. 2 ) {
  my $data = GET_BODY $url, 'Accept-Charset', 'iso-8859-1';
  ok t_cmp( $data, qr~$s1~, "street ok? (iso-8859-1)" );
}

for ( 1 .. 2 ) {

t/10_pkit_comment.t  view on Meta::CPAN

use warnings FATAL => 'all';
use Apache::Test;
use Apache::TestUtil;
use Apache::TestRequest 'GET_BODY';
plan tests => 3;

# simple load test
ok 1;

# check if we can request a page
my $url = '/charset_tmpl';

# preform the test twice, the first time to fill the cache and a
# second time to use the results.
for ( 1 .. 2 ) {
  my $data = GET_BODY $url, 'Accept-Charset', 'iso-8859-1';
  ok ( $data !~ /pkit_comment/i );
}



( run in 0.773 second using v1.01-cache-2.11-cpan-4d50c553e7e )