internal DependencyCheck(IEditorField dependee, object satisfiedBy, MaskMatch match, CompareOperator compare, bool isMask)
 {
     _dependee    = dependee;
     _satisfiedBy = satisfiedBy;
     _match       = match;
     _compare     = compare;
     _isInt       = _satisfiedBy is int;
     _isMask      = isMask && _isInt;
 }
        /// <summary>
        /// Creates a Site-specific Source string for the Field supplied.
        /// </summary>
        /// <param name="field">
        /// The field that needs a modified source.
        /// </param>
        /// <param name="suppliedSourceValue">
        /// The tokenized string that needs the site name.
        /// </param>
        /// <param name="forceEncode">
        /// The force Encode.
        /// </param>
        /// <returns>
        /// A Source that has the "$Site" token replaced. The replacement could be a "*" wildcard.
        /// </returns>
        public static string GetSiteSource(IEditorField field, string suppliedSourceValue, bool forceEncode)
        {
            var siteName = GetSiteName(field);

            // Ensure we get some sort of valid path back if the site name doesn't resolve.
            if (string.IsNullOrEmpty(siteName))
            {
                siteName = "*";
            }

            if (forceEncode)
            {
                return DatasourceResolver.EncodeQuery(suppliedSourceValue.Replace("$site", siteName));
            }

            return suppliedSourceValue.Replace("$site", siteName);
        }
 /// <summary>
 /// Given a Field, resolves the item that the Field belongs to.
 /// </summary>
 /// <param name="field">The field in the content editor.</param>
 /// <returns>The item being edited.</returns>
 private static Item GetFieldItem(IEditorField field)
 {
     return global::Sitecore.Context.ContentDatabase.Items[field.ItemID];
 }
 /// <summary>
 /// Creates a Site-specific Source string for the Field supplied.
 /// </summary>
 /// <param name="field">
 /// The field that needs a modified source.
 /// </param>
 /// <param name="suppliedSourceValue">
 /// The tokenized string that needs the site name.
 /// </param>
 /// <returns>
 /// A Source that has the "$Site" token replaced. The replacement could be a "*" wildcard.
 /// </returns>
 public static string GetSiteSource(IEditorField field, string suppliedSourceValue)
 {
     return GetSiteSource(field, suppliedSourceValue, true);
 }
 /// <summary>
 /// Given a context, returns the nearest ancestor node that represents a Site. This could be a Site Folder or a
 /// true Site node. The Template Name must contain the word "Site".
 /// </summary>
 /// <param name="field">The context field.</param>
 /// <returns>The name of the Site object for the current Item.</returns>
 public static string GetSiteName(IEditorField field)
 {
     return GetSiteName(GetFieldItem(field));
 }
Esempio n. 6
0
        public FieldSlot AddField(Box parent, Widget label, Widget field, string syncTooltip, FieldLabelClosure labelClosure,
                                  FieldValueClosure readClosure, FieldValueClosure writeClosure, FieldOptions options)
        {
            FieldSlot slot = new FieldSlot();

            slot.Parent       = parent;
            slot.Label        = label;
            slot.Field        = field;
            slot.LabelClosure = labelClosure;
            slot.ReadClosure  = readClosure;
            slot.WriteClosure = writeClosure;
            if (MultipleTracks && (options & FieldOptions.NoSync) == 0)
            {
                slot.SyncButton = new SyncButton();
                if (syncTooltip != null)
                {
                    TooltipSetter.Set(tooltip_host, slot.SyncButton, syncTooltip);
                }
                slot.SyncButton.Clicked += delegate {
                    dialog.ForeachNonCurrentTrack(delegate(EditorTrackInfo track) {
                        slot.WriteClosure(track, slot.Field);
                    });
                };
            }

            Table table = new Table(1, 1, false);

            table.ColumnSpacing = 1;

            table.Attach(field, 0, 1, 1, 2,
                         AttachOptions.Expand | AttachOptions.Fill,
                         AttachOptions.Fill, 0, 0);

            IEditorField editor_field = field as IEditorField;

            if (editor_field != null)
            {
                editor_field.Changed += delegate {
                    if (CurrentTrack != null)
                    {
                        slot.WriteClosure(CurrentTrack, slot.Field);
                    }
                };
            }

            if (slot.SyncButton != null)
            {
                table.Attach(slot.SyncButton, 1, 2, 1, 2,
                             AttachOptions.Fill,
                             AttachOptions.Fill, 0, 0);
            }

            if (label != null)
            {
                if (label is Label)
                {
                    ((Label)label).MnemonicWidget = field;
                }
                table.Attach(label, 0, table.NColumns, 0, 1,
                             AttachOptions.Fill | AttachOptions.Expand,
                             AttachOptions.Fill, 0, 0);
            }

            table.ShowAll();

            if ((options & FieldOptions.Shrink) == 0)
            {
                slot.Container = table;
                parent.PackStart(table, false, false, 0);
            }
            else
            {
                HBox shrink = new HBox();
                shrink.Show();
                slot.Container = shrink;
                shrink.PackStart(table, false, false, 0);
                parent.PackStart(shrink, false, false, 0);
            }

            field_slots.Add(slot);
            return(slot);
        }