Example #1
0
        private void AddDatePickerScriptToPage()
        {
            if (!jQueryPickerEnabled)
            {
                return;
            }

            UITools.AddScript(UITools.ClientScriptConfigurations.JQueryUIPath);
            UITools.AddStyleSheetToHeader(Page.Header, UITools.ClientScriptConfigurations.jQueryCustomUICssPath);

            //add culture-specific calendar scripts only if the current culture is different than en-US
            var cc = CultureInfo.CurrentUICulture;

            if (cc.Name != "en" && cc.Name != "en-US")
            {
                var folderPath = SkinManager.Resolve(UITools.ClientScriptConfigurations.JQueryUIFolderPath);
                var minPostFix = folderPath.EndsWith("minified") ? ".min" : string.Empty;
                UITools.AddScript(RepositoryPath.Combine(folderPath, string.Format("i18n/jquery.ui.datepicker-{0}{1}.js", cc.Name, minPostFix)));
            }

            var datePickerScript = GetDatePickerScript();
            var ic = GetInnerControl() as TextBox;

            UITools.RegisterStartupScript("datepickerex_" + (ic != null ? ic.ClientID :_dateTextBox.ClientID), datePickerScript, Page);
        }
Example #2
0
        //==================================================================================== Overrides

        protected override void OnInit(EventArgs e)
        {
            UITools.AddScript(UITools.ClientScriptConfigurations.SNQueryBuilderJSPath);
            UITools.AddStyleSheetToHeader(UITools.GetHeader(), UITools.ClientScriptConfigurations.SNQueryBuilderCSSPath);

            base.OnInit(e);
        }
Example #3
0
        /// <summary>
        /// Overrided for basic settings on initialization.
        /// - textbox width, etc.
        /// </summary>
        /// <param name="e">EventArgs</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            // include jQuery for javascript
            SenseNet.Portal.UI.UITools.AddScript(SenseNet.Portal.UI.UITools.ClientScriptConfigurations.jQueryPath);
            UITools.AddStyleSheetToHeader(UITools.GetHeader(), "$skin/styles/SN.Tagging.css");

            if (RenderMode == FieldControlRenderMode.Browse)
            {
                _tbTagList.Width   = 200;
                _tbTagList.Visible = true;
                _tbTagList.Text    = String.Empty;

                //_errorLabel.Width = 200;
                //_errorLabel.Visible = true;
                //_errorLabel.Text = String.Empty;


                _tbTagList.CssClass = String.IsNullOrEmpty(CssClass) ?
                                      "sn-tags-input sn-ctrl IUTagList" : CssClass;
            }
            Controls.Add(_tbTagList);
            Controls.Add(_errorLabel);
            Controls.Add(_btnAddTag);
        }
Example #4
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public TagAdminPortlet()
 {
     Name        = "$TagAdminPortlet:PortletDisplayName";
     Description = "$TagAdminPortlet:PortletDescription";
     Category    = new PortletCategory(PortletCategoryType.Application);
     Tags        = "/Root/System/Tags";
     UITools.AddStyleSheetToHeader(UITools.GetHeader(), "$skin/styles/SN.Tagging.css");
 }
Example #5
0
 /// <summary>
 /// Default constructor.
 /// </summary>
 public TagAdminPortlet()
 {
     Name        = "Tag admin";
     Description = "Portlet for administrating tags";
     Category    = new PortletCategory(PortletCategoryType.Application);
     Tags        = "/Root/System/Tags";
     UITools.AddStyleSheetToHeader(UITools.GetHeader(), "$skin/styles/SN.Tagging.css");
 }
        //================================================================================= Overrides

        protected override void OnPreRender(EventArgs e)
        {
            //we need to place this here, because editor parts are only rendered,
            //not added as controls, so OnInit is not executed!
            UITools.AddScript(UITools.ClientScriptConfigurations.SNQueryBuilderJSPath);
            UITools.AddStyleSheetToHeader(UITools.GetHeader(), UITools.ClientScriptConfigurations.SNQueryBuilderCSSPath);

            base.OnPreRender(e);
        }
 /* ========================================================================================= Methods */
 protected override void OnInit(EventArgs e)
 {
     base.OnInit(e);
     if (!IsNewSkin)
     {
         UITools.AddScript("$skin/scripts/sn/SN.AllowedChildTypes.js");
         UITools.AddStyleSheetToHeader(UITools.GetHeader(), "$skin/styles/icons.css");
     }
 }
