Beispiel #1
0
        /// <summary>
        /// Adds an item to the structured tree root.
        /// The item is placed at the
        /// </summary>
        /// <param name="item">
        /// The item.
        /// </param>
        public void AddItem(Item item)
        {
            string id          = new ShortID(item.ID).ToString();
            Item   currentNode = this.StructuredTreeRootItem;
            int    level       = 1;

            foreach (char letter in id)
            {
                Item child = currentNode.Children[letter.ToString()];
                if (child == null)
                {
                    using (new SecurityDisabler())
                    {
                        using (new EditContext(currentNode))
                        {
                            child = currentNode.Add(letter.ToString(), this.FolderMasterItem);
                        }
                    }
                }

                currentNode = child;

                if (level == this.StructuredDataFolderLevels)
                {
                    item.MoveTo(currentNode);
                    return;
                }

                level += 1;
            }
        }
        public override object GetFieldValue(IIndexableDataField indexableField)
        {
            Field field = indexableField as SitecoreItemDataField;

            var list = new List <string>();

            var multiField = FieldTypeManager.GetField(field) as MultilistField;

            if (multiField != null)
            {
                foreach (string key in multiField.List)
                {
                    string itm = key;

                    if (ID.IsID(itm))
                    {
                        itm = ShortID.Encode(itm).ToLowerInvariant();
                        list.Add(itm);
                    }
                }

                return(list);
            }

            return(list);
        }
        private void Jump(object sender, Message message, int offset)
        {
            string control    = Context.ClientPage.ClientRequest.Control;
            string workflowID = ShortID.Decode(control.Substring(0, 0x20));
            string stateID    = ShortID.Decode(control.Substring(0x21, 0x20));

            control = control.Substring(0, 0x41);
            IWorkflowProvider workflowProvider = Context.ContentDatabase.WorkflowProvider;

            Error.Assert(workflowProvider != null, "Workflow provider for database \"" + Context.ContentDatabase.Name + "\" not found.");
            IWorkflow workflow = workflowProvider.GetWorkflow(workflowID);

            Error.Assert(workflow != null, "Workflow \"" + workflowID + "\" not found.");
            Assert.IsNotNull(workflow, "workflow");
            WorkflowState state = workflow.GetState(stateID);

            Error.Assert(state != null, "Workflow state \"" + stateID + "\" not found.");
            Border border = new Border
            {
                ID = control + "_content"
            };

            DataUri[] items = this.GetItems(state, workflow);
            this.DisplayState(workflow, state, items, border, offset, this.PageSize);
            Context.ClientPage.ClientResponse.SetOuterHtml(control + "_content", border);
        }
        protected override string GetMediaPath(string localPath)
        {
            int    indexA = -1;
            string strB   = string.Empty;

            foreach (string str in MediaManager.Provider.Config.MediaPrefixes)
            {
                indexA = localPath.IndexOf(str, StringComparison.InvariantCultureIgnoreCase);
                if (indexA >= 0)
                {
                    strB = str;
                    break;
                }
            }
            if (indexA < 0 || string.Compare(localPath, indexA, strB, 0, strB.Length, true, CultureInfo.InvariantCulture) != 0)
            {
                return(string.Empty);
            }
            string id = StringUtil.Divide(StringUtil.Mid(localPath, indexA + strB.Length), '.', true)[0];

            if (id.EndsWith("/", StringComparison.InvariantCulture))
            {
                return(string.Empty);
            }
            if (ShortID.IsShortID(id))
            {
                return(ShortID.Decode(id));
            }
            //2014-06-16 - Removed decode call below
            return("/sitecore/media library/" + id.TrimStart(new char[1] {
                '/'
            }));;
        }
        protected virtual void InitProperties()
        {
            this.WidthInput.Value  = WebUtil.GetQueryString(Constants.PlayerParameters.Width, MediaFrameworkContext.DefaultPlayerSize.Width.ToString(CultureInfo.InvariantCulture));
            this.HeightInput.Value = WebUtil.GetQueryString(Constants.PlayerParameters.Height, MediaFrameworkContext.DefaultPlayerSize.Height.ToString(CultureInfo.InvariantCulture));

            string player = WebUtil.GetQueryString(Constants.PlayerParameters.PlayerId, string.Empty);

            this.PlayerId = ShortID.IsShortID(player) ? new ShortID(player) : ID.Null.ToShortID();

            var mediaItemId = WebUtil.GetQueryString(Constants.PlayerParameters.ItemId);

            if (ID.IsID(mediaItemId))
            {
                Item     item;
                Database db = Context.ContentDatabase ?? Context.Database;

                if (db != null && (item = db.GetItem(new ID(mediaItemId))) != null)
                {
                    this.Filename.Value = item.Paths.MediaPath;
                    this.DataContext.SetFolder(item.Uri);

                    this.SourceItemID = item.ID;
                    this.InitPlayersList(item);

                    string activePage = WebUtil.GetQueryString(Constants.PlayerParameters.ActivePage);
                    if (!string.IsNullOrEmpty(activePage))
                    {
                        this.Active = activePage;
                    }
                }
            }
        }
        public static IEnumerable <Item> GetItemsInCategories([NotNull] IEnumerable <ID> categories)
        {
            Assert.ArgumentNotNull(categories, "categories");

            var index = SearchManager.SystemIndex;

            if (index == null)
            {
                return(new Item[0]);
            }

            var query = new CombinedQuery();

            foreach (var id in categories)
            {
                query.Add(new FieldQuery("_categories", ShortID.Encode(id)), QueryOccurance.Must);
            }
            SearchResultCollection collection;

            using (var context = index.CreateSearchContext())
            {
                collection = context.Search(query).FetchResults(0, int.MaxValue);
            }
            return(collection.Select(result => SearchManager.GetObject(result)).OfType <Item>());
        }
        protected void ShowConfirm(ClientPipelineArgs args)
        {
            Assert.ArgumentNotNull(args, "args");
            if (!args.IsPostBack)
            {
                SheerResponse.Confirm("Personalize component settings will be removed. Are you sure you want to continue?");
                args.WaitForPostBack();
                return;
            }
            if (!args.HasResult || !(args.Result != "no"))
            {
                this.ComponentPersonalization.Checked = true;
                return;
            }
            SheerResponse.Eval("scTogglePersonalizeComponentSection()");
            XElement rulesSet = this.RulesSet;

            foreach (XElement xElement in rulesSet.Elements("rule"))
            {
                XElement actionById = PersonalizationFormWithActions.GetActionById(xElement, this.SetRenderingActionId);
                if (actionById == null)
                {
                    continue;
                }
                actionById.Remove();
                HtmlTextWriter htmlTextWriter = new HtmlTextWriter(new StringWriter());
                this.RenderSetRenderingAction(xElement, htmlTextWriter);
                ShortID shortID = ShortID.Parse(xElement.GetAttributeValue("uid"));
                Assert.IsNotNull(shortID, "ruleId");
                SheerResponse.SetInnerHtml(string.Concat(shortID, "_setrendering"), htmlTextWriter.InnerWriter.ToString().Replace("{ID}", shortID.ToString()));
            }
            this.RulesSet = rulesSet;
        }
        private void RenderContentControls(HtmlTextWriter output, VariableValueItemStub value)
        {
            bool flag;

            Assert.ArgumentNotNull(output, "output");
            Assert.ArgumentNotNull(value, "value");
            ShortID tid            = value.Id.ToShortID();
            Item    currentContent = null;

            currentContent = GetCurrentContent(value, out flag);
            string str = flag ? "default-values" : string.Empty;

            if (value.HideComponent)
            {
                str = str + " display-off";
            }
            output.Write("<div {0} id='{1}_content'>", (str == string.Empty) ? str : ("class='" + str + "'"), tid);
            string click = value.HideComponent ? "javascript:void(0);" : ("variation:setcontent(variationid=" + tid + ")");
            string reset = value.HideComponent
                                        ? "javascript:void(0);"
                                        : "ResetVariationContent(\\\"{0}\\\")".FormatWith(new object[] { tid });

            RenderPicker(output, currentContent, click, reset, true);
            output.Write("</div>");
        }
        private void RenderComponentControls(HtmlTextWriter output, VariableValueItemStub value)
        {
            bool    flag;
            ShortID tid = value.Id.ToShortID();
            Item    currentRenderingItem = GetCurrentRenderingItem(value, out flag);
            string  thumbnailSrc         = GetThumbnailSrc(currentRenderingItem);
            string  str2 = flag ? "default-values" : string.Empty;

            if (value.HideComponent)
            {
                str2 = str2 + " display-off";
            }
            output.Write("<div id='{0}_component' {1}>", tid,
                         string.IsNullOrEmpty(str2) ? string.Empty : ("class='" + str2 + "'"));
            output.Write("<div style=\"background-image:url('{0}')\" class='thumbnail-container'>", thumbnailSrc);
            output.Write("</div>");
            output.Write("<div class='picker-container'>");
            string click = value.HideComponent ? "javascript:void(0);" : ("variation:setcomponent(variationid=" + tid + ")");
            string reset = value.HideComponent
                                        ? "javascript:void(0);"
                                        : "ResetVariationComponent(\\\"{0}\\\")".FormatWith(new object[] { tid });

            RenderPicker(output, currentRenderingItem, click, reset, false);
            output.Write("</div>");
            output.Write("</div>");
        }
        /// <summary>
        /// Raises the load event.
        /// </summary>
        /// <param name="e">The <see cref="T: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(EventArgs e)
        {
            Assert.ArgumentNotNull(e, "e");
            base.OnLoad(e);
            if (Context.ClientPage.IsEvent)
            {
                return;
            }

            Mode = WebUtil.GetQueryString("mo");
            DataContext.GetFromQueryString();
            string queryString = WebUtil.GetQueryString("fo");

            if (ShortID.IsShortID(queryString))
            {
                DataContext.Folder = ShortID.Parse(queryString).ToID().ToString();
            }

            Context.ClientPage.ServerProperties["mode"] = WebUtil.GetQueryString("mo");

            if (!string.IsNullOrEmpty(WebUtil.GetQueryString("databasename")))
            {
                DataContext.Parameters = "databasename=" + WebUtil.GetQueryString("databasename");
            }

            Item folder = DataContext.GetFolder();

            Assert.IsNotNull(folder, "Folder not found");
            SelectItem(folder);

            Upload.Click = "media:upload(edit=" + (Settings.Media.OpenContentEditorAfterUpload ? "1" : "0") +
                           ",load=1)";
            Upload.ToolTip     = Translate.Text("Upload a new media file to the Media Library");
            EditButton.ToolTip = Translate.Text("Edit the media item in the Content Editor.");
        }
Beispiel #11
0
        // on ok
        protected override void OnOK(object sender, EventArgs args)
        {
            Assert.ArgumentNotNull(sender, "sender");
            Assert.ArgumentNotNull((object)args, "args");
            ListString listString = new ListString(WebUtil.GetFormValue("sortorder"));

            if (listString.Count == 0) // no changes made
            {
                base.OnOK(sender, args);
            }
            else
            {
                if (IsDBsort(listString.ToString()))
                {
                    SortContentOptions sortContentOptions = SortContentOptions.Parse();
                    ProcessDbOrder(sortContentOptions.Item.Children[0], listString); // save sort order of db view data
                }
                else // sort input view items
                {
                    ListString source = listString;
                    this.Sort(source.Select <string, ID>(x => ShortID.DecodeID(x)));
                    SheerResponse.SetDialogValue("1");
                }
                base.OnOK(sender, args);
            }
        }
Beispiel #12
0
 protected string GetItemID(ID id, string language, string version)
 {
     Assert.ArgumentNotNull(id, "id");
     Assert.ArgumentNotNull(language, "language");
     Assert.ArgumentNotNull(version, "version");
     return(ShortID.Encode(id) + language + "%" + version);
 }
        protected void Remove_Click()
        {
            Item itemFromQueryString = UIUtil.GetItemFromQueryString(Context.ContentDatabase);

            Error.AssertItemFound(itemFromQueryString);
            ArrayList arrayList = new ArrayList();

            foreach (System.Web.UI.Control control in this.ExistingAliases.Selected)
            {
                string path = ShortID.Decode(StringUtil.Mid(control.ID.Split(MultiSiteAliases.Constants.HypenSplitChar).LastOrDefault(), 0));
                Item   obj  = itemFromQueryString.Database.GetItem(path);
                if (obj != null)
                {
                    arrayList.Add((object)obj);
                }
            }
            if (arrayList.Count == 0)
            {
                SheerResponse.Alert(MultiSiteAliases.Constants.AliasesNotSelected);
            }
            else
            {
                foreach (Item obj in arrayList)
                {
                    obj.Delete();
                    Log.Audit((object)this, MultiSiteAliases.Constants.RemoveAliases, AuditFormatter.FormatItem(obj));
                }
                RefreshPostDeletion(itemFromQueryString);
            }
        }
        protected override void OnOK(object sender, EventArgs args)
        {
            Assert.ArgumentNotNull(sender, "sender");
            Assert.ArgumentNotNull(args, "args");
            ListString str         = new ListString(WebUtil.GetFormValue("sortorder"));
            ListString strToDelete = new ListString(WebUtil.GetFormValue("deleteItem"));

            if (str.Count == 0 && strToDelete.Count == 0)
            {
                base.OnOK(sender, args);
            }
            else
            {
                if (strToDelete.Count > 0)
                {
                    this.Delete(from i in strToDelete select ShortID.DecodeID(i));
                }
                if (str.Count > 0)
                {
                    this.Sort(from i in str select ShortID.DecodeID(i));
                }

                SheerResponse.SetDialogValue("1");
                base.OnOK(sender, args);
            }
        }
Beispiel #15
0
        public override TElement MapToType <TElement>(Document document, Sitecore.ContentSearch.Linq.Methods.SelectMethod selectMethod, IEnumerable <IFieldQueryTranslator> virtualFieldProcessors, Sitecore.ContentSearch.Security.SearchSecurityOptions securityOptions)
        {
            // if the result type is not IStandardTemplateItem, use the default functionality
            if (!typeof(IStandardTemplateItem).IsAssignableFrom(typeof(TElement)))
            {
                return(base.MapToType <TElement>(document, selectMethod, virtualFieldProcessors, securityOptions));
            }

            // initializers can't really support sub-selects of objects. Error if that's what's being used.
            if (selectMethod != null)
            {
                throw new NotSupportedException("Using Select on a Synthesis object type is supported. Convert the query to a list or array before selecting, then select using LINQ to objects.");
            }

            var fields = ExtractFieldsFromDocument(document, virtualFieldProcessors);

            ShortID templateId;

            if (!fields.ContainsKey("_template") || !ShortID.TryParse(fields["_template"], out templateId))
            {
                templateId = ID.Null.ToShortID();
            }

            var result = Initializers.GetInitializer(templateId.ToID()).CreateInstanceFromSearch(fields);

            if (result is TElement)
            {
                return((TElement)result);
            }

            return(default(TElement));
        }
Beispiel #16
0
        protected virtual void GetContextMenu(string where)
        {
            Assert.ArgumentNotNullOrEmpty(where, "where");
            IDataView dataView = this.GetDataView();

            if (dataView != null)
            {
                string source  = Sitecore.Context.ClientPage.ClientRequest.Source;
                string control = Sitecore.Context.ClientPage.ClientRequest.Control;
                int    num     = source.LastIndexOf("_");
                Assert.IsTrue(num >= 0, "Invalid source ID");
                string id   = ShortID.Decode(StringUtil.Mid(source, num + 1));
                Item   item = dataView.GetItem(id);
                if (item != null)
                {
                    SheerResponse.DisableOutput();
                    Sitecore.Shell.Framework.ContextMenu menu = new Sitecore.Shell.Framework.ContextMenu();
                    CommandContext context = new CommandContext(item);
                    Sitecore.Web.UI.HtmlControls.Menu contextMenu = menu.Build(context);
                    contextMenu.AddDivider();
                    contextMenu.Add("__Refresh", "Refresh", "Applications/16x16/refresh.png", string.Empty, string.Concat(new object[] { "javascript:Sitecore.Treeview.refresh(\"", source, "\",\"", control, "\",\"", item.ID.ToShortID(), "\")" }), false, string.Empty, MenuItemType.Normal);
                    SheerResponse.EnableOutput();
                    SheerResponse.ShowContextMenu(control, where, contextMenu);
                }
            }
        }
        /// <summary>Expands the tree view to node.</summary>
        /// <returns>The tree view to node.</returns>
        private static string ExpandTreeViewToNode()
        {
            var str1        = WebUtil.GetQueryString("root");
            var str2        = WebUtil.GetQueryString("id");
            var queryString = WebUtil.GetQueryString("la");

            if (str2.IndexOf('_') >= 0)
            {
                str2 = StringUtil.Mid(str2, str2.LastIndexOf('_') + 1);
            }
            if (str1.IndexOf('_') >= 0)
            {
                str1 = StringUtil.Mid(str1, str1.LastIndexOf('_') + 1);
            }
            if (str2.Length > 0 && str1.Length > 0)
            {
                var language = Language.Parse(queryString);
                var folder   = Client.ContentDatabase.GetItem(ShortID.DecodeID(str2), language);
                var root     = Client.ContentDatabase.GetItem(ShortID.DecodeID(str1), language);
                if (folder != null && root != null)
                {
                    return(GetTree(folder, root).RenderTree(false));
                }
            }
            return(string.Empty);
        }
        protected void RenameVariation(Message message)
        {
            string argument = message.Arguments["variationId"];
            string str2     = message.Arguments["name"];

            Assert.ArgumentNotNull(argument, "variationId");
            Assert.ArgumentNotNull(str2, "name");
            ID id = ShortID.DecodeID(argument);
            List <VariableValueItemStub> variableValues = VariableValues;
            int num = variableValues.FindIndex(value => value.Id == id);

            if (num < 0)
            {
                SheerResponse.Alert("Item not found.", new string[0]);
            }
            else if (string.IsNullOrEmpty(str2))
            {
                SheerResponse.Alert("An item name cannot be blank.", new string[0]);
                SheerResponse.Eval("Sitecore.CollapsiblePanel.editName(\"{0}\")".FormatWith(new object[] { argument }));
            }
            else
            {
                variableValues[num].Name = str2;
                VariableValues           = variableValues;
            }
        }
Beispiel #19
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());
            }
        }
        /// <summary>
        /// Renders the control page design mode.
        ///
        /// </summary>
        /// <param name="output">The output.</param><param name="isDesignAllowed">if set to <c>true</c> [is design allowed].</param><param name="control">The control.</param>
        private void RenderControlPageDesignMode(HtmlTextWriter output, bool isDesignAllowed, Control control)
        {
            Assert.ArgumentNotNull((object)output, "output");
            Assert.ArgumentNotNull((object)control, "control");
            RenderingReference renderingReference = Client.Page.GetRenderingReference(control);
            bool flag = false;

            if (renderingReference != null)
            {
                string uniqueId = renderingReference.UniqueId;
                if (Sitecore.Data.ID.IsID(uniqueId))
                {
                    string controlId = ShortID.Encode(uniqueId);
                    Item   obj       = this.GetItem();
                    Assert.IsNotNull((object)obj, "item");
                    ChromeData controlData = Placeholder72.GetControlData(renderingReference, obj);
                    output.Write(Placeholder72.GetControlStartMarker(controlId, controlData, isDesignAllowed));
                    control.RenderControl(output);
                    output.Write(Placeholder72.GetControlEndMarker(controlData));
                    flag = true;
                }
            }
            if (flag)
            {
                return;
            }
            control.RenderControl(output);
        }
Beispiel #21
0
        /// <summary>
        /// Gets the publishing targets.
        ///
        /// </summary>
        ///
        /// <returns>
        /// The publishing targets.
        ///
        /// </returns>
        /// <contract><ensures condition="not null"/></contract>
        private static List <Item> GetPublishingTargets()
        {
            var list = new List <Item>();

            foreach (string str in Context.ClientPage.ClientRequest.Form.Keys)
            {
                if (str != null && str.StartsWith("pb_", StringComparison.InvariantCulture))
                {
                    Item obj = Context.ContentDatabase.Items[ShortID.Decode(str.Substring(3))];
                    Assert.IsNotNull(obj, typeof(Item), "Publishing group not found.", new object[0]);

                    var targetList = obj["Publishing Targets"];

                    if (targetList == null || targetList == "")
                    {
                        list.Add(obj);
                    }
                    else
                    {
                        var targets = targetList.Split('|');

                        foreach (var child in targets)
                        {
                            var targetItem = Context.ContentDatabase.GetItem(child);
                            list.Add(targetItem);
                        }
                    }
                }
            }
            return(list);
        }
