save.php 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  1. <?php
  2. /**
  3. * Edit blog form
  4. *
  5. * @package Blog
  6. */
  7. $blog = get_entity($vars['guid']);
  8. $vars['entity'] = $blog;
  9. $draft_warning = $vars['draft_warning'];
  10. if ($draft_warning) {
  11. $draft_warning = '<span class="mbm elgg-text-help">' . $draft_warning . '</span>';
  12. }
  13. $delete_link = '';
  14. $preview_button = '';
  15. if ($vars['guid']) {
  16. // add a delete button if editing
  17. $delete_url = "action/blog/delete?guid={$vars['guid']}";
  18. $delete_link = elgg_view('output/url', array(
  19. 'href' => $delete_url,
  20. 'text' => elgg_echo('delete'),
  21. 'class' => 'elgg-button elgg-button-delete float-alt',
  22. 'confirm' => elgg_echo('deleteconfirm')
  23. ));
  24. }
  25. // published blogs do not get the preview button
  26. if (!$vars['guid'] || ($blog && $blog->status != 'published')) {
  27. $preview_button = elgg_view('input/submit', array(
  28. 'value' => elgg_echo('preview'),
  29. 'name' => 'preview',
  30. 'class' => 'mls elgg-button-action',
  31. ));
  32. }
  33. $icon_remove_input = "";
  34. if ($vars["guid"]) {
  35. $icon_label = elgg_echo("blog_tools:label:icon:exists");
  36. if ($blog->icontime) {
  37. $icon_remove_input = "<br /><img src='" . $blog->getIconURL() . "' />";
  38. $icon_remove_input .= "<br />";
  39. $icon_remove_input .= elgg_view("input/checkbox", array(
  40. "name" => "remove_icon",
  41. "value" => "yes"
  42. ));
  43. $icon_remove_input .= elgg_echo("blog_tools:label:icon:remove");
  44. }
  45. } else {
  46. $icon_label = elgg_echo("blog_tools:label:icon:new");
  47. }
  48. if ($vars['guid']) {
  49. $entity = get_entity($vars['guid']);
  50. $saved = date('F j, Y @ H:i', $entity->time_created);
  51. } else {
  52. $saved = elgg_echo('never');
  53. }
  54. // publication options
  55. $status = "<div class='mbs'>";
  56. $status .= "<label for='blog_status'>" . elgg_echo('status') . "</label>";
  57. $status .= elgg_view('input/dropdown', array(
  58. 'name' => 'status',
  59. 'id' => 'blog_status',
  60. 'value' => $vars['status'],
  61. 'options_values' => array(
  62. 'draft' => elgg_echo('status:draft'),
  63. 'published' => elgg_echo('status:published')
  64. ),
  65. 'class' => 'mls'
  66. ));
  67. $status .= "</div>";
  68. // advanced publication options
  69. if (blog_tools_use_advanced_publication_options()) {
  70. if (!empty($blog)) {
  71. $publication_date_value = elgg_extract("publication_date", $vars, $blog->publication_date);
  72. $expiration_date_value = elgg_extract("expiration_date", $vars, $blog->expiration_date);
  73. } else {
  74. $publication_date_value = elgg_extract("publication_date", $vars);
  75. $expiration_date_value = elgg_extract("expiration_date", $vars);
  76. }
  77. if (empty($publication_date_value)) {
  78. $publication_date_value = "";
  79. }
  80. if (empty($expiration_date_value)) {
  81. $expiration_date_value = "";
  82. }
  83. $publication_date = "<div class='mbs'>";
  84. $publication_date .= "<label for='publication_date'>" . elgg_echo("blog_tools:label:publication_date") . "</label>";
  85. $publication_date .= elgg_view("input/date", array(
  86. "name" => "publication_date",
  87. "value" => $publication_date_value));
  88. $publication_date .= "<div class='elgg-subtext'>" . elgg_echo("blog_tools:publication_date:description") . "</div>";
  89. $publication_date .= "</div>";
  90. $expiration_date = "<div class='mbs'>";
  91. $expiration_date .= "<label for='expiration_date'>" . elgg_echo("blog_tools:label:expiration_date") . "</label>";
  92. $expiration_date .= elgg_view("input/date", array(
  93. "name" => "expiration_date",
  94. "value" => $expiration_date_value));
  95. $expiration_date .= "<div class='elgg-subtext'>" . elgg_echo("blog_tools:expiration_date:description") . "</div>";
  96. $expiration_date .= "</div>";
  97. $publication_options = elgg_view_module("info", elgg_echo("blog_tools:label:publication_options"), $status . $publication_date . $expiration_date);
  98. } else {
  99. $publication_options = $status;
  100. }
  101. // show owner
  102. $show_owner_setting = elgg_get_plugin_setting("show_full_owner", "blog_tools");
  103. if (empty($show_owner_setting)) {
  104. $show_owner_setting = "no";
  105. }
  106. if (empty($blog)) {
  107. $show_owner_value = elgg_extract("show_owner", $vars, $show_owner_setting);
  108. } else {
  109. $show_owner_value = elgg_extract("show_owner", $vars, $blog->show_owner);
  110. }
  111. if ($show_owner_setting == "optional") {
  112. $show_owner_input = elgg_view('input/dropdown', array(
  113. 'name' => 'show_owner',
  114. 'id' => 'blog_show_owner',
  115. 'class' => 'mls',
  116. 'value' => $show_owner_value,
  117. 'options_values' => array('no' => elgg_echo('option:no'), 'yes' => elgg_echo('option:yes'))
  118. ));
  119. } else {
  120. $show_owner_input = elgg_view('input/hidden', array(
  121. 'name' => 'show_owner',
  122. 'id' => 'blog_show_owner',
  123. 'value' => $show_owner_value,
  124. ));
  125. }
  126. // start drawing the form
  127. echo $draft_warning;
  128. // title
  129. echo "<div>";
  130. echo "<label for='blog_title'>" . elgg_echo('title') . "</label>";
  131. echo elgg_view('input/text', array('name' => 'title', 'id' => 'blog_title', 'value' => $vars['title']));
  132. echo "</div>";
  133. // exerpt
  134. echo "<div>";
  135. echo "<label for='blog_excerpt'>" . elgg_echo('blog:excerpt') . "</label>";
  136. echo elgg_view('input/text', array('name' => 'excerpt', 'id' => 'blog_excerpt', 'value' => _elgg_html_decode($vars['excerpt'])));
  137. echo "</div>";
  138. // icon
  139. echo "<div>";
  140. echo "<label for='blog_icon'>$icon_label</label>";
  141. echo elgg_view("input/file", array("name" => "icon", "id" => "blog_icon"));
  142. echo $icon_remove_input;
  143. echo "</div>";
  144. // the blog content
  145. echo "<div>";
  146. echo "<label for='blog_description'>" . elgg_echo('blog:body') . "</label>";
  147. echo elgg_view('input/longtext', array('name' => 'description', 'id' => 'blog_description', 'value' => $vars['description']));
  148. echo "</div>";
  149. // tags
  150. echo "<div>";
  151. echo "<label for='blog_tags'>" . elgg_echo('tags') . "</label>";
  152. echo elgg_view('input/tags', array('name' => 'tags', 'id' => 'blog_tags', 'value' => $vars['tags']));
  153. echo "</div>";
  154. // categories
  155. echo elgg_view('input/categories', $vars);
  156. // comments
  157. echo "<div>";
  158. echo "<label for='blog_comments_on'>" . elgg_echo('comments') . "</label>";
  159. echo elgg_view('input/dropdown', array(
  160. 'name' => 'comments_on',
  161. 'id' => 'blog_comments_on',
  162. 'class' => 'mls',
  163. 'value' => $vars['comments_on'],
  164. 'options_values' => array(
  165. 'On' => elgg_echo('on'),
  166. 'Off' => elgg_echo('off')
  167. )
  168. ));
  169. echo "</div>";
  170. // show owner information
  171. if ($show_owner_setting == "optional") {
  172. echo "<div>";
  173. echo "<label for='blog_show_owner'>" . elgg_echo('blog_tools:label:show_owner') . "</label>";
  174. echo $show_owner_input;
  175. echo "</div>";
  176. } else {
  177. echo $show_owner_input;
  178. }
  179. // access
  180. echo "<div>";
  181. echo "<label for='blog_access_id'>" . elgg_echo('access') . "</label>";
  182. echo elgg_view('input/access', array('name' => 'access_id', 'id' => 'blog_access_id', 'class' => 'mls', 'value' => $vars['access_id']));
  183. echo "</div>";
  184. // advanced publication options
  185. echo $publication_options;
  186. // buttons and hidden inputs
  187. echo "<div class='elgg-foot'>";
  188. echo "<div class='elgg-subtext mbm'>";
  189. echo elgg_echo('blog:save_status');
  190. echo "<span class='blog-save-status-time mls'>$saved</span>";
  191. echo "</div>";
  192. echo elgg_view('input/hidden', array('name' => 'guid', 'value' => $vars['guid']));
  193. echo elgg_view('input/hidden', array('name' => 'container_guid', 'value' => elgg_get_page_owner_guid()));
  194. echo elgg_view('input/submit', array('value' => elgg_echo('save'), 'name' => 'save'));
  195. echo $preview_button;
  196. echo $delete_link;
  197. echo "</div>";