Example #8
0
        /// <summary>
        /// Overrided method for initalize the content view, get the searched tag's name and the search result.
        /// </summary>
        /// <param name="e">Event arguments</param>
        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);
            tbTagSearch.Text             = LastSearchedTag;
            TagSearchListView.DataSource = Results;
            TagSearchListView.DataBind();

            Portal.UI.UITools.AddScript(Portal.UI.UITools.ClientScriptConfigurations.jQueryPath);
            UITools.AddStyleSheetToHeader(UITools.GetHeader(), "$skin/styles/SN.Tagging.css");
        }
Example #9
0
        // Events /////////////////////////////////////////////////////////////////
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            UITools.AddScript(UITools.ClientScriptConfigurations.SwfUploadPath);
            UITools.AddScript(UITools.ClientScriptConfigurations.SwfObjectPath);

            // add widgetcss: this contains z-index style settings to bring forward swf object button and push backward fake uploadbutton
            UITools.AddStyleSheetToHeader(Page.Header, UITools.ClientScriptConfigurations.SNWidgetsCss, 100);

            _allowedTypes = GetAllowedTypes();
        }
Example #10
0
        /* ========================================================================= Methods */

        protected override void OnInit(EventArgs e)
        {
            base.OnInit(e);

            if (string.IsNullOrEmpty(this.Path))
            {
                return;
            }

            UITools.AddStyleSheetToHeader(UITools.GetHeader(), this.Path, this.Order, this.Rel, this.Type, this.Media, this.Title, this.AllowBundling);
        }
Example #11
0
        protected override void OnInit(EventArgs e)
        {
            UITools.AddScript(UITools.ClientScriptConfigurations.SNQueryBuilderJSPath);

            if (SkinManager.IsNewSkin())
            {
                UITools.AddStyleSheetToHeader(UITools.GetHeader(), UITools.ClientScriptConfigurations.SNQueryBuilderNewCSSPath);
            }
            else
            {
                UITools.AddStyleSheetToHeader(UITools.GetHeader(), UITools.ClientScriptConfigurations.SNQueryBuilderCSSPath);
            }

            base.OnInit(e);
        }
Example #12
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load"/> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            if (!IsVisible)
            {
                base.OnLoad(e);
                return;
            }

            UITools.AddStyleSheetToHeader(Page.Header, UITools.ClientScriptConfigurations.IconsCssPath);
            UITools.AddStyleSheetToHeader(Page.Header, UITools.ClientScriptConfigurations.jQueryCustomUICssPath);
            UITools.AddStyleSheetToHeader(Page.Header, UITools.ClientScriptConfigurations.SNWidgetsCss, 100);
            UITools.AddPickerCss();

            UITools.AddScript(UITools.ClientScriptConfigurations.SNPortalRemoteControlPath);

            base.OnLoad(e);

            InitializeControl();
        }
Example #13
0
        private static void OnPreRenderComplete(object sender, EventArgs args)
        {
            // Add a link tag for every CSS bundle in the current PortalContext

            var header = ((System.Web.UI.Page)sender).Header;

            foreach (var bundle in Current.CssBundles)
            {
                // Also adding it to the bundle handler
                bundle.Close();
                BundleHandler.AddBundleIfNotThere(bundle);
                ThreadPool.QueueUserWorkItem(x => BundleHandler.AddBundleToCache(bundle));

                if (BundleHandler.IsBundleInCache(bundle))
                {
                    var cssLink = new HtmlLink();

                    cssLink.Href = "/" + BundleHandler.UrlPart + "/" + bundle.FakeFilename;
                    cssLink.Attributes["rel"]   = "stylesheet";
                    cssLink.Attributes["type"]  = bundle.MimeType;
                    cssLink.Attributes["media"] = bundle.Media;

                    header.Controls.Add(cssLink);
                }
                else
                {
                    // The bundle will be complete in a few seconds; disallow caching the page until then
                    HttpHeaderTools.SetCacheControlHeaders(httpCacheability: HttpCacheability.NoCache);

                    foreach (var path in bundle.Paths)
                    {
                        UITools.AddStyleSheetToHeader(header, path, 0, "stylesheet", bundle.MimeType, bundle.Media, string.Empty, false);
                    }
                }

                foreach (var postponedPath in bundle.PostponedPaths)
                {
                    UITools.AddStyleSheetToHeader(header, postponedPath, 0, "stylesheet", bundle.MimeType, bundle.Media, string.Empty, false);
                }
            }
        }
