diff --git a/docs/changelog/7.x.x.txt b/docs/changelog/7.x.x.txt index 2e65ad823..f4c2865fb 100644 --- a/docs/changelog/7.x.x.txt +++ b/docs/changelog/7.x.x.txt @@ -5,6 +5,14 @@ WebGUI::Operation::Workflow::www_activityHelper for details. - api: Asset properties that have default values are now enforced by the API as they always have been by the user interface. + - api: You may now use a displayOnly attribute in your asset properties list + that will display a field, but is not settable via the update() method. + - api: You may now use a customDrawMethod attribute in your asset properties + list that will enable you to add custom display options for that fields when + the edit form is automatically generated. + - Added file attachments to the Wiki. + - Added a new attachments form control. + - Added a form control skeleton. - Added Site Starter to WebGUI Initial Configuration. - Added pagination to purchase history in commerce. - Replaced color picker form control with a more robust version. diff --git a/docs/upgrades/templates-7.4.0/wikipageedit.tmpl b/docs/upgrades/templates-7.4.0/wikipageedit.tmpl index 944e07605..997184e1f 100644 --- a/docs/upgrades/templates-7.4.0/wikipageedit.tmpl +++ b/docs/upgrades/templates-7.4.0/wikipageedit.tmpl @@ -3,26 +3,26 @@ + + + + - - -
- + ~~~ diff --git a/lib/WebGUI/Asset.pm b/lib/WebGUI/Asset.pm index 47a6cb51f..887ecb57b 100644 --- a/lib/WebGUI/Asset.pm +++ b/lib/WebGUI/Asset.pm @@ -334,7 +334,7 @@ sub definition { hoverHelp=>$i18n->get('104 description'), uiLevel=>3, fieldType=>'text', - defaultValue=>undef, + defaultValue=>'', filter=>'fixUrl' }, isHidden=>{ @@ -865,7 +865,16 @@ sub getEditForm { } my $tab = $fieldHash{tab} || "properties"; - $tabform->getTab($tab)->dynamicField(%params); + + # use a custom draw method + my $drawMethod = $properties->{$fieldName}{customDrawMethod}; + if ($drawMethod) { + $params{value} = $self->$drawMethod(\%params); + $params{fieldType} = "readOnly"; + } + + #draw the field + $tabform->getTab($tab)->dynamicField(%params); } } @@ -1081,6 +1090,25 @@ sub getRoot { } +#------------------------------------------------------------------- + +=head2 getTempspace ( session ) + +Constructor. Returns the tempspace folder. + +=head3 session + +A reference to the current session. + +=cut + +sub getTempspace { + my $class = shift; + my $session = shift; + return WebGUI::Asset->newByDynamicClass($session, "tempspace0000000000000"); +} + + #------------------------------------------------------------------- =head2 getTitle ( ) @@ -2025,11 +2053,16 @@ sub update { # deal with all the properties in this part of the definition foreach my $property (keys %{$definition->{properties}}) { - + # skip a property unless it was specified to be set by the properties field or has a default value next unless (exists $properties->{$property} || exists $definition->{properties}{$property}{defaultValue}); + + # skip a property if it has the display only flag set + next if ($properties->{property}{displayOnly}); + # use the update value my $value = $properties->{$property}; + # use the current value because the update value was undef unless (defined $value) { $value = $self->get($property); diff --git a/lib/WebGUI/Asset/WikiPage.pm b/lib/WebGUI/Asset/WikiPage.pm index 442abe985..af21dee28 100644 --- a/lib/WebGUI/Asset/WikiPage.pm +++ b/lib/WebGUI/Asset/WikiPage.pm @@ -14,8 +14,8 @@ use base 'WebGUI::Asset'; use strict; use Tie::IxHash; use WebGUI::International; -use WebGUI::Storage::Image; use WebGUI::Utility; +use WebGUI::VersionTag; #------------------------------------------------------------------- @@ -41,10 +41,6 @@ Override the default method in order to deal with attachments. sub addRevision { my $self = shift; my $newSelf = $self->SUPER::addRevision(@_); - if ($self->get("storageId")) { - my $newStorage = WebGUI::Storage->get($self->session,$self->get("storageId"))->copy; - $newSelf->update({storageId=>$newStorage->getId}); - } my $now = time(); $newSelf->update({ isHidden => 1, @@ -80,8 +76,6 @@ sub definition { tie %properties, 'Tie::IxHash'; %properties = ( - storageId => { fieldType => 'image', - defaultValue => undef }, content => { fieldType => "HTMLArea", defaultValue => undef }, views => { @@ -150,16 +144,16 @@ sub getEditForm { formHeader => WebGUI::Form::formHeader($session, { action => $url}) .WebGUI::Form::hidden($session, { name => 'func', value => 'editSave' }) .WebGUI::Form::hidden($session, { name=>"proceed", value=>"showConfirmation" }), - formTitle => WebGUI::Form::text($session, { name => 'title', maxlength => 255, size => 40, value => $self->get('title') }), - formContent => WebGUI::Form::HTMLArea($session, { name => 'content', richEditId => $wiki->get('richEditor'), value => $self->get('content') }), + formTitle => WebGUI::Form::text($session, { name => 'title', maxlength => 255, size => 40, + value => $self->get('title'), defaultValue=>$form->get("title","text") }), + formContent => WebGUI::Form::HTMLArea($session, { name => 'content', richEditId => $wiki->get('richEditor'), value => $self->get('content') }) , formSubmit => WebGUI::Form::submit($session, { value => 'Save' }), formProtect => WebGUI::Form::yesNo($session, { name => "isProtected", value=>$self->getValue("isProtected")}), - formAttachment => '', formKeywords => WebGUI::Form::text($session, { name => "keywords", value => WebGUI::Keyword->new($session)->getKeywordsForAsset({asset=>$self}), }), - allowsAttachments => $wiki->get("maxAttachments"), + allowsAttachments => $wiki->get("allowAttachments"), formFooter => WebGUI::Form::formFooter($session), isNew => ($self->getId eq "new"), canAdminister => $wiki->canAdminister, @@ -172,27 +166,20 @@ sub getEditForm { protectQuestionLabel => $i18n->get("protectQuestionLabel"), isProtected => $self->isProtected }; + my $children = []; if ($self->getId eq "new") { $var->{formHeader} .= WebGUI::Form::hidden($session, { name=>"assetId", value=>"new" }) .WebGUI::Form::hidden($session, { name=>"class", value=>$form->process("class","className") }); - } + } else { + $children = $self->getLineage(["children"]); + } + $var->{formAttachment} = WebGUI::Form::Attachments($session, { + value => $children, + maxAttachments => $wiki->get("allowAttachments") + }); return $self->processTemplate($var, $wiki->getValue('pageEditTemplateId')); } -#------------------------------------------------------------------- -sub getStorageLocation { - my $self = shift; - unless (exists $self->{_storageLocation}) { - if ($self->get("storageId") eq "") { - $self->{_storageLocation} = WebGUI::Storage::Image->create($self->session); - $self->update({storageId=>$self->{_storageLocation}->getId}); - } else { - $self->{_storageLocation} = WebGUI::Storage::Image->get($self->session,$self->get("storageId")); - } - } - return $self->{_storageLocation}; -} - #------------------------------------------------------------------- sub getWiki { my $self = shift; @@ -249,29 +236,26 @@ sub processPropertiesFromFormPost { $self->update({isProtected => $self->session->form("isProtected")}); } - delete $self->{_storageLocation}; - my $size = 0; - my $storage = $self->getStorageLocation; - - foreach my $file (@{$storage->getFiles}) { - if ($storage->isImage($file)) { - my ($w, $h) = $storage->getSizeInPixels($file); - my $max_size = $self->getWiki->get("maxImageSize") - || $self->session->setting->get("maxImageSize"); - if($w > $max_size || $h > $max_size) { - if($w > $h) { - $storage->resize($file, $max_size); - } - else { - $storage->resize($file, 0, $max_size); - } - } - $storage->generateThumbnail($file, $self->getWiki->get("thumbnailSize")); - } - $size += $storage->getFileSize($file); + my @attachments = $self->session->form->param("attachments"); + my @tags = (); + foreach my $assetId (@attachments) { + my $asset = WebGUI::Asset->newByDynamicClass($self->session, $assetId); + if (defined $asset) { + unless ($asset->get("parentId") eq $self->getId) { + $asset->setParent($self); + } + push(@tags, $asset->get("tagId")); + $asset->setVersionTag($self->get("tagId")); } - - $self->setSize($size); + } + foreach my $tag (@tags) { + my $version = WebGUI::VersionTag->new($self->session, $tag); + if (defined $version) { + if ($version->getAssetCount == 0) { + $version->rollback; + } + } + } $self->requestAutoCommit; } @@ -332,21 +316,22 @@ sub view { }); } my $var = { - keywordsLoop => \@keywordsLoop, - viewLabel => $i18n->get("viewLabel"), - editLabel => $i18n->get("editLabel"), - historyLabel => $i18n->get("historyLabel"), - wikiHomeLabel=>$i18n->get("wikiHomeLabel", "Asset_WikiMaster"), - searchLabel=>$i18n->get("searchLabel", "Asset_WikiMaster"), - searchUrl=>$self->getParent->getUrl("func=search"), - recentChangesUrl=>$self->getParent->getUrl("func=recentChanges"), - recentChangesLabel=>$i18n->get("recentChangesLabel", "Asset_WikiMaster"), - mostPopularUrl=>$self->getParent->getUrl("func=mostPopular"), - mostPopularLabel=>$i18n->get("mostPopularLabel", "Asset_WikiMaster"), - wikiHomeUrl=>$self->getParent->getUrl, - historyUrl=>$self->getUrl("func=getHistory"), - editContent=>$self->getEditForm, - content => $self->getWiki->autolinkHtml($self->scrubContent), + keywordsLoop => \@keywordsLoop, + viewLabel => $i18n->get("viewLabel"), + editLabel => $i18n->get("editLabel"), + historyLabel => $i18n->get("historyLabel"), + wikiHomeLabel => $i18n->get("wikiHomeLabel", "Asset_WikiMaster"), + searchLabel => $i18n->get("searchLabel", "Asset_WikiMaster"), + searchUrl => $self->getParent->getUrl("func=search"), + recentChangesUrl => $self->getParent->getUrl("func=recentChanges"), + recentChangesLabel => $i18n->get("recentChangesLabel", "Asset_WikiMaster"), + mostPopularUrl => $self->getParent->getUrl("func=mostPopular"), + mostPopularLabel => $i18n->get("mostPopularLabel", "Asset_WikiMaster"), + wikiHomeUrl => $self->getParent->getUrl, + historyUrl => $self->getUrl("func=getHistory"), + editContent => $self->getEditForm, + allowsAttachments => $self->getWiki->get("allowAttachments"), + content => $self->getWiki->autolinkHtml($self->scrubContent), }; return $self->processTemplate($var, $self->getWiki->get("pageTemplateId")); } diff --git a/lib/WebGUI/Asset/Wobject/Article.pm b/lib/WebGUI/Asset/Wobject/Article.pm index f048caf89..dc3018074 100644 --- a/lib/WebGUI/Asset/Wobject/Article.pm +++ b/lib/WebGUI/Asset/Wobject/Article.pm @@ -141,6 +141,7 @@ sub definition { return $class->SUPER::definition($session, $definition); } + #------------------------------------------------------------------- sub duplicate { diff --git a/lib/WebGUI/Asset/Wobject/WikiMaster.pm b/lib/WebGUI/Asset/Wobject/WikiMaster.pm index b5a1aeb04..ec1064ca7 100644 --- a/lib/WebGUI/Asset/Wobject/WikiMaster.pm +++ b/lib/WebGUI/Asset/Wobject/WikiMaster.pm @@ -40,11 +40,12 @@ sub appendRecentChanges { my $self = shift; my $var = shift; my $limit = shift || $self->get("recentChangesCount") || 50; - my $rs = $self->session->db->read("select asset.assetId, revisionDate from assetData left join asset on assetData.assetId=asset.assetId where - lineage like ? and lineage<>? and status='approved' order by revisionDate desc limit ?", - [$self->get("lineage").'%', $self->get("lineage"), $limit]); - while (my ($id, $version) = $rs->array) { - my $asset = WebGUI::Asset->new($self->session, $id, "WebGUI::Asset::WikiPage", $version); + foreach my $asset (@{$self->getLineage(["children"], { + returnObjects => 1, + limit => $limit, + includeOnlyClasses =>["WebGUI::Asset::WikiPage"], + orderByClause => "assetData.revisionDate desc" + })}) { my $user = WebGUI::User->new($self->session, $asset->get("actionTakenBy")); my $specialAction = ''; my $isAvailable = 1; @@ -296,6 +297,13 @@ sub definition { label => $i18n->get("max image size"), hoverHelp => $i18n->get("max image size help") }, + allowAttachments => { + fieldType => "integer", + defaultValue => 0, + tab => "security", + label => $i18n->get("allow attachments"), + hoverHelp => $i18n->get("allow attachments help"), + }, useContentFilter =>{ fieldType=>"yesNo", defaultValue=>1, @@ -390,7 +398,6 @@ sub www_byKeyword { }); $p->setBaseUrl($self->getUrl("func=byKeyword")); foreach my $assetData (@{$p->getPageData}) { -$self->session->errorHandler->warn($assetData->{assetId}); my $asset = WebGUI::Asset->newByDynamicClass($self->session, $assetData->{assetId}); next unless defined $asset; push(@pages, { @@ -447,6 +454,7 @@ sub www_recentChanges { sub www_search { my $self = shift; my $i18n = WebGUI::International->new($self->session, "Asset_WikiMaster"); + my $queryString = $self->session->form->process('query', 'text'); my $var = { resultsLabel=>$i18n->get("resultsLabel"), notWhatYouWanted=>$i18n->get("notWhatYouWantedLabel"), @@ -459,9 +467,8 @@ sub www_search { mostPopularUrl=>$self->getUrl("func=mostPopular"), mostPopularLabel=>$i18n->get("mostPopularLabel"), wikiHomeUrl=>$self->getUrl, - addPageUrl=>$self->getUrl("func=add;class=WebGUI::Asset::WikiPage"), + addPageUrl=>$self->getUrl("func=add;class=WebGUI::Asset::WikiPage;title=".$queryString), }; - my $queryString = $self->session->form->process('query', 'text'); if (defined $queryString) { $self->session->scratch->set('wikiSearchQueryString', $queryString); } diff --git a/lib/WebGUI/AssetVersioning.pm b/lib/WebGUI/AssetVersioning.pm index 271e43a32..cdaf85ade 100644 --- a/lib/WebGUI/AssetVersioning.pm +++ b/lib/WebGUI/AssetVersioning.pm @@ -357,11 +357,31 @@ Sets the versioning lock to "on" so that this piece of content may not be edited sub setVersionLock { my $self = shift; - $self->session->db->write("update asset set isLockedBy=".$self->session->db->quote($self->session->user->userId)." where assetId=".$self->session->db->quote($self->getId)); + $self->session->db->write("update asset set isLockedBy=? where assetId=?", [$self->session->user->userId, $self->getId]); $self->updateHistory("locked"); $self->purgeCache; } +#------------------------------------------------------------------- + +=head2 setVersionTag ( tagId ) + +Changes the version tag associated with this revision to something new. + +=head3 tagId + +A new version tag id. + +=cut + +sub setVersionTag { + my $self = shift; + my $tagId = shift; + $self->session->db->write("update assetData set tagId=? where assetId=?", [$tagId, $self->getId]); + $self->updateHistory("changed version tag to $tagId"); + $self->purgeCache; +} + #------------------------------------------------------------------- diff --git a/lib/WebGUI/Form/Attachments.pm b/lib/WebGUI/Form/Attachments.pm new file mode 100644 index 000000000..e485b2fe8 --- /dev/null +++ b/lib/WebGUI/Form/Attachments.pm @@ -0,0 +1,294 @@ +package WebGUI::Form::Attachments; + +=head1 LEGAL + + ------------------------------------------------------------------- + WebGUI is Copyright 2001-2007 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 + ------------------------------------------------------------------- + +=cut + +use strict; +use base 'WebGUI::Form::Control'; +use WebGUI::Asset; +use WebGUI::International; +use WebGUI::Storage::Image; +use WebGUI::VersionTag; + +=head1 NAME + +Package WebGUI::Form::File + +=head1 DESCRIPTION + +Creates a javascript driven file upload control for asset attachments. + +B This is meant to be used in +conjunction with one or more Rich Editors (see WebGUI::Form::HTMLArea) and should be placed above them in the field +list for ease of use. + +B This form control is not capable of handling all aspects of the files uploaded to it. So you as the +developer need to complete the process after the form has been submitted. See the getValueFromPost() method for +details. + +=head1 SEE ALSO + +This is a subclass of WebGUI::Form::Control. + +=head1 METHODS + +The following methods are specifically available from this class. Check the superclass for additional methods. + +=cut + +#------------------------------------------------------------------- + +=head2 definition ( [ additionalTerms ] ) + +See the super class for additional details. + +=head3 additionalTerms + +The following additional parameters have been added via this sub class. + +=head4 name + +If no name is specified a default name of "attachments" will be used. + +=head4 maxAttachments + +How many attachments will be allowed to be uploaded. Defaults to 1. + +=head4 value + +An array reference of asset objects (not ids, but objects) that should be displayed in the attachments box. + +=cut + +sub definition { + my $class = shift; + my $session = shift; + my $definition = shift || []; + my $i18n = WebGUI::International->new($session); + push(@{$definition}, { + formName=>{ + defaultValue=>$i18n->get("file") + }, + name=>{ + defaultValue=>"attachments" + }, + maxAttachments=>{ + defaultValue=>1 + }, + profileEnabled=>{ + defaultValue=>0 + }, + dbDataType => { + defaultValue => "VARCHAR(22) BINARY", + }, + }); + return $class->SUPER::definition($session, $definition); +} + +#------------------------------------------------------------------- + +=head2 getValueFromPost ( ) + +Returns an array reference of asset ids that have been uploaded. New assets are uploaded to a temporary location, +and you must move them to the place in the asset tree you want them, or they will be automatically deleted. + +=cut + +sub getValueFromPost { + my $self = shift; + my @values = $self->session->form->param($self->get("name")); + return \@values; +} + +#------------------------------------------------------------------- + +=head2 toHtml ( ) + +Renders an attachments control. + +=cut + +sub toHtml { + my $self = shift; + my @assetIds = @{$self->get("value")}; + my $attachmentsList = "attachments=".join(";attachments=", @assetIds) if (scalar(@assetIds)); + return '
'; +} + + + +#------------------------------------------------------------------- + +=head2 www_delete () + +Deletes an attachment. + +=cut + +sub www_delete { + my $session = shift; + my $assetId = $session->form->param("assetId"); + my @assetIds = $session->form->param("attachments"); + if ($assetId ne "") { + my $asset = WebGUI::Asset->newByDynamicClass($session, $assetId); + if (defined $asset) { + if ($asset->canEdit) { + my $version = WebGUI::VersionTag->new($session, $asset->get("tagId")); + $asset->purge; + if ($version->getAssetCount == 0) { + $version->rollback; + } + my @tempAssetIds = (); + foreach my $id (@assetIds) { + push(@tempAssetIds, $id) unless $id eq $assetId; + } + @assetIds = @tempAssetIds; + } + } + } + return www_show($session,\@assetIds); +} + +#------------------------------------------------------------------- + +=head2 www_show () + +A web accessible method that displays the attachments associated with this attachments control. + +=cut + +sub www_show { + my $session = shift; + my ($form, $url, $style) = $session->quick(qw(form url style)); + my $assetIdRef = shift; + my @assetIds = []; + if (defined $assetIdRef) { + $assetIdRef ||= []; + @assetIds = @{$assetIdRef}; + } + else { + @assetIds = $session->form->param("attachments"); + } + $session->http->setCacheControl("none"); + $style->setScript($url->extras("/AttachmentsControl/AttachmentsControl.js"), + {type=>"text/javascript"}); + $style->setLink($url->extras("/AttachmentsControl/AttachmentsControl.css"), + {type=>"text/css", rel=>"stylesheet"}); + my $uploadControl = ''; + my $i18n = WebGUI::International->new($session, "Control_Attachments"); + my $maxFiles = $form->param('maxAttachments') - scalar(@assetIds) ; + my $attachmentForms = ''; + foreach my $assetId (@assetIds) { + $attachmentForms .= ''; + } + if ($maxFiles > 0) { + $uploadControl = '
+ X +
+ + + + + '. $attachmentForms + .' +
+ Upload an attachment. + '; + } + my $attachments = ''; + my $attachmentsList = "attachments=".join(";attachments=", @assetIds) if (scalar(@assetIds)); + foreach my $assetId (@assetIds) { + my $asset = WebGUI::Asset->newByDynamicClass($session, $assetId); + if (defined $asset) { + $attachments .= '
param("maxAttachments").";" + .$attachmentsList.";assetId=".$assetId.";name=".$form->param("name")).'" class="deleteAttachment">X + '; + if ($asset->isa("WebGUI::Asset::File::Image")) { + $attachments .= ' +
'.$asset->getTitle.'
+ '.$asset->getTitle.' + '.$asset->getTitle.''; + } + else { + $attachments .= ' +
'.$asset->getTitle.'
+ '.$asset->getTitle.''; + } + $attachments .= '
'; + } + } + my $output = ' '.$style->generateAdditionalHeadTags.' + + + '.$uploadControl.'
Upload attachments here. Copy and paste attachments into the editor.
+
'.$attachments.'
'; + return $output; +} + +#------------------------------------------------------------------- + +=head2 www_upload + +A web accessible method that uploads an attachment to tempsace. + +=cut + +sub www_upload { + my $session = shift; + my $form = $session->form; + my @assetIds = $form->param("attachments"); + my $storage = WebGUI::Storage::Image->createTemp($session); + my $filename = $storage->addFileFromFormPost("attachment"); + my $tempspace = WebGUI::Asset->getTempspace($session); + if ($storage->isImage($filename)) { + my $image = $tempspace->addChild({ + title => $filename, + url => "attachments/".$filename, + className => "WebGUI::Asset::File::Image", + filename => $filename, + templateId => "PBtmpl0000000000000088", + }); + $image->getStorageLocation->addFileFromFilesystem($storage->getPath($filename)); + $image->generateThumbnail(); + $image->setSize; + push(@assetIds, $image->getId); + } + else { + my $file = $tempspace->addChild({ + title => $filename, + url => "attachments/".$filename, + className => "WebGUI::Asset::File", + filename => $filename, + templateId => "PBtmpl0000000000000024", + }); + $file->getStorageLocation->addFileFromFilesystem($storage->getPath($filename)); + $file->setSize; + push(@assetIds, $file->getId); + } + if ($session->setting->get("autoRequestCommit")) { + WebGUI::VersionTag->getWorking($session)->requestCommit; + } + $storage->delete; + return www_show($session, \@assetIds); +} + + +1; + diff --git a/lib/WebGUI/Form/_control.skeleton b/lib/WebGUI/Form/_control.skeleton new file mode 100644 index 000000000..01824150a --- /dev/null +++ b/lib/WebGUI/Form/_control.skeleton @@ -0,0 +1,122 @@ +package WebGUI::Form::MyControl; + +=head1 LEGAL + + ------------------------------------------------------------------- + WebGUI is Copyright 2001-2007 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 + ------------------------------------------------------------------- + +=cut + +use strict; +use base 'WebGUI::Form::Control'; +use WebGUI::International; + +=head1 NAME + +Package WebGUI::Form::MyControl + +=head1 DESCRIPTION + +Creates a text input box form field. + +=head1 SEE ALSO + +This is a subclass of WebGUI::Form::Control. + +=head1 METHODS + +The following methods are specifically available from this class. Check the superclass for additional methods. + +=cut + +#------------------------------------------------------------------- + +=head2 definition ( [ additionalTerms ] ) + +See the super class for additional details. + +=head3 additionalTerms + +The following additional parameters have been added via this sub class. + +=head4 size + +Defaults to the setting textBoxSize or 30 if that's not set. Specifies how big of a text box to display. + +=head4 profileEnabled + +Flag that tells the User Profile system that this is a valid form element in a User Profile + +=cut + +sub definition { + my $class = shift; + my $session = shift; + my $definition = shift || []; + my $i18n = WebGUI::International->new($session); + push(@{$definition}, { + formName=>{ + defaultValue=> $i18n->get("475") + }, + size=>{ + defaultValue=>$session->setting->get("textBoxSize") || 30 + }, + profileEnabled=>{ + defaultValue=>1 + }, + }); + return $class->SUPER::definition($session, $definition); +} + +#------------------------------------------------------------------- + +=head2 getValueFromPost ( [ value ] ) + +Retrieves a value from a form GET or POST and returns it. If the value comes back as undef, this method will return the defaultValue instead. + +=head3 value + +An optional value to process, instead of POST input. + +=cut + +sub getValueFromPost { + my $self = shift; + my $formValue; + + if (@_) { + $formValue = shift; + } + elsif ($self->session->request) { + $formValue = $self->session->form->param($self->get("name")); + } + if (defined $formValue) { + return $formValue; + } else { + return $self->{defaultValue}; + } +} + +#------------------------------------------------------------------- + +=head2 toHtml ( ) + +Renders an input tag of type text. + +=cut + +sub toHtml { + my $self = shift; + my $value = $self->fixMacros($self->fixQuotes($self->fixSpecialCharacters($self->get("value")))); + return 'get("extras").' />'; +} + +1; + diff --git a/lib/WebGUI/Setup.pm b/lib/WebGUI/Setup.pm index a08343c58..ebbdf2d04 100644 --- a/lib/WebGUI/Setup.pm +++ b/lib/WebGUI/Setup.pm @@ -210,7 +210,7 @@ sub setup { my $form = $session->form; my $snippet = '/* auto generated by WebGUI '.$WebGUI::VERSION.' */ .clearFloat { clear: both; } -body { background-color: '.$form->get("pageBackgroundColor").'; } +body { background-color: '.$form->get("pageBackgroundColor").'; color: '.$form->get("contentTextColor").'} a { color: '.$form->get("linkColor").';} a:visited { color: '.$form->get("visitedLinkColor").'; } #editToggleContainer { padding: 1px; } @@ -367,6 +367,7 @@ a:visited { color: '.$form->get("visitedLinkColor").'; } addAsset($page, { title => "Wiki", isHidden => 1, + allowAttachments => 5, className => "WebGUI::Asset::Wobject::WikiMaster", description => "Welcome to our wiki. Here you can help us keep information up to date.", }); diff --git a/lib/WebGUI/VersionTag.pm b/lib/WebGUI/VersionTag.pm index 5ec7a969e..f46ec8120 100644 --- a/lib/WebGUI/VersionTag.pm +++ b/lib/WebGUI/VersionTag.pm @@ -420,7 +420,7 @@ sub requestCommit { =head2 rollback ( ) -A class method. Eliminates all revisions of all assets created under a specific version tag. Also removes the version tag. +Eliminates all revisions of all assets created under a specific version tag. Also removes the version tag. =cut diff --git a/lib/WebGUI/i18n/English/Asset_WikiMaster.pm b/lib/WebGUI/i18n/English/Asset_WikiMaster.pm index e66a9f4a0..15561158c 100644 --- a/lib/WebGUI/i18n/English/Asset_WikiMaster.pm +++ b/lib/WebGUI/i18n/English/Asset_WikiMaster.pm @@ -1,6 +1,16 @@ package WebGUI::i18n::English::Asset_WikiMaster; our $I18N = { + 'allow attachments' => { + lastUpdated => 0, + message => q|Allowed Attachments|, + context => "field label" + }, + 'allow attachments help' => { + lastUpdated => 0, + message => q|?|, + context => "The number of attachments that are allowed to be placed on each wiki page." + }, 'assetName' => { lastUpdated => 1160157064, message => 'Wiki' }, 'asset description' => { lastUpdated => 1160157064, message => q|A wiki is a collaborative content publishing mechanism. Traditionally wiki's use the wiki markup language, but that's generally not much easier to deal with than HTML, so WebGUI's wiki instead just uses a rich editor to help users publish rich great looking content.| }, diff --git a/www/extras/AttachmentsControl/AttachmentsControl.css b/www/extras/AttachmentsControl/AttachmentsControl.css new file mode 100644 index 000000000..fda7dfe48 --- /dev/null +++ b/www/extras/AttachmentsControl/AttachmentsControl.css @@ -0,0 +1,21 @@ +#attachments { width: 100%; background-color: #eeeeee; padding: 3px; height: 100%; } +.attachment { position: relative; width: 100px; height: 80px; border: 0px; margin-right: 5px; padding: 0px; padding-left: 20px; + border: 1px dashed #bbbbbb; overflow: hidden; float: left; text-align: center;} +.attachment img { border: 0px; width: 90px; max-height: 70px; vertical-align: middle; margin: 5px; } +.attachment a { vertical-align: middle; margin: 5px; } +body { margin: 0px; padding: 0px; background-color: #eeeeee; } +#upload { position:fixed; _position:absolute; bottom:0; right:0; font-family: sans-serif; cursor: pointer; +_top:expression(document.body.scrollTop+document.body.clientHeight-this.clientHeight); width: 150px; font-size: 12px; background-color: #008000; text-align: center; text-decoration: none; z-index: 10; color: white; } +#instructions { font-size: 11px; color: white; width: 100%; background-color: black; font-family: sans-serif;} +#uploadForm { position:fixed; _position:absolute; top:0; _top:expression(eval(document.body.scrollTop)); left:0; margin:0; padding:0; background-color: #eeeeee; z-index: 20; width: 100%; height: 100%; display: none; vertical-align: middle; text-align: center; padding-top: 5px; } +#uploadFormCloser { position: absolute; top: 0px; right: 0px; background-color: #800000; color: #ffffff; margin: 3px; + padding: 3px; border: 2px solid black; text-decoration: none; cursor: pointer; } +.deleteAttachment {position: absolute; top: 0px; left: 0px; background-color: #800000; color: white; z-index: 10; + font-size: 14px; text-decoration: none; border: 1px solid black; width: 16px; height: 16px;} +.thumbnail {position: absolute; z-index: 10; top: 20px; left: 0px;} +.thumbnail img { width: 15px; height: 15px; border: 1px solid black; } +.imageLink { position: absolute; top: 40px; left: 0px; background-color: #eeeeee; color: blue; z-index: 10; + font-size: 14px; text-decoration: underline; border: 1px solid black; width: 16px; height: 16px; + overflow: hidden; } + + diff --git a/www/extras/AttachmentsControl/AttachmentsControl.js b/www/extras/AttachmentsControl/AttachmentsControl.js new file mode 100644 index 000000000..c70a10e31 --- /dev/null +++ b/www/extras/AttachmentsControl/AttachmentsControl.js @@ -0,0 +1,12 @@ +WebguiAttachmentUploadForm = function () { + return { + show: function () { + document.getElementById("uploadForm").style.display = "block"; + }, + hide: function () { + document.getElementById("uploadForm").style.display = "none"; + } + } +}(); + +