added asset form control, fixed some interval problems, added a check so users can't delete the default page or the not found page
This commit is contained in:
parent
1523c9c904
commit
778236efcb
8 changed files with 198 additions and 21 deletions
|
|
@ -2232,6 +2232,7 @@ Moves self to trash, returns www_view() method of Parent if canEdit. Otherwise r
|
|||
sub www_delete {
|
||||
my $self = shift;
|
||||
return $self->getAdminConsole->render(WebGUI::Privilege::insufficient()) unless $self->canEdit;
|
||||
return $self->getAdminConsole->render(WebGUI::Privilege::vitalComponent()) if (isIn($self->getId, $session{setting}{defaultPage}, $session{setting}{notFoundPage}));
|
||||
$self->trash;
|
||||
return $self->getParent->www_view;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,12 +17,13 @@ package WebGUI::Form;
|
|||
use strict;
|
||||
use HTTP::BrowserDetect;
|
||||
use Tie::IxHash;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::DateTime;
|
||||
use WebGUI::International;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::SQL;
|
||||
use WebGUI::Style;
|
||||
use WebGUI::Asset::Template;
|
||||
use WebGUI::URL;
|
||||
use WebGUI::Utility;
|
||||
|
||||
|
|
@ -38,9 +39,11 @@ Base forms package. Eliminates some of the normal code work that goes along with
|
|||
|
||||
use WebGUI::Form;
|
||||
|
||||
$html = WebGUI::Form::asset({value=>$assetId});
|
||||
$html = WebGUI::Form::button({value=>"Click me!", extras=>qq|onclick="alert('Aaaaggggghhh!!!')"|});
|
||||
$html = WebGUI::Form::checkbox({name=>"whichOne", value=>"red"});
|
||||
$html = WebGUI::Form::checkList({name=>"dayOfWeek", options=>\%days});
|
||||
$html = WebGUI::Form::codearea({name=>"stylesheet"});
|
||||
$html = WebGUI::Form::combo({name=>"fruit",options=>\%fruit});
|
||||
$html = WebGUI::Form::contentType({name=>"contentType");
|
||||
$html = WebGUI::Form::databaseLink();
|
||||
|
|
@ -110,6 +113,58 @@ sub _fixTags {
|
|||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 asset ( hashref )
|
||||
|
||||
Returns an asset picker control.
|
||||
|
||||
=head3 value
|
||||
|
||||
The asset ID assigned to this control.
|
||||
|
||||
=head3 name
|
||||
|
||||
The name of this field. Defaults to "asset".
|
||||
|
||||
=head3 defaultValue
|
||||
|
||||
If no value is specified, use this value.
|
||||
|
||||
=head3 class
|
||||
|
||||
Limit options to a specific class type such as "WebGUI::Asset::Wobject::Article"
|
||||
|
||||
=head3 extras
|
||||
|
||||
Assign extra things like javascript events to this form element.
|
||||
|
||||
=cut
|
||||
|
||||
|
||||
sub asset {
|
||||
my $params = shift;
|
||||
my $value = $params->{value} || $params->{defaultValue};
|
||||
my $name = $params->{name} || "asset";
|
||||
my $asset = WebGUI::Asset->newByDynamicClass($value) || WebGUI::Asset->getRoot;
|
||||
return hidden({
|
||||
name=>$name,
|
||||
extras=>'id="'.$name.'" '.$params->{extras},
|
||||
value=>$asset->getId
|
||||
})
|
||||
.text({
|
||||
name=>$name."_display",
|
||||
extras=>'id="'.$name."_display".'" readonly="1"',
|
||||
value=>$asset->get("title")
|
||||
})
|
||||
.button({
|
||||
value=>"...",
|
||||
extras=>'onclick="window.open(\''.$asset->getUrl("op=formAssetTree&classLimiter=".$params->{class}."&formId=".$name).'\',\'assetPicker\',\'toolbar=no, location=no, status=no, directories=no, width=400, height=400\');"'
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 button ( hashRef )
|
||||
|
|
@ -994,11 +1049,15 @@ The default value for this form element.
|
|||
|
||||
This will be used if no value is specified.
|
||||
|
||||
=head3 extras
|
||||
|
||||
Add extra things like ids and javascript event handlers.
|
||||
|
||||
=cut
|
||||
|
||||
sub hidden {
|
||||
my $params = shift;
|
||||
return '<input type="hidden" name="'.$params->{name}.'" value="'._fixQuotes(_fixMacros(_fixSpecialCharacters($params->{value}))).'" />'."\n";
|
||||
return '<input type="hidden" name="'.$params->{name}.'" value="'._fixQuotes(_fixMacros(_fixSpecialCharacters($params->{value}))).'" '.$params->{extras}.' />'."\n";
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ This package helps in the processing of the form variables that are returned fro
|
|||
use WebGUI::FormProcessor;
|
||||
$value = WebGUI::FormProcessor::process("favoriteColor","selectList","black");
|
||||
|
||||
$value = WebGUI::FormProcessor::asset("assetId");
|
||||
$value = WebGUI::FormProcessor::checkbox("whichOne");
|
||||
$value = WebGUI::FormProcessor::checkList("dayOfWeek");
|
||||
$value = WebGUI::FormProcessor::codearea("snippet");
|
||||
|
|
@ -74,6 +75,22 @@ sub _checkEmailAddy {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 asset ( name )
|
||||
|
||||
Returns an asset id.
|
||||
|
||||
=head3 name
|
||||
|
||||
The name of the form variable to retrieve.
|
||||
|
||||
=cut
|
||||
|
||||
sub asset {
|
||||
return $session{form}{$_[0]};
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 checkbox ( name )
|
||||
|
||||
Returns an array or a carriage return ("\n") separated scalar depending upon whether you're returning the values into an array or a scalar.
|
||||
|
|
@ -386,7 +403,8 @@ The name of the form variable to retrieve.
|
|||
=cut
|
||||
|
||||
sub interval {
|
||||
return (WebGUI::DateTime::intervalToSeconds($session{form}{$_[0]."_interval"},$session{form}{$_[0]."_units"}) || 0);
|
||||
my $val = WebGUI::DateTime::intervalToSeconds($session{form}{$_[0]."_interval"},$session{form}{$_[0]."_units"}) || 0;
|
||||
return $val;
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -450,7 +468,6 @@ The default value for this variable. If the variable is undefined then the defau
|
|||
sub process {
|
||||
my ($name, $type, $default) = @_;
|
||||
my $value;
|
||||
return undef unless (exists $session{form}{$name});
|
||||
$type = "text" if ($type eq "");
|
||||
$value = &$type($name);
|
||||
unless (defined $value) {
|
||||
|
|
|
|||
|
|
@ -38,6 +38,10 @@ Package that makes HTML forms typed data and significantly reduces the code need
|
|||
use WebGUI::HTMLForm;
|
||||
$f = WebGUI::HTMLForm->new;
|
||||
|
||||
$f-asset(
|
||||
-value=>$assetId,
|
||||
-label=>"Pick an Asset"
|
||||
);
|
||||
$f->button(
|
||||
-value=>"Click me!",
|
||||
-extras=>qq|onClick="alert('Aaaaaaaggggghh!!!!')"|
|
||||
|
|
@ -52,6 +56,10 @@ Package that makes HTML forms typed data and significantly reduces the code need
|
|||
-options=>\%days,
|
||||
-label=>"Which day?"
|
||||
);
|
||||
$f->codearea(
|
||||
-name=>"stylesheet",
|
||||
-label=>"Stylesheet"
|
||||
);
|
||||
$f->combo(
|
||||
-name=>"fruit",
|
||||
-options=>\%fruit,
|
||||
|
|
@ -220,6 +228,71 @@ sub _uiLevelChecksOut {
|
|||
}
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 asset ( name, label, value, class, extras, subtext, defaultValue, uiLevel )
|
||||
|
||||
Returns an asset picker control.
|
||||
|
||||
=head3 name
|
||||
|
||||
The name of this field. Defaults to "asset".
|
||||
|
||||
=head3 label
|
||||
|
||||
A label to display next to this field.
|
||||
|
||||
=head3 value
|
||||
|
||||
The asset ID to assign to this control.
|
||||
|
||||
=head3 class
|
||||
|
||||
Limit the assets picked to a specific class such as "WebGUI::Asset::File"
|
||||
|
||||
=head3 extras
|
||||
|
||||
Add extra attributes to the form element like javascript event handlers.
|
||||
|
||||
=head3 subtext
|
||||
|
||||
A small message to appear under the form element with additional instructions.
|
||||
|
||||
=head3 defaultValue
|
||||
|
||||
If value is not specified we'll use this instead.
|
||||
|
||||
=head3 uiLevel
|
||||
|
||||
What UI level is required to see this control.
|
||||
|
||||
=cut
|
||||
|
||||
sub asset {
|
||||
my ($self, @p) = @_;
|
||||
my ($name, $label, $value, $class, $extras, $subtext, $defaultValue, $uiLevel) = rearrange([qw(name label value class extras subtext defaultValue uiLevel)], @p);
|
||||
my $output;
|
||||
if (_uiLevelChecksOut($uiLevel)) {
|
||||
$output = WebGUI::Form::asset({
|
||||
"name"=>$name,
|
||||
"value"=>$value,
|
||||
"class"=>$class,
|
||||
"extras"=>$extras,
|
||||
"defaultValue"=>$defaultValue
|
||||
});
|
||||
$output .= _subtext($subtext);
|
||||
$output = $self->_tableFormRow($label,$output);
|
||||
} else {
|
||||
$output = WebGUI::Form::hidden({
|
||||
"name"=>$name,
|
||||
"value"=>$value,
|
||||
"defaultValue"=>$defaultValue
|
||||
});
|
||||
}
|
||||
$self->{_data} .= $output;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 button ( value [, label, extras, subtext, defaultValue ] )
|
||||
|
|
|
|||
|
|
@ -95,9 +95,10 @@ sub getOperations {
|
|||
'editDatabaseLink' => 'WebGUI::Operation::DatabaseLink',
|
||||
'editDatabaseLinkSave' => 'WebGUI::Operation::DatabaseLink',
|
||||
'listDatabaseLinks' => 'WebGUI::Operation::DatabaseLink',
|
||||
'richEditPageTree' => 'WebGUI::Operation::RichEdit',
|
||||
'richEditImageTree' => 'WebGUI::Operation::RichEdit',
|
||||
'richEditViewThumbnail' => 'WebGUI::Operation::RichEdit',
|
||||
'formAssetTree' => 'WebGUI::Operation::FormHelpers',
|
||||
'richEditPageTree' => 'WebGUI::Operation::FormHelpers',
|
||||
'richEditImageTree' => 'WebGUI::Operation::FormHelpers',
|
||||
'richEditViewThumbnail' => 'WebGUI::Operation::FormHelpers',
|
||||
'manageUsersInGroup' => 'WebGUI::Operation::Group',
|
||||
'deleteGroup' => 'WebGUI::Operation::Group',
|
||||
'deleteGroupConfirm' => 'WebGUI::Operation::Group',
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
package WebGUI::Operation::RichEdit;
|
||||
package WebGUI::Operation::FormHelpers;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# WebGUI is Copyright 2001-2004 Plain Black Corporation.
|
||||
|
|
@ -16,6 +16,34 @@ use WebGUI::HTMLForm;
|
|||
use WebGUI::Session;
|
||||
use WebGUI::Style;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
sub www_formAssetTree {
|
||||
my $base = WebGUI::Asset->newByUrl || WebGUI::Asset->getRoot;
|
||||
my @crumb;
|
||||
my $ancestors = $base->getLineage(["self","ancestors"],{returnQuickReadObjects=>1});
|
||||
foreach my $ancestor (@{$ancestors}) {
|
||||
push(@crumb,'<a href="'.$ancestor->getUrl("op=formAssetTree&classLimiter=".$session{form}{classLimiter}."&formId="
|
||||
.$session{form}{formId}).'">'.$ancestor->get("menuTitle").'</a>');
|
||||
}
|
||||
my $output = '<p>'.join(" > ", @crumb)."</p>\n";
|
||||
my $children = $base->getLineage(["children"],{returnQuickReadObjects=>1});
|
||||
foreach my $child (@{$children}) {
|
||||
next unless $child->canView;
|
||||
if ($child->get("className") =~ /^$session{form}{classLimiter}/) {
|
||||
$output .= '<a href="#" onclick="window.opener.document.getElementById(\''.$session{form}{formId}
|
||||
.'\').value=\''.$child->getId.'\';window.opener.document.getElementById(\''.
|
||||
$session{form}{formId}.'_display\').value=\''.$child->get("title").'\';window.close();">(•)</a> ';
|
||||
} else {
|
||||
$output .= "(•) ";
|
||||
}
|
||||
$output .= '<a href="'.$child->getUrl("op=formAssetTree&classLimiter=".$session{form}{classLimiter}."&formId="
|
||||
.$session{form}{formId}).'">'.$child->get("menuTitle").'</a>'."<br />\n";
|
||||
}
|
||||
$session{page}{useEmptyStyle} = 1;
|
||||
return $output;
|
||||
}
|
||||
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
sub www_richEditPageTree {
|
||||
|
|
@ -60,24 +60,21 @@ sub www_editSettings {
|
|||
-value=>$session{setting}{companyURL}
|
||||
);
|
||||
# content settings
|
||||
my $pages = WebGUI::SQL->buildHashRef("select pageId,menuTitle from page order by menuTitle");
|
||||
my %htmlFilter = (
|
||||
'none'=>$i18n->get(420),
|
||||
'most'=>$i18n->get(421),
|
||||
'javascript'=>$i18n->get(526),
|
||||
'all'=>$i18n->get(419)
|
||||
);
|
||||
$tabform->getTab("content")->selectList(
|
||||
$tabform->getTab("content")->asset(
|
||||
-name=>"defaultPage",
|
||||
-options=>$pages,
|
||||
-label=>$i18n->get(527),
|
||||
-value=>[$session{setting}{defaultPage}]
|
||||
-value=>$session{setting}{defaultPage}
|
||||
);
|
||||
$tabform->getTab("content")->selectList(
|
||||
$tabform->getTab("content")->asset(
|
||||
-name=>"notFoundPage",
|
||||
-options=>$pages,
|
||||
-label=>$i18n->get(141),
|
||||
-value=>[$session{setting}{notFoundPage}]
|
||||
-value=>$session{setting}{notFoundPage}
|
||||
);
|
||||
$tabform->getTab("content")->text(
|
||||
-name=>"urlExtension",
|
||||
|
|
@ -101,7 +98,7 @@ sub www_editSettings {
|
|||
);
|
||||
$tabform->getTab("content")->yesNo(
|
||||
-name=>"metaDataEnabled",
|
||||
-label=>$i18n->get("Enable Metadata ?", 'MetaData'),
|
||||
-label=>$i18n->get("Enable Metadata ?", 'Asset'),
|
||||
-value=>$session{setting}{metaDataEnabled}
|
||||
);
|
||||
# user interface settings
|
||||
|
|
@ -202,12 +199,10 @@ sub www_editSettings {
|
|||
-label=>$i18n->get(540),
|
||||
-value=>$session{setting}{karmaPerLogin}
|
||||
);
|
||||
my ($interval, $units) = WebGUI::DateTime::secondsToInterval($session{setting}{sessionTimeout});
|
||||
$tabform->getTab("user")->interval(
|
||||
-name=>"sessionTimeout",
|
||||
-label=>$i18n->get(142),
|
||||
-intervalValue=>$interval,
|
||||
-unitsValue=>$units
|
||||
-value=>$session{setting}{sessionTimeout}
|
||||
);
|
||||
$tabform->getTab("user")->yesNo(
|
||||
-name=>"selfDeactivation",
|
||||
|
|
@ -221,9 +216,9 @@ sub www_editSettings {
|
|||
);
|
||||
$tabform->getTab("user")->yesNo(
|
||||
-name=>"passiveProfilingEnabled",
|
||||
-label=>$i18n->get("Enable passive profiling ?", 'MetaData'),
|
||||
-label=>$i18n->get("Enable passive profiling ?", 'Asset'),
|
||||
-value=>$session{setting}{passiveProfilingEnabled},
|
||||
-extras=>' onChange="alert(\''.$i18n->get("Illegal Warning","MetaData").'\')" '
|
||||
-extras=>' onChange="alert(\''.$i18n->get("Illegal Warning","Asset").'\')" '
|
||||
);
|
||||
# auth settings
|
||||
WebGUI::Style::setScript($session{config}{extrasURL}."/swapLayers.js",{language=>"Javascript"});
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue