Merge commit '4635b91554' into WebGUI8. Syntax clean up to 7.10.2
This commit is contained in:
commit
87326192a3
46 changed files with 956 additions and 969 deletions
|
|
@ -1,3 +1,17 @@
|
|||
7.10.2
|
||||
- fixed #11884: Editing Templates impossible / Code editor not loaded
|
||||
- recommitted ukplayer. Removal broke Matrix. Licencing information was available but overlooked.
|
||||
- fixed #11883: Wiki "Add page" link does not encode special chars
|
||||
- fixed #11886: profile knows it's me, but doesn't display edit
|
||||
- fixed #11789: Date form reports 1 day earlier on Edit for the time zone corresponding to Europe/Berlin.
|
||||
- fixed #11894: Europe London timezone decrements birth date
|
||||
- fixed #11857: make page printable?
|
||||
- fixed #11891: Shop credit not displayed in payment method screen
|
||||
- fixed #11871: Metadata display and criteria builder problems
|
||||
- fixed #10189: pbworkflow000000000007 Hanging
|
||||
- fixed #11897: Continue to the site link loses current page
|
||||
- fixed #11618: Code Editor: Content loses it's whitespace formatting
|
||||
|
||||
7.10.1
|
||||
- fixed #11851: Story Topic: top story variables should be available all the time
|
||||
- fixed #11854: CS doesn't return Not Found page
|
||||
|
|
|
|||
|
|
@ -21,6 +21,19 @@ save you many hours of grief.
|
|||
Account Macro template
|
||||
Admin Toggle Macro template
|
||||
|
||||
7.10.2
|
||||
--------------------------------------------------------------------
|
||||
* The URL used by Display Message on Login always returns the user to
|
||||
the page where they logged in. If your site depended on the old,
|
||||
buggy behavior of returning the user to the home page after showing
|
||||
a message, then in the Settings you can assign Redirect After Login Url
|
||||
to /.
|
||||
|
||||
* The UKPLayer - a slideshow that displays images as a movie -
|
||||
is in WebGUI again. Licencing information was overlooked. An
|
||||
upgrade to 7.10.1 will break the Matrix. This is fixed now.
|
||||
|
||||
|
||||
7.10.1
|
||||
--------------------------------------------------------------------
|
||||
* WebGUI now depends on PerlIO::eol, for doing line ending translation.
|
||||
|
|
|
|||
|
|
@ -11,8 +11,19 @@ templates, you will need to apply these changes manually to your copies.
|
|||
toggle.url => toggle_url
|
||||
toggle.text => toggle_text
|
||||
|
||||
7.10.2
|
||||
|
||||
* The Make Page Printable template has changed (as per bug #11857). The HTML
|
||||
is now consistent with other default Style templates. The Plain Black logo and
|
||||
copyright info have been removed and a stylesheet was added to provide very
|
||||
simple default formatting for text, header and footer (makepageprintable.css).
|
||||
|
||||
7.10.1
|
||||
|
||||
* Profile templates - root/import/account/profile/default-view-profile-template
|
||||
- root/import/account/profile/profile-account-layout
|
||||
Moved the "back to profile" link from the Profile View template to the Profile Layout template.
|
||||
|
||||
* Asset Report Template - asset-report/asset-report-default-template
|
||||
Remove the empty template attachment
|
||||
|
||||
|
|
|
|||
BIN
docs/upgrades/packages-7.10.1/root_import_account_profile.wgpkg
Normal file
BIN
docs/upgrades/packages-7.10.1/root_import_account_profile.wgpkg
Normal file
Binary file not shown.
BIN
docs/upgrades/packages-7.10.2/root_import_style.wgpkg
Normal file
BIN
docs/upgrades/packages-7.10.2/root_import_style.wgpkg
Normal file
Binary file not shown.
123
docs/upgrades/upgrade_7.10.1-7.10.2.pl
Normal file
123
docs/upgrades/upgrade_7.10.1-7.10.2.pl
Normal file
|
|
@ -0,0 +1,123 @@
|
|||
#!/usr/bin/env perl
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
# 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
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
our ($webguiRoot);
|
||||
|
||||
BEGIN {
|
||||
$webguiRoot = "../..";
|
||||
unshift (@INC, $webguiRoot."/lib");
|
||||
}
|
||||
|
||||
use strict;
|
||||
use Getopt::Long;
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Storage;
|
||||
use WebGUI::Asset;
|
||||
|
||||
|
||||
my $toVersion = '7.10.2';
|
||||
my $quiet; # this line required
|
||||
|
||||
|
||||
my $session = start(); # this line required
|
||||
|
||||
# upgrade functions go here
|
||||
|
||||
finish($session); # this line required
|
||||
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Describe what our function does
|
||||
#sub exampleFunction {
|
||||
# my $session = shift;
|
||||
# print "\tWe're doing some stuff here that you should know about... " unless $quiet;
|
||||
# # and here's our code
|
||||
# print "DONE!\n" unless $quiet;
|
||||
#}
|
||||
|
||||
|
||||
# -------------- DO NOT EDIT BELOW THIS LINE --------------------------------
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Add a package to the import node
|
||||
sub addPackage {
|
||||
my $session = shift;
|
||||
my $file = shift;
|
||||
|
||||
print "\tUpgrading package $file\n" unless $quiet;
|
||||
# Make a storage location for the package
|
||||
my $storage = WebGUI::Storage->createTemp( $session );
|
||||
$storage->addFileFromFilesystem( $file );
|
||||
|
||||
# Import the package into the import node
|
||||
my $package = eval {
|
||||
my $node = WebGUI::Asset->getImportNode($session);
|
||||
$node->importPackage( $storage, {
|
||||
overwriteLatest => 1,
|
||||
clearPackageFlag => 1,
|
||||
setDefaultTemplate => 1,
|
||||
} );
|
||||
};
|
||||
|
||||
if ($package eq 'corrupt') {
|
||||
die "Corrupt package found in $file. Stopping upgrade.\n";
|
||||
}
|
||||
if ($@ || !defined $package) {
|
||||
die "Error during package import on $file: $@\nStopping upgrade\n.";
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
sub start {
|
||||
my $configFile;
|
||||
$|=1; #disable output buffering
|
||||
GetOptions(
|
||||
'configFile=s'=>\$configFile,
|
||||
'quiet'=>\$quiet
|
||||
);
|
||||
my $session = WebGUI::Session->open($webguiRoot,$configFile);
|
||||
$session->user({userId=>3});
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->set({name=>"Upgrade to ".$toVersion});
|
||||
return $session;
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
sub finish {
|
||||
my $session = shift;
|
||||
updateTemplates($session);
|
||||
my $versionTag = WebGUI::VersionTag->getWorking($session);
|
||||
$versionTag->commit;
|
||||
$session->db->write("insert into webguiVersion values (".$session->db->quote($toVersion).",'upgrade',".time().")");
|
||||
$session->close();
|
||||
}
|
||||
|
||||
#-------------------------------------------------
|
||||
sub updateTemplates {
|
||||
my $session = shift;
|
||||
return undef unless (-d "packages-".$toVersion);
|
||||
print "\tUpdating packages.\n" unless ($quiet);
|
||||
opendir(DIR,"packages-".$toVersion);
|
||||
my @files = readdir(DIR);
|
||||
closedir(DIR);
|
||||
my $newFolder = undef;
|
||||
foreach my $file (@files) {
|
||||
next unless ($file =~ /\.wgpkg$/);
|
||||
# Fix the filename to include a path
|
||||
$file = "packages-" . $toVersion . "/" . $file;
|
||||
addPackage( $session, $file );
|
||||
}
|
||||
}
|
||||
|
||||
#vim:ft=perl
|
||||
|
|
@ -82,7 +82,8 @@ sub appendCategoryVars {
|
|||
$var->{'profile_category_'.$categoryId."_shortLabel"} = $shortCategoryLabel;
|
||||
$var->{'profile_category_'.$categoryId."_index" } = $index;
|
||||
$var->{'profile_category_'.$categoryId."_fields" } = $fields;
|
||||
|
||||
|
||||
$var->{'can_edit_profile' } = $self->uid eq $self->session->user->userId;
|
||||
|
||||
#Update the isActive flag to determine the default active tab
|
||||
$self->store->{hasActiveTab} = ($self->store->{hasActiveTab} || $isActive);
|
||||
|
|
@ -471,8 +472,6 @@ sub www_view {
|
|||
|
||||
$self->appendCommonVars($var);
|
||||
|
||||
$var->{'can_edit_profile' } = $uid eq $session->user->userId;
|
||||
|
||||
my $privacySetting = $user->profileField('publicProfile') || 'none';
|
||||
$var->{"profile_privacy_$privacySetting"} = "true";
|
||||
|
||||
|
|
|
|||
|
|
@ -2642,7 +2642,7 @@ sub www_changeUrl {
|
|||
my $i18n = WebGUI::International->new($self->session, "Asset");
|
||||
my $f = WebGUI::HTMLForm->new($self->session, action=>$self->getUrl);
|
||||
$f->hidden(name=>"func", value=>"changeUrlConfirm");
|
||||
$f->hidden(name=>"proceed", value=>$self->session->form->param("proceed"));
|
||||
$f->hidden(name=>"proceed", value=>scalar($self->session->form->param("proceed")));
|
||||
$f->text(name=>"url", value=>$self->get('url'), label=>$i18n->get("104"), hoverHelp=>$i18n->get('104 description'));
|
||||
$f->yesNo(name=>"confirm", value=>0, label=>$i18n->get("confirm change"), hoverHelp=>$i18n->get("confirm change url message"), subtext=>'<br />'.$i18n->get("confirm change url message"));
|
||||
$f->submit;
|
||||
|
|
|
|||
|
|
@ -1440,7 +1440,7 @@ override processEditForm => sub {
|
|||
my $assetId = $self->getId;
|
||||
my $revisionDate = $self->revisionDate;
|
||||
|
||||
$session->db->write("UPDATE Event SET sequenceNumber =? WHERE assetId = ? AND revisionDate =?",[($form->param('sequenceNumber') || $top_val), $assetId, $revisionDate]);
|
||||
$session->db->write("UPDATE Event SET sequenceNumber =? WHERE assetId = ? AND revisionDate =?",[(scalar($form->param('sequenceNumber')) || $top_val), $assetId, $revisionDate]);
|
||||
|
||||
|
||||
# Pre-process Related Links and manage changes
|
||||
|
|
|
|||
|
|
@ -90,6 +90,9 @@ sub _drawQueryBuilder {
|
|||
"!=" => $i18n->get("isnt")
|
||||
};
|
||||
}
|
||||
$operator{checkList} = {
|
||||
"+~" => $i18n->get("contains"),
|
||||
};
|
||||
$operator{integer} = {
|
||||
"=" => $i18n->get("equal to"),
|
||||
"!=" => $i18n->get("not equal to"),
|
||||
|
|
@ -145,6 +148,8 @@ sub _drawQueryBuilder {
|
|||
# The value select field
|
||||
my $valFieldName = "val_field".$i;
|
||||
my $options = $fields->{$field}{possibleValues};
|
||||
##Only allow one at a time to be selected, and work with current JS for choosing which one.
|
||||
$fieldType = 'radioList' if $fieldType eq 'checkList';
|
||||
my $valueField = WebGUI::Form::dynamicField($session,
|
||||
fieldType=>$fieldType,
|
||||
name=>$valFieldName,
|
||||
|
|
@ -374,7 +379,6 @@ sub getFieldsList {
|
|||
foreach my $field (@{WebGUI::ProfileField->getFields($session)}) {
|
||||
my $fieldId = $field->getId;
|
||||
next if $fieldId =~ /contentPositions/;
|
||||
$session->log->warn($fieldId);
|
||||
$fieldNames{$fieldId} = $field->getLabel.' ['.$fieldId.']';
|
||||
}
|
||||
$output .= '<table cellspacing="0" cellpadding="3" border="1"><tr><td><table cellspacing="0" cellpadding="3" border="0">';
|
||||
|
|
@ -388,8 +392,6 @@ sub getFieldsList {
|
|||
-vertical=>1,
|
||||
-uiLevel=>9
|
||||
);
|
||||
$session->log->warn($list->get('uiLevel'));
|
||||
$session->log->warn($list->passUiLevelCheck);
|
||||
$output .= $list->toHtmlWithWrapper;
|
||||
$output .= '</table></td><td><table cellspacing="0" cellpadding="3" border="0">';
|
||||
my @prefFieldsToImport = $self->getPrefFieldsToImport;
|
||||
|
|
@ -601,8 +603,8 @@ sub getShortcutByCriteria {
|
|||
# | | |
|
||||
# |- $field |_ $operator |- $value
|
||||
# |_ $attribute |_ $attribute
|
||||
my $operator = qr/<>|!=|=|>=|<=|>|<|like/i;
|
||||
my $attribute = qr/['"][^()|=><!]+['"]|[^()|=><!\s]+/i;
|
||||
my $operator = qr/<>|!=|=|>=|<=|>|<|like|\+~/i;
|
||||
my $attribute = qr/['"][^()|=><!]+['"]|[^()|=><!\s]+/i;
|
||||
|
||||
my $constraint = $criteria;
|
||||
|
||||
|
|
@ -610,6 +612,7 @@ sub getShortcutByCriteria {
|
|||
my $db = $self->session->db;
|
||||
my $counter = "b";
|
||||
my @joins = ();
|
||||
##Transform the expression into valid SQL
|
||||
foreach my $expression ($criteria =~ /($attribute\s*$operator\s*$attribute)/gi) {
|
||||
# $expression will match "State = Wisconsin"
|
||||
|
||||
|
|
@ -617,9 +620,10 @@ sub getShortcutByCriteria {
|
|||
# We need it later.
|
||||
push(@joins," left join metaData_values ".$counter."_v on a.assetId=".$counter."_v.assetId ");
|
||||
# Get the field (State) and the value (Wisconsin) from the $expression.
|
||||
$expression =~ /($attribute)\s*$operator\s*($attribute)/gi;
|
||||
$expression =~ /($attribute)\s*($operator)\s*($attribute)/gi;
|
||||
my $field = $1;
|
||||
my $value = $2;
|
||||
my $current_operator = $2;
|
||||
my $value = $3;
|
||||
|
||||
# quote the field / value variables.
|
||||
my $quotedField = $field;
|
||||
|
|
@ -627,18 +631,21 @@ sub getShortcutByCriteria {
|
|||
unless ($field =~ /^\s*['"].*['"]\s*/) {
|
||||
$quotedField = $db->quote($field);
|
||||
}
|
||||
unless ($value =~ /^\s*['"].*['"]\s*/) {
|
||||
$quotedValue = $db->quote($value);
|
||||
}
|
||||
unless ($value =~ /^\s*['"].*['"]\s*/) {
|
||||
$quotedValue = $db->quote($value);
|
||||
}
|
||||
|
||||
# transform replacement from "State = Wisconsin" to
|
||||
# "(fieldname=State and value = Wisconsin)"
|
||||
my $clause = "(".$counter."_p.fieldName=".$quotedField." and ".$counter."_v.value ";
|
||||
$replacement =~ s/\Q$field/$clause/;
|
||||
$replacement =~ s/\Q$value/$quotedValue )/i;
|
||||
$replacement =~ s/\Q$field/$clause/;
|
||||
$replacement =~ s/\Q$value/$quotedValue )/i;
|
||||
|
||||
# replace $expression with the new $replacement in $constraint.
|
||||
$constraint =~ s/\Q$expression/$replacement/;
|
||||
$constraint =~ s/\Q$expression/$replacement/;
|
||||
if ($current_operator eq '+~') {
|
||||
$constraint =~ s/and ${counter}_v\.value\s*\+~\s*$quotedValue/and FIND_IN_SET($quotedValue, REPLACE(${counter}_v.value,"\\n",","))/;
|
||||
}
|
||||
push (@joins, " left join metaData_properties ".$counter."_p on ".$counter."_p.fieldId=".$counter."_v.fieldId ");
|
||||
$counter++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2023,7 +2023,7 @@ sub www_importEvents {
|
|||
-label => $i18n->get('ignore first line'),
|
||||
-name => 'ignore_first_line',
|
||||
-hoverHelp => $i18n->get('import hoverhelp first line'),
|
||||
-defaultValue => $form->param('ignore_first_line'),
|
||||
-defaultValue => scalar $form->param('ignore_first_line'),
|
||||
);
|
||||
|
||||
# create the std & meta fields part of the form
|
||||
|
|
@ -2040,7 +2040,7 @@ sub www_importEvents {
|
|||
name => 'fieldsToImport',
|
||||
defaultValue => \@defaultImportableFields,
|
||||
options => \%importableFields,
|
||||
value => $form->get('fieldsToImport'),
|
||||
value => scalar $form->get('fieldsToImport'),
|
||||
);
|
||||
|
||||
$f->submit(-value=>$i18n->get('import events'));
|
||||
|
|
|
|||
|
|
@ -2610,7 +2610,7 @@ sub www_editThingDataSaveViaAjax {
|
|||
return '{}';
|
||||
}
|
||||
else {
|
||||
warn "thingId not found in thingProperties\n";
|
||||
$session->log->warn("thingId ".$thingProperties->{thingId}." not found in thingProperties");
|
||||
$session->http->setStatus(404);
|
||||
return JSON->new->encode({message => "The thingId you requested can not be found."});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -196,6 +196,7 @@ use WebGUI::International;
|
|||
use HTML::Parser;
|
||||
use URI::Escape;
|
||||
use WebGUI::Form;
|
||||
use WebGUI::Search;
|
||||
use Clone qw/clone/;
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
@ -993,7 +994,7 @@ sub www_search {
|
|||
mostPopularUrl=>$self->getUrl("func=mostPopular"),
|
||||
mostPopularLabel=>$i18n->get("mostPopularLabel"),
|
||||
wikiHomeUrl=>$self->getUrl,
|
||||
addPageUrl=>$self->getUrl("func=add;class=WebGUI::Asset::WikiPage;title=".$queryString),
|
||||
addPageUrl=>$self->getUrl("func=add;class=WebGUI::Asset::WikiPage;title=".$self->session->url->escape($queryString)),
|
||||
};
|
||||
$self->appendSearchBoxVars($var, $queryString);
|
||||
if (length $queryString) {
|
||||
|
|
|
|||
|
|
@ -1056,10 +1056,13 @@ sub showMessageOnLogin {
|
|||
WebGUI::Macro::process( $self->session, \$output );
|
||||
|
||||
# Add the link to continue
|
||||
my $session = $self->session;
|
||||
$session->log->warn("returnUrl: >".$self->session->form->get( 'returnUrl' )."<");
|
||||
$session->log->warn("redirectAfterLoginUrl: >".$self->session->form->get( 'returnUrl' )."<");
|
||||
my $redirectUrl = $self->session->form->get( 'returnUrl' )
|
||||
|| $self->session->setting->get("redirectAfterLoginUrl")
|
||||
|| $self->session->scratch->get( 'redirectAfterLogin' )
|
||||
|| $self->session->url->getSiteURL . $self->session->url->gateway()
|
||||
|| $self->session->url->getBackToSiteURL
|
||||
;
|
||||
|
||||
$output .= '<p><a href="' . $redirectUrl . '">' . $i18n->get( 'showMessageOnLogin return' )
|
||||
|
|
|
|||
|
|
@ -16,7 +16,6 @@ package WebGUI::Form::Codearea;
|
|||
|
||||
use strict;
|
||||
use base 'WebGUI::Form::Textarea';
|
||||
use HTML::Entities qw(encode_entities decode_entities);
|
||||
use WebGUI::International;
|
||||
|
||||
=head1 NAME
|
||||
|
|
@ -90,18 +89,6 @@ sub definition {
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getDatabaseFieldType ( )
|
||||
|
||||
Returns "MEDIUMTEXT".
|
||||
|
||||
=cut
|
||||
|
||||
sub getDatabaseFieldType {
|
||||
return "MEDIUMTEXT";
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getName ( session )
|
||||
|
||||
Returns the human readable name of this control.
|
||||
|
|
@ -113,101 +100,4 @@ sub getName {
|
|||
return WebGUI::International->new($session, 'WebGUI')->get('codearea');
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 getValue ( [value] )
|
||||
|
||||
Return the value, HTML decoded
|
||||
|
||||
=cut
|
||||
|
||||
sub getValue {
|
||||
my ( $self, @args ) = @_;
|
||||
my $value = $self->SUPER::getValue( @args );
|
||||
return decode_entities( $value );
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 headTags ( )
|
||||
|
||||
Set the head tags for this form plugin
|
||||
|
||||
=cut
|
||||
|
||||
sub headTags {
|
||||
my $self = shift;
|
||||
my ($style, $url) = $self->session->quick(qw(style url));
|
||||
$style->setCss($url->extras("yui/build/resize/assets/skins/sam/resize.css"));
|
||||
$style->setCss($url->extras("yui/build/assets/skins/sam/skin.css"));
|
||||
$style->setScript($url->extras("yui/build/utilities/utilities.js"));
|
||||
$style->setScript($url->extras("yui/build/container/container_core-min.js"));
|
||||
$style->setScript($url->extras("yui/build/menu/menu-min.js"));
|
||||
$style->setScript($url->extras("yui/build/button/button-min.js"));
|
||||
$style->setScript($url->extras("yui/build/resize/resize-min.js"));
|
||||
$style->setScript($url->extras("yui/build/editor/editor-min.js"));
|
||||
$style->setScript($url->extras("yui-webgui/build/code-editor/code-editor.js"));
|
||||
#$style->setCss($url->extras("yui/build/logger/assets/logger.css"));
|
||||
#$style->setCss($url->extras("yui/build/logger/assets/skins/sam/logger.css"));
|
||||
#$style->setScript($url->extras("yui/build/logger/logger.js"));
|
||||
$self->SUPER::headTags();
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 isDynamicCompatible ( )
|
||||
|
||||
A class method that returns a boolean indicating whether this control is compatible with the DynamicField control.
|
||||
|
||||
=cut
|
||||
|
||||
sub isDynamicCompatible {
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders a code area field.
|
||||
|
||||
=cut
|
||||
|
||||
sub toHtml {
|
||||
my $self = shift;
|
||||
|
||||
my $value = encode_entities( $self->fixMacros($self->fixTags($self->fixSpecialCharacters(scalar $self->getOriginalValue))) );
|
||||
my $width = $self->get('width');
|
||||
if ( $width !~ /%|px/ ) {
|
||||
$width .= 'px';
|
||||
}
|
||||
my $height = $self->get('height');
|
||||
if ( $height !~ /%|px/ ) {
|
||||
$height .= 'px';
|
||||
}
|
||||
|
||||
my $id = $self->get('id');
|
||||
my $name = $self->get('name');
|
||||
my $extras = $self->get('extras');
|
||||
my $syntax = $self->get('syntax');
|
||||
my $styleAttr = $self->get('style');
|
||||
|
||||
my $codeCss = $self->session->url->extras("yui-webgui/build/code-editor/code.css");
|
||||
my $out = <<"END_HTML";
|
||||
<textarea id="$id" name="$name" $extras rows="10" cols="60" style="font-family: monospace; $styleAttr; height: 100%; width: 100%; resize: none;">$value</textarea>
|
||||
<script type="text/javascript">
|
||||
(function(){
|
||||
YAHOO.util.Event.onDOMReady( function () {
|
||||
var myeditor = new YAHOO.widget.CodeEditor('${id}', { toggleButton: true, handleSubmit: true, css_url: '${codeCss}', height: '${height}', width: '${width}', status: true, resize: true });
|
||||
myeditor.render();
|
||||
|
||||
//var myLogReader = new YAHOO.widget.LogReader();
|
||||
} );
|
||||
}());
|
||||
</script>
|
||||
END_HTML
|
||||
return $out;
|
||||
}
|
||||
|
||||
1;
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use strict;
|
|||
use base 'WebGUI::Form::Text';
|
||||
use WebGUI::Form::Hidden;
|
||||
use WebGUI::International;
|
||||
use Scalar::Util qw/blessed/;
|
||||
|
||||
my $isaEpoch = qr/^-?\d+$/;
|
||||
|
||||
|
|
@ -241,8 +242,11 @@ sub toHtml {
|
|||
$value = $self->set("value",'');
|
||||
}
|
||||
else {
|
||||
$value = eval { WebGUI::DateTime->new($session, $self->getOriginalValue)->toMysqlDate; };
|
||||
$value = WebGUI::DateTime->new($session,0)->toMysqlDate if $value eq '';
|
||||
my $originalValue = $self->getOriginalValue;
|
||||
my $dt = eval { WebGUI::DateTime->new($session, $originalValue); };
|
||||
$dt = WebGUI::DateTime->new($session,0) if ! (blessed $dt && $dt->isa('DateTime')); ##Parsing error
|
||||
$dt->set_time_zone($session->datetime->getTimeZone);
|
||||
$value = $dt->toMysqlDate;
|
||||
}
|
||||
|
||||
my $field = WebGUI::Form::Text->new($self->session,
|
||||
|
|
|
|||
|
|
@ -197,7 +197,6 @@ sub toHtml {
|
|||
$self->set("extras", $self->get('extras') . q{ onblur="fixChars(this.form['}.$self->get("name").q{'])" mce_editable="true" });
|
||||
$self->set("resizable", 0);
|
||||
return $self->SUPER::toHtml.$self->{_richEdit}->getRichEditor($self->get('id'));
|
||||
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
|
|
|||
|
|
@ -276,7 +276,7 @@ sub headTags {
|
|||
|
||||
=head2 toHtml ( )
|
||||
|
||||
Renders an input tag of type text.
|
||||
Set the head tags for this form plugin
|
||||
|
||||
=cut
|
||||
|
||||
|
|
|
|||
|
|
@ -163,16 +163,9 @@ Renders an input tag of type text.
|
|||
sub toHtml {
|
||||
my $self = shift;
|
||||
my $value = $self->fixMacros($self->fixTags($self->fixSpecialCharacters(scalar $self->getOriginalValue)));
|
||||
my $width = $self->get('width') || '100%';
|
||||
if ( $width !~ /%|px/ ) {
|
||||
$width .= 'px';
|
||||
}
|
||||
my $height = $self->get('height') || '100%';
|
||||
if ( $height !~ /%|px/ ) {
|
||||
$height .= 'px';
|
||||
}
|
||||
my ($style, $url, $stow) = $self->session->quick(qw(style url stow));
|
||||
my $sizeStyle = ' width: ' . $width . '; height: ' . $height . ';';
|
||||
my $width = $self->get('width') || 400;
|
||||
my $height = $self->get('height') || 150;
|
||||
my $sizeStyle = ' width: ' . $width . 'px; height: ' . $height . 'px;';
|
||||
my $out
|
||||
= '<textarea id="' . $self->get('id') . '"'
|
||||
. ' name="' . $self->get("name") . '"'
|
||||
|
|
|
|||
|
|
@ -1980,7 +1980,7 @@ sub vitalGroup {
|
|||
if (! $groupId && ref $class ) {
|
||||
$groupId = $class->getId;
|
||||
}
|
||||
return $groupId ~~ [ map { "$_" } (1..17), 15, 16, 17, qw/pbgroup000000000000015 pbgroup000000000000016 pbgroup000000000000017 /];
|
||||
return $groupId ~~ [ map { "$_" } (1..13), 15, 16, 17, qw/pbgroup000000000000015 pbgroup000000000000016 pbgroup000000000000017 /];
|
||||
}
|
||||
|
||||
1;
|
||||
|
|
|
|||
|
|
@ -308,6 +308,9 @@ sub www_runCronJob {
|
|||
# Run the instance
|
||||
my $error = $instance->start( 1 );
|
||||
if ($error) {
|
||||
##Unable to communicate with spectre. Delete this instance to it does not get stuck.
|
||||
$session->log->error("Unable to communicate with spectre: $error about taskId: $taskId. Deleting instanceId: ". $instance->getId);
|
||||
$instance->delete();
|
||||
return "error";
|
||||
}
|
||||
$task->delete( 1 ) if ( $task->get("runOnce") );
|
||||
|
|
|
|||
|
|
@ -53,7 +53,8 @@ around BUILDARGS => sub {
|
|||
|
||||
=head2 adjust ( amount, [ comment ] )
|
||||
|
||||
Adjusts the amount of credit this user has by a specified amount.
|
||||
Adjusts the amount of credit this user has by a specified amount. Returns 0 if the current user is Visitor.
|
||||
Otherwise, returns the amount set.
|
||||
|
||||
=head3 amount
|
||||
|
||||
|
|
@ -157,6 +158,20 @@ A unique id for a user that you want to adjust the credit of. Defaults to the cu
|
|||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 purge ( )
|
||||
|
||||
Removes all shop credit for the current user.
|
||||
|
||||
=cut
|
||||
|
||||
sub purge {
|
||||
my ($self) = @_;
|
||||
$self->session->db->write("delete from shopCredit where userId = ?",[$self->userId]);
|
||||
return 1;
|
||||
}
|
||||
|
||||
#-------------------------------------------------------------------
|
||||
|
||||
=head2 session ()
|
||||
|
||||
Returns a reference to the current session.
|
||||
|
|
|
|||
|
|
@ -146,7 +146,7 @@ sub appendCartVariables {
|
|||
my $session = $self->session;
|
||||
my $credit = WebGUI::Shop::Credit->new($session, $cart->getPosUser->userId);
|
||||
$var->{inShopCreditAvailable} = $credit->getSum;
|
||||
$var->{inShopCreditDeduction} = $credit->calculateDeduction($var->{totalPrice});
|
||||
$var->{inShopCreditDeduction} = $credit->calculateDeduction($totalPrice);
|
||||
$var->{totalPrice } = $cart->formatCurrency($totalPrice + $var->{inShopCreditDeduction});
|
||||
return $self;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ use strict;
|
|||
use WebGUI::Group;
|
||||
use WebGUI::Workflow::Instance;
|
||||
use JSON ();
|
||||
use WebGUI::Exception;
|
||||
use WebGUI::ProfileField;
|
||||
use Scalar::Util qw( weaken );
|
||||
use Net::CIDR::Lite;
|
||||
|
|
@ -418,6 +419,10 @@ sub delete {
|
|||
$book->delete;
|
||||
}
|
||||
|
||||
require WebGUI::Shop::Credit;
|
||||
my $credit = WebGUI::Shop::Credit->new($session, $userId);
|
||||
$credit->purge;
|
||||
|
||||
# remove user itself
|
||||
$db->write("DELETE FROM userProfileData WHERE userId=?",[$userId]);
|
||||
$db->write("DELETE FROM users WHERE userId=?",[$userId]);
|
||||
|
|
|
|||
|
|
@ -102,8 +102,9 @@ See WebGUI::Workflow::Activity::execute() for details.
|
|||
=cut
|
||||
|
||||
sub execute {
|
||||
my $self = shift;
|
||||
my $self = shift;
|
||||
my $start = time();
|
||||
my $stop = $start + $self->getTTL;
|
||||
|
||||
# kill temporary assets
|
||||
my $tempspace = WebGUI::Asset->getTempspace($self->session);
|
||||
|
|
@ -125,11 +126,11 @@ sub execute {
|
|||
}
|
||||
}
|
||||
# taking too long, give up
|
||||
return $self->WAITING(1) if (time() - $start > $self->getTTL);
|
||||
return $self->WAITING(1) if (time() > $stop);
|
||||
}
|
||||
|
||||
# kill temporary files
|
||||
return $self->recurseFileSystem($start, $self->session->config->get("uploadsPath")."/temp");
|
||||
return $self->recurseFileSystem($stop, $self->session->config->get("uploadsPath")."/temp");
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -147,7 +148,7 @@ The starting path.
|
|||
|
||||
sub recurseFileSystem {
|
||||
my $self = shift;
|
||||
my $start = shift;
|
||||
my $stop = shift;
|
||||
my $path = shift;
|
||||
if (opendir(DIR,$path)) {
|
||||
my @filelist = readdir(DIR);
|
||||
|
|
@ -155,10 +156,10 @@ sub recurseFileSystem {
|
|||
foreach my $file (@filelist) {
|
||||
unless ($file eq "." || $file eq "..") {
|
||||
# taking too long, time to abort
|
||||
return $self->WAITING(1) if (time() - $start > 50);
|
||||
return $self->WAITING(1) if (time() > $stop);
|
||||
|
||||
# must search for children
|
||||
$self->recurseFileSystem($start, $path."/".$file);
|
||||
$self->recurseFileSystem($stop, $path."/".$file);
|
||||
|
||||
# if it's old enough, let's kill it
|
||||
if ($self->checkFileAge($path."/".$file)) {
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ sub execute {
|
|||
$msg->addHtml( $self->get('notificationMessage') );
|
||||
$msg->queue;
|
||||
|
||||
if ( time - $time > 60 ) {
|
||||
if ( time - $time > $self->getTTL ) {
|
||||
return $self->WAITING(1);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,7 @@ See WebGUI::Workflow::Activity::execute() for details.
|
|||
|
||||
sub execute {
|
||||
my ( $self, $obj, $instance ) = @_;
|
||||
my $timeLimit = time + 55;
|
||||
my $timeLimit = time + $self->getTTL;
|
||||
|
||||
my $piped = $instance->getScratch('recurrences')
|
||||
|| $self->generateRecurrenceList();
|
||||
|
|
|
|||
|
|
@ -49,6 +49,12 @@ our $I18N = {
|
|||
lastUpdated => 1053183804
|
||||
},
|
||||
|
||||
'contains' => {
|
||||
message => q|contains|,
|
||||
lastUpdated => 1053183804,
|
||||
context => q|to be a member of a set, inclusive|,
|
||||
},
|
||||
|
||||
'1' => {
|
||||
message => q|Asset to Mirror|,
|
||||
lastUpdated => 1031514049
|
||||
|
|
|
|||
|
|
@ -127,24 +127,6 @@ isnt($event6a->get('storageId'), $event6->get('storageId'), '... and it is diffe
|
|||
|
||||
my $versionTag2 = WebGUI::VersionTag->getWorking($session);
|
||||
WebGUI::Test->addToCleanup($versionTag2);
|
||||
$versionTag2->commit;
|
||||
|
||||
my $event7 = $cal->addChild(
|
||||
{
|
||||
className => 'WebGUI::Asset::Event',
|
||||
assetId => 'EventAssetTestStorage6',
|
||||
url => 'hidden_event',
|
||||
}, undef, undef, { skipNotifications => 1, skipAutoCommitWorkflows => 1 },
|
||||
);
|
||||
|
||||
my $tag = WebGUI::VersionTag->getWorking($session);
|
||||
$tag->commit;
|
||||
addToCleanup($tag);
|
||||
|
||||
is $event7->isHidden, 1, 'isHidden set to 1 by default';
|
||||
|
||||
$event7->isHidden(0);
|
||||
is $event7->isHidden, 1, 'isHidden cannot be set to 0';
|
||||
|
||||
my $event7 = $cal->addChild({
|
||||
className => 'WebGUI::Asset::Event',
|
||||
|
|
|
|||
|
|
@ -10,11 +10,12 @@
|
|||
|
||||
use strict;
|
||||
|
||||
use WebGUI::Test;
|
||||
|
||||
use WebGUI::Storage;
|
||||
use WebGUI::Asset;
|
||||
use WebGUI::Asset::File::ZipArchive;
|
||||
|
||||
use WebGUI::Test;
|
||||
use Test::More; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
plan tests => 3;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@ use WebGUI::Session;
|
|||
use WebGUI::Asset::Template;
|
||||
use Exception::Class;
|
||||
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use Data::Dumper;
|
||||
use Test::Exception;
|
||||
|
|
|
|||
67
t/Asset/Wobject/WikiMaster/search.t
Normal file
67
t/Asset/Wobject/WikiMaster/search.t
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# 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
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Test the featured page of the Wiki
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../../../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
my $import = WebGUI::Asset->getImportNode( $session );
|
||||
|
||||
my $templateId = 'WIKIMASTER_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]; } );
|
||||
|
||||
my $wiki
|
||||
= $import->addChild( {
|
||||
className => 'WebGUI::Asset::Wobject::WikiMaster',
|
||||
searchTemplateId => $templateId,
|
||||
} );
|
||||
|
||||
WebGUI::Test->addToCleanup($wiki);
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 1; # Increment this number for each test you create
|
||||
|
||||
$session->request->setup_body({
|
||||
query => 'Red&Andy',
|
||||
});
|
||||
|
||||
{
|
||||
WebGUI::Test->mockAssetId($templateId, $templateMock);
|
||||
$wiki->www_search();
|
||||
WebGUI::Test->unmockAssetId($templateId);
|
||||
}
|
||||
|
||||
is $templateVars->{addPageUrl},
|
||||
$wiki->getUrl('func=add;class=WebGUI::Asset::WikiPage;title=Red%26Andy'),
|
||||
'search encodes unsafe characters in addPageUrl';
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
#
|
||||
|
||||
#vim:ft=perl
|
||||
42
t/Auth.t
42
t/Auth.t
|
|
@ -43,7 +43,26 @@ my $createAccountSession = WebGUI::Test->newSession(0, {
|
|||
$auth = WebGUI::Auth->new( $createAccountSession, $AUTH_METHOD );
|
||||
my $username = $createAccountSession->id->generate;
|
||||
push @cleanupUsernames, $username;
|
||||
$output = $auth->createAccountSave( $username, { }, "PASSWORD" );
|
||||
$output = $auth->createAccountSave( $username, { }, "PASSWORD" );
|
||||
WebGUI::Test->addToCleanup(sub {
|
||||
for my $username ( @cleanupUsernames ) {
|
||||
# We don't create actual, real users, so we have to cleanup by hand
|
||||
my $userId = $session->db->quickScalar(
|
||||
"SELECT userId FROM users WHERE username=?",
|
||||
[ $username ]
|
||||
);
|
||||
|
||||
my @tableList
|
||||
= qw{authentication users userProfileData groupings inbox userLoginLog};
|
||||
|
||||
for my $table ( @tableList ) {
|
||||
$session->db->write(
|
||||
"DELETE FROM $table WHERE userId=?",
|
||||
[ $userId ]
|
||||
);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
is(
|
||||
$createAccountSession->http->getRedirectLocation, 'REDIRECT_URL',
|
||||
|
|
@ -70,24 +89,3 @@ is(
|
|||
);
|
||||
is $output, undef, 'login returns undef when showMessageOnLogin is false';
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Cleanup
|
||||
END {
|
||||
for my $username ( @cleanupUsernames ) {
|
||||
# We don't create actual, real users, so we have to cleanup by hand
|
||||
my $userId = $session->db->quickScalar(
|
||||
"SELECT userId FROM users WHERE username=?",
|
||||
[ $username ]
|
||||
);
|
||||
|
||||
my @tableList
|
||||
= qw{authentication users userProfileData groupings inbox userLoginLog};
|
||||
|
||||
for my $table ( @tableList ) {
|
||||
$session->db->write(
|
||||
"DELETE FROM $table WHERE userId=?",
|
||||
[ $userId ]
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -206,6 +206,7 @@ $output = WebGUI::Content::Asset::dispatch( $session );
|
|||
is $output, 'www_view one', 'an empty URL returns the default asset';
|
||||
$session->setting->set('defaultPage', $originalDefaultPage);
|
||||
|
||||
<<<<<<< HEAD
|
||||
#----------------------------------------------------------------------------
|
||||
# 304 Content Not Modified response
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ my $testBlock = [
|
|||
|
||||
my $formType = 'date';
|
||||
|
||||
my $numTests = 26 + scalar @{ $testBlock } ;
|
||||
my $numTests = 27 + scalar @{ $testBlock } ;
|
||||
|
||||
|
||||
plan tests => $numTests;
|
||||
|
|
@ -79,7 +79,7 @@ is($input->name, 'TestDate', 'Checking input name');
|
|||
is($input->type, 'text', 'Checking input type');
|
||||
is(
|
||||
$input->value,
|
||||
WebGUI::DateTime->new($session, $defaultTime)->toMysqlDate,
|
||||
WebGUI::DateTime->new($session, $defaultTime)->set_time_zone($session->user->get('timeZone'))->toMysqlDate,
|
||||
"Checking default value"
|
||||
);
|
||||
is($input->{size}, 10, 'Checking size param, default');
|
||||
|
|
@ -143,7 +143,7 @@ is(
|
|||
$date2 = WebGUI::Form::Date->new($session, {defaultValue => '2008-008-001'});
|
||||
is(
|
||||
getValueFromForm($session, $date2->toHtml),
|
||||
'1970-01-01',
|
||||
'1969-12-31',
|
||||
"toHtml: defaultValue in bad mysql format returns date from epoch 0"
|
||||
);
|
||||
|
||||
|
|
@ -159,6 +159,18 @@ is($date2->getValueAsHtml(), '8/16/2001', "getValueAsHtml: defaultValue in mysql
|
|||
$date2 = WebGUI::Form::Date->new($session, {defaultValue => '2008-08-01', value => '2001-08-16', });
|
||||
is($date2->getValueAsHtml(), '2001-08-16', "getValueAsHtml: defaultValue in mysql format, value as mysql returns value in mysql format");
|
||||
|
||||
my $dutchie = WebGUI::User->create($session);
|
||||
WebGUI::Test->addToCleanup($dutchie);
|
||||
$dutchie->update({timeZone => 'Europe/Amsterdam', });
|
||||
$session->user({user => $dutchie});
|
||||
my $date_form = WebGUI::Form::Date->new($session, { name => 'test_date', });
|
||||
$session->request->setup_body({ test_date => '2001-08-16', });
|
||||
my $epochal_value = $date_form->getValue;
|
||||
|
||||
$date_form->set(value => $epochal_value);
|
||||
my $mysql_date = getValueFromForm($session, $date_form->toHtml);
|
||||
is $mysql_date, '2001-08-16', 'Form data processed and rendered round trip';
|
||||
|
||||
sub getValueFromForm {
|
||||
my ($session, $textForm) = @_;
|
||||
my ($header, $footer) = (WebGUI::Form::formHeader($session), WebGUI::Form::formFooter($session));
|
||||
|
|
|
|||
142
t/Shop/Credit.t
Normal file
142
t/Shop/Credit.t
Normal file
|
|
@ -0,0 +1,142 @@
|
|||
# vim:syntax=perl
|
||||
#-------------------------------------------------------------------
|
||||
# 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
|
||||
#------------------------------------------------------------------
|
||||
|
||||
# Write a little about what this script tests.
|
||||
#
|
||||
#
|
||||
|
||||
use FindBin;
|
||||
use strict;
|
||||
use lib "$FindBin::Bin/../lib";
|
||||
use Test::More;
|
||||
use Test::Deep;
|
||||
use Test::Exception;
|
||||
use Data::Dumper;
|
||||
use JSON;
|
||||
use HTML::Form;
|
||||
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Shop::Credit;
|
||||
use WebGUI::User;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
my $session = WebGUI::Test->session;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Tests
|
||||
|
||||
plan tests => 27;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# figure out if the test can actually run
|
||||
|
||||
my $e;
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# new
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
my $credit;
|
||||
my $credit_user = WebGUI::User->create($session);
|
||||
WebGUI::Test->addToCleanup($credit_user);
|
||||
|
||||
# Test incorrect for parameters
|
||||
|
||||
eval { $credit = WebGUI::Shop::Credit->new(); };
|
||||
$e = Exception::Class->caught();
|
||||
isa_ok ($e, 'WebGUI::Error::InvalidParam', 'new takes exception to not giving it a session object');
|
||||
cmp_deeply (
|
||||
$e,
|
||||
methods(
|
||||
error => 'Need a session.',
|
||||
),
|
||||
'new takes exception to not giving it a session object',
|
||||
);
|
||||
|
||||
lives_ok { $credit = WebGUI::Shop::Credit->new($session, $credit_user->userId); } 'new works with an explicit userId';
|
||||
can_ok($credit, qw/adjust purge getSum getLedger calculateDeduction session userId/);
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# session
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
isa_ok ($credit->session, 'WebGUI::Session', 'session method returns a session object');
|
||||
is ($session->getId, $credit->session->getId, 'session method returns OUR session object');
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# userId
|
||||
#
|
||||
#######################################################################
|
||||
is ($credit->userId, $credit_user->userId, 'userId accessor returns the userId we set');
|
||||
|
||||
$session->user({userId => 3});
|
||||
lives_ok { $credit = WebGUI::Shop::Credit->new($session); } 'new works without an explicit userId';
|
||||
is $credit->userId, 3, '... by default, it uses the session user';
|
||||
|
||||
$session->user({userId => 1});
|
||||
lives_ok { $credit = WebGUI::Shop::Credit->new($session); } 'new works for visitor, too';
|
||||
|
||||
##Restore the original user for more testing
|
||||
$credit = WebGUI::Shop::Credit->new($session, $credit_user->userId);
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# adjust, getSum, calculateDeduction
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
my $credit1 = WebGUI::Shop::Credit->new($session, 1);
|
||||
my $credit3 = WebGUI::Shop::Credit->new($session, 3);
|
||||
WebGUI::Test->addToCleanup(sub { $credit3->purge });
|
||||
WebGUI::Test->addToCleanup(sub { $credit->purge });
|
||||
|
||||
is $credit1->adjust(300, 'bonus for visitors'), 0, 'visitor cannot have credit';
|
||||
is $credit1->getSum, "0.00", 'getSum: Formatting and amount for Visitor';
|
||||
is $credit3->getSum, "0.00", '... for Admin';
|
||||
is $credit->getSum, "0.00", '... for credit user';
|
||||
|
||||
is $credit3->adjust(200, 'Admin never gets enough credit'), 200, 'Give Admin 200 credit';
|
||||
is $credit3->getSum, "200.00", '... getSum for Admin';
|
||||
is $credit->getSum, "0.00", '... for credit user';
|
||||
|
||||
is $credit->adjust(50, 'Refund'), 50, 'Give credit user 50 credit';
|
||||
is $credit3->getSum, "200.00", '... getSum for Admin, uniqueness check';
|
||||
is $credit->getSum, "50.00", '... for credit user';
|
||||
|
||||
is $credit->adjust(-10, 'Typo in original refund'), -10, 'Negative adustment';
|
||||
is $credit3->getSum, "200.00", '... getSum for Admin, uniqueness check';
|
||||
is $credit->getSum, "40.00", '... for credit user';
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# calculateDeduction
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
is $credit->calculateDeduction(10), "-10.00", 'calculateDeduction returns the max of either the amount';
|
||||
is $credit->calculateDeduction(80), "-40.00", '... or the available credit';
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# purge
|
||||
#
|
||||
#######################################################################
|
||||
|
||||
$credit->purge;
|
||||
is $credit->getSum, "0.00", 'user credit purged';
|
||||
is $credit3->getSum, "200.00", '... but only for credit user';
|
||||
|
|
@ -22,8 +22,11 @@ use HTML::Form;
|
|||
|
||||
use WebGUI::Test; # Must use this before any other WebGUI modules
|
||||
use WebGUI::Session;
|
||||
use WebGUI::Shop::Cart;
|
||||
use WebGUI::Shop::Credit;
|
||||
use WebGUI::Shop::PayDriver;
|
||||
use Clone;
|
||||
use WebGUI::User;
|
||||
|
||||
#----------------------------------------------------------------------------
|
||||
# Init
|
||||
|
|
@ -394,11 +397,14 @@ my $blue_widget = $widget->setCollateral('variantsJSON', 'variantId', 'new',
|
|||
);
|
||||
|
||||
$versionTag->commit;
|
||||
|
||||
$widget = $widget->cloneFromDb;
|
||||
|
||||
$session->user({userId => 3});
|
||||
my $credited_user = WebGUI::User->create($session);
|
||||
$session->user({user => $credited_user});
|
||||
|
||||
my $cart = WebGUI::Shop::Cart->newBySession($session);
|
||||
WebGUI::Test->addToCleanup($versionTag, $cart);
|
||||
WebGUI::Test->addToCleanup($versionTag, $cart, $credited_user);
|
||||
my $addressBook = $cart->getAddressBook;
|
||||
my $workAddress = $addressBook->addAddress({
|
||||
label => 'work',
|
||||
|
|
@ -432,6 +438,26 @@ cmp_deeply(
|
|||
'appendCartVariables: checking shippableItemsInCart and totalPrice & subtotal formatting'
|
||||
);
|
||||
|
||||
my $credit = WebGUI::Shop::Credit->new($session, $credited_user->userId);
|
||||
$credit->adjust('1', 'credit for testing');
|
||||
$cart_variables = {};
|
||||
$driver->appendCartVariables($cart_variables);
|
||||
cmp_deeply(
|
||||
$cart_variables,
|
||||
{
|
||||
taxes => ignore(),
|
||||
shippableItemsInCart => 1,
|
||||
subtotal => '5.00',
|
||||
inShopCreditDeduction => '-1.00',
|
||||
inShopCreditAvailable => '1.00',
|
||||
totalPrice => '4.00',
|
||||
shipping => ignore(),
|
||||
|
||||
},
|
||||
'... checking credit display'
|
||||
);
|
||||
|
||||
|
||||
#######################################################################
|
||||
#
|
||||
# delete
|
||||
|
|
|
|||
3
t/User.t
3
t/User.t
|
|
@ -18,7 +18,7 @@ use WebGUI::User;
|
|||
use WebGUI::ProfileField;
|
||||
use WebGUI::Shop::AddressBook;
|
||||
|
||||
use Test::More tests => 226; # increment this value for each test you create
|
||||
use Test::More tests => 225; # increment this value for each test you create
|
||||
use Test::Deep;
|
||||
use Data::Dumper;
|
||||
|
||||
|
|
@ -417,7 +417,6 @@ ok($user->isInGroup(3), "addToGroups: New user is in group 3(Admin)");
|
|||
ok($user->isInGroup(11), "New user is in group 11(Secondary Admins)");
|
||||
ok($user->isInGroup(12), "New user is in group 12(Turn On Admin)");
|
||||
ok($user->isInGroup(13), "New user is in group 13(Export Managers)");
|
||||
ok($user->isInGroup(14), "New user is in group 14(Product Managers)");
|
||||
|
||||
$user->deleteFromGroups([3]);
|
||||
ok(!$user->isInGroup(3), "deleteFromGroups: New user is not in group 3(Admin)");
|
||||
|
|
|
|||
|
|
@ -10,10 +10,6 @@
|
|||
|
||||
use File::Spec::Functions qw( catdir rel2abs );
|
||||
use File::Basename;
|
||||
use Test::Class;
|
||||
use Module::Find;
|
||||
use lib rel2abs( catdir ( dirname( __FILE__ ), 'tests' ) );
|
||||
|
||||
useall('Test::WebGUI::Form');
|
||||
use File::Basename qw( dirname );
|
||||
use Test::Class::Load rel2abs( catdir ( dirname( __FILE__ ), 'tests' ) );
|
||||
Test::Class->runtests;
|
||||
|
||||
|
|
|
|||
BIN
www/extras/ukplayer/dummycontent/explain.jpg
Normal file
BIN
www/extras/ukplayer/dummycontent/explain.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 31 KiB |
63
www/extras/ukplayer/licence.txt
Normal file
63
www/extras/ukplayer/licence.txt
Normal file
|
|
@ -0,0 +1,63 @@
|
|||
The UKPLayer is licensed under the terms of the GNU General Public License, version 2
|
||||
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
|
||||
SWFObject 2, the code used to display the Slideshow, is licensed under the MIT License
|
||||
http://www.opensource.org/licenses/mit-license.php
|
||||
|
||||
The UKPlayer makes use of three libraries that are compatible with GPL v.2. These are:
|
||||
|
||||
PureMVC (Creative Commons Attribution Licence 3.0)
|
||||
http://puremvc.org/
|
||||
|
||||
Tweener (BSD Licence)
|
||||
http://code.google.com/p/tweener/wiki/License
|
||||
|
||||
Hydrotik (licence see below)
|
||||
http://blog.hydrotik.com/
|
||||
/*
|
||||
|
||||
* Copyright 2007-2008 (c) Donovan Adams, http://blog.hydrotik.com/
|
||||
|
||||
*
|
||||
|
||||
* Permission is hereby granted, free of charge, to any person
|
||||
|
||||
* obtaining a copy of this software and associated documentation
|
||||
|
||||
* files (the "Software"), to deal in the Software without
|
||||
|
||||
* restriction, including without limitation the rights to use,
|
||||
|
||||
* copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
|
||||
* copies of the Software, and to permit persons to whom the
|
||||
|
||||
* Software is furnished to do so, subject to the following
|
||||
|
||||
* conditions:
|
||||
|
||||
*
|
||||
|
||||
* The above copyright notice and this permission notice shall be
|
||||
|
||||
* included in all copies or substantial portions of the Software.
|
||||
|
||||
*
|
||||
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
|
||||
* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES
|
||||
|
||||
* OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
|
||||
* NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT
|
||||
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
|
||||
|
||||
* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
||||
|
||||
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
||||
|
||||
* OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
||||
*/
|
||||
290
www/extras/ukplayer/readme.txt
Normal file
290
www/extras/ukplayer/readme.txt
Normal file
|
|
@ -0,0 +1,290 @@
|
|||
United Knowledge Slideshow Player - readme.txt
|
||||
|
||||
Copyright: United Knowledge, 2009
|
||||
|
||||
The Slideshow PLayer is licensed under the terms of the GNU General Public License, version 2
|
||||
http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt
|
||||
|
||||
SWFObject 2, the code used to display the Slideshow, is licensed under the MIT License
|
||||
http://www.opensource.org/licenses/mit-license.php
|
||||
|
||||
Check out the latest source on:
|
||||
http://git.st.unitedknowledge.org/git/ukplayer.git
|
||||
git clone git://git.st.unitedknowledge.org/ukplayer.git
|
||||
git clone http://git.st.unitedknowledge.org/git/ukplayer.git
|
||||
|
||||
More information about licences can be found in the file licences.txt in this directory.
|
||||
|
||||
|
||||
**********************************************************************************************
|
||||
* *
|
||||
* The configuration XML *
|
||||
* *
|
||||
**********************************************************************************************
|
||||
|
||||
With the configuration .xml file you can customize the look and the behaviour of the
|
||||
slideshow. It contains the following properties (the values are example values; there are
|
||||
default values for most, but we recommend setting ALL properties yourself).
|
||||
|
||||
|
||||
|
||||
**********************************************************************************************
|
||||
* Structure of the xml *
|
||||
**********************************************************************************************
|
||||
|
||||
<config>
|
||||
[properties go here]
|
||||
</config>
|
||||
|
||||
|
||||
|
||||
**********************************************************************************************
|
||||
* General properties *
|
||||
**********************************************************************************************
|
||||
|
||||
<content_url>/someUrl/someXmlFile.xml</content_url>
|
||||
The url to the .xml file that contains the content.
|
||||
Value: an absolute or relative url to an xml file
|
||||
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
The width and height of the player itself (this value is overwritten by the flashVars
|
||||
but the tags need to be here).
|
||||
Value: number in px
|
||||
|
||||
<default_duration>8</default_duration>
|
||||
The duration of each slide. This can be overwritten by setting the duration per slide
|
||||
in the content .xml file.
|
||||
Value: number in seconds
|
||||
|
||||
<default_slidewidth>400</default_slidewidth>
|
||||
<default_slideheight>300</default_slideheight>
|
||||
If the width or height of a slide is larger than the values specified here, the slide
|
||||
will be resized proportionally. Slides that are smaller than the slidshow will not be
|
||||
resized.
|
||||
Value: number in px
|
||||
|
||||
<background_color>0xeeeeee</background_color>
|
||||
The background color for the slideshow. This will be visible during the transitions
|
||||
and when a slide is smaller than the slideshow.
|
||||
Value: 0x followed by hexadecimal color
|
||||
|
||||
<skin>rounded</skin>
|
||||
The textarea, controls and thumbnails can be displayed with two different skins.
|
||||
Value: simple or rounded
|
||||
|
||||
|
||||
|
||||
**********************************************************************************************
|
||||
* Text properties *
|
||||
**********************************************************************************************
|
||||
|
||||
<font>Verdana</font>
|
||||
The font of the text in the slideshow.
|
||||
Value: Verdana, Arial or TimesNewRoman
|
||||
|
||||
<font_size>12</font_size>
|
||||
The font size of the text in the slideshow.
|
||||
Value: number in px
|
||||
|
||||
<font_color>0xffffff</font_color>
|
||||
The color of the text in the slideshow.
|
||||
Value: 0x followed by hexadecimal color
|
||||
|
||||
<text_border_color>0xffffff</text_border_color>
|
||||
The color of the border of the textarea.
|
||||
Value: 0x followed by hexadecimal color
|
||||
|
||||
<text_bg_color>0x000000</text_bg_color>
|
||||
The background color of the textarea.
|
||||
Value: 0x followed by hexadecimal color
|
||||
|
||||
<text_autohide>false</text_autohide>
|
||||
When set to true the textarea will hide after a few seconds.
|
||||
Value: true or false
|
||||
|
||||
<text_display>over</text_display>
|
||||
The textarea can be postioned over the slides, above the slides (the height of the player
|
||||
should be the sum of the height of the slides and the height of the textarea) or can be
|
||||
hidden.
|
||||
Value: over, above or none
|
||||
|
||||
<text_height>50</text_height>
|
||||
The minimum height of the textarea.
|
||||
Value: number in px
|
||||
|
||||
|
||||
|
||||
**********************************************************************************************
|
||||
* Controls properties *
|
||||
**********************************************************************************************
|
||||
|
||||
<controls_color>0xffffff</controls_color>
|
||||
The color of the buttons.
|
||||
Value: 0x followed by hexadecimal color
|
||||
|
||||
<controls_border_color>0xffffff</controls_border_color>
|
||||
The color of the border of the area with the buttons.
|
||||
Value: 0x followed by hexadecimal color
|
||||
|
||||
<controls_bg_color>0x000000</controls_bg_color>
|
||||
The background color of the area with the buttons.
|
||||
Value: 0x followed by hexadecimal color
|
||||
|
||||
<controls_autohide>true</controls_autohide>
|
||||
When set to true the controls will hide after a few seconds.
|
||||
Value: true or false
|
||||
|
||||
<playbutton_percent_width>20</playbutton_percent_width>
|
||||
The width of the big play button (which appears when auto_start is false and, if loop is
|
||||
set to false, after the slideshow has finished) can be set in a percentage of the total
|
||||
width of the movie.
|
||||
Value: percentage of movie width
|
||||
|
||||
<playbutton_max_width>200</playbutton_max_width>
|
||||
A maximum width for the play button to prevent it from becoming too large.
|
||||
Value: number in px
|
||||
|
||||
|
||||
|
||||
**********************************************************************************************
|
||||
* Thumbnail properties *
|
||||
**********************************************************************************************
|
||||
|
||||
<thumbnail_width>40</thumbnail_width>
|
||||
<thumbnail_height>30</thumbnail_height>
|
||||
The height and width of each thumbnail image in the bar at the bottom of the
|
||||
slideshow.
|
||||
Value: number in px
|
||||
|
||||
<thumbnail_border_color>0x888888</thumbnail_border_color>
|
||||
The color of the border of each thumbnail image.
|
||||
Value: 0x followed by hexadecimal color
|
||||
|
||||
<menu_autohide>true</menu_autohide>
|
||||
When set to true the thumbnail bar will hide after a few seconds.
|
||||
Value: true or false
|
||||
|
||||
<menu_dead_zone_width>160</menu_dead_zone_width>
|
||||
The width of the area in the center of the thumbnail bar in which the user can hover
|
||||
the mouse, without the thumbnail bar moving to the left or to the right.
|
||||
Value: number in px
|
||||
|
||||
<menu_gaps>6</menu_gaps>
|
||||
The width of the gap between two thumbnail images.
|
||||
Value: number in px
|
||||
|
||||
<thumbnails_hide>false</thumbnails_hide>
|
||||
When set to true, the thumbnails are hidden.
|
||||
Value: true or false
|
||||
|
||||
|
||||
|
||||
**********************************************************************************************
|
||||
* Behaviour properties *
|
||||
**********************************************************************************************
|
||||
|
||||
<mute_at_start>true</mute_at_start>
|
||||
If true the slideshow will start with the sound muted.
|
||||
Value: true or false
|
||||
|
||||
<sound>off</sound>
|
||||
If the sound is turned off, the audio files will not be played and the mute and volume
|
||||
controls will be hidden.
|
||||
Value: on or off
|
||||
|
||||
<autostart>false</autostart>
|
||||
If true the slideshow will start upon loading. If false a play button will be
|
||||
displayed.
|
||||
Value: true or false
|
||||
|
||||
<autopause>true</autopause>
|
||||
If true the slideshow will pause when clicking on a thumbnail or clicking the
|
||||
previous or next buttons.
|
||||
Value: true or false
|
||||
|
||||
<loop>false</loop>
|
||||
If true the slideshow will loop. If false, when the last slide has been displayed,
|
||||
the slideshow will move back to the first slide and show a play button.
|
||||
Value: true or false
|
||||
|
||||
|
||||
|
||||
**********************************************************************************************
|
||||
* Error messages *
|
||||
**********************************************************************************************
|
||||
|
||||
<error_message_content><![CDATA[Content Xml not found]]></error_message_content>
|
||||
<error_message_image><![CDATA[Image not found]]></error_message_image>
|
||||
Value: any text in CDATA tags: <![CDATA[ ... ]]>
|
||||
|
||||
|
||||
|
||||
|
||||
**********************************************************************************************
|
||||
* *
|
||||
* The content XML *
|
||||
* *
|
||||
**********************************************************************************************
|
||||
|
||||
The content .xml file contains the properties for each slide.
|
||||
|
||||
|
||||
|
||||
**********************************************************************************************
|
||||
* Structure of the xml *
|
||||
**********************************************************************************************
|
||||
|
||||
<content>
|
||||
<slides>
|
||||
<slide>[properties go here]</slide>
|
||||
<slide>[properties go here]</slide>
|
||||
...
|
||||
</slides>
|
||||
</content>
|
||||
|
||||
|
||||
|
||||
**********************************************************************************************
|
||||
* Properties in the slide tag *
|
||||
**********************************************************************************************
|
||||
|
||||
<title><![CDATA[My first slide]]></title>
|
||||
The title of the slide.
|
||||
Value: any text in CDATA tags: <![CDATA[ ... ]]>
|
||||
|
||||
<description><![CDATA[This is my first slide!]]></description>
|
||||
The description of the slide.
|
||||
Value: any text in CDATA tags: <![CDATA[ ... ]]>
|
||||
|
||||
<image_source>/someUrl/someImg.jpg</image_source>
|
||||
The url to the slide image.
|
||||
Value: an absolute or relative url to a .jpg, .gif or .png file
|
||||
|
||||
<thumb_source>/someUrl/someImg_thumb.jpg</thumb_source>
|
||||
The url to the thumbnail of the slide image.
|
||||
Value: an absolute or relative url to a .jpg, .gif or .png file
|
||||
|
||||
<sound_source>/someUrl/someImg_thumb.jpg</sound_source>
|
||||
The url to the sound file that will be played when the slide is displayed. It will be
|
||||
played once for the duration of the slide (if the duration of the sound file is longer
|
||||
than the set duration of the slide it will be cut off). This property is optional.
|
||||
Value: an absolute or relative url to a .mp3 file
|
||||
|
||||
<duration>8</duration>
|
||||
The duration for this specific slide. This value will overwrite the duration value set
|
||||
in the configuration xml. This property is optional.
|
||||
Value: number in seconds
|
||||
|
||||
<width>400</width>
|
||||
<height>300</height>
|
||||
The width and height of the slide. This will overwrite the default_slidewidth and
|
||||
default_slideheight set in the configuration xml. The width and height properties are
|
||||
optional.
|
||||
Value: number in px
|
||||
|
||||
|
||||
|
||||
**********************************************************************************************
|
||||
* eof *
|
||||
**********************************************************************************************
|
||||
80
www/extras/ukplayer/slideshow.html
Normal file
80
www/extras/ukplayer/slideshow.html
Normal file
|
|
@ -0,0 +1,80 @@
|
|||
<!DOCTYPE html PUBLIC "-/W3C/DTD XHTML 1.0 Strict/EN" "http:/www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http:/www.w3.org/1999/xhtml" lang="en" xml:lang="en">
|
||||
<head>
|
||||
<title>UKplayer Slideshow Demo</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<script type="text/javascript" src="swfobject.js"></script>
|
||||
<script type="text/javascript">
|
||||
swfobject.registerObject("myFlashContent","9.0.0","expressInstall.swf");
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<!--
|
||||
This is the United Knowledge Player for WebGUI.
|
||||
It enables you to display photo's as a movie. The
|
||||
configuration options can be found in the readme
|
||||
file here:
|
||||
/extras/ukplayer/readme.txt
|
||||
|
||||
There are three example files to show you how to
|
||||
use this player:
|
||||
/extras/ukplayer/slideshow.html
|
||||
/extras/ukplayer/config.xml
|
||||
/extras/ukplayer/content.xml
|
||||
|
||||
This player is Free Software under the GPL v2
|
||||
Check out the latest source on:
|
||||
http://git.st.unitedknowledge.org/git/ukplayer.git
|
||||
git clone git://git.st.unitedknowledge.org/ukplayer.git
|
||||
git clone http://git.st.unitedknowledge.org/git/ukplayer.git
|
||||
|
||||
Copyright 2008-2010 United Knowledge http:/www.unitedknowledge.nl/
|
||||
-->
|
||||
|
||||
<div>
|
||||
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="300" id="myFlashContent">
|
||||
<param name="movie" value="slideShow.swf" />
|
||||
<param name="flashvars" value="config=config.xml" />
|
||||
<!--[if !IE]>-->
|
||||
<object type="application/x-shockwave-flash" data="slideShow.swf" width="400" height="300">
|
||||
<param name="flashvars" value="config=config.xml" />
|
||||
<!--<![endif]-->
|
||||
<a href="http:/www.adobe.com/go/getflashplayer">
|
||||
<img src="http:/www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
|
||||
</a>
|
||||
<!--[if !IE]>-->
|
||||
</object>
|
||||
<!--<![endif]-->
|
||||
</object>
|
||||
</div>
|
||||
|
||||
<p>Code generated with the <a href="http://www.bobbyvandersluis.com/swfobject/generator/index.html">SWFObject 2 HTML and JavaScript generator</a>.</p>
|
||||
|
||||
<textarea rows="25" cols="130">
|
||||
<script type="text/javascript" src="^Extras(ukplayer/swfobject.js);"></script>
|
||||
<script type="text/javascript">
|
||||
swfobject.registerObject("myFlashContent","9.0.0","^Extras(ukplayer/expressInstall.swf);");
|
||||
</script>
|
||||
|
||||
<div>
|
||||
<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width="400" height="300" id="myFlashContent">
|
||||
<param name="movie" value="^Extras(ukplayer/slideShow.swf);" />
|
||||
<param name="flashvars" value="config=^Extras(ukplayer/config.xml);" />
|
||||
<!--[if !IE]>-->
|
||||
<object type="application/x-shockwave-flash" data="^Extras(ukplayer/slideShow.swf);" width="400" height="300">
|
||||
<param name="flashvars" value="config=^Extras(ukplayer/config.xml);" />
|
||||
<!--<![endif]-->
|
||||
<a href="http:/www.adobe.com/go/getflashplayer">
|
||||
<img src="http:/www.adobe.com/images/shared/download_buttons/get_flash_player.gif" alt="Get Adobe Flash player" />
|
||||
</a>
|
||||
<!--[if !IE]>-->
|
||||
</object>
|
||||
<!--<![endif]-->
|
||||
</object>
|
||||
</div>
|
||||
</textarea>
|
||||
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,747 +0,0 @@
|
|||
/*
|
||||
* HTML Parser By John Resig (ejohn.org)
|
||||
* Original code by Erik Arvidsson, Mozilla Public License
|
||||
* http://erik.eae.net/simplehtmlparser/simplehtmlparser.js
|
||||
*
|
||||
* // Use like so:
|
||||
* HTMLParser(htmlString, {
|
||||
* start: function(tag, attrs, unary) {},
|
||||
* end: function(tag) {},
|
||||
* chars: function(text) {},
|
||||
* comment: function(text) {}
|
||||
* });
|
||||
*
|
||||
* // or to get an XML string:
|
||||
* HTMLtoXML(htmlString);
|
||||
*
|
||||
* // or to get an XML DOM Document
|
||||
* HTMLtoDOM(htmlString);
|
||||
*
|
||||
* // or to inject into an existing document/DOM node
|
||||
* HTMLtoDOM(htmlString, document);
|
||||
* HTMLtoDOM(htmlString, document.body);
|
||||
*
|
||||
*/
|
||||
|
||||
(function(){
|
||||
|
||||
// Regular Expressions for parsing tags and attributes
|
||||
var startTag = /^<(\w+)((?:\s+\w+(?:\s*=\s*(?:(?:"[^"]*")|(?:'[^']*')|[^>\s]+))?)*)\s*(\/?)>/,
|
||||
endTag = /^<\/(\w+)[^>]*>/,
|
||||
attr = /(\w+)(?:\s*=\s*(?:(?:"((?:\\.|[^"])*)")|(?:'((?:\\.|[^'])*)')|([^>\s]+)))?/g;
|
||||
|
||||
// Empty Elements - HTML 4.01
|
||||
var empty = makeMap("area,base,basefont,br,col,frame,hr,img,input,isindex,link,meta,param,embed");
|
||||
|
||||
// Block Elements - HTML 4.01
|
||||
var block = makeMap("address,applet,blockquote,button,center,dd,del,dir,div,dl,dt,fieldset,form,frameset,hr,iframe,ins,isindex,li,map,menu,noframes,noscript,object,ol,p,pre,script,table,tbody,td,tfoot,th,thead,tr,ul");
|
||||
|
||||
// Inline Elements - HTML 4.01
|
||||
var inline = makeMap("a,abbr,acronym,applet,b,basefont,bdo,big,br,button,cite,code,del,dfn,em,font,i,iframe,img,input,ins,kbd,label,map,object,q,s,samp,script,select,small,span,strike,strong,sub,sup,textarea,tt,u,var");
|
||||
|
||||
// Elements that you can, intentionally, leave open
|
||||
// (and which close themselves)
|
||||
var closeSelf = makeMap("colgroup,dd,dt,li,options,p,td,tfoot,th,thead,tr");
|
||||
|
||||
// Attributes that have their values filled in disabled="disabled"
|
||||
var fillAttrs = makeMap("checked,compact,declare,defer,disabled,ismap,multiple,nohref,noresize,noshade,nowrap,readonly,selected");
|
||||
|
||||
// Special Elements (can contain anything)
|
||||
var special = makeMap("script,style");
|
||||
|
||||
var HTMLParser = this.HTMLParser = function( html, handler ) {
|
||||
var index, chars, match, stack = [], last = html;
|
||||
stack.last = function(){
|
||||
return this[ this.length - 1 ];
|
||||
};
|
||||
|
||||
while ( html ) {
|
||||
chars = true;
|
||||
|
||||
// Make sure we're not in a script or style element
|
||||
if ( !stack.last() || !special[ stack.last() ] ) {
|
||||
|
||||
// Comment
|
||||
if ( html.indexOf("<!--") == 0 ) {
|
||||
index = html.indexOf("-->");
|
||||
|
||||
if ( index >= 0 ) {
|
||||
if ( handler.comment )
|
||||
handler.comment( html.substring( 4, index ) );
|
||||
html = html.substring( index + 3 );
|
||||
chars = false;
|
||||
}
|
||||
|
||||
// end tag
|
||||
} else if ( html.indexOf("</") == 0 ) {
|
||||
match = html.match( endTag );
|
||||
|
||||
if ( match ) {
|
||||
html = html.substring( match[0].length );
|
||||
match[0].replace( endTag, parseEndTag );
|
||||
chars = false;
|
||||
}
|
||||
|
||||
// start tag
|
||||
} else if ( html.indexOf("<") == 0 ) {
|
||||
match = html.match( startTag );
|
||||
|
||||
if ( match ) {
|
||||
html = html.substring( match[0].length );
|
||||
match[0].replace( startTag, parseStartTag );
|
||||
chars = false;
|
||||
}
|
||||
}
|
||||
|
||||
if ( chars ) {
|
||||
index = html.indexOf("<");
|
||||
|
||||
var text = index < 0 ? html : html.substring( 0, index );
|
||||
html = index < 0 ? "" : html.substring( index );
|
||||
|
||||
if ( handler.chars )
|
||||
handler.chars( text );
|
||||
}
|
||||
|
||||
} else {
|
||||
html = html.replace(new RegExp("(.*)<\/" + stack.last() + "[^>]*>"), function(all, text){
|
||||
text = text.replace(/<!--(.*?)-->/g, "$1")
|
||||
.replace(/<!\[CDATA\[(.*?)]]>/g, "$1");
|
||||
|
||||
if ( handler.chars )
|
||||
handler.chars( text );
|
||||
|
||||
return "";
|
||||
});
|
||||
|
||||
parseEndTag( "", stack.last() );
|
||||
}
|
||||
|
||||
if ( html == last )
|
||||
throw "Parse Error: " + html;
|
||||
last = html;
|
||||
}
|
||||
|
||||
// Clean up any remaining tags
|
||||
parseEndTag();
|
||||
|
||||
function parseStartTag( tag, tagName, rest, unary ) {
|
||||
if ( block[ tagName ] ) {
|
||||
while ( stack.last() && inline[ stack.last() ] ) {
|
||||
parseEndTag( "", stack.last() );
|
||||
}
|
||||
}
|
||||
|
||||
if ( closeSelf[ tagName ] && stack.last() == tagName ) {
|
||||
parseEndTag( "", tagName );
|
||||
}
|
||||
|
||||
unary = empty[ tagName ] || !!unary;
|
||||
|
||||
if ( !unary )
|
||||
stack.push( tagName );
|
||||
|
||||
if ( handler.start ) {
|
||||
var attrs = [];
|
||||
|
||||
rest.replace(attr, function(match, name) {
|
||||
var value = arguments[2] ? arguments[2] :
|
||||
arguments[3] ? arguments[3] :
|
||||
arguments[4] ? arguments[4] :
|
||||
fillAttrs[name] ? name : "";
|
||||
|
||||
attrs.push({
|
||||
name: name,
|
||||
value: value,
|
||||
escaped: value.replace(/(^|[^\\])"/g, '$1\\\"') //"
|
||||
});
|
||||
});
|
||||
|
||||
if ( handler.start )
|
||||
handler.start( tagName, attrs, unary );
|
||||
}
|
||||
}
|
||||
|
||||
function parseEndTag( tag, tagName ) {
|
||||
// If no tag name is provided, clean shop
|
||||
if ( !tagName )
|
||||
var pos = 0;
|
||||
|
||||
// Find the closest opened tag of the same type
|
||||
else
|
||||
for ( var pos = stack.length - 1; pos >= 0; pos-- )
|
||||
if ( stack[ pos ] == tagName )
|
||||
break;
|
||||
|
||||
if ( pos >= 0 ) {
|
||||
// Close all the open elements, up the stack
|
||||
for ( var i = stack.length - 1; i >= pos; i-- )
|
||||
if ( handler.end )
|
||||
handler.end( stack[ i ] );
|
||||
|
||||
// Remove the open elements from the stack
|
||||
stack.length = pos;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
this.HTMLtoXML = function( html ) {
|
||||
var results = "";
|
||||
|
||||
HTMLParser(html, {
|
||||
start: function( tag, attrs, unary ) {
|
||||
results += "<" + tag;
|
||||
|
||||
for ( var i = 0; i < attrs.length; i++ )
|
||||
results += " " + attrs[i].name + '="' + attrs[i].escaped + '"';
|
||||
|
||||
results += (unary ? "/" : "") + ">";
|
||||
},
|
||||
end: function( tag ) {
|
||||
results += "</" + tag + ">";
|
||||
},
|
||||
chars: function( text ) {
|
||||
results += text;
|
||||
},
|
||||
comment: function( text ) {
|
||||
results += "<!--" + text + "-->";
|
||||
}
|
||||
});
|
||||
|
||||
return results;
|
||||
};
|
||||
|
||||
this.HTMLtoDOM = function( html, doc ) {
|
||||
// There can be only one of these elements
|
||||
var one = makeMap("html,head,body,title");
|
||||
|
||||
// Enforce a structure for the document
|
||||
var structure = {
|
||||
link: "head",
|
||||
base: "head"
|
||||
};
|
||||
|
||||
if ( !doc ) {
|
||||
if ( typeof DOMDocument != "undefined" )
|
||||
doc = new DOMDocument();
|
||||
else if ( typeof document != "undefined" && document.implementation && document.implementation.createDocument )
|
||||
doc = document.implementation.createDocument("", "", null);
|
||||
else if ( typeof ActiveX != "undefined" )
|
||||
doc = new ActiveXObject("Msxml.DOMDocument");
|
||||
|
||||
} else
|
||||
doc = doc.ownerDocument ||
|
||||
doc.getOwnerDocument && doc.getOwnerDocument() ||
|
||||
doc;
|
||||
|
||||
var elems = [],
|
||||
documentElement = doc.documentElement ||
|
||||
doc.getDocumentElement && doc.getDocumentElement();
|
||||
|
||||
// If we're dealing with an empty document then we
|
||||
// need to pre-populate it with the HTML document structure
|
||||
if ( !documentElement && doc.createElement ) (function(){
|
||||
var html = doc.createElement("html");
|
||||
var head = doc.createElement("head");
|
||||
head.appendChild( doc.createElement("title") );
|
||||
html.appendChild( head );
|
||||
html.appendChild( doc.createElement("body") );
|
||||
doc.appendChild( html );
|
||||
})();
|
||||
|
||||
// Find all the unique elements
|
||||
if ( doc.getElementsByTagName )
|
||||
for ( var i in one )
|
||||
one[ i ] = doc.getElementsByTagName( i )[0];
|
||||
|
||||
// If we're working with a document, inject contents into
|
||||
// the body element
|
||||
var curParentNode = one.body;
|
||||
|
||||
HTMLParser( html, {
|
||||
start: function( tagName, attrs, unary ) {
|
||||
// If it's a pre-built element, then we can ignore
|
||||
// its construction
|
||||
if ( one[ tagName ] ) {
|
||||
curParentNode = one[ tagName ];
|
||||
return;
|
||||
}
|
||||
|
||||
var elem = doc.createElement( tagName );
|
||||
|
||||
for ( var attr in attrs )
|
||||
elem.setAttribute( attrs[ attr ].name, attrs[ attr ].value );
|
||||
|
||||
if ( structure[ tagName ] && typeof one[ structure[ tagName ] ] != "boolean" )
|
||||
one[ structure[ tagName ] ].appendChild( elem );
|
||||
|
||||
else if ( curParentNode && curParentNode.appendChild )
|
||||
curParentNode.appendChild( elem );
|
||||
|
||||
if ( !unary ) {
|
||||
elems.push( elem );
|
||||
curParentNode = elem;
|
||||
}
|
||||
},
|
||||
end: function( tag ) {
|
||||
elems.length -= 1;
|
||||
|
||||
// Init the new parentNode
|
||||
curParentNode = elems[ elems.length - 1 ];
|
||||
},
|
||||
chars: function( text ) {
|
||||
curParentNode.appendChild( doc.createTextNode( text ) );
|
||||
},
|
||||
comment: function( text ) {
|
||||
// create comment node
|
||||
}
|
||||
});
|
||||
|
||||
return doc;
|
||||
};
|
||||
|
||||
function makeMap(str){
|
||||
var obj = {}, items = str.split(",");
|
||||
for ( var i = 0; i < items.length; i++ )
|
||||
obj[ items[i] ] = true;
|
||||
return obj;
|
||||
}
|
||||
})();
|
||||
|
||||
|
||||
(function() {
|
||||
var Dom = YAHOO.util.Dom,
|
||||
Event = YAHOO.util.Event,
|
||||
Lang = YAHOO.lang
|
||||
;
|
||||
|
||||
YAHOO.widget.CodeEditor = function (id, cfg) {
|
||||
// TODO: Make a cfg for off by default
|
||||
this.editorState = "on";
|
||||
|
||||
// Disable Editor configs that don't apply
|
||||
cfg["animate"] = false;
|
||||
cfg["dompath"] = false;
|
||||
cfg["focusAtStart"] = false;
|
||||
|
||||
// Default toolbar is different
|
||||
cfg["toolbar"] = cfg["toolbar"] || {
|
||||
titlebar : "Code Editor",
|
||||
buttons : []
|
||||
};
|
||||
|
||||
YAHOO.widget.CodeEditor.superclass.constructor.call(this, id, cfg);
|
||||
|
||||
// Allow us to have no buttons
|
||||
// This will be fixed in a future version of YUI Editor
|
||||
YAHOO.widget.Toolbar.prototype.disableAllButtons
|
||||
= function () {
|
||||
if (!this._buttonList) {
|
||||
this._buttonList = [];
|
||||
}
|
||||
if (this.get('disabled')) {
|
||||
return false;
|
||||
}
|
||||
var len = this._buttonList.length;
|
||||
for (var i = 0; i < len; i++) {
|
||||
this.disableButton(this._buttonList[i]);
|
||||
}
|
||||
};
|
||||
// End allow us to have no buttons
|
||||
|
||||
this.on('editorContentLoaded', function() {
|
||||
// Add the code stylesheet
|
||||
var link = this._getDoc().createElement('link');
|
||||
link.rel = "stylesheet";
|
||||
link.type = "text/css";
|
||||
link.href = this.get('css_url');
|
||||
this._getDoc().getElementsByTagName('head')[0].appendChild(link);
|
||||
// Highlight the initial value
|
||||
if ( this.getEditorText() != this.old_text ) {
|
||||
Lang.later(10, this, function () { this.highlight(true) } );
|
||||
if ( this.status ) {
|
||||
Lang.later(100, this, this._writeStatus);
|
||||
}
|
||||
this.old_text = this.getEditorText();
|
||||
}
|
||||
// Setup resize
|
||||
if ( this.status ) {
|
||||
this._setupResize();
|
||||
}
|
||||
}, this, true);
|
||||
|
||||
this.on('editorKeyUp', function(ev) {
|
||||
// Highlight only if content has changed
|
||||
if ( this.getEditorText() != this.old_text ) {
|
||||
Lang.later(10, this, this.highlight);
|
||||
if ( this.status ) {
|
||||
Lang.later(100, this, this._writeStatus);
|
||||
}
|
||||
this.old_text = this.getEditorText();
|
||||
}
|
||||
}, this, true);
|
||||
|
||||
|
||||
//Borrowed this from CodePress: http://codepress.sourceforge.net
|
||||
this.cc = '\u2009'; // carret char
|
||||
// TODO: Make this configurable based on a syntax definition
|
||||
this.keywords = [
|
||||
{ code: /(<DOCTYPE.*?-->.)/g, tag: '<ins>$1</ins>' }, // comments
|
||||
{ code: /(<[^!]*?>)/g, tag: '<b>$1</b>' }, // all tags
|
||||
{ code: /(<!--.*?-->.)/g, tag: '<ins>$1</ins>' }, // comments
|
||||
{ code: /\b(YAHOO|widget|util|Dom|Event|lang)\b/g, tag: '<cite>$1</cite>' }, // reserved words
|
||||
{ code: /\b(break|continue|do|for|new|this|void|case|default|else|function|return|typeof|while|if|label|switch|var|with|catch|boolean|int|try|false|throws|null|true|goto)\b/g, tag: '<b>$1</b>' }, // reserved words
|
||||
{ code: /\"(.*?)(\"|<br>|<\/P>)/gi, tag: '<s>"$1$2</s>' }, // strings double quote
|
||||
{ code: /\'(.*?)(\'|<br>|<\/P>)/gi, tag: '<s>\'$1$2</s>' }, // strings single quote
|
||||
{ code: /\b(alert|isNaN|parent|Array|parseFloat|parseInt|blur|clearTimeout|prompt|prototype|close|confirm|length|Date|location|Math|document|element|name|self|elements|setTimeout|navigator|status|String|escape|Number|submit|eval|Object|event|onblur|focus|onerror|onfocus|onclick|top|onload|toString|onunload|unescape|open|valueOf|window|onmouseover|innerHTML)\b/g, tag: '<u>$1</u>' }, // special words
|
||||
{ code: /([^:]|^)\/\/(.*?)(<br|<\/P)/gi, tag: '$1<i>//$2</i>$3' }, // comments //
|
||||
{ code: /\/\*(.*?)\*\//g, tag: '<i>/*$1*/</i>' } // comments / * */
|
||||
];
|
||||
//End Borrowed Content
|
||||
|
||||
|
||||
if ( cfg["toggleButton"] ) {
|
||||
var editor = this;
|
||||
|
||||
// Add toggle button
|
||||
var button = document.createElement("input");
|
||||
|
||||
button.type = "button";
|
||||
button.value = "Toggle Editor";
|
||||
|
||||
Event.addListener( button, "click", function () {
|
||||
if ( editor.editorState == "off" ) {
|
||||
editor.editorState = "on";
|
||||
var fc = editor.get('element').previousSibling,
|
||||
el = editor.get('element');
|
||||
|
||||
Dom.setStyle(fc, 'position', 'static');
|
||||
Dom.setStyle(fc, 'top', '0');
|
||||
Dom.setStyle(fc, 'left', '0');
|
||||
Dom.setStyle(el, 'visibility', 'hidden');
|
||||
Dom.setStyle(el, 'top', '-9999px');
|
||||
Dom.setStyle(el, 'left', '-9999px');
|
||||
Dom.setStyle(el, 'position', 'absolute');
|
||||
editor.get('element_cont').addClass('yui-editor-container');
|
||||
YAHOO.log('Reset designMode on the Editor', 'info', 'example');
|
||||
editor._setDesignMode('on');
|
||||
YAHOO.log('Inject the HTML from the textarea into the editor', 'info', 'example');
|
||||
|
||||
// Escape HTML
|
||||
var div = document.createElement("div");
|
||||
var text = editor.get('textarea').value;
|
||||
// IE truncates whitespace internally, so go line by line
|
||||
var lines = text.split(/\n/);
|
||||
for ( var i = 0; i < lines.length; i++ ) {
|
||||
var line = lines[i];
|
||||
YAHOO.log( i + ": " + line, "info", "CodeEditor" );
|
||||
div.appendChild( document.createTextNode( line ) );
|
||||
div.appendChild( document.createElement( "br" ) );
|
||||
}
|
||||
var html = div.innerHTML;
|
||||
// We have <br>, not \n
|
||||
html = html.replace(/\n/g,"");
|
||||
|
||||
YAHOO.log( html, "info", "CodeEditor" );
|
||||
editor.setEditorHTML(html);
|
||||
editor.highlight();
|
||||
}
|
||||
else {
|
||||
editor.editorState = "off";
|
||||
editor.saveHTML();
|
||||
var fc = editor.get('element').previousSibling,
|
||||
el = editor.get('element');
|
||||
|
||||
Dom.setStyle(fc, 'position', 'absolute');
|
||||
Dom.setStyle(fc, 'top', '-9999px');
|
||||
Dom.setStyle(fc, 'left', '-9999px');
|
||||
editor.get('element_cont').removeClass('yui-editor-container');
|
||||
Dom.setStyle(el, 'visibility', 'visible');
|
||||
Dom.setStyle(el, 'top', '');
|
||||
Dom.setStyle(el, 'left', '');
|
||||
Dom.setStyle(el, 'position', 'static');
|
||||
|
||||
// Unescape HTML
|
||||
var div = document.createElement("div");
|
||||
var text = editor.getEditorText();
|
||||
// IE truncates all whitespace internally, so add HTML for it
|
||||
if ( editor.browser.ie && editor.browser.ie <= 8 ) {
|
||||
text = text.replace(/\n/g, " <br>");
|
||||
text = text.replace(/\t/g, " ");
|
||||
}
|
||||
div.innerHTML = text;
|
||||
editor.get('element').value = "";
|
||||
for ( var i = 0; i < div.childNodes.length; i++ ) {
|
||||
if ( div.childNodes[i].nodeName == "#text" ) {
|
||||
editor.get('element').value = editor.get('element').value
|
||||
+ div.childNodes[i].nodeValue
|
||||
+ "\n"
|
||||
;
|
||||
}
|
||||
}
|
||||
YAHOO.log( editor.getEditorText(), "info", "CodeEditor" );
|
||||
YAHOO.log( div.childNodes[0].nodeValue, "info", "CodeEditor" );
|
||||
YAHOO.log( editor.get('element').value, "info", "CodeEditor" );
|
||||
}
|
||||
} );
|
||||
|
||||
// Put it right after the text area
|
||||
var ta = document.getElementById( id );
|
||||
if ( ta.nextSibling ) {
|
||||
ta.parentNode.insertBefore( button, ta.nextSibling );
|
||||
}
|
||||
else {
|
||||
ta.parentNode.appendChild( button );
|
||||
}
|
||||
}
|
||||
};
|
||||
Lang.extend( YAHOO.widget.CodeEditor, YAHOO.widget.SimpleEditor, {
|
||||
/**
|
||||
* @property _defaultCSS
|
||||
* @description The default CSS used in the config for 'css'. This way you can add to the config like this: { css: YAHOO.widget.SimpleEditor.prototype._defaultCSS + 'ADD MYY CSS HERE' }
|
||||
* @type String
|
||||
*/
|
||||
_defaultCSS: 'html { height: 95%; } body { background-color: #fff; font:13px/1.22 arial,helvetica,clean,sans-serif;*font-size:small;*font:x-small; } a, a:visited, a:hover { color: blue !important; text-decoration: underline !important; cursor: text !important; } .warning-localfile { border-bottom: 1px dashed red !important; } .yui-busy { cursor: wait !important; } img.selected { border: 2px dotted #808080; } img { cursor: pointer !important; border: none; } body.ptags.webkit div { margin: 11px 0; }'
|
||||
});
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @method _cleanIncomingHTML
|
||||
* @description Clean up the HTML that the textarea starts with
|
||||
*/
|
||||
YAHOO.widget.CodeEditor.prototype._cleanIncomingHTML = function(str) {
|
||||
// Workaround for bug in Lang.substitute
|
||||
str = str.replace(/{/gi, 'RIGHT_BRACKET');
|
||||
str = str.replace(/}/gi, 'LEFT_BRACKET');
|
||||
|
||||
// before <br> for IE8- so lines show up correctly
|
||||
if ( this.browser.ie && this.browser.ie <= 8 ) {
|
||||
str = str.replace(/\r?\n/g, " <br>");
|
||||
}
|
||||
|
||||
// Fix tabs into softtabs
|
||||
str = str.replace(/\t/g, ' '); // TODO: Make softtabs configurable
|
||||
|
||||
return str;
|
||||
};
|
||||
|
||||
/* Override to fix problem with the rest of what the normal _handleFormSubmit does
|
||||
* ( it doesn't properly click the correct submit button )
|
||||
*/
|
||||
YAHOO.widget.CodeEditor.prototype._handleFormSubmit = function () {
|
||||
if ( this.editorState == "on" ) {
|
||||
this.saveHTML();
|
||||
}
|
||||
return;
|
||||
};
|
||||
/* End override to fix problem */
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @method _writeStatus
|
||||
* @description Write the number of Characters and Lines to the status line
|
||||
*/
|
||||
YAHOO.widget.CodeEditor.prototype._writeStatus = function () {
|
||||
if ( this.status ) {
|
||||
var text = this.getEditorText();
|
||||
this.status.innerHTML
|
||||
= 'C: ' + text.length
|
||||
+ ' L: ' + text.split(/\r?\n/).length
|
||||
;
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @private
|
||||
* @method _setupResize
|
||||
* @description Creates the Resize instance and binds its events.
|
||||
*/
|
||||
YAHOO.widget.CodeEditor.prototype._setupResize
|
||||
= function() {
|
||||
if (!YAHOO.util.DD || !YAHOO.util.Resize) { return false; }
|
||||
if (this.get('resize')) {
|
||||
var config = {};
|
||||
Lang.augmentObject(config, this._resizeConfig); //Break the config reference
|
||||
this.resize = new YAHOO.util.Resize(this.get('element_cont').get('element'), config);
|
||||
this.resize.on('resize', function(args) {
|
||||
var anim = this.get('animate');
|
||||
this.set('animate', false);
|
||||
this.set('width', args.width + 'px');
|
||||
var h = args.height,
|
||||
th = (this.toolbar.get('element').clientHeight + 2),
|
||||
dh = 0;
|
||||
if (this.status) {
|
||||
dh = (this.status.clientHeight + 1); //It has a 1px top border..
|
||||
}
|
||||
var newH = (h - th - dh);
|
||||
this.set('height', newH + 'px');
|
||||
this.get('element_cont').setStyle('height', '');
|
||||
this.set('animate', anim);
|
||||
}, this, true);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* @method cleanHTML
|
||||
* @description Reduce the HTML in the editor to plain text to be put back in the
|
||||
* textarea. Called by saveHTML()
|
||||
*/
|
||||
YAHOO.widget.CodeEditor.prototype.cleanHTML = function (html) {
|
||||
if (!html) {
|
||||
html = this.getEditorHTML();
|
||||
}
|
||||
|
||||
// Handle special-case HTML
|
||||
html = html.replace(/( ){4}/g,"\t"); // TODO: make softtabs configurable
|
||||
html = html.replace(/ /g," ");
|
||||
// Remove spaces at end of lines
|
||||
html = html.replace(/ ?<br>/gi,'\n');
|
||||
|
||||
// Parse the text out of the remaining HTML
|
||||
text = "";
|
||||
HTMLParser( html, {
|
||||
chars : function (t) { text += t }
|
||||
} );
|
||||
|
||||
// If, after all this, we are left with only a \n, user didn't add anything
|
||||
// (editor adds a <br> if it starts blank)
|
||||
if ( text == "\n" ) {
|
||||
text = "";
|
||||
}
|
||||
|
||||
return text;
|
||||
};
|
||||
|
||||
/*
|
||||
* @method focusCaret
|
||||
* @description I don't actually know what this does, it was like this when I got here
|
||||
*/
|
||||
YAHOO.widget.CodeEditor.prototype.focusCaret = function() {
|
||||
if (this.browser.gecko) {
|
||||
if (this._getWindow().find(this.cc)) {
|
||||
this._getSelection().getRangeAt(0).deleteContents();
|
||||
}
|
||||
} else if (this.browser.webkit || this.browser.ie || this.browser.opera) {
|
||||
var cur = this._getDoc().getElementById('cur');
|
||||
if ( cur ) {
|
||||
cur.id = '';
|
||||
cur.innerHTML = '';
|
||||
this._selectNode(cur);
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @method getEditorText
|
||||
* @description Get the text inside the editor, removing any HTML used for highlighting
|
||||
*/
|
||||
YAHOO.widget.CodeEditor.prototype.getEditorText
|
||||
= function () {
|
||||
var html = this.getEditorHTML();
|
||||
var text = this.cleanHTML( html );
|
||||
return text;
|
||||
};
|
||||
|
||||
/**
|
||||
* @method highlight
|
||||
* @description Apply the syntax highlighting to the content of the editor
|
||||
* @param {Boolean} focus If true, editor currently has focus
|
||||
*/
|
||||
YAHOO.widget.CodeEditor.prototype.highlight = function(focus) {
|
||||
|
||||
// Opera support is not working yet
|
||||
if ( this.browser.opera ) {
|
||||
return;
|
||||
}
|
||||
// Firefox < 3 support is not working yet
|
||||
if ( this.browser.gecko && this.browser.gecko <= 1.8 ) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Keep track of where the cursor is right now
|
||||
if (!focus) {
|
||||
if (this.browser.gecko) {
|
||||
this._getSelection().getRangeAt(0).insertNode(this._getDoc().createTextNode(this.cc));
|
||||
} else if (this.browser.webkit || this.browser.ie || this.browser.opera) {
|
||||
try {
|
||||
this.execCommand('inserthtml', this.cc);
|
||||
}
|
||||
catch (e) {}
|
||||
}
|
||||
}
|
||||
|
||||
// Remove existing highlighting
|
||||
var html = this.getEditorText();
|
||||
|
||||
// Fix line breaks
|
||||
html = html.replace( /\t/g, " " );
|
||||
if ( this.browser.ie ) {
|
||||
html = html.replace( /\n/g, " <br>" );
|
||||
}
|
||||
else {
|
||||
html = html.replace( /\n/g, "<br>");
|
||||
}
|
||||
|
||||
// Apply new highlighting
|
||||
for (var i = 0; i < this.keywords.length; i++) {
|
||||
html = html.replace(this.keywords[i].code, this.keywords[i].tag);
|
||||
}
|
||||
|
||||
// Replace cursor
|
||||
if ( !this.browser.gecko ) {
|
||||
html = html.replace(this.cc, '<span id="cur">|</span>');
|
||||
}
|
||||
|
||||
this._getDoc().body.innerHTML = html;
|
||||
if (!focus) {
|
||||
this.focusCaret();
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* @method initAttributes
|
||||
* @description Initializes all of the configuration attributes used to create
|
||||
* the editor.
|
||||
* @param {Object} attr Object literal specifying a set of
|
||||
* configuration attributes used to create the editor.
|
||||
*/
|
||||
YAHOO.widget.CodeEditor.prototype.initAttributes
|
||||
= function(attr) {
|
||||
YAHOO.widget.CodeEditor.superclass.initAttributes.call(this, attr);
|
||||
var self = this;
|
||||
/**
|
||||
* @attribute status
|
||||
* @description Toggle the display of a status line below the editor
|
||||
* @default false
|
||||
* @type Boolean
|
||||
*/
|
||||
this.setAttributeConfig('status', {
|
||||
value: attr.status || false,
|
||||
method: function(status) {
|
||||
if (status && !this.status) {
|
||||
this.status = document.createElement('DIV');
|
||||
this.status.id = this.get('id') + '_status';
|
||||
Dom.addClass(this.status, 'dompath'); // Piggy-back on Editor's dompath
|
||||
this.get('element_cont').get('firstChild').appendChild(this.status);
|
||||
if (this.get('iframe')) {
|
||||
this._writeStatus();
|
||||
}
|
||||
} else if (!status && this.status) {
|
||||
this.status.parentNode.removeChild(this.status);
|
||||
this.status = null;
|
||||
}
|
||||
}
|
||||
});
|
||||
/**
|
||||
* @attribute css_url
|
||||
* @description The URL to the CSS file for the inside of the code editor
|
||||
* @default 'code.css'
|
||||
* @type String
|
||||
*/
|
||||
this.setAttributeConfig('css_url', {
|
||||
value: attr.css_url || 'code.css'
|
||||
} );
|
||||
};
|
||||
|
||||
})();
|
||||
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
body { background:white url(line-numbers.png) repeat-y scroll 0pt -4px; font-family:monospace; font-size:13px; height:100%; line-height:16px; margin-left:32px; margin-top:8px; white-space:pre; }
|
||||
b, i, s, u, a, em, tt, ins, big, cite, strong, var, dfn {text-decoration:none;font-weight:normal;font-style:normal;font-size:13px;}
|
||||
b, cite {color:#7F0055;font-weight:bold;} /* reserved words */
|
||||
u {color:darkblue;font-weight:bold;} /* special words */
|
||||
i, i b, i s, i u {color:green;font-weight:normal;} /* comments */
|
||||
s, s b, s u {color:#2A00FF;font-weight:normal;} /* strings */
|
||||
ins, ins b, ins s, ins em {color:green;} /* comments */
|
||||
a {color:blue; text-decoration: underline; } /* links */
|
||||
body.ie { padding-left: 32px; margin-left: 0px; background-position: 0 -10px; margin-top: 0px;}
|
||||
Binary file not shown.
|
Before Width: | Height: | Size: 16 KiB |
Loading…
Add table
Add a link
Reference in a new issue