Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
X
xwiki-platform
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Package Registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
XWiki
xwiki-platform
Commits
4720f18f
Commit
4720f18f
authored
8 years ago
by
Thomas Mortagne
Browse files
Options
Downloads
Patches
Plain Diff
XWIKI-13555: sdoc is not always available in the script binding
XWIKI-13528: Add support for replacing the default WYSIWYG editor
parent
fb54cde0
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/render/XWikiScriptContextInitializer.java
+26
-11
26 additions, 11 deletions
...a/com/xpn/xwiki/render/XWikiScriptContextInitializer.java
with
26 additions
and
11 deletions
xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/render/XWikiScriptContextInitializer.java
+
26
−
11
View file @
4720f18f
...
@@ -36,6 +36,7 @@
...
@@ -36,6 +36,7 @@
import
com.xpn.xwiki.api.Context
;
import
com.xpn.xwiki.api.Context
;
import
com.xpn.xwiki.api.Document
;
import
com.xpn.xwiki.api.Document
;
import
com.xpn.xwiki.api.XWiki
;
import
com.xpn.xwiki.api.XWiki
;
import
com.xpn.xwiki.doc.XWikiDocument
;
import
com.xpn.xwiki.web.Utils
;
import
com.xpn.xwiki.web.Utils
;
import
com.xpn.xwiki.web.XWikiMessageTool
;
import
com.xpn.xwiki.web.XWikiMessageTool
;
...
@@ -91,18 +92,32 @@ public void initialize(ScriptContext scriptContext)
...
@@ -91,18 +92,32 @@ public void initialize(ScriptContext scriptContext)
ScriptContext
.
ENGINE_SCOPE
);
ScriptContext
.
ENGINE_SCOPE
);
}
}
if
(
xcontext
.
getDoc
()
!=
null
)
{
// Current document
Document
apiDocument
=
xcontext
.
getDoc
().
newDocument
(
xcontext
);
XWikiDocument
doc
=
xcontext
.
getDoc
();
Document
translatedDocument
=
apiDocument
;
if
(
doc
!=
null
)
{
try
{
Document
previousDoc
=
(
Document
)
scriptContext
.
getAttribute
(
"doc"
);
translatedDocument
=
apiDocument
.
getTranslatedDocument
();
if
(
previousDoc
==
null
||
!
previousDoc
.
getDocumentReference
().
equals
(
doc
.
getDocumentReference
()))
{
}
catch
(
XWikiException
e
)
{
Document
apiDocument
=
doc
.
newDocument
(
xcontext
);
this
.
logger
.
warn
(
"Failed to retrieve the translated document for [{}]. "
Document
translatedDocument
=
apiDocument
;
+
"Continue using the default translation."
,
apiDocument
.
getFullName
(),
e
);
try
{
translatedDocument
=
apiDocument
.
getTranslatedDocument
();
}
catch
(
XWikiException
e
)
{
this
.
logger
.
warn
(
"Failed to retrieve the translated document for [{}]. "
+
"Continue using the default translation."
,
apiDocument
.
getFullName
(),
e
);
}
scriptContext
.
setAttribute
(
"doc"
,
apiDocument
,
ScriptContext
.
ENGINE_SCOPE
);
scriptContext
.
setAttribute
(
"cdoc"
,
translatedDocument
,
ScriptContext
.
ENGINE_SCOPE
);
scriptContext
.
setAttribute
(
"tdoc"
,
translatedDocument
,
ScriptContext
.
ENGINE_SCOPE
);
}
}
// Current secure document
XWikiDocument
sdoc
=
(
XWikiDocument
)
xcontext
.
get
(
"sdoc"
);
if
(
sdoc
!=
null
)
{
Document
previousSDoc
=
(
Document
)
scriptContext
.
getAttribute
(
"sdoc"
);
if
(
previousSDoc
==
null
||
!
previousSDoc
.
getDocumentReference
().
equals
(
sdoc
.
getDocumentReference
()))
{
scriptContext
.
setAttribute
(
"sdoc"
,
sdoc
.
newDocument
(
xcontext
),
ScriptContext
.
ENGINE_SCOPE
);
}
}
scriptContext
.
setAttribute
(
"doc"
,
apiDocument
,
ScriptContext
.
ENGINE_SCOPE
);
scriptContext
.
setAttribute
(
"cdoc"
,
translatedDocument
,
ScriptContext
.
ENGINE_SCOPE
);
scriptContext
.
setAttribute
(
"tdoc"
,
translatedDocument
,
ScriptContext
.
ENGINE_SCOPE
);
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment