Merge branch 'master' of git@github.com:plainblack/webgui
This commit is contained in:
commit
9db3e02444
38 changed files with 898 additions and 228 deletions
|
|
@ -10,6 +10,18 @@
|
|||
- fixed #11047: required field on dataform
|
||||
- fixed #11162: Can't delete calendar Related Material Link
|
||||
- fixed #11154: vendor payouts screen borked ( Martin Kamerbeek / Oqapi )
|
||||
- fixed #11166: Documentation bug - addChild
|
||||
- fixed #11116: Deleted user's version tags and revisions
|
||||
- fixed #11168: Points do not work with uncommitted Map
|
||||
- fixed #10888: Add Point... how do I enter details?
|
||||
- fixed #10887: Map Point dropdown doesn't update
|
||||
- fixed #11172: Collaboration broken vars: isSecond, isThird etc.
|
||||
- fixed #11165: DatePicker broken in IE7
|
||||
- added: Manage System Clipboard group setting
|
||||
- added: Manage System Trash group setting
|
||||
- fixed #11069: "More" options menu in asset manager
|
||||
- rfe #10755: Adding SetLanguage bazaar item
|
||||
- fixed #11176: New upgrade error in 7.6.35 to 7.7.17
|
||||
|
||||
7.8.2
|
||||
- Added scheduled vendor payout workflow activity. (Special thanks to Martin @ Oqapi)
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
|
|
@ -22,6 +22,7 @@ use Getopt::Long;
|
|||
use WebGUI::Session;
|
||||
use WebGUI::Storage;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Utility;
|
||||
|
||||
|
||||
my $toVersion = '7.8.3';
|
||||
|
|
@ -33,25 +34,49 @@ my $session = start(); # this line required
|
|||
# upgrade functions go here
|
||||
reKeyTemplateAttachments($session);
|
||||
addSelectPaymentGatewayTemplateToSettings($session);
|
||||
addClipboardAdminSetting($session);
|
||||
addTrashAdminSetting($session);
|
||||
addPickLanguageMacro($session);
|
||||
installSetLanguage($session);
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub addClipboardAdminSetting {
|
||||
my $session = shift;
|
||||
print "\tAdding clipboard admin setting... " unless $quiet;
|
||||
$session->setting->add('groupIdAdminClipboard', 3);
|
||||
print "Done.\n" unless $quiet;
|
||||
}
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
sub addTrashAdminSetting {
|
||||
my $session = shift;
|
||||
print "\tAdding trash admin setting... " unless $quiet;
|
||||
$session->setting->add('groupIdAdminTrash', 3);
|
||||
print "Done.\n" unless $quiet;
|
||||
}
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
sub reKeyTemplateAttachments {
|
||||
my $session = shift;
|
||||
print "\tChanging the key structure for the template attachments table... " unless $quiet;
|
||||
# and here's our code
|
||||
$session->db->write('ALTER TABLE template_attachments ADD COLUMN attachId CHAR(22) BINARY NOT NULL');
|
||||
my $rh = $session->db->read('select url, templateId, revisionDate from template_attachments');
|
||||
my $wh = $session->db->prepare('update template_attachments set attachId=? where url=? and templateId=? and revisionDate=?');
|
||||
while (my @key = $rh->array) {
|
||||
$wh->execute([$session->id->generate, @key ]);
|
||||
my $columnExists = $session->db->dbh->column_info(undef, undef, 'template_attachments', 'attachId')->fetchrow_hashref;
|
||||
if (! $columnExists) {
|
||||
# and here's our code
|
||||
$session->db->write('ALTER TABLE template_attachments ADD COLUMN attachId CHAR(22) BINARY NOT NULL');
|
||||
my $rh = $session->db->read('select url, templateId, revisionDate from template_attachments');
|
||||
my $wh = $session->db->prepare('update template_attachments set attachId=? where url=? and templateId=? and revisionDate=?');
|
||||
while (my @key = $rh->array) {
|
||||
$wh->execute([$session->id->generate, @key ]);
|
||||
}
|
||||
$rh->finish;
|
||||
$wh->finish;
|
||||
$session->db->write('ALTER TABLE template_attachments DROP PRIMARY KEY');
|
||||
$session->db->write('ALTER TABLE template_attachments ADD PRIMARY KEY (attachId)');
|
||||
}
|
||||
$rh->finish;
|
||||
$wh->finish;
|
||||
$session->db->write('ALTER TABLE template_attachments DROP PRIMARY KEY');
|
||||
$session->db->write('ALTER TABLE template_attachments ADD PRIMARY KEY (attachId)');
|
||||
print "DONE!\n" unless $quiet;
|
||||
}
|
||||
|
||||
|
|
@ -60,7 +85,7 @@ sub reKeyTemplateAttachments {
|
|||
sub addSelectPaymentGatewayTemplateToSettings {
|
||||
my $session = shift;
|
||||
print "\tAdding select payment gateway template to settings... " unless $quiet;
|
||||
$session->db->write("insert into settings values ('selectGatewayTemplateId', '2GxjjkRuRkdUg_PccRPjpA');");
|
||||
$session->setting->add('selectGatewayTemplateId', '2GxjjkRuRkdUg_PccRPjpA') unless $session->setting->has('selectGatewayTemplateId');
|
||||
print "Done.\n" unless $quiet;
|
||||
}
|
||||
|
||||
|
|
@ -71,6 +96,30 @@ sub addSelectPaymentGatewayTemplateToSettings {
|
|||
# print "DONE!\n" unless $quiet;
|
||||
#}
|
||||
|
||||
#------------------------------------------------------------------------
|
||||
sub addPickLanguageMacro {
|
||||
my $session = shift;
|
||||
print "\tAdding Pick Language macro... " unless $quiet;
|
||||
$session->config->set('macros/PickLanguage', 'PickLanguage');
|
||||
print "Done.\n" unless $quiet;
|
||||
}
|
||||
|
||||
sub installSetLanguage {
|
||||
my $session = shift;
|
||||
print "\tAdding SetLanguage content handler... " unless $quiet;
|
||||
##Content Handler
|
||||
my $contentHandlers = $session->config->get('contentHandlers');
|
||||
if (!isIn('WebGUI::Content::SetLanguage', @{ $contentHandlers }) ) {
|
||||
my @newHandlers = ();
|
||||
foreach my $handler (@{ $contentHandlers }) {
|
||||
push @newHandlers, $handler;
|
||||
push @newHandlers, 'WebGUI::Content::SetLanguage' if
|
||||
$handler eq 'WebGUI::Content::PassiveAnalytics';
|
||||
}
|
||||
$session->config->set('contentHandlers', \@newHandlers);
|
||||
}
|
||||
print "Done.\n" unless $quiet;
|
||||
}
|
||||
|
||||
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -811,6 +811,7 @@
|
|||
"Page" : "Page",
|
||||
"PageTitle" : "PageTitle",
|
||||
"PageUrl" : "PageUrl",
|
||||
"PickLanguage" : "PickLanguage",
|
||||
"RandomAssetProxy" : "RandomAssetProxy",
|
||||
"RandomThread" : "RandomThread",
|
||||
"RootTitle" : "RootTitle",
|
||||
|
|
@ -968,6 +969,7 @@
|
|||
"WebGUI::Content::AssetManager",
|
||||
"WebGUI::Content::AssetDiscovery",
|
||||
"WebGUI::Content::PassiveAnalytics",
|
||||
"WebGUI::Content::SetLanguage",
|
||||
"WebGUI::Content::AjaxI18N",
|
||||
"WebGUI::Content::Account",
|
||||
"WebGUI::Content::AssetHistory",
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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[
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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 = "
|
||||
|
|
|
|||
|
|
@ -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' ),
|
||||
};
|
||||
}
|
||||
|
|
|
|||
83
lib/WebGUI/Content/SetLanguage.pm
Normal file
83
lib/WebGUI/Content/SetLanguage.pm
Normal 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;
|
||||
37
lib/WebGUI/Help/Macro_PickLanguage.pm
Normal file
37
lib/WebGUI/Help/Macro_PickLanguage.pm
Normal 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
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
65
lib/WebGUI/Macro/PickLanguage.pm
Normal file
65
lib/WebGUI/Macro/PickLanguage.pm
Normal 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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
48
lib/WebGUI/i18n/English/Macro_PickLanguage.pm
Normal file
48
lib/WebGUI/i18n/English/Macro_PickLanguage.pm
Normal 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
|
||||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -24,12 +24,12 @@ use WebGUI::Session;
|
|||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
plan tests => 20; # Increment this number for each test you create
|
||||
plan tests => 21; # Increment this number for each test you create
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my @addChildArgs = ( {skipAutoCommitWorkflows=>1} );
|
||||
my @addChildArgs = ( {skipAutoCommitWorkflows=>1, skipNotification => 1, } );
|
||||
my $collab = WebGUI::Asset->getImportNode( $session )->addChild({
|
||||
className => 'WebGUI::Asset::Wobject::Collaboration',
|
||||
threadsPerPage => 20,
|
||||
|
|
@ -54,7 +54,7 @@ my @threads = (
|
|||
$_->setSkipNotification for @threads; # 100+ messages later...
|
||||
my $versionTag = WebGUI::VersionTag->getWorking( $session );
|
||||
$versionTag->commit;
|
||||
WebGUI::Test->tagsToRollback($versionTag);
|
||||
addToCleanup($versionTag);
|
||||
|
||||
my $templateVars;
|
||||
my $posts;
|
||||
|
|
@ -89,4 +89,51 @@ ok( !$posts->[0]->{'user.isVisitor'}, 'first post made by visitor');
|
|||
ok( $posts->[0]->{'hideProfileUrl'}, 'hide profile url, and user is visitor');
|
||||
ok( !$posts->[0]->{'lastReply.user.isVisitor'}, 'lastReply not made by visitor');
|
||||
ok( $posts->[0]->{'lastReply.hideProfileUrl'}, 'lastReply hide profile url, since user is visitor');
|
||||
|
||||
|
||||
###################################################################
|
||||
#
|
||||
#isSecond, isThird, etc.
|
||||
#
|
||||
###################################################################
|
||||
|
||||
my @newThreads = ();
|
||||
foreach my $index (1 .. 5) {
|
||||
$newThreads[$index] = $collab->addChild( {
|
||||
className => 'WebGUI::Asset::Post::Thread',
|
||||
title => "X - Bar",
|
||||
isSticky => 0,
|
||||
ownerUserId => 3,
|
||||
}, undef, 2+$index, @addChildArgs);
|
||||
$newThreads[$index]->setSkipNotification;
|
||||
}
|
||||
my $vt2 = WebGUI::VersionTag->getWorking($session);
|
||||
$vt2->commit;
|
||||
addToCleanup($versionTag);
|
||||
|
||||
$session->user({userId => 3});
|
||||
$templateVars = $collab->getViewTemplateVars();
|
||||
my $indexVars;
|
||||
foreach my $post (@{ $templateVars->{post_loop }}) {
|
||||
push @{$indexVars}, {
|
||||
isSecond => $post->{isSecond} ? 1 : 0,
|
||||
isThird => $post->{isThird} ? 1 : 0,
|
||||
isFourth => $post->{isFourth} ? 1 : 0,
|
||||
isFifth => $post->{isFifth} ? 1 : 0,
|
||||
};
|
||||
}
|
||||
|
||||
cmp_deeply(
|
||||
$indexVars,
|
||||
[
|
||||
{ isSecond => 0, isThird => 0, isFourth => 0, isFifth => 0, },
|
||||
{ isSecond => 1, isThird => 0, isFourth => 0, isFifth => 0, },
|
||||
{ isSecond => 0, isThird => 1, isFourth => 0, isFifth => 0, },
|
||||
{ isSecond => 0, isThird => 0, isFourth => 1, isFifth => 0, },
|
||||
{ isSecond => 0, isThird => 0, isFourth => 0, isFifth => 1, },
|
||||
{ isSecond => 0, isThird => 0, isFourth => 0, isFifth => 0, }, ##No modulo
|
||||
{ isSecond => 0, isThird => 0, isFourth => 0, isFifth => 0, }, ##No modulo
|
||||
],
|
||||
'checking isSecond, isThird, isFourth, isFifth'
|
||||
);
|
||||
#vim:ft=perl
|
||||
|
|
|
|||
55
t/Content/SetLanguage.t
Normal file
55
t/Content/SetLanguage.t
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Content::SetLanguage;
|
||||
|
||||
# load your modules here
|
||||
|
||||
use Test::More tests => 5; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
# put your tests here
|
||||
my $formvariables = {
|
||||
'op' =>'setLanguage',
|
||||
'language' => 'English'
|
||||
};
|
||||
#test 1
|
||||
$session->request->setup_body($formvariables);
|
||||
WebGUI::Content::SetLanguage::handler($session);
|
||||
is($session->scratch->getLanguageOverride, 'English', 'the language was not set');
|
||||
#test2
|
||||
$formvariables->{'language'} = 'delete';
|
||||
$session->request->setup_body($formvariables);
|
||||
WebGUI::Content::SetLanguage::handler($session);
|
||||
is($session->scratch->getLanguageOverride, undef, 'language delete should remove the scratch variable');
|
||||
#test3
|
||||
$formvariables->{'op'} = 'SetLanguage';
|
||||
$formvariables->{'language'} = 'English';
|
||||
$session->request->setup_body($formvariables);
|
||||
WebGUI::Content::SetLanguage::handler($session);
|
||||
is($session->scratch->getLanguageOverride, undef, 'Naming the method wrongly should not change anything');
|
||||
#test4
|
||||
$formvariables->{'op'} = 'setLanguage';
|
||||
$formvariables->{'language'} = 'MyImaginaryLanguageThatIsNotInstalled';
|
||||
$session->request->setup_body($formvariables);
|
||||
WebGUI::Content::SetLanguage::handler($session);
|
||||
is($session->scratch->getLanguageOverride, undef, 'Giving a non installed language should not change anything');
|
||||
#test5
|
||||
$formvariables->{'language'} = undef;
|
||||
$session->request->setup_body($formvariables);
|
||||
WebGUI::Content::SetLanguage::handler($session);
|
||||
is($session->scratch->getLanguageOverride, undef, 'Passing an empty language variable should return undef');
|
||||
|
||||
|
|
@ -16,12 +16,13 @@ use WebGUI::Session;
|
|||
use Test::More; # increment this value for each test you create
|
||||
use File::Copy;
|
||||
use File::Spec;
|
||||
use WebGUI::Content::SetLanguage;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
my $numTests = 1; ##For conditional load check
|
||||
my $langTests = 4; ##For language look-up tests
|
||||
$numTests += 12 + $langTests;
|
||||
$numTests += 20 + $langTests;
|
||||
|
||||
plan tests => $numTests;
|
||||
|
||||
|
|
@ -50,6 +51,16 @@ is($i18n->get('topicName', 'WebGUI'), 'WebGUI', 'get: test manual namespace over
|
|||
|
||||
installPigLatin();
|
||||
|
||||
#tests for sub new
|
||||
my $i18nNew1 = WebGUI::International->new($session);
|
||||
is($i18nNew1->{_language}, 'English', 'Calling new without parameters should return object with language English');
|
||||
is($i18nNew1->{_namespace}, 'WebGUI', 'Calling without parameters should give namespace WebgUI');
|
||||
my $i18nNew2 = WebGUI::International->new($session, 'WebGUI::Asset');
|
||||
is($i18nNew2->{_language}, 'English', 'Calling new with only namespace parameter should return object with language English');
|
||||
is($i18nNew2->{_namespace}, 'WebGUI::Asset', 'Calling with only parameter namespace should give requested namespace');
|
||||
my $i18nNew3 = WebGUI::International->new($session, undef , 'PigLatin');
|
||||
is($i18nNew3->{_language}, 'PigLatin', 'Calling new with only language parameter should return object with language PigLatin');
|
||||
is($i18nNew3->{_namespace}, 'WebGUI', 'Calling with only parameter namespace should give WebGUI ');
|
||||
my $languages = $i18n->getLanguages();
|
||||
|
||||
my $gotPigLatin = exists $languages->{PigLatin};
|
||||
|
|
@ -102,6 +113,24 @@ sub installPigLatin {
|
|||
);
|
||||
}
|
||||
|
||||
#test for sub new with language overridden by scratch
|
||||
my $formvariables = {
|
||||
'op' =>'setLanguage',
|
||||
'language' => 'PigLatin'
|
||||
};
|
||||
$session->request->setup_body($formvariables);
|
||||
WebGUI::Content::SetLanguage::handler($session);
|
||||
my $newi18n = WebGUI::International->new($session);
|
||||
is(
|
||||
$newi18n->get('webgui','WebGUI','PigLatin'),
|
||||
'ebGUIWay',
|
||||
'if the piglatin language is in the scratch that messages should be retrieved'
|
||||
);
|
||||
is(
|
||||
$newi18n->get('104','Asset','PigLatin'),
|
||||
$newi18n->get('104', 'WebGUI', 'English'),
|
||||
'Language check after SetLanguage contentHandler : key from missing file return English key'
|
||||
);
|
||||
END {
|
||||
unlink File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin WebGUI.pm/);
|
||||
unlink File::Spec->catfile(WebGUI::Test->lib, qw/WebGUI i18n PigLatin.pm/);
|
||||
|
|
|
|||
|
|
@ -14,26 +14,14 @@ use lib "$FindBin::Bin/../lib";
|
|||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Macro::AdminBar;
|
||||
use HTML::TokeParser;
|
||||
|
||||
use Test::More; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
my $numTests = 2;
|
||||
|
||||
$numTests += 1; #For the use_ok
|
||||
|
||||
plan tests => $numTests;
|
||||
|
||||
my $macro = 'WebGUI::Macro::AdminBar';
|
||||
my $loaded = use_ok($macro);
|
||||
|
||||
my $originalAssets = $session->config->get('assets');
|
||||
|
||||
SKIP: {
|
||||
|
||||
skip "Unable to load $macro", $numTests-1 unless $loaded;
|
||||
plan tests => 2;
|
||||
|
||||
my $output;
|
||||
$output = WebGUI::Macro::AdminBar::process($session);
|
||||
|
|
@ -42,9 +30,3 @@ $session->var->switchAdminOn;
|
|||
$output = WebGUI::Macro::AdminBar::process($session);
|
||||
ok($output, 'AdminBar returns something when admin is on');
|
||||
|
||||
|
||||
}
|
||||
|
||||
END: {
|
||||
$session->config->set('assets', $originalAssets);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,22 +14,14 @@ use lib "$FindBin::Bin/../lib";
|
|||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Macro::AdminText;
|
||||
use Data::Dumper;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
use Test::More; # increment this value for each test you create
|
||||
|
||||
my $numTests = 6 + 1;
|
||||
|
||||
plan tests => $numTests;
|
||||
|
||||
my $macro = 'WebGUI::Macro::AdminText';
|
||||
my $loaded = use_ok($macro);
|
||||
|
||||
SKIP: {
|
||||
|
||||
skip "Unable to load $macro", $numTests-1 unless $loaded;
|
||||
plan tests => 6;
|
||||
|
||||
my $output;
|
||||
|
||||
|
|
@ -54,5 +46,3 @@ is($output, undef, 'undef text');
|
|||
$session->var->switchAdminOff;
|
||||
$output = WebGUI::Macro::AdminText::process($session, 'admin');
|
||||
is($output, '', 'user is admin, not in admin mode');
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,12 +16,13 @@ use WebGUI::Test;
|
|||
use WebGUI::Session;
|
||||
use HTML::TokeParser;
|
||||
use Data::Dumper;
|
||||
use WebGUI::Macro::AdminToggle;
|
||||
|
||||
use Test::More; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
my ($versionTag, $template) = addTemplate();
|
||||
my $template = addTemplate();
|
||||
|
||||
my $homeAsset = WebGUI::Asset->getDefault($session);
|
||||
$session->asset($homeAsset);
|
||||
|
|
@ -105,14 +106,7 @@ foreach my $testSet (@testSets) {
|
|||
$numTests += 1 + (ref $testSet->{output} eq 'CODE');
|
||||
}
|
||||
|
||||
plan tests => $numTests + 2; ##conditional module load and TODO at end
|
||||
|
||||
my $macro = 'WebGUI::Macro::AdminToggle';
|
||||
my $loaded = use_ok($macro);
|
||||
|
||||
SKIP: {
|
||||
|
||||
skip "Unable to load $macro", $numTests-1 unless $loaded;
|
||||
plan tests => $numTests + 1; ##conditional module load and TODO at end
|
||||
|
||||
foreach my $testSet (@testSets) {
|
||||
$session->user({userId=>$testSet->{userId}});
|
||||
|
|
@ -136,8 +130,6 @@ foreach my $testSet (@testSets) {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
TODO: {
|
||||
local $TODO = 'Tests to make later';
|
||||
ok(0, 'Run tests with a user other than Admin');
|
||||
|
|
@ -159,7 +151,8 @@ sub addTemplate {
|
|||
};
|
||||
my $template = $importNode->addChild($properties, $properties->{id});
|
||||
$versionTag->commit;
|
||||
return ($versionTag, $template);
|
||||
addToCleanup($versionTag);
|
||||
return $template;
|
||||
}
|
||||
|
||||
sub simpleHTMLParser {
|
||||
|
|
@ -181,9 +174,3 @@ sub simpleTextParser {
|
|||
|
||||
return ($url, $label);
|
||||
}
|
||||
|
||||
END {
|
||||
if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') {
|
||||
$versionTag->rollback;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,23 +14,17 @@ use lib "$FindBin::Bin/../lib";
|
|||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Macro::At_username;
|
||||
use Data::Dumper;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
use Test::More; # increment this value for each test you create
|
||||
|
||||
my $numTests = 2 + 1; # For conditional load and skip
|
||||
my $numTests = 2; # For conditional load and skip
|
||||
|
||||
plan tests => $numTests;
|
||||
|
||||
my $macro = 'WebGUI::Macro::At_username';
|
||||
my $loaded = use_ok($macro);
|
||||
|
||||
SKIP: {
|
||||
|
||||
skip "Unable to load $macro", $numTests-1 unless $loaded;
|
||||
|
||||
my $output;
|
||||
|
||||
$session->user({userId => 1});
|
||||
|
|
@ -41,4 +35,3 @@ $session->user({userId => 3});
|
|||
$output = WebGUI::Macro::At_username::process($session);
|
||||
is($output, 'Admin', 'username = Admin');
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ my $session = WebGUI::Test->session;
|
|||
use Test::More; # increment this value for each test you create
|
||||
|
||||
my $homeAsset = WebGUI::Asset->getDefault($session);
|
||||
my ($versionTag, $asset, $group, @users) = setupTest($session, $homeAsset);
|
||||
my ($asset, $group, @users) = setupTest($session, $homeAsset);
|
||||
|
||||
my @testSets = (
|
||||
{
|
||||
|
|
@ -111,17 +111,6 @@ sub setupTest {
|
|||
$users[1]->addToGroups([$cm->getId]);
|
||||
##User 2 is a member of a content manager sub-group
|
||||
$users[2]->addToGroups([$editGroup->getId]);
|
||||
return ($versionTag, $asset, $editGroup, @users);
|
||||
}
|
||||
|
||||
END { ##Clean-up after yourself, always
|
||||
if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') {
|
||||
$versionTag->rollback;
|
||||
}
|
||||
foreach my $testGroup ($group) {
|
||||
$testGroup->delete if (defined $testGroup and ref $testGroup eq 'WebGUI::Group');
|
||||
}
|
||||
foreach my $dude (@users) {
|
||||
$dude->delete if (defined $dude and ref $dude eq 'WebGUI::User');
|
||||
}
|
||||
addToCleanup($versionTag, $editGroup, @users);
|
||||
return ($asset, $editGroup, @users);
|
||||
}
|
||||
|
|
|
|||
125
t/Macro/PickLanguage.t
Normal file
125
t/Macro/PickLanguage.t
Normal file
|
|
@ -0,0 +1,125 @@
|
|||
#-------------------------------------------------------------------
|
||||
# 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 FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
|
||||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Asset::Template;
|
||||
|
||||
use Test::More; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
use Test::MockObject;
|
||||
use Test::MockObject::Extends;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
my $numTests = 3;
|
||||
|
||||
$numTests += 1; #For the use_ok
|
||||
|
||||
plan tests => $numTests;
|
||||
|
||||
my $macro = 'WebGUI::Macro::PickLanguage';
|
||||
my $loaded = use_ok($macro);
|
||||
|
||||
my $macroMock = Test::MockObject->new({});
|
||||
$macroMock->set_isa('WebGUI::Macro::PickLanguage');
|
||||
$macroMock->set_true('process');
|
||||
|
||||
#test for normal use
|
||||
|
||||
my $templateId = 'PICKLANGUAGE_TEMPLATE_';
|
||||
|
||||
my $templateMock = Test::MockObject->new({});
|
||||
$templateMock->set_isa('WebGUI::Asset::Template');
|
||||
$templateMock->set_always('getId', $templateId);
|
||||
my $templateVars;
|
||||
$templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||
|
||||
|
||||
{
|
||||
WebGUI::Test->mockAssetId($templateId, $templateMock);
|
||||
WebGUI::Macro::PickLanguage::process($session,$templateMock->getId);
|
||||
|
||||
cmp_deeply(
|
||||
$templateVars,
|
||||
{
|
||||
lang_loop => [
|
||||
{ 'language_url' => '?op=setLanguage;language=English',
|
||||
'language_lang' => 'English',
|
||||
'language_langAbbr' => 'en',
|
||||
'language_langAbbrLoc' => 'US',
|
||||
'language_langEng' => 'English'
|
||||
},
|
||||
],
|
||||
},
|
||||
'some template variables are created'
|
||||
);
|
||||
WebGUI::Test->unmockAssetId($templateId);
|
||||
}
|
||||
|
||||
#test when template Id is left empty
|
||||
|
||||
$templateId = '';
|
||||
my $templateNoId = $templateMock->mock('process','');
|
||||
$templateMock->set_always('getId', $templateId);
|
||||
$templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||
|
||||
{
|
||||
|
||||
WebGUI::Test->mockAssetId($templateId, $templateMock);
|
||||
WebGUI::Macro::PickLanguage::process($session,$templateMock->getId);
|
||||
|
||||
cmp_deeply(
|
||||
$templateVars,
|
||||
{
|
||||
lang_loop => [
|
||||
{ 'language_url' => '?op=setLanguage;language=English',
|
||||
'language_lang' => 'English',
|
||||
'language_langAbbr' => 'en',
|
||||
'language_langAbbrLoc' => 'US',
|
||||
'language_langEng' => 'English'
|
||||
},
|
||||
],
|
||||
},
|
||||
'some template variables are created, when no templateId is passed on with the macro'
|
||||
);
|
||||
WebGUI::Test->unmockAssetId($templateId);
|
||||
}
|
||||
|
||||
|
||||
#{
|
||||
# WebGUI::Test->mockAssetId($templateNoId, $templateMock);
|
||||
# $error = WebGUI::Macro::PickLanguage::process($session,$templateMock->getId);
|
||||
#
|
||||
# is($error,'Could not instanciate template with id []',"Empty template Id should return error");
|
||||
#
|
||||
# WebGUI::Test->unmockAssetId($templateNoId);
|
||||
#}
|
||||
|
||||
#test for an incorrect template Id
|
||||
|
||||
$templateId = '1234567890123456789012';
|
||||
my $templateWrongId = $templateMock->mock('process','');
|
||||
$templateMock->set_always('getId', $templateId);
|
||||
$templateMock->mock('process', sub { $templateVars = $_[1]; } );
|
||||
my $error;
|
||||
|
||||
|
||||
{
|
||||
WebGUI::Test->mockAssetId($templateWrongId, $templateMock);
|
||||
$error = WebGUI::Macro::PickLanguage::process($session,$templateMock->getId);
|
||||
|
||||
is($error,'Could not instanciate template with id [1234567890123456789012]',"Template from the wrong namespace should not be initiated");
|
||||
WebGUI::Test->unmockAssetId($templateWrongId);
|
||||
}
|
||||
|
||||
|
|
@ -16,13 +16,14 @@ use WebGUI::Test;
|
|||
use WebGUI::Session;
|
||||
use HTML::TokeParser;
|
||||
use Data::Dumper;
|
||||
use WebGUI::Macro::a_account;
|
||||
|
||||
use Test::More; # increment this value for each test you create
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
# <a class="myAccountLink" href="<tmpl_var account.url>"><tmpl_var account.text></a>
|
||||
my ($versionTag, $template) = addTemplate();
|
||||
my $template = addTemplate();
|
||||
|
||||
my $homeAsset = WebGUI::Asset->getDefault($session);
|
||||
|
||||
|
|
@ -65,17 +66,8 @@ foreach my $testSet (@testSets) {
|
|||
$numTests += 1 + (ref $testSet->{output} eq 'CODE');
|
||||
}
|
||||
|
||||
$numTests += 1; #For the use_ok
|
||||
|
||||
plan tests => $numTests;
|
||||
|
||||
my $macro = 'WebGUI::Macro::a_account';
|
||||
my $loaded = use_ok($macro);
|
||||
|
||||
SKIP: {
|
||||
|
||||
skip "Unable to load $macro", $numTests-1 unless $loaded;
|
||||
|
||||
foreach my $testSet (@testSets) {
|
||||
my $output = WebGUI::Macro::a_account::process( $session,
|
||||
$testSet->{label}, $testSet->{template} );
|
||||
|
|
@ -90,8 +82,6 @@ foreach my $testSet (@testSets) {
|
|||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sub addTemplate {
|
||||
$session->user({userId=>3});
|
||||
my $importNode = WebGUI::Asset->getImportNode($session);
|
||||
|
|
@ -108,7 +98,8 @@ sub addTemplate {
|
|||
};
|
||||
my $template = $importNode->addChild($properties, $properties->{id});
|
||||
$versionTag->commit;
|
||||
return ($versionTag, $template);
|
||||
addToCleanup($versionTag);
|
||||
return $template;
|
||||
}
|
||||
|
||||
sub simpleHTMLParser {
|
||||
|
|
@ -130,9 +121,3 @@ sub simpleTextParser {
|
|||
|
||||
return ($url, $label);
|
||||
}
|
||||
|
||||
END {
|
||||
if (defined $versionTag and ref $versionTag eq 'WebGUI::VersionTag') {
|
||||
$versionTag->rollback;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -122,9 +122,7 @@ $mail = WebGUI::Mail::Send->create( $session, {
|
|||
});
|
||||
$mail->addHeaderField('List-ID', "H\x{00C4}ufige Fragen");
|
||||
my $messageId = $mail->queue;
|
||||
diag $messageId;
|
||||
my $dbMail = WebGUI::Mail::Send->retrieve($session, $messageId);
|
||||
diag ref $dbMail;
|
||||
is($dbMail->getMimeEntity->head->get('List-ID'), "=?UTF-8?Q?H=C3=84ufige=20Fragen?=\n", 'addHeaderField: handles utf-8 correctly');
|
||||
|
||||
# TODO: Test that addHtml creates a body with the right content type
|
||||
|
|
@ -337,7 +335,7 @@ $mail->send;
|
|||
is(scalar @mailIds, $startingMessages+2, 'sending a message with a group added two messages');
|
||||
|
||||
@mailIds = $session->db->buildArray("select messageId from mailQueue where message like ?",['%Mail::Send test message%']);
|
||||
is(scalar @mailIds, $startingMessages+2, 'sending a message with a group added the right two messages');
|
||||
is(scalar @mailIds, 2, 'sending a message with a group added the right two messages');
|
||||
|
||||
my @emailAddresses = ();
|
||||
foreach my $mailId (@mailIds) {
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ use lib "$FindBin::Bin/../lib";
|
|||
use WebGUI::Test;
|
||||
use WebGUI::Session;
|
||||
|
||||
use Test::More tests => 58; # increment this value for each test you create
|
||||
use Test::More tests => 62; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
|
||||
my $session = WebGUI::Test->session;
|
||||
|
|
@ -117,6 +117,16 @@ is($sessionBank[0]->scratch->deleteNameByValue('',''), undef, 'deleteNameByValue
|
|||
is($sessionBank[3]->scratch->deleteNameByValue('falseValue','0'), 1, 'deleteNameByValue will delete values that are false (0)');
|
||||
is($sessionBank[2]->scratch->deleteNameByValue('falseValue',''), 1, "deleteNameByValue will delete values that are false ('')");
|
||||
|
||||
$scratch->setLanguageOverride('English');
|
||||
is($scratch->getLanguageOverride, 'English', 'session scratch language is not correctly set');
|
||||
$scratch->removeLanguageOverride;
|
||||
is($scratch->getLanguageOverride, undef, 'The session scratch variable language is not removed');
|
||||
$scratch->setLanguageOverride('myimmaginarylanguagethatisnotinstalled');
|
||||
is($scratch->getLanguageOverride, undef, 'A non-existing language is set');
|
||||
$scratch->setLanguageOverride('English');
|
||||
$scratch->setLanguageOverride();
|
||||
is($scratch->getLanguageOverride, 'English', 'A empty string is falsely recognised as a language');
|
||||
|
||||
END {
|
||||
$session->scratch->deleteAll;
|
||||
foreach my $wgSess ($newSession, @sessionBank) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ if ( typeof WebGUI.AssetManager == "undefined" ) {
|
|||
|
||||
// Keep track of the open more menus
|
||||
WebGUI.AssetManager.MoreMenusDisplayed = {};
|
||||
WebGUI.AssetManager.CrumbMoreMenu;
|
||||
WebGUI.AssetManager.CrumbMoreMenu = undefined;
|
||||
// Append something to a url:
|
||||
WebGUI.AssetManager.appendToUrl = function ( url, params ) {
|
||||
var components = [ url ];
|
||||
|
|
@ -25,15 +25,14 @@ WebGUI.AssetManager.appendToUrl = function ( url, params ) {
|
|||
}
|
||||
components.push(params);
|
||||
return components.join('');
|
||||
}
|
||||
};
|
||||
|
||||
/*---------------------------------------------------------------------------
|
||||
WebGUI.AssetManager.addHighlightToRow ( child )
|
||||
Highlight the row containing this element by adding to it the "highlight"
|
||||
class
|
||||
*/
|
||||
WebGUI.AssetManager.addHighlightToRow
|
||||
= function ( child ) {
|
||||
WebGUI.AssetManager.addHighlightToRow = function ( child ) {
|
||||
var row = WebGUI.AssetManager.findRow( child );
|
||||
if ( !YAHOO.util.Dom.hasClass( row, "highlight" ) ) {
|
||||
YAHOO.util.Dom.addClass( row, "highlight" );
|
||||
|
|
@ -44,16 +43,15 @@ WebGUI.AssetManager.addHighlightToRow
|
|||
WebGUI.AssetManager.buildMoreMenu ( url, linkElement )
|
||||
Build a WebGUI style "More" menu for the asset referred to by url
|
||||
*/
|
||||
WebGUI.AssetManager.buildMoreMenu
|
||||
= function ( url, linkElement, isNotLocked ) {
|
||||
WebGUI.AssetManager.buildMoreMenu = function ( url, linkElement, isNotLocked ) {
|
||||
// Build a more menu
|
||||
var rawItems = WebGUI.AssetManager.MoreMenuItems;
|
||||
var menuItems = [];
|
||||
var isLocked = !isNotLocked;
|
||||
for ( var i = 0; i < rawItems.length; i++ ) {
|
||||
var itemUrl = rawItems[i].url.match( /<url>/ )
|
||||
? rawItems[i].url.replace( /<url>(?:\?(.*))?/, WebGUI.AssetManager.appendToUrl(url, "$1") )
|
||||
: url + rawItems[i].url
|
||||
var itemUrl = rawItems[i].url
|
||||
? WebGUI.AssetManager.appendToUrl(url, rawItems[i].url)
|
||||
: url
|
||||
;
|
||||
if (! (itemUrl.match( /func=edit;/) && isLocked )) {
|
||||
menuItems.push( { "url" : itemUrl, "text" : rawItems[i].label } );
|
||||
|
|
@ -63,7 +61,7 @@ WebGUI.AssetManager.buildMoreMenu
|
|||
"zindex" : 1000,
|
||||
"clicktohide" : true,
|
||||
"position" : "dynamic",
|
||||
"context" : [ linkElement, "tl", "bl" ],
|
||||
"context" : [ linkElement, "tl", "bl", ["beforeShow", "windowResize"] ],
|
||||
"itemdata" : menuItems
|
||||
};
|
||||
|
||||
|
|
@ -74,8 +72,7 @@ WebGUI.AssetManager.buildMoreMenu
|
|||
WebGUI.AssetManager.findRow ( child )
|
||||
Find the row that contains this child element.
|
||||
*/
|
||||
WebGUI.AssetManager.findRow
|
||||
= function ( child ) {
|
||||
WebGUI.AssetManager.findRow = function ( child ) {
|
||||
var node = child;
|
||||
while ( node ) {
|
||||
if ( node.tagName == "TR" ) {
|
||||
|
|
@ -114,7 +111,7 @@ WebGUI.AssetManager.formatActions = function ( elCell, oRecord, oColumn, orderNu
|
|||
var options = WebGUI.AssetManager.buildMoreMenu(oRecord.getData( 'url' ), more, oRecord.getData( 'actions' ));
|
||||
|
||||
var menu = new YAHOO.widget.Menu( "moreMenu" + oRecord.getData( 'assetId' ), options );
|
||||
YAHOO.util.Event.onDOMReady( function () { menu.render( document.getElementById( 'assetManager' ) ) } );
|
||||
YAHOO.util.Event.onDOMReady( function () { menu.render( document.getElementById( 'assetManager' ) ); } );
|
||||
YAHOO.util.Event.addListener( more, "click", function (e) { YAHOO.util.Event.stopEvent(e); menu.show(); menu.focus(); }, null, menu );
|
||||
};
|
||||
|
||||
|
|
@ -202,8 +199,9 @@ WebGUI.AssetManager.BuildQueryString = function ( state, dt ) {
|
|||
WebGUI.AssetManager.formatRevisionDate = function ( elCell, oRecord, oColumn, orderNumber ) {
|
||||
var revisionDate = new Date( oRecord.getData( "revisionDate" ) * 1000 );
|
||||
var minutes = revisionDate.getMinutes();
|
||||
if (minutes < 10)
|
||||
if (minutes < 10) {
|
||||
minutes = "0" + minutes;
|
||||
}
|
||||
elCell.innerHTML = revisionDate.getFullYear() + '-' + ( revisionDate.getMonth() + 1 )
|
||||
+ '-' + revisionDate.getDate() + ' ' + ( revisionDate.getHours() )
|
||||
+ ':' + minutes
|
||||
|
|
@ -308,7 +306,7 @@ WebGUI.AssetManager.initDataTable = function (o) {
|
|||
WebGUI.AssetManager.DataTable.handleDataReturnPayload = function(oRequest, oResponse, oPayload) {
|
||||
oPayload.totalRecords = oResponse.meta.totalRecords;
|
||||
return oPayload;
|
||||
}
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -130,11 +130,11 @@ YAHOO.WebGUI.Form.DatePicker = {
|
|||
],
|
||||
NAVIGATOR: {
|
||||
strings : {
|
||||
'submit' : YAHOO.WebGUI.Form.DatePicker.i18n.get('WebGUI', 'submit'),
|
||||
'cancel' : YAHOO.WebGUI.Form.DatePicker.i18n.get('WebGUI', 'cancel'),
|
||||
'month' : YAHOO.WebGUI.Form.DatePicker.i18n.get('DateTime', 'Month'),
|
||||
'year' : YAHOO.WebGUI.Form.DatePicker.i18n.get('DateTime', 'Year'),
|
||||
'invalid year' : YAHOO.WebGUI.Form.DatePicker.i18n.get('Form_Date', 'Invalid year')
|
||||
'submit' : YAHOO.WebGUI.Form.DatePicker.i18n.get('WebGUI', 'submit'),
|
||||
'cancel' : YAHOO.WebGUI.Form.DatePicker.i18n.get('WebGUI', 'cancel'),
|
||||
'month' : YAHOO.WebGUI.Form.DatePicker.i18n.get('DateTime', 'Month'),
|
||||
'year' : YAHOO.WebGUI.Form.DatePicker.i18n.get('DateTime', 'Year'),
|
||||
'invalidYear' : YAHOO.WebGUI.Form.DatePicker.i18n.get('Form_Date', 'Invalid year')
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
|||
157
www/extras/yui-webgui/build/map/map.js
vendored
157
www/extras/yui-webgui/build/map/map.js
vendored
|
|
@ -7,33 +7,40 @@ if (typeof WebGUI.Map == "undefined") {
|
|||
}
|
||||
|
||||
// Keep track of all points on all maps and how to focus on them
|
||||
// A hash (map) of hashes (markers)
|
||||
WebGUI.Map.markers = {};
|
||||
|
||||
// Keep a loading dialog
|
||||
WebGUI.Map.loadingDialog = undefined;
|
||||
|
||||
/**
|
||||
* WebGUI.Map.deletePoint( map, mgr, mapUrl, marker )
|
||||
* WebGUI.Map.deletePoint( map, mgr, marker )
|
||||
* Delete a point from the map.
|
||||
* NOTE: We assume the user has already confirmed this action
|
||||
*/
|
||||
WebGUI.Map.deletePoint
|
||||
= function ( map, mgr, mapUrl, marker ) {
|
||||
= function ( map, mgr, marker ) {
|
||||
var callback = function ( text, code ) {
|
||||
WebGUI.Map.hideLoading();
|
||||
var response = YAHOO.lang.JSON.parse( text );
|
||||
// remove the marker from the map
|
||||
if ( !response.error ) {
|
||||
mgr.removeMarker( marker );
|
||||
delete WebGUI.Map.markers[ map.assetId ][ marker.assetId ];
|
||||
}
|
||||
};
|
||||
GDownloadUrl( mapUrl + '?func=ajaxDeletePoint;assetId=' + marker.assetId, callback);
|
||||
WebGUI.Map.showLoading();
|
||||
GDownloadUrl( map.url + '?func=ajaxDeletePoint;assetId=' + marker.assetId, callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* WebGUI.Map.editPoint( map, mgr, mapUrl, marker )
|
||||
* WebGUI.Map.editPoint( map, mgr, marker )
|
||||
* Edit a point on the map.
|
||||
* up the edit box. mgr is the Marker Manager to add the marker
|
||||
* to. mapUrl is the URL of the map asset
|
||||
* to.
|
||||
*/
|
||||
WebGUI.Map.editPoint
|
||||
= function ( map, mgr, mapUrl, marker ) {
|
||||
= function ( map, mgr, marker ) {
|
||||
var assetId = '';
|
||||
if ( !marker ) {
|
||||
marker = new GMarker( map.getCenter(), { draggable: true } );
|
||||
|
|
@ -44,28 +51,13 @@ WebGUI.Map.editPoint
|
|||
assetId = "new";
|
||||
marker.assetId = "new";
|
||||
GEvent.addListener( marker, "dragend", function (latlng) {
|
||||
WebGUI.Map.setPointLocation( marker, latlng, mapUrl );
|
||||
WebGUI.Map.setPointLocation( marker, latlng );
|
||||
} );
|
||||
}
|
||||
else {
|
||||
assetId = marker.assetId;
|
||||
}
|
||||
|
||||
// Create a loading dialog
|
||||
var loadingDialog = new YAHOO.widget.Panel("loading", { width:"240px",
|
||||
fixedcenter:true,
|
||||
close:false,
|
||||
draggable:false,
|
||||
zindex:4,
|
||||
modal:true,
|
||||
visible:false
|
||||
}
|
||||
);
|
||||
|
||||
loadingDialog.setHeader("Loading, please wait...");
|
||||
loadingDialog.setBody('<img src="' + map.extrasUrl + '/yui-webgui/build/map/assets/loading.gif" />');
|
||||
loadingDialog.render(document.body);
|
||||
|
||||
// Callback should open the window with the form
|
||||
var callback = function (text, code) {
|
||||
YAHOO.util.Dom.addClass( document.body, "yui-skin-sam" );
|
||||
|
|
@ -84,7 +76,7 @@ WebGUI.Map.editPoint
|
|||
var lng = marker.getLatLng().lng();
|
||||
this.form.elements['latitude'].value = lat;
|
||||
this.form.elements['longitude'].value = lng;
|
||||
|
||||
WebGUI.Map.showLoading();
|
||||
this.submit();
|
||||
}
|
||||
|
||||
|
|
@ -104,6 +96,7 @@ WebGUI.Map.editPoint
|
|||
// Update marker info
|
||||
var point = YAHOO.lang.JSON.parse( o.responseText );
|
||||
marker.assetId = point.assetId;
|
||||
marker.title = point.title;
|
||||
GEvent.clearListeners( marker, "click" );
|
||||
GEvent.clearListeners( marker, "infowindowbeforeclose" );
|
||||
|
||||
|
|
@ -125,7 +118,7 @@ WebGUI.Map.editPoint
|
|||
editButton.type = "button";
|
||||
editButton.value = "Edit";
|
||||
GEvent.addDomListener( editButton, "click", function () {
|
||||
WebGUI.Map.editPoint( map, mgr, mapUrl, marker );
|
||||
WebGUI.Map.editPoint( map, mgr, marker );
|
||||
} );
|
||||
divButton.appendChild( editButton );
|
||||
|
||||
|
|
@ -134,52 +127,69 @@ WebGUI.Map.editPoint
|
|||
deleteButton.value = "Delete"; // Replace with i18n
|
||||
GEvent.addDomListener( deleteButton, "click", function () {
|
||||
if ( confirm("Are you sure you want to delete this point?") ) {
|
||||
WebGUI.Map.deletePoint( map, mgr, mapUrl, marker );
|
||||
WebGUI.Map.deletePoint( map, mgr, marker );
|
||||
}
|
||||
} );
|
||||
divButton.appendChild( deleteButton );
|
||||
}
|
||||
marker.bindInfoWindow( infoWin );
|
||||
GEvent.addListener( marker, "dragend", function (latlng) {
|
||||
WebGUI.Map.setPointLocation( marker, latlng, mapUrl );
|
||||
WebGUI.Map.setPointLocation( marker, latlng );
|
||||
} );
|
||||
WebGUI.Map.hideLoading();
|
||||
|
||||
WebGUI.Map.markers[map.assetId][marker.assetId] = marker;
|
||||
WebGUI.Map.updateSelectPoint( map );
|
||||
}
|
||||
};
|
||||
|
||||
// Hide the loading dialog
|
||||
loadingDialog.hide();
|
||||
WebGUI.Map.hideLoading();
|
||||
};
|
||||
|
||||
// Show the loading dialog
|
||||
loadingDialog.show();
|
||||
WebGUI.Map.showLoading();
|
||||
|
||||
// Get the form
|
||||
GDownloadUrl( mapUrl + '?func=ajaxEditPoint;assetId=' + assetId, callback );
|
||||
GDownloadUrl( map.url + '?func=ajaxEditPoint;assetId=' + assetId, callback );
|
||||
};
|
||||
|
||||
/**
|
||||
* WebGUI.Map.focusOn( assetId )
|
||||
* WebGUI.Map.focusOn( pointId )
|
||||
* Pan the appropriate map to view the appropriate map point
|
||||
*/
|
||||
WebGUI.Map.focusOn
|
||||
= function ( assetId ) {
|
||||
var marker = WebGUI.Map.markers[assetId];
|
||||
= function ( pointId ) {
|
||||
var marker;
|
||||
for ( var mapId in WebGUI.Map.markers ) {
|
||||
if ( WebGUI.Map.markers[mapId][pointId] ) {
|
||||
marker = WebGUI.Map.markers[mapId][pointId];
|
||||
break;
|
||||
}
|
||||
}
|
||||
if ( !marker ) return;
|
||||
var map = marker.map;
|
||||
var infoWin = marker.infoWin;
|
||||
if ( map.getZoom() < 5 ) {
|
||||
map.setZoom(6);
|
||||
if ( map.getZoom() <= 4 ) {
|
||||
map.setZoom(5);
|
||||
}
|
||||
map.panTo( marker.getLatLng() );
|
||||
marker.openInfoWindow( marker.infoWin );
|
||||
};
|
||||
|
||||
WebGUI.Map.hideLoading
|
||||
= function () {
|
||||
WebGUI.Map.loadingDialog.hide();
|
||||
};
|
||||
|
||||
/**
|
||||
* WebGUI.Map.preparePoints ( map, mgr, mapUrl, points )
|
||||
* WebGUI.Map.preparePoints ( map, mgr, points )
|
||||
* Prepare the points from WebGUI into Google Map GMarkers
|
||||
*/
|
||||
WebGUI.Map.preparePoints
|
||||
= function ( map, mgr, mapUrl, points ) {
|
||||
= function ( map, mgr, points ) {
|
||||
WebGUI.Map.markers[map.assetId] = {};
|
||||
|
||||
// Transform points into markers
|
||||
var markers = [];
|
||||
for ( var i = 0; i < points.length; i++ ) (function(i){ // Create closure for callbacks
|
||||
|
|
@ -190,6 +200,7 @@ WebGUI.Map.preparePoints
|
|||
draggable: point.canEdit
|
||||
} );
|
||||
marker.assetId = point.assetId;
|
||||
marker.title = point.title;
|
||||
marker.map = map;
|
||||
|
||||
// Create info window
|
||||
|
|
@ -205,7 +216,7 @@ WebGUI.Map.preparePoints
|
|||
editButton.type = "button";
|
||||
editButton.value = "Edit"; // Replace with i18n
|
||||
GEvent.addDomListener( editButton, "click", function () {
|
||||
WebGUI.Map.editPoint( map, mgr, mapUrl, marker );
|
||||
WebGUI.Map.editPoint( map, mgr, marker );
|
||||
} );
|
||||
divButton.appendChild( editButton );
|
||||
|
||||
|
|
@ -214,19 +225,19 @@ WebGUI.Map.preparePoints
|
|||
deleteButton.value = "Delete"; // Replace with i18n
|
||||
GEvent.addDomListener( deleteButton, "click", function () {
|
||||
if ( confirm("Are you sure you want to delete this point?") ) {
|
||||
WebGUI.Map.deletePoint( map, mgr, mapUrl, marker );
|
||||
WebGUI.Map.deletePoint( map, mgr, marker );
|
||||
}
|
||||
} );
|
||||
divButton.appendChild( deleteButton );
|
||||
|
||||
infoWin.appendChild( divButton );
|
||||
GEvent.addListener( marker, "dragend", function (latlng) {
|
||||
WebGUI.Map.setPointLocation( marker, latlng, mapUrl );
|
||||
WebGUI.Map.setPointLocation( marker, latlng );
|
||||
} );
|
||||
}
|
||||
|
||||
// Keep info
|
||||
WebGUI.Map.markers[point.assetId] = marker;
|
||||
WebGUI.Map.markers[map.assetId][point.assetId] = marker;
|
||||
|
||||
marker.bindInfoWindow( infoWin );
|
||||
|
||||
|
|
@ -251,25 +262,85 @@ WebGUI.Map.setCenter
|
|||
;
|
||||
var callback = function ( text, code ) {
|
||||
// TODO: Notify the poor user
|
||||
WebGUI.Map.hideLoading();
|
||||
};
|
||||
WebGUI.Map.showLoading();
|
||||
GDownloadUrl(url,callback);
|
||||
};
|
||||
|
||||
/**
|
||||
* WebGUI.Map.setPointLocation( marker, latlng, mapUrl, assetId )
|
||||
* WebGUI.Map.setPointLocation( marker, latlng )
|
||||
* Update the point's location in the database.
|
||||
*/
|
||||
WebGUI.Map.setPointLocation
|
||||
= function ( marker, latlng, mapUrl, assetId ) {
|
||||
var url = mapUrl + '?func=ajaxSetPointLocation'
|
||||
= function ( marker, latlng ) {
|
||||
var url = marker.map.url + '?func=ajaxSetPointLocation'
|
||||
+ ';assetId=' + marker.assetId
|
||||
+ ';latitude=' + latlng.lat()
|
||||
+ ';longitude=' + latlng.lng()
|
||||
;
|
||||
var callback = function ( text, code ) {
|
||||
// TODO: Notify the poor user
|
||||
WebGUI.Map.hideLoading();
|
||||
};
|
||||
WebGUI.Map.showLoading();
|
||||
GDownloadUrl(url, callback);
|
||||
};
|
||||
|
||||
WebGUI.Map.showLoading
|
||||
= function () {
|
||||
// Create a loading dialog
|
||||
if ( !WebGUI.Map.loadingDialog ) {
|
||||
var loadingDialog = new YAHOO.widget.Panel("loading", { width:"240px",
|
||||
fixedcenter:true,
|
||||
close:false,
|
||||
draggable:false,
|
||||
zindex:4,
|
||||
modal:true,
|
||||
visible:false
|
||||
}
|
||||
);
|
||||
|
||||
loadingDialog.setHeader("Loading, please wait...");
|
||||
loadingDialog.setBody('<img src="' + getWebguiProperty('extrasURL') + '/yui-webgui/build/map/assets/loading.gif" />');
|
||||
loadingDialog.render(document.body);
|
||||
WebGUI.Map.loadingDialog = loadingDialog;
|
||||
}
|
||||
|
||||
WebGUI.Map.loadingDialog.show();
|
||||
};
|
||||
|
||||
|
||||
WebGUI.Map.updateSelectPoint
|
||||
= function (map) {
|
||||
var select = document.getElementById( 'selectPoint_' + map.assetId );
|
||||
if ( !select) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Clear old points
|
||||
while ( select.options.length > 1 ) {
|
||||
select.length = 1;
|
||||
}
|
||||
|
||||
var markers = WebGUI.Map.markers[map.assetId];
|
||||
var sorted = [];
|
||||
for ( var pointId in markers ) {
|
||||
sorted.push( pointId );
|
||||
}
|
||||
|
||||
sorted.sort( function (a,b) {
|
||||
var ma = WebGUI.Map.markers[map.assetId][a];
|
||||
var mb = WebGUI.Map.markers[map.assetId][b];
|
||||
|
||||
if ( ma.title > mb.title ) { return 1; }
|
||||
else if ( ma.title < mb.title ) { return -1; }
|
||||
else { return 0; }
|
||||
} );
|
||||
|
||||
// Add new points
|
||||
for ( var i = 0; i < sorted.length; i++ ) {
|
||||
select.options[ select.options.length ]
|
||||
= new Option( markers[sorted[i]].title, sorted[i] );
|
||||
}
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue