protected void ShowTags(string notFoundTag)
        {
            ClientPipelineArgs args = ContinuationManager.Current.CurrentArgs as ClientPipelineArgs;

            if (args.IsPostBack)
            {
                if (args.HasResult && args.Result != "undefined")
                {
                    Database db           = Sitecore.Context.ContentDatabase ?? Sitecore.Context.Database;
                    Item     categoryItem = db.GetItem(new ID(args.Result));
                    string   tagValue     = GetCategoryName(categoryItem);
                    string   tagId        = categoryItem.ID.ToString();
                    SheerResponse.Eval("SetTag('{0}','{1}')", tagValue, tagId);
                }
            }
            else
            {
                UrlString url =
                    new UrlString(
                        ControlManager.GetControlUrl(new ControlName("Sitecore.Shell.Applications.Taxonomy.Dialogs.TagBrowser")));
                UrlHandle currentHandle = UrlHandle.Get();
                UrlHandle handle        = new UrlHandle();
                handle["tagNotFound"]      = notFoundTag;
                handle["categoriesRootId"] = currentHandle["categoriesRootId"];
                handle.Add(url);
                SheerResponse.ShowModalDialog(url.ToString(), "650px", "600px", string.Empty, true);
                args.WaitForPostBack();
            }
        }
Beispiel #2
0
        protected void createTag_Click()
        {
            string parentPath            = newTagParentLiteral.Text;
            string categoryName          = categoryNameEdit.Text;
            string categoryWeight        = categoryWeightEdit.Value.ToString();
            string categoryParentRelated = categoryRelatedToParentEdit.Value.ToString();
            string categoryChildRelated  = categoryRelatedToChildEdit.Value.ToString();

            if (string.IsNullOrEmpty(parentPath) ||
                string.IsNullOrEmpty(categoryName) ||
                string.IsNullOrEmpty(categoryWeight) ||
                string.IsNullOrEmpty(categoryParentRelated) ||
                string.IsNullOrEmpty(categoryChildRelated))
            {
                SheerResponse.Alert("You need to fill all the fields and select parent category/group to create new category.");
                return;
            }

            Database  db       = Sitecore.Context.ContentDatabase ?? Sitecore.Context.Database;
            UrlHandle handle   = UrlHandle.Get();
            Item      rootItem = db.GetItem(new ID(handle["categoriesRootId"]));

            parentPath = rootItem.Paths.Path + parentPath;
            Item parentItem      = db.GetItem(parentPath);
            Item newCategoryItem = parentItem.Add(categoryName, new TemplateID(new ID("{FCE30413-F1D8-43F4-8B93-B51FDED4D251}")));

            using (new EditContext(newCategoryItem))
            {
                newCategoryItem[CategoryItem.Fields.Weight]              = categoryWeight;
                newCategoryItem[CategoryItem.Fields.RelatedToParent]     = categoryParentRelated;
                newCategoryItem[CategoryItem.Fields.RelatedWithChildren] = categoryChildRelated;
            }
            SheerResponse.Eval("categoryTreeview_AddNode('{0}','I{1}','{2}');", categoryName, newCategoryItem.ID.ToShortID(),
                               Images.GetThemedImageSource(newCategoryItem.Appearance.Icon, ImageDimension.id16x16));
        }
Beispiel #3
0
        protected void Node_Selected()
        {
            string selected = WebUtil.GetFormValue("categoryTreeview_Selected");

            selected = ShortID.Decode(StringUtil.Mid(selected, 1));
            if (Sitecore.Data.ID.IsID(selected))
            {
                UrlHandle handle       = UrlHandle.Get();
                Database  db           = Sitecore.Context.ContentDatabase ?? Sitecore.Context.Database;
                Item      selectedItem = db.GetItem(new ID(selected));
                Item      rootItem     = db.GetItem(new ID(handle["categoriesRootId"]));

                if (selectedItem.TemplateID.ToString() != "{A69C0097-5CE1-435B-99E9-FA2B998D1C70}")
                {
                    SheerResponse.Eval("enableButton_Ok();");
                }
                else
                {
                    SheerResponse.Eval("disableButton_Ok();");
                }

                string categoryPath = selectedItem.Paths.Path.Substring(rootItem.Paths.Path.Length);
                newTagParentLiteral.Text = string.Format("{0}", categoryPath);
                createTagBtn.Disabled    = !(selectedItem.Access.CanCreate() && selectedItem.Access.CanWrite());
            }
        }
Beispiel #4
0
        private void PopulateAvailableColumns()
        {
            var handle = UrlHandle.Get();

            var itemUri = ItemUri.Parse(handle["id"]);

            var item = Sitecore.Data.Database.GetItem(itemUri);

            if (item == null)
            {
                return;
            }

            try
            {
                var referenceItem = new ReferenceItem(item);
                var viewer        = BaseViewer.Create(referenceItem.FullType, string.Empty);
                if (viewer == null)
                {
                    return;
                }


                foreach (var availableColumn in viewer.AvailableColumns)
                {
                    ColumnName.Controls.Add(new ListItem {
                        Header = availableColumn, Value = availableColumn.ToLowerInvariant()
                    });
                }
            }
            catch (FileNotFoundException)
            {
                //todo
            }
        }
Beispiel #5
0
        public void Run(ClientPipelineArgs args)
        {
            Item item       = Database.GetItem(ItemUri.Parse(args.Parameters["uri"]));
            bool isPostBack = args.IsPostBack;

            if (isPostBack)
            {
                isPostBack = !args.HasResult;
                if (!isPostBack)
                {
                    UrlHandle       urlHandle       = UrlHandle.Get(new UrlString(string.Concat("hdl=", args.Result)), "hdl", true);
                    string          str             = urlHandle["fields"];
                    FieldDescriptor fieldDescriptor = FieldDescriptor.Parse(str);
                    string          value           = fieldDescriptor.Value;
                    item.Editing.BeginEdit();
                    item.Fields[Data.ProjectFieldId].Value = value;
                    item.Editing.EndEdit();

                    String refresh = String.Format("item:refreshchildren(id={0})", item.Parent.ID);
                    Sitecore.Context.ClientPage.SendMessage(this, refresh);
                }
            }
            else
            {
                SheerResponse.ShowModalDialog(GetOptions(args, args.Parameters).ToUrlString().ToString(), "720", "320", string.Empty, true);
                args.WaitForPostBack();
            }
        }
        /// <summary>
        /// Reads the raw value and set initial values.
        /// </summary>
        private void ReadRawValueAndSetInitValues()
        {
            bool   queryString = WebUtil.GetQueryString("hdl") != string.Empty;
            string empty       = string.Empty;

            if (queryString)
            {
                empty = UrlHandle.Get()["va"];
            }
            if (empty == string.Empty)
            {
                return;
            }
            XElement xElement = XElement.Parse(empty);

            if (InsertAnchor.GetXmlAttributeValue(xElement, "linktype") == "anchor")
            {
                this.Text.Parameters["Text"]          = InsertAnchor.GetXmlAttributeValue(xElement, "text");
                this.Style.Parameters["Text"]         = InsertAnchor.GetXmlAttributeValue(xElement, "class");
                this.Anchor.Parameters["Text"]        = InsertAnchor.GetXmlAttributeValue(xElement, "anchor");
                this.AlternateText.Parameters["Text"] = InsertAnchor.GetXmlAttributeValue(xElement, "title");

                //////////////////////////////////////////////////////// START CUSTOM BIT ////////////////////////////////////////////////////////
                this.GoalLoadedValue.Parameters["Text"]  = InsertAnchor.GetXmlAttributeValue(xElement, "goal");
                this.EventLoadedValue.Parameters["Text"] = InsertAnchor.GetXmlAttributeValue(xElement, "pageevent");
                //this.Goal.Parameters["Text"] = InsertLinkDialogTree.GetXmlAttributeValue(xElement, "goal");
                //this.Event.Parameters["Text"] = InsertLinkDialogTree.GetXmlAttributeValue(xElement, "pageevent");
                //////////////////////////////////////////////////////// END CUSTOM BIT ////////////////////////////////////////////////////////
            }
        }
        protected override void OnInit(System.EventArgs e)
        {
            UrlHandle handle          = UrlHandle.Get();
            string    categoriesValue = handle["categories"];

            categories.Value = categoriesValue.Replace(@"//", @"/");
            base.OnInit(e);
        }
        /// <summary>
        /// Raises the load event.
        /// </summary>
        /// <param name="e">
        /// The <see cref="System.EventArgs"/> instance containing the event data.
        /// </param>
        /// <remarks>
        /// This method notifies the server control that it should perform actions common to each HTTP
        /// request for the page it is associated with, such as setting up a database query. At this
        /// stage in the page lifecycle, server controls in the hierarchy are created and initialized,
        /// view state is restored, and form controls reflect client-side data. Use the IsPostBack
        /// property to determine whether the page is being loaded in response to a client postback,
        /// or if it is being loaded and accessed for the first time.
        /// </remarks>
        protected override void OnLoad([NotNull] EventArgs e)
        {
            Assert.ArgumentNotNull(e, "e");

            this.CheckSecurity();

            base.OnLoad(e);

            if (Context.ClientPage.IsEvent)
            {
                return;
            }

            var urlHandle = UrlHandle.Get();

            var icon = urlHandle["ic"];

            if (!string.IsNullOrEmpty(icon))
            {
                this.Dialog["Icon"] = icon;
            }

            var header = WebUtil.SafeEncode(urlHandle["he"]);

            if (header.Length > 0)
            {
                this.Dialog["Header"] = header;
            }

            var text = WebUtil.SafeEncode(urlHandle["txt"]);

            if (text.Length > 0)
            {
                this.Dialog["Text"] = text;
            }

            var button = WebUtil.SafeEncode(urlHandle["btn"]);

            if (button.Length > 0)
            {
                this.Dialog["OKButton"] = button;
            }

            var filter    = urlHandle["flt"];
            var blobsList = LogStorageManager.ListBlobs(filter);

            foreach (var blob in blobsList)
            {
                var item = new ListviewItem();
                this.FileLister.Controls.Add(item);
                item.ID     = Control.GetUniqueID("I");
                item.Header = blob.Uri.Segments.Last();
                item.Icon   = "Applications/16x16/document.png";
                item.ServerProperties["Blob"] = blob.Name;
                item.ColumnValues["size"]     = MainUtil.FormatSize(blob.Properties.Length);
                item.ColumnValues["modified"] = blob.Properties.LastModified.HasValue ? blob.Properties.LastModified.Value.LocalDateTime : DateTime.Now;
            }
        }
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);
            if (!Context.ClientPage.IsEvent && !Context.ClientPage.IsPostBack)
            {
                var handle = UrlHandle.Get();
                var path   = handle["path"];
                if (path == null)
                {
                    var uri  = Sitecore.Data.ItemUri.ParseQueryString(Context.ContentDatabase);
                    var item = Database.GetItem(uri);
                    if (item != null)
                    {
                        ItemUri.Attributes["value"] = item.Uri.ToString();
                    }
                }
                else
                {
                    ItemUri.Attributes["value"] = path;
                }

                Versioned.Attributes["value"]    = handle["versioned"];
                LanguageName.Attributes["value"] = handle["language"];
                Overwrite.Attributes["value"]    = handle["overwrite"];
                Unpack.Attributes["value"]       = handle["unpack"];
                var title = handle["te"];
                if (!string.IsNullOrEmpty(title))
                {
                    DialogHeader.Text = WebUtil.SafeEncode(title);
                }

                var icon = handle["ic"];
                if (!string.IsNullOrEmpty(icon))
                {
                    DialogIcon.Src     = WebUtil.SafeEncode(icon);
                    DialogIcon.Visible = true;
                }

                var message = handle["ds"];
                if (!string.IsNullOrEmpty(message))
                {
                    DialogDescription.Text = WebUtil.SafeEncode(message);
                }

                var ok = handle["ok"];
                if (!string.IsNullOrEmpty(ok))
                {
                    OKButton.Header = WebUtil.SafeEncode(ok);
                }

                var cancel = handle["cancel"];
                if (!string.IsNullOrEmpty(cancel))
                {
                    CancelButton.Header = WebUtil.SafeEncode(cancel);
                }
                TypeResolver.Resolve <IUrlHandleWrapper>().DisposeHandle(handle);
            }
        }
