webgui/lib/WebGUI/Wobject/WobjectProxy.pm
2003-03-03 05:23:56 +00:00

137 lines
5.1 KiB
Perl

package WebGUI::Wobject::WobjectProxy;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2003 Plain Black LLC.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
use Tie::CPHash;
use WebGUI::DateTime;
use WebGUI::Icon;
use WebGUI::International;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::Page;
use WebGUI::TabForm;
use WebGUI::Template;
use WebGUI::Wobject;
our @ISA = qw(WebGUI::Wobject);
#-------------------------------------------------------------------
sub duplicate {
my ($w);
$w = $_[0]->SUPER::duplicate($_[1]);
$w = WebGUI::Wobject::WobjectProxy->new({wobjectId=>$w,namespace=>$_[0]->get("namespace")});
$w->set({
proxiedWobjectId=>$_[0]->get("proxiedWobjectId")
});
}
#-------------------------------------------------------------------
sub name {
return WebGUI::International::get(3,$_[0]->get("namespace"));
}
#-------------------------------------------------------------------
sub new {
my $class = shift;
my $property = shift;
my $self = WebGUI::Wobject->new(
$property,
[qw(proxiedWobjectId)]
);
bless $self, $class;
}
#-------------------------------------------------------------------
sub uiLevel {
return 8;
}
#-------------------------------------------------------------------
sub www_edit {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
my ($output, $f, $startDate, $endDate, $templatePosition,%wobjects, %page, %wobject, $a, $b);
tie %wobject, 'Tie::CPHash';
tie %page, 'Tie::CPHash';
tie %wobjects, 'Tie::IxHash';
$output = helpIcon(1,$_[0]->get("namespace"));
$output .= '<h1>'.WebGUI::International::get(2,$_[0]->get("namespace")).'</h1>';
$templatePosition = $_[0]->get("templatePosition") || 1;
$startDate = $_[0]->get("startDate") || $session{page}{startDate};
$endDate = $_[0]->get("endDate") || $session{page}{endDate};
my %tabs;
tie %tabs, 'Tie::IxHash';
%tabs = (
properties=>{
label=>WebGUI::International::get(893)
},
layout=>{
label=>WebGUI::International::get(105),
uiLevel=>5
},
privileges=>{
label=>WebGUI::International::get(107),
uiLevel=>9
}
);
$f = WebGUI::TabForm->new(\%tabs);
$f->hidden({name=>"wid",value=>$_[0]->get("wobjectId")});
$f->hidden({name=>"namespace",value=>$_[0]->get("namespace")}) if ($_[0]->get("wobjectId") eq "new");
$f->hidden({name=>"func",value=>"editSave"});
$f->getTab("properties")->readOnly($_[0]->get("wobjectId"),WebGUI::International::get(499));
$f->hidden({name=>"title",value=>$_[0]->name});
$f->hidden({name=>"displayTitle",value=>0});
$f->getTab("layout")->select(
-name=>"templatePosition",
-label=>WebGUI::International::get(363),
-value=>[$templatePosition],
-uiLevel=>5,
-options=>WebGUI::Page::getTemplatePositions($session{page}{templateId}),
-subtext=>WebGUI::Page::drawTemplate($session{page}{templateId})
);
$f->getTab("privileges")->date("startDate",WebGUI::International::get(497),$startDate);
$f->getTab("privileges")->date("endDate",WebGUI::International::get(498),$endDate);
$a = WebGUI::SQL->read("select pageId,menuTitle from page where pageId<2 or pageId>25 order by menuTitle");
while (%page = $a->hash) {
$b = WebGUI::SQL->read("select wobjectId,title from wobject
where pageId=".$page{pageId}." and namespace<>'WobjectProxy' and
namespace<>'ExtraColumn' and endDate>=".time()." and pageId<>3 order by sequenceNumber");
while (%wobject = $b->hash) {
$wobjects{$wobject{wobjectId}} = $page{menuTitle}." / ".$wobject{title}." (".$wobject{wobjectId}.")";
}
$b->finish;
}
$a->finish;
$f->getTab("properties")->select("proxiedWobjectId",\%wobjects,WebGUI::International::get(1,$_[0]->get("namespace")),[$_[0]->get("proxiedWobjectId")]);
$output .= $f->print;
return $output;
}
#-------------------------------------------------------------------
sub www_editSave {
return WebGUI::Privilege::insufficient() unless (WebGUI::Privilege::canEditPage());
$_[0]->SUPER::www_editSave({
proxiedWobjectId=>$session{form}{proxiedWobjectId}
});
return "";
}
#-------------------------------------------------------------------
sub www_view {
return WebGUI::International::get(4,$_[0]->get("namespace"));
}
1;