diff --git a/docs/changelog/6.x.x.txt b/docs/changelog/6.x.x.txt index 392cbdd5e..722dc9708 100644 --- a/docs/changelog/6.x.x.txt +++ b/docs/changelog/6.x.x.txt @@ -1,9 +1,16 @@ 6.3.0 + - Migrated all wobjects to assets. + - Migrated pages to the layout and redirect assets. + - Converted site maps to navigation macros. + - Converted file managers to layout assets with file and image assets + attached. + - Converted page templates to use CSS-based layouts instead of tables. - Added a "Position" property to the DataForm Edit Field interface. This makes it easier to move a field to a certain position. (Len Kranendonk). - Added the variables "record.edit.icon", "record.delete.url" and "record.delete.icon" to the DataForm DataList template. (Len Kranendonk). - Converted all confirmation pages to client-side confirmation dialogs. Saves a pageload. (Len Kranendonk). - - Added a new, more user-friendly administrative console. + - Added a new, more user-friendly administrative console complete with over + 40 new icons developed specifically for WebGUI. - SQL Report now supports multiple queries. (Thanks to Brunswick New Technologies for funding this development.) - Removed the old rich editors and replaced them with Tiny MCE. diff --git a/docs/gotcha.txt b/docs/gotcha.txt index 82582a2f5..29c580228 100644 --- a/docs/gotcha.txt +++ b/docs/gotcha.txt @@ -38,6 +38,12 @@ save you many hours of grief. operates, or else the scheduler plugin ProcessRecurringPayments will fail with a cert error. + * If you have any custom page templates, they'll need to be updated + to work with the new Layout system. The templates have been + changed significantly enough that automatic migration of them is + not possible. + + 6.2.8 -------------------------------------------------------------------- * Due to a bug in the theme system, if you created any themes in any diff --git a/docs/upgrades/upgrade_6.2.9-6.3.0.pl b/docs/upgrades/upgrade_6.2.9-6.3.0.pl index 5f09de630..dd71310dc 100644 --- a/docs/upgrades/upgrade_6.2.9-6.3.0.pl +++ b/docs/upgrades/upgrade_6.2.9-6.3.0.pl @@ -50,10 +50,24 @@ $sth->finish; WebGUI::SQL->write("delete from settings where name in ('siteicon','favicon')"); +print "\tMigrating wobject templates to asset templates.\n" unless ($quiet); +my $sth = WebGUI::SQL->read("select templateId, template, namespace from template where namespace in ('Article', + 'USS', 'SyndicatedContent', 'MessageBoard', 'DataForm', 'EventsCalendar', 'HttpProxy', 'Poll', 'WobjectProxy', + 'IndexedSearch', 'SQLReport', 'Survey', 'WSClient')"); +while (my $t = $sth->hashRef) { + $t->{template} = ' + +

