コード例 #1
0
 public override string Execute(Dictionary<string, string> parameters)
 {
     string Name = parameters["name"];
     if (string.IsNullOrEmpty(Name))
         return string.Format("[TokenProvider : parameter {0} missing]", Name);
     int PortalId = PortalSettings.Current.PortalId;
     BlockController bc = new BlockController();
     var b = bc.GetBlock(Name, PortalId, LocaleController.Instance.GetCurrentLocale(PortalId).Code);
     if (b != null)
     {
         return string.IsNullOrEmpty(b.Content) ? "" : TokenReplaceUtils.Replace(HttpUtility.HtmlDecode(b.Content));
     }
     else
     {
         return string.Format("[TokenProvider : no block with name {0} exist]", Name);
     }
 }
コード例 #2
0
        protected void btnSubmit_Click(object sender, EventArgs e)
        {
            var t = new Satrabel.OpenBlocks.Block.Block();
            var tc = new BlockController();
            if (ItemId > 0)
            {
                t = tc.GetBlock(ItemId, PortalId);
                t.LastModifiedByUserId = UserId;
                t.LastModifiedOnDate = DateTime.Now;
                //t.AssignedUserId = Convert.ToInt32(ddlAssignedUser.SelectedValue);
            }
            else
            {
                t = new Satrabel.OpenBlocks.Block.Block()
                {
                    //AssignedUserId = Convert.ToInt32(ddlAssignedUser.SelectedValue),
                    CreatedByUserId = UserId,
                    CreatedOnDate = DateTime.Now,
                };
            }
            t.Name = txtName.Text.Trim();
            t.CultureCode = ddlCultureCode.SelectedIndex > 0 ? ddlCultureCode.SelectedValue : "";
            t.BlockType = int.Parse(rblType.SelectedValue);
            if (t.BlockType == 1)
                t.Content = txtContentTxt.Text.Trim();
            else if (t.BlockType == 2)
                t.Content = ((TextEditor)txtContentHtml).Text;
            t.LastModifiedOnDate = DateTime.Now;
            t.LastModifiedByUserId = UserId;
            t.PortalId = PortalId;

            if (t.BlockId > 0)
            {
                tc.UpdateBlock(t);
            }
            else
            {
                tc.CreateBlock(t);
            }
            Response.Redirect(DotNetNuke.Common.Globals.NavigateURL());
        }
コード例 #3
0
 protected void Page_Load(object sender, EventArgs e)
 {
     try
     {
         //Implement your edit logic for your module
         if (!Page.IsPostBack)
         {
             //get a list of users to assign the user to the Object
             /*
             ddlAssignedUser.DataSource = UserController.GetUsers(PortalId);
             ddlAssignedUser.DataTextField = "Username";
             ddlAssignedUser.DataValueField = "UserId";
             ddlAssignedUser.DataBind();
             */
             ddlCultureCode.DataSource = LocaleController.Instance.GetLocales(PortalId).Values;
             ddlCultureCode.DataTextField = "NativeName";
             ddlCultureCode.DataValueField = "Code";
             ddlCultureCode.DataBind();
             //check if we have an ID passed in via a querystring parameter, if so, load that item to edit.
             //ItemId is defined in the ItemModuleBase.cs file
             if (ItemId > 0)
             {
                 var tc = new BlockController();
                 var t = tc.GetBlock(ItemId, PortalId);
                 if (t != null)
                 {
                     rblType.SelectedValue = t.BlockType.ToString();
                     txtName.Text = t.Name;
                     txtContentTxt.Text = t.Content;
                     ((TextEditor)txtContentHtml).Text = t.Content;
                     ListItem li =  ddlCultureCode.Items.FindByValue(t.CultureCode);
                     if (li != null)
                     {
                         li.Selected = true;
                     }
                     txtContentTxt.Visible = t.BlockType == 1;
                     txtContentHtml.Visible = t.BlockType == 2;
                 }
             }
         }
     }
     catch (Exception exc) //Module failed to load
     {
         Exceptions.ProcessModuleLoadException(this, exc);
     }
 }