Example #14
0
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            UITools.AddStyleSheetToHeader(UITools.GetHeader(), "$skin/styles/SN.Rating.css");
            UITools.AddScript("$skin/scripts/sn/SN.Rating.js");
            if (Enable)
            {
                if (ValidateParams())
                {
                    switch (Mode)
                    {
                    case RateControlMode.Admin:
                        BuildAdminMode();
                        break;

                    case RateControlMode.Normal:
                        BuildNormalMode();
                        break;

                    case RateControlMode.ReadOnly:
                        BuildReadOnlyMode();
                        break;

                    default:
                        throw new NotSupportedException("Not supported this mode");
                    }
                }
                else
                {
                    BuildErrorParams();
                }
            }
            else
            {
                BuildEmptyMode();
            }
            this.ChildControlsCreated = true;
        }
Example #15
0
        private void AddCachedReferences()
        {
            if (!Cacheable)
            {
                return;
            }

            var cachedData = OutputCache.GetCachedData(GetCacheKey());

            if (cachedData == null)
            {
                return;
            }

            if (cachedData.ScriptReferences != null)
            {
                // add all cached script references
                foreach (var reference in cachedData.ScriptReferences)
                {
                    UITools.AddScript(reference);
                }
            }

            if (cachedData.StyleSheetReferences != null)
            {
                var header = UITools.GetHeader();

                // add all cached stylesheet references
                foreach (var reference in cachedData.StyleSheetReferences)
                {
                    UITools.AddStyleSheetToHeader(header, reference.CssPath, reference.Order, reference.Rel,
                                                  reference.Type, reference.Media, reference.Title,
                                                  reference.AllowBundlingIfEnabled);
                }
            }
        }
Example #16
0
        private void RenderScriptReferences()
        {
            var           smartList       = SmartLoader.GetScriptsToLoad();
            var           allowJsBundling = PortalContext.Current.BundleOptions.AllowJsBundling;
            JsBundle      bundle          = null;
            List <string> postponedList   = null;

            if (allowJsBundling)
            {
                bundle        = new JsBundle();
                postponedList = new List <string>();
            }

            foreach (var spath in smartList)
            {
                var lower = spath.ToLower();

                if (lower.EndsWith(".css"))
                {
                    UITools.AddStyleSheetToHeader(UITools.GetHeader(), spath);
                }
                else
                {
                    if (allowJsBundling)
                    {
                        // If bundling is allowed, add the path to the bundle - if it is not blacklisted
                        if (PortalBundleOptions.JsIsBlacklisted(spath))
                        {
                            postponedList.Add(spath);
                        }
                        else
                        {
                            bundle.AddPath(spath);
                        }
                    }
                    else
                    {
                        // If bundling is disabled, fall back to the old behaviour
                        var sref = new ScriptReference(spath);
                        Scripts.Add(sref);
                    }
                }
            }

            if (allowJsBundling)
            {
                // If bundling is allowed, closing the bundle and adding it as a single script reference
                bundle.Close();
                BundleHandler.AddBundleIfNotThere(bundle);
                ThreadPool.QueueUserWorkItem(x => BundleHandler.AddBundleToCache(bundle));

                if (BundleHandler.IsBundleInCache(bundle))
                {
                    // If the bundle is complete, add it as a single script reference
                    var sref = new ScriptReference("/sn-bundles/" + bundle.FakeFilename);
                    Scripts.Add(sref);
                }
                else
                {
                    // The bundle will be complete in a few seconds; disallow caching the page until then
                    this.Page.Response.Cache.SetCacheability(HttpCacheability.NoCache);

                    // Fallback to adding every script again as separate script references
                    foreach (var path in bundle.Paths)
                    {
                        var sref = new ScriptReference(path);
                        Scripts.Add(sref);
                    }
                }

                //add blacklisted js path's to the script collection individually
                foreach (var path in postponedList)
                {
                    Scripts.Add(new ScriptReference(path));
                }
            }
        }
