Skip to content

Commit

Permalink
fixed issue with opening document from subsite
Browse files Browse the repository at this point in the history
  • Loading branch information
NikolayRechkin committed Feb 21, 2018
1 parent 1c5d8d6 commit b0adb52
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 11 deletions.
4 changes: 2 additions & 2 deletions ONLYOFFICE/Layouts/Onlyoffice/CallbackHandler.ashx.cs
Expand Up @@ -50,8 +50,8 @@ public void ProcessRequest(HttpContext context)
SPListItemId = "",
SPListURLDir = "",
Folder = "",
url = HttpUtility.HtmlEncode(HttpContext.Current.Request.Url.Scheme) + "://" + HttpContext.Current.Request.Url.Authority;

url = HttpUtility.HtmlEncode(HttpContext.Current.Request.Url.Scheme) + "://" + HttpContext.Current.Request.Url.Authority +
HttpContext.Current.Request.RawUrl.Substring(0, HttpContext.Current.Request.RawUrl.IndexOf("_layouts"));
//get secret key
SPSecurity.RunWithElevatedPrivileges(delegate()
{
Expand Down
4 changes: 2 additions & 2 deletions ONLYOFFICE/Layouts/Onlyoffice/Settings.aspx.cs
Expand Up @@ -36,8 +36,8 @@ namespace Onlyoffice.Layouts
public partial class Settings : LayoutsPageBase
{
protected string path = AppDomain.CurrentDomain.BaseDirectory;
protected string url = HttpUtility.HtmlEncode(HttpContext.Current.Request.Url.Scheme) + "://" + HttpContext.Current.Request.Url.Authority;

protected string url = HttpUtility.HtmlEncode(HttpContext.Current.Request.Url.Scheme) + "://" + HttpContext.Current.Request.Url.Authority +
HttpContext.Current.Request.RawUrl.Substring(0, HttpContext.Current.Request.RawUrl.IndexOf("_layouts"));
protected void Page_Load(object sender, EventArgs e)
{
DocumentServerTitle.Text = Microsoft.SharePoint.Utilities.SPUtility.GetLocalizedString("$Resources:Resource,DocumentServer", "core", (uint)SPContext.Current.Web.UICulture.LCID);
Expand Down
8 changes: 4 additions & 4 deletions ONLYOFFICE/Layouts/Onlyoffice/editorPage.aspx.cs
Expand Up @@ -61,9 +61,9 @@ public partial class editorPage : LayoutsPageBase
CurrentUserLogin = "",
SPListItemId, SPListURLDir, SPSource, SPListId, Folder, Secret,
DocumentSeverHost = "@http://localhost",
host = HttpContext.Current.Request.Url.Host,
SPUrl = HttpUtility.HtmlEncode(HttpContext.Current.Request.Url.Scheme) + "://" + HttpContext.Current.Request.Url.Authority,

host = HttpUtility.HtmlEncode(HttpContext.Current.Request.Url.Scheme) + "://" + HttpContext.Current.Request.Url.Authority,
SPUrl = HttpUtility.HtmlEncode(HttpContext.Current.Request.Url.Scheme) + "://" + HttpContext.Current.Request.Url.Authority +
HttpContext.Current.Request.RawUrl.Substring(0, HttpContext.Current.Request.RawUrl.IndexOf("_layouts")),
SPVersion = SPFarm.Local.BuildVersion.Major == 14 ? "": "15/";

protected int CurrentUserId = 0;
Expand Down Expand Up @@ -167,7 +167,7 @@ protected void Page_Load(object sender, EventArgs e)

Folder = Path.GetDirectoryName(file.ServerRelativeUrl);
Folder = Folder.Replace("\\", "/");
GoToBack = SPUrl + Folder;
GoToBack = host + Folder;

FileAuthor = file.Author.Name;

Expand Down
9 changes: 8 additions & 1 deletion ONLYOFFICE/MenuAction/Elements.xml
Expand Up @@ -12,7 +12,14 @@
Start the URL with the token ~remoteAppUrl if the page is in the
associated web project, use ~appWebUrl if page is in the app project.
-->
<UrlAction Url="javascript:window.open(_spPageContextInfo.webServerRelativeUrl + '_layouts/Onlyoffice/editorPage.aspx?SPListItemId={ItemId}&amp;SPListURLDir={ListUrlDir}&amp;action=track')" />
<UrlAction Url="javascript:
var url = '';
if(_spPageContextInfo.webServerRelativeUrl.substr(_spPageContextInfo.webServerRelativeUrl.length - 1) != '/')
url = _spPageContextInfo.webServerRelativeUrl + '/';
else
url = _spPageContextInfo.webServerRelativeUrl;
window.open(url + '_layouts/Onlyoffice/editorPage.aspx?SPListItemId={ItemId}&amp;SPListURLDir={ListUrlDir}&amp;action=track');
" />

</CustomAction>
</Elements>
12 changes: 11 additions & 1 deletion ONLYOFFICE/RibbonAction/Elements.xml
Expand Up @@ -27,7 +27,17 @@
</CommandUIDefinitions>
<CommandUIHandlers>
<CommandUIHandler Command="Invoke_RibbonAction"
CommandAction="javascript:window.open(_spPageContextInfo.webServerRelativeUrl + '_layouts/Onlyoffice/editorPage.aspx?SPListItemId={SelectedItemId}&amp;SPListId={SelectedListId}&amp;SPSource={Source}&amp;SPListURLDir={ListUrlDir}&amp;action=download')"
CommandAction="javascript:
var url = '', listUrl = '';
if(_spPageContextInfo.webServerRelativeUrl.substr(_spPageContextInfo.webServerRelativeUrl.length - 1) != '/'){
url = _spPageContextInfo.webServerRelativeUrl + '/'; //if subsite
listUrl = _spPageContextInfo.webServerRelativeUrl + '/';
}
else{
url = _spPageContextInfo.webServerRelativeUrl;
}
window.open(url + '_layouts/Onlyoffice/editorPage.aspx?SPListItemId={SelectedItemId}&amp;SPListId={SelectedListId}&amp;SPSource={Source}&amp;SPListURLDir='+escape(listUrl)+'{ListUrlDir}&amp;action=download');
"
EnabledScript="javascript:
function enableONLYOFFICEButton() {
var items = SP.ListOperation.Selection.getSelectedItems();
Expand Down
2 changes: 1 addition & 1 deletion ONLYOFFICE/SettingAction/Elements.xml
Expand Up @@ -6,6 +6,6 @@
Sequence="1000"
Title="$Resources:Resource,Settings"
Rights="ManageWeb">
<UrlAction Url="/_layouts/Onlyoffice/Settings.aspx"/>
<UrlAction Url="~site/_layouts/Onlyoffice/Settings.aspx"/>
</CustomAction>
</Elements>

0 comments on commit b0adb52

Please sign in to comment.