protected override void OnPreRender(EventArgs e)
    {
        //set widget token image path
        if (_userWidget != null)
        {
            hdnWidgetTokenImagePath.Value = _userWidget.TemplateSourceDirectory + "/" + _widget.ControlURL + ".jpg";
        }

        if (_widget != null)
        {
            hdnWidgetTitle.Value = _widget.ControlURL.Substring(0, _widget.ControlURL.Length - 5);
            WidgetTypeModel wtm = new WidgetTypeModel();
            WidgetTypeData wtd = new WidgetTypeData();
            wtm.FindByControlURL(_widget.ControlURL, out wtd);
            if (wtd != null)
            {
                hdnwidgetTokenTypeId.Value = wtd.ID.ToString();
            }
        }

        base.OnPreRender(e);
    }
Esempio n. 2
0
    private void saveGlobalWidgetProperties()
    {
        List<GlobalWidgetPropertySettings> settingsList = new List<GlobalWidgetPropertySettings>();
        PropertyInfo[] globalProperties = this.GetType().GetProperties();
        foreach (PropertyInfo pi in globalProperties)
        {
            GlobalWidgetPropertySettings setting = new GlobalWidgetPropertySettings();

            GlobalWidgetData[] propertyAttributes = (GlobalWidgetData[])pi.GetCustomAttributes(typeof(GlobalWidgetData), true);
            if (propertyAttributes != null && propertyAttributes.Length > 0)
            {
                setting.PropertyName = pi.Name;
                setting.Type = pi.PropertyType;
                setting.value = pi.GetValue(this, null);
                settingsList.Add(setting);
            }
        }

        XmlSerializer serializer = new XmlSerializer(typeof(List<GlobalWidgetPropertySettings>));
        StringWriter s = new StringWriter();
        serializer.Serialize(s, settingsList);

        WidgetTypeData widgetData = new WidgetTypeData();
        WidgetTypeModel m_refWidgetModel = new WidgetTypeModel();
        m_refWidgetModel.FindByID(_host.WidgetInfo.ID, out widgetData);

        m_refWidgetModel.Update(widgetData.ID, widgetData.Title, widgetData.Title, widgetData.ControlURL, s.GetStringBuilder().ToString(), true);
    }
 void IWidgetHost.LoadWidgetDataMembers()
 {
     if (_userWidget != null)
     {
         WidgetTypeModel widgetTypeModel = new WidgetTypeModel();
         WidgetModel widgetModel = new WidgetModel();
         WidgetTypeData widgettype = null;
         if (widgetTypeModel.FindByControlURL(_widget.ControlURL, out widgettype))
         {
             Ektron.Cms.PageBuilder.WidgetHost wh = new Ektron.Cms.PageBuilder.WidgetHost();
             wh.PopulateWidgetProperties(ref _userWidget, ref widgettype, _widget.Settings);
         }
     }
 }