diff --git a/lib/WebGUI/SQL.pm b/lib/WebGUI/SQL.pm index 75ef85d53..094246c3c 100644 --- a/lib/WebGUI/SQL.pm +++ b/lib/WebGUI/SQL.pm @@ -235,7 +235,8 @@ Ends a query after calling the "new" or "read" methods. =cut sub finish { - return $_[0]->{_sth}->finish; + $_[0]->{_sth}->finish; + return ""; } @@ -372,14 +373,13 @@ By default this method uses the WebGUI database handler. However, you may choose =cut sub new { - my ($class, $sql, $dbh, $sth); - $class = shift; - $sql = shift; - $dbh = shift || $WebGUI::Session::session{dbh}; + my $class = shift; + my $sql = shift; + my $dbh = shift || $WebGUI::Session::session{dbh}; if ($WebGUI::Session::session{setting}{showDebug}) { push(@{$WebGUI::Session::session{SQLquery}},$sql); } - $sth = $dbh->prepare($sql) or WebGUI::ErrorHandler::fatalError("Couldn't prepare statement: ".$sql." : ". DBI->errstr); + my $sth = $dbh->prepare($sql) or WebGUI::ErrorHandler::fatalError("Couldn't prepare statement: ".$sql." : ". DBI->errstr); $sth->execute or WebGUI::ErrorHandler::fatalError("Couldn't execute statement: ".$sql." : ". DBI->errstr); bless ({_sth => $sth}, $class); } @@ -500,9 +500,11 @@ By default this method uses the WebGUI database handler. However, you may choose =cut sub quickHashRef { - my ($sth, $data); - $sth = WebGUI::SQL->new($_[1],$_[2]); - $data = $sth->hashRef; + my $self = shift; + my $sql = shift; + my $dbh = shift; + my $sth = WebGUI::SQL->new($sql,$dbh); + my $data = $sth->hashRef; $sth->finish; if (defined $data) { return $data; diff --git a/lib/WebGUI/Wobject.pm b/lib/WebGUI/Wobject.pm index a6e5c096e..cbae8a52e 100644 --- a/lib/WebGUI/Wobject.pm +++ b/lib/WebGUI/Wobject.pm @@ -828,17 +828,21 @@ A namespace to use for the template. Defaults to the wobject's namespace. =cut sub processTemplate { + my $self = shift; + my $templateId = shift; + my $var = shift; + my $namespace = shift; my %vars = ( - %{$_[0]->{_property}}, - %{$_[2]} + %{$self->{_property}}, + %{$var} ); - if (defined $_[0]->get("_WobjectProxy")) { + if (defined $self->get("_WobjectProxy")) { $vars{isShortcut} = 1; - my ($originalPageURL) = WebGUI::SQL->quickArray("select urlizedTitle from page where pageId=".$_[0]->get("pageId")); - $vars{originalURL} = WebGUI::URL::gateway($originalPageURL."#".$_[0]->get("wobjectId")); + my ($originalPageURL) = WebGUI::SQL->quickArray("select urlizedTitle from page where pageId=".$self->get("pageId")); + $vars{originalURL} = WebGUI::URL::gateway($originalPageURL."#".$self->get("wobjectId")); } - my $namespace = $_[3] || $_[0]->get("namespace"); - return WebGUI::Template::process($_[1],$namespace, \%vars); + my $namespace = $namespace || $self->get("namespace"); + return WebGUI::Template::process($templateId,$namespace, \%vars); } #------------------------------------------------------------------- diff --git a/lib/WebGUI/Wobject/Article.pm b/lib/WebGUI/Wobject/Article.pm index 5c8ca604c..cd65784d8 100644 --- a/lib/WebGUI/Wobject/Article.pm +++ b/lib/WebGUI/Wobject/Article.pm @@ -120,17 +120,18 @@ sub www_editSave { #------------------------------------------------------------------- sub www_view { + my $self = shift; my ($file, %var); - if ($_[0]->get("image") ne "") { - $file = WebGUI::Attachment->new($_[0]->get("image"),$_[0]->get("wobjectId")); + if ($self->get("image") ne "") { + $file = WebGUI::Attachment->new($self->get("image"),$self->get("wobjectId")); $var{"image.url"} = $file->getURL; $var{"image.thumbnail"} = $file->getThumbnail; } - $var{description} = $_[0]->get("description"); - if ($_[0]->get("convertCarriageReturns")) { + $var{description} = $self->get("description"); + if ($self->get("convertCarriageReturns")) { $var{description} =~ s/\n/\\n/g; } - $var{"new.template"} = WebGUI::URL::page("wid=".$_[0]->get("wobjectId")."&func=view")."&overrideTemplateId="; + $var{"new.template"} = WebGUI::URL::page("wid=".$self->get("wobjectId")."&func=view")."&overrideTemplateId="; $var{"description.full"} = $var{description}; $var{"description.full"} =~ s/\^\-\;//g; $var{"description.first.100words"} = $var{"description.full"}; @@ -155,7 +156,7 @@ sub www_view { $var{"description.first.2sentences"} =~ s/^((.*?\.){2}).*/$1/s; $var{"description.first.sentence"} = $var{"description.first.2sentences"}; $var{"description.first.sentence"} =~ s/^(.*?\.).*/$1/s; - my $p = WebGUI::Paginator->new(WebGUI::URL::page("wid=".$_[0]->get("wobjectId")."&func=view"),1); + my $p = WebGUI::Paginator->new(WebGUI::URL::page("wid=".$self->get("wobjectId")."&func=view"),1); if ($session{form}{makePrintable} || $var{description} eq "") { $var{description} =~ s/\^\-\;//g; $p->setDataByArrayRef([$var{description}]); @@ -165,39 +166,39 @@ sub www_view { $var{description} = $p->getPage; } $p->appendTemplateVars(\%var); - if ($_[0]->get("attachment") ne "") { - $file = WebGUI::Attachment->new($_[0]->get("attachment"),$_[0]->get("wobjectId")); + if ($self->get("attachment") ne "") { + $file = WebGUI::Attachment->new($self->get("attachment"),$self->get("wobjectId")); $var{"attachment.box"} = $file->box; $var{"attachment.icon"} = $file->getIcon; $var{"attachment.url"} = $file->getURL; $var{"attachment.name"} = $file->getFilename; } - my $callback = WebGUI::URL::page("func=view&wid=".$_[0]->get("wobjectId")); - if ($_[0]->get("allowDiscussion")) { - my $forum = WebGUI::Forum->new($_[0]->get("forumId")); + my $callback = WebGUI::URL::page("func=view&wid=".$self->get("wobjectId")); + if ($self->get("allowDiscussion")) { + my $forum = WebGUI::Forum->new($self->get("forumId")); $var{"replies.count"} = ($forum->get("replies") + $forum->get("threads")); $var{"replies.URL"} = WebGUI::Forum::UI::formatForumURL($callback,$forum->get("forumId")); - $var{"replies.label"} = WebGUI::International::get(28,$_[0]->get("namespace")); + $var{"replies.label"} = WebGUI::International::get(28,$self->get("namespace")); $var{"post.URL"} = WebGUI::Forum::UI::formatNewThreadURL($callback,$forum->get("forumId")); - $var{"post.label"} = WebGUI::International::get(24,$_[0]->get("namespace")); + $var{"post.label"} = WebGUI::International::get(24,$self->get("namespace")); } - my $templateId = $_[0]->getValue("templateId"); + my $templateId = $self->getValue("templateId"); if ($session{form}{overrideTemplateId} ne "") { $templateId = $session{form}{overrideTemplateId}; } if ($session{form}{forumOp}) { - unless ($!= $_[0]->get("wobjectId")) { - WebGUI::ErrorHandler::security("access a forum that was not related to this message board (".$_[0]->get("wobjectId").")"); + unless ($!= $self->get("wobjectId")) { + WebGUI::ErrorHandler::security("access a forum that was not related to this message board (".$self->get("wobjectId").")"); return WebGUI::Privilege::insufficient(); } return WebGUI::Forum::UI::forumOp({ callback=>$callback, - title=>$_[0]->get("title"), - description=>$_[0]->get("description"), - forumId=>$_[0]->get("forumId") + title=>$self->get("title"), + description=>$self->get("description"), + forumId=>$self->get("forumId") }); } else { - return $_[0]->processTemplate($templateId,\%var); + return $self->processTemplate($templateId,\%var); } }