PageRenderTime 52ms CodeModel.GetById 18ms RepoModel.GetById 0ms app.codeStats 0ms

/install/setup.info.php

http://modx-ja.googlecode.com/
PHP | 207 lines | 174 code | 23 blank | 10 comment | 57 complexity | 0b66446d5d368e19e0c0866411ce8274 MD5 | raw file
Possible License(s): AGPL-1.0, GPL-2.0, LGPL-2.1, BSD-3-Clause
  1. <?php
  2. //:: MODx Installer Setup file
  3. //:::::::::::::::::::::::::::::::::::::::::
  4. require_once('../manager/includes/version.inc.php');
  5. $moduleName = 'MODX';
  6. $moduleVersion = $modx_branch.' '.$modx_version;
  7. $moduleRelease = $modx_release_date;
  8. $moduleSQLBaseFile = "setup.sql";
  9. $moduleSQLDataFile = "setup.data.sql";
  10. $chunkPath = $setupPath .'/assets/chunks';
  11. $snippetPath = $setupPath .'/assets/snippets';
  12. $pluginPath = $setupPath .'/assets/plugins';
  13. $modulePath = $setupPath .'/assets/modules';
  14. $templatePath = $setupPath .'/assets/templates';
  15. $tvPath = $setupPath .'/assets/tvs';
  16. @ $conn = mysql_connect($database_server, $database_user, $database_password);
  17. if (function_exists('mysql_set_charset'))
  18. {
  19. mysql_set_charset($database_connection_charset);
  20. }
  21. @ mysql_select_db(trim($dbase, '`'), $conn);
  22. // setup Template template files - array : name, description, type - 0:file or 1:content, parameters, category
  23. $mt = &$moduleTemplates;
  24. if(is_dir($templatePath) && is_readable($templatePath)) {
  25. $d = dir($templatePath);
  26. while (false !== ($tplfile = $d->read()))
  27. {
  28. if(substr($tplfile, -4) != '.tpl') continue;
  29. $params = parse_docblock($templatePath, $tplfile);
  30. if(is_array($params) && (count($params)>0))
  31. {
  32. $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
  33. if($installMode===1 && compare_check($params)=='same') continue;
  34. $mt[] = array
  35. (
  36. $params['name'],
  37. $description,
  38. // Don't think this is gonna be used ... but adding it just in case 'type'
  39. $params['type'],
  40. "$templatePath/{$params['filename']}",
  41. $params['modx_category'],
  42. $params['lock_template'],
  43. array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
  44. );
  45. }
  46. }
  47. $d->close();
  48. }
  49. // setup Template Variable template files
  50. $mtv = &$moduleTVs;
  51. if(is_dir($tvPath) && is_readable($tvPath)) {
  52. $d = dir($tvPath);
  53. while (false !== ($tplfile = $d->read())) {
  54. if(substr($tplfile, -4) != '.tpl') continue;
  55. $params = parse_docblock($tvPath, $tplfile);
  56. if(is_array($params) && (count($params)>0)) {
  57. $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
  58. if($installMode===1 && compare_check($params)=='same') continue;
  59. $mtv[] = array(
  60. $params['name'],
  61. $params['caption'],
  62. $description,
  63. $params['input_type'],
  64. $params['input_options'],
  65. $params['input_default'],
  66. $params['output_widget'],
  67. $params['output_widget_params'],
  68. "$templatePath/{$params['filename']}", /* not currently used */
  69. $params['template_assignments'], /* comma-separated list of template names */
  70. $params['modx_category'],
  71. $params['lock_tv'], /* value should be 1 or 0 */
  72. array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
  73. );
  74. }
  75. }
  76. $d->close();
  77. }
  78. // setup chunks template files - array : name, description, type - 0:file or 1:content, file or content
  79. $mc = &$moduleChunks;
  80. if(is_dir($chunkPath) && is_readable($chunkPath)) {
  81. $d = dir($chunkPath);
  82. while (false !== ($tplfile = $d->read())) {
  83. if(substr($tplfile, -4) != '.tpl') {
  84. continue;
  85. }
  86. $params = parse_docblock($chunkPath, $tplfile);
  87. if(is_array($params) && count($params) > 0) {
  88. if($installMode===1 && compare_check($params)=='same') continue;
  89. $mc[] = array(
  90. $params['name'],
  91. $params['description'],
  92. "$chunkPath/{$params['filename']}",
  93. $params['modx_category'],
  94. array_key_exists('overwrite', $params) ? $params['overwrite'] : 'true',
  95. array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
  96. );
  97. }
  98. }
  99. $d->close();
  100. }
  101. // setup snippets template files - array : name, description, type - 0:file or 1:content, file or content,properties
  102. $ms = &$moduleSnippets;
  103. if(is_dir($snippetPath) && is_readable($snippetPath)) {
  104. $d = dir($snippetPath);
  105. while (false !== ($tplfile = $d->read())) {
  106. if(substr($tplfile, -4) != '.tpl') {
  107. continue;
  108. }
  109. $params = parse_docblock($snippetPath, $tplfile);
  110. if(is_array($params) && count($params) > 0) {
  111. $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
  112. if($installMode===1 && compare_check($params)=='same') continue;
  113. $ms[] = array(
  114. $params['name'],
  115. $description,
  116. "$snippetPath/{$params['filename']}",
  117. $params['properties'],
  118. $params['modx_category'],
  119. array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
  120. );
  121. }
  122. }
  123. $d->close();
  124. }
  125. // setup plugins template files - array : name, description, type - 0:file or 1:content, file or content,properties
  126. $mp = &$modulePlugins;
  127. if(is_dir($pluginPath) && is_readable($pluginPath))
  128. {
  129. $d = dir($pluginPath);
  130. while (false !== ($tplfile = $d->read()))
  131. {
  132. if(substr($tplfile, -4) != '.tpl')
  133. {
  134. continue;
  135. }
  136. $params = parse_docblock($pluginPath, $tplfile);
  137. if(is_array($params) && 0 < count($params))
  138. {
  139. if(!empty($params['version'])) $description = "<strong>{$params['version']}</strong> {$params['description']}";
  140. else $description = $params['description'];
  141. if($installMode===1 && compare_check($params)=='same') continue;
  142. $mp[] = array(
  143. $params['name'],
  144. $description,
  145. "$pluginPath/{$params['filename']}",
  146. $params['properties'],
  147. $params['events'],
  148. $params['guid'],
  149. $params['modx_category'],
  150. $params['legacy_names'],
  151. array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
  152. );
  153. }
  154. }
  155. $d->close();
  156. }
  157. // setup modules - array : name, description, type - 0:file or 1:content, file or content,properties, guid,enable_sharedparams
  158. $mm = &$moduleModules;
  159. if(is_dir($modulePath) && is_readable($modulePath)) {
  160. $d = dir($modulePath);
  161. while (false !== ($tplfile = $d->read())) {
  162. if(substr($tplfile, -4) != '.tpl') {
  163. continue;
  164. }
  165. $params = parse_docblock($modulePath, $tplfile);
  166. if(is_array($params) && count($params) > 0) {
  167. $description = empty($params['version']) ? $params['description'] : "<strong>{$params['version']}</strong> {$params['description']}";
  168. if($installMode===1 && compare_check($params)=='same') continue;
  169. $mm[] = array(
  170. $params['name'],
  171. $description,
  172. "$modulePath/{$params['filename']}",
  173. $params['properties'],
  174. $params['guid'],
  175. intval($params['shareparams']),
  176. $params['modx_category'],
  177. array_key_exists('installset', $params) ? preg_split("/\s*,\s*/", $params['installset']) : false
  178. );
  179. }
  180. }
  181. $d->close();
  182. }
  183. // setup callback function
  184. $callBackFnc = "clean_up";