From 428200daad8536e194848dd511016a6e1095787a Mon Sep 17 00:00:00 2001 From: JT Smith Date: Sat, 5 Oct 2002 22:07:20 +0000 Subject: [PATCH] Added UI Level to Article, and fixed some form bugs. --- lib/WebGUI/Form.pm | 14 ++++--- lib/WebGUI/HTMLForm.pm | 36 +++++++++------- lib/WebGUI/Macro/AdminBar.pm | 4 +- lib/WebGUI/Wobject.pm | 77 +++++++++++++++++++++++++++++------ lib/WebGUI/Wobject/Article.pm | 48 ++++++++++++++++++---- 5 files changed, 138 insertions(+), 41 deletions(-) diff --git a/lib/WebGUI/Form.pm b/lib/WebGUI/Form.pm index 01844fee5..7d15e6a37 100644 --- a/lib/WebGUI/Form.pm +++ b/lib/WebGUI/Form.pm @@ -453,7 +453,7 @@ sub group { =cut sub hidden { - return ''; + return ''."\n"; } @@ -465,6 +465,10 @@ sub hidden { the HTMLForm package, but we decided to make it a public method in case anybody else had a use for it. +=item name + + The name of this field. + =item options A hash reference where the key is the "name" of the hidden field. @@ -479,16 +483,16 @@ sub hidden { sub hiddenList { my ($output, $key, $item); foreach $key (keys %{$_[0]->{options}}) { - foreach $item (@$_[0]->{value}) { + foreach $item (@{$_[0]->{value}}) { if ($item eq $key) { $output .= hidden({ - name=>$key, - value=>$item + name=>$_[0]->{name}, + value=>$key }); } } } - return $output; + return $output."\n"; } diff --git a/lib/WebGUI/HTMLForm.pm b/lib/WebGUI/HTMLForm.pm index 08aa216f5..55a316e45 100644 --- a/lib/WebGUI/HTMLForm.pm +++ b/lib/WebGUI/HTMLForm.pm @@ -16,6 +16,7 @@ package WebGUI::HTMLForm; use CGI::Util qw(rearrange); use strict qw(vars refs); +use WebGUI::DateTime; use WebGUI::Form; use WebGUI::International; use WebGUI::Session; @@ -98,7 +99,7 @@ sub _subtext { #------------------------------------------------------------------- sub _tableFormRow { unless ($_[0]->{_noTable}) { - return ''.$_[1].''.$_[2].''; + return ''.$_[1].''.$_[2]."\n"; } else { return $_[2]; } @@ -244,7 +245,8 @@ sub checkList { $output .= _subtext($subtext); $output = $self->_tableFormRow($label,$output); } else { - hiddenList({ + $output = WebGUI::Form::hiddenList({ + name=>$name, options=>$options, value=>$value }); @@ -325,6 +327,7 @@ sub combo { $output = $self->_tableFormRow($label,$output); } else { $output = WebGUI::Form::hiddenList({ + name=>$name, options=>$options, value=>$value }); @@ -398,7 +401,7 @@ sub date { } else { $output = WebGUI::Form::hidden({ name=>$name, - value=>$value + value=>epochToSet($value) }); } $self->{_data} .= $output; @@ -600,7 +603,8 @@ sub group { $output = $self->_tableFormRow($label,$output); } else { my $hashRef = WebGUI::SQL->quickHashRef("select groupId,groupName from groups"); - hiddenList({ + $output = WebGUI::Form::hiddenList({ + name=>$name, options=>$hashRef, value=>$value }); @@ -912,15 +916,15 @@ sub new { my ($noTable, $action, $method, $extras, $enctype, $tableExtras) = rearrange([noTable, action, method, extras, enctype, tableExtras], @p); $noTable = $noTable || 0; - $header = WebGUI::Form::formHeader({ + $header = "\n\n".WebGUI::Form::formHeader({ action=>$action, extras=>$extras, method=>$method, enctype=>$enctype }); - $header .= '' unless ($noTable); - $footer = '
' unless ($noTable); - $footer .= ''; + $header .= "\n' unless ($noTable); + $footer = "
\n" unless ($noTable); + $footer .= "\n\n"; bless {_noTable => $noTable, _header => $header, _footer => $footer, _data => ''}, $self; } @@ -990,7 +994,7 @@ sub password { $output = $self->_tableFormRow($label,$output); } else { $output = WebGUI::Form::hidden({ - name=>$name.'_interval', + name=>$name, value=>$value }); } @@ -1061,7 +1065,7 @@ sub phone { $output = $self->_tableFormRow($label,$output); } else { $output = WebGUI::Form::hidden({ - name=>$name.'_interval', + name=>$name, value=>$value }); } @@ -1224,7 +1228,8 @@ sub radioList { $output .= _subtext($subtext); $output = $self->_tableFormRow($label,$output); } else { - hiddenList({ + $output = WebGUI::Form::hiddenList({ + name=>$name, options=>$options, value=>[$value] }); @@ -1367,7 +1372,8 @@ sub select { $output .= _subtext($subtext); $output = $self->_tableFormRow($label,$output); } else { - hiddenList({ + $output = WebGUI::Form::hiddenList({ + name=>$name, options=>$options, value=>$value }); @@ -1481,7 +1487,7 @@ sub text { $output = $self->_tableFormRow($label,$output); } else { $output = WebGUI::Form::hidden({ - name=>$name.'_interval', + name=>$name, value=>$value }); } @@ -1631,7 +1637,7 @@ sub url { $output = $self->_tableFormRow($label,$output); } else { $output = WebGUI::Form::hidden({ - name=>$name.'_interval', + name=>$name, value=>$value }); } @@ -1764,7 +1770,7 @@ sub zipcode { $output = $self->_tableFormRow($label,$output); } else { $output = WebGUI::Form::hidden({ - name=>$name.'_interval', + name=>$name, value=>$value }); } diff --git a/lib/WebGUI/Macro/AdminBar.pm b/lib/WebGUI/Macro/AdminBar.pm index 9f5886319..1f9ddcbec 100644 --- a/lib/WebGUI/Macro/AdminBar.pm +++ b/lib/WebGUI/Macro/AdminBar.pm @@ -28,7 +28,9 @@ sub _replacement { #--content adder $hash{WebGUI::URL::page()} = WebGUI::International::get(1); $hash{WebGUI::URL::page('op=editPage&npp='.$session{page}{pageId})} = WebGUI::International::get(2); - $hash{WebGUI::URL::page('op=selectPackageToDeploy')} = WebGUI::International::get(376); + if ($session{user}{uiLevel} >= 7) { + $hash{WebGUI::URL::page('op=selectPackageToDeploy')} = WebGUI::International::get(376); + } foreach $key (keys %{$session{wobject}}) { $hash2{WebGUI::URL::page('func=edit&wid=new&namespace='.$key)} = $session{wobject}{$key}; } diff --git a/lib/WebGUI/Wobject.pm b/lib/WebGUI/Wobject.pm index df24fb3f8..08a83e8b4 100644 --- a/lib/WebGUI/Wobject.pm +++ b/lib/WebGUI/Wobject.pm @@ -162,7 +162,7 @@ sub description { =cut sub discussionProperties { - my ($f,$editTimeout,$groupToModerate,%moderationType,$moderationType); + my ($f,$editTimeout,$interval, $units, $groupToModerate,%moderationType,$moderationType); %moderationType = (before=>WebGUI::International::get(567),after=>WebGUI::International::get(568)); $f = WebGUI::HTMLForm->new; if ($_[0]->get("wobjectId") eq "new") { @@ -173,15 +173,38 @@ sub discussionProperties { $moderationType = $_[0]->get("moderationType"); } $groupToModerate = $_[0]->get("groupToModerate") || 4; - $f->group("groupToPost",WebGUI::International::get(564),[$_[0]->get("groupToPost")]); - $f->interval("editTimeout",WebGUI::International::get(566),WebGUI::DateTime::secondsToInterval($editTimeout)); - if ($session{setting}{useKarma}) { + $f->group( + -name=>"groupToPost", + -label=>WebGUI::International::get(564), + -value=>[$_[0]->get("groupToPost")], + -uiLevel=>7 + ); + ($interval, $units) = WebGUI::DateTime::secondsToInterval($editTimeout); + $f->interval( + -name=>"editTimeout", + -label=>WebGUI::International::get(566), + -intervalValue=>$interval, + -unitsValue=>$units, + -uiLevel=>7 + ); + if ($session{setting}{useKarma} && $session{user}{uiLevel} <= 7) { $f->integer("karmaPerPost",WebGUI::International::get(541),$_[0]->get("karmaPerPost")); } else { $f->hidden("karmaPerPost",$_[0]->get("karmaPerPost")); } - $f->group("groupToModerate",WebGUI::International::get(565),[$groupToModerate]); - $f->select("moderationType",\%moderationType,WebGUI::International::get(569),[$moderationType]); + $f->group( + -name=>"groupToModerate", + -label=>WebGUI::International::get(565), + -value=>[$groupToModerate], + -uiLevel=>7 + ); + $f->select( + -name=>"moderationType", + -options=>\%moderationType, + -label=>WebGUI::International::get(569), + -value=>[$moderationType], + -uiLevel=>7 + ); return $f->printRowsOnly; } @@ -895,13 +918,43 @@ sub www_edit { $f->hidden("namespace",$_[0]->get("namespace")) if ($_[0]->get("wobjectId") eq "new"); $f->hidden("func","editSave"); $f->submit if ($_[0]->get("wobjectId") ne "new"); - $f->readOnly($_[0]->get("wobjectId"),WebGUI::International::get(499)); + $f->readOnly( + -value=>$_[0]->get("wobjectId"), + -label=>WebGUI::International::get(499), + -uiLevel=>3 + ); $f->text("title",WebGUI::International::get(99),$title); - $f->yesNo("displayTitle",WebGUI::International::get(174),$displayTitle); - $f->yesNo("processMacros",WebGUI::International::get(175),$_[0]->get("processMacros")); - $f->select("templatePosition",WebGUI::Template::getPositions($session{page}{templateId}),WebGUI::International::get(363),[$templatePosition]); - $f->date("startDate",WebGUI::International::get(497),$startDate); - $f->date("endDate",WebGUI::International::get(498),$endDate); + $f->yesNo( + -name=>"displayTitle", + -label=>WebGUI::International::get(174), + -value=>$displayTitle, + -uiLevel=>5 + ); + $f->yesNo( + -name=>"processMacros", + -label=>WebGUI::International::get(175), + -value=>$_[0]->get("processMacros"), + -uiLevel=>5 + ); + $f->select( + -name=>"templatePosition", + -label=>WebGUI::International::get(363), + -value=>[$templatePosition], + -uiLevel=>5, + -options=>WebGUI::Template::getPositions($session{page}{templateId}) + ); + $f->date( + -name=>"startDate", + -label=>WebGUI::International::get(497), + -value=>$startDate, + -uiLevel=>9 + ); + $f->date( + -name=>"endDate", + -label=>WebGUI::International::get(498), + -value=>$endDate, + -uiLevel=>9 + ); $f->HTMLArea("description",WebGUI::International::get(85),$_[0]->get("description")); $f->raw($_[1]); $f->submit; diff --git a/lib/WebGUI/Wobject/Article.pm b/lib/WebGUI/Wobject/Article.pm index d575fcd61..6b8ca3f0f 100644 --- a/lib/WebGUI/Wobject/Article.pm +++ b/lib/WebGUI/Wobject/Article.pm @@ -68,19 +68,51 @@ sub www_edit { $output = helpIcon(1,$namespace); $output .= '

'.WebGUI::International::get(12,$namespace).'

'; $f = WebGUI::HTMLForm->new; - $f->raw($_[0]->fileProperty("image",6)); + $f->raw( + -value=>$_[0]->fileProperty("image",6), + -uiLevel=>3 + ); %hash = ( right => WebGUI::International::get(15,$namespace), left => WebGUI::International::get(16,$namespace), center => WebGUI::International::get(17,$namespace) ); - $f->select("alignImage",\%hash,WebGUI::International::get(14,$namespace),[$_[0]->get("alignImage")]); - $f->raw($_[0]->fileProperty("attachment",9)); - $f->text("linkTitle",WebGUI::International::get(7,$namespace),$_[0]->get("linkTitle")); - $f->url("linkURL",WebGUI::International::get(8,$namespace),$_[0]->get("linkURL")); - $f->yesNo("convertCarriageReturns",WebGUI::International::get(10,$namespace),$_[0]->get("convertCarriageReturns") - ,'','   '.WebGUI::International::get(11,$namespace).''); - $f->yesNo("allowDiscussion",WebGUI::International::get(18,$namespace),$_[0]->get("allowDiscussion")); + $f->select( + -name=>"alignImage", + -options=>\%hash, + -label=>WebGUI::International::get(14,$namespace), + -value=>[$_[0]->get("alignImage")], + -uiLevel=>3 + ); + $f->raw( + -value=>$_[0]->fileProperty("attachment",9), + -uiLevel=>1 + ); + $f->text( + -name=>"linkTitle", + -label=>WebGUI::International::get(7,$namespace), + -value=>$_[0]->get("linkTitle"), + -uiLevel=>3 + ); + $f->url( + -name=>"linkURL", + -label=>WebGUI::International::get(8,$namespace), + -value=>$_[0]->get("linkURL"), + -uiLevel=>3 + ); + $f->yesNo( + -name=>"convertCarriageReturns", + -label=>WebGUI::International::get(10,$namespace), + -value=>$_[0]->get("convertCarriageReturns"), + -subtext=>'   '.WebGUI::International::get(11,$namespace).'', + -uiLevel=>5 + ); + $f->yesNo( + -name=>"allowDiscussion", + -label=>WebGUI::International::get(18,$namespace), + -value=>$_[0]->get("allowDiscussion"), + -uiLevel=>5 + ); $f->raw($_[0]->SUPER::discussionProperties); $output .= $_[0]->SUPER::www_edit($f->printRowsOnly); return $output;