Beispiel #22
0
        public override void Execute(CommandContext context)
        {
            Assert.ArgumentNotNull(context, "context");
            if (context.Items.Length == 1)
            {
                Item currentItem             = context.Items[0];
                LanguageCollection languages = LanguageManager.GetLanguages(currentItem.Database);

                SheerResponse.DisableOutput();
                Menu menu = new Menu();
                foreach (Language language in languages)
                {
                    Item item = currentItem.Database.GetItem(currentItem.ID, language);
                    if (item != null && item.Versions.GetVersionNumbers(false).Length == 0)
                    {
                        continue;
                    }

                    string id           = "L" + ShortID.NewId();
                    string languageName = GetLanguageName(language.CultureInfo);
                    string icon         = LanguageService.GetIcon(language, currentItem.Database);
                    string click        = string.Format("item:addversionrecursive(id={0},sourceLang={1},targetLang={2})",
                                                        currentItem.ID, language, currentItem.Language);
                    menu.Add(id, languageName, icon, string.Empty, click, false, string.Empty, MenuItemType.Normal);
                }
                SheerResponse.EnableOutput();
                SheerResponse.ShowPopup("CopyFromLanguageButton", "below", menu);
            }
        }
        /// <summary>
        /// Adds all fields.
        /// </summary>
        /// <param name="document">
        /// The document.
        /// </param>
        /// <param name="item">
        /// The item.
        /// </param>
        /// <param name="versionSpecific">
        /// Ignored, must always be true.
        /// </param>
        protected override void AddAllFields([NotNull] Document document, [NotNull] Item item, bool versionSpecific)
        {
            Assert.ArgumentNotNull(document, "document");
            Assert.ArgumentNotNull(item, "item");

            base.AddAllFields(document, item, versionSpecific);

            if (item.Name == "__Standard Values")
            {
                return;
            }

            var fields = item.Fields;

            fields.ReadAll();
            foreach (Data.Fields.Field field in fields)
            {
                if (string.IsNullOrEmpty(field.Key))
                {
                    continue;
                }

                if (field.Type == "Classification")
                {
                    var relations = TaxonomyEngine.GetAllCategories(field.Item, field.Value);
                    foreach (var info in relations.Values)
                    {
                        document.Add(CreateTextField("_categories", ShortID.Encode(info.Category)));
                        continue;
                    }
                }
            }
        }
Beispiel #24
0
 protected virtual string GetItemId(ID id, string language, string version)
 {
     Assert.ArgumentNotNull((object)id, "id");
     Assert.ArgumentNotNull((object)language, "language");
     Assert.ArgumentNotNull((object)version, "version");
     return(ShortID.Encode(id) + language + "%" + version);
 }
        protected string GetParameterValue(CommandContext context)
        {
            var id = ShortID.Decode(WebUtil.GetFormValue("scDeviceID"));
            var layoutDefinition = GetLayoutDefinition();

            if (layoutDefinition == null)
            {
                return(string.Empty);
            }

            var device = layoutDefinition.GetDevice(id);
            var renderingByUniqueId = device?.GetRenderingByUniqueId(context.Parameters["referenceId"]);

            if (renderingByUniqueId == null)
            {
                return(string.Empty);
            }

            if (string.IsNullOrEmpty(renderingByUniqueId.Parameters))
            {
                return(string.Empty);
            }

            var parameters = WebUtil.ParseUrlParameters(renderingByUniqueId.Parameters);

            return(parameters[this.ParamKey]);
        }
