1: <?php
2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18:
19:
20: use Xoops\Core\Kernel\Handlers\XoopsModule;
21:
22: 23: 24: 25: 26:
27: function xoops_module_install_xlanguage(XoopsModule $module)
28: {
29: $xoops = Xoops::getInstance();
30: xlanguage_mkdirs($xoops->path(\XoopsBaseConfig::get('var-path')) . '/configs/xlanguage');
31:
32: return true;
33: }
34:
35: 36: 37: 38: 39: 40:
41: function xoops_module_update_xlanguage(XoopsModule $module, $version)
42: {
43: return xoops_module_install_xlanguage($module);
44: }
45:
46: 47: 48: 49: 50: 51:
52: function xlanguage_mkdirs($pathname, $pathout = null)
53: {
54: $xoops = Xoops::getInstance();
55: $pathname = substr($pathname, strlen(\XoopsBaseConfig::get('root-path')));
56: $pathname = str_replace(DIRECTORY_SEPARATOR, '/', $pathname);
57:
58: $dest = ($pathout === null) ? \XoopsBaseConfig::get('root-path') : $pathout;
59: $paths = explode('/', $pathname);
60:
61: foreach ($paths as $path) {
62: if (!empty($path)) {
63: $dest = $dest . '/' . $path;
64: if (!is_dir($dest)) {
65: if (!mkdir($dest, 0755)) {
66: return false;
67: } else {
68: xlanguage_copyfile($xoops->path('uploads'), 'index.html', $dest);
69: }
70: }
71: }
72: }
73:
74: return true;
75: }
76:
77: 78: 79: 80: 81: 82: 83:
84: function xlanguage_copyfile($folder_in, $source_file, $folder_out)
85: {
86: if (!is_dir($folder_out)) {
87: if (!xlanguage_mkdirs($folder_out)) {
88: return false;
89: }
90: }
91:
92:
93: if (is_file($folder_in . '/' . $source_file)) {
94: return copy($folder_in . '/' . $source_file, $folder_out . '/' . basename($source_file));
95: }
96:
97: return false;
98: }
99: