@@ -17,228 +17,228 @@ |
||
17 | 17 | */ |
18 | 18 | trait FilesManagement |
19 | 19 | { |
20 | - /** |
|
21 | - * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
22 | - * |
|
23 | - * @param string $folder The full path of the directory to check |
|
24 | - * |
|
25 | - * @return void |
|
26 | - * @throws \RuntimeException |
|
27 | - */ |
|
28 | - public static function createFolder($folder) |
|
29 | - { |
|
30 | - try { |
|
31 | - if (!file_exists($folder)) { |
|
32 | - if (!mkdir($folder) && !is_dir($folder)) { |
|
33 | - throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
34 | - } |
|
35 | - |
|
36 | - file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
37 | - } |
|
38 | - } |
|
39 | - catch (\Exception $e) { |
|
40 | - echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
41 | - } |
|
42 | - } |
|
43 | - |
|
44 | - /** |
|
45 | - * @param $file |
|
46 | - * @param $folder |
|
47 | - * @return bool |
|
48 | - */ |
|
49 | - public static function copyFile($file, $folder) |
|
50 | - { |
|
51 | - return copy($file, $folder); |
|
52 | - } |
|
53 | - |
|
54 | - /** |
|
55 | - * @param $src |
|
56 | - * @param $dst |
|
57 | - */ |
|
58 | - public static function recurseCopy($src, $dst) |
|
59 | - { |
|
60 | - $dir = opendir($src); |
|
61 | - @mkdir($dst); |
|
62 | - while (false !== ($file = readdir($dir))) { |
|
63 | - if (('.' !== $file) && ('..' !== $file)) { |
|
64 | - if (is_dir($src . '/' . $file)) { |
|
65 | - self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
66 | - } else { |
|
67 | - copy($src . '/' . $file, $dst . '/' . $file); |
|
68 | - } |
|
69 | - } |
|
70 | - } |
|
71 | - closedir($dir); |
|
72 | - } |
|
73 | - |
|
74 | - /** |
|
75 | - * |
|
76 | - * Remove files and (sub)directories |
|
77 | - * |
|
78 | - * @param string $src source directory to delete |
|
79 | - * |
|
80 | - * @uses \Xmf\Module\Helper::getHelper() |
|
81 | - * @uses \Xmf\Module\Helper::isUserAdmin() |
|
82 | - * |
|
83 | - * @return bool true on success |
|
84 | - */ |
|
85 | - public static function deleteDirectory($src) |
|
86 | - { |
|
87 | - // Only continue if user is a 'global' Admin |
|
88 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
89 | - return false; |
|
90 | - } |
|
91 | - |
|
92 | - $success = true; |
|
93 | - // remove old files |
|
94 | - $dirInfo = new \SplFileInfo($src); |
|
95 | - // validate is a directory |
|
96 | - if ($dirInfo->isDir()) { |
|
97 | - $fileList = array_diff(scandir($src, SCANDIR_SORT_NONE), ['..', '.']); |
|
98 | - foreach ($fileList as $k => $v) { |
|
99 | - $fileInfo = new \SplFileInfo("{$src}/{$v}"); |
|
100 | - if ($fileInfo->isDir()) { |
|
101 | - // recursively handle subdirectories |
|
102 | - if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
103 | - break; |
|
104 | - } |
|
105 | - } else { |
|
106 | - // delete the file |
|
107 | - if (!($success = unlink($fileInfo->getRealPath()))) { |
|
108 | - break; |
|
109 | - } |
|
110 | - } |
|
111 | - } |
|
112 | - // now delete this (sub)directory if all the files are gone |
|
113 | - if ($success) { |
|
114 | - $success = rmdir($dirInfo->getRealPath()); |
|
115 | - } |
|
116 | - } else { |
|
117 | - // input is not a valid directory |
|
118 | - $success = false; |
|
119 | - } |
|
120 | - return $success; |
|
121 | - } |
|
122 | - |
|
123 | - /** |
|
124 | - * |
|
125 | - * Recursively remove directory |
|
126 | - * |
|
127 | - * @todo currently won't remove directories with hidden files, should it? |
|
128 | - * |
|
129 | - * @param string $src directory to remove (delete) |
|
130 | - * |
|
131 | - * @return bool true on success |
|
132 | - */ |
|
133 | - public static function rrmdir($src) |
|
134 | - { |
|
135 | - // Only continue if user is a 'global' Admin |
|
136 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
137 | - return false; |
|
138 | - } |
|
139 | - |
|
140 | - // If source is not a directory stop processing |
|
141 | - if (!is_dir($src)) { |
|
142 | - return false; |
|
143 | - } |
|
144 | - |
|
145 | - $success = true; |
|
146 | - |
|
147 | - // Open the source directory to read in files |
|
148 | - $iterator = new \DirectoryIterator($src); |
|
149 | - foreach ($iterator as $fObj) { |
|
150 | - if ($fObj->isFile()) { |
|
151 | - $filename = $fObj->getPathname(); |
|
152 | - $fObj = null; // clear this iterator object to close the file |
|
153 | - if (!unlink($filename)) { |
|
154 | - return false; // couldn't delete the file |
|
155 | - } |
|
156 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
157 | - // Try recursively on directory |
|
158 | - self::rrmdir($fObj->getPathname()); |
|
159 | - } |
|
160 | - } |
|
161 | - $iterator = null; // clear iterator Obj to close file/directory |
|
162 | - return rmdir($src); // remove the directory & return results |
|
163 | - } |
|
164 | - |
|
165 | - /** |
|
166 | - * Recursively move files from one directory to another |
|
167 | - * |
|
168 | - * @param string $src - Source of files being moved |
|
169 | - * @param string $dest - Destination of files being moved |
|
170 | - * |
|
171 | - * @return bool true on success |
|
172 | - */ |
|
173 | - public static function rmove($src, $dest) |
|
174 | - { |
|
175 | - // Only continue if user is a 'global' Admin |
|
176 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
177 | - return false; |
|
178 | - } |
|
179 | - |
|
180 | - // If source is not a directory stop processing |
|
181 | - if (!is_dir($src)) { |
|
182 | - return false; |
|
183 | - } |
|
184 | - |
|
185 | - // If the destination directory does not exist and could not be created stop processing |
|
186 | - if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
187 | - return false; |
|
188 | - } |
|
189 | - |
|
190 | - // Open the source directory to read in files |
|
191 | - $iterator = new \DirectoryIterator($src); |
|
192 | - foreach ($iterator as $fObj) { |
|
193 | - if ($fObj->isFile()) { |
|
194 | - rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
195 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
196 | - // Try recursively on directory |
|
197 | - self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
198 | - // rmdir($fObj->getPath()); // now delete the directory |
|
199 | - } |
|
200 | - } |
|
201 | - $iterator = null; // clear iterator Obj to close file/directory |
|
202 | - return rmdir($src); // remove the directory & return results |
|
203 | - } |
|
204 | - |
|
205 | - /** |
|
206 | - * Recursively copy directories and files from one directory to another |
|
207 | - * |
|
208 | - * @param string $src - Source of files being moved |
|
209 | - * @param string $dest - Destination of files being moved |
|
210 | - * |
|
211 | - * @uses \Xmf\Module\Helper::getHelper() |
|
212 | - * @uses \Xmf\Module\Helper::isUserAdmin() |
|
213 | - * |
|
214 | - * @return bool true on success |
|
215 | - */ |
|
216 | - public static function rcopy($src, $dest) |
|
217 | - { |
|
218 | - // Only continue if user is a 'global' Admin |
|
219 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
220 | - return false; |
|
221 | - } |
|
222 | - |
|
223 | - // If source is not a directory stop processing |
|
224 | - if (!is_dir($src)) { |
|
225 | - return false; |
|
226 | - } |
|
227 | - |
|
228 | - // If the destination directory does not exist and could not be created stop processing |
|
229 | - if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
230 | - return false; |
|
231 | - } |
|
232 | - |
|
233 | - // Open the source directory to read in files |
|
234 | - $iterator = new \DirectoryIterator($src); |
|
235 | - foreach ($iterator as $fObj) { |
|
236 | - if ($fObj->isFile()) { |
|
237 | - copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
238 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
239 | - self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
240 | - } |
|
241 | - } |
|
242 | - return true; |
|
243 | - } |
|
20 | + /** |
|
21 | + * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
22 | + * |
|
23 | + * @param string $folder The full path of the directory to check |
|
24 | + * |
|
25 | + * @return void |
|
26 | + * @throws \RuntimeException |
|
27 | + */ |
|
28 | + public static function createFolder($folder) |
|
29 | + { |
|
30 | + try { |
|
31 | + if (!file_exists($folder)) { |
|
32 | + if (!mkdir($folder) && !is_dir($folder)) { |
|
33 | + throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
34 | + } |
|
35 | + |
|
36 | + file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
37 | + } |
|
38 | + } |
|
39 | + catch (\Exception $e) { |
|
40 | + echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
41 | + } |
|
42 | + } |
|
43 | + |
|
44 | + /** |
|
45 | + * @param $file |
|
46 | + * @param $folder |
|
47 | + * @return bool |
|
48 | + */ |
|
49 | + public static function copyFile($file, $folder) |
|
50 | + { |
|
51 | + return copy($file, $folder); |
|
52 | + } |
|
53 | + |
|
54 | + /** |
|
55 | + * @param $src |
|
56 | + * @param $dst |
|
57 | + */ |
|
58 | + public static function recurseCopy($src, $dst) |
|
59 | + { |
|
60 | + $dir = opendir($src); |
|
61 | + @mkdir($dst); |
|
62 | + while (false !== ($file = readdir($dir))) { |
|
63 | + if (('.' !== $file) && ('..' !== $file)) { |
|
64 | + if (is_dir($src . '/' . $file)) { |
|
65 | + self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
66 | + } else { |
|
67 | + copy($src . '/' . $file, $dst . '/' . $file); |
|
68 | + } |
|
69 | + } |
|
70 | + } |
|
71 | + closedir($dir); |
|
72 | + } |
|
73 | + |
|
74 | + /** |
|
75 | + * |
|
76 | + * Remove files and (sub)directories |
|
77 | + * |
|
78 | + * @param string $src source directory to delete |
|
79 | + * |
|
80 | + * @uses \Xmf\Module\Helper::getHelper() |
|
81 | + * @uses \Xmf\Module\Helper::isUserAdmin() |
|
82 | + * |
|
83 | + * @return bool true on success |
|
84 | + */ |
|
85 | + public static function deleteDirectory($src) |
|
86 | + { |
|
87 | + // Only continue if user is a 'global' Admin |
|
88 | + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
89 | + return false; |
|
90 | + } |
|
91 | + |
|
92 | + $success = true; |
|
93 | + // remove old files |
|
94 | + $dirInfo = new \SplFileInfo($src); |
|
95 | + // validate is a directory |
|
96 | + if ($dirInfo->isDir()) { |
|
97 | + $fileList = array_diff(scandir($src, SCANDIR_SORT_NONE), ['..', '.']); |
|
98 | + foreach ($fileList as $k => $v) { |
|
99 | + $fileInfo = new \SplFileInfo("{$src}/{$v}"); |
|
100 | + if ($fileInfo->isDir()) { |
|
101 | + // recursively handle subdirectories |
|
102 | + if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
103 | + break; |
|
104 | + } |
|
105 | + } else { |
|
106 | + // delete the file |
|
107 | + if (!($success = unlink($fileInfo->getRealPath()))) { |
|
108 | + break; |
|
109 | + } |
|
110 | + } |
|
111 | + } |
|
112 | + // now delete this (sub)directory if all the files are gone |
|
113 | + if ($success) { |
|
114 | + $success = rmdir($dirInfo->getRealPath()); |
|
115 | + } |
|
116 | + } else { |
|
117 | + // input is not a valid directory |
|
118 | + $success = false; |
|
119 | + } |
|
120 | + return $success; |
|
121 | + } |
|
122 | + |
|
123 | + /** |
|
124 | + * |
|
125 | + * Recursively remove directory |
|
126 | + * |
|
127 | + * @todo currently won't remove directories with hidden files, should it? |
|
128 | + * |
|
129 | + * @param string $src directory to remove (delete) |
|
130 | + * |
|
131 | + * @return bool true on success |
|
132 | + */ |
|
133 | + public static function rrmdir($src) |
|
134 | + { |
|
135 | + // Only continue if user is a 'global' Admin |
|
136 | + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
137 | + return false; |
|
138 | + } |
|
139 | + |
|
140 | + // If source is not a directory stop processing |
|
141 | + if (!is_dir($src)) { |
|
142 | + return false; |
|
143 | + } |
|
144 | + |
|
145 | + $success = true; |
|
146 | + |
|
147 | + // Open the source directory to read in files |
|
148 | + $iterator = new \DirectoryIterator($src); |
|
149 | + foreach ($iterator as $fObj) { |
|
150 | + if ($fObj->isFile()) { |
|
151 | + $filename = $fObj->getPathname(); |
|
152 | + $fObj = null; // clear this iterator object to close the file |
|
153 | + if (!unlink($filename)) { |
|
154 | + return false; // couldn't delete the file |
|
155 | + } |
|
156 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
157 | + // Try recursively on directory |
|
158 | + self::rrmdir($fObj->getPathname()); |
|
159 | + } |
|
160 | + } |
|
161 | + $iterator = null; // clear iterator Obj to close file/directory |
|
162 | + return rmdir($src); // remove the directory & return results |
|
163 | + } |
|
164 | + |
|
165 | + /** |
|
166 | + * Recursively move files from one directory to another |
|
167 | + * |
|
168 | + * @param string $src - Source of files being moved |
|
169 | + * @param string $dest - Destination of files being moved |
|
170 | + * |
|
171 | + * @return bool true on success |
|
172 | + */ |
|
173 | + public static function rmove($src, $dest) |
|
174 | + { |
|
175 | + // Only continue if user is a 'global' Admin |
|
176 | + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
177 | + return false; |
|
178 | + } |
|
179 | + |
|
180 | + // If source is not a directory stop processing |
|
181 | + if (!is_dir($src)) { |
|
182 | + return false; |
|
183 | + } |
|
184 | + |
|
185 | + // If the destination directory does not exist and could not be created stop processing |
|
186 | + if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
187 | + return false; |
|
188 | + } |
|
189 | + |
|
190 | + // Open the source directory to read in files |
|
191 | + $iterator = new \DirectoryIterator($src); |
|
192 | + foreach ($iterator as $fObj) { |
|
193 | + if ($fObj->isFile()) { |
|
194 | + rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
195 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
196 | + // Try recursively on directory |
|
197 | + self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
198 | + // rmdir($fObj->getPath()); // now delete the directory |
|
199 | + } |
|
200 | + } |
|
201 | + $iterator = null; // clear iterator Obj to close file/directory |
|
202 | + return rmdir($src); // remove the directory & return results |
|
203 | + } |
|
204 | + |
|
205 | + /** |
|
206 | + * Recursively copy directories and files from one directory to another |
|
207 | + * |
|
208 | + * @param string $src - Source of files being moved |
|
209 | + * @param string $dest - Destination of files being moved |
|
210 | + * |
|
211 | + * @uses \Xmf\Module\Helper::getHelper() |
|
212 | + * @uses \Xmf\Module\Helper::isUserAdmin() |
|
213 | + * |
|
214 | + * @return bool true on success |
|
215 | + */ |
|
216 | + public static function rcopy($src, $dest) |
|
217 | + { |
|
218 | + // Only continue if user is a 'global' Admin |
|
219 | + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
220 | + return false; |
|
221 | + } |
|
222 | + |
|
223 | + // If source is not a directory stop processing |
|
224 | + if (!is_dir($src)) { |
|
225 | + return false; |
|
226 | + } |
|
227 | + |
|
228 | + // If the destination directory does not exist and could not be created stop processing |
|
229 | + if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
230 | + return false; |
|
231 | + } |
|
232 | + |
|
233 | + // Open the source directory to read in files |
|
234 | + $iterator = new \DirectoryIterator($src); |
|
235 | + foreach ($iterator as $fObj) { |
|
236 | + if ($fObj->isFile()) { |
|
237 | + copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
238 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
239 | + self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
240 | + } |
|
241 | + } |
|
242 | + return true; |
|
243 | + } |
|
244 | 244 | } |
@@ -28,8 +28,8 @@ discard block |
||
28 | 28 | public static function createFolder($folder) |
29 | 29 | { |
30 | 30 | try { |
31 | - if (!file_exists($folder)) { |
|
32 | - if (!mkdir($folder) && !is_dir($folder)) { |
|
31 | + if ( ! file_exists($folder)) { |
|
32 | + if ( ! mkdir($folder) && ! is_dir($folder)) { |
|
33 | 33 | throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
34 | 34 | } |
35 | 35 | |
@@ -85,7 +85,7 @@ discard block |
||
85 | 85 | public static function deleteDirectory($src) |
86 | 86 | { |
87 | 87 | // Only continue if user is a 'global' Admin |
88 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
88 | + if ( ! ($GLOBALS['xoopsUser'] instanceof XoopsUser) || ! $GLOBALS['xoopsUser']->isAdmin()) { |
|
89 | 89 | return false; |
90 | 90 | } |
91 | 91 | |
@@ -99,12 +99,12 @@ discard block |
||
99 | 99 | $fileInfo = new \SplFileInfo("{$src}/{$v}"); |
100 | 100 | if ($fileInfo->isDir()) { |
101 | 101 | // recursively handle subdirectories |
102 | - if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
102 | + if ( ! $success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
103 | 103 | break; |
104 | 104 | } |
105 | 105 | } else { |
106 | 106 | // delete the file |
107 | - if (!($success = unlink($fileInfo->getRealPath()))) { |
|
107 | + if ( ! ($success = unlink($fileInfo->getRealPath()))) { |
|
108 | 108 | break; |
109 | 109 | } |
110 | 110 | } |
@@ -133,12 +133,12 @@ discard block |
||
133 | 133 | public static function rrmdir($src) |
134 | 134 | { |
135 | 135 | // Only continue if user is a 'global' Admin |
136 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
136 | + if ( ! ($GLOBALS['xoopsUser'] instanceof XoopsUser) || ! $GLOBALS['xoopsUser']->isAdmin()) { |
|
137 | 137 | return false; |
138 | 138 | } |
139 | 139 | |
140 | 140 | // If source is not a directory stop processing |
141 | - if (!is_dir($src)) { |
|
141 | + if ( ! is_dir($src)) { |
|
142 | 142 | return false; |
143 | 143 | } |
144 | 144 | |
@@ -150,15 +150,15 @@ discard block |
||
150 | 150 | if ($fObj->isFile()) { |
151 | 151 | $filename = $fObj->getPathname(); |
152 | 152 | $fObj = null; // clear this iterator object to close the file |
153 | - if (!unlink($filename)) { |
|
153 | + if ( ! unlink($filename)) { |
|
154 | 154 | return false; // couldn't delete the file |
155 | 155 | } |
156 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
156 | + } elseif ( ! $fObj->isDot() && $fObj->isDir()) { |
|
157 | 157 | // Try recursively on directory |
158 | 158 | self::rrmdir($fObj->getPathname()); |
159 | 159 | } |
160 | 160 | } |
161 | - $iterator = null; // clear iterator Obj to close file/directory |
|
161 | + $iterator = null; // clear iterator Obj to close file/directory |
|
162 | 162 | return rmdir($src); // remove the directory & return results |
163 | 163 | } |
164 | 164 | |
@@ -173,17 +173,17 @@ discard block |
||
173 | 173 | public static function rmove($src, $dest) |
174 | 174 | { |
175 | 175 | // Only continue if user is a 'global' Admin |
176 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
176 | + if ( ! ($GLOBALS['xoopsUser'] instanceof XoopsUser) || ! $GLOBALS['xoopsUser']->isAdmin()) { |
|
177 | 177 | return false; |
178 | 178 | } |
179 | 179 | |
180 | 180 | // If source is not a directory stop processing |
181 | - if (!is_dir($src)) { |
|
181 | + if ( ! is_dir($src)) { |
|
182 | 182 | return false; |
183 | 183 | } |
184 | 184 | |
185 | 185 | // If the destination directory does not exist and could not be created stop processing |
186 | - if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
186 | + if ( ! is_dir($dest) && ! mkdir($dest, 0755)) { |
|
187 | 187 | return false; |
188 | 188 | } |
189 | 189 | |
@@ -192,13 +192,13 @@ discard block |
||
192 | 192 | foreach ($iterator as $fObj) { |
193 | 193 | if ($fObj->isFile()) { |
194 | 194 | rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
195 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
195 | + } elseif ( ! $fObj->isDot() && $fObj->isDir()) { |
|
196 | 196 | // Try recursively on directory |
197 | 197 | self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
198 | 198 | // rmdir($fObj->getPath()); // now delete the directory |
199 | 199 | } |
200 | 200 | } |
201 | - $iterator = null; // clear iterator Obj to close file/directory |
|
201 | + $iterator = null; // clear iterator Obj to close file/directory |
|
202 | 202 | return rmdir($src); // remove the directory & return results |
203 | 203 | } |
204 | 204 | |
@@ -216,17 +216,17 @@ discard block |
||
216 | 216 | public static function rcopy($src, $dest) |
217 | 217 | { |
218 | 218 | // Only continue if user is a 'global' Admin |
219 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
219 | + if ( ! ($GLOBALS['xoopsUser'] instanceof XoopsUser) || ! $GLOBALS['xoopsUser']->isAdmin()) { |
|
220 | 220 | return false; |
221 | 221 | } |
222 | 222 | |
223 | 223 | // If source is not a directory stop processing |
224 | - if (!is_dir($src)) { |
|
224 | + if ( ! is_dir($src)) { |
|
225 | 225 | return false; |
226 | 226 | } |
227 | 227 | |
228 | 228 | // If the destination directory does not exist and could not be created stop processing |
229 | - if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
229 | + if ( ! is_dir($dest) && ! mkdir($dest, 0755)) { |
|
230 | 230 | return false; |
231 | 231 | } |
232 | 232 | |
@@ -235,7 +235,7 @@ discard block |
||
235 | 235 | foreach ($iterator as $fObj) { |
236 | 236 | if ($fObj->isFile()) { |
237 | 237 | copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
238 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
238 | + } elseif ( ! $fObj->isDot() && $fObj->isDir()) { |
|
239 | 239 | self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
240 | 240 | } |
241 | 241 | } |
@@ -35,8 +35,7 @@ |
||
35 | 35 | |
36 | 36 | file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
37 | 37 | } |
38 | - } |
|
39 | - catch (\Exception $e) { |
|
38 | + } catch (\Exception $e) { |
|
40 | 39 | echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
41 | 40 | } |
42 | 41 | } |
@@ -33,48 +33,48 @@ |
||
33 | 33 | */ |
34 | 34 | class Breadcrumb |
35 | 35 | { |
36 | - public $dirname; |
|
37 | - private $bread = []; |
|
36 | + public $dirname; |
|
37 | + private $bread = []; |
|
38 | 38 | |
39 | - /** |
|
40 | - * |
|
41 | - */ |
|
42 | - public function __construct() |
|
43 | - { |
|
44 | - $this->dirname = basename(dirname(__DIR__)); |
|
45 | - } |
|
39 | + /** |
|
40 | + * |
|
41 | + */ |
|
42 | + public function __construct() |
|
43 | + { |
|
44 | + $this->dirname = basename(dirname(__DIR__)); |
|
45 | + } |
|
46 | 46 | |
47 | - /** |
|
48 | - * Add link to breadcrumb |
|
49 | - * |
|
50 | - * @param string $title |
|
51 | - * @param string $link |
|
52 | - */ |
|
53 | - public function addLink($title = '', $link = '') |
|
54 | - { |
|
55 | - $this->bread[] = [ |
|
56 | - 'link' => $link, |
|
57 | - 'title' => $title |
|
58 | - ]; |
|
59 | - } |
|
47 | + /** |
|
48 | + * Add link to breadcrumb |
|
49 | + * |
|
50 | + * @param string $title |
|
51 | + * @param string $link |
|
52 | + */ |
|
53 | + public function addLink($title = '', $link = '') |
|
54 | + { |
|
55 | + $this->bread[] = [ |
|
56 | + 'link' => $link, |
|
57 | + 'title' => $title |
|
58 | + ]; |
|
59 | + } |
|
60 | 60 | |
61 | - /** |
|
62 | - * Render Pedigree BreadCrumb |
|
63 | - * |
|
64 | - */ |
|
65 | - public function render() |
|
66 | - { |
|
67 | - if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) { |
|
68 | - require_once $GLOBALS['xoops']->path('class/theme.php'); |
|
69 | - $GLOBALS['xoTheme'] = new xos_opal_Theme(); |
|
70 | - } |
|
61 | + /** |
|
62 | + * Render Pedigree BreadCrumb |
|
63 | + * |
|
64 | + */ |
|
65 | + public function render() |
|
66 | + { |
|
67 | + if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) { |
|
68 | + require_once $GLOBALS['xoops']->path('class/theme.php'); |
|
69 | + $GLOBALS['xoTheme'] = new xos_opal_Theme(); |
|
70 | + } |
|
71 | 71 | |
72 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
73 | - $breadcrumbTpl = new \XoopsTpl(); |
|
74 | - $breadcrumbTpl->assign('breadcrumb', $this->bread); |
|
75 | - $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl'); |
|
76 | - unset($breadcrumbTpl); |
|
72 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
73 | + $breadcrumbTpl = new \XoopsTpl(); |
|
74 | + $breadcrumbTpl->assign('breadcrumb', $this->bread); |
|
75 | + $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl'); |
|
76 | + unset($breadcrumbTpl); |
|
77 | 77 | |
78 | - return $html; |
|
79 | - } |
|
78 | + return $html; |
|
79 | + } |
|
80 | 80 | } |
@@ -24,38 +24,38 @@ |
||
24 | 24 | */ |
25 | 25 | class Helper extends \Xmf\Module\Helper |
26 | 26 | { |
27 | - public $debug; |
|
27 | + public $debug; |
|
28 | 28 | |
29 | - /** |
|
30 | - * @internal param $debug |
|
31 | - * @param bool $debug |
|
32 | - */ |
|
33 | - protected function __construct($debug = false) |
|
34 | - { |
|
35 | - $this->debug = $debug; |
|
36 | - $this->dirname = basename(dirname(__DIR__)); |
|
37 | - } |
|
29 | + /** |
|
30 | + * @internal param $debug |
|
31 | + * @param bool $debug |
|
32 | + */ |
|
33 | + protected function __construct($debug = false) |
|
34 | + { |
|
35 | + $this->debug = $debug; |
|
36 | + $this->dirname = basename(dirname(__DIR__)); |
|
37 | + } |
|
38 | 38 | |
39 | - /** |
|
40 | - * @param bool $debug |
|
41 | - * |
|
42 | - * @return \Xoopsmodules\instruction\Helper |
|
43 | - */ |
|
44 | - public static function getInstance($debug = false) |
|
45 | - { |
|
46 | - static $instance; |
|
47 | - if (null === $instance) { |
|
48 | - $instance = new static($debug); |
|
49 | - } |
|
39 | + /** |
|
40 | + * @param bool $debug |
|
41 | + * |
|
42 | + * @return \Xoopsmodules\instruction\Helper |
|
43 | + */ |
|
44 | + public static function getInstance($debug = false) |
|
45 | + { |
|
46 | + static $instance; |
|
47 | + if (null === $instance) { |
|
48 | + $instance = new static($debug); |
|
49 | + } |
|
50 | 50 | |
51 | - return $instance; |
|
52 | - } |
|
51 | + return $instance; |
|
52 | + } |
|
53 | 53 | |
54 | - /** |
|
55 | - * @return string |
|
56 | - */ |
|
57 | - public function getDirname() |
|
58 | - { |
|
59 | - return $this->dirname; |
|
60 | - } |
|
54 | + /** |
|
55 | + * @return string |
|
56 | + */ |
|
57 | + public function getDirname() |
|
58 | + { |
|
59 | + return $this->dirname; |
|
60 | + } |
|
61 | 61 | } |
@@ -12,60 +12,60 @@ |
||
12 | 12 | */ |
13 | 13 | class PageHandler extends \XoopsPersistableObjectHandler |
14 | 14 | { |
15 | - /** |
|
16 | - * @param null|mixed $db |
|
17 | - */ |
|
18 | - public function __construct(\XoopsDatabase $db = null) |
|
19 | - { |
|
20 | - parent::__construct($db, 'instruction_page', Page::class, 'pageid', 'title'); |
|
21 | - } |
|
15 | + /** |
|
16 | + * @param null|mixed $db |
|
17 | + */ |
|
18 | + public function __construct(\XoopsDatabase $db = null) |
|
19 | + { |
|
20 | + parent::__construct($db, 'instruction_page', Page::class, 'pageid', 'title'); |
|
21 | + } |
|
22 | 22 | |
23 | - /** |
|
24 | - * Generate function for update user post |
|
25 | - * |
|
26 | - * @ Update user post count after send approve content |
|
27 | - * @ Update user post count after change status content |
|
28 | - * @ Update user post count after delete content |
|
29 | - * @param $uid |
|
30 | - * @param $status |
|
31 | - * @param $action |
|
32 | - */ |
|
33 | - public function updateposts($uid, $status, $action) |
|
34 | - { |
|
35 | - // |
|
36 | - switch ($action) { |
|
37 | - // Добавление страницы |
|
38 | - case 'add': |
|
39 | - if ($uid && $status) { |
|
40 | - $user = new \XoopsUser($uid); |
|
41 | - $memberHandler = xoops_getHandler('member'); |
|
42 | - // Добавялем +1 к комментам |
|
43 | - $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') + 1); |
|
44 | - } |
|
45 | - break; |
|
46 | - // Удаление страницы |
|
47 | - case 'delete': |
|
48 | - if ($uid && $status) { |
|
49 | - $user = new \XoopsUser($uid); |
|
50 | - $memberHandler = xoops_getHandler('member'); |
|
51 | - // Декримент комментов |
|
52 | - //$user->setVar( 'posts', $user->getVar( 'posts' ) - 1 ); |
|
53 | - // Сохраняем |
|
54 | - $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') - 1); |
|
55 | - } |
|
56 | - break; |
|
23 | + /** |
|
24 | + * Generate function for update user post |
|
25 | + * |
|
26 | + * @ Update user post count after send approve content |
|
27 | + * @ Update user post count after change status content |
|
28 | + * @ Update user post count after delete content |
|
29 | + * @param $uid |
|
30 | + * @param $status |
|
31 | + * @param $action |
|
32 | + */ |
|
33 | + public function updateposts($uid, $status, $action) |
|
34 | + { |
|
35 | + // |
|
36 | + switch ($action) { |
|
37 | + // Добавление страницы |
|
38 | + case 'add': |
|
39 | + if ($uid && $status) { |
|
40 | + $user = new \XoopsUser($uid); |
|
41 | + $memberHandler = xoops_getHandler('member'); |
|
42 | + // Добавялем +1 к комментам |
|
43 | + $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') + 1); |
|
44 | + } |
|
45 | + break; |
|
46 | + // Удаление страницы |
|
47 | + case 'delete': |
|
48 | + if ($uid && $status) { |
|
49 | + $user = new \XoopsUser($uid); |
|
50 | + $memberHandler = xoops_getHandler('member'); |
|
51 | + // Декримент комментов |
|
52 | + //$user->setVar( 'posts', $user->getVar( 'posts' ) - 1 ); |
|
53 | + // Сохраняем |
|
54 | + $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') - 1); |
|
55 | + } |
|
56 | + break; |
|
57 | 57 | |
58 | - case 'status': |
|
59 | - if ($uid) { |
|
60 | - $user = new \XoopsUser($uid); |
|
61 | - $memberHandler = xoops_getHandler('member'); |
|
62 | - if ($status) { |
|
63 | - $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') - 1); |
|
64 | - } else { |
|
65 | - $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') + 1); |
|
66 | - } |
|
67 | - } |
|
68 | - break; |
|
69 | - } |
|
70 | - } |
|
58 | + case 'status': |
|
59 | + if ($uid) { |
|
60 | + $user = new \XoopsUser($uid); |
|
61 | + $memberHandler = xoops_getHandler('member'); |
|
62 | + if ($status) { |
|
63 | + $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') - 1); |
|
64 | + } else { |
|
65 | + $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') + 1); |
|
66 | + } |
|
67 | + } |
|
68 | + break; |
|
69 | + } |
|
70 | + } |
|
71 | 71 | } |
@@ -16,60 +16,60 @@ discard block |
||
16 | 16 | */ |
17 | 17 | class Category extends \XoopsObject |
18 | 18 | { |
19 | - // constructor |
|
20 | - public function __construct() |
|
21 | - { |
|
22 | - // $this->XoopsObject(); |
|
23 | - $this->initVar('cid', XOBJ_DTYPE_INT, null, false, 5); |
|
24 | - $this->initVar('pid', XOBJ_DTYPE_INT, 0, false, 5); |
|
25 | - $this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false); |
|
26 | - $this->initVar('imgurl', XOBJ_DTYPE_TXTBOX, '', false); |
|
27 | - $this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false); |
|
28 | - $this->initVar('weight', XOBJ_DTYPE_INT, 0, false, 11); |
|
29 | - $this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10); |
|
30 | - $this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10); |
|
31 | - $this->initVar('metakeywords', XOBJ_DTYPE_TXTBOX, '', false); |
|
32 | - $this->initVar('metadescription', XOBJ_DTYPE_TXTBOX, '', false); |
|
33 | - } |
|
34 | - |
|
35 | - /** |
|
36 | - * @return mixed |
|
37 | - */ |
|
38 | - public function get_new_enreg() |
|
39 | - { |
|
40 | - $new_enreg = $GLOBALS['xoopsDB']->getInsertId(); |
|
41 | - return $new_enreg; |
|
42 | - } |
|
43 | - |
|
44 | - // Получаем форму |
|
45 | - |
|
46 | - /** |
|
47 | - * @param bool|null|string $action |
|
48 | - * @return \XoopsThemeForm |
|
49 | - */ |
|
50 | - public function getForm($action = false) |
|
51 | - { |
|
52 | - //global $xoopsDB, $xoopsModule, $xoopsModuleConfig; |
|
53 | - require_once __DIR__ . '/../include/common.php'; |
|
54 | - // Если нет $action |
|
55 | - if (false === $action) { |
|
56 | - $action = xoops_getenv('REQUEST_URI'); |
|
57 | - } |
|
58 | - // Подключаем формы |
|
59 | - include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
60 | - |
|
61 | - // Название формы |
|
62 | - $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDCAT) : sprintf(_AM_INSTRUCTION_FORMEDITCAT); |
|
63 | - |
|
64 | - // Форма |
|
65 | - $form = new \XoopsThemeForm($title, 'formcat', $action, 'post', true); |
|
66 | - //$form->setExtra('enctype="multipart/form-data"'); |
|
67 | - // Название категории |
|
68 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true); |
|
69 | - // Редактор |
|
70 | - $form->addElement(new \XoopsFormTextArea(_AM_INSTRUCTION_DSCC, 'description', $this->getVar('description', 'e')), true); |
|
71 | - //image |
|
72 | - /* |
|
19 | + // constructor |
|
20 | + public function __construct() |
|
21 | + { |
|
22 | + // $this->XoopsObject(); |
|
23 | + $this->initVar('cid', XOBJ_DTYPE_INT, null, false, 5); |
|
24 | + $this->initVar('pid', XOBJ_DTYPE_INT, 0, false, 5); |
|
25 | + $this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false); |
|
26 | + $this->initVar('imgurl', XOBJ_DTYPE_TXTBOX, '', false); |
|
27 | + $this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false); |
|
28 | + $this->initVar('weight', XOBJ_DTYPE_INT, 0, false, 11); |
|
29 | + $this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10); |
|
30 | + $this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10); |
|
31 | + $this->initVar('metakeywords', XOBJ_DTYPE_TXTBOX, '', false); |
|
32 | + $this->initVar('metadescription', XOBJ_DTYPE_TXTBOX, '', false); |
|
33 | + } |
|
34 | + |
|
35 | + /** |
|
36 | + * @return mixed |
|
37 | + */ |
|
38 | + public function get_new_enreg() |
|
39 | + { |
|
40 | + $new_enreg = $GLOBALS['xoopsDB']->getInsertId(); |
|
41 | + return $new_enreg; |
|
42 | + } |
|
43 | + |
|
44 | + // Получаем форму |
|
45 | + |
|
46 | + /** |
|
47 | + * @param bool|null|string $action |
|
48 | + * @return \XoopsThemeForm |
|
49 | + */ |
|
50 | + public function getForm($action = false) |
|
51 | + { |
|
52 | + //global $xoopsDB, $xoopsModule, $xoopsModuleConfig; |
|
53 | + require_once __DIR__ . '/../include/common.php'; |
|
54 | + // Если нет $action |
|
55 | + if (false === $action) { |
|
56 | + $action = xoops_getenv('REQUEST_URI'); |
|
57 | + } |
|
58 | + // Подключаем формы |
|
59 | + include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
60 | + |
|
61 | + // Название формы |
|
62 | + $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDCAT) : sprintf(_AM_INSTRUCTION_FORMEDITCAT); |
|
63 | + |
|
64 | + // Форма |
|
65 | + $form = new \XoopsThemeForm($title, 'formcat', $action, 'post', true); |
|
66 | + //$form->setExtra('enctype="multipart/form-data"'); |
|
67 | + // Название категории |
|
68 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true); |
|
69 | + // Редактор |
|
70 | + $form->addElement(new \XoopsFormTextArea(_AM_INSTRUCTION_DSCC, 'description', $this->getVar('description', 'e')), true); |
|
71 | + //image |
|
72 | + /* |
|
73 | 73 | $downloadscat_img = $this->getVar('imgurl') ? $this->getVar('imgurl') : 'blank.gif'; |
74 | 74 | $uploadirectory='/uploads/tdmdownloads/images/cats'; |
75 | 75 | $imgtray = new \XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMIMG,'<br>'); |
@@ -88,110 +88,110 @@ discard block |
||
88 | 88 | $imgtray->addElement($fileseltray); |
89 | 89 | $form->addElement($imgtray); |
90 | 90 | */ |
91 | - // Родительская категория |
|
92 | - // $categoryHandler = xoops_getModuleHandler('category', 'instruction'); |
|
93 | - $criteria = new \CriteriaCompo(); |
|
94 | - // Если мы редактируем, то убрать текущую категорию из списка выбора родительской |
|
95 | - if (!$this->isNew()) { |
|
96 | - $criteria->add(new \Criteria('cid', $this->getVar('cid'), '<>')); |
|
97 | - } |
|
98 | - $criteria->setSort('weight ASC, title'); |
|
99 | - $criteria->setOrder('ASC'); |
|
100 | - |
|
101 | - $db = \XoopsDatabaseFactory::getDatabase(); |
|
102 | - $categoryHandler = new CategoryHandler($db); |
|
103 | - |
|
104 | - $instructioncat_arr = $categoryHandler->getall($criteria); |
|
105 | - unset($criteria); |
|
106 | - // Подключаем трей |
|
107 | - include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
108 | - $mytree = new \XoopsObjectTree($instructioncat_arr, 'cid', 'pid'); |
|
109 | - |
|
110 | - // $form->addElement(new \XoopsFormLabel(_AM_INSTRUCTION_PCATC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
111 | - |
|
112 | - $helper = Helper::getInstance(); |
|
113 | - $module = $helper->getModule(); |
|
114 | - |
|
115 | - if (Utility::checkVerXoops($module, '2.5.9')) { |
|
116 | - $mytree_select = $mytree->makeSelectElement('pid', 'title', '--', $this->getVar('pid'), true, 0, '', _AM_INSTRUCTION_PCATC); |
|
117 | - $form->addElement($mytree_select); |
|
118 | - } else { |
|
119 | - $form->addElement(new \XoopsFormLabel(_AM_INSTRUCTION_PCATC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
120 | - } |
|
121 | - |
|
122 | - // Вес |
|
123 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_WEIGHTC, 'weight', 5, 5, $this->getVar('weight')), true); |
|
124 | - // Мета-теги ключевых слов |
|
125 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'metakeywords', 50, 255, $this->getVar('metakeywords')), false); |
|
126 | - // Мета-теги описания |
|
127 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'metadescription', 50, 255, $this->getVar('metadescription')), false); |
|
128 | - |
|
129 | - // ========================================================== |
|
130 | - // ========================================================== |
|
131 | - |
|
132 | - // Права |
|
133 | - $memberHandler = xoops_getHandler('member'); |
|
134 | - $group_list = $memberHandler->getGroupList(); |
|
135 | - $gpermHandler = xoops_getHandler('groupperm'); |
|
136 | - $full_list = array_keys($group_list); |
|
137 | - |
|
138 | - // Права на просмотр |
|
139 | - $groups_ids = []; |
|
140 | - // Если мы редактируем |
|
141 | - if (!$this->isNew()) { |
|
142 | - $groups_ids = $gpermHandler->getGroupIds('instruction_view', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
143 | - $groups_ids = array_values($groups_ids); |
|
144 | - $groups_instr_view = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_VIEW, 'groups_instr_view', $groups_ids); |
|
145 | - } else { |
|
146 | - $groups_instr_view = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_VIEW, 'groups_instr_view', $full_list); |
|
147 | - } |
|
148 | - $groups_instr_view->addOptionArray($group_list); |
|
149 | - $form->addElement($groups_instr_view); |
|
150 | - |
|
151 | - // Права на отправку |
|
152 | - $groups_ids = []; |
|
153 | - if (!$this->isNew()) { |
|
154 | - $groups_ids = $gpermHandler->getGroupIds('instruction_submit', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
155 | - $groups_ids = array_values($groups_ids); |
|
156 | - $groups_instr_submit = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_SUBMIT, 'groups_instr_submit', $groups_ids); |
|
157 | - } else { |
|
158 | - $groups_instr_submit = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_SUBMIT, 'groups_instr_submit', $full_list); |
|
159 | - } |
|
160 | - $groups_instr_submit->addOptionArray($group_list); |
|
161 | - $form->addElement($groups_instr_submit); |
|
162 | - |
|
163 | - // Права на редактирование |
|
164 | - $groups_ids = []; |
|
165 | - if (!$this->isNew()) { |
|
166 | - $groups_ids = $gpermHandler->getGroupIds('instruction_edit', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
167 | - $groups_ids = array_values($groups_ids); |
|
168 | - $groups_instr_edit = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_EDIT, 'groups_instr_edit', $groups_ids); |
|
169 | - } else { |
|
170 | - $groups_instr_edit = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_EDIT, 'groups_instr_edit', $full_list); |
|
171 | - } |
|
172 | - $groups_instr_edit->addOptionArray($group_list); |
|
173 | - $form->addElement($groups_instr_edit); |
|
174 | - |
|
175 | - // ========================================================== |
|
176 | - // ========================================================== |
|
177 | - |
|
178 | - // Если мы редактируем категорию |
|
179 | - if (!$this->isNew()) { |
|
180 | - $form->addElement(new \XoopsFormHidden('cid', $this->getVar('cid'))); |
|
181 | - //$form->addElement( new \XoopsFormHidden( 'catmodify', true)); |
|
182 | - } |
|
183 | - // |
|
184 | - $form->addElement(new \XoopsFormHidden('op', 'savecat')); |
|
185 | - // Кнопка |
|
186 | - $button_tray = new \XoopsFormElementTray('', ''); |
|
187 | - $submit_btn = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
188 | - $button_tray->addElement($submit_btn); |
|
189 | - $cancel_btn = new \XoopsFormButton('', 'cancel', _CANCEL, 'cancel'); |
|
190 | - $cancel_btn->setExtra('onclick="javascript:history.go(-1);"'); |
|
191 | - $button_tray->addElement($cancel_btn); |
|
192 | - $form->addElement($button_tray); |
|
193 | - |
|
194 | - return $form; |
|
195 | - } |
|
91 | + // Родительская категория |
|
92 | + // $categoryHandler = xoops_getModuleHandler('category', 'instruction'); |
|
93 | + $criteria = new \CriteriaCompo(); |
|
94 | + // Если мы редактируем, то убрать текущую категорию из списка выбора родительской |
|
95 | + if (!$this->isNew()) { |
|
96 | + $criteria->add(new \Criteria('cid', $this->getVar('cid'), '<>')); |
|
97 | + } |
|
98 | + $criteria->setSort('weight ASC, title'); |
|
99 | + $criteria->setOrder('ASC'); |
|
100 | + |
|
101 | + $db = \XoopsDatabaseFactory::getDatabase(); |
|
102 | + $categoryHandler = new CategoryHandler($db); |
|
103 | + |
|
104 | + $instructioncat_arr = $categoryHandler->getall($criteria); |
|
105 | + unset($criteria); |
|
106 | + // Подключаем трей |
|
107 | + include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
108 | + $mytree = new \XoopsObjectTree($instructioncat_arr, 'cid', 'pid'); |
|
109 | + |
|
110 | + // $form->addElement(new \XoopsFormLabel(_AM_INSTRUCTION_PCATC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
111 | + |
|
112 | + $helper = Helper::getInstance(); |
|
113 | + $module = $helper->getModule(); |
|
114 | + |
|
115 | + if (Utility::checkVerXoops($module, '2.5.9')) { |
|
116 | + $mytree_select = $mytree->makeSelectElement('pid', 'title', '--', $this->getVar('pid'), true, 0, '', _AM_INSTRUCTION_PCATC); |
|
117 | + $form->addElement($mytree_select); |
|
118 | + } else { |
|
119 | + $form->addElement(new \XoopsFormLabel(_AM_INSTRUCTION_PCATC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
120 | + } |
|
121 | + |
|
122 | + // Вес |
|
123 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_WEIGHTC, 'weight', 5, 5, $this->getVar('weight')), true); |
|
124 | + // Мета-теги ключевых слов |
|
125 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'metakeywords', 50, 255, $this->getVar('metakeywords')), false); |
|
126 | + // Мета-теги описания |
|
127 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'metadescription', 50, 255, $this->getVar('metadescription')), false); |
|
128 | + |
|
129 | + // ========================================================== |
|
130 | + // ========================================================== |
|
131 | + |
|
132 | + // Права |
|
133 | + $memberHandler = xoops_getHandler('member'); |
|
134 | + $group_list = $memberHandler->getGroupList(); |
|
135 | + $gpermHandler = xoops_getHandler('groupperm'); |
|
136 | + $full_list = array_keys($group_list); |
|
137 | + |
|
138 | + // Права на просмотр |
|
139 | + $groups_ids = []; |
|
140 | + // Если мы редактируем |
|
141 | + if (!$this->isNew()) { |
|
142 | + $groups_ids = $gpermHandler->getGroupIds('instruction_view', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
143 | + $groups_ids = array_values($groups_ids); |
|
144 | + $groups_instr_view = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_VIEW, 'groups_instr_view', $groups_ids); |
|
145 | + } else { |
|
146 | + $groups_instr_view = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_VIEW, 'groups_instr_view', $full_list); |
|
147 | + } |
|
148 | + $groups_instr_view->addOptionArray($group_list); |
|
149 | + $form->addElement($groups_instr_view); |
|
150 | + |
|
151 | + // Права на отправку |
|
152 | + $groups_ids = []; |
|
153 | + if (!$this->isNew()) { |
|
154 | + $groups_ids = $gpermHandler->getGroupIds('instruction_submit', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
155 | + $groups_ids = array_values($groups_ids); |
|
156 | + $groups_instr_submit = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_SUBMIT, 'groups_instr_submit', $groups_ids); |
|
157 | + } else { |
|
158 | + $groups_instr_submit = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_SUBMIT, 'groups_instr_submit', $full_list); |
|
159 | + } |
|
160 | + $groups_instr_submit->addOptionArray($group_list); |
|
161 | + $form->addElement($groups_instr_submit); |
|
162 | + |
|
163 | + // Права на редактирование |
|
164 | + $groups_ids = []; |
|
165 | + if (!$this->isNew()) { |
|
166 | + $groups_ids = $gpermHandler->getGroupIds('instruction_edit', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
167 | + $groups_ids = array_values($groups_ids); |
|
168 | + $groups_instr_edit = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_EDIT, 'groups_instr_edit', $groups_ids); |
|
169 | + } else { |
|
170 | + $groups_instr_edit = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_EDIT, 'groups_instr_edit', $full_list); |
|
171 | + } |
|
172 | + $groups_instr_edit->addOptionArray($group_list); |
|
173 | + $form->addElement($groups_instr_edit); |
|
174 | + |
|
175 | + // ========================================================== |
|
176 | + // ========================================================== |
|
177 | + |
|
178 | + // Если мы редактируем категорию |
|
179 | + if (!$this->isNew()) { |
|
180 | + $form->addElement(new \XoopsFormHidden('cid', $this->getVar('cid'))); |
|
181 | + //$form->addElement( new \XoopsFormHidden( 'catmodify', true)); |
|
182 | + } |
|
183 | + // |
|
184 | + $form->addElement(new \XoopsFormHidden('op', 'savecat')); |
|
185 | + // Кнопка |
|
186 | + $button_tray = new \XoopsFormElementTray('', ''); |
|
187 | + $submit_btn = new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
188 | + $button_tray->addElement($submit_btn); |
|
189 | + $cancel_btn = new \XoopsFormButton('', 'cancel', _CANCEL, 'cancel'); |
|
190 | + $cancel_btn->setExtra('onclick="javascript:history.go(-1);"'); |
|
191 | + $button_tray->addElement($cancel_btn); |
|
192 | + $form->addElement($button_tray); |
|
193 | + |
|
194 | + return $form; |
|
195 | + } |
|
196 | 196 | } |
197 | 197 |
@@ -92,7 +92,7 @@ discard block |
||
92 | 92 | // $categoryHandler = xoops_getModuleHandler('category', 'instruction'); |
93 | 93 | $criteria = new \CriteriaCompo(); |
94 | 94 | // Если мы редактируем, то убрать текущую категорию из списка выбора родительской |
95 | - if (!$this->isNew()) { |
|
95 | + if ( ! $this->isNew()) { |
|
96 | 96 | $criteria->add(new \Criteria('cid', $this->getVar('cid'), '<>')); |
97 | 97 | } |
98 | 98 | $criteria->setSort('weight ASC, title'); |
@@ -138,7 +138,7 @@ discard block |
||
138 | 138 | // Права на просмотр |
139 | 139 | $groups_ids = []; |
140 | 140 | // Если мы редактируем |
141 | - if (!$this->isNew()) { |
|
141 | + if ( ! $this->isNew()) { |
|
142 | 142 | $groups_ids = $gpermHandler->getGroupIds('instruction_view', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
143 | 143 | $groups_ids = array_values($groups_ids); |
144 | 144 | $groups_instr_view = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_VIEW, 'groups_instr_view', $groups_ids); |
@@ -150,7 +150,7 @@ discard block |
||
150 | 150 | |
151 | 151 | // Права на отправку |
152 | 152 | $groups_ids = []; |
153 | - if (!$this->isNew()) { |
|
153 | + if ( ! $this->isNew()) { |
|
154 | 154 | $groups_ids = $gpermHandler->getGroupIds('instruction_submit', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
155 | 155 | $groups_ids = array_values($groups_ids); |
156 | 156 | $groups_instr_submit = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_SUBMIT, 'groups_instr_submit', $groups_ids); |
@@ -162,7 +162,7 @@ discard block |
||
162 | 162 | |
163 | 163 | // Права на редактирование |
164 | 164 | $groups_ids = []; |
165 | - if (!$this->isNew()) { |
|
165 | + if ( ! $this->isNew()) { |
|
166 | 166 | $groups_ids = $gpermHandler->getGroupIds('instruction_edit', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
167 | 167 | $groups_ids = array_values($groups_ids); |
168 | 168 | $groups_instr_edit = new \XoopsFormCheckBox(_AM_INSTRUCTION_PERM_EDIT, 'groups_instr_edit', $groups_ids); |
@@ -176,7 +176,7 @@ discard block |
||
176 | 176 | // ========================================================== |
177 | 177 | |
178 | 178 | // Если мы редактируем категорию |
179 | - if (!$this->isNew()) { |
|
179 | + if ( ! $this->isNew()) { |
|
180 | 180 | $form->addElement(new \XoopsFormHidden('cid', $this->getVar('cid'))); |
181 | 181 | //$form->addElement( new \XoopsFormHidden( 'catmodify', true)); |
182 | 182 | } |
@@ -12,177 +12,177 @@ |
||
12 | 12 | */ |
13 | 13 | class Page extends \XoopsObject |
14 | 14 | { |
15 | - // constructor |
|
16 | - public function __construct() |
|
17 | - { |
|
18 | - // $this->XoopsObject(); |
|
19 | - $this->initVar('pageid', XOBJ_DTYPE_INT, null, false, 11); |
|
20 | - $this->initVar('pid', XOBJ_DTYPE_INT, 0, false, 11); |
|
21 | - $this->initVar('instrid', XOBJ_DTYPE_INT, 0, false, 11); |
|
22 | - $this->initVar('uid', XOBJ_DTYPE_INT, 0, false, 11); |
|
23 | - $this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false, 255); |
|
24 | - $this->initVar('status', XOBJ_DTYPE_INT, 1, false, 1); |
|
25 | - $this->initVar('type', XOBJ_DTYPE_INT, 1, false, 1); |
|
26 | - $this->initVar('hometext', XOBJ_DTYPE_TXTAREA, null, false); |
|
27 | - $this->initVar('footnote', XOBJ_DTYPE_TXTAREA, '', false); |
|
28 | - $this->initVar('weight', XOBJ_DTYPE_INT, 0, false, 11); |
|
29 | - $this->initVar('keywords', XOBJ_DTYPE_TXTBOX, '', false, 255); |
|
30 | - $this->initVar('description', XOBJ_DTYPE_TXTBOX, '', false, 255); |
|
31 | - $this->initVar('comments', XOBJ_DTYPE_INT, 0, false, 11); |
|
32 | - $this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10); |
|
33 | - $this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10); |
|
34 | - $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false, 1); |
|
35 | - $this->initVar('dosmiley', XOBJ_DTYPE_INT, 0, false, 1); |
|
36 | - $this->initVar('doxcode', XOBJ_DTYPE_INT, 1, false, 1); |
|
37 | - $this->initVar('dobr', XOBJ_DTYPE_INT, 0, false, 1); |
|
38 | - } |
|
39 | - |
|
40 | - public function Page() |
|
41 | - { |
|
42 | - $this->__construct(); |
|
43 | - } |
|
44 | - |
|
45 | - /** |
|
46 | - * @return mixed |
|
47 | - */ |
|
48 | - public function get_new_enreg() |
|
49 | - { |
|
50 | - $new_enreg = $GLOBALS['xoopsDB']->getInsertId(); |
|
51 | - return $new_enreg; |
|
52 | - } |
|
53 | - |
|
54 | - // Получаем форму |
|
55 | - |
|
56 | - /** |
|
57 | - * @param bool|null|string $action |
|
58 | - * @param int $instrid |
|
59 | - * @return \XoopsThemeForm |
|
60 | - */ |
|
61 | - public function getForm($action = false, $instrid = 0) |
|
62 | - { |
|
63 | - // Если нет $action |
|
64 | - if (false === $action) { |
|
65 | - $action = xoops_getenv('REQUEST_URI'); |
|
66 | - } |
|
67 | - |
|
68 | - // Подключаем формы |
|
69 | - include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
70 | - // Подключаем типы страниц |
|
71 | - $pagetypes = include $GLOBALS['xoops']->path('modules/instruction/include/pagetypes.inc.php'); |
|
72 | - |
|
73 | - // Название формы |
|
74 | - $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDPAGE) : sprintf(_AM_INSTRUCTION_FORMEDITPAGE); |
|
75 | - |
|
76 | - // Форма |
|
77 | - $form = new \XoopsThemeForm($title, 'instr_form_page', $action, 'post', true); |
|
78 | - // Название |
|
79 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true); |
|
80 | - |
|
81 | - // Родительская страница |
|
82 | - // $pageHandler = xoops_getModuleHandler('page', 'instruction'); |
|
83 | - $criteria = new \CriteriaCompo(); |
|
84 | - // ID инструкции в которой данная страница |
|
85 | - $instrid_page = $this->isNew() ? $instrid : $this->getVar('instrid'); |
|
86 | - // Находим все страницы данной инструкции |
|
87 | - $criteria->add(new \Criteria('instrid', $instrid_page, '=')); |
|
88 | - // Если мы редактируем, то убрать текущую страницу из списка выбора родительской |
|
89 | - if (!$this->isNew()) { |
|
90 | - $criteria->add(new \Criteria('pageid', $this->getVar('pageid'), '<>')); |
|
91 | - } |
|
92 | - $criteria->setSort('weight'); |
|
93 | - $criteria->setOrder('ASC'); |
|
94 | - $inspage_arr = $pageHandler->getall($criteria); |
|
95 | - unset($criteria); |
|
96 | - // Подключаем трей |
|
97 | - include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
98 | - $mytree = new \XoopsObjectTree($inspage_arr, 'pageid', 'pid'); |
|
99 | - |
|
100 | - // $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_PPAGEC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
101 | - $helper = Helper::getInstance(); |
|
102 | - $module = $helper->getModule(); |
|
103 | - |
|
104 | - if (Utility::checkVerXoops($module, '2.5.9')) { |
|
105 | - $mytree_select = $mytree->makeSelectElement('pid', 'title', '--', $this->getVar('pid'), true, 0, '', _AM_INSTRUCTION_PPAGEC); |
|
106 | - $form->addElement($mytree_select); |
|
107 | - } else { |
|
108 | - $form->addElement(new \XoopsFormLabel(_AM_INSTRUCTION_PPAGEC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
109 | - } |
|
110 | - |
|
111 | - // Вес |
|
112 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_WEIGHTC, 'weight', 5, 5, $this->getVar('weight')), true); |
|
113 | - // Основной текст |
|
114 | - $form->addElement(Utility::getWysiwygForm(_AM_INSTRUCTION_HOMETEXTC, 'hometext', $this->getVar('hometext', 'e')), true); |
|
115 | - // Сноска |
|
116 | - $form_footnote = new \XoopsFormTextArea(_AM_INSTRUCTION_FOOTNOTEC, 'footnote', $this->getVar('footnote', 'e')); |
|
117 | - $form_footnote->setDescription(_AM_INSTRUCTION_FOOTNOTE_DSC); |
|
118 | - $form->addElement($form_footnote, false); |
|
119 | - unset($form_footnote); |
|
120 | - // Статус |
|
121 | - $form->addElement(new \XoopsFormRadioYN(_AM_INSTRUCTION_ACTIVEC, 'status', $this->getVar('status')), false); |
|
122 | - // Тип страницы |
|
123 | - $form_type = new \XoopsFormSelect(_AM_INSTR_PAGETYPEC, 'type', $this->getVar('type')); |
|
124 | - $form_type->setDescription(_AM_INSTR_PAGETYPEC_DESC); |
|
125 | - $form_type->addOptionArray($pagetypes); |
|
126 | - $form->addElement($form_type, false); |
|
127 | - // Мета-теги ключевых слов |
|
128 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'keywords', 50, 255, $this->getVar('keywords')), false); |
|
129 | - // Мета-теги описания |
|
130 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'description', 50, 255, $this->getVar('description')), false); |
|
131 | - |
|
132 | - // Настройки |
|
133 | - $option_tray = new \XoopsFormElementTray(_OPTIONS, '<br>'); |
|
134 | - // HTML |
|
135 | - $html_checkbox = new \XoopsFormCheckBox('', 'dohtml', $this->getVar('dohtml')); |
|
136 | - $html_checkbox->addOption(1, _AM_INSTR_DOHTML); |
|
137 | - $option_tray->addElement($html_checkbox); |
|
138 | - // Смайлы |
|
139 | - $smiley_checkbox = new \XoopsFormCheckBox('', 'dosmiley', $this->getVar('dosmiley')); |
|
140 | - $smiley_checkbox->addOption(1, _AM_INSTR_DOSMILEY); |
|
141 | - $option_tray->addElement($smiley_checkbox); |
|
142 | - // ББ коды |
|
143 | - $xcode_checkbox = new \XoopsFormCheckBox('', 'doxcode', $this->getVar('doxcode')); |
|
144 | - $xcode_checkbox->addOption(1, _AM_INSTR_DOXCODE); |
|
145 | - $option_tray->addElement($xcode_checkbox); |
|
146 | - // |
|
147 | - $br_checkbox = new \XoopsFormCheckBox('', 'dobr', $this->getVar('dobr')); |
|
148 | - $br_checkbox->addOption(1, _AM_INSTR_DOAUTOWRAP); |
|
149 | - $option_tray->addElement($br_checkbox); |
|
150 | - // |
|
151 | - $form->addElement($option_tray); |
|
152 | - |
|
153 | - // Если мы редактируем страницу |
|
154 | - if (!$this->isNew()) { |
|
155 | - $form->addElement(new \XoopsFormHidden('pageid', $this->getVar('pageid'))); |
|
156 | - } else { |
|
157 | - $form->addElement(new \XoopsFormHidden('pageid', 0)); |
|
158 | - } |
|
159 | - // ID инструкции |
|
160 | - if ($instrid) { |
|
161 | - $form->addElement(new \XoopsFormHidden('instrid', $instrid)); |
|
162 | - } else { |
|
163 | - $form->addElement(new \XoopsFormHidden('instrid', 0)); |
|
164 | - } |
|
165 | - // |
|
166 | - $form->addElement(new \XoopsFormHidden('op', 'savepage')); |
|
167 | - // Кнопка |
|
168 | - $button_tray = new \XoopsFormElementTray('', ''); |
|
169 | - $button_tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
170 | - $save_btn = new \XoopsFormButton('', 'cancel', _AM_INSTR_SAVEFORM); |
|
171 | - $save_btn->setExtra('onclick="instrSavePage();"'); |
|
172 | - $button_tray->addElement($save_btn); |
|
173 | - $form->addElement($button_tray); |
|
174 | - |
|
175 | - return $form; |
|
176 | - } |
|
177 | - |
|
178 | - // |
|
179 | - |
|
180 | - /** |
|
181 | - * @return mixed |
|
182 | - */ |
|
183 | - public function getInstrid() |
|
184 | - { |
|
185 | - // Возвращаем ID инструкции |
|
186 | - return $this->getVar('instrid'); |
|
187 | - } |
|
15 | + // constructor |
|
16 | + public function __construct() |
|
17 | + { |
|
18 | + // $this->XoopsObject(); |
|
19 | + $this->initVar('pageid', XOBJ_DTYPE_INT, null, false, 11); |
|
20 | + $this->initVar('pid', XOBJ_DTYPE_INT, 0, false, 11); |
|
21 | + $this->initVar('instrid', XOBJ_DTYPE_INT, 0, false, 11); |
|
22 | + $this->initVar('uid', XOBJ_DTYPE_INT, 0, false, 11); |
|
23 | + $this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false, 255); |
|
24 | + $this->initVar('status', XOBJ_DTYPE_INT, 1, false, 1); |
|
25 | + $this->initVar('type', XOBJ_DTYPE_INT, 1, false, 1); |
|
26 | + $this->initVar('hometext', XOBJ_DTYPE_TXTAREA, null, false); |
|
27 | + $this->initVar('footnote', XOBJ_DTYPE_TXTAREA, '', false); |
|
28 | + $this->initVar('weight', XOBJ_DTYPE_INT, 0, false, 11); |
|
29 | + $this->initVar('keywords', XOBJ_DTYPE_TXTBOX, '', false, 255); |
|
30 | + $this->initVar('description', XOBJ_DTYPE_TXTBOX, '', false, 255); |
|
31 | + $this->initVar('comments', XOBJ_DTYPE_INT, 0, false, 11); |
|
32 | + $this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10); |
|
33 | + $this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10); |
|
34 | + $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false, 1); |
|
35 | + $this->initVar('dosmiley', XOBJ_DTYPE_INT, 0, false, 1); |
|
36 | + $this->initVar('doxcode', XOBJ_DTYPE_INT, 1, false, 1); |
|
37 | + $this->initVar('dobr', XOBJ_DTYPE_INT, 0, false, 1); |
|
38 | + } |
|
39 | + |
|
40 | + public function Page() |
|
41 | + { |
|
42 | + $this->__construct(); |
|
43 | + } |
|
44 | + |
|
45 | + /** |
|
46 | + * @return mixed |
|
47 | + */ |
|
48 | + public function get_new_enreg() |
|
49 | + { |
|
50 | + $new_enreg = $GLOBALS['xoopsDB']->getInsertId(); |
|
51 | + return $new_enreg; |
|
52 | + } |
|
53 | + |
|
54 | + // Получаем форму |
|
55 | + |
|
56 | + /** |
|
57 | + * @param bool|null|string $action |
|
58 | + * @param int $instrid |
|
59 | + * @return \XoopsThemeForm |
|
60 | + */ |
|
61 | + public function getForm($action = false, $instrid = 0) |
|
62 | + { |
|
63 | + // Если нет $action |
|
64 | + if (false === $action) { |
|
65 | + $action = xoops_getenv('REQUEST_URI'); |
|
66 | + } |
|
67 | + |
|
68 | + // Подключаем формы |
|
69 | + include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
70 | + // Подключаем типы страниц |
|
71 | + $pagetypes = include $GLOBALS['xoops']->path('modules/instruction/include/pagetypes.inc.php'); |
|
72 | + |
|
73 | + // Название формы |
|
74 | + $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDPAGE) : sprintf(_AM_INSTRUCTION_FORMEDITPAGE); |
|
75 | + |
|
76 | + // Форма |
|
77 | + $form = new \XoopsThemeForm($title, 'instr_form_page', $action, 'post', true); |
|
78 | + // Название |
|
79 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true); |
|
80 | + |
|
81 | + // Родительская страница |
|
82 | + // $pageHandler = xoops_getModuleHandler('page', 'instruction'); |
|
83 | + $criteria = new \CriteriaCompo(); |
|
84 | + // ID инструкции в которой данная страница |
|
85 | + $instrid_page = $this->isNew() ? $instrid : $this->getVar('instrid'); |
|
86 | + // Находим все страницы данной инструкции |
|
87 | + $criteria->add(new \Criteria('instrid', $instrid_page, '=')); |
|
88 | + // Если мы редактируем, то убрать текущую страницу из списка выбора родительской |
|
89 | + if (!$this->isNew()) { |
|
90 | + $criteria->add(new \Criteria('pageid', $this->getVar('pageid'), '<>')); |
|
91 | + } |
|
92 | + $criteria->setSort('weight'); |
|
93 | + $criteria->setOrder('ASC'); |
|
94 | + $inspage_arr = $pageHandler->getall($criteria); |
|
95 | + unset($criteria); |
|
96 | + // Подключаем трей |
|
97 | + include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
98 | + $mytree = new \XoopsObjectTree($inspage_arr, 'pageid', 'pid'); |
|
99 | + |
|
100 | + // $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_PPAGEC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
101 | + $helper = Helper::getInstance(); |
|
102 | + $module = $helper->getModule(); |
|
103 | + |
|
104 | + if (Utility::checkVerXoops($module, '2.5.9')) { |
|
105 | + $mytree_select = $mytree->makeSelectElement('pid', 'title', '--', $this->getVar('pid'), true, 0, '', _AM_INSTRUCTION_PPAGEC); |
|
106 | + $form->addElement($mytree_select); |
|
107 | + } else { |
|
108 | + $form->addElement(new \XoopsFormLabel(_AM_INSTRUCTION_PPAGEC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
109 | + } |
|
110 | + |
|
111 | + // Вес |
|
112 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_WEIGHTC, 'weight', 5, 5, $this->getVar('weight')), true); |
|
113 | + // Основной текст |
|
114 | + $form->addElement(Utility::getWysiwygForm(_AM_INSTRUCTION_HOMETEXTC, 'hometext', $this->getVar('hometext', 'e')), true); |
|
115 | + // Сноска |
|
116 | + $form_footnote = new \XoopsFormTextArea(_AM_INSTRUCTION_FOOTNOTEC, 'footnote', $this->getVar('footnote', 'e')); |
|
117 | + $form_footnote->setDescription(_AM_INSTRUCTION_FOOTNOTE_DSC); |
|
118 | + $form->addElement($form_footnote, false); |
|
119 | + unset($form_footnote); |
|
120 | + // Статус |
|
121 | + $form->addElement(new \XoopsFormRadioYN(_AM_INSTRUCTION_ACTIVEC, 'status', $this->getVar('status')), false); |
|
122 | + // Тип страницы |
|
123 | + $form_type = new \XoopsFormSelect(_AM_INSTR_PAGETYPEC, 'type', $this->getVar('type')); |
|
124 | + $form_type->setDescription(_AM_INSTR_PAGETYPEC_DESC); |
|
125 | + $form_type->addOptionArray($pagetypes); |
|
126 | + $form->addElement($form_type, false); |
|
127 | + // Мета-теги ключевых слов |
|
128 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'keywords', 50, 255, $this->getVar('keywords')), false); |
|
129 | + // Мета-теги описания |
|
130 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'description', 50, 255, $this->getVar('description')), false); |
|
131 | + |
|
132 | + // Настройки |
|
133 | + $option_tray = new \XoopsFormElementTray(_OPTIONS, '<br>'); |
|
134 | + // HTML |
|
135 | + $html_checkbox = new \XoopsFormCheckBox('', 'dohtml', $this->getVar('dohtml')); |
|
136 | + $html_checkbox->addOption(1, _AM_INSTR_DOHTML); |
|
137 | + $option_tray->addElement($html_checkbox); |
|
138 | + // Смайлы |
|
139 | + $smiley_checkbox = new \XoopsFormCheckBox('', 'dosmiley', $this->getVar('dosmiley')); |
|
140 | + $smiley_checkbox->addOption(1, _AM_INSTR_DOSMILEY); |
|
141 | + $option_tray->addElement($smiley_checkbox); |
|
142 | + // ББ коды |
|
143 | + $xcode_checkbox = new \XoopsFormCheckBox('', 'doxcode', $this->getVar('doxcode')); |
|
144 | + $xcode_checkbox->addOption(1, _AM_INSTR_DOXCODE); |
|
145 | + $option_tray->addElement($xcode_checkbox); |
|
146 | + // |
|
147 | + $br_checkbox = new \XoopsFormCheckBox('', 'dobr', $this->getVar('dobr')); |
|
148 | + $br_checkbox->addOption(1, _AM_INSTR_DOAUTOWRAP); |
|
149 | + $option_tray->addElement($br_checkbox); |
|
150 | + // |
|
151 | + $form->addElement($option_tray); |
|
152 | + |
|
153 | + // Если мы редактируем страницу |
|
154 | + if (!$this->isNew()) { |
|
155 | + $form->addElement(new \XoopsFormHidden('pageid', $this->getVar('pageid'))); |
|
156 | + } else { |
|
157 | + $form->addElement(new \XoopsFormHidden('pageid', 0)); |
|
158 | + } |
|
159 | + // ID инструкции |
|
160 | + if ($instrid) { |
|
161 | + $form->addElement(new \XoopsFormHidden('instrid', $instrid)); |
|
162 | + } else { |
|
163 | + $form->addElement(new \XoopsFormHidden('instrid', 0)); |
|
164 | + } |
|
165 | + // |
|
166 | + $form->addElement(new \XoopsFormHidden('op', 'savepage')); |
|
167 | + // Кнопка |
|
168 | + $button_tray = new \XoopsFormElementTray('', ''); |
|
169 | + $button_tray->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
170 | + $save_btn = new \XoopsFormButton('', 'cancel', _AM_INSTR_SAVEFORM); |
|
171 | + $save_btn->setExtra('onclick="instrSavePage();"'); |
|
172 | + $button_tray->addElement($save_btn); |
|
173 | + $form->addElement($button_tray); |
|
174 | + |
|
175 | + return $form; |
|
176 | + } |
|
177 | + |
|
178 | + // |
|
179 | + |
|
180 | + /** |
|
181 | + * @return mixed |
|
182 | + */ |
|
183 | + public function getInstrid() |
|
184 | + { |
|
185 | + // Возвращаем ID инструкции |
|
186 | + return $this->getVar('instrid'); |
|
187 | + } |
|
188 | 188 | } |
@@ -86,7 +86,7 @@ discard block |
||
86 | 86 | // Находим все страницы данной инструкции |
87 | 87 | $criteria->add(new \Criteria('instrid', $instrid_page, '=')); |
88 | 88 | // Если мы редактируем, то убрать текущую страницу из списка выбора родительской |
89 | - if (!$this->isNew()) { |
|
89 | + if ( ! $this->isNew()) { |
|
90 | 90 | $criteria->add(new \Criteria('pageid', $this->getVar('pageid'), '<>')); |
91 | 91 | } |
92 | 92 | $criteria->setSort('weight'); |
@@ -151,7 +151,7 @@ discard block |
||
151 | 151 | $form->addElement($option_tray); |
152 | 152 | |
153 | 153 | // Если мы редактируем страницу |
154 | - if (!$this->isNew()) { |
|
154 | + if ( ! $this->isNew()) { |
|
155 | 155 | $form->addElement(new \XoopsFormHidden('pageid', $this->getVar('pageid'))); |
156 | 156 | } else { |
157 | 157 | $form->addElement(new \XoopsFormHidden('pageid', 0)); |
@@ -16,28 +16,28 @@ |
||
16 | 16 | */ |
17 | 17 | class CategoryHandler extends \XoopsPersistableObjectHandler |
18 | 18 | { |
19 | - /** |
|
20 | - * @param null|mixed $db |
|
21 | - */ |
|
22 | - public function __construct(\XoopsDatabase $db = null) |
|
23 | - { |
|
24 | - parent::__construct($db, 'instruction_cat', Category::class, 'cid', 'title'); |
|
25 | - } |
|
19 | + /** |
|
20 | + * @param null|mixed $db |
|
21 | + */ |
|
22 | + public function __construct(\XoopsDatabase $db = null) |
|
23 | + { |
|
24 | + parent::__construct($db, 'instruction_cat', Category::class, 'cid', 'title'); |
|
25 | + } |
|
26 | 26 | |
27 | - // Обновление даты обновления категории |
|
27 | + // Обновление даты обновления категории |
|
28 | 28 | |
29 | - /** |
|
30 | - * @param int $cid |
|
31 | - * @param null|int $time |
|
32 | - * @return mixed |
|
33 | - */ |
|
34 | - public function updateDateupdated($cid = 0, $time = null) |
|
35 | - { |
|
36 | - // Если не передали время |
|
37 | - $time = null === $time ? time() : (int)$time; |
|
38 | - // |
|
39 | - $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `cid` = %u', $this->table, $time, (int)$cid); |
|
40 | - // |
|
41 | - return $this->db->query($sql); |
|
42 | - } |
|
29 | + /** |
|
30 | + * @param int $cid |
|
31 | + * @param null|int $time |
|
32 | + * @return mixed |
|
33 | + */ |
|
34 | + public function updateDateupdated($cid = 0, $time = null) |
|
35 | + { |
|
36 | + // Если не передали время |
|
37 | + $time = null === $time ? time() : (int)$time; |
|
38 | + // |
|
39 | + $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `cid` = %u', $this->table, $time, (int)$cid); |
|
40 | + // |
|
41 | + return $this->db->query($sql); |
|
42 | + } |
|
43 | 43 | } |
@@ -34,9 +34,9 @@ |
||
34 | 34 | public function updateDateupdated($cid = 0, $time = null) |
35 | 35 | { |
36 | 36 | // Если не передали время |
37 | - $time = null === $time ? time() : (int)$time; |
|
37 | + $time = null === $time ? time() : (int) $time; |
|
38 | 38 | // |
39 | - $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `cid` = %u', $this->table, $time, (int)$cid); |
|
39 | + $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `cid` = %u', $this->table, $time, (int) $cid); |
|
40 | 40 | // |
41 | 41 | return $this->db->query($sql); |
42 | 42 | } |
@@ -12,120 +12,120 @@ |
||
12 | 12 | */ |
13 | 13 | class Instruction extends \XoopsObject |
14 | 14 | { |
15 | - // constructor |
|
16 | - public function __construct() |
|
17 | - { |
|
18 | - // $this->XoopsObject(); |
|
19 | - $this->initVar('instrid', XOBJ_DTYPE_INT, null, false, 11); |
|
20 | - $this->initVar('cid', XOBJ_DTYPE_INT, 0, false, 5); |
|
21 | - $this->initVar('uid', XOBJ_DTYPE_INT, 0, false, 11); |
|
22 | - $this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false); |
|
23 | - $this->initVar('status', XOBJ_DTYPE_INT, 0, false, 1); |
|
24 | - $this->initVar('pages', XOBJ_DTYPE_INT, 0, false, 11); |
|
25 | - $this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false); |
|
26 | - $this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10); |
|
27 | - $this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10); |
|
28 | - $this->initVar('metakeywords', XOBJ_DTYPE_TXTBOX, '', false); |
|
29 | - $this->initVar('metadescription', XOBJ_DTYPE_TXTBOX, '', false); |
|
30 | - |
|
31 | - // Нет в таблице |
|
32 | - $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); |
|
33 | - $this->initVar('dobr', XOBJ_DTYPE_INT, 0, false); |
|
34 | - } |
|
35 | - |
|
36 | - public function Instruction() |
|
37 | - { |
|
38 | - $this->__construct(); |
|
39 | - } |
|
40 | - |
|
41 | - /** |
|
42 | - * @return mixed |
|
43 | - */ |
|
44 | - public function get_new_enreg() |
|
45 | - { |
|
46 | - $new_enreg = $GLOBALS['xoopsDB']->getInsertId(); |
|
47 | - return $new_enreg; |
|
48 | - } |
|
49 | - |
|
50 | - // Получаем форму |
|
51 | - |
|
52 | - /** |
|
53 | - * @param bool|null|string $action |
|
54 | - * @return \XoopsThemeForm |
|
55 | - */ |
|
56 | - public function getForm($action = false) |
|
57 | - { |
|
58 | - global $xoopsDB, $xoopsModule, $xoopsModuleConfig; |
|
59 | - // Если нет $action |
|
60 | - if (false === $action) { |
|
61 | - $action = xoops_getenv('REQUEST_URI'); |
|
62 | - } |
|
63 | - // Подключаем формы |
|
64 | - include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
65 | - |
|
66 | - // Название формы |
|
67 | - $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDINSTR) : sprintf(_AM_INSTRUCTION_FORMEDITINSTR); |
|
68 | - |
|
69 | - // Форма |
|
70 | - $form = new \XoopsThemeForm($title, 'forminstr', $action, 'post', true); |
|
71 | - //$form->setExtra('enctype="multipart/form-data"'); |
|
72 | - // Название инструкции |
|
73 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true); |
|
74 | - // Категория |
|
75 | - $categoryHandler = new CategoryHandler; |
|
76 | - $criteria = new \CriteriaCompo(); |
|
77 | - $criteria->setSort('weight ASC, title'); |
|
78 | - $criteria->setOrder('ASC'); |
|
79 | - $instructioncat_arr = $categoryHandler->getall($criteria); |
|
80 | - unset($criteria); |
|
81 | - // Подключаем трей |
|
82 | - include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
83 | - $mytree = new \XoopsObjectTree($instructioncat_arr, 'cid', 'pid'); |
|
84 | - |
|
85 | - // $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_CATC, $mytree->makeSelBox('cid', 'title', '--', $this->getVar('cid'), true))); |
|
86 | - $helper = Helper::getInstance(); |
|
87 | - $module = $helper->getModule(); |
|
88 | - |
|
89 | - if (Utility::checkVerXoops($module, '2.5.9')) { |
|
90 | - $mytree_select = $mytree->makeSelectElement('cid', 'title', '--', $this->getVar('cid'), true, 0, '', _AM_INSTRUCTION_CATC); |
|
91 | - $form->addElement($mytree_select); |
|
92 | - } else { |
|
93 | - $form->addElement(new \XoopsFormLabel(_AM_INSTRUCTION_CATC, $mytree->makeSelBox('cid', 'title', '--', $this->getVar('cid'), true))); |
|
94 | - } |
|
95 | - |
|
96 | - // Описание |
|
97 | - $form->addElement(Utility::getWysiwygForm(_AM_INSTRUCTION_DESCRIPTIONC, 'description', $this->getVar('description', 'e')), true); |
|
98 | - // Статус |
|
99 | - $form->addElement(new \XoopsFormRadioYN(_AM_INSTRUCTION_ACTIVEC, 'status', $this->getVar('status')), false); |
|
100 | - |
|
101 | - // Теги |
|
102 | - $dir_tag_ok = false; |
|
103 | - if (is_dir('../../tag') || is_dir('../tag')) { |
|
104 | - $dir_tag_ok = true; |
|
105 | - } |
|
106 | - // Если влючена поддержка тегов и есть модуль tag |
|
107 | - if (xoops_getModuleOption('usetag', 'instruction') && $dir_tag_ok) { |
|
108 | - $itemIdForTag = $this->isNew() ? 0 : $this->getVar('instrid'); |
|
109 | - // Подключаем форму тегов |
|
110 | - include_once $GLOBALS['xoops']->path('modules/tag/include/formtag.php'); |
|
111 | - // Добавляем элемент в форму |
|
112 | - $form->addElement(new \XoopsFormTag('tag', 60, 255, $itemIdForTag, 0)); |
|
113 | - } |
|
114 | - |
|
115 | - // Мета-теги ключевых слов |
|
116 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'metakeywords', 50, 255, $this->getVar('metakeywords')), false); |
|
117 | - // Мета-теги описания |
|
118 | - $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'metadescription', 50, 255, $this->getVar('metadescription')), false); |
|
119 | - |
|
120 | - // Если мы редактируем категорию |
|
121 | - if (!$this->isNew()) { |
|
122 | - $form->addElement(new \XoopsFormHidden('instrid', $this->getVar('instrid'))); |
|
123 | - } |
|
124 | - // |
|
125 | - $form->addElement(new \XoopsFormHidden('op', 'saveinstr')); |
|
126 | - // Кнопка |
|
127 | - $form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
128 | - return $form; |
|
129 | - } |
|
15 | + // constructor |
|
16 | + public function __construct() |
|
17 | + { |
|
18 | + // $this->XoopsObject(); |
|
19 | + $this->initVar('instrid', XOBJ_DTYPE_INT, null, false, 11); |
|
20 | + $this->initVar('cid', XOBJ_DTYPE_INT, 0, false, 5); |
|
21 | + $this->initVar('uid', XOBJ_DTYPE_INT, 0, false, 11); |
|
22 | + $this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false); |
|
23 | + $this->initVar('status', XOBJ_DTYPE_INT, 0, false, 1); |
|
24 | + $this->initVar('pages', XOBJ_DTYPE_INT, 0, false, 11); |
|
25 | + $this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false); |
|
26 | + $this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10); |
|
27 | + $this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10); |
|
28 | + $this->initVar('metakeywords', XOBJ_DTYPE_TXTBOX, '', false); |
|
29 | + $this->initVar('metadescription', XOBJ_DTYPE_TXTBOX, '', false); |
|
30 | + |
|
31 | + // Нет в таблице |
|
32 | + $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); |
|
33 | + $this->initVar('dobr', XOBJ_DTYPE_INT, 0, false); |
|
34 | + } |
|
35 | + |
|
36 | + public function Instruction() |
|
37 | + { |
|
38 | + $this->__construct(); |
|
39 | + } |
|
40 | + |
|
41 | + /** |
|
42 | + * @return mixed |
|
43 | + */ |
|
44 | + public function get_new_enreg() |
|
45 | + { |
|
46 | + $new_enreg = $GLOBALS['xoopsDB']->getInsertId(); |
|
47 | + return $new_enreg; |
|
48 | + } |
|
49 | + |
|
50 | + // Получаем форму |
|
51 | + |
|
52 | + /** |
|
53 | + * @param bool|null|string $action |
|
54 | + * @return \XoopsThemeForm |
|
55 | + */ |
|
56 | + public function getForm($action = false) |
|
57 | + { |
|
58 | + global $xoopsDB, $xoopsModule, $xoopsModuleConfig; |
|
59 | + // Если нет $action |
|
60 | + if (false === $action) { |
|
61 | + $action = xoops_getenv('REQUEST_URI'); |
|
62 | + } |
|
63 | + // Подключаем формы |
|
64 | + include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
65 | + |
|
66 | + // Название формы |
|
67 | + $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDINSTR) : sprintf(_AM_INSTRUCTION_FORMEDITINSTR); |
|
68 | + |
|
69 | + // Форма |
|
70 | + $form = new \XoopsThemeForm($title, 'forminstr', $action, 'post', true); |
|
71 | + //$form->setExtra('enctype="multipart/form-data"'); |
|
72 | + // Название инструкции |
|
73 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true); |
|
74 | + // Категория |
|
75 | + $categoryHandler = new CategoryHandler; |
|
76 | + $criteria = new \CriteriaCompo(); |
|
77 | + $criteria->setSort('weight ASC, title'); |
|
78 | + $criteria->setOrder('ASC'); |
|
79 | + $instructioncat_arr = $categoryHandler->getall($criteria); |
|
80 | + unset($criteria); |
|
81 | + // Подключаем трей |
|
82 | + include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
83 | + $mytree = new \XoopsObjectTree($instructioncat_arr, 'cid', 'pid'); |
|
84 | + |
|
85 | + // $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_CATC, $mytree->makeSelBox('cid', 'title', '--', $this->getVar('cid'), true))); |
|
86 | + $helper = Helper::getInstance(); |
|
87 | + $module = $helper->getModule(); |
|
88 | + |
|
89 | + if (Utility::checkVerXoops($module, '2.5.9')) { |
|
90 | + $mytree_select = $mytree->makeSelectElement('cid', 'title', '--', $this->getVar('cid'), true, 0, '', _AM_INSTRUCTION_CATC); |
|
91 | + $form->addElement($mytree_select); |
|
92 | + } else { |
|
93 | + $form->addElement(new \XoopsFormLabel(_AM_INSTRUCTION_CATC, $mytree->makeSelBox('cid', 'title', '--', $this->getVar('cid'), true))); |
|
94 | + } |
|
95 | + |
|
96 | + // Описание |
|
97 | + $form->addElement(Utility::getWysiwygForm(_AM_INSTRUCTION_DESCRIPTIONC, 'description', $this->getVar('description', 'e')), true); |
|
98 | + // Статус |
|
99 | + $form->addElement(new \XoopsFormRadioYN(_AM_INSTRUCTION_ACTIVEC, 'status', $this->getVar('status')), false); |
|
100 | + |
|
101 | + // Теги |
|
102 | + $dir_tag_ok = false; |
|
103 | + if (is_dir('../../tag') || is_dir('../tag')) { |
|
104 | + $dir_tag_ok = true; |
|
105 | + } |
|
106 | + // Если влючена поддержка тегов и есть модуль tag |
|
107 | + if (xoops_getModuleOption('usetag', 'instruction') && $dir_tag_ok) { |
|
108 | + $itemIdForTag = $this->isNew() ? 0 : $this->getVar('instrid'); |
|
109 | + // Подключаем форму тегов |
|
110 | + include_once $GLOBALS['xoops']->path('modules/tag/include/formtag.php'); |
|
111 | + // Добавляем элемент в форму |
|
112 | + $form->addElement(new \XoopsFormTag('tag', 60, 255, $itemIdForTag, 0)); |
|
113 | + } |
|
114 | + |
|
115 | + // Мета-теги ключевых слов |
|
116 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'metakeywords', 50, 255, $this->getVar('metakeywords')), false); |
|
117 | + // Мета-теги описания |
|
118 | + $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'metadescription', 50, 255, $this->getVar('metadescription')), false); |
|
119 | + |
|
120 | + // Если мы редактируем категорию |
|
121 | + if (!$this->isNew()) { |
|
122 | + $form->addElement(new \XoopsFormHidden('instrid', $this->getVar('instrid'))); |
|
123 | + } |
|
124 | + // |
|
125 | + $form->addElement(new \XoopsFormHidden('op', 'saveinstr')); |
|
126 | + // Кнопка |
|
127 | + $form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
128 | + return $form; |
|
129 | + } |
|
130 | 130 | } |
131 | 131 |
@@ -118,7 +118,7 @@ |
||
118 | 118 | $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'metadescription', 50, 255, $this->getVar('metadescription')), false); |
119 | 119 | |
120 | 120 | // Если мы редактируем категорию |
121 | - if (!$this->isNew()) { |
|
121 | + if ( ! $this->isNew()) { |
|
122 | 122 | $form->addElement(new \XoopsFormHidden('instrid', $this->getVar('instrid'))); |
123 | 123 | } |
124 | 124 | // |
@@ -70,8 +70,8 @@ |
||
70 | 70 | $debug = false; |
71 | 71 | |
72 | 72 | if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) { |
73 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
74 | - $xoopsTpl = new \XoopsTpl(); |
|
73 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
74 | + $xoopsTpl = new \XoopsTpl(); |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | $moduleDirName = basename(dirname(__DIR__)); |
@@ -69,7 +69,7 @@ |
||
69 | 69 | |
70 | 70 | $debug = false; |
71 | 71 | |
72 | -if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) { |
|
72 | +if ( ! isset($GLOBALS['xoopsTpl']) || ! ($GLOBALS['xoopsTpl'] instanceof XoopsTpl)) { |
|
73 | 73 | require_once $GLOBALS['xoops']->path('class/template.php'); |
74 | 74 | $xoopsTpl = new \XoopsTpl(); |
75 | 75 | } |