You can subscribe to this list here.
| 2001 |
Jan
|
Feb
|
Mar
|
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
(381) |
Nov
(176) |
Dec
(310) |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 2002 |
Jan
(334) |
Feb
(96) |
Mar
(149) |
Apr
(214) |
May
(120) |
Jun
(56) |
Jul
(10) |
Aug
(273) |
Sep
(182) |
Oct
(56) |
Nov
(125) |
Dec
(22) |
| 2003 |
Jan
(63) |
Feb
(181) |
Mar
(498) |
Apr
(433) |
May
(39) |
Jun
(512) |
Jul
(276) |
Aug
(156) |
Sep
(101) |
Oct
(66) |
Nov
(24) |
Dec
(161) |
| 2004 |
Jan
(1) |
Feb
(377) |
Mar
(68) |
Apr
(26) |
May
(107) |
Jun
(333) |
Jul
(13) |
Aug
|
Sep
(76) |
Oct
(88) |
Nov
(170) |
Dec
(91) |
| 2005 |
Jan
(52) |
Feb
(239) |
Mar
(402) |
Apr
(15) |
May
(2) |
Jun
(1) |
Jul
(13) |
Aug
|
Sep
(71) |
Oct
(34) |
Nov
|
Dec
|
| 2006 |
Jan
(5) |
Feb
(5) |
Mar
(2) |
Apr
|
May
|
Jun
|
Jul
|
Aug
(3) |
Sep
(7) |
Oct
(2) |
Nov
|
Dec
|
| 2007 |
Jan
|
Feb
|
Mar
(1) |
Apr
|
May
|
Jun
|
Jul
|
Aug
|
Sep
|
Oct
|
Nov
|
Dec
|
|
From: Chris W. <la...@us...> - 2001-10-22 11:50:08
|
Update of /cvsroot/openinteract/SPOPS/SPOPS
In directory usw-pr-cvs1:/tmp/cvs-serv344
Modified Files:
DBI.pm GDBM.pm LDAP.pm
Log Message:
all calls to 'new()' when fetching objects should be accompanied by
'skip_default_values'
Index: DBI.pm
===================================================================
RCS file: /cvsroot/openinteract/SPOPS/SPOPS/DBI.pm,v
retrieving revision 1.51
retrieving revision 1.52
diff -C2 -d -r1.51 -r1.52
*** DBI.pm 2001/10/12 21:00:26 1.51
--- DBI.pm 2001/10/22 11:50:00 1.52
***************
*** 226,231 ****
# it; if not, check to see if we can whip up a cached object
! if ( $p->{data} ) {
! $obj = $class->new( $p->{data} );
}
else {
--- 226,231 ----
# it; if not, check to see if we can whip up a cached object
! if ( ref $p->{data} eq 'HASH' ) {
! $obj = $class->new({ %{ $p->{data} }, skip_default_values => 1 });
}
else {
***************
*** 268,272 ****
# a parameter of an object -- THAT would be fun to debug...
! $obj = $class->new( { id => $id, %{ $p } } );
$obj->_fetch_assign_row( $raw_fields, $row, $p );
}
--- 268,272 ----
# a parameter of an object -- THAT would be fun to debug...
! $obj = $class->new( { id => $id, skip_default_values => 1, %{ $p } } );
$obj->_fetch_assign_row( $raw_fields, $row, $p );
}
Index: GDBM.pm
===================================================================
RCS file: /cvsroot/openinteract/SPOPS/SPOPS/GDBM.pm,v
retrieving revision 1.13
retrieving revision 1.14
diff -C2 -d -r1.13 -r1.14
*** GDBM.pm 2001/10/12 21:00:26 1.13
--- GDBM.pm 2001/10/22 11:50:00 1.14
***************
*** 19,23 ****
my $C = $class->CONFIG;
if ( ref $C->{field} eq 'HASH' ) {
! $C->{field_list} = [ sort{ $C->{field}->{$a} <=> $C->{field}->{$b} } keys %{ $C->{field} } ];
}
$class->_class_initialize( $CONFIG ); # allow subclasses to do their own thing
--- 19,23 ----
my $C = $class->CONFIG;
if ( ref $C->{field} eq 'HASH' ) {
! $C->{field_list} = [ sort{ $C->{field}{$a} <=> $C->{field}{$b} } keys %{ $C->{field} } ];
}
$class->_class_initialize( $CONFIG ); # allow subclasses to do their own thing
***************
*** 81,90 ****
$gdbm_filename = $item->{tmp_gdbm_filename};
}
! if ( $item->CONFIG->{gdbm_info}->{file_fragment} and $p->{directory} ) {
DEBUG() && _w( 1, "Found file fragent and directory" );
! $gdbm_filename ||= join( '/', $p->{directory}, $item->CONFIG->{gdbm_info}->{file_fragment} );
}
! $gdbm_filename ||= $item->CONFIG->{gdbm_info}->{filename};
! $gdbm_filename ||= $item->global_config->{gdbm_info}->{filename};
}
DEBUG() && _w( 1, "Trying file $gdbm_filename to connect" );
--- 81,90 ----
$gdbm_filename = $item->{tmp_gdbm_filename};
}
! if ( $item->CONFIG->{gdbm_info}{file_fragment} and $p->{directory} ) {
DEBUG() && _w( 1, "Found file fragent and directory" );
! $gdbm_filename ||= join( '/', $p->{directory}, $item->CONFIG->{gdbm_info}{file_fragment} );
}
! $gdbm_filename ||= $item->CONFIG->{gdbm_info}{filename};
! $gdbm_filename ||= $item->global_config->{gdbm_info}{filename};
}
DEBUG() && _w( 1, "Trying file $gdbm_filename to connect" );
***************
*** 137,141 ****
return undef unless ( $item_info );
my $data = undef;
! {
no strict 'vars';
$data = eval $item_info;
--- 137,141 ----
return undef unless ( $item_info );
my $data = undef;
! {
no strict 'vars';
$data = eval $item_info;
***************
*** 145,161 ****
}
! # Retreive an object
sub fetch {
my ( $class, $id, $p ) = @_;
! my $data = $p->{data};
unless ( $data ) {
return undef unless ( $id and $id !~ /^tmp/ );
return undef unless ( $class->pre_fetch_action( { id => $id } ) );
! $data = $class->_return_structure_for_key( $class->object_key( $id ),
! { filename => $p->{filename},
directory => $p->{directory} } );
! }
! my $obj = $class->new( $data );
$obj->clear_change;
return undef unless ( $class->post_fetch_action );
--- 145,161 ----
}
! # Retreive an object
sub fetch {
my ( $class, $id, $p ) = @_;
! my $data = $p->{data} || {};
unless ( $data ) {
return undef unless ( $id and $id !~ /^tmp/ );
return undef unless ( $class->pre_fetch_action( { id => $id } ) );
! $data = $class->_return_structure_for_key( $class->object_key( $id ),
! { filename => $p->{filename},
directory => $p->{directory} } );
! }
! my $obj = $class->new({ %{ $data }, skip_default_values => 1 });
$obj->clear_change;
return undef unless ( $class->post_fetch_action );
***************
*** 177,181 ****
next unless ( $data );
push @objects, $class->fetch( undef, { data => $data } );
! }
return \@objects;
}
--- 177,181 ----
next unless ( $data );
push @objects, $class->fetch( undef, { data => $data } );
! }
return \@objects;
}
***************
*** 194,198 ****
}
return undef unless ( $self->pre_save_action( { is_add => $is_add } ) );
!
# Build the data and dump to string
--- 194,198 ----
}
return undef unless ( $self->pre_save_action( { is_add => $is_add } ) );
!
# Build the data and dump to string
***************
*** 200,204 ****
local $Data::Dumper::Indent = 0;
my $obj_string = Data::Dumper->Dump( [ \%data ], [ 'data' ] );
!
# Save to DB
--- 200,204 ----
local $Data::Dumper::Indent = 0;
my $obj_string = Data::Dumper->Dump( [ \%data ], [ 'data' ] );
!
# Save to DB
***************
*** 282,286 ****
B<global_gdbm_tie( \%params )>
! Returns a tied hashref if successful.
There are many different ways of creating a filename used for
--- 282,286 ----
B<global_gdbm_tie( \%params )>
! Returns a tied hashref if successful.
There are many different ways of creating a filename used for
***************
*** 337,341 ****
In the config file just joins the 'name' and 'version' parameters of
! an object and returns the result.
B<object_key>
--- 337,341 ----
In the config file just joins the 'name' and 'version' parameters of
! an object and returns the result.
B<object_key>
Index: LDAP.pm
===================================================================
RCS file: /cvsroot/openinteract/SPOPS/SPOPS/LDAP.pm,v
retrieving revision 1.30
retrieving revision 1.31
diff -C2 -d -r1.30 -r1.31
*** LDAP.pm 2001/10/12 21:00:26 1.30
--- LDAP.pm 2001/10/22 11:50:01 1.31
***************
*** 186,190 ****
DEBUG() && _wm( 1, "Single entry found ok; setting values into object",
"(Delay security: $info->{delay_security_check})" );
! my $obj = $class->new;
$obj->_fetch_assign_row( undef, $entry );
if ( $info->{delay_security_check} && ! $p->{skip_security} ) {
--- 186,190 ----
DEBUG() && _wm( 1, "Single entry found ok; setting values into object",
"(Delay security: $info->{delay_security_check})" );
! my $obj = $class->new({ skip_default_values => 1 });
$obj->_fetch_assign_row( undef, $entry );
if ( $info->{delay_security_check} && ! $p->{skip_security} ) {
***************
*** 250,254 ****
$class->_check_error( $p->{ldap_msg}, 'Error trying to run LDAP search' );
}
! return SPOPS::Iterator::LDAP->new( $p );
}
--- 250,254 ----
$class->_check_error( $p->{ldap_msg}, 'Error trying to run LDAP search' );
}
! return SPOPS::Iterator::LDAP->new( { %{ $p }, skip_default_values => 1 });
}
***************
*** 266,270 ****
ENTRY:
while ( my $entry = $ldap_msg->shift_entry ) {
! my $obj = $class->new;
$obj->_fetch_assign_row( undef, $entry );
my $level = ( $p->{skip_security} )
--- 266,270 ----
ENTRY:
while ( my $entry = $ldap_msg->shift_entry ) {
! my $obj = $class->new({ skip_default_values => 1 });
$obj->_fetch_assign_row( undef, $entry );
my $level = ( $p->{skip_security} )
|
|
From: Chris W. <la...@us...> - 2001-10-22 06:27:53
|
Update of /cvsroot/openinteract/SPOPS
In directory usw-pr-cvs1:/tmp/cvs-serv25242
Modified Files:
Changes
Log Message:
latest changes
Index: Changes
===================================================================
RCS file: /cvsroot/openinteract/SPOPS/Changes,v
retrieving revision 1.65
retrieving revision 1.66
diff -C2 -d -r1.65 -r1.66
*** Changes 2001/10/22 05:43:10 1.65
--- Changes 2001/10/22 06:27:50 1.66
***************
*** 15,18 ****
--- 15,23 ----
information for a particular record to use as defaults.
+ * SPOPS/DBI/MySQL.pm:
+
+ - Added SPOPS::ClassFactory behavior so we can tell MySQL to find
+ defaults for fields.
+
* SPOPS/ClassFactory/DefaultBehavior.pm:
|
|
From: Chris W. <la...@us...> - 2001-10-22 06:26:29
|
Update of /cvsroot/openinteract/SPOPS/SPOPS/DBI
In directory usw-pr-cvs1:/tmp/cvs-serv24578
Modified Files:
MySQL.pm
Log Message:
set defaults if asked
Index: MySQL.pm
===================================================================
RCS file: /cvsroot/openinteract/SPOPS/SPOPS/DBI/MySQL.pm,v
retrieving revision 1.11
retrieving revision 1.12
diff -C2 -d -r1.11 -r1.12
*** MySQL.pm 2001/10/12 21:00:26 1.11
--- MySQL.pm 2001/10/22 06:26:26 1.12
***************
*** 5,8 ****
--- 5,9 ----
use strict;
use SPOPS qw( _w DEBUG );
+ use SPOPS::ClassFactory qw( OK NOTIFY );
use SPOPS::Key::DBI::HandleField;
***************
*** 25,28 ****
--- 26,66 ----
DEBUG() && _w( 1, "Setting to handle field: $item->CONFIG->{handle_field}" );
return SPOPS::Key::DBI::HandleField::post_fetch_id( $item, @args );
+ }
+
+
+ # Code generation behavior -- find defaults if asked
+
+ sub behavior_factory {
+ my ( $class ) = @_;
+ DEBUG() && _w( 1, "Installing MySQL default discovery for ($class)" );
+ return { manipulate_configuration => \&find_mysql_defaults };
+ }
+
+
+ sub find_mysql_defaults {
+ my ( $class ) = @_;
+ my $CONFIG = $class->CONFIG;
+ return ( OK, undef ) unless ( $CONFIG->{find_defaults} eq 'yes' );
+ my $dbh = $class->global_datasource_handle( $CONFIG->{datasource} );
+ unless ( $dbh ) {
+ return ( NOTIFY, "Cannot find defaults because no DBI database " .
+ "handle available to class ($class)" );
+ }
+
+ my $sql = "DESCRIBE $CONFIG->{base_table}";
+ my ( $sth );
+ eval {
+ $sth = $dbh->prepare( $sql );
+ $sth->execute;
+ };
+ if ( $@ ) {
+ return ( NOTIFY, "Cannot find defaults because there was an error " .
+ "executing ($sql): $@. Class: $class" );
+ }
+ while ( my $row = $sth->fetchrow_arrayref ) {
+ my $default = $row->[4];
+ next unless ( $default );
+ $CONFIG->{default_values}{ $row->[0] } = $default;
+ }
}
|
|
From: Chris W. <la...@us...> - 2001-10-22 05:43:13
|
Update of /cvsroot/openinteract/SPOPS In directory usw-pr-cvs1:/tmp/cvs-serv1900 Modified Files: Changes Log Message: latest changes Index: Changes =================================================================== RCS file: /cvsroot/openinteract/SPOPS/Changes,v retrieving revision 1.64 retrieving revision 1.65 diff -C2 -d -r1.64 -r1.65 *** Changes 2001/10/15 04:54:03 1.64 --- Changes 2001/10/22 05:43:10 1.65 *************** *** 1,4 **** --- 1,28 ---- Revision history for Perl extension SPOPS. + 0.52 + + Individual: + + * eg/find_defaults_demo.pl: + + - Self-contained script used to demonstrate how + My::DBI::FindDefaults works. + + * eg/My/DBI/FindDefaults.pm: + + - Example of a SPOPS::ClassFactory behavior that retrieves the + information for a particular record to use as defaults. + + * SPOPS/ClassFactory/DefaultBehavior.pm: + + - Bugfix: rulesets used to be generated using the method + 'ruleset_add'. We now use 'ruleset_factory' since it's more + descriptive and consistent with the behavior generation + code. However, we forgot to keep the old method enabled for a few + versions. Fixed. (Thanks to Peter Beardsley + <pbe...@ap...> for the report.) + + 0.51 Sun Oct 14 20:23:59 EDT 2001 |
|
From: Chris W. <la...@us...> - 2001-10-22 05:42:53
|
Update of /cvsroot/openinteract/SPOPS In directory usw-pr-cvs1:/tmp/cvs-serv1687 Modified Files: MANIFEST Log Message: added defaults items Index: MANIFEST =================================================================== RCS file: /cvsroot/openinteract/SPOPS/MANIFEST,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** MANIFEST 2001/10/15 04:53:21 1.21 --- MANIFEST 2001/10/22 05:42:50 1.22 *************** *** 64,67 **** --- 64,68 ---- eg/README eg/fetch_doodads.pl + eg/find_defaults_demo.pl eg/stock_doodads.pl eg/stock_user_group.pl *************** *** 75,77 **** eg/My/Group.pm eg/My/Security.pm ! eg/My/User.pm \ No newline at end of file --- 76,79 ---- eg/My/Group.pm eg/My/Security.pm ! eg/My/User.pm ! eg/My/DBI/FindDefaults.pm \ No newline at end of file |
|
From: Chris W. <la...@us...> - 2001-10-22 05:42:39
|
Update of /cvsroot/openinteract/SPOPS
In directory usw-pr-cvs1:/tmp/cvs-serv1495
Modified Files:
SPOPS.pm
Log Message:
added the ability to set default values when you initialize an object
Index: SPOPS.pm
===================================================================
RCS file: /cvsroot/openinteract/SPOPS/SPOPS.pm,v
retrieving revision 1.50
retrieving revision 1.51
diff -C2 -d -r1.50 -r1.51
*** SPOPS.pm 2001/10/12 19:59:09 1.50
--- SPOPS.pm 2001/10/22 05:42:37 1.51
***************
*** 116,126 ****
}
DEBUG() && _w( 1, "Creating new object of class ($class) with tie class ",
"($tie_class); lazy loading ($params->{is_lazy_load});",
"field mapping ($params->{is_field_map})" );
- my ( %data );
my $int = tie %data, $tie_class, $class, $params;
DEBUG() && _w( 4, "Internal tie structure of new object: ", Dumper( $int ) );
my $self = bless( \%data, $class );
$self->initialize( $p );
return $self;
--- 116,135 ----
}
+ my ( %data );
+
DEBUG() && _w( 1, "Creating new object of class ($class) with tie class ",
"($tie_class); lazy loading ($params->{is_lazy_load});",
"field mapping ($params->{is_field_map})" );
my $int = tie %data, $tie_class, $class, $params;
DEBUG() && _w( 4, "Internal tie structure of new object: ", Dumper( $int ) );
my $self = bless( \%data, $class );
+
+ # Set defaults if set, unless NOT specified
+
+ my $defaults = $p->{default_values} || $CONFIG->{default_values};
+ if ( ref $defaults eq 'HASH' and ! $p->{skip_default_values} ) {
+ map { $data{ $_ } = $defaults->{ $_ } } keys %{ $defaults };
+ }
+
$self->initialize( $p );
return $self;
***************
*** 792,795 ****
--- 801,807 ----
the MyUser class.
+ You can also pass in default values to use for the object in the
+ 'default_values' key.
+
We use a number of parameters from your object configuration. These
are:
***************
*** 829,832 ****
--- 841,860 ----
All you need to do is create a field map, defining the interface
property names as the keys and the database field names as the values.
+
+ =item *
+
+ B<default_values> (\%) (optional)
+
+ Hashref of field names and default values for the fields when the
+ object is initialized with C<new()>.
+
+ One problem with setting default values in your object configuration
+ B<and> in your database is that the two may become unsynchronized,
+ resulting in many pulled hairs in debugging.
+
+ To get around the synchronization issue, you can set this dynamically
+ using various methods with
+ L<SPOPS::ClassFactory|SPOPS::ClassFactory>. (A sample,
+ C<My::DBI::FindDefaults>, is shipped with SPOPS.)
=back
|
|
From: Chris W. <la...@us...> - 2001-10-22 05:41:00
|
Update of /cvsroot/openinteract/SPOPS/doc/Manual In directory usw-pr-cvs1:/tmp/cvs-serv519/doc/Manual Modified Files: Configuration.pod Log Message: added configuration information for 'default_values' Index: Configuration.pod =================================================================== RCS file: /cvsroot/openinteract/SPOPS/doc/Manual/Configuration.pod,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** Configuration.pod 2001/10/12 19:39:07 1.6 --- Configuration.pod 2001/10/22 05:40:57 1.7 *************** *** 43,56 **** The name of the class SPOPS will build. ! B<code_class> (\@) An arrayref of class names that will be read in as additional behaviors to the SPOPS-generated class. ! B<field> (\@) An arrayref of fieldnames used in this object. ! B<strict_field> (bool) A flag indicating whether to use strict field checking. --- 43,56 ---- The name of the class SPOPS will build. ! B<code_class> (\@) (optional) An arrayref of class names that will be read in as additional behaviors to the SPOPS-generated class. ! B<field> (\@) (optional if setting dynamically) An arrayref of fieldnames used in this object. ! B<strict_field> (bool) (optional) A flag indicating whether to use strict field checking. *************** *** 63,67 **** they're also used in the normal ISA fashion as class ancestors. ! B<rules_from> (\@) An arrayref of classes to read class factory behaviors and object --- 63,67 ---- they're also used in the normal ISA fashion as class ancestors. ! B<rules_from> (\@) (optional) An arrayref of classes to read class factory behaviors and object *************** *** 75,79 **** object. Currently, multi-field primary keys are not supported. ! B<column_group> (\%) Used by the lazy loading process to determine the group-to-fieldname --- 75,79 ---- object. Currently, multi-field primary keys are not supported. ! B<column_group> (\%) (optional) Used by the lazy loading process to determine the group-to-fieldname *************** *** 81,85 **** information on lazy loading. ! B<field_map> (\%) A hashref of field-to-field relationships so you can make an object --- 81,85 ---- information on lazy loading. ! B<field_map> (\%) (optional) A hashref of field-to-field relationships so you can make an object *************** *** 90,123 **** field mapping. ! B<multivalue> (\@) List all fieldnames that can hold multiple values. Currently the only native support for this is in L<SPOPS::LDAP|SPOPS::LDAP>, but you can also use it along with some object rules to fake relationships. ! B<no_insert> (\@) List of fields not to use when creating a new object in the datastore. ! B<no_update> (\@) List of fields not to update when saving a previously saved object. ! B<skip_undef> (\@) You can elect not to include a field that's undefined when saving or updating an object by including it in this list. ! B<creation_security> (\%) If you're using security, specify here what security the object will have when it's first created. ! B<no_security> (bool) If true, the object won't use security even if L<SPOPS::Secure|SPOPS::Secure> is in the C<isa>. ! B<no_cache> (bool) If true, the object won't be cached even if the application specifies --- 90,137 ---- field mapping. ! B<default_values> (\%) (optional) + Hashref of field names and default values for the fields when the + object is initialized with C<new()>. + + One problem with setting default values in your object configuration + B<and> in your database is that the two may become unsynchronized, + resulting in many pulled hairs when debugging. + + To get around the synchronization issue, you can set this dynamically + using various methods with + L<SPOPS::ClassFactory|SPOPS::ClassFactory>. (A sample, + C<My::DBI::FindDefaults>, is shipped with SPOPS.) + + B<multivalue> (\@) (optional) + List all fieldnames that can hold multiple values. Currently the only native support for this is in L<SPOPS::LDAP|SPOPS::LDAP>, but you can also use it along with some object rules to fake relationships. ! B<no_insert> (\@) (optional) List of fields not to use when creating a new object in the datastore. ! B<no_update> (\@) (optional) List of fields not to update when saving a previously saved object. ! B<skip_undef> (\@) (optional) You can elect not to include a field that's undefined when saving or updating an object by including it in this list. ! B<creation_security> (\%) (required if you're using security) If you're using security, specify here what security the object will have when it's first created. ! B<no_security> (bool) (optional) If true, the object won't use security even if L<SPOPS::Secure|SPOPS::Secure> is in the C<isa>. ! B<no_cache> (bool) (optional) If true, the object won't be cached even if the application specifies *************** *** 143,147 **** query information to it. ! B<as_string_order> (\@) Ordered list of object fields to use when the C<as_string()> method is --- 157,161 ---- query information to it. ! B<as_string_order> (\@) (optional) Ordered list of object fields to use when the C<as_string()> method is *************** *** 149,158 **** listed in the C<field> configuration key. ! B<as_string_label> (\%) Hashref of object field-to-label mappings used when the C<as_string()> method is called. ! B<has_a> (\%) Metadata for SPOPS to use when building a relationship from one object --- 163,172 ---- listed in the C<field> configuration key. ! B<as_string_label> (\%) (optional) Hashref of object field-to-label mappings used when the C<as_string()> method is called. ! B<has_a> (\%) (optional) Metadata for SPOPS to use when building a relationship from one object *************** *** 164,168 **** more information. ! B<fetch_by> (\@) A list of fields that tell SPOPS you want to create special methods --- 178,182 ---- more information. ! B<fetch_by> (\@) (optional) A list of fields that tell SPOPS you want to create special methods *************** *** 187,191 **** L<SPOPS::DBI|SPOPS::DBI> in it. ! B<base_table> ($) Table name for data to be stored. This may be modified during the --- 201,205 ---- L<SPOPS::DBI|SPOPS::DBI> in it. ! B<base_table> ($) Table name for data to be stored. This may be modified during the *************** *** 194,198 **** C<table_name()> class method. ! B<sql_defaults> (\@) List of fields that have defaults defined in the SQL table. For --- 208,212 ---- C<table_name()> class method. ! B<sql_defaults> (\@) (optional) List of fields that have defaults defined in the SQL table. For *************** *** 205,210 **** object to ensure that the data in the object and the data in the database are synced. ! ! B<field_alter> (\%) Allows you to define different formatting behaviors for retrieving --- 219,223 ---- object to ensure that the data in the object and the data in the database are synced. ! B<field_alter> (\%) (optional) Allows you to define different formatting behaviors for retrieving *************** *** 228,232 **** =head2 General Relationship Fields ! B<links_to> (\%) The 'links_to' field allows you to specify a SPOPS alias and specify --- 241,245 ---- =head2 General Relationship Fields ! B<links_to> (\%) (optional) The 'links_to' field allows you to specify a SPOPS alias and specify |
|
From: Chris W. <la...@us...> - 2001-10-22 05:39:41
|
Update of /cvsroot/openinteract/SPOPS/eg In directory usw-pr-cvs1:/tmp/cvs-serv32285 Modified Files: find_defaults_demo.pl Log Message: added demo for find_results Index: find_defaults_demo.pl =================================================================== RCS file: /cvsroot/openinteract/SPOPS/eg/find_defaults_demo.pl,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** find_defaults_demo.pl 2001/10/22 05:16:14 1.1 --- find_defaults_demo.pl 2001/10/22 05:39:39 1.2 *************** *** 5,11 **** use SPOPS::Initialize; ! my $DBI_DSN = 'DBI:Pg:dbname=grange'; ! my $DBI_USER = 'cwinters'; ! my $DBI_PASS = 'dingbat'; my ( $DBH ); --- 5,11 ---- use SPOPS::Initialize; ! my $DBI_DSN = 'DBI:Pg:dbname=test'; ! my $DBI_USER = 'username'; ! my $DBI_PASS = 'password'; my ( $DBH ); |
|
From: Chris W. <la...@us...> - 2001-10-22 05:39:20
|
Update of /cvsroot/openinteract/SPOPS/eg
In directory usw-pr-cvs1:/tmp/cvs-serv32100
Modified Files:
README
Log Message:
added new find_defaults items
Index: README
===================================================================
RCS file: /cvsroot/openinteract/SPOPS/eg/README,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** README 2001/10/15 04:46:13 1.7
--- README 2001/10/22 05:39:17 1.8
***************
*** 3,11 ****
This directory contains sample SPOPS code and classes you can use for
! users, groups and security, along with a simple class to test them
! out. Plus one class that's useful anywhere.
! For the class that's useful anywhere:
My/DiscoverField.pm
--- 3,11 ----
This directory contains sample SPOPS code and classes you can use for
! users, groups and security, along with sample scripts to test them
! out. Plus two classes that are useful anywhere.
! For the classes that are useful anywhere:
My/DiscoverField.pm
***************
*** 14,17 ****
--- 14,22 ----
do not need to specify fields in your object configuration if
you're using all fields in the table. (Extremely handy!)
+
+ My/DBI/FieldDefaults.pm
+
+ - class that retrieves the information for a particular record to
+ use as defaults.
|
|
From: Chris W. <la...@us...> - 2001-10-22 05:17:01
|
Update of /cvsroot/openinteract/SPOPS/eg/My/DBI
In directory usw-pr-cvs1:/tmp/cvs-serv20755/My/DBI
Added Files:
FindDefaults.pm
Log Message:
added sample SPOPS::ClassFactory behavior to retrieve defaults from a
particular record
--- NEW FILE: FindDefaults.pm ---
package My::DBI::FindDefaults;
# $Id: FindDefaults.pm,v 1.1 2001/10/22 05:16:59 lachoy Exp $
use strict;
use SPOPS qw( DEBUG _w );
use SPOPS::ClassFactory qw( ERROR OK NOTIFY );
sub behavior_factory {
my ( $class ) = @_;
DEBUG() && _w( 1, "Installing default discovery for ($class)" );
return { manipulate_configuration => \&find_defaults };
}
sub find_defaults {
my ( $class ) = @_;
my $CONFIG = $class->CONFIG;
return ( OK, undef ) unless ( $CONFIG->{find_default_id} and
ref $CONFIG->{find_default_field} eq 'ARRAY' and
scalar @{ $CONFIG->{find_default_field} } );
my $dbh = $class->global_datasource_handle( $CONFIG->{datasource} );
unless ( $dbh ) {
return ( NOTIFY, "Cannot find defaults because no DBI database " .
"handle available to class ($class)" );
}
my $default_fields = join( ', ', @{ $CONFIG->{find_default_field} } );
my $id_clause = $class->id_clause( $CONFIG->{find_default_id},
'', { db => $dbh } );
my $sql = qq/
SELECT $default_fields
FROM $CONFIG->{base_table}
WHERE $id_clause /;
my ( $sth );
eval {
$sth = $dbh->prepare( $sql );
$sth->execute;
};
if ( $@ ) {
return ( NOTIFY, "Cannot find defaults because SELECT failed to execute.\n" .
"SQL: $sql\nError: $@\nClass: $class" );
}
my $row = $sth->fetchrow_arrayref;
unless ( ref $row eq 'ARRAY' and scalar @{ $row } ) {
return ( NOTIFY, "No record found for ID $CONFIG->{find_default_id} in " .
"class ($class)" );
}
my $count = 0;
foreach my $field ( @{ $CONFIG->{find_default_field} } ) {
$CONFIG->{default_values}{ $field } = $row->[ $count ];
$count++;
}
return ( OK, undef );
}
1;
__END__
=pod
=head1 NAME
My::DBI::FindDefaults - Load default values from a particular record
=head1 SYNOPSIS
# Load information from record 4 for fields 'language' and 'country'
my $spops = {
class => 'This::Class',
isa => [ 'SPOPS::DBI' ],
field => [ 'email', 'language', 'country' ],
id_field => 'email',
base_table => 'test_table',
rules_from => [ 'My::DBI::FindDefaults' ],
find_default_id => 4,
find_default_fields => [ 'language', 'country' ],
};
=head1 DESCRIPTION
This class allows you to specify default values based on the
information in a particular record in the database. Just specify the
ID of the record and the fields which you want to copy as defaults.
=head1 METHODS
B<behavior_factory()>
Loads the behavior during the
L<SPOPS::ClassFactory|SPOPS::ClassFactory> process.
B<find_defaults()>
Retrieve the defaults from the database.
=head1 BUGS
None known.
=head1 TO DO
Nothing known.
=head1 SEE ALSO
L<SPOPS::ClassFactory|SPOPS::ClassFactory>
POOP Group mailing list thread:
http://www.geocrawler.com/lists/3/SourceForge/3024/0/6867367/
=head1 COPYRIGHT
Copyright (c) 2001 intes.net, inc.. All rights reserved.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=head1 AUTHORS
Chris Winters <ch...@cw...>
=cut
|
|
From: Chris W. <la...@us...> - 2001-10-22 05:16:24
|
Update of /cvsroot/openinteract/SPOPS/eg/My/DBI In directory usw-pr-cvs1:/tmp/cvs-serv20422/My/DBI Log Message: Directory /cvsroot/openinteract/SPOPS/eg/My/DBI added to the repository |
|
From: Chris W. <la...@us...> - 2001-10-22 05:16:16
|
Update of /cvsroot/openinteract/SPOPS/eg
In directory usw-pr-cvs1:/tmp/cvs-serv20348
Added Files:
find_defaults_demo.pl
Log Message:
added demo script for My::DBI::FindDefaults
--- NEW FILE: find_defaults_demo.pl ---
#!/usr/bin/perl
use strict;
use DBI;
use SPOPS::Initialize;
my $DBI_DSN = 'DBI:Pg:dbname=grange';
my $DBI_USER = 'cwinters';
my $DBI_PASS = 'dingbat';
my ( $DBH );
END {
remove_demo_table();
}
{
create_demo_table();
fill_demo_table();
my $config = {
'demo' => {
class => 'My::Demo',
isa => [ 'SPOPS::DBI' ],
base_table => 'spops_find_defaults',
id_field => 'email',
field_discover => 'yes',
rules_from => [ 'My::DiscoverField', 'My::DBI::FindDefaults' ],
find_default_id => 'te...@te...',
find_default_field => [ 'language', 'country' ],
},
};
SPOPS::Initialize->process({ config => $config });
my $demo = My::Demo->new();
print "Default for language: ($demo->{language})\n",
"Default for country: ($demo->{country})\n";
}
sub create_demo_table {
My::Demo::global_datasource_handle();
my $sql = <<DEMO;
CREATE TABLE spops_find_defaults (
email varchar(50) not null primary key,
language char(2) null,
country varchar(20) null
)
DEMO
$DBH->do( $sql );
}
sub fill_demo_table {
my $sql = <<'NEW';
INSERT INTO spops_find_defaults ( email, language, country )
VALUES ( 'te...@te...', 'en', 'USA' )
NEW
$DBH->do( $sql );
}
sub remove_demo_table {
$DBH->do( 'DROP TABLE spops_find_defaults' );
}
sub My::Demo::global_datasource_handle {
return $DBH if ( $DBH );
$DBH = DBI->connect( $DBI_DSN, $DBI_USER, $DBI_PASS,
{ RaiseError => 1, PrintError => 0 } );
die "Cannot connect! $DBI::errstr" unless ( $DBH );
return $DBH;
}
|
|
From: Chris W. <la...@us...> - 2001-10-22 02:00:32
|
Update of /cvsroot/openinteract/OpenInteract/pkg/base_page/OpenInteract/Handler
In directory usw-pr-cvs1:/tmp/cvs-serv1489/OpenInteract/Handler
Modified Files:
Page.pm
Log Message:
comments...
Index: Page.pm
===================================================================
RCS file: /cvsroot/openinteract/OpenInteract/pkg/base_page/OpenInteract/Handler/Page.pm,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** Page.pm 2001/10/20 15:12:15 1.1
--- Page.pm 2001/10/22 02:00:29 1.2
***************
*** 120,124 ****
--- 120,132 ----
status_msg => $p->{status_msg} };
+ # Get the actual location requested -- this can be passed in
+ # directly, specified in a parameter or taken from the URL.
+
my $location = $class->_clean_location( $class->_find_location( $p ) );
+
+ # Try and find a page object (just the metadata) matching with our
+ # location. Note that _find_page_object() will also treat
+ # $location as a directory request, where appropriate
+
my $page = eval { $p->{page} || $class->_find_page_object( $location ) };
my $error_type = $@;
|
|
From: Chris W. <la...@us...> - 2001-10-20 15:17:46
|
Update of /cvsroot/openinteract/OpenInteract/OpenInteract
In directory usw-pr-cvs1:/tmp/cvs-serv13658/OpenInteract
Modified Files:
SPOPS.pm
Log Message:
remove html_* methods; cosmetic
Index: SPOPS.pm
===================================================================
RCS file: /cvsroot/openinteract/OpenInteract/OpenInteract/SPOPS.pm,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** SPOPS.pm 2001/10/17 04:47:07 1.14
--- SPOPS.pm 2001/10/20 15:17:44 1.15
***************
*** 31,35 ****
# Don't create an object key if we're explicitly told not to
! return 1 if ( $self->CONFIG->{skip_object_key} );
$p ||= {};
--- 31,35 ----
# Don't create an object key if we're explicitly told not to
! return 1 if ( $self->CONFIG->{skip_object_key} || $p->{skip_object_key} );
$p ||= {};
***************
*** 66,70 ****
my ( $self, $p ) = @_;
$p ||= {};
! my $row = $self->db_select({ %{ $p },
from => OBJECT_KEY_TABLE,
select => [ 'object_key' ],
--- 66,70 ----
my ( $self, $p ) = @_;
$p ||= {};
! my $row = $self->db_select({ %{ $p },
from => OBJECT_KEY_TABLE,
select => [ 'object_key' ],
***************
*** 84,88 ****
$p->{db} ||= $class->global_db_handle;
die "Cannot retrieve object info without key!" unless ( $key );
! my $row = SPOPS::SQLInterface->db_select({ %{ $p },
from => OBJECT_KEY_TABLE,
select => [ 'class', 'object_id' ],
--- 84,88 ----
$p->{db} ||= $class->global_db_handle;
die "Cannot retrieve object info without key!" unless ( $key );
! my $row = SPOPS::SQLInterface->db_select({ %{ $p },
from => OBJECT_KEY_TABLE,
select => [ 'class', 'object_id' ],
***************
*** 114,123 ****
sub log_action {
my ( $self, $action, $id ) = @_;
! return 1 unless ( $self->CONFIG->{track}->{ $action } );
return $self->log_action_enter( $action, $id );
}
! # Log the object, the action (create, update, remove), who did
# the action and when it was done.
#
--- 114,123 ----
sub log_action {
my ( $self, $action, $id ) = @_;
! return 1 unless ( $self->CONFIG->{track}{ $action } );
return $self->log_action_enter( $action, $id );
}
! # Log the object, the action (create, update, remove), who did
# the action and when it was done.
#
***************
*** 127,142 ****
my ( $self, $action, $id, $uid ) = @_;
my $R = OpenInteract::Request->instance;
! $uid ||= ( ref $R->{auth}->{user} ) ? $R->{auth}->{user}->{user_id} : 0;
my $now = SPOPS::Utility->now;
my $class = ref $self || $self;
my $log_msg = $R->apache->param( '_log_message' );
$R->DEBUG && $R->scrib( 1, "Entering action $action to $class ($id) by $uid on $now" );
! eval { $self->db_insert({ db => $R->db,
! table => 'object_track',
field => [ qw/ class object_id action action_by action_on notes / ],
value => [ $class, $id, $action, $uid, $now, $log_msg ] } ); };
if ( $@ ) {
$R->scrib( 0, "Log entry failed: $SPOPS::Error::system_msg" );
! OpenInteract::Error->set( SPOPS::Error->get );
$OpenInteract::Error::user_msg = "Cannot log object action: $action";
$OpenInteract::Error::notes = "Object: $class ($id) by $uid on $now";
--- 127,142 ----
my ( $self, $action, $id, $uid ) = @_;
my $R = OpenInteract::Request->instance;
! $uid ||= ( ref $R->{auth}{user} ) ? $R->{auth}{user}{user_id} : 0;
my $now = SPOPS::Utility->now;
my $class = ref $self || $self;
my $log_msg = $R->apache->param( '_log_message' );
$R->DEBUG && $R->scrib( 1, "Entering action $action to $class ($id) by $uid on $now" );
! eval { $self->db_insert({ db => $R->db,
! table => 'object_track',
field => [ qw/ class object_id action action_by action_on notes / ],
value => [ $class, $id, $action, $uid, $now, $log_msg ] } ); };
if ( $@ ) {
$R->scrib( 0, "Log entry failed: $SPOPS::Error::system_msg" );
! OpenInteract::Error->set( SPOPS::Error->get );
$OpenInteract::Error::user_msg = "Cannot log object action: $action";
$OpenInteract::Error::notes = "Object: $class ($id) by $uid on $now";
***************
*** 157,162 ****
return undef unless ( ref $self and $self->id );
my $R = OpenInteract::Request->instance;
! my $data = eval { $self->db_select({
! db => $R->db,
select => [ 'action_by' ],
from => [ 'object_track' ],
--- 157,162 ----
return undef unless ( ref $self and $self->id );
my $R = OpenInteract::Request->instance;
! my $data = eval { $self->db_select({
! db => $R->db,
select => [ 'action_by' ],
from => [ 'object_track' ],
***************
*** 166,170 ****
if ( $@ ) {
$OpenInteract::Error::user_msg = 'Cannot retrieve object creator(s)';
! $OpenInteract::Error::extra = { class => ref $self,
object_id => $self->id };
$R->throw( { code => 306 } );
--- 166,170 ----
if ( $@ ) {
$OpenInteract::Error::user_msg = 'Cannot retrieve object creator(s)';
! $OpenInteract::Error::extra = { class => ref $self,
object_id => $self->id };
$R->throw( { code => 306 } );
***************
*** 182,191 ****
my ( $self, $uid ) = @_;
my $R = OpenInteract::Request->instance;
! $uid ||= $R->{auth}->{user}->{user_id};
return undef unless ( $uid );
# the great and powerful superuser sees all
! return 1 if ( $uid eq $R->CONFIG->{default_objects}->{superuser} );
my $creator_list = eval { $self->fetch_creator } || [];
--- 182,191 ----
my ( $self, $uid ) = @_;
my $R = OpenInteract::Request->instance;
! $uid ||= $R->{auth}{user}{user_id};
return undef unless ( $uid );
# the great and powerful superuser sees all
! return 1 if ( $uid eq $R->CONFIG->{default_objects}{superuser} );
my $creator_list = eval { $self->fetch_creator } || [];
***************
*** 197,202 ****
! # Retrieve an arrayref of arrayrefs where item 0 is the uid
! # of the user who last did the update and item 1 is the
# date of the update
--- 197,202 ----
! # Retrieve an arrayref of arrayrefs where item 0 is the uid
! # of the user who last did the update and item 1 is the
# date of the update
***************
*** 218,222 ****
if ( $@ ) {
$OpenInteract::Error::user_msg = 'Cannot retrieve object updates';
! $OpenInteract::Error::extra = { class => ref $self,
object_id => $self->id };
$R->throw( { code => 306 } );
--- 218,222 ----
if ( $@ ) {
$OpenInteract::Error::user_msg = 'Cannot retrieve object updates';
! $OpenInteract::Error::extra = { class => ref $self,
object_id => $self->id };
$R->throw( { code => 306 } );
***************
*** 259,286 ****
sub global_user_class { return OpenInteract::Request->user }
sub global_group_class { return OpenInteract::Request->group }
! sub global_user_current { return OpenInteract::Request->instance->{auth}->{user} }
! sub global_group_current { return OpenInteract::Request->instance->{auth}->{group} }
!
!
! ########################################
! # HTML ENCODE/DECODE (keep?)
! ########################################
!
! # Use this to translate from
! # <font size="-1"...
! # to
! # <font size="-1"...
! # Params: 0: class; 1: text
!
! sub html_encode { return HTML::Entities::encode( $_[1] ); }
!
!
! # Use this to translate from
! # <font size="-1"...
! # to
! # <font size="-1"...
! # Params: 0: class; 1: text
!
! sub html_decode { return HTML::Entities::decode( $_[1] ); }
--- 259,264 ----
sub global_user_class { return OpenInteract::Request->user }
sub global_group_class { return OpenInteract::Request->group }
! sub global_user_current { return OpenInteract::Request->instance->{auth}{user} }
! sub global_group_current { return OpenInteract::Request->instance->{auth}{group} }
***************
*** 297,306 ****
$p->{object} ||= [];
! # If we weren't given any objects and we were called by
# a class instead of an object
return undef unless ( ref $item or scalar @{ $p->{object} } );
! # If we were just called by an object, make it our message
push @{ $p->{object} }, $item unless ( scalar @{ $p->{object} } );
--- 275,284 ----
$p->{object} ||= [];
! # If we weren't given any objects and we were called by
# a class instead of an object
return undef unless ( ref $item or scalar @{ $p->{object} } );
! # If we were just called by an object, make it our message
push @{ $p->{object} }, $item unless ( scalar @{ $p->{object} } );
***************
*** 317,321 ****
"\n$separator\nEnd $p->{type} object\n\n\n";
}
! eval { OpenInteract::Utility->send_email({
to => $p->{email},
from => $R->CONFIG->{mail}{admin_email} || $R->CONFIG->{admin_email},
--- 295,299 ----
"\n$separator\nEnd $p->{type} object\n\n\n";
}
! eval { OpenInteract::Utility->send_email({
to => $p->{email},
from => $R->CONFIG->{mail}{admin_email} || $R->CONFIG->{admin_email},
***************
*** 392,396 ****
Makes an entry into the 'object_track' table, which logs all object
creations, updates and deletions. We do not note the content that
! changes, but we do note who did the action and when it was done.
Parameters:
--- 370,374 ----
Makes an entry into the 'object_track' table, which logs all object
creations, updates and deletions. We do not note the content that
! changes, but we do note who did the action and when it was done.
Parameters:
***************
*** 496,538 ****
information in your class configuration which specifies the fields you
want to use in the listing along with associated labels.
-
- B<html_encode( $text )>
-
- Parameters:
-
- =over 4
-
- =item *
-
- B<text> ($)
-
- Text to encode.
-
- =back
-
- B<Returns>: escaped version of $text (e.g., the character '"' will be
- replaced by ")
-
- B<html_decode( $text )>
-
- Parameters:
-
- =over 4
-
- =item *
-
- B<text> ($)
-
- Text to decode.
-
- =back
-
- Returns: unescaped version of $text (e.g., the entity " will be
- replaced by the character '"')
-
- It may seem silly to have these html_ methods which currently just
- call the method of an external module, but we might wish to do more in
- the future (for example, screen out javascript>. This way, we have a
- central place to change it.
=head1 TO DO
--- 474,477 ----
|
|
From: Chris W. <la...@us...> - 2001-10-20 15:17:03
|
Update of /cvsroot/openinteract/OpenInteract/OpenInteract
In directory usw-pr-cvs1:/tmp/cvs-serv13535/OpenInteract
Modified Files:
CommonHandler.pm
Log Message:
pass options from _edit_customize to save()
Index: CommonHandler.pm
===================================================================
RCS file: /cvsroot/openinteract/OpenInteract/OpenInteract/CommonHandler.pm,v
retrieving revision 1.24
retrieving revision 1.25
diff -C2 -d -r1.24 -r1.25
*** CommonHandler.pm 2001/10/14 20:56:30 1.24
--- CommonHandler.pm 2001/10/20 15:17:00 1.25
***************
*** 469,473 ****
my %show_params = ();
! eval { $object->save };
if ( $@ ) {
my $ei = OpenInteract::Error->set( SPOPS::Error->get );
--- 469,473 ----
my %show_params = ();
! eval { $object->save( $opts ) };
if ( $@ ) {
my $ei = OpenInteract::Error->set( SPOPS::Error->get );
|
|
From: Chris W. <la...@us...> - 2001-10-20 15:16:20
|
Update of /cvsroot/openinteract/OpenInteract
In directory usw-pr-cvs1:/tmp/cvs-serv13449
Modified Files:
Changes
Log Message:
latest changes
Index: Changes
===================================================================
RCS file: /cvsroot/openinteract/OpenInteract/Changes,v
retrieving revision 1.72
retrieving revision 1.73
diff -C2 -d -r1.72 -r1.73
*** Changes 2001/10/18 13:49:41 1.72
--- Changes 2001/10/20 15:16:18 1.73
***************
*** 63,66 ****
--- 63,72 ----
add/clarify some docs.
+ * OpenInteract/SPOPS.pm:
+
+ - Remove the html_encode and html_decode methods; they're in the
+ template plugin, and if you really need them elsewhere you can call
+ the HTML::Entities methods by hand.
+
* OpenInteract/Template/Plugin.pm:
|
|
From: Chris W. <la...@us...> - 2001-10-20 15:14:33
|
Update of /cvsroot/openinteract/OpenInteract/pkg/base_page/template
In directory usw-pr-cvs1:/tmp/cvs-serv13214/template
Modified Files:
edit_document_box.tmpl
Added Files:
page_directory_list.meta page_directory_list.tmpl
page_form.meta page_form.tmpl page_search_form.meta
page_search_form.tmpl
Log Message:
updated all templates
--- NEW FILE: page_directory_list.meta ---
name: page_directory_list
title: Listing of pages by directory
package: base_page
Lists the static pages by directory, with one of the directories
optionally being picked and expanded
--- NEW FILE: page_directory_list.tmpl ---
[%########################################
page_directory_list( selected_dir, dir_list, children_files )
List directories in the system, with optionally one directory
selected so that all files in it are listed.
Parameters:
selected_dir: should be set to the name of the directory selected
dir_list: should be an arrayref of arrayrefs, the first element
is the directory name, the second the number of files
in the directory.
children_files: SPOPS::Iterator object containing BasicPage objects.
These are objects in the 'selected_dir'.
########################################%]
[%########################################
MACROS
########################################-%]
[%- MACRO create_expand_choice BLOCK -%]
[%- SET is_chosen = ( dir_info.0 == selected_dir ) ? 1 : 0 -%]
[%- SET is_last = ( dir_info.0 == last_dir ) ? 1 : 0 -%]
[%- IF is_chosen -%]
[%- ( is_last ) ? '/images/file_minus_collapse_last.gif'
: '/images/file_minus_collapse.gif' -%]
[%- ELSE -%]
[%- ( is_last ) ? '/images/file_plus_expand_last.gif'
: '/images/file_plus_expand.gif' -%]
[%- END -%]
[%- END -%]
[% MACRO show_files_in_directory BLOCK -%]
[%- WHILE ( page = children_files.get_next ) -%]
[%- edit_url = OI.make_url( base = '/BasePage/show/', edit = 1,
location = page.location ) -%]
<tr bgcolor="[% PROCESS row_color %]">
<td align="right"><img src="/images/file_tree_line.gif"
height="16" width="19"></td>
<td> </td>
<td><font size="-1">
<a href="[% edit_url %]">[% page.location %]</a>
</font></td>
<td><font size="-1">[% page.title %]</font></td>
</tr>
[% END -%]
[% END -%]
[%########################################
DISPLAY START
########################################-%]
[%- DEFAULT theme = OI.theme_properties -%]
[%- PROCESS error_message -%]
<h2 align="left">Document Manager</h2>
<p align="left">Listing of all document directories. in the
system. Click on the '+' to expand a directory and see its files.</p>
<div align="center">
[% INCLUDE table_bordered_begin( table_width = '90%' ) -%]
[%- last_dir_index = dir_list.max;
last_dir = dir_list.$last_dir_index.0 -%]
[% FOREACH dir_info = dir_list -%]
[%- expand_choice = create_expand_choice();
dir_url = OI.make_url( base = '/BasePage/listing/',
selected_dir = dir_info.0 -%]
<tr bgcolor="[% PROCESS row_color( count = loop.count ) %]">
<td align="right">
<a href="[% dir_url %]"><img src="[% expand_choice %]"
height="16" width="19" border="0"></a></td>
<td colspan="2"><font size="-1">[% dir_info.0 %]</font></td>
<td><font size="-1">([% dir_info.1 %] files)</font></td>
</tr>
[%- IF is_chosen -%]
[%- show_files_in_directory( count = loop.count ) -%]
[% END -%]
[%- END -%]
[% PROCESS table_bordered_end -%]
</div>
--- NEW FILE: page_form.meta ---
name: page_form
title: Form for basic page input
package: base_page
All the information needed for a basic page; this should take the
place of static pages and enable the entire website to be editable via
the browser. Also allows file upload of content.
--- NEW FILE: page_form.tmpl ---
[%- DEFAULT theme = OI.theme_properties;
count = 0 -%]
[%- OI.box_add( 'edit_document_box', location = page.location );
[%- PROCESS error_message -%]
[%- PROCESS static_message -%]
<div align="center">
<h2>Web Page Editor</h2>
<p>Edit the page corresponding to <tt>Location</tt> below. Changes are
made instantly.</p>
<form name="page" method="POST"
action="/Page/edit/">
[% INCLUDE table_bordered_begin( table_width = '90%' ) -%]
[%- display_type = ( page.location )
? 'Edit a' : 'Create a New' -%]
[% INCLUDE label_row( color = theme.head_bgcolor,
label = "$display_type Document" ) -%]
[%- count = count + 1 -%]
[%- location_plabel = '<br><font size="-1">(must be unique)</font>' -%]
[% INCLUDE label_form_text_row( label = 'Location', is_required = 1,
required_display = theme.required,
post_label = location_plabel,
name = 'location', value = page.location,
size = 30, maxlength = 100 ) -%]
[%- count = count + 1 -%]
[% INCLUDE label_form_text_row( label = 'Title',
name = 'title', value = page.title,
size = 30, maxlength = 150 ) -%]
[%- count = count + 1 -%]
[% INCLUDE label_form_text_row( label = 'Author',
name = 'author', value = page.author,
size = 30, maxlength = 200 ) -%]
[%- count = count + 1 -%]
[% INCLUDE label_form_text_row( label = 'Keywords',
name = 'keywords', value = page.keywords,
size = 30, maxlength = 75 ) -%]
[%- count = count + 1 -%]
[%- box_plabel = '<font size="-1"><em>Separate each box by whitespace; order is not important</em></font>' -%]
[% INCLUDE label_form_text_row( label = 'Boxes', post_label = box_plabel,
name = 'boxes', value = page.boxes,
size = 30, maxlength = 75 ) -%]
[%- count = count + 1 -%]
[%- template_plabel = '<font size="-1"><em>main template to use; blank uses the default</em></font>' -%]
[% INCLUDE label_form_text_row( label = 'Main Template', post_label = template.plabel,
name = 'main_template', value = page.main_template,
size = 30, maxlength = 40 ) -%]
[%- count = count + 1 -%]
[% INCLUDE label_form_textarea_row( label = 'Document', name = 'content',
value = OI.html_encode( page.content ),
cols = 70, rows = 18,
colspan = 2, wrap = 'virtual' ) -%]
[%- count = count + 1 -%]
[% INCLUDE label_form_date_row( label = 'Active On Date', name = 'active_on',
value = page.active_on ) -%]
[%- count = count + 1 -%]
[% INCLUDE label_form_date_row( label = 'Expires On Date', name = 'expires_on',
value = page.expires_on ) -%]
[%- count = count + 1 -%]
[% INCLUDE label_form_checkbox_row( label = 'Active?', name = 'is_active',
value = 'yes', picked = page.is_active ) -%]
[%- count = count + 1 -%]
[% INCLUDE label_row_begin( label = 'Updates' ) -%]
<td>[%- PROCESS object_updates -%]</td>
</tr>
[%- count = count + 1 -%]
[% INCLUDE label_form_submit_row( value = 'Modify' ) -%]
[% PROCESS table_bordered_end -%]
[%- form_hidden( name = 'old_location', value = page.location ) -%]
</form>
</div>
--- NEW FILE: page_search_form.meta ---
name: page_search_form
title: Search for pages (not full-text)
package: base_page
Search form to find pages
--- NEW FILE: page_search_form.tmpl ---
[%- DEFAULT theme = OI.theme_properties;
SET count = 0;
OI.box_add( 'classified_tools_box' ); -%]
[%- PROCESS error_message -%]
[%- PROCESS status_message -%]
<div align="center">
<h2>Search Pages</h2>
<p align="left">Enter criteria below to search pages on the
system. The more criteria you enter, the more restrictive your search
and the fewer results you will retrieve.</p>
<form name="page_search" method="GET" action="/Page/search/">
[% INCLUDE table_bordered_begin( table_width = '75%' ) -%]
[%- count = count + 1 -%]
[% INCLUDE label_form_text_row( label = 'Title', name = 'title' ) -%]
[%- count = count + 1 -%]
[% INCLUDE label_form_text_row( label = 'Author', name = 'author' ) -%]
[%- count = count + 1 -%]
[% INCLUDE label_form_text_row( label = 'Keywords', name = 'keyword' ) -%]
[%- count = count + 1 -%]
[% INCLUDE label_form_select_row( label = 'Using Template', first_label = 'Templates...',
name = 'main_template', plain = 1,
value_list = template_list ) -%]
[%- count = count + 1 -%]
[% INCLUDE label_form_checkbox_row( label = 'Active?', name = 'is_active',
value = 'yes', picked = 'yes' ) -%]
[%- count = count + 1 -%]
[% INCLUDE form_submit_row( value = 'Search' ) -%]
[% INCLUDE table_bordered_end() -%]
</form>
</div>
Index: edit_document_box.tmpl
===================================================================
RCS file: /cvsroot/openinteract/OpenInteract/pkg/base_page/template/edit_document_box.tmpl,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** edit_document_box.tmpl 2001/10/17 12:11:26 1.1
--- edit_document_box.tmpl 2001/10/20 15:14:30 1.2
***************
*** 6,10 ****
location = location ); -%]
<font size="-1"">
! [% theme.bullet %] <a href="[% new_url %]">Create a new document</a>
These actions apply to the document currently onscreen<br>
[% theme.bullet %] <a href="[% edit_url %]">Edit this document</a><br>
--- 6,10 ----
location = location ); -%]
<font size="-1"">
! [% theme.bullet %] <a href="[% new_url %]">Create a new document</a><br>
These actions apply to the document currently onscreen<br>
[% theme.bullet %] <a href="[% edit_url %]">Edit this document</a><br>
|
|
From: Chris W. <la...@us...> - 2001-10-20 15:14:13
|
Update of /cvsroot/openinteract/OpenInteract/pkg/base_page/struct In directory usw-pr-cvs1:/tmp/cvs-serv13160/struct Added Files: page.sql page_content.sql Log Message: updated structures -- 'page' is now just the metadata for a particular document; page_content is used if you want to store them in the DB --- NEW FILE: page.sql --- CREATE TABLE page ( location varchar(150) not null, directory varchar(150) null, title varchar(250) null, author varchar(200) null, keywords varchar(75) null, boxes varchar(75) null, main_template varchar(40) null, active_on datetime null, expires_on datetime null, is_active char(3) default 'no', is_file char(3) default 'no', mime_type varchar(30) null, notes text null, primary key ( location ) ) --- NEW FILE: page_content.sql --- CREATE TABLE page_content ( location varchar(150) not null, content text null, primary key ( location ) ) |
|
From: Chris W. <la...@us...> - 2001-10-20 15:13:19
|
Update of /cvsroot/openinteract/OpenInteract/pkg/base_page/data
In directory usw-pr-cvs1:/tmp/cvs-serv13053/data
Added Files:
install_security.dat
Log Message:
updated security
--- NEW FILE: install_security.dat ---
$security = [
{ spops_class => 'OpenInteract::Security',
field_order => [ qw/ class object_id scope scope_id security_level / ],
transform_default_to_id => [ 'scope_id' ],
transform_class_to_website => [ 'class' ] },
[ 'OpenInteract::Handler::Page', 0, 'w', 'world', 4 ],
[ 'OpenInteract::Handler::Page', 0, 'g', 'site_admin_group', 8 ],
[ 'OpenInteract::Page', 'ROOT_OBJECT', 'w', 'world', 4 ],
[ 'OpenInteract::Page', 'ROOT_OBJECT', 'g', 'site_admin_group', 8 ],
];
|
|
From: Chris W. <la...@us...> - 2001-10-20 15:12:55
|
Update of /cvsroot/openinteract/OpenInteract/pkg/base_page/conf
In directory usw-pr-cvs1:/tmp/cvs-serv12970/conf
Modified Files:
action.perl spops.perl
Log Message:
updated config
Index: action.perl
===================================================================
RCS file: /cvsroot/openinteract/OpenInteract/pkg/base_page/conf/action.perl,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** action.perl 2001/10/17 12:10:51 1.1
--- action.perl 2001/10/20 15:12:52 1.2
***************
*** 1,28 ****
$action = {
! 'basepage' => {
'class' => 'OpenInteract::Handler::BasePage',
'security' => 'yes',
!
! # The next three items are used in the new version of
! # the handler
!
! # What should we try on directory requests or when we
! # don't find an object?
!
! 'object_home_name' => 'home',
!
! # What should we try on directory requests or when we
! # don't find a file?
!
! 'filesystem_home_name' => 'index.html',
!
! # Storage preference. Choices are:
! # 'object', 'filesystem', 'both-object', 'both-filesystem'
! #
! # The entry with the 'both' items is what we should
! # try first -- try fetching the object first with 'both-object'
! # and the filesystem file first with 'both-filesystem'.
!
! 'storage' => 'both-object',
},
--- 1,7 ----
$action = {
! 'page' => {
'class' => 'OpenInteract::Handler::BasePage',
'security' => 'yes',
! 'directory_index' => [ 'index.html', 'home.html', 'index', 'home' ],
},
***************
*** 31,36 ****
'weight' => 4,
'title' => 'Document Info',
! 'template' => 'edit_document_box',
! 'package' => 'static_page',
'security' => 'no',
},
--- 10,14 ----
'weight' => 4,
'title' => 'Document Info',
! 'template' => 'static_page::edit_document_box',
'security' => 'no',
},
Index: spops.perl
===================================================================
RCS file: /cvsroot/openinteract/OpenInteract/pkg/base_page/conf/spops.perl,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** spops.perl 2001/10/17 12:10:51 1.1
--- spops.perl 2001/10/20 15:12:52 1.2
***************
*** 1,12 ****
$spops = {
! 'basicpage' => {
! class => 'OpenInteract::BasicPage',
! code_class => 'OpenInteract::BasicPage',
isa => [ qw/ OpenInteract::SPOPS::DBI
SPOPS::Secure::Hierarchy
SPOPS::Utility SPOPS::DBI / ],
field => [ qw/ location directory title author keywords
! active_on expires_on boxes main_template
! is_file / ],
column_group => {},
id_field => 'location',
--- 1,12 ----
$spops = {
! 'page' => {
! class => 'OpenInteract::Page',
! code_class => [ 'OpenInteract::Page' ],
isa => [ qw/ OpenInteract::SPOPS::DBI
SPOPS::Secure::Hierarchy
SPOPS::Utility SPOPS::DBI / ],
field => [ qw/ location directory title author keywords
! boxes main_template mime_type
! active_on expires_on is_active is_file / ],
column_group => {},
id_field => 'location',
***************
*** 14,28 ****
skip_undef => [],
no_update => [],
! base_table => 'basic_page',
sql_defaults => [],
! alias => [ 'static_page' ],
has_a => {},
links_to => {},
track => { create => 1, update => 1, remove => 1 },
! display => { url => '/BasicPage/show/' },
name => 'title',
object_name => 'Document',
! storage => 'filesystem',
! db_table => 'basic_page_content',
hierarchy_separator => '/',
hierarchy_field => 'location',
--- 14,28 ----
skip_undef => [],
no_update => [],
! base_table => 'page',
sql_defaults => [],
! alias => [ 'static_page', 'basicpage' ],
has_a => {},
links_to => {},
track => { create => 1, update => 1, remove => 1 },
! display => { url => '/Page/show/' },
name => 'title',
object_name => 'Document',
! default_storage => 'file',
! content_table => 'page_content',
hierarchy_separator => '/',
hierarchy_field => 'location',
|
|
From: Chris W. <la...@us...> - 2001-10-20 15:12:36
|
Update of /cvsroot/openinteract/OpenInteract/pkg/base_page/OpenInteract/Page
In directory usw-pr-cvs1:/tmp/cvs-serv12923/OpenInteract/Page
Added Files:
Database.pm File.pm
Log Message:
implementation for content retrieval (and saving?)
--- NEW FILE: Database.pm ---
package OpenInteract::Page::Database;
# Read in the page content from a separate table/object
sub _load {
my ( $self ) = @_;
my $page_content = $self->page_content;
$self->{pagetext} = $page_content->{pagetext};
$self->{script} = $page-content->{script};
}
sub _save {
}
sub _remove {
}
1;
--- NEW FILE: File.pm ---
package OpenInteract::Page::File;
# $Id: File.pm,v 1.1 2001/10/20 15:12:34 lachoy Exp $
use strict;
# Read in the content from a file
sub load_content {
my ( $self ) = @_;
my $R = OpenInteract::Request->instance;
my $html_dir = $R->CONFIG->get_dir( 'html' );
$html_dir =~ s|/$||;
my $full_location = join( '', $html_dir, $self->{location} );
next unless ( -f $full_location );
$R->DEBUG && $R->scrib( 1, "Filesystem location ($full_location) ",
"exists. Trying to read file." );
open( STATIC, $full_location ) || die "Cannot access file: no access";
local $/ = undef;
$self->{pagetext} = <STATIC>;
# Pull out the title, main template, author, extra boxes (if they
# exist)
if ( $self->{pagetext} =~ s|<title>(.*)?</title>|| ) {
$self->{title} ||= $1;
}
if ( $self->{pagetext} =~ s|<template>(.*)?</template>|| ) {
$self->{main_template} ||= $1;
}
if ( $self->{pagetext} =~ s|<author>(.*)?</author>|| ) {
$self->{author} ||= $1;
}
if ( $self->{pagetext} =~ s|<boxes>(.*)?</boxes>|| ) {
$self->{boxes} ||= $1;
}
# Only use the information between the $BODY_DEMARCATION tags (if
# they exist)
$self->{pagetext} =~ s/$BODY_DEMARCATION(.*)?$BODY_DEMARCATION/$1/;
# If the page still has <body> tags, only use the information
# between them
$self->{pagetext} =~ s|<body>(.*)?</body>|$1|i;
}
sub _save {
}
sub _remove {
}
1;
|
|
From: Chris W. <la...@us...> - 2001-10-20 15:12:18
|
Update of /cvsroot/openinteract/OpenInteract/pkg/base_page/OpenInteract/Handler
In directory usw-pr-cvs1:/tmp/cvs-serv12876/OpenInteract/Handler
Added Files:
Page.pm
Log Message:
beginning of rewritten static_page handler (DOES NOT WORK YET)
--- NEW FILE: Page.pm ---
package OpenInteract::Handler::Page;
# $Id: Page.pm,v 1.1 2001/10/20 15:12:15 lachoy Exp $
use strict;
use Class::Date ();
use OpenInteract::CommonHandler qw( OK ERROR );
use OpenInteract::Handler::GenericDispatcher qw( DEFAULT_SECURITY_KEY );
use SPOPS::Secure qw( :level );
@OpenInteract::Handler::BasePage::ISA = qw( OpenInteract::CommonHandler SPOPS::Secure );
$OpenInteract::Handler::BasePage::VERSION = sprintf("%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/);
$OpenInteract::Handler::BasePage::author = 'ch...@cw...';
$OpenInteract::Handler::BasePage::default_method = 'show';
@OpenInteract::Handler::BasePage::forbidden_methods = ();
%OpenInteract::Handler::BasePage::security = (
DEFAULT_SECURITY_KEY() => SEC_LEVEL_WRITE,
show => SEC_LEVEL_NONE, notify => SEC_LEVEL_READ,
);
use constant MAIN_SCRIPT => '/Page';
# Use this to signal that we shouldn't send the content through TT --
# this is useful for documentation :-)
use constant NO_PARSE_STATUS => 'no_parse';
# 52 weeks -- default expiration for page
use constant DEFAULT_EXPIRE => 60 * 60 * 24 * 7 * 52;
# Use this to mark the beginning and end of the "good" content in a
# page in the filesystem; this allows you to use an HTML editor to
# create the content and to save a full html page to the filesystem
my $BODY_DEMARCATION = '<!-- OI BODY -->';
# Use this to check whether the file retrieved is displayable in the
# browser; others (pdf, ps, mov, etc.) get sent to the user directly
my %DISPLAY_TYPES = map { $_ => 1 } ( 'text/html', 'text/plain', 'text/xml' );
# Use this to separate your single document into multiple pages
my $PAGE_SEPARATOR = '<!--PAGE-->';
sub MY_PACKAGE { return 'base_page' }
sub MY_HANDLER_PATH { return '/Page' }
sub MY_OBJECT_TYPE { return 'page' }
sub MY_OBJECT_CLASS { return OpenInteract::Request->instance->page }
sub MY_SEARCH_FIELDS { return () }
sub MY_OBJECT_FORM_TITLE { return 'Edit Page' }
sub MY_OBJECT_FORM_TEMPLATE { return '' }
sub MY_EDIT_RETURN_URL { return '/' }
sub MY_EDIT_DISPLAY_TASK { return 'show' }
sub MY_EDIT_FIELDS { return qw( location title author keywords
boxes main_template notes ) }
sub MY_EDIT_FIELDS_TOGGLED { return qw( is_active is_file ) }
sub MY_EDIT_FIELDS_DATE { return qw( active_on expires_on ) }
sub MY_ALLOW_SEARCH_FORM { return 1 }
sub MY_ALLOW_SEARCH { return 1 }
sub MY_ALLOW_EDIT { return 1 }
sub MY_ALLOW_REMOVE { return 1 }
sub MY_ALLOW_WIZARD { return undef }
# Overrides entry in OpenInteract::Handler::GenericDispatcher
sub _get_task {
my ( $class ) = @_;
my $R = OpenInteract::Request->instance;
return 'show' if ( $R->{path}{full}->[0] ne 'Page' );
return lc shift @{ $R->{path}{current} } ||
$OpenInteract::Handler::Page::default_method;
}
# Retrieve all directories, expanding the one we were asked to (if at
# all). Note that these are just the objects in the database, although
# hopefully there's one of these corresponding to every file in the
# filesystem.
sub listing {
my ( $class, $p ) = @_;
my $R = OpenInteract::Request->instance;
my $selected_dir = $R->apache->param( 'selected_dir' );
my $params = { selected_dir => $selected_dir,
error_msg => $p->{error_msg} };
$params->{dir_list} = eval { $R->page->list_directories };
if ( $@ ) {
OpenIntereact::Error->set( SPOPS::Error->get );
$R->throw({ code => 403 });
$params->{dir_list} = [];
}
# Store the pages found using the directory as a key pointing to a
# listref of files it contains
if ( $selected_dir ) {
$params->{children_files} = $R->static_page->fetch_iterator({
where => 'directory = ?',
value => [ $selected_dir ] });
}
$R->{page}{title} = 'Listing of Documents';
return $R->template->handler( {}, $params,
{ name => 'page::page_directory_list' } );
}
sub show {
my ( $class, $p ) = @_;
my $R = OpenInteract::Request->instance;
my $params = { main_script => MAIN_SCRIPT,
error_msg => $p->{error_msg},
status_msg => $p->{status_msg} };
my $location = $class->_clean_location( $class->_find_location( $p ) );
my $page = eval { $p->{page} || $class->_find_page_object( $location ) };
my $error_type = $@;
my $do_edit = ( $R->apache->param( 'edit' ) and
$p->{level} >= SEC_LEVEL_WRITE );
unless ( $page or $do_edit ) {
$R->DEBUG && $R->scrib( 1, "",
"Error type: ($error_type)" );
# We have to force the content-type here because the user
# might have requested a file that actually exists in the
# filesystem and which Apache has already mapped a
# content-type. You'll know when this happens because you'll
# be prompted to d/l the file or a plugin (like Acrobat
# Reader) will try to display it, but the *actual* content
# will be plain old HTML...
$R->{page}{content_type} = 'text/html';
if ( $error_type =~ /^security/ ) {
my $admin_email = $R->CONFIG->{mail}{admin_email};
return <<FORBID;
<h2>Access Forbidden</h2>
<p>You do not have access rights to view this page. Please e-mail the
administrator at <a href="mailto:$admin_email">$admin_email</a> if you
feel you have received this message in error.</p>
FORBID
}
elsif ( $error_type =~ /^access/ ) {
return "<h2>Cannot Access</h2><p>Failure accessing page.</p>";
}
return <<NOTFOUND;
<h2>Page Not Found</h2>
<p>Could not find page with location you requested
(<tt>$location</tt>). Did you mistype the address?</p>
NOTFOUND
}
# If we specified that we're going to send a separate file to the
# user (usually not HTML, text, etc.) then set the information and
# quit processing
unless ( $class->_is_page_displayable( $page ) ) {
$R->{page}{send_file} = $page->{location};
$R->DEBUG && $R->scrib( 1, "File being retrieved is not displayable.",
"Set 'send_file' to $page->{location}" );
return undef;
}
# We have a page and we can display it, so grab the content
$page->load_content;
# Now figure out if we're editing or not
# Now we have a page; just check to see if we were instructed to
# display the editable form for this page, and if so ensure this
# user can do so.
my $text_params = {};
if ( $do_edit ) {
$page ||= $R->page->new;
$params->{page} = $page;
$text_params = { name => 'page::page_form' };
$R->{page}{title} = 'Edit a Document';
my $update_items = ( $page->is_saved ) ? eval { $page->fetch_updates( 5 ) } : [];
foreach my $update_info ( @{ $update_items } ) {
my $user = eval { $R->user->fetch( $update_info->[0] ) };
my $username = ( $user ) ? $user->{login_name} : 'administrator';
push @{ $params->{update_list} }, { login_name => $username, date => $update_info->[1] };
}
}
else {
# Ensure the page is viewable right now
unless ( $class->_is_active( $page ) ) {
$R->DEBUG && $R->scrib( 1, "Page is not currently active; return error" );
$R->{page}{title} = 'Page not yet active';
return '<h2 align="center">Not Active</h2><p>Sorry, this page is not currentlyactive.</p>';
}
$R->{page}{title} = $page->{title};
# Allows the page to define the main template it will use; if
# the page doesn't define one then the main UI module will use
# the default
$R->{page}{_template_name_} = $page->{main_template};
# You can split your page into multiple viewable pages -- see
# _split_pages() for more info
$text_params = $class->_split_pages( $page );
$class->_add_object_boxes( $page, $p );
}
# If the page has told us not to run it through TT, just return
# its content.
if ( $page->{_template_status} eq NO_PARSE_STATUS ) {
return $page->{content};
}
return $R->template->handler( {}, $params, $text_params );
}
sub _is_page_displayable {
my ( $class, $page ) = @_;
return 1 unless ( $page->{mime_type} );
return 1 if ( $DISPLAY_TYPES{ $page->{mime_type} } );
return undef;
}
# Find the location from whatever paramters, information we need
sub _find_location {
my ( $class, $p ) = @_;
return $p->{page}{location} if ( $p->{page} );
my $R = OpenInteract::Request->instance;
return $p->{location} ||
$R->apache->param( 'location' ) ||
$R->{path}{original};
}
# Security -- remove all '.' from the beginning of the location
# requested so people don't try to go up the directory tree. Also
# remove any two-dot sequence.
#
# In the future we might flag these as bad requests (die from here)
# and simply bail with a stern scoling.
sub _clean_location {
my ( $class, $location ) = @_;
return undef unless ( $location );
$location =~ s/^\.+//;
$location =~ s/\.\./_/;
return $location;
}
# Find object with $location in the database. We also try to do the
# work so that you can request a directory index ('home',
# 'index.html', etc.);
sub _find_page_object {
my ( $class, $location ) = @_;
my $R = OpenInteract::Request->instance;
$R->DEBUG && $R->scrib( 1, "Trying to retrieve object with location ($location)" );
# Chop off any query strings and put in a case-consistent format
$location = $class->_remove_query_string( $location );
$location = lc $location;
# Just like 'DirectoryIndex' in Apache...
my $index_names = $R->CONFIG->{action}{page}{directory_index} || [];
$R->DEBUG && $R->scrib( 1, "Using the following for index names: ",
join( ', ', @{ $index_names } ) );
my @locations = ( $location );
if ( $location =~ m|/$| ) {
$R->DEBUG && $R->scrib( 1, "Explicit directory request; add indexes" );
push @locations, map { "$location$_" } @{ $index_names };
}
elsif ( $location !~ /\.\w+$/ ) {
$R->DEBUG && $R->scrib( 1, "Location has no extension; add indexes " ),
push @locations, map { "$location/$_" } @{ $index_names };
}
else {
my ( $sans_extension );
( $sans_extension = $location ) =~ s/\.\w+$//;
$R->DEBUG && $R->scrib( 1, "Also check location without the extension ",
"using $sans_extension" );
push @locations, $sans_extension;
}
my ( $page );
my ( $error_type );
foreach my $location ( @locations ) {
$page = eval { $R->page->fetch( $location ) };
if ( $@ ) {
$R->scrib( 0, "Encountered error trying to retrieve ($location);",
"continuing with other locations." );
$error_type = SPOPS::Error->get->{type};
}
return $page if ( $page );
}
return undef unless ( $error_type );
die $error_type;
}
sub _remove_query_string {
my ( $class, $text ) = @_;
$text =~ s|^(.*)\?.*$|$1|;
return $text;
}
sub _split_pages {
my ( $class, $page ) = @_;
my $R = OpenInteract::Request->instance;
# Split the page into separate pages -- first check and see if the
# document IS paged, then do the splitting and other contortions
if ( $page->{content} =~ /$PAGE_SEPARATOR/ ) {
my @text_pages = split /$PAGE_SEPARATOR/, $page->{content};
my $page_num = $R->apache->param( 'pagenum' ) || 1;
my $this_page = $text_pages[ $page_num - 1 ];
my $total_pages = scalar @text_pages;
my $current_pagenum = $page_num;
$this_page .= <<PCOUNT;
<p align="right"><font size="-1">
[% OI.comp( 'page_count', total_pages = $total_pages,
url = '$page->{location}',
current_pagenum = $current_pagenum ) %]
</font></p>
PCOUNT
return { text => $this_page };
}
return { text => $page->{content} };
}
sub _add_object_boxes {
my ( $class, $page, $p ) = @_;
my $R = OpenInteract::Request->instance;
my $box_string = $page->{boxes};
# If this page has specified any boxes, push them onto the stack
# unless they start with a '-', in which case set that name aside
# so we can go through all of the boxes and remove it.
my %box_remove = ();
if ( $box_string ) {
my @boxes = split /\s+/, $box_string;
foreach my $box_name ( @boxes ) {
next if ( $box_name =~ /^\s*$/ );
$R->DEBUG && $R->scrib( 1, "Adding box name ($box_name) from page definition" );
if ( $box_name =~ s/^\-// ) {
$box_remove{ $box_name }++;
}
else {
push @{ $R->{boxes} }, $box_name;
}
}
# Go through ALL the boxes and do a removal if necessary
# TODO: we should move this processing to base_box)
my @box_keep = ();
foreach my $box_info ( @{ $R->{boxes} } ) {
next if ( ref $box_info and $box_remove{ $box_info->{name} } );
next if ( ! ref $box_info and $box_remove{ $box_info } );
push @box_keep, $box_info;
}
$R->{boxes} = \@box_keep;
}
# If this person has WRITE access to the module, give them a box
# so they can edit/remove this document
if ( $p->{level} >= SEC_LEVEL_WRITE ) {
push @{ $R->{boxes} }, { name => 'edit_document_box',
params => { location => $page->{location} } };
}
return undef;
}
sub _is_active {
my ( $class, $page ) = @_;
return undef if ( $page->{is_active} eq 'no' );
return 1 unless ( $page->{active_on} );
my $active = Class::Date::date([ split '-', $page->{active_on} ]);
my $now = Class::Date->now;
my $expires = Class::Date::date([ split '-', $page->{expires_on} ]);
my $R = OpenInteract::Request->instance;
$R->DEBUG && $R->scrib( 1, "Active on: $active; Expires on: $expires" );
return undef if ( $now < $active );
return undef if ( $now > $expires );
return 1;
}
sub _edit_customize {
}
1;
|
|
From: Chris W. <la...@us...> - 2001-10-20 15:11:51
|
Update of /cvsroot/openinteract/OpenInteract/pkg/base_page/OpenInteract
In directory usw-pr-cvs1:/tmp/cvs-serv12815/OpenInteract
Added Files:
Page.pm
Log Message:
added parent class of pages -- implementation in subclass, but we
delegate rather than use inheritance
--- NEW FILE: Page.pm ---
package OpenInteract::Page;
# $Id: Page.pm,v 1.1 2001/10/20 15:11:48 lachoy Exp $
use strict;
use Data::Dumper qw( Dumper );
use File::Basename qw();
$OpenInteract::Page::VERSION = sprintf("%d.%02d", q$Revision: 1.1 $ =~ /(\d+)\.(\d+)/);
########################################
# CLASS METHODS
########################################
# Retrieve unique directory names and counts of member files from the
# system.
#
# Returns: arrayref of arrayrefs, first member is the directory name
# and the second is the number of files in the directory.
sub list_directories {
my ( $class ) = @_;
my $directory_list = eval { $class->db_select({
from => $class->CONFIG->{table_name},
select => [ 'directory, count(*)' ],
select_modifier => 'DISTINCT',
order => 'directory',
group => 'directory' }) };
if ( $@ ) {
my $R = OpenInteract::Request->instance;
$R->scrib( 0, "Error trying to retrieve distinct directory names: $@",
Dumper( SPOPS::Error->get ) );
$directory_list = [];
}
return $directory_list;
}
########################################
# OBJECT METHODS
########################################
# Just replace the generated 'url' method with one that just uses the
# location. This won't work if you do not have the Page handler
# answering all 'unknown' requests.
sub object_description {
my ( $self ) = @_;
my $info = $self->SUPER::object_description;
$info->{url} = $self->{location};
return $info;
}
# Fetch the content from either the filesystem or database, depending.
sub content {
my ( $self ) = @_;
return $self->{content} = ( $self->{is_file} eq 'yes' )
? OpenInteract::Page::File->load( $self )
: OpenInteract::Page::Database->load( $self );
}
########################################
# RULESET METHODS
########################################
# Here we add a ruleset so we can set the value for 'directory'
# whenever we save the object
sub ruleset_behavior {
my ( $class, $rs_table ) = @_;
push @{ $rs_table->{pre_save_action} }, \&find_directory;
return __PACKAGE__;
}
sub find_directory {
my ( $self, $p ) = @_;
$self->{directory} = File::Basename::dirname( $self->{location} );
return 1;
}
1;
__END__
=pod
=head1 NAME
OpenInteract::Page - Additional methods for the SPOPS Page object
=head1 SYNOPSIS
# Create a new basic page object
my $page = OpenInteract::Page->new();
$page->{location} = '/mysite/home';
$page->{is_file} = 'no';
$page->{pagetext} = "<h2>Headline</h2><p>This is the text for my page</p>";
$page->{author} = "Scooby Doo";
$page->save;
print "Directory for location $page->{location} is $page->{directory}\n";
# Get the list of directories
my $directory_info = OpenInteract::Page->list_directories();
foreach my $info ( @{ $directory_info } ) {
print "Directory $info->[0] has $info->[1] entries\n";
}
=head1 DESCRIPTION
This class adds methods to the SPOPS class that represents static pages.
=head1 METHODS
B<find_directories()>
Class method that finds all unique directories currently used in the
system along with the number of files in each.
Returns an arrayref of arrayrefs. The first element in each arrayref
in the directory name, the second is the number of files in the
directory.
B<object_description()>
(Overrides method from SPOPS.)
Modify the C<url> value of the returned hashref of object information
to simply be the location of the basic page.
=head1 RULESETS
B<pre_save_action>
Set the C<directory> property from the C<location> property
=head1 BUGS
None known.
=head1 TO DO
Nothing known.
=head1 SEE ALSO
=head1 COPYRIGHT
Copyright (c) 2001 intes.net, inc.. All rights reserved.
This library is free software; you can redistribute it and/or modify
it under the same terms as Perl itself.
=head1 AUTHORS
Chris Winters <ch...@cw...>
=cut
|
|
From: Chris W. <la...@us...> - 2001-10-20 15:10:27
|
Update of /cvsroot/openinteract/OpenInteract/pkg/base_page/OpenInteract/Page In directory usw-pr-cvs1:/tmp/cvs-serv12619/OpenInteract/Page Log Message: Directory /cvsroot/openinteract/OpenInteract/pkg/base_page/OpenInteract/Page added to the repository |
|
From: Chris W. <la...@us...> - 2001-10-20 15:10:19
|
Update of /cvsroot/openinteract/OpenInteract/pkg/base_page/struct In directory usw-pr-cvs1:/tmp/cvs-serv12595/struct Log Message: Directory /cvsroot/openinteract/OpenInteract/pkg/base_page/struct added to the repository |