Beispiel #26
0
 public UpdateContextAwareCrawler(IndexUpdateContext updateContext, ShortID runningContextId, IEnumerable <Uri> urlsToCrawl, ILog logger, params IPipelineStep[] pipeline)
     : base(urlsToCrawl, pipeline)
 {
     m_Logger         = logger;
     RunningContextId = runningContextId;
     _updateContext   = updateContext;
 }
        private void BuildCheckList()
        {
            this.FlushTargets.Controls.Clear();
            string     str2 = Settings.DefaultPublishingTargets.ToLowerInvariant();
            ListString str  = new ListString(Registry.GetString("/Current_User/Publish/Targets"));

            // add master database

            Sitecore.Publishing.PublishManager.GetPublishingTargets(Context.ContentDatabase).ForEach(target =>
            {
                string str3 = "pb_" + ShortID.Encode(target.ID);
                HtmlGenericControl child = new HtmlGenericControl("input");
                this.FlushTargets.Controls.Add(child);
                child.Attributes["type"] = "checkbox";
                child.ID  = str3;
                bool flag = str2.IndexOf('|' + target.Key + '|', StringComparison.InvariantCulture) >= 0;
                if (str.Contains(target.ID.ToString()))
                {
                    flag = true;
                }
                if (flag)
                {
                    child.Attributes["checked"] = "checked";
                }
                child.Disabled = !target.Access.CanWrite();
                HtmlGenericControl control2 = new HtmlGenericControl("label");
                this.FlushTargets.Controls.Add(control2);
                control2.Attributes["for"] = str3;
                control2.InnerText         = target.DisplayName;
                this.FlushTargets.Controls.Add(new LiteralControl("<br>"));
            });
        }
        public DocumentMappingResult <TElement> MapToType <TElement>(Func <Dictionary <string, string> > getFieldsMethod, SelectMethod selectMethod)
        {
            // if the result type is not IStandardTemplateItem, use the default functionality
            if (!IsSynthesisType <TElement>())
            {
                return(new DocumentMappingResult <TElement>(default(TElement), false));
            }

            // initializers can't really support sub-selects of objects. Error if that's what's being used.
            if (selectMethod != null)
            {
                throw new NotSupportedException("Using Select on a Synthesis object type is supported. Convert the query to a list or array before selecting, then select using LINQ to objects.");
            }

            var evaluatedFields = getFieldsMethod();

            ShortID templateId;

            if (!evaluatedFields.ContainsKey("_template") || !ShortID.TryParse(evaluatedFields["_template"], out templateId))
            {
                templateId = ID.Null.ToShortID();
            }

            var initializer = _overrideInitializer ?? ProviderResolver.FindGlobalInitializer(templateId.ToID());

            var result = initializer.CreateInstanceFromSearch(evaluatedFields);

            if (result is TElement)
            {
                return(new DocumentMappingResult <TElement>((TElement)result, true));
            }

            return(new DocumentMappingResult <TElement>(default(TElement), true));           // note that this is still 'success', because we mapped onto a Synthesis type so we do not want to use default mapping
        }
Beispiel #29
0
        /// <summary>
        /// On Load
        /// </summary>
        /// <param name="e">
        /// The e.
        /// </param>
        protected override void OnLoad(EventArgs e)
        {
            Assert.ArgumentNotNull(e, "e");
            base.OnLoad(e);

            if (!Context.ClientPage.IsEvent)
            {
                this.Mode = WebUtil.GetQueryString("mo");
                try
                {
                    this.InternalLinkDataContext.GetFromQueryString();
                }
                catch
                {
                }

                try
                {
                    this.MediaDataContext.GetFromQueryString();
                }
                catch
                {
                }

                var queryString = WebUtil.GetQueryString("fo");
                if (queryString.Length > 0)
                {
                    if (queryString.EndsWith(".aspx", StringComparison.OrdinalIgnoreCase))
                    {
                        if (!queryString.StartsWith("/sitecore"))
                        {
                            queryString = FileUtil.MakePath("/sitecore/content", queryString, '/');
                        }

                        if (queryString.EndsWith(".aspx"))
                        {
                            queryString = StringUtil.Left(queryString, queryString.Length - 5);
                        }

                        this.InternalLinkDataContext.Folder = queryString;
                    }
                    else if (ShortID.IsShortID(queryString))
                    {
                        queryString = ShortID.Parse(queryString).ToID().ToString();
                        var item = Client.ContentDatabase.GetItem(queryString);
                        if (item != null)
                        {
                            if (!item.Paths.IsMediaItem)
                            {
                                this.InternalLinkDataContext.Folder = queryString;
                            }
                            else
                            {
                                this.MediaDataContext.Folder = queryString;
                            }
                        }
                    }
                }
            }
        }
