PageRenderTime 110ms CodeModel.GetById 32ms RepoModel.GetById 7ms app.codeStats 0ms

/campsite/src/admin-files/articles/edit.php

https://github.com/joechrysler/Campsite
PHP | 1417 lines | 1232 code | 124 blank | 61 comment | 235 complexity | ee298216fccf09ccb8be01fb989de00f MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, LGPL-2.1, Apache-2.0

Large files files are truncated, but you can click here to view the full file

  1. <?php
  2. require_once($GLOBALS['g_campsiteDir']."/$ADMIN_DIR/articles/article_common.php");
  3. require_once($GLOBALS['g_campsiteDir']. "/$ADMIN_DIR/articles/editor_load_tinymce.php");
  4. require_once($GLOBALS['g_campsiteDir'].'/classes/DbReplication.php');
  5. require_once($GLOBALS['g_campsiteDir'].'/classes/ArticlePublish.php');
  6. require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleAttachment.php');
  7. require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleImage.php');
  8. require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleTopic.php');
  9. require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleAudioclip.php');
  10. require_once($GLOBALS['g_campsiteDir'].'/classes/ShortURL.php');
  11. camp_load_translation_strings("article_comments");
  12. if (SystemPref::Get('UseCampcasterAudioclips') == 'Y') {
  13. camp_load_translation_strings("article_audioclips");
  14. }
  15. camp_load_translation_strings("api");
  16. // These are optional, depending on whether you are in a section
  17. // or whether editing an article that doesnt have a location.
  18. $f_publication_id = Input::Get('f_publication_id', 'int', 0, true);
  19. $f_issue_number = Input::Get('f_issue_number', 'int', 0, true);
  20. $f_section_number = Input::Get('f_section_number', 'int', 0, true);
  21. $f_language_id = Input::Get('f_language_id', 'int', 0, true);
  22. $f_article_number = Input::Get('f_article_number', 'int', 0);
  23. $f_unlock = Input::Get('f_unlock', 'string', false, true);
  24. // Saved session values
  25. // $f_edit_mode can be "view" or "edit"
  26. $f_edit_mode = camp_session_get('f_edit_mode', 'edit');
  27. // Whether to show comments at the bottom of the article
  28. // (you may not want to show them to speed up your loading time)
  29. $f_show_comments = camp_session_get('f_show_comments', 1);
  30. // Selected language of the article
  31. $f_language_selected = (int)camp_session_get('f_language_selected', 0);
  32. if (!Input::IsValid()) {
  33. camp_html_display_error(getGS('Invalid input: $1', Input::GetErrorString()), $_SERVER['REQUEST_URI']);
  34. exit;
  35. }
  36. // Fetch article
  37. $articleObj = new Article($f_language_selected, $f_article_number);
  38. if (!$articleObj->exists()) {
  39. camp_html_display_error(getGS('No such article.'));
  40. exit;
  41. }
  42. $articleAuthorObj = new Author($articleObj->getAuthorId());
  43. $articleData = $articleObj->getArticleData();
  44. // Get article type fields.
  45. $dbColumns = $articleData->getUserDefinedColumns(false, true);
  46. $articleType = new ArticleType($articleObj->getType());
  47. $articleImages = ArticleImage::GetImagesByArticleNumber($f_article_number);
  48. $lockUserObj = new User($articleObj->getLockedByUser());
  49. $articleCreator = new User($articleObj->getCreatorId());
  50. $articleEvents = ArticlePublish::GetArticleEvents($f_article_number, $f_language_selected, true);
  51. $articleTopics = ArticleTopic::GetArticleTopics($f_article_number);
  52. $articleFiles = ArticleAttachment::GetAttachmentsByArticleNumber($f_article_number, $f_language_selected);
  53. $articleAudioclips = ArticleAudioclip::GetAudioclipsByArticleNumber($f_article_number, $f_language_selected);
  54. $articleLanguages = $articleObj->getLanguages();
  55. // Create displayable "last modified" time.
  56. $lastModified = strtotime($articleObj->getLastModified());
  57. $today = getdate();
  58. $savedOn = getdate($lastModified);
  59. $savedToday = true;
  60. if ($today['year'] != $savedOn['year'] || $today['mon'] != $savedOn['mon'] || $today['mday'] != $savedOn['mday']) {
  61. $savedToday = false;
  62. }
  63. $showComments = false;
  64. $showCommentControls = false;
  65. if ($f_publication_id > 0) {
  66. $publicationObj = new Publication($f_publication_id);
  67. $issueObj = new Issue($f_publication_id, $f_language_id, $f_issue_number);
  68. $sectionObj = new Section($f_publication_id, $f_issue_number, $f_language_id, $f_section_number);
  69. $languageObj = new Language($articleObj->getLanguageId());
  70. $showCommentControls = ($publicationObj->commentsEnabled() && $articleType->commentsEnabled());
  71. $showComments = $showCommentControls && $articleObj->commentsEnabled();
  72. }
  73. if ($showComments) {
  74. require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleComment.php');
  75. if (SystemPref::Get("UseDBReplication") == 'Y') {
  76. $dbReplicationObj = new DbReplication();
  77. $connectedToOnlineServer = $dbReplicationObj->connect();
  78. if ($connectedToOnlineServer == true) {
  79. // Fetch the comments attached to this article
  80. // (from replication database)
  81. $comments = ArticleComment::GetArticleComments($f_article_number, $f_language_id);
  82. }
  83. } else {
  84. // Fetch the comments attached to this article
  85. // (from local database)
  86. $comments = ArticleComment::GetArticleComments($f_article_number, $f_language_id);
  87. }
  88. }
  89. // Automatically switch to "view" mode if user doesnt have permissions.
  90. if (!$articleObj->userCanModify($g_user)) {
  91. $f_edit_mode = "view";
  92. }
  93. //
  94. // Automatic unlocking
  95. //
  96. $locked = true;
  97. // If the article hasnt been touched in 24 hours
  98. $timeDiff = camp_time_diff_str($articleObj->getLockTime());
  99. if ($timeDiff['days'] > 0) {
  100. $articleObj->setIsLocked(false);
  101. $locked = false;
  102. }
  103. // If the user who locked the article doesnt exist anymore, unlock the article.
  104. elseif (($articleObj->getLockedByUser() != 0) && !$lockUserObj->exists()) {
  105. $articleObj->setIsLocked(false);
  106. $locked = false;
  107. }
  108. //
  109. // Automatic locking
  110. //
  111. // If the article has not been unlocked and is not locked by a user.
  112. if ($f_unlock === false) {
  113. if (!$articleObj->isLocked()) {
  114. // Lock the article
  115. $articleObj->setIsLocked(true, $g_user->getUserId());
  116. }
  117. } else {
  118. $f_edit_mode = "view";
  119. }
  120. // Automatically unlock the article is the user goes into VIEW mode
  121. $lockedByCurrentUser = ($articleObj->getLockedByUser() == $g_user->getUserId());
  122. if (($f_edit_mode == "view") && $lockedByCurrentUser) {
  123. $articleObj->setIsLocked(false);
  124. }
  125. // If the article is locked by the current user, OK to edit.
  126. if ($lockedByCurrentUser) {
  127. $locked = false;
  128. }
  129. //
  130. // Begin Display of page
  131. //
  132. include_once($GLOBALS['g_campsiteDir']."/$ADMIN_DIR/javascript_common.php");
  133. if ($f_edit_mode == "edit") {
  134. $title = getGS("Edit article");
  135. } else {
  136. $title = getGS("View article");
  137. }
  138. if ($f_publication_id > 0) {
  139. $topArray = array('Pub' => $publicationObj, 'Issue' => $issueObj,
  140. 'Section' => $sectionObj, 'Article'=>$articleObj);
  141. camp_html_content_top($title, $topArray);
  142. } else {
  143. $crumbs = array();
  144. $crumbs[] = array(getGS("Actions"), "");
  145. $crumbs[] = array($title, "");
  146. echo camp_html_breadcrumbs($crumbs);
  147. }
  148. $hasArticleBodyField = false;
  149. foreach ($dbColumns as $dbColumn) {
  150. if ($dbColumn->getType() == ArticleTypeField::TYPE_BODY) {
  151. $hasArticleBodyField = true;
  152. }
  153. }
  154. if (($f_edit_mode == "edit") && $hasArticleBodyField) {
  155. $languageSelectedObj = new Language($f_language_selected);
  156. $editorLanguage = camp_session_get('TOL_Language', $languageSelectedObj->getCode());
  157. editor_load_tinymce($dbColumns, $g_user, $f_article_number, $editorLanguage);
  158. }
  159. if ($g_user->hasPermission('EditorSpellcheckerEnabled')) {
  160. $spellcheck = 'spellcheck="true"';
  161. } else {
  162. $spellcheck = 'spellcheck="false"';
  163. }
  164. ?>
  165. <!-- YUI dependencies -->
  166. <script src="<?php echo $Campsite['WEBSITE_URL']; ?>/javascript/yui/build/yahoo/yahoo-min.js"></script>
  167. <script src="<?php echo $Campsite['WEBSITE_URL']; ?>/javascript/yui/build/event/event-min.js"></script>
  168. <script src="<?php echo $Campsite['WEBSITE_URL']; ?>/javascript/yui/build/dom/dom-min.js"></script>
  169. <script src="<?php echo $Campsite['WEBSITE_URL']; ?>/javascript/yui/build/connection/connection-min.js"></script>
  170. <script src="<?php echo $Campsite['WEBSITE_URL']; ?>/javascript/yui/build/animation/animation-min.js"></script>
  171. <script src="<?php echo $Campsite['WEBSITE_URL']; ?>/javascript/yui/build/container/container.js"></script>
  172. <!-- Autocomplete dependencies -->
  173. <script src="<?php echo $Campsite['WEBSITE_URL']; ?>/javascript/yui/build/yahoo-dom-event/yahoo-dom-event.js"></script>
  174. <script src="<?php echo $Campsite['WEBSITE_URL']; ?>/javascript/yui/build/datasource/datasource-min.js"></script>
  175. <!-- Button dependencies -->
  176. <script src="<?php echo $Campsite['WEBSITE_URL']; ?>/javascript/yui/build/element/element-beta-min.js"></script>
  177. <script src="<?php echo $Campsite['WEBSITE_URL']; ?>/javascript/yui/build/button/button-min.js"></script>
  178. <!-- Autocomplete Source file -->
  179. <script src="<?php echo $Campsite['WEBSITE_URL']; ?>/javascript/yui/build/autocomplete/autocomplete-min.js"></script>
  180. <!-- CSS file (default YUI Sam Skin) -->
  181. <link rel="stylesheet" type="text/css" href="<?php echo $Campsite['WEBSITE_URL']; ?>/javascript/yui/build/autocomplete/assets/skins/sam/autocomplete.css" />
  182. <link rel="stylesheet" type="text/css" href="<?php echo $Campsite['WEBSITE_URL']; ?>/javascript/yui/build/button/assets/skins/sam/button.css" />
  183. <link rel="stylesheet" type="text/css" href="<?php echo $Campsite['WEBSITE_URL']; ?>/javascript/yui/build/container/assets/container.css" />
  184. <link rel="stylesheet" type="text/css" href="/admin/articles/yui-assets/styles.css" />
  185. <?php
  186. // If the article is locked.
  187. if ($articleObj->userCanModify($g_user) && $locked && ($f_edit_mode == "edit")) {
  188. ?>
  189. <p>
  190. <table border="0" cellspacing="0" cellpadding="6" class="table_input">
  191. <tr>
  192. <td colspan="2">
  193. <b><?php putGS("Article is locked"); ?> </b>
  194. <hr noshade size="1" color="black">
  195. </td>
  196. </tr>
  197. <tr>
  198. <td colspan="2" align="center">
  199. <blockquote>
  200. <?php
  201. $timeDiff = camp_time_diff_str($articleObj->getLockTime());
  202. if ($timeDiff['hours'] > 0) {
  203. putGS('The article has been locked by $1 ($2) $3 hour(s) and $4 minute(s) ago.',
  204. '<B>'.htmlspecialchars($lockUserObj->getRealName()),
  205. htmlspecialchars($lockUserObj->getUserName()).'</B>',
  206. $timeDiff['hours'], $timeDiff['minutes']);
  207. } else {
  208. putGS('The article has been locked by $1 ($2) $3 minute(s) ago.',
  209. '<B>'.htmlspecialchars($lockUserObj->getRealName()),
  210. htmlspecialchars($lockUserObj->getUserName()).'</B>',
  211. $timeDiff['minutes']);
  212. }
  213. ?>
  214. <br/>
  215. </blockquote>
  216. </td>
  217. </tr>
  218. <tr>
  219. <td colspan="2">
  220. <div align="CENTER">
  221. <input type="button" name="Yes" value="<?php putGS('Unlock'); ?>" class="button" onclick="location.href='<?php echo camp_html_article_url($articleObj, $f_language_id, "do_unlock.php"); ?>'" />
  222. <input type="button" name="Yes" value="<?php putGS('View'); ?>" class="button" onclick="location.href='<?php echo camp_html_article_url($articleObj, $f_language_id, "edit.php", "", "&f_edit_mode=view"); ?>'" />
  223. <input type="button" name="No" value="<?php putGS('Cancel'); ?>" class="button" onclick="location.href='/<?php echo $ADMIN; ?>/articles/?f_publication_id=<?php p($f_publication_id); ?>&f_issue_number=<?php p($f_issue_number); ?>&f_language_id=<?php p($f_language_id); ?>&f_section_number=<?php p($f_section_number); ?>'" />
  224. </div>
  225. </td>
  226. </tr>
  227. </table>
  228. <p>
  229. <?php
  230. return;
  231. }
  232. if ($f_edit_mode == "edit") { ?>
  233. <style type="text/css">@import url(<?php echo $Campsite["WEBSITE_URL"]; ?>/javascript/jscalendar/calendar-system.css);</style>
  234. <script type="text/javascript" src="<?php echo $Campsite["WEBSITE_URL"]; ?>/javascript/jscalendar/calendar.js"></script>
  235. <script type="text/javascript" src="<?php echo $Campsite["WEBSITE_URL"]; ?>/javascript/jscalendar/lang/calendar-<?php echo camp_session_get('TOL_Language', 'en'); ?>.js"></script>
  236. <script type="text/javascript" src="<?php echo $Campsite["WEBSITE_URL"]; ?>/javascript/jscalendar/calendar-setup.js"></script>
  237. <?php } // if edit mode ?>
  238. <?php if ($f_publication_id > 0) { ?>
  239. <table border="0" cellspacing="0" cellpadding="1" class="action_buttons" style="padding-top: 5px;">
  240. <tr>
  241. <td><a href="<?php echo "/$ADMIN/articles/?f_publication_id=$f_publication_id&f_issue_number=$f_issue_number&f_section_number=$f_section_number&f_language_id=$f_language_id"; ?>"><img src="<?php echo $Campsite["ADMIN_IMAGE_BASE_URL"]; ?>/left_arrow.png" border="0"></a></td>
  242. <td><a href="<?php echo "/$ADMIN/articles/?f_publication_id=$f_publication_id&f_issue_number=$f_issue_number&f_section_number=$f_section_number&f_language_id=$f_language_id"; ?>"><b><?php putGS("Article List"); ?></b></a></td>
  243. <?php if ($g_user->hasPermission('AddArticle')) { ?>
  244. <td style="padding-left: 20px;"><a href="add.php?f_publication_id=<?php p($f_publication_id); ?>&f_issue_number=<?php p($f_issue_number); ?>&f_section_number=<?php p($f_section_number); ?>&f_language_id=<?php p($f_language_id); ?>" ><img src="<?php echo $Campsite["ADMIN_IMAGE_BASE_URL"]; ?>/add.png" border="0"></a></td>
  245. <td><a href="add.php?f_publication_id=<?php p($f_publication_id); ?>&f_issue_number=<?php p($f_issue_number); ?>&f_section_number=<?php p($f_section_number); ?>&f_language_id=<?php p($f_language_id); ?>" ><b><?php putGS("Add new article"); ?></b></a></td>
  246. <?php } ?>
  247. </tr>
  248. </table>
  249. <?php } ?>
  250. <?php camp_html_display_msgs("0.25em", "0.25em"); ?>
  251. <div id="yui-connection-container"></div>
  252. <div id="yui-connection-message"></div>
  253. <div id="yui-connection-error"></div>
  254. <table border="0" cellspacing="1" cellpadding="0" class="table_input" width="900px" style="margin-top: 5px;">
  255. <tr>
  256. <td width="700px" style="border-bottom: 1px solid #8baed1;" colspan="2">
  257. <!-- for the left side of the article edit screen -->
  258. <table cellpadding="0" cellspacing="0">
  259. <tr>
  260. <td width="100%" valign="middle">
  261. <!-- BEGIN the article control bar -->
  262. <form name="article_actions" action="do_article_action.php" method="POST">
  263. <input type="hidden" name="f_publication_id" id="f_publication_id" value="<?php p($f_publication_id); ?>" />
  264. <input type="hidden" name="f_issue_number" id="f_issue_number" value="<?php p($f_issue_number); ?>" />
  265. <input type="hidden" name="f_section_number" id="f_section_number" value="<?php p($f_section_number); ?>" />
  266. <input type="hidden" name="f_language_id" id="f_language_id" value="<?php p($f_language_id); ?>" />
  267. <input type="hidden" name="f_language_selected" id="f_language_selected" value="<?php p($f_language_selected); ?>" />
  268. <input type="hidden" name="f_article_number" id="f_article_number" value="<?php p($f_article_number); ?>" />
  269. <table border="0" cellspacing="1" cellpadding="0">
  270. <tr>
  271. <td style="padding-left: 1em;">
  272. <script>
  273. function action_selected(dropdownElement) {
  274. // Get the index of the "delete" option.
  275. deleteOptionIndex = -1;
  276. for (var index = 0; index < dropdownElement.options.length; index++) {
  277. if (dropdownElement.options[index].value == "delete") {
  278. deleteOptionIndex = index;
  279. }
  280. }
  281. // if the user has selected the "delete" option
  282. if (dropdownElement.selectedIndex == deleteOptionIndex) {
  283. ok = confirm("<?php putGS("Are you sure you want to delete this article?"); ?>");
  284. if (!ok) {
  285. dropdownElement.options[0].selected = true;
  286. return;
  287. }
  288. }
  289. // do the action if it isnt the first or second option
  290. if ((dropdownElement.selectedIndex != 0) && (dropdownElement.selectedIndex != 1)) {
  291. dropdownElement.form.submit();
  292. }
  293. }
  294. </script>
  295. <select name="f_action" class="input_select" onchange="action_selected(this);">
  296. <option value=""><?php putGS("Actions"); ?>...</option>
  297. <option value="">-----------</option>
  298. <?php if ($articleObj->userCanModify($g_user) && $articleObj->isLocked()) { ?>
  299. <option value="unlock"><?php putGS("Unlock"); ?></option>
  300. <?php } ?>
  301. <?php if ($g_user->hasPermission('DeleteArticle')) { ?>
  302. <option value="delete"><?php putGS("Delete"); ?></option>
  303. <?php } ?>
  304. <?php if ($g_user->hasPermission('AddArticle')) { ?>
  305. <option value="copy"><?php putGS("Duplicate"); ?></option>
  306. <?php } ?>
  307. <?php if ($g_user->hasPermission('TranslateArticle')) { ?>
  308. <option value="translate"><?php putGS("Translate"); ?></option>
  309. <?php } ?>
  310. <?php if ($g_user->hasPermission('MoveArticle')) { ?>
  311. <option value="move"><?php putGS("Move"); ?></option>
  312. <?php } ?>
  313. </select>
  314. </td>
  315. <!-- BEGIN Workflow -->
  316. <td style="padding-left: 1em;">
  317. <?php
  318. // Show a different menu depending on the rights of the user.
  319. if ($g_user->hasPermission("Publish")) { ?>
  320. <select name="f_action_workflow" class="input_select" onchange="this.form.submit();">
  321. <?php
  322. if (isset($issueObj) && $issueObj->isPublished()) {
  323. camp_html_select_option("Y", $articleObj->getWorkflowStatus(), getGS("Status") . ': ' . getGS("Published"));
  324. } else {
  325. camp_html_select_option("M", $articleObj->getWorkflowStatus(), getGS("Status") . ': ' . getGS("Publish with issue"));
  326. }
  327. camp_html_select_option("S", $articleObj->getWorkflowStatus(), getGS("Status") . ': ' . getGS("Submitted"));
  328. camp_html_select_option("N", $articleObj->getWorkflowStatus(), getGS("Status") . ': ' . getGS("New"));
  329. ?>
  330. </select>
  331. <?php } elseif ($articleObj->userCanModify($g_user) && ($articleObj->getWorkflowStatus() != 'Y')) { ?>
  332. <select name="f_action_workflow" class="input_select" onchange="this.form.submit();">
  333. <?php
  334. camp_html_select_option("S", $articleObj->getWorkflowStatus(), getGS("Status") . ': ' . getGS("Submitted"));
  335. camp_html_select_option("N", $articleObj->getWorkflowStatus(), getGS("Status") . ': ' . getGS("New"));
  336. ?>
  337. </select>
  338. <?php } else {
  339. switch ($articleObj->getWorkflowStatus()) {
  340. case 'Y':
  341. echo getGS("Status") . ': ' . getGS("Published");
  342. break;
  343. case 'M':
  344. echo getGS("Status") . ': ' . getGS("Publish with issue");
  345. break;
  346. case 'S':
  347. echo getGS("Status") . ': ' . getGS("Submitted");
  348. break;
  349. case 'N':
  350. echo getGS("Status") . ': ' . getGS("New");
  351. break;
  352. }
  353. }
  354. if (count($articleEvents) > 0) {
  355. ?>
  356. <img src="<?php echo $Campsite["ADMIN_IMAGE_BASE_URL"]; ?>/automatic_publishing.png" alt="<?php putGS("Scheduled Publishing"); ?>" title="<?php putGS("Scheduled Publishing"); ?>" border="0" width="22" height="22" align="middle" style="padding-bottom: 1px;">
  357. <?php
  358. }
  359. ?>
  360. </td>
  361. <!-- END Workflow -->
  362. <td style="padding-left: 1em;">
  363. <table border="0" cellspacing="0" cellpadding="3">
  364. <tr>
  365. <td><?php putGS('Language'); ?>:</td>
  366. <td>
  367. <?php
  368. if (count($articleLanguages) > 1) {
  369. $languageUrl = "edit.php?f_publication_id=$f_publication_id"
  370. ."&f_issue_number=$f_issue_number"
  371. ."&f_section_number=$f_section_number"
  372. ."&f_article_number=$f_article_number"
  373. ."&f_language_id=$f_language_id"
  374. ."&f_language_selected=";
  375. ?>
  376. <select name="f_language_selected" class="input_select" onchange="dest = '<?php p($languageUrl); ?>'+this.options[this.selectedIndex].value; location.href=dest;">
  377. <?php
  378. foreach ($articleLanguages as $articleLanguage) {
  379. camp_html_select_option($articleLanguage->getLanguageId(), $f_language_selected, htmlspecialchars($articleLanguage->getNativeName()));
  380. }
  381. ?></select>
  382. <?php } else {
  383. $articleLanguage = camp_array_peek($articleLanguages);
  384. echo '<b>'.htmlspecialchars($articleLanguage->getNativeName()).'</b>';
  385. }
  386. ?>
  387. </td>
  388. </tr>
  389. </table>
  390. </td>
  391. </tr>
  392. </table>
  393. </form>
  394. <!-- END the article control bar -->
  395. </td>
  396. <?php
  397. if ($articleObj->userCanModify($g_user)) {
  398. $switchModeUrl = camp_html_article_url($articleObj, $f_language_id, "edit.php")
  399. ."&f_edit_mode=".( ($f_edit_mode =="edit") ? "view" : "edit");
  400. ?>
  401. <td align="right" style="padding-top: 1px;" valign="top">
  402. <table cellpadding="0" cellspacing="0" border="0">
  403. <tr><td>
  404. <input type="button" name="edit" value="<?php putGS("Edit"); ?>" <?php if ($f_edit_mode == "edit") {?> disabled class="button_disabled" <?php } else { ?> onclick="location.href='<?php p($switchModeUrl); ?>';" class="button" <?php } ?> />
  405. </td>
  406. <td style="padding-left: 5px; padding-right: 10px;">
  407. <input type="button" name="edit" value="<?php putGS("View"); ?>" <?php if ($f_edit_mode == "view") {?> disabled class="button_disabled" <?php } else { ?> onclick="location.href='<?php p($switchModeUrl); ?>';" class="button" <?php } ?> />
  408. </td>
  409. <td nowrap>
  410. <div id="yui-saved-box">
  411. <div id="yui-connection-saved"></div>
  412. <div id="yui-saved">
  413. <script>
  414. var dateTime = '<?php if ($savedToday) { p(date("H:i:s", $lastModified)); } else { p(date("Y-m-d H:i", $lastModified)); } ?>';
  415. if (document.getElementById('yui-connection-saved').value == undefined) {
  416. document.write('<?php putGS("Saved:"); ?> ' + dateTime);
  417. }
  418. </script>
  419. </div>
  420. </div>
  421. </td>
  422. </tr></table>
  423. </td>
  424. <?php } ?>
  425. </tr>
  426. </table>
  427. </td>
  428. </tr>
  429. <tr>
  430. <td valign="top">
  431. <!-- BEGIN article content -->
  432. <form name="article_edit" action="do_edit.php" method="POST">
  433. <fieldset id="pushbuttonsfrommarkup" class=" yui-skin-sam">
  434. <input type="hidden" name="f_publication_id" value="<?php p($f_publication_id); ?>" />
  435. <input type="hidden" name="f_issue_number" value="<?php p($f_issue_number); ?>" />
  436. <input type="hidden" name="f_section_number" value="<?php p($f_section_number); ?>" />
  437. <input type="hidden" name="f_language_id" value="<?php p($f_language_id); ?>" />
  438. <input type="hidden" name="f_language_selected" value="<?php p($f_language_selected); ?>" />
  439. <input type="hidden" name="f_article_number" value="<?php p($f_article_number); ?>" />
  440. <input type="hidden" name="f_message" id="f_message" value="" />
  441. <table width="100%">
  442. <tr>
  443. <td style="padding-top: 3px;">
  444. <?php if ($f_edit_mode == "edit") { ?>
  445. <table width="100%" style="border-bottom: 1px solid #8baed1; padding: 0px;">
  446. <tr>
  447. <td align="center">
  448. <?php if ($f_publication_id > 0) { ?>
  449. <!-- Preview Link -->
  450. <input type="submit" name="preview" value="<?php putGS('Preview'); ?>" class="button" onclick="window.open('/<?php echo $ADMIN; ?>/articles/preview.php?f_publication_id=<?php p($f_publication_id); ?>&amp;f_issue_number=<?php p($f_issue_number); ?>&amp;f_section_number=<?php p($f_section_number); ?>&amp;f_article_number=<?php p($f_article_number); ?>&amp;f_language_id=<?php p($f_language_id); ?>&amp;f_language_selected=<?php p($f_language_selected); ?>', 'fpreview', 'resizable=yes, menubar=no, toolbar=no, width=680, height=560'); return false">
  451. &nbsp;&nbsp;&nbsp;&nbsp;
  452. <?php } ?>
  453. <input type="button" name="save" id="save" value="<?php putGS('Save All'); ?>" class="button" onClick="makeRequest('all');" />
  454. &nbsp;&nbsp;&nbsp;&nbsp;
  455. <input type="submit" name="save_and_close" id="save_and_close" value="<?php putGS('Save and Close'); ?>" class="button" />
  456. </td>
  457. </tr>
  458. </table>
  459. <?php } ?>
  460. <table width="100%" style="border-bottom: 1px solid #8baed1; padding-bottom: 3px;">
  461. <tr>
  462. <td align="left" valign="top" style="padding-right: 5px;">
  463. <?php if ($f_edit_mode == "edit") { ?>
  464. <input type="button" id="save_f_article_title" name="button4" value="<?php putGS('Saved'); ?>">
  465. <?php } ?>
  466. </td>
  467. <td align="right" valign="top"><b><?php putGS("Name"); ?>:</b></td>
  468. <td align="left" valign="top" colspan="2">
  469. <?php if ($f_edit_mode == "edit") { ?>
  470. <input type="text" name="f_article_title" id="f_article_title" size="55" class="input_text" value="<?php print htmlspecialchars($articleObj->getTitle()); ?>" onkeyup="buttonEnable('save_f_article_title');" <?php print $spellcheck ?> />
  471. <?php } else {
  472. print wordwrap(htmlspecialchars($articleObj->getTitle()), 60, "<br>");
  473. }
  474. ?>
  475. </td>
  476. </tr>
  477. <tr>
  478. <td align="left" valign="top" style="padding-right: 5px;">
  479. <?php if ($f_edit_mode == "edit") { ?>
  480. <input type="button" id="save_f_article_author" name="button5" value="<?php putGS('Saved'); ?>">
  481. <?php } ?>
  482. </td>
  483. <td align="right" valign="top"><b><?php putGS("Author"); ?>:</b></td>
  484. <td align="left" valign="top" class="yui-skin-sam">
  485. <?php if ($f_edit_mode == "edit") { ?>
  486. <div id="authorAutoComplete">
  487. <input type="text" name="f_article_author" id="f_article_author" size="45" class="input_text" value="<?php print htmlspecialchars($articleAuthorObj->getName()); ?>" onkeyup="buttonEnable('save_f_article_author');" />
  488. <div id="authorContainer"></div>
  489. </div>
  490. <?php } else {
  491. print wordwrap(htmlspecialchars($articleAuthorObj->getName()), 60, "<br>");
  492. }
  493. ?>
  494. </td>
  495. <td align="right" valign="top" style="padding-right: 0.5em;"><b><?php putGS("Created by"); ?>:</b> <?php p(htmlspecialchars($articleCreator->getRealName())); ?></td>
  496. </tr>
  497. </table>
  498. <table cellpadding="0" cellspacing="0" width="100%">
  499. <tr>
  500. <td align="left" valign="top">
  501. <!-- Left-hand column underneath article title -->
  502. <table>
  503. <tr>
  504. <td align="right" valign="top" style="padding-left: 1em;"><b><?php putGS("Reads"); ?>:</b></td>
  505. <td align="left" valign="top">
  506. <?php
  507. if ($articleObj->isPublished()) {
  508. $requestObject = new RequestObject($articleObj->getProperty('object_id'));
  509. if ($requestObject->exists()) {
  510. echo $requestObject->getRequestCount();
  511. } else {
  512. echo "0";
  513. }
  514. } else {
  515. putGS("N/A");
  516. }
  517. ?>
  518. </td>
  519. </tr>
  520. <!-- Type -->
  521. <tr>
  522. <td align="right" valign="top" style="padding-left: 1em;"><b><?php putGS("Type"); ?>:</b></td>
  523. <td align="left" valign="top">
  524. <?php print htmlspecialchars($articleType->getDisplayName()); ?>
  525. </td>
  526. </tr>
  527. <!-- Number -->
  528. <tr>
  529. <td align="right" valign="top" nowrap><b><?php putGS("Number"); ?>:</b></td>
  530. <td align="left" valign="top" style="padding-top: 2px; padding-left: 4px;">
  531. <?php
  532. p($articleObj->getArticleNumber());
  533. if (isset($publicationObj) && $publicationObj->getUrlTypeId() == 2 && $articleObj->isPublished()) {
  534. $url = ShortURL::GetURL($publicationObj->getPublicationId(), $articleObj->getLanguageId(), null, null, $articleObj->getArticleNumber());
  535. if (PEAR::isError($url)) {
  536. echo $url->getMessage();
  537. } else {
  538. echo '&nbsp;(<a href="' . $url . '">' . getGS("Link to public page") . '</a>)';
  539. }
  540. }
  541. ?></td>
  542. </tr>
  543. <!-- Creation Date -->
  544. <tr>
  545. <td align="right" valign="top" style="padding-left: 1em;"><b><nobr><?php putGS("Creation date"); ?>:</nobr></b></td>
  546. <td align="left" valign="top" nowrap>
  547. <?php if ($f_edit_mode == "edit") { ?>
  548. <input type="hidden" name="f_creation_date" value="<?php p($articleObj->getCreationDate()); ?>" id="f_creation_date" />
  549. <table cellpadding="0" cellspacing="2"><tr>
  550. <td><span id="show_c_date"><?php p($articleObj->getCreationDate()); ?></span></td>
  551. <td valign="top" align="left"><img src="<?php echo $Campsite["ADMIN_IMAGE_BASE_URL"]; ?>/calendar.gif" id="f_trigger_c"
  552. style="cursor: pointer; border: 1px solid red;"
  553. title="Date selector"
  554. onmouseover="this.style.background='red';"
  555. onmouseout="this.style.background=''" /></td>
  556. </tr></table>
  557. <script type="text/javascript">
  558. Calendar.setup({
  559. inputField:"f_creation_date",
  560. ifFormat:"%Y-%m-%d %H:%M:00",
  561. displayArea:"show_c_date",
  562. daFormat:"%Y-%m-%d %H:%M:00",
  563. showsTime:true,
  564. showOthers:true,
  565. weekNumbers:false,
  566. range:new Array(1990, 2020),
  567. button:"f_trigger_c"
  568. });
  569. </script>
  570. <?php } else { ?>
  571. <?php print htmlspecialchars($articleObj->getCreationDate()); ?>
  572. <?php } ?>
  573. </td>
  574. </tr>
  575. <!-- End creation date -->
  576. <tr>
  577. <td align="right" valign="top" style="padding-left: 1em;"><b><?php putGS("Publish date"); ?>:</b></td>
  578. <td align="left" valign="top">
  579. <?php if ($f_edit_mode == "edit" && $articleObj->isPublished()) { ?>
  580. <input type="hidden" name="f_publish_date" value="<?php p($articleObj->getPublishDate()); ?>" id="f_publish_date" />
  581. <table cellpadding="0" cellspacing="2"><tr>
  582. <td><span id="show_p_date"><?php p($articleObj->getPublishDate()); ?></span></td>
  583. <td valign="top" align="left"><img src="<?php echo $Campsite["ADMIN_IMAGE_BASE_URL"]; ?>/calendar.gif" id="f_trigger_p"
  584. style="cursor: pointer; border: 1px solid red;"
  585. title="Date selector"
  586. onmouseover="this.style.background='red';"
  587. onmouseout="this.style.background=''" /></td>
  588. </tr></table>
  589. <script type="text/javascript">
  590. Calendar.setup({
  591. inputField:"f_publish_date",
  592. ifFormat:"%Y-%m-%d %H:%M:00",
  593. displayArea:"show_p_date",
  594. daFormat:"%Y-%m-%d %H:%M:00",
  595. showsTime:true,
  596. showOthers:true,
  597. weekNumbers:false,
  598. range:new Array(1990, 2020),
  599. button:"f_trigger_p"
  600. });
  601. </script>
  602. <?php } elseif ($articleObj->isPublished()) { ?>
  603. <?php print htmlspecialchars($articleObj->getPublishDate()); ?>
  604. <?php } else { ?>
  605. <input type="hidden" name="f_publish_date" value="<?php p($articleObj->getPublishDate()); ?>" id="f_publish_date" />
  606. <?php putGS('N/A'); } ?>
  607. </td>
  608. </tr>
  609. </table>
  610. </td>
  611. <!-- Right-hand column underneath article title -->
  612. <td valign="top" align="right" style="padding-right: 2em; padding-top: 0.25em;">
  613. <table border="0" cellpadding="0" cellspacing="1">
  614. <!-- Show article on front page -->
  615. <tr>
  616. <td align="right" valign="top"><input type="CHECKBOX" name="f_on_front_page" id="f_on_front_page" class="input_checkbox" <?php if ($articleObj->onFrontPage()) { ?> CHECKED<?php } ?> <?php if ($f_edit_mode == "view") { ?>disabled<?php }?> /></td>
  617. <td align="left" valign="top" style="padding-top: 0.1em;">
  618. <?php putGS('Show article on front page'); ?>
  619. </td>
  620. </tr>
  621. <!-- Show article on section page -->
  622. <tr>
  623. <td align="right" valign="top"><input type="CHECKBOX" name="f_on_section_page" id="f_on_section_page" class="input_checkbox" <?php if ($articleObj->onSectionPage()) { ?> CHECKED<?php } ?> <?php if ($f_edit_mode == "view") { ?>disabled<?php }?> /></td>
  624. <td align="left" valign="top" style="padding-top: 0.1em;">
  625. <?php putGS('Show article on section page'); ?>
  626. </td>
  627. </tr>
  628. <!-- Article viewable by public -->
  629. <tr>
  630. <td align="right" valign="top"><input type="CHECKBOX" name="f_is_public" id="f_is_public" class="input_checkbox" <?php if ($articleObj->isPublic()) { ?> CHECKED<?php } ?> <?php if ($f_edit_mode == "view") { ?>disabled<?php }?> /></td>
  631. <td align="left" valign="top" style="padding-top: 0.1em;">
  632. <?php putGS('Visible to non-subscribers'); ?>
  633. </td>
  634. </tr>
  635. <!-- Comments enabled -->
  636. <?php
  637. if ($showCommentControls) {
  638. ?>
  639. <tr>
  640. <td align="left" colspan="2" style="padding-top: 0.25em;">
  641. <?php putGS("Comments"); ?>:
  642. <select name="f_comment_status" id="f_comment_status" class="input_select" <?php if ($f_edit_mode == "view") { ?>disabled<?php } ?>>
  643. <?php
  644. if ($articleObj->commentsEnabled()) {
  645. if ($articleObj->commentsLocked()) {
  646. $commentStatus = 'locked';
  647. } else {
  648. $commentStatus = 'enabled';
  649. }
  650. } else {
  651. $commentStatus = 'disabled';
  652. }
  653. camp_html_select_option('disabled', $commentStatus, getGS("Disabled"));
  654. camp_html_select_option('locked', $commentStatus, getGS("Locked"));
  655. camp_html_select_option('enabled', $commentStatus, getGS("Enabled"));
  656. ?>
  657. </select>
  658. </td>
  659. </tr>
  660. <?php } // end if comments enabled ?>
  661. </table>
  662. </td>
  663. </tr>
  664. </table>
  665. </td>
  666. </tr>
  667. <tr>
  668. <td style="border-top: 1px solid #8baed1; padding-top: 3px;">
  669. <table>
  670. <tr>
  671. <td align="left" style="padding-right: 5px;">
  672. <?php if ($f_edit_mode == "edit") { ?>
  673. <input type="button" id="save_f_keywords" name="button6" value="<?php putGS('Saved'); ?>">
  674. <?php } ?>
  675. </td>
  676. <td align="right" ><?php putGS("Keywords"); ?>:</td>
  677. <td>
  678. <?php if ($f_edit_mode == "edit") { ?>
  679. <input type="TEXT" name="f_keywords" id="f_keywords" value="<?php print htmlspecialchars($articleObj->getKeywords()); ?>" class="input_text" size="50" maxlength="255" onkeyup="buttonEnable('save_f_keywords');" <?php print $spellcheck ?> />
  680. <?php } else {
  681. print htmlspecialchars($articleObj->getKeywords());
  682. }
  683. ?>
  684. </td>
  685. </tr>
  686. <?php
  687. $fCustomFields = array();
  688. $fCustomSwitches = array();
  689. $fCustomTextareas = array();
  690. $saveButtons = array();
  691. $saveButtonNames = array('save_f_article_title','save_f_article_author','save_f_keywords');
  692. // Display the article type fields.
  693. foreach ($dbColumns as $dbColumn) {
  694. if ($dbColumn->getType() == ArticleTypeField::TYPE_TEXT) {
  695. // Single line text fields
  696. ?>
  697. <tr>
  698. <td align="left" style="padding-right: 5px;">
  699. <?php if ($f_edit_mode == "edit") {
  700. $saveButtonNames[] = 'save_' . $dbColumn->getName();
  701. $saveButtons[] = 'var oSave' . $dbColumn->getName() .'Button = new YAHOO.widget.Button("save_' . $dbColumn->getName() . '", {
  702. onclick: { fn: onButtonClick },
  703. disabled: true
  704. });';
  705. ?>
  706. <input type="button" id="save_<?php p($dbColumn->getName()); ?>" value="<?php putGS('Saved'); ?>">
  707. <?php } ?>
  708. </td>
  709. <td align="right">
  710. <?php echo htmlspecialchars($dbColumn->getDisplayName()); ?>:
  711. </td>
  712. <td>
  713. <?php
  714. if ($f_edit_mode == "edit") {
  715. $fCustomFields[] = $dbColumn->getName();
  716. ?>
  717. <input name="<?php echo $dbColumn->getName(); ?>"
  718. id="<?php echo $dbColumn->getName(); ?>"
  719. type="TEXT"
  720. value="<?php print htmlspecialchars($articleData->getProperty($dbColumn->getName())); ?>"
  721. class="input_text"
  722. size="50"
  723. maxlength="255"
  724. onkeyup="buttonEnable('save_<?php p($dbColumn->getName()); ?>');"
  725. <?php print $spellcheck ?> />
  726. <?php } else {
  727. print htmlspecialchars($articleData->getProperty($dbColumn->getName()));
  728. }
  729. ?>
  730. </td>
  731. </tr>
  732. <?php
  733. } elseif ($dbColumn->getType() == ArticleTypeField::TYPE_DATE) {
  734. // Date fields
  735. if ($articleData->getProperty($dbColumn->getName()) == "0000-00-00") {
  736. $articleData->setProperty($dbColumn->getName(), "CURDATE()", true, true);
  737. }
  738. ?>
  739. <tr>
  740. <td align="left" style="padding-right: 5px;">
  741. <?php if ($f_edit_mode == "edit") { ?>
  742. <input type="button" id="save_<?php p($dbColumn->getName()); ?>" value="<?php putGS('Saved'); ?>">
  743. <?php } ?>
  744. </td>
  745. <td align="right">
  746. <?php echo htmlspecialchars($dbColumn->getDisplayName()); ?>:
  747. </td>
  748. <td>
  749. <?php
  750. if ($f_edit_mode == "edit") {
  751. $fCustomFields[] = $dbColumn->getName();
  752. $saveButtonNames[] = 'save_' . $dbColumn->getName();
  753. $saveButtons[] = 'var oSave' . $dbColumn->getName() .'Button = new YAHOO.widget.Button("save_' . $dbColumn->getName() . '", {
  754. onclick: { fn: onButtonClick },
  755. disabled: true
  756. });';
  757. ?>
  758. <input name="<?php echo $dbColumn->getName(); ?>"
  759. id="<?php echo $dbColumn->getName(); ?>"
  760. type="TEXT"
  761. value="<?php echo htmlspecialchars($articleData->getProperty($dbColumn->getName())); ?>"
  762. class="input_text"
  763. size="11"
  764. maxlength="10"
  765. onkeyup="buttonEnable('save_<?php p($dbColumn->getName()); ?>');" />
  766. <?php } else { ?>
  767. <span style="padding-left: 4px; padding-right: 4px; padding-top: 1px; padding-bottom: 1px; border: 1px solid #888; margin-right: 5px; background-color: #EEEEEE;"><?php echo htmlspecialchars($articleData->getProperty($dbColumn->getName())); ?></span>
  768. <?php
  769. }
  770. ?>
  771. <?php putGS('YYYY-MM-DD'); ?>
  772. </td>
  773. </tr>
  774. <?php
  775. } elseif ($dbColumn->getType() == ArticleTypeField::TYPE_BODY) {
  776. // Multiline text fields
  777. // Transform Campsite-specific tags into editor-friendly tags.
  778. $text = $articleData->getProperty($dbColumn->getName());
  779. // Subheads
  780. $text = preg_replace("/<!\*\*\s*Title\s*>/i", "<span class=\"campsite_subhead\">", $text);
  781. $text = preg_replace("/<!\*\*\s*EndTitle\s*>/i", "</span>", $text);
  782. // Internal Links with targets
  783. $text = preg_replace("/<!\*\*\s*Link\s*Internal\s*([\w=&]*)\s*target[\s\"]*([\w_]*)[\s\"]*>/i", '<a href="/campsite/campsite_internal_link?$1" target="$2">', $text);
  784. // Internal Links without targets
  785. $text = preg_replace("/<!\*\*\s*Link\s*Internal\s*([\w=&]*)\s*>/i", '<a href="/campsite/campsite_internal_link?$1">', $text);
  786. // External Links (old style 2.1) with targets
  787. $text = preg_replace("/<!\*\*\s*Link\s*External[\s\"]*([^\s\"]*)[\s\"]*target[\s\"]*([\w_]*)[\s\"]*>/i", '<a href="$1" target="$2">', $text);
  788. // External Links (old style 2.1) without targets
  789. $text = preg_replace("/<!\*\*\s*Link\s*External[\s\"]*([^\s\"]*)[\s\"]*>/i", '<a href="$1">', $text);
  790. // End link
  791. $text = preg_replace("/<!\*\*\s*EndLink\s*>/i", "</a>", $text);
  792. // Images
  793. preg_match_all("/<!\*\*\s*Image\s*([\d]*)\s*/i",$text, $imageMatches);
  794. preg_match_all("/\s*sub=\"(.*?)\"/", $text, $titles);
  795. preg_match_all("/<!\*\*\s*Image\s*([\d]*)\s*(.*?)\s*ratio=\"(.*?)\"/", $text, $ratios);
  796. if (isset($imageMatches[1][0])) {
  797. if (isset($titles) && sizeof($titles) > 0) {
  798. for($x = 0; $x < sizeof($titles[0]); $x++) {
  799. $text = preg_replace("/\s*".preg_replace('~\/~', '\/',
  800. $titles[0][$x])."/", ' title="'.$titles[1][$x].'"', $text);
  801. }
  802. }
  803. $formattingErrors = false;
  804. foreach ($imageMatches[1] as $templateId) {
  805. // Get the image URL
  806. $articleImage = new ArticleImage($f_article_number, null, $templateId);
  807. if (!$articleImage->exists()) {
  808. ArticleImage::RemoveImageTagsFromArticleText($f_article_number, $templateId);
  809. $formattingErrors = true;
  810. continue;
  811. }
  812. $image = new Image($articleImage->getImageId());
  813. $imageUrl = $image->getImageUrl();
  814. unset($fakeTemplateId);
  815. if (isset($ratios) && sizeof($ratios) > 0) {
  816. $n = 0;
  817. foreach ($ratios[3] as $ratio) {
  818. if ($ratios[1][$n++] == $templateId) {
  819. $fakeTemplateId = $templateId.'_'.$ratio;
  820. }
  821. }
  822. }
  823. if (!isset($fakeTemplateId)) {
  824. $fakeTemplateId = $templateId;
  825. }
  826. $text = preg_replace("/<!\*\*\s*Image\s*".$templateId."\s*/i", '<img src="'.$imageUrl.'" id="'.$fakeTemplateId.'" ', $text);
  827. }
  828. if ($formattingErrors) {
  829. ?>
  830. <script type="text/javascript">
  831. window.location.reload();
  832. </script>
  833. <?php
  834. }
  835. }
  836. ?>
  837. <tr>
  838. <td align="right" valign="top" style="padding-top: 8px; padding-right: 5px;">
  839. <?php if ($f_edit_mode == "edit") {
  840. $saveButtonNames[] = 'save_' . $dbColumn->getName();
  841. $saveButtons[] = 'var oSave' . $dbColumn->getName() .'Button = new YAHOO.widget.Button("save_' . $dbColumn->getName() . '", {
  842. onclick: { fn: onButtonClick },
  843. disabled: true
  844. });';
  845. ?>
  846. <input type="button" id="save_<?php p($dbColumn->getName()); ?>" value="<?php putGS('Saved'); ?>">
  847. <?php } ?>
  848. </td>
  849. <td align="right" valign="top" style="padding-top: 8px;">
  850. <?php echo htmlspecialchars($dbColumn->getDisplayName()); ?>:
  851. </td>
  852. <td align="left" valign="top">
  853. <table cellpadding="0" cellspacing="0" width="100%">
  854. <tr>
  855. <?php
  856. if ($f_edit_mode == "edit") {
  857. $textAreaId = $dbColumn->getName() . '_' . $f_article_number;
  858. $fCustomTextareas[] = $textAreaId;
  859. ?>
  860. <td><textarea name="<?php print($textAreaId); ?>"
  861. id="<?php print($textAreaId); ?>"
  862. rows="20" cols="70" onkeyup="buttonEnable('save_<?php p($dbColumn->getName()); ?>');"><?php print $text; ?></textarea>
  863. </td>
  864. <?php } else { ?>
  865. <td align="left" style="padding: 5px; <?php if (!empty($text)) {?>border: 1px solid #888; margin-right: 5px;<?php } ?>" <?php if (!empty($text)) {?>bgcolor="#EEEEEE"<?php } ?>><?php p($text); ?></td>
  866. <?php } ?>
  867. </tr>
  868. </table>
  869. </td>
  870. </tr>
  871. <?php
  872. } elseif ($dbColumn->getType() == ArticleTypeField::TYPE_TOPIC) {
  873. $articleTypeField = new ArticleTypeField($articleObj->getType(),
  874. substr($dbColumn->getName(), 1));
  875. $rootTopicId = $articleTypeField->getTopicTypeRootElement();
  876. $rootTopic = new Topic($rootTopicId);
  877. $subtopics = Topic::GetTree($rootTopicId);
  878. $articleTopicId = $articleData->getProperty($dbColumn->getName());
  879. ?>
  880. <tr>
  881. <td align="left" style="padding-right: 5px;">
  882. <?php if ($f_edit_mode == "edit") {
  883. $fCustomFields[] = $dbColumn->getName();
  884. $saveButtonNames[] = 'save_' . $dbColumn->getName();
  885. $saveButtons[] = 'var oSave' . $dbColumn->getName() .'Button = new YAHOO.widget.Button("save_' . $dbColumn->getName() . '", {
  886. onclick: { fn: onButtonClick },
  887. disabled: true
  888. });';
  889. ?>
  890. <input type="button" id="save_<?php p($dbColumn->getName()); ?>" value="<?php putGS('Saved'); ?>">
  891. <?php } ?>
  892. </td>
  893. <td align="right">
  894. <?php echo $articleTypeField->getDisplayName(); ?>:
  895. </td>
  896. <td>
  897. <?php if (count($subtopics) == 0) { ?>
  898. No subtopics available.
  899. <?php } else { ?>
  900. <select class="input_select" name="<?php echo $dbColumn->getName(); ?>" id="<?php echo $dbColumn->getName(); ?>" <?php if ($f_edit_mode != "edit") { ?>disabled<?php } ?> onchange="buttonEnable('save_<?php p($dbColumn->getName()); ?>');">
  901. <option value="0"></option>
  902. <?php
  903. $TOL_Language = camp_session_get('TOL_Language', 'en');
  904. $currentLanguage = new Language($TOL_Language);
  905. $currentLanguageId = $currentLanguage->getLanguageId();
  906. foreach ($subtopics as $topicPath) {
  907. $printTopic = array();
  908. foreach ($topicPath as $topicId => $topic) {
  909. $translations = $topic->getTranslations();
  910. if (array_key_exists($currentLanguageId, $translations)) {
  911. $currentTopic = $translations[$currentLanguageId];
  912. } elseif ( ($currentLanguageId != 1) && array_key_exists(1, $translations)) {
  913. $currentTopic = $translations[1];
  914. } else {
  915. $currentTopic = end($translations);
  916. }
  917. $printTopic[] = $currentTopic;
  918. }
  919. camp_html_select_option($topicId, $articleTopicId, implode(" / ", $printTopic));
  920. }
  921. ?>
  922. </select>
  923. <?php } ?>
  924. </td>
  925. </tr>
  926. <?php
  927. } elseif ($dbColumn->getType() == ArticleTypeField::TYPE_SWITCH) {
  928. $checked = $articleData->getFieldValue($dbColumn->getPrintName()) ? 'checked' : '';
  929. ?>
  930. <tr>
  931. <td align="left" style="padding-right: 5px;">
  932. <?php if ($f_edit_mode == "edit") {
  933. $fCustomSwitches[] = $dbColumn->getName();
  934. $saveButtonNames[] = 'save_' . $dbColumn->getName();
  935. $saveButtons[] = 'var oSave' . $dbColumn->getName() .'Button = new YAHOO.widget.Button("save_' . $dbColumn->getName() . '", {
  936. onclick: { fn: onButtonClick },
  937. disabled: true
  938. });';
  939. ?>
  940. <input type="button" id="save_<?php p($dbColumn->getName()); ?>" value="<?php putGS('Saved'); ?>">
  941. <?php } ?>
  942. </td>
  943. <td align="right">
  944. <?php echo $dbColumn->getDisplayName(); ?>:
  945. </td>
  946. <td>
  947. <input type="checkbox" name="<?php echo $dbColumn->getName(); ?>" id="<?php echo $dbColumn->getName(); ?>" <?php if ($f_edit_mode != "edit") { ?>disabled<?php } ?> onchange="buttonEnable('save_<?php p($dbColumn->getName()); ?>');" class="input_checkbox" <?php echo $checked; ?> />
  948. </td>
  949. </tr>
  950. <?php
  951. } elseif ($dbColumn->getType() == ArticleTypeField::TYPE_NUMERIC) {
  952. ?>
  953. <tr>
  954. <td align="left" style="padding-right: 5px;">
  955. <?php if ($f_edit_mode == "edit") {
  956. $fCustomFields[] = $dbColumn->getName();
  957. $saveButtonNames[] = 'save_' . $dbColumn->getName();
  958. $saveButtons[] = 'var oSave' . $dbColumn->getName() .'Button = new YAHOO.widget.Button("save_' . $dbColumn->getName() . '", {
  959. onclick: { fn: onButtonClick },
  960. disabled: true
  961. });';
  962. ?>
  963. <input type="button" id="save_<?php p($dbColumn->getName()); ?>" value="<?php putGS('Saved'); ?>">
  964. <?php } ?>
  965. </td>
  966. <td align="right">
  967. <?php echo $dbColumn->getDisplayName(); ?>:
  968. </td>
  969. <td>
  970. <input type="text" class="input_text" size="20" maxlength="20" <?php print $spellcheck ?>
  971. name="<?php echo $dbColumn->getName(); ?>"
  972. value="<?php echo htmlspecialchars($articleData->getProperty($dbColumn->getName())); ?>"
  973. id="<?php echo $dbColumn->getName(); ?>"
  974. <?php if ($f_edit_mode != "edit") { ?>disabled<?php } ?>
  975. onkeyup="buttonEnable('save_<?php p($dbColumn->getName()); ?>');" />
  976. </td>
  977. </tr>
  978. <?php
  979. }
  980. } // foreach ($dbColumns as $dbColumn)
  981. ?>
  982. </table>
  983. </td>
  984. </tr>
  985. <?php if ($f_edit_mode == "edit") { ?>
  986. <tr>
  987. <td colspan="2" align="center">
  988. <?php if ($f_publication_id > 0) { ?>
  989. <!-- Preview Link -->
  990. <input type="submit" name="preview" value="<?php putGS('Preview'); ?>" class="button" onclick="window.open('/<?php echo $ADMIN; ?>/articles/preview.php?f_publication_id=<?php p($f_publication_id); ?>&amp;f_issue_number=<?php p($f_issue_number); ?>&amp;f_section_number=<?php p($f_section_number); ?>&amp;f_article_number=<?php p($f_article_number); ?>&amp;f_language_id=<?php p($f_language_id); ?>&amp;f_language_selected=<?php p($f_language_selected); ?>',…

Large files files are truncated, but you can click here to view the full file