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 pl_olga_vv_admin {
  6.  
  7. var $_debug_prefix;
  8.  
  9. var $_config;
  10. var $_topic;
  11. var $errcode;
  12. var $errstr;
  13. var $form_prefix;
  14. // ...
  15.  
  16.  
  17.  
  18.  
  19. function pl_olga_vv_admin($topic, $config) {
  20.  
  21. $this->_debug_prefix = "pl.olga.vv admin::";
  22.  
  23. $this->_config = $config;
  24. $this->_topic = $topic;
  25.  
  26. $this->errcode = MIDCOM_ERROK;
  27. $this->errstr = "";
  28. $this->form_prefix = "pl_olga_vv_";
  29. // ...
  30. }
  31.  
  32.  
  33. function can_handle($argc, $argv) {
  34.  
  35. debug_push($this->_debug_prefix . "can_handle");
  36.  
  37. // see if we can handle this request
  38. if ($argc == 0) {
  39. return true;
  40. }
  41. if ($argc == 1 && $argv[0] == "create") {
  42. return true;
  43. }
  44. switch ($argv[0]) {
  45. case "view":
  46. case "edit":
  47. case "delete":
  48. case "create":
  49. return true;
  50. default:
  51. return false;
  52. }
  53. debug_pop();
  54. return true;
  55. }
  56.  
  57.  
  58. function handle($argc, $argv) {
  59.  
  60. debug_push($this->_debug_prefix . "handle");
  61.  
  62. // handle args, parse the url, save data from forms, prepare output
  63.  
  64. if ($argc == 0) {
  65. $this->_view = "welcome";
  66. debug_add ("viewport = welcome");
  67. debug_pop ();
  68. return true;
  69. }
  70.  
  71. switch ($argv[0]) {
  72.  
  73. case "view":
  74. $result = $this->_init_view($argv[1]);
  75. break;
  76.  
  77. case "edit":
  78. $result = $this->_init_edit();
  79. break;
  80.  
  81. case "delete":
  82. $result = $this->_init_delete($argv[1]);
  83. break;
  84.  
  85. case "create":
  86. $result = $this->_init_create(($argc==2) ? $argv[1] : null);
  87. break;
  88.  
  89. default:
  90. $result = false;
  91. break;
  92. }
  93. debug_pop();
  94. return $result;
  95.  
  96. }
  97.  
  98. function _init_create($id = null) {
  99. if (is_null($id)) {
  100. global $midgard;
  101. return true;
  102. }
  103. }
  104.  
  105. function _init_edit() {
  106. if (array_key_exists($this->form_prefix."submit", $_REQUEST)) {
  107. if(array_key_exists($this->form_prefix."allow_create_by_uri", $_REQUEST)) $this->_topic->parameter("pl.olga.vv","allow_create_by_uri","true");
  108. else $this->_topic->parameter("pl.olga.vv","allow_create_by_uri","false");
  109. if(array_key_exists($this->form_prefix."antispam", $_REQUEST)) $this->_topic->parameter("pl.olga.vv","antispam","true");
  110. else $this->_topic->parameter("pl.olga.vv","antispam","false");
  111. $this->_topic->update();
  112. }
  113. $this->_view = "welcome";
  114. $GLOBALS["pl_olga_vv_nap_activeid"] = false;
  115. return true;
  116. }
  117. function _init_delete($id,$init=true) {
  118. if ($init) {
  119. if (!$this->_init_view($id)) {
  120. return false;
  121. }
  122. $thread = $this->_thread;
  123. } else {
  124. $thread = mgd_get_article($id);
  125. }
  126. $replies = mgd_list_reply_articles($thread->id);
  127. if ($replies) {
  128. while ($replies->fetch()) {
  129. $this->_init_delete($replies->id,false);
  130. }
  131. }
  132. $param_domains = $thread->listparameters();
  133. if ($param_domains) {
  134. while ($param_domains->fetch()) {
  135. $params = $thread->listparameters($param_domains->domain);
  136. if ($params) {
  137. while ($params->fetch()) {
  138. $thread->parameter($params->domain,$params->value,"");
  139. }
  140. }
  141. }
  142. }
  143. $stat = $thread->delete();
  144. if ($stat) {
  145. $this->_view = "welcome";
  146. }
  147. return $stat;
  148. }
  149. function _init_view($id) {
  150. global $pl_olga_vv_layouts;
  151.  
  152. $thread = mgd_get_article($id);
  153. if (!$thread) {
  154. debug_add("Thread $id could not be loaded: " . mgd_errstr(), MIDCOM_LOG_INFO);
  155. $this->errstr = "Thread $id could not be loaded: " . mgd_errstr();
  156. $this->errcode = MIDCOM_ERRNOTFOUND;
  157. return false;
  158. }
  159. $this->_thread = $thread;
  160. $GLOBALS["pl_olga_vv_nap_activeid"] = false;
  161.  
  162. return true;
  163. }
  164. function show() {
  165.  
  166. global $pl_olga_vv_layouts;
  167. global $midcom;
  168. debug_push($this->_debug_prefix . "show");
  169.  
  170. // get l10n libraries
  171. $i18n =& $GLOBALS["midcom"]->get_service("i18n");
  172. $GLOBALS["view_l10n"] = $i18n->get_l10n("pl.olga.vv");
  173. $GLOBALS["view_l10n_midcom"] = $i18n->get_l10n("midcom");
  174.  
  175. global $view;
  176.  
  177. $view["allow_create_by_uri"] = $this->_topic->parameter("pl.olga.vv","allow_create_by_uri");
  178. $view["antispam"] = $this->_topic->parameter("pl.olga.vv","antispam");
  179.  
  180. midcom_show_style("admin-welcome");
  181. debug_pop();
  182. return true;
  183. }
  184.  
  185.  
  186. function get_metadata() {
  187. return false;
  188. }
  189.  
  190.  
  191. function get_current_leaf() {
  192.  
  193. // return id of current leaf, e.g. article id
  194. // return id of current leaf, e.g. article id
  195. return false;
  196. }
  197.  
  198. } // admin
  199.  
  200. ?>

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