From: Chris W. <la...@us...> - 2005-02-28 23:43:55
|
Update of /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2 In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26167 Modified Files: Util.pm Log Message: some core classes shouldn't use OI2::Context directly since it brings in everything else and has a high likelihood of creating a circular reference Index: Util.pm =================================================================== RCS file: /cvsroot/openinteract/OpenInteract2/lib/OpenInteract2/Util.pm,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** Util.pm 26 Feb 2005 05:56:20 -0000 1.21 --- Util.pm 28 Feb 2005 23:43:40 -0000 1.22 *************** *** 13,17 **** use MIME::Lite (); use OpenInteract2::Constants qw( :log ); - use OpenInteract2::Context qw( CTX ); use OpenInteract2::Exception qw( oi_error ); use SPOPS::Secure qw( :level :verbose ); --- 13,16 ---- *************** *** 20,23 **** --- 19,23 ---- my ( $log ); + my ( $CTX ); use constant DEFAULT_SUBJECT => 'Mail sent from OpenInteract'; *************** *** 30,33 **** --- 30,41 ---- application/x-javascript application/x-perl ); + sub _load_context { + unless ( $CTX ) { + require OpenInteract2::Context; + $CTX = OpenInteract2::Context->instance; + } + return $CTX; + } + ######################################## # DATE ROUTINES *************** *** 42,47 **** $p->{format} ||= '%Y-%m-%d %T'; $p->{time} ||= time; ! return CTX->create_date({ epoch => $p->{time} }) ! ->strftime( $p->{format} ); } --- 50,56 ---- $p->{format} ||= '%Y-%m-%d %T'; $p->{time} ||= time; ! _load_context(); ! return $CTX->create_date({ epoch => $p->{time} }) ! ->strftime( $p->{format} ); } *************** *** 228,232 **** my ( $ext ) = $cleaned_name =~ /\.(\w+)$/; my $mime_type = eval { ! CTX->lookup_object( 'content_type' ) ->mime_type_by_extension( lc $ext ); }; --- 237,241 ---- my ( $ext ) = $cleaned_name =~ /\.(\w+)$/; my $mime_type = eval { ! OpenInteract2::ContentType ->mime_type_by_extension( lc $ext ); }; *************** *** 249,253 **** sub _build_header_info { my ( $class, $p ) = @_; ! my $mail_config = CTX->lookup_mail_config; return ( To => $p->{to} || $p->{email}, From => $p->{from} || $mail_config->{admin_email}, --- 258,263 ---- sub _build_header_info { my ( $class, $p ) = @_; ! _load_context(); ! my $mail_config = $CTX->lookup_mail_config; return ( To => $p->{to} || $p->{email}, From => $p->{from} || $mail_config->{admin_email}, *************** *** 258,262 **** sub _get_smtp_host { my ( $class, $p ) = @_; ! my $mail_config = CTX->lookup_mail_config; return $p->{smtp} || $mail_config->{smtp_host}; --- 268,273 ---- sub _get_smtp_host { my ( $class, $p ) = @_; ! _load_context(); ! my $mail_config = $CTX->lookup_mail_config; return $p->{smtp} || $mail_config->{smtp_host}; *************** *** 286,290 **** } ! my $website_dir = CTX->lookup_directory( 'website' ); my $cleaned_filename = catfile( $website_dir, $filename ); if ( -f $cleaned_filename ) { --- 297,302 ---- } ! _load_context(); ! my $website_dir = $CTX->lookup_directory( 'website' ); my $cleaned_filename = catfile( $website_dir, $filename ); if ( -f $cleaned_filename ) { |