Example #17
0
        private void RenderScriptReferences()
        {
            // Get scripts that are added by the framework
            var frameworkScriptPaths = GetFrameworkScripts();

            // Construct smart list
            var smartList = new List <string>();

            // Hard-code WebForms.js - it will be rendered here, and not in Page (like by default)
            smartList.Add(GetUrl(new ScriptReference(this.Page.ClientScript.GetWebResourceUrl(typeof(System.Web.UI.Page), "WebForms.js"))));
            // Add scripts needed by the framework
            smartList.AddRange(frameworkScriptPaths);
            // Add scripts previously added to this control
            smartList.AddRange(this.Scripts.Select(s => GetUrl(s)));
            // Add scripts from the smart loader
            smartList.AddRange(SmartLoader.GetScriptsToLoad());

            // Clear previous scripts (they are now part of smartList)
            Scripts.Clear();

            // Initialize bundling
            var allowJsBundling = PortalContext.Current.BundleOptions.AllowJsBundling;
            var bundle          = allowJsBundling ? new JsBundle() : null;

            // Go through all scripts
            foreach (var spath in smartList)
            {
                var lower = spath.ToLower();

                if (lower.EndsWith(".css"))
                {
                    UITools.AddStyleSheetToHeader(UITools.GetHeader(), spath);
                }
                else
                {
                    var isPostponed       = PortalBundleOptions.JsIsBlacklisted(spath);
                    var isFrameworkScript = frameworkScriptPaths.Contains(spath);

                    if (isPostponed)
                    {
                        _postponedList.Add(spath);
                    }
                    if (allowJsBundling && !isPostponed)
                    {
                        bundle.AddPath(spath);
                    }
                    if (!isPostponed && !isFrameworkScript)
                    {
                        Scripts.Add(new ScriptReference(spath));
                    }
                }
            }

            // Go through postponed scripts
            foreach (var spath in _postponedList)
            {
                Scripts.Add(new ScriptReference(spath));
            }

            // NOTE: At this point, script order is the following:
            // 1) scripts added by the framework
            // 2) scripts added directly to this control
            // 3) scripts from SmartLoader (that are not blacklisted from bundling)
            // 4) scripts from SmartLoader (that are blacklisted from bundling)

            // Finalize bundling
            if (allowJsBundling)
            {
                // If bundling is allowed, close the bundle and process it
                bundle.Close();
                BundleHandler.AddBundleIfNotThere(bundle);
                ThreadPool.QueueUserWorkItem(x => BundleHandler.AddBundleToCache(bundle));

                if (BundleHandler.IsBundleInCache(bundle))
                {
                    // If the bundle is complete, use its path to replace the path of all the scripts that are not postponed
                    _bundle = bundle;
                }
            }
        }
