public ResponseFilterInplaceViewStream(Stream responseStream, TranslatorHelper.TranslatorHelper translatorHelper, string languageCode, string siteUrl)
 {
     _responseStream   = responseStream;
     _translatorHelper = translatorHelper;
     _languageCode     = languageCode;
     _siteUrl          = siteUrl;
 }
 public HttpApplicationEvents(TranslatorHelper.TranslatorHelper translatorHelper, License license, IAutomaticTranslation automaticTranslationPlugin)
 {
     _license = license;
     _automaticTranslationPlugin   = automaticTranslationPlugin;
     _translatorHelper             = translatorHelper;
     _debugTranslatorHelper        = new DebugTranslatorHelper(_translatorHelper);
     _currentTranslatorHelperToUse = _translatorHelper;
 }
 public ResponseFilterGenericStream(Stream inputStream, TranslatorHelper.TranslatorHelper translatorHelper, string languageCode, bool pageToTranslate, bool viewAllItemsInEveryLanguages, bool completingDictionaryMode, int extractorStatus, string url, int autoCompletionStatus, bool mobilePage, License.LicenseType licenseType)
 {
     _responseStream               = inputStream;
     _translatorHelper             = translatorHelper;
     _languageCode                 = languageCode;
     _pageToTranslate              = pageToTranslate;
     _viewAllItemsInEveryLanguages = viewAllItemsInEveryLanguages;
     _completingDictionaryMode     = completingDictionaryMode;
     _extractorStatus              = extractorStatus;
     _url = url;
     _autoCompletionStatus = autoCompletionStatus;
     _mobilePage           = mobilePage;
     _licenseType          = licenseType;
 }
        public void ContextBeginRequest(object sender, EventArgs e)
        {
            try
            {
                HttpContext context = ((HttpApplication)sender).Context;

                // Store the time of request beginning
                if (context == null)
                {
                    return;
                }

                HttpContext.Current.Items[OceanikITranslator] = _currentTranslatorHelperToUse;

                if (!HttpContext.Current.Request.Path.EndsWith("/") && HttpContext.Current.Request.Path.EndsWith(".aspx", StringComparison.OrdinalIgnoreCase))
                {
                    string resultDebugHtml = HttpContext.Current.Request.QueryString["SPS_Debug_Html"];

                    if (!string.IsNullOrEmpty(resultDebugHtml))
                    {
                        _currentTranslatorHelperToUse = resultDebugHtml.Equals("true", StringComparison.OrdinalIgnoreCase) ? _debugTranslatorHelper : _translatorHelper;
                    }

                    if (HttpContext.Current.Request.Path.Contains("/_layouts/inplview.aspx") && !HttpContext.Current.Items.Contains(ContextKey))
                    {
                        string languageCode   = Utilities.GetLanguageCode(context);
                        string currentSiteUrl = context.Request.Url.AbsoluteUri.Replace(context.Request.Url.PathAndQuery, string.Empty);

                        HttpResponse response = HttpContext.Current.Response;
                        response.Filter = new ResponseFilterInplaceViewStream(response.Filter, _currentTranslatorHelperToUse, languageCode, currentSiteUrl);
                        HttpContext.Current.Items.Add(ContextKey, new object());

                        return;
                    }
                }
            }
            catch (Exception ex)
            {
                Utilities.LogException("Error in Oceanik.HttpApplicationEvents.Context_BeginRequest: " + ex.Message, EventLogEntryType.Warning);
            }
        }