01 sub edit_entry {
02     my ($cb, $app, $param, $tmpl) = @_;
03     my $blog = $app->blog;
04     my $plugin = MT->component('FacebookPoster');
05     my $fb_thumbnail = $plugin->get_config_value('fjfbp_picture_url', 'blog:' . $blog->id) || '';
06 
07     # set 'Publish to Facebook' checkbox
08     my $checked = 0;
09     if (!$param->{new_object}) {
10         my $entry = MT->model('entry')->load($param->{id});
11         $checked = 1 if ($entry->fjfbp_publish);
12         $fb_thumbnail = $entry->fb_thumbnail if($entry->fb_thumbnail);
13     }
14     else {
15         $checked = 1 if ($plugin->get_config_value('fjfbp_' . $param->{object_type} . '_default', 'blog:' . $blog->id));
16     }
17     my $head_node = $tmpl->getElementById('header_include');
18     my $var_node = $tmpl->createElement('setvar', { 'name' => 'fjfbp_publish', 'value' => $checked });
19     $tmpl->insertBefore($var_node, $head_node);
20 
21     # set Facebook widget
22     my $varblock_node = $tmpl->createElement('setvarblock', { 'name' => 'related_content', 'append' => 1 });
23     my $innerHTML = <<HERE;
24 <mtapp:widget
25     id="entry-fbfbp-widget"
26     class="widget"
27     label="<__trans phrase=\"Facebook\">">
28     <div><input type="checkbox" name="fjfbp_publish" value="1"<mt:if name="fjfbp_publish"> checked="checked"</mt:if> /> <__trans phrase="Publish to facebook"></div>
29     <label>Facebook Thumbnail URL</label>
30     <div><input type="url" name="fb_thumbnail" class="text full" value="$fb_thumbnail" /></div>
31 </mtapp:widget>
32 HERE
33     $innerHTML = $plugin->translate_templatized($innerHTML);
34     $varblock_node->innerHTML($innerHTML);
35     $tmpl->insertBefore($varblock_node, $head_node);
36 }