Ejemplo n.º 1
0
        /// <summary>
        /// Makes a field editable via the Page Editor. Use the Model property as the target item, e.g. model => model.Title where Title is field name.
        ///
        /// </summary>
        /// <param name="field"></param>
        /// <returns></returns>
        public string Editable(Expression <Func <T, object> > field, AbstractParameters parameters)
        {
            if (field == null)
            {
                throw new NullReferenceException("No field set");
            }

            if (Model == null)
            {
                throw new NullReferenceException("No model set");
            }

            try
            {
                var result = GlassHtml.Editable <T>(Model, field, parameters);
                return(result);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Makes the editable.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="field">The field.</param>
        /// <param name="standardOutput">The standard output.</param>
        /// <param name="target">The model.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns>System.String.</returns>
        private string MakeEditable <T>(Expression <Func <T, object> > field, Expression <Func <T, string> > standardOutput, T target, AbstractParameters parameters)
        {
            var parametersString = parameters == null ? string.Empty : parameters.ToString();

            return(MakeEditable <T>(field, standardOutput, target, parametersString));
        }
Ejemplo n.º 3
0
 /// <summary>
 /// Makes the field editable using the Sitecore Page Editor. Using the specifed service to write data.
 /// </summary>
 /// <typeparam name="T">A class loaded by Glass.Sitecore.Mapper</typeparam>
 /// <param name="target">The model object that contains the item to be edited</param>
 /// <param name="field">The field that should be made editable</param>
 /// <param name="standardOutput">The output to display when the Sitecore Page Editor is not being used</param>
 /// <param name="parameters">Additional rendering parameters, e.g. ImageParameters</param>
 /// <returns>HTML output to either render the editable controls or normal HTML</returns>
 public virtual string Editable <T>(T target, Expression <Func <T, object> > field, Expression <Func <T, string> > standardOutput, AbstractParameters parameters)
 {
     return(MakeEditable(field, null, target, parameters));
 }
Ejemplo n.º 4
0
 /// <summary>
 /// Makes a field editable via the Page Editor. Use the Model property as the target item, e.g. model =&gt; model.Title where Title is field name.
 /// </summary>
 /// <param name="field">The field.</param>
 /// <param name="parameters">The parameters.</param>
 /// <returns>System.String.</returns>
 public string Editable(Expression <Func <T, object> > field, AbstractParameters parameters)
 {
     return(base.Editable(this.Model, field, parameters));
 }
Ejemplo n.º 5
0
 /// <summary>
 /// Makes a field editable via the Page Editor. Use the Model property as the target item, e.g. model =&gt; model.Title where Title is field name.
 /// </summary>
 /// <param name="field">The field.</param>
 /// <param name="standardOutput">The standard output.</param>
 /// <param name="parameters">The parameters.</param>
 /// <returns>System.String.</returns>
 public string Editable(Expression <Func <T, object> > field, Expression <Func <T, string> > standardOutput,
                        AbstractParameters parameters)
 {
     return(base.Editable(this.Model, field, standardOutput, parameters));
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Makes a field editable via the Page Editor. Use the Model property as the target item, e.g. model =&gt; model.Title where Title is field name.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="glassHtml">The glass HTML.</param>
        /// <param name="model">The model.</param>
        /// <param name="field">The field.</param>
        /// <param name="standardOutput">The standard output.</param>
        /// <param name="parameters">The parameters.</param>
        /// <returns>System.String.</returns>
        /// <exception cref="System.NullReferenceException">
        /// No field set
        /// or
        /// No standardoutput set
        /// or
        /// No model set
        /// </exception>
        public static string Editable <T>(GlassHtml glassHtml, T model, Expression <Func <T, object> > field, Expression <Func <T, string> > standardOutput, AbstractParameters parameters)
        {
            if (field == null)
            {
                throw new NullReferenceException("No field set");
            }

            if (standardOutput == null)
            {
                throw new NullReferenceException("No standardoutput set");
            }

            if (model == null)
            {
                throw new NullReferenceException("No model set");
            }

            try
            {
                var result = glassHtml.Editable <T>(model, field, standardOutput, parameters);
                return(result);
            }
            catch (Exception ex)
            {
                return(ex.Message);
            }
        }
 /// <summary>
 /// Makes a field editable via the Page Editor. Use the Model property as the target item, e.g. model =&gt; model.Title where Title is field name.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="model">The model.</param>
 /// <param name="field">The field.</param>
 /// <param name="standardOutput">The standard output.</param>
 /// <param name="parameters">The parameters.</param>
 /// <returns>System.String.</returns>
 public string Editable <T>(T model, Expression <Func <T, object> > field, Expression <Func <T, string> > standardOutput, AbstractParameters parameters)
 {
     return(UiUtilities.Editable(GlassHtml, model, field, standardOutput, parameters));
 }
Ejemplo n.º 8
0
 /// <summary>
 /// Makes the field editable using the Sitecore Page Editor. Using the specifed service to write data.
 /// </summary>
 /// <param name="field">The field that should be made editable</param>
 /// <param name="parameters"> </param>
 /// <returns>HTML output to either render the editable controls or normal HTML</returns>
 public HtmlString Editable <T>(T target, Expression <Func <T, object> > field, AbstractParameters parameters)
 {
     return(new HtmlString(GlassHtml.Editable(target, field, parameters)));
 }
Ejemplo n.º 9
0
 /// <summary>
 /// Makes the field editable using the Sitecore Page Editor. Using the specifed service to write data.
 /// </summary>
 /// <param name="field">The field that should be made editable</param>
 /// <param name="standardOutput">The output to display when the Sitecore Page Editor is not being used</param>
 /// <returns>HTML output to either render the editable controls or normal HTML</returns>
 public HtmlString Editable(Expression <Func <TModel, object> > field,
                            Expression <Func <TModel, string> > standardOutput, AbstractParameters parameters)
 {
     return(new HtmlString(GlassHtml.Editable(Model, field, standardOutput, parameters)));
 }
Ejemplo n.º 10
0
 /// <summary>
 /// Makes the editable.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="field">The field.</param>
 /// <param name="standardOutput">The standard output.</param>
 /// <param name="target">The target.</param>
 /// <param name="parameters">The parameters.</param>
 /// <returns>System.String.</returns>
 private string MakeEditable <T>(Expression <Func <T, object> > field, Expression <Func <T, string> > standardOutput, T target, AbstractParameters parameters)
 {
     return(MakeEditable <T>(field, standardOutput, target, parameters.ToString()));
 }
 /// <summary>
 /// Makes the field editable using the Sitecore Page Editor. Using the specifed service to write data.
 /// </summary>
 /// <typeparam name="T">A class loaded by Glass.Sitecore.Mapper</typeparam>
 /// <param name="field">The field that should be made editable</param>
 /// <param name="target">The target object that contains the item to be edited</param>
 /// <param name="parameters">Additional rendering parameters, e.g. ImageParameters</param>
 /// <returns>HTML output to either render the editable controls or normal HTML</returns>
 public string Editable <T>(T target, Expression <Func <T, object> > field, AbstractParameters parameters)
 {
     return(MakeEditable <T>(field, null, target, _db, parameters));
 }
Ejemplo n.º 12
0
 /// <summary>
 /// Editables the specified field.
 /// </summary>
 /// <param name="field">The field.</param>
 /// <returns>RawString.</returns>
 /// <exception cref="System.NullReferenceException">
 /// No field set
 /// or
 /// No model set
 /// </exception>
 public IEncodedString Editable(Expression <Func <TModel, object> > field, AbstractParameters parameters)
 {
     return(GlassHtml.Editable(this.Model, field, parameters));
 }
Ejemplo n.º 13
0
 /// <summary>
 /// Editables the specified target.
 /// </summary>
 /// <typeparam name="T">The type of the t1.</typeparam>
 /// <param name="target">The target.</param>
 /// <param name="field">The field.</param>
 /// <param name="standardOutput">The standard output.</param>
 /// <returns>
 /// IEncodedString.
 /// </returns>
 public IEncodedString Editable <T>(T target, Expression <Func <T, object> > field,
                                    Expression <Func <T, string> > standardOutput, AbstractParameters parameters)
 {
     return(GlassHtml.Editable(target, field, standardOutput, parameters));
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Editables the specified target.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="target">The target.</param>
 /// <param name="field">The field.</param>
 /// <param name="parameters">The parameters.</param>
 /// <returns>RawString.</returns>
 public RawString Editable <T>(T target, Expression <Func <T, object> > field, AbstractParameters parameters)
 {
     return(_glassHtml.Editable(target, field, parameters).RawString());
 }
Ejemplo n.º 15
0
 /// <summary>
 /// Makes a field editable via the Page Editor. Use the Model property as the target item, e.g. model =&gt; model.Title where Title is field name.
 /// </summary>
 /// <typeparam name="T"></typeparam>
 /// <param name="model">The model.</param>
 /// <param name="field">The field.</param>
 /// <param name="parameters">The parameters.</param>
 /// <returns>System.String.</returns>
 public string Editable <T>(T model, Expression <Func <T, object> > field, AbstractParameters parameters)
 {
     return(GlassHtml.Editable(model, field, parameters));
 }