Merge branch 'master' of git@github.com:plainblack/webgui

This commit is contained in:
daviddelikat 2009-10-28 09:15:34 -05:00
commit 9db3e02444
38 changed files with 898 additions and 228 deletions

View file

@ -1263,7 +1263,11 @@ sub getIsa {
$sth->finish;
return undef;
}
return WebGUI::Asset->newPending($session, $assetId);
my $asset = WebGUI::Asset->newByDynamicClass($session, $assetId);
if (!$asset) {
WebGUI::Error::ObjectNotFound->throw(id => $assetId);
}
return $asset;
};
}

View file

@ -166,10 +166,10 @@ sub appendPostListTemplateVars {
"user.isVisitor" => $post->get("ownerUserId") eq "1",
"edit.url" => $post->getEditUrl,
'controls' => $controls,
"isSecond" => (($i+1)%2==0),
"isThird" => (($i+1)%3==0),
"isFourth" => (($i+1)%4==0),
"isFifth" => (($i+1)%5==0),
"isSecond" => (($i+1) == 2),
"isThird" => (($i+1) == 3),
"isFourth" => (($i+1) == 4),
"isFifth" => (($i+1) == 5),
"user.hasRead" => $hasRead,
"user.isPoster" => $post->isPoster,
"avatar.url" => $post->getAvatarUrl,

View file

@ -388,6 +388,8 @@ sub view {
var mapId = "%s";
var mapUrl = "%s";
var map = new GMap2( document.getElementById("map_" + mapId) );
map.url = mapUrl;
map.assetId = mapId;
map.setCenter(new GLatLng(%s, %s), %s);
map.setUIToDefault();
map.extrasUrl = "%s";
@ -414,7 +416,7 @@ ENDHTML
}
$mapHtml .= <<'ENDHTML';
markermanager.addMarkers( WebGUI.Map.preparePoints(map, markermanager, mapUrl, points), 0 );
markermanager.addMarkers( WebGUI.Map.preparePoints(map, markermanager, points), 0 );
ENDHTML
}
@ -434,13 +436,13 @@ ENDHTML
if ( document.getElementById( "setCenter_" + mapId ) ) {
var button = document.getElementById( "setCenter_" + mapId );
GEvent.addDomListener( button, "click", function () {
WebGUI.Map.setCenter( map, mapUrl );
WebGUI.Map.setCenter( map );
} );
}
if ( document.getElementById( "addPoint_" + mapId ) ) {
var button = document.getElementById( "addPoint_" + mapId );
GEvent.addDomListener( button, "click", function () {
WebGUI.Map.editPoint( map, markermanager, mapUrl );
WebGUI.Map.editPoint( map, markermanager );
} );
}
});
@ -463,6 +465,18 @@ ENDHTML
id => sprintf( 'setCenter_%s', $self->getId ),
} );
# Select box to choose a map point
tie my %selectPointOptions, 'Tie::IxHash', (
"" => '-- ' . $i18n->get('select a point'),
map { $_->{assetId} => $_->{title} } sort { $a->{title} cmp $b->{title} } @{$var->{mapPoints}},
);
$var->{ selectPoint }
= WebGUI::Form::selectBox( $session, {
extras => q{onchange="WebGUI.Map.focusOn(this.options[this.selectedIndex].value);"},
id => sprintf( q{selectPoint_%s}, $self->getId ),
options => \%selectPointOptions,
} );
return $self->processTemplate( $var, undef, $self->{_viewTemplate} );
}
@ -556,8 +570,19 @@ sub www_ajaxEditPointSave {
my $errors = $asset->processAjaxEditForm;
# Commit!
if ($asset->getAutoCommitWorkflowId && $self->hasBeenCommitted) {
$asset->requestAutoCommit;
if ( $asset->getAutoCommitWorkflowId ) {
if ( $self->hasBeenCommitted) {
$asset->requestAutoCommit;
}
else {
# Add mappoint to map's version tag
my $oldTagId = $asset->get('tagId');
$asset->setVersionTag( $self->get('tagId') );
my $oldTag = WebGUI::VersionTag->new( $session, $oldTagId );
if ( $oldTag->getAssetCount <= 0 ) {
$oldTag->rollback;
}
}
}
# Encode entities because we're returning as HTML

View file

@ -444,7 +444,7 @@ sub www_emptyClipboard {
my $self = shift;
my $ac = WebGUI::AdminConsole->new($self->session,"clipboard");
return $self->session->privilege->insufficient() unless ($self->session->user->isInGroup(4));
foreach my $asset (@{$self->getAssetsInClipboard(!($self->session->form->process("systemClipboard") && $self->session->user->isAdmin))}) {
foreach my $asset (@{$self->getAssetsInClipboard(!($self->session->form->process("systemClipboard") && $self->session->user->isInGroup($self->session->setting->get('groupIdAdminClipboard'))))}) {
$asset->trash;
}
return $self->www_manageClipboard();
@ -464,20 +464,29 @@ sub www_manageClipboard {
my $ac = WebGUI::AdminConsole->new($self->session,"clipboard");
return $self->session->privilege->insufficient() unless ($self->session->user->isInGroup(12));
my $i18n = WebGUI::International->new($self->session, "Asset");
my ($header,$limit);
if ($self->session->form->process("systemClipboard") && $self->session->user->isAdmin) {
$header = $i18n->get(966);
$ac->addSubmenuItem($self->getUrl('func=manageClipboard'), $i18n->get(949));
$ac->addSubmenuItem($self->getUrl('func=emptyClipboard;systemClipboard=1'), $i18n->get(959),
'onclick="return window.confirm(\''.$i18n->get(951,"WebGUI").'\')"',"Asset");
} else {
$ac->addSubmenuItem($self->getUrl('func=manageClipboard;systemClipboard=1'), $i18n->get(954));
$ac->addSubmenuItem($self->getUrl('func=emptyClipboard'), $i18n->get(950),
'onclick="return window.confirm(\''.$i18n->get(951,"WebGUI").'\')"',"Asset");
$limit = 1;
}
$self->session->style->setLink($self->session->url->extras('assetManager/assetManager.css'), {rel=>"stylesheet",type=>"text/css"});
$self->session->style->setScript($self->session->url->extras('assetManager/assetManager.js'), {type=>"text/javascript"});
my $header;
my $limit = 1;
my $canAdmin = $self->session->user->isInGroup($self->session->setting->get('groupIdAdminClipboard'));
if ($self->session->form->process("systemClipboard") && $canAdmin) {
$header = $i18n->get(966);
$ac->addSubmenuItem($self->getUrl('func=manageClipboard'), $i18n->get(949));
$ac->addSubmenuItem($self->getUrl('func=emptyClipboard;systemClipboard=1'), $i18n->get(959),
'onclick="return window.confirm(\''.$i18n->get(951,"WebGUI").'\')"',"Asset");
$limit = undef;
}
elsif ( $canAdmin ) {
$ac->addSubmenuItem($self->getUrl('func=manageClipboard;systemClipboard=1'), $i18n->get(954));
$ac->addSubmenuItem($self->getUrl('func=emptyClipboard'), $i18n->get(950),
'onclick="return window.confirm(\''.$i18n->get(951,"WebGUI").'\')"',"Asset");
}
else {
$ac->addSubmenuItem($self->getUrl('func=emptyClipboard'), $i18n->get(950),
'onclick="return window.confirm(\''.$i18n->get(951,"WebGUI").'\')"',"Asset");
}
$self->session->style->setLink($self->session->url->extras('assetManager/assetManager.css'), {rel=>"stylesheet",type=>"text/css"});
$self->session->style->setScript($self->session->url->extras('assetManager/assetManager.js'), {type=>"text/javascript"});
my $output = "
<script type=\"text/javascript\">
//<![CDATA[

View file

@ -56,11 +56,9 @@ An epoch representing the time this asset was created.
=head3 options
A hash reference that allows passed in options to change how this method behaves.
=head4 skipAutoCommitWorkflows
If this is set to 1 assets that normally autocommit their workflows (like CS Posts) won't do that.
A hash reference that allows passed in options to change how this method behaves. Currently,
these options are passed down to L<addRevision>, and are not actually used by C<addChild>.
Please see the POD for L<addRevision> for a list of options.
=cut

View file

@ -392,15 +392,18 @@ sub www_manageTrash {
my $ac = WebGUI::AdminConsole->new($self->session,"trash");
my $i18n = WebGUI::International->new($self->session,"Asset");
return $self->session->privilege->insufficient() unless ($self->session->user->isInGroup(12));
my ($header, $limit);
$ac->setHelp("trash manage");
if ($self->session->form->process("systemTrash") && $self->session->user->isAdmin) {
$ac->setHelp("trash manage");
my $header;
my $limit = 1;
my $canAdmin = $self->session->user->isInGroup($self->session->setting->get('groupIdAdminTrash'));
if ($self->session->form->process("systemTrash") && $canAdmin) {
$header = $i18n->get(965);
$ac->addSubmenuItem($self->getUrl('func=manageTrash'), $i18n->get(10,"WebGUI"));
} else {
$ac->addSubmenuItem($self->getUrl('func=manageTrash;systemTrash=1'), $i18n->get(964));
$limit = 1;
$limit = undef;
}
elsif ( $canAdmin ) {
$ac->addSubmenuItem($self->getUrl('func=manageTrash;systemTrash=1'), $i18n->get(964));
}
$self->session->style->setLink($self->session->url->extras('assetManager/assetManager.css'), {rel=>"stylesheet",type=>"text/css"});
$self->session->style->setScript($self->session->url->extras('assetManager/assetManager.js'), {type=>"text/javascript"});
my $output = "

View file

@ -169,56 +169,56 @@ sub getMoreMenu {
# These links are shown based on UI level
if ( $userUiLevel >= $toolbarUiLevel->{ "changeUrl" } ) {
push @more_fields, {
url => '<url>?func=changeUrl;proceed=manageAssets',
url => 'func=changeUrl;proceed=manageAssets',
label => $i18n->get( 'change url' ),
};
}
if ( $userUiLevel >= $toolbarUiLevel->{ "editBranch" } ) {
push @more_fields, {
url => '<url>?func=editBranch',
url => 'func=editBranch',
label => $i18n->get( 'edit branch' ),
};
}
if ( $userUiLevel >= $toolbarUiLevel->{ "shortcut" } ) {
push @more_fields, {
url => '<url>?func=createShortcut;proceed=manageAssets',
url => 'func=createShortcut;proceed=manageAssets',
label => $i18n->get( 'create shortcut' ),
};
}
if ( $userUiLevel >= $toolbarUiLevel->{ "revisions" } ) {
push @more_fields, {
url => '<url>?func=manageRevisions',
url => 'func=manageRevisions',
label => $i18n->get( 'revisions' ),
};
}
if ( $userUiLevel >= $toolbarUiLevel->{ "view" } ) {
push @more_fields, {
url => '<url>',
url => '',
label => $i18n->get( 'view' ),
};
}
if ( $userUiLevel >= $toolbarUiLevel->{ "edit" } ) {
push @more_fields, {
url => '<url>?func=edit;proceed=manageAssets',
url => 'func=edit;proceed=manageAssets',
label => $i18n->get( 'edit' ),
};
}
if ( $userUiLevel >= $toolbarUiLevel->{ "lock" } ) {
push @more_fields, {
url => '<url>?func=lock;proceed=manageAssets',
url => 'func=lock;proceed=manageAssets',
label => $i18n->get( 'lock' ),
};
}
if ( $session->config->get("exportPath") && $userUiLevel >= $toolbarUiLevel->{"export"} ) {
push @more_fields, {
url => '<url>?func=export',
url => 'func=export',
label => $i18n->get( 'Export Page' ),
};
}

View file

@ -0,0 +1,83 @@
package WebGUI::Content::SetLanguage;
=head1 LEGAL
-------------------------------------------------------------------
WebGUI is Copyright 2001-2009 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 WebGUI::Session;
use WebGUI::International;
=head1 NAME
Package WebGUI::Content::SetLanguage
=head1 DESCRIPTION
Sets or delete an scratch variable that overrides the profile field language
=head1 SYNOPSIS
use WebGUI::Content::SetLanguage;
WebGUI::Content::SetLanguage::handler();
=head1 SUBROUTINES
These subroutines are available from this package:
handler
=cut
#-------------------------------------------------------------
=head2 handler ( session, op, setLanguage )
sets or delete scratch variable in a session and returns undef
=head3 session
The current WebGUI::Session object.
=head3 op
op should be setLanguage to call the handler
=head3 language
language should be an installed language or delete
=cut
sub handler {
my ($session) = @_;
return undef unless $session->form->get('op') eq 'setLanguage';
my $language = $session->form->get('language');
#check whether a language has been given in the url
if (!$language) {
$session->log->error('There is no language given to this method');
return undef;
}
#make it possible to delete the language scratch variable from the session
if ($language eq 'delete' ) {
$session->scratch->removeLanguageOverride;
return undef;
}
#set a scratch variable language or throw error if language is not installed
else {
return $session->scratch->setLanguageOverride($language);
}
}
1;

View file

@ -0,0 +1,37 @@
package WebGUI::Help::Macro_PickLanguage;
use strict;
our $HELP = {
'template variables' => {
title => 'picklanguage title',
body => '',
fields =>[],
'variables' => [
{
name => "lang_loop",
variables => [
{
name => "language_lang",
},
{
name => "language_langAbbr",
},
{
name => "language_langAbbrLoc",
},
{
name => "language_langEng",
},
],
},
],
related => [
],
},
};
1; ##All perl modules must return true
#vim:ft=perl

View file

@ -284,7 +284,7 @@ Specify a default language. Defaults to user preference or "English".
sub new {
my ($class, $session, $namespace, $language) = @_;
$namespace ||= 'WebGUI';
$language ||= $session->user->profileField('language');
$language ||= $session->scratch->getLanguageOverride() || $session->user->profileField('language');
my $self =
bless {
_session => $session,

View file

@ -34,7 +34,7 @@ The text displayed to the user for this link. If this is blank an international
=head3 linkonly
The url for a template from the Macro/DeactivateAccount namespace to use for formatting the link.
If true, it will return only the URL for deactivating a user account.
=cut

View file

@ -0,0 +1,65 @@
package WebGUI::Macro::PickLanguage; # edit this line to match your own macro name
#-------------------------------------------------------------------
# WebGUI is Copyright 2001-2009 Plain Black Corporation.
#-------------------------------------------------------------------
# Please read the legal notices (docs/legal.txt) and the license
# (docs/license.txt) that came with this distribution before using
# this software.
#-------------------------------------------------------------------
# http://www.plainblack.com info@plainblack.com
#-------------------------------------------------------------------
use strict;
=head1 NAME
Package WebGUI::Macro::PickLanguage
=head1 DESCRIPTION
This macro makes a link for each installed language so when clicked the SetLanguage contetntHandler is called and sets the language in the scratch. The link text is the label from the language.
=head2 process( $session )
The main macro class, Macro.pm, will call this subroutine and pass it
=over 4
=item *
A session variable
=item templateId
This macro takes a templateId to show the links
=back
=cut
#-------------------------------------------------------------------
sub process {
my $session = shift;
my $templateId = shift || "_aE16Rr1-bXBf8SIaLZjCg";
my $template = WebGUI::Asset::Template->new($session, $templateId);
return "Could not instanciate template with id [$templateId]" unless $template;
my $i18n = WebGUI::International->new($session);
my $languages = $i18n->getLanguages();
my $vars = {'lang_loop' => []};
foreach my $language ( keys %$languages ) {
my $langVars = {};
$langVars->{ 'language_url' } = '?op=setLanguage;language=' . $language ;
$langVars->{ 'language_lang' } = $i18n->getLanguage($language , 'label');
$langVars->{ 'language_langAbbr' } = $i18n->getLanguage($language, 'languageAbbreviation');
$langVars->{ 'language_langAbbrLoc' } = $i18n->getLanguage($language, 'locale');
$langVars->{ 'language_langEng' } = $language;
push(@{$vars->{lang_loop}}, $langVars);
}
return $template->process($vars);
}
1;
#vim:ft=perl

View file

@ -520,6 +520,7 @@ sub definition {
groupIdAdminActiveSessions
groupIdAdminAdSpace
groupIdAdminCache
groupIdAdminClipboard
groupIdAdminCron
groupIdAdminDatabaseLink
groupIdAdminFilePump
@ -534,6 +535,7 @@ sub definition {
groupIdAdminReplacements
groupIdAdminSpectre
groupIdAdminStatistics
groupIdAdminTrash
groupIdAdminUser
groupIdAdminUserAdd
groupIdAdminVersionTag

View file

@ -373,10 +373,9 @@ sub www_commitVersionTag {
$session->url->page("op=commitVersionTag;tagId=".$tag->getId),
);
$p->setDataByQuery(q{
SELECT assetData.revisionDate, users.username, asset.assetId, asset.className
SELECT assetData.revisionDate, assetData.revisedBy, asset.assetId, asset.className
FROM assetData
LEFT JOIN asset ON assetData.assetId = asset.assetId
LEFT JOIN users ON assetData.revisedBy = users.userId
WHERE assetData.tagId=? },
undef,
undef,
@ -384,8 +383,9 @@ sub www_commitVersionTag {
);
foreach my $row ( @{$p->getPageData} ) {
my ( $date, $by, $id, $class) = @{ $row }{ qw( revisionDate username assetId className ) };
my ( $date, $byUserId, $id, $class) = @{ $row }{ qw( revisionDate revisedBy assetId className ) };
my $asset = WebGUI::Asset->new($session, $id, $class, $date);
my $byUser = WebGUI::User->new( $session, $byUserId );
$output
.= '<tr><td>'
.$session->icon->view("func=view;revision=".$date, $asset->get("url"))
@ -393,7 +393,7 @@ sub www_commitVersionTag {
<td>'.$asset->getTitle.'</td>
<td><img src="'.$asset->getIcon(1).'" alt="'.$asset->getName.'" />'.$asset->getName.'</td>
<td>'.$session->datetime->epochToHuman($date).'</td>
<td>'.$by.'</td></tr>';
<td>'.$byUser->get('username').'</td></tr>';
}
$output .= '</table>'.$p->getBarSimple;
@ -809,11 +809,12 @@ sub www_manageRevisionsInTag {
. '</tr> '
;
my $p = WebGUI::Paginator->new($session,$session->url->page("op=manageRevisionsInTag;tagId=".$tag->getId));
$p->setDataByQuery("select assetData.revisionDate, users.username, asset.assetId, asset.className from assetData
left join asset on assetData.assetId=asset.assetId left join users on assetData.revisedBy=users.userId
$p->setDataByQuery("select assetData.revisionDate, assetData.revisedBy, asset.assetId, asset.className from assetData
left join asset on assetData.assetId=asset.assetId
where assetData.tagId=?",undef, undef, [$tag->getId]);
foreach my $row (@{$p->getPageData}) {
my ($date,$by,$id, $class) = ($row->{revisionDate}, $row->{username}, $row->{assetId}, $row->{className});
my ($date,$byUserId,$id, $class) = ($row->{revisionDate}, $row->{revisedBy}, $row->{assetId}, $row->{className});
my $byUser = WebGUI::User->new( $session, $byUserId );
my $asset = WebGUI::Asset->new($session,$id,$class,$date);
# A checkbox for delete and move actions
my $checkbox = WebGUI::Form::checkbox( $session, {
@ -827,7 +828,7 @@ sub www_manageRevisionsInTag {
<td>'.$asset->getTitle.'</td>
<td><img src="'.$asset->getIcon(1).'" alt="'.$asset->getName.'" />'.$asset->getName.'</td>
<td>'.$session->datetime->epochToHuman($date).'</td>
<td>'.$by.'</td></tr>';
<td>'.$byUser->username.'</td></tr>';
}
$output .= '</table>'.$p->getBarSimple.WebGUI::Form::formFooter( $session );
$tag = $session->db->getRow("assetVersionTag","tagId",$tag->getId);

View file

@ -15,6 +15,7 @@ package WebGUI::Session::Scratch;
=cut
use strict;
use WebGUI::International;
=head1 NAME
@ -160,6 +161,19 @@ sub get {
return $self->{_data}{$var};
}
#-------------------------------------------------------------------
=head2 getLanguageOverride ()
Retrieves the language of the session scratch
=cut
sub getLanguageOverride {
my $self = shift;
my $languageOverride = $self->session->scratch->get('language');
return $languageOverride;
}
#-------------------------------------------------------------------
@ -180,7 +194,18 @@ sub new {
bless {_session=>$session, _data=>$data}, $class;
}
#-------------------------------------------------------------------
=head2 removeLanguageOverride()
Removes the language scratch variable from the session
=cut
sub removeLanguageOverride {
my $self = shift;
$self->session->scratch->delete('language');
}
#-------------------------------------------------------------------
=head2 session ( )
@ -220,5 +245,30 @@ sub set {
$self->session->db->write("insert into userSessionScratch (sessionId, name, value) values (?,?,?) on duplicate key update value=VALUES(value)", [$self->session->getId, $name, $value]);
}
#----------------------------------------------------------------------
=head2 setLanguageOverride ( language )
Sets a scratch variable language in the session if the language is installed
=head3 language
The language that should be set into the session
=cut
sub setLanguageOverride {
my $self = shift;
my $language = shift;
my $i18n = WebGUI::International->new($self->session);
if($i18n->getLanguages()->{$language}) {
$self->session->scratch->set("language",$language);
return undef;
}
else {
$self->session->log->error("Language $language is not installed in this site");
return undef;
}
}
1;

View file

@ -163,6 +163,11 @@ our $I18N = {
lastUpdated => 0,
context => 'Success message',
},
'select a point' => {
message => "Select a point",
lastUpdated => 0,
context => "Choose from the list of points that existon the map",
},
'assetName' => {
message => "Map",
lastUpdated => 0,

View file

@ -0,0 +1,48 @@
package WebGUI::i18n::English::Macro_PickLanguage; ##Be sure to change the package name to match the filename
use strict; ##Required for all good Perl::Critic compliant code
our $I18N = { ##hashref of hashes
'picklanguage title' => {
message => q|PickLanguage macro template variables|,
lastUpdated => 1131394070,
context => q|Title of the help object|
},
'lang_loop' => { ##key that will be used to reference this entry. Do not translate this.
message => q|A loop that contains all installed languages|,
lastUpdated => 1131394070, #seconds from the epoch
context => q|A template loop|
},
'language_lang' => {
message => q|The name of the language in that language.|,
lastUpdated => 1131394072,
context => q|A template variable to show the name of the language|
},
'language_langAbbr' => {
message => q|An standard code for the language, for instance "en".|,
lastUpdated => 1131394072,
context => q|A label of the language to use in the template|
},
'language_langAbbrLoc' => {
message => q|An standard abbreviated label for the language, for instance "US".|,
lastUpdated => 1131394072,
context => q|A label of the language to use in the template|
},
'language_langEng' => {
message => q|The English name of the language.|,
lastUpdated => 1131394072,
context => q|A label of the language to use in the template|
},
'language_url' => {
message => q|The url that sets the WebGUI language to the selected language.|,
lastUpdated => 1131394072,
context => q|The url to change languages|
},
};
1;
#vim:ft=perl

View file

@ -3904,6 +3904,15 @@ LongTruncOk=1</p>
},
'settings groupIdAdminClipboard label' => {
message => q{Clipboard},
lastUpdated => 0,
},
'settings groupIdAdminClipboard hoverHelp' => {
message => q{Group to manage the system clipboard.},
lastUpdated => 0,
},
'settings groupIdAdminCron label' => {
message => q{Cron},
@ -4051,6 +4060,15 @@ LongTruncOk=1</p>
lastUpdated => 0,
},
'settings groupIdAdminTrash label' => {
message => q{Trash},
lastUpdated => 0,
},
'settings groupIdAdminTrash hoverHelp' => {
message => q{Group to manage the system trash.},
lastUpdated => 0,
},
'settings groupIdAdminUser label' => {
message => q{Users},
lastUpdated => 0,