Beispiel #10
0
        /// <summary>
        /// Reads the root parameter and update root placeholders.
        /// </summary>
        private void ReadQueryParamsAndUpdatePlaceholders()
        {
            Item   item;
            string queryString = WebUtil.GetQueryString("ro");
            string str         = WebUtil.GetQueryString("hdl");

            if (!string.IsNullOrEmpty(queryString) && queryString != "{0}")
            {
                this.TreeView.Parameters["RootItem"] = queryString;
            }
            this.InsertAnchorButton.Parameters["Click"]   = string.Format(this.InsertAnchorButton.Parameters["Click"], WebUtility.UrlEncode(queryString), WebUtility.UrlEncode(str));
            this.InsertEmailButton.Parameters["Click"]    = string.Format(this.InsertEmailButton.Parameters["Click"], WebUtility.UrlEncode(queryString), WebUtility.UrlEncode(str));
            this.ListViewToggleButton.Parameters["Click"] = string.Format(this.ListViewToggleButton.Parameters["Click"], WebUtility.UrlEncode(queryString), WebUtility.UrlEncode(str));
            bool   empty  = str != string.Empty;
            string empty1 = string.Empty;

            if (empty)
            {
                empty1 = UrlHandle.Get()["va"];
            }
            if (empty1 == string.Empty)
            {
                return;
            }
            XElement xElement = XElement.Parse(empty1);

            if (InsertLinkDialogTree.GetXmlAttributeValue(xElement, "linktype") == "internal")
            {
                string xmlAttributeValue = InsertLinkDialogTree.GetXmlAttributeValue(xElement, "id");
                if (string.IsNullOrWhiteSpace(xmlAttributeValue))
                {
                    return;
                }
                if (string.IsNullOrEmpty(queryString))
                {
                    item = null;
                }
                else
                {
                    item = ClientHost.Databases.ContentDatabase.GetItem(queryString);
                }
                Item rootItem = item ?? ClientHost.Databases.ContentDatabase.GetRootItem();
                Item mediaItemFromQueryString = SelectMediaDialog.GetMediaItemFromQueryString(xmlAttributeValue);
                if (rootItem != null && mediaItemFromQueryString != null && mediaItemFromQueryString.Paths.LongID.StartsWith(rootItem.Paths.LongID))
                {
                    this.TreeView.Parameters["PreLoadPath"] = string.Concat(rootItem.ID, mediaItemFromQueryString.Paths.LongID.Substring(rootItem.Paths.LongID.Length));
                }
                this.TextDescription.Parameters["Text"]  = InsertLinkDialogTree.GetXmlAttributeValue(xElement, "text");
                this.AltText.Parameters["Text"]          = InsertLinkDialogTree.GetXmlAttributeValue(xElement, "title");
                this.StyleClass.Parameters["Text"]       = InsertLinkDialogTree.GetXmlAttributeValue(xElement, "class");
                this.QueryString.Parameters["Text"]      = InsertLinkDialogTree.GetXmlAttributeValue(xElement, "querystring");
                this.CustomAttributes.Parameters["Text"] = InsertLinkDialogTree.GetXmlAttributeValue(xElement, "customattributes");
                this.AnchorText.Parameters["Text"]       = InsertLinkDialogTree.GetXmlAttributeValue(xElement, "anchor");
                this.SetupTargetDropbox(xElement);
            }
        }
Beispiel #11
0
        private void SetValue(string value)
        {
            UrlHandle urlHandle  = UrlHandle.Get();
            string    itemId     = urlHandle["itemId"];
            string    fieldId    = urlHandle["fieldId"];
            string    sessionKey = string.Format("{0}_{1}_classification", itemId, fieldId);

            result.Value = value;
            WebUtil.SetSessionValue(sessionKey, value);
        }
 protected override void OnPreRender(EventArgs e)
 {
     base.OnPreRender(e);
     if (!AjaxScriptManager.IsEvent)
     {
         UrlHandle handle = UrlHandle.Get();
         Value = handle["value"];
         RenderTaxonomies();
     }
 }
        /// <summary>
        /// Gets the name of the BLOB from the specified handle.
        /// </summary>
        /// <param name="blobHandle">The blob handle.</param>
        /// <returns></returns>
        public static string GetBlobName(string blobHandle)
        {
            Assert.ArgumentNotNull(blobHandle, "blobHandle");

            var parameters = new NameValueCollection
            {
                { "blob", blobHandle }
            };

            return(UrlHandle.Get(new UrlString(parameters), "blob")["blob"]);
        }
Beispiel #14
0
        protected override void OnLoad(EventArgs e)
        {
            Assert.ArgumentNotNull(e, "e");
            base.OnLoad(e);
            UrlHandle handle = UrlHandle.Get();

            base.Header = handle["templatename"];
            var    cSharpFormat            = new CSharpFormat();
            string t4TemplateClassFormated = cSharpFormat.FormatCode(handle["class"]);

            OutputDiv.InnerHtml = t4TemplateClassFormated;
        }
Beispiel #15
0
 protected override void OnLoad(EventArgs e)
 {
     base.OnLoad(e);
     if (!Sitecore.Context.ClientPage.IsEvent)
     {
         UrlHandle urlHandle = UrlHandle.Get();
         categories.Value       = urlHandle["categories"];
         conflictcatigory.Value = urlHandle["conflictcat"];
         tagsBox.InnerHtml      = urlHandle["rendered"];
         SheerResponse.Eval("SaveResult();");
     }
 }
Beispiel #16
0
 public bool TryGetHandle(out UrlHandle handle)
 {
     try
     {
         handle = UrlHandle.Get();
     }
     catch
     {
         handle = null;
         return(false);
     }
     return(true);
 }
        protected void EditWeight(string index)
        {
            int indexValue          = Int32.Parse(index);
            ClientPipelineArgs args = ContinuationManager.Current.CurrentArgs as ClientPipelineArgs;

            if (args.IsPostBack)
            {
                if (args.HasResult && args.Result != "undefined")
                {
                    if (indexValue > -1)
                    {
                        string oldValue = CategoryWeightList[indexValue];
                        string newValue = string.Format("{0}:{1}", StringUtil.GetPrefix(oldValue, ':'), args.Result);
                        Value = Value.Replace(oldValue, newValue);
                    }
                    else
                    {
                        Value += string.Format("|{0}:{1}|", Sitecore.Data.ID.Null, args.Result);
                        Value  = Value.Replace("||", "|").Trim("|".ToCharArray());
                    }
                    this.RenderTaxonomies();
                }
            }
            else
            {
                string    weightsRootID            = "{4A36115B-6120-4EDD-B6F2-E5F0EB2678EE}";
                UrlHandle handle                   = UrlHandle.Get();
                string    sourceItemId             = handle["sourceItemId"];
                Item      classificationSourceItem = Client.ContentDatabase.GetItem(new ID(sourceItemId));
                if (classificationSourceItem != null)
                {
                    Item taxonomies = classificationSourceItem.Children["Weights"];
                    if (taxonomies != null)
                    {
                        weightsRootID = taxonomies.ID.ToString();
                    }
                }

                UrlString url = new UrlString("/sitecore/shell/Applications/Item browser.aspx");
                url.Append("ro", weightsRootID);
                url.Append("id", weightsRootID);
                url.Append("sc_content", Sitecore.Context.ContentDatabase.Name);
                //url.Append("flt", "Contains('{EB06CEC0-5E2D-4DC4-875B-01ADCC577D13},{C20ED30F-D974-4C65-AE57-CE745C37940E}', @@templateid)");
                SheerResponse.ShowModalDialog(url.ToString(), "300px", "300px", string.Empty, true);
                args.WaitForPostBack();
            }
        }
Beispiel #18
0
        protected override void OnLoad(EventArgs e)
        {
            UrlHandle handle       = UrlHandle.Get();
            string    currentValue = handle["value"];

            if (!string.IsNullOrEmpty(currentValue))
            {
                foreach (string tagValue in currentValue.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries))
                {
                    string   categoryId   = StringUtil.GetPrefix(tagValue, ':');
                    Database db           = Sitecore.Context.ContentDatabase ?? Sitecore.Context.Database;
                    Item     categoryItem = db.GetItem(new ID(categoryId));
                    string   categoryName = this.GetCategoryName(categoryItem);
                    tagsBox.InnerHtml += string.Format(
                        "<span class=\"tagSet\"><span class=\"tagId\">{0}</span>{1}</span>;", categoryId, categoryName);
                }
            }
            base.OnLoad(e);
        }
Beispiel #19
0
        private void ReadQueryParamsAndUpdatePlaceholders()
        {
            string queryString1 = WebUtil.GetQueryString("ro");
            string queryString2 = WebUtil.GetQueryString("hdl");

            if (!string.IsNullOrEmpty(queryString1) && queryString1 != "{0}")
            {
                this.TreeView.Parameters["RootItem"] = queryString1;
            }
            this.InsertAnchorButton.Parameters["Click"]   = string.Format(this.InsertAnchorButton.Parameters["Click"], (object)WebUtility.UrlEncode(queryString1), (object)WebUtility.UrlEncode(queryString2));
            this.InsertEmailButton.Parameters["Click"]    = string.Format(this.InsertEmailButton.Parameters["Click"], (object)WebUtility.UrlEncode(queryString1), (object)WebUtility.UrlEncode(queryString2));
            this.ListViewToggleButton.Parameters["Click"] = string.Format(this.ListViewToggleButton.Parameters["Click"], (object)WebUtility.UrlEncode(queryString1), (object)WebUtility.UrlEncode(queryString2));
            bool   flag = queryString2 != string.Empty;
            string text = string.Empty;

            if (flag)
            {
                text = UrlHandle.Get()["va"];
            }
            if (!(text != string.Empty))
            {
                return;
            }
            XElement element = XElement.Parse(text);

            if (InsertLinkDialogTree.GetXmlAttributeValue(element, "linktype") == "internal")
            {
                if (!string.IsNullOrEmpty(InsertLinkDialogTree.GetXmlAttributeValue(element, "id")))
                {
                    Item contextItem = ((Database)ClientHost.Databases.ContentDatabase).GetItem(queryString1 ?? string.Empty) ?? ((Database)ClientHost.Databases.ContentDatabase).GetRootItem();
                    Item linkedItem  = (Item)SelectMediaDialog.GetMediaItemFromQueryString(InsertLinkDialogTree.GetXmlAttributeValue(element, "id"));
                    if (contextItem != null && linkedItem != null && linkedItem.Paths.LongID.StartsWith(contextItem.Paths.LongID))
                    {
                        this.TreeView.Parameters["PreLoadPath"] = contextItem.ID.ToString() + linkedItem.Paths.LongID.Substring(contextItem.Paths.LongID.Length);
                    }
                }
                this.TextDescription.Parameters["Text"] = InsertLinkDialogTree.GetXmlAttributeValue(element, "text");
                this.AltText.Parameters["Text"]         = InsertLinkDialogTree.GetXmlAttributeValue(element, "title");
                this.StyleClass.Parameters["Text"]      = InsertLinkDialogTree.GetXmlAttributeValue(element, "class");
                this.QueryString.Parameters["Text"]     = InsertLinkDialogTree.GetXmlAttributeValue(element, "querystring");
            }
        }
Beispiel #20
0
        /// <summary>
        /// Reads the raw value and set initial values.
        /// </summary>
        private void ReadRawValueAndSetInitValues()
        {
            bool   queryString = WebUtil.GetQueryString("hdl") != string.Empty;
            string empty       = string.Empty;

            if (queryString)
            {
                empty = UrlHandle.Get()["va"];
            }
            if (empty == string.Empty)
            {
                return;
            }
            XElement xElement = XElement.Parse(empty);

            if (InsertEmail.GetXmlAttributeValue(xElement, "linktype") == "mailto")
            {
                string xmlAttributeValue = InsertEmail.GetXmlAttributeValue(xElement, "url");
                bool   flag   = xmlAttributeValue.IndexOf("?subject=", StringComparison.OrdinalIgnoreCase) != -1;
                string str    = xmlAttributeValue.Replace("mailto:", string.Empty);
                string empty1 = string.Empty;
                if (flag)
                {
                    string[] strArrays = str.Replace("subject=", string.Empty).Split(new char[] { '?' });
                    str    = strArrays[0];
                    empty1 = HttpUtility.UrlDecode(strArrays[1]);
                }
                this.DisplayedText.Parameters["Text"] = InsertEmail.GetXmlAttributeValue(xElement, "text");
                this.Style.Parameters["Text"]         = InsertEmail.GetXmlAttributeValue(xElement, "style");
                this.EmailAddress.Parameters["Text"]  = str;
                this.Subject.Parameters["Text"]       = empty1;


                //////////////////////////////////////////////////////// START CUSTOM BIT ////////////////////////////////////////////////////////
                this.GoalLoadedValue.Parameters["Text"]  = InsertEmail.GetXmlAttributeValue(xElement, "goal");
                this.EventLoadedValue.Parameters["Text"] = InsertEmail.GetXmlAttributeValue(xElement, "pageevent");
                //this.Goal.Parameters["Text"] = InsertLinkDialogTree.GetXmlAttributeValue(xElement, "goal");
                //this.Event.Parameters["Text"] = InsertLinkDialogTree.GetXmlAttributeValue(xElement, "pageevent");
                //////////////////////////////////////////////////////// END CUSTOM BIT ////////////////////////////////////////////////////////
            }
        }
