Skip to content
Snippets Groups Projects
Commit a1274401 authored by Eduard Moraru's avatar Eduard Moraru
Browse files

XWIKI-12299: Deprecate XWiki.parseContent since it is misleading and outdated

- Deprecaed both core and api methods
- Replaced their usage in xwiki-plaform with #evaluate
parent 313e05f7
No related branches found
No related tags found
No related merge requests found
...@@ -6,7 +6,8 @@ ...@@ -6,7 +6,8 @@
#set ($version = $xwiki.getXWikiPreference("version")) #set ($version = $xwiki.getXWikiPreference("version"))
#end #end
#if ("$!version" != "") #if ("$!version" != "")
#set ($version = $xwiki.parseContent($version)) ## The version information coming from preferences is usually Velocity code, so make sure to evaluate it.
#set ($version = "#evaluate($version)")
#else #else
#set ($version = $!xwiki.version) #set ($version = $!xwiki.version)
#end #end
......
...@@ -30,7 +30,10 @@ ...@@ -30,7 +30,10 @@
#if(!$title) #if(!$title)
#set($title = $!xwiki.getSpacePreference('title')) #set($title = $!xwiki.getSpacePreference('title'))
#if($title != '') #if($title != '')
#set($title = "$escapetool.xml($xwiki.parseContent($title))") ## Evaluate the title since it can have velocity code.
#set($title = "#evaluate($title)")
## Don`t forget to escape it.
#set($title = "$escapetool.xml($title)")
#else #else
#set($title = "XWiki - $escapetool.xml($!doc.space) - $escapetool.xml($!tdoc.displayTitle)") #set($title = "XWiki - $escapetool.xml($!doc.space) - $escapetool.xml($!tdoc.displayTitle)")
#end #end
...@@ -78,9 +81,10 @@ ...@@ -78,9 +81,10 @@
## --------------------------------------------------------------------------------------------------------------- ## ---------------------------------------------------------------------------------------------------------------
<meta name="gwt:property" content="locale=$!{xcontext.language}" /> <meta name="gwt:property" content="locale=$!{xcontext.language}" />
## --------------------------------------------------------------------------------------------------------------- ## ---------------------------------------------------------------------------------------------------------------
## Add user-defined Meta directives ## Add user-defined Meta directives.
## --------------------------------------------------------------------------------------------------------------- ## ---------------------------------------------------------------------------------------------------------------
$xwiki.parseContent($!xwiki.getSpacePreference("meta")) ## Note: Velocity code, so it needs to be evaluated.
#evaluate($!xwiki.getSpacePreference("meta"))
## --------------------------------------------------------------------------------------------------------------- ## ---------------------------------------------------------------------------------------------------------------
## Hook for inserting Link extensions. This will be replaced with the pulled link references. ## Hook for inserting Link extensions. This will be replaced with the pulled link references.
## --------------------------------------------------------------------------------------------------------------- ## ---------------------------------------------------------------------------------------------------------------
......
...@@ -1761,6 +1761,10 @@ public <T> List<T> search(String sql, int nb, int start, Object[][] whereParams, ...@@ -1761,6 +1761,10 @@ public <T> List<T> search(String sql, int nb, int start, Object[][] whereParams,
return getStore().search(sql, nb, start, whereParams, context); return getStore().search(sql, nb, start, whereParams, context);
} }
/**
* @deprecated Since 7.2M1. Use specific rendering/parsing options for the content type you want to parse/render.
*/
@Deprecated
public String parseContent(String content, XWikiContext xcontext) public String parseContent(String content, XWikiContext xcontext)
{ {
return getOldRendering().parseContent(content, xcontext); return getOldRendering().parseContent(content, xcontext);
......
...@@ -800,7 +800,9 @@ public List<Document> wrapDocs(List<?> docs) ...@@ -800,7 +800,9 @@ public List<Document> wrapDocs(List<?> docs)
* *
* @param content * @param content
* @return evaluated content if the content contains velocity scripts * @return evaluated content if the content contains velocity scripts
* @deprecated Since 7.2M1. Use specific rendering/parsing options for the content type you want to parse/render.
*/ */
@Deprecated
public String parseContent(String content) public String parseContent(String content)
{ {
return this.xwiki.parseContent(content, getXWikiContext()); return this.xwiki.parseContent(content, getXWikiContext());
......
...@@ -190,7 +190,7 @@ $xwiki.getUserName("xwiki:${username}") ...@@ -190,7 +190,7 @@ $xwiki.getUserName("xwiki:${username}")
#else #else
</li> </li>
#end #end
<li class="tocEntry"><a href="#$tocEntry.key">$!tocEntry.value.numbering $xwiki.parseContent($tocEntry.value.text)</a> <li class="tocEntry"><a href="#$tocEntry.key">$!tocEntry.value.numbering #evaluate($tocEntry.value.text)</a>
#set ($lastLevel = $level) #set ($lastLevel = $level)
#set($openeditem = true) #set($openeditem = true)
#end #end
......
...@@ -91,7 +91,8 @@ ...@@ -91,7 +91,8 @@
#set ($fullMessage = $xwiki.getDocument('XWiki.SharePage').getObject('XWiki.Mail', 'language', $xcontext.language, true).getProperty('html').value) #set ($fullMessage = $xwiki.getDocument('XWiki.SharePage').getObject('XWiki.Mail', 'language', $xcontext.language, true).getProperty('html').value)
#set ($fullMessage = $fullMessage.replace('${recipientName}', $services.localization.render('core.viewers.share.recipientPlaceholder'))) #set ($fullMessage = $fullMessage.replace('${recipientName}', $services.localization.render('core.viewers.share.recipientPlaceholder')))
#set ($fullMessage = $fullMessage.replaceAll('<pre[^>]*+>[^<]*+</pre>', $message)) #set ($fullMessage = $fullMessage.replaceAll('<pre[^>]*+>[^<]*+</pre>', $message))
#set ($fullMessage = $xwiki.parseContent($fullMessage)) ## Evaluate the template's content since it contains Velocity code.
#set ($fullMessage = "#evaluate($fullMessage)")
<dt><label for="message">$services.localization.render('core.viewers.share.messagePreviewLabel')</label></dt> <dt><label for="message">$services.localization.render('core.viewers.share.messagePreviewLabel')</label></dt>
<dd class='mail-preview'>$fullMessage</dd> <dd class='mail-preview'>$fullMessage</dd>
......
...@@ -106,7 +106,7 @@ ...@@ -106,7 +106,7 @@
#end #end
#set ($skin = $xwiki.getSkin()) #set ($skin = $xwiki.getSkin())
## Compute the copyright and evaluate its content with Velocity to allow users to put some scripts inside ## Compute the copyright and evaluate its content with Velocity to allow users to put some scripts inside
#set ($copyright = $xwiki.parseContent($xwiki.getSpaceCopyright())) #set ($copyright = "#evaluate($xwiki.getSpaceCopyright())")
#set ($xwikimode = $xcontext.getMode()) #set ($xwikimode = $xcontext.getMode())
#set ($logredir = $escapetool.xml($xwiki.relativeRequestURL)) #set ($logredir = $escapetool.xml($xwiki.relativeRequestURL))
## ##
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment