/// <summary>
 /// Initializes the dialog renderings
 /// </summary>
 public override void Initialize()
 {
     SelectMediaDialog.RedirectOnItembucketsDisabled(
         ClientHost.Items.GetItem(
             Sitecore.Configuration.Settings.GetSetting("Namics.Common.Packages.CopyPageToVersions.DialogId")));
     ReadQueryParamsAndUpdatePlaceholders();
 }
Ejemplo n.º 2
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);
            }
        }
        private static bool TryGetIdPath(string id, string rootItemId, out string idPath)
        {
            idPath = string.Empty;

            var selectionItem = SelectMediaDialog.GetMediaItemFromQueryString(id);

            if (selectionItem == null)
            {
                return(false);
            }

            idPath = selectionItem.Paths.LongID.Substring(1);
            idPath = idPath.Substring(idPath.IndexOf(rootItemId, StringComparison.InvariantCultureIgnoreCase));

            return(true);
        }
Ejemplo n.º 4
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");
            }
        }