Beispiel #30
0
        protected string GetFilterSectionHtml([NotNull] XElement filter, bool fillVisitorCount)
        {
            Assert.ArgumentNotNull(filter, "filter");

            var writer = new HtmlTextWriter(new StringWriter(CultureInfo.CurrentCulture));
            var id     = ShortID.Parse(filter.GetAttributeValue("uid")).ToString();

            writer.Write("<table id='{ID}_body' cellspacing='0' cellpadding='0' class='rule-body'>");
            writer.Write("<tbody>");
            writer.Write("<tr>");

            writer.Write("<td class='left-column'>");
            RenderRuleConditions(filter, writer);
            writer.Write("</td>");

            writer.Write("<td class='right-column'>");
            writer.Write(string.Format(CultureInfo.InvariantCulture, "<span>{0}</span>", HttpUtility.HtmlEncode(Translate.Text(SB.Texts.ContactsThatMatchThisRule))));
            if (fillVisitorCount)
            {
                XElement rule;
                var      number = GetVisitorsCount(GetFilterPosition(id), out rule);
                writer.Write(string.Format(CultureInfo.InvariantCulture, "<span class='value' id='{1}ID{2}_count'>{0}</span>", number, "{", "}"));
            }
            else
            {
                writer.Write(string.Format(CultureInfo.InvariantCulture, "<span class='value'>{0}</span>", HttpUtility.HtmlEncode(Translate.Text(SB.Texts.Calculating))));
            }
            writer.Write("</td>");

            writer.Write("</tr>");
            writer.Write("</tbody>");
            writer.Write("</table>");

            var panelHtml      = writer.InnerWriter.ToString().Replace("{ID}", id);
            var actionsContext = new CollapsiblePanelRenderer.ActionsContext
            {
                IsVisible     = true,
                OnActionClick = "javascript:return Sitecore.CollapsiblePanel.showActionsMenu(this,event)",
                Menu          = GetActionsMenu(id)
            };

            var name = Translate.Text(SB.Texts.SpecifyName);

            if (!string.IsNullOrEmpty(filter.GetAttributeValue("name")))
            {
                name = filter.GetAttributeValue("name");
            }

            var nameContext = new CollapsiblePanelRenderer.NameContext(name)
            {
                Editable      = true,
                OnNameChanged = "javascript:return Sitecore.CollapsiblePanel.renameComplete(this,event)"
            };

            var panelRenderer = new CollapsiblePanelRenderer();

            panelRenderer.CssClass = "rule-container";
            return(Assert.ResultNotNull(panelRenderer.Render(id, panelHtml, nameContext, actionsContext)));
        }
        public static string NormalizeGuid(string guid, bool lowercase)
        {
            if (!string.IsNullOrEmpty(guid) && IsGuid(guid))
            {
                var shortId = new ShortID(guid);
                return lowercase ? shortId.ToString().ToLowerInvariant() : shortId.ToString();
            }

            return guid;
        }
    /// <summary>
    /// Adds an item to the structured tree root.
    /// The item is placed at the 
    /// </summary>
    /// <param name="item">
    /// The item.
    /// </param>
    public void AddItem(Item item)
    {
      string id = new ShortID(item.ID).ToString();
      Item currentNode = this.StructuredTreeRootItem;
      int level = 1;

      foreach (char letter in id)
      {
        Item child = currentNode.Children[letter.ToString()];
        if (child == null)
        {
          using (new SecurityDisabler())
          {
            using (new EditContext(currentNode))
            {
              child = currentNode.Add(letter.ToString(), this.FolderMasterItem);
            }
          }
        }

        currentNode = child;

        if (level == this.StructuredDataFolderLevels)
        {
          item.MoveTo(currentNode);
          return;
        }

        level += 1;
      }
    }