Source for file admin.php

Documentation is available at admin.php

  1. <?php
  2.  
  3. /* Admin interface, called by the "contentadmin" interface class */
  4.  
  5. class midgard_admin_sitewizard_admin {
  6.  
  7. var $_debug_prefix;
  8.  
  9. var $_config;
  10. var $_topic;
  11. var $_view;
  12. var $errcode;
  13. var $errstr;
  14. var $form_prefix;
  15. var $_config_dm;
  16. var $_l10n;
  17. var $_l10n_midcom;
  18. var $_local_toolbar;
  19. var $_topic_toolbar;
  20.  
  21. function midgard_admin_sitewizard_admin($topic, $config) {
  22.  
  23. $this->_debug_prefix = "midgard.admin.sitewizard admin::";
  24.  
  25. $this->_config = $config;
  26. $this->_topic = $topic;
  27. $this->_view = "";
  28. $this->_config_dm = null;
  29. $this->errcode = MIDCOM_ERROK;
  30. $this->errstr = "";
  31.  
  32. // get l10n libraries
  33. $i18n =& $GLOBALS["midcom"]->get_service("i18n");
  34. $this->_l10n = $i18n->get_l10n("midgard.admin.sitewizard");
  35. $this->_l10n_midcom = $i18n->get_l10n("midcom");
  36. $GLOBALS["view_l10n"] = $this->_l10n;
  37. $GLOBALS["view_l10n_midcom"] = $this->_l10n_midcom;
  38.  
  39. $this->_local_toolbar =& $GLOBALS['midcom_admin_content_toolbar_component'];
  40. $this->_topic_toolbar =& $GLOBALS['midcom_admin_content_toolbar_main'];
  41. }
  42.  
  43.  
  44. function can_handle($argc, $argv) {
  45.  
  46. debug_push($this->_debug_prefix . "can_handle");
  47.  
  48. // see if we can handle this request
  49. if ($argc == 0) {
  50. return true;
  51. } else {
  52. return false;
  53. }
  54. }
  55.  
  56.  
  57. function handle($argc, $argv) {
  58. global $_REQUEST;
  59.  
  60. debug_push($this->_debug_prefix . "handle");
  61.  
  62. // handle args, parse the url, save data from forms, prepare output
  63.  
  64. /* Add the topic configuration item */
  65. $this->_topic_toolbar->add_item(Array(
  66. MIDCOM_TOOLBAR_URL => '',
  67. MIDCOM_TOOLBAR_LABEL => $this->_l10n_midcom->get('component configuration'),
  68. MIDCOM_TOOLBAR_HELPTEXT => $this->_l10n_midcom->get('component configuration helptext'),
  69. MIDCOM_TOOLBAR_ICON => 'stock-icons/16x16/stock_folder-properties.png',
  70. MIDCOM_TOOLBAR_ENABLED => true
  71. ));
  72. if ($argc == 0) {
  73. $this->_view = "welcome";
  74. debug_add ("viewport = welcome");
  75.  
  76. // Provide configuration form
  77. $this->_init_config();
  78. debug_pop ();
  79. return true;
  80. }
  81. debug_pop();
  82. return false;
  83.  
  84. }
  85.  
  86. function _init_config() {
  87.  
  88. $schemadbs = $this->_config->get("schemadbs");
  89. $GLOBALS["view_schemadbs"] = array_merge(Array("" => $GLOBALS["view_l10n_midcom"]->get("default setting")), $schemadbs);
  90. $this->_config_dm = new midcom_helper_datamanager("file:/midgard/admin/sitewizard/config/schemadb_config.dat");
  91. if ($this->_config_dm == false) {
  92. debug_add("Failed to instantinate configuration datamanager.", MIDCOM_LOG_CRIT);
  93. $GLOBALS["midcom"]->generate_error(MIDCOM_ERRCRIT, "Failed to instantinate configuration datamanager.");
  94. }
  95.  
  96. if (! $this->_config_dm->init($this->_topic)) {
  97. debug_add("Failed to initialize the datamanager.", MIDCOM_LOG_CRIT);
  98. debug_print_r("Topic object we tried was:", $this->_topic);
  99. $GLOBALS["midcom"]->generate_error(MIDCOM_ERRCRIT,
  100. "Failed to initialize configuration datamanager.");
  101. }
  102.  
  103.  
  104. switch ($this->_config_dm->process_form()) {
  105. case MIDCOM_DATAMGR_SAVED:
  106. debug_add("Invalidating MidCOM cache", MIDCOM_LOG_DEBUG);
  107. break;
  108. case MIDCOM_DATAMGR_EDITING:
  109. case MIDCOM_DATAMGR_CANCELLED:
  110. // We stay here whatever happens here, at least as long as
  111. // there is no fatal error.
  112. break;
  113.  
  114. case MIDCOM_DATAMGR_FAILED:
  115. $this->errstr = "Datamanager: " . $GLOBALS["midcom_errstr"];
  116. $this->errcode = MIDCOM_ERRCRIT;
  117. debug_pop();
  118. return false;
  119. }
  120.  
  121. }
  122. function show() {
  123.  
  124. global $midcom;
  125. global $view_topic;
  126. $view_topic = $this->_topic;
  127. $GLOBALS["view_l10n"] = $this->_l10n;
  128. debug_push($this->_debug_prefix . "show");
  129.  
  130. if ($this->_view == "welcome") {
  131. global $title;
  132. global $view_config;
  133.  
  134. $view_config = $this->_config_dm;
  135.  
  136. midcom_show_style("admin-welcome");
  137. }
  138. debug_pop();
  139. return true;
  140. }
  141.  
  142.  
  143. function get_metadata() {
  144.  
  145. return false;
  146. }
  147.  
  148. } // admin
  149.  
  150. ?>

Documentation generated on Mon, 21 Nov 2005 18:09:42 +0100 by phpDocumentor 1.3.0RC3