BxDataMigrationTemplate.php 7.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  1. <?php
  2. /***************************************************************************
  3. * Dolphin Smart Community Builder
  4. * -------------------
  5. * begin : Mon Mar 23 2006
  6. * copyright : (C) 2007 BoonEx Group
  7. * website : http://www.boonex.com
  8. * This file is part of Dolphin - Smart Community Builder
  9. *
  10. * Dolphin is free software; you can redistribute it and/or modify it under
  11. * the terms of the GNU General Public License as published by the
  12. * Free Software Foundation; either version 2 of the
  13. * License, or any later version.
  14. *
  15. * Dolphin is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
  16. * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  17. * See the GNU General Public License for more details.
  18. * You should have received a copy of the GNU General Public License along with Dolphin,
  19. * see license.txt file; if not, write to marketing@boonex.com
  20. ***************************************************************************/
  21. bx_import('BxDolModuleTemplate');
  22. class BxDataMigrationTemplate extends BxDolModuleTemplate
  23. {
  24. /**
  25. * Class constructor
  26. */
  27. function BxDataMigrationTemplate(&$oConfig, &$oDb)
  28. {
  29. parent::BxDolModuleTemplate($oConfig, $oDb);
  30. }
  31. function pageCodeAdminStart()
  32. {
  33. ob_start();
  34. }
  35. function adminBlock ($sContent, $sTitle, $aMenu = array())
  36. {
  37. return DesignBoxAdmin($sTitle, $sContent, $aMenu);
  38. }
  39. function pageCodeAdmin ($sTitle)
  40. {
  41. global $_page;
  42. global $_page_cont;
  43. $_page['name_index'] = 9;
  44. $_page['header'] = $sTitle ? $sTitle : $GLOBALS['site']['title'];
  45. $_page['header_text'] = $sTitle;
  46. $_page_cont[$_page['name_index']]['page_main_code'] = ob_get_clean();
  47. PageCodeAdmin();
  48. }
  49. /**
  50. * Function will include the js file ;
  51. *
  52. * @param : $sName (string) - name of needed file ;
  53. * @return : (text) ;
  54. */
  55. function addJs($sName)
  56. {
  57. return '<script type="text/javascript" src="' . $this -> _oConfig -> getHomeUrl() . 'js/' . $sName . '" language="javascript"/></script>';
  58. }
  59. /**
  60. * Function will get spy's css file;
  61. *
  62. * @param : $sFileName (string) - css file name;
  63. * @return : (string);
  64. */
  65. function getCssFile($sFileName)
  66. {
  67. return '<link href="' . $this -> getCssUrl($sFileName) . '" rel="stylesheet" type="text/css" />';
  68. }
  69. /**
  70. * Function will get config form;
  71. *
  72. * @param : $oModule (object) - current module;
  73. * @return : (text) - html presentation data;
  74. */
  75. function getConfigForm(&$oModule)
  76. {
  77. $aForm = array (
  78. 'form_attrs' => array (
  79. 'action' => $oModule -> sPathToModule . 'administration/settings',
  80. 'method' => 'post',
  81. 'name' => 'form',
  82. ),
  83. 'params' => array (
  84. 'checker_helper' => 'BxCheckerMigration',
  85. 'db' => array(
  86. 'submit_name' => 'do_submit', // some filed name with non empty value to determine if the for was submitted,
  87. ),
  88. ),
  89. 'inputs' => array(
  90. 'location' => array (
  91. 'type' => 'text',
  92. 'name' => 'location',
  93. 'caption' => _t('_bx_data_migration_q_where_located'),
  94. 'required' => true,
  95. 'value' => $oModule -> _oDb -> getExtraParam('root'),
  96. 'info' => _t('_bx_data_migration_q_d_where_located', ' ' . BX_DIRECTORY_PATH_ROOT),
  97. // checker params
  98. 'checker' => array (
  99. 'func' => 'DolpinDirectory',
  100. 'params' => array(),
  101. 'error' => _t('_bx_data_migration_q_e_wrong_path'),
  102. ),
  103. ),
  104. ),
  105. );
  106. // add submit button;
  107. $aForm['inputs'][] = array (
  108. 'type' => 'submit',
  109. 'name' => 'do_submit',
  110. 'value' => _t('_Submit'),
  111. );
  112. $oForm = & new BxTemplFormView($aForm);
  113. $oForm -> initChecker();
  114. if ( $oForm -> isSubmittedAndValid() ) {
  115. $sOutputCode = $oModule -> createConfig( $oForm -> getCleanValue('location') );
  116. }
  117. else {
  118. $sOutputCode = $oForm -> getCode();
  119. }
  120. return $sOutputCode;
  121. }
  122. /**
  123. * Function will generate list of modules;
  124. *
  125. * @param : $aModules (array) - list of all allowed modules;
  126. * @param : $aStatusTexts (array) - list of modules status texts;
  127. * @param : $oModule (object) - current module's instance;
  128. * @return : (text) html presentation data;
  129. */
  130. function getModulesList($aModules, &$aStatusTexts, &$oModule)
  131. {
  132. $sLoadingImg = $this -> getIconUrl('loading.gif');
  133. $sOutputCode = $this -> addJs('data_migration.js');
  134. $sOutputCode .= "<script type=\"text/javascript\">
  135. oDataMigration.sPathToModule = '{$oModule -> sPathToModule}migration/';
  136. oDataMigration.sLoadingImg = '{$sLoadingImg}';
  137. </script>";
  138. $aForm = array (
  139. 'form_attrs' => array (
  140. 'action' => $oModule -> sPathToModule . 'administration',
  141. 'method' => 'post',
  142. 'name' => 'form',
  143. ),
  144. 'params' => array (
  145. 'db' => array(
  146. 'submit_name' => 'do_submit', // some filed name with non empty value to determine if the for was submitted,
  147. ),
  148. ),
  149. 'inputs' => array(
  150. 'modules' => array (
  151. 'type' => 'select',
  152. 'name' => 'module',
  153. 'caption' => _t('_bx_data_migration_select'),
  154. 'required' => true,
  155. 'attrs' => array(
  156. 'id' => 'modules',
  157. ),
  158. ),
  159. ),
  160. );
  161. // add submit button;
  162. $aForm['inputs'][] = array (
  163. 'type' => 'button',
  164. 'value' => _t('_bx_data_migration_move'),
  165. 'attrs' => array(
  166. 'onclick' => 'oDataMigration.moveData( $(\'#modules\').val() )',
  167. ),
  168. );
  169. $aForm['inputs'][] = array (
  170. 'type' => 'custom',
  171. 'content' => '<div id="callback">&nbsp;</div>',
  172. 'colspan' => true,
  173. );
  174. $aForm['inputs']['modules']['values'] = $aModules;
  175. // list of status text processed modules;
  176. if( $aStatusTexts && is_array($aStatusTexts) ) {
  177. foreach($aStatusTexts as $sModule => $sStatusText)
  178. {
  179. $aForm['inputs'][] = array (
  180. 'type' => 'custom',
  181. 'content' => $sStatusText,
  182. 'caption' => $sModule,
  183. );
  184. }
  185. }
  186. $oForm = & new BxTemplFormView($aForm);
  187. $sOutputCode .= $oForm -> getCode();
  188. return $this -> addCss('data_migration.css', true) . $sOutputCode;
  189. }
  190. }