Beispiel #21
0
        /// <summary>
        /// Inits the previous action list.
        /// </summary>
        private void InitPreviousActionList()
        {
            var actionDefinition = this.CurrentForm.SaveActions;
            var handle           = UrlHandle.Get();

            if (handle != null && !string.IsNullOrEmpty(handle["actiondefinition"]))
            {
                actionDefinition = handle["actiondefinition"];
            }

            var list = ListDefinition.Parse(actionDefinition);

            IEnumerable <string> ids = new List <string>();

            if (list.Groups.Any())
            {
                ids = list.Groups.First().ListItems.TakeWhile(i => i.Unicid != this.UniqID).Select(i => i.Unicid);
            }

            this.PreviousActionList.Items.LoadItemsFromActions(actionDefinition, (i, uniqId) => i.InnerItem.TemplateID == FieldsIds.CrmActionTemplateID && ids.FirstOrDefault(id => id == uniqId) != null);
        }
 protected override void OnLoad(EventArgs e)
 {
     Assert.ArgumentNotNull(e, "e");
     base.OnLoad(e);
     if (!Context.ClientPage.IsEvent)
     {
         UrlHandle handle = UrlHandle.Get();
         this.TreeList.Source = handle["source"];
         this.TreeList.SetValue(StringUtil.GetString(new string[] { handle["value"] }));
         if (!string.IsNullOrEmpty(handle["title"]))
         {
             this.Dialog["Header"] = handle["title"];
         }
         if (!string.IsNullOrEmpty(handle["text"]))
         {
             this.Dialog["text"] = handle["text"];
         }
         if (!string.IsNullOrEmpty(handle["icon"]))
         {
             this.Dialog["icon"] = handle["icon"];
         }
     }
 }
        protected override void OnLoad(System.EventArgs e)
        {
            base.OnLoad(e);
            UrlHandle     handle        = UrlHandle.Get();
            string        itemId        = handle["itemId"];
            string        taxonomyValue = handle["taxonomyValue"];
            List <string> listValue     = taxonomyValue.Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList();

            listValue.RemoveAll(str => str.Contains(Sitecore.Data.ID.Null.ToString()));
            taxonomyValue = String.Join("|", listValue.ToArray <string>());
            if (!string.IsNullOrEmpty(taxonomyValue) && !string.IsNullOrEmpty(itemId) && Sitecore.Data.ID.IsID(itemId))
            {
                Item currentItem = Client.ContentDatabase.GetItem(new ID(itemId));
                IOrderedEnumerable <RelationInfo> categories =
                    TaxonomyEngine.GetAllCategories(currentItem, taxonomyValue).Values.OrderBy(info => info.Weight);
                IEnumerable <RelationInfo> setCategories = (from category in categories
                                                            where !category.Calculated
                                                            select category);


                foreach (RelationInfo link in setCategories)
                {
                    GridPanel categoriesPanel = new GridPanel();
                    ResultBox.Controls.Add(categoriesPanel);
                    categoriesPanel.Attributes["class"] = "categoriesPanel";
                    categoriesPanel.Columns             = 100;
                    categoriesPanel.Controls.Add(GetCategoryPanel(link));
                    BuildRelatedCategories(categories, categoriesPanel, link);
                }
            }
            else
            {
                Literal noDataLiteral = new Literal("No taxonomy data could be retrieved.");
                ResultBox.Controls.Add(noDataLiteral);
            }
        }
        /// <summary>
        /// Reads the raw value and set initial values.
        /// </summary>
        private void ReadRawValueAndSetInitValues()
        {
            bool   queryString = WebUtil.GetQueryString("hdl") != string.Empty;
            string empty       = string.Empty;

            if (queryString)
            {
                empty = UrlHandle.Get()["va"];
            }
            if (empty == string.Empty)
            {
                return;
            }
            XElement xElement = XElement.Parse(empty);

            if (InsertAnchor.GetXmlAttributeValue(xElement, "linktype") == "anchor")
            {
                this.Text.Parameters["Text"]             = InsertAnchor.GetXmlAttributeValue(xElement, "text");
                this.Style.Parameters["Text"]            = InsertAnchor.GetXmlAttributeValue(xElement, "class");
                this.Anchor.Parameters["Text"]           = InsertAnchor.GetXmlAttributeValue(xElement, "anchor");
                this.AlternateText.Parameters["Text"]    = InsertAnchor.GetXmlAttributeValue(xElement, "title");
                this.CustomAttributes.Parameters["Text"] = InsertAnchor.GetXmlAttributeValue(xElement, "customattributes");
            }
        }
Beispiel #25
0
        protected override void OnLoad(System.EventArgs e)
        {
            base.OnLoad(e);
            if (!XamlControl.AjaxScriptManager.IsEvent)
            {
                UrlHandle handle      = UrlHandle.Get();
                string    notFoundTag = handle["tagNotFound"];
                if (!string.IsNullOrEmpty(notFoundTag))
                {
                    messageLiteral.Text   = string.Format("Sitecore couldn't recognize the '<b>{0}</b>' tag.<br/>", notFoundTag) + messageLiteral.Text;
                    categoryNameEdit.Text = notFoundTag;
                }

                string categoriesRootId = handle["categoriesRootId"];
                //Item rootItem = Client.ContentDatabase.GetItem(new ID(categoriesRootId));
                Database       db             = Sitecore.Context.ContentDatabase ?? Sitecore.Context.Database;
                Item           rootItem       = db.GetItem(new ID(categoriesRootId));
                TreeviewSource treeviewSource = new TreeviewSource();

                categoryTreeview.Nodes.Clear();
                treeviewSource.Render(categoryTreeview, rootItem, true);
                categoryTreeview.ClientEvents.NodeSelect = new ClientEvent("categoryTreeview_OnNodeSelect");
            }
        }
 protected virtual string GetLink()
 {
     return(StringUtil.GetString(UrlHandle.Get()["va"], "<ultralink/>"));
 }