Example #18
0
        protected override void OnPreRender(EventArgs e)
        {
            UITools.AddStyleSheetToHeader(UITools.GetHeader(), "$skin/styles/SN.Tagging.css");
            using (var traceOperation = Logger.TraceOperation("TagCloudPortlet.OnPreRender: ", this.Name))
            {
                base.OnPreRender(e);
                //if cached return
                if (Cacheable && CanCache && IsInCache)
                {
                    //System.Diagnostics.Trace.WriteLine(this.ID + " OnPreRender END - Portlet cached.");
                    return;
                }

                char[] splitchars       = { ',' };
                var    contentTypeArray = ContentTypes.Split(splitchars, StringSplitOptions.RemoveEmptyEntries);
                var    searchPathArray  = !string.IsNullOrEmpty(SearchPaths)
                                          ? SearchPaths.ToLower().Split(splitchars, StringSplitOptions.RemoveEmptyEntries)
                                          : (ContextNode == null ? new string[0] : new[] { ContextNode.Path.ToLower() });
                var allTypes = new List <string>();

                foreach (var type in contentTypeArray)
                {
                    allTypes.Add(type.ToLower());

                    if (IncludeChildren) //if all descendant types are needed
                    {
                        var baseType = ContentType.GetByName(type);
                        if (baseType != null)
                        {
                            foreach (var childType in ContentType.GetContentTypes())
                            {
                                if (childType.IsDescendantOf(baseType))
                                {
                                    allTypes.Add(childType.Name.ToLower());
                                }
                            }
                        }
                    }
                }

                var ctrl = Page.LoadControl(contentViewPath) as TagCloudControl;
                if (ctrl != null)
                {
                    var repeater = ctrl.FindControl("TagCloudRepeater") as System.Web.UI.WebControls.Repeater;
                    if (repeater != null)
                    {
                        if (allTypes.Count == 0 && searchPathArray.Count() == 0)
                        {
                            repeater.DataSource = TagManager.GetTagClasses(MaxCount);
                        }
                        else
                        {
                            repeater.DataSource = TagManager.GetTagClasses(searchPathArray, allTypes.ToArray(), MaxCount);
                        }
                        ctrl.SearchPortletPath = SearchPortletPath;
                        repeater.DataBind();
                    }

                    Controls.Add(ctrl);
                }
                else
                {
                    Controls.Add(new LiteralControl("ContentView error."));
                }
                traceOperation.IsSuccessful = true;
            }
        }
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.PreRender"/> event.
        /// </summary>
        /// <param name="e">An <see cref="T:System.EventArgs"/> object that contains the event data.</param>
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);

            UITools.AddStyleSheetToHeader(UITools.GetHeader(), "$skin/styles/sn-calendar.css");

            var myNodeList = new List <MyCalendarEvent>();

            foreach (DateTime selectedDate in MyCalendar.SelectedDates)
            {
                foreach (var item in CalendarEvents)
                {
                    var myNewEvent = new MyCalendarEvent
                    {
                        EventText         = "",
                        Registering       = 2,
                        BrowseContentPath = item.Path
                    };

                    var      eventStartDate = Convert.ToDateTime(item["StartDate"]);
                    var      eventEndDate   = Convert.ToDateTime(item["EndDate"]);
                    DateTime startDate;
                    DateTime endDate;

                    if (!(eventStartDate <= selectedDate))
                    {
                        startDate = Convert.ToDateTime(item["StartDate"]);
                        startDate = new DateTime(startDate.Year, startDate.Month, startDate.Day, 0, 0, 0);

                        endDate = Convert.ToDateTime(item["EndDate"]);
                        endDate = new DateTime(endDate.Year, endDate.Month, endDate.Day, 23, 59, 59);

                        eventStartDate = startDate;
                        eventEndDate   = endDate;
                    }

                    if (eventStartDate <= selectedDate && selectedDate <= eventEndDate)
                    {
                        var    numParticipants = GetNumberOfParticipants(item);
                        var    maxParticipants = Convert.ToInt32(item["MaxParticipants"]);
                        string regItemPath;
                        var    isSubscribed = IsUserAlreadySubscribed(item, out regItemPath);

                        if (Convert.ToBoolean(item["RequiresRegistration"]))
                        {
                            // Registration needed
                            // Participant text defines the avalaible free spaces for the event
                            var partText = String.Format(SenseNetResourceManager.Current.GetString("EventCalendar", "ParticipantsText"),
                                                         maxParticipants - numParticipants,
                                                         maxParticipants);

                            myNewEvent.ParticipantText = partText;

                            if (maxParticipants > numParticipants)
                            {
                                if (isSubscribed)
                                {
                                    myNewEvent.Registering = 1;
                                    myNewEvent.EventText   = SenseNetResourceManager.Current.GetString("EventCalendar", "AlreadyApplied");

                                    // Unregister URL
                                    myNewEvent.BrowseContentPath = regItemPath;
                                }
                                else
                                {
                                    myNewEvent.Registering = 0;
                                    myNewEvent.EventText   = SenseNetResourceManager.Current.GetString("EventCalendar", "ApplyText");

                                    // Register URL
                                    myNewEvent.BrowseContentPath = ((CalendarEvent)item).RegistrationForm.Path;
                                }
                            }
                            else if (numParticipants == maxParticipants)
                            {
                                myNewEvent.Registering = 3;
                                myNewEvent.EventText   = SenseNetResourceManager.Current.GetString("EventCalendar", "FullEventText");
                                if (isSubscribed)
                                {
                                    myNewEvent.Visible = true;

                                    // Unregister URL
                                    myNewEvent.BrowseContentPath = regItemPath;
                                }
                                else
                                {
                                    myNewEvent.Visible = false;
                                }
                            }
                        }
                        else
                        {
                            // Don't need registration
                            myNewEvent.EventText = SenseNetResourceManager.Current.GetString("EventCalendar", "DontNeedRegistration");
                        }
                        if (!(myNodeList.Any(i => i.RelatedNode.Id == item.Id)))
                        {
                            myNewEvent.RelatedNode = item;
                            myNodeList.Add(myNewEvent);
                        }
                    }
                }
            }

            CalendarEventResult.DataSource = myNodeList;
            this.DataBind();
        }
