public EntryPresenter(BlogEntry entry) { OnSeletion = new EventHandler(EntryPresenter_Click); DisplayedEntry = entry; InitializeComponent(); TitleLabel.Text = entry.Title; ThumbnailPictureBox.Load(getImageLink(entry)); groupBox.Text = $"[{entry.Number}]"; setDefaultBackColor(); BackColor = defaultBackColor; counter++; }
private void setTags(BlogEntry entry) { using (var connection = new MySqlConnection(connetionString)) using (var command = connection.CreateCommand()) { connection.Open(); foreach (int tag in entry.TagIds) { command.CommandText = $"INSERT INTO cb_term_relationships (object_id, term_taxonomy_id, term_order) VALUES ({entry.Id}, {tag}, 0)"; command.ExecuteNonQuery(); } } }
private void handlePanelSelection(object sender, EventArgs e) { if (infoLabel.Visible) { infoLabel.Hide(); actionButton.Show(); } foreach (var node in collect(treeViewCategories.Nodes)) { node.Checked = false; } Control control = sender as Control; while (control.GetType() != typeof(EntryPresenter)) { control = control.Parent; } if (control.GetType() == typeof(EntryPresenter)) { displayed = control as EntryPresenter; selected = displayed.DisplayedEntry; } pictureBoxThumbnail.Image = displayed.GetImage(); textBoxTitle.Text = selected.Title; textBoxDescription.Text = selected.Description; numberLabel.Text = selected.Number.ToString(); if (selected.IsPosted) { actionButton.Enabled = false; foreach (Tag node in collect(treeViewCategories.Nodes)) { foreach (int tagID in selected.TagIds) { if (node.TagID == tagID) { node.Checked = true; } } } } else { actionButton.Enabled = true; } }
public void publish(BlogEntry entry) { using (var connection = new MySqlConnection(connetionString)) using (var command = connection.CreateCommand()) { command.CommandText = "INSERT INTO " + "cb_posts(ID, post_author, post_date, post_date_gmt, post_content, post_title, post_excerpt, post_status, comment_status, ping_status, post_password, post_name, to_ping, pinged, post_modified, post_modified_gmt, post_content_filtered, post_parent, guid, menu_order, post_type, post_mime_type, comment_count) " + "VALUES (@ID, @post_author, @post_date, @post_date_gmt, @post_content, @post_title, @post_excerpt, @post_status, @comment_status, @ping_status, @post_password, @post_name, @to_ping, @pinged, @post_modified, @post_modified_gmt, @post_content_filtered, @post_parent, @guid, @menu_order, @post_type, @post_mime_type, @comment_count)"; connection.Open(); command.Parameters.AddWithValue("@ID", entry.Id); command.Parameters.AddWithValue("@post_author", 1); command.Parameters.AddWithValue("@post_date", getFormattedTime(getUTCTime())); command.Parameters.AddWithValue("@post_date_gmt", getFormattedTime(DateTime.Now)); command.Parameters.AddWithValue("@post_content", entry.Content); command.Parameters.AddWithValue("@post_title", entry.Title); command.Parameters.AddWithValue("@post_excerpt", ""); command.Parameters.AddWithValue("@post_status", "publish"); command.Parameters.AddWithValue("@comment_status", "open"); command.Parameters.AddWithValue("@ping_status", "open"); command.Parameters.AddWithValue("@post_password", ""); command.Parameters.AddWithValue("@post_name", entry.Name); command.Parameters.AddWithValue("@to_ping", ""); command.Parameters.AddWithValue("@pinged", ""); command.Parameters.AddWithValue("@post_modified", ""); command.Parameters.AddWithValue("@post_modified_gmt", ""); command.Parameters.AddWithValue("@post_content_filtered", ""); command.Parameters.AddWithValue("@post_parent", 0); command.Parameters.AddWithValue("@guid", "http://telewizjatychy.pl/?p=" + entry.Id); command.Parameters.AddWithValue("@menu_order", 0); command.Parameters.AddWithValue("@post_type", "post"); command.Parameters.AddWithValue("@post_mime_type", ""); command.Parameters.AddWithValue("@comment_count", 0); command.ExecuteNonQuery(); } setTags(entry); entry.IsPosted = true; }