Beispiel #27
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)
        {
            Assert.ArgumentNotNull((object)e, "e");
            base.OnLoad(e);
            if (XamlControl.AjaxScriptManager.IsEvent)
            {
                return;
            }
            this.ImageWidth  = 0;
            this.ImageHeight = 0;
            ItemUri uri = ItemUri.ParseQueryString();

            if (uri == (ItemUri)null)
            {
                return;
            }
            Item obj = Database.GetItem(uri);

            if (obj == null)
            {
                return;
            }
            string text = obj["Dimensions"];

            if (string.IsNullOrEmpty(text))
            {
                return;
            }
            int length = text.IndexOf('x');

            if (length < 0)
            {
                return;
            }
            this.ImageWidth  = MainUtil.GetInt(StringUtil.Left(text, length).Trim(), 0);
            this.ImageHeight = MainUtil.GetInt(StringUtil.Mid(text, length + 1).Trim(), 0);
            if (this.ImageWidth <= 0 || this.ImageHeight <= 0)
            {
                this.Aspect.Checked  = false;
                this.Aspect.Disabled = true;
            }
            else
            {
                this.Aspect.Checked = true;
            }
            if (this.ImageWidth > 0)
            {
                this.OriginalSize.Text = Translate.Text("Original Dimensions: {0} x {1}", (object)this.ImageWidth, (object)this.ImageHeight);
            }

            if (MainUtil.GetLong((object)obj["Size"], 0L) >= Settings.Media.MaxSizeInMemory)
            {
                this.HeightEdit.Enabled = false;
                this.WidthEdit.Enabled  = false;
                this.Aspect.Disabled    = true;
            }
            else
            {
                this.SizeWarning.Visible = false;
            }
            this.OriginalText.Text = StringUtil.GetString(new string[2]
            {
                obj["Alt"],
                Translate.Text("[none]")
            });
            UrlHandle urlHandle = UrlHandle.Get();
            XmlValue  xmlValue  = new XmlValue(urlHandle["xmlvalue"], "image");

            this.XmlValue        = xmlValue;
            this.Alt.Text        = xmlValue.GetAttribute("alt");
            this.HeightEdit.Text = xmlValue.GetAttribute("height");
            this.WidthEdit.Text  = xmlValue.GetAttribute("width");
            this.HSpace.Text     = xmlValue.GetAttribute("hspace");
            this.VSpace.Text     = xmlValue.GetAttribute("vspace");
            this.Img.ImageUrl    = this.GetMediaUrl(obj);
            this.Img.Height      = imageHeight;

            this.OriginalWidth.Value  = obj["Width"];
            this.OriginalHeight.Value = obj["Height"];

            this.X1.Text = this.GetCoordinateValue(xmlValue, "x1");
            this.X2.Text = this.GetCoordinateValue(xmlValue, "x2");
            this.Y1.Text = this.GetCoordinateValue(xmlValue, "y1");
            this.Y2.Text = this.GetCoordinateValue(xmlValue, "y2");

            this.Ratio.Value = xmlValue.GetAttribute("ratio");
            if (!string.IsNullOrWhiteSpace(this.Ratio.Value))
            {
                HeightEdit.Enabled      = false;
                WidthEdit.Enabled       = false;
                CroppingOptions.Visible = false;
            }

            if (MainUtil.GetBool(urlHandle["disableheight"], false))
            {
                this.HeightEdit.Enabled = false;
                this.Aspect.Checked     = false;
                this.Aspect.Disabled    = true;
            }

            if (!string.IsNullOrEmpty(this.GetCoordinateValue(xmlValue, "x2")))
            {
                var croppedWidth  = Math.Round((decimal)(int.Parse(this.GetCoordinateValue(xmlValue, "x2")) - int.Parse(this.GetCoordinateValue(xmlValue, "x1"))));
                var croppedHeight = Math.Round((decimal)(int.Parse(this.GetCoordinateValue(xmlValue, "y2")) - int.Parse(this.GetCoordinateValue(xmlValue, "y1"))));

                //var str3 = xmlValue.GetAttribute("width");
                //var str4 = xmlValue.GetAttribute("height");

                //if (string.IsNullOrEmpty(str3) || string.IsNullOrEmpty(str4))
                //{
                //    str3 = croppedWidth.ToString();
                //    str4 = croppedHeight.ToString();
                //}
                //else
                //{
                //    str3 = Math.Round((decimal)croppedWidth * int.Parse(str4) / croppedHeight).ToString();
                //}
                this.CroppedSize.Text = Translate.Text("Cropped Dimensions before resizing: {0} x {1}", (object)croppedWidth, (object)croppedHeight);
            }

            if (!MainUtil.GetBool(urlHandle["disablewidth"], false))
            {
                return;
            }
            this.WidthEdit.Enabled = false;
            this.Aspect.Checked    = false;
            this.Aspect.Disabled   = true;
        }
