Changeset 3947
- Timestamp:
- 05/20/09 17:25:22 (3 years ago)
- Location:
- trunk
- Files:
-
- 233 edited
-
BehaviourContrib/lib/Foswiki/Contrib/BehaviourContrib.pm (modified) (1 diff)
-
EditTablePlugin/lib/Foswiki/Plugins/EditTablePlugin.pm (modified) (2 diffs)
-
EditTablePlugin/lib/Foswiki/Plugins/EditTablePlugin/Core.pm (modified) (5 diffs)
-
EditTablePlugin/test/unit/EditTablePlugin/EditTablePluginTests.pm (modified) (1 diff)
-
InterwikiPlugin/lib/Foswiki/Plugins/InterwikiPlugin.pm (modified) (2 diffs)
-
MailerContrib/lib/Foswiki/Contrib/MailerContrib.pm (modified) (1 diff)
-
PreferencesPlugin/lib/Foswiki/Plugins/PreferencesPlugin.pm (modified) (16 diffs)
-
RenderListPlugin/lib/Foswiki/Plugins/RenderListPlugin.pm (modified) (11 diffs)
-
SlideShowPlugin/lib/Foswiki/Plugins/SlideShowPlugin.pm (modified) (1 diff)
-
SmiliesPlugin/lib/Foswiki/Plugins/SmiliesPlugin.pm (modified) (1 diff)
-
SpreadSheetPlugin/lib/Foswiki/Plugins/SpreadSheetPlugin.pm (modified) (3 diffs)
-
SpreadSheetPlugin/lib/Foswiki/Plugins/SpreadSheetPlugin/Calc.pm (modified) (28 diffs)
-
TablePlugin/lib/Foswiki/Plugins/TablePlugin.pm (modified) (3 diffs)
-
TablePlugin/lib/Foswiki/Plugins/TablePlugin/Core.pm (modified) (1 diff)
-
TinyMCEPlugin/lib/Foswiki/Plugins/TinyMCEPlugin.pm (modified) (3 diffs)
-
TwistyPlugin/lib/Foswiki/Plugins/TwistyPlugin.pm (modified) (4 diffs)
-
WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin.pm (modified) (2 diffs)
-
WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML.pm (modified) (1 diff)
-
WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm (modified) (1 diff)
-
WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/WC.pm (modified) (1 diff)
-
WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm (modified) (1 diff)
-
WysiwygPlugin/test/unit/WysiwygPlugin/TranslatorTests.pm (modified) (10 diffs)
-
core/lib/Assert.pm (modified) (3 diffs)
-
core/lib/Foswiki.pm (modified) (3 diffs)
-
core/lib/Foswiki/AccessControlException.pm (modified) (1 diff)
-
core/lib/Foswiki/AggregateIterator.pm (modified) (1 diff)
-
core/lib/Foswiki/Attach.pm (modified) (1 diff)
-
core/lib/Foswiki/Compatibility.pm (modified) (4 diffs)
-
core/lib/Foswiki/Configure/Checker.pm (modified) (2 diffs)
-
core/lib/Foswiki/Configure/Checkers/AuthScripts.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/BasicSanity.pm (modified) (4 diffs)
-
core/lib/Foswiki/Configure/Checkers/CGISetup.pm (modified) (2 diffs)
-
core/lib/Foswiki/Configure/Checkers/ConfigurationLogName.pm (modified) (3 diffs)
-
core/lib/Foswiki/Configure/Checkers/DataDir.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/DebugFileName.pm (modified) (2 diffs)
-
core/lib/Foswiki/Configure/Checkers/DefaultUrlHost.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/DispScriptUrlPath.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/Environment.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/Htpasswd/Encoding.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/Htpasswd/FileName.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/LocalesDir.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/LogFileName.pm (modified) (2 diffs)
-
core/lib/Foswiki/Configure/Checkers/LoginManager.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/LoginNameFilterIn.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/LowerNational.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/MailProgram.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/MimeTypesFileName.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/MinPasswordLength.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/NameFilter.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/OS.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/PubDir.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/PubUrlPath.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/RCS/EgrepCmd.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/RCS/ExtOption.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/RCS/FgrepCmd.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/RCS/SearchAlgorithm.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/RCS/asciiFileSuffixes.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/RCS/ciCmd.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/RCS/ciDateCmd.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/RCS/coCmd.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/RCS/delRevCmd.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/RCS/diffCmd.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/RCS/histCmd.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/RCS/infoCmd.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/RCS/initBinaryCmd.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/RCS/initTextCmd.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/RCS/lockCmd.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/RCS/rlogDateCmd.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/RCS/tmpBinaryCmd.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/RCS/unlockCmd.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/Register/AllowLoginName.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/Register/NeedVerification.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/RegistrationApprovals.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/SafeEnvPath.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/ScriptSuffix.pm (modified) (2 diffs)
-
core/lib/Foswiki/Configure/Checkers/ScriptUrlPath.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/Sessions/ExpireAfter.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/Site/CharSet.pm (modified) (2 diffs)
-
core/lib/Foswiki/Configure/Checkers/Site/Locale.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/StoreImpl.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/TemplateDir.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/UploadFilter.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/UpperNational.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/UseClientSessions.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/UseLocale.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Checkers/WarningFileName.pm (modified) (2 diffs)
-
core/lib/Foswiki/Configure/Checkers/WebMasterEmail.pm (modified) (2 diffs)
-
core/lib/Foswiki/Configure/Checkers/WorkingDir.pm (modified) (3 diffs)
-
core/lib/Foswiki/Configure/FINDEXTENSIONS.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/FoswikiCfg.pm (modified) (2 diffs)
-
core/lib/Foswiki/Configure/LANGUAGES.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Load.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/PLUGINS.pm (modified) (2 diffs)
-
core/lib/Foswiki/Configure/Pluggable.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Root.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Section.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Types/BOOLEAN.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Types/COMMAND.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Types/LANGUAGE.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Types/NUMBER.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Types/OCTAL.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Types/PASSWORD.pm (modified) (2 diffs)
-
core/lib/Foswiki/Configure/Types/PATH.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Types/PERL.pm (modified) (3 diffs)
-
core/lib/Foswiki/Configure/Types/REGEX.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Types/SELECT.pm (modified) (2 diffs)
-
core/lib/Foswiki/Configure/Types/SELECTCLASS.pm (modified) (3 diffs)
-
core/lib/Foswiki/Configure/Types/STRING.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Types/UNKNOWN.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Types/URL.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Types/URLPATH.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/UI.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/UIs/AUTH.pm (modified) (4 diffs)
-
core/lib/Foswiki/Configure/UIs/EXTEND.pm (modified) (8 diffs)
-
core/lib/Foswiki/Configure/UIs/EXTENSIONS.pm (modified) (8 diffs)
-
core/lib/Foswiki/Configure/UIs/FINDEXTENSIONS.pm (modified) (2 diffs)
-
core/lib/Foswiki/Configure/UIs/LANGUAGES.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/UIs/PLUGINS.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/UIs/PasswordProtected.pm (modified) (2 diffs)
-
core/lib/Foswiki/Configure/UIs/Root.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/UIs/Section.pm (modified) (2 diffs)
-
core/lib/Foswiki/Configure/UIs/TAGS.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/UIs/UPDATE.pm (modified) (2 diffs)
-
core/lib/Foswiki/Configure/UIs/Value.pm (modified) (1 diff)
-
core/lib/Foswiki/Configure/Value.pm (modified) (1 diff)
-
core/lib/Foswiki/Engine.pm (modified) (2 diffs)
-
core/lib/Foswiki/Engine/CGI.pm (modified) (1 diff)
-
core/lib/Foswiki/Engine/CLI.pm (modified) (1 diff)
-
core/lib/Foswiki/EngineException.pm (modified) (1 diff)
-
core/lib/Foswiki/Form.pm (modified) (1 diff)
-
core/lib/Foswiki/Form/Checkbox.pm (modified) (1 diff)
-
core/lib/Foswiki/Form/Label.pm (modified) (1 diff)
-
core/lib/Foswiki/Form/ListFieldDefinition.pm (modified) (1 diff)
-
core/lib/Foswiki/Form/Radio.pm (modified) (2 diffs)
-
core/lib/Foswiki/Form/Select.pm (modified) (1 diff)
-
core/lib/Foswiki/Form/Text.pm (modified) (1 diff)
-
core/lib/Foswiki/Form/Textarea.pm (modified) (2 diffs)
-
core/lib/Foswiki/Func.pm (modified) (5 diffs)
-
core/lib/Foswiki/I18N.pm (modified) (1 diff)
-
core/lib/Foswiki/I18N/Extract.pm (modified) (2 diffs)
-
core/lib/Foswiki/I18N/Fallback.pm (modified) (1 diff)
-
core/lib/Foswiki/If/Node.pm (modified) (1 diff)
-
core/lib/Foswiki/If/OP_allows.pm (modified) (1 diff)
-
core/lib/Foswiki/If/OP_context.pm (modified) (1 diff)
-
core/lib/Foswiki/If/OP_defined.pm (modified) (1 diff)
-
core/lib/Foswiki/If/OP_dollar.pm (modified) (1 diff)
-
core/lib/Foswiki/If/OP_ingroup.pm (modified) (1 diff)
-
core/lib/Foswiki/If/OP_isempty.pm (modified) (1 diff)
-
core/lib/Foswiki/If/OP_istopic.pm (modified) (1 diff)
-
core/lib/Foswiki/If/OP_isweb.pm (modified) (1 diff)
-
core/lib/Foswiki/If/Parser.pm (modified) (1 diff)
-
core/lib/Foswiki/IncludeHandlers/http.pm (modified) (2 diffs)
-
core/lib/Foswiki/Infix/Error.pm (modified) (1 diff)
-
core/lib/Foswiki/Infix/Parser.pm (modified) (1 diff)
-
core/lib/Foswiki/Iterator.pm (modified) (1 diff)
-
core/lib/Foswiki/Iterator/FilterIterator.pm (modified) (2 diffs)
-
core/lib/Foswiki/Iterator/ProcessIterator.pm (modified) (1 diff)
-
core/lib/Foswiki/LineIterator.pm (modified) (1 diff)
-
core/lib/Foswiki/ListIterator.pm (modified) (3 diffs)
-
core/lib/Foswiki/Logger/PlainFile.pm (modified) (3 diffs)
-
core/lib/Foswiki/LoginManager.pm (modified) (1 diff)
-
core/lib/Foswiki/LoginManager/ApacheLogin.pm (modified) (1 diff)
-
core/lib/Foswiki/LoginManager/Session.pm (modified) (1 diff)
-
core/lib/Foswiki/LoginManager/TemplateLogin.pm (modified) (1 diff)
-
core/lib/Foswiki/Meta.pm (modified) (25 diffs)
-
core/lib/Foswiki/Net/UserCredAgent.pm (modified) (1 diff)
-
core/lib/Foswiki/OopsException.pm (modified) (1 diff)
-
core/lib/Foswiki/Prefs.pm (modified) (1 diff)
-
core/lib/Foswiki/Prefs/BaseBackend.pm (modified) (2 diffs)
-
core/lib/Foswiki/Prefs/HASH.pm (modified) (3 diffs)
-
core/lib/Foswiki/Prefs/Parser.pm (modified) (1 diff)
-
core/lib/Foswiki/Prefs/Stack.pm (modified) (2 diffs)
-
core/lib/Foswiki/Prefs/TopicRAM.pm (modified) (1 diff)
-
core/lib/Foswiki/Prefs/Web.pm (modified) (3 diffs)
-
core/lib/Foswiki/Query/Node.pm (modified) (1 diff)
-
core/lib/Foswiki/Query/OP_and.pm (modified) (1 diff)
-
core/lib/Foswiki/Query/OP_d2n.pm (modified) (1 diff)
-
core/lib/Foswiki/Query/OP_dot.pm (modified) (1 diff)
-
core/lib/Foswiki/Query/OP_eq.pm (modified) (1 diff)
-
core/lib/Foswiki/Query/OP_gt.pm (modified) (1 diff)
-
core/lib/Foswiki/Query/OP_gte.pm (modified) (1 diff)
-
core/lib/Foswiki/Query/OP_lc.pm (modified) (1 diff)
-
core/lib/Foswiki/Query/OP_length.pm (modified) (1 diff)
-
core/lib/Foswiki/Query/OP_like.pm (modified) (1 diff)
-
core/lib/Foswiki/Query/OP_lt.pm (modified) (1 diff)
-
core/lib/Foswiki/Query/OP_lte.pm (modified) (1 diff)
-
core/lib/Foswiki/Query/OP_ne.pm (modified) (1 diff)
-
core/lib/Foswiki/Query/OP_not.pm (modified) (1 diff)
-
core/lib/Foswiki/Query/OP_ob.pm (modified) (1 diff)
-
core/lib/Foswiki/Query/OP_or.pm (modified) (1 diff)
-
core/lib/Foswiki/Query/OP_ref.pm (modified) (1 diff)
-
core/lib/Foswiki/Query/OP_uc.pm (modified) (1 diff)
-
core/lib/Foswiki/Query/OP_where.pm (modified) (1 diff)
-
core/lib/Foswiki/Query/Parser.pm (modified) (1 diff)
-
core/lib/Foswiki/Render.pm (modified) (22 diffs)
-
core/lib/Foswiki/Request.pm (modified) (1 diff)
-
core/lib/Foswiki/Sandbox.pm (modified) (1 diff)
-
core/lib/Foswiki/Search.pm (modified) (32 diffs)
-
core/lib/Foswiki/Search/InfoCache.pm (modified) (6 diffs)
-
core/lib/Foswiki/Search/Node.pm (modified) (2 diffs)
-
core/lib/Foswiki/Search/Parser.pm (modified) (3 diffs)
-
core/lib/Foswiki/Store/QueryAlgorithms/BruteForce.pm (modified) (4 diffs)
-
core/lib/Foswiki/Store/RcsLite.pm (modified) (1 diff)
-
core/lib/Foswiki/Store/RcsLiteHandler.pm (modified) (1 diff)
-
core/lib/Foswiki/Store/RcsWrap.pm (modified) (1 diff)
-
core/lib/Foswiki/Store/RcsWrapHandler.pm (modified) (2 diffs)
-
core/lib/Foswiki/Store/SearchAlgorithms/Forking.pm (modified) (8 diffs)
-
core/lib/Foswiki/Store/SearchAlgorithms/PurePerl.pm (modified) (5 diffs)
-
core/lib/Foswiki/Store/VCHandler.pm (modified) (16 diffs)
-
core/lib/Foswiki/Store/VCStore.pm (modified) (22 diffs)
-
core/lib/Foswiki/Time.pm (modified) (1 diff)
-
core/lib/Foswiki/UI.pm (modified) (8 diffs)
-
core/lib/Foswiki/UI/ChangeForm.pm (modified) (1 diff)
-
core/lib/Foswiki/UI/Changes.pm (modified) (1 diff)
-
core/lib/Foswiki/UI/Edit.pm (modified) (1 diff)
-
core/lib/Foswiki/UI/Manage.pm (modified) (5 diffs)
-
core/lib/Foswiki/UI/Passwords.pm (modified) (1 diff)
-
core/lib/Foswiki/UI/Preview.pm (modified) (1 diff)
-
core/lib/Foswiki/UI/RDiff.pm (modified) (7 diffs)
-
core/lib/Foswiki/UI/Register.pm (modified) (3 diffs)
-
core/lib/Foswiki/UI/Rename.pm (modified) (29 diffs)
-
core/lib/Foswiki/UI/Rest.pm (modified) (9 diffs)
-
core/lib/Foswiki/UI/Save.pm (modified) (5 diffs)
-
core/lib/Foswiki/UI/Statistics.pm (modified) (1 diff)
-
core/lib/Foswiki/UI/Upload.pm (modified) (1 diff)
-
core/lib/Foswiki/UI/View.pm (modified) (2 diffs)
-
core/lib/Foswiki/UI/Viewfile.pm (modified) (2 diffs)
-
core/lib/Foswiki/Users.pm (modified) (2 diffs)
-
core/lib/Foswiki/Users/ApacheHtpasswdUser.pm (modified) (1 diff)
-
core/lib/Foswiki/Users/BaseUserMapping.pm (modified) (1 diff)
-
core/lib/Foswiki/Users/HtPasswdUser.pm (modified) (2 diffs)
-
core/lib/Foswiki/Validation.pm (modified) (9 diffs)
-
core/lib/Foswiki/ValidationException.pm (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/BehaviourContrib/lib/Foswiki/Contrib/BehaviourContrib.pm
r3944 r3947 28 28 my $base = '%PUBURLPATH%/%SYSTEMWEB%/BehaviourContrib'; 29 29 my $USE_SRC = 30 Foswiki::Func::getPreferencesValue('BEHAVIOURCONTRIB_DEBUG') ? 31 '_src' : ''; 30 Foswiki::Func::getPreferencesValue('BEHAVIOURCONTRIB_DEBUG') 31 ? '_src' 32 : ''; 32 33 my $head = <<HERE; 33 34 <script type='text/javascript' src='$base/behaviour$USE_SRC.js'></script> -
trunk/EditTablePlugin/lib/Foswiki/Plugins/EditTablePlugin.pm
r3498 r3947 26 26 our $RELEASE = '4.23'; 27 27 28 our $pluginName = 'EditTablePlugin';29 our $ENCODE_START = '--EditTableEncodeStart--';30 our $ENCODE_END = '--EditTableEncodeEnd--';31 our $ASSET_URL = '%PUBURL%/%SYSTEMWEB%/EditTablePlugin';28 our $pluginName = 'EditTablePlugin'; 29 our $ENCODE_START = '--EditTableEncodeStart--'; 30 our $ENCODE_END = '--EditTableEncodeEnd--'; 31 our $ASSET_URL = '%PUBURL%/%SYSTEMWEB%/EditTablePlugin'; 32 32 our $NO_PREFS_IN_TOPIC = 1; 33 our $SHORTDESCRIPTION = 'Edit tables using edit fields, date pickers and drop down boxes'; 33 our $SHORTDESCRIPTION = 34 'Edit tables using edit fields, date pickers and drop down boxes'; 34 35 our $web; 35 36 our $topic; … … 60 61 $usesJavascriptInterface = 61 62 Foswiki::Func::getPreferencesFlag('EDITTABLEPLUGIN_JAVASCRIPTINTERFACE') 62 || 1;63 || 1; 63 64 $viewModeHeaderDone = 0; 64 65 $editModeHeaderDone = 0; -
trunk/EditTablePlugin/lib/Foswiki/Plugins/EditTablePlugin/Core.pm
r3761 r3947 171 171 # Item1458 ignore all saving unless it happened using POST method. 172 172 $doSave = 0 173 if ( $query && $query->method() && uc( $query->method()) ne 'POST' );173 if ( $query && $query->method() && uc( $query->method() ) ne 'POST' ); 174 174 175 175 if ($Foswiki::Plugins::EditTablePlugin::debug) { … … 529 529 # to TABLE for exactly this purpose. Please to not remove this 530 530 # feature again. 531 if ( $doEdit && !$doSave && ( $paramTableNr == $tableNr ) && 532 ( $editTableTag !~ /%TABLE{.*?disableallsort="on".*?}%/ ) ) { 531 if ( $doEdit 532 && !$doSave 533 && ( $paramTableNr == $tableNr ) 534 && ( $editTableTag !~ /%TABLE{.*?disableallsort="on".*?}%/ ) ) 535 { 533 536 $editTableTag =~ s/(%TABLE{.*?)(}%)/$1 disableallsort="on"$2/; 534 } 535 537 } 538 536 539 # The Data::parseText merges a TABLE and EDITTABLE to one line 537 540 # We split it again to make editing easier for the user … … 644 647 $prefEDIT_BUTTON = 645 648 Foswiki::Func::getPreferencesValue("\U$pluginName\E_EDIT_BUTTON") 646 || '%MAKETEXT{"Edit this table"}%, %ATTACHURL%/edittable.gif';649 || '%MAKETEXT{"Edit this table"}%, %ATTACHURL%/edittable.gif'; 647 650 648 651 $prefSAVE_BUTTON = … … 661 664 "\U$pluginName\E_DELETE_LAST_ROW_BUTTON") 662 665 || '%MAKETEXT{"Delete last row"}%'; 663 666 664 667 $prefCANCEL_BUTTON = 665 668 Foswiki::Func::getPreferencesValue("\U$pluginName\E_CANCEL_BUTTON") 666 669 || '%MAKETEXT{"Cancel"}%'; 667 670 668 671 $prefMESSAGE_INCLUDED_TOPIC_DOES_NOT_EXIST = 669 672 Foswiki::Func::getPreferencesValue( … … 767 770 my $iTopic = Foswiki::Func::extractNameValuePair( $theArgs, 'include' ); 768 771 if ($iTopic) { 769 ($inWeb, $iTopic) = Foswiki::Func::normalizeWebTopicName($inWeb, $iTopic); 770 771 unless (Foswiki::Func::topicExists( $inWeb, $iTopic )) { 772 ( $inWeb, $iTopic ) = 773 Foswiki::Func::normalizeWebTopicName( $inWeb, $iTopic ); 774 775 unless ( Foswiki::Func::topicExists( $inWeb, $iTopic ) ) { 772 776 $warningMessage = $prefMESSAGE_INCLUDED_TOPIC_DOES_NOT_EXIST; 773 } else { 777 } 778 else { 774 779 775 780 my $text = Foswiki::Func::readTopicText( $inWeb, $iTopic ); -
trunk/EditTablePlugin/test/unit/EditTablePlugin/EditTablePluginTests.pm
r3790 r3947 975 975 my ( $meta, $newtext ) = Foswiki::Func::readTopic( $webName, $topicName ); 976 976 977 # Expected is that saving causes the TABLE and EDITTABLE tags to be saved on two lines.977 # Expected is that saving causes the TABLE and EDITTABLE tags to be saved on two lines. 978 978 my $expected = <<NEWEXPECTED; 979 979 %TABLE{columnwidths="80,80,50,110,150,50,50,50,50,50,70,70,50" dataalign="left,left,center,left,left,center,center,center,center,center,center,right,right,center" headeralign="center" headerrows="1" footerrows="1" headerislabel="on"}% -
trunk/InterwikiPlugin/lib/Foswiki/Plugins/InterwikiPlugin.pm
r3455 r3947 38 38 use strict; 39 39 40 use Foswiki::Func ();# The plugins API40 use Foswiki::Func (); # The plugins API 41 41 use Foswiki::Plugins (); # For the API version 42 42 43 our $VERSION = '$Rev$';44 our $RELEASE = '15 Apr 2009';43 our $VERSION = '$Rev$'; 44 our $RELEASE = '15 Apr 2009'; 45 45 our $NO_PREFS_IN_TOPIC = 1; 46 our $SHORTDESCRIPTION = 'Link ExternalSite:Page text to external sites based on aliases defined in a rules topic'; 46 our $SHORTDESCRIPTION = 47 'Link ExternalSite:Page text to external sites based on aliases defined in a rules topic'; 47 48 48 49 our $interLinkFormat; … … 75 76 || '<a class="interwikiLink" href="$url" title="$tooltip"><noautolink>$label</noautolink></a>'; 76 77 77 my ( $interWeb, $interTopic) =78 Foswiki::Func::normalizeWebTopicName(79 $installWeb,80 Foswiki::Func::getPreferencesValue('INTERWIKIPLUGIN_RULESTOPIC')81 || 'InterWikis');78 my ( $interWeb, $interTopic ) = Foswiki::Func::normalizeWebTopicName( 79 $installWeb, 80 Foswiki::Func::getPreferencesValue('INTERWIKIPLUGIN_RULESTOPIC') 81 || 'InterWikis' 82 ); 82 83 83 84 my $text = Foswiki::Func::readTopicText( $interWeb, $interTopic, undef, 1 ); -
trunk/MailerContrib/lib/Foswiki/Contrib/MailerContrib.pm
r3944 r3947 18 18 use CGI qw(-any); 19 19 20 use Foswiki ();21 use Foswiki::Plugins ();22 use Foswiki::Time ();23 use Foswiki::Func ();20 use Foswiki (); 21 use Foswiki::Plugins (); 22 use Foswiki::Time (); 23 use Foswiki::Func (); 24 24 use Foswiki::Contrib::MailerContrib::WebNotify (); 25 use Foswiki::Contrib::MailerContrib::Change ();26 use Foswiki::Contrib::MailerContrib::UpData ();25 use Foswiki::Contrib::MailerContrib::Change (); 26 use Foswiki::Contrib::MailerContrib::UpData (); 27 27 28 28 our $VERSION = '$Rev$'; -
trunk/PreferencesPlugin/lib/Foswiki/Plugins/PreferencesPlugin.pm
r3945 r3947 26 26 use strict; 27 27 28 use Foswiki::Func (); # The plugins API29 use Foswiki::Plugins (); # For the API version28 use Foswiki::Func (); # The plugins API 29 use Foswiki::Plugins (); # For the API version 30 30 31 31 use vars qw( @shelter ); … … 33 33 our $VERSION = '$Rev$'; 34 34 our $RELEASE = '19 Apr 2009'; 35 our $SHORTDESCRIPTION = 'Allows editing of preferences using fields predefined in a form'; 35 our $SHORTDESCRIPTION = 36 'Allows editing of preferences using fields predefined in a form'; 36 37 our $NO_PREFS_IN_TOPIC = 1; 37 38 … … 39 40 40 41 # Markers used during form generation 41 my $START_MARKER = $MARKER.'STARTPREF'.$MARKER;42 my $END_MARKER = $MARKER.'ENDPREF'.$MARKER;42 my $START_MARKER = $MARKER . 'STARTPREF' . $MARKER; 43 my $END_MARKER = $MARKER . 'ENDPREF' . $MARKER; 43 44 44 45 sub initPlugin { 46 45 47 # check for Plugins.pm versions 46 if( $Foswiki::Plugins::VERSION < 1.026 ) { 47 Foswiki::Func::writeWarning( 'Version mismatch between PreferencesPlugin and Plugins.pm' ); 48 if ( $Foswiki::Plugins::VERSION < 1.026 ) { 49 Foswiki::Func::writeWarning( 50 'Version mismatch between PreferencesPlugin and Plugins.pm'); 48 51 return 0; 49 52 } … … 56 59 ### my ( $text, $topic, $web ) = @_; 57 60 my $topic = $_[1]; 58 my $web = $_[2];61 my $web = $_[2]; 59 62 return unless ( $_[0] =~ m/%EDITPREFERENCES(?:{(.*?)})?%/ ); 60 63 … … 62 65 require Foswiki::Attrs; 63 66 my $formDef; 64 my $attrs = new Foswiki::Attrs( $1);65 if ( defined( $attrs->{_DEFAULT} )) {66 my ( $formWeb, $form ) = Foswiki::Func::normalizeWebTopicName(67 $web, $attrs->{_DEFAULT} );67 my $attrs = new Foswiki::Attrs($1); 68 if ( defined( $attrs->{_DEFAULT} ) ) { 69 my ( $formWeb, $form ) = 70 Foswiki::Func::normalizeWebTopicName( $web, $attrs->{_DEFAULT} ); 68 71 69 72 # SMELL: Unpublished API. No choice, though :-( … … 75 78 my $query = Foswiki::Func::getCgiQuery(); 76 79 77 my $action = lc( $query->param( 'prefsaction' ));78 $query->Delete( 'prefsaction');80 my $action = lc( $query->param('prefsaction') ); 81 $query->Delete('prefsaction'); 79 82 $action =~ s/\s.*$//; 80 83 … … 83 86 84 87 # Replace setting values by form fields but not inside comments Item4816 85 my $outtext = '';88 my $outtext = ''; 86 89 my $insidecomment = 0; 87 foreach my $token ( split /(<!--|-->)/, $_[0] ) {90 foreach my $token ( split /(<!--|-->)/, $_[0] ) { 88 91 if ( $token =~ /<!--/ ) { 89 92 $insidecomment++; 90 } elsif ( $token =~ /-->/ ) { 93 } 94 elsif ( $token =~ /-->/ ) { 91 95 $insidecomment-- if ( $insidecomment > 0 ); 92 } elsif ( !$insidecomment ) { 93 $token =~ s(^((?:\t| )+\*\s(Set|Local)\s*)(\w+)\s*\=(.*$(\n[ \t]+[^\s*].*$)*)) 96 } 97 elsif ( !$insidecomment ) { 98 $token =~ 99 s(^((?:\t| )+\*\s(Set|Local)\s*)(\w+)\s*\=(.*$(\n[ \t]+[^\s*].*$)*)) 94 100 ($1._generateEditField($web, $topic, $3, $4, $formDef))gem; 95 101 } … … 100 106 $_[0] =~ s/%EDITPREFERENCES({.*?})?%/ 101 107 _generateControlButtons($web, $topic)/ge; 102 my $viewUrl = Foswiki::Func::getScriptUrl( 103 $web, $topic, 'viewauth' ); 108 my $viewUrl = Foswiki::Func::getScriptUrl( $web, $topic, 'viewauth' ); 104 109 my $startForm = CGI::start_form( 105 -name => 'editpreferences',110 -name => 'editpreferences', 106 111 -method => 'post', 107 -action => $viewUrl ); 112 -action => $viewUrl 113 ); 108 114 $startForm =~ s/\s+$//s; 109 115 my $endForm = CGI::end_form(); 110 116 $endForm =~ s/\s+$//s; 111 $_[0] =~ s/^(.*?)$START_MARKER(.*)$END_MARKER(.*?)$/$1$startForm$2$endForm$3/s; 117 $_[0] =~ 118 s/^(.*?)$START_MARKER(.*)$END_MARKER(.*?)$/$1$startForm$2$endForm$3/s; 112 119 $_[0] =~ s/$START_MARKER|$END_MARKER//gs; 113 120 } 114 121 115 if ( $action eq 'cancel' ) {122 if ( $action eq 'cancel' ) { 116 123 Foswiki::Func::setTopicEditLock( $web, $topic, 0 ); 117 124 118 } elsif( $action eq 'save' ) { 125 } 126 elsif ( $action eq 'save' ) { 119 127 120 128 # Make sure the request came from POST 121 if ( $query && $query->method() && uc($query->method()) ne 'POST' ) { 129 if ( $query && $query->method() && uc( $query->method() ) ne 'POST' ) { 130 122 131 # silently ignore it if the request didn't come from a POST 123 } else { 124 my( $meta, $text ) = Foswiki::Func::readTopic( $web, $topic ); 132 } 133 else { 134 my ( $meta, $text ) = Foswiki::Func::readTopic( $web, $topic ); 135 125 136 # SMELL: unchecked implicit untaint of value? 126 137 $text =~ s(^((?:\t| )+\*\s(Set|Local)\s)(\w+)\s\=\s(.*)$) … … 129 140 } 130 141 Foswiki::Func::setTopicEditLock( $web, $topic, 0 ); 142 131 143 # Finish with a redirect so that the *new* values are seen 132 144 my $viewUrl = Foswiki::Func::getScriptUrl( $web, $topic, 'view' ); … … 134 146 return; 135 147 } 148 136 149 # implicit action="view", or drop through from "save" or "cancel" 137 150 $_[0] =~ s/%EDITPREFERENCES({.*?})?%/_generateEditButton($web, $topic)/ge; … … 148 161 # Pluck the default value of a named field from a form definition 149 162 sub _getField { 150 my ( $formDef, $name ) = @_;151 foreach my $f ( @{ $formDef->{fields}} ) {152 if ( $f->{name} eq $name ) {163 my ( $formDef, $name ) = @_; 164 foreach my $f ( @{ $formDef->{fields} } ) { 165 if ( $f->{name} eq $name ) { 153 166 return $f; 154 167 } … … 161 174 # extra edit types defined in other plugins. 162 175 sub _generateEditField { 163 my ( $web, $topic, $name, $value, $formDef ) = @_;176 my ( $web, $topic, $name, $value, $formDef ) = @_; 164 177 $value =~ s/^\s*(.*?)\s*$/$1/ge; 165 178 166 my ( $extras, $html);167 168 if ( $formDef) {179 my ( $extras, $html ); 180 181 if ($formDef) { 169 182 my $fieldDef; 170 if (defined(&Foswiki::Form::getField)) { 183 if ( defined(&Foswiki::Form::getField) ) { 184 171 185 # TWiki 4.2 and later 172 $fieldDef = $formDef->getField( $name ); 173 } else { 186 $fieldDef = $formDef->getField($name); 187 } 188 else { 189 174 190 # TWiki < 4.2 175 191 $fieldDef = _getField( $formDef, $name ); 176 192 } 177 if ( $fieldDef ) { 178 if( defined(&Foswiki::Form::renderFieldForEdit)) { 193 if ($fieldDef) { 194 if ( defined(&Foswiki::Form::renderFieldForEdit) ) { 195 179 196 # TWiki < 4.2 SMELL: use of unpublished core function 180 197 ( $extras, $html ) = 181 $formDef->renderFieldForEdit( $fieldDef, $web, $topic, $value); 182 } else { 198 $formDef->renderFieldForEdit( $fieldDef, $web, $topic, 199 $value ); 200 } 201 else { 202 183 203 # TWiki 4.2 and later SMELL: use of unpublished core function 184 204 ( $extras, $html ) = … … 187 207 } 188 208 } 189 unless( $html ) { 209 unless ($html) { 210 190 211 # No form definition, default to text field. 191 $html = CGI::textfield( -class=>'foswikiAlert foswikiInputField', 192 -name => $name, 193 -size => 80, -value => $value ); 212 $html = CGI::textfield( 213 -class => 'foswikiAlert foswikiInputField', 214 -name => $name, 215 -size => 80, 216 -value => $value 217 ); 194 218 } 195 219 196 220 push( @shelter, $html ); 197 221 198 return $START_MARKER. 199 CGI::span({class=>'foswikiAlert', 200 style=>'font-weight:bold;'}, 201 $name . ' = SHELTER' . $MARKER . $#shelter).$END_MARKER; 222 return $START_MARKER 223 . CGI::span( 224 { 225 class => 'foswikiAlert', 226 style => 'font-weight:bold;' 227 }, 228 $name . ' = SHELTER' . $MARKER . $#shelter 229 ) . $END_MARKER; 202 230 } 203 231 204 232 # Generate the button that replaces the EDITPREFERENCES tag in view mode 205 233 sub _generateEditButton { 206 my( $web, $topic ) = @_; 207 208 my $viewUrl = Foswiki::Func::getScriptUrl( 209 $web, $topic, 'viewauth' ); 234 my ( $web, $topic ) = @_; 235 236 my $viewUrl = Foswiki::Func::getScriptUrl( $web, $topic, 'viewauth' ); 210 237 my $text = CGI::start_form( 211 -name => 'editpreferences',238 -name => 'editpreferences', 212 239 -method => 'post', 213 -action => $viewUrl ); 214 $text .= CGI::input({ 215 type => 'hidden', 216 name => 'prefsaction', 217 value => 'edit'}); 218 $text .= CGI::submit(-name => 'edit', 219 -value=>'Edit Preferences', 220 -class=>'foswikiButton'); 240 -action => $viewUrl 241 ); 242 $text .= CGI::input( 243 { 244 type => 'hidden', 245 name => 'prefsaction', 246 value => 'edit' 247 } 248 ); 249 $text .= CGI::submit( 250 -name => 'edit', 251 -value => 'Edit Preferences', 252 -class => 'foswikiButton' 253 ); 221 254 $text .= CGI::end_form(); 222 255 $text =~ s/\n//sg; … … 226 259 # Generate the buttons that replace the EDITPREFERENCES tag in edit mode 227 260 sub _generateControlButtons { 228 my( $web, $topic ) = @_; 229 230 my $text = $START_MARKER.CGI::submit(-name=>'prefsaction', 231 -value=>'Save new settings', 232 -class=>'foswikiSubmit', 233 -accesskey=>'s'); 261 my ( $web, $topic ) = @_; 262 263 my $text = $START_MARKER 264 . CGI::submit( 265 -name => 'prefsaction', 266 -value => 'Save new settings', 267 -class => 'foswikiSubmit', 268 -accesskey => 's' 269 ); 234 270 $text .= ' '; 235 $text .= CGI::submit(-name=>'prefsaction', -value=>'Cancel', 236 -class=>'foswikiButtonCancel', 237 -accesskey=>'c').$END_MARKER; 271 $text .= CGI::submit( 272 -name => 'prefsaction', 273 -value => 'Cancel', 274 -class => 'foswikiButtonCancel', 275 -accesskey => 'c' 276 ) . $END_MARKER; 238 277 return $text; 239 278 } … … 243 282 # Set statement. 244 283 sub _saveSet { 245 my ( $query, $web, $topic, $name, $value, $formDef ) = @_;246 247 my $newValue = $query->param( $name) || $value;248 249 if ( $formDef) {284 my ( $query, $web, $topic, $name, $value, $formDef ) = @_; 285 286 my $newValue = $query->param($name) || $value; 287 288 if ($formDef) { 250 289 my $fieldDef = _getField( $formDef, $name ); 251 290 my $type = $fieldDef->{type} || ''; 252 if ( $type && $type =~ /^checkbox/ ) {253 my $val = '';291 if ( $type && $type =~ /^checkbox/ ) { 292 my $val = ''; 254 293 my $vals = $fieldDef->{value}; 255 foreach my $item ( @$vals) {256 my $cvalue = $query->param( $name .$item );257 if ( defined( $cvalue) ) {258 if ( !$val ) {294 foreach my $item (@$vals) { 295 my $cvalue = $query->param( $name . $item ); 296 if ( defined($cvalue) ) { 297 if ( !$val ) { 259 298 $val = ''; 260 } else {261 $val .= ', ' if( $cvalue );262 299 } 263 $val .= $item if( $cvalue ); 300 else { 301 $val .= ', ' if ($cvalue); 302 } 303 $val .= $item if ($cvalue); 264 304 } 265 305 } … … 267 307 } 268 308 } 309 269 310 # if no form def, it's just treated as text 270 311 271 return $name .' = '.$newValue;312 return $name . ' = ' . $newValue; 272 313 } 273 314 -
trunk/RenderListPlugin/lib/Foswiki/Plugins/RenderListPlugin.pm
r3944 r3947 12 12 # This program is distributed in the hope that it will be useful, 13 13 # but WITHOUT ANY WARRANTY; without even the implied warranty of 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 15 15 # 16 16 # As per the GPL, removal of this notice is prohibited. 17 17 # ========================= 18 18 19 20 # ========================= 21 package Foswiki::Plugins::RenderListPlugin; # change the package name and $pluginName!!!19 # ========================= 20 package Foswiki::Plugins::RenderListPlugin 21 ; # change the package name and $pluginName!!! 22 22 23 23 use strict; … … 25 25 # ========================= 26 26 use vars qw( 27 $web $topic $user $installWeb28 $pubUrl $attachUrl29 );30 31 our $VERSION = '$Rev: 16234 $';32 our $RELEASE = '2.1';33 our $pluginName = 'RenderListPlugin';# Name of this Plugin27 $web $topic $user $installWeb 28 $pubUrl $attachUrl 29 ); 30 31 our $VERSION = '$Rev: 16234 $'; 32 our $RELEASE = '2.1'; 33 our $pluginName = 'RenderListPlugin'; # Name of this Plugin 34 34 our $NO_PREFS_IN_TOPIC = 1; 35 35 our $SHORTDESCRIPTION = 'Render bullet lists in a variety of formats'; … … 37 37 our %defaultThemes = ( 38 38 THREAD => 'tree, 1', 39 HOME => 'icon, 1, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/home.gif', 40 ORG => 'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/home.gif', 41 GROUP => 'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/group.gif', 42 EMAIL => 'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/email.gif', 43 TREND => 'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/trend.gif', 44 FILE => 'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/file.gif', 39 HOME => 40 'icon, 1, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/home.gif', 41 ORG => 42 'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/home.gif', 43 GROUP => 44 'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/group.gif', 45 EMAIL => 46 'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/email.gif', 47 TREND => 48 'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/trend.gif', 49 FILE => 50 'icon, 0, 16, 16, %ATTACHURL%/empty.gif, %ATTACHURL%/dot_udr.gif, %ATTACHURL%/dot_ud.gif, %ATTACHURL%/dot_ur.gif, %ATTACHURL%/file.gif', 45 51 ); 46 52 47 53 # ========================= 48 sub initPlugin 49 { 54 sub initPlugin { 50 55 ( $topic, $web, $user, $installWeb ) = @_; 51 56 52 57 # check for Plugins.pm versions 53 if( $Foswiki::Plugins::VERSION < 1 ) { 54 Foswiki::Func::writeWarning( "Version mismatch between $pluginName and Plugins.pm" ); 58 if ( $Foswiki::Plugins::VERSION < 1 ) { 59 Foswiki::Func::writeWarning( 60 "Version mismatch between $pluginName and Plugins.pm"); 55 61 return 0; 56 62 } 57 63 58 64 # one time initialization 59 $pubUrl = Foswiki::Func::getUrlHost() . Foswiki::Func::getPubUrlPath();65 $pubUrl = Foswiki::Func::getUrlHost() . Foswiki::Func::getPubUrlPath(); 60 66 $attachUrl = "$pubUrl/$installWeb/$pluginName"; 61 67 … … 65 71 66 72 # ========================= 67 sub startRenderingHandler 68 { 73 sub startRenderingHandler { 69 74 ### my ( $text, $web ) = @_; # do not uncomment, use $_[0], $_[1] instead 70 75 … … 73 78 # Render here, not in commonTagsHandler so that lists produced by 74 79 # Plugins, TOC and SEARCH can be rendered 75 if ($_[0] =~/%RENDERLIST/o ) { 76 unless ($_[0] =~ s/%RENDERLIST{(.*?)}%(([\n\r]+[^ ]{3}[^\n\r]*)*?)(([\n\r]+ {3}[^\n\r]*)+)/&handleRenderList($1, $2, $4)/ges ) { 80 if ( $_[0] =~ /%RENDERLIST/o ) { 81 unless ( $_[0] =~ 82 s/%RENDERLIST{(.*?)}%(([\n\r]+[^ ]{3}[^\n\r]*)*?)(([\n\r]+ {3}[^\n\r]*)+)/&handleRenderList($1, $2, $4)/ges 83 ) 84 { 85 77 86 # Cairo compatibility fallback 78 $_[0] =~ s/%RENDERLIST{(.*?)}%(([\n\r]+[^\t]{1}[^\n\r]*)*?)(([\n\r]+\t[^\n\r]*)+)/&handleRenderList($1, $2, $4)/ges;79 } 80 }81 }82 83 # ========================= 84 sub handleRenderList 85 {87 $_[0] =~ 88 s/%RENDERLIST{(.*?)}%(([\n\r]+[^\t]{1}[^\n\r]*)*?)(([\n\r]+\t[^\n\r]*)+)/&handleRenderList($1, $2, $4)/ges; 89 } 90 } 91 } 92 93 # ========================= 94 sub handleRenderList { 86 95 my ( $theAttr, $thePre, $theList ) = @_; 87 96 88 97 $theAttr =~ s/ {3}/\t/gs; 89 $thePre =~ s/ {3}/\t/gs;98 $thePre =~ s/ {3}/\t/gs; 90 99 $theList =~ s/ {3}/\t/gs; 91 100 92 101 my $focus = &Foswiki::Func::extractNameValuePair( $theAttr, "focus" ); 93 102 my $depth = &Foswiki::Func::extractNameValuePair( $theAttr, "depth" ); 94 my $theme = &Foswiki::Func::extractNameValuePair( $theAttr, "theme" ) ||95 &Foswiki::Func::extractNameValuePair( $theAttr);96 $theme = uc( $theme || '');97 if ( defined $defaultThemes{$theme}) {103 my $theme = &Foswiki::Func::extractNameValuePair( $theAttr, "theme" ) 104 || &Foswiki::Func::extractNameValuePair($theAttr); 105 $theme = uc( $theme || '' ); 106 if ( defined $defaultThemes{$theme} ) { 98 107 $theme = $defaultThemes{$theme}; 99 } else { 108 } 109 else { 100 110 $theme = "RENDERLISTPLUGIN_${theme}_THEME"; 101 $theme = &Foswiki::Func::getPreferencesValue( $theme)111 $theme = &Foswiki::Func::getPreferencesValue($theme) 102 112 || "unrecognized theme type"; 103 113 } 104 114 my ( $type, $params ) = split( /, */, $theme, 2 ); 105 $type = lc( $type ); 106 107 if( $type eq "tree" || $type eq "icon" ) { 108 return $thePre . renderIconList( $type, $params, $focus, $depth, $theList ); 109 } else { 115 $type = lc($type); 116 117 if ( $type eq "tree" || $type eq "icon" ) { 118 return $thePre 119 . renderIconList( $type, $params, $focus, $depth, $theList ); 120 } 121 else { 110 122 return "$thePre$theList"; 111 123 } … … 113 125 114 126 # ========================= 115 sub renderIconList 116 { 127 sub renderIconList { 117 128 my ( $theType, $theParams, $theFocus, $theDepth, $theText ) = @_; 118 129 119 130 $theText =~ s/^[\n\r]*//os; 120 my @tree = ();121 my $level = 0;122 my $type = "";123 my $text = "";131 my @tree = (); 132 my $level = 0; 133 my $type = ""; 134 my $text = ""; 124 135 my $focusIndex = -1; 125 foreach ( split( /[\n\r]+/, $theText ) ) {136 foreach ( split( /[\n\r]+/, $theText ) ) { 126 137 m/^(\t+)(.) *(.*)/; 127 $level = length( $1);128 $type = $2;129 $text = $3;130 if ( ( $theFocus) && ( $focusIndex < 0 ) && ( $text =~ /$theFocus/ ) ) {131 $focusIndex = scalar( @tree);138 $level = length($1); 139 $type = $2; 140 $text = $3; 141 if ( ($theFocus) && ( $focusIndex < 0 ) && ( $text =~ /$theFocus/ ) ) { 142 $focusIndex = scalar(@tree); 132 143 } 133 144 push( @tree, { level => $level, type => $type, text => $text } ); … … 135 146 136 147 # reduce tree to relatives around focus 137 if( $focusIndex >= 0 ) { 148 if ( $focusIndex >= 0 ) { 149 138 150 # splice tree into before, current node and after parts 139 151 my @after = splice( @tree, $focusIndex + 1 ); 140 my $nref = pop( @tree);152 my $nref = pop(@tree); 141 153 142 154 # highlight node with focus and remove links 143 155 $text = $nref->{'text'}; 144 $text =~ s/^([^\-]*)\[\[.*?\]\[(.*?)\]\]/$1$2/o; # remove [[...][...]] link 145 $text =~ s/^([^\-]*)\[\[(.*?)\]\]/$1$2/o; # remove [[...]] link 146 $text = "<b> $text </b>"; # bold focus text 156 $text =~ 157 s/^([^\-]*)\[\[.*?\]\[(.*?)\]\]/$1$2/o; # remove [[...][...]] link 158 $text =~ s/^([^\-]*)\[\[(.*?)\]\]/$1$2/o; # remove [[...]] link 159 $text = "<b> $text </b>"; # bold focus text 147 160 $nref->{'text'} = $text; 148 161 149 162 # remove uncles and siblings below current node 150 163 $level = $nref->{'level'}; 151 for( my $i = 0; $i < scalar( @after ); $i++ ) { 152 if( ( $after[$i]->{'level'} < $level ) 153 || ( $after[$i]->{'level'} <= $level && $after[$i]->{'type'} ne " " ) ) { 164 for ( my $i = 0 ; $i < scalar(@after) ; $i++ ) { 165 if ( 166 ( $after[$i]->{'level'} < $level ) 167 || ( $after[$i]->{'level'} <= $level 168 && $after[$i]->{'type'} ne " " ) 169 ) 170 { 154 171 splice( @after, $i ); 155 172 last; … … 159 176 # remove uncles and siblings above current node 160 177 my @before = (); 161 for ( my $i = scalar( @tree ) - 1; $i >= 0; $i-- ) {162 if ( $tree[$i]->{'level'} < $level ) {178 for ( my $i = scalar(@tree) - 1 ; $i >= 0 ; $i-- ) { 179 if ( $tree[$i]->{'level'} < $level ) { 163 180 push( @before, $tree[$i] ); 164 181 $level = $tree[$i]->{'level'}; 165 182 } 166 183 } 167 @tree = reverse( @before);168 $focusIndex = scalar( @tree);184 @tree = reverse(@before); 185 $focusIndex = scalar(@tree); 169 186 push( @tree, $nref ); 170 187 push( @tree, @after ); … … 173 190 # limit depth of tree 174 191 my $depth = $theDepth; 175 unless ( $depth =~ s/.*?([0-9]+).*/$1/o ) {192 unless ( $depth =~ s/.*?([0-9]+).*/$1/o ) { 176 193 $depth = 0; 177 194 } 178 if ( $theFocus) {179 if ( $theDepth eq "" ) {195 if ($theFocus) { 196 if ( $theDepth eq "" ) { 180 197 $depth = $focusIndex + 3; 181 } else { 198 } 199 else { 182 200 $depth += $focusIndex + 1; 183 201 } 184 202 } 185 if ( $depth > 0 ) {203 if ( $depth > 0 ) { 186 204 my @tmp = (); 187 foreach my $ref ( @tree) {188 push( @tmp, $ref ) if ( $ref->{'level'} <= $depth );205 foreach my $ref (@tree) { 206 push( @tmp, $ref ) if ( $ref->{'level'} <= $depth ); 189 207 } 190 208 @tree = @tmp; … … 198 216 $theParams =~ s/%SYSTEMWEB%/$Foswiki::cfg{SystemWebName}/geo; 199 217 my ( $showLead, $width, $height, $iconSp, $iconT, $iconI, $iconL, $iconImg ) 200 = split( /, */, $theParams );201 $width = 16 unless( $width);202 $height = 16 unless( $height);203 $iconSp = "empty.gif" unless( $iconSp);204 $iconSp = fixImageTag( $iconSp, $width, $height );205 $iconT = "dot_udr.gif" unless( $iconT);206 $iconT = fixImageTag( $iconT, $width, $height );207 $iconI = "dot_ud.gif" unless( $iconI);208 $iconI = fixImageTag( $iconI, $width, $height );209 $iconL = "dot_ur.gif" unless( $iconL);210 $iconL = fixImageTag( $iconL, $width, $height );211 $iconImg = "home.gif" unless( $iconImg);218 = split( /, */, $theParams ); 219 $width = 16 unless ($width); 220 $height = 16 unless ($height); 221 $iconSp = "empty.gif" unless ($iconSp); 222 $iconSp = fixImageTag( $iconSp, $width, $height ); 223 $iconT = "dot_udr.gif" unless ($iconT); 224 $iconT = fixImageTag( $iconT, $width, $height ); 225 $iconI = "dot_ud.gif" unless ($iconI); 226 $iconI = fixImageTag( $iconI, $width, $height ); 227 $iconL = "dot_ur.gif" unless ($iconL); 228 $iconL = fixImageTag( $iconL, $width, $height ); 229 $iconImg = "home.gif" unless ($iconImg); 212 230 $iconImg = fixImageTag( $iconImg, $width, $height ); 213 231 214 232 $text = ""; 215 233 my $start = 0; 216 $start = 1 unless ( $showLead);234 $start = 1 unless ($showLead); 217 235 my @listIcon = (); 218 for( my $i = 0; $i < scalar( @tree ); $i++ ) { 219 $text .= '<table border="0" cellspacing="0" cellpadding="0"><tr>' . "\n"; 236 for ( my $i = 0 ; $i < scalar(@tree) ; $i++ ) { 237 $text .= 238 '<table border="0" cellspacing="0" cellpadding="0"><tr>' . "\n"; 220 239 $level = $tree[$i]->{'level'}; 221 for ( my $l = $start; $l < $level; $l++ ) {222 if ( $l == $level - 1 ) {240 for ( my $l = $start ; $l < $level ; $l++ ) { 241 if ( $l == $level - 1 ) { 223 242 $listIcon[$l] = $iconSp; 224 for( my $x = $i + 1; $x < scalar( @tree ); $x++ ) { 225 last if( $tree[$x]->{'level'} < $level ); 226 if( $tree[$x]->{'level'} <= $level && $tree[$x]->{'type'} ne " " ) { 227 $listIcon[$l] = $iconI; 228 last; 229 } 243 for ( my $x = $i + 1 ; $x < scalar(@tree) ; $x++ ) { 244 last if ( $tree[$x]->{'level'} < $level ); 245 if ( $tree[$x]->{'level'} <= $level 246 && $tree[$x]->{'type'} ne " " ) 247 { 248 $listIcon[$l] = $iconI; 249 last; 250 } 230 251 } 231 if( $tree[$i]->{'type'} eq " " ) { 232 $text .= "<td valign=\"top\">$listIcon[$l]</td>\n"; 233 } elsif( $listIcon[$l] eq $iconSp ) { 234 $text .= "<td valign=\"top\">$iconL</td>\n"; 235 } else { 236 $text .= "<td valign=\"top\">$iconT</td>\n"; 252 if ( $tree[$i]->{'type'} eq " " ) { 253 $text .= "<td valign=\"top\">$listIcon[$l]</td>\n"; 237 254 } 238 } else { 239 $text .= "<td valign=\"top\">" . ($listIcon[$l] || '') . "</td>\n"; 240 } 241 } 242 if( $theType eq "icon" ) { 255 elsif ( $listIcon[$l] eq $iconSp ) { 256 $text .= "<td valign=\"top\">$iconL</td>\n"; 257 } 258 else { 259 $text .= "<td valign=\"top\">$iconT</td>\n"; 260 } 261 } 262 else { 263 $text .= 264 "<td valign=\"top\">" . ( $listIcon[$l] || '' ) . "</td>\n"; 265 } 266 } 267 if ( $theType eq "icon" ) { 268 243 269 # icon theme type 244 if( $tree[$i]->{'type'} eq " " ) { 270 if ( $tree[$i]->{'type'} eq " " ) { 271 245 272 # continuation line 246 273 $text .= "<td valign=\"top\">$iconSp</td>\n"; 247 } elsif( $tree[$i]->{'text'} =~ /^\s*(<b>)?\s*((icon\:)?<img[^>]+>|icon\:[^\s]+)\s*(.*)/ ) { 274 } 275 elsif ( $tree[$i]->{'text'} =~ 276 /^\s*(<b>)?\s*((icon\:)?<img[^>]+>|icon\:[^\s]+)\s*(.*)/ ) 277 { 278 248 279 # specific icon 249 280 $tree[$i]->{'text'} = $4; 250 $tree[$i]->{'text'} = "$1 $4" if ( $1);281 $tree[$i]->{'text'} = "$1 $4" if ($1); 251 282 my $icon = $2; 252 283 $icon =~ s/^icon\://o; 253 284 $icon = fixImageTag( $icon, $width, $height ); 254 285 $text .= "<td valign=\"top\">$icon</td>\n"; 255 } else { 286 } 287 else { 288 256 289 # default icon 257 290 $text .= "<td valign=\"top\">$iconImg</td>\n"; 258 291 } 259 $text .= "<td valign=\"top\"><nobr> $tree[$i]->{'text'} </nobr></td>\n"; 260 261 } else { 292 $text .= 293 "<td valign=\"top\"><nobr> $tree[$i]->{'text'} </nobr></td>\n"; 294 295 } 296 else { 297 262 298 # tree theme type 263 if( $tree[$i]->{'text'} =~ /^\s*(<b>)?\s*((icon\:)?<img[^>]+>|icon\:[^\s]+)\s*(.*)/ ) { 299 if ( $tree[$i]->{'text'} =~ 300 /^\s*(<b>)?\s*((icon\:)?<img[^>]+>|icon\:[^\s]+)\s*(.*)/ ) 301 { 302 264 303 # specific icon 265 304 $tree[$i]->{'text'} = $4; 266 $tree[$i]->{'text'} = "$1 $4" if ( $1);305 $tree[$i]->{'text'} = "$1 $4" if ($1); 267 306 my $icon = $2; 268 307 $icon =~ s/^icon\://o; 269 308 $icon = fixImageTag( $icon, $width, $height ); 270 309 $text .= "<td valign=\"top\">$icon</td>\n"; 271 $text .= "<td valign=\"top\"><nobr> $tree[$i]->{'text'} </nobr></td>\n"; 272 } else { 273 $text .= "<td valign=\"top\"><nobr> $tree[$i]->{'text'} </nobr></td>\n"; 310 $text .= 311 "<td valign=\"top\"><nobr> $tree[$i]->{'text'} </nobr></td>\n"; 312 } 313 else { 314 $text .= 315 "<td valign=\"top\"><nobr> $tree[$i]->{'text'} </nobr></td>\n"; 274 316 } 275 317 } … … 280 322 281 323 # ========================= 282 sub fixImageTag 283 { 324 sub fixImageTag { 284 325 my ( $theIcon, $theWidth, $theHeight ) = @_; 285 326 286 if( $theIcon !~ /^<img/i ) { 287 $theIcon .= '.gif' if( $theIcon !~ /\.(png|gif|jpeg|jpg)$/i ); 288 $theIcon = "$attachUrl/$theIcon" if( $theIcon !~ /^(\/|https?\:)/ ); 289 $theIcon = "<img src=\"$theIcon\" width=\"$theWidth\" height=\"$theHeight\"" 290 . " alt=\"\" border=\"0\" />"; 327 if ( $theIcon !~ /^<img/i ) { 328 $theIcon .= '.gif' if ( $theIcon !~ /\.(png|gif|jpeg|jpg)$/i ); 329 $theIcon = "$attachUrl/$theIcon" if ( $theIcon !~ /^(\/|https?\:)/ ); 330 $theIcon = 331 "<img src=\"$theIcon\" width=\"$theWidth\" height=\"$theHeight\"" 332 . " alt=\"\" border=\"0\" />"; 291 333 } 292 334 return $theIcon; -
trunk/SlideShowPlugin/lib/Foswiki/Plugins/SlideShowPlugin.pm
r3944 r3947 29 29 our $VERSION = '$Rev$'; 30 30 our $RELEASE = '31 Mar 2009'; 31 our $SHORTDESCRIPTION = 'Create web based presentations based on topics with headings'; 31 our $SHORTDESCRIPTION = 32 'Create web based presentations based on topics with headings'; 32 33 our $NO_PREFS_IN_TOPIC = 1; 33 34 -
trunk/SmiliesPlugin/lib/Foswiki/Plugins/SmiliesPlugin.pm
r3447 r3947 30 30 $smiliesPubUrl $allPattern $smiliesFormat ); 31 31 32 our $VERSION = '$Rev$';33 our $RELEASE = '03 Apr 2009';32 our $VERSION = '$Rev$'; 33 our $RELEASE = '03 Apr 2009'; 34 34 our $NO_PREFS_IN_TOPIC = 1; 35 our $SHORTDESCRIPTION = 'Render smilies like :-) as icons';35 our $SHORTDESCRIPTION = 'Render smilies like :-) as icons'; 36 36 37 37 sub initPlugin { -
trunk/SpreadSheetPlugin/lib/Foswiki/Plugins/SpreadSheetPlugin.pm
r3944 r3947 27 27 use strict; 28 28 29 30 29 # ========================= 31 30 use vars qw( 32 $web $topic $user $installWeb $debug $skipInclude $doInit33 );31 $web $topic $user $installWeb $debug $skipInclude $doInit 32 ); 34 33 35 our $VERSION = '$Rev: 13748 $';36 our $RELEASE = '11 May 2009';34 our $VERSION = '$Rev: 13748 $'; 35 our $RELEASE = '11 May 2009'; 37 36 our $NO_PREFS_IN_TOPIC = 1; 38 our $SHORTDESCRIPTION = 'Add spreadsheet calculations like "$SUM($ABOVE())" to Foswiki tables and other topic text'; 37 our $SHORTDESCRIPTION = 38 'Add spreadsheet calculations like "$SUM($ABOVE())" to Foswiki tables and other topic text'; 39 39 40 40 $doInit = 0; 41 41 42 42 # ========================= 43 sub initPlugin 44 { 43 sub initPlugin { 45 44 ( $topic, $web, $user, $installWeb ) = @_; 46 45 47 46 # check for Plugins.pm versions 48 if( $Foswiki::Plugins::VERSION < 1 ) { 49 Foswiki::Func::writeWarning( "Version mismatch between SpreadSheetPlugin and Plugins.pm" ); 47 if ( $Foswiki::Plugins::VERSION < 1 ) { 48 Foswiki::Func::writeWarning( 49 "Version mismatch between SpreadSheetPlugin and Plugins.pm"); 50 50 return 0; 51 51 } 52 52 53 53 # Get plugin debug flag 54 $debug = Foswiki::Func::getPreferencesFlag( "SPREADSHEETPLUGIN_DEBUG") || 0;54 $debug = Foswiki::Func::getPreferencesFlag("SPREADSHEETPLUGIN_DEBUG") || 0; 55 55 56 56 # Flag to skip calc if in include 57 $skipInclude = Foswiki::Func::getPreferencesFlag( "SPREADSHEETPLUGIN_SKIPINCLUDE" ) || 1; 57 $skipInclude = 58 Foswiki::Func::getPreferencesFlag("SPREADSHEETPLUGIN_SKIPINCLUDE") || 1; 58 59 59 60 # Plugin correctly initialized 60 Foswiki::Func::writeDebug( "- Foswiki::Plugins::SpreadSheetPlugin::initPlugin( $web.$topic ) is OK" ) if $debug; 61 Foswiki::Func::writeDebug( 62 "- Foswiki::Plugins::SpreadSheetPlugin::initPlugin( $web.$topic ) is OK" 63 ) if $debug; 61 64 $doInit = 1; 62 65 return 1; … … 64 67 65 68 # ========================= 66 sub commonTagsHandler 67 { 69 sub commonTagsHandler { 68 70 ### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead 69 71 70 Foswiki::Func::writeDebug( "- SpreadSheetPlugin::commonTagsHandler( $_[2].$_[1] )" ) if $debug; 72 Foswiki::Func::writeDebug( 73 "- SpreadSheetPlugin::commonTagsHandler( $_[2].$_[1] )") 74 if $debug; 71 75 72 if( ( $_[3] ) && ( $skipInclude ) ) { 76 if ( ( $_[3] ) && ($skipInclude) ) { 77 73 78 # bail out, handler called from an %INCLUDE{}% 74 79 return; 75 80 } 76 unless( $_[0] =~ /%CALC\{.*?\}%/ ) { 81 unless ( $_[0] =~ /%CALC\{.*?\}%/ ) { 82 77 83 # nothing to do 78 84 return; … … 81 87 require Foswiki::Plugins::SpreadSheetPlugin::Calc; 82 88 83 if ( $doInit) {89 if ($doInit) { 84 90 $doInit = 0; 85 91 Foswiki::Plugins::SpreadSheetPlugin::Calc::init( $web, $topic, $debug ); 86 92 } 87 Foswiki::Plugins::SpreadSheetPlugin::Calc::CALC( @_);93 Foswiki::Plugins::SpreadSheetPlugin::Calc::CALC(@_); 88 94 } 89 95 -
trunk/SpreadSheetPlugin/lib/Foswiki/Plugins/SpreadSheetPlugin/Calc.pm
r3887 r3947 31 31 use Time::Local; 32 32 33 34 33 # ========================= 35 34 use vars qw( 36 $web $topic $debug $dontSpaceRE37 $renderingWeb @tableMatrix $cPos $rPos $escToken38 %varStore @monArr @wdayArr %mon2num39 );40 41 $escToken = "\0";42 %varStore = ();35 $web $topic $debug $dontSpaceRE 36 $renderingWeb @tableMatrix $cPos $rPos $escToken 37 %varStore @monArr @wdayArr %mon2num 38 ); 39 40 $escToken = "\0"; 41 %varStore = (); 43 42 $dontSpaceRE = ""; 44 @monArr = ( "Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" ); 45 @wdayArr = ( "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday" ); 46 { my $count = 0; 47 %mon2num = map { $_ => $count++ } @monArr; 48 } 49 50 51 # ========================= 52 sub init 43 @monArr = ( 44 "Jan", "Feb", "Mar", "Apr", "May", "Jun", 45 "Jul", "Aug", "Sep", "Oct", "Nov", "Dec" 46 ); 47 @wdayArr = ( 48 "Sunday", "Monday", "Tuesday", "Wednesday", 49 "Thursday", "Friday", "Saturday" 50 ); 53 51 { 52 my $count = 0; 53 %mon2num = map { $_ => $count++ } @monArr; 54 } 55 56 # ========================= 57 sub init { 54 58 ( $web, $topic, $debug ) = @_; 55 59 56 60 # initialize variables, once per page view 57 %varStore = ();61 %varStore = (); 58 62 $dontSpaceRE = ""; 59 63 60 64 # Module initialized 61 Foswiki::Func::writeDebug( "- Foswiki::Plugins::SpreadSheetPlugin::Calc::init( $web.$topic )" ) if $debug; 65 Foswiki::Func::writeDebug( 66 "- Foswiki::Plugins::SpreadSheetPlugin::Calc::init( $web.$topic )") 67 if $debug; 62 68 return 1; 63 69 } 64 70 65 71 # ========================= 66 sub CALC 67 { 72 sub CALC { 68 73 ### my ( $text, $topic, $web ) = @_; # do not uncomment, use $_[0], $_[1]... instead 69 74 70 Foswiki::Func::writeDebug( "- SpreadSheetPlugin::Calc::CALC( $_[2].$_[1] )" ) if $debug; 75 Foswiki::Func::writeDebug("- SpreadSheetPlugin::Calc::CALC( $_[2].$_[1] )") 76 if $debug; 71 77 72 78 @tableMatrix = (); 73 $cPos = -1;74 $rPos = -1;75 $web = $_[2];76 77 my @result = ();78 my $insidePRE = 0;79 $cPos = -1; 80 $rPos = -1; 81 $web = $_[2]; 82 83 my @result = (); 84 my $insidePRE = 0; 79 85 my $insideTABLE = 0; 80 my $line = "";81 my $before = "";82 my $cell = "";83 my @row = ();86 my $line = ""; 87 my $before = ""; 88 my $cell = ""; 89 my @row = (); 84 90 85 91 $_[0] =~ s/\r//go; 86 $_[0] =~ s/\\\n//go; # Join lines ending in "\"87 foreach ( split( /\n/, $_[0] ) ) {92 $_[0] =~ s/\\\n//go; # Join lines ending in "\" 93 foreach ( split( /\n/, $_[0] ) ) { 88 94 89 95 # change state: … … 93 99 m|</verbatim>|i && ( $insidePRE = 0 ); 94 100 95 if( ! ( $insidePRE ) ) { 96 97 if( /^\s*\|.*\|\s*$/ ) { 101 if ( !($insidePRE) ) { 102 103 if (/^\s*\|.*\|\s*$/) { 104 98 105 # inside | table | 99 if ( !$insideTABLE ) {106 if ( !$insideTABLE ) { 100 107 $insideTABLE = 1; 101 @tableMatrix = (); # reset table matrix102 $cPos = -1;103 $rPos = -1;108 @tableMatrix = (); # reset table matrix 109 $cPos = -1; 110 $rPos = -1; 104 111 } 105 112 $line = $_; 106 113 $line =~ s/^(\s*\|)(.*)\|\s*$/$2/o; 107 114 $before = $1; 108 @row = split( /\|/o, $line, -1 );109 push( @tableMatrix, [ @row] );115 @row = split( /\|/o, $line, -1 ); 116 push( @tableMatrix, [@row] ); 110 117 $rPos++; 111 118 $line = "$before"; 112 for( $cPos = 0; $cPos < @row; $cPos++ ) { 119 120 for ( $cPos = 0 ; $cPos < @row ; $cPos++ ) { 113 121 $cell = $row[$cPos]; 114 122 $cell =~ s/%CALC\{(.*?)\}%/&doCalc($1)/geo; … … 117 125 s/.*/$line/o; 118 126 119 } else { 127 } 128 else { 129 120 130 # outside | table | 121 if ( $insideTABLE) {131 if ($insideTABLE) { 122 132 $insideTABLE = 0; 123 133 } … … 131 141 132 142 # ========================= 133 sub doCalc 134 { 135 my( $theAttributes ) = @_; 136 my $text = &Foswiki::Func::extractNameValuePair( $theAttributes ); 143 sub doCalc { 144 my ($theAttributes) = @_; 145 my $text = &Foswiki::Func::extractNameValuePair($theAttributes); 137 146 138 147 # Add nesting level to parenthesis, … … 142 151 $text = doFunc( "MAIN", $text ); 143 152 144 if( ( $rPos >= 0 ) && ( $cPos >= 0 ) ) { 153 if ( ( $rPos >= 0 ) && ( $cPos >= 0 ) ) { 154 145 155 # update cell in table matrix 146 156 $tableMatrix[$rPos][$cPos] = $text; … … 151 161 152 162 # ========================= 153 sub addNestingLevel 154 { 155 my( $theParen, $theLevelRef ) = @_; 156 157 my $result = ""; 158 if( $theParen eq "(" ) { 159 $$theLevelRef++; 160 $result = "$escToken$$theLevelRef$theParen"; 161 } else { 162 $result = "$escToken$$theLevelRef$theParen"; 163 $$theLevelRef--; 164 } 165 return $result; 166 } 167 168 # ========================= 169 sub doFunc 170 { 171 my( $theFunc, $theAttr ) = @_; 172 173 $theAttr = "" unless( defined $theAttr ); 174 Foswiki::Func::writeDebug( "- SpreadSheetPlugin::Calc::doFunc: $theFunc( $theAttr ) start" ) if $debug; 175 176 unless( $theFunc =~ /^(IF|LISTIF|LISTMAP|NOEXEC)$/ ) { 163 sub addNestingLevel { 164 my ( $theParen, $theLevelRef ) = @_; 165 166 my $result = ""; 167 if ( $theParen eq "(" ) { 168 $$theLevelRef++; 169 $result = "$escToken$$theLevelRef$theParen"; 170 } 171 else { 172 $result = "$escToken$$theLevelRef$theParen"; 173 $$theLevelRef--; 174 } 175 return $result; 176 } 177 178 # ========================= 179 sub doFunc { 180 my ( $theFunc, $theAttr ) = @_; 181 182 $theAttr = "" unless ( defined $theAttr ); 183 Foswiki::Func::writeDebug( 184 "- SpreadSheetPlugin::Calc::doFunc: $theFunc( $theAttr ) start") 185 if $debug; 186 187 unless ( $theFunc =~ /^(IF|LISTIF|LISTMAP|NOEXEC)$/ ) { 188 177 189 # Handle functions recursively 178 $theAttr =~ s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 190 $theAttr =~ 191 s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 192 179 193 # Clean up unbalanced mess 180 194 $theAttr =~ s/$escToken\-*[0-9]+([\(\)])/$1/go; 181 195 } 196 182 197 # else: delay the function handler to after parsing the parameters, 183 198 # in which case handling functions and cleaning up needs to be done later 184 199 185 200 my $result = ""; 186 my $i = 0;187 if ( $theFunc eq "MAIN" ) {201 my $i = 0; 202 if ( $theFunc eq "MAIN" ) { 188 203 $result = $theAttr; 189 204 190 } elsif( $theFunc eq "EXEC" ) { 205 } 206 elsif ( $theFunc eq "EXEC" ) { 207 191 208 # add nesting level escapes 192 209 my $level = 0; 193 210 $result = $theAttr; 194 211 $result =~ s/([\(\)])/addNestingLevel($1, \$level)/geo; 195 # execute functions in attribute recursively and clean up unbalanced parenthesis 196 $result =~ s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 212 213 # execute functions in attribute recursively and clean up unbalanced parenthesis 214 $result =~ 215 s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 197 216 $result =~ s/$escToken\-*[0-9]+([\(\)])/$1/go; 198 217 199 } elsif( $theFunc eq "NOEXEC" ) { 218 } 219 elsif ( $theFunc eq "NOEXEC" ) { 200 220 $result = $theAttr; 201 221 202 } elsif( $theFunc eq "T" ) { 222 } 223 elsif ( $theFunc eq "T" ) { 203 224 $result = ""; 204 my @arr = getTableRange( "$theAttr..$theAttr");205 if ( @arr) {225 my @arr = getTableRange("$theAttr..$theAttr"); 226 if (@arr) { 206 227 $result = $arr[0]; 207 228 } 208 229 209 } elsif( $theFunc eq "TRIM" ) { 230 } 231 elsif ( $theFunc eq "TRIM" ) { 210 232 $result = $theAttr || ""; 211 233 $result =~ s/^\s*//o; … … 213 235 $result =~ s/\s+/ /go; 214 236 215 } elsif( $theFunc eq "FORMAT" ) { 216 # Format FORMAT(TYPE, precision, value) returns formatted value -- JimStraus - 05 Jan 2003 217 my( $format, $res, $value ) = split( /,\s*/, $theAttr ); 218 $format =~ s/^\s*(.*?)\s*$/$1/; #Strip leading and trailing spaces 219 $res =~ s/^\s*(.*?)\s*$/$1/; 220 $value =~ s/^\s*(.*?)\s*$/$1/; 221 if( $format eq "DOLLAR" ) { 237 } 238 elsif ( $theFunc eq "FORMAT" ) { 239 240 # Format FORMAT(TYPE, precision, value) returns formatted value -- JimStraus - 05 Jan 2003 241 my ( $format, $res, $value ) = split( /,\s*/, $theAttr ); 242 $format =~ s/^\s*(.*?)\s*$/$1/; #Strip leading and trailing spaces 243 $res =~ s/^\s*(.*?)\s*$/$1/; 244 $value =~ s/^\s*(.*?)\s*$/$1/; 245 if ( $format eq "DOLLAR" ) { 222 246 my $neg = 1 if $value < 0; 223 247 $value = abs($value); 224 $result = sprintf( "%0.${res}f", $value);248 $result = sprintf( "%0.${res}f", $value ); 225 249 my $temp = reverse $result; 226 250 $temp =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; 227 $result = "\$" . (scalar reverse $temp); 228 $result = "(".$result.")" if $neg; 229 } elsif( $format eq "COMMA" ) { 230 $result = sprintf("%0.${res}f", $value); 251 $result = "\$" . ( scalar reverse $temp ); 252 $result = "(" . $result . ")" if $neg; 253 } 254 elsif ( $format eq "COMMA" ) { 255 $result = sprintf( "%0.${res}f", $value ); 231 256 my $temp = reverse $result; 232 257 $temp =~ s/(\d\d\d)(?=\d)(?!\d*\.)/$1,/g; 233 258 $result = scalar reverse $temp; 234 } elsif( $format eq "PERCENT" ) { 235 $result = sprintf("%0.${res}f%%", $value * 100); 236 } elsif( $format eq "NUMBER" ) { 237 $result = sprintf("%0.${res}f", $value); 238 } elsif( $format eq "K" ) { 239 $result = sprintf("%0.${res}f K", $value / 1024); 240 } elsif( $format eq "KB" ) { 241 $result = sprintf("%0.${res}f KB", $value / 1024); 242 } elsif ($format eq "MB") { 243 $result = sprintf("%0.${res}f MB", $value / (1024 * 1024)); 244 } elsif( $format =~ /^KBMB/ ) { 259 } 260 elsif ( $format eq "PERCENT" ) { 261 $result = sprintf( "%0.${res}f%%", $value * 100 ); 262 } 263 elsif ( $format eq "NUMBER" ) { 264 $result = sprintf( "%0.${res}f", $value ); 265 } 266 elsif ( $format eq "K" ) { 267 $result = sprintf( "%0.${res}f K", $value / 1024 ); 268 } 269 elsif ( $format eq "KB" ) { 270 $result = sprintf( "%0.${res}f KB", $value / 1024 ); 271 } 272 elsif ( $format eq "MB" ) { 273 $result = sprintf( "%0.${res}f MB", $value / ( 1024 * 1024 ) ); 274 } 275 elsif ( $format =~ /^KBMB/ ) { 245 276 $value /= 1024; 246 277 my @lbls = ( "MB", "GB", "TB", "PB", "EB", "ZB" ); 247 278 my $lbl = "KB"; 248 while ( $value >= 1024 && @lbls ) {279 while ( $value >= 1024 && @lbls ) { 249 280 $value /= 1024; 250 281 $lbl = shift @lbls; 251 282 } 252 $result = sprintf("%0.${res}f", $value) . " $lbl"; 253 } else { 283 $result = sprintf( "%0.${res}f", $value ) . " $lbl"; 284 } 285 else { 286 254 287 # FORMAT not recognized, just return value 255 288 $result = $value; 256 289 } 257 290 258 } elsif( $theFunc eq "EMPTY" ) { 291 } 292 elsif ( $theFunc eq "EMPTY" ) { 259 293 $result = 1; 260 $result = 0 if( length( $theAttr ) > 0 ); 261 262 } elsif( $theFunc eq "EXACT" ) { 294 $result = 0 if ( length($theAttr) > 0 ); 295 296 } 297 elsif ( $theFunc eq "EXACT" ) { 263 298 $result = 0; 264 my ( $str1, $str2 ) = split( /,\s*/, $theAttr, 2 );265 $str1 = "" unless ( $str1);266 $str2 = "" unless ( $str2);267 $str1 =~ s/^\s*(.*?)\s*$/$1/o; # cut leading and trailing spaces299 my ( $str1, $str2 ) = split( /,\s*/, $theAttr, 2 ); 300 $str1 = "" unless ($str1); 301 $str2 = "" unless ($str2); 302 $str1 =~ s/^\s*(.*?)\s*$/$1/o; # cut leading and trailing spaces 268 303 $str2 =~ s/^\s*(.*?)\s*$/$1/o; 269 $result = 1 if( $str1 eq $str2 ); 270 271 } elsif( $theFunc eq "RAND" ) { 272 my $max = _getNumber( $theAttr ); 273 $max = 1 if( $max <= 0 ); 274 $result = rand( $max ); 275 276 } elsif( $theFunc eq "VALUE" ) { 277 $result = _getNumber( $theAttr ); 278 279 } elsif( $theFunc =~ /^(EVAL|INT)$/ ) { 280 $result = safeEvalPerl( $theAttr ); 281 unless( $result =~ /^ERROR/ ) { 282 $result = int( _getNumber( $result ) ) if( $theFunc eq "INT" ); 283 } 284 285 } elsif( $theFunc eq "ROUND" ) { 304 $result = 1 if ( $str1 eq $str2 ); 305 306 } 307 elsif ( $theFunc eq "RAND" ) { 308 my $max = _getNumber($theAttr); 309 $max = 1 if ( $max <= 0 ); 310 $result = rand($max); 311 312 } 313 elsif ( $theFunc eq "VALUE" ) { 314 $result = _getNumber($theAttr); 315 316 } 317 elsif ( $theFunc =~ /^(EVAL|INT)$/ ) { 318 $result = safeEvalPerl($theAttr); 319 unless ( $result =~ /^ERROR/ ) { 320 $result = int( _getNumber($result) ) if ( $theFunc eq "INT" ); 321 } 322 323 } 324 elsif ( $theFunc eq "ROUND" ) { 325 286 326 # ROUND(num, digits) 287 my( $num, $digits ) = split( /,\s*/, $theAttr, 2 ); 288 $result = safeEvalPerl( $num ); 289 unless( $result =~ /^ERROR/ ) { 290 $result = _getNumber( $result ); 291 if( ( $digits ) && ( $digits =~ s/^.*?(\-?[0-9]+).*$/$1/o ) && ( $digits ) ) { 327 my ( $num, $digits ) = split( /,\s*/, $theAttr, 2 ); 328 $result = safeEvalPerl($num); 329 unless ( $result =~ /^ERROR/ ) { 330 $result = _getNumber($result); 331 if ( ($digits) 332 && ( $digits =~ s/^.*?(\-?[0-9]+).*$/$1/o ) 333 && ($digits) ) 334 { 292 335 my $factor = 10**$digits; 293 336 $result *= $factor; 294 337 ( $result >= 0 ) ? ( $result += 0.5 ) : ( $result -= 0.5 ); 295 $result = int( $result);338 $result = int($result); 296 339 $result /= $factor; 297 } else { 340 } 341 else { 298 342 ( $result >= 0 ) ? ( $result += 0.5 ) : ( $result -= 0.5 ); 299 $result = int( $result ); 300 } 301 } 302 303 } elsif( $theFunc eq "MOD" ) { 343 $result = int($result); 344 } 345 } 346 347 } 348 elsif ( $theFunc eq "MOD" ) { 304 349 $result = 0; 305 my ( $num1, $num2 ) = split( /,\s*/, $theAttr, 2 );306 $num1 = _getNumber( $num1);307 $num2 = _getNumber( $num2);308 if ( $num1 && $num2 ) {350 my ( $num1, $num2 ) = split( /,\s*/, $theAttr, 2 ); 351 $num1 = _getNumber($num1); 352 $num2 = _getNumber($num2); 353 if ( $num1 && $num2 ) { 309 354 $result = $num1 % $num2; 310 355 } 311 356 312 } elsif( $theFunc eq "ODD" ) { 313 $result = _getNumber( $theAttr ) % 2; 314 315 } elsif( $theFunc eq "EVEN" ) { 316 $result = ( _getNumber( $theAttr ) + 1 ) % 2; 317 318 } elsif( $theFunc eq "AND" ) { 357 } 358 elsif ( $theFunc eq "ODD" ) { 359 $result = _getNumber($theAttr) % 2; 360 361 } 362 elsif ( $theFunc eq "EVEN" ) { 363 $result = ( _getNumber($theAttr) + 1 ) % 2; 364 365 } 366 elsif ( $theFunc eq "AND" ) { 319 367 $result = 0; 320 my @arr = getListAsInteger( $theAttr);321 foreach $i ( @arr) {322 unless ( $i) {368 my @arr = getListAsInteger($theAttr); 369 foreach $i (@arr) { 370 unless ($i) { 323 371 $result = 0; 324 372 last; … … 327 375 } 328 376 329 } elsif( $theFunc eq "OR" ) { 377 } 378 elsif ( $theFunc eq "OR" ) { 330 379 $result = 0; 331 my @arr = getListAsInteger( $theAttr);332 foreach $i ( @arr) {333 if ( $i) {380 my @arr = getListAsInteger($theAttr); 381 foreach $i (@arr) { 382 if ($i) { 334 383 $result = 1; 335 384 last; … … 337 386 } 338 387 339 } elsif( $theFunc eq "NOT" ) { 388 } 389 elsif ( $theFunc eq "NOT" ) { 340 390 $result = 1; 341 $result = 0 if( _getNumber( $theAttr ) ); 342 343 } elsif( $theFunc eq "ABS" ) { 344 $result = abs( _getNumber( $theAttr ) ); 345 346 } elsif( $theFunc eq "SIGN" ) { 347 $i = _getNumber( $theAttr ); 348 $result = 0; 349 $result = 1 if( $i > 0 ); 350 $result = -1 if( $i < 0 ); 351 352 } elsif( $theFunc eq "LN" ) { 353 $result = log(_getNumber( $theAttr ) ); 354 355 } elsif( $theFunc eq "LOG" ) { 356 my( $num, $base ) = split( /,\s*/, $theAttr, 2 ); 357 $num = _getNumber( $num ); 358 $base = _getNumber( $base ); 359 $base = 10 if( $base <= 0 ); 360 $result = log( $num ) / log( $base ); 361 362 } elsif( $theFunc eq "EXP" ) { 363 $result = exp( _getNumber( $theAttr ) ); 364 365 } elsif( $theFunc eq "PI" ) { 391 $result = 0 if ( _getNumber($theAttr) ); 392 393 } 394 elsif ( $theFunc eq "ABS" ) { 395 $result = abs( _getNumber($theAttr) ); 396 397 } 398 elsif ( $theFunc eq "SIGN" ) { 399 $i = _getNumber($theAttr); 400 $result = 0; 401 $result = 1 if ( $i > 0 ); 402 $result = -1 if ( $i < 0 ); 403 404 } 405 elsif ( $theFunc eq "LN" ) { 406 $result = log( _getNumber($theAttr) ); 407 408 } 409 elsif ( $theFunc eq "LOG" ) { 410 my ( $num, $base ) = split( /,\s*/, $theAttr, 2 ); 411 $num = _getNumber($num); 412 $base = _getNumber($base); 413 $base = 10 if ( $base <= 0 ); 414 $result = log($num) / log($base); 415 416 } 417 elsif ( $theFunc eq "EXP" ) { 418 $result = exp( _getNumber($theAttr) ); 419 420 } 421 elsif ( $theFunc eq "PI" ) { 366 422 $result = 3.1415926535897932384; 367 423 368 } elsif( $theFunc eq "SQRT" ) { 369 $result = sqrt( _getNumber( $theAttr ) ); 370 371 } elsif( $theFunc eq "IF" ) { 424 } 425 elsif ( $theFunc eq "SQRT" ) { 426 $result = sqrt( _getNumber($theAttr) ); 427 428 } 429 elsif ( $theFunc eq "IF" ) { 430 372 431 # IF(condition, value if true, value if false) 373 my( $condition, $str1, $str2 ) = _properSplit( $theAttr, 3 ); 374 # with delay, handle functions in condition recursively and clean up unbalanced parenthesis 375 $condition =~ s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 432 my ( $condition, $str1, $str2 ) = _properSplit( $theAttr, 3 ); 433 434 # with delay, handle functions in condition recursively and clean up unbalanced parenthesis 435 $condition =~ 436 s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 376 437 $condition =~ s/$escToken\-*[0-9]+([\(\)])/$1/go; 377 438 $condition =~ s/^\s*(.*?)\s*$/$1/o; 378 $result = safeEvalPerl( $condition);379 unless ( $result =~ /^ERROR/ ) {380 if ( $result) {439 $result = safeEvalPerl($condition); 440 unless ( $result =~ /^ERROR/ ) { 441 if ($result) { 381 442 $result = $str1; 382 } else { 443 } 444 else { 383 445 $result = $str2; 384 446 } 385 $result = "" unless( defined( $result ) ); 386 # with delay, handle functions in result recursively and clean up unbalanced parenthesis 387 $result =~ s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 447 $result = "" unless ( defined($result) ); 448 449 # with delay, handle functions in result recursively and clean up unbalanced parenthesis 450 $result =~ 451 s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 388 452 $result =~ s/$escToken\-*[0-9]+([\(\)])/$1/go; 389 453 390 } # else return error message 391 392 } elsif( $theFunc eq "UPPER" ) { 393 $result = uc( $theAttr ); 394 395 } elsif( $theFunc eq "LOWER" ) { 396 $result = lc( $theAttr ); 397 398 } elsif( $theFunc eq "PROPER" ) { 454 } # else return error message 455 456 } 457 elsif ( $theFunc eq "UPPER" ) { 458 $result = uc($theAttr); 459 460 } 461 elsif ( $theFunc eq "LOWER" ) { 462 $result = lc($theAttr); 463 464 } 465 elsif ( $theFunc eq "PROPER" ) { 466 399 467 # FIXME: I18N 400 $result = lc( $theAttr);468 $result = lc($theAttr); 401 469 $result =~ s/(^|[^a-z])([a-z])/$1 . uc($2)/geo; 402 470 403 } elsif( $theFunc eq "PROPERSPACE" ) { 404 $result = _properSpace( $theAttr ); 405 406 } elsif( $theFunc eq "CHAR" ) { 407 if( $theAttr =~ /([0-9]+)/ ) { 471 } 472 elsif ( $theFunc eq "PROPERSPACE" ) { 473 $result = _properSpace($theAttr); 474 475 } 476 elsif ( $theFunc eq "CHAR" ) { 477 if ( $theAttr =~ /([0-9]+)/ ) { 408 478 $i = $1; 409 } else { 479 } 480 else { 410 481 $i = 0; 411 482 } 412 483 $i = 255 if $i > 255; 413 $i = 0 if $i < 0; 414 $result = chr( $i ); 415 416 } elsif( $theFunc eq "REPEAT" ) { 417 my( $str, $num ) = split( /,\s*/, $theAttr, 2 ); 418 $str = "" unless( defined( $str ) ); 419 $num = _getNumber( $num ); 484 $i = 0 if $i < 0; 485 $result = chr($i); 486 487 } 488 elsif ( $theFunc eq "REPEAT" ) { 489 my ( $str, $num ) = split( /,\s*/, $theAttr, 2 ); 490 $str = "" unless ( defined($str) ); 491 $num = _getNumber($num); 420 492 $result = "$str" x $num; 421 493 422 } elsif( $theFunc eq "CODE" ) { 423 $result = ord( $theAttr ); 424 425 } elsif( $theFunc eq "LENGTH" ) { 426 $result = length( $theAttr ); 427 428 } elsif( $theFunc eq "ROW" ) { 494 } 495 elsif ( $theFunc eq "CODE" ) { 496 $result = ord($theAttr); 497 498 } 499 elsif ( $theFunc eq "LENGTH" ) { 500 $result = length($theAttr); 501 502 } 503 elsif ( $theFunc eq "ROW" ) { 429 504 $i = $theAttr || 0; 430 505 $result = $rPos + $i + 1; 431 506 432 } elsif( $theFunc eq "COLUMN" ) { 507 } 508 elsif ( $theFunc eq "COLUMN" ) { 433 509 $i = $theAttr || 0; 434 510 $result = $cPos + $i + 1; 435 511 436 } elsif( $theFunc eq "LEFT" ) { 437 $i = $rPos + 1; 512 } 513 elsif ( $theFunc eq "LEFT" ) { 514 $i = $rPos + 1; 438 515 $result = "R$i:C0..R$i:C$cPos"; 439 516 440 } elsif( $theFunc eq "ABOVE" ) { 441 $i = $cPos + 1; 517 } 518 elsif ( $theFunc eq "ABOVE" ) { 519 $i = $cPos + 1; 442 520 $result = "R0:C$i..R$rPos:C$i"; 443 521 444 } elsif( $theFunc eq "RIGHT" ) { 445 $i = $rPos + 1; 522 } 523 elsif ( $theFunc eq "RIGHT" ) { 524 $i = $rPos + 1; 446 525 $result = "R$i:C$cPos..R$i:C32000"; 447 526 448 } elsif( $theFunc eq "DEF" ) { 527 } 528 elsif ( $theFunc eq "DEF" ) { 529 449 530 # Format DEF(list) returns first defined cell 450 531 # Added by MF 26/3/2002, fixed by PeterThoeny 451 my @arr = getList( $theAttr);452 foreach my $cell ( @arr) {453 if ( $cell) {532 my @arr = getList($theAttr); 533 foreach my $cell (@arr) { 534 if ($cell) { 454 535 $cell =~ s/^\s*(.*?)\s*$/$1/o; 455 if ( $cell) {536 if ($cell) { 456 537 $result = $cell; 457 538 last; … … 460 541 } 461 542 462 } elsif( $theFunc eq "MAX" ) { 543 } 544 elsif ( $theFunc eq "MAX" ) { 463 545 my @arr = sort { $a <=> $b } 464 grep { /./ } 465 grep { defined $_ } 466 getListAsFloat( $theAttr ); 546 grep { /./ } 547 grep { defined $_ } getListAsFloat($theAttr); 467 548 $result = $arr[$#arr]; 468 549 469 } elsif( $theFunc eq "MIN" ) { 550 } 551 elsif ( $theFunc eq "MIN" ) { 470 552 my @arr = sort { $a <=> $b } 471 grep { /./ } 472 grep { defined $_ } 473 getListAsFloat( $theAttr ); 553 grep { /./ } 554 grep { defined $_ } getListAsFloat($theAttr); 474 555 $result = $arr[0]; 475 556 476 } elsif( $theFunc eq "SUM" ) { 557 } 558 elsif ( $theFunc eq "SUM" ) { 477 559 $result = 0; 478 my @arr = getListAsFloat( $theAttr ); 479 foreach $i ( @arr ) { 480 $result += $i if defined $i; 481 } 482 483 } elsif( $theFunc eq "SUMPRODUCT" ) { 560 my @arr = getListAsFloat($theAttr); 561 foreach $i (@arr) { 562 $result += $i if defined $i; 563 } 564 565 } 566 elsif ( $theFunc eq "SUMPRODUCT" ) { 484 567 $result = 0; 485 568 my @arr; 486 569 my @lol = split( /,\s*/, $theAttr ); 487 570 my $size = 32000; 488 for $i (0 .. $#lol ) { 489 @arr = getListAsFloat( $lol[$i] ); 490 $lol[$i] = [ @arr ]; # store reference to array 491 $size = @arr if( @arr < $size ); # remember smallest array 492 } 493 if( ( $size > 0 ) && ( $size < 32000 ) ) { 494 my $y; my $prod; my $val; 571 for $i ( 0 .. $#lol ) { 572 @arr = getListAsFloat( $lol[$i] ); 573 $lol[$i] = [@arr]; # store reference to array 574 $size = @arr if ( @arr < $size ); # remember smallest array 575 } 576 if ( ( $size > 0 ) && ( $size < 32000 ) ) { 577 my $y; 578 my $prod; 579 my $val; 495 580 $size--; 496 for $y ( 0 .. $size ) {581 for $y ( 0 .. $size ) { 497 582 $prod = 1; 498 for $i ( 0 .. $#lol ) {583 for $i ( 0 .. $#lol ) { 499 584 $val = $lol[$i][$y]; 500 if ( defined $val ) {585 if ( defined $val ) { 501 586 $prod *= $val; 502 } else { 503 $prod = 0; # don't count empty cells 587 } 588 else { 589 $prod = 0; # don't count empty cells 504 590 } 505 591 } … … 508 594 } 509 595 510 } elsif( $theFunc =~ /^(SUMDAYS|DURATION)$/ ) { 596 } 597 elsif ( $theFunc =~ /^(SUMDAYS|DURATION)$/ ) { 598 511 599 # DURATION is undocumented, is for SvenDowideit 512 600 # contributed by SvenDowideit - 07 Mar 2003; modified by PTh 513 601 $result = 0; 514 my @arr = getListAsDays( $theAttr ); 515 foreach $i ( @arr ) { 516 $result += $i if defined $i; 517 } 518 519 } elsif( $theFunc eq "WORKINGDAYS" ) { 520 my( $num1, $num2 ) = split( /,\s*/, $theAttr, 2 ); 521 $result = _workingDays( _getNumber( $num1 ), _getNumber( $num2 ) ); 522 523 } elsif( $theFunc =~ /^(MULT|PRODUCT)$/ ) { # MULT is deprecated, no not remove 602 my @arr = getListAsDays($theAttr); 603 foreach $i (@arr) { 604 $result += $i if defined $i; 605 } 606 607 } 608 elsif ( $theFunc eq "WORKINGDAYS" ) { 609 my ( $num1, $num2 ) = split( /,\s*/, $theAttr, 2 ); 610 $result = _workingDays( _getNumber($num1), _getNumber($num2) ); 611 612 } 613 elsif ( $theFunc =~ /^(MULT|PRODUCT)$/ ) 614 { # MULT is deprecated, no not remove 524 615 $result = 0; 525 my @arr = getListAsFloat( $theAttr);616 my @arr = getListAsFloat($theAttr); 526 617 $result = 1; 527 foreach $i ( @arr ) { 528 $result *= $i if defined $i; 529 } 530 531 } elsif( $theFunc =~ /^(AVERAGE|MEAN)$/ ) { 618 foreach $i (@arr) { 619 $result *= $i if defined $i; 620 } 621 622 } 623 elsif ( $theFunc =~ /^(AVERAGE|MEAN)$/ ) { 532 624 $result = 0; 533 625 my $items = 0; 534 my @arr = getListAsFloat( $theAttr);535 foreach $i ( @arr) {536 if ( defined $i ) {626 my @arr = getListAsFloat($theAttr); 627 foreach $i (@arr) { 628 if ( defined $i ) { 537 629 $result += $i; 538 630 $items++; 539 631 } 540 632 } 541 if ( $items > 0 ) {633 if ( $items > 0 ) { 542 634 $result = $result / $items; 543 635 } 544 636 545 } elsif( $theFunc eq "MEDIAN" ) { 546 my @arr = sort { $a <=> $b } grep { defined $_ } getListAsFloat( $theAttr ); 637 } 638 elsif ( $theFunc eq "MEDIAN" ) { 639 my @arr = 640 sort { $a <=> $b } grep { defined $_ } getListAsFloat($theAttr); 547 641 $i = @arr; 548 if( ( $i % 2 ) > 0 ) { 549 $result = $arr[$i/2]; 550 } elsif( $i ) { 642 if ( ( $i % 2 ) > 0 ) { 643 $result = $arr[ $i / 2 ]; 644 } 645 elsif ($i) { 551 646 $i /= 2; 552 $result = ( $arr[$i] + $arr[$i-1] ) / 2; 553 } 554 555 } elsif( $theFunc eq "PERCENTILE" ) { 556 my( $percentile, $set ) = split( /,\s*/, $theAttr, 2 ); 557 my @arr = sort { $a <=> $b } grep { defined $_ } getListAsFloat( $set ); 647 $result = ( $arr[$i] + $arr[ $i - 1 ] ) / 2; 648 } 649 650 } 651 elsif ( $theFunc eq "PERCENTILE" ) { 652 my ( $percentile, $set ) = split( /,\s*/, $theAttr, 2 ); 653 my @arr = sort { $a <=> $b } grep { defined $_ } getListAsFloat($set); 558 654 $result = 0; 559 655 560 my $size = scalar( @arr);561 if ( $size > 0 ) {656 my $size = scalar(@arr); 657 if ( $size > 0 ) { 562 658 $i = $percentile / 100 * ( $size + 1 ); 563 my $iInt = int( $i);564 if ( $i <= 1 ) {659 my $iInt = int($i); 660 if ( $i <= 1 ) { 565 661 $result = $arr[0]; 566 } elsif( $i >= $size ) { 567 $result = $arr[$size-1]; 568 } elsif( $i == $iInt ) { 569 $result = $arr[$i-1]; 570 } else { 662 } 663 elsif ( $i >= $size ) { 664 $result = $arr[ $size - 1 ]; 665 } 666 elsif ( $i == $iInt ) { 667 $result = $arr[ $i - 1 ]; 668 } 669 else { 670 571 671 # interpolate beween neighbors # Example: $i = 7.25 572 my $r1 = $iInt + 1 - $i; # 0.75 = 7 + 1 - 7.25573 my $r2 = 1 - $r1; # 0.25 = 1 - 0.75574 my $x1 = $arr[ $iInt-1];672 my $r1 = $iInt + 1 - $i; # 0.75 = 7 + 1 - 7.25 673 my $r2 = 1 - $r1; # 0.25 = 1 - 0.75 674 my $x1 = $arr[ $iInt - 1 ]; 575 675 my $x2 = $arr[$iInt]; 576 $result = ($r1 * $x1) + ($r2 * $x2); 577 } 578 } 579 580 } elsif( $theFunc eq "COUNTSTR" ) { 581 $result = 0; # count any string 582 $i = 0; # count string equal second attr 676 $result = ( $r1 * $x1 ) + ( $r2 * $x2 ); 677 } 678 } 679 680 } 681 elsif ( $theFunc eq "COUNTSTR" ) { 682 $result = 0; # count any string 683 $i = 0; # count string equal second attr 583 684 my $list = $theAttr; 584 my $str = "";585 if ( $theAttr =~ /^(.*),\s*(.*?)$/ ) {# greedy match for last comma685 my $str = ""; 686 if ( $theAttr =~ /^(.*),\s*(.*?)$/ ) { # greedy match for last comma 586 687 $list = $1; 587 $str = $2;688 $str = $2; 588 689 } 589 690 $str =~ s/\s*$//o; 590 my @arr = getList( $list);591 foreach my $cell ( @arr) {592 if ( defined $cell ) {691 my @arr = getList($list); 692 foreach my $cell (@arr) { 693 if ( defined $cell ) { 593 694 $cell =~ s/^\s*(.*?)\s*$/$1/o; 594 $result++ if( $cell ); 595 $i++ if( $cell eq $str ); 596 } 597 } 598 $result = $i if( $str ); 599 600 } elsif( $theFunc eq "COUNTITEMS" ) { 695 $result++ if ($cell); 696 $i++ if ( $cell eq $str ); 697 } 698 } 699 $result = $i if ($str); 700 701 } 702 elsif ( $theFunc eq "COUNTITEMS" ) { 601 703 $result = ""; 602 my @arr = getList( $theAttr);704 my @arr = getList($theAttr); 603 705 my %items = (); 604 my $key = ""; 605 foreach $key ( @arr ) { 606 $key =~ s/^\s*(.*?)\s*$/$1/o if( $key ); 607 if( $key ) { 608 if( exists( $items{ $key } ) ) { 609 $items{ $key }++; 610 } else { 611 $items{ $key } = 1; 706 my $key = ""; 707 foreach $key (@arr) { 708 $key =~ s/^\s*(.*?)\s*$/$1/o if ($key); 709 if ($key) { 710 if ( exists( $items{$key} ) ) { 711 $items{$key}++; 712 } 713 else { 714 $items{$key} = 1; 612 715 } 613 716 } … … 618 721 $result =~ s|<br /> $||o; 619 722 620 } elsif( $theFunc =~ /^(FIND|SEARCH)$/ ) { 621 my( $searchString, $string, $pos ) = split( /,\s*/, $theAttr, 3 ); 622 $string = '' unless ( defined $string ); 623 $searchString = '' unless (defined $searchString ); 624 $result = 0; 723 } 724 elsif ( $theFunc =~ /^(FIND|SEARCH)$/ ) { 725 my ( $searchString, $string, $pos ) = split( /,\s*/, $theAttr, 3 ); 726 $string = '' unless ( defined $string ); 727 $searchString = '' unless ( defined $searchString ); 728 $result = 0; 625 729 $pos--; 626 $pos = 0 if( $pos < 0 ); 627 $searchString = quotemeta( $searchString ) if( $theFunc eq "FIND" ); 628 pos( $string ) = $pos if( $pos ); 629 # using zero width lookahead '(?=...)' to keep pos at the beginning of match 630 if( $searchString ne '' && eval '$string =~ m/(?=$searchString)/g' ) { 631 $result = pos( $string ) + 1; 632 } 633 634 } elsif( $theFunc eq "REPLACE" ) { 635 my( $string, $start, $num, $replace ) = split ( /,\s*/, $theAttr, 4 ); 730 $pos = 0 if ( $pos < 0 ); 731 $searchString = quotemeta($searchString) if ( $theFunc eq "FIND" ); 732 pos($string) = $pos if ($pos); 733 734 # using zero width lookahead '(?=...)' to keep pos at the beginning of match 735 if ( $searchString ne '' && eval '$string =~ m/(?=$searchString)/g' ) { 736 $result = pos($string) + 1; 737 } 738 739 } 740 elsif ( $theFunc eq "REPLACE" ) { 741 my ( $string, $start, $num, $replace ) = split( /,\s*/, $theAttr, 4 ); 636 742 $string = "" unless ( defined $string ); 637 743 $result = $string; 638 $start-- unless ( $start < 1);639 $num = 0 unless( $num);640 $replace = "" unless ( defined $replace );744 $start-- unless ( $start < 1 ); 745 $num = 0 unless ($num); 746 $replace = "" unless ( defined $replace ); 641 747 eval 'substr( $string, $start, $num, $replace )'; 642 748 $result = $string; 643 749 644 } elsif( $theFunc eq "SUBSTITUTE" ) { 645 my( $string, $from, $to, $inst, $options ) = split( /,\s*/, $theAttr ); 750 } 751 elsif ( $theFunc eq "SUBSTITUTE" ) { 752 my ( $string, $from, $to, $inst, $options ) = split( /,\s*/, $theAttr ); 646 753 $string = "" unless ( defined $string ); 647 754 $result = $string; 648 $from = "" unless( defined $from );649 $from = quotemeta( $from ) unless( $options && $options =~ /r/i);650 $to = "" unless( defined $to );755 $from = "" unless ( defined $from ); 756 $from = quotemeta($from) unless ( $options && $options =~ /r/i ); 757 $to = "" unless ( defined $to ); 651 758 652 759 # Note that the number 0 is valid string. An empty string as well as 0 653 760 # are valid return values 654 761 if ( $string ne "" && $from ne "" ) { 655 if( $inst ) { 762 if ($inst) { 763 656 764 # replace Nth instance 657 765 my $count = 0; 658 if( eval '$string =~ s/($from)/if( ++$count == $inst ) { $to; } else { $1; }/gex;' ) { 766 if ( 767 eval 768 '$string =~ s/($from)/if( ++$count == $inst ) { $to; } else { $1; }/gex;' 769 ) 770 { 659 771 $result = $string; 660 772 } 661 } else { 773 } 774 else { 775 662 776 # global replace 663 if ( eval '$string =~ s/$from/$to/g' ) {777 if ( eval '$string =~ s/$from/$to/g' ) { 664 778 $result = $string; 665 779 } 666 780 } 667 } 668 669 } elsif( $theFunc =~ /^(MIDSTRING|SUBSTRING)$/ ) { 670 my( $string, $start, $num ) = split ( /,\s*/, $theAttr, 3 ); 781 } 782 783 } 784 elsif ( $theFunc =~ /^(MIDSTRING|SUBSTRING)$/ ) { 785 my ( $string, $start, $num ) = split( /,\s*/, $theAttr, 3 ); 671 786 $result = ''; 672 if ( $start && $num ) {673 $start-- unless ( $start < 1);787 if ( $start && $num ) { 788 $start-- unless ( $start < 1 ); 674 789 eval '$result = substr( $string, $start, $num )'; 675 790 } 676 791 677 } elsif( $theFunc =~ /^(LEFTSTRING)$/ ) { 678 my( $string, $num ) = split ( /,\s*/, $theAttr, 2 ); 792 } 793 elsif ( $theFunc =~ /^(LEFTSTRING)$/ ) { 794 my ( $string, $num ) = split( /,\s*/, $theAttr, 2 ); 679 795 $string = "" unless ( defined $string ); 680 $num = 1 if ( !defined $num );796 $num = 1 if ( !defined $num ); 681 797 eval '$result = substr( $string, 0, $num )'; 682 683 } elsif( $theFunc =~ /^(RIGHTSTRING)$/ ) { 684 my( $string, $num ) = split ( /,\s*/, $theAttr, 2 ); 798 799 } 800 elsif ( $theFunc =~ /^(RIGHTSTRING)$/ ) { 801 my ( $string, $num ) = split( /,\s*/, $theAttr, 2 ); 685 802 $string = "" unless ( defined $string ); 686 $num = 1 if ( !defined $num );687 $num = 0 if ( $num < 0);688 my $start = length( $string) - $num;689 $start = 0 if $start < 0;803 $num = 1 if ( !defined $num ); 804 $num = 0 if ( $num < 0 ); 805 my $start = length($string) - $num; 806 $start = 0 if $start < 0; 690 807 eval '$result = substr( $string, $start, $num )'; 691 808 692 } elsif( $theFunc eq "INSERTSTRING" ) { 693 my( $string, $start, $new ) = split ( /,\s*/, $theAttr, 3 ); 809 } 810 elsif ( $theFunc eq "INSERTSTRING" ) { 811 my ( $string, $start, $new ) = split( /,\s*/, $theAttr, 3 ); 694 812 $string = "" unless ( defined $string ); 695 $start = _getNumber( $start);813 $start = _getNumber($start); 696 814 eval 'substr( $string, $start, 0, $new )'; 697 815 $result = $string; 698 816 699 } elsif( $theFunc eq "TRANSLATE" ) { 817 } 818 elsif ( $theFunc eq "TRANSLATE" ) { 700 819 $result = $theAttr; 701 # greedy match for comma separated parameters (in case first parameter has embedded commas) 702 if( $theAttr =~ /^(.*)\,\s*(.+)\,\s*(.+)$/ ) { 820 821 # greedy match for comma separated parameters (in case first parameter has embedded commas) 822 if ( $theAttr =~ /^(.*)\,\s*(.+)\,\s*(.+)$/ ) { 703 823 my $string = $1; 704 my $from = $2; 705 my $to = $3; 706 $from =~ s/\$comma/,/g; $from =~ s/\$sp/ /g; $from = quotemeta( $from ); 707 $to =~ s/\$comma/,/g; $to =~ s/\$sp/ /g; $to = quotemeta( $to ); 708 $from =~ s/([a-zA-Z0-9])\\\-([a-zA-Z0-9])/$1\-$2/g; # fix quotemeta (allow only ranges) 709 $to =~ s/([a-zA-Z0-9])\\\-([a-zA-Z0-9])/$1\-$2/g; 824 my $from = $2; 825 my $to = $3; 826 $from =~ s/\$comma/,/g; 827 $from =~ s/\$sp/ /g; 828 $from = quotemeta($from); 829 $to =~ s/\$comma/,/g; 830 $to =~ s/\$sp/ /g; 831 $to = quotemeta($to); 832 $from =~ s/([a-zA-Z0-9])\\\-([a-zA-Z0-9])/$1\-$2/g 833 ; # fix quotemeta (allow only ranges) 834 $to =~ s/([a-zA-Z0-9])\\\-([a-zA-Z0-9])/$1\-$2/g; 710 835 $result = $string; 711 if( $string && eval "\$string =~ tr/$from/$to/" ) { 836 837 if ( $string && eval "\$string =~ tr/$from/$to/" ) { 712 838 $result = $string; 713 839 } 714 840 } 715 841 716 } elsif ( $theFunc eq "TIME" ) { 842 } 843 elsif ( $theFunc eq "TIME" ) { 717 844 $result = $theAttr; 718 845 $result =~ s/^\s+//o; 719 846 $result =~ s/\s+$//o; 720 if( $result ) { 721 $result = _date2serial( $result ); 722 } else { 847 if ($result) { 848 $result = _date2serial($result); 849 } 850 else { 723 851 $result = time(); 724 852 } 725 853 726 } elsif ( $theFunc eq "TODAY" ) { 727 $result = _date2serial( _serial2date( time(), '$year/$month/$day GMT', 1 ) ); 728 729 } elsif( $theFunc =~ /^(FORMATTIME|FORMATGMTIME)$/ ) { 730 my( $time, $str ) = split( /,\s*/, $theAttr, 2 ); 731 if( $time =~ /([0-9]+)/ ) { 854 } 855 elsif ( $theFunc eq "TODAY" ) { 856 $result = 857 _date2serial( _serial2date( time(), '$year/$month/$day GMT', 1 ) ); 858 859 } 860 elsif ( $theFunc =~ /^(FORMATTIME|FORMATGMTIME)$/ ) { 861 my ( $time, $str ) = split( /,\s*/, $theAttr, 2 ); 862 if ( $time =~ /([0-9]+)/ ) { 732 863 $time = $1; 733 } else { 864 } 865 else { 734 866 $time = time(); 735 867 } 736 868 my $isGmt = 0; 737 $isGmt = 1 if( ( $str =~ m/ gmt/i ) || ( $theFunc eq "FORMATGMTIME" ) ); 869 $isGmt = 1 870 if ( ( $str =~ m/ gmt/i ) || ( $theFunc eq "FORMATGMTIME" ) ); 738 871 $result = _serial2date( $time, $str, $isGmt ); 739 872 740 } elsif( $theFunc eq "FORMATTIMEDIFF" ) { 741 my( $scale, $prec, $time ) = split( /,\s*/, $theAttr, 3 ); 742 $scale = "" unless( $scale ); 743 $prec = int( _getNumber( $prec ) - 1 ); 744 $prec = 0 if( $prec < 0 ); 745 $time = _getNumber( $time ); 746 $time = 0 if( $time < 0 ); 747 my @unit = ( 0, 0, 0, 0, 0, 0 ); # sec, min, hours, days, month, years 748 my @factor = ( 1, 60, 60, 24, 30.4166, 12 ); # sec, min, hours, days, month, years 749 my @singular = ( 'second', 'minute', 'hour', 'day', 'month', 'year' ); 750 my @plural = ( 'seconds', 'minutes', 'hours', 'days', 'month', 'years' ); 873 } 874 elsif ( $theFunc eq "FORMATTIMEDIFF" ) { 875 my ( $scale, $prec, $time ) = split( /,\s*/, $theAttr, 3 ); 876 $scale = "" unless ($scale); 877 $prec = int( _getNumber($prec) - 1 ); 878 $prec = 0 if ( $prec < 0 ); 879 $time = _getNumber($time); 880 $time = 0 if ( $time < 0 ); 881 my @unit = ( 0, 0, 0, 0, 0, 0 ); # sec, min, hours, days, month, years 882 my @factor = 883 ( 1, 60, 60, 24, 30.4166, 12 ); # sec, min, hours, days, month, years 884 my @singular = ( 'second', 'minute', 'hour', 'day', 'month', 'year' ); 885 my @plural = 886 ( 'seconds', 'minutes', 'hours', 'days', 'month', 'years' ); 751 887 my $min = 0; 752 888 my $max = $prec; 753 if( $scale =~ /^min/i ) { 889 890 if ( $scale =~ /^min/i ) { 754 891 $min = 1; 755 892 $unit[1] = $time; 756 } elsif( $scale =~ /^hou/i ) { 893 } 894 elsif ( $scale =~ /^hou/i ) { 757 895 $min = 2; 758 896 $unit[2] = $time; 759 } elsif( $scale =~ /^day/i ) { 897 } 898 elsif ( $scale =~ /^day/i ) { 760 899 $min = 3; 761 900 $unit[3] = $time; 762 } elsif( $scale =~ /^mon/i ) { 901 } 902 elsif ( $scale =~ /^mon/i ) { 763 903 $min = 4; 764 904 $unit[4] = $time; 765 } elsif( $scale =~ /^yea/i ) { 905 } 906 elsif ( $scale =~ /^yea/i ) { 766 907 $min = 5; 767 908 $unit[5] = $time; 768 } else { 909 } 910 else { 769 911 $unit[0] = $time; 770 912 } 771 my @arr = ();772 my $i = 0;913 my @arr = (); 914 my $i = 0; 773 915 my $val1 = 0; 774 916 my $val2 = 0; 775 for ( $i = $min; $i < 5; $i++ ) {917 for ( $i = $min ; $i < 5 ; $i++ ) { 776 918 $val1 = $unit[$i]; 777 $val2 = $unit[ $i+1] = int($val1 / $factor[$i+1]);778 $val1 = $unit[$i] = $val1 - int( $val2 * $factor[$i+1]);779 780 push( @arr, "$val1 $singular[$i]" ) if ( $val1 == 1 );781 push( @arr, "$val1 $plural[$i]" ) if ( $val1 > 1 );782 } 783 push( @arr, "$val2 $singular[$i]" ) if ( $val2 == 1 );784 push( @arr, "$val2 $plural[$i]" ) if ( $val2 > 1 );785 push( @arr, "0 $plural[$min]" ) unless( @arr);786 my @reverse = reverse( @arr);787 $#reverse = $prec if ( @reverse > $prec );919 $val2 = $unit[ $i + 1 ] = int( $val1 / $factor[ $i + 1 ] ); 920 $val1 = $unit[$i] = $val1 - int( $val2 * $factor[ $i + 1 ] ); 921 922 push( @arr, "$val1 $singular[$i]" ) if ( $val1 == 1 ); 923 push( @arr, "$val1 $plural[$i]" ) if ( $val1 > 1 ); 924 } 925 push( @arr, "$val2 $singular[$i]" ) if ( $val2 == 1 ); 926 push( @arr, "$val2 $plural[$i]" ) if ( $val2 > 1 ); 927 push( @arr, "0 $plural[$min]" ) unless (@arr); 928 my @reverse = reverse(@arr); 929 $#reverse = $prec if ( @reverse > $prec ); 788 930 $result = join( ', ', @reverse ); 789 931 $result =~ s/(.+)\, /$1 and /; 790 932 791 } elsif( $theFunc eq "TIMEADD" ) { 792 my( $time, $value, $scale ) = split( /,\s*/, $theAttr, 3 ); 793 $time = 0 unless( $time ); 794 $value = 0 unless( $value ); 795 $scale = "" unless( $scale ); 796 $time =~ s/.*?([0-9]+).*/$1/o || 0; 797 $value =~ s/.*?(\-?[0-9\.]+).*/$1/o || 0; 798 $value *= 60 if( $scale =~ /^min/i ); 799 $value *= 3600 if( $scale =~ /^hou/i ); 800 $value *= 3600*24 if( $scale =~ /^day/i ); 801 $value *= 3600*24*7 if( $scale =~ /^week/i ); 802 $value *= 3600*24*30.42 if( $scale =~ /^mon/i ); # FIXME: exact calc 803 $value *= 3600*24*365 if( $scale =~ /^year/i ); # FIXME: exact calc 804 $result = int( $time + $value ); 805 806 } elsif( $theFunc eq "TIMEDIFF" ) { 807 my( $time1, $time2, $scale ) = split( /,\s*/, $theAttr, 3 ); 808 $scale ||= ''; 809 $time1 = 0 unless( $time1 ); 810 $time2 = 0 unless( $time2 ); 811 $time1 =~ s/.*?([0-9]+).*/$1/o || 0; 812 $time2 =~ s/.*?([0-9]+).*/$1/o || 0; 813 $result = $time2 - $time1; 814 $result /= 60 if( $scale =~ /^min/i ); 815 $result /= 3600 if( $scale =~ /^hou/i ); 816 $result /= 3600*24 if( $scale =~ /^day/i ); 817 $result /= 3600*24*7 if( $scale =~ /^week/i ); 818 $result /= 3600*24*30.42 if( $scale =~ /^mon/i ); # FIXME: exact calc 819 $result /= 3600*24*365 if( $scale =~ /^year/i ); # FIXME: exact calc 820 821 } elsif( $theFunc eq "SET" ) { 822 my( $name, $value ) = split( /,\s*/, $theAttr, 2 ); 823 $name =~ s/[^a-zA-Z0-9\_]//go; 824 if( $name && defined( $value ) ) { 825 $value =~ s/\s*$//o; 826 $varStore{ $name } = $value; 827 } 828 829 } elsif( $theFunc eq "SETIFEMPTY" ) { 830 my( $name, $value ) = split( /,\s*/, $theAttr, 2 ); 831 $name =~ s/[^a-zA-Z0-9\_]//go; 832 if( $name && defined( $value ) && ! $varStore{ $name } ) { 833 $value =~ s/\s*$//o; 834 $varStore{ $name } = $value; 835 } 836 837 } elsif( $theFunc eq "SETM" ) { 838 my( $name, $value ) = split( /,\s*/, $theAttr, 2 ); 839 $name =~ s/[^a-zA-Z0-9\_]//go; 840 if( $name ) { 841 my $old = $varStore{ $name }; 842 $old = "" unless( defined( $old ) ); 843 $value = safeEvalPerl( "$old $value" ); 844 $varStore{ $name } = $value; 845 } 846 847 } elsif( $theFunc eq "GET" ) { 848 my $name = $theAttr; 849 $name =~ s/[^a-zA-Z0-9\_]//go; 850 $result = $varStore{ $name } if( $name ); 851 $result = "" unless( defined( $result ) ); 852 853 } elsif( $theFunc eq "LIST" ) { 854 my @arr = getList( $theAttr ); 855 $result = _listToDelimitedString( @arr ); 856 857 } elsif( $theFunc eq "LISTITEM" ) { 858 my( $index, $str ) = _properSplit( $theAttr, 2 ); 859 $index = _getNumber( $index ); 860 $str = "" unless( defined( $str ) ); 861 my @arr = getList( $str ); 933 } 934 elsif ( $theFunc eq "TIMEADD" ) { 935 my ( $time, $value, $scale ) = split( /,\s*/, $theAttr, 3 ); 936 $time = 0 unless ($time); 937 $value = 0 unless ($value); 938 $scale = "" unless ($scale); 939 $time =~ s/.*?([0-9]+).*/$1/o || 0; 940 $value =~ s/.*?(\-?[0-9\.]+).*/$1/o || 0; 941 $value *= 60 if ( $scale =~ /^min/i ); 942 $value *= 3600 if ( $scale =~ /^hou/i ); 943 $value *= 3600 * 24 if ( $scale =~ /^day/i ); 944 $value *= 3600 * 24 * 7 if ( $scale =~ /^week/i ); 945 $value *= 3600 * 24 * 30.42 946 if ( $scale =~ /^mon/i ); # FIXME: exact calc 947 $value *= 3600 * 24 * 365 if ( $scale =~ /^year/i ); # FIXME: exact calc 948 $result = int( $time + $value ); 949 950 } 951 elsif ( $theFunc eq "TIMEDIFF" ) { 952 my ( $time1, $time2, $scale ) = split( /,\s*/, $theAttr, 3 ); 953 $scale ||= ''; 954 $time1 = 0 unless ($time1); 955 $time2 = 0 unless ($time2); 956 $time1 =~ s/.*?([0-9]+).*/$1/o || 0; 957 $time2 =~ s/.*?([0-9]+).*/$1/o || 0; 958 $result = $time2 - $time1; 959 $result /= 60 if ( $scale =~ /^min/i ); 960 $result /= 3600 if ( $scale =~ /^hou/i ); 961 $result /= 3600 * 24 if ( $scale =~ /^day/i ); 962 $result /= 3600 * 24 * 7 if ( $scale =~ /^week/i ); 963 $result /= 3600 * 24 * 30.42 964 if ( $scale =~ /^mon/i ); # FIXME: exact calc 965 $result /= 3600 * 24 * 365 966 if ( $scale =~ /^year/i ); # FIXME: exact calc 967 968 } 969 elsif ( $theFunc eq "SET" ) { 970 my ( $name, $value ) = split( /,\s*/, $theAttr, 2 ); 971 $name =~ s/[^a-zA-Z0-9\_]//go; 972 if ( $name && defined($value) ) { 973 $value =~ s/\s*$//o; 974 $varStore{$name} = $value; 975 } 976 977 } 978 elsif ( $theFunc eq "SETIFEMPTY" ) { 979 my ( $name, $value ) = split( /,\s*/, $theAttr, 2 ); 980 $name =~ s/[^a-zA-Z0-9\_]//go; 981 if ( $name && defined($value) && !$varStore{$name} ) { 982 $value =~ s/\s*$//o; 983 $varStore{$name} = $value; 984 } 985 986 } 987 elsif ( $theFunc eq "SETM" ) { 988 my ( $name, $value ) = split( /,\s*/, $theAttr, 2 ); 989 $name =~ s/[^a-zA-Z0-9\_]//go; 990 if ($name) { 991 my $old = $varStore{$name}; 992 $old = "" unless ( defined($old) ); 993 $value = safeEvalPerl("$old $value"); 994 $varStore{$name} = $value; 995 } 996 997 } 998 elsif ( $theFunc eq "GET" ) { 999 my $name = $theAttr; 1000 $name =~ s/[^a-zA-Z0-9\_]//go; 1001 $result = $varStore{$name} if ($name); 1002 $result = "" unless ( defined($result) ); 1003 1004 } 1005 elsif ( $theFunc eq "LIST" ) { 1006 my @arr = getList($theAttr); 1007 $result = _listToDelimitedString(@arr); 1008 1009 } 1010 elsif ( $theFunc eq "LISTITEM" ) { 1011 my ( $index, $str ) = _properSplit( $theAttr, 2 ); 1012 $index = _getNumber($index); 1013 $str = "" unless ( defined($str) ); 1014 my @arr = getList($str); 862 1015 my $size = scalar @arr; 863 if( $index && $size ) { 864 $index-- if( $index > 0 ); # documented index starts at 1 865 $index = $size + $index if( $index < 0 ); # start from back if negative 866 $result = $arr[$index] if( ( $index >= 0 ) && ( $index < $size ) ); 867 } 868 869 } elsif( $theFunc eq "LISTJOIN" ) { 870 my( $sep, $str ) = _properSplit( $theAttr, 2 ); 871 $str = "" unless( defined( $str ) ); 872 $result = _listToDelimitedString( getList( $str ) ); 873 $sep = ", " unless( $sep ); 874 $sep =~ s/\$comma/,/go; 875 $sep =~ s/\$sp/ /go; 876 $sep =~ s/\$n/\n/go; 1016 if ( $index && $size ) { 1017 $index-- if ( $index > 0 ); # documented index starts at 1 1018 $index = $size + $index 1019 if ( $index < 0 ); # start from back if negative 1020 $result = $arr[$index] if ( ( $index >= 0 ) && ( $index < $size ) ); 1021 } 1022 1023 } 1024 elsif ( $theFunc eq "LISTJOIN" ) { 1025 my ( $sep, $str ) = _properSplit( $theAttr, 2 ); 1026 $str = "" unless ( defined($str) ); 1027 $result = _listToDelimitedString( getList($str) ); 1028 $sep = ", " unless ($sep); 1029 $sep =~ s/\$comma/,/go; 1030 $sep =~ s/\$sp/ /go; 1031 $sep =~ s/\$n/\n/go; 877 1032 $result =~ s/, /$sep/go; 878 1033 879 } elsif( $theFunc eq "LISTSIZE" ) { 880 my @arr = getList( $theAttr ); 1034 } 1035 elsif ( $theFunc eq "LISTSIZE" ) { 1036 my @arr = getList($theAttr); 881 1037 $result = scalar @arr; 882 1038 883 } elsif( $theFunc eq "LISTSORT" ) { 1039 } 1040 elsif ( $theFunc eq "LISTSORT" ) { 884 1041 my $isNumeric = 1; 885 my @arr = map {1042 my @arr = map { 886 1043 s/^\s*//o; 887 1044 s/\s*$//o; 888 $isNumeric = 0 unless ( $_ =~ /^[\+\-]?[0-9\.]+$/ );1045 $isNumeric = 0 unless ( $_ =~ /^[\+\-]?[0-9\.]+$/ ); 889 1046 $_ 890 } getList( $theAttr);891 if ( $isNumeric) {1047 } getList($theAttr); 1048 if ($isNumeric) { 892 1049 @arr = sort { $a <=> $b } @arr; 893 } else { 1050 } 1051 else { 894 1052 @arr = sort @arr; 895 1053 } 896 $result = _listToDelimitedString( @arr ); 897 898 } elsif( $theFunc eq "LISTSHUFFLE" ) { 899 my @arr = getList( $theAttr ); 1054 $result = _listToDelimitedString(@arr); 1055 1056 } 1057 elsif ( $theFunc eq "LISTSHUFFLE" ) { 1058 my @arr = getList($theAttr); 900 1059 my $size = scalar @arr; 901 if ( $size > 1 ) {902 for ( $i = $size; $i--; ) {1060 if ( $size > 1 ) { 1061 for ( $i = $size ; $i-- ; ) { 903 1062 my $j = int( rand( $i + 1 ) ); 904 next if( $i == $j ); 905 @arr[$i, $j] = @arr[$j, $i]; 906 } 907 } 908 $result = _listToDelimitedString( @arr ); 909 910 } elsif( $theFunc eq "LISTRAND" ) { 911 my @arr = getList( $theAttr ); 1063 next if ( $i == $j ); 1064 @arr[ $i, $j ] = @arr[ $j, $i ]; 1065 } 1066 } 1067 $result = _listToDelimitedString(@arr); 1068 1069 } 1070 elsif ( $theFunc eq "LISTRAND" ) { 1071 my @arr = getList($theAttr); 912 1072 my $size = scalar @arr; 913 if ( $size > 1 ) {914 $i = int( rand( $size - 1 ) + 0.5 );1073 if ( $size > 1 ) { 1074 $i = int( rand( $size - 1 ) + 0.5 ); 915 1075 $result = $arr[$i]; 916 } elsif( $size == 1 ) { 1076 } 1077 elsif ( $size == 1 ) { 917 1078 $result = $arr[0]; 918 1079 } 919 1080 920 } elsif( $theFunc eq "LISTREVERSE" ) { 921 my @arr = reverse getList( $theAttr ); 922 $result = _listToDelimitedString( @arr ); 923 924 } elsif( $theFunc eq "LISTTRUNCATE" ) { 925 my( $index, $str ) = _properSplit( $theAttr, 2 ); 926 $index = int( _getNumber( $index ) ); 927 $str = "" unless( defined( $str ) ); 928 my @arr = getList( $str ); 1081 } 1082 elsif ( $theFunc eq "LISTREVERSE" ) { 1083 my @arr = reverse getList($theAttr); 1084 $result = _listToDelimitedString(@arr); 1085 1086 } 1087 elsif ( $theFunc eq "LISTTRUNCATE" ) { 1088 my ( $index, $str ) = _properSplit( $theAttr, 2 ); 1089 $index = int( _getNumber($index) ); 1090 $str = "" unless ( defined($str) ); 1091 my @arr = getList($str); 929 1092 my $size = scalar @arr; 930 if( $index > 0 ) { 931 $index = $size if( $index > $size ); 932 $#arr = $index - 1; 933 $result = _listToDelimitedString( @arr ); 934 } elsif( $index < 0 ) { 935 $index = - $size if( $index < - $size ); 1093 if ( $index > 0 ) { 1094 $index = $size if ( $index > $size ); 1095 $#arr = $index - 1; 1096 $result = _listToDelimitedString(@arr); 1097 } 1098 elsif ( $index < 0 ) { 1099 $index = -$size if ( $index < -$size ); 936 1100 splice( @arr, 0, $size + $index ); 937 $result = _listToDelimitedString( @arr ); 938 } #else result = ''; 939 940 } elsif( $theFunc eq "LISTUNIQUE" ) { 1101 $result = _listToDelimitedString(@arr); 1102 } #else result = ''; 1103 1104 } 1105 elsif ( $theFunc eq "LISTUNIQUE" ) { 941 1106 my %seen = (); 942 my @arr = grep { ! $seen{$_} ++ } getList( $theAttr ); 943 $result = _listToDelimitedString( @arr ); 944 945 } elsif( $theFunc eq "LISTMAP" ) { 1107 my @arr = grep { !$seen{$_}++ } getList($theAttr); 1108 $result = _listToDelimitedString(@arr); 1109 1110 } 1111 elsif ( $theFunc eq "LISTMAP" ) { 1112 946 1113 # LISTMAP(action, item 1, item 2, ...) 947 my( $action, $str ) = _properSplit( $theAttr, 2 ); 948 $action = "" unless( defined( $action ) ); 949 $str = "" unless( defined( $str ) ); 950 # with delay, handle functions in result recursively and clean up unbalanced parenthesis 951 $str =~ s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 1114 my ( $action, $str ) = _properSplit( $theAttr, 2 ); 1115 $action = "" unless ( defined($action) ); 1116 $str = "" unless ( defined($str) ); 1117 1118 # with delay, handle functions in result recursively and clean up unbalanced parenthesis 1119 $str =~ 1120 s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 952 1121 $str =~ s/$escToken\-*[0-9]+([\(\)])/$1/go; 953 1122 my $item = ""; 954 1123 $i = 0; 955 my @arr = 956 map { 957 $item = $_; 958 $_ = $action; 959 $i++; 960 s/\$index/$i/go; 961 $_ .= $item unless( s/\$item/$item/go ); 962 s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 963 s/$escToken\-*[0-9]+([\(\)])/$1/go; 964 $_ 965 } getList( $str ); 966 $result = _listToDelimitedString( @arr ); 967 968 } elsif( $theFunc eq "LISTIF" ) { 1124 my @arr = map { 1125 $item = $_; 1126 $_ = $action; 1127 $i++; 1128 s/\$index/$i/go; 1129 $_ .= $item unless (s/\$item/$item/go); 1130 s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 1131 s/$escToken\-*[0-9]+([\(\)])/$1/go; 1132 $_ 1133 } getList($str); 1134 $result = _listToDelimitedString(@arr); 1135 1136 } 1137 elsif ( $theFunc eq "LISTIF" ) { 1138 969 1139 # LISTIF(cmd, item 1, item 2, ...) 970 my ( $cmd, $str ) = _properSplit( $theAttr, 2 );971 $cmd = "" unless ( defined( $cmd) );1140 my ( $cmd, $str ) = _properSplit( $theAttr, 2 ); 1141 $cmd = "" unless ( defined($cmd) ); 972 1142 $cmd =~ s/^\s*(.*?)\s*$/$1/o; 973 $str = "" unless( defined( $str ) ); 974 # with delay, handle functions in result recursively and clean up unbalanced parenthesis 975 $str =~ s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 1143 $str = "" unless ( defined($str) ); 1144 1145 # with delay, handle functions in result recursively and clean up unbalanced parenthesis 1146 $str =~ 1147 s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 976 1148 $str =~ s/$escToken\-*[0-9]+([\(\)])/$1/go; 977 1149 my $item = ""; … … 979 1151 $i = 0; 980 1152 my @arr = 981 grep { ! /^FOSWIKI_GREP_REMOVE$/ } 982 map { 983 $item = $_; 984 $_ = $cmd; 985 $i++; 986 s/\$index/$i/go; 987 s/\$item/$item/go; 988 s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 989 s/$escToken\-*[0-9]+([\(\)])/$1/go; 990 $eval = safeEvalPerl( $_ ); 991 if( $eval =~ /^ERROR/ ) { 992 $_ = $eval; 993 } elsif( $eval ) { 994 $_ = $item; 995 } else { 996 $_ = "FOSWIKI_GREP_REMOVE"; 997 } 998 } getList( $str ); 999 $result = _listToDelimitedString( @arr ); 1000 1001 } elsif ( $theFunc eq "NOP" ) { 1153 grep { !/^FOSWIKI_GREP_REMOVE$/ } 1154 map { 1155 $item = $_; 1156 $_ = $cmd; 1157 $i++; 1158 s/\$index/$i/go; 1159 s/\$item/$item/go; 1160 s/\$([A-Z]+)$escToken([0-9]+)\((.*?)$escToken\2\)/&doFunc($1,$3)/geo; 1161 s/$escToken\-*[0-9]+([\(\)])/$1/go; 1162 $eval = safeEvalPerl($_); 1163 if ( $eval =~ /^ERROR/ ) { 1164 $_ = $eval; 1165 } 1166 elsif ($eval) { 1167 $_ = $item; 1168 } 1169 else { 1170 $_ = "FOSWIKI_GREP_REMOVE"; 1171 } 1172 } getList($str); 1173 $result = _listToDelimitedString(@arr); 1174 1175 } 1176 elsif ( $theFunc eq "NOP" ) { 1177 1002 1178 # pass everything through, this will allow plugins to defy plugin order 1003 1179 # for example the %SEARCH{}% variable … … 1005 1181 $result = $theAttr; 1006 1182 1007 } elsif ( $theFunc eq "EXISTS" ) { 1183 } 1184 elsif ( $theFunc eq "EXISTS" ) { 1008 1185 $result = Foswiki::Func::topicExists( $web, $theAttr ); 1009 $result = 0 unless( $result ); 1010 } 1011 1012 Foswiki::Func::writeDebug( "- SpreadSheetPlugin::Calc::doFunc: $theFunc( $theAttr ) returns: $result" ) if $debug; 1186 $result = 0 unless ($result); 1187 } 1188 1189 Foswiki::Func::writeDebug( 1190 "- SpreadSheetPlugin::Calc::doFunc: $theFunc( $theAttr ) returns: $result" 1191 ) if $debug; 1013 1192 return $result; 1014 1193 } 1015 1194 1016 1195 # ========================= 1017 sub _listToDelimitedString 1018 { 1196 sub _listToDelimitedString { 1019 1197 my @arr = map { s/^\s*//o; s/\s*$//o; $_ } @_; 1020 1198 my $text = join( ", ", @arr ); … … 1023 1201 1024 1202 # ========================= 1025 sub _properSplit 1026 { 1027 my( $theAttr, $theLevel ) = @_; 1203 sub _properSplit { 1204 my ( $theAttr, $theLevel ) = @_; 1028 1205 1029 1206 # escape commas inside functions 1030 $theAttr =~ s/(\$[A-Z]+$escToken([0-9]+)\(.*?$escToken\2\))/_escapeCommas($1)/geo; 1207 $theAttr =~ 1208 s/(\$[A-Z]+$escToken([0-9]+)\(.*?$escToken\2\))/_escapeCommas($1)/geo; 1209 1031 1210 # split at commas and restore commas inside functions 1032 my @arr = map{ s/<$escToken>/\,/go; $_ } split( /,\s*/, $theAttr, $theLevel ); 1211 my @arr = 1212 map { s/<$escToken>/\,/go; $_ } split( /,\s*/, $theAttr, $theLevel ); 1033 1213 return @arr; 1034 1214 } 1035 1215 1036 1216 # ========================= 1037 sub _escapeCommas 1038 { 1039 my( $theText ) = @_; 1217 sub _escapeCommas { 1218 my ($theText) = @_; 1040 1219 $theText =~ s/\,/<$escToken>/go; 1041 1220 return $theText; … … 1043 1222 1044 1223 # ========================= 1045 sub _getNumber 1046 { 1047 my( $theText ) = @_; 1048 return 0 unless( $theText ); 1049 $theText =~ s/([0-9])\,(?=[0-9]{3})/$1/go; # "1,234,567" ==> "1234567" 1050 if( $theText =~ /[0-9]e/i ) { # "1.5e-3" ==> "0.0015" 1224 sub _getNumber { 1225 my ($theText) = @_; 1226 return 0 unless ($theText); 1227 $theText =~ s/([0-9])\,(?=[0-9]{3})/$1/go; # "1,234,567" ==> "1234567" 1228 if ( $theText =~ /[0-9]e/i ) { # "1.5e-3" ==> "0.0015" 1051 1229 $theText = sprintf "%.20f", $theText; 1052 1230 $theText =~ s/0+$//; 1053 1231 } 1054 unless( $theText =~ s/^.*?(\-?[0-9\.]+).*$/$1/o ) { # "xy-1.23zz" ==> "-1.23" 1232 unless ( $theText =~ s/^.*?(\-?[0-9\.]+).*$/$1/o ) 1233 { # "xy-1.23zz" ==> "-1.23" 1055 1234 $theText = 0; 1056 1235 } 1057 $theText =~ s/^(\-?)0+([0-9])/$1$2/o; # "-0009.12" ==> "-9.12"1058 $theText =~ s/^(\-?)\./${1}0\./o; # "-.25" ==> "-0.25"1059 $theText =~ s/^\-0$/0/o; # "-0" ==> "0"1060 $theText =~ s/\.$//o; # "123." ==> "123"1236 $theText =~ s/^(\-?)0+([0-9])/$1$2/o; # "-0009.12" ==> "-9.12" 1237 $theText =~ s/^(\-?)\./${1}0\./o; # "-.25" ==> "-0.25" 1238 $theText =~ s/^\-0$/0/o; # "-0" ==> "0" 1239 $theText =~ s/\.$//o; # "123." ==> "123" 1061 1240 return $theText; 1062 1241 } 1063 1242 1064 1243 # ========================= 1065 sub safeEvalPerl 1066 { 1067 my( $theText ) = @_; 1244 sub safeEvalPerl { 1245 my ($theText) = @_; 1246 1068 1247 # Allow only simple math with operators - + * / % ( ) 1069 $theText =~ s/\%\s*[^\-\+\*\/0-9\.\(\)]+//go; # defuse %hash but keep modulus 1070 # keep only numbers and operators (shh... don't tell anyone, we support comparison operators) 1248 $theText =~ 1249 s/\%\s*[^\-\+\*\/0-9\.\(\)]+//go; # defuse %hash but keep modulus 1250 # keep only numbers and operators (shh... don't tell anyone, we support comparison operators) 1071 1251 $theText =~ s/[^\!\<\=\>\-\+\*\/\%0-9e\.\(\)]*//go; 1072 $theText =~ s/(^|[^0-9])e/$1/go; # remove "e"-s unless in expression such as "123e-4" 1252 $theText =~ 1253 s/(^|[^0-9])e/$1/go; # remove "e"-s unless in expression such as "123e-4" 1073 1254 $theText =~ /(.*)/; 1074 $theText = $1; # untainted variable 1075 return "" unless( $theText ); 1076 local $SIG{__DIE__} = sub { Foswiki::Func::writeDebug($_[0]); warn $_[0] }; 1255 $theText = $1; # untainted variable 1256 return "" unless ($theText); 1257 local $SIG{__DIE__} = 1258 sub { Foswiki::Func::writeDebug( $_[0] ); warn $_[0] }; 1077 1259 my $result = eval $theText; 1078 if( $@ ) { 1260 1261 if ($@) { 1079 1262 $result = $@; 1080 1263 $result =~ s/[\n\r]//go; 1081 $result =~ s/\[[^\]]+.*view.*?\:\s?//o; # Cut "[Mon Mar 15 23:31:39 2004] view: " 1082 $result =~ s/\s?at \(eval.*?\)\sline\s?[0-9]*\.?\s?//go; # Cut "at (eval 51) line 2." 1264 $result =~ 1265 s/\[[^\]]+.*view.*?\:\s?//o; # Cut "[Mon Mar 15 23:31:39 2004] view: " 1266 $result =~ s/\s?at \(eval.*?\)\sline\s?[0-9]*\.?\s?//go 1267 ; # Cut "at (eval 51) line 2." 1083 1268 $result = "ERROR: $result"; 1084 1269 1085 } else { 1086 $result = 0 unless( $result ); # logical false is "0" 1270 } 1271 else { 1272 $result = 0 unless ($result); # logical false is "0" 1087 1273 } 1088 1274 return $result; … … 1090 1276 1091 1277 # ========================= 1092 sub getListAsInteger 1093 { 1094 my( $theAttr ) = @_; 1095 1096 my $val = 0; 1097 my @list = getList( $theAttr ); 1098 (my $baz = "foo") =~ s/foo//; # reset search vars. defensive coding 1099 for my $i (0 .. $#list ) { 1278 sub getListAsInteger { 1279 my ($theAttr) = @_; 1280 1281 my $val = 0; 1282 my @list = getList($theAttr); 1283 ( my $baz = "foo" ) =~ s/foo//; # reset search vars. defensive coding 1284 for my $i ( 0 .. $#list ) { 1100 1285 $val = $list[$i]; 1286 1101 1287 # search first integer pattern, skip over HTML tags 1102 if( $val =~ /^\s*(?:<[^>]*>)*([\-\+]*[0-9]+).*/o ) { 1103 $list[$i] = $1; # untainted variable, possibly undef 1104 } else { 1288 if ( $val =~ /^\s*(?:<[^>]*>)*([\-\+]*[0-9]+).*/o ) { 1289 $list[$i] = $1; # untainted variable, possibly undef 1290 } 1291 else { 1105 1292 $list[$i] = undef; 1106 1293 } … … 1110 1297 1111 1298 # ========================= 1112 sub getListAsFloat 1113 { 1114 my( $theAttr ) = @_; 1115 1116 my $val = 0; 1117 my @list = getList( $theAttr ); 1118 (my $baz = "foo") =~ s/foo//; # reset search vars. defensive coding 1119 for my $i (0 .. $#list ) { 1299 sub getListAsFloat { 1300 my ($theAttr) = @_; 1301 1302 my $val = 0; 1303 my @list = getList($theAttr); 1304 ( my $baz = "foo" ) =~ s/foo//; # reset search vars. defensive coding 1305 for my $i ( 0 .. $#list ) { 1120 1306 $val = $list[$i] || ""; 1307 1121 1308 # search first float pattern, skip over HTML tags 1122 if( $val =~ /^\s*(?:<[^>]*>)*\$?([\-\+]*[0-9\.]+).*/o ) { 1123 $list[$i] = $1; # untainted variable, possibly undef 1124 } else { 1309 if ( $val =~ /^\s*(?:<[^>]*>)*\$?([\-\+]*[0-9\.]+).*/o ) { 1310 $list[$i] = $1; # untainted variable, possibly undef 1311 } 1312 else { 1125 1313 $list[$i] = undef; 1126 1314 } … … 1130 1318 1131 1319 # ========================= 1132 sub getListAsDays 1133 { 1134 my( $theAttr ) = @_; 1320 sub getListAsDays { 1321 my ($theAttr) = @_; 1135 1322 1136 1323 # contributed by by SvenDowideit - 07 Mar 2003; modified by PTh 1137 1324 my $val = 0; 1138 my @arr = getList( $theAttr);1139 ( my $baz = "foo") =~ s/foo//;# reset search vars. defensive coding1140 for my $i ( 0 .. $#arr ) {1325 my @arr = getList($theAttr); 1326 ( my $baz = "foo" ) =~ s/foo//; # reset search vars. defensive coding 1327 for my $i ( 0 .. $#arr ) { 1141 1328 $val = $arr[$i] || ""; 1329 1142 1330 # search first float pattern 1143 if( $val =~ /^\s*([\-\+]*[0-9\.]+)\s*d/oi ) { 1144 $arr[$i] = $1; # untainted variable, possibly undef 1145 } elsif( $val =~ /^\s*([\-\+]*[0-9\.]+)\s*w/oi ) { 1146 $arr[$i] = 5 * $1; # untainted variable, possibly undef 1147 } elsif( $val =~ /^\s*([\-\+]*[0-9\.]+)\s*h/oi ) { 1148 $arr[$i] = $1 / 8; # untainted variable, possibly undef 1149 } elsif( $val =~ /^\s*([\-\+]*[0-9\.]+)/o ) { 1150 $arr[$i] = $1; # untainted variable, possibly undef 1151 } else { 1331 if ( $val =~ /^\s*([\-\+]*[0-9\.]+)\s*d/oi ) { 1332 $arr[$i] = $1; # untainted variable, possibly undef 1333 } 1334 elsif ( $val =~ /^\s*([\-\+]*[0-9\.]+)\s*w/oi ) { 1335 $arr[$i] = 5 * $1; # untainted variable, possibly undef 1336 } 1337 elsif ( $val =~ /^\s*([\-\+]*[0-9\.]+)\s*h/oi ) { 1338 $arr[$i] = $1 / 8; # untainted variable, possibly undef 1339 } 1340 elsif ( $val =~ /^\s*([\-\+]*[0-9\.]+)/o ) { 1341 $arr[$i] = $1; # untainted variable, possibly undef 1342 } 1343 else { 1152 1344 $arr[$i] = undef; 1153 1345 } … … 1157 1349 1158 1350 # ========================= 1159 sub getList 1160 { 1161 my( $theAttr ) = @_; 1351 sub getList { 1352 my ($theAttr) = @_; 1162 1353 1163 1354 my @list = (); 1164 foreach( split( /,\s*/, $theAttr ) ) { 1165 if( m/\s*R([0-9]+)\:C([0-9]+)\s*\.\.+\s*R([0-9]+)\:C([0-9]+)/ ) { 1355 foreach ( split( /,\s*/, $theAttr ) ) { 1356 if (m/\s*R([0-9]+)\:C([0-9]+)\s*\.\.+\s*R([0-9]+)\:C([0-9]+)/) { 1357 1166 1358 # table range 1167 push( @list, getTableRange( $_ ) ); 1168 } else { 1359 push( @list, getTableRange($_) ); 1360 } 1361 else { 1362 1169 1363 # list item 1170 $list[ $#list+1] = $_;1364 $list[ $#list + 1 ] = $_; 1171 1365 } 1172 1366 } … … 1175 1369 1176 1370 # ========================= 1177 sub getTableRange 1178 { 1179 my( $theAttr ) = @_; 1371 sub getTableRange { 1372 my ($theAttr) = @_; 1180 1373 1181 1374 my @arr = (); 1182 if ( $rPos < 0 ) {1375 if ( $rPos < 0 ) { 1183 1376 return @arr; 1184 1377 } 1185 1378 1186 Foswiki::Func::writeDebug( "- SpreadSheetPlugin::Calc::getTableRange( $theAttr )" ) if $debug; 1187 unless( $theAttr =~ /\s*R([0-9]+)\:C([0-9]+)\s*\.\.+\s*R([0-9]+)\:C([0-9]+)/ ) { 1379 Foswiki::Func::writeDebug( 1380 "- SpreadSheetPlugin::Calc::getTableRange( $theAttr )") 1381 if $debug; 1382 unless ( 1383 $theAttr =~ /\s*R([0-9]+)\:C([0-9]+)\s*\.\.+\s*R([0-9]+)\:C([0-9]+)/ ) 1384 { 1188 1385 return @arr; 1189 1386 } … … 1192 1389 my $r2 = $3 - 1; 1193 1390 my $c2 = $4 - 1; 1194 my $r = 0;1195 my $c = 0;1196 if ( $c1 < 0) { $c1 = 0; }1197 if ( $c2 < 0) { $c2 = 0; }1198 if ( $c2 < $c1) { $c = $c1; $c1 = $c2; $c2 = $c; }1199 if ( $r1 > $rPos ) { $r1 = $rPos; }1200 if ( $r1 < 0 ){ $r1 = 0; }1201 if ( $r2 > $rPos ) { $r2 = $rPos; }1202 if ( $r2 < 0 ){ $r2 = 0; }1203 if ( $r2 < $r1) { $r = $r1; $r1 = $r2; $r2 = $r; }1391 my $r = 0; 1392 my $c = 0; 1393 if ( $c1 < 0 ) { $c1 = 0; } 1394 if ( $c2 < 0 ) { $c2 = 0; } 1395 if ( $c2 < $c1 ) { $c = $c1; $c1 = $c2; $c2 = $c; } 1396 if ( $r1 > $rPos ) { $r1 = $rPos; } 1397 if ( $r1 < 0 ) { $r1 = 0; } 1398 if ( $r2 > $rPos ) { $r2 = $rPos; } 1399 if ( $r2 < 0 ) { $r2 = 0; } 1400 if ( $r2 < $r1 ) { $r = $r1; $r1 = $r2; $r2 = $r; } 1204 1401 1205 1402 my $pRow = (); … … 1207 1404 $pRow = $tableMatrix[$r]; 1208 1405 for $c ( $c1 .. $c2 ) { 1209 if ( $c < @$pRow ) {1406 if ( $c < @$pRow ) { 1210 1407 push( @arr, $$pRow[$c] ); 1211 1408 } 1212 1409 } 1213 1410 } 1214 Foswiki::Func::writeDebug( "- SpreadSheetPlugin::Calc::getTableRange() returns @arr" ) if $debug; 1411 Foswiki::Func::writeDebug( 1412 "- SpreadSheetPlugin::Calc::getTableRange() returns @arr") 1413 if $debug; 1215 1414 return @arr; 1216 1415 } 1217 1416 1218 1417 # ========================= 1219 sub _date2serial 1220 { 1221 my ( $theText ) = @_; 1222 1223 my $sec = 0; my $min = 0; my $hour = 0; my $day = 1; my $mon = 0; my $year = 0; 1224 1225 if( $theText =~ m|([0-9]{1,2})[-\s/]+([A-Z][a-z][a-z])[-\s/]+([0-9]{4})[-\s/]+([0-9]{1,2}):([0-9]{1,2})| ) { 1226 # "31 Dec 2003 - 23:59", "31-Dec-2003 - 23:59", "31 Dec 2003 - 23:59 - any suffix" 1227 $day = $1; $mon = $mon2num{$2} || 0; $year = $3 - 1900; $hour = $4; $min = $5; 1228 } elsif( $theText =~ m|([0-9]{1,2})[-\s/]+([A-Z][a-z][a-z])[-\s/]+([0-9]{2,4})| ) { 1418 sub _date2serial { 1419 my ($theText) = @_; 1420 1421 my $sec = 0; 1422 my $min = 0; 1423 my $hour = 0; 1424 my $day = 1; 1425 my $mon = 0; 1426 my $year = 0; 1427 1428 if ( $theText =~ 1429 m|([0-9]{1,2})[-\s/]+([A-Z][a-z][a-z])[-\s/]+([0-9]{4})[-\s/]+([0-9]{1,2}):([0-9]{1,2})| 1430 ) 1431 { 1432 1433 # "31 Dec 2003 - 23:59", "31-Dec-2003 - 23:59", "31 Dec 2003 - 23:59 - any suffix" 1434 $day = $1; 1435 $mon = $mon2num{$2} || 0; 1436 $year = $3 - 1900; 1437 $hour = $4; 1438 $min = $5; 1439 } 1440 elsif ( 1441 $theText =~ m|([0-9]{1,2})[-\s/]+([A-Z][a-z][a-z])[-\s/]+([0-9]{2,4})| ) 1442 { 1443 1229 1444 # "31 Dec 2003", "31 Dec 03", "31-Dec-2003", "31/Dec/2003" 1230 $day = $1; $mon = $mon2num{$2} || 0; $year = $3; 1231 $year += 100 if( $year < 80 ); # "05" --> "105" (leave "99" as is) 1232 $year -= 1900 if( $year >= 1900 ); # "2005" --> "105" 1233 } elsif( $theText =~ m|([0-9]{4})[-/\.]([0-9]{1,2})[-/\.]([0-9]{1,2})[-/\.\,\s]+([0-9]{1,2})[-\:/\.]([0-9]{1,2})[-\:/\.]([0-9]{1,2})| ) { 1445 $day = $1; 1446 $mon = $mon2num{$2} || 0; 1447 $year = $3; 1448 $year += 100 if ( $year < 80 ); # "05" --> "105" (leave "99" as is) 1449 $year -= 1900 if ( $year >= 1900 ); # "2005" --> "105" 1450 } 1451 elsif ( $theText =~ 1452 m|([0-9]{4})[-/\.]([0-9]{1,2})[-/\.]([0-9]{1,2})[-/\.\,\s]+([0-9]{1,2})[-\:/\.]([0-9]{1,2})[-\:/\.]([0-9]{1,2})| 1453 ) 1454 { 1455 1234 1456 # "2003/12/31 23:59:59", "2003-12-31-23-59-59", "2003.12.31.23.59.59" 1235 $year = $1 - 1900; $mon = $2 - 1; $day = $3; $hour = $4; $min = $5; $sec = $6; 1236 } elsif( $theText =~ m|([0-9]{4})[-/\.]([0-9]{1,2})[-/\.]([0-9]{1,2})[-/\.\,\s]+([0-9]{1,2})[-\:/\.]([0-9]{1,2})| ) { 1457 $year = $1 - 1900; 1458 $mon = $2 - 1; 1459 $day = $3; 1460 $hour = $4; 1461 $min = $5; 1462 $sec = $6; 1463 } 1464 elsif ( $theText =~ 1465 m|([0-9]{4})[-/\.]([0-9]{1,2})[-/\.]([0-9]{1,2})[-/\.\,\s]+([0-9]{1,2})[-\:/\.]([0-9]{1,2})| 1466 ) 1467 { 1468 1237 1469 # "2003/12/31 23:59", "2003-12-31-23-59", "2003.12.31.23.59" 1238 $year = $1 - 1900; $mon = $2 - 1; $day = $3; $hour = $4; $min = $5; 1239 } elsif( $theText =~ m|([0-9]{4})[-/]([0-9]{1,2})[-/]([0-9]{1,2})| ) { 1470 $year = $1 - 1900; 1471 $mon = $2 - 1; 1472 $day = $3; 1473 $hour = $4; 1474 $min = $5; 1475 } 1476 elsif ( $theText =~ m|([0-9]{4})[-/]([0-9]{1,2})[-/]([0-9]{1,2})| ) { 1477 1240 1478 # "2003/12/31", "2003-12-31" 1241 $year = $1 - 1900; $mon = $2 - 1; $day = $3; 1242 } elsif( $theText =~ m|([0-9]{1,2})[-/]([0-9]{1,2})[-/]([0-9]{2,4})| ) { 1243 # "12/31/2003", "12/31/03", "12-31-2003" 1244 # (shh, don't tell anyone that we support ambiguous American dates, my boss asked me to) 1245 $year = $3; $mon = $1 - 1; $day = $2; 1246 $year += 100 if( $year < 80 ); # "05" --> "105" (leave "99" as is) 1247 $year -= 1900 if( $year >= 1900 ); # "2005" --> "105" 1248 } else { 1479 $year = $1 - 1900; 1480 $mon = $2 - 1; 1481 $day = $3; 1482 } 1483 elsif ( $theText =~ m|([0-9]{1,2})[-/]([0-9]{1,2})[-/]([0-9]{2,4})| ) { 1484 1485 # "12/31/2003", "12/31/03", "12-31-2003" 1486 # (shh, don't tell anyone that we support ambiguous American dates, my boss asked me to) 1487 $year = $3; 1488 $mon = $1 - 1; 1489 $day = $2; 1490 $year += 100 if ( $year < 80 ); # "05" --> "105" (leave "99" as is) 1491 $year -= 1900 if ( $year >= 1900 ); # "2005" --> "105" 1492 } 1493 else { 1494 1249 1495 # unsupported format 1250 1496 return 0; 1251 1497 } 1252 if( ( $sec > 60 ) || ( $min > 59 ) || ( $hour > 23 ) || ( $day < 1 ) || ( $day > 31 ) || ( $mon > 11 ) ) { 1498 if ( ( $sec > 60 ) 1499 || ( $min > 59 ) 1500 || ( $hour > 23 ) 1501 || ( $day < 1 ) 1502 || ( $day > 31 ) 1503 || ( $mon > 11 ) ) 1504 { 1505 1253 1506 # unsupported, out of range 1254 1507 return 0; … … 1261 1514 # intended. Especially the function WORKINGDAYS suffer from this. 1262 1515 # and it also causes surprises with respect to daylight saving time 1263 my $timeislocal = Foswiki::Func::getPreferencesFlag( "SPREADSHEETPLUGIN_TIMEISLOCAL" ) || 0; 1516 my $timeislocal = 1517 Foswiki::Func::getPreferencesFlag("SPREADSHEETPLUGIN_TIMEISLOCAL") || 0; 1264 1518 $timeislocal = Foswiki::Func::isTrue($timeislocal); 1265 1519 1266 if ( $theText =~ /local/i ) {1520 if ( $theText =~ /local/i ) { 1267 1521 return timelocal( $sec, $min, $hour, $day, $mon, $year ); 1268 } elsif( $theText =~ /gmt/i ) { 1522 } 1523 elsif ( $theText =~ /gmt/i ) { 1269 1524 return timegm( $sec, $min, $hour, $day, $mon, $year ); 1270 } elsif( $timeislocal ) { 1525 } 1526 elsif ($timeislocal) { 1271 1527 return timelocal( $sec, $min, $hour, $day, $mon, $year ); 1272 } else { 1528 } 1529 else { 1273 1530 return timegm( $sec, $min, $hour, $day, $mon, $year ); 1274 1531 } … … 1276 1533 1277 1534 # ========================= 1278 sub _serial2date 1279 { 1535 sub _serial2date { 1280 1536 my ( $theTime, $theStr, $isGmt ) = @_; 1281 1537 1282 my( $sec, $min, $hour, $day, $mon, $year, $wday, $yday ) = localtime( $theTime ); 1283 ( $sec, $min, $hour, $day, $mon, $year, $wday, $yday ) = gmtime( $theTime ) if( $isGmt ); 1538 my ( $sec, $min, $hour, $day, $mon, $year, $wday, $yday ) = 1539 localtime($theTime); 1540 ( $sec, $min, $hour, $day, $mon, $year, $wday, $yday ) = gmtime($theTime) 1541 if ($isGmt); 1284 1542 1285 1543 $theStr =~ s/\$sec[o]?[n]?[d]?[s]?/sprintf("%.2u",$sec)/geoi; … … 1300 1558 1301 1559 # ========================= 1302 sub _properSpace 1303 { 1304 my ( $theStr ) = @_; 1560 sub _properSpace { 1561 my ($theStr) = @_; 1305 1562 1306 1563 # FIXME: I18N 1307 1564 1308 unless( $dontSpaceRE ) { 1309 $dontSpaceRE = &Foswiki::Func::getPreferencesValue( "DONTSPACE" ) || 1310 &Foswiki::Func::getPreferencesValue( "SPREADSHEETPLUGIN_DONTSPACE" ) || 1311 "CodeWarrior, MacDonald, McIntosh, RedHat, SuSE"; 1565 unless ($dontSpaceRE) { 1566 $dontSpaceRE = 1567 &Foswiki::Func::getPreferencesValue("DONTSPACE") 1568 || &Foswiki::Func::getPreferencesValue("SPREADSHEETPLUGIN_DONTSPACE") 1569 || "CodeWarrior, MacDonald, McIntosh, RedHat, SuSE"; 1312 1570 $dontSpaceRE =~ s/[^a-zA-Z0-9\,\s]//go; 1313 $dontSpaceRE = "(" . join( "|", split( /[\,\s]+/, $dontSpaceRE ) ) . ")"; 1571 $dontSpaceRE = 1572 "(" . join( "|", split( /[\,\s]+/, $dontSpaceRE ) ) . ")"; 1573 1314 1574 # Example: "(RedHat|McIntosh)" 1315 1575 } 1316 $theStr =~ s/$dontSpaceRE/_spaceWikiWord( $1, "<DONT_SPACE>" )/geo; # e.g. "Mc<DONT_SPACE>Intosh" 1317 $theStr =~ s/(^|[\s\(]|\]\[)([a-zA-Z0-9]+)/$1 . _spaceWikiWord( $2, " " )/geo; 1318 $theStr =~ s/<DONT_SPACE>//go; # remove "<DONT_SPACE>" marker 1576 $theStr =~ s/$dontSpaceRE/_spaceWikiWord( $1, "<DONT_SPACE>" )/geo 1577 ; # e.g. "Mc<DONT_SPACE>Intosh" 1578 $theStr =~ 1579 s/(^|[\s\(]|\]\[)([a-zA-Z0-9]+)/$1 . _spaceWikiWord( $2, " " )/geo; 1580 $theStr =~ s/<DONT_SPACE>//go; # remove "<DONT_SPACE>" marker 1319 1581 1320 1582 return $theStr; … … 1322 1584 1323 1585 # ========================= 1324 sub _spaceWikiWord 1325 { 1586 sub _spaceWikiWord { 1326 1587 my ( $theStr, $theSpacer ) = @_; 1327 1588 … … 1333 1594 1334 1595 # ========================= 1335 sub _workingDays 1336 { 1596 sub _workingDays { 1337 1597 my ( $start, $end ) = @_; 1338 1598 1339 1599 # Calculate working days between two times. 1340 # Times are standard system times (secs since 1970). 1600 # Times are standard system times (secs since 1970). 1341 1601 # Working days are Monday through Friday (sorry, Israel!) 1342 1602 # A day has 60 * 60 * 24 = 86400 sec 1343 1603 1344 1604 # We allow the two dates to be swapped around 1345 ( $start, $end) = ($end, $start) if ( $start > $end );1605 ( $start, $end ) = ( $end, $start ) if ( $start > $end ); 1346 1606 use integer; 1347 1607 my $elapsed_days = int( ( $end - $start ) / 86400 ); 1348 my $whole_weeks = int( $elapsed_days / 7 );1349 my $extra_days = $elapsed_days - ( $whole_weeks * 7 );1350 my $work_days = $elapsed_days - ($whole_weeks * 2);1351 1352 for ( my $i = 0 ; $i < $extra_days; $i++ ) {1353 my $tempwday = ( gmtime( $end - $i * 86400))[6];1608 my $whole_weeks = int( $elapsed_days / 7 ); 1609 my $extra_days = $elapsed_days - ( $whole_weeks * 7 ); 1610 my $work_days = $elapsed_days - ( $whole_weeks * 2 ); 1611 1612 for ( my $i = 0 ; $i < $extra_days ; $i++ ) { 1613 my $tempwday = ( gmtime( $end - $i * 86400 ) )[6]; 1354 1614 if ( $tempwday == 6 || $tempwday == 0 ) { 1355 1615 $work_days--; -
trunk/TablePlugin/lib/Foswiki/Plugins/TablePlugin.pm
r3457 r3947 27 27 package Foswiki::Plugins::TablePlugin; 28 28 29 use Foswiki::Func (); # The plugins API30 use Foswiki::Plugins (); # For the API version29 use Foswiki::Func (); # The plugins API 30 use Foswiki::Plugins (); # For the API version 31 31 32 32 use vars qw( $topic $installWeb $initialised ); … … 34 34 our $VERSION = '$Rev$'; 35 35 our $RELEASE = '1.038'; 36 our $SHORTDESCRIPTION = 'Control attributes of tables and sorting of table columns'; 36 our $SHORTDESCRIPTION = 37 'Control attributes of tables and sorting of table columns'; 37 38 our $NO_PREFS_IN_TOPIC = 1; 38 39 39 40 sub initPlugin { 40 my ( $web, $user );41 my ( $web, $user ); 41 42 ( $topic, $web, $user, $installWeb ) = @_; 42 43 43 44 # check for Plugins.pm versions 44 if( $Foswiki::Plugins::VERSION < 1.026 ) { 45 Foswiki::Func::writeWarning( 'Version mismatch between TablePlugin and Plugins.pm' ); 45 if ( $Foswiki::Plugins::VERSION < 1.026 ) { 46 Foswiki::Func::writeWarning( 47 'Version mismatch between TablePlugin and Plugins.pm'); 46 48 return 0; 47 49 } … … 58 60 ### my ( $text, $removed ) = @_; 59 61 60 my $sort = Foswiki::Func::getPreferencesValue( 'TABLEPLUGIN_SORT')62 my $sort = Foswiki::Func::getPreferencesValue('TABLEPLUGIN_SORT') 61 63 || 'all'; 62 return unless ($sort && $sort =~ /^(all|attachments)$/) || 63 $_[0] =~ /%TABLE{.*?}%/; 64 return 65 unless ( $sort && $sort =~ /^(all|attachments)$/ ) 66 || $_[0] =~ /%TABLE{.*?}%/; 64 67 65 68 # on-demand inclusion 66 69 require Foswiki::Plugins::TablePlugin::Core; 67 Foswiki::Plugins::TablePlugin::Core::handler( @_);70 Foswiki::Plugins::TablePlugin::Core::handler(@_); 68 71 } 69 72 -
trunk/TablePlugin/lib/Foswiki/Plugins/TablePlugin/Core.pm
r3457 r3947 1726 1726 $pluginAttrs = 1727 1727 Foswiki::Func::getPreferencesValue('TABLEPLUGIN_TABLEATTRIBUTES') 1728 || 'tableborder="1" cellpadding="0" cellspacing="0" valign="top" headercolor="#ffffff" headerbg="#687684" headerbgsorted="#334455" databg="#ffffff,#edf4f9" databgsorted="#f1f7fc,#ddebf6" tablerules="rows"';1728 || 'tableborder="1" cellpadding="0" cellspacing="0" valign="top" headercolor="#ffffff" headerbg="#687684" headerbgsorted="#334455" databg="#ffffff,#edf4f9" databgsorted="#f1f7fc,#ddebf6" tablerules="rows"'; 1729 1729 $prefsAttrs = Foswiki::Func::getPreferencesValue('TABLEATTRIBUTES'); 1730 1730 _setDefaults(); -
trunk/TinyMCEPlugin/lib/Foswiki/Plugins/TinyMCEPlugin.pm
r3777 r3947 26 26 # allow other extensions to override them. 27 27 # PLEASE ENSURE THE PLUGIN TOPIC EXAMPLES ARE KEPT IN SYNCH! 28 our $defaultINIT = <<'HERE';28 our $defaultINIT = <<'HERE'; 29 29 mode:"textareas", 30 30 editor_selector : "foswikiWysiwygEdit", … … 76 76 content_css : "%PUBURLPATH%/%SYSTEMWEB%/TinyMCEPlugin/wysiwyg%IF{"$TINYMCEPLUGIN_DEBUG" then="_src"}%.css,%PUBURLPATH%/%SYSTEMWEB%/SkinTemplates/base.css,%FOSWIKI_STYLE_URL%,%FOSWIKI_COLORS_URL%" 77 77 HERE 78 our %defaultINIT_BROWSER = (79 MSIE => 'paste_auto_cleanup_on_paste : true',80 OPERA => '',81 GECKO => 'gecko_spellcheck : true',78 our %defaultINIT_BROWSER = ( 79 MSIE => 'paste_auto_cleanup_on_paste : true', 80 OPERA => '', 81 GECKO => 'gecko_spellcheck : true', 82 82 SAFARI => '', 83 );83 ); 84 84 85 85 use Foswiki::Func (); … … 180 180 } 181 181 if ($extras) { 182 $extras = Foswiki::Func::getPreferencesValue( 183 'TINYMCEPLUGIN_INIT_' . $extras ) || $defaultINIT_BROWSER{$extras}; 182 $extras = 183 Foswiki::Func::getPreferencesValue( 'TINYMCEPLUGIN_INIT_' . $extras ) 184 || $defaultINIT_BROWSER{$extras}; 184 185 if ( defined $extras ) { 185 186 $init = join( ',', ( split( ',', $init ), split( ',', $extras ) ) ); -
trunk/TwistyPlugin/lib/Foswiki/Plugins/TwistyPlugin.pm
r3449 r3947 26 26 27 27 use Foswiki::Func (); 28 use CGI::Cookie ();28 use CGI::Cookie (); 29 29 use strict; 30 30 31 use vars 32 qw( @modes $doneHeader $doneDefaults $twistyCount 31 use vars qw( @modes $doneHeader $doneDefaults $twistyCount 33 32 $prefMode $prefShowLink $prefHideLink $prefRemember); 34 33 … … 36 35 37 36 our $RELEASE = '1.5.2'; 38 our $SHORTDESCRIPTION = 'Twisty section Javascript library to open/close content dynamically'; 37 our $SHORTDESCRIPTION = 38 'Twisty section Javascript library to open/close content dynamically'; 39 39 our $NO_PREFS_IN_TOPIC = 1; 40 40 … … 100 100 # Untaint is required if use locale is on 101 101 Foswiki::Func::loadTemplate( 102 Foswiki::Sandbox::untaintUnchecked( lc($pluginName)) );102 Foswiki::Sandbox::untaintUnchecked( lc($pluginName) ) ); 103 103 my $header = Foswiki::Func::expandTemplate('twisty:header'); 104 104 Foswiki::Func::addToHEAD( $pluginName, $header ); … … 248 248 ? '<img src="' . $imgleft . '" border="0" alt="" />' 249 249 : ''; 250 250 251 251 my $imgLinkTag = 252 252 '<a href="#">' 253 253 . $imgLeftTag 254 . '<span class="foswikiLinkLabel foswikiUnvisited' . $linkClass . '">' 254 . '<span class="foswikiLinkLabel foswikiUnvisited' 255 . $linkClass . '">' 255 256 . $link 256 257 . '</span>' -
trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin.pm
r3945 r3947 30 30 use Encode (); 31 31 32 use Foswiki::Func ();# The plugins API33 use Foswiki::Plugins (); # For the API version32 use Foswiki::Func (); # The plugins API 33 use Foswiki::Plugins (); # For the API version 34 34 use Foswiki::Plugins::WysiwygPlugin::Constants (); 35 35 … … 771 771 my ( $session, $plugin, $verb, $response ) = @_; 772 772 my $query = Foswiki::Func::getCgiQuery(); 773 773 774 # Item1458 ignore uploads not using POST 774 if ( $query && $query->method() && uc($query->method()) ne 'POST') {775 returnRESTResult( $response, 405, "Method not Allowed");775 if ( $query && $query->method() && uc( $query->method() ) ne 'POST' ) { 776 returnRESTResult( $response, 405, "Method not Allowed" ); 776 777 return; 777 778 } -
trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML.pm
r3897 r3947 224 224 225 225 sub _default { 226 my ( $this, $event, $text ) = @_; 226 my ( $this, $event, $text ) = @_; 227 227 228 # Unexpected $event event from HTML::Parser; text contains '$text' 228 ASSERT(0);229 ASSERT(0); 229 230 } 230 231 -
trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/Node.pm
r3945 r3947 446 446 # If this node has the specified class, insert a new "span" node with that 447 447 # class between this node and all of this node's children. 448 sub _moveClassToSpan 449 { 450 my $this = shift; 448 sub _moveClassToSpan { 449 my $this = shift; 451 450 my $class = shift; 452 451 453 if ( $this->{tag} and 454 lc($this->{tag}) ne 'span' and 455 $this->_removeClass($class) ) { 456 457 my $newspan = new Foswiki::Plugins::WysiwygPlugin::HTML2TML::Node( $this->{context}, 'span', { class => $class } ); 452 if ( $this->{tag} 453 and lc( $this->{tag} ) ne 'span' 454 and $this->_removeClass($class) ) 455 { 456 457 my $newspan = 458 new Foswiki::Plugins::WysiwygPlugin::HTML2TML::Node( $this->{context}, 459 'span', { class => $class } ); 458 460 my $kid = $this->{head}; 459 461 while ($kid) { -
trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/HTML2TML/WC.pm
r3944 r3947 43 43 use strict; 44 44 45 our ( $NO_TML, $NO_HTML, $NO_BLOCK_TML, $NOP_ALL, $BLOCK_TML, $BR2NL, 46 $CHECKn, $CHECKw, $CHECKs, $CHECK1, $CHECK2, $NBSP, $NBBR, $TAB, $PON, $POFF, $WS, 47 $VERY_CLEAN, $PROTECTED, $KEEP_ENTITIES, $KEEP_WS ); 45 our ( 46 $NO_TML, $NO_HTML, $NO_BLOCK_TML, $NOP_ALL, 47 $BLOCK_TML, $BR2NL, $CHECKn, $CHECKw, 48 $CHECKs, $CHECK1, $CHECK2, $NBSP, 49 $NBBR, $TAB, $PON, $POFF, 50 $WS, $VERY_CLEAN, $PROTECTED, $KEEP_ENTITIES, 51 $KEEP_WS 52 ); 48 53 49 54 $NO_HTML = 1 << 0; -
trunk/WysiwygPlugin/lib/Foswiki/Plugins/WysiwygPlugin/TML2HTML.pm
r3896 r3947 788 788 } 789 789 790 $cell = ' ' .$cell if $cell =~ /^(?:\*|==?|__?)[^\s]/;791 $cell = $cell .' ' if $cell =~ /[^\s](?:\*|==?|__?)$/;792 793 push( @tr, { fn => $fn, attr => $attr, text => $cell } ); 790 $cell = ' ' . $cell if $cell =~ /^(?:\*|==?|__?)[^\s]/; 791 $cell = $cell . ' ' if $cell =~ /[^\s](?:\*|==?|__?)$/; 792 793 push( @tr, { fn => $fn, attr => $attr, text => $cell } ); 794 794 } 795 795 -
trunk/WysiwygPlugin/test/unit/WysiwygPlugin/TranslatorTests.pm
r3944 r3947 39 39 my $HTML2TML = 1 << 1; # test html => finaltml (default tml) 40 40 my $ROUNDTRIP = 1 << 2; # test tml => => finaltml 41 # Note: ROUNDTRIP is *not* the same as the combination of 41 42 # Note: ROUNDTRIP is *not* the same as the combination of 42 43 # HTML2TML and TML2HTML. The HTML and TML comparisons are both 43 44 # somewhat "flexible". This is necessry because, for example, 44 45 # the nature of whitespace in the TML may change. 45 # ROUNDTRIP tests are intended to isolate gradual degradation 46 # ROUNDTRIP tests are intended to isolate gradual degradation 46 47 # of the TML, where TML -> HTML -> not quite TML -> HTML 47 48 # -> even worse TML, ad nauseum … … 62 63 63 64 # Each testcase is a subhash with fields as follows: 64 # exec => $TML2HTML to test TML -> HTML, $HTML2TML to test HTML -> TML, 65 # exec => $TML2HTML to test TML -> HTML, $HTML2TML to test HTML -> TML, 65 66 # $ROUNDTRIP to test TML-> ->TML, all other bits are ignored. 66 # They may be OR'd togoether to perform multiple tests. 67 # For example: $TML2HTML | $HTML2TML to test both 67 # They may be OR'd togoether to perform multiple tests. 68 # For example: $TML2HTML | $HTML2TML to test both 68 69 # TML -> HTML and HTML -> TML 69 70 # name => identifier (used to compose the testcase function name) … … 169 170 </p> 170 171 BLAH 171 tml => '=Code='172 tml => '=Code=' 172 173 }, 173 174 { … … 178 179 }, 179 180 { 180 exec => $TML2HTML | $HTML2TML,181 exec => $TML2HTML | $HTML2TML, 181 182 name => 'bToFromHtml', 182 183 html => '<p><b>Bold</b></p>', … … 184 185 }, 185 186 { 186 exec => $TML2HTML | $HTML2TML,187 exec => $TML2HTML | $HTML2TML, 187 188 name => 'strongCodeToFromHtml', 188 189 html => <<'BLAH', … … 191 192 </p> 192 193 BLAH 193 tml => '==Code=='194 tml => '==Code==' 194 195 }, 195 196 { … … 201 202 </p> 202 203 BLAH 203 tml => '==Code=='204 tml => '==Code==' 204 205 }, 205 206 { … … 211 212 </p> 212 213 BLAH 213 tml => '==Code=='214 tml => '==Code==' 214 215 }, 215 216 { … … 221 222 </p> 222 223 BLAH 223 tml => '==Code=='224 tml => '==Code==' 224 225 }, 225 226 { … … 260 261 </table> 261 262 BLAH 262 tml => <<'BLAH',263 tml => <<'BLAH', 263 264 | =Code= | 264 265 | =code= at start | -
trunk/core/lib/Assert.pm
r3945 r3947 19 19 20 20 use Exporter; 21 our @ISA = ( 'Exporter');21 our @ISA = ('Exporter'); 22 22 23 23 our %EXPORT_TAGS = ( 24 NDEBUG => [ 'ASSERT', 'UNTAINTED', 'TAINT', 'DEBUG'],25 DEBUG => [ 'ASSERT', 'UNTAINTED', 'TAINT', 'DEBUG'],24 NDEBUG => [ 'ASSERT', 'UNTAINTED', 'TAINT', 'DEBUG' ], 25 DEBUG => [ 'ASSERT', 'UNTAINTED', 'TAINT', 'DEBUG' ], 26 26 ); 27 27 28 28 our $VERSION = '$Rev$'; 29 our $DIRTY = $ENV{PATH};# Used in TAINT29 our $DIRTY = $ENV{PATH}; # Used in TAINT 30 30 31 31 Exporter::export_tags(qw(NDEBUG DEBUG)); 32 32 33 33 # constant.pm, alas, adds too much load time (yes, I benchmarked it) 34 sub ASSERTS_ON { 1 } # CONSTANT35 sub ASSERTS_OFF { 0 } # CONSTANT34 sub ASSERTS_ON { 1 } # CONSTANT 35 sub ASSERTS_OFF { 0 } # CONSTANT 36 36 37 37 sub noop { return $_[0] } … … 48 48 else { 49 49 my $caller = caller; 50 *{ $caller . '::ASSERT' } = \&noop;51 *{ $caller . '::TAINT' } = \&noop;52 *{ $caller . '::DEBUG' } = \&ASSERTS_OFF;50 *{ $caller . '::ASSERT' } = \&noop; 51 *{ $caller . '::TAINT' } = \&noop; 52 *{ $caller . '::DEBUG' } = \&ASSERTS_OFF; 53 53 } 54 54 use strict 'refs'; … … 76 76 # Taint the datum passed and return the tainted value 77 77 sub TAINT($) { 78 return substr( $_[0].$DIRTY, 0, length($_[0]));78 return substr( $_[0] . $DIRTY, 0, length( $_[0] ) ); 79 79 } 80 80 -
trunk/core/lib/Foswiki.pm
r3945 r3947 46 46 use Assert; 47 47 use Error qw( :try ); 48 use Monitor ();49 use Fcntl; # File control constants e.g. O_EXCL50 use CGI (); # Always required to get html generation tags;51 use Digest::MD5 (); # For passthru and validation48 use Monitor (); 49 use Fcntl; # File control constants e.g. O_EXCL 50 use CGI (); # Always required to get html generation tags; 51 use Digest::MD5 (); # For passthru and validation 52 52 53 53 # Components that all requests need … … 639 639 my $cgis = $this->getCGISession(); 640 640 if ( $cgis && $contentType eq 'text/html' ) { 641 641 642 # Don't expire the validation key through login, or when 642 643 # endpoint is an error. 643 644 Foswiki::Validation::expireValidationKeys($cgis) 644 unless ($this->{request}->action() eq 'login' 645 or ( $ENV{REDIRECT_STATUS} || 0 ) >= 400); 645 unless ( $this->{request}->action() eq 'login' 646 or ( $ENV{REDIRECT_STATUS} || 0 ) >= 400 ); 647 646 648 # Inject validation key in HTML forms 647 649 $text =~ s/(<form[^>]*method=['"]POST['"][^>]*>)/ … … 945 947 my $F; 946 948 sysopen( $F, "$passthruFilename", O_RDWR | O_EXCL | O_CREAT, 0600 ) 947 || die 'Unable to open '.$Foswiki::cfg{WorkingDir} 948 .'/tmp for write; check the setting of {WorkingDir} in configure,' 949 .' and check file permissions: '.$!; 949 || die 'Unable to open ' 950 . $Foswiki::cfg{WorkingDir} 951 . '/tmp for write; check the setting of {WorkingDir} in configure,' 952 . ' and check file permissions: ' 953 . $!; 950 954 $query->save($F); 951 955 close($F); -
trunk/core/lib/Foswiki/AccessControlException.pm
r3944 r3947 48 48 49 49 use Error (); 50 our @ISA = ( 'Error' ); # base class 51 50 our @ISA = ('Error'); # base class 52 51 53 52 our $VERSION = '$Rev$'; -
trunk/core/lib/Foswiki/AggregateIterator.pm
r3944 r3947 14 14 15 15 use Foswiki::Iterator (); 16 our @ISA = ( 'Foswiki::Iterator');16 our @ISA = ('Foswiki::Iterator'); 17 17 18 18 =begin TML -
trunk/core/lib/Foswiki/Attach.pm
r3440 r3947 271 271 # the link checkbox, Foswiki will generate the width and height 272 272 # img parameters, speeding up the page rendering. 273 my $stream = $topicObject->openAttachment( $attName, '<');273 my $stream = $topicObject->openAttachment( $attName, '<' ); 274 274 my ( $nx, $ny ) = _imgsize( $stream, $attName ); 275 275 $stream->close(); -
trunk/core/lib/Foswiki/Compatibility.pm
r3944 r3947 387 387 # of anchor name generator 388 388 sub makeCompatibleAnchors { 389 my ( $text) = @_;389 my ($text) = @_; 390 390 my @anchors; 391 391 … … 393 393 # target. 394 394 my $badAnchor = _makeBadAnchorName( $text, 0 ); 395 push( @anchors, $badAnchor),396 397 # There's an even older algorithm we have to allow for398 my $worseAnchor = _makeBadAnchorName( $text, 1 );399 if ( $worseAnchor ne $badAnchor) {400 push( @anchors, $worseAnchor ),395 push( @anchors, $badAnchor ), 396 397 # There's an even older algorithm we have to allow for 398 my $worseAnchor = _makeBadAnchorName( $text, 1 ); 399 if ( $worseAnchor ne $badAnchor ) { 400 push( @anchors, $worseAnchor ),; 401 401 } 402 402 … … 433 433 $anchorName =~ s/&#?[a-zA-Z0-9]+;//g; # remove HTML entities 434 434 $anchorName =~ s/&//g; # remove & 435 # filter TOC excludes if not at beginning435 # filter TOC excludes if not at beginning 436 436 $anchorName =~ s/^(.+?)\s*$Foswiki::regex{headerPatternNoTOC}.*/$1/o; 437 437 … … 442 442 # anything else than English alphanum characters in anchors 443 443 # So we convert anything non A-Za-z0-9_ to underscores 444 # and limit the number consecutive of underscores to 1 445 # This means that pure non-English anchors will become A, A_AN1, A_AN2, ... 444 # and limit the number consecutive of underscores to 1 445 # This means that pure non-English anchors will become A, A_AN1, A_AN2, ... 446 446 # We accept anchors starting with 0-9. It is non RFC but it works and it 447 447 # is very important for compatibility 448 448 $anchorName =~ s/[^A-Za-z0-9]+/_/g; 449 $anchorName =~ s/__+/_/g; # remove excessive '_' chars450 449 $anchorName =~ s/__+/_/g; # remove excessive '_' chars 450 451 451 if ( !$compatibilityMode ) { 452 $anchorName =~ s/^[\s#_]+//; # no leading space nor '#', '_'453 } 454 455 $anchorName =~ s/^$/A/; # prevent empty anchor452 $anchorName =~ s/^[\s#_]+//; # no leading space nor '#', '_' 453 } 454 455 $anchorName =~ s/^$/A/; # prevent empty anchor 456 456 457 457 # limit to 32 chars 458 458 $anchorName =~ s/^(.{32})(.*)$/$1/; 459 459 if ( !$compatibilityMode ) { 460 $anchorName =~ s/[\s_]+$//; # no trailing space, nor '_'460 $anchorName =~ s/[\s_]+$//; # no trailing space, nor '_' 461 461 } 462 462 return $anchorName; -
trunk/core/lib/Foswiki/Configure/Checker.pm
r3946 r3947 6 6 7 7 use Foswiki::Configure::UI (); 8 our @ISA = ( 'Foswiki::Configure::UI');8 our @ISA = ('Foswiki::Configure::UI'); 9 9 10 10 use File::Spec (); 11 use CGI ();11 use CGI (); 12 12 13 13 sub guessed { … … 308 308 else { 309 309 my $version = `$prog -V` || ''; 310 if ($version !~ /Can't exec/ 311 # "Can't exec" has been observed on some systems, 312 # despite perlop saying `` returns undef if the prog 313 # can't be run. See Foswikitask:Item1011 314 && $version =~ /(\d+(\.\d+)+)/ ) { 310 if ( 311 $version !~ /Can't exec/ 312 313 # "Can't exec" has been observed on some systems, 314 # despite perlop saying `` returns undef if the prog 315 # can't be run. See Foswikitask:Item1011 316 && $version =~ /(\d+(\.\d+)+)/ 317 ) 318 { 315 319 $version = $1; 316 320 } -
trunk/core/lib/Foswiki/Configure/Checkers/AuthScripts.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/BasicSanity.pm
r3945 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub new { … … 29 29 $this->{LocalSiteDotCfg} = Foswiki::findFileOnPath('LocalSite.cfg'); 30 30 unless ( $this->{LocalSiteDotCfg} ) { 31 $this->{LocalSiteDotCfg} = Foswiki::findFileOnPath('Foswiki.spec') || ''; 31 $this->{LocalSiteDotCfg} = Foswiki::findFileOnPath('Foswiki.spec') 32 || ''; 32 33 $this->{LocalSiteDotCfg} =~ s/Foswiki\.spec/LocalSite.cfg/; 33 34 } … … 68 69 HERE 69 70 } 70 elsif ( ( my $mess = $this->checkCfg(\%Foswiki::cfg)) ) {71 elsif ( ( my $mess = $this->checkCfg( \%Foswiki::cfg ) ) ) { 71 72 $result .= <<HERE; 72 73 The existing configuration file … … 173 174 174 175 sub checkCfg { 175 my ( $this, $entry, $keys) = @_;176 my ( $this, $entry, $keys ) = @_; 176 177 $keys ||= ''; 177 178 my $mess = ''; 178 179 179 if ( ref($entry) eq 'HASH') {180 foreach my $el ( keys %$entry) {181 $mess .= $this->checkCfg( $entry->{$el}, "$keys\{$el}");182 } 183 } 184 elsif ( ref($entry) eq 'ARRAY') {185 foreach my $i ( 0..scalar(@$entry)) {186 $mess .= $this->checkCfg( $entry->[$i], "$keys\[$i]")180 if ( ref($entry) eq 'HASH' ) { 181 foreach my $el ( keys %$entry ) { 182 $mess .= $this->checkCfg( $entry->{$el}, "$keys\{$el}" ); 183 } 184 } 185 elsif ( ref($entry) eq 'ARRAY' ) { 186 foreach my $i ( 0 .. scalar(@$entry) ) { 187 $mess .= $this->checkCfg( $entry->[$i], "$keys\[$i]" ); 187 188 } 188 189 } 189 190 else { 190 if ( defined $entry && $entry =~ /NOT SET/) {191 if ( defined $entry && $entry =~ /NOT SET/ ) { 191 192 $mess .= 192 "<div>\$Foswiki::cfg::$keys has been guessed and may be incorrect</div>";193 "<div>\$Foswiki::cfg::$keys has been guessed and may be incorrect</div>"; 193 194 } 194 195 } -
trunk/core/lib/Foswiki/Configure/Checkers/CGISetup.pm
r3946 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 use File::Spec (); … … 126 126 else { 127 127 $mess = 128 'Foswiki.pm (Version: <strong>' . $Foswiki::VERSION . '</strong>) found'; 128 'Foswiki.pm (Version: <strong>' 129 . $Foswiki::VERSION 130 . '</strong>) found'; 129 131 } 130 132 $block .= $this->setting( 'Foswiki module in @INC path', $mess ); -
trunk/core/lib/Foswiki/Configure/Checkers/ConfigurationLogName.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 use Foswiki::Configure::Load (); 9 9 … … 12 12 13 13 if ( $Foswiki::cfg{ConfigurationLogName} 14 && $Foswiki::cfg{ConfigurationLogName} !~/^NOT SET/ )14 && $Foswiki::cfg{ConfigurationLogName} !~ /^NOT SET/ ) 15 15 { 16 16 my $logFile = $Foswiki::cfg{ConfigurationLogName} || ""; … … 22 22 } 23 23 else { 24 $Foswiki::cfg{ConfigurationLogName} =~ s/^NOT SET/$Foswiki::cfg{DataDir}/g; 24 $Foswiki::cfg{ConfigurationLogName} =~ 25 s/^NOT SET/$Foswiki::cfg{DataDir}/g; 25 26 return $this->guessed(0); 26 27 } -
trunk/core/lib/Foswiki/Configure/Checkers/DataDir.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/DebugFileName.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 use Foswiki::Configure::Load (); … … 13 13 14 14 if ( $Foswiki::cfg{DebugFileName} 15 && $Foswiki::cfg{DebugFileName} !~/^NOT SET/ )15 && $Foswiki::cfg{DebugFileName} !~ /^NOT SET/ ) 16 16 { 17 17 my $logFile = $Foswiki::cfg{DebugFileName} || ""; -
trunk/core/lib/Foswiki/Configure/Checkers/DefaultUrlHost.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/DispScriptUrlPath.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/Environment.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub ui { -
trunk/core/lib/Foswiki/Configure/Checkers/Htpasswd/Encoding.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/Htpasswd/FileName.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/LocalesDir.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/LogFileName.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 use Foswiki::Configure::Load (); … … 13 13 14 14 if ( $Foswiki::cfg{LogFileName} 15 && $Foswiki::cfg{LogFileName} !~/^NOT SET/ )15 && $Foswiki::cfg{LogFileName} !~ /^NOT SET/ ) 16 16 { 17 17 my $logFile = $Foswiki::cfg{LogFileName} || ""; -
trunk/core/lib/Foswiki/Configure/Checkers/LoginManager.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/LoginNameFilterIn.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { return shift->checkRE('{LoginNameFilterIn}'); } -
trunk/core/lib/Foswiki/Configure/Checkers/LowerNational.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/MailProgram.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/MimeTypesFileName.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/MinPasswordLength.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/NameFilter.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { return shift->checkRE('{NameFilter}'); } -
trunk/core/lib/Foswiki/Configure/Checkers/OS.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/PubDir.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/PubUrlPath.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { 10 10 my $this = shift; 11 11 12 unless ( $Foswiki::cfg{PubUrlPath} && $Foswiki::cfg{PubUrlPath} ne 'NOT SET' ) { 12 unless ( $Foswiki::cfg{PubUrlPath} 13 && $Foswiki::cfg{PubUrlPath} ne 'NOT SET' ) 14 { 13 15 my $guess = $Foswiki::cfg{ScriptUrlPath}; 14 16 $guess =~ s/bin$/pub/; -
trunk/core/lib/Foswiki/Configure/Checkers/RCS/EgrepCmd.pm
r3944 r3947 2 2 package Foswiki::Configure::Checkers::RCS::EgrepCmd; 3 3 use Foswiki::Configure::Checker (); 4 our @ISA = ( 'Foswiki::Configure::Checker');4 our @ISA = ('Foswiki::Configure::Checker'); 5 5 6 6 use strict; -
trunk/core/lib/Foswiki/Configure/Checkers/RCS/ExtOption.pm
r3944 r3947 2 2 package Foswiki::Configure::Checkers::RCS::ExtOption; 3 3 use Foswiki::Configure::Checker (); 4 our @ISA = ( 'Foswiki::Configure::Checker');4 our @ISA = ('Foswiki::Configure::Checker'); 5 5 6 6 use strict; -
trunk/core/lib/Foswiki/Configure/Checkers/RCS/FgrepCmd.pm
r3944 r3947 2 2 package Foswiki::Configure::Checkers::RCS::FgrepCmd; 3 3 use Foswiki::Configure::Checker (); 4 our @ISA = ( 'Foswiki::Configure::Checker');4 our @ISA = ('Foswiki::Configure::Checker'); 5 5 6 6 use strict; -
trunk/core/lib/Foswiki/Configure/Checkers/RCS/SearchAlgorithm.pm
r3944 r3947 2 2 package Foswiki::Configure::Checkers::RCS::SearchAlgorithm; 3 3 use Foswiki::Configure::Checker (); 4 our @ISA = ( 'Foswiki::Configure::Checker');4 our @ISA = ('Foswiki::Configure::Checker'); 5 5 6 6 use strict; -
trunk/core/lib/Foswiki/Configure/Checkers/RCS/asciiFileSuffixes.pm
r3944 r3947 2 2 package Foswiki::Configure::Checkers::RCS::asciiFileSuffixes; 3 3 use Foswiki::Configure::Checker (); 4 our @ISA = ( 'Foswiki::Configure::Checker');4 our @ISA = ('Foswiki::Configure::Checker'); 5 5 6 6 use strict; -
trunk/core/lib/Foswiki/Configure/Checkers/RCS/ciCmd.pm
r3944 r3947 2 2 package Foswiki::Configure::Checkers::RCS::ciCmd; 3 3 use Foswiki::Configure::Checker (); 4 our @ISA = ( 'Foswiki::Configure::Checker');4 our @ISA = ('Foswiki::Configure::Checker'); 5 5 6 6 use strict; -
trunk/core/lib/Foswiki/Configure/Checkers/RCS/ciDateCmd.pm
r3944 r3947 2 2 package Foswiki::Configure::Checkers::RCS::ciDateCmd; 3 3 use Foswiki::Configure::Checker (); 4 our @ISA = ( 'Foswiki::Configure::Checker');4 our @ISA = ('Foswiki::Configure::Checker'); 5 5 6 6 use strict; -
trunk/core/lib/Foswiki/Configure/Checkers/RCS/coCmd.pm
r3944 r3947 2 2 package Foswiki::Configure::Checkers::RCS::coCmd; 3 3 use Foswiki::Configure::Checker (); 4 our @ISA = ( 'Foswiki::Configure::Checker');4 our @ISA = ('Foswiki::Configure::Checker'); 5 5 6 6 use strict; -
trunk/core/lib/Foswiki/Configure/Checkers/RCS/delRevCmd.pm
r3944 r3947 2 2 package Foswiki::Configure::Checkers::RCS::delRevCmd; 3 3 use Foswiki::Configure::Checker (); 4 our @ISA = ( 'Foswiki::Configure::Checker');4 our @ISA = ('Foswiki::Configure::Checker'); 5 5 6 6 use strict; -
trunk/core/lib/Foswiki/Configure/Checkers/RCS/diffCmd.pm
r3944 r3947 2 2 package Foswiki::Configure::Checkers::RCS::diffCmd; 3 3 use Foswiki::Configure::Checker (); 4 our @ISA = ( 'Foswiki::Configure::Checker');4 our @ISA = ('Foswiki::Configure::Checker'); 5 5 6 6 use strict; -
trunk/core/lib/Foswiki/Configure/Checkers/RCS/histCmd.pm
r3944 r3947 2 2 package Foswiki::Configure::Checkers::RCS::histCmd; 3 3 use Foswiki::Configure::Checker (); 4 our @ISA = ( 'Foswiki::Configure::Checker');4 our @ISA = ('Foswiki::Configure::Checker'); 5 5 6 6 use strict; -
trunk/core/lib/Foswiki/Configure/Checkers/RCS/infoCmd.pm
r3944 r3947 2 2 package Foswiki::Configure::Checkers::RCS::infoCmd; 3 3 use Foswiki::Configure::Checker (); 4 our @ISA = ( 'Foswiki::Configure::Checker');4 our @ISA = ('Foswiki::Configure::Checker'); 5 5 6 6 use strict; -
trunk/core/lib/Foswiki/Configure/Checkers/RCS/initBinaryCmd.pm
r3944 r3947 2 2 package Foswiki::Configure::Checkers::RCS::initBinaryCmd; 3 3 use Foswiki::Configure::Checker (); 4 our @ISA = ( 'Foswiki::Configure::Checker');4 our @ISA = ('Foswiki::Configure::Checker'); 5 5 6 6 use strict; -
trunk/core/lib/Foswiki/Configure/Checkers/RCS/initTextCmd.pm
r3944 r3947 2 2 package Foswiki::Configure::Checkers::RCS::initTextCmd; 3 3 use Foswiki::Configure::Checker (); 4 our @ISA = ( 'Foswiki::Configure::Checker');4 our @ISA = ('Foswiki::Configure::Checker'); 5 5 6 6 use strict; -
trunk/core/lib/Foswiki/Configure/Checkers/RCS/lockCmd.pm
r3944 r3947 2 2 package Foswiki::Configure::Checkers::RCS::lockCmd; 3 3 use Foswiki::Configure::Checker (); 4 our @ISA = ( 'Foswiki::Configure::Checker');4 our @ISA = ('Foswiki::Configure::Checker'); 5 5 6 6 use strict; -
trunk/core/lib/Foswiki/Configure/Checkers/RCS/rlogDateCmd.pm
r3944 r3947 2 2 package Foswiki::Configure::Checkers::RCS::rlogDateCmd; 3 3 use Foswiki::Configure::Checker (); 4 our @ISA = ( 'Foswiki::Configure::Checker');4 our @ISA = ('Foswiki::Configure::Checker'); 5 5 6 6 use strict; -
trunk/core/lib/Foswiki/Configure/Checkers/RCS/tmpBinaryCmd.pm
r3944 r3947 2 2 package Foswiki::Configure::Checkers::RCS::tmpBinaryCmd; 3 3 use Foswiki::Configure::Checker (); 4 our @ISA = ( 'Foswiki::Configure::Checker');4 our @ISA = ('Foswiki::Configure::Checker'); 5 5 6 6 use strict; -
trunk/core/lib/Foswiki/Configure/Checkers/RCS/unlockCmd.pm
r3944 r3947 2 2 package Foswiki::Configure::Checkers::RCS::unlockCmd; 3 3 use Foswiki::Configure::Checker (); 4 our @ISA = ( 'Foswiki::Configure::Checker');4 our @ISA = ('Foswiki::Configure::Checker'); 5 5 6 6 use strict; -
trunk/core/lib/Foswiki/Configure/Checkers/Register/AllowLoginName.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/Register/NeedVerification.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { 10 10 my $this = shift; 11 11 12 if ( $Foswiki::cfg{Register}{NeedVerification} and !$Foswiki::cfg{EnableEmail} ) 12 if ( $Foswiki::cfg{Register}{NeedVerification} 13 and !$Foswiki::cfg{EnableEmail} ) 13 14 { 14 15 return $this->WARN( -
trunk/core/lib/Foswiki/Configure/Checkers/RegistrationApprovals.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/SafeEnvPath.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 # Unix or Linux, Windows ActiveState Perl, using PERL5SHELL set to cygwin shell -
trunk/core/lib/Foswiki/Configure/Checkers/ScriptSuffix.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { … … 12 12 # SMELL: should check to see what the extension on _this_ script 13 13 # is, and generate a helpful message 14 if ( defined $Foswiki::cfg{ScriptSuffix} && $Foswiki::cfg{ScriptSuffix} ne '' ) 14 if ( defined $Foswiki::cfg{ScriptSuffix} 15 && $Foswiki::cfg{ScriptSuffix} ne '' ) 15 16 { 16 17 if ( !$Foswiki::query->path_info() =~ /$Foswiki::cfg{ScriptSuffix}$/ ) { -
trunk/core/lib/Foswiki/Configure/Checkers/ScriptUrlPath.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/Sessions/ExpireAfter.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/Site/CharSet.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { … … 17 17 $Foswiki::cfg{Site}{CharSet} =~ s/^utf8$/utf-8/i; 18 18 $Foswiki::cfg{Site}{CharSet} =~ s/^eucjp$/euc-jp/i; 19 $Foswiki::cfg{Site}{CharSet} = lc( $Foswiki::cfg{Site}{CharSet} );19 $Foswiki::cfg{Site}{CharSet} = lc( $Foswiki::cfg{Site}{CharSet} ); 20 20 } 21 21 return ''; -
trunk/core/lib/Foswiki/Configure/Checkers/Site/Locale.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 my @required = ( -
trunk/core/lib/Foswiki/Configure/Checkers/StoreImpl.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/TemplateDir.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/UploadFilter.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { return shift->checkRE('{UploadFilter}'); } -
trunk/core/lib/Foswiki/Configure/Checkers/UpperNational.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { -
trunk/core/lib/Foswiki/Configure/Checkers/UseClientSessions.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 my @modules = ( -
trunk/core/lib/Foswiki/Configure/Checkers/UseLocale.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 my @required = ( -
trunk/core/lib/Foswiki/Configure/Checkers/WarningFileName.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 use Foswiki::Configure::Load (); … … 13 13 14 14 if ( $Foswiki::cfg{WarningFileName} 15 && $Foswiki::cfg{WarningFileName} !~/^NOT SET/ )15 && $Foswiki::cfg{WarningFileName} !~ /^NOT SET/ ) 16 16 { 17 17 my $logFile = $Foswiki::cfg{WarningFileName} || ""; -
trunk/core/lib/Foswiki/Configure/Checkers/WebMasterEmail.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { … … 15 15 ); 16 16 } 17 17 18 # $regex{emailAddrRegex} ... 18 19 if ( $Foswiki::cfg{WebMasterEmail} !~ -
trunk/core/lib/Foswiki/Configure/Checkers/WorkingDir.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Checker (); 7 our @ISA = ( 'Foswiki::Configure::Checker');7 our @ISA = ('Foswiki::Configure::Checker'); 8 8 9 9 sub check { … … 16 16 mkdir("$Foswiki::cfg{WorkingDir}") 17 17 || return $this->ERROR( 18 "$Foswiki::cfg{WorkingDir} does not exist, and I can't create it: $!"18 "$Foswiki::cfg{WorkingDir} does not exist, and I can't create it: $!" 19 19 ); 20 20 $mess .= $this->NOTE("Created $Foswiki::cfg{WorkingDir}"); … … 47 47 } 48 48 else { 49 $mess .= $this->NOTE("Created $Foswiki::cfg{WorkingDir}/work_areas"); 49 $mess .= 50 $this->NOTE("Created $Foswiki::cfg{WorkingDir}/work_areas"); 50 51 } 51 52 } -
trunk/core/lib/Foswiki/Configure/FINDEXTENSIONS.pm
r3944 r3947 8 8 9 9 use Foswiki::Configure::Pluggable (); 10 our @ISA = ( 'Foswiki::Configure::Pluggable');10 our @ISA = ('Foswiki::Configure::Pluggable'); 11 11 12 use Foswiki::Configure::Type ();12 use Foswiki::Configure::Type (); 13 13 use Foswiki::Configure::Value (); 14 14 -
trunk/core/lib/Foswiki/Configure/FoswikiCfg.pm
r3946 r3947 51 51 use Data::Dumper (); 52 52 53 use Foswiki::Configure::Section ();54 use Foswiki::Configure::Value ();53 use Foswiki::Configure::Section (); 54 use Foswiki::Configure::Value (); 55 55 use Foswiki::Configure::Pluggable (); 56 use Foswiki::Configure::Item ();56 use Foswiki::Configure::Item (); 57 57 58 58 # Used in saving, when we need a callback. Otherwise the methods here are … … 113 113 # parse. They are expanded to section blocks at the end. 114 114 package SectionMarker; 115 @SectionMarker::ISA = ( 'Foswiki::Configure::Item');115 @SectionMarker::ISA = ('Foswiki::Configure::Item'); 116 116 117 117 sub new { -
trunk/core/lib/Foswiki/Configure/LANGUAGES.pm
r3944 r3947 6 6 7 7 use Foswiki::Configure::Pluggable (); 8 our @ISA = ( 'Foswiki::Configure::Pluggable');8 our @ISA = ('Foswiki::Configure::Pluggable'); 9 9 10 10 sub new { -
trunk/core/lib/Foswiki/Configure/Load.pm
r3944 r3947 147 147 push( @errors, $@ ) if ($@); 148 148 foreach my $dir (@INC) { 149 my $root; # SMELL: Not used149 my $root; # SMELL: Not used 150 150 _loadDefaultsFrom( "$dir/Foswiki/Plugins", $root, \%read, \@errors ); 151 151 _loadDefaultsFrom( "$dir/Foswiki/Contrib", $root, \%read, \@errors ); -
trunk/core/lib/Foswiki/Configure/PLUGINS.pm
r3944 r3947 7 7 8 8 use Foswiki::Configure::Pluggable (); 9 our @ISA = ( 'Foswiki::Configure::Pluggable');9 our @ISA = ('Foswiki::Configure::Pluggable'); 10 10 11 11 use Foswiki::Configure::Pluggable (); 12 use Foswiki::Configure::Type ();13 use Foswiki::Configure::Value ();12 use Foswiki::Configure::Type (); 13 use Foswiki::Configure::Value (); 14 14 15 15 my $scanner = Foswiki::Configure::Type::load('SELECTCLASS'); … … 31 31 $modules{$simple} = $module; 32 32 } 33 foreach my $module ( sort { lc( $a ) cmp lc( $b) } keys %modules ) {33 foreach my $module ( sort { lc($a) cmp lc($b) } keys %modules ) { 34 34 $this->addChild( 35 35 new Foswiki::Configure::Value( -
trunk/core/lib/Foswiki/Configure/Pluggable.pm
r3944 r3947 13 13 14 14 use Foswiki::Configure::Section (); 15 our @ISA = ( 'Foswiki::Configure::Section');15 our @ISA = ('Foswiki::Configure::Section'); 16 16 17 17 sub load { -
trunk/core/lib/Foswiki/Configure/Root.pm
r3944 r3947 8 8 9 9 use Foswiki::Configure::Section (); 10 our @ISA = ( 'Foswiki::Configure::Section');10 our @ISA = ('Foswiki::Configure::Section'); 11 11 12 12 sub new { -
trunk/core/lib/Foswiki/Configure/Section.pm
r3945 r3947 6 6 7 7 use Foswiki::Configure::Item (); 8 our @ISA = ( 'Foswiki::Configure::Item');8 our @ISA = ('Foswiki::Configure::Item'); 9 9 10 10 sub new { -
trunk/core/lib/Foswiki/Configure/Types/BOOLEAN.pm
r3944 r3947 6 6 7 7 use Foswiki::Configure::Type (); 8 our @ISA = ( 'Foswiki::Configure::Type');8 our @ISA = ('Foswiki::Configure::Type'); 9 9 10 10 sub prompt { -
trunk/core/lib/Foswiki/Configure/Types/COMMAND.pm
r3944 r3947 6 6 7 7 use Foswiki::Configure::Types::STRING (); 8 our @ISA = ( 'Foswiki::Configure::Types::STRING');8 our @ISA = ('Foswiki::Configure::Types::STRING'); 9 9 10 10 1; -
trunk/core/lib/Foswiki/Configure/Types/LANGUAGE.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Types::BOOLEAN (); 7 our @ISA = ( 'Foswiki::Configure::Types::BOOLEAN');7 our @ISA = ('Foswiki::Configure::Types::BOOLEAN'); 8 8 9 9 # When any language changes, delete the cache -
trunk/core/lib/Foswiki/Configure/Types/NUMBER.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Type (); 7 our @ISA = ( 'Foswiki::Configure::Type');7 our @ISA = ('Foswiki::Configure::Type'); 8 8 9 9 sub prompt { -
trunk/core/lib/Foswiki/Configure/Types/OCTAL.pm
r3944 r3947 6 6 7 7 use Foswiki::Configure::Types::NUMBER (); 8 our @ISA = ( 'Foswiki::Configure::Types::NUMBER');8 our @ISA = ('Foswiki::Configure::Types::NUMBER'); 9 9 10 10 sub prompt { -
trunk/core/lib/Foswiki/Configure/Types/PASSWORD.pm
r3944 r3947 6 6 7 7 use Foswiki::Configure::Types::STRING (); 8 our @ISA = ( 'Foswiki::Configure::Types::STRING');8 our @ISA = ('Foswiki::Configure::Types::STRING'); 9 9 10 10 sub prompt { … … 25 25 -default => $value, 26 26 -autocomplete => 'off', 27 -class => 'foswikiInputField',27 -class => 'foswikiInputField', 28 28 ); 29 29 } -
trunk/core/lib/Foswiki/Configure/Types/PATH.pm
r3944 r3947 6 6 7 7 use Foswiki::Configure::Types::STRING (); 8 our @ISA = ( 'Foswiki::Configure::Types::STRING');8 our @ISA = ('Foswiki::Configure::Types::STRING'); 9 9 10 10 1; -
trunk/core/lib/Foswiki/Configure/Types/PERL.pm
r3944 r3947 16 16 17 17 use Foswiki::Configure::Type (); 18 our @ISA = ( 'Foswiki::Configure::Type');18 our @ISA = ('Foswiki::Configure::Type'); 19 19 20 20 use Data::Dumper (); … … 64 64 sub string2value { 65 65 my ( $this, $val ) = @_; 66 67 $val =~ s/^[[:space:]]+(.*?)$/$1/s; # strip at start68 $val =~ s/^(.*?)[[:space:]]+$/$1/s; # strip at end69 66 67 $val =~ s/^[[:space:]]+(.*?)$/$1/s; # strip at start 68 $val =~ s/^(.*?)[[:space:]]+$/$1/s; # strip at end 69 70 70 my $s; 71 71 if ( $s = _rvalue($val) ) { … … 75 75 "Could not parse text to a data structure (at: $s)\nPlease go back and check if the text has the correct syntax."; 76 76 } 77 $val =~ /(.*)/s; # parsed, so safe to untaint77 $val =~ /(.*)/s; # parsed, so safe to untaint 78 78 return eval $1; 79 79 } -
trunk/core/lib/Foswiki/Configure/Types/REGEX.pm
r3944 r3947 5 5 6 6 use Foswiki::Configure::Types::STRING (); 7 our @ISA = ( 'Foswiki::Configure::Types::STRING');7 our @ISA = ('Foswiki::Configure::Types::STRING'); 8 8 9 9 sub prompt { -
trunk/core/lib/Foswiki/Configure/Types/SELECT.pm
r3944 r3947 6 6 7 7 use Foswiki::Configure::Type (); 8 our @ISA = ( 'Foswiki::Configure::Type');8 our @ISA = ('Foswiki::Configure::Type'); 9 9 10 10 sub prompt { … … 22 22 } 23 23 } 24 return CGI::Select( { name => $id, size => 1, class => 'foswikiSelect' }, $sopts ); 24 return CGI::Select( { name => $id, size => 1, class => 'foswikiSelect' }, 25 $sopts ); 25 26 } 26 27 -
trunk/core/lib/Foswiki/Configure/Types/SELECTCLASS.pm
r3944 r3947 6 6 7 7 use Foswiki::Configure::Types::SELECT (); 8 our @ISA = ( 'Foswiki::Configure::Types::SELECT');8 our @ISA = ('Foswiki::Configure::Types::SELECT'); 9 9 10 10 # generate an input field for SELECTCLASS types … … 48 48 foreach my $place (@$places) { 49 49 if ( opendir( DIR, $place ) ) { 50 50 51 #next if ($place =~ /^\..*/); 51 52 foreach my $subplace ( readdir DIR ) { 52 53 next unless $subplace =~ $pathel; 54 53 55 #next if ($subplace =~ /^\..*/); 54 56 push( @newplaces, $place . '/' . $1 ); … … 67 69 foreach my $file ( readdir DIR ) { 68 70 next unless $file =~ $leaf; 69 next if ( $file =~ /^\..*/);71 next if ( $file =~ /^\..*/ ); 70 72 $file =~ /^(.*)\.pm$/; 71 73 my $module = "$place/$1"; -
trunk/core/lib/Foswiki/Configure/Types/STRING.pm
r3944 r3947 6 6 7 7 use Foswiki::Configure::Type (); 8 our @ISA = ( 'Foswiki::Configure::Type');8 our @ISA = ('Foswiki::Configure::Type'); 9 9 10 10 1; -
trunk/core/lib/Foswiki/Configure/Types/UNKNOWN.pm
r3944 r3947 9 9 10 10 use Foswiki::Configure::Type (); 11 our @ISA = ( 'Foswiki::Configure::Type');11 our @ISA = ('Foswiki::Configure::Type'); 12 12 13 13 sub new { -
trunk/core/lib/Foswiki/Configure/Types/URL.pm
r3944 r3947 6 6 7 7 use Foswiki::Configure::Type (); 8 our @ISA = ( 'Foswiki::Configure::Type');8 our @ISA = ('Foswiki::Configure::Type'); 9 9 10 10 sub new { -
trunk/core/lib/Foswiki/Configure/Types/URLPATH.pm
r3944 r3947 6 6 7 7 use Foswiki::Configure::Types::STRING (); 8 our @ISA = ( 'Foswiki::Configure::Types::STRING');8 our @ISA = ('Foswiki::Configure::Types::STRING'); 9 9 10 10 1; -
trunk/core/lib/Foswiki/Configure/UI.pm
r3945 r3947 13 13 use strict; 14 14 use File::Spec (); 15 use FindBin ();15 use FindBin (); 16 16 17 17 our $totwarnings; -
trunk/core/lib/Foswiki/Configure/UIs/AUTH.pm
r3944 r3947 6 6 7 7 use Foswiki::Configure::UI (); 8 our @ISA = ( 'Foswiki::Configure::UI');8 our @ISA = ('Foswiki::Configure::UI'); 9 9 10 10 my %nonos = ( … … 22 22 $scriptName =~ s/.*[\/\\]//; # Fix for Item3511, on Win XP 23 23 24 $output .= CGI::start_form( { name => 'twiki_configure', action => $scriptName, method => 'post' } ); 24 $output .= CGI::start_form( 25 { name => 'twiki_configure', action => $scriptName, method => 'post' } 26 ); 25 27 26 28 # Pass URL params through, except those below … … 41 43 CGI::h3( CGI::strong("Your Password:") ) 42 44 . CGI::p( 43 CGI::password_field( -name=>'cfgAccess', -size =>20, -maxlength=>80, -class => 'foswikiInputField' ) 45 CGI::password_field( 46 -name => 'cfgAccess', 47 -size => 20, 48 -maxlength => 80, 49 -class => 'foswikiInputField' 50 ) 44 51 . ' ' 45 52 . CGI::submit( … … 107 114 { class => 'foswikiFormStep' }, 108 115 CGI::strong('New Password:') 109 . CGI::p( CGI::password_field( -name=>'newCfgP', -size=>20, -maxlength=>80, -class => 'foswikiInputField' ) ) 116 . CGI::p( 117 CGI::password_field( 118 -name => 'newCfgP', 119 -size => 20, 120 -maxlength => 80, 121 -class => 'foswikiInputField' 122 ) 123 ) 110 124 ); 111 125 $output .= CGI::div( 112 126 { class => 'foswikiFormStep' }, 113 127 CGI::strong('Confirm Password:') 114 . CGI::p( CGI::password_field( -name=>'confCfgP', size=>20, -maxlength=>80, -class => 'foswikiInputField' ) ) 128 . CGI::p( 129 CGI::password_field( 130 -name => 'confCfgP', 131 size => 20, 132 -maxlength => 80, 133 -class => 'foswikiInputField' 134 ) 135 ) 115 136 ); 116 137 $submitStr = 'Change Password and ' . $submitStr; -
trunk/core/lib/Foswiki/Configure/UIs/EXTEND.pm
r3944 r3947 6 6 7 7 use Foswiki::Configure::UI (); 8 our @ISA = ( 'Foswiki::Configure::UI');8 our @ISA = ('Foswiki::Configure::UI'); 9 9 use File::Temp (); 10 10 use File::Copy (); 11 11 use File::Spec (); 12 use Cwd ();12 use Cwd (); 13 13 14 14 sub ui { … … 151 151 # will just hang :-( 152 152 chdir( $this->{root} ); 153 unshift( @ARGV, '-a' ); # don't prompt154 unshift( @ARGV, '-d');# yes, you can download155 # Note: -r not passed to the script, so it will _not_ try to156 # re-use existing archives found on disc to resolve dependencies.153 unshift( @ARGV, '-a' ); # don't prompt 154 unshift( @ARGV, '-d' ); # yes, you can download 155 # Note: -r not passed to the script, so it will _not_ try to 156 # re-use existing archives found on disc to resolve dependencies. 157 157 print "<pre>\n"; 158 158 eval { … … 160 160 do $installScript; 161 161 use warnings 'redefine'; 162 die $@ if $@; # propagate162 die $@ if $@; # propagate 163 163 }; 164 164 print "</pre>\n"; … … 218 218 elsif ( $file =~ s#^locale/#$Foswiki::cfg{LocalesDir}/# ) { 219 219 } 220 elsif ( $file =~ s#^(bin/\w+)$#$this->{root}$1$Foswiki::cfg{ScriptSuffix}# ) { 220 elsif ( $file =~ s#^(bin/\w+)$#$this->{root}$1$Foswiki::cfg{ScriptSuffix}# ) 221 { 221 222 222 223 #This makes a couple of bad assumptions … … 241 242 if ( opendir( $d, "$dir$path" ) ) { 242 243 foreach my $f ( grep { !/^\.*$/ } readdir $d ) { 244 243 245 # Someone might upload a package that contains 244 246 # a filename which, when passed to File::Copy, does something … … 246 248 # SMELL: potential problem with unicode chars in file names? (yes) 247 249 # TODO: should really compare to MANIFEST 248 if ( $f =~ /^([-\w.,]+)$/) {250 if ( $f =~ /^([-\w.,]+)$/ ) { 249 251 $f = $1; 250 252 if ( -d "$dir$path/$f" ) { … … 255 257 push( @names, "$path$f" ); 256 258 } 257 } else { 258 print "WARNING: skipping possibly unsafe file (not able to show it for the same reason :( )<br />\n"; 259 } 260 else { 261 print 262 "WARNING: skipping possibly unsafe file (not able to show it for the same reason :( )<br />\n"; 259 263 } 260 264 } … … 305 309 my @members = $zip->members(); 306 310 foreach my $member (@members) { 307 my $file = $member->fileName();311 my $file = $member->fileName(); 308 312 $file =~ /(.*)/; 309 $file = $1; #yes, we must untaint313 $file = $1; #yes, we must untaint 310 314 my $target = $file; 311 my $err = $zip->extractMember( $file, $target );315 my $err = $zip->extractMember( $file, $target ); 312 316 if ($err) { 313 317 print "Failed to extract '$file' from zip file ", -
trunk/core/lib/Foswiki/Configure/UIs/EXTENSIONS.pm
r3945 r3947 4 4 5 5 use Foswiki::Configure::UI (); 6 our @ISA = ( 'Foswiki::Configure::UI');6 our @ISA = ('Foswiki::Configure::UI'); 7 7 8 8 use Foswiki::Configure::Type (); … … 129 129 130 130 # Unexpanded, assume pseudo-installed 131 $link = '';132 $text = 'pseudo-installed';131 $link = ''; 132 $text = 'pseudo-installed'; 133 133 $ext->{cssclass} = 'pseudoinstalled'; 134 134 } … … 143 143 $text = 'Re-install'; 144 144 $ext->{cssclass} = 'reinstall'; 145 if ( $ext->{version} =~ /^\s*v?(\d+)\.(\d+)(?:\.(\d+))?/ ) 145 if ( $ext->{version} =~ 146 /^\s*v?(\d+)\.(\d+)(?:\.(\d+))?/ ) 146 147 { 147 148 148 149 # Compatible version number 149 my $arev = ( $1 * 1000 + $2 ) * 1000 + ( $3 || 0);150 my $arev = ( $1 * 1000 + $2 ) * 1000 + ( $3 || 0 ); 150 151 if ( $arev > $irev ) { 151 152 $text = 'Upgrade'; … … 168 169 } 169 170 } 170 elsif ( $ext->{installedVersion} =~ 171 /(\d{4})-(\d\d)-(\d\d)/ ) { 171 elsif ( 172 $ext->{installedVersion} =~ /(\d{4})-(\d\d)-(\d\d)/ ) 173 { 174 172 175 # ISO date 173 176 my $idate = d2n( $3, $2, $1 ); 174 177 $text = 'Re-install'; 175 178 $ext->{cssclass} = 'reinstall'; 176 if ( $ext->{version} =~ /(\d{4})-(\d\d)-(\d\d)/ ) {179 if ( $ext->{version} =~ /(\d{4})-(\d\d)-(\d\d)/ ) { 177 180 my $adate = d2n( $3, $2, $1 ); 178 181 if ( $adate > $idate ) { … … 183 186 } 184 187 elsif ( $ext->{installedVersion} =~ 185 /(\d{1,2}) ($MNAME) (\d{4})/ ) { 188 /(\d{1,2}) ($MNAME) (\d{4})/ ) 189 { 186 190 187 191 # dd Mmm yyyy date 188 my $idate = d2n( $1, $N2M{ lc($2)}, $3 );192 my $idate = d2n( $1, $N2M{ lc($2) }, $3 ); 189 193 $text = 'Re-install'; 190 194 $ext->{cssclass} = 'reinstall'; 191 if ( $ext->{version} =~ 192 /(\d{1,2}) ($MNAME) (\d{4})/ ) { 193 my $adate = d2n( $1, $N2M{lc($2)}, $3 ); 195 if ( $ext->{version} =~ /(\d{1,2}) ($MNAME) (\d{4})/ ) { 196 my $adate = d2n( $1, $N2M{ lc($2) }, $3 ); 194 197 if ( $adate > $idate ) { 195 198 $text = 'Upgrade'; … … 206 209 else { 207 210 $text = $ext->{$f} || '-'; 208 $text =~ s/!(\w+)/$1/go; # remove ! escape syntax from text211 $text =~ s/!(\w+)/$1/go; # remove ! escape syntax from text 209 212 if ( $f eq 'topic' ) { 210 213 my $link = $ext->{data} . $ext->{topic}; 211 214 $text = CGI::a( { href => $link }, $text ); 212 215 } 216 213 217 =pod 214 218 elsif ($f eq 'image' … … 219 223 } 220 224 =cut 225 221 226 } 222 227 my %opts = ( valign => 'top' ); … … 229 234 if ( $ext->{installedVersion} ) { 230 235 push @classes, 'installed'; 231 push( @classes, $ext->{cssclass} ) if ( $ext->{cssclass});236 push( @classes, $ext->{cssclass} ) if ( $ext->{cssclass} ); 232 237 push @classes, 'twikiExtension' 233 238 if $ext->{installedVersion} =~ /\(TWiki\)/; -
trunk/core/lib/Foswiki/Configure/UIs/FINDEXTENSIONS.pm
r3944 r3947 6 6 7 7 use Foswiki::Configure::UIs::Section (); 8 our @ISA = ( 'Foswiki::Configure::UIs::Section');8 our @ISA = ('Foswiki::Configure::UIs::Section'); 9 9 use Foswiki::Configure::Type (); 10 10 … … 20 20 my $bad = 0; 21 21 foreach my $module 22 qw(Foswiki::Configure::UIs::EXTEND Foswiki::Configure::UIs::FINDEXTENSIONS) { 22 qw(Foswiki::Configure::UIs::EXTEND Foswiki::Configure::UIs::FINDEXTENSIONS) 23 { 23 24 eval "require $module"; 24 25 if ($@) { -
trunk/core/lib/Foswiki/Configure/UIs/LANGUAGES.pm
r3944 r3947 4 4 5 5 use Foswiki::Configure::UIs::Section (); 6 our @ISA = ( 'Foswiki::Configure::UIs::Section');6 our @ISA = ('Foswiki::Configure::UIs::Section'); 7 7 8 8 1; -
trunk/core/lib/Foswiki/Configure/UIs/PLUGINS.pm
r3944 r3947 6 6 7 7 use Foswiki::Configure::UIs::Section (); 8 our @ISA = ( 'Foswiki::Configure::UIs::Section');8 our @ISA = ('Foswiki::Configure::UIs::Section'); 9 9 10 10 1; -
trunk/core/lib/Foswiki/Configure/UIs/PasswordProtected.pm
r3944 r3947 9 9 10 10 use Foswiki::Configure::UI (); 11 our @ISA = ( 'Foswiki::Configure::UI');11 our @ISA = ('Foswiki::Configure::UI'); 12 12 13 13 use Foswiki::Configure::Type (); … … 18 18 19 19 if ( $Foswiki::query->param('newCfgP') ) { 20 if ( $Foswiki::query->param('newCfgP') eq $Foswiki::query->param('confCfgP')21 )20 if ( $Foswiki::query->param('newCfgP') eq 21 $Foswiki::query->param('confCfgP') ) 22 22 { 23 23 $this->{updates}{'{Password}'} = -
trunk/core/lib/Foswiki/Configure/UIs/Root.pm
r3944 r3947 8 8 9 9 use Foswiki::Configure::UIs::Section (); 10 our @ISA = ( 'Foswiki::Configure::UIs::Section');10 our @ISA = ('Foswiki::Configure::UIs::Section'); 11 11 12 12 # Visit the nodes in a tree of configuration items, and generate -
trunk/core/lib/Foswiki/Configure/UIs/Section.pm
r3944 r3947 12 12 13 13 use Foswiki::Configure::UI (); 14 our @ISA = ( 'Foswiki::Configure::UI');14 our @ISA = ('Foswiki::Configure::UI'); 15 15 16 16 # depth == 1 is the root … … 60 60 onclick => 'foldBlock("' . $id . '"); return false;' 61 61 }, 62 '<span class="blockLinkIndicator"></span>' . $section->{headline} . $mess 62 '<span class="blockLinkIndicator"></span>' 63 . $section->{headline} 64 . $mess 63 65 ); 64 66 -
trunk/core/lib/Foswiki/Configure/UIs/TAGS.pm
r3944 r3947 6 6 7 7 use Foswiki::Configure::UI (); 8 our @ISA = ( 'Foswiki::Configure::UI');8 our @ISA = ('Foswiki::Configure::UI'); 9 9 10 use Foswiki::Configure::Type ();10 use Foswiki::Configure::Type (); 11 11 use Foswiki::Configure::Value (); 12 12 -
trunk/core/lib/Foswiki/Configure/UIs/UPDATE.pm
r3944 r3947 6 6 7 7 use Foswiki::Configure::UI (); 8 our @ISA = ( 'Foswiki::Configure::UI');8 our @ISA = ('Foswiki::Configure::UI'); 9 9 10 10 use Foswiki::Configure::FoswikiCfg (); … … 28 28 29 29 if ( $this->{log} && defined( $Foswiki::cfg{ConfigurationLogName} ) ) { 30 # configuration variable may be coming from POST, and might thus 31 # be tainted, we must be able to trust that the adminstrator has 32 # input a proper path and therefore untaint rigourously 33 # NOTE: this assumes configure is properly hardened through the web 34 # server as instructed in the fine manual! 35 $Foswiki::cfg{ConfigurationLogName} =~ /^(.*)$/; 36 $Foswiki::cfg{ConfigurationLogName} = $1; 30 31 # configuration variable may be coming from POST, and might thus 32 # be tainted, we must be able to trust that the adminstrator has 33 # input a proper path and therefore untaint rigourously 34 # NOTE: this assumes configure is properly hardened through the web 35 # server as instructed in the fine manual! 36 $Foswiki::cfg{ConfigurationLogName} =~ /^(.*)$/; 37 $Foswiki::cfg{ConfigurationLogName} = $1; 37 38 if ( open( F, '>>', $Foswiki::cfg{ConfigurationLogName} ) ) { 38 39 print F $this->{log}; -
trunk/core/lib/Foswiki/Configure/UIs/Value.pm
r3944 r3947 6 6 7 7 use Foswiki::Configure::UI (); 8 our @ISA = ( 'Foswiki::Configure::UI');8 our @ISA = ('Foswiki::Configure::UI'); 9 9 10 10 # Generates the appropriate HTML for getting a value to configure the -
trunk/core/lib/Foswiki/Configure/Value.pm
r3945 r3947 6 6 7 7 use Foswiki::Configure::Item (); 8 our @ISA = ( 'Foswiki::Configure::Item');8 our @ISA = ('Foswiki::Configure::Item'); 9 9 10 10 use Foswiki::Configure::Type (); -
trunk/core/lib/Foswiki/Engine.pm
r3507 r3947 149 149 my ( $param, $value, %params, @plist ); 150 150 foreach my $pair (@pairs) { 151 ( $param, $value ) = split('=', $pair, 2); 151 ( $param, $value ) = split( '=', $pair, 2 ); 152 152 153 # url decode 153 154 if ( defined $value ) { … … 318 319 my ( $this, $res, $req ) = @_; 319 320 $this->finalizeCookies($res); 320 if ( $req && $req->method() && uc( $req->method()) eq 'HEAD' ) {321 if ( $req && $req->method() && uc( $req->method() ) eq 'HEAD' ) { 321 322 $res->body(''); 322 323 $res->deleteHeader('Content-Length'); -
trunk/core/lib/Foswiki/Engine/CGI.pm
r3944 r3947 16 16 17 17 use Foswiki::Engine (); 18 our @ISA = ( 'Foswiki::Engine');18 our @ISA = ('Foswiki::Engine'); 19 19 20 20 use Assert; 21 use Foswiki::Request ();21 use Foswiki::Request (); 22 22 use Foswiki::Request::Upload (); 23 use Foswiki::Response ();23 use Foswiki::Response (); 24 24 25 25 sub run { -
trunk/core/lib/Foswiki/Engine/CLI.pm
r3944 r3947 18 18 19 19 use Foswiki::Engine (); 20 our @ISA = ( 'Foswiki::Engine');20 our @ISA = ('Foswiki::Engine'); 21 21 22 use Foswiki::Request ();22 use Foswiki::Request (); 23 23 use Foswiki::Request::Upload (); 24 use Foswiki::Response ();24 use Foswiki::Response (); 25 25 26 26 sub run { -
trunk/core/lib/Foswiki/EngineException.pm
r3944 r3947 17 17 18 18 use Error (); 19 our @ISA = ( 'Error');19 our @ISA = ('Error'); 20 20 21 21 =begin TML -
trunk/core/lib/Foswiki/Form.pm
r3945 r3947 33 33 34 34 use Foswiki::Meta (); 35 our @ISA = ( 'Foswiki::Meta');35 our @ISA = ('Foswiki::Meta'); 36 36 37 37 use Assert; 38 38 use Error qw( :try ); 39 39 40 use Foswiki::Form::FieldDefinition ();40 use Foswiki::Form::FieldDefinition (); 41 41 use Foswiki::Form::ListFieldDefinition (); 42 42 -
trunk/core/lib/Foswiki/Form/Checkbox.pm
r3944 r3947 5 5 6 6 use Foswiki::Form::ListFieldDefinition (); 7 our @ISA = ( 'Foswiki::Form::ListFieldDefinition');7 our @ISA = ('Foswiki::Form::ListFieldDefinition'); 8 8 9 9 sub new { -
trunk/core/lib/Foswiki/Form/Label.pm
r3944 r3947 5 5 6 6 use Foswiki::Form::FieldDefinition (); 7 our @ISA = ( 'Foswiki::Form::FieldDefinition');7 our @ISA = ('Foswiki::Form::FieldDefinition'); 8 8 9 9 sub isEditable { -
trunk/core/lib/Foswiki/Form/ListFieldDefinition.pm
r3944 r3947 16 16 17 17 use Foswiki::Form::FieldDefinition (); 18 our @ISA = ( 'Foswiki::Form::FieldDefinition');18 our @ISA = ('Foswiki::Form::FieldDefinition'); 19 19 20 20 =begin TML -
trunk/core/lib/Foswiki/Form/Radio.pm
r3944 r3947 5 5 6 6 use Foswiki::Form::ListFieldDefinition (); 7 our @ISA = ( 'Foswiki::Form::ListFieldDefinition');7 our @ISA = ('Foswiki::Form::ListFieldDefinition'); 8 8 9 9 sub new { … … 26 26 foreach my $item ( @{ $this->getOptions() } ) { 27 27 $attrs{$item} = { 28 class => $this->cssClasses( 'foswikiRadioButton'),28 class => $this->cssClasses('foswikiRadioButton'), 29 29 label => $topicObject->expandMacros($item) 30 30 }; -
trunk/core/lib/Foswiki/Form/Select.pm
r3944 r3947 4 4 5 5 use Foswiki::Form::ListFieldDefinition (); 6 our @ISA = ( 'Foswiki::Form::ListFieldDefinition');6 our @ISA = ('Foswiki::Form::ListFieldDefinition'); 7 7 8 8 use Assert; -
trunk/core/lib/Foswiki/Form/Text.pm
r3944 r3947 5 5 6 6 use Foswiki::Form::FieldDefinition (); 7 our @ISA = ( 'Foswiki::Form::FieldDefinition');7 our @ISA = ('Foswiki::Form::FieldDefinition'); 8 8 9 9 sub new { -
trunk/core/lib/Foswiki/Form/Textarea.pm
r3944 r3947 5 5 6 6 use Foswiki::Form::FieldDefinition (); 7 our @ISA = ( 'Foswiki::Form::FieldDefinition');7 our @ISA = ('Foswiki::Form::FieldDefinition'); 8 8 9 9 sub new { … … 44 44 '', 45 45 CGI::textarea( 46 -class => $this->cssClasses( 'foswikiTextarea'),46 -class => $this->cssClasses('foswikiTextarea'), 47 47 -cols => $this->{cols}, 48 48 -rows => $this->{rows}, -
trunk/core/lib/Foswiki/Func.pm
r3946 r3947 53 53 use Assert; 54 54 55 use Foswiki ();55 use Foswiki (); 56 56 use Foswiki::Plugins (); 57 use Foswiki::Meta ();57 use Foswiki::Meta (); 58 58 59 59 =begin TML … … 1043 1043 sub getListOfWebs { 1044 1044 my $filter = shift; 1045 my $web = shift;1045 my $web = shift; 1046 1046 ASSERT($Foswiki::Plugins::SESSION) if DEBUG; 1047 1047 require Foswiki::WebFilter; 1048 1048 my $f = new Foswiki::WebFilter($filter); 1049 return $Foswiki::Plugins::SESSION->deepWebList( $f, $web);1049 return $Foswiki::Plugins::SESSION->deepWebList( $f, $web ); 1050 1050 } 1051 1051 … … 1631 1631 1632 1632 sub getAttachmentList { 1633 my ( $web, $topic) = @_;1633 my ( $web, $topic ) = @_; 1634 1634 ( $web, $topic ) = 1635 1635 $Foswiki::Plugins::SESSION->normalizeWebTopicName( $web, $topic ); 1636 my $topicObject = Foswiki::Meta->new(1637 $Foswiki::Plugins::SESSION, $web, $topic );1636 my $topicObject = 1637 Foswiki::Meta->new( $Foswiki::Plugins::SESSION, $web, $topic ); 1638 1638 my $it = $topicObject->eachAttachment(); 1639 1639 return sort $it->all(); … … 1657 1657 ( $web, $topic ) = 1658 1658 $Foswiki::Plugins::SESSION->normalizeWebTopicName( $web, $topic ); 1659 my $topicObject = Foswiki::Meta->new(1660 $Foswiki::Plugins::SESSION, $web, $topic );1661 return $topicObject->hasAttachment( $attachment);1659 my $topicObject = 1660 Foswiki::Meta->new( $Foswiki::Plugins::SESSION, $web, $topic ); 1661 return $topicObject->hasAttachment($attachment); 1662 1662 } 1663 1663 … … 2310 2310 $Foswiki::Plugins::SESSION = $record; 2311 2311 return $result; 2312 }, %options 2312 }, 2313 %options 2313 2314 ); 2314 2315 } -
trunk/core/lib/Foswiki/I18N.pm
r3946 r3947 93 93 . "\nInstall the module or turn off {UserInterfaceInternationalisation}" 94 94 ); 95 } else { 96 @Foswiki::I18N::ISA = ( 'Locale::Maketext' ); 95 } 96 else { 97 @Foswiki::I18N::ISA = ('Locale::Maketext'); 97 98 } 98 99 -
trunk/core/lib/Foswiki/I18N/Extract.pm
r3945 r3947 20 20 if ($@) { 21 21 $initError = $@; 22 } else { 23 @Foswiki::I18N::Extract::ISA = ( 'Locale::Maketext::Extract' ); 22 } 23 else { 24 @Foswiki::I18N::Extract::ISA = ('Locale::Maketext::Extract'); 24 25 } 25 26 } … … 41 42 my $session = shift; 42 43 43 if ( defined $initError) {44 if ( defined $initError ) { 44 45 $session->logger->log( 'warning', $initError ) if $session; 45 46 return; -
trunk/core/lib/Foswiki/I18N/Fallback.pm
r3944 r3947 8 8 9 9 use Foswiki::I18N (); 10 our @ISA = ( 'Foswiki::I18N');10 our @ISA = ('Foswiki::I18N'); 11 11 12 12 sub new { -
trunk/core/lib/Foswiki/If/Node.pm
r3944 r3947 14 14 15 15 use Foswiki::Query::Node (); 16 our @ISA = ( 'Foswiki::Query::Node');16 our @ISA = ('Foswiki::Query::Node'); 17 17 18 18 use Foswiki::Infix::Node (); -
trunk/core/lib/Foswiki/If/OP_allows.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::BinaryOP (); 14 our @ISA = ( 'Foswiki::Query::BinaryOP');14 our @ISA = ('Foswiki::Query::BinaryOP'); 15 15 16 16 use Assert; -
trunk/core/lib/Foswiki/If/OP_context.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::UnaryOP (); 14 our @ISA = ( 'Foswiki::Query::UnaryOP');14 our @ISA = ('Foswiki::Query::UnaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/If/OP_defined.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::UnaryOP (); 14 our @ISA = ( 'Foswiki::Query::UnaryOP');14 our @ISA = ('Foswiki::Query::UnaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/If/OP_dollar.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::UnaryOP (); 14 our @ISA = ( 'Foswiki::Query::UnaryOP');14 our @ISA = ('Foswiki::Query::UnaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/If/OP_ingroup.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::BinaryOP (); 14 our @ISA = ( 'Foswiki::Query::BinaryOP');14 our @ISA = ('Foswiki::Query::BinaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/If/OP_isempty.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::UnaryOP (); 14 our @ISA = ( 'Foswiki::Query::UnaryOP');14 our @ISA = ('Foswiki::Query::UnaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/If/OP_istopic.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::UnaryOP (); 14 our @ISA = ( 'Foswiki::Query::UnaryOP');14 our @ISA = ('Foswiki::Query::UnaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/If/OP_isweb.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::UnaryOP (); 14 our @ISA = ( 'Foswiki::Query::UnaryOP');14 our @ISA = ('Foswiki::Query::UnaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/If/Parser.pm
r3944 r3947 14 14 15 15 use Foswiki::Query::Parser (); 16 our @ISA = ( 'Foswiki::Query::Parser');16 our @ISA = ('Foswiki::Query::Parser'); 17 17 18 18 use Assert; -
trunk/core/lib/Foswiki/IncludeHandlers/http.pm
r3665 r3947 38 38 my $topicObject = 39 39 Foswiki::Meta->new( $session, $incWeb, $incTopic ); 40 unless ( $topicObject->hasAttachment( $incAtt ) ) 41 { 40 unless ( $topicObject->hasAttachment($incAtt) ) { 42 41 return $session->_includeWarning( $control->{warn}, 43 42 'bad_attachment', $url ); … … 53 52 } 54 53 } 55 my $fh = $topicObject->openAttachment( $incAtt, '<');54 my $fh = $topicObject->openAttachment( $incAtt, '<' ); 56 55 local $/; 57 56 $text = <$fh>; -
trunk/core/lib/Foswiki/Infix/Error.pm
r3944 r3947 13 13 14 14 use Error (); 15 our @ISA = ( 'Error');15 our @ISA = ('Error'); 16 16 17 17 sub new { -
trunk/core/lib/Foswiki/Infix/Parser.pm
r3440 r3947 18 18 use Error qw( :try ); 19 19 use Foswiki::Infix::Error (); 20 use Foswiki::Infix::Node ();20 use Foswiki::Infix::Node (); 21 21 22 22 # Set to 1 for debug -
trunk/core/lib/Foswiki/Iterator.pm
r3300 r3947 55 55 sub next { ASSERT('Pure virtual function called') if DEBUG; } 56 56 57 58 57 =begin TML 59 58 -
trunk/core/lib/Foswiki/Iterator/FilterIterator.pm
r3945 r3947 15 15 16 16 use Foswiki::Iterator (); 17 our @ISA = ( 'Foswiki::Iterator');17 our @ISA = ('Foswiki::Iterator'); 18 18 19 19 =begin TML … … 67 67 my ($this) = @_; 68 68 69 return unless ( $this->{iterator}->reset());70 $this->{next} = undef;69 return unless ( $this->{iterator}->reset() ); 70 $this->{next} = undef; 71 71 $this->{pending} = 0; 72 72 -
trunk/core/lib/Foswiki/Iterator/ProcessIterator.pm
r3944 r3947 16 16 17 17 use Foswiki::Iterator (); 18 our @ISA = ( 'Foswiki::Iterator');18 our @ISA = ('Foswiki::Iterator'); 19 19 20 20 =begin TML -
trunk/core/lib/Foswiki/LineIterator.pm
r3944 r3947 15 15 16 16 use Foswiki::Iterator (); 17 our @ISA = ( 'Foswiki::Iterator');17 our @ISA = ('Foswiki::Iterator'); 18 18 19 19 =begin TML -
trunk/core/lib/Foswiki/ListIterator.pm
r3944 r3947 14 14 15 15 use Foswiki::Iterator (); 16 our @ISA = ( 'Foswiki::Iterator');16 our @ISA = ('Foswiki::Iterator'); 17 17 18 18 use Assert; … … 31 31 my ( $class, $list ) = @_; 32 32 33 ASSERT( !defined($list) || UNIVERSAL::isa( $list, 'ARRAY' )) if DEBUG;33 ASSERT( !defined($list) || UNIVERSAL::isa( $list, 'ARRAY' ) ) if DEBUG; 34 34 35 35 my $this = bless( … … 164 164 sub reset { 165 165 my ($this) = @_; 166 $this->{next} = undef;166 $this->{next} = undef; 167 167 $this->{index} = 0; 168 168 -
trunk/core/lib/Foswiki/Logger/PlainFile.pm
r3944 r3947 6 6 7 7 use Foswiki::Logger (); 8 our @ISA = ( 'Foswiki::Logger');8 our @ISA = ('Foswiki::Logger'); 9 9 10 10 =begin TML … … 27 27 =cut 28 28 29 use Foswiki::Time ();29 use Foswiki::Time (); 30 30 use Foswiki::ListIterator (); 31 31 … … 79 79 package Foswiki::Logger::EventIterator; 80 80 require Foswiki::LineIterator; 81 @Foswiki::Logger::EventIterator::ISA = ( 'Foswiki::LineIterator');81 @Foswiki::Logger::EventIterator::ISA = ('Foswiki::LineIterator'); 82 82 83 83 sub new { -
trunk/core/lib/Foswiki/LoginManager.pm
r3945 r3947 1006 1006 1007 1007 sub isValidLoginName { 1008 my ($this, $name) = @_; 1008 my ( $this, $name ) = @_; 1009 1009 1010 # this function was erroneously marked as static 1010 ASSERT( !ref($name) ) if DEBUG;1011 ASSERT( !ref($name) ) if DEBUG; 1011 1012 return $name =~ /$Foswiki::cfg{LoginNameFilterIn}/; 1012 1013 } -
trunk/core/lib/Foswiki/LoginManager/ApacheLogin.pm
r3945 r3947 26 26 27 27 use Foswiki::LoginManager (); 28 our @ISA = ( 'Foswiki::LoginManager');28 our @ISA = ('Foswiki::LoginManager'); 29 29 30 30 =begin TML -
trunk/core/lib/Foswiki/LoginManager/Session.pm
r3944 r3947 20 20 21 21 use CGI::Session (); 22 our @ISA = ( 'CGI::Session');22 our @ISA = ('CGI::Session'); 23 23 24 24 *VERSION = \$CGI::Session::VERSION; -
trunk/core/lib/Foswiki/LoginManager/TemplateLogin.pm
r3945 r3947 21 21 22 22 use Foswiki::LoginManager (); 23 our @ISA = ( 'Foswiki::LoginManager');23 our @ISA = ('Foswiki::LoginManager'); 24 24 25 25 =begin TML -
trunk/core/lib/Foswiki/Meta.pm
r3945 r3947 138 138 $this->{_web} = $web; 139 139 $this->{_topic} = $topic; 140 140 141 #$this->{_text} = undef; # topics only 141 142 … … 233 234 return '' unless $path; 234 235 return $path unless $this->{_topic}; 235 $path .= '.' .$this->{_topic};236 $path .= '.' . $this->{_topic}; 236 237 return $path; 237 238 } … … 251 252 my $scope; 252 253 253 unless ( $this->{_web} || $this->{_topic}) {254 unless ( $this->{_web} || $this->{_topic} ) { 254 255 return $this->{_session}->{prefs}->getPreference($key); 255 256 } 257 256 258 # make sure the preferences are parsed and cached 257 259 unless ( $this->{_preferences} ) { … … 293 295 =cut 294 296 295 sub existsInStore {297 sub existsInStore { 296 298 my $this = shift; 297 299 if ( defined $this->{_topic} ) { 298 return $this->{_session}->{store} ->topicExists(299 $this->{_web}, $this->{_topic} );300 return $this->{_session}->{store} 301 ->topicExists( $this->{_web}, $this->{_topic} ); 300 302 } 301 303 elsif ( defined $this->{_web} ) { 302 304 return $this->{_session}->{store}->webExists( $this->{_web} ); 303 } else { 304 return 1; # the root always exists 305 } 306 else { 307 return 1; # the root always exists 305 308 } 306 309 } … … 361 364 my $topic = $it->next(); 362 365 next unless ( $templateWeb =~ /^_/ || $topic =~ /^Web/ ); 363 my $topicObject = Foswiki::Meta->load(364 $this->{_session}, $templateWeb, $topic );366 my $topicObject = 367 Foswiki::Meta->load( $this->{_session}, $templateWeb, $topic ); 365 368 $topicObject->saveAs( $this->{_web}, $topic ); 366 369 } … … 389 392 $Foswiki::cfg{WebPrefsTopicName} ); 390 393 my $text = $prefsTopicObject->text; 391 foreach my $key ( keys %$opts) {394 foreach my $key ( keys %$opts ) { 392 395 $text =~ 393 396 s/($Foswiki::regex{setRegex}$key\s*=).*?$/$1 $opts->{$key}/gm 394 if defined $opts->{$key};397 if defined $opts->{$key}; 395 398 } 396 399 $prefsTopicObject->text($text); … … 483 486 my ($this) = @_; 484 487 ASSERT( !$this->{_topic} ) if DEBUG; 485 if (!$this->{_web}) { 488 if ( !$this->{_web} ) { 489 486 490 # Root 487 491 require Foswiki::ListIterator; 488 return new Foswiki::ListIterator( []);489 } 490 return $this->{_session}->{store}->eachTopic( $this);492 return new Foswiki::ListIterator( [] ); 493 } 494 return $this->{_session}->{store}->eachTopic($this); 491 495 } 492 496 … … 507 511 my ($this) = @_; 508 512 ASSERT( $this->{_topic} ) if DEBUG; 509 ASSERT( $this->{_web} ) if DEBUG;510 return $this->{_session}->{store}->eachAttachment( $this);513 ASSERT( $this->{_web} ) if DEBUG; 514 return $this->{_session}->{store}->eachAttachment($this); 511 515 } 512 516 … … 582 586 $this->{FILEATTACHMENT} = []; 583 587 $this->{_loadedRev} = $this->{_session}->{store}->readTopic( $this, $rev ); 584 #SMELL: removed see getLoadedRevision - should remove any non-numeric rev's (like the $rev stuff from svn) 588 589 #SMELL: removed see getLoadedRevision - should remove any non-numeric rev's (like the $rev stuff from svn) 585 590 $this->{_preferences}->finish() if defined $this->{_preferences}; 586 591 $this->{_preferences} = undef; … … 606 611 else { 607 612 608 # Lazy load609 #SMELL: will reload repeatedly if there is no topic text - ie if the topic is all META613 # Lazy load 614 #SMELL: will reload repeatedly if there is no topic text - ie if the topic is all META 610 615 $this->reload() unless defined( $this->{_text} ); 611 616 } … … 1175 1180 undef $reason; 1176 1181 1177 print STDERR "Check $mode access $cUID to " .$this->getPath()."\n"1182 print STDERR "Check $mode access $cUID to " . $this->getPath() . "\n" 1178 1183 if MONITOR_ACLS; 1179 1184 … … 1403 1408 1404 1409 sub _atomicLock { 1405 my ( $this, $cUID) = @_;1410 my ( $this, $cUID ) = @_; 1406 1411 if ( $this->{_topic} ) { 1407 1412 1408 1413 # Topic 1409 $this->{_session}->{store}->lockTopic( $this, $cUID);1414 $this->{_session}->{store}->lockTopic( $this, $cUID ); 1410 1415 } 1411 1416 else { … … 1429 1434 1430 1435 sub _atomicUnlock { 1431 my ( $this, $cUID) = @_;1436 my ( $this, $cUID ) = @_; 1432 1437 if ( $this->{_topic} ) { 1433 $this->{_session}->{store}->unlockTopic( $this, $cUID);1438 $this->{_session}->{store}->unlockTopic( $this, $cUID ); 1434 1439 } 1435 1440 else { … … 1531 1536 1532 1537 sub deleteMostRecentRevision { 1533 my ( $this, %opts) = @_;1538 my ( $this, %opts ) = @_; 1534 1539 my $rev; 1535 1540 my $cUID = $opts{user} || $this->{_session}->{user}; … … 1537 1542 $this->_atomicLock($cUID); 1538 1543 try { 1539 $rev = $this->{_session}->{store}->delRev( $this, $cUID);1544 $rev = $this->{_session}->{store}->delRev( $this, $cUID ); 1540 1545 } 1541 1546 finally { … … 1587 1592 $extra .= Foswiki::Time::formatTime( $info->{date}, '$rcs', 'gmtime' ); 1588 1593 $extra .= ' minor' if ( $opts{minor} ); 1589 $this->{_session}->writeLog( 1590 $opts{forcedate} ? 'cmd' : 'save', 1591 $this->getPath(), 1592 $extra, $cUID 1593 ); 1594 $this->{_session}->writeLog( $opts{forcedate} ? 'cmd' : 'save', 1595 $this->getPath(), $extra, $cUID ); 1594 1596 } 1595 1597 } … … 1661 1663 1662 1664 if ( $attachment 1663 && !$store->attachmentExists( $this, $attachment ) ) { 1665 && !$store->attachmentExists( $this, $attachment ) ) 1666 { 1664 1667 throw Error::Simple( 'No such attachment ' 1665 1668 . $this->{_web} . '.' … … 1776 1779 1777 1780 sub onTick { 1778 my ( $this, $time) = @_;1779 1780 if ( !$this->{_topic}) {1781 my ( $this, $time ) = @_; 1782 1783 if ( !$this->{_topic} ) { 1781 1784 my $it = $this->eachWeb(); 1782 while ( $it->hasNext()) {1785 while ( $it->hasNext() ) { 1783 1786 my $web = $it->next(); 1784 $web = $this->getPath() ."/$web" if $this->getPath();1785 my $m = new Foswiki::Meta( $this->{_session}, $web);1787 $web = $this->getPath() . "/$web" if $this->getPath(); 1788 my $m = new Foswiki::Meta( $this->{_session}, $web ); 1786 1789 $m->onTick($time); 1787 1790 } 1788 1791 $it = $this->eachTopic(); 1789 while ( $it->hasNext()) {1792 while ( $it->hasNext() ) { 1790 1793 my $topic = $it->next(); 1791 my $topicObject = new Foswiki::Meta(1792 $this->{_session}, $this->getPath(), $topic);1794 my $topicObject = 1795 new Foswiki::Meta( $this->{_session}, $this->getPath(), $topic ); 1793 1796 $topicObject->onTick($time); 1794 1797 } 1798 1795 1799 # Clean up spurious leases that may have been left behind 1796 1800 # during cancelled topic creation 1797 $this->{_session}->{store} 1798 ->removeSpuriousLeases( $this->getPath() );1799 }else {1801 $this->{_session}->{store}->removeSpuriousLeases( $this->getPath() ); 1802 } 1803 else { 1800 1804 my $lease = $this->getLease(); 1801 if ( $lease && $lease->{expires} < $time) {1805 if ( $lease && $lease->{expires} < $time ) { 1802 1806 $this->clearLease(); 1803 1807 } … … 1869 1873 $action = 'upload'; 1870 1874 1871 $attrs = {1875 $attrs = { 1872 1876 name => $opts{name}, 1873 1877 attachment => $opts{name}, … … 1879 1883 1880 1884 if ( $plugins->haveHandlerFor('beforeAttachmentSaveHandler') ) { 1885 1881 1886 # SMELL: the attachment handler requires a file on disc 1882 1887 # Because of the way CGI works, the stream is actually attached … … 1900 1905 try { 1901 1906 $this->{_session}->{store} 1902 ->saveAttachment( 1903 $this, $opts{name}, $opts{stream},1904 $opts{author} || $this->{_session}->{user});1905 }catch Error with {1907 ->saveAttachment( $this, $opts{name}, $opts{stream}, 1908 $opts{author} || $this->{_session}->{user} ); 1909 } 1910 catch Error with { 1906 1911 $error = shift; 1907 1912 }; … … 1909 1914 my $fileVersion = $this->getMaxRevNo( $opts{name} ); 1910 1915 $attrs->{version} = $fileVersion; 1911 $attrs->{path} = $opts{filepath} if ( defined( $opts{filepath} ) );1912 $attrs->{size} = $opts{filesize} if ( defined( $opts{filesize} ) );1913 $attrs->{date} = $opts{filedate} if ( defined( $opts{filedate} ) );1916 $attrs->{path} = $opts{filepath} if ( defined( $opts{filepath} ) ); 1917 $attrs->{size} = $opts{filesize} if ( defined( $opts{filesize} ) ); 1918 $attrs->{date} = $opts{filedate} if ( defined( $opts{filedate} ) ); 1914 1919 1915 1920 if ( $plugins->haveHandlerFor('afterAttachmentSaveHandler') ) { 1916 1921 $plugins->dispatch( 'afterAttachmentSaveHandler', $attrs, 1917 $this->{_topic}, $this->{_web},1918 $error ? $error->{-text} : undef );1922 $this->{_topic}, $this->{_web}, 1923 $error ? $error->{-text} : undef ); 1919 1924 } 1920 1925 } … … 1994 1999 1995 2000 sub testAttachment { 1996 my ($this, $attachment, $test) = @_; 1997 1998 $test =~ /(\w)/; $test = $1; 1999 if ($test eq 'r') { 2001 my ( $this, $attachment, $test ) = @_; 2002 2003 $test =~ /(\w)/; 2004 $test = $1; 2005 if ( $test eq 'r' ) { 2000 2006 return $this->haveAccess('VIEW'); 2001 } elsif ($test eq 'w') { 2007 } 2008 elsif ( $test eq 'w' ) { 2002 2009 return $this->haveAccess('CHANGE'); 2003 2010 } 2004 2011 2005 return return $this->{_session}->{store} 2006 ->testAttachment($this, $attachment, $test); 2012 return 2013 return $this->{_session}->{store} 2014 ->testAttachment( $this, $attachment, $test ); 2007 2015 } 2008 2016 … … 2032 2040 2033 2041 sub openAttachment { 2034 my ( $this, $attachment, $mode, @opts) = @_;2042 my ( $this, $attachment, $mode, @opts ) = @_; 2035 2043 2036 2044 return $this->{_session}->{store} 2037 ->openAttachment( $this, $attachment, $mode, @opts);2045 ->openAttachment( $this, $attachment, $mode, @opts ); 2038 2046 2039 2047 } … … 2063 2071 try { 2064 2072 $this->{_session}->{store} 2065 ->moveAttachment( $this, $name, $to, $newName, $cUID );2073 ->moveAttachment( $this, $name, $to, $newName, $cUID ); 2066 2074 $this->reload(); 2067 2075 $to->reload(); 2068 } finally { 2076 } 2077 finally { 2069 2078 $to->_atomicUnlock($cUID); 2070 2079 $this->_atomicUnlock($cUID); -
trunk/core/lib/Foswiki/Net/UserCredAgent.pm
r3944 r3947 9 9 10 10 use LWP::UserAgent (); 11 our @ISA = ( 'LWP::UserAgent');11 our @ISA = ('LWP::UserAgent'); 12 12 13 13 sub new { -
trunk/core/lib/Foswiki/OopsException.pm
r3944 r3947 88 88 89 89 use Error (); 90 our @ISA = ( 'Error');90 our @ISA = ('Error'); 91 91 92 92 use Assert; -
trunk/core/lib/Foswiki/Prefs.pm
r3877 r3947 464 464 next 465 465 unless defined $stack->backAtLevel(-2)->getLocal($k) 466 && !$stack->finalizedBefore( $k, -2);466 && !$stack->finalizedBefore( $k, -2 ); 467 467 my $val = 468 468 Foswiki::entityEncode( $stack->backAtLevel(-2)->getLocal($k) ); -
trunk/core/lib/Foswiki/Prefs/BaseBackend.pm
r3805 r3947 24 24 25 25 sub new { 26 my ( $proto, $values) = @_;26 my ( $proto, $values ) = @_; 27 27 my $class = ref($proto) || $proto; 28 28 … … 111 111 112 112 sub cleanupInsertValue { 113 my ( $this, $value_ref) = @_;114 115 $$value_ref =~ tr/\r//d; # Delete \r116 $$value_ref =~ tr/\t/ /; # replace TAB by space117 $$value_ref =~ s/([^\\])\\n/$1\n/g; # replace \n by new line118 $$value_ref =~ s/([^\\])\\\\n/$1\\n/g; # replace \\n by \n119 $$value_ref =~ tr/`//d; # filter out dangerous chars113 my ( $this, $value_ref ) = @_; 114 115 $$value_ref =~ tr/\r//d; # Delete \r 116 $$value_ref =~ tr/\t/ /; # replace TAB by space 117 $$value_ref =~ s/([^\\])\\n/$1\n/g; # replace \n by new line 118 $$value_ref =~ s/([^\\])\\\\n/$1\\n/g; # replace \\n by \n 119 $$value_ref =~ tr/`//d; # filter out dangerous chars 120 120 } 121 121 -
trunk/core/lib/Foswiki/Prefs/HASH.pm
r3945 r3947 21 21 22 22 sub new { 23 my ( $proto, $values) = @_;23 my ( $proto, $values ) = @_; 24 24 25 25 my $this = $proto->SUPER::new(); 26 while ( my ($key, $value) = each %$values) {27 $this->insert( 'Set', $key, $value);26 while ( my ( $key, $value ) = each %$values ) { 27 $this->insert( 'Set', $key, $value ); 28 28 } 29 29 … … 43 43 44 44 sub get { 45 my ( $this, $key) = @_;45 my ( $this, $key ) = @_; 46 46 return $this->{$key}; 47 47 } … … 54 54 my ( $this, $type, $key, $value ) = @_; 55 55 56 $this->cleanupInsertValue( \$value);56 $this->cleanupInsertValue( \$value ); 57 57 $this->{$key} = $value; 58 58 return 1; -
trunk/core/lib/Foswiki/Prefs/Parser.pm
r3440 r3947 74 74 # PREFERENCE_<pref title> but that's all I can work out :-( 75 75 # I can't find any clues in Codev either. 76 if ( defined($field->{title})) {76 if ( defined( $field->{title} ) ) { 77 77 $prefs->insert( $type, 'PREFERENCE_' . $field->{title}, $value ); 78 78 } -
trunk/core/lib/Foswiki/Prefs/Stack.pm
r3945 r3947 312 312 foreach my $p ( keys %{ $this->{'map'} } ) { 313 313 $this->{'map'}{$p} &= $mask; 314 314 315 315 while ( length( $this->{'map'}{$p} ) > 0 316 316 && ord( substr( $this->{'map'}{$p}, -1 ) ) == 0 ) … … 318 318 substr( $this->{'map'}{$p}, -1 ) = ''; 319 319 } 320 320 321 321 delete $this->{'map'}{$p} if length( $this->{'map'}{$p} ) == 0; 322 322 } -
trunk/core/lib/Foswiki/Prefs/TopicRAM.pm
r3944 r3947 79 79 my ( $this, $type, $key, $value ) = @_; 80 80 81 $this->cleanupInsertValue( \$value);81 $this->cleanupInsertValue( \$value ); 82 82 83 83 my $index = $type eq 'Set' ? 'values' : 'local'; -
trunk/core/lib/Foswiki/Prefs/Web.pm
r3877 r3947 29 29 my $proto = shift; 30 30 my $class = ref($proto) || $proto; 31 my ( $stack, $level) = @_;32 my $this = {31 my ( $stack, $level ) = @_; 32 my $this = { 33 33 stack => $stack, 34 34 level => $level, … … 93 93 94 94 sub cloneStack { 95 my ( $this, $level) = @_;95 my ( $this, $level ) = @_; 96 96 return $this->{stack}->clone($level); 97 97 } … … 106 106 107 107 sub get { 108 my ( $this, $key) = @_;108 my ( $this, $key ) = @_; 109 109 $this->{stack}->getPreference( $key, $this->{level} ); 110 110 } -
trunk/core/lib/Foswiki/Query/Node.pm
r3944 r3947 27 27 28 28 use Foswiki::Infix::Node (); 29 our @ISA = ( 'Foswiki::Infix::Node');29 our @ISA = ('Foswiki::Infix::Node'); 30 30 31 31 # 1 for debug -
trunk/core/lib/Foswiki/Query/OP_and.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::BinaryOP (); 14 our @ISA = ( 'Foswiki::Query::BinaryOP');14 our @ISA = ('Foswiki::Query::BinaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/Query/OP_d2n.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::UnaryOP (); 14 our @ISA = ( 'Foswiki::Query::UnaryOP');14 our @ISA = ('Foswiki::Query::UnaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/Query/OP_dot.pm
r3945 r3947 12 12 13 13 use Foswiki::Query::BinaryOP (); 14 our @ISA = ( 'Foswiki::Query::BinaryOP');14 our @ISA = ('Foswiki::Query::BinaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/Query/OP_eq.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::BinaryOP (); 14 our @ISA = ( 'Foswiki::Query::BinaryOP');14 our @ISA = ('Foswiki::Query::BinaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/Query/OP_gt.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::BinaryOP (); 14 our @ISA = ( 'Foswiki::Query::BinaryOP');14 our @ISA = ('Foswiki::Query::BinaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/Query/OP_gte.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::BinaryOP (); 14 our @ISA = ( 'Foswiki::Query::BinaryOP');14 our @ISA = ('Foswiki::Query::BinaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/Query/OP_lc.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::UnaryOP (); 14 our @ISA = ( 'Foswiki::Query::UnaryOP');14 our @ISA = ('Foswiki::Query::UnaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/Query/OP_length.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::UnaryOP (); 14 our @ISA = ( 'Foswiki::Query::UnaryOP');14 our @ISA = ('Foswiki::Query::UnaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/Query/OP_like.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::BinaryOP (); 14 our @ISA = ( 'Foswiki::Query::BinaryOP');14 our @ISA = ('Foswiki::Query::BinaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/Query/OP_lt.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::BinaryOP (); 14 our @ISA = ( 'Foswiki::Query::BinaryOP');14 our @ISA = ('Foswiki::Query::BinaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/Query/OP_lte.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::BinaryOP (); 14 our @ISA = ( 'Foswiki::Query::BinaryOP');14 our @ISA = ('Foswiki::Query::BinaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/Query/OP_ne.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::BinaryOP (); 14 our @ISA = ( 'Foswiki::Query::BinaryOP');14 our @ISA = ('Foswiki::Query::BinaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/Query/OP_not.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::UnaryOP (); 14 our @ISA = ( 'Foswiki::Query::UnaryOP');14 our @ISA = ('Foswiki::Query::UnaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/Query/OP_ob.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::UnaryOP (); 14 our @ISA = ( 'Foswiki::Query::UnaryOP');14 our @ISA = ('Foswiki::Query::UnaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/Query/OP_or.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::BinaryOP (); 14 our @ISA = ( 'Foswiki::Query::BinaryOP');14 our @ISA = ('Foswiki::Query::BinaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/Query/OP_ref.pm
r3945 r3947 13 13 14 14 use Foswiki::Query::BinaryOP (); 15 our @ISA = ( 'Foswiki::Query::BinaryOP');15 our @ISA = ('Foswiki::Query::BinaryOP'); 16 16 17 17 sub new { -
trunk/core/lib/Foswiki/Query/OP_uc.pm
r3944 r3947 12 12 13 13 use Foswiki::Query::UnaryOP (); 14 our @ISA = ( 'Foswiki::Query::UnaryOP');14 our @ISA = ('Foswiki::Query::UnaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/Query/OP_where.pm
r3945 r3947 12 12 13 13 use Foswiki::Query::BinaryOP (); 14 our @ISA = ( 'Foswiki::Query::BinaryOP');14 our @ISA = ('Foswiki::Query::BinaryOP'); 15 15 16 16 sub new { -
trunk/core/lib/Foswiki/Query/Parser.pm
r3944 r3947 15 15 16 16 use Foswiki::Infix::Parser (); 17 our @ISA = ( 'Foswiki::Infix::Parser');17 our @ISA = ('Foswiki::Infix::Parser'); 18 18 19 19 use Foswiki::Query::Node (); -
trunk/core/lib/Foswiki/Render.pm
r3618 r3947 137 137 $text =~ s/\$web/$pWeb/g; 138 138 $text =~ s/\$topic/$pTopic/g; 139 if( ! $depth or $currentDepth == $depth ) { 139 140 if ( !$depth or $currentDepth == $depth ) { 140 141 unshift( @stack, $text ); 141 142 } … … 336 337 $row =~ s/\t/ /g; # change tabs to space 337 338 $row =~ s/\s*$//; # remove trailing spaces 338 # calc COLSPAN339 # calc COLSPAN 339 340 $row =~ s/(\|\|+)/ 340 341 'colspan'.$Foswiki::TranslationToken.length($1).'|'/ge; … … 397 398 $text =~ s/$Foswiki::regex{headerPatternNoTOC}//o; 398 399 399 my $html = '<nop><h' . $level . '>' 400 . $this->_makeAnchorTarget( $topicObject, $text ) 401 . ' ' . $text . ' </h' . $level . '>'; 400 my $html = 401 '<nop><h' 402 . $level . '>' 403 . $this->_makeAnchorTarget( $topicObject, $text ) . ' ' 404 . $text . ' </h' 405 . $level . '>'; 402 406 403 407 return $html; … … 406 410 # Make an anchor that can be used as the target of links. 407 411 sub _makeAnchorTarget { 408 my ($this, $topicObject, $text) = @_; 409 410 my $goodAnchor = $this->_makeAnchorName( $text ); 411 my $html = CGI::a( { 412 name => $this->_makeAnchorNameUnique($topicObject, $goodAnchor), 413 }, '' ); 414 415 if ($Foswiki::cfg{RequireCompatibleAnchors}) { 412 my ( $this, $topicObject, $text ) = @_; 413 414 my $goodAnchor = $this->_makeAnchorName($text); 415 my $html = CGI::a( 416 { name => $this->_makeAnchorNameUnique( $topicObject, $goodAnchor ), }, 417 '' 418 ); 419 420 if ( $Foswiki::cfg{RequireCompatibleAnchors} ) { 421 416 422 # Add in extra anchors compatible with old formats, as required 417 423 require Foswiki::Compatibility; 418 my @extras = Foswiki::Compatibility::makeCompatibleAnchors( $text ); 419 foreach my $extra ( @extras ) { 420 next if ($extra eq $goodAnchor); 421 $html .= CGI::a( { 422 name => $this->_makeAnchorNameUnique( $topicObject, $extra ), 423 }, '' ); 424 my @extras = Foswiki::Compatibility::makeCompatibleAnchors($text); 425 foreach my $extra (@extras) { 426 next if ( $extra eq $goodAnchor ); 427 $html .= CGI::a( 428 { 429 name => 430 $this->_makeAnchorNameUnique( $topicObject, $extra ), 431 }, 432 '' 433 ); 424 434 } 425 435 } … … 441 451 442 452 if ( $text =~ /^$Foswiki::regex{anchorRegex}$/ ) { 453 443 454 # accept, already valid -- just remove leading # 444 455 return substr( $text, 1 ); … … 447 458 # $anchorName is a *byte* string. If it contains any wide characters 448 459 # the encoding algorithm will not work. 449 ASSERT( $text !~ /[^\x00-\xFF]/) if DEBUG;460 ASSERT( $text !~ /[^\x00-\xFF]/ ) if DEBUG; 450 461 451 462 # use _ as an escape character to escape any byte outside the … … 454 465 455 466 # Ensure the anchor always starts with an [A-Za-z] 456 $text = 'A' .$text;467 $text = 'A' . $text; 457 468 458 469 return $text; … … 534 545 535 546 sub internalLink { 536 my ( $this, $web, $topic, $linkText, $anchor, $linkIfAbsent, 537 $ keepWebPrefix, $hasExplicitLinkLabel )547 my ( $this, $web, $topic, $linkText, $anchor, $linkIfAbsent, $keepWebPrefix, 548 $hasExplicitLinkLabel ) 538 549 = @_; 539 550 … … 583 594 sub _renderWikiWord { 584 595 my ( $this, $web, $topic, $linkText, $anchor, $linkIfAbsent, 585 $keepWebPrefix ) 586 = @_; 596 $keepWebPrefix ) = @_; 587 597 my $session = $this->{session}; 588 598 my $topicExists = $session->topicExists( $web, $topic ); … … 635 645 my $href = $this->{session}->getScriptUrl( 0, 'view', $web, $topic ); 636 646 if ($anchor) { 637 $anchor = $this->_makeAnchorName( $anchor ); 647 $anchor = $this->_makeAnchorName($anchor); 648 638 649 # No point in trying to make it unique; just aim at the first 639 650 # occurrence 640 $href = $href.'#'.Foswiki::urlEncode($anchor);651 $href = $href . '#' . Foswiki::urlEncode($anchor); 641 652 } 642 653 my $cssClassName = "$currentTopic$currentWebHome"; … … 865 876 my $formField = $params->{_DEFAULT}; 866 877 return '' unless defined $formField; 867 my $altText = $params->{alttext};868 my $default = $params->{default};869 my $rev = $params->{rev} || '';870 my $format = $params->{format};871 872 unless ( defined $format) {878 my $altText = $params->{alttext}; 879 my $default = $params->{default}; 880 my $rev = $params->{rev} || ''; 881 my $format = $params->{format}; 882 883 unless ( defined $format ) { 873 884 $format = '$value'; 874 885 } … … 876 887 # SMELL: this local creation of a cache looks very suspicious. Suspect 877 888 # this may have been a one-off optimisation. 878 my $formTopicObject = $this->{ffCache}{ $topicObject->getPath() .$rev };889 my $formTopicObject = $this->{ffCache}{ $topicObject->getPath() . $rev }; 879 890 unless ($formTopicObject) { 880 $formTopicObject = Foswiki::Meta->load( 881 $this->{session}, $topicObject->web, $topicObject->topic, $rev ); 891 $formTopicObject = 892 Foswiki::Meta->load( $this->{session}, $topicObject->web, 893 $topicObject->topic, $rev ); 882 894 unless ( $formTopicObject->haveAccess('VIEW') ) { 883 895 884 896 # Access violation, create dummy meta with empty text, so 885 897 # it looks like it was already loaded. 886 $formTopicObject = Foswiki::Meta->new( 887 $this->{session}, $topicObject->web, $topicObject->topic, '' ); 888 } 889 $this->{ffCache}{ $formTopicObject->getPath().$rev } = 898 $formTopicObject = 899 Foswiki::Meta->new( $this->{session}, $topicObject->web, 900 $topicObject->topic, '' ); 901 } 902 $this->{ffCache}{ $formTopicObject->getPath() . $rev } = 890 903 $formTopicObject; 891 904 } … … 1078 1091 # the 'relabeling' of anchor names if the same topic is processed 1079 1092 # more than once, cf. explanation in expandMacros() 1080 $this->_clearAnchorNames( $topicObject);1093 $this->_clearAnchorNames($topicObject); 1081 1094 1082 1095 # '#WikiName' anchors. Don't attempt to make these unique; renaming … … 1798 1811 # special characters 1799 1812 $matchWeb =~ s#[./]#$REMARKER#g; 1800 $matchWeb = quotemeta( $matchWeb ); 1813 $matchWeb = quotemeta($matchWeb); 1814 1801 1815 # $REMARKER is escaped by quotemeta so we need to match the escape 1802 1816 $matchWeb =~ s#\\$REMARKER#[./]#go; … … 2058 2072 # targets to normal rendering. 2059 2073 2060 2061 2074 # clear the set of unique anchornames in order to inhibit 2062 2075 # the 'relabeling' of anchor names if the same topic is processed 2063 2076 # more than once, cf. explanation in expandMacros() 2064 $this->_clearAnchorNames( $topicObject);2077 $this->_clearAnchorNames($topicObject); 2065 2078 2066 2079 # NB: While we're processing $text line by line here, … … 2069 2082 # regex{headerPatternDa}. We have to adhere to this 2070 2083 # order here as well. 2071 my @regexps = ( 2072 $Foswiki::regex{headerPatternHt}, 2073 $Foswiki::regex{headerPatternDa} 2074 ); 2075 my @lines = split( /\r?\n/, $text ); 2084 my @regexps = 2085 ( $Foswiki::regex{headerPatternHt}, $Foswiki::regex{headerPatternDa} ); 2086 my @lines = split( /\r?\n/, $text ); 2076 2087 my @targets; 2077 2088 my $lineno = 0; … … 2080 2091 for my $i ( 0 .. $#regexps ) { 2081 2092 if ( $line =~ m/$regexps[$i]/ ) { 2093 2082 2094 # c.f. _makeAnchorHeading 2083 2095 my ( $level, $text ) = ( $1, $2 ); … … 2086 2098 my $atext = $text; 2087 2099 $text =~ s/\s*$Foswiki::regex{headerPatternNoTOC}.*//o; 2100 2088 2101 # Ignore empty headings 2089 2102 next unless $text; 2090 2103 2091 2104 # $i == 1 is $Foswiki::regex{headerPatternDa} 2092 $level = length( $level) if ( $i == 1 );2105 $level = length($level) if ( $i == 1 ); 2093 2106 if ( ( $level >= $minDepth ) && ( $level <= $maxDepth ) ) { 2094 my $anchor = $this->_makeAnchorNameUnique( 2095 $topicObject, $this->_makeAnchorName( $atext )); 2107 my $anchor = 2108 $this->_makeAnchorNameUnique( $topicObject, 2109 $this->_makeAnchorName($atext) ); 2096 2110 my $target = { 2097 2111 anchor => $anchor, … … 2099 2113 level => $level, 2100 2114 }; 2101 push( @targets, $target);2115 push( @targets, $target ); 2102 2116 2103 2117 next LINE; … … 2107 2121 } 2108 2122 2109 foreach my $a ( @targets) {2123 foreach my $a (@targets) { 2110 2124 my $text = $a->{text}; 2111 2125 $highest = $a->{level} if ( $a->{level} < $highest ); … … 2171 2185 # C'est la vie. 2172 2186 sub _clearAnchorNames { 2173 my ( $this, $topicObject) = @_;2174 $this->{_anchorNames}{ $topicObject->getPath()} = ();2187 my ( $this, $topicObject ) = @_; 2188 $this->{_anchorNames}{ $topicObject->getPath() } = (); 2175 2189 } 2176 2190 … … 2182 2196 # is rendered. 2183 2197 sub _makeAnchorNameUnique { 2184 my ( $this, $topicObject, $anchorName) = @_;2185 my $cnt = 1;2186 my $suffix = '';2198 my ( $this, $topicObject, $anchorName ) = @_; 2199 my $cnt = 1; 2200 my $suffix = ''; 2187 2201 my $context = $topicObject->getPath(); 2188 2202 $this->{_anchorNames}{$context} ||= (); 2189 while ( exists $this->{_anchorNames}{$context}{ $anchorName.$suffix} ) {2203 while ( exists $this->{_anchorNames}{$context}{ $anchorName . $suffix } ) { 2190 2204 2191 2205 # $anchorName.$suffix must _always_ be 'compatible', or things -
trunk/core/lib/Foswiki/Request.pm
r3945 r3947 57 57 58 58 use CGI (); 59 our @ISA = ( 'CGI');59 our @ISA = ('CGI'); 60 60 61 61 use Assert; 62 use Error ();62 use Error (); 63 63 use IO::File (); 64 64 use CGI::Util qw(rearrange); -
trunk/core/lib/Foswiki/Sandbox.pm
r3945 r3947 60 60 $EMULATED_SAFE_PIPE_OPEN = 1; 61 61 62 # Detect ActiveState and Strawberry perl. (Cygwin perl returns "cygwin" for $^O)62 # Detect ActiveState and Strawberry perl. (Cygwin perl returns "cygwin" for $^O) 63 63 if ( $^O eq 'MSWin32' ) { 64 64 $REAL_SAFE_PIPE_OPEN = 0; -
trunk/core/lib/Foswiki/Search.pm
r3945 r3947 14 14 use Error qw( :try ); 15 15 16 use Foswiki ();17 use Foswiki::Sandbox ();18 use Foswiki::Render (); # SMELL: expensive19 use Foswiki::Search::InfoCache ();20 use Foswiki::ListIterator ();16 use Foswiki (); 17 use Foswiki::Sandbox (); 18 use Foswiki::Render (); # SMELL: expensive 19 use Foswiki::Search::InfoCache (); 20 use Foswiki::ListIterator (); 21 21 use Foswiki::Iterator::FilterIterator (); 22 22 … … 112 112 113 113 # E.g. "Web*, FooBar" ==> "^(Web.*|FooBar)$" 114 $options->{excludeTopics} = _makeTopicPattern( $options->{excludeTopics})115 if ($options->{excludeTopics});114 $options->{excludeTopics} = _makeTopicPattern( $options->{excludeTopics} ) 115 if ( $options->{excludeTopics} ); 116 116 117 117 my $topicFilter; 118 118 my $it; 119 if ($options->{includeTopics}) { 120 # E.g. "Bug*, *Patch" ==> "^(Bug.*|.*Patch)$" 121 $options->{includeTopics} = _makeTopicPattern($options->{includeTopics}); 119 if ( $options->{includeTopics} ) { 120 121 # E.g. "Bug*, *Patch" ==> "^(Bug.*|.*Patch)$" 122 $options->{includeTopics} = 123 _makeTopicPattern( $options->{includeTopics} ); 122 124 123 125 # limit search to topic list … … 136 138 #TODO: erm, what about non-case senstive? 137 139 my @list = 138 grep( $this->{session}->topicExists( $webObject->web, $_ ),140 grep( $this->{session}->topicExists( $webObject->web, $_ ), 139 141 split( /\|/, $topics ) ); 140 $it = new Foswiki::ListIterator( \@list);142 $it = new Foswiki::ListIterator( \@list ); 141 143 } 142 144 elsif ( !$options->{casesensitive} ) { … … 148 150 } 149 151 150 $it = $webObject->eachTopic() unless (defined($it)); 151 152 my $filterIter = new Foswiki::Iterator::FilterIterator($it, sub { 153 my $item = shift; 154 #my $data = shift; 155 return unless !$topicFilter || $item =~ /$topicFilter/; 156 157 # exclude topics, Codev.ExcludeWebTopicsFromSearch 158 if ( $options->{casesensitive} && $options->{excludeTopics} ) { 159 return if $item =~ /$options->{excludeTopics}/i; 160 } 161 elsif ($options->{excludeTopics}) { 162 return if $item =~ /$options->{excludeTopics}/; 163 } 164 return 1; 165 }); 152 $it = $webObject->eachTopic() unless ( defined($it) ); 153 154 my $filterIter = new Foswiki::Iterator::FilterIterator( 155 $it, 156 sub { 157 my $item = shift; 158 159 #my $data = shift; 160 return unless !$topicFilter || $item =~ /$topicFilter/; 161 162 # exclude topics, Codev.ExcludeWebTopicsFromSearch 163 if ( $options->{casesensitive} && $options->{excludeTopics} ) { 164 return if $item =~ /$options->{excludeTopics}/i; 165 } 166 elsif ( $options->{excludeTopics} ) { 167 return if $item =~ /$options->{excludeTopics}/; 168 } 169 return 1; 170 } 171 ); 166 172 return $filterIter; 167 173 168 # my @topicList = ();169 # while ( $filterIter->hasNext() ) {170 # my $tn = $filterIter->next();171 # push( @topicList, $tn );172 # }173 # return @topicList;174 # my @topicList = (); 175 # while ( $filterIter->hasNext() ) { 176 # my $tn = $filterIter->next(); 177 # push( @topicList, $tn ); 178 # } 179 # return @topicList; 174 180 } 175 181 176 182 #convert a comma separated list of webs into the list we'll process 177 183 sub _getListOfWebs { 178 my ( $this, $webName, $recurse, $searchAllFlag) = @_;184 my ( $this, $webName, $recurse, $searchAllFlag ) = @_; 179 185 my $session = $this->{session}; 180 186 … … 320 326 1 - Foswiki::isTrue( ( $params{zeroresults} || 'on' ), $nonoise ); 321 327 my $noTotal = Foswiki::isTrue( $params{nototal}, $nonoise ); 322 my $newLine = $params{newline}|| '';323 my $sortOrder = $params{order}|| '';324 my $revSort = Foswiki::isTrue( $params{reverse} );325 my $scope = $params{scope}|| '';328 my $newLine = $params{newline} || ''; 329 my $sortOrder = $params{order} || ''; 330 my $revSort = Foswiki::isTrue( $params{reverse} ); 331 my $scope = $params{scope} || ''; 326 332 my $searchString = defined $params{search} ? $params{search} : ''; 327 333 my $separator = $params{separator}; 328 334 my $template = $params{template} || ''; 329 my $topic = $params{topic} || '';330 my $type = $params{type} || '';335 my $topic = $params{topic} || ''; 336 my $type = $params{type} || ''; 331 337 332 338 my $wordBoundaries = 0; … … 369 375 my $searchAllFlag = ( $webName =~ /(^|[\,\s])(all|on)([\,\s]|$)/i ); 370 376 371 my @webs = $this->_getListOfWebs($webName, $recurse, $searchAllFlag); 377 my @webs = $this->_getListOfWebs( $webName, $recurse, $searchAllFlag ); 378 372 379 #to help later processing (formatResults) 373 380 $params{numberOfWebs} = scalar(@webs); … … 453 460 } 454 461 else { 462 455 463 # don't render; will be done later 456 464 $searchResult .= $tmplSearch; … … 468 476 469 477 #TODO: actually want to pass the entire SEARCH params - so that each search backend can optimise if it suites its impl 470 my $options = {471 casesensitive => $caseSensitive,472 wordboundaries => $wordBoundaries,473 includeTopics => $topic,474 excludeTopics => $excludeTopic,475 scope => $scope,476 type => $type,477 };478 my $options = { 479 casesensitive => $caseSensitive, 480 wordboundaries => $wordBoundaries, 481 includeTopics => $topic, 482 excludeTopics => $excludeTopic, 483 scope => $scope, 484 type => $type, 485 }; 478 486 479 487 if ( length($searchString) == 0 ) { 488 480 489 #default search should return no results 481 490 $searchString = '1 = 2'; 482 #shortcircuit the search 483 #FIXME: this breaks the per-web summary output that is hidden in the foreach 491 492 #shortcircuit the search 493 #FIXME: this breaks the per-web summary output that is hidden in the foreach 484 494 @webs = (); 485 495 } 486 496 487 497 my $theParser; 488 if ( $type eq 'query') {498 if ( $type eq 'query' ) { 489 499 unless ( defined($queryParser) ) { 490 500 require Foswiki::Query::Parser; … … 492 502 } 493 503 $theParser = $queryParser; 494 } else { 504 } 505 else { 495 506 unless ( defined($searchParser) ) { 496 507 require Foswiki::Search::Parser; … … 501 512 my $error = ''; 502 513 try { 503 $query = $theParser->parse( $searchString, $options);514 $query = $theParser->parse( $searchString, $options ); 504 515 } 505 516 catch Foswiki::Infix::Error with { … … 511 522 512 523 #TODO: 513 unless ( $type eq 'query')514 { 515 #shorcircuit the search foreach below for a zero result search516 #FIXME: this breaks the per-web summary output that is hidden in the foreach517 @webs = () unless scalar( @{$query->{tokens}}); #default524 unless ( $type eq 'query' ) { 525 526 #shorcircuit the search foreach below for a zero result search 527 #FIXME: this breaks the per-web summary output that is hidden in the foreach 528 @webs = () unless scalar( @{ $query->{tokens} } ); #default 518 529 } 519 530 … … 544 555 my $inputTopicSet = _getTopicList( $this, $webObject, $options ); 545 556 546 next if ( $noEmpty && !$inputTopicSet->hasNext() ); # Nothing to show for this web 557 next 558 if ( $noEmpty && !$inputTopicSet->hasNext() ) 559 ; # Nothing to show for this web 547 560 548 561 my $infoCache = $webObject->query( $query, $inputTopicSet, $options ); 549 $this->sortResults($web, $infoCache, %params); 550 my ($web_ttopics, $web_searchResult) = $this->formatResults($tmplTable, $tmplNumber, $webObject, $query, $infoCache, %params); 562 $this->sortResults( $web, $infoCache, %params ); 563 my ( $web_ttopics, $web_searchResult ) = $this->formatResults( 564 $tmplTable, $tmplNumber, $webObject, 565 $query, $infoCache, %params 566 ); 551 567 $ttopics += $web_ttopics; 552 568 $searchResult .= $web_searchResult; … … 592 608 593 609 =cut 610 594 611 sub sortResults { 595 my ( $this, $web, $infoCache, %params) = @_;612 my ( $this, $web, $infoCache, %params ) = @_; 596 613 my $session = $this->{session}; 597 614 598 my $sortOrder = $params{order}|| '';599 my $revSort = Foswiki::isTrue( $params{reverse} );600 my $date = $params{date}|| '';601 my $limit = $params{limit}|| '';615 my $sortOrder = $params{order} || ''; 616 my $revSort = Foswiki::isTrue( $params{reverse} ); 617 my $date = $params{date} || ''; 618 my $limit = $params{limit} || ''; 602 619 603 620 #SMELL: duplicated code - removeme 604 621 # Limit search results 605 622 if ( $limit =~ /(^\d+$)/o ) { 623 606 624 # only digits, all else is the same as 607 625 # an empty string. "+10" won't work. … … 609 627 } 610 628 else { 629 611 630 # change 'all' to 0, then to big number 612 631 $limit = 0; 613 632 } 614 633 $limit = 32000 unless ($limit); 615 616 634 617 635 # sort the topic list by date, author or topic name, and cache the 618 636 # info extracted to do the sorting 619 637 if ( $sortOrder eq 'modified' ) { 638 620 639 # For performance: 621 640 # * sort by approx time (to get a rough list) … … 626 645 # time is taken from topic instead of dir list. 627 646 my $slack = 10; 628 if ( $limit + 2 * $slack < scalar( @{$infoCache->{list}}) ) {647 if ( $limit + 2 * $slack < scalar( @{ $infoCache->{list} } ) ) { 629 648 630 649 # sort by approx latest rev time … … 633 652 sort { $a->[0] <=> $b->[0] } 634 653 map { [ $session->getApproxRevTime( $web, $_ ), $_ ] } 635 @{ $infoCache->{list}};654 @{ $infoCache->{list} }; 636 655 @tmpList = reverse(@tmpList) if ($revSort); 637 656 638 657 # then shorten list and build the hashes for date and author 639 658 my $idx = $limit + $slack; 640 @{ $infoCache->{list}} = ();659 @{ $infoCache->{list} } = (); 641 660 foreach (@tmpList) { 642 push( @{ $infoCache->{list}}, $_ );661 push( @{ $infoCache->{list} }, $_ ); 643 662 $idx -= 1; 644 663 last if $idx <= 0; … … 657 676 } 658 677 else { 678 659 679 # simple sort, see Codev.SchwartzianTransformMisused 660 680 # note no extraction of topic info here, as not needed 661 681 # for the sort. Instead it will be read lazily, later on. 662 682 if ($revSort) { 663 @{$infoCache->{list}} = sort { $b cmp $a } @{$infoCache->{list}}; 683 @{ $infoCache->{list} } = 684 sort { $b cmp $a } @{ $infoCache->{list} }; 664 685 } 665 686 else { 666 @{$infoCache->{list}} = sort { $a cmp $b } @{$infoCache->{list}}; 687 @{ $infoCache->{list} } = 688 sort { $a cmp $b } @{ $infoCache->{list} }; 667 689 } 668 690 } … … 672 694 my @ends = Foswiki::Time::parseInterval($date); 673 695 my @resultList = (); 674 foreach my $topic (@{$infoCache->{list}}) { 696 foreach my $topic ( @{ $infoCache->{list} } ) { 697 675 698 # if date falls out of interval: exclude topic from result 676 699 my $topicdate = $session->getApproxRevTime( $web, $topic ); … … 678 701 unless ( $topicdate < $ends[0] || $topicdate > $ends[1] ); 679 702 } 680 @{ $infoCache->{list}} = @resultList;703 @{ $infoCache->{list} } = @resultList; 681 704 } 682 705 } … … 688 711 689 712 =cut 690 sub formatResults{ 691 my ($this, $tmplTable, $tmplNumber, $webObject, $query, $infoCache, %params) = @_; 692 my $session = $this->{session}; 693 my $users = $session->{users}; 694 my $web = $webObject->web; 713 714 sub formatResults { 715 my ( $this, $tmplTable, $tmplNumber, $webObject, $query, $infoCache, 716 %params ) 717 = @_; 718 my $session = $this->{session}; 719 my $users = $session->{users}; 720 my $web = $webObject->web; 695 721 my $thisWebNoSearchAll = $webObject->getPreference('NOSEARCHALL') || ''; 696 697 722 698 723 my $callback = $params{_callback}; … … 709 734 my $inline = $params{inline}; 710 735 my $limit = $params{limit} || ''; 736 711 737 # Limit search results 712 738 if ( $limit =~ /(^\d+$)/o ) { 739 713 740 # only digits, all else is the same as 714 741 # an empty string. "+10" won't work. … … 716 743 } 717 744 else { 745 718 746 # change 'all' to 0, then to big number 719 747 $limit = 0; … … 721 749 $limit = 32000 unless ($limit); 722 750 723 my $doMultiple = Foswiki::isTrue( $params{multiple} );724 my $nonoise = Foswiki::isTrue( $params{nonoise} );725 my $noEmpty = Foswiki::isTrue( $params{noempty}, $nonoise );751 my $doMultiple = Foswiki::isTrue( $params{multiple} ); 752 my $nonoise = Foswiki::isTrue( $params{nonoise} ); 753 my $noEmpty = Foswiki::isTrue( $params{noempty}, $nonoise ); 726 754 727 755 # Note: a defined header/footer overrides noheader/nofooter 728 756 # To maintain Cairo compatibility we ommit default header/footer if the 729 757 # now deprecated option 'inline' is used combined with 'format' 730 my $noHeader = !defined($header)731 && Foswiki::isTrue( $params{noheader}, $nonoise )758 my $noHeader = 759 !defined($header) && Foswiki::isTrue( $params{noheader}, $nonoise ) 732 760 || ( !$header && $format && $inline ); 733 761 734 my $noFooter = !defined($footer)735 && Foswiki::isTrue( $params{nofooter}, $nonoise )762 my $noFooter = 763 !defined($footer) && Foswiki::isTrue( $params{nofooter}, $nonoise ) 736 764 || ( !$footer && $format && $inline ); 737 765 … … 751 779 my $type = $params{type} || ''; 752 780 753 my $ttopics = 0;781 my $ttopics = 0; 754 782 my $searchResult = ''; 755 783 … … 760 788 if ( defined $header ) { 761 789 $beforeText = Foswiki::expandStandardEscapes($header); 762 $beforeText =~ s/\$web/$web/gos; # expand name of web763 $beforeText =~ s/([^\n])$/$1\n/os; # add new line at end790 $beforeText =~ s/\$web/$web/gos; # expand name of web 791 $beforeText =~ s/([^\n])$/$1\n/os; # add new line at end 764 792 } 765 793 766 794 if ( defined $footer ) { 767 795 $afterText = Foswiki::expandStandardEscapes($footer); 768 $afterText =~ s/\$web/$web/gos; # expand name of web769 $afterText =~ s/([^\n])$/$1\n/os; # add new line at end796 $afterText =~ s/\$web/$web/gos; # expand name of web 797 $afterText =~ s/([^\n])$/$1\n/os; # add new line at end 770 798 } 771 799 772 800 # output the list of topics in $web 773 my $ntopics = 0; # number of topics in current web774 my $nhits = 0; # number of hits (if multiple=on) in current web801 my $ntopics = 0; # number of topics in current web 802 my $nhits = 0; # number of hits (if multiple=on) in current web 775 803 my $headerDone = $noHeader; 776 while ( $infoCache->hasNext()) {777 my $topic = $infoCache->next();804 while ( $infoCache->hasNext() ) { 805 my $topic = $infoCache->next(); 778 806 my $forceRendering = 0; 779 807 my $info = $infoCache->get($topic); … … 782 810 require Foswiki::Time; 783 811 my $revDate = Foswiki::Time::formatTime($epochSecs); 784 my $isoDate = 785 Foswiki::Time::formatTime( $epochSecs, '$iso', 'gmtime' ); 812 my $isoDate = Foswiki::Time::formatTime( $epochSecs, '$iso', 'gmtime' ); 786 813 787 814 my $ru = $info->{editby} || 'UnknownUser'; … … 790 817 my $cUID = $users->getCanonicalUserID($ru); 791 818 if ( !$cUID ) { 819 792 820 # Not a login name or a wiki name. Is it a valid cUID? 793 821 my $ln = $users->getLoginName($ru); … … 807 835 if ($doExpandVars) { 808 836 if ( $web eq $baseWeb && $topic eq $baseTopic ) { 837 809 838 # primitive way to prevent recursion 810 839 $text =~ s/%SEARCH/%<nop>SEARCH/g; … … 816 845 my @multipleHitLines = (); 817 846 if ($doMultiple) { 847 818 848 #TODO: i wonder if this shoudl be a HoistRE.. 819 my @tokens = @{$query->{tokens}};820 my $pattern = $tokens[$#tokens]; # last token in an AND search849 my @tokens = @{ $query->{tokens} }; 850 my $pattern = $tokens[$#tokens]; # last token in an AND search 821 851 $pattern = quotemeta($pattern) if ( $type ne 'regex' ); 822 852 unless ($text) { … … 931 961 s/\$count\((.*?\s*\.\*)\)/_countPattern( $text, $1 )/ges; 932 962 933 # FIXME: Allow all regex characters but escape them934 # Note: The RE requires a .* at the end of a pattern to avoid false positives935 # in pattern matching963 # FIXME: Allow all regex characters but escape them 964 # Note: The RE requires a .* at the end of a pattern to avoid false positives 965 # in pattern matching 936 966 $out =~ 937 s/\$pattern\((.*?\s*\.\*)\)/_extractPattern( $text, $1 )/ges;967 s/\$pattern\((.*?\s*\.\*)\)/_extractPattern( $text, $1 )/ges; 938 968 $out =~ s/\r?\n/$newLine/gos if ($newLine); 939 969 if ( defined($separator) ) { … … 982 1012 } 983 1013 984 #don't expand if a format is specified - it breaks tables and stuff1014 #don't expand if a format is specified - it breaks tables and stuff 985 1015 unless ($format) { 986 1016 $out = $webObject->renderTML($out); … … 1041 1071 } 1042 1072 } 1043 return ( $ttopics, $searchResult);1073 return ( $ttopics, $searchResult ); 1044 1074 } 1045 1075 -
trunk/core/lib/Foswiki/Search/InfoCache.pm
r3944 r3947 4 4 5 5 use Foswiki::ListIterator (); 6 our @ISA = ( 'Foswiki::ListIterator');6 our @ISA = ('Foswiki::ListIterator'); 7 7 8 8 =begin TML … … 42 42 my ( $class, $session, $defaultWeb, $topicList ) = @_; 43 43 my $this = $class->SUPER::new($topicList); 44 $this->{_session} = $session;44 $this->{_session} = $session; 45 45 $this->{_defaultWeb} = $defaultWeb; 46 46 47 47 return $this; 48 48 } 49 49 50 sub isImmutable { 50 51 my $this = shift; 51 return ($this->{index} != 0); 52 } 52 return ( $this->{index} != 0 ); 53 } 54 53 55 sub addTopics { 54 56 my ( $this, $defaultWeb, @list ) = @_; 55 ASSERT(!$this->isImmutable()); #cannot modify list once its being used as an iterator. 56 57 if (defined($defaultWeb) && ($defaultWeb ne $this->{_defaultWeb})) { 57 ASSERT( !$this->isImmutable() ) 58 ; #cannot modify list once its being used as an iterator. 59 60 if ( defined($defaultWeb) && ( $defaultWeb ne $this->{_defaultWeb} ) ) { 58 61 foreach my $t (@list) { 59 my ($web, $topic) = Foswiki::Func::normalizeTopic($defaultWeb, $t); 60 push(@{$this->{list}}, "$web.$topic"); 61 } 62 } else { 62 my ( $web, $topic ) = 63 Foswiki::Func::normalizeTopic( $defaultWeb, $t ); 64 push( @{ $this->{list} }, "$web.$topic" ); 65 } 66 } 67 else { 68 63 69 #TODO: what if the list is an arrayref? 64 push(@{$this->{list}}, @list); 65 } 66 } 67 70 push( @{ $this->{list} }, @list ); 71 } 72 } 68 73 69 74 ######OLD methods … … 77 82 78 83 $info->{tom} = 79 Foswiki::Meta->load( $this->{_session}, $this->{_defaultWeb}, $topic ); 84 Foswiki::Meta->load( $this->{_session}, $this->{_defaultWeb}, 85 $topic ); 80 86 81 87 # SMELL: why do this here? Smells of a hack, as AFAICT it is done … … 109 115 unless ($ri) { 110 116 my $tmp = 111 Foswiki::Meta->load( $this->{_session}, $this->{_defaultWeb}, $topic,112 1 );117 Foswiki::Meta->load( $this->{_session}, $this->{_defaultWeb}, 118 $topic, 1 ); 113 119 $info->{rev1info} = $ri = $tmp->getRevisionInfo(); 114 120 } … … 140 146 ASSERT($sortfield); 141 147 142 ASSERT(!$this->isImmutable()); #cannot modify list once its being used as an iterator. 148 ASSERT( !$this->isImmutable() ) 149 ; #cannot modify list once its being used as an iterator. 143 150 144 151 # populate the cache for each topic 145 foreach my $topic ( @{$this->{list}}) {152 foreach my $topic ( @{ $this->{list} } ) { 146 153 if ( $sortfield =~ /^creat/ ) { 147 154 … … 164 171 } 165 172 if ($revSort) { 166 @{ $this->{list}} = map { $_->[1] }173 @{ $this->{list} } = map { $_->[1] } 167 174 sort { _compare( $b->[0], $a->[0] ) } 168 map { [ $this->{$_}->{$sortfield}, $_ ] } @{ $this->{list}};175 map { [ $this->{$_}->{$sortfield}, $_ ] } @{ $this->{list} }; 169 176 } 170 177 else { 171 @{ $this->{list}} = map { $_->[1] }178 @{ $this->{list} } = map { $_->[1] } 172 179 sort { _compare( $a->[0], $b->[0] ) } 173 map { [ $this->{$_}->{$sortfield}, $_ ] } @{ $this->{list}};180 map { [ $this->{$_}->{$sortfield}, $_ ] } @{ $this->{list} }; 174 181 } 175 182 } -
trunk/core/lib/Foswiki/Search/Node.pm
r3944 r3947 19 19 20 20 use Foswiki::Infix::Node (); 21 our @ISA = ( 'Foswiki::Infix::Node');21 our @ISA = ('Foswiki::Infix::Node'); 22 22 23 23 =begin TML … … 31 31 sub new { 32 32 my ( $class, $search, $tokens, $options ) = @_; 33 my $this = bless( { tokens => $tokens, search => $search, options => $options }, $class ); 33 my $this = 34 bless( { tokens => $tokens, search => $search, options => $options }, 35 $class ); 34 36 return $this; 35 37 } 36 37 38 38 39 1; -
trunk/core/lib/Foswiki/Search/Parser.pm
r3944 r3947 19 19 20 20 use Foswiki::Infix::Parser (); 21 our @ISA = ( 'Foswiki::Infix::Parser');21 our @ISA = ('Foswiki::Infix::Parser'); 22 22 23 23 use Foswiki::Search::Node (); … … 42 42 my $this = shift; 43 43 44 return if ( $this->{initialised});44 return if ( $this->{initialised} ); 45 45 46 46 # Build pattern of stop words … … 111 111 } 112 112 113 my $result = new Foswiki::Search::Node( $searchString, \@tokens, $options );113 my $result = new Foswiki::Search::Node( $searchString, \@tokens, $options ); 114 114 return $result; 115 115 } -
trunk/core/lib/Foswiki/Store/QueryAlgorithms/BruteForce.pm
r3874 r3947 23 23 24 24 use Foswiki::Search::Node (); 25 use Foswiki::Meta ();25 use Foswiki::Meta (); 26 26 use Foswiki::Search::InfoCache; 27 28 27 29 28 sub query { … … 32 31 my $topicSet = $inputTopicSet; 33 32 34 #TODO: howto ask iterator for list length? 35 # if ( scalar(@$topics) > 6 ) { 36 require Foswiki::Query::HoistREs; 37 my @filter = Foswiki::Query::HoistREs::hoist($query); 38 if (scalar(@filter)) { 39 my $searchOptions = { 40 type => 'regex', 41 casesensitive => 1, 42 files_without_match => 1, 43 }; 44 my $searchQuery = new Foswiki::Search::Node($query->toString(), \@filter, $searchOptions); 45 $topicSet = $store->searchInWebMetaData($searchQuery, $web, $topicSet, $searchOptions); 46 } else { 47 #print STDERR "WARNING: couldn't hoistREs on ".$query->toString(); 48 } 49 # } 33 #TODO: howto ask iterator for list length? 34 # if ( scalar(@$topics) > 6 ) { 35 require Foswiki::Query::HoistREs; 36 my @filter = Foswiki::Query::HoistREs::hoist($query); 37 if ( scalar(@filter) ) { 38 my $searchOptions = { 39 type => 'regex', 40 casesensitive => 1, 41 files_without_match => 1, 42 }; 43 my $searchQuery = 44 new Foswiki::Search::Node( $query->toString(), \@filter, 45 $searchOptions ); 46 $topicSet = 47 $store->searchInWebMetaData( $searchQuery, $web, $topicSet, 48 $searchOptions ); 49 } 50 else { 51 52 #print STDERR "WARNING: couldn't hoistREs on ".$query->toString(); 53 } 54 55 # } 50 56 51 57 my %matches; … … 54 60 my $topic = $topicSet->next(); 55 61 my $meta = 56 Foswiki::Meta->new( $store->{session}, $web, $topic );#, <FILE> );57 #this 'lazy load will become useful when @$topics becomes an infoCache62 Foswiki::Meta->new( $store->{session}, $web, $topic ); #, <FILE> ); 63 #this 'lazy load will become useful when @$topics becomes an infoCache 58 64 $meta->reload() unless ( $meta->getLoadedRev() ); 59 65 next unless ( $meta->getLoadedRev() ); … … 66 72 67 73 my @topics = keys(%matches); 68 my $resultTopicSet = new Foswiki::Search::InfoCache( $Foswiki::Plugins::SESSION, $web, \@topics); 74 my $resultTopicSet = 75 new Foswiki::Search::InfoCache( $Foswiki::Plugins::SESSION, $web, 76 \@topics ); 69 77 return $resultTopicSet; 70 78 } -
trunk/core/lib/Foswiki/Store/RcsLite.pm
r3944 r3947 21 21 22 22 use Foswiki::Store::VCStore (); 23 our @ISA = ( 'Foswiki::Store::VCStore');23 our @ISA = ('Foswiki::Store::VCStore'); 24 24 25 25 # This constructor is required to hide the =Foswiki::Store::RcsLiteHandler= -
trunk/core/lib/Foswiki/Store/RcsLiteHandler.pm
r3944 r3947 88 88 89 89 use Foswiki::Store::VCHandler (); 90 our @ISA = ( 'Foswiki::Store::VCHandler');90 our @ISA = ('Foswiki::Store::VCHandler'); 91 91 92 92 use Assert; 93 93 use Error qw( :try ); 94 94 95 use FileHandle ();95 use FileHandle (); 96 96 use Foswiki::Store (); 97 97 use Foswiki::Sandbox (); -
trunk/core/lib/Foswiki/Store/RcsWrap.pm
r3944 r3947 21 21 22 22 use Foswiki::Store::VCStore (); 23 our @ISA = ( 'Foswiki::Store::VCStore');23 our @ISA = ('Foswiki::Store::VCStore'); 24 24 25 25 # This constructor is required to hide the =Foswiki::Store::RcsWrapHandler= -
trunk/core/lib/Foswiki/Store/RcsWrapHandler.pm
r3945 r3947 20 20 21 21 use Foswiki::Store::VCHandler (); 22 our @ISA = ( 'Foswiki::Store::VCHandler');22 our @ISA = ('Foswiki::Store::VCHandler'); 23 23 24 24 use File::Copy (); … … 108 108 my ( $this, $text, $comment, $user, $date ) = @_; 109 109 $this->init(); 110 110 111 #print STDERR "Wrap: Forced save at $date $this->{file}\n" if $date; 111 112 112 unless ( -e $this->{rcsFile} ) { #113 # SMELL: what is this for?113 unless ( -e $this->{rcsFile} ) { # 114 # SMELL: what is this for? 114 115 _lock($this); 115 116 _ci( $this, $comment, $user, $date ); -
trunk/core/lib/Foswiki/Store/SearchAlgorithms/Forking.pm
r3874 r3947 6 6 use Assert; 7 7 use Foswiki::Search::InfoCache; 8 9 8 10 9 =begin TML … … 77 76 my $sDir = $Foswiki::cfg{DataDir} . '/' . $web . '/'; 78 77 79 # while (my @set = splice( @take, 0, $maxTopicsInSet )) {80 # @set = map { "$sDir/$_.txt" } @set;78 # while (my @set = splice( @take, 0, $maxTopicsInSet )) { 79 # @set = map { "$sDir/$_.txt" } @set; 81 80 my @set; 82 81 $inputTopicSet->reset(); 83 82 while ( $inputTopicSet->hasNext() ) { 84 83 my $tn = $inputTopicSet->next(); 85 push(@set, "$sDir/$tn.txt"); 86 if (($#set >= $maxTopicsInSet) #replace with character count.. 87 || !($inputTopicSet->hasNext())) { 84 push( @set, "$sDir/$tn.txt" ); 85 if ( 86 ( $#set >= $maxTopicsInSet ) #replace with character count.. 87 || !( $inputTopicSet->hasNext() ) 88 ) 89 { 88 90 my ( $m, $exit ) = Foswiki::Sandbox->sysCommand( 89 91 $program, … … 92 94 ); 93 95 @set = (); 96 94 97 # man grep: "Normally, exit status is 0 if selected lines are found 95 98 # and 1 otherwise. But the exit status is 2 if an error occurred, … … 97 100 # line is found." 98 101 if ( $exit > 1 ) { 99 #TODO: need to work out a way to alert the admin there is a problem, without 100 # filling up the log files with repeated SEARCH's 101 102 # NOTE: we ignore the error, because grep returns an error if it comes across a broken file link 103 # or a file it does not have permission to open, so throwing here gives wrong search results. 104 # throw Error::Simple("$program Grep for '$searchString' returned error") 102 103 #TODO: need to work out a way to alert the admin there is a problem, without 104 # filling up the log files with repeated SEARCH's 105 106 # NOTE: we ignore the error, because grep returns an error if it comes across a broken file link 107 # or a file it does not have permission to open, so throwing here gives wrong search results. 108 # throw Error::Simple("$program Grep for '$searchString' returned error") 105 109 } 106 110 $matches .= $m; … … 121 125 this is the new way - 122 126 =cut 127 123 128 sub query { 124 129 my ( $query, $web, $inputTopicSet, $store, $options ) = @_; 125 ASSERT( scalar(@{$query->{tokens}}) > 0) if DEBUG;130 ASSERT( scalar( @{ $query->{tokens} } ) > 0 ) if DEBUG; 126 131 127 132 # default scope is 'text' 128 $options->{'scope'} = 'text' unless ( defined($options->{'scope'}) && $options->{'scope'} =~ /^(topic|all)$/ ); 133 $options->{'scope'} = 'text' 134 unless ( defined( $options->{'scope'} ) 135 && $options->{'scope'} =~ /^(topic|all)$/ ); 129 136 130 137 my $topicSet = $inputTopicSet; 131 ASSERT( UNIVERSAL::isa( $topicSet, 'Foswiki::Iterator' )) if DEBUG;138 ASSERT( UNIVERSAL::isa( $topicSet, 'Foswiki::Iterator' ) ) if DEBUG; 132 139 133 140 my %completeMatch; 134 141 135 142 #print STDERR "######## Forking search ($web) tokens ".scalar(@{$query->{tokens}})." : ".join(',', @{$query->{tokens}})."\n"; 136 # AND search - search once for each token, ANDing result together137 foreach my $token ( @{$query->{tokens}}) {143 # AND search - search once for each token, ANDing result together 144 foreach my $token ( @{ $query->{tokens} } ) { 138 145 139 146 # flag for AND NOT search … … 153 160 154 161 # FIXME I18N 155 $qtoken = quotemeta($qtoken) if ( $options->{'type'} ne 'regex' ); 162 $qtoken = quotemeta($qtoken) 163 if ( $options->{'type'} ne 'regex' ); 156 164 if ( $options->{'casesensitive'} ) { 157 165 … … 161 169 } 162 170 else { 171 163 172 #push(@scopeTopicList, $topic) if ( $topic =~ /$qtoken/i ); 164 173 $topicMatches{$topic} = 1 if ( $topic =~ /$qtoken/i ); … … 183 192 while ( $topicSet->hasNext() ) { 184 193 my $topic = $topicSet->next(); 194 185 195 #push( @scopeTextList, $topic ) 186 196 if ( $topicMatches{$topic} ) { 197 187 198 #remove this match 188 199 delete $completeMatch{$topic}; 189 200 } 190 201 } 191 } else { 202 } 203 else { 204 192 205 #TODO: the sad thing about this is we lose info 193 206 %completeMatch = %topicMatches; 194 207 } 208 195 209 # reduced topic list for next token 196 210 @scopeTextList = keys(%completeMatch); 197 $topicSet = new Foswiki::Search::InfoCache( $Foswiki::Plugins::SESSION, $web, \@scopeTextList); 211 $topicSet = 212 new Foswiki::Search::InfoCache( $Foswiki::Plugins::SESSION, $web, 213 \@scopeTextList ); 198 214 } 199 215 200 216 return $topicSet; 217 201 218 #return \%completeMatch; 202 219 } -
trunk/core/lib/Foswiki/Store/SearchAlgorithms/PurePerl.pm
r3874 r3947 6 6 use Assert; 7 7 use Foswiki::Search::InfoCache; 8 9 8 10 9 =begin TML … … 76 75 this is the new way - 77 76 =cut 77 78 78 sub query { 79 79 my ( $query, $web, $inputTopicSet, $store, $options ) = @_; 80 ASSERT( scalar(@{$query->{tokens}}) > 0) if DEBUG;80 ASSERT( scalar( @{ $query->{tokens} } ) > 0 ) if DEBUG; 81 81 82 82 # default scope is 'text' 83 $options->{'scope'} = 'text' unless ( defined($options->{'scope'}) && $options->{'scope'} =~ /^(topic|all)$/ ); 83 $options->{'scope'} = 'text' 84 unless ( defined( $options->{'scope'} ) 85 && $options->{'scope'} =~ /^(topic|all)$/ ); 84 86 85 87 my $topicSet = $inputTopicSet; 86 ASSERT( UNIVERSAL::isa( $topicSet, 'Foswiki::Iterator' )) if DEBUG;88 ASSERT( UNIVERSAL::isa( $topicSet, 'Foswiki::Iterator' ) ) if DEBUG; 87 89 88 90 my %completeMatch; 89 91 90 92 #print STDERR "######## Forking search ($web) tokens ".scalar(@{$query->{tokens}})." : ".join(',', @{$query->{tokens}})."\n"; 91 # AND search - search once for each token, ANDing result together92 foreach my $token ( @{$query->{tokens}}) {93 # AND search - search once for each token, ANDing result together 94 foreach my $token ( @{ $query->{tokens} } ) { 93 95 94 96 # flag for AND NOT search … … 108 110 109 111 # FIXME I18N 110 $qtoken = quotemeta($qtoken) if ( $options->{'type'} ne 'regex' ); 112 $qtoken = quotemeta($qtoken) 113 if ( $options->{'type'} ne 'regex' ); 111 114 if ( $options->{'casesensitive'} ) { 112 115 … … 116 119 } 117 120 else { 121 118 122 #push(@scopeTopicList, $topic) if ( $topic =~ /$qtoken/i ); 119 123 $topicMatches{$topic} = 1 if ( $topic =~ /$qtoken/i ); … … 138 142 while ( $topicSet->hasNext() ) { 139 143 my $topic = $topicSet->next(); 144 140 145 #push( @scopeTextList, $topic ) 141 146 if ( $topicMatches{$topic} ) { 147 142 148 #remove this match 143 149 delete $completeMatch{$topic}; 144 150 } 145 151 } 146 } else { 152 } 153 else { 154 147 155 #TODO: the sad thing about this is we lose info 148 156 %completeMatch = %topicMatches; 149 157 } 158 150 159 # reduced topic list for next token 151 160 @scopeTextList = keys(%completeMatch); 152 $topicSet = new Foswiki::Search::InfoCache( $Foswiki::Plugins::SESSION, $web, \@scopeTextList); 161 $topicSet = 162 new Foswiki::Search::InfoCache( $Foswiki::Plugins::SESSION, $web, 163 \@scopeTextList ); 153 164 } 154 165 155 166 return $topicSet; 156 # return \%completeMatch; 167 168 # return \%completeMatch; 157 169 } 158 170 -
trunk/core/lib/Foswiki/Store/VCHandler.pm
r3946 r3947 61 61 62 62 $this->{file} = 63 $Foswiki::cfg{PubDir} . '/' 63 $Foswiki::cfg{PubDir} . '/' 64 64 . $web . '/' 65 65 . $this->{topic} . '/' 66 66 . $attachment; 67 67 $this->{rcsFile} = 68 $Foswiki::cfg{PubDir} . '/' 69 . $web . '/' 68 $Foswiki::cfg{PubDir} . '/' 69 . $web . '/' 70 70 . $topic 71 71 . $rcsSubDir . '/' … … 77 77 $Foswiki::cfg{DataDir} . '/' . $web . '/' . $topic . '.txt'; 78 78 $this->{rcsFile} = 79 $Foswiki::cfg{DataDir} . '/' 79 $Foswiki::cfg{DataDir} . '/' 80 80 . $web 81 81 . $rcsSubDir . '/' … … 198 198 sub getLatestRevision { 199 199 my $this = shift; 200 200 201 #SMELL: why is this assumption made rather than delegating to the impl? ($this->getRevision();) 201 202 return readFile( $this, $this->{file} ); … … 332 333 333 334 no strict 'refs'; 334 return &{ $this->{searchFn} }( $searchString, $web, $inputTopicSet, $store, $options, $Foswiki::sandbox ); 335 return &{ $this->{searchFn} }( 336 $searchString, $web, $inputTopicSet, $store, $options, $Foswiki::sandbox 337 ); 335 338 use strict 'refs'; 336 339 } … … 356 359 357 360 my $engine; 358 if ( $options->{type} eq 'query') {361 if ( $options->{type} eq 'query' ) { 359 362 unless ( $this->{queryFn} ) { 360 363 eval "require $Foswiki::cfg{RCS}{QueryAlgorithm}"; 361 364 die 362 "Bad {RCS}{QueryAlgorithm}; suggest you run configure and select a different algorithm\n$@"365 "Bad {RCS}{QueryAlgorithm}; suggest you run configure and select a different algorithm\n$@" 363 366 if $@; 364 367 $this->{queryFn} = $Foswiki::cfg{RCS}{QueryAlgorithm} . '::query'; 365 368 } 366 369 $engine = $this->{queryFn}; 367 } else { 370 } 371 else { 368 372 unless ( $this->{searchQueryFn} ) { 369 373 eval "require $Foswiki::cfg{RCS}{SearchAlgorithm}"; 370 374 die 371 "Bad {RCS}{SearchAlgorithm}; suggest you run configure and select a different algorithm\n$@"375 "Bad {RCS}{SearchAlgorithm}; suggest you run configure and select a different algorithm\n$@" 372 376 if $@; 373 $this->{searchQueryFn} = $Foswiki::cfg{RCS}{SearchAlgorithm} . '::query'; 377 $this->{searchQueryFn} = 378 $Foswiki::cfg{RCS}{SearchAlgorithm} . '::query'; 374 379 } 375 380 $engine = $this->{searchQueryFn}; … … 377 382 378 383 no strict 'refs'; 379 return &{ $engine}( $query, $web, $inputTopicSet, $store, $options );384 return &{$engine}( $query, $web, $inputTopicSet, $store, $options ); 380 385 use strict 'refs'; 381 386 } … … 764 769 765 770 sub test { 766 my ( $this, $test) = @_;771 my ( $this, $test ) = @_; 767 772 return eval "-$test '$this->{file}'"; 768 773 } … … 916 921 elsif ( !unlink($entry) && -e $entry ) { 917 922 if ( $Foswiki::cfg{OS} ne 'WINDOWS' ) { 918 throw Error::Simple( 'VCHandler: Failed to delete file ' 923 throw Error::Simple( 'VCHandler: Failed to delete file ' 919 924 . $entry . ': ' 920 925 . $! ); … … 946 951 947 952 { 953 948 954 # Package that ties a filehandle to a memory string for reading 949 955 package Foswiki::Store::_MemoryFile; 950 956 951 957 sub TIEHANDLE { 952 my ($class, $data) = @_; 953 return bless({data => $data, size => length($data), ptr => 0}, $class); 958 my ( $class, $data ) = @_; 959 return 960 bless( { data => $data, size => length($data), ptr => 0 }, $class ); 954 961 } 955 962 … … 957 964 my $this = shift; 958 965 my ( undef, $len, $offset ) = @_; 959 if ( $this->{size} - $this->{ptr} < $len) {966 if ( $this->{size} - $this->{ptr} < $len ) { 960 967 $len = $this->{size} - $this->{ptr}; 961 968 } 962 969 return 0 unless $len; 963 $_[0] = substr( $this->{data}, $this->{ptr}, $len);970 $_[0] = substr( $this->{data}, $this->{ptr}, $len ); 964 971 $this->{ptr} += $len; 965 972 return $len; … … 969 976 my $this = shift; 970 977 return if $this->{ptr} == $this->{size}; 971 return substr( $this->{data}, $this->{ptr}) if !defined $/;978 return substr( $this->{data}, $this->{ptr} ) if !defined $/; 972 979 my $start = $this->{ptr}; 973 while ($this->{ptr} < $this->{size} 974 && substr($this->{data}, $this->{ptr}, 1) ne $/) { 980 while ( $this->{ptr} < $this->{size} 981 && substr( $this->{data}, $this->{ptr}, 1 ) ne $/ ) 982 { 975 983 $this->{ptr}++; 976 984 } 977 985 $this->{ptr}++ if $this->{ptr} < $this->{size}; 978 return substr( $this->{data}, $start, $this->{ptr} - $start);986 return substr( $this->{data}, $start, $this->{ptr} - $start ); 979 987 } 980 988 … … 1007 1015 1008 1016 sub openStream { 1009 my ( $this, $mode, %opts) = @_;1017 my ( $this, $mode, %opts ) = @_; 1010 1018 my $stream; 1011 if ($mode eq '<' && $opts{version}) { 1019 if ( $mode eq '<' && $opts{version} ) { 1020 1012 1021 # Bulk load the revision and tie a filehandle 1013 1022 require Symbol; 1014 $stream = Symbol::gensym; # create an anonymous glob 1015 tie(*$stream, 'Foswiki::Store::_MemoryFile', 1016 $this->getRevision($opts{version})); 1017 } else { 1018 if ($mode =~ />/) { 1019 mkPathTo($this->{file}); 1020 } 1021 unless ( open( $stream, $mode, $this->{file} )) { 1023 $stream = Symbol::gensym; # create an anonymous glob 1024 tie( *$stream, 'Foswiki::Store::_MemoryFile', 1025 $this->getRevision( $opts{version} ) ); 1026 } 1027 else { 1028 if ( $mode =~ />/ ) { 1029 mkPathTo( $this->{file} ); 1030 } 1031 unless ( open( $stream, $mode, $this->{file} ) ) { 1022 1032 throw Error::Simple( 1023 1033 'VCHandler: stream open ' . $this->{file} . ' failed: ' . $! ); … … 1074 1084 my ( $this, $attachmentsKnownInMeta ) = @_; 1075 1085 1076 my %filesListedInPub = $this->_getAttachmentStats();1086 my %filesListedInPub = $this->_getAttachmentStats(); 1077 1087 my %filesListedInMeta = (); 1078 1088 … … 1102 1112 # Do not change this from array to hash, you would lose the 1103 1113 # proper attachment sequence 1104 my @deindexedBecauseMetaDoesnotIndexAttachments = 1105 values(%filesListedInPub); 1114 my @deindexedBecauseMetaDoesnotIndexAttachments = values(%filesListedInPub); 1106 1115 1107 1116 return @deindexedBecauseMetaDoesnotIndexAttachments; … … 1118 1127 sub getAttachmentList { 1119 1128 my $this = shift; 1120 my $dir = "$Foswiki::cfg{PubDir}/$this->{web}/$this->{topic}";1129 my $dir = "$Foswiki::cfg{PubDir}/$this->{web}/$this->{topic}"; 1121 1130 opendir DIR, $dir || return (); 1122 1131 my @files = grep { !/^[.*_]/ && !/,v$/ } readdir(DIR); … … 1128 1137 # for any given web, topic 1129 1138 sub _getAttachmentStats { 1130 my $this = shift;1139 my $this = shift; 1131 1140 my %attachmentList = (); 1132 my $dir = "$Foswiki::cfg{PubDir}/$this->{web}/$this->{topic}";1133 foreach my $attachment ( $this->getAttachmentList()) {1141 my $dir = "$Foswiki::cfg{PubDir}/$this->{web}/$this->{topic}"; 1142 foreach my $attachment ( $this->getAttachmentList() ) { 1134 1143 my @stat = stat( $dir . "/" . $attachment ); 1135 1144 $attachmentList{$attachment} = -
trunk/core/lib/Foswiki/Store/VCStore.pm
r3944 r3947 32 32 33 33 use Foswiki::Store (); 34 our @ISA = ( 'Foswiki::Store');34 our @ISA = ('Foswiki::Store'); 35 35 36 36 use Assert; … … 115 115 # Use the potentially more risky topic version number for speed 116 116 my $gotRev; 117 my $ri = $topicObject->get( 'TOPICINFO');118 if ( defined($ri)) {117 my $ri = $topicObject->get('TOPICINFO'); 118 if ( defined($ri) ) { 119 119 $gotRev = $ri->{version}; 120 } else { 120 } 121 else { 122 121 123 # SMELL: Risky. In most cases, I reckon this is going to be OK. 122 124 # Alt kick down to to the handler to get the real deal? … … 129 131 # Add attachments that are new from reading the pub directory. 130 132 # Only check the currently requested topic. 131 if ( $Foswiki::cfg{AutoAttachPubFiles}132 && $topicObject->webeq $this->{session}->{webName}133 && $topicObject->topic eq $this->{session}->{topicName} )133 if ( $Foswiki::cfg{AutoAttachPubFiles} 134 && $topicObject->web eq $this->{session}->{webName} 135 && $topicObject->topic eq $this->{session}->{topicName} ) 134 136 { 135 137 … … 139 141 my @validAttachmentsFound; 140 142 foreach my $foundAttachment (@attachmentsFoundInPub) { 143 141 144 # test if the attachment filename would need sanitizing, 142 145 # if so, ignore it. … … 167 170 # Documented in Foswiki::Store 168 171 sub moveAttachment { 169 my ( 170 $this, $oldTopicObject, $oldAttachment, 171 $newTopicObject, $newAttachment, $cUID 172 ) = @_; 173 174 ASSERT($oldTopicObject->isa('Foswiki::Meta')) if DEBUG; 175 ASSERT($newTopicObject->isa('Foswiki::Meta')) if DEBUG; 176 ASSERT($oldAttachment) if DEBUG; 177 ASSERT($newAttachment) if DEBUG; 178 ASSERT($cUID) if DEBUG; 172 my ( $this, $oldTopicObject, $oldAttachment, $newTopicObject, 173 $newAttachment, $cUID ) 174 = @_; 175 176 ASSERT( $oldTopicObject->isa('Foswiki::Meta') ) if DEBUG; 177 ASSERT( $newTopicObject->isa('Foswiki::Meta') ) if DEBUG; 178 ASSERT($oldAttachment) if DEBUG; 179 ASSERT($newAttachment) if DEBUG; 180 ASSERT($cUID) if DEBUG; 179 181 180 182 my $handler = 181 183 $this->getHandler( $oldTopicObject->web, $oldTopicObject->topic, 182 184 $oldAttachment ); 183 if ( $handler->storedDataExists()) {185 if ( $handler->storedDataExists() ) { 184 186 $handler->moveAttachment( $newTopicObject->web, $newTopicObject->topic, 185 $newAttachment );187 $newAttachment ); 186 188 } 187 189 … … 220 222 sub attachmentExists { 221 223 my ( $this, $topicObject, $att ) = @_; 222 my $handler = $this->getHandler(223 $topicObject->web, $topicObject->topic, $att );224 my $handler = 225 $this->getHandler( $topicObject->web, $topicObject->topic, $att ); 224 226 return 1 if $handler->storedDataExists(); 227 225 228 # Filestore denies knowledge of it; check the meta 226 229 $topicObject->reload() unless $topicObject->getLoadedRev(); … … 259 262 # Documented in Foswiki::Store 260 263 sub testAttachment { 261 my ( $this, $topicObject, $attachment, $test) = @_;262 my $handler = $this->getHandler(263 $topicObject->web, $topicObject->topic, $attachment);264 return $handler->test( $test);264 my ( $this, $topicObject, $attachment, $test ) = @_; 265 my $handler = 266 $this->getHandler( $topicObject->web, $topicObject->topic, $attachment ); 267 return $handler->test($test); 265 268 } 266 269 … … 271 274 my $handler = 272 275 $this->getHandler( $topicObject->web, $topicObject->topic, $att ); 273 return $handler->openStream( $mode, @opts);276 return $handler->openStream( $mode, @opts ); 274 277 } 275 278 … … 327 330 sub saveAttachment { 328 331 my ( $this, $topicObject, $name, $stream, $author ) = @_; 329 ASSERT( $topicObject->isa('Foswiki::Meta')) if DEBUG;330 ASSERT( defined $name)if DEBUG;331 ASSERT( defined $stream)if DEBUG;332 ASSERT( defined $author)if DEBUG;332 ASSERT( $topicObject->isa('Foswiki::Meta') ) if DEBUG; 333 ASSERT( defined $name ) if DEBUG; 334 ASSERT( defined $stream ) if DEBUG; 335 ASSERT( defined $author ) if DEBUG; 333 336 my $handler = 334 337 $this->getHandler( $topicObject->web, $topicObject->topic, $name ); … … 342 345 sub saveTopic { 343 346 my ( $this, $topicObject, $cUID, $options ) = @_; 344 ASSERT( $topicObject->isa('Foswiki::Meta')) if DEBUG;347 ASSERT( $topicObject->isa('Foswiki::Meta') ) if DEBUG; 345 348 ASSERT($cUID) if DEBUG; 346 349 … … 370 373 $topicObject->setRevisionInfo( 371 374 { 372 date => $options->{forcedate} || time(),375 date => $options->{forcedate} || time(), 373 376 author => $cUID, 374 377 version => $nextRev … … 376 379 ); 377 380 378 $handler->addRevisionFromText( 379 $topicObject->getEmbeddedStoreForm(), 381 $handler->addRevisionFromText( $topicObject->getEmbeddedStoreForm(), 380 382 'save topic', $cUID, $options->{forcedate} ); 381 383 … … 392 394 sub repRev { 393 395 my ( $this, $topicObject, $cUID, %options ) = @_; 394 ASSERT( $topicObject->isa( 'Foswiki::Meta') ) if DEBUG;396 ASSERT( $topicObject->isa('Foswiki::Meta') ) if DEBUG; 395 397 ASSERT($cUID) if DEBUG; 396 398 … … 410 412 411 413 # use defaults (current time, current user) 412 $info->{date} = time();414 $info->{date} = time(); 413 415 $info->{author} = $cUID; 414 416 } … … 428 430 sub delRev { 429 431 my ( $this, $topicObject, $cUID ) = @_; 430 ASSERT( $topicObject->isa('Foswiki::Meta') ) if DEBUG;432 ASSERT( $topicObject->isa('Foswiki::Meta') ) if DEBUG; 431 433 ASSERT($cUID) if DEBUG; 432 434 … … 441 443 442 444 # restore last topic from repository 443 $handler->restoreLatestRevision( $cUID);445 $handler->restoreLatestRevision($cUID); 444 446 445 447 return $rev; … … 451 453 sub lockTopic { 452 454 my ( $this, $topicObject, $cUID ) = @_; 453 ASSERT( $topicObject->isa('Foswiki::Meta')) if DEBUG;455 ASSERT( $topicObject->isa('Foswiki::Meta') ) if DEBUG; 454 456 ASSERT($cUID) if DEBUG; 455 457 my $handler = $this->getHandler( $topicObject->web, $topicObject->topic ); … … 530 532 # Documented in Foswiki::Store 531 533 sub eachAttachment { 532 my ( $this, $topicObject) = @_;534 my ( $this, $topicObject ) = @_; 533 535 534 536 my $handler = $this->getHandler( $topicObject->web, $topicObject->topic ); 535 537 my @list = $handler->getAttachmentList(); 536 538 require Foswiki::ListIterator; 537 return new Foswiki::ListIterator( \@list);539 return new Foswiki::ListIterator( \@list ); 538 540 } 539 541 … … 542 544 my ( $this, $webObject ) = @_; 543 545 544 my $handler = $this->getHandler( $webObject->web);546 my $handler = $this->getHandler( $webObject->web ); 545 547 my @list = $handler->getTopicNames(); 546 548 … … 552 554 sub eachWeb { 553 555 my ( $this, $webObject, $all ) = @_; 556 554 557 # Undocumented; this fn actually accepts a web name as well. This is 555 558 # to make the recursion more efficient. 556 559 my $web = ref($webObject) ? $webObject->web : $webObject; 557 560 558 my $handler = $this->getHandler( $web);559 my @list = $handler->getWebNames();561 my $handler = $this->getHandler($web); 562 my @list = $handler->getWebNames(); 560 563 if ($all) { 561 564 my $root = $web ? "$web/" : ''; … … 595 598 my ( $this, $query, $web, $inputTopicSet, $options ) = @_; 596 599 ASSERT($query); 597 ASSERT( UNIVERSAL::isa( $query, 'Foswiki::Query::Node' ) || UNIVERSAL::isa( $query, 'Foswiki::Search::Node' ) ); 600 ASSERT( UNIVERSAL::isa( $query, 'Foswiki::Query::Node' ) 601 || UNIVERSAL::isa( $query, 'Foswiki::Search::Node' ) ); 598 602 599 603 my $handler = $this->getHandler($web); 600 return $handler->searchInWebMetaData( $query, $web, $inputTopicSet, $this, $options ); 604 return $handler->searchInWebMetaData( $query, $web, $inputTopicSet, $this, 605 $options ); 601 606 } 602 607 … … 605 610 my ( $this, $searchString, $web, $topics, $options ) = @_; 606 611 607 my $handler = $this->getHandler($web);612 my $handler = $this->getHandler($web); 608 613 my $inputTopicSet = new Foswiki::ListIterator($topics); 609 614 610 return $handler->searchInWebContent( $searchString, $web, $inputTopicSet, $this, $options ); 615 return $handler->searchInWebContent( $searchString, $web, $inputTopicSet, 616 $this, $options ); 611 617 } 612 618 -
trunk/core/lib/Foswiki/Time.pm
r3440 r3947 126 126 $tzadj = -Time::Local::timelocal( 0, 0, 0, 1, 0, 70 ); 127 127 } 128 128 129 # try "31 Dec 2001 - 23:59" (Foswiki date) 129 130 # or "31 Dec 2001" -
trunk/core/lib/Foswiki/UI.pm
r3946 r3947 29 29 30 30 $Foswiki::cfg{SwitchBoard}{attach} = { 31 package => 'Foswiki::UI::Attach',31 package => 'Foswiki::UI::Attach', 32 32 function => 'attach', 33 context => { attach => 1 },33 context => { attach => 1 }, 34 34 }; 35 35 $Foswiki::cfg{SwitchBoard}{changes} = { 36 package => 'Foswiki::UI::Changes',36 package => 'Foswiki::UI::Changes', 37 37 function => 'changes', 38 context => { changes => 1 },38 context => { changes => 1 }, 39 39 }; 40 40 $Foswiki::cfg{SwitchBoard}{edit} = { 41 package => 'Foswiki::UI::Edit',41 package => 'Foswiki::UI::Edit', 42 42 function => 'edit', 43 context => { edit => 1 },43 context => { edit => 1 }, 44 44 }; 45 45 $Foswiki::cfg{SwitchBoard}{login} = { 46 package => undef,46 package => undef, 47 47 function => 'logon', 48 context => { ( login => 1, logon => 1 ) },48 context => { ( login => 1, logon => 1 ) }, 49 49 }; 50 50 $Foswiki::cfg{SwitchBoard}{logon} = { 51 package => undef,51 package => undef, 52 52 function => 'logon', 53 context => { ( login => 1, logon => 1 ) },53 context => { ( login => 1, logon => 1 ) }, 54 54 }; 55 55 $Foswiki::cfg{SwitchBoard}{manage} = { 56 package => 'Foswiki::UI::Manage',56 package => 'Foswiki::UI::Manage', 57 57 function => 'manage', 58 context => { manage => 1 },59 allow => { POST => 1 },58 context => { manage => 1 }, 59 allow => { POST => 1 }, 60 60 }; 61 61 $Foswiki::cfg{SwitchBoard}{oops} = { 62 package => 'Foswiki::UI::Oops',62 package => 'Foswiki::UI::Oops', 63 63 function => 'oops_cgi', 64 context => { oops => 1 },64 context => { oops => 1 }, 65 65 }; 66 66 $Foswiki::cfg{SwitchBoard}{preview} = { 67 package => 'Foswiki::UI::Preview',67 package => 'Foswiki::UI::Preview', 68 68 function => 'preview', 69 context => { preview => 1 },69 context => { preview => 1 }, 70 70 }; 71 71 $Foswiki::cfg{SwitchBoard}{rdiffauth} = { 72 package => 'Foswiki::UI::RDiff',72 package => 'Foswiki::UI::RDiff', 73 73 function => 'diff', 74 context => { diff => 1 },74 context => { diff => 1 }, 75 75 }; 76 76 $Foswiki::cfg{SwitchBoard}{rdiff} = { 77 package => 'Foswiki::UI::RDiff',77 package => 'Foswiki::UI::RDiff', 78 78 function => 'diff', 79 context => { diff => 1 },79 context => { diff => 1 }, 80 80 }; 81 81 $Foswiki::cfg{SwitchBoard}{register} = { 82 package => 'Foswiki::UI::Register',82 package => 'Foswiki::UI::Register', 83 83 function => 'register_cgi', 84 context => { register => 1 }, 84 context => { register => 1 }, 85 85 86 # method verify must allow GET; protect in Foswiki::UI::Register 86 87 #allow => { POST => 1 }, 87 88 }; 88 89 $Foswiki::cfg{SwitchBoard}{rename} = { 89 package => 'Foswiki::UI::Rename',90 package => 'Foswiki::UI::Rename', 90 91 function => 'rename', 91 context => { rename => 1 }, 92 context => { rename => 1 }, 93 92 94 # Rename is 2 stage; protect in Foswiki::UI::Rename 93 95 #allow => { POST => 1 }, 94 96 }; 95 97 $Foswiki::cfg{SwitchBoard}{resetpasswd} = { 96 package => 'Foswiki::UI::Passwords',98 package => 'Foswiki::UI::Passwords', 97 99 function => 'resetPassword', 98 context => { resetpasswd => 1 },99 allow => { POST => 1 },100 context => { resetpasswd => 1 }, 101 allow => { POST => 1 }, 100 102 }; 101 103 $Foswiki::cfg{SwitchBoard}{rest} = { 102 package => 'Foswiki::UI::Rest',104 package => 'Foswiki::UI::Rest', 103 105 function => 'rest', 104 context => { rest => 1 },106 context => { rest => 1 }, 105 107 }; 106 108 $Foswiki::cfg{SwitchBoard}{save} = { 107 package => 'Foswiki::UI::Save',109 package => 'Foswiki::UI::Save', 108 110 function => 'save', 109 context => { save => 1 },110 allow => { POST => 1 },111 context => { save => 1 }, 112 allow => { POST => 1 }, 111 113 }; 112 114 $Foswiki::cfg{SwitchBoard}{search} = { 113 package => 'Foswiki::UI::Search',115 package => 'Foswiki::UI::Search', 114 116 function => 'search', 115 context => { search => 1 },117 context => { search => 1 }, 116 118 }; 117 119 $Foswiki::cfg{SwitchBoard}{statistics} = { 118 package => 'Foswiki::UI::Statistics',120 package => 'Foswiki::UI::Statistics', 119 121 function => 'statistics', 120 context => { statistics => 1 },122 context => { statistics => 1 }, 121 123 }; 122 124 $Foswiki::cfg{SwitchBoard}{upload} = { 123 package => 'Foswiki::UI::Upload',125 package => 'Foswiki::UI::Upload', 124 126 function => 'upload', 125 context => { upload => 1 },126 allow => { POST => 1 },127 context => { upload => 1 }, 128 allow => { POST => 1 }, 127 129 }; 128 130 $Foswiki::cfg{SwitchBoard}{viewauth} = { 129 package => 'Foswiki::UI::View',131 package => 'Foswiki::UI::View', 130 132 function => 'view', 131 context => { view => 1 },133 context => { view => 1 }, 132 134 }; 133 135 $Foswiki::cfg{SwitchBoard}{viewfile} = { 134 package => 'Foswiki::UI::Viewfile',136 package => 'Foswiki::UI::Viewfile', 135 137 function => 'viewfile', 136 context => { viewfile => 1 },138 context => { viewfile => 1 }, 137 139 }; 138 140 $Foswiki::cfg{SwitchBoard}{view} = { 139 package => 'Foswiki::UI::View',141 package => 'Foswiki::UI::View', 140 142 function => 'view', 141 context => { view => 1 },143 context => { view => 1 }, 142 144 }; 143 145 } … … 192 194 } 193 195 194 if (ref($dispatcher) eq 'ARRAY') { 196 if ( ref($dispatcher) eq 'ARRAY' ) { 197 195 198 # Old-style array entry in switchboard from a plugin 196 199 my @array = @$dispatcher; … … 202 205 } 203 206 204 if ( $dispatcher->{package} && !$isInitialized{ $dispatcher->{package}} ) {207 if ( $dispatcher->{package} && !$isInitialized{ $dispatcher->{package} } ) { 205 208 eval qq(use $dispatcher->{package}); 206 209 die $@ if $@; 207 $isInitialized{ $dispatcher->{package}} = 1;210 $isInitialized{ $dispatcher->{package} } = 1; 208 211 } 209 212 … … 245 248 } 246 249 } 250 247 251 #print STDERR "INCOMING ".$req->method()." ".$req->url." -> ".$sub."\n"; 248 252 #require Data::Dumper; … … 250 254 if ( UNIVERSAL::isa( $Foswiki::engine, 'Foswiki::Engine::CLI' ) ) { 251 255 $dispatcher->{context}->{command_line} = 1; 252 } elsif ( defined $req->method() 253 && ( 254 ( defined $dispatcher->{allow} 255 && !$dispatcher->{allow}->{uc($req->method())} ) 256 || 257 ( defined $dispatcher->{deny} 258 && $dispatcher->{deny}->{uc($req->method())} ) 259 ) 260 ) { 256 } 257 elsif ( 258 defined $req->method() 259 && ( 260 ( 261 defined $dispatcher->{allow} 262 && !$dispatcher->{allow}->{ uc( $req->method() ) } 263 ) 264 || ( defined $dispatcher->{deny} 265 && $dispatcher->{deny}->{ uc( $req->method() ) } ) 266 ) 267 ) 268 { 261 269 $res = new Foswiki::Response(); 262 270 $res->header( -type => 'text/html', -status => '405' ); 263 $res->print('Bad Request: '.uc($req->method()).' denied for ' 264 .$req->action()); 271 $res->print( 'Bad Request: ' 272 . uc( $req->method() ) 273 . ' denied for ' 274 . $req->action() ); 265 275 return $res; 266 276 } 267 $res = _execute( $req, \&$sub, %{ $dispatcher->{context}} );277 $res = _execute( $req, \&$sub, %{ $dispatcher->{context} } ); 268 278 return $res; 269 279 } … … 298 308 catch Foswiki::ValidationException with { 299 309 my $query = $session->{request}; 310 300 311 # Redirect with passthrough so we don't lose the 301 312 # original query params. We use the login script for 302 313 # validation because it already has the correct criteria 303 314 # in httpd.conf for Apache login. 304 my $url = $session->getScriptUrl( 305 0, 'login', $session->{webName}, $session->{topicName} ); 306 $query->param( -name => 'action', 307 -value => 'validate' ); 308 $query->param( -name => 'origurl', 309 -value => $session->{request}->uri ); 315 my $url = 316 $session->getScriptUrl( 0, 'login', $session->{webName}, 317 $session->{topicName} ); 318 $query->param( 319 -name => 'action', 320 -value => 'validate' 321 ); 322 $query->param( 323 -name => 'origurl', 324 -value => $session->{request}->uri 325 ); 310 326 $session->redirect( $url, 1 ); # with passthrough 311 327 } … … 395 411 sub logon { 396 412 my $session = shift; 397 if (($session->{request}->param('action') ||'') eq 'validate' 398 # Force login if not recognisably authenticated 399 && $session->inContext('authenticated')) { 400 Foswiki::Validation::validate( $session ); 401 } else { 402 $session->{users}->{loginManager}->login( 403 $session->{request}, $session ); 413 if ( 414 ( $session->{request}->param('action') || '' ) eq 'validate' 415 416 # Force login if not recognisably authenticated 417 && $session->inContext('authenticated') 418 ) 419 { 420 Foswiki::Validation::validate($session); 421 } 422 else { 423 $session->{users}->{loginManager} 424 ->login( $session->{request}, $session ); 404 425 } 405 426 } … … 496 517 # Check the nonce before we do anything else 497 518 my $nonce = $session->{request}->param('validation_key'); 498 if (!defined($nonce) || !Foswiki::Validation::isValidNonce( 499 $session->getCGISession(), $nonce)) { 519 if ( !defined($nonce) 520 || !Foswiki::Validation::isValidNonce( $session->getCGISession(), 521 $nonce ) ) 522 { 500 523 throw Foswiki::ValidationException(); 501 524 } 502 if (defined($nonce)) { 525 if ( defined($nonce) ) { 526 503 527 # Expire the nonce. If the user tries to use it again, they will 504 528 # be prompted. 505 Foswiki::Validation::expireValidationKeys( 506 $ session->getCGISession(), $nonce );529 Foswiki::Validation::expireValidationKeys( $session->getCGISession(), 530 $nonce ); 507 531 } 508 532 } -
trunk/core/lib/Foswiki/UI/ChangeForm.pm
r3440 r3947 62 62 my ( $formWeb, $formTopic ) = 63 63 $session->normalizeWebTopicName( $topicObject->web, $form ); 64 my $formLabelContent = 65 ' '66 . ($session->topicExists( $formWeb, $formTopic )64 my $formLabelContent = ' ' 65 . ( 66 $session->topicExists( $formWeb, $formTopic ) 67 67 ? '[[' . $formWeb . '.' . $formTopic . '][' . $form . ']]' 68 : $form ); 68 : $form 69 ); 69 70 $formList .= CGI::label( { for => $formElemId }, $formLabelContent ); 70 71 } -
trunk/core/lib/Foswiki/UI/Changes.pm
r3440 r3947 8 8 use Error qw( :try ); 9 9 10 use Foswiki ();11 use Foswiki::UI ();10 use Foswiki (); 11 use Foswiki::UI (); 12 12 use Foswiki::Time (); 13 13 -
trunk/core/lib/Foswiki/UI/Edit.pm
r3440 r3947 14 14 use Error qw( :try ); 15 15 16 use Foswiki ();17 use Foswiki::UI ();16 use Foswiki (); 17 use Foswiki::UI (); 18 18 use Foswiki::OopsException (); 19 19 -
trunk/core/lib/Foswiki/UI/Manage.pm
r3820 r3947 17 17 use Error qw( :try ); 18 18 19 use Foswiki ();20 use Foswiki::UI ();19 use Foswiki (); 20 use Foswiki::UI (); 21 21 use Foswiki::OopsException (); 22 use Foswiki::Sandbox ();22 use Foswiki::Sandbox (); 23 23 24 24 =begin TML … … 168 168 } 169 169 170 Foswiki::UI::checkValidationKey( 171 $session , 'createweb', $session->{webName}, $session->{topicName} );170 Foswiki::UI::checkValidationKey( $session, 'createweb', $session->{webName}, 171 $session->{topicName} ); 172 172 173 173 # Get options from the form (only those options that are already 174 174 # set in the template WebPreferences topic are changed, so we can 175 175 # just copy everything) 176 my $me = $session->{users}->getWikiName($cUID);176 my $me = $session->{users}->getWikiName($cUID); 177 177 my $opts = { 178 178 … … 181 181 ALLOWTOPICCHANGE => $me, 182 182 ALLOWTOPICRENAME => 'nobody', 183 ALLOWWEBCHANGE => $me,184 ALLOWWEBRENAME => $me,183 ALLOWWEBCHANGE => $me, 184 ALLOWWEBRENAME => $me, 185 185 }; 186 186 foreach my $p ( $query->param() ) { … … 374 374 375 375 $newTopicObject->remove('PREFERENCE'); # delete previous settings 376 # Note: $Foswiki::regex{setVarRegex} cannot be used as it requires377 # use in code that parses multiline settings line by line.376 # Note: $Foswiki::regex{setVarRegex} cannot be used as it requires 377 # use in code that parses multiline settings line by line. 378 378 $settings =~ 379 s(^(?:\t| )+\*\s+(Set|Local)\s+($Foswiki::regex{tagNameRegex})\s*=\s*?(.*)$)379 s(^(?:\t| )+\*\s+(Set|Local)\s+($Foswiki::regex{tagNameRegex})\s*=\s*?(.*)$) 380 380 (_parsePreferenceValue($newTopicObject, $1, $2, $3))mgeo; 381 382 381 383 382 my $saveOpts = {}; … … 393 392 && $info->{author} ne $session->{user} ) 394 393 { 395 my $currTopicObject = Foswiki::Meta->load( 396 $session, $web, $topic ); 394 my $currTopicObject = Foswiki::Meta->load( $session, $web, $topic ); 397 395 $newTopicObject->merge($currTopicObject); 398 396 } -
trunk/core/lib/Foswiki/UI/Passwords.pm
r3440 r3947 14 14 use Error qw( :try ); 15 15 16 use Foswiki ();16 use Foswiki (); 17 17 use Foswiki::OopsException (); 18 use Foswiki::Sandbox ();18 use Foswiki::Sandbox (); 19 19 20 20 =begin TML -
trunk/core/lib/Foswiki/UI/Preview.pm
r3440 r3947 6 6 use Error qw( :try ); 7 7 8 use Foswiki ();9 use Foswiki::UI::Save ();8 use Foswiki (); 9 use Foswiki::UI::Save (); 10 10 use Foswiki::OopsException (); 11 11 -
trunk/core/lib/Foswiki/UI/RDiff.pm
r3721 r3947 15 15 use Error qw( :try ); 16 16 17 use Foswiki ();17 use Foswiki (); 18 18 use Foswiki::UI (); 19 19 … … 475 475 } 476 476 my $revHigh = $query->param('rev1'); 477 my $revLow = $query->param('rev2');477 my $revLow = $query->param('rev2'); 478 478 479 479 my $skin = $session->getSkin(); … … 491 491 if ( $diffType eq 'last' ) { 492 492 $revHigh = $maxrev; 493 $revLow = $maxrev - 1;493 $revLow = $maxrev - 1; 494 494 } 495 495 … … 514 514 # do one or more diffs 515 515 $difftmpl = $topicObject->expandMacros($difftmpl); 516 my $rHigh = $revHigh;517 my $rLow = $revLow;516 my $rHigh = $revHigh; 517 my $rLow = $revLow; 518 518 my $isMultipleDiff = 0; 519 519 520 520 if ( ( $diffType eq 'history' ) && ( $rHigh > $rLow + 1 ) ) { 521 $rLow = $rHigh - 1;521 $rLow = $rHigh - 1; 522 522 $isMultipleDiff = 1; 523 523 } … … 528 528 529 529 # Load the revs being diffed 530 $topicObject{$rHigh} = Foswiki::Meta->load( 531 $session, $topicObject->web, $topicObject->topic, $rHigh ) 530 $topicObject{$rHigh} = 531 Foswiki::Meta->load( $session, $topicObject->web, $topicObject->topic, 532 $rHigh ) 532 533 unless $topicObject{$rHigh}; 533 ASSERT($topicObject{$rHigh}->getLoadedRev() == $rHigh, $topicObject{$rHigh}->getLoadedRev()." == $rHigh") if DEBUG; 534 535 $topicObject{$rLow} = Foswiki::Meta->load( 536 $session, $topicObject->web, $topicObject->topic, $rLow ) 534 ASSERT( 535 $topicObject{$rHigh}->getLoadedRev() == $rHigh, 536 $topicObject{$rHigh}->getLoadedRev() . " == $rHigh" 537 ) if DEBUG; 538 539 $topicObject{$rLow} = 540 Foswiki::Meta->load( $session, $topicObject->web, $topicObject->topic, 541 $rLow ) 537 542 unless $topicObject{$rLow}; 538 ASSERT($topicObject{$rLow}->getLoadedRev() == $rLow, $topicObject{$rLow}->getLoadedRev()." == $rLow") if DEBUG; 543 ASSERT( 544 $topicObject{$rLow}->getLoadedRev() == $rLow, 545 $topicObject{$rLow}->getLoadedRev() . " == $rLow" 546 ) if DEBUG; 539 547 540 548 my $diff = $difftmpl; … … 550 558 } 551 559 else { 552 $rInfo = $session->renderer->renderRevisionInfo( $topicObject, $rHigh, 560 $rInfo = 561 $session->renderer->renderRevisionInfo( $topicObject, $rHigh, 553 562 '$date - $wikiusername' ); 554 $rInfo2 = $session->renderer->renderRevisionInfo( $topicObject, $rHigh, 563 $rInfo2 = 564 $session->renderer->renderRevisionInfo( $topicObject, $rHigh, 555 565 '$rev ($date - $time) - $wikiusername' ); 556 566 } … … 593 603 $page .= $diff; 594 604 $rHigh = $rHigh - 1; 595 $rLow = $rLow - 1;596 $rLow = 1 if ( $rLow < 1 );605 $rLow = $rLow - 1; 606 $rLow = 1 if ( $rLow < 1 ); 597 607 } while ( $diffType eq 'history' && ( $rHigh > $revLow || $rHigh == 1 ) ); 598 608 -
trunk/core/lib/Foswiki/UI/Register.pm
r3946 r3947 15 15 use Error qw( :try ); 16 16 17 use Foswiki ();17 use Foswiki (); 18 18 use Foswiki::OopsException (); 19 use Foswiki::Sandbox ();19 use Foswiki::Sandbox (); 20 20 21 21 # Keys from the user data that should *not* be included in … … 55 55 my $action = $query->param('action') || ''; 56 56 57 if ( $action ne 'verify' && $query && $query->method() && 58 uc($query->method()) ne 'POST') { 59 throw Foswiki::OopsException( 60 'attention', 61 web => $session->{webName}, 62 topic => $session->{topicName}, 63 def => 'post_method_only', 64 params => [ 'upload' ] 57 if ( $action ne 'verify' 58 && $query 59 && $query->method() 60 && uc( $query->method() ) ne 'POST' ) 61 { 62 throw Foswiki::OopsException( 63 'attention', 64 web => $session->{webName}, 65 topic => $session->{topicName}, 66 def => 'post_method_only', 67 params => ['upload'] 65 68 ); 66 69 } … … 386 389 my $file = _codeFile( $data->{VerificationCode} ); 387 390 my $F; 388 open( $F, '>', $file ) or throw Error::Simple( 'Failed to open file: ' . $! ); 391 open( $F, '>', $file ) 392 or throw Error::Simple( 'Failed to open file: ' . $! ); 389 393 print $F '# Verification code', "\n"; 390 394 -
trunk/core/lib/Foswiki/UI/Rename.pm
r3945 r3947 72 72 my ( $session, $oldWeb, $oldTopic ) = @_; 73 73 74 my $query = $session->{cgiQuery};75 my $newTopic = $query->param('newtopic')|| '';76 my $newWeb = $query->param('newweb')|| '';74 my $query = $session->{cgiQuery}; 75 my $newTopic = $query->param('newtopic') || ''; 76 my $newWeb = $query->param('newweb') || ''; 77 77 78 78 # Validate the new web name … … 136 136 } 137 137 138 my $attachment = $query->param('attachment');138 my $attachment = $query->param('attachment'); 139 139 my $newAttachment = $query->param('newattachment'); 140 140 … … 179 179 return Foswiki::Sandbox::sanitizeAttachmentName($att); 180 180 } 181 );181 ); 182 182 } 183 183 … … 232 232 233 233 # Has user selected new name yet? 234 if ( !$newTopic || ( $attachment && !$newAttachment) || $confirm ) {234 if ( !$newTopic || ( $attachment && !$newAttachment ) || $confirm ) { 235 235 $newAttachment ||= $attachment; 236 236 … … 238 238 Foswiki::UI::checkAccess( $session, 'VIEW', $old ); 239 239 240 _newTopicOrAttachmentScreen( 241 $ session, $old, $new, $attachment, $newAttachment, $confirm );240 _newTopicOrAttachmentScreen( $session, $old, $new, $attachment, 241 $newAttachment, $confirm ); 242 242 return; 243 243 244 244 } 245 245 246 return if ($query && $query->method() 247 && uc($query->method()) ne 'POST'); 248 249 Foswiki::UI::checkValidationKey( 250 $session, 'rename', $session->{webName}, $session->{topicName} ); 246 return 247 if ( $query 248 && $query->method() 249 && uc( $query->method() ) ne 'POST' ); 250 251 Foswiki::UI::checkValidationKey( $session, 'rename', $session->{webName}, 252 $session->{topicName} ); 251 253 252 254 # Update references in referring pages - not applicable to attachments. … … 258 260 } 259 261 260 _moveTopicOrAttachment( 261 $ session, $old, $new, $attachment, $newAttachment, $refs );262 _moveTopicOrAttachment( $session, $old, $new, $attachment, $newAttachment, 263 $refs ); 262 264 263 265 my $new_url; … … 293 295 } 294 296 else { 297 295 298 # No parent topic, redirect to home topic 296 299 $new_url = … … 334 337 # If the user is not allowed to rename anything in the current 335 338 # web - stop here 336 Foswiki::UI::checkAccess( $session, 'RENAME', $oldWebObject );339 Foswiki::UI::checkAccess( $session, 'RENAME', $oldWebObject ); 337 340 338 341 my $newParentWeb = $query->param('newparentweb') || ''; … … 389 392 # This also ensures we check root webs for ALLOWROOTRENAME and 390 393 # DENYROOTRENAME 391 my $oldParentWebObject = new Foswiki::Meta(392 $session, $oldParentWeb || undef );394 my $oldParentWebObject = 395 new Foswiki::Meta( $session, $oldParentWeb || undef ); 393 396 Foswiki::UI::checkAccess( $session, 'RENAME', $oldParentWebObject ); 394 397 … … 401 404 my $newTopic; 402 405 my $lockFailure = ''; 403 my $confirm = $query->param('confirm') || '';406 my $confirm = $query->param('confirm') || ''; 404 407 405 408 Foswiki::UI::checkWebExists( $session, $oldWeb, … … 473 476 $info->{modify}{$ref}{summary} = $refs{$ref}; 474 477 $info->{modify}{$ref}{access} = 475 $topicObject->haveAccess( 'CHANGE');478 $topicObject->haveAccess('CHANGE'); 476 479 if ( !$info->{modify}{$ref}{access} ) { 477 480 $info->{modify}{$ref}{accessReason} = … … 491 494 require Foswiki::WebFilter; 492 495 next unless $Foswiki::WebFilter::public->ok( $session, $subweb ); 493 _leaseContents( $session, $info, 494 $oldWebObject->web . '/' . $subweb,$confirm );496 _leaseContents( $session, $info, $oldWebObject->web . '/' . $subweb, 497 $confirm ); 495 498 } 496 499 … … 593 596 } 594 597 595 Foswiki::UI::checkValidationKey( 596 $session , 'rename', $session->{webName}, $session->{topicName} );598 Foswiki::UI::checkValidationKey( $session, 'rename', $session->{webName}, 599 $session->{topicName} ); 597 600 598 601 my $newWebObject = Foswiki::Meta->new( $session, $newWeb ); … … 636 639 # also remove lease on all referring topics 637 640 foreach my $ref (@$refs) { 638 my @path = split( /[.\/]/, $ref );641 my @path = split( /[.\/]/, $ref ); 639 642 my $webTopic = pop(@path); 640 643 my $webIter = join( '/', @path ); … … 735 738 if ($attachment) { 736 739 try { 737 $from->moveAttachment( 738 $attachment, $to,new_name => $toattachment );740 $from->moveAttachment( $attachment, $to, 741 new_name => $toattachment ); 739 742 } 740 743 catch Error::Simple with { … … 831 834 my $repl = $newTopic; 832 835 833 my $newWeb = $args->{newWeb};834 my $oldWeb = $args->{oldWeb};836 my $newWeb = $args->{newWeb}; 837 my $oldWeb = $args->{oldWeb}; 835 838 my $sameWeb = ( $oldWeb eq $newWeb ); 836 839 … … 874 877 ASSERT( defined $args->{oldWeb} ) if DEBUG; 875 878 ASSERT( defined $args->{newWeb} ) if DEBUG; 876 ASSERT( $text !~ /$MARKER/ ) if DEBUG;879 ASSERT( $text !~ /$MARKER/ ) if DEBUG; 877 880 878 881 my $newWeb = $args->{newWeb}; … … 904 907 905 908 my $renderer = $session->renderer; 906 my $webObject = Foswiki::Meta->new( $session, $from->web() );909 my $webObject = Foswiki::Meta->new( $session, $from->web() ); 907 910 my $it = $webObject->eachTopic(); 908 911 my $oldTopic = $from->topic(); … … 911 914 912 915 # exclude this topic from the list 913 topics => [ grep { !/^$oldTopic$/ } $it->all() ], 914 915 inWeb => $from->web, 916 inTopic => $from->topic, 917 918 oldWeb => $from->web, 916 topics => [ grep { !/^$oldTopic$/ } $it->all() ], 917 918 inWeb => $from->web, 919 inTopic => $from->topic, 920 921 oldWeb => $from->web, 922 919 923 #oldTopic => will be filled in by _replaceInternalRefs 920 924 921 newWeb => $from->web, 925 newWeb => $from->web, 926 922 927 #newTopic => will be filled in by _replaceInternalRefs 923 928 }; … … 938 943 # Ok, let's look for links to topics in the 939 944 # new web and remove their web qualifiers 940 $webObject = Foswiki::Meta->new( $session, $to->web() );945 $webObject = Foswiki::Meta->new( $session, $to->web() ); 941 946 $it = $webObject->eachTopic(); 942 947 … … 947 952 fullPaths => 0, 948 953 949 inWeb => $to->web, 950 inTopic => $to->topic, 951 952 oldWeb => $to->web, 954 inWeb => $to->web, 955 inTopic => $to->topic, 956 957 oldWeb => $to->web, 958 953 959 #oldTopic => will be filled in by _replaceInternalRefs 954 960 955 newWeb => $to->web, 961 newWeb => $to->web, 962 956 963 #newTopic => will be filled in by _replaceInternalRefs 957 964 }; … … 990 997 # Display screen so user can decide on new web, topic, attachment names. 991 998 sub _newTopicOrAttachmentScreen { 992 my ( $session, $from, $to, $attachment, $toattachment, 993 $confirm, $doAllowNonWikiWord ) = @_; 999 my ( $session, $from, $to, $attachment, $toattachment, $confirm, 1000 $doAllowNonWikiWord ) 1001 = @_; 994 1002 995 1003 my $query = $session->{cgiQuery}; … … 1018 1026 1019 1027 if ( $to->web eq $Foswiki::cfg{TrashWebName} ) { 1028 1020 1029 # Deleting an attachment or a topic 1021 if ( $attachment ) { 1030 if ($attachment) { 1031 1022 1032 # Trashing an attachment; look for a non-conflicting name in the 1023 1033 # trash web 1024 1034 my $base = $toattachment || $attachment; 1025 my $ext = '';1026 if ( $base =~ s/^(.*)(\..*?)$/$1_/) {1035 my $ext = ''; 1036 if ( $base =~ s/^(.*)(\..*?)$/$1_/ ) { 1027 1037 $ext = $2; 1028 1038 } 1029 my $n = 1;1030 while ( $to->hasAttachment( $toattachment )) {1039 my $n = 1; 1040 while ( $to->hasAttachment($toattachment) ) { 1031 1041 $toattachment = $base . $n . $ext; 1032 1042 $n++; 1033 1043 } 1034 1044 1035 } else { 1045 } 1046 else { 1047 1036 1048 # Trashing a topic; look for a non-conflicting name in the 1037 1049 # trash web … … 1256 1268 $tmpl =~ s/%LOCAL_SEARCH%/$search/go; 1257 1269 1258 my $fromWebHome = new Foswiki::Meta(1259 $session, $from->web, $Foswiki::cfg{HomeTopicName});1270 my $fromWebHome = 1271 new Foswiki::Meta( $session, $from->web, $Foswiki::cfg{HomeTopicName} ); 1260 1272 $tmpl = $fromWebHome->expandMacros($tmpl); 1261 1273 $tmpl = $fromWebHome->renderTML($tmpl); … … 1275 1287 1276 1288 # Check validity of web and topic 1277 $itemWeb = Foswiki::Sandbox::untaint( 1278 $itemWeb, \&Foswiki::Sandbox::validateWebName);1279 $itemTopic = Foswiki::Sandbox::untaint( 1280 $itemTopic, \&Foswiki::Sandbox::validateTopicName);1289 $itemWeb = Foswiki::Sandbox::untaint( $itemWeb, 1290 \&Foswiki::Sandbox::validateWebName ); 1291 $itemTopic = Foswiki::Sandbox::untaint( $itemTopic, 1292 \&Foswiki::Sandbox::validateTopicName ); 1281 1293 1282 1294 # Skip web.topic that fails validation 1283 next unless ( $itemWeb && $itemTopic);1284 1285 ASSERT( $itemWeb !~ /\./) if DEBUG;# cos we will split on . later1295 next unless ( $itemWeb && $itemTopic ); 1296 1297 ASSERT( $itemWeb !~ /\./ ) if DEBUG; # cos we will split on . later 1286 1298 push @result, "$itemWeb.$itemTopic"; 1287 1299 } … … 1313 1325 my %results; 1314 1326 foreach my $searchWeb (@webs) { 1315 my $interWeb = ( $searchWeb ne $om->web());1327 my $interWeb = ( $searchWeb ne $om->web() ); 1316 1328 next if ( $allWebs && !$interWeb ); 1317 1329 … … 1319 1331 my $searchString = Foswiki::Render::getReferenceRE( 1320 1332 $om->web(), $om->topic(), 1321 grep => 1,1333 grep => 1, 1322 1334 interweb => $interWeb 1323 1335 ); … … 1325 1337 . Foswiki::Render::getReferenceRE( 1326 1338 $om->web(), $om->topic(), 1327 grep => 1,1339 grep => 1, 1328 1340 interweb => $interWeb, 1329 url => 11341 url => 1 1330 1342 ); 1331 1343 my @topicList = (); … … 1374 1386 1375 1387 foreach my $item (@$refs) { 1376 my ( $itemWeb, $itemTopic ) = split( /\./, $item, 2);1388 my ( $itemWeb, $itemTopic ) = split( /\./, $item, 2 ); 1377 1389 1378 1390 if ( $session->topicExists( $itemWeb, $itemTopic ) ) { -
trunk/core/lib/Foswiki/UI/Rest.pm
r3941 r3947 76 76 # SMELL: excess brackets in RE? 77 77 unless ( $topic =~ /((?:.*[\.\/])+)(.*)/ ) { 78 $res->header( -type => 'text/html', -status => '400' );78 $res->header( -type => 'text/html', -status => '400' ); 79 79 $err = 'ERROR: (400) Invalid REST invocation' 80 80 . " - Invalid topic parameter $topic\n"; 81 $res->print( $err);81 $res->print($err); 82 82 throw Foswiki::EngineException( 400, $err, $res ); 83 83 } … … 94 94 my $login = $req->param('username'); 95 95 if ($login) { 96 my $pass = $req->param('password');96 my $pass = $req->param('password'); 97 97 my $validation = $session->{users}->checkPassword( $login, $pass ); 98 98 unless ($validation) { 99 $res->header( -type => 'text/html', -status => '401' );99 $res->header( -type => 'text/html', -status => '401' ); 100 100 $err = "ERROR: (401) Can't login as $login"; 101 101 $res->print($err); … … 112 112 try { 113 113 $session->{users}->{loginManager}->checkAccess(); 114 } catch Error with { 115 my $e = shift; 116 $res->header( -type => 'text/html', -status => '401' ); 114 } 115 catch Error with { 116 my $e = shift; 117 $res->header( -type => 'text/html', -status => '401' ); 117 118 $err = "ERROR: (401) $e"; 118 119 $res->print($err); … … 127 128 unless ( $pathInfo =~ m#/(.*?)[./]([^/]*)# ) { 128 129 129 $res->header( -type => 'text/html', -status => '400' );130 $res->header( -type => 'text/html', -status => '400' ); 130 131 $err = "ERROR: (400) Invalid REST invocation - $pathInfo is malformed"; 131 132 $res->print($err); … … 139 140 140 141 # Check we have this handler 141 unless ( $record ) { 142 $res->header( -type => 'text/html', -status => '404' ); 143 $err = 'ERROR: (404) Invalid REST invocation - ' 144 .$pathInfo.' does not refer to a known handler'; 142 unless ($record) { 143 $res->header( -type => 'text/html', -status => '404' ); 144 $err = 145 'ERROR: (404) Invalid REST invocation - ' 146 . $pathInfo 147 . ' does not refer to a known handler'; 145 148 $res->print($err); 146 149 throw Foswiki::EngineException( 404, $err, $res ); … … 148 151 149 152 # Check the method is allowed 150 if ( $record->{http_allow} && defined $req->method()) {151 my %allowed = map { $_ => 1 } split (/[,\s]+/, $record->{http_allow});152 unless ( $allowed{uc($req->method())}) {153 if ( $record->{http_allow} && defined $req->method() ) { 154 my %allowed = map { $_ => 1 } split( /[,\s]+/, $record->{http_allow} ); 155 unless ( $allowed{ uc( $req->method() ) } ) { 153 156 $res->header( -type => 'text/html', -status => '405' ); 154 $err = 'ERROR: (405) Bad Request: '.uc($req->method()).' denied'; 157 $err = 158 'ERROR: (405) Bad Request: ' . uc( $req->method() ) . ' denied'; 155 159 $res->print($err); 156 160 throw Foswiki::EngineException( 404, $err, $res ); … … 159 163 160 164 # Check someone is logged in 161 if ( $record->{authenticate}) {165 if ( $record->{authenticate} ) { 162 166 unless ( $session->inContext('authenticated') 163 || $Foswiki::cfg{LoginManager} eq 'none' ) { 164 $res->header( -type => 'text/html', -status => '401' ); 167 || $Foswiki::cfg{LoginManager} eq 'none' ) 168 { 169 $res->header( -type => 'text/html', -status => '401' ); 165 170 $err = "ERROR: (401) $pathInfo requires you to be logged in"; 166 171 $res->print($err); … … 170 175 171 176 # Validate the request 172 if ( $record->{validate}) {177 if ( $record->{validate} ) { 173 178 my $nonce = $req->param('validation_key'); 174 if (!defined($nonce) || !Foswiki::Validation::isValidNonce( 175 $session->getCGISession(), $nonce)) { 176 $res->header( -type => 'text/html', -status => '401' ); 179 if ( 180 !defined($nonce) 181 || !Foswiki::Validation::isValidNonce( 182 $session->getCGISession(), $nonce 183 ) 184 ) 185 { 186 $res->header( -type => 'text/html', -status => '401' ); 177 187 $err = "ERROR: (403) Invalid validation code"; 178 188 $res->print($err); 179 189 throw Foswiki::EngineException( 401, $err, $res ); 180 190 } 191 181 192 # SMELL: Note we don't expire the validation code. If we expired it, 182 193 # then subsequent requests using the same code would have to be … … 197 208 } 198 209 elsif ($result) { 210 199 211 # If the handler doesn't want to handle all the details of the 200 212 # response, they can return a page here and get it 200'd 201 213 $session->writeCompletePage($result); 202 214 } 215 203 216 # Otherwise it's assumed that the handler dealt with the response. 204 217 } -
trunk/core/lib/Foswiki/UI/Save.pm
r3925 r3947 16 16 use Assert; 17 17 18 use Foswiki ();19 use Foswiki::UI ();20 use Foswiki::Meta ();18 use Foswiki (); 19 use Foswiki::UI (); 20 use Foswiki::Meta (); 21 21 use Foswiki::OopsException (); 22 22 … … 432 432 } 433 433 my $viewURL = $session->getScriptUrl( 1, 'view', $w, $t ); 434 $session->redirect( $session->redirectto($viewURL), undef, 1 );434 $session->redirect( $session->redirectto($viewURL), undef, 1 ); 435 435 436 436 return; … … 438 438 439 439 # Do this *before* we do any query parameter rewriting 440 Foswiki::UI::checkValidationKey( $session, 'save', $web, $topic);440 Foswiki::UI::checkValidationKey( $session, 'save', $web, $topic ); 441 441 442 442 my $editaction = lc( $query->param('editaction') ) || ''; … … 489 489 490 490 # drop through 491 } else { 491 } 492 else { 493 492 494 # redirect to topic view or any other redirectto specified as an url param 493 $redirecturl = $session->redirectto($session->getScriptUrl( 1, 'view', $web, $topic )); 495 $redirecturl = 496 $session->redirectto( 497 $session->getScriptUrl( 1, 'view', $web, $topic ) ); 494 498 } 495 499 … … 523 527 ); 524 528 } 525 526 529 527 530 if ( $adminCmd eq 'delRev' ) { -
trunk/core/lib/Foswiki/UI/Statistics.pm
r3440 r3947 225 225 while ( !$logFileUserName && scalar(@$line) ) { 226 226 $logFileUserName = shift @$line; 227 227 228 # Use Func::getCanonicalUserID because it accepts login, 228 229 # wikiname or web.wikiname -
trunk/core/lib/Foswiki/UI/Upload.pm
r3440 r3947 15 15 use Error qw( :try ); 16 16 17 use Foswiki ();18 use Foswiki::UI ();19 use Foswiki::Sandbox ();17 use Foswiki (); 18 use Foswiki::UI (); 19 use Foswiki::Sandbox (); 20 20 use Foswiki::OopsException (); 21 21 -
trunk/core/lib/Foswiki/UI/View.pm
r3440 r3947 16 16 use Assert; 17 17 18 use Foswiki ();19 use Foswiki::UI ();20 use Foswiki::Sandbox ();18 use Foswiki (); 19 use Foswiki::UI (); 20 use Foswiki::Sandbox (); 21 21 use Foswiki::OopsException (); 22 use Foswiki::Store ();22 use Foswiki::Store (); 23 23 24 24 =begin TML … … 330 330 my $page; 331 331 332 if ( $query->param('xml')) {332 if ( $query->param('xml') ) { 333 333 require Foswiki::TOM; 334 334 $page = Foswiki::TOM->new->TML2TOM($text); -
trunk/core/lib/Foswiki/UI/Viewfile.pm
r3469 r3947 140 140 my $fh = $topicObject->openAttachment( $fileName, '<', version => $rev ); 141 141 142 my $type = _suffixToMimeType($fileName);143 my $dispo = 'inline;filename=' . $fileName;142 my $type = _suffixToMimeType($fileName); 143 my $dispo = 'inline;filename=' . $fileName; 144 144 145 145 #re-set to 200, in case this was a 404 or other redirect … … 148 148 ->header( -type => $type, qq(Content-Disposition="$dispo") ); 149 149 local $/; 150 150 151 # SMELL: Maybe could be less memory hungry if we could 151 152 # set the response body to the file handle. -
trunk/core/lib/Foswiki/Users.pm
r3945 r3947 68 68 69 69 BEGIN { 70 70 71 # no point calling rand() without this 71 72 # See Camel-3 pp 800. "Do not call =srand()= multiple times in your … … 409 410 my ( $this, $identifier ) = @_; 410 411 my $cUID; 412 411 413 # Someone we already know? 412 414 -
trunk/core/lib/Foswiki/Users/ApacheHtpasswdUser.pm
r3944 r3947 4 4 5 5 use Foswiki::Users::Password (); 6 our @ISA = ( 'Foswiki::Users::Password');6 our @ISA = ('Foswiki::Users::Password'); 7 7 8 8 use Apache::Htpasswd (); -
trunk/core/lib/Foswiki/Users/BaseUserMapping.pm
r3944 r3947 29 29 30 30 use Foswiki::UserMapping (); 31 our @ISA = ( 'Foswiki::UserMapping');31 our @ISA = ('Foswiki::UserMapping'); 32 32 33 33 use Assert; -
trunk/core/lib/Foswiki/Users/HtPasswdUser.pm
r3946 r3947 16 16 17 17 use Foswiki::Users::Password (); 18 our @ISA = ( 'Foswiki::Users::Password');18 our @ISA = ('Foswiki::Users::Password'); 19 19 20 20 use Assert; … … 174 174 175 175 if ( $Foswiki::cfg{Htpasswd}{Encoding} eq 'sha1' ) { 176 my $encodedPassword = 177 '{SHA}' . Digest::SHA::sha1_base64( $passwd ); 176 my $encodedPassword = '{SHA}' . Digest::SHA::sha1_base64($passwd); 178 177 179 178 # don't use chomp, it relies on $/ -
trunk/core/lib/Foswiki/Validation.pm
r3941 r3947 7 7 8 8 use Digest::MD5 (); 9 use Foswiki ();9 use Foswiki (); 10 10 11 11 =begin TML … … 52 52 my $nonce = $digester->b64digest(); 53 53 $actions->{$nonce} = time() + $Foswiki::cfg{LeaseLength}; 54 #print STDERR time.": ADD $nonce ".join('; ', map { "$_=$actions->{$_}" } keys %$actions)."\n"; 54 55 #print STDERR time.": ADD $nonce ".join('; ', map { "$_=$actions->{$_}" } keys %$actions)."\n"; 55 56 $cgis->param( 'VALID_ACTIONS', $actions ); 56 return $form .CGI::hidden(-name => 'validation_key', -value=>$nonce);57 return $form . CGI::hidden( -name => 'validation_key', -value => $nonce ); 57 58 } 58 59 … … 83 84 84 85 sub expireValidationKeys { 85 my ( $cgis, $key) = @_;86 my ( $cgis, $key ) = @_; 86 87 my $actions = $cgis->param('VALID_ACTIONS'); 87 88 if ($actions) { 88 if ( defined $key && exists $actions->{$key}) {89 $actions->{$key} = 0; # force-expire this key89 if ( defined $key && exists $actions->{$key} ) { 90 $actions->{$key} = 0; # force-expire this key 90 91 } 91 92 my $deaths = 0; 92 my $now = time(); 93 while (my ($nonce, $time) = each %$actions) { 94 if ($time < $now) { 93 my $now = time(); 94 while ( my ( $nonce, $time ) = each %$actions ) { 95 if ( $time < $now ) { 96 95 97 #print STDERR time.": EXPIRE $nonce $time\n"; 96 98 delete $actions->{$nonce}; … … 99 101 } 100 102 if ($deaths) { 101 $cgis->param( 'VALID_ACTIONS', $actions);103 $cgis->param( 'VALID_ACTIONS', $actions ); 102 104 } 103 105 } … … 115 117 116 118 sub validate { 117 my ( $session) = @_;118 my $query = $session->{request};119 my $web = $session->{webName};120 my $topic = $session->{topicName};119 my ($session) = @_; 120 my $query = $session->{request}; 121 my $web = $session->{webName}; 122 my $topic = $session->{topicName}; 121 123 122 124 my $origurl = $query->param('origurl'); 123 $query->delete( 'origurl');125 $query->delete('origurl'); 124 126 125 127 my $tmpl = 126 128 $session->templates->readTemplate( 'validate', $session->getSkin() ); 127 129 128 if ( $query->param('response')) {130 if ( $query->param('response') ) { 129 131 my $url; 130 if ( $query->param('response') eq 'OK') {132 if ( $query->param('response') eq 'OK' ) { 131 133 if ( !$origurl || $origurl eq $query->url() ) { 132 134 $url = $session->getScriptUrl( 0, 'view', $web, $topic ); … … 134 136 else { 135 137 $url = $origurl; 138 136 139 # SMELL: do we ever need this? 137 ASSERT($url !~ /#/) if DEBUG; 140 ASSERT( $url !~ /#/ ) if DEBUG; 141 138 142 # Unpack params encoded in the origurl and restore them 139 143 # to the query. If they were left in the query string they … … 153 157 } 154 158 else { 159 155 160 #print STDERR "REJECTED; redirect to GET view\n"; 156 161 # Validation failed; redirect to view (302) … … 158 163 $session->redirect( $url, 0 ); # no passthrough 159 164 } 160 } else { 165 } 166 else { 167 161 168 #print STDERR "PROMPT VALIDATE\n"; 162 169 # prompt for user verification … … 164 171 165 172 $session->{prefs}->setSessionPreferences( 166 ORIGURL => Foswiki::_encode( 'entity', $origurl || '' ), 167 ); 173 ORIGURL => Foswiki::_encode( 'entity', $origurl || '' ), ); 168 174 169 175 my $topicObject = Foswiki::Meta->new( $session, $web, $topic ); -
trunk/core/lib/Foswiki/ValidationException.pm
r3944 r3947 13 13 14 14 use Error (); 15 our @ISA = ( 'Error' );# base class15 our @ISA = ('Error'); # base class 16 16 17 17 =begin TML
Note: See TracChangeset
for help on using the changeset viewer.
