converting nav and more asset manager fixes

This commit is contained in:
JT Smith 2004-12-28 05:01:04 +00:00
parent 63345d79fe
commit a287beda58
19 changed files with 1206 additions and 556 deletions

File diff suppressed because one or more lines are too long

View file

@ -82,12 +82,15 @@ WebGUI::SQL->write("alter table wobject add printableStyleTemplateId varchar(22)
WebGUI::SQL->write("alter table wobject add cacheTimeout int not null default 60");
WebGUI::SQL->write("alter table wobject add cacheTimeoutVisitor int not null default 3600");
WebGUI::SQL->write("alter table wobject drop primary key");
# next 2 lines are for sitemap to nav migration
WebGUI::SQL->write("alter table Navigation rename tempoldnav");
WebGUI::SQL->write("create table Navigation (assetId varchar(22) not null primary key, assetsToInclude text, startType varchar(35), startPoint varchar(255), endPoint varchar(35), showSystemPages int not null default 0, showHiddenPages int not null default 0, showUnprivilegedPages int not null default 0)");
my $sth = WebGUI::SQL->read("select distinct(namespace) from wobject");
while (my ($namespace) = $sth->array) {
WebGUI::SQL->write("alter table ".$namespace." add column assetId varchar(22) not null");
}
$sth->finish;
walkTree('0','theroot','000001','1');
walkTree('0','PBasset000000000000001','000001','1');
print "\t\tMaking second round of table structure changes\n" unless ($quiet);
WebGUI::SQL->write("drop table SiteMap");
WebGUI::SQL->write("delete from template where namespace in ('SiteMap')");
@ -123,87 +126,152 @@ WebGUI::SQL->write("alter table wobject drop column bufferPrevId");
WebGUI::SQL->write("alter table wobject drop column forumId");
WebGUI::SQL->write("alter table wobject drop column startDate");
WebGUI::SQL->write("alter table wobject drop column endDate");
WebGUI::SQL->write("alter table wobject drop column addedBy");
WebGUI::SQL->write("alter table wobject drop column dateAdded");
WebGUI::SQL->write("alter table wobject drop column editedBy");
WebGUI::SQL->write("alter table wobject drop column lastEdited");
WebGUI::SQL->write("alter table wobject drop column allowDiscussion");
WebGUI::SQL->write("drop table page");
WebGUI::SQL->write("alter table Article drop column image");
WebGUI::SQL->write("alter table Article drop column attachment");
my %migration;
print "\tUpdating navigation to work with asset tree\n" unless ($quiet);
WebGUI::SQL->write("alter table Navigation add column assetsToInclude text");
WebGUI::SQL->write("alter table Navigation add column startType varchar(35)");
WebGUI::SQL->write("alter table Navigation add column startPoint varchar(35)");
WebGUI::SQL->write("alter table Navigation add column baseType varchar(35)");
WebGUI::SQL->write("alter table Navigation add column basePage varchar(255)");
WebGUI::SQL->write("alter table Navigation add column endType varchar(35)");
WebGUI::SQL->write("alter table Navigation add column endPoint varchar(35)");
my $sth = WebGUI::SQL->read("select * from Navigation");
print "\tConverting navigation system to asset tree\n" unless ($quiet);
my ($navRootLineage) = WebGUI::SQL->quickArray("select assetId,title,lineage from asset where length(lineage)=12 order by lineage desc limit 1");
$navRootLineage = sprintf("%012d",("000001000005"+1));
my $navRootId = WebGUI::SQL->setRow("asset","assetId",{
assetId=>"new",
isHidden=>1,
title=>"Navigation Configurations",
menuTitle=>"Navigation Configurations",
url=>fixUrl('doesntexistyet',"Navigation Configurations"),
ownerUserId=>"3",
groupIdView=>"4",
groupIdEdit=>"4",
parentId=>"PBasset000000000000001",
lineage=>$navRootLineage,
lastUpdated=>time(),
className=>"WebGUI::Admin::Wobject::Navigation",
state=>"published"
});
WebGUI::SQL->setRow("wobject","assetId",{
assetId=>$navRootId,
templateId=>"1",
styleTemplateId=>"1",
printableStyleTemplateId=>"3"
},undef,$navRootId);
WebGUI::SQL->setRow("Navigation","assetId",{
assetId=>$navRootId,
startType=>"relativeToCurrentUrl",
startPoint=>"0",
endPoint=>"55",
assetsToInclude=>"descendants"
},undef,$navRootId);
my $sth = WebGUI::SQL->read("select * from tempoldnav");
my $navRankCounter = 1;
while (my $data = $sth->hashRef) {
my %newNav;
$newNav{navigationId} = $data->{navigationId};
$newNav{identifier} = $data->{identifier};
print "\t\tConverting ".$data->{identifier}."\n" unless ($quiet);
my (%newNav,%newAsset,%newWobject);
$newNav{assetId} = $newWobject{assetId} = $newAsset{assetId} = getNewId("nav",$data->{navigationId});
$newAsset{url} = fixUrl($newAsset{assetId},$data->{identifier});
$newAsset{isHidden} = 1;
$newAsset{title} = $newAsset{menuTitle} = $data->{identifier};
$newAsset{ownerUserId} = "3";
$newAsset{groupIdView} = $newAsset{groupIdEdit} = "4";
$newAsset{className} = 'WebGUI::Asset::Wobject::Navigation';
$newAsset{state} = 'published';
$newAsset{lastUpdated} = time();
$newAsset{parentId} = $navRootId;
$newAsset{lineage} = $navRootLineage.sprintf("%06d",$navRankCounter);
$newWobject{templateId} = $data->{templateId};
$newWobject{styleTemplateId}="1";
$newWobject{printableStyleTemplateId}="3";
$newNav{showSystemPages} = $data->{showSystemPages};
$newNav{showHiddenPages} = $data->{showHiddenPages};
$newNav{showUnprivilegedPages} = $data->{showUnprivilegedPages};
$newNav{startType} = "relativeToRoot";
$newNav{startPoint} = $data->{stopAtLevel}+1;
if ($data->{startAt} eq "root") {
$newNav{baseType} = "relativeToRoot";
$newNav{basePage} = "0";
$newNav{startType} = "relativeToRoot";
$newNav{startPoint} = "0";
} elsif ($data->{startAt} eq "WebGUIroot") {
$newNav{baseType} = "relativeToRoot";
$newNav{basePage} = "1";
$newNav{startType} = "relativeToRoot";
$newNav{startPoint} = "1";
} elsif ($data->{startAt} eq "top") {
$newNav{baseType} = "relativeToRoot";
$newNav{basePage} = "2";
$newNav{startType} = "relativeToRoot";
$newNav{startPoint} = "2";
} elsif ($data->{startAt} eq "grandmother") {
$newNav{baseType} = "relativeToCurrentPage";
$newNav{basePage} = "-2";
$newNav{startType} = "relativeToCurrentUrl";
$newNav{startPoint} = "-2";
} elsif ($data->{startAt} eq "mother") {
$newNav{baseType} = "relativeToCurrentPage";
$newNav{basePage} = "-1";
$newNav{startType} = "relativeToCurrentUrl";
$newNav{startPoint} = "-1";
} elsif ($data->{startAt} eq "current") {
$newNav{baseType} = "relativeToCurrentPage";
$newNav{basePage} = "0";
$newNav{startType} = "relativeToCurrentUrl";
$newNav{startPoint} = "0";
} elsif ($data->{startAt} eq "daughter") {
$newNav{baseType} = "relativeToCurrentPage";
$newNav{basePage} = "1";
$newNav{startType} = "relativeToCurrentUrl";
$newNav{startPoint} = "1";
} else {
$newNav{baseType} = "specificUrl";
$newNav{basePage} = $data->{startAt};
$newNav{startType} = "specificUrl";
$newNav{startPoint} = $data->{startAt};
}
$newNav{endType} = "relativeToBasePage";
$newNav{endPoint} = ($data->{depth} == 99)?55:$data->{stopAtLevel});
$newNav{endPoint} = (($data->{depth} == 99)?55:$data->{depth});
if ($data->{method} eq "daughters") {
$newNav{endPoint} = "1";
$newNav{assetsToInclude} = "descendants";
} elsif ($data->{method} eq "sisters") {
$newNav{assetsToInclude} = "siblings";
} elsif ($data->{method} eq "self_and_sisters") {
$newNav{assetsToInclude} = "self,siblings";
$newNav{assetsToInclude} = "self\nsiblings";
} elsif ($data->{method} eq "descendants") {
$newNav{assetsToInclude} = "descendants";
} elsif ($data->{method} eq "self_and_descendants") {
$newNav{assetsToInclude} = "self,descendants";
$newNav{assetsToInclude} = "self\ndescendants";
} elsif ($data->{method} eq "leaves_under") {
$newNav{endPoint} = "1";
$newNav{assetsToInclude} = "descendants";
} elsif ($data->{method} eq "generation") {
$newNav{assetsToInclude} = "self,sisters";
$newNav{assetsToInclude} = "self\nsisters";
} elsif ($data->{method} eq "ancestors") {
$newNav{assetsToInclude} = "ancestors";
$newNav{endPoint} += $newNav{startPoint} unless ($newNav{startType} eq "specificUrl");
$newNav{startType} = "relativeToRoot";
$newNav{startPoint} = $data->{stopAtLevel}+1;
$newNav{assetsToInclude} = "descendants";
} elsif ($data->{method} eq "self_and_ancestors") {
$newNav{assetsToInclude} = "self,ancestors";
$newNav{endPoint} += $newNav{startPoint} unless ($newNav{startType} eq "specificUrl");
$newNav{startType} = "relativeToRoot";
$newNav{startPoint} = $data->{stopAtLevel}+1;
$newNav{assetsToInclude} = "self\ndescendants";
} elsif ($data->{method} eq "pedigree") {
$newNav{endPoint} += $newNav{startPoint} unless ($newNav{startType} eq "specificUrl");
$newNav{startType} = "relativeToRoot";
$newNav{startPoint} = $data->{stopAtLevel}+1;
$newNav{assetsToInclude} = "pedigree";
}
WebGUI::SQL->setRow("Navigation","navigationId",\%newNav);
WebGUI::SQL->setRow("asset","assetId",\%newAsset,undef,$newNav{assetId});
WebGUI::SQL->setRow("wobject","assetId",\%newWobject,undef,$newNav{assetId});
WebGUI::SQL->setRow("Navigation","assetId",\%newNav,undef,$newNav{assetId});
$navRankCounter++;
}
$sth->finish;
WebGUI::SQL->write("alter table Navigation drop column depth");
WebGUI::SQL->write("alter table Navigation drop column startAt");
WebGUI::SQL->write("alter table Navigation drop column stopAtLevel");
WebGUI::SQL->write("alter table Navigation drop column method");
WebGUI::SQL->write("alter table Navigation drop column reverse");
WebGUI::SQL->write("update Navigation set startPoint='root' where startPoint='nameless_root'");
WebGUI::SQL->write("drop table tempoldnav");
print "\tDeleting files which are no longer used.\n" unless ($quiet);
#unlink("../../lib/WebGUI/Page.pm");
#unlink("../../lib/WebGUI/Operation/Page.pm");
#unlink("../../lib/WebGUI/Navigation.pm");
#unlink("../../lib/WebGUI/Operation/Navigation.pm");
#unlink("../../lib/WebGUI/Attachment.pm");
#unlink("../../lib/WebGUI/Node.pm");
#unlink("../../lib/WebGUI/Wobject/Article.pm");
#unlink("../../lib/WebGUI/Wobject/SiteMap.pm");
#unlink("../../lib/WebGUI/Wobject/DataForm.pm");
#unlink("../../lib/WebGUI/Wobject/USS.pm");
#unlink("../../lib/WebGUI/Wobject/FileManager.pm");
WebGUI::Session::close();
@ -316,18 +384,17 @@ sub walkTree {
rmtree($session{config}{uploadsPath}.'/'.$wobject->{wobjectId});
} elsif ($wobject->{namespace} eq "SiteMap") {
print "\t\t\tConverting SiteMap ".$wobject->{wobjectId}." into Navigation\n" unless ($quiet);
my $navident = 'SiteMap_'.$namespace->{wobjectId};
my ($starturl) = WebGUI::SQL->quickArray("select urlizedTitle from page
where pageId=".quote($namespace->{startAtThisLevel}));
WebGUI::SQL->write("insert into Navigation (navigationId, identifier, depth, startAt,
templateId) values (".quote(WebGUI::Id::generate()).", ".quote($navident).",
".quote($namespace->{depth}).", ".quote($starturl).", '1')");
my $navmacro = $wobject->{description}.'<p>^Navigation('.$navident.');</p>';
WebGUI::SQL->write("update asset set className='WebGUI::Asset::Wobject::Article' where assetId=".quote($wobjectId));
WebGUI::SQL->write("update wobject set namespace='Article', description=".quote($navmacro)."
where assetId=".quote($wobjectId));
WebGUI::SQL->write("insert into Article (assetId,wobjectId) values (".quote($wobjectId).",
".quote($wobject->{wobjectId}).")");
WebGUI::SQL->setRow("Navigation","assetId",{
assetId=>$wobjectId,
endPoint=>$namespace->{depth},
startPoint=>$starturl,
startType=>"specificUrl",
assetsToInclude=>"descendants"
},undef,$wobjectId);
WebGUI::SQL->write("update asset set className='WebGUI::Asset::Wobject::Navigation' where assetId=".quote($wobjectId));
WebGUI::SQL->write("update wobject set namespace='Navigation', templateId='1' where assetId=".quote($wobjectId));
} elsif ($wobject->{namespace} eq "FileManager") {
print "\t\t\tConverting File Manager ".$wobject->{wobjectId}." into File Folder Layout\n" unless ($quiet);
WebGUI::SQL->write("update asset set className='WebGUI::Asset::Layout' where assetId=".quote($wobjectId));
@ -469,3 +536,321 @@ sub isIn {
}
sub getNewId {
my $type = shift;
my $oldId = shift;
my $namespace = shift;
my $migration = {'tmpl' => {
'Operation/MessageLog/View' => {
'1' => 'PBtmpl0000000000000050'
},
'Forum/Search' => {
'1' => 'PBtmpl0000000000000031'
},
'Auth/WebGUI/Account' => {
'1' => 'PBtmpl0000000000000010'
},
'Forum/PostPreview' => {
'1' => 'PBtmpl0000000000000030'
},
'MessageBoard' => {
'1' => 'PBtmpl0000000000000047'
},
'FileManager' => {
'1' => 'PBtmpl0000000000000025',
'2' => 'PBtmpl0000000000000087'
},
'Operation/Profile/View' => {
'1' => 'PBtmpl0000000000000052'
},
'Forum/PostForm' => {
'1' => 'PBtmpl0000000000000029'
},
'Operation/RedeemSubscription' => {
'1' => 'PBtmpl0000000000000053'
},
'Navigation' => {
'8' => 'PBtmpl0000000000000136',
'6' => 'PBtmpl0000000000000130',
'1001' => 'PBtmpl0000000000000075',
'4' => 'PBtmpl0000000000000117',
'1' => 'PBtmpl0000000000000048',
'3' => 'PBtmpl0000000000000108',
'7' => 'PBtmpl0000000000000134',
'1000' => 'PBtmpl0000000000000071',
'2' => 'PBtmpl0000000000000093',
'5' => 'PBtmpl0000000000000124'
},
'Macro/L_loginBox' => {
'1' => 'PBtmpl0000000000000044',
'2' => 'PBtmpl0000000000000092'
},
'Commerce/ConfirmCheckout' => {
'1' => 'PBtmpl0000000000000016'
},
'prompt' => {
'1' => 'PBtmpl0000000000000057'
},
'Auth/SMB/Login' => {
'1' => 'PBtmpl0000000000000009'
},
'ImageAsset' => {
'2' => 'PBtmpl0000000000000088'
},
'AttachmentBox' => {
'1' => 'PBtmpl0000000000000003'
},
'Forum' => {
'1' => 'PBtmpl0000000000000026'
},
'Poll' => {
'1' => 'PBtmpl0000000000000055'
},
'FileAsset' => {
'1' => 'PBtmpl0000000000000024'
},
'HttpProxy' => {
'1' => 'PBtmpl0000000000000033'
},
'Auth/SMB/Create' => {
'1' => 'PBtmpl0000000000000008'
},
'Commerce/ViewPurchaseHistory' => {
'1' => 'PBtmpl0000000000000019'
},
'Article' => {
'6' => 'PBtmpl0000000000000129',
'4' => 'PBtmpl0000000000000115',
'1' => 'PBtmpl0000000000000002',
'3' => 'PBtmpl0000000000000103',
'2' => 'PBtmpl0000000000000084',
'5' => 'PBtmpl0000000000000123'
},
'style' => {
'6' => 'PBtmpl0000000000000132',
'adminConsole' => 'PBtmpl0000000000000137',
'3' => 'PBtmpl0000000000000111',
'1001' => 'PBtmpl0000000000000076',
'1' => 'PBtmpl0000000000000060',
'1000' => 'PBtmpl0000000000000072',
'10' => 'PBtmpl0000000000000070'
},
'Macro/SubscriptionItem' => {
'1' => 'PBtmpl0000000000000046'
},
'WSClient' => {
'1' => 'PBtmpl0000000000000069',
'2' => 'PBtmpl0000000000000100'
},
'Operation/MessageLog/Message' => {
'1' => 'PBtmpl0000000000000049'
},
'Auth/SMB/Account' => {
'1' => 'PBtmpl0000000000000007'
},
'Survey' => {
'1' => 'PBtmpl0000000000000061'
},
'EventsCalendar' => {
'1' => 'PBtmpl0000000000000022',
'3' => 'PBtmpl0000000000000105',
'2' => 'PBtmpl0000000000000086'
},
'Macro/AdminToggle' => {
'1' => 'PBtmpl0000000000000036'
},
'Auth/LDAP/Create' => {
'1' => 'PBtmpl0000000000000005'
},
'Auth/WebGUI/Create' => {
'1' => 'PBtmpl0000000000000011'
},
'page' => {
'6' => 'PBtmpl0000000000000131',
'3' => 'PBtmpl0000000000000109',
'7' => 'PBtmpl0000000000000135',
'2' => 'PBtmpl0000000000000094',
'15' => 'PBtmpl0000000000000078',
'1' => 'PBtmpl0000000000000054',
'4' => 'PBtmpl0000000000000118',
'5' => 'PBtmpl0000000000000125'
},
'Macro/H_homeLink' => {
'1' => 'PBtmpl0000000000000042'
},
'USS' => {
'6' => 'PBtmpl0000000000000133',
'21' => 'PBtmpl0000000000000102',
'3' => 'PBtmpl0000000000000112',
'2' => 'PBtmpl0000000000000097',
'17' => 'PBtmpl0000000000000081',
'20' => 'PBtmpl0000000000000101',
'15' => 'PBtmpl0000000000000079',
'14' => 'PBtmpl0000000000000077',
'4' => 'PBtmpl0000000000000121',
'1' => 'PBtmpl0000000000000066',
'18' => 'PBtmpl0000000000000082',
'1000' => 'PBtmpl0000000000000074',
'16' => 'PBtmpl0000000000000080',
'19' => 'PBtmpl0000000000000083',
'5' => 'PBtmpl0000000000000128'
},
'AdminConsole' => {
'1' => 'PBtmpl0000000000000001'
},
'SQLReport' => {
'1' => 'PBtmpl0000000000000059'
},
'Macro/AdminBar' => {
'1' => 'PBtmpl0000000000000035',
'2' => 'PBtmpl0000000000000090'
},
'Survey/Gradebook' => {
'1' => 'PBtmpl0000000000000062'
},
'DataForm/List' => {
'1' => 'PBtmpl0000000000000021'
},
'Macro/GroupDelete' => {
'1' => 'PBtmpl0000000000000041'
},
'Product' => {
'4' => 'PBtmpl0000000000000119',
'1' => 'PBtmpl0000000000000056',
'3' => 'PBtmpl0000000000000110',
'2' => 'PBtmpl0000000000000095'
},
'Commerce/TransactionError' => {
'1' => 'PBtmpl0000000000000018'
},
'IndexedSearch' => {
'1' => 'PBtmpl0000000000000034',
'3' => 'PBtmpl0000000000000106',
'2' => 'PBtmpl0000000000000089'
},
'Auth/WebGUI/Expired' => {
'1' => 'PBtmpl0000000000000012'
},
'Commerce/SelectPaymentGateway' => {
'1' => 'PBtmpl0000000000000017'
},
'Macro/File' => {
'1' => 'PBtmpl0000000000000039',
'3' => 'PBtmpl0000000000000107',
'2' => 'PBtmpl0000000000000091'
},
'Survey/Overview' => {
'1' => 'PBtmpl0000000000000063'
},
'Macro/a_account' => {
'1' => 'PBtmpl0000000000000037'
},
'Macro/LoginToggle' => {
'1' => 'PBtmpl0000000000000043'
},
'Auth/LDAP/Account' => {
'1' => 'PBtmpl0000000000000004'
},
'Survey/Response' => {
'1' => 'PBtmpl0000000000000064'
},
'Commerce/CheckoutCanceled' => {
'1' => 'PBtmpl0000000000000015'
},
'USS/Submission' => {
'1' => 'PBtmpl0000000000000067',
'3' => 'PBtmpl0000000000000113',
'2' => 'PBtmpl0000000000000098'
},
'Auth/WebGUI/Recovery' => {
'1' => 'PBtmpl0000000000000014'
},
'Macro/r_printable' => {
'1' => 'PBtmpl0000000000000045'
},
'Operation/Profile/Edit' => {
'1' => 'PBtmpl0000000000000051'
},
'SyndicatedContent' => {
'1' => 'PBtmpl0000000000000065',
'1000' => 'PBtmpl0000000000000073'
},
'USS/SubmissionForm' => {
'4' => 'PBtmpl0000000000000122',
'1' => 'PBtmpl0000000000000068',
'3' => 'PBtmpl0000000000000114',
'2' => 'PBtmpl0000000000000099'
},
'EventsCalendar/Event' => {
'1' => 'PBtmpl0000000000000023'
},
'Macro/GroupAdd' => {
'1' => 'PBtmpl0000000000000040'
},
'Forum/Notification' => {
'1' => 'PBtmpl0000000000000027'
},
'Auth/LDAP/Login' => {
'1' => 'PBtmpl0000000000000006'
},
'DataForm' => {
'4' => 'PBtmpl0000000000000116',
'1' => 'PBtmpl0000000000000020',
'3' => 'PBtmpl0000000000000104',
'2' => 'PBtmpl0000000000000085'
},
'Auth/WebGUI/Login' => {
'1' => 'PBtmpl0000000000000013'
},
'richEditor' => {
'tinymce' => 'PBtmpl0000000000000138',
'5' => 'PBtmpl0000000000000126'
},
'Forum/Thread' => {
'1' => 'PBtmpl0000000000000032'
},
'Forum/Post' => {
'1' => 'PBtmpl0000000000000028'
},
'Macro/EditableToggle' => {
'1' => 'PBtmpl0000000000000038'
},
'richEditor/pagetree' => {
'1' => 'PBtmpl0000000000000058'
}
},
'nav' => {
'1002' => 'PBnav00000000000000005',
'11' => 'PBnav00000000000000006',
'7' => 'PBnav00000000000000019',
'2' => 'PBnav00000000000000014',
'17' => 'PBnav00000000000000012',
'1' => 'PBnav00000000000000001',
'18' => 'PBnav00000000000000013',
'16' => 'PBnav00000000000000011',
'13' => 'PBnav00000000000000008',
'iBkcoHUb-z4vzYPyX0oS5A' => 'PBnav00000000000000023',
'6' => 'PBnav00000000000000018',
'b3XBaWXeMXS39HPDfV2y5Q' => 'PBnav00000000000000022',
'3' => 'PBnav00000000000000015',
'9' => 'PBnav00000000000000021',
'12' => 'PBnav00000000000000007',
'14' => 'PBnav00000000000000009',
'15' => 'PBnav00000000000000010',
'8' => 'PBnav00000000000000020',
'1001' => 'PBnav00000000000000004',
'4' => 'PBnav00000000000000016',
'1000' => 'PBnav00000000000000003',
'10' => 'PBnav00000000000000002',
'5' => 'PBnav00000000000000017'
}
};
my $newId;
if ($type eq "nav") {
$newId = $migration->{nav}{$oldId};
} elsif ($type eq "tmpl") {
$newId = $migration->{tmpl}{$namespace}{$oldId};
}
$newId = WebGUI::Id::generate() unless ($newId);
return $newId;
}

View file

@ -69,7 +69,7 @@ create table asset (
index (parentId)
);
insert into asset (assetId, parentId, lineage, state, className, title, menuTitle, url, isSystem, ownerUserId, groupIdView, groupIdEdit) values ('theroot', 'infinity', '000001','published','WebGUI::Asset','Root','Root','root',1,'3','3','3');
insert into asset (assetId, parentId, lineage, state, className, title, menuTitle, url, isSystem, ownerUserId, groupIdView, groupIdEdit) values ('PBasset000000000000001', 'infinity', '000001','published','WebGUI::Asset','Root','Root','root',1,'3','3','3');
create table assetHistory (
assetId varchar(22) not null,

View file

@ -279,38 +279,39 @@ sub getEditForm {
-value=>$self->get("url"),
-uiLevel=>3
);
$tabform->getTab("properties")->yesNo(
-name=>"isHidden",
-value=>$self->get("isHidden"),
-label=>WebGUI::International::get(886),
-uiLevel=>6
);
$tabform->getTab("properties")->yesNo(
-name=>"newWindow",
-value=>$self->get("newWindow"),
-label=>WebGUI::International::get(940),
-uiLevel=>6
);
$tabform->getTab("properties")->yesNo(
-name=>"encryptPage",
-value=>$self->get("encryptPage"),
-label=>WebGUI::International::get('encrypt page'),
-uiLevel=>6
);
$tabform->getTab("properties")->textarea(
-name=>"synopsis",
-label=>WebGUI::International::get(412),
-value=>$self->get("synopsis"),
-uiLevel=>3
);
$tabform->addTab("privileges",WebGUI::International::get(107),6);
$tabform->getTab("privileges")->dateTime(
$tabform->addTab("display",WebGUI::International::get(105),5);
$tabform->getTab("display")->yesNo(
-name=>"isHidden",
-value=>$self->get("isHidden"),
-label=>WebGUI::International::get(886),
-uiLevel=>6
);
$tabform->getTab("display")->yesNo(
-name=>"newWindow",
-value=>$self->get("newWindow"),
-label=>WebGUI::International::get(940),
-uiLevel=>6
);
$tabform->addTab("security",WebGUI::International::get(107),6);
$tabform->getTab("security")->yesNo(
-name=>"encryptPage",
-value=>$self->get("encryptPage"),
-label=>WebGUI::International::get('encrypt page'),
-uiLevel=>6
);
$tabform->getTab("security")->dateTime(
-name=>"startDate",
-label=>WebGUI::International::get(497),
-value=>$self->get("startDate"),
-uiLevel=>6
);
$tabform->getTab("privileges")->dateTime(
$tabform->getTab("security")->dateTime(
-name=>"endDate",
-label=>WebGUI::International::get(498),
-value=>$self->get("endDate"),
@ -331,7 +332,7 @@ sub getEditForm {
$clause = "userId=".quote($self->get("ownerUserId"));
}
my $users = WebGUI::SQL->buildHashRef("select userId,username from users where $clause order by username");
$tabform->getTab("privileges")->selectList(
$tabform->getTab("security")->selectList(
-name=>"ownerUserId",
-options=>$users,
-label=>WebGUI::International::get(108),
@ -339,13 +340,13 @@ sub getEditForm {
-subtext=>$subtext,
-uiLevel=>6
);
$tabform->getTab("privileges")->group(
$tabform->getTab("security")->group(
-name=>"groupIdView",
-label=>WebGUI::International::get(872),
-value=>[$self->get("groupIdView")],
-uiLevel=>6
);
$tabform->getTab("privileges")->group(
$tabform->getTab("security")->group(
-name=>"groupIdEdit",
-label=>WebGUI::International::get(871),
-value=>[$self->get("groupIdEdit")],
@ -356,6 +357,12 @@ sub getEditForm {
}
sub getFirstDescendant {
my $self = shift;
$self->{_firstDescendant} = WebGUI::Asset->newByLineage($self->get("lineage").$self->formatRank(1)) unless (exists $self->{_firstDescendant});
return $self->{_firstDescendant};
}
sub getIcon {
my $self = shift;
my $small = shift;
@ -452,7 +459,7 @@ sub getLineageLength {
}
sub getName {
return WebGUI::International::get('asset','Asset');
return WebGUI::International::get("asset","Asset");
}
sub getNextChildRank {
@ -560,16 +567,6 @@ sub new {
return undef;
}
sub newByPropertyHashRef {
my $class = shift;
my $properties = shift;
my $className = $properties->{className};
my $cmd = "use ".$className;
eval ($cmd);
WebGUI::ErrorHandler::fatalError("Couldn't compile asset package: ".$className.". Root cause: ".$@) if ($@);
bless {_properties => $properties}, $className;
}
sub newByDynamicClass {
my $class = shift;
my $assetId = shift;
@ -592,6 +589,23 @@ sub newByDynamicClass {
}
sub newByLineage {
my $class = shift;
my $lineage = shift;
my $asset = WebGUI::SQL->quickHashRef("select assetId, className from asset where lineage=".quote($lineage));
return WebGUI::Asset->newByDynamicClass($asset->{assetId}, $asset->{className});
}
sub newByPropertyHashRef {
my $class = shift;
my $properties = shift;
my $className = $properties->{className};
my $cmd = "use ".$className;
eval ($cmd);
WebGUI::ErrorHandler::fatalError("Couldn't compile asset package: ".$className.". Root cause: ".$@) if ($@);
bless {_properties => $properties}, $className;
}
sub newByUrl {
my $class = shift;
my $url = shift || $session{env}{PATH_INFO};
@ -786,7 +800,7 @@ sub www_add {
my %properties = (
groupIdView => $self->get("groupIdView"),
groupIdEdit => $self->get("groupIdEdit"),
ownerId => $self->get("ownerId"),
ownerUserId => $self->get("ownerUserId"),
encryptPage => $self->get("encryptPage"),
isHidden => $self->get("isHidden"),
startDate => $self->get("startDate"),
@ -909,7 +923,7 @@ sub www_manageAssets {
<div id="contextMenu" class="contextMenu"></div>
<div id="propertiesWindow" class="propertiesWindow"></div>
<div id="crumbtrail"></div>
<div id="workspace" style="height: 200px;">Retrieving Assets...</div>
<div id="workspace">Retrieving Assets...</div>
<div id="dragImage" class="dragIdentifier">hello</div>
';
$output .= "<script>\n";

View file

@ -81,13 +81,13 @@ sub edit {
-uiLevel=>6
);
$tabform->addTab("privileges",WebGUI::International::get(107),6);
$tabform->getTab("privileges")->dateTime(
$tabform->getTab("security")->dateTime(
-name=>"startDate",
-label=>WebGUI::International::get(497),
-value=>$self->get("startDate"),
-uiLevel=>6
);
$tabform->getTab("privileges")->dateTime(
$tabform->getTab("security")->dateTime(
-name=>"endDate",
-label=>WebGUI::International::get(498),
-value=>$self->get("endDate"),
@ -108,7 +108,7 @@ sub edit {
$clause = "userId=".quote($self->get("ownerUserId"));
}
my $users = WebGUI::SQL->buildHashRef("select userId,username from users where $clause order by username");
$tabform->getTab("privileges")->selectList(
$tabform->getTab("security")->selectList(
-name=>"ownerUserId",
-options=>$users,
-label=>WebGUI::International::get(108),
@ -116,13 +116,13 @@ sub edit {
-subtext=>$subtext,
-uiLevel=>6
);
$tabform->getTab("privileges")->group(
$tabform->getTab("security")->group(
-name=>"groupIdView",
-label=>WebGUI::International::get(872),
-value=>[$self->get("groupIdView")],
-uiLevel=>6
);
$tabform->getTab("privileges")->group(
$tabform->getTab("security")->group(
-name=>"groupIdEdit",
-label=>WebGUI::International::get(871),
-value=>[$self->get("groupIdEdit")],

View file

@ -175,51 +175,43 @@ Returns the TabForm object that will be used in generating the edit page for thi
sub getEditForm {
my $self = shift;
my $tabform = $self->SUPER::getEditForm();
$tabform->addTab("layout",WebGUI::International::get(105),5);
$tabform->getTab("layout")->yesNo(
$tabform->getTab("display")->yesNo(
-name=>"displayTitle",
-label=>WebGUI::International::get(174),
-value=>$self->getValue("displayTitle"),
-uiLevel=>5
);
$tabform->getTab("layout")->template(
$tabform->getTab("display")->template(
-value=>$self->getValue("templateId"),
-namespace=>$self->get("namespace"),
-afterEdit=>'func=edit&amp;wid='.$self->get("wobjectId")."&amp;namespace=".$self->get("namespace")
);
$tabform->getTab("layout")->template(
$tabform->getTab("display")->template(
-name=>"styleTemplateId",
-label=>WebGUI::International::get(1073),
-value=>$self->getValue("styleTemplateId"),
-namespace=>'style',
-afterEdit=>'op=editPage&amp;npp='.$session{form}{npp}
);
$tabform->getTab("layout")->template(
$tabform->getTab("display")->template(
-name=>"printableStyleTemplateId",
-label=>WebGUI::International::get(1079),
-value=>$self->getValue("printableStyleTemplateId"),
-namespace=>'style',
-afterEdit=>'op=editPage&amp;npp='.$session{form}{npp}
);
# if ($childCount) {
$tabform->getTab("layout")->yesNo(
-name=>"recurseStyle",
-subtext=>' &nbsp; '.WebGUI::International::get(106),
-uiLevel=>9
);
# }
$tabform->getTab("properties")->HTMLArea(
-name=>"description",
-label=>WebGUI::International::get(85),
-value=>$self->getValue("description")
);
$tabform->getTab("properties")->interval(
$tabform->getTab("display")->interval(
-name=>"cacheTimeout",
-label=>WebGUI::International::get(895),
-value=>$self->getValue("cacheTimeout"),
-uiLevel=>8
);
$tabform->getTab("properties")->interval(
$tabform->getTab("display")->interval(
-name=>"cacheTimeoutVisitor",
-label=>WebGUI::International::get(896),
-value=>$self->getValue("cacheTimeoutVisitor"),
@ -230,20 +222,6 @@ sub getEditForm {
#-------------------------------------------------------------------
=head2 getName ( )
This method should be overridden by all wobjects and should return an internationalized human friendly name for the wobject. This method only exists in the super class for reverse compatibility and will try to look up the name based on the old name definition.
=cut
sub getName {
my $self = shift;
return $self->get("className");
}
#-------------------------------------------------------------------

View file

@ -35,18 +35,18 @@ sub definition {
tableName=>'Article',
className=>'WebGUI::Asset::Wobject::Article',
properties=>{
linkURL=>{
fieldType=>'url',
defaultValue=>undef
},
linkTitle=>{
fieldType=>'text',
defaultValue=>undef
},
convertCarriageReturns=>{
fieldType=>'yesNo',
defaultValue=>0
}
linkURL=>{
fieldType=>'url',
defaultValue=>undef
},
linkTitle=>{
fieldType=>'text',
defaultValue=>undef
},
convertCarriageReturns=>{
fieldType=>'yesNo',
defaultValue=>0
}
}
});
return $class->SUPER::definition($definition);
@ -70,7 +70,7 @@ sub getEditForm {
-value=>$self->getValue("linkURL"),
-uiLevel=>3
);
$tabform->getTab("layout")->yesNo(
$tabform->getTab("display")->yesNo(
-name=>"convertCarriageReturns",
-label=>WebGUI::International::get(10,"Article"),
-value=>$self->getValue("convertCarriageReturns"),

View file

@ -0,0 +1,469 @@
package WebGUI::Asset::Wobject::Navigation;
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2004 Plain Black Corporation.
#-------------------------------------------------------------------
# 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::IxHash;
use WebGUI::Asset::Wobject;
use WebGUI::ErrorHandler;
use WebGUI::Form;
use WebGUI::International;
use WebGUI::Privilege;
use WebGUI::Session;
use WebGUI::SQL;
use WebGUI::TabForm;
use WebGUI::URL;
use WebGUI::Utility;
our @ISA = qw(WebGUI::Asset::Wobject);
sub definition {
my $class = shift;
my $definition = shift;
push(@{$definition}, {
tableName=>'Navigation',
className=>'WebGUI::Asset::Wobject::Navigation',
properties=>{
assetsToInclude=>{
fieldType=>'checkList',
defaultValue=>"descendants"
},
startType=>{
fieldType=>'selectList',
defaultValue=>"relativeToCurrentUrl"
},
startPoint=>{
fieldType=>'text',
defaultValue=>0
},
endPoint=>{
fieldType=>'selectList',
defaultValue=>55
},
showSystemPages=>{
fieldType=>'yesNo',
defaultValue=>0
},
showHiddenPages=>{
fieldType=>'yesNo',
defaultValue=>0
},
showUnprivilegedPages=>{
fieldType=>'yesNo',
defaultValue=>0
}
}
});
return $class->SUPER::definition($definition);
}
sub getEditForm {
my $self = shift;
my $tabform = $self->SUPER::getEditForm;
my ($descendantsChecked, $selfChecked, $pedigreeChecked, $siblingsChecked);
my @assetsToInclude = split("\n",$self->getValue("assetsToInclude"));
my $afterScript;
foreach my $item (@assetsToInclude) {
if ($item eq "self") {
$selfChecked = 1;
} elsif ($item eq "descendants") {
$descendantsChecked = 1;
$afterScript = "displayNavEndPoint = false;";
} elsif ($item eq "siblings") {
$siblingsChecked = 1;
} elsif ($item eq "pedigree") {
$pedigreeChecked = 1;
}
}
$tabform->getTab("properties")->selectList(
-name=>"startType",
-options=>{
specificUrl=>'Specific URL',
relativeToCurrentUrl=>'Relative To Current URL',
relativeToRoot=>'Relative To Root'
},
-value=>[$self->getValue("startType")],
-label=>"Start Point Type",
-extras=>'id="navStartType" onChange="changeStartPoint()"'
);
$tabform->getTab("properties")->readOnly(
-label=>"Start Point",
-value=>'<div id="navStartPoint"></div>'
);
$tabform->getTab("properties")->readOnly(
-label=>"Assets to Include",
-value=>WebGUI::Form::checkbox({
checked=>$selfChecked,
name=>"assetsToInclude",
value=>"self"
}).'Self<br />'
.WebGUI::Form::checkbox({
checked=>$siblingsChecked,
name=>"assetsToInclude",
value=>"siblings"
}).'Siblings<br />'
.WebGUI::Form::checkbox({
checked=>$descendantsChecked,
name=>"assetsToInclude",
value=>"descendants",
extras=>'onChange="toggleEndPoint()"'
}).'Descendants<br />'
.WebGUI::Form::checkbox({
checked=>$pedigreeChecked,
name=>"assetsToInclude",
value=>"pedigree"
}).'Pedigree<br />'
);
WebGUI::ErrorHandler::warn($self->getValue("startType"));
my %options;
tie %options, 'Tie::IxHash';
%options = (
'55'=>'Infinity',
'1'=>'./a/ (+1)',
'2'=>'./a/b/ (+2)',
'3'=>'./a/b/c/ (+3)',
'4'=>'./a/b/c/d/ (+4)',
'5'=>'./a/b/c/d/e/ (+5)'
);
$tabform->getTab("properties")->raw(
'</tbody><tbody id="navEnd"><tr><td class="formDescription">End Point</td><td>'
.WebGUI::Form::selectList({
name=>"endPoint",
value=>[$self->getValue("endPoint")],
options=>\%options
})
.'</td></tr></tbody><tbody>'
);
$tabform->getTab("display")->yesNo(
-name=>'showSystemPages',
-label=>WebGUI::International::get(30,'Navigation'),
-value=>$self->getValue("showSystemPages")
);
$tabform->getTab("display")->yesNo(
-name=>'showHiddenPages',
-label=>WebGUI::International::get(31,'Navigation'),
-value=>$self->getValue("showHiddenPages")
);
$tabform->getTab("display")->yesNo(
-name=>'showUnprivilegedPages',
-label=>WebGUI::International::get(32,'Navigation'),
-value=>$self->getValue("showUnprivilegedPages")
);
my $start = $self->getValue("startPoint");
$tabform->getTab("properties")->raw("<script type=\"text/javascript\">
var displayNavEndPoint = true;
function toggleEndPoint () {
if (displayNavEndPoint) {
document.getElementById('navEnd').style.display='none';
displayNavEndPoint = false;
} else {
document.getElementById('navEnd').style.display='';
displayNavEndPoint = true;
}
}
function changeStartPoint () {
var types = new Array();
types['specificUrl']='<input type=\"text\" name=\"startPoint\" value=\"".$start."\">';
types['relativeToRoot']='<select name=\"startPoint\"><option value=\"0\"".(($start == 0)?' selected=\"1\"':'').">/ (0)</option><option value=\"1\"".(($start eq "1")?' selected=\"1\"':'').">/a/ (+1)</option><option value=\"2\"".(($start eq "2")?' selected=\"1\"':'').">/a/b/ (+2)</option><option value=\"3\"".(($start eq "3")?' selected=\"1\"':'').">/a/b/c/ (+3)</option><option value=\"4\"".(($start eq "4")?' selected=\"1\"':'').">/a/b/c/d/ (+4)</option><option value=\"5\"".(($start eq "5")?' selected=\"1\"':'').">/a/b/c/d/e/ (+5)</option><option value=\"6\"".(($start eq "6")?' selected=\"1\"':'').">/a/b/c/d/e/f/ (+6)</option><option value=\"7\"".(($start eq "7")?' selected=\"1\"':'').">/a/b/c/d/e/f/g/h/ (+7)</option><option value=\"8\"".(($start eq "8")?' selected=\"1\"':'').">/a/b/c/d/e/f/g/h/ (+8)</option><option value=\"9\"".(($start eq "9")?' selected=\"1\"':'').">/a/b/c/d/e/f/g/h/i/ (+9)</option></select>';
types['relativeToCurrentUrl']='<select name=\"startPoint\"><option value=\"-3\"".(($start eq "-3")?' selected=\"1\"':'').">../../.././ (-3)</option><option value=\"-2\"".(($start eq "-2")?' selected=\"1\"':'').">../.././ (-2)</option><option value=\"-1\"".(($start eq "-1")?' selected=\"1\"':'').">.././ (-1)</option><option value=\"0\"".(($start == 0)?' selected=\"1\"':'').">./ (0)</option><option value=\"1\"".(($start eq "1")?' selected=\"1\"':'').">./a/ (+1)</option><option value=\"2\"".(($start eq "2")?' selected=\"1\"':'').">./a/b/ (+2)</option><option value=\"3\"".(($start eq "3")?' selected=\"1\"':'').">./a/b/c/ (+3)</option></select>';
document.getElementById('navStartPoint').innerHTML=types[document.getElementById('navStartType').options[document.getElementById('navStartType').selectedIndex].value];
}
".$afterScript."
changeStartPoint();
toggleEndPoint();
</script>");
my $previewButton = qq{
<INPUT TYPE="button" VALUE="Preview" NAME="preview"
OnClick="
window.open('', 'navPreview', 'toolbar=no,status=no,location=no,scrollbars=yes,resizable=yes');
this.form.func.value='preview';
this.form.target = 'navPreview';
this.form.submit()">};
my $saveButton = ' <input type="button" value="'.WebGUI::International::get(62).'" onClick="
this.value=\''.WebGUI::International::get(452).'\';
this.form.func.value=\'editSave\';
this.form.target=\'_self\';
this.form.submit();
" >';
$tabform->{_submit} = $previewButton." ".$saveButton;
return $tabform;
}
sub getName {
return WebGUI::International::get("navigation","Navigation");
}
sub view {
my $self = shift;
# we've got to determine what our start point is based upon user conditions
my $start;
if (!exists $session{asset}) {
$start = $self;
} elsif ($self->get("startType") eq "specificUrl") {
$start = WebGUI::Asset->getByUrl($self->get("startPoint"));
} elsif ($self->get("startType") eq "relativeToRoot") {
unless (($self->get("startPoint")+1) >= $self->getLineageLength) {
$start = WebGUI::Asset->newByLineage(substr($session{asset}->get("lineage"),0, ($self->get("startPoint") + 1) * 6));
}
} elsif ($self->get("startType") eq "relativeToCurrentUrl") {
if ($self->get("startPoint") < 0) {
$start = WebGUI::Asset->newByLineage(substr($session{asset}->get("lineage"),0,
($session{asset}->getLineageLength - $self->get("startPoint") + 1) * 6
));
} elsif ($self->get("startPoint") > 0) {
my $lineage = $session{asset}->getLineage;
for (1..$self->get("startPoint")) {
$lineage .= $self->formatRank(1);
}
$start = WebGUI::Asset->newByLineage($lineage);
}
}
$start = $session{asset} unless (defined $start); # if none of the above results in a start point, then the current page must be it
my @assets = $start->getLineage();
my $config;
my $base;
my (@relatives, %rules);
foreach my $relative ("ancestors","self","siblings","descendants") {
push(@relatives,$relative) if ($config->{relative});
}
$rules{returnQuickReadObjects} = 1;
$base->getLineage(\@relatives,\%rules);
my @interestingPageProperties = ('pageId', 'parentId', 'title', 'ownerId', 'urlizedTitle',
'synopsis', 'newWindow', 'menuTitle', 'encryptLogin');
my $var = {'page_loop' => []};
my $p = $self->_getStartPageObject();
my $method = $self->_methods()->{$self->{_method}}{method};
my $cache = WebGUI::Cache->new($self->{_identifier}.'-'.$session{page}{pageId}, "Navigation-".$session{config}{configFile});
my $cacheContent = $cache->get unless $session{var}{adminOn};
my (@page_loop, $lastPage, %unfolded);
tie %unfolded, "Tie::IxHash";
# Store current page properties in template var
my $currentPage = WebGUI::Page->getPage();
my $currentRoot = $currentPage->getWebGUIRoot();
foreach my $property (@interestingPageProperties) {
$var->{'basepage.'.$property} = $currentPage->get($property);
}
unless (defined $cacheContent &&
! $session{url}{siteURL}) { # Never use cache if an alternate site url is specified.
# The loop was not cached
my @pages = eval $method;
if ($@) {
WebGUI::ErrorHandler::warn("Error in WebGUI::Navigation::build while trying to execute $method".$@);
}
if (@pages) {
my $startPageDepth = $p->get("depth")+1;
my $maxDepth = $startPageDepth + $self->{_depth};
my $minDepth = $startPageDepth - $self->{_depth};
foreach my $page (@pages) {
my $pageData = {};
$pageData->{"page.absDepth"} = $page->{'depth'} + 1;
$pageData->{"page.isSystem"} = $page->{isSystem};
# Check if in depth range
next if ($pageData->{"page.absDepth"} > $maxDepth || $pageData->{"page.absDepth"} < $minDepth);
# Check stopAtLevel
next if ($pageData->{"page.absDepth"} < $self->{_stopAtLevel});
# Check showSystemPages
next if (! $self->{_showSystemPages} && $pageData->{"page.isSystem"});
# Deal with hidden pages, don't ever hide pages if admin mode is on
next if(($page->{'hideFromNavigation'} && ! $self->{_showHiddenPages}) && (! $session{var}{adminOn}));
# Initial page info
$pageData->{"page.url"} = WebGUI::URL::gateway($page->{'urlizedTitle'});
if ($page->{'encryptPage'}) {
$pageData->{"page.url"} =~ s/http:/https:/;
}
$pageData->{"page.relDepth"} = $pageData->{"page.absDepth"} - $startPageDepth;
$pageData->{"page.isBasepage"} = ($page->{'pageId'} eq $session{page}{pageId});
$pageData->{"page.isHidden"} = $page->{'hideFromNavigation'};
# indent
my $indent = 0;
if ($self->{_method} eq 'pedigree' # reverse traversing
|| $self->{_method} eq 'ancestors' # needs another way to calculate
|| $self->{_method} eq 'self_and_ancestors') { # the indent
if ($self->{_stopAtLevel} <= $startPageDepth && $self->{_stopAtLevel} > 0) {
$indent = $pageData->{"page.absDepth"} - ($self->{_stopAtLevel} - 1) - 1;
} elsif ($self->{_stopAtLevel} > $startPageDepth && $self->{_stopAtLevel} > 0) {
$indent = 0;
} else {
$indent = $pageData->{"page.absDepth"} - 1;
}
} else {
$indent = $pageData->{"page.absDepth"} - $startPageDepth - 1;
}
$pageData->{"page.indent_loop"} = [];
push(@{$pageData->{"page.indent_loop"}},{'indent'=>$_}) for(1..$indent);
$pageData->{"page.indent"} = "&nbsp;&nbsp;&nbsp;" x $indent;
# Put page properties in $pageData hashref
foreach my $property (@interestingPageProperties) {
$pageData->{"page.".$property} = $page->{$property};
}
$pageData->{"page.isRoot"} = (! $page->{'parentId'});
$pageData->{"page.isTop"} = ($pageData->{"page.absDepth"} == 2);
$pageData->{"page.hasDaughter"} = ($page->{'nestedSetRight'} - $page->{'nestedSetLeft'} > 1);
$pageData->{"page.isDaughter"} = ($page->{'parentId'} eq $currentPage->get('pageId'));
$pageData->{"page.isMother"} = ($page->{'pageId'} eq $currentPage->get('parentId'));
$pageData->{"page.isAncestor"}
= (($page->{'nestedSetLeft'} < $currentPage->get('nestedSetLeft'))
&& ($page->{'nestedSetRight'} > $currentPage->get('nestedSetRight')));
$pageData->{"page.isDescendent"}
= (($page->{'nestedSetLeft'} > $currentPage->get('nestedSetLeft'))
&& ($page->{'nestedSetRight'} < $currentPage->get('nestedSetRight')));
$pageData->{"page.inRoot"}
= (($page->{'nestedSetLeft'} > $currentRoot->get('nestedSetLeft'))
&& ($page->{'nestedSetRight'} < $currentRoot->get('nestedSetRight')));
# Some information about my mother
my $mother = WebGUI::Page->getPage($page->{parentId});
if ($page->{parentId} ne "0") {
foreach (qw(title urlizedTitle parentId pageId)) {
$pageData->{"page.mother.$_"} = $mother->get($_);
}
$pageData->{"page.isSister"}
= (($mother->get("pageId") eq $currentPage->get("parentId"))
&& !$pageData->{"page.isBasepage"});
}
$pageData->{"page.inBranch"}
= ($pageData->{"page.isAncestor"}
|| $pageData->{"page.isDescendent"}
|| $pageData->{"page.isSister"}
|| $pageData->{"page.isBasepage"});
$pageData->{"page.isLeftMost"} = (($page->{'nestedSetLeft'} - 1) == $mother->get('nestedSetLeft'));
$pageData->{"page.isRightMost"} = (($page->{'nestedSetRight'} + 1) == $mother->get('nestedSetRight'));
my $depthDiff = ($lastPage) ? ($lastPage->{'page.absDepth'} - $pageData->{'page.absDepth'}) : 0;
if ($depthDiff > 0) {
$pageData->{"page.depthDiff"} = $depthDiff if ($depthDiff > 0);
$pageData->{"page.depthDiffIs".$depthDiff} = 1;
push(@{$pageData->{"page.depthDiff_loop"}},{}) for(1..$depthDiff);
}
# Some information about my depth
$pageData->{"page.depthIs".$pageData->{"page.absDepth"}} = 1;
$pageData->{"page.relativeDepthIs".$pageData->{"page.relDepth"}} = 1;
# We need a copy of the last page for the depthDiffLoop
$lastPage = $pageData;
# Store $pageData in page_loop. Mind the order.
if ($self->{_reverse}) {
unshift(@page_loop, $pageData);
} else {
push(@page_loop, $pageData);
}
}
}
# We had a cache miss, so let's put the data in cache
$cache->set(\@page_loop, 3600*24) unless $session{var}{adminOn};
} else {
# We had a cache hit
@page_loop = @{$cacheContent};
}
# Do the user-dependent checks (which cannot be cached globally)
foreach my $pageData (@page_loop) {
$pageData->{"page.isViewable"} = WebGUI::Page::canView($pageData->{'page.pageId'});
# Check privileges
if ($pageData->{"page.isViewable"} || $self->{_showUnprivilegedPages}) {
push (@{$var->{page_loop}}, $pageData);
push (@{$unfolded{$pageData->{"page.parentId"}}}, $pageData);
}
}
foreach (values %unfolded) {
push(@{$var->{unfolded_page_loop}}, @{$_});
}
# Configure button
$var->{'config.button'} = $self->_getEditButton();
# Some properties of the page the user's viewing.
$var->{'basepage.hasDaughter'} = $currentPage->hasDaughter();
$var->{"basepage.isHome"} = ($currentPage->get('pageId') eq '1');
if ($self->{_template}) {
return WebGUI::Template::processRaw($self->{_template}, $var);
} else {
return WebGUI::Template::process($self->{_templateId}, "Navigation", $var);
}
}
sub www_edit {
my $self = shift;
return WebGUI::Privilege::insufficient() unless $self->canEdit;
$self->getAdminConsole->setHelp("navigation add/edit");
return $self->getAdminConsole->render($self->getEditForm->print,WebGUI::International::get("22","Navigation"));
}
#-------------------------------------------------------------------
sub www_preview {
my $self = shift;
$session{var}{adminOn} = 0;
return WebGUI::Privilege::insufficient() unless (WebGUI::Grouping::isInGroup(3));
my $nav = WebGUI::Navigation->new( depth=>$session{form}{depth},
method=>$session{form}{method},
startAt=>$session{form}{startAt},
stopAtLevel=>$session{form}{stopAtLevel},
templateId=>$session{form}{templateId},
showSystemPages=>$session{form}{showSystemPages},
showHiddenPages=>$session{form}{showHiddenPages},
showUnprivilegedPages=>$session{form}{showUnprivilegedPages},
'reverse'=>$session{form}{'reverse'},
);
my $output = qq(
<table width="100%" border="0" cellpadding="5" cellspacing="0">
<tr><td class="tableHeader" valign="top">
Configuration
</td><td class="tableHeader" valign="top">Output</td></tr>
<tr><td class="tableHeader" valign="top">
<font size=1>
Identifier: $session{form}{identifier}<br>
startAt: $session{form}{startAt}<br>
method: $session{form}{method}<br>
stopAtLevel: $session{form}{stopAtLevel}<br>
depth: $session{form}{depth}<br>
templateId: $session{form}{templateId}<br>
reverse: $session{form}{'reverse'}<br>
showSystemPages: $session{form}{showSystemPages}<br>
showHiddenPages: $session{form}{showHiddenPages}<br>
showUnprivilegedPages: $session{form}{showUnprivilegedPages}<br>
</font>
</td><td class="tableData" valign="top">
) . $nav->build . qq(</td></tr></table>);
# Because of the way the system is set up, the preview is cached. So let's remove it again...
WebGUI::Cache->new($nav->{_identifier}."$session{page}{pageId}", "Navigation-".$session{config}{configFile})->delete;
return _submenu($output,"preview");
}
1;

View file

@ -82,7 +82,7 @@ sub getEditForm {
-label=>WebGUI::International::get(1,"SyndicatedContent"),
-value=>$self->getValue("rssUrl")
);
$tabform->getTab("layout")->integer(
$tabform->getTab("display")->integer(
-name=>"maxHeadlines",
-label=>WebGUI::International::get(3,"SyndicatedContent"),
-value=>$self->getValue("maxHeadlines")

View file

@ -161,36 +161,36 @@ sub duplicate {
sub getEditForm {
my $self = shift;
my $tabform = $self->getEditForm;
$tabform->getTab("layout")->template(
$tabform->getTab("display")->template(
-name=>"submissionTemplateId",
-value=>$self->getValue("submissionTemplateId"),
-namespace=>$self->get("namespace")."/Submission",
-label=>WebGUI::International::get(73,$self->get("namespace")),
-afterEdit=>'func=edit&wid='.$self->get("wobjectId")
);
$tabform->getTab("layout")->template(
$tabform->getTab("display")->template(
-name=>"submissionFormTemplateId",
-value=>$self->getValue("submissionFormTemplateId"),
-namespace=>$self->get("namespace")."/SubmissionForm",
-label=>WebGUI::International::get(87,$self->get("namespace")),
-afterEdit=>'func=edit&wid='.$self->get("wobjectId")
);
$tabform->getTab("privileges")->group(
$tabform->getTab("security")->group(
-name=>"groupToApprove",
-label=>WebGUI::International::get(1,$self->get("namespace")),
-value=>[$self->getValue("groupToApprove")]
);
$tabform->getTab("privileges")->group(
$tabform->getTab("security")->group(
-name=>"groupToContribute",
-label=>WebGUI::International::get(2,$self->get("namespace")),
-value=>[$self->getValue("groupToContribute")]
);
$tabform->getTab("layout")->integer(
$tabform->getTab("display")->integer(
-name=>"submissionsPerPage",
-label=>WebGUI::International::get(6,$self->get("namespace")),
-value=>$self->getValue("submissionsPerPage")
);
$tabform->getTab("privileges")->selectList(
$tabform->getTab("security")->selectList(
-name=>"defaultStatus",
-options=>{
Approved=>status('Approved'),
@ -209,10 +209,10 @@ sub getEditForm {
} else {
$tabform->getTab("properties")->hidden("karmaPerSubmission",$self->getValue("karmaPerSubmission"));
}
$tabform->getTab("layout")->filterContent(
$tabform->getTab("display")->filterContent(
-value=>$self->getValue("filterContent")
);
$tabform->getTab("layout")->selectList(
$tabform->getTab("display")->selectList(
-name=>"sortBy",
-value=>[$self->getValue("sortBy")],
-options=>{
@ -223,7 +223,7 @@ sub getEditForm {
},
-label=>WebGUI::International::get(79,$self->get("namespace"))
);
$tabform->getTab("layout")->selectList(
$tabform->getTab("display")->selectList(
-name=>"sortOrder",
-value=>[$self->getValue("sortOrder")],
-options=>{

View file

@ -707,7 +707,7 @@ sub rows {
#-------------------------------------------------------------------
=head2 setRow ( table, key, data [, dbh ] )
=head2 setRow ( table, key, data [, dbh, id ] )
Inserts/updates a row of data into the database. Returns the value of the key.
@ -717,22 +717,26 @@ The name of the table to use.
=head3 key
The name of the primary key of the table.
The name of the primary key of the table.
=head3 data
A hash reference containing column names and values to be set.
A hash reference containing column names and values to be set. If the field matching the key parameter is set to "new" then a new row will be created.
=head3 dbh
A database handler to use. Defaults to the WebGUI database handler.
=head3 id
Use this ID to create a new row. Same as setting the key value to "new" except that we'll use this passed in id instead.
=cut
sub setRow {
my ($self, $table, $keyColumn, $data, $dbh) = @_;
if ($data->{$keyColumn} eq "new") {
$data->{$keyColumn} = WebGUI::Id::generate();
my ($self, $table, $keyColumn, $data, $dbh, $id) = @_;
if ($data->{$keyColumn} eq "new" || $id) {
$data->{$keyColumn} = $id || WebGUI::Id::generate();
WebGUI::SQL->write("insert into $table ($keyColumn) values (".quote($data->{$keyColumn}).")", $dbh);
}
my (@pairs);

View file

@ -1,187 +1,36 @@
package WebGUI::i18n::English::Navigation;
our $I18N = {
'add new' => {
message => q|Add new navigation.|,
lastUpdated => 1101774172,
context => q|A submenu item in admin console that allows the user to add a new navigation config.|
},
'33' => {
message => q|Error: This identifier is already in use. Please use an unique value.|,
lastUpdated => 1077081255
},
'32' => {
message => q|Show unprivileged pages|,
lastUpdated => 1077080845
},
'21' => {
message => q|List all Navigation.|,
lastUpdated => 1077080151
},
'7' => {
message => q|my daughter's level (./page)|,
lastUpdated => 1077078687
},
'26' => {
message => q|Stop traversing when reaching level|,
lastUpdated => 1077080617
},
'2' => {
message => q|root level (/home)|,
lastUpdated => 1077078325
},
'17' => {
message => q|pedigree|,
lastUpdated => 1077079481
},
'1' => {
message => q|nameless root|,
lastUpdated => 1077078206
},
'18' => {
message => q|Edit this Navigation.|,
lastUpdated => 1077079911
},
'30' => {
message => q|Show system pages|,
lastUpdated => 1077080766
},
'16' => {
message => q|self and ancestors|,
lastUpdated => 1077079343
},
'27' => {
message => q|Max depth|,
lastUpdated => 1077080669
},
'25' => {
message => q|Base page|,
lastUpdated => 1077080583
},
'28' => {
message => q|Return a loop with|,
lastUpdated => 1077080706
},
'14' => {
message => q|generation|,
lastUpdated => 1077079203
},
'20' => {
message => q|Delete this Navigation.|,
lastUpdated => 1077080098
},
'24' => {
message => q|Identifier|,
lastUpdated => 1077080504
},
'10' => {
message => q|self and sisters|,
lastUpdated => 1077078879
},
'31' => {
message => q|Show hidden pages|,
lastUpdated => 1077080799
},
'35' => {
message => q|<font color="red">Please specify an identifier. ie: ^Navigation(myMenu);</font>|,
lastUpdated => 1077081415
},
'11' => {
message => q|descendants|,
lastUpdated => 1077078969
},
'22' => {
message=> q|Edit Navigation|,
lastUpdated => 1077078969
},
'13' => {
message => q|childless descendants|,
lastUpdated => 1077079109
},
'23' => {
message => q|Navigation properties|,
lastUpdated => 1077080317
},
'29' => {
message => q|Reverse output|,
lastUpdated => 1100587628
},
'6' => {
message => q|my level (.)|,
lastUpdated => 1077078579
},
'3' => {
message => q|top level (/home/page)|,
lastUpdated => 1077078394
},
'9' => {
message => q|sisters|,
lastUpdated => 1077078821
},
'12' => {
message => q|self and descendants|,
lastUpdated => 1077079020
},
'15' => {
message => q|ancestors|,
lastUpdated => 1077079273
},
'8' => {
message => q|daughters|,
lastUpdated => 1077078773
},
'4' => {
message => q|my grandmother's level (../../page)|,
lastUpdated => 1077078456
},
'preview' => {
message => q|Preview Navigation|,
lastUpdated => 1077078456
},
'19' => {
message => q|Copy this Navigation.|,
lastUpdated => 1077080062
},
'5' => {
message => q|my mother's level (../page)|,
lastUpdated => 1077078526
},
'navigation' => {
message => q|Navigation|,
lastUpdated => 1077078526,

View file

@ -1347,7 +1347,7 @@ How should this user be notified when they get a new WebGUI message?
},
'107' => {
message => q|Privileges|,
message => q|Security|,
lastUpdated => 1031514049
},
@ -2061,8 +2061,8 @@ The title of the page is what your users will use to navigate through the site.
A shorter or altered title to appear in navigation. If left blank this will default to <i>Title</i>.
<p>
<b>Page URL</b><br>
You may either specify a URL for the page, or if you leave this blank, a URL based on the <b>Title</b> will be generated.
<b>URL</b><br>
You may either specify a URL for the asset, or if you leave this blank, a URL based on the <b>Title</b> will be generated.
<p>
<b>Redirect URL</b><br>
@ -2082,7 +2082,7 @@ Select yes to hide this page from the navigation menus and site maps.
Select yes to open this page in a new window. This is often used in conjunction with the <b>Redirect URL</b> parameter.
<p>
<b>Encrypt page?</b><br>
<b>Encrypt content?</b><br>
Select yes to serve this page over SSL.
<p>
@ -2123,9 +2123,6 @@ If you don't wish to specify meta tags yourself, WebGUI can generate meta tags b
By default, when you create a page, it inherits a few traits from its parent. One of those traits is style. Choose from the list of styles if you would like to change the appearance of this page. See <i>Add Style</i> for more details.
<p>
If you select "Yes" below the style pull-down menu, all of the pages below this page will take on the style you've chosen for this page.
<p>
<b>Printable Style</b><br>
This sets the printable style for this page to be something other than the WebGUI Default Printable Style.
<p>
@ -3935,8 +3932,9 @@ Large sites using external group data will be making many calls to the external
},
'104' => {
message => q|Page URL|,
lastUpdated => 1031514049
message => q|URL|,
lastUpdated => 1031514049,
context => q|asset property|
},
'412' => {
@ -5395,11 +5393,6 @@ Start typing! Or better yet, copy the snippet from some other electronic documen
lastUpdated => 1060433369
},
'106' => {
message => q|Select "Yes" to change all the pages under this page to this style.|,
lastUpdated => 1031514049
},
'707' => {
message => q|Show debugging?|,
lastUpdated => 1031514049
@ -6353,7 +6346,7 @@ What group should be alerted when a new user registers?
},
'105' => {
message => q|Layout|,
message => q|Display|,
lastUpdated => 1046638916
},
@ -6614,9 +6607,9 @@ config file.</p>
context => q|option for Rich Editor in profile|
},
'encrypt page' => {
message => q|Encrypt page?|,
message => q|Encrypt content?|,
lastUpdated =>1092748557,
context => q|page property|
context => q|asset property|
},
'Forum, Post Preview Template Title' => {
message => q|Forum Post Preview Template|,

View file

@ -1,6 +1,7 @@
//--------Constructor--------------------
//Creates a new asset object.
function Asset() {
//properties
this.url = "";
@ -65,19 +66,5 @@ function Asset_view() {
location.href = "http://" + manager.tools.getHostName(location.href) + this.url;
}
//function Asset_displayProperties() {
// html = "<table border='0'><tr><td class=\"propertiesMenuName\">Title:</td><td class=\"propertiesMenuValue\">" + this.title + "</td></tr>";
// html+="<tr><td class=\"propertiesMenuName\">Rank:</td><td class=\"propertiesMenuValue\">" + this.rank + "</td></tr>"
// html+="<tr><td class=\"propertiesMenuName\">Asset ID:</td><td class=\"propertiesMenuValue\">" + this.assetId + "</td></tr>"
// html+="<tr><td class=\"propertiesMenuName\">Asset Type:</td><td class=\"propertiesMenuValue\">" + this.type + "</td></tr>"
// html+="<tr><td class=\"propertiesMenuName\">Size:</td><td class=\"propertiesMenuValue\">" + this.size + "</td></tr>"
// html+="<tr><td class=\"propertiesMenuName\">Last Updated:</td><td class=\"propertiesMenuValue\">" + this.lastUpdate + "</td></tr>"
// html+="</table>";
// manager.display.displayPropertiesWindow(html);
//}

View file

@ -1,12 +1,15 @@
//--------Constructor--------------------
//Manages an array of assets.
function AssetManager(assetArrayData,headerArrayData,labels,crumbtrail) {
//create all the objects used by the manager
this.tools = new Tools();
this.contextMenu = new ContextMenu();
this.display = new Display();
this.eventManager = new EventManager();
this.keys = new Array();
this.keys[0] = "rank";
this.keys[1] = "title";
@ -34,31 +37,30 @@ function AssetManager(assetArrayData,headerArrayData,labels,crumbtrail) {
this.getSelectedAssetIds = AssetManager_getSelectedAssetIds;
}
//returns a reference to the asset manager
function AssetManager_getManager() {
//debug(manager.assetArrayData);
return manager;
}
//renders the full asset manager
function AssetManager_renderAssets() {
var gridStr = '<table border="0" cellspacing="0" id="am_grid" class="am-grid"><tbody id="am_grid_body"><tr id="am_grid.headers" class="am-grid-headers">';
var eventStr='';
var id = "";
for (i=0;i<this.columnHeadings.length;i++) {
id = 'am_grid.headers.' + i;
id = 'am_grid.headers.' + i;
gridStr+= '<td id="' + id + '" class="am-grid-header-' + i + '">' + this.columnHeadings[i] + '</td>';
eventStr += 'document.getElementById("' + id + '").onclick=AssetManager_getManager().eventManager.gridHeaderClick;';
eventStr += 'document.getElementById("' + id + '").onmouseover=AssetManager_getManager().eventManager.gridHeaderMouseOver;';
eventStr += 'document.getElementById("' + id + '").onmouseout=AssetManager_getManager().eventManager.gridHeaderMouseOut;';
}
gridStr+= '</tr>';
//['Rank','Title','Type','Last Updated','Size'];
for (i=0;i<this.assetArrayData.length;i++) {
id = 'am_grid.row.'+ i;
gridStr += '<tr id="'+ id + '" class="am-grid-row">';
/* rank, title, type, lastUpdate, size, url, assetId */
asset = new Asset();
asset.rank = this.assetArrayData[i][0];
@ -72,9 +74,6 @@ function AssetManager_renderAssets() {
this.assets[i]=asset;
//add the row events
// eventStr += 'document.getElementById("' + id + '").onclick=Grid_rowClicked;';
// eventStr += 'document.getElementById("' + id + '").onmouseover=Grid_rowMouseOver;';
// eventStr += 'document.getElementById("' + id + '").onmouseout=Grid_rowMouseOut;';
eventStr += 'document.getElementById("' + id + '").ondblclick=AssetManager_getManager().eventManager.assetDoubleClick;';
eventStr += 'document.getElementById("' + id + '").onmousedown=AssetManager_getManager().eventManager.assetMouseDown;';
eventStr += 'document.getElementById("' + id + '").oncontextmenu=AssetManager_getManager().eventManager.assetRightClick;';
@ -90,7 +89,6 @@ function AssetManager_renderAssets() {
gridStr +='<img src="' + asset.icon + '" border="0"/>';
}
gridStr+=this.assetArrayData[i][k] + '</td>';
// eventStr += 'document.getElementById("' + id + '").asset = AssetManager_getManager().assets[' + i + '];';
}
}
gridStr+='</tr>';
@ -100,11 +98,11 @@ function AssetManager_renderAssets() {
document.getElementById("workspace").innerHTML=gridStr;
eval(eventStr);
this.buildCrumbTrail();
}
this.buildCrumbTrail();
}
//builds the asset crumb trail
function AssetManager_buildCrumbTrail() {
var crumbtrail = document.getElementById("crumbtrail");
var contents = '<table><tr>';
@ -130,8 +128,6 @@ function AssetManager_buildCrumbTrail() {
asset.title = this.crumbtrail[i][2];
asset.url = this.crumbtrail[i][1];
asset.assetId = this.crumbtrail[i][0];
asset.div = document.getElementById(this.crumbtrail[i][0]);
asset.div.ondblclick=AssetManager_getManager().eventManager.assetDoubleClick;
@ -140,25 +136,21 @@ function AssetManager_buildCrumbTrail() {
asset.isParent = true;
document.getElementById(this.crumbtrail[i][0]).asset = asset;
this.assets[this.assets.length] = asset;
}
this.assets[this.assets.length] = asset;
}
}
function AssetManager_getAsset(obj) {
//returns an asset based on a div object
function AssetManager_getAsset(obj) {
while (obj.tagName!=this.display.topLevelElement && !obj.asset) {
obj=this.display.dom? obj.parentNode : obj.parentElement
}
}
return obj.asset;
}
//displays the right click context menu
function AssetManager_displayContextMenu(x,y,asset) {
var arr = new Array();
var arr = new Array();
if (this.display.overObjects.length == 1) {
arr[arr.length] = new ContextMenuItem(this.labels["go"],"javascript:manager.display.contextMenu.owner.go()");
arr[arr.length] = new ContextMenuItem("<img src='/extras/assetManager/breakerLine.gif'>","");
@ -212,6 +204,7 @@ function AssetManager_remove() {
}
}
//returns the asset IDS of all selected assets
function AssetManager_getSelectedAssetIds() {
var assetIds = "";
for (i=0;i<this.display.overObjects.length;i++) {
@ -220,6 +213,7 @@ function AssetManager_getSelectedAssetIds() {
return assetIds;
}
//Sorts the asset grid based on a column index
function AssetManager_sortGrid(columnIndex) {
var prop = this.keys[columnIndex];
@ -247,8 +241,7 @@ function AssetManager_sortGrid(columnIndex) {
}else {
colHeader.sortOrder=">";
document.getElementById('am_grid.headers.' + columnIndex).innerHTML = this.columnHeadings[columnIndex] + ' <img src="/extras/assetManager/down.gif" />';
}
}
var rowArray = new Array();

View file

@ -1,30 +1,19 @@
//--------Constructor--------------------
//creates a new Display object. The display object manages selected assets, the drag functionality, and highlighting.
function Display() {
this.dom=document.getElementById&&!document.all;
this.baseX=0;
this.baseY=0;
this.width=0;
this.height=0;
this.rootNode="";
this.packageNS = "";
this.focusObjects = new Array();
this.overObjects = new Array();
this.overCrumbtrail = null;
this.topLevelElement=this.dom? "HTML" : "BODY"
this.scrollJump = 25;
this.dragEnabled = false;
this.displayPropertiesWindow = Display_displayPropertiesWindow;
this.hidePropertiesWindow = Display_hidePropertiesWindow;
this.dragStart = Display_dragStart;
this.adjustScrollBars = Display_adjustScrollBars;
this.dragStop = Display_dragStop;
this.activityLists = new Array();
this.spy = Display_spy;
this.currentTemp=null;
this.temp1 = 0;
this.temp2=0;
this.move = Display_move;
this.x = 0;
this.y = 0;
@ -33,8 +22,6 @@ function Display() {
this.contextMenu=new ContextMenu();
this.bringToFront = Display_bringToFront;
this.lastZIndex = 1000;
this.dragableObjectClasses = new Array();
this.registerDragableClass = Display_registerDragableClass;
this.keyDown = Display_keyDown;
this.keyUp = Display_keyUp;
this.selectAsset = Display_selectAsset;
@ -44,115 +31,59 @@ function Display() {
//---------Method Implementations -------------
function Display_registerDragableClass(objectClassName,classNameDuringDrag) {
var obj = new Object();
obj.clazzName = objectClassName;
obj.clazzNameDuringDrag = classNameDuringDrag;
this.dragableObjectClasses[this.dragableObjectClasses.length] = obj;
}
//changes the z index of obj to be greater than all other elements
function Display_bringToFront(obj) {
this.lastZIndex++;
obj.style.zIndex = this.lastZIndex;
}
function Display_hidePropertiesWindow() {
manager.tools.hideObject(document.getElementById("propertiesWindow"));
}
function Display_displayPropertiesWindow(html) {
temp = "<table border='1' cellspacing='0'><tr><td><table border='0'><tr bgcolor='#000000'><td width='325' class='dragable'><font color='#FFFFFF'>" + manager.labels['properties'] + "</font></td><td align='right'><a href='javascript:manager.display.hidePropertiesWindow()'>X</a></td></tr><tr><td colspan='2'>" + html + "</td></tr></table></td></tr></table>";
propWindow = document.getElementById("propertiesWindow");
propWindow.innerHTML=temp;
propWindow.style.top=50 + document.body.scrollTop;
propWindow.style.left=50 + document.body.scrollLeft;
manager.tools.showObject(propWindow);
this.bringToFront(propWindow);
}
//called to enable dragging on an element
function Display_dragStart(firedobj,xCoordinate,yCoordinate) {
if (!firedobj) return;
if (this.shiftKeyDown) return;
while (firedobj.tagName!=this.topLevelElement && !firedobj.asset && firedobj.className != "dragable") {
if (this.shiftKeyDown || this.controlKeyDown) return;
//traverse up the dom tree until you find the asset
while (firedobj.tagName!=this.topLevelElement && !firedobj.asset) {
firedobj=manager.display.dom? firedobj.parentNode : firedobj.parentElement
}
if ((!firedobj.asset || firedobj.asset.isParent) && firedobj.className != "dragable") {
if ((!firedobj.asset || firedobj.asset.isParent)) {
return;
}
this.dragEnabled=true;
// while (firedobj.tagName!=this.topLevelElement) {
// for (i =0;i<this.dragableObjectClasses.length;i++) {
// if (firedobj.className==this.dragableObjectClasses[i].clazzName) {
this.pageHeight = window.document.body.scrollHeight;
this.pageWidth = window.document.body.scrollWidth;
this.pageHeight = document.documentElement.scrollHeight;
this.pageWidth = document.documentElement.scrollWidth;
if (firedobj.asset) {
this.focusObjects[0]=firedobj.asset;
}else {
this.focusObjects[0] = firedobj;
}
this.focusObjects[0]=firedobj.asset;
//this.bringToFront(this.focusObject);
//hack to get the transparency - need to make generic
// this.focusObject.dragDescriptor = this.dragableObjectClasses[i];
// this.focusObject.className=this.dragableObjectClasses[i].clazzNameDuringDrag;
if (firedobj.asset) {
this.bringToFront(document.getElementById("dragImage"));
document.getElementById("dragImage").innerHTML = "&nbsp;&nbsp;" + firedobj.asset.title + "&nbsp;&nbsp;";
}else {
this.temp1=parseInt(this.focusObjects[0].style.left+0)
this.temp2=parseInt(this.focusObjects[0].style.top+0)
}
this.x=xCoordinate;
this.y=yCoordinate;
return false;
// }
// }
// firedobj=display.dom? firedobj.parentNode : firedobj.parentElement
// }
//return false;
this.bringToFront(document.getElementById("dragImage"));
document.getElementById("dragImage").innerHTML = "&nbsp;&nbsp;" + firedobj.asset.title + "&nbsp;&nbsp;";
this.x=xCoordinate;
this.y=yCoordinate;
return false;
}
//called on mouse up if dragging was enabled
function Display_dragStop() {
if (this.dragEnabled) {
this.dragEnabled = false;
document.getElementById("dragImage").style.display="none";
//if (this.focusObjects.dragDescriptor.clazzName == "activityMenuItem") {
if (this.overObjects[0] && this.overObjects[0].assetId && this.overObjects[0] != this.focusObjects[0]) {
if (this.overObjects[0].isParent) {
this.focusObjects[0].setParent(this.overObjects[0]);
}else {
this.focusObjects[0].setRank(this.overObjects[0].rank);
}
}
//this.focusObject.style.top=0;
//this.focusObject.style.left=0;
}
//this.focusObject.className = this.focusObject.dragDescriptor.clazzName;
//}
if (this.overObjects[0] && this.overObjects[0].assetId && this.overObjects[0] != this.focusObjects[0]) {
if (this.overObjects[0].isParent) {
this.focusObjects[0].setParent(this.overObjects[0]);
}else {
this.focusObjects[0].setRank(this.overObjects[0].rank);
}
}
}
}
//checks to see if an asset is already in the overObjects array
function Display_isSelected(asset) {
//check to see if obj is already in array
var inArray=false;
@ -164,67 +95,69 @@ function Display_isSelected(asset) {
return false;
}
//adds an asset to the overobjects array
function Display_selectAsset(asset) {
// debug(this.overObjects.length);
if (!this.controlKeyDown && !this.shiftKeyDown) {
for (i=0;i<this.overObjects.length;i++) {
this.overObjects[i].div.className="am-grid-row";
if (asset.isParent) {
this.overObjects[i].div.className="am-crumbtrail";
}else {
this.overObjects[i].div.className="am-grid-row";
}
}
this.overObjects=new Array();
}
if (!this.isSelected(asset)) {
this.overObjects[this.overObjects.length] = asset;
asset.div.className="am-grid-row-over";
if (asset.isParent) {
asset.div.className="am-crumbtrail-over";
}else {
asset.div.className="am-grid-row-over";
}
}
}
//Clears out the over objects array
function Display_clearSelectedAssets() {
for (i=0;i<this.overObjects.length;i++) {
this.overObjects[i].div.style.backgroundColor="white";
if (this.overObjects[i].isParent) {
this.overObjects[i].div.className="am-crumbtrail";
}else {
this.overObjects[i].div.className="am-grid-row";
}
}
this.overObjects=new Array();
}
//called on mouse move. checks to see if mouse cursor is over an asset when dragging
function Display_move(e){
if (this.dragEnabled){
if (this.dragEnabled){
this.adjustScrollBars(e);
if (this.focusObjects[0].className=="dragable") {
this.focusObjects[0].style.left=this.dom? this.temp1+e.clientX-this.x: this.temp1+event.clientX-this.x
this.focusObjects[0].style.top=this.dom? this.temp2+e.clientY-this.y : this.temp2+event.clientY-this.y
}else {
var act = this.spy(this.dom? e.pageX: (e.clientX + document.body.scrollLeft),this.dom? e.pageY: (e.clientY + document.body.scrollTop));
var topScroll = document.documentElement.scrollTop;
var leftScroll =document.documentElement.scrollLeft;
var act = this.spy(this.dom? e.pageX: (e.clientX + document.documentElement.scrollLeft),this.dom? e.pageY: (e.clientY + document.documentElement.scrollTop));
if (act && act.asset) {
this.selectAsset(act.asset);
}else {
this.clearSelectedAssets();
}
if (act && act.asset) {
this.selectAsset(act.asset);
}else {
this.clearSelectedAssets();
}
if (this.overObjects[0] != this.focusObjects[0]) {
//var act = this.spy(this.dom? e.pageX: (e.clientX + document.body.scrollLeft),this.dom? e.pageY: (e.clientY + document.body.scrollTop));
var act = this.spy(this.dom? e.pageX: (e.clientX + window.scrollX),this.dom? e.pageY: (e.clientY + window.scrollY));
document.getElementById("dragImage").style.display = "block";
// document.getElementById("dragImage").style.top = this.dom? (e.clientY+ 15 + document.body.scrollTop) + "px" : (event.clientY + 15) + "px";
document.getElementById("dragImage").style.top = this.dom? (e.clientY+ 15 + window.scrollY) + "px" : (event.clientY + 15) + "px";
// debug(document.body.scrollTop);
//debug(window.scrollY);
//document.getElementById("dragImage").style.left = this.dom? (e.clientX + 5 + document.body.scrollTop) + "px" : (event.clientX + 5) + "px";
document.getElementById("dragImage").style.left = this.dom? (e.clientX + 5 + window.scrollX) + "px" : (event.clientX + 5) + "px";
}
}
return false
//change the position of the drag icon box
document.getElementById("dragImage").style.display = "block";
document.getElementById("dragImage").style.top = this.dom? (e.clientY+ 15 + topScroll) + "px" : (event.clientY + 15 + topScroll) + "px";
document.getElementById("dragImage").style.left = this.dom? (e.clientX + 5 + leftScroll) + "px" : (event.clientX + 5 + leftScroll) + "px";
}
return false
}
//check to see if the mouse cursor is over and asset. If so, returns the asset
function Display_spy(x,y) {
var returnObj = null;
@ -244,22 +177,19 @@ function Display_spy(x,y) {
x1+=fObj.offsetLeft;
fObj=fObj.offsetParent;
}
if (x >x1 && x < (x1 + obj.offsetWidth)) {
if (y> y1 && y< (y1 + obj.offsetHeight)) {
//for (j=0;j<obj.bpm.children.length;j++) {
// if (y>(y1 + obj.bpm.children[j].offsetTop) && y < (y1 + obj.bpm.children[j].offsetTop + obj.bpm.children[j].offsetHeight)) {
return obj;
// }
//}
//add 13 pixels for ie since border widths are included in calculation
var fudge = this.dom? 0:13;
if (y> y1 && y< (y1 + obj.offsetHeight + fudge)) {
return obj;
}
}
}
}
return returnObj;
}
//called on keyDown. Does the right thing (ex. delete, cut, copy, ect)
function Display_keyDown(e) {
if (e.keyCode==16) {
this.shiftKeyDown = true;
@ -270,6 +200,7 @@ function Display_keyDown(e) {
}
}
//called on keyUp. Does the right thing (ex. delete, cut, copy, ect)
function Display_keyUp(e) {
if (e.keyCode==16) {
this.shiftKeyDown = false;
@ -278,42 +209,46 @@ function Display_keyUp(e) {
}
}
//checks to see if the scroll bars need to be adjusted
//checks to see if the scroll bars need to be adjusted. Called durring dragging
function Display_adjustScrollBars(e) {
var scrY=0;
var scrX=0;
if (e.clientY > document.body.clientHeight-this.scrollJump) {
if (e.clientY + document.body.scrollTop < this.pageHeight - (this.scrollJump + 40)) {
var topScroll = document.documentElement.scrollTop;
var leftScroll = document.documentElement.scrollLeft;
var innerHeight = document.documentElement.clientHeight;
var innerWidth = document.documentElement.clientWidth;
if (e.clientY > innerHeight-this.scrollJump) {
if (e.clientY + topScroll < this.pageHeight - (this.scrollJump + 40)) {
scrY=this.scrollJump;
window.scroll(document.body.scrollLeft,document.body.scrollTop + scrY);
window.scroll(leftScroll,topScroll + scrY);
this.y-=scrY;
}
}else if (e.clientY < this.scrollJump) {
if (document.body.scrollTop < this.scrollJump) {
scrY = document.body.scrollTop;
if (topScroll < this.scrollJump) {
scrY = topScroll;
}else {
scrY=this.scrollJump;
}
window.scroll(document.body.scrollLeft,document.body.scrollTop - scrY);
window.scroll(leftScroll,topScroll - scrY);
this.y+=scrY;
}
if (e.clientX > document.body.clientWidth-this.scrollJump) {
if (e.clientX + document.body.scrollLeft < this.pageWidth - (this.scrollJump + 40)) {
if (e.clientX > innerWidth-this.scrollJump) {
if (e.clientX + leftScroll < this.pageWidth - (this.scrollJump + 40)) {
scrX=this.scrollJump;
window.scroll(document.body.scrollLeft + scrX,document.body.scrollTop);
window.scroll(leftScroll + scrX,topScroll);
this.x-=scrX;
}
}else if (e.clientX < this.scrollJump) {
if (document.body.scrollLeft < this.scrollJump) {
scrX = document.body.scrollLeft;
if (leftScroll < this.scrollJump) {
scrX = leftScroll;
}else {
scrX=this.scrollJump;
}
window.scroll(document.body.scrollLeft - scrX,document.body.scrollTop);
window.scroll(leftScroll - scrX,topScroll);
this.x+=scrX;
}
}

View file

@ -11,6 +11,8 @@ function EventManager() {
document.onkeyup=EventManager_keyUp;
this.gridHeaderClick = EventManager_gridHeaderClick;
this.gridHeaderMouseOver = EventManager_gridHeaderMouseOver;
this.gridHeaderMouseOut = EventManager_gridHeaderMouseOut;
this.assetDoubleClick = EventManager_assetDoubleClick;
this.assetRightClick = EventManager_assetRightClick;
this.assetMouseDown = EventManager_assetMouseDown;
@ -19,6 +21,28 @@ function EventManager() {
//---------Method Implementations -------------
function EventManager_gridHeaderMouseOver(e) {
var dom = document.getElementById&&!document.all;
e=dom? e : event;
if (!manager.display.dragEnabled) {
var obj =dom? e.target : e.srcElement
var parts = obj.className.split("-");
obj.className="am-grid-header-over-" + parts[parts.length -1];
}
}
function EventManager_gridHeaderMouseOut(e) {
var dom = document.getElementById&&!document.all;
e=dom? e : event;
var obj =dom? e.target : e.srcElement
var parts = obj.className.split("-");
obj.className="am-grid-header-" + parts[parts.length -1];
}
function EventManager_keyDown(e) {
var dom = document.getElementById&&!document.all;
e=dom? e : event;
@ -64,6 +88,8 @@ function EventManager_assetMouseDown(e) {
var dom = document.getElementById&&!document.all;
e=dom? e : event;
Display_adjustScrollBars(e);
if (e.button==2) {
//this is a hack to get the context menu stuff to work right in IE
if (!dom) {
@ -91,6 +117,8 @@ function EventManager_documentMouseDown(e) {
manager.display.dragStart(asset.div,e.clientX,e.clientY);
return;
}
}else {
manager.display.clearSelectedAssets();
}
if (e.button != 2) {
@ -116,8 +144,6 @@ function EventManager_documentMouseUp(e) {
}
manager.display.dragStop();
//if (obj) manager.display.selectActivity(obj);
return false;
}
@ -133,7 +159,6 @@ function EventManager_gridHeaderClick(e) {
var e=dom? e : event;
var obj =dom? e.target : e.srcElement
var parts = obj.id.split(".");
var parts = obj.id.split(".");
AssetManager_getManager().sortGrid(parts[parts.length-1]);
}

View file

@ -4,7 +4,6 @@
function Tools() {
this.dom=document.getElementById&&!document.all;
this.topLevelElement=this.dom? "HTML" : "BODY"
this.getActivity = Tools_getActivity;
this.debug = Tools_debug;
this.debugEnabled = false;
this.getElementChildren = Tools_getElementChildren;
@ -52,11 +51,6 @@ function Tools_cancelEvent() {
return false;
}
//recurses up a tree to get any activity of className activity
function Tools_getActivity(obj) {
var parts = obj.id.split(".");
return manager.assets[parts[0] + "." + parts[1] + "." + parts[2]];
}
//shows a positionable element by toggling the style display property
function Tools_showObject(obj) {

View file

@ -1,7 +1,3 @@
#crumbtrail{
color: #3E697E;
font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, Arial, sans-serif;
}
.am-grid {
height: 100%;
font: menu;
@ -25,7 +21,7 @@
.am-grid-header-0 img{
padding: 0 3px 0 3px;
}
.am-grid-header-0 .over{
.am-grid-header-over-0{
width: 10px;
background-color: #F2F3F4;
border-left: 1px solid #fff;
@ -47,6 +43,15 @@
padding: 0 3px 0 3px;
}
.am-grid-header-over-1{
width: 200px;
background-color: #F2F3F4;
border-left: 1px solid #fff;
border-right: 1px solid #7F949F;
border-bottom: 2px solid #EA5600;
padding: 0 0 0 10px;
}
.am-grid-header-2 {
width: 50px;
background-color: #F2F3F4;
@ -59,6 +64,15 @@
padding: 0 3px 0 3px;
}
.am-grid-header-over-2{
width: 50px;
background-color: #F2F3F4;
border-left: 1px solid #fff;
border-right: 1px solid #7F949F;
border-bottom: 2px solid #EA5600;
padding: 0 0 0 10px;
}
.am-grid-header-3 {
width: 150px;
background-color: #F2F3F4;
@ -71,6 +85,15 @@
padding: 0 3px 0 3px;
}
.am-grid-header-over-3{
width: 150px;
background-color: #F2F3F4;
border-left: 1px solid #fff;
border-right: 1px solid #7F949F;
border-bottom: 2px solid #EA5600;
padding: 0 0 0 10px;
}
.am-grid-header-4 {
width: 50px;
background-color: #F2F3F4;
@ -83,6 +106,17 @@
.am-grid-header-4 img{
padding: 0 3px 0 3px;
}
.am-grid-header-over-4{
width: 50px;
background-color: #F2F3F4;
border-left: 1px solid #fff;
border-right: 1px solid #7F949F;
border-bottom: 2px solid #EA5600;
padding: 0 10px 0 0;
text-align: right;
}
.am-grid-row {
color: #000;
}
@ -124,13 +158,16 @@
.am-crumbtrail {
font-size: 12px;
color: #3E697E;
font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, Arial, sans-serif;
cursor: pointer;
}
.am-crumbtrail-header {
font-size: 12px;
font-weight: 700;
.am-crumbtrail-over {
color: #3E697E;
font-family: "Lucida Grande", "Lucida Sans Unicode", Tahoma, Verdana, Arial, sans-serif;
cursor: pointer;
text-decoration: underline;
}
.contextMenu{