PageRenderTime 48ms CodeModel.GetById 23ms RepoModel.GetById 0ms app.codeStats 0ms

/campsite/src/admin-files/article_types/fields/do_retype.php

https://github.com/joechrysler/Campsite
PHP | 80 lines | 67 code | 12 blank | 1 comment | 4 complexity | 22edc50c9a972eb4bc1b2a4372bc3428 MD5 | raw file
Possible License(s): BSD-3-Clause, AGPL-1.0, LGPL-2.1, Apache-2.0
  1. <?php
  2. camp_load_translation_strings("article_type_fields");
  3. camp_load_translation_strings("api");
  4. require_once($GLOBALS['g_campsiteDir'].'/classes/Input.php');
  5. require_once($GLOBALS['g_campsiteDir'].'/classes/Log.php');
  6. require_once($GLOBALS['g_campsiteDir'].'/classes/ArticleType.php');
  7. // Check permissions
  8. if (!$g_user->hasPermission('ManageArticleTypes')) {
  9. camp_html_display_error(getGS("You do not have the right to add article type fields."));
  10. exit;
  11. }
  12. $articleTypeName = Input::Get('f_article_type');
  13. $fieldName = trim(Input::Get('f_field_name'));
  14. $fieldType = trim(Input::Get('f_article_field_type'));
  15. $field = new ArticleTypeField($articleTypeName, $fieldName);
  16. $correct = true;
  17. $errorMsgs = array();
  18. if (!$field->exists()) {
  19. $errorMsgs[] = getGS('The field $1 does not exist.', '<B>'.urlencode($fieldName).'</B>');
  20. $correct = false;
  21. }
  22. if (array_search($fieldType, $field->getConvertibleToTypes()) === false) {
  23. $errorMsgs[] = getGS('Can not convert the field $1 from $2 to type $3.',
  24. $fieldName, $field->getType(), $fieldType);
  25. $correct = false;
  26. }
  27. if ($correct) {
  28. $field->setType($fieldType);
  29. camp_html_goto_page("/$ADMIN/article_types/fields/?f_article_type=".urlencode($articleTypeName));
  30. }
  31. $crumbs = array();
  32. $crumbs[] = array(getGS("Configure"), "");
  33. $crumbs[] = array(getGS("Article Types"), "/$ADMIN/article_types/");
  34. $crumbs[] = array($articleTypeName, '');
  35. $crumbs[] = array(getGS("Article type fields"), "/$ADMIN/article_types/fields/?f_article_type=".urlencode($articleTypeName));
  36. $crumbs[] = array(getGS("Adding new field"), "");
  37. echo camp_html_breadcrumbs($crumbs);
  38. ?>
  39. <P>
  40. <TABLE BORDER="0" CELLSPACING="0" CELLPADDING="8" class="message_box">
  41. <TR>
  42. <TD COLSPAN="2">
  43. <B> <?php putGS("Adding new field"); ?> </B>
  44. <HR NOSHADE SIZE="1" COLOR="BLACK">
  45. </TD>
  46. </TR>
  47. <TR>
  48. <TD COLSPAN="2">
  49. <BLOCKQUOTE><ul>
  50. <?php
  51. foreach ($errorMsgs as $errorMsg) { ?>
  52. <li><?php p($errorMsg); ?></li>
  53. <?php
  54. }
  55. ?>
  56. </ul></BLOCKQUOTE>
  57. </TD>
  58. </TR>
  59. <TR>
  60. <TD COLSPAN="2">
  61. <DIV ALIGN="CENTER">
  62. <INPUT TYPE="button" class="button" NAME="Ok" VALUE="<?php putGS('OK'); ?>" ONCLICK="location.href='/<?php p($ADMIN); ?>/article_types/fields/add.php?f_article_type=<?php print urlencode($articleTypeName); ?>'">
  63. </DIV>
  64. </TD>
  65. </TR>
  66. </TABLE>
  67. <P>
  68. <?php camp_html_copyright_notice(); ?>