Example #20
0
        public static XslTransformExecutionContext GetXslt(string nodePath, bool resolveScripts)
        {
            string nodeKey = "xslt:" + nodePath;

            XslTransformExecutionContext context = (XslTransformExecutionContext)(Cache.Get(nodeKey));

            if (context == null)
            {
                context = new XslTransformExecutionContext();

                context.XslCompiledTransform = new XslCompiledTransform(Debugger.IsAttached);
                RepositoryPathResolver resolver = new RepositoryPathResolver();

                try
                {
                    context.XslCompiledTransform.Load(nodePath, XsltSettings.Default, resolver);
                }
                catch (NullReferenceException e) // rethrow
                {
                    throw new NullReferenceException(e.Message + "<br/>" + nodePath + " (or include)");
                }

                AggregateCacheDependency aggregatedDependency = new AggregateCacheDependency();

                context.NamespaceExtensions    = resolver.ImportNamespaceCollection.Distinct().ToArray();
                context.ImportScriptCollection = resolver.ImportScriptCollection;
                context.ImportCssCollection    = resolver.ImportCssCollection;

                foreach (var dependencyPath in resolver.DependencyPathCollection)
                {
                    // Create an aggregate cache dependeny that includes NodeId, Path, NodeTypeId
                    // Our cache item will be invalidated if the dependency node is invalidated
                    //  - by node id
                    //  - by path
                    //  - by nodeType

                    string fsFilePath = null;
                    if (HttpContext.Current != null &&
                        WebApplication.DiskFSSupportMode == DiskFSSupportMode.Prefer)
                    {
                        fsFilePath = HttpContext.Current.Server.MapPath(dependencyPath);
                    }
                    if (!string.IsNullOrEmpty(fsFilePath) && System.IO.File.Exists(fsFilePath))
                    {
                        SnTrace.Repository.Write("Cannot create cache dependency for a filesystem entry: {0}", fsFilePath);
                    }
                    else
                    {
                        var nodeHead = NodeHead.Get(dependencyPath);
                        aggregatedDependency.Add(
                            new PathDependency(nodeHead.Path),
                            new NodeIdDependency(nodeHead.Id),
                            new NodeTypeDependency(nodeHead.NodeTypeId)
                            );
                    }
                }

                Cache.Insert(nodeKey, context, aggregatedDependency);
            }

            if (resolveScripts)
            {
                foreach (var script in context.ImportScriptCollection)
                {
                    UITools.AddScript(script);
                }
                foreach (var css in context.ImportCssCollection)
                {
                    UITools.AddStyleSheetToHeader(UITools.GetHeader(), css);
                }
            }

            return(context);
        }