+
+ '.$t->{template}; + WebGUI::SQL->write("update template set template=".quote($t->{template})." where templateId=".quote($t->{templateId})." and namespace=".quote($t->{namespace})); +} +$sth->finish; + # this is here because we don't want to actually migrate stuff yet @@ -64,6 +78,8 @@ print "\t\tMaking first round of table structure changes\n" unless ($quiet); WebGUI::SQL->write("alter table wobject add column assetId varchar(22) not null"); WebGUI::SQL->write("alter table wobject add styleTemplateId varchar(22) not null"); WebGUI::SQL->write("alter table wobject add printableStyleTemplateId varchar(22) not null"); +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"); my $sth = WebGUI::SQL->read("select distinct(namespace) from wobject"); while (my ($namespace) = $sth->array) { @@ -130,24 +146,33 @@ sub walkTree { while (my $page = $a->hashRef) { print "\t\tConverting page ".$page->{pageId}."\n" unless ($quiet); my $pageId = WebGUI::Id::generate(); + if ($page->{pageId} eq $session{setting}{defaultPage}) { + WebGUI::SQL->write("update settings set value=".quote($pageId)." where name='defaultPage'"); + } + if ($page->{pageId} eq $session{setting}{notFoundPage}) { + WebGUI::SQL->write("update settings set value=".quote($pageId)." where name='notFoundPage'"); + } my $pageLineage = $parentLineage.sprintf("%06d",$myRank); my $pageUrl = fixUrl($pageId,$page->{urlizedTitle}); - my $className = 'WebGUI::Asset::Layout'; + my $className = 'WebGUI::Asset::Wobject::Layout'; if ($page->{redirectURL} ne "") { $className = 'WebGUI::Asset::Redirect'; } WebGUI::SQL->write("insert into asset (assetId, parentId, lineage, className, state, title, menuTitle, url, startDate, - endDate, synopsis, newWindow, isHidden, ownerUserId, groupIdView, groupIdEdit, encryptPage ) values (".quote($pageId).", + endDate, synopsis, newWindow, isHidden, ownerUserId, groupIdView, groupIdEdit, encryptPage, assetSize ) values (".quote($pageId).", ".quote($newParentId).", ".quote($pageLineage).", ".quote($className).",'published',".quote($page->{title}).", ".quote($page->{menuTitle}).", ".quote($pageUrl).", ".quote($page->{startDate}).", ".quote($page->{endDate}).", ".quote($page->{synopsis}).", ".quote($page->{newWindow}).", ".quote($page->{hideFromNavigation}).", ".quote($page->{ownerId}).", - ".quote($page->{groupIdView}).", ".quote($page->{groupIdEdit}).", ".quote($page->{encryptPage}).")"); + ".quote($page->{groupIdView}).", ".quote($page->{groupIdEdit}).", ".quote($page->{encryptPage}).", + ".length($page->{title}.$page->{menuTitle}.$page->{synopsis}.$page->{urlizedTitle}).")"); if ($page->{redirectURL} ne "") { WebGUI::SQL->write("insert into redirect (assetId, redirectUrl) values (".quote($pageId).",".quote($page->{redirectURL}).")"); } else { - WebGUI::SQL->write("insert into wobject (assetId, styleTemplateId, templateId, printableStyleTemplateId) values ( + WebGUI::SQL->write("insert into wobject (assetId, styleTemplateId, templateId, printableStyleTemplateId, + cacheTimeout, cacheTimeoutVisitor, displayTitle) values ( ".quote($pageId).", ".quote($page->{styleId}).", ".quote($page->{templateId}).", - ".quote($page->{printableStyleId}).")"); + ".quote($page->{printableStyleId}).", ".quote($page->{cacheTimeout}).",".quote($page->{cacheTimeoutVisitor}).", + 0)"); WebGUI::SQL->write("insert into layout (assetId) values (".quote($pageId).")"); } my $rank = 1; @@ -169,12 +194,14 @@ sub walkTree { } $className = 'WebGUI::Asset::Wobject::'.$wobject->{namespace}; WebGUI::SQL->write("insert into asset (assetId, parentId, lineage, className, state, title, menuTitle, url, startDate, - endDate, isHidden, ownerUserId, groupIdView, groupIdEdit, encryptPage) values (".quote($wobjectId).", - ".quote($pageId).", ".quote($wobjectLineage).", ".quote($className).",'published',".quote($page->{title}).", - ".quote($page->{title}).", ".quote($wobjectUrl).", ".quote($wobject->{startDate}).", ".quote($wobject->{endDate}).", - 1, ".quote($ownerId).", ".quote($groupIdView).", ".quote($groupIdEdit).", ".quote($page->{encryptPage}).")"); + endDate, isHidden, ownerUserId, groupIdView, groupIdEdit, encryptPage, assetSize) values (".quote($wobjectId).", + ".quote($pageId).", ".quote($wobjectLineage).", ".quote($className).",'published',".quote($wobject->{title}).", + ".quote($wobject->{title}).", ".quote($wobjectUrl).", ".quote($wobject->{startDate}).", ".quote($wobject->{endDate}).", + 1, ".quote($ownerId).", ".quote($groupIdView).", ".quote($groupIdEdit).", ".quote($page->{encryptPage}).", + ".length($wobject->{title}.$wobject->{description}).")"); WebGUI::SQL->write("update wobject set assetId=".quote($wobjectId).", styleTemplateId=".quote($page->{styleId}).", - printableStyleTemplateId=".quote($page->{printableStyleId})." where wobjectId=".quote($wobject->{wobjectId})); + printableStyleTemplateId=".quote($page->{printableStyleId}).", cacheTimeout=".quote($page->{cacheTimeout}) + .", cacheTimeoutVisitor=".quote($page->{cacheTimeoutVisitor})." where wobjectId=".quote($wobject->{wobjectId})); WebGUI::SQL->write("update ".$wobject->{namespace}." set assetId=".quote($wobjectId)." where wobjectId=" .quote($wobject->{wobjectId})); if ($wobject->{namespace} eq "Article") { @@ -244,6 +271,25 @@ sub walkTree { $rank++; } $b->finish; + if ($className eq "WebGUI::Asset::Wobject::Layout") { # Let's position some content + my $positions; + my $last = 1; + my @assets; + my @positions; + my $b = WebGUI::SQL->read("select assetId, templatePosition from wobject where pageId=".quote($page->{pageId})." + order by templatePosition, sequenceNumber"); + while (my ($assetId, $position) = $b->array) { + if ($position ne $last) { + push(@positions,join(",",@assets)); + @assets = (); + } + $last = $position; + push(@assets,$assetId); + } + $b->finish; + my $contentPositions = join("\.",@positions); + WebGUI::SQL->write("update layout set contentPositions=".quote($contentPositions)." where assetId=".quote($pageId)); + } walkTree($page->{pageId},$pageId,$pageLineage,$rank); $myRank++; } diff --git a/docs/upgrades/upgrade_6.2.9-6.3.0.sql b/docs/upgrades/upgrade_6.2.9-6.3.0.sql index 93d4e2bf3..8b1c00f44 100644 --- a/docs/upgrades/upgrade_6.2.9-6.3.0.sql +++ b/docs/upgrades/upgrade_6.2.9-6.3.0.sql @@ -11,7 +11,6 @@ update userProfileData set fieldData='tinyMCE' where fieldName='richEditor'; UPDATE template set template = '\r\n\r\n\r\n\r\n\r\n\r\n\r\n\r\n
\r\nInsert/Edit Link\r\n\r\n
\r\n Link Settings\r\n
\r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n \r\n
Link URL:
Link Target:\r\n
 
\r\n
\r\n \r\n\r\n
\r\n
\r\n\r\n\r\n
\r\n Available Page Tree\r\n
\r\n\r\n \')\">
\r\n
\r\n
\r\n
\r\n \r\n
\r\n\r\n' where namespace='richEditor/pagetree' && templateId = '1'; INSERT INTO template VALUES ('adminConsole','Admin Console','\r\n\r\n\r\n WebGUI <tmpl_var session.webgui.version>-<tmpl_var session.webgui.status> Admin Console\r\n \r\n\r\n\r\n\r\n\r\n\r\n','style',1,0); -INSERT INTO template VALUES ('1','Admin Console','^StyleSheet(^Extras;/adminConsole/adminConsole.css);\r\n^JavaScript(^Extras;/adminConsole/adminConsole.js);\r\n\r\n
\r\n \r\n \" target=\"_blank\">\"?\"\r\n \r\n
\r\n
\r\n \" border=\"0\" title=\"\" alt=\"\" />\r\n
\r\n
\r\n \" border=\"0\" title=\"\" alt=\"\" />\r\n
\r\n
\r\n \r\n
\r\n
\r\n \r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n  \r\n
\r\n \r\n \r\n \r\n \r\n \r\n
\r\n  \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n \">
\r\n
\r\n
\r\n
\r\n
\r\n ^AdminToggle;
\r\n ^LoginToggle;
\r\n
\r\n
\r\n\r\n','AdminConsole',1,1); delete from settings where name='adminStyleId'; delete from settings where name='useAdminStyle'; @@ -63,6 +62,8 @@ create table asset ( isHidden int not null default 0, isSystem int not null default 0, encryptPage int not null default 0, + lastUpdated bigint not null default 0, + assetSize int not null default 0, unique index (lineage asc), unique index (url), index (parentId) @@ -83,14 +84,14 @@ create table redirect ( ); create table layout ( - assetId varchar(22) not null primary key + assetId varchar(22) not null primary key, + contentPositions text ); create table FileAsset ( assetId varchar(22) not null primary key, storageId varchar(22) not null, filename varchar(255) not null, - fileSize int not null, olderVersions text ); @@ -181,3 +182,19 @@ create table ImageAsset ( thumbnailSize int not null default 50 ); +INSERT INTO template VALUES ('1','Admin Console','^StyleSheet(^Extras;/adminConsole/adminConsole.css);\r\n^JavaScript(^Extras;/adminConsole/adminConsole.js);\r\n\r\n
\r\n \r\n \" target=\"_blank\">\"?\"\r\n \r\n
\r\n
\r\n \" border=\"0\" title=\"\" alt=\"\" />\r\n
\r\n
\r\n\"*\"\r\n
\r\n
\r\n \" border=\"0\" title=\"\" alt=\"\" />\r\n
\r\n
\r\n \r\n
\r\n
\r\n \r\n
\r\n
\r\n \r\n
\r\n
\r\n
\r\n  \r\n
\r\n \r\n \r\n \r\n \r\n \r\n
\r\n  \r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n
\r\n \r\n \">
\r\n
\r\n
\r\n
\r\n
\r\n ^AdminToggle;
\r\n ^LoginToggle;
\r\n
\r\n
\r\n\r\n','AdminConsole',1,1); +insert into settings (name,value) values ('AdminConsoleTemplate',1); +delete from template where namespace='Macro/AdminBar' and templateId in ('1','2'); +INSERT INTO template VALUES ('1','Default Admin Bar','\r\n \r\n
\r\n\r\n \r\n \r\n\r\n \r\n \r\n
\r\n\r\n
\r\n \r\n
\r\n
\r\n','Macro/AdminBar',1,1); +INSERT INTO template VALUES ('2','DHTML Admin Bar','^JavaScript(\"/coolmenus/coolmenus4.js\");\r\n\r\n\r\n\r\n','Macro/AdminBar',1,1); + +delete from template where namespace='page' and templateId in ('1','2','3','4','5','6','7'); + +INSERT INTO template VALUES ('5','Left Column','\">\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n
 
\r\n\r\n
\r\n\r\n
\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n\r\n\r\n\r\n
\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n\r\n
\r\n\r\n
 
\r\n\r\n \r\n
 
\r\n \r\n
\r\n ','page',1,1); +INSERT INTO template VALUES ('4','Three Over One','\">\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n
 
\r\n\r\n
\r\n\r\n
\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n\r\n\r\n\r\n\r\n
\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n\r\n\r\n\r\n
\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n\r\n\r\n
\r\n\r\n
 
\r\n\r\n\r\n
\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n\r\n\r\n\r\n\r\n \r\n
 
\r\n \r\n
\r\n ','page',1,1); +INSERT INTO template VALUES ('3','One Over Three','\">\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n
\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n\r\n\r\n
 
\r\n\r\n
\r\n\r\n
\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n\r\n\r\n\r\n
\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n\r\n\r\n\r\n\r\n
\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n\r\n\r\n
\r\n\r\n
 
\r\n\r\n\r\n \r\n
 
\r\n \r\n
\r\n ','page',1,1); +INSERT INTO template VALUES ('2','News','\">\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n
\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n\r\n\r\n
 
\r\n\r\n
\r\n\r\n
\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n\r\n\r\n\r\n
\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n\r\n
\r\n\r\n
 
\r\n\r\n\r\n\r\n
\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n\r\n\r\n\r\n\r\n\r\n \r\n
 
\r\n \r\n
\r\n ','page',1,1); +INSERT INTO template VALUES ('7','Side By Side','\">\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n
 
\r\n\r\n
\r\n\r\n
\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n\r\n\r\n\r\n
\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n\r\n
\r\n\r\n
 
\r\n\r\n\r\n \r\n
 
\r\n \r\n
\r\n ','page',1,1); +INSERT INTO template VALUES ('6','Right Column','\">\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n
 
\r\n\r\n
\r\n\r\n
\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n\r\n\r\n\r\n
\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n
\r\n\r\n
\r\n\r\n
 
\r\n\r\n\r\n \r\n
 
\r\n \r\n
\r\n ','page',1,1); +INSERT INTO template VALUES ('1','Default Page','\">\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n

\r\n
\r\n\r\n\r\n \r\n\r\n\r\n\r\n \r\n \">\r\n \r\n \r\n \r\n\r\n\r\n \r\n
_div\" class=\"dragable\"> \r\n \r\n\r\n
\r\n\r\n \r\n
\r\n
\r\n\r\n \r\n
 
\r\n \r\n
\r\n ','page',1,1); + diff --git a/lib/WebGUI.pm b/lib/WebGUI.pm index 7f710b67f..64f2c96f0 100644 --- a/lib/WebGUI.pm +++ b/lib/WebGUI.pm @@ -15,6 +15,7 @@ our $STATUS = "gamma"; use strict qw(vars subs); use Tie::CPHash; use WebGUI::Affiliate; +use WebGUI::Asset; use WebGUI::Cache; use WebGUI::ErrorHandler; use WebGUI::Grouping; @@ -29,55 +30,6 @@ use WebGUI::URL; use WebGUI::PassiveProfiling; -#------------------------------------------------------------------- -sub _generatePage { - my $content = shift; - if ($session{form}{op} eq "" && $session{setting}{trackPageStatistics} && $session{form}{wid} ne "new") { - WebGUI::SQL->write("insert into pageStatistics (dateStamp, userId, username, ipAddress, userAgent, referer, - pageId, pageTitle, wobjectId, wobjectFunction) values (".time().",".quote($session{user}{userId}) - .",".quote($session{user}{username}).", - ".quote($session{env}{REMOTE_ADDR}).", ".quote($session{env}{HTTP_USER_AGENT}).", - ".quote($session{env}{HTTP_REFERER}).", ".quote($session{page}{pageId}).", - ".quote($session{page}{title}).", ".quote($session{form}{wid}).", ".quote($session{form}{func}).")"); - } - my $output = WebGUI::Style::process($content); - if ($session{setting}{showDebug} || ($session{form}{debug}==1 && WebGUI::Grouping::isInGroup(3))) { - $output .= WebGUI::ErrorHandler::showDebug(); - } - return $output; -} - -#------------------------------------------------------------------- -sub _getPageInfo { - my $sql = "select * from page where "; - my $url = shift || $ENV{PATH_INFO}; - $url = lc($url); - $url =~ s/\/$//; - $url =~ s/^\///; - $url =~ s/\'//; - $url =~ s/\"//; - my $pageData; - if ($url ne "") { - $pageData = WebGUI::SQL->quickHashRef($sql."urlizedTitle=".quote($url)); - if ($pageData->{subroutine} eq "") { - if($ENV{"MOD_PERL"}) { - my $r = Apache->request; - if(defined($r)) { - $r->custom_response(404, $url); - $r->status(404); - } - } else { - $session{http}{status} = '404'; - } - $pageData = WebGUI::SQL->quickHashRef($sql."pageId=".quote($session{setting}{notFoundPage})); - } - } else { - $pageData = WebGUI::SQL->quickHashRef($sql."pageId=".quote($session{setting}{defaultPage})); - } - $session{page} = $pageData; - return $pageData; -} - #------------------------------------------------------------------- sub _processOperations { my ($cmd, $output); @@ -105,56 +57,32 @@ sub _processOperations { sub page { my $webguiRoot = shift; my $configFile = shift; - my $useExistingSession = shift; # used for static page generation functions where you may generate more than one page at a time. - my $pageUrl = shift; + my $useExistingSession = shift; # used for static page generation functions where you may generate more than one asset at a time. + my $assetUrl = shift; my $fastcgi = shift; WebGUI::Session::open($webguiRoot,$configFile,$fastcgi) unless ($useExistingSession); - my $page = _getPageInfo($pageUrl); my $output = _processOperations(); - if ($output ne "") { - $output = _generatePage($output); - } else { - my $useCache = ( - $session{form}{op} eq "" && - $session{form}{func} eq "" && - ( - ( $session{page}{cacheTimeout} > 10 && $session{user}{userId} !=1) || - ( $session{page}{cacheTimeoutVisitor} > 10 && $session{user}{userId} == 1) - ) && - not $session{var}{adminOn} - ); - my $cache; - if ($useCache) { - $cache = WebGUI::Cache->new("page_".$session{page}{pageId}."_".$session{user}{userId}); - $output = $cache->get; + if ($output eq "") { + my $asset = WebGUI::Asset->newByUrl($assetUrl); + my $method = "view"; + if (exists $session{form}{func}) { + $method = $session{form}{func}; } - unless ($output) { - my $cmd = "use ".$page->{subroutinePackage}; - eval ($cmd); - WebGUI::ErrorHandler::fatalError("Couldn't compile page package: ".$page->{subroutinePackage}.". Root cause: ".$@) if ($@); - my $params = eval $page->{subroutineParams}; - WebGUI::ErrorHandler::fatalError("Couldn't interpret page params: ".$page->{subroutineParams}.". Root cause: ".$@) if ($@); - $cmd = $page->{subroutinePackage}."::".$page->{subroutine}; - $output = eval{&$cmd($params)}; - WebGUI::ErrorHandler::fatalError("Couldn't execute page command: ".$page->{subroutine}.". Root cause: ".$@) if ($@); - if (WebGUI::HTTP::getMimeType() eq "text/html") { - $output = _generatePage($output); - } - my $ttl; - if ($session{user}{userId} == 1) { - $ttl = $session{page}{cacheTimeoutVisitor}; - } else { - $ttl = $session{page}{cacheTimeout}; - } - $cache->set($output, $ttl) if ($useCache && !WebGUI::HTTP::isRedirect()); - WebGUI::PassiveProfiling::addPage(); # add wobjects on page to passive profile log + $method = "www_".$method; + $output = $asset->$method(); + if ($output eq "" && $method ne "view") { + $output = $asset->www_view; } + WebGUI::ErrorHandler::fatalError("Couldn't call method ".$method." on asset for ".$asset->get("url")." (".$asset->getId."). Root cause: ".$!) if ($!); } WebGUI::Affiliate::grabReferral(); # process affilliate tracking request if (WebGUI::HTTP::isRedirect() && !$useExistingSession) { $output = WebGUI::HTTP::getHeader(); } else { $output = WebGUI::HTTP::getHeader().$output; + if ($session{setting}{showDebug} || ($session{form}{debug}==1 && WebGUI::Grouping::isInGroup(3))) { + $output .= WebGUI::ErrorHandler::showDebug(); + } } # This allows an operation or wobject to write directly to the browser. $output = undef if ($session{page}{empty}); diff --git a/lib/WebGUI/AdminConsole.pm b/lib/WebGUI/AdminConsole.pm index 6ce3f490c..34ab96a28 100644 --- a/lib/WebGUI/AdminConsole.pm +++ b/lib/WebGUI/AdminConsole.pm @@ -4,16 +4,23 @@ use strict; use WebGUI::Grouping; use WebGUI::International; use WebGUI::Session; +use WebGUI::Style; use WebGUI::Template; use WebGUI::URL; sub _formatFunction { my $self = shift; my $function = shift; + my $url; + if (exists $function->{func}) { + $url = WebGUI::URL::page("func=".$function->{func}); + } else { + $url = WebGUI::URL::page("op=".$function->{op}); + } return { title=>WebGUI::International::get($function->{title}{id}, $function->{title}{namespace}), icon=>$session{config}{extrasURL}."/adminConsole/".$function->{icon}, - url=>WebGUI::URL::page("op=".$function->{op}), + url=>$url, canUse=>WebGUI::Grouping::isInGroup($function->{group}) }; } @@ -46,7 +53,7 @@ sub getAdminFunction { namespace=>"Asset" }, icon=>"assets.gif", - op=>"manageAssets", + func=>"manageAssets", group=>"12" }, "users"=>{ @@ -267,8 +274,7 @@ sub render { $var{"console.icon"} = $acParams->{icon}; $var{"help.url"} = $self->{_helpUrl}; $var{"application_loop"} = $self->getAdminFunction; - $session{page}{useAdminStyle} = 1; - return WebGUI::Template::process($session{setting}{AdminConsoleTemplate}, "AdminConsole", \%var); + return WebGUI::Style::process(WebGUI::Template::process($session{setting}{AdminConsoleTemplate}, "AdminConsole", \%var),"adminConsole"); } sub setHelp { @@ -278,5 +284,13 @@ sub setHelp { $self->{_helpUrl} = WebGUI::URL::page('op=viewHelp&hid='.$id.'&namespace='.$namespace) if ($id); } +sub setIcon { + my $self = shift; + my $icon = shift; + if ($icon) { + $self->{_function}{icon} = $icon; + } +} + 1; diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index dfa63e530..efe6502c1 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -3,8 +3,14 @@ package WebGUI::Asset; #needs documentation use strict; +use Tie::IxHash; +use WebGUI::Clipboard; use WebGUI::DateTime; +use WebGUI::ErrorHandler; +use WebGUI::Form; use WebGUI::Grouping; +use WebGUI::HTTP; +use WebGUI::Icon; use WebGUI::Id; use WebGUI::Privilege; use WebGUI::Session; @@ -22,14 +28,13 @@ sub addChild { values (".quote($id).",".quote($self->getId).", ".quote($lineage).", 'published', ".quote($properties->{className}).", ".quote($id).", 997995720, 9223372036854775807)"); - foreach my $definition (@{$self->{definition}}) { + foreach my $definition (@{$self->definition}) { unless ($definition->{tableName} eq "asset") { WebGUI::SQL->write("insert into ".$definition->{tableName}." (assetId) values (".quote($id).")"); } } WebGUI::SQL->commit; - my $className = $properties->{className}; - my $newAsset = $className->new($id); + my $newAsset = WebGUI::Asset->newByDynamicClass($id, $properties->{className}); $newAsset->update($properties); return $newAsset; } @@ -46,9 +51,10 @@ sub canEdit { sub canView { my $self = shift; my $userId = shift || $session{user}{userId}; + return 0 unless ($self->get("state") eq "published"); if ($userId eq $self->get("ownerUserId")) { return 1; - } elsif ($self->get("startDate") < time() && + } elsif ( $self->get("startDate") < time() && $self->get("endDate") > time() && WebGUI::Grouping::isInGroup($self->get("groupIdView"),$userId)) { return 1; @@ -75,8 +81,9 @@ sub cut { sub definition { my $class = shift; - my $definition = shift; - push(@{$definition}, { + my $definition = shift || []; + my @newDef = @{$definition}; + push(@newDef, { tableName=>'asset', className=>'WebGUI::Asset', properties=>{ @@ -117,18 +124,13 @@ sub definition { fieldType=>'dateTime', defaultValue=>undef }, + assetSize=>{ + fieldType=>'hidden', + defaultValue=>0 + } } }); - return $definition; -} - -sub delete { - my $self = shift; - WebGUI::SQL->beginTransaction; - WebGUI::SQL->write("update asset set state='limbo' where lineage like ".quote($self->get("lineage").'%')); - WebGUI::SQL->write("update asset set state='trash' where assetId=".quote($self->getId)); - WebGUI::SQL->commit; - $self->{_properties}{state} = "trash"; + return \@newDef; } sub demote { @@ -148,6 +150,7 @@ sub duplicate { return $newAsset; } + sub fixUrl { my $self = shift; my $url = WebGUI::URL::urlize(shift); @@ -197,9 +200,33 @@ sub getAdminConsole { unless (exists $self->{_adminConsole}) { $self->{_adminConsole} = WebGUI::AdminConsole->new("assets"); } + $self->{_adminConsole}->setIcon($self->getIcon); return $self->{_adminConsole}; } +sub getAssetAdderLinks { + my $self = shift; + my @links; + foreach my $class (@{$session{config}{assets}}) { + my $load = "use ".$class; + eval ($load); + if ($@) { + WebGUI::ErrorHandler::warn("Couldn't compile ".$class." because ".$@); + } else { + my $label = eval{$class->getName()}; + if ($@) { + WebGUI::ErrorHandler::warn("Couldn't get the name of ".$class." because ".$@); + } else { + push(@links, { + label=>$label, + url=>$self->getUrl("func=add&class=".$class) + }); + } + } + } + return \@links; +} + sub getEditForm { my $self = shift; my $tabform = WebGUI::TabForm->new(); @@ -213,7 +240,13 @@ sub getEditForm { value=>"1" }); } - $tabform->add("properties",WebGUI::International::get("properties","Asset")); + if ($session{form}{afterEdit}) { + $tabform->hidden({ + name=>"afterEdit", + value=>$session{form}{afterEdit} + }); + } + $tabform->addTab("properties",WebGUI::International::get("properties","Asset")); $tabform->getTab("properties")->readOnly( -label=>WebGUI::International::get("asset id","Asset"), -value=>$self->get("assetId") @@ -259,7 +292,7 @@ sub getEditForm { -value=>$self->get("synopsis"), -uiLevel=>3 ); - $tabform->add("privileges",WebGUI::International::get(107),6); + $tabform->addTab("privileges",WebGUI::International::get(107),6); $tabform->getTab("privileges")->dateTime( -name=>"startDate", -label=>WebGUI::International::get(497), @@ -287,7 +320,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")->select( + $tabform->getTab("privileges")->selectList( -name=>"ownerUserId", -options=>$users, -label=>WebGUI::International::get(108), @@ -311,6 +344,15 @@ sub getEditForm { return $tabform; } + +sub getIcon { + my $self = shift; + my $small = shift; + return $session{config}{extrasURL}.'/adminConsole/small/assets.gif' if ($small); + return $session{config}{extrasURL}.'/adminConsole/assets.gif'; +} + + sub getId { my $self = shift; return $self->get("assetId"); @@ -329,28 +371,19 @@ sub getIndexerParams { } -sub getName { - return WebGUI::International::get('asset','Asset'); -} - -sub getNextChildRank { - my $self = shift; - my ($lineage) = WebGUI::SQL->quickArray("select max(lineage) from asset where parentId=".quote($self->getId)); - my $rank; - if (defined $lineage) { - $rank = $self->getRank($lineage); - $rank++; - } else { - $rank = 1; - } - return $self->formatRank($rank); -} - sub getLineage { my $self = shift; my $relatives = shift; my $rules = shift; my $lineage = $self->get("lineage"); + my $whereExclusion = " and state='published'"; + if (exists $rules->{excludeClasses}) { + my @set; + foreach my $className (@{$rules->{excludeClasses}}) { + push(@set,"className <> ".quote($className)); + } + $whereExclusion .= 'and ('.join(" and ",@set).')'; + } my $whereSiblings; if (isIn("siblings",@{$relatives})) { $whereSiblings = "(parentId=".quote($self->get("parentId"))." and assetId<>".quote($self->getId).")"; @@ -379,15 +412,17 @@ sub getLineage { if ($whereSiblings ne "" || $whereExact ne "") { $whereDescendants = " or "; } - my $lineageLength = length($lineage); - $whereDescendants .= "lineage like ".quote($lineage.'%')." and length(lineage)> ".$lineageLength; + $whereDescendants .= "lineage like ".quote($lineage.'%')." and lineage<>".quote($lineage); + if (exists $rules->{endingLineageLength}) { + $whereDescendants .= " and length(lineage) <= ".($rules->{endingLineageLength}*6); + } } - my $sql = "select assetId from asset where $whereSiblings $whereExact $whereDescendants order by lineage"; + my $sql = "select assetId,className from asset where $whereSiblings $whereExact $whereDescendants $whereExclusion order by lineage"; my @lineage; my $sth = WebGUI::SQL->read($sql); - while (my ($assetId) = $sth->array) { - if ($rules->{returnOjbects}) { - push(@lineage,WebGUI::Asset->new($assetId); + while (my ($assetId,$className) = $sth->array) { + if ($rules->{returnObjects}) { + push(@lineage,WebGUI::Asset->newByDynamicClass($assetId, $className)); } else { push(@lineage,$assetId); } @@ -396,9 +431,31 @@ sub getLineage { return \@lineage; } +sub getLineageLength { + my $self = shift; + return length($self->get("lineage"))/6; +} + +sub getName { + return WebGUI::International::get('asset','Asset'); +} + +sub getNextChildRank { + my $self = shift; + my ($lineage) = WebGUI::SQL->quickArray("select max(lineage) from asset where parentId=".quote($self->getId)); + my $rank; + if (defined $lineage) { + $rank = $self->getRank($lineage); + $rank++; + } else { + $rank = 1; + } + return $self->formatRank($rank); +} + sub getParent { my $self = shift; - return WebGUI::Asset->new($self->get("parentId")); + return WebGUI::Asset->newByDynamicClass($self->get("parentId")); } sub getParentLineage { @@ -421,6 +478,12 @@ sub getUiLevel { return 0; } +sub getUrl { + my $self = shift; + my $params = shift; + return WebGUI::URL::gateway($self->get("url"),$params); +} + sub getValue { my $self = shift; my $key = shift; @@ -437,6 +500,12 @@ sub getValue { return undef; } +sub hasChildren { + my $self = shift; + my ($hasChildren) = WebGUI::SQL->read("select count(*) from asset where parentId=".quote($self->getId)); + return $hasChildren; +} + sub new { my $class = shift; my $assetId = shift; @@ -457,23 +526,75 @@ sub new { $sql .= " where asset.assetId=".quote($assetId); $properties = WebGUI::SQL->quickHashRef($sql); return undef unless (exists $properties->{assetId}); - foreach my $property (keys %{$overrideProperties}) { - unless (isIn($property, qw(assetId className parentId lineage state))) { - $properties->{$property} = $overrideProperties->{$property}; - } - } } + if (defined $overrideProperties) { + foreach my $definition (@{$class->definition}) { + foreach my $property (keys %{$definition->{properties}}) { + if (exists $overrideProperties->{$property}) { + $properties->{$property} = $overrideProperties->{$property}; + } + } + } + } if (defined $properties) { - return bless { _properties=>$properties }, $class; + my $object = { _properties => $properties }; + bless $object, $class; + return $object; } return undef; } + +sub newByDynamicClass { + my $class = shift; + my $assetId = shift; + my $className = shift; + unless (defined $className) { + ($className) = WebGUI::SQL->quickArray("select className from asset where assetId=".quote($assetId)); + } + if ($className eq "") { + WebGUI::HTTP::setStatus('404',"Page Not Found"); + WebGUI::ErrorHandler::fatalError("The page not found page doesn't exist.") if ($assetId eq $session{setting}{notFoundPage}); + return WebGUI::Asset->newByDynamicClass($session{setting}{notFoundPage}); + } + my $cmd = "use ".$className; + eval ($cmd); + WebGUI::ErrorHandler::fatalError("Couldn't compile asset package: ".$className.". Root cause: ".$@) if ($@); + my $assetObject = eval{$className->new($assetId)}; + WebGUI::ErrorHandler::fatalError("Couldn't create asset instance for ".$assetId.". Root cause: ".$@) if ($@); + return $assetObject; +} + + +sub newByUrl { + my $class = shift; + my $url = shift || $session{env}{PATH_INFO}; + $url = lc($url); + $url =~ s/\/$//; + $url =~ s/^\///; + $url =~ s/\'//; + $url =~ s/\"//; + my $asset; + if ($url ne "") { + $asset = WebGUI::SQL->quickHashRef("select assetId, className from asset where url=".quote($url)); + return WebGUI::Asset->newByDynamicClass($asset->{assetId}, $asset->{className}); + } + return $class->newByDynamicClass($session{setting}{defaultPage}); +} + + +sub republish { + my $self = shift; + WebGUI::SQL->write("update asset set state='published' where lineage like ".quote($self->get("lineage").'%')); + $self->{_properties}{state} = "published"; +} + sub paste { my $self = shift; - my $newParentId = shift; - if ($self->setParent($newParentId)) { - WebGUI::SQL->write("update asset set state='published' where lineage like ".quote($self->get("lineage").'%')); + my $assetId = shift; + my $pastedAsset = WebGUI::Asset->new($assetId); + if ($self->getId eq $pastedAsset->get("parentId") || $pastedAsset->setParent($self->getId)) { + $pastedAsset->republish; return 1; } return 0; @@ -508,6 +629,7 @@ sub setParent { my $self = shift; my $newParentId = shift; return 0 if ($newParentId eq $self->get("parentId")); # don't move it to where it already is + return 0 if ($newParentId eq $self->getId); # don't move it to itself my $parent = WebGUI::Asset->new($newParentId); if (defined $parent) { my $oldLineage = $self->get("lineage"); @@ -549,6 +671,16 @@ sub setRank { return 1; } +sub setSize { + my $self = shift; + my $extra = shift; + my $sizetest; + foreach my $key (keys %{$self->get}) { + $sizetest .= $self->get($key); + } + WebGUI::SQL->write("update asset set assetSize=".(length($sizetest)+$extra)." where assetId=".quote($self->getId)); +} + sub swapRank { my $self = shift; my $second = shift; @@ -563,17 +695,30 @@ sub swapRank { } +sub trash { + my $self = shift; + WebGUI::SQL->beginTransaction; + WebGUI::SQL->write("update asset set state='limbo' where lineage like ".quote($self->get("lineage").'%')); + WebGUI::SQL->write("update asset set state='trash' where assetId=".quote($self->getId)); + WebGUI::SQL->commit; + $self->{_properties}{state} = "trash"; +} + sub update { my $self = shift; my $properties = shift; WebGUI::SQL->beginTransaction; foreach my $definition (@{$self->definition}) { my @setPairs; + if ($definition->{tableName} eq "asset") { + push(@setPairs,"lastUpdated=".time()); + } foreach my $property (keys %{$definition->{properties}}) { my $value = $properties->{$property} || $definition->{properties}{$property}{defaultValue}; if (defined $value) { if (exists $definition->{properties}{$property}{filter}) { - $value = $self->$definition->{properties}{$property}{filter}($value); + my $filter = $definition->{properties}{$property}{filter}; + $value = $self->$filter($value); } $self->{_properties}{$property} = $value; push(@setPairs, $property."=".quote($value)); @@ -583,6 +728,7 @@ sub update { WebGUI::SQL->write("update ".$definition->{tableName}." set ".join(",",@setPairs)." where assetId=".quote($self->getId)); } } + $self->setSize; WebGUI::SQL->commit; return 1; } @@ -596,18 +742,57 @@ sub www_copy { return ""; } +sub www_copyList { + my $self = shift; + return WebGUI::Privilege::insufficient() unless $self->canEdit; + my $newAsset = $self->duplicate; + $newAsset->cut; + foreach my $assetId ($session{cgi}->param("assetId")) { + my $asset = WebGUI::Asset->newByDynamicClass($assetId); + if ($asset->canEdit) { + my $newAsset = $asset->duplicate; + $newAsset->cut; + } + } + return $self->manageAssets(); +} + sub www_cut { my $self = shift; return WebGUI::Privilege::insufficient() unless $self->canEdit; $self->cut; - return ""; + return $self->getParent->www_view; +} + +sub www_cutList { + my $self = shift; + return WebGUI::Privilege::insufficient() unless $self->canEdit; + foreach my $assetId ($session{cgi}->param("assetId")) { + my $asset = WebGUI::Asset->newByDynamicClass($assetId); + if ($asset->canEdit) { + $asset->cut; + } + } + return $self->manageAssets(); } sub www_delete { my $self = shift; return WebGUI::Privilege::insufficient() unless $self->canEdit; - $self->delete; - return ""; + $self->trash; + return $self->getParent->www_view; +} + +sub www_deleteList { + my $self = shift; + return WebGUI::Privilege::insufficient() unless $self->canEdit; + foreach my $assetId ($session{cgi}->param("assetId")) { + my $asset = WebGUI::Asset->newByDynamicClass($assetId); + if ($asset->canEdit) { + $asset->trash; + } + } + return $self->manageAssets(); } sub www_demote { @@ -620,7 +805,7 @@ sub www_demote { sub www_edit { my $self = shift; return WebGUI::Privilege::insufficient() unless $self->canEdit; - return $self->getAdminConsole->render($self->getEditForm); + return $self->getAdminConsole->render($self->getEditForm->print); } sub www_editSave { @@ -628,7 +813,7 @@ sub www_editSave { my %data; foreach my $definition (@{$self->definition}) { foreach my $property (keys %{$definition->{properties}}) { - my $data{$property} = WebGUI::FormProcessor::process( + $data{$property} = WebGUI::FormProcessor::process( $property, $definition->{properties}{fieldType}, $definition->{properties}{defaultValue} @@ -636,16 +821,135 @@ sub www_editSave { } } $self->update(\%data); + return $self->www_manageAssets if ($session{form}{afterEdit} eq "assetManager"); return ""; } +sub www_editTree { + return "not yet implemented"; +} + +sub www_editTreeSave { + return "not yet implemented"; +} + +sub www_manageAssets { + my $self = shift; + return WebGUI::Privilege::insufficient() unless $self->canEdit; + WebGUI::Style::setLink($session{config}{extrasURL}.'/assetManager/ActiveWidgets/runtime/styles/xp/grid.css', {rel=>"stylesheet",type=>"text/css"}); + WebGUI::Style::setLink($session{config}{extrasURL}.'/assetManager/assetManager.css', {rel=>"stylesheet",type=>"text/css"}); + WebGUI::Style::setScript($session{config}{extrasURL}.'/assetManager/ActiveWidgets/source/lib/grid.js', {type=>"text/javascript"}); + WebGUI::Style::setScript($session{config}{extrasURL}.'/assetManager/Tools.js', {type=>"text/javascript"}); + WebGUI::Style::setScript($session{config}{extrasURL}.'/assetManager/ContextMenu.js', {type=>"text/javascript"}); + WebGUI::Style::setScript($session{config}{extrasURL}.'/assetManager/Asset.js', {type=>"text/javascript"}); + WebGUI::Style::setScript($session{config}{extrasURL}.'/assetManager/Display.js', {type=>"text/javascript"}); + WebGUI::Style::setScript($session{config}{extrasURL}.'/assetManager/EventManager.js', {type=>"text/javascript"}); + WebGUI::Style::setScript($session{config}{extrasURL}.'/assetManager/AssetManager.js', {type=>"text/javascript"}); + my $children = $self->getLineage(["descendants"],{returnObjects=>1, endingLineageLength=>$self->getLineageLength+1}); + my $output; + $output = ' +
+
+
+
Retrieving Assets...
+
hello
+ '; + $output .= "\n"; + $output .= '
'.WebGUI::International::get(1).' +
+   +
+
'.WebGUI::International::get(1083).'
'; + foreach my $link (@{$self->getAssetAdderLinks}) { + $output .= ''.$link->{label}.'
'; + } + $output .= '
'; + my $clipboard = WebGUI::Clipboard::getAssetsInClipboard(); + my %options; + tie %options, 'Tie::IxHash'; + my $hasClips = 0; + foreach my $item (@{$clipboard}) { + $options{$item->{assetId}} = $item->{title}; + $hasClips = 1; + } + if ($hasClips) { + $output .= '
'.WebGUI::International::get(1082).'
' + .WebGUI::Form::formHeader() + .WebGUI::Form::hidden({name=>"func",value=>"pasteList"}) + .WebGUI::Form::checkList({name=>"assetId",options=>\%options}) + .'
' + .WebGUI::Form::submit({value=>"Paste"}) + .WebGUI::Form::formFooter() + .'
'; + } + $output .= ' +
+   +
+
+ '; + return $self->getAdminConsole->render($output); +} + + sub www_paste { my $self = shift; return WebGUI::Privilege::insufficient() unless $self->canEdit; - $self->paste($session{form}{newParentId}); + $self->paste($session{form}{assetId}); return ""; } +sub www_pasteList { + my $self = shift; + return WebGUI::Privilege::insufficient() unless $self->canEdit; + foreach my $clipId ($session{cgi}->param("assetId")) { + $self->paste($clipId); + } + return $self->manageAssets(); +} + sub www_promote { my $self = shift; return WebGUI::Privilege::insufficient() unless $self->canEdit; @@ -653,10 +957,29 @@ sub www_promote { return ""; } -sub www_view { +sub www_setParent { my $self = shift; return WebGUI::Privilege::insufficient() unless $self->canEdit; - return "No view has been defined for this asset."; + my $newParent = shift; + $self->setParent($newParent) if (defined $newParent); + return $self->www_manageAssets(); + } +sub www_setRank { + my $self = shift; + return WebGUI::Privilege::insufficient() unless $self->canEdit; + my $newRank = $session{form}{rank}; + $self->setRank($newRank) if (defined $newRank); + return $self->www_manageAssets(); +} + +sub www_view { + my $self = shift; + return WebGUI::Privilege::noAccess() unless $self->canView; + return "No view has been implemented for this asset."; +} + + 1; + diff --git a/lib/WebGUI/Asset/File.pm b/lib/WebGUI/Asset/File.pm index b9bf397cd..519177ac7 100644 --- a/lib/WebGUI/Asset/File.pm +++ b/lib/WebGUI/Asset/File.pm @@ -108,6 +108,18 @@ sub getEditForm { } +#------------------------------------------------------------------- +sub getIcon { + my $self = shift; + my $small = shift; + if ($small) { + my $storage = WebGUI::Storage->new($self->get("storageId")); + return $storage->getFileIconUrl($self->get("filename")); + } + return $session{config}{extrasURL}.'/assets/file.gif'; +} + + #------------------------------------------------------------------- =head2 getName @@ -151,26 +163,26 @@ Gathers data from www_edit and persists it. sub www_editSave { my $self = shift; - $self->SUPER::www_editSave(); + my $output = $self->SUPER::www_editSave(); my $storage = WebGUI::Storage->create; my $filename = $storage->addFileFromFormPost("file"); if (defined $filename) { my $oldVersions; if ($self->get($filename)) { # do file versioning my @old = split("\n",$self->get("olderVersions")); - push(@old,$self->get{"storageId")."|".$self->get("filename")); + push(@old,$self->get("storageId")."|".$self->get("filename")); $oldVersions = join("\n",@old); } $self->update({ filename=>$filename, storageId=>$storage->getId, - fileSize=>$storage->getFileSize, olderVersions=>$oldVersions }); + $self->setSize($storage->getFileSize($filename)); } else { $storage->delete; } - return ""; + return $output; } diff --git a/lib/WebGUI/Asset/File/Image.pm b/lib/WebGUI/Asset/File/Image.pm index 90a986752..94e27facd 100644 --- a/lib/WebGUI/Asset/File/Image.pm +++ b/lib/WebGUI/Asset/File/Image.pm @@ -98,16 +98,16 @@ sub generateThumbnail { } if ($self->getValue("filename") && $hasImageMagick) { my $storage = WebGUI::Storage->new($self->get("storageId")); - $image = Image::Magick->new; - $error = $image->Read($storage->getPath($storage->get("filename"))); + my $image = Image::Magick->new; + my $error = $image->Read($storage->getPath($storage->get("filename"))); if ($error) { $self->_addError("Couldn't read image for thumnail creation: ".$error); return 0; } - ($x, $y) = $image->Get('width','height'); - $n = $self->get("thumbnailSize"); + my ($x, $y) = $image->Get('width','height'); + my $n = $self->get("thumbnailSize"); if ($x > $n || $y > $n) { - $r = $x>$y ? $x / $n : $y / $n; + my $r = $x>$y ? $x / $n : $y / $n; $image->Scale(width=>($x/$r),height=>($y/$r)); } if (isIn($storage->getFileExtension($self->get("filename")), qw(tif tiff bmp))) { @@ -152,6 +152,15 @@ sub getEditForm { } +#------------------------------------------------------------------- +sub getIcon { + my $self = shift; + my $small = shift; + return $session{config}{extrasURL}.'/assets/image.gif' unless ($small); + $self->SUPER::getIcon(1); +} + + #------------------------------------------------------------------- =head2 getName diff --git a/lib/WebGUI/Asset/Redirect.pm b/lib/WebGUI/Asset/Redirect.pm index ee3e9f193..2025302bd 100644 --- a/lib/WebGUI/Asset/Redirect.pm +++ b/lib/WebGUI/Asset/Redirect.pm @@ -92,6 +92,15 @@ sub getEditForm { } +#------------------------------------------------------------------- +sub getIcon { + my $self = shift; + my $small = shift; + return $session{config}{extrasURL}.'/assets/small/redirect.gif' if ($small); + return $session{config}{extrasURL}.'/assets/redirect.gif'; +} + + #------------------------------------------------------------------- =head2 getUiLevel () diff --git a/lib/WebGUI/Asset/Wobject.pm b/lib/WebGUI/Asset/Wobject.pm index 3e1a4f218..3098d1188 100644 --- a/lib/WebGUI/Asset/Wobject.pm +++ b/lib/WebGUI/Asset/Wobject.pm @@ -18,6 +18,7 @@ use CGI::Util qw(rearrange); use DBI; use strict qw(subs vars); use Tie::IxHash; +use WebGUI::Asset; use WebGUI::AdminConsole; use WebGUI::DateTime; use WebGUI::FormProcessor; @@ -32,6 +33,7 @@ use WebGUI::Node; use WebGUI::Page; use WebGUI::Privilege; use WebGUI::Session; +use WebGUI::Style; use WebGUI::SQL; use WebGUI::TabForm; use WebGUI::Template; @@ -40,9 +42,11 @@ use WebGUI::Utility; use WebGUI::MetaData; use WebGUI::Wobject::WobjectProxy; +our @ISA = qw(WebGUI::Asset); + =head1 NAME -Package WebGUI::Wobject +Package WebGUI::Asset::Wobject =head1 DESCRIPTION @@ -83,7 +87,19 @@ sub definition { cacheTimeoutVisitor=>{ fieldType=>'interval', defaultValue=>600 - } + }, + templateId=>{ + fieldType=>'template', + defaultValue=>undef + }, + styleTemplateId=>{ + fieldType=>'template', + defaultValue=>undef + }, + printableStyleTemplateId=>{ + fieldType=>'template', + defaultValue=>undef + } } }); return $class->SUPER::definition($definition); @@ -115,7 +131,7 @@ A comparison expression to be used when checking whether the action should be al sub confirm { return WebGUI::Privilege::vitalComponent() if ($_[4]); - my $noURL = $_[3] || WebGUI::URL::page(); + my $noURL = $_[3] || $_[0]->getUrl; my $output = '

'.WebGUI::International::get(42).'

'; $output .= $_[1].'

'; $output .= '

'.WebGUI::International::get(44).''; @@ -174,24 +190,24 @@ sub getEditForm { $tabform->getTab("layout")->template( -name=>"styleTemplateId", -label=>WebGUI::International::get(1073), - -value=>($page{styleId} || 2), + -value=>$self->getValue("styleTemplateId"), -namespace=>'style', -afterEdit=>'op=editPage&npp='.$session{form}{npp} ); $tabform->getTab("layout")->template( -name=>"printableStyleTemplateId", -label=>WebGUI::International::get(1079), - -value=>($page{printableStyleId} || 3), + -value=>$self->getValue("printableStyleTemplateId"), -namespace=>'style', -afterEdit=>'op=editPage&npp='.$session{form}{npp} ); - if ($childCount) { +# if ($childCount) { $tabform->getTab("layout")->yesNo( -name=>"recurseStyle", -subtext=>'   '.WebGUI::International::get(106), -uiLevel=>9 ); - } +# } $tabform->getTab("properties")->HTMLArea( -name=>"description", -label=>WebGUI::International::get(85), @@ -209,6 +225,7 @@ sub getEditForm { -value=>$self->getValue("cacheTimeoutVisitor"), -uiLevel=>8 ); + return $tabform; } @@ -237,7 +254,20 @@ Logs the view of the wobject to the passive profiling mechanism. sub logView { my $self = shift; - WebGUI::PassiveProfiling::add($self->get("assetId")); + if ($session{setting}{passiveProfilingEnabled}) { + WebGUI::PassiveProfiling::add($self->get("assetId")); +# not sure what this will do in the new model +# WebGUI::PassiveProfiling::addPage(); # add wobjects on asset to passive profile log + } + # disabled for the time being because it's dangerous + # if ($session{form}{op} eq "" && $session{setting}{trackPageStatistics} && $session{form}{wid} ne "new") { + # WebGUI::SQL->write("insert into pageStatistics (dateStamp, userId, username, ipAddress, userAgent, referer, + # assetId, assetTitle, wobjectId, wobjectFunction) values (".time().",".quote($session{user}{userId}) + # .",".quote($session{user}{username}).", + # ".quote($session{env}{REMOTE_ADDR}).", ".quote($session{env}{HTTP_USER_AGENT}).", + # ".quote($session{env}{HTTP_REFERER}).", ".quote($session{asset}{assetId}).", + # ".quote($session{asset}{title}).", ".quote($session{form}{wid}).", ".quote($session{form}{func}).")"); + # } return; } @@ -261,16 +291,10 @@ sub processMacros { #------------------------------------------------------------------- -=head2 processTemplate ( templateId, vars [ , namespace ] ) +=head2 processTemplate ( vars, namespace [ , templateId ] ) Returns the content generated from this template. -B Only for use in wobjects that support templates. - -=head3 templateId - -An id referring to a particular template in the templates table. - =head3 hashRef A hash reference containing variables and loops to pass to the template engine. @@ -279,27 +303,41 @@ A hash reference containing variables and loops to pass to the template engine. A namespace to use for the template. Defaults to the wobject's namespace. +=head3 templateId + +An id referring to a particular template in the templates table. Defaults to $self->get("templateId"). + =cut sub processTemplate { my $self = shift; - my $templateId = shift; my $var = shift; - my $namespace = shift || $self->get("namespace"); - if ($self->{_useMetaData}) { - my $meta = WebGUI::MetaData::getMetaDataFields($self->get("wobjectId")); - foreach my $field (keys %$meta) { - $var->{$meta->{$field}{fieldName}} = $meta->{$field}{value}; - } + my $namespace = shift; + my $templateId = shift || $self->get("templateId"); + my $meta = WebGUI::MetaData::getMetaDataFields($self->get("wobjectId")); + foreach my $field (keys %$meta) { + $var->{$meta->{$field}{fieldName}} = $meta->{$field}{value}; } + my $wobjectToolbar = deleteIcon('func=delete',$self->get("url"),WebGUI::International::get(43)) + .editIcon('func=edit',$self->get("url")) + .moveUpIcon('func=promote',$self->get("url")) + .moveDownIcon('func=demote',$self->get("url")) + # .moveTopIcon('func=moveTop&wid='.${$wobject}{wobjectId}) + # .moveBottomIcon('func=moveBottom&wid='.${$wobject}{wobjectId}) + .cutIcon('func=cut',$self->get("url")) + .copyIcon('func=copy',$self->get("url")); + # if (${$wobject}{namespace} ne "WobjectProxy" && isIn("WobjectProxy",@{$session{config}{wobjects}})) { + # $wobjectToolbar .= shortcutIcon('func=createShortcut'); + #} + $var->{'controls'} = $wobjectToolbar; my %vars = ( - %{$self->{_property}}, + %{$self->{_properties}}, %{$var} ); if (defined $self->get("_WobjectProxy")) { $vars{isShortcut} = 1; - my ($originalPageURL) = WebGUI::SQL->quickArray("select urlizedTitle from page where pageId=".quote($self->get("pageId")),WebGUI::SQL->getSlave); - $vars{originalURL} = WebGUI::URL::gateway($originalPageURL."#".$self->get("wobjectId")); + my ($originalPageURL) = WebGUI::SQL->quickArray("select url from asset where assetId=".quote($self->getId),WebGUI::SQL->getSlave); + $vars{originalURL} = WebGUI::URL::gateway($originalPageURL."#".$self->getId); } return WebGUI::Template::process($templateId,$namespace, \%vars); } @@ -320,6 +358,14 @@ sub purge { +#------------------------------------------------------------------- + +sub view { + my $self = shift; + return "No view has been created for this wobject."; +} + + #------------------------------------------------------------------- =head2 www_createShortcut ( ) @@ -360,12 +406,47 @@ B This method should only need to be extended if you need to do some spec sub www_editSave { my $self = shift; - $self->SUPER::www_editSave(); + my $output = $self->SUPER::www_editSave(); WebGUI::MetaData::metaDataSave($self->getId); - return ""; + return $output; } + + +#------------------------------------------------------------------- + +sub www_view { + my $self = shift; + $self->logView(); + return WebGUI::Privilege::noAccess() unless $self->canView; + my $cache; + my $output; + my $useCache = ( + $session{form}{op} eq "" && + ( + ( $self->get("cacheTimeout") > 10 && $session{user}{userId} !=1) || + ( $self->get("cacheTimeoutVisitor") > 10 && $session{user}{userId} == 1) + ) && + not $session{var}{adminOn} + ); +# if ($useCache) { + # $cache = WebGUI::Cache->new("asset_".$self->getId."_".$session{user}{userId}); + # $output = $cache->get; +# } + unless ($output) { + $output = $self->view; + my $ttl; + if ($session{user}{userId} == 1) { + $ttl = $self->get("cacheTimeoutVisitor"); + } else { + $ttl = $self->get("cacheTimeout"); + } +# $cache->set($output, $ttl) if ($useCache && !WebGUI::HTTP::isRedirect()); + } + return WebGUI::Style::process($output,$self->get("styleTemplateId")); +} + 1; diff --git a/lib/WebGUI/Asset/Wobject/Article.pm b/lib/WebGUI/Asset/Wobject/Article.pm index e27f2076b..ae964b656 100644 --- a/lib/WebGUI/Asset/Wobject/Article.pm +++ b/lib/WebGUI/Asset/Wobject/Article.pm @@ -22,8 +22,7 @@ use WebGUI::International; use WebGUI::Paginator; use WebGUI::Privilege; use WebGUI::Session; -use WebGUI::URL; -use WebGUI::Wobject; +use WebGUI::Asset::Wobject; our @ISA = qw(WebGUI::Asset::Wobject); @@ -61,21 +60,21 @@ sub getEditForm { my $tabform = $self->SUPER::getEditForm(); $tabform->getTab("properties")->text( -name=>"linkTitle", - -label=>WebGUI::International::get(7,$self->get("namespace")), + -label=>WebGUI::International::get(7,"Article"), -value=>$self->getValue("linkTitle"), -uiLevel=>3 ); $tabform->getTab("properties")->url( -name=>"linkURL", - -label=>WebGUI::International::get(8,$self->get("namespace")), + -label=>WebGUI::International::get(8,"Article"), -value=>$self->getValue("linkURL"), -uiLevel=>3 ); $tabform->getTab("layout")->yesNo( -name=>"convertCarriageReturns", - -label=>WebGUI::International::get(10,$_[0]->get("namespace")), - -value=>$_[0]->getValue("convertCarriageReturns"), - -subtext=>'   '.WebGUI::International::get(11,$_[0]->get("namespace")).'', + -label=>WebGUI::International::get(10,"Article"), + -value=>$self->getValue("convertCarriageReturns"), + -subtext=>'   '.WebGUI::International::get(11,"Article").'', -uiLevel=>5, -defaultValue=>0 ); @@ -83,6 +82,15 @@ sub getEditForm { } +#------------------------------------------------------------------- +sub getIcon { + my $self = shift; + my $small = shift; + return $session{config}{extrasURL}.'/assets/small/article.gif' if ($small); + return $session{config}{extrasURL}.'/assets/article.gif'; +} + + #------------------------------------------------------------------- sub getName { return WebGUI::International::get(1,"Article"); @@ -90,31 +98,8 @@ sub getName { #------------------------------------------------------------------- -sub www_edit { - my $self = shift; - return WebGUI::Privilege::insufficient() unless $self->canEdit; - $self->getAdminConsole->setHelp("article add/edit"); - return $self->getAdminConsole->render($self->getEditForm,WebGUI::International::get("12","Article")); -} - - -#------------------------------------------------------------------- -sub www_editSave { - my ($image, $attachment, %property); - $_[0]->SUPER::www_editSave() if ($_[0]->get("wobjectId") eq "new"); - $image = WebGUI::Attachment->new("",$_[0]->get("wobjectId")); - $image->save("image"); - $attachment = WebGUI::Attachment->new("",$_[0]->get("wobjectId")); - $attachment->save("attachment"); - $property{image} = $image->getFilename if ($image->getFilename ne ""); - $property{attachment} = $attachment->getFilename if ($attachment->getFilename ne ""); - return $_[0]->SUPER::www_editSave(\%property); -} - -#------------------------------------------------------------------- -sub www_view { +sub view { my $self = shift; - $self->logView() if ($session{setting}{passiveProfilingEnabled}); my ($file, %var); if ($self->get("image") ne "") { $file = WebGUI::Attachment->new($self->get("image"),$self->get("wobjectId")); @@ -125,7 +110,7 @@ sub www_view { if ($self->get("convertCarriageReturns")) { $var{description} =~ s/\n/\\n/g; } - $var{"new.template"} = WebGUI::URL::page("wid=".$self->get("wobjectId")."&func=view")."&overrideTemplateId="; + $var{"new.template"} = $self->getUrl("wid=".$self->get("wobjectId")."&func=view")."&overrideTemplateId="; $var{"description.full"} = $var{description}; $var{"description.full"} =~ s/\^\-\;//g; $var{"description.first.100words"} = $var{"description.full"}; @@ -150,7 +135,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=".$self->get("wobjectId")."&func=view"),1); + my $p = WebGUI::Paginator->new($self->getUrl("wid=".$self->get("wobjectId")."&func=view"),1); if ($session{form}{makePrintable} || $var{description} eq "") { $var{description} =~ s/\^\-\;//g; $p->setDataByArrayRef([$var{description}]); @@ -167,7 +152,7 @@ sub www_view { $var{"attachment.url"} = $file->getURL; $var{"attachment.name"} = $file->getFilename; } - my $callback = WebGUI::URL::page("func=view&wid=".$self->get("wobjectId")); + my $callback = $self->getUrl("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")); @@ -188,10 +173,20 @@ sub www_view { forumId=>$self->get("forumId") }); } else { - return $self->processTemplate($templateId,\%var); + return $self->processTemplate(\%var, "Article", $templateId); } } +#------------------------------------------------------------------- +sub www_edit { + my $self = shift; + return WebGUI::Privilege::insufficient() unless $self->canEdit; + $self->getAdminConsole->setHelp("article add/edit"); + return $self->getAdminConsole->render($self->getEditForm->print,WebGUI::International::get("12","Article")); +} + + + 1; diff --git a/lib/WebGUI/Icon.pm b/lib/WebGUI/Icon.pm index 25568d432..2150061c9 100644 --- a/lib/WebGUI/Icon.pm +++ b/lib/WebGUI/Icon.pm @@ -101,7 +101,7 @@ The URL to any page. Defaults to the current page. sub copyIcon { my ($output, $pageURL); - $pageURL = $_[1] || $session{page}{urlizedTitle}; + $pageURL = $_[1] || $session{env}{PATH_INFO}; $output = ''; $output .= 'Copy'; return $output; @@ -125,7 +125,7 @@ The URL to any page. Defaults to the current page. sub cutIcon { my ($output, $pageURL); - $pageURL = $_[1] || $session{page}{urlizedTitle}; + $pageURL = $_[1] || $session{env}{PATH_INFO}; $output = ''; $output .= 'Cut'; return $output; @@ -158,7 +158,7 @@ sub deleteIcon { $confirmText = qq| onclick="return confirm('$confirmText')" |; } - $pageURL = $_[1] || $session{page}{urlizedTitle}; + $pageURL = $_[1] || $session{env}{PATH_INFO}; $output = ''; $output .= 'Delete'; @@ -195,7 +195,7 @@ The URL to any page. Defaults to the current page. sub editIcon { my ($output, $pageURL); - $pageURL = $_[1] || $session{page}{urlizedTitle}; + $pageURL = $_[1] || $session{env}{PATH_INFO}; $output = ''; $output .= 'Edit'; return $output; @@ -219,7 +219,7 @@ The URL to any page. Defaults to the current page. sub exportIcon { my ($output, $pageURL); - $pageURL = $_[1] || $session{page}{urlizedTitle}; + $pageURL = $_[1] || $session{env}{PATH_INFO}; $output = ''; # TODO Change icon to Jeffs export icon $output .= 'Export'; @@ -292,7 +292,7 @@ The URL to any page. Defaults to the current page. sub manageIcon { my ($output, $pageURL); - $pageURL = $_[1] || $session{page}{urlizedTitle}; + $pageURL = $_[1] || $session{env}{PATH_INFO}; $output = ''; $output .= 'Manage'; return $output; @@ -316,7 +316,7 @@ The URL to any page. Defaults to the current page. sub moveBottomIcon { my ($output, $pageURL); - $pageURL = $_[1] || $session{page}{urlizedTitle}; + $pageURL = $_[1] || $session{env}{PATH_INFO}; $output = ''; $output .= 'Move To Bottom'; return $output; @@ -340,7 +340,7 @@ The URL to any page. Defaults to the current page. sub moveDownIcon { my ($output, $pageURL); - $pageURL = $_[1] || $session{page}{urlizedTitle}; + $pageURL = $_[1] || $session{env}{PATH_INFO}; $output = ''; $output .= 'Move Down'; return $output; @@ -364,7 +364,7 @@ The URL to any page. Defaults to the current page. sub moveLeftIcon { my ($output, $pageURL); - $pageURL = $_[1] || $session{page}{urlizedTitle}; + $pageURL = $_[1] || $session{env}{PATH_INFO}; $output = ''; $output .= 'Move Left'; return $output; @@ -388,7 +388,7 @@ The URL to any page. Defaults to the current page. sub moveRightIcon { my ($output, $pageURL); - $pageURL = $_[1] || $session{page}{urlizedTitle}; + $pageURL = $_[1] || $session{env}{PATH_INFO}; $output = ''; $output .= 'Move Right'; return $output; @@ -412,7 +412,7 @@ The URL to any page. Defaults to the current page. sub moveTopIcon { my ($output, $pageURL); - $pageURL = $_[1] || $session{page}{urlizedTitle}; + $pageURL = $_[1] || $session{env}{PATH_INFO}; $output = ''; $output .= 'Move To Top'; return $output; @@ -436,7 +436,7 @@ The URL to any page. Defaults to the current page. sub moveUpIcon { my ($output, $pageURL); - $pageURL = $_[1] || $session{page}{urlizedTitle}; + $pageURL = $_[1] || $session{env}{PATH_INFO}; $output = ''; $output .= 'Move Up'; return $output; @@ -472,7 +472,7 @@ The URL to any page. Defaults to the current page. sub pasteIcon { my ($output, $pageURL); - $pageURL = $_[1] || $session{page}{urlizedTitle}; + $pageURL = $_[1] || $session{env}{PATH_INFO}; $output = ''; $output .= 'Paste'; return $output; @@ -496,7 +496,7 @@ The URL to any page. Defaults to the current page. sub shortcutIcon { my ($output, $pageURL); - $pageURL = $_[1] || $session{page}{urlizedTitle}; + $pageURL = $_[1] || $session{env}{PATH_INFO}; $output = ''; $output .= 'Shortcut'; return $output; @@ -520,7 +520,7 @@ The URL to any page. Defaults to the current page. sub viewIcon { my ($output, $pageURL); - $pageURL = $_[1] || $session{page}{urlizedTitle}; + $pageURL = $_[1] || $session{env}{PATH_INFO}; $output = ''; $output .= 'View'; return $output; diff --git a/lib/WebGUI/Macro/AdminBar.pm b/lib/WebGUI/Macro/AdminBar.pm index 6a594c98a..fe7a758e4 100644 --- a/lib/WebGUI/Macro/AdminBar.pm +++ b/lib/WebGUI/Macro/AdminBar.pm @@ -14,6 +14,7 @@ use strict qw(refs vars); use Tie::CPHash; use Tie::IxHash; use WebGUI::AdminConsole; +use WebGUI::Clipboard; use WebGUI::Grouping; use WebGUI::International; use WebGUI::Macro; @@ -37,18 +38,18 @@ sub process { $var{'packages.label'} = WebGUI::International::get(376); my @packages; my $i; - my $sth = WebGUI::SQL->read("select pageId,title from page where parentId='5'"); - while (my %data = $sth->hash) { - $data{title} =~ s/'//g; - push(@packages, { - 'package.url'=>WebGUI::URL::page('op=deployPackage&pid='.$data{pageId}), - 'package.label'=>$data{title}, - 'package.count'=>$i - }); - $i++; - } - $sth->finish; - $var{package_loop} = \@packages; +# my $sth = WebGUI::SQL->read("select pageId,title from page where parentId='5'"); + # while (my %data = $sth->hash) { +# $data{title} =~ s/'//g; +# push(@packages, { + # 'package.url'=>WebGUI::URL::page('op=deployPackage&pid='.$data{pageId}), + # 'package.label'=>$data{title}, +# 'package.count'=>$i +# }); +# $i++; + # } + # $sth->finish; +# $var{package_loop} = \@packages; #--contenttypes adder $var{'contentTypes.label'} = WebGUI::International::get(1083); foreach my $namespace (@{$session{config}{wobjects}}) { @@ -81,64 +82,18 @@ sub process { $var{'addpage.label'} = WebGUI::International::get(2); #--clipboard paster $var{'clipboard.label'} = WebGUI::International::get(1082); - %hash2 = (); - - # get pages and store in array of arrays in order to integrate with wobjects and sort by buffer date - if ($session{setting}{sharedClipboard} eq "1") { - $query = "select bufferDate,pageId,title from page where parentId='2' order by bufferDate"; - } else { - $query = "select bufferDate,pageId,title from page where parentId='2' " - ." and bufferUserId=".quote($session{user}{userId}) - ." order by bufferDate"; - } - $r = WebGUI::SQL->read($query); - while (%cphash = $r->hash) { - $cphash{title} =~ s/'//g; - push @item, [ $cphash{bufferDate}, - WebGUI::URL::page('op=pastePage&pageId='.$cphash{pageId}), - $cphash{title} . ' ('. WebGUI::International::get(2) .')' ]; - } - $r->finish; - - # get wobjects and store in array of arrays in order to integrate with pages and sort by buffer date - if ($session{setting}{sharedClipboard} eq "1") { - $query = "select bufferDate,wobjectId,title,namespace from wobject where pageId='2' " - ." order by bufferDate"; - } else { - $query = "select bufferDate,wobjectId,title,namespace from wobject where pageId='2' " - ." and bufferUserId=".quote($session{user}{userId}) - ." order by bufferDate"; - } - $r = WebGUI::SQL->read($query); - while (%cphash = $r->hash) { - $cphash{title} =~ s/'//g; - push @item, [ $cphash{bufferDate}, - WebGUI::URL::page('func=paste&wid='.$cphash{wobjectId}), - $cphash{title} . ' ('. $cphash{namespace} .')' ]; - } - $r->finish; - - # Reverse sort by bufferDate and and create hash from list values - my @sorted_item = sort {$b->[0] <=> $a->[0]} @item; - @item = (); - for $i ( 0 .. $#sorted_item ) { - $hash2{ $sorted_item[$i][1] } = $sorted_item[$i][2]; - } - @sorted_item = (); - my @clipboard; - $i = 0; - foreach my $key (keys %hash2) { - push(@clipboard,{ - 'clipboard.url'=>$key, - 'clipboard.label'=>$hash2{$key}, - 'clipboard.count'=>$i + my $clipboard = WebGUI::Clipboard::getAssetsInClipboard(); + foreach my $item (@{$clipboard}) { + my $title = $item->{title}; + $title =~ s/'//g; # stops it from breaking the javascript menus + push(@{$var{clipboard_loop}}, { + 'clipboard.label'=>$title, + 'clipboard.url'=>WebGUI::URL::page("func=paste&assetId=".$item->{assetId}) }); - $i++; } - $var{'clipboard_loop'} = \@clipboard; #--admin functions %hash = ( - 'http://validator.w3.org/check?uri='.WebGUI::URL::escape(WebGUI::URL::page())=>WebGUI::International::get(399), + 'http://validator.w3.org/check?uri=referer'=>WebGUI::International::get(399), ); my $acParams = WebGUI::AdminConsole->getAdminConsoleParams; $hash{$acParams->{url}} = $acParams->{title} if ($acParams->{canUse}); diff --git a/lib/WebGUI/Macro/AdminToggle.pm b/lib/WebGUI/Macro/AdminToggle.pm index 01e1e2e51..30e868aa5 100644 --- a/lib/WebGUI/Macro/AdminToggle.pm +++ b/lib/WebGUI/Macro/AdminToggle.pm @@ -22,9 +22,9 @@ use WebGUI::URL; sub process { if (WebGUI::Grouping::isInGroup(12)) { my %var; - my @param = WebGUI::Macro::getParams($_[0]); - my $turnOn = $param[0] || WebGUI::International::get(516); - my $turnOff = $param[1] || WebGUI::International::get(517); + my ($turnOn,$turnOff,$templateName) = WebGUI::Macro::getParams($_[0]); + $turnOn |= WebGUI::International::get(516); + $turnOff |= WebGUI::International::get(517); if ($session{var}{adminOn}) { $var{'toggle.url'} = WebGUI::URL::page('op=switchOffAdmin'); $var{'toggle.text'} = $turnOff; @@ -32,7 +32,7 @@ sub process { $var{'toggle.url'} = WebGUI::URL::page('op=switchOnAdmin'); $var{'toggle.text'} = $turnOn; } - return WebGUI::Template::process(WebGUI::Template::getIdByName($param[2],"Macro/AdminToggle"),"Macro/AdminToggle",\%var); + return WebGUI::Template::process(WebGUI::Template::getIdByName($templateName,"Macro/AdminToggle")||1,"Macro/AdminToggle",\%var); } return ""; } diff --git a/lib/WebGUI/Macro/Backslash_pageUrl.pm b/lib/WebGUI/Macro/Backslash_pageUrl.pm index 1459c2128..d7e65b6e1 100644 --- a/lib/WebGUI/Macro/Backslash_pageUrl.pm +++ b/lib/WebGUI/Macro/Backslash_pageUrl.pm @@ -16,7 +16,9 @@ use WebGUI::URL; #------------------------------------------------------------------- sub process { - return WebGUI::URL::getScriptURL().$session{page}{urlizedTitle}; + my $pathinfo = $session{env}{PATH_INFO}; + $pathinfo =~ s/^\/(.*)/$1/; + return WebGUI::URL::getScriptURL().$pathinfo; } diff --git a/lib/WebGUI/Macro/H_homeLink.pm b/lib/WebGUI/Macro/H_homeLink.pm index 462c92845..6925f2d47 100644 --- a/lib/WebGUI/Macro/H_homeLink.pm +++ b/lib/WebGUI/Macro/H_homeLink.pm @@ -23,7 +23,7 @@ sub process { if ($session{setting}{defaultPage} eq $session{page}{pageId}) { $temp = $session{page}{urlizedTitle}; } else { - ($temp) = WebGUI::SQL->quickArray("select urlizedTitle from page where pageId=".quote($session{setting}{defaultPage}),WebGUI::SQL->getSlave); + ($temp) = WebGUI::SQL->quickArray("select url from asset where assetId=".quote($session{setting}{defaultPage}),WebGUI::SQL->getSlave); } $temp = WebGUI::URL::gateway($temp); if ($param[0] ne "linkonly") { diff --git a/lib/WebGUI/Macro/LoginToggle.pm b/lib/WebGUI/Macro/LoginToggle.pm index 8549b2538..c47be4c8b 100644 --- a/lib/WebGUI/Macro/LoginToggle.pm +++ b/lib/WebGUI/Macro/LoginToggle.pm @@ -32,7 +32,7 @@ sub process { $var{'toggle.url'} = WebGUI::URL::page('op=logout'); $var{'toggle.text'} = $logout; } - return WebGUI::Template::process(WebGUI::Template::getIdByName($param[3],"Macro/LoginToggle"), "Macro/LoginToggle", \%var); + return WebGUI::Template::process(WebGUI::Template::getIdByName($param[3],"Macro/LoginToggle")||1, "Macro/LoginToggle", \%var); } diff --git a/lib/WebGUI/SQL.pm b/lib/WebGUI/SQL.pm index 0e543039e..8684fdaed 100644 --- a/lib/WebGUI/SQL.pm +++ b/lib/WebGUI/SQL.pm @@ -217,7 +217,6 @@ sub buildHashRef { %hash = $_[0]->buildHash($_[1],$_[2]); return \%hash; } - #------------------------------------------------------------------- diff --git a/lib/WebGUI/Storage.pm b/lib/WebGUI/Storage.pm index fa0c87b54..3928b4308 100644 --- a/lib/WebGUI/Storage.pm +++ b/lib/WebGUI/Storage.pm @@ -88,7 +88,7 @@ The error message to add to the object. sub _addError { my $self = shift; my $errorMessage = shift; - push(@$self->{_errors},$errorMessage); + push(@{$self->{_errors}},$errorMessage); WebGUI::ErrorHandler::warn($errorMessage); } @@ -375,7 +375,7 @@ sub get { my $class = shift; my $id = shift; my $parts = _getStorageParts($id); - bless {_id => $id, _part1 => $part->[0], _part2 => $part->[1]}, $class; + bless {_id => $id, _part1 => $parts->[0], _part2 => $parts->[1]}, $class; } #------------------------------------------------------------------- @@ -473,18 +473,8 @@ Returns the size of this file. sub getFileSize { my $self = shift; my $filename = shift; - my ($size); my (@attributes) = stat($self->getPath($filename)); - if ($attributes[7] > 1048576) { - $size = round($attributes[7]/1048576); - $size .= 'MB'; - } elsif ($attributes[7] > 1024) { - $size = round($attributes[7]/1024); - $size .= 'kB'; - } else { - $size = $attributes[7].'B'; - } - return $size; + return $attributes[7]; } diff --git a/lib/WebGUI/Style.pm b/lib/WebGUI/Style.pm index b38c33af5..38aa4cef4 100644 --- a/lib/WebGUI/Style.pm +++ b/lib/WebGUI/Style.pm @@ -108,7 +108,7 @@ sub getTemplate { #------------------------------------------------------------------- -=head2 process ( content [ , templateId ] ) +=head2 process ( content, templateId ) Returns a parsed style with content based upon the current WebGUI session information. @@ -118,19 +118,16 @@ The content to be parsed into the style. Usually generated by WebGUI::Page::gene =head3 templateId -The unique identifier for the template to retrieve. Defaults to the style template tied to the current page. +The unique identifier for the template to retrieve. =cut sub process { my %var; $var{'body.content'} = shift; - my $templateId = shift || $session{page}{styleId}; + my $templateId = shift; if ($session{page}{makePrintable}) { $templateId = $session{page}{printableStyleId}; - } elsif ($session{page}{useAdminStyle}) { - #$templateId = $session{setting}{adminStyleId}; - $templateId = "adminConsole"; } elsif ($session{scratch}{personalStyleId} ne "") { $templateId = $session{scratch}{personalStyleId}; } elsif ($session{page}{useEmptyStyle}) { diff --git a/lib/WebGUI/Template.pm b/lib/WebGUI/Template.pm index e121775ad..c94f892f8 100644 --- a/lib/WebGUI/Template.pm +++ b/lib/WebGUI/Template.pm @@ -96,17 +96,17 @@ Returns a hash reference containing all of the template parameters. =head3 templateId -Defaults to "1". Specify the templateId of the template to retrieve. +Specify the templateId of the template to retrieve. =head3 namespace -Defaults to "page". Specify the namespace of the template to retrieve. +Specify the namespace of the template to retrieve. =cut sub get { - my $templateId = shift || 1; - my $namespace = shift || "page"; + my $templateId = shift; + my $namespace = shift; return WebGUI::SQL->quickHashRef("select * from template where templateId=".quote($templateId)." and namespace=".quote($namespace),WebGUI::SQL->getSlave); } @@ -162,11 +162,11 @@ Evaluate a template replacing template commands for HTML. =head3 templateId -Defaults to "1". Specify the templateId of the template to retrieve. +Specify the templateId of the template to retrieve. =head3 namespace -Defaults to "page". Specify the namespace of the template to retrieve. +Specify the namespace of the template to retrieve. =head3 vars @@ -175,8 +175,8 @@ A hash reference containing template variables and loops. Automatically includes =cut sub process { - my $templateId = shift || 1; - my $namespace = shift || "page"; + my $templateId = shift; + my $namespace = shift; my $vars = shift; my $file = _getTemplateFile($templateId,$namespace); my $fileCacheDir = $session{config}{uploadsPath}.$session{os}{slash}."temp".$session{os}{slash}."templatecache"; @@ -202,7 +202,8 @@ sub process { } } if ($session{config}{templateCacheType} eq "file" && not $error) { - $params{file_cache} = 1; + # disabled until we can figure out what's wrong with it + # $params{file_cache} = 1; } elsif ($session{config}{templateCacheType} eq "memory") { $params{cache} = 1; } elsif ($session{config}{templateCacheType} eq "ipc") { diff --git a/lib/WebGUI/URL.pm b/lib/WebGUI/URL.pm index ab62645f1..2b3a15e40 100644 --- a/lib/WebGUI/URL.pm +++ b/lib/WebGUI/URL.pm @@ -121,12 +121,12 @@ Name value pairs to add to the URL in the form of: sub gateway { my $url = getScriptURL().$_[0]; - if ($_[1]) { - $url = append($url,$_[1]); - } if ($session{setting}{preventProxyCache} == 1) { $url = append($url,"noCache=".randint(0,1000).';'.time()); } + if ($_[1]) { + $url = append($url,$_[1]); + } return $url; } @@ -258,13 +258,15 @@ sub page { } else { $url = getScriptURL(); } - $url .= $session{page}{urlizedTitle}; - if ($pairs) { - $url = append($url,$pairs); - } + my $pathinfo = $session{env}{PATH_INFO}; + $pathinfo =~ s/^\/(.*)/$1/; + $url .= $pathinfo; if ($session{setting}{preventProxyCache} == 1) { $url = append($url,"noCache=".randint(0,1000).';'.time()); } + if ($pairs) { + $url = append($url,$pairs); + } return $url; } diff --git a/lib/WebGUI/Utility.pm b/lib/WebGUI/Utility.pm index 62f9398aa..a35f485b5 100644 --- a/lib/WebGUI/Utility.pm +++ b/lib/WebGUI/Utility.pm @@ -22,7 +22,7 @@ use Tie::IxHash; our @ISA = qw(Exporter); our @EXPORT = qw(&isBetween &makeTabSafe &makeArrayTabSafe &randomizeHash &commify &randomizeArray - &sortHashDescending &sortHash &isIn &makeCommaSafe &makeArrayCommaSafe &randint &round); + &formatBytes &sortHashDescending &sortHash &isIn &makeCommaSafe &makeArrayCommaSafe &randint &round); =head1 NAME @@ -37,6 +37,7 @@ This package provides miscellaneous but useful utilities to the WebGUI programme use WebGUI::Utility; $string = commify($integer); + $size = formatBytes($integer); $boolean = isIn($value, @array); makeArrayCommaSafe(\@array); makeArrayTabSafe(\@array); @@ -73,6 +74,32 @@ sub commify { return scalar reverse $text; } + +#------------------------------------------------------------------- + +=head2 formatBytes ( integer ) + +Returns a formatted file size like "3MB" or "44kB". + +=head3 integer + +An integer representing the number of bytes to format. + +=cut + +sub formatBytes { + my $size = shift; + if ($size > 1048576) { + return round($size/1048576).'MB'; + } elsif ($size > 1024) { + return round($size/1024).'kB'; + } else { + return $size.'B'; + } +} + + + #------------------------------------------------------------------- =head2 isBetween ( value, first, second ) diff --git a/lib/WebGUI/i18n/English/WebGUI.pm b/lib/WebGUI/i18n/English/WebGUI.pm index e787d0d36..e0f0064d3 100644 --- a/lib/WebGUI/i18n/English/WebGUI.pm +++ b/lib/WebGUI/i18n/English/WebGUI.pm @@ -2075,10 +2075,6 @@ Choose which group can view this page. If you want both visitors and registered Choose the group that can edit this page. The group assigned editing rights can also always view the page.

-Wobject privileges?
-Allows content managers to specify view/edit privileges on a per wobject basis rather than relying on the privileges on the page. -

- Recursively set privileges?
You can optionally give the privileges of this page to all pages under this page.

@@ -4018,11 +4014,6 @@ The toolbar for manipulating the properties of the page. lastUpdated => 1031514049 }, - '1003' => { - message => q|Wobject privileges?|, - lastUpdated => 1056041703 - }, - '555' => { message => q|Edit this user's karma.|, lastUpdated => 1031514049 diff --git a/www/extras/assets/layout.gif b/www/extras/assets/layout.gif new file mode 100644 index 000000000..0687b2424 Binary files /dev/null and b/www/extras/assets/layout.gif differ diff --git a/www/extras/assets/small/layout.gif b/www/extras/assets/small/layout.gif new file mode 100644 index 000000000..68fabbe32 Binary files /dev/null and b/www/extras/assets/small/layout.gif differ