|
From: Chris W. <la...@us...> - 2001-10-29 05:15:23
|
Update of /cvsroot/openinteract/OpenInteract/pkg/base_page/script
In directory usw-pr-cvs1:/tmp/cvs-serv5605/script
Added Files:
static_page2base_page.pl
Log Message:
added first draft of script to move from 'static_page' to 'base_page'
--- NEW FILE: static_page2base_page.pl ---
#!/usr/bin/perl
# $Id: static_page2base_page.pl,v 1.1 2001/10/29 05:15:20 lachoy Exp $
# Transition all your static_page objects to base_page. This assumes
# that you are using all-database storage and want to transition to
# all-filesystem storage.
use strict;
use OpenInteract::Startup;
# Do you want to add '.html' to any pages that don't have it? This can
# be useful if you need to use the files for something else, or ensure
# that they can be used
my $ADD_HTML = 'yes';
# Do you want your pages saved in the filesystem? This is encouraged.
my $AS_FILE = 'yes';
{
my $R = OpenInteract::Startup->setup_static_environment_options();
# First retrieve all the static page objects
my $iter = $R->static_page->fetch_iterator({ skip_security => 1 });
my $page_class = $R->page;
my $count = 1;
while ( my $static_page = $iter->get_next ) {
print "$count: $static_page->{location}\n";
# Modify the location as necessary
my $location => $static_page->{location};
if ( $ADD_HTML eq 'yes' and $location !~ /\.html$/ ) {
$location .= '.html';
}
# Set most page properties
my $page = $page_class->new({
title => $static_page->{title},
author => $static_page->{author},
keywords => $static_page->{keywords},
boxes => $static_page->{boxes},
main_template => $static_page->{main_template},
active_on => $static_page->{active_on},
expires_on => $static_page->{expires_on},
is_active => $static_page->{is_active},
notes => $static_page->{notes},
mime_type => 'text/html',
location => $location });
# Set file status
if ( $AS_FILE eq 'yes' ) {
$page->{is_file} = 'yes';
}
else {
$page->{is_file} = 'no';
}
# Set the content
if ( $static_page->{script} ) {
$page->{content} = join( "\n", $static_page->{pagetext},
qq(<script language="JavaScript">\n<!--\n),
$static_page->{script},
qq(\n// -->\n</script>) );
}
else {
$page->{content} = $static_page->{pagetext};
}
# Save the page object (automatically saves the content) and
# display a status
eval { $page->save({ skip_security => 1 }) };
if ( $@ ) {
print " ERROR: $@\n";
}
else {
print " OK: $page->{location}\n";
}
$count++;
}
}
|