Beispiel #28
0
        protected override void OK_Click()
        {
            string selected = WebUtil.GetFormValue("categoryTreeview_Selected");

            selected = ShortID.Decode(StringUtil.Mid(selected, 1));
            if (string.IsNullOrEmpty(selected))
            {
                SheerResponse.Alert("Please select a category.");
                return;
            }

            if (Sitecore.Data.ID.IsID(selected))
            {
                UrlHandle handle       = UrlHandle.Get();
                Database  db           = Sitecore.Context.ContentDatabase ?? Sitecore.Context.Database;
                Item      selectedItem = db.GetItem(new ID(selected));
                Item      rootItem     = db.GetItem(new ID(handle["categoriesRootId"]));

                if (selectedItem.TemplateID.ToString() != "{A69C0097-5CE1-435B-99E9-FA2B998D1C70}")
                {
                    string taxValue = handle["value"];
                    if (taxValue.Contains(selectedItem.ID.ToString()))
                    {
                        SheerResponse.Alert("Selected category is already assigned.\nPlease select another category.");
                        return;
                    }

                    if (!string.IsNullOrEmpty(taxValue))
                    {
                        List <string> conflictCategoryNames = new List <string>();

                        List <ID> tagConflicts = TaxonomyEngine.GetConflictTags(selectedItem.ID).ToList();
                        if (tagConflicts.Count > 0)
                        {
                            foreach (ID itemTagId in StringUtil.Split(taxValue, '|', true).Select(id => new ID(StringUtil.GetPrefix(id, ':'))))
                            {
                                if (tagConflicts.Contains(itemTagId))
                                {
                                    CategoryItem categoryItem = new CategoryItem(Client.ContentDatabase.GetItem(itemTagId));
                                    conflictCategoryNames.Add(categoryItem.CategoryName);
                                }
                            }
                        }

                        if (conflictCategoryNames.Count > 0)
                        {
                            CategoryItem categoryItem = new CategoryItem(selectedItem);

                            if (conflictCategoryNames.Count > 3)
                            {
                                SheerResponse.Alert(
                                    string.Format(
                                        Messages.CategoryConflictsWithAlreadyAssignedMoreThanThree,
                                        categoryItem.CategoryName,
                                        StringUtil.Join(conflictCategoryNames.Take(3).Select(categoryName => "  -" + categoryName + "\n"), string.Empty),
                                        conflictCategoryNames.Count - 3));
                            }
                            else
                            {
                                SheerResponse.Alert(
                                    string.Format(
                                        Messages.CategoryConflictsWithAlreadyAssigned,
                                        categoryItem.CategoryName,
                                        StringUtil.Join(conflictCategoryNames.Select(categoryName => "  -" + categoryName + "\n"), string.Empty)));
                            }
                            return;
                        }
                    }
                    SheerResponse.SetDialogValue(selected);
                    base.OK_Click();
                }
                else
                {
                    SheerResponse.Alert("Please select a category.");
                }
            }
        }
Beispiel #29
0
        protected void EditWeight()
        {
            ClientPipelineArgs args = ContinuationManager.Current.CurrentArgs as ClientPipelineArgs;

            if (args.IsPostBack)
            {
                if (args.HasResult && args.Result != "undefined" && curWeight != args.Result)
                {
                    List <string> CategoryWeightList = GetValue().Split("|".ToCharArray(), StringSplitOptions.RemoveEmptyEntries).ToList();
                    int           indTochange        = CategoryWeightList.FindIndex(str => str.Contains(currentTagId));


                    if (indTochange > -1)
                    {
                        CategoryWeightList[indTochange] = String.Format("{0}:{1}", currentTagId, args.Result);
                        String newValue = String.Join("|", CategoryWeightList.ToArray <string>());
                        SetValue(newValue);
                        SheerResponse.Eval("ReSaveResult('{0}','{1}');", currentTagId, args.Result);
                    }
                }
            }
            else
            {
                string weightsRootID = "{4A36115B-6120-4EDD-B6F2-E5F0EB2678EE}";
                curWeight = weightsRootID;
                UrlHandle handle                   = UrlHandle.Get();
                string    sourceItemId             = handle["itemId"];
                Item      classificationSourceItem = Client.ContentDatabase.GetItem(new ID(sourceItemId));

                if (classificationSourceItem != null)
                {
                    Item taxonomies = classificationSourceItem.Children["Weights"];
                    if (taxonomies != null)
                    {
                        weightsRootID = taxonomies.ID.ToString();
                    }
                }

                UrlString url = new UrlString("/sitecore/shell/Applications/Item browser.aspx");
                url.Append("ro", weightsRootID);
                url.Append("id", weightsRootID);
                if (!currentTagId.IsNullOrEmpty())
                {
                    char[]   delimiters = new char[] { '|' };
                    string   temp       = GetValue();
                    string[] parts      = temp.Split(delimiters, StringSplitOptions.RemoveEmptyEntries);

                    foreach (String strTemp in parts)
                    {
                        if (strTemp.IndexOf(currentTagId) > -1)
                        {
                            curWeight = strTemp.Split(":".ToCharArray(), StringSplitOptions.None)[1];
                        }
                    }
                }
                url.Append("fo", curWeight);
                url.Append("sc_content", Sitecore.Context.ContentDatabase.Name);
                //url.Append("flt", "Contains('{EB06CEC0-5E2D-4DC4-875B-01ADCC577D13},{C20ED30F-D974-4C65-AE57-CE745C37940E}', @@templateid)");

                SheerResponse.ShowModalDialog(url.ToString(), "300px", "300px", string.Empty, true);
                args.WaitForPostBack();
            }
        }