@@ -32,48 +32,48 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | class PedigreeBreadcrumb |
| 34 | 34 | { |
| 35 | - public $dirname; |
|
| 36 | - private $bread = []; |
|
| 35 | + public $dirname; |
|
| 36 | + private $bread = []; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * |
|
| 40 | - */ |
|
| 41 | - public function __construct() |
|
| 42 | - { |
|
| 43 | - $this->dirname = basename(dirname(__DIR__)); |
|
| 44 | - } |
|
| 38 | + /** |
|
| 39 | + * |
|
| 40 | + */ |
|
| 41 | + public function __construct() |
|
| 42 | + { |
|
| 43 | + $this->dirname = basename(dirname(__DIR__)); |
|
| 44 | + } |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Add link to breadcrumb |
|
| 48 | - * |
|
| 49 | - * @param string $title |
|
| 50 | - * @param string $link |
|
| 51 | - */ |
|
| 52 | - public function addLink($title = '', $link = '') |
|
| 53 | - { |
|
| 54 | - $this->bread[] = [ |
|
| 55 | - 'link' => $link, |
|
| 56 | - 'title' => $title |
|
| 57 | - ]; |
|
| 58 | - } |
|
| 46 | + /** |
|
| 47 | + * Add link to breadcrumb |
|
| 48 | + * |
|
| 49 | + * @param string $title |
|
| 50 | + * @param string $link |
|
| 51 | + */ |
|
| 52 | + public function addLink($title = '', $link = '') |
|
| 53 | + { |
|
| 54 | + $this->bread[] = [ |
|
| 55 | + 'link' => $link, |
|
| 56 | + 'title' => $title |
|
| 57 | + ]; |
|
| 58 | + } |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Render Pedigree BreadCrumb |
|
| 62 | - * |
|
| 63 | - */ |
|
| 64 | - public function render() |
|
| 65 | - { |
|
| 66 | - if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) { |
|
| 67 | - require_once $GLOBALS['xoops']->path('class/theme.php'); |
|
| 68 | - $GLOBALS['xoTheme'] = new xos_opal_Theme(); |
|
| 69 | - } |
|
| 60 | + /** |
|
| 61 | + * Render Pedigree BreadCrumb |
|
| 62 | + * |
|
| 63 | + */ |
|
| 64 | + public function render() |
|
| 65 | + { |
|
| 66 | + if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) { |
|
| 67 | + require_once $GLOBALS['xoops']->path('class/theme.php'); |
|
| 68 | + $GLOBALS['xoTheme'] = new xos_opal_Theme(); |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 72 | - $breadcrumbTpl = new XoopsTpl(); |
|
| 73 | - $breadcrumbTpl->assign('breadcrumb', $this->bread); |
|
| 74 | - $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl'); |
|
| 75 | - unset($breadcrumbTpl); |
|
| 71 | + require_once $GLOBALS['xoops']->path('class/template.php'); |
|
| 72 | + $breadcrumbTpl = new XoopsTpl(); |
|
| 73 | + $breadcrumbTpl->assign('breadcrumb', $this->bread); |
|
| 74 | + $html = $breadcrumbTpl->fetch('db:' . $this->dirname . '_common_breadcrumb.tpl'); |
|
| 75 | + unset($breadcrumbTpl); |
|
| 76 | 76 | |
| 77 | - return $html; |
|
| 78 | - } |
|
| 77 | + return $html; |
|
| 78 | + } |
|
| 79 | 79 | } |
@@ -63,7 +63,7 @@ |
||
| 63 | 63 | */ |
| 64 | 64 | public function render() |
| 65 | 65 | { |
| 66 | - if (!isset($GLOBALS['xoTheme']) || !is_object($GLOBALS['xoTheme'])) { |
|
| 66 | + if ( ! isset($GLOBALS['xoTheme']) || ! is_object($GLOBALS['xoTheme'])) { |
|
| 67 | 67 | require_once $GLOBALS['xoops']->path('class/theme.php'); |
| 68 | 68 | $GLOBALS['xoTheme'] = new xos_opal_Theme(); |
| 69 | 69 | } |
@@ -16,226 +16,226 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | trait FilesManagement |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
| 21 | - * |
|
| 22 | - * @param string $folder The full path of the directory to check |
|
| 23 | - * |
|
| 24 | - * @return void |
|
| 25 | - */ |
|
| 26 | - public static function createFolder($folder) |
|
| 27 | - { |
|
| 28 | - try { |
|
| 29 | - if (!file_exists($folder)) { |
|
| 30 | - if (!mkdir($folder) && !is_dir($folder)) { |
|
| 31 | - throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
| 32 | - } |
|
| 33 | - |
|
| 34 | - file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
| 35 | - } |
|
| 36 | - } catch (Exception $e) { |
|
| 37 | - echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
| 38 | - } |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - /** |
|
| 42 | - * @param $file |
|
| 43 | - * @param $folder |
|
| 44 | - * @return bool |
|
| 45 | - */ |
|
| 46 | - public static function copyFile($file, $folder) |
|
| 47 | - { |
|
| 48 | - return copy($file, $folder); |
|
| 49 | - } |
|
| 50 | - |
|
| 51 | - /** |
|
| 52 | - * @param $src |
|
| 53 | - * @param $dst |
|
| 54 | - */ |
|
| 55 | - public static function recurseCopy($src, $dst) |
|
| 56 | - { |
|
| 57 | - $dir = opendir($src); |
|
| 58 | - @mkdir($dst); |
|
| 59 | - while (false !== ($file = readdir($dir))) { |
|
| 60 | - if (('.' !== $file) && ('..' !== $file)) { |
|
| 61 | - if (is_dir($src . '/' . $file)) { |
|
| 62 | - self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
| 63 | - } else { |
|
| 64 | - copy($src . '/' . $file, $dst . '/' . $file); |
|
| 65 | - } |
|
| 66 | - } |
|
| 67 | - } |
|
| 68 | - closedir($dir); |
|
| 69 | - } |
|
| 70 | - |
|
| 71 | - /** |
|
| 72 | - * |
|
| 73 | - * Remove files and (sub)directories |
|
| 74 | - * |
|
| 75 | - * @param string $src source directory to delete |
|
| 76 | - * |
|
| 77 | - * @uses \Xmf\Module\Helper::getHelper() |
|
| 78 | - * @uses \Xmf\Module\Helper::isUserAdmin() |
|
| 79 | - * |
|
| 80 | - * @return bool true on success |
|
| 81 | - */ |
|
| 82 | - public static function deleteDirectory($src) |
|
| 83 | - { |
|
| 84 | - // Only continue if user is a 'global' Admin |
|
| 85 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
| 86 | - return false; |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - $success = true; |
|
| 90 | - // remove old files |
|
| 91 | - $dirInfo = new SplFileInfo($src); |
|
| 92 | - // validate is a directory |
|
| 93 | - if ($dirInfo->isDir()) { |
|
| 94 | - $fileList = array_diff(scandir($src, SCANDIR_SORT_NONE), ['..', '.']); |
|
| 95 | - foreach ($fileList as $k => $v) { |
|
| 96 | - $fileInfo = new SplFileInfo("{$src}/{$v}"); |
|
| 97 | - if ($fileInfo->isDir()) { |
|
| 98 | - // recursively handle subdirectories |
|
| 99 | - if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
| 100 | - break; |
|
| 101 | - } |
|
| 102 | - } else { |
|
| 103 | - // delete the file |
|
| 104 | - if (!($success = unlink($fileInfo->getRealPath()))) { |
|
| 105 | - break; |
|
| 106 | - } |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - // now delete this (sub)directory if all the files are gone |
|
| 110 | - if ($success) { |
|
| 111 | - $success = rmdir($dirInfo->getRealPath()); |
|
| 112 | - } |
|
| 113 | - } else { |
|
| 114 | - // input is not a valid directory |
|
| 115 | - $success = false; |
|
| 116 | - } |
|
| 117 | - return $success; |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - /** |
|
| 121 | - * |
|
| 122 | - * Recursively remove directory |
|
| 123 | - * |
|
| 124 | - * @todo currently won't remove directories with hidden files, should it? |
|
| 125 | - * |
|
| 126 | - * @param string $src directory to remove (delete) |
|
| 127 | - * |
|
| 128 | - * @return bool true on success |
|
| 129 | - */ |
|
| 130 | - public static function rrmdir($src) |
|
| 131 | - { |
|
| 132 | - // Only continue if user is a 'global' Admin |
|
| 133 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
| 134 | - return false; |
|
| 135 | - } |
|
| 136 | - |
|
| 137 | - // If source is not a directory stop processing |
|
| 138 | - if (!is_dir($src)) { |
|
| 139 | - return false; |
|
| 140 | - } |
|
| 141 | - |
|
| 142 | - $success = true; |
|
| 143 | - |
|
| 144 | - // Open the source directory to read in files |
|
| 145 | - $iterator = new DirectoryIterator($src); |
|
| 146 | - foreach ($iterator as $fObj) { |
|
| 147 | - if ($fObj->isFile()) { |
|
| 148 | - $filename = $fObj->getPathname(); |
|
| 149 | - $fObj = null; // clear this iterator object to close the file |
|
| 150 | - if (!unlink($filename)) { |
|
| 151 | - return false; // couldn't delete the file |
|
| 152 | - } |
|
| 153 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
| 154 | - // Try recursively on directory |
|
| 155 | - self::rrmdir($fObj->getPathname()); |
|
| 156 | - } |
|
| 157 | - } |
|
| 158 | - $iterator = null; // clear iterator Obj to close file/directory |
|
| 159 | - return rmdir($src); // remove the directory & return results |
|
| 160 | - } |
|
| 161 | - |
|
| 162 | - /** |
|
| 163 | - * Recursively move files from one directory to another |
|
| 164 | - * |
|
| 165 | - * @param string $src - Source of files being moved |
|
| 166 | - * @param string $dest - Destination of files being moved |
|
| 167 | - * |
|
| 168 | - * @return bool true on success |
|
| 169 | - */ |
|
| 170 | - public static function rmove($src, $dest) |
|
| 171 | - { |
|
| 172 | - // Only continue if user is a 'global' Admin |
|
| 173 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
| 174 | - return false; |
|
| 175 | - } |
|
| 176 | - |
|
| 177 | - // If source is not a directory stop processing |
|
| 178 | - if (!is_dir($src)) { |
|
| 179 | - return false; |
|
| 180 | - } |
|
| 181 | - |
|
| 182 | - // If the destination directory does not exist and could not be created stop processing |
|
| 183 | - if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
| 184 | - return false; |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - // Open the source directory to read in files |
|
| 188 | - $iterator = new DirectoryIterator($src); |
|
| 189 | - foreach ($iterator as $fObj) { |
|
| 190 | - if ($fObj->isFile()) { |
|
| 191 | - rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
| 192 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
| 193 | - // Try recursively on directory |
|
| 194 | - self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
| 195 | - // rmdir($fObj->getPath()); // now delete the directory |
|
| 196 | - } |
|
| 197 | - } |
|
| 198 | - $iterator = null; // clear iterator Obj to close file/directory |
|
| 199 | - return rmdir($src); // remove the directory & return results |
|
| 200 | - } |
|
| 201 | - |
|
| 202 | - /** |
|
| 203 | - * Recursively copy directories and files from one directory to another |
|
| 204 | - * |
|
| 205 | - * @param string $src - Source of files being moved |
|
| 206 | - * @param string $dest - Destination of files being moved |
|
| 207 | - * |
|
| 208 | - * @uses \Xmf\Module\Helper::getHelper() |
|
| 209 | - * @uses \Xmf\Module\Helper::isUserAdmin() |
|
| 210 | - * |
|
| 211 | - * @return bool true on success |
|
| 212 | - */ |
|
| 213 | - public static function rcopy($src, $dest) |
|
| 214 | - { |
|
| 215 | - // Only continue if user is a 'global' Admin |
|
| 216 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
| 217 | - return false; |
|
| 218 | - } |
|
| 219 | - |
|
| 220 | - // If source is not a directory stop processing |
|
| 221 | - if (!is_dir($src)) { |
|
| 222 | - return false; |
|
| 223 | - } |
|
| 224 | - |
|
| 225 | - // If the destination directory does not exist and could not be created stop processing |
|
| 226 | - if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
| 227 | - return false; |
|
| 228 | - } |
|
| 229 | - |
|
| 230 | - // Open the source directory to read in files |
|
| 231 | - $iterator = new DirectoryIterator($src); |
|
| 232 | - foreach ($iterator as $fObj) { |
|
| 233 | - if ($fObj->isFile()) { |
|
| 234 | - copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
| 235 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
| 236 | - self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
| 237 | - } |
|
| 238 | - } |
|
| 239 | - return true; |
|
| 240 | - } |
|
| 19 | + /** |
|
| 20 | + * Function responsible for checking if a directory exists, we can also write in and create an index.html file |
|
| 21 | + * |
|
| 22 | + * @param string $folder The full path of the directory to check |
|
| 23 | + * |
|
| 24 | + * @return void |
|
| 25 | + */ |
|
| 26 | + public static function createFolder($folder) |
|
| 27 | + { |
|
| 28 | + try { |
|
| 29 | + if (!file_exists($folder)) { |
|
| 30 | + if (!mkdir($folder) && !is_dir($folder)) { |
|
| 31 | + throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
|
| 32 | + } |
|
| 33 | + |
|
| 34 | + file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>'); |
|
| 35 | + } |
|
| 36 | + } catch (Exception $e) { |
|
| 37 | + echo 'Caught exception: ', $e->getMessage(), "\n", '<br>'; |
|
| 38 | + } |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + /** |
|
| 42 | + * @param $file |
|
| 43 | + * @param $folder |
|
| 44 | + * @return bool |
|
| 45 | + */ |
|
| 46 | + public static function copyFile($file, $folder) |
|
| 47 | + { |
|
| 48 | + return copy($file, $folder); |
|
| 49 | + } |
|
| 50 | + |
|
| 51 | + /** |
|
| 52 | + * @param $src |
|
| 53 | + * @param $dst |
|
| 54 | + */ |
|
| 55 | + public static function recurseCopy($src, $dst) |
|
| 56 | + { |
|
| 57 | + $dir = opendir($src); |
|
| 58 | + @mkdir($dst); |
|
| 59 | + while (false !== ($file = readdir($dir))) { |
|
| 60 | + if (('.' !== $file) && ('..' !== $file)) { |
|
| 61 | + if (is_dir($src . '/' . $file)) { |
|
| 62 | + self::recurseCopy($src . '/' . $file, $dst . '/' . $file); |
|
| 63 | + } else { |
|
| 64 | + copy($src . '/' . $file, $dst . '/' . $file); |
|
| 65 | + } |
|
| 66 | + } |
|
| 67 | + } |
|
| 68 | + closedir($dir); |
|
| 69 | + } |
|
| 70 | + |
|
| 71 | + /** |
|
| 72 | + * |
|
| 73 | + * Remove files and (sub)directories |
|
| 74 | + * |
|
| 75 | + * @param string $src source directory to delete |
|
| 76 | + * |
|
| 77 | + * @uses \Xmf\Module\Helper::getHelper() |
|
| 78 | + * @uses \Xmf\Module\Helper::isUserAdmin() |
|
| 79 | + * |
|
| 80 | + * @return bool true on success |
|
| 81 | + */ |
|
| 82 | + public static function deleteDirectory($src) |
|
| 83 | + { |
|
| 84 | + // Only continue if user is a 'global' Admin |
|
| 85 | + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
| 86 | + return false; |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + $success = true; |
|
| 90 | + // remove old files |
|
| 91 | + $dirInfo = new SplFileInfo($src); |
|
| 92 | + // validate is a directory |
|
| 93 | + if ($dirInfo->isDir()) { |
|
| 94 | + $fileList = array_diff(scandir($src, SCANDIR_SORT_NONE), ['..', '.']); |
|
| 95 | + foreach ($fileList as $k => $v) { |
|
| 96 | + $fileInfo = new SplFileInfo("{$src}/{$v}"); |
|
| 97 | + if ($fileInfo->isDir()) { |
|
| 98 | + // recursively handle subdirectories |
|
| 99 | + if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
| 100 | + break; |
|
| 101 | + } |
|
| 102 | + } else { |
|
| 103 | + // delete the file |
|
| 104 | + if (!($success = unlink($fileInfo->getRealPath()))) { |
|
| 105 | + break; |
|
| 106 | + } |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + // now delete this (sub)directory if all the files are gone |
|
| 110 | + if ($success) { |
|
| 111 | + $success = rmdir($dirInfo->getRealPath()); |
|
| 112 | + } |
|
| 113 | + } else { |
|
| 114 | + // input is not a valid directory |
|
| 115 | + $success = false; |
|
| 116 | + } |
|
| 117 | + return $success; |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + /** |
|
| 121 | + * |
|
| 122 | + * Recursively remove directory |
|
| 123 | + * |
|
| 124 | + * @todo currently won't remove directories with hidden files, should it? |
|
| 125 | + * |
|
| 126 | + * @param string $src directory to remove (delete) |
|
| 127 | + * |
|
| 128 | + * @return bool true on success |
|
| 129 | + */ |
|
| 130 | + public static function rrmdir($src) |
|
| 131 | + { |
|
| 132 | + // Only continue if user is a 'global' Admin |
|
| 133 | + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
| 134 | + return false; |
|
| 135 | + } |
|
| 136 | + |
|
| 137 | + // If source is not a directory stop processing |
|
| 138 | + if (!is_dir($src)) { |
|
| 139 | + return false; |
|
| 140 | + } |
|
| 141 | + |
|
| 142 | + $success = true; |
|
| 143 | + |
|
| 144 | + // Open the source directory to read in files |
|
| 145 | + $iterator = new DirectoryIterator($src); |
|
| 146 | + foreach ($iterator as $fObj) { |
|
| 147 | + if ($fObj->isFile()) { |
|
| 148 | + $filename = $fObj->getPathname(); |
|
| 149 | + $fObj = null; // clear this iterator object to close the file |
|
| 150 | + if (!unlink($filename)) { |
|
| 151 | + return false; // couldn't delete the file |
|
| 152 | + } |
|
| 153 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
| 154 | + // Try recursively on directory |
|
| 155 | + self::rrmdir($fObj->getPathname()); |
|
| 156 | + } |
|
| 157 | + } |
|
| 158 | + $iterator = null; // clear iterator Obj to close file/directory |
|
| 159 | + return rmdir($src); // remove the directory & return results |
|
| 160 | + } |
|
| 161 | + |
|
| 162 | + /** |
|
| 163 | + * Recursively move files from one directory to another |
|
| 164 | + * |
|
| 165 | + * @param string $src - Source of files being moved |
|
| 166 | + * @param string $dest - Destination of files being moved |
|
| 167 | + * |
|
| 168 | + * @return bool true on success |
|
| 169 | + */ |
|
| 170 | + public static function rmove($src, $dest) |
|
| 171 | + { |
|
| 172 | + // Only continue if user is a 'global' Admin |
|
| 173 | + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
| 174 | + return false; |
|
| 175 | + } |
|
| 176 | + |
|
| 177 | + // If source is not a directory stop processing |
|
| 178 | + if (!is_dir($src)) { |
|
| 179 | + return false; |
|
| 180 | + } |
|
| 181 | + |
|
| 182 | + // If the destination directory does not exist and could not be created stop processing |
|
| 183 | + if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
| 184 | + return false; |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + // Open the source directory to read in files |
|
| 188 | + $iterator = new DirectoryIterator($src); |
|
| 189 | + foreach ($iterator as $fObj) { |
|
| 190 | + if ($fObj->isFile()) { |
|
| 191 | + rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
| 192 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
| 193 | + // Try recursively on directory |
|
| 194 | + self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
| 195 | + // rmdir($fObj->getPath()); // now delete the directory |
|
| 196 | + } |
|
| 197 | + } |
|
| 198 | + $iterator = null; // clear iterator Obj to close file/directory |
|
| 199 | + return rmdir($src); // remove the directory & return results |
|
| 200 | + } |
|
| 201 | + |
|
| 202 | + /** |
|
| 203 | + * Recursively copy directories and files from one directory to another |
|
| 204 | + * |
|
| 205 | + * @param string $src - Source of files being moved |
|
| 206 | + * @param string $dest - Destination of files being moved |
|
| 207 | + * |
|
| 208 | + * @uses \Xmf\Module\Helper::getHelper() |
|
| 209 | + * @uses \Xmf\Module\Helper::isUserAdmin() |
|
| 210 | + * |
|
| 211 | + * @return bool true on success |
|
| 212 | + */ |
|
| 213 | + public static function rcopy($src, $dest) |
|
| 214 | + { |
|
| 215 | + // Only continue if user is a 'global' Admin |
|
| 216 | + if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
| 217 | + return false; |
|
| 218 | + } |
|
| 219 | + |
|
| 220 | + // If source is not a directory stop processing |
|
| 221 | + if (!is_dir($src)) { |
|
| 222 | + return false; |
|
| 223 | + } |
|
| 224 | + |
|
| 225 | + // If the destination directory does not exist and could not be created stop processing |
|
| 226 | + if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
| 227 | + return false; |
|
| 228 | + } |
|
| 229 | + |
|
| 230 | + // Open the source directory to read in files |
|
| 231 | + $iterator = new DirectoryIterator($src); |
|
| 232 | + foreach ($iterator as $fObj) { |
|
| 233 | + if ($fObj->isFile()) { |
|
| 234 | + copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
| 235 | + } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
| 236 | + self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
|
| 237 | + } |
|
| 238 | + } |
|
| 239 | + return true; |
|
| 240 | + } |
|
| 241 | 241 | } |
@@ -26,8 +26,8 @@ discard block |
||
| 26 | 26 | public static function createFolder($folder) |
| 27 | 27 | { |
| 28 | 28 | try { |
| 29 | - if (!file_exists($folder)) { |
|
| 30 | - if (!mkdir($folder) && !is_dir($folder)) { |
|
| 29 | + if ( ! file_exists($folder)) { |
|
| 30 | + if ( ! mkdir($folder) && ! is_dir($folder)) { |
|
| 31 | 31 | throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder)); |
| 32 | 32 | } |
| 33 | 33 | |
@@ -82,7 +82,7 @@ discard block |
||
| 82 | 82 | public static function deleteDirectory($src) |
| 83 | 83 | { |
| 84 | 84 | // Only continue if user is a 'global' Admin |
| 85 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
| 85 | + if ( ! ($GLOBALS['xoopsUser'] instanceof XoopsUser) || ! $GLOBALS['xoopsUser']->isAdmin()) { |
|
| 86 | 86 | return false; |
| 87 | 87 | } |
| 88 | 88 | |
@@ -96,12 +96,12 @@ discard block |
||
| 96 | 96 | $fileInfo = new SplFileInfo("{$src}/{$v}"); |
| 97 | 97 | if ($fileInfo->isDir()) { |
| 98 | 98 | // recursively handle subdirectories |
| 99 | - if (!$success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
| 99 | + if ( ! $success = self::deleteDirectory($fileInfo->getRealPath())) { |
|
| 100 | 100 | break; |
| 101 | 101 | } |
| 102 | 102 | } else { |
| 103 | 103 | // delete the file |
| 104 | - if (!($success = unlink($fileInfo->getRealPath()))) { |
|
| 104 | + if ( ! ($success = unlink($fileInfo->getRealPath()))) { |
|
| 105 | 105 | break; |
| 106 | 106 | } |
| 107 | 107 | } |
@@ -130,12 +130,12 @@ discard block |
||
| 130 | 130 | public static function rrmdir($src) |
| 131 | 131 | { |
| 132 | 132 | // Only continue if user is a 'global' Admin |
| 133 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
| 133 | + if ( ! ($GLOBALS['xoopsUser'] instanceof XoopsUser) || ! $GLOBALS['xoopsUser']->isAdmin()) { |
|
| 134 | 134 | return false; |
| 135 | 135 | } |
| 136 | 136 | |
| 137 | 137 | // If source is not a directory stop processing |
| 138 | - if (!is_dir($src)) { |
|
| 138 | + if ( ! is_dir($src)) { |
|
| 139 | 139 | return false; |
| 140 | 140 | } |
| 141 | 141 | |
@@ -147,15 +147,15 @@ discard block |
||
| 147 | 147 | if ($fObj->isFile()) { |
| 148 | 148 | $filename = $fObj->getPathname(); |
| 149 | 149 | $fObj = null; // clear this iterator object to close the file |
| 150 | - if (!unlink($filename)) { |
|
| 150 | + if ( ! unlink($filename)) { |
|
| 151 | 151 | return false; // couldn't delete the file |
| 152 | 152 | } |
| 153 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
| 153 | + } elseif ( ! $fObj->isDot() && $fObj->isDir()) { |
|
| 154 | 154 | // Try recursively on directory |
| 155 | 155 | self::rrmdir($fObj->getPathname()); |
| 156 | 156 | } |
| 157 | 157 | } |
| 158 | - $iterator = null; // clear iterator Obj to close file/directory |
|
| 158 | + $iterator = null; // clear iterator Obj to close file/directory |
|
| 159 | 159 | return rmdir($src); // remove the directory & return results |
| 160 | 160 | } |
| 161 | 161 | |
@@ -170,17 +170,17 @@ discard block |
||
| 170 | 170 | public static function rmove($src, $dest) |
| 171 | 171 | { |
| 172 | 172 | // Only continue if user is a 'global' Admin |
| 173 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
| 173 | + if ( ! ($GLOBALS['xoopsUser'] instanceof XoopsUser) || ! $GLOBALS['xoopsUser']->isAdmin()) { |
|
| 174 | 174 | return false; |
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | // If source is not a directory stop processing |
| 178 | - if (!is_dir($src)) { |
|
| 178 | + if ( ! is_dir($src)) { |
|
| 179 | 179 | return false; |
| 180 | 180 | } |
| 181 | 181 | |
| 182 | 182 | // If the destination directory does not exist and could not be created stop processing |
| 183 | - if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
| 183 | + if ( ! is_dir($dest) && ! mkdir($dest, 0755)) { |
|
| 184 | 184 | return false; |
| 185 | 185 | } |
| 186 | 186 | |
@@ -189,13 +189,13 @@ discard block |
||
| 189 | 189 | foreach ($iterator as $fObj) { |
| 190 | 190 | if ($fObj->isFile()) { |
| 191 | 191 | rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
| 192 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
| 192 | + } elseif ( ! $fObj->isDot() && $fObj->isDir()) { |
|
| 193 | 193 | // Try recursively on directory |
| 194 | 194 | self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
| 195 | 195 | // rmdir($fObj->getPath()); // now delete the directory |
| 196 | 196 | } |
| 197 | 197 | } |
| 198 | - $iterator = null; // clear iterator Obj to close file/directory |
|
| 198 | + $iterator = null; // clear iterator Obj to close file/directory |
|
| 199 | 199 | return rmdir($src); // remove the directory & return results |
| 200 | 200 | } |
| 201 | 201 | |
@@ -213,17 +213,17 @@ discard block |
||
| 213 | 213 | public static function rcopy($src, $dest) |
| 214 | 214 | { |
| 215 | 215 | // Only continue if user is a 'global' Admin |
| 216 | - if (!($GLOBALS['xoopsUser'] instanceof XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) { |
|
| 216 | + if ( ! ($GLOBALS['xoopsUser'] instanceof XoopsUser) || ! $GLOBALS['xoopsUser']->isAdmin()) { |
|
| 217 | 217 | return false; |
| 218 | 218 | } |
| 219 | 219 | |
| 220 | 220 | // If source is not a directory stop processing |
| 221 | - if (!is_dir($src)) { |
|
| 221 | + if ( ! is_dir($src)) { |
|
| 222 | 222 | return false; |
| 223 | 223 | } |
| 224 | 224 | |
| 225 | 225 | // If the destination directory does not exist and could not be created stop processing |
| 226 | - if (!is_dir($dest) && !mkdir($dest, 0755)) { |
|
| 226 | + if ( ! is_dir($dest) && ! mkdir($dest, 0755)) { |
|
| 227 | 227 | return false; |
| 228 | 228 | } |
| 229 | 229 | |
@@ -232,7 +232,7 @@ discard block |
||
| 232 | 232 | foreach ($iterator as $fObj) { |
| 233 | 233 | if ($fObj->isFile()) { |
| 234 | 234 | copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
| 235 | - } elseif (!$fObj->isDot() && $fObj->isDir()) { |
|
| 235 | + } elseif ( ! $fObj->isDot() && $fObj->isDir()) { |
|
| 236 | 236 | self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename()); |
| 237 | 237 | } |
| 238 | 238 | } |
@@ -96,7 +96,7 @@ discard block |
||
| 96 | 96 | $form->addElement(new XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'metadescription', 50, 255, $this->getVar('metadescription')), false); |
| 97 | 97 | |
| 98 | 98 | // Если мы редактируем категорию |
| 99 | - if (!$this->isNew()) { |
|
| 99 | + if ( ! $this->isNew()) { |
|
| 100 | 100 | $form->addElement(new XoopsFormHidden('instrid', $this->getVar('instrid'))); |
| 101 | 101 | } |
| 102 | 102 | // |
@@ -118,9 +118,9 @@ discard block |
||
| 118 | 118 | public function updateDateupdated($instrid = 0, $time = null) |
| 119 | 119 | { |
| 120 | 120 | // Если не передали время |
| 121 | - $time = null === $time ? time() : (int)$time; |
|
| 121 | + $time = null === $time ? time() : (int) $time; |
|
| 122 | 122 | // |
| 123 | - $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `instrid` = %u', $this->table, $time, (int)$instrid); |
|
| 123 | + $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `instrid` = %u', $this->table, $time, (int) $instrid); |
|
| 124 | 124 | // |
| 125 | 125 | return $this->db->query($sql); |
| 126 | 126 | } |
@@ -8,153 +8,153 @@ |
||
| 8 | 8 | |
| 9 | 9 | class InstructionInstruction extends XoopsObject |
| 10 | 10 | { |
| 11 | - // constructor |
|
| 12 | - public function __construct() |
|
| 13 | - { |
|
| 14 | - // $this->XoopsObject(); |
|
| 15 | - $this->initVar('instrid', XOBJ_DTYPE_INT, null, false, 11); |
|
| 16 | - $this->initVar('cid', XOBJ_DTYPE_INT, 0, false, 5); |
|
| 17 | - $this->initVar('uid', XOBJ_DTYPE_INT, 0, false, 11); |
|
| 18 | - $this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false); |
|
| 19 | - $this->initVar('status', XOBJ_DTYPE_INT, 0, false, 1); |
|
| 20 | - $this->initVar('pages', XOBJ_DTYPE_INT, 0, false, 11); |
|
| 21 | - $this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false); |
|
| 22 | - $this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10); |
|
| 23 | - $this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10); |
|
| 24 | - $this->initVar('metakeywords', XOBJ_DTYPE_TXTBOX, '', false); |
|
| 25 | - $this->initVar('metadescription', XOBJ_DTYPE_TXTBOX, '', false); |
|
| 26 | - |
|
| 27 | - // Нет в таблице |
|
| 28 | - $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); |
|
| 29 | - $this->initVar('dobr', XOBJ_DTYPE_INT, 0, false); |
|
| 30 | - } |
|
| 31 | - |
|
| 32 | - public function InstructionInstruction() |
|
| 33 | - { |
|
| 34 | - $this->__construct(); |
|
| 35 | - } |
|
| 36 | - |
|
| 37 | - public function get_new_enreg() |
|
| 38 | - { |
|
| 39 | - $new_enreg = $GLOBALS['xoopsDB']->getInsertId(); |
|
| 40 | - return $new_enreg; |
|
| 41 | - } |
|
| 42 | - |
|
| 43 | - // Получаем форму |
|
| 44 | - public function getForm($action = false) |
|
| 45 | - { |
|
| 46 | - global $xoopsDB, $xoopsModule, $xoopsModuleConfig; |
|
| 47 | - // Если нет $action |
|
| 48 | - if (false === $action) { |
|
| 49 | - $action = xoops_getenv('REQUEST_URI'); |
|
| 50 | - } |
|
| 51 | - // Подключаем формы |
|
| 52 | - include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
| 53 | - |
|
| 54 | - // Название формы |
|
| 55 | - $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDINSTR) : sprintf(_AM_INSTRUCTION_FORMEDITINSTR); |
|
| 56 | - |
|
| 57 | - // Форма |
|
| 58 | - $form = new XoopsThemeForm($title, 'forminstr', $action, 'post', true); |
|
| 59 | - //$form->setExtra('enctype="multipart/form-data"'); |
|
| 60 | - // Название инструкции |
|
| 61 | - $form->addElement(new XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true); |
|
| 62 | - // Категория |
|
| 63 | - $instructioncatHandler = xoops_getModuleHandler('category', 'instruction'); |
|
| 64 | - $criteria = new CriteriaCompo(); |
|
| 65 | - $criteria->setSort('weight ASC, title'); |
|
| 66 | - $criteria->setOrder('ASC'); |
|
| 67 | - $instructioncat_arr = $instructioncatHandler->getall($criteria); |
|
| 68 | - unset($criteria); |
|
| 69 | - // Подключаем трей |
|
| 70 | - include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
| 71 | - $mytree = new XoopsObjectTree($instructioncat_arr, 'cid', 'pid'); |
|
| 72 | - |
|
| 73 | - // $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_CATC, $mytree->makeSelBox('cid', 'title', '--', $this->getVar('cid'), true))); |
|
| 74 | - $moduleDirName = basename(__DIR__); |
|
| 75 | - if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) { |
|
| 76 | - } else { |
|
| 77 | - $moduleHelper = Xmf\Module\Helper::getHelper('system'); |
|
| 78 | - } |
|
| 79 | - $module = $moduleHelper->getModule(); |
|
| 80 | - |
|
| 81 | - if (InstructionUtility::checkVerXoops($module, '2.5.9')) { |
|
| 82 | - $mytree_select = $mytree->makeSelectElement('cid', 'title', '--', $this->getVar('cid'), true, 0, '', _AM_INSTRUCTION_CATC); |
|
| 83 | - $form->addElement($mytree_select); |
|
| 84 | - } else { |
|
| 85 | - $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_CATC, $mytree->makeSelBox('cid', 'title', '--', $this->getVar('cid'), true))); |
|
| 86 | - } |
|
| 87 | - |
|
| 88 | - // Описание |
|
| 89 | - $form->addElement(InstructionUtility::getWysiwygForm(_AM_INSTRUCTION_DESCRIPTIONC, 'description', $this->getVar('description', 'e')), true); |
|
| 90 | - // Статус |
|
| 91 | - $form->addElement(new XoopsFormRadioYN(_AM_INSTRUCTION_ACTIVEC, 'status', $this->getVar('status')), false); |
|
| 92 | - |
|
| 93 | - // Теги |
|
| 94 | - if (is_dir('../../tag') || is_dir('../tag')) { |
|
| 95 | - $dir_tag_ok = true; |
|
| 96 | - } else { |
|
| 97 | - $dir_tag_ok = false; |
|
| 98 | - } |
|
| 99 | - // Если влючена поддержка тегов и есть модуль tag |
|
| 100 | - if (xoops_getModuleOption('usetag', 'instruction') && $dir_tag_ok) { |
|
| 101 | - $itemIdForTag = $this->isNew() ? 0 : $this->getVar('instrid'); |
|
| 102 | - // Подключаем форму тегов |
|
| 103 | - include_once $GLOBALS['xoops']->path('modules/tag/include/formtag.php'); |
|
| 104 | - // Добавляем элемент в форму |
|
| 105 | - $form->addElement(new XoopsFormTag('tag', 60, 255, $itemIdForTag, 0)); |
|
| 106 | - } |
|
| 107 | - |
|
| 108 | - // Мета-теги ключевых слов |
|
| 109 | - $form->addElement(new XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'metakeywords', 50, 255, $this->getVar('metakeywords')), false); |
|
| 110 | - // Мета-теги описания |
|
| 111 | - $form->addElement(new XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'metadescription', 50, 255, $this->getVar('metadescription')), false); |
|
| 112 | - |
|
| 113 | - // Если мы редактируем категорию |
|
| 114 | - if (!$this->isNew()) { |
|
| 115 | - $form->addElement(new XoopsFormHidden('instrid', $this->getVar('instrid'))); |
|
| 116 | - } |
|
| 117 | - // |
|
| 118 | - $form->addElement(new XoopsFormHidden('op', 'saveinstr')); |
|
| 119 | - // Кнопка |
|
| 120 | - $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
| 121 | - return $form; |
|
| 122 | - } |
|
| 11 | + // constructor |
|
| 12 | + public function __construct() |
|
| 13 | + { |
|
| 14 | + // $this->XoopsObject(); |
|
| 15 | + $this->initVar('instrid', XOBJ_DTYPE_INT, null, false, 11); |
|
| 16 | + $this->initVar('cid', XOBJ_DTYPE_INT, 0, false, 5); |
|
| 17 | + $this->initVar('uid', XOBJ_DTYPE_INT, 0, false, 11); |
|
| 18 | + $this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false); |
|
| 19 | + $this->initVar('status', XOBJ_DTYPE_INT, 0, false, 1); |
|
| 20 | + $this->initVar('pages', XOBJ_DTYPE_INT, 0, false, 11); |
|
| 21 | + $this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false); |
|
| 22 | + $this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10); |
|
| 23 | + $this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10); |
|
| 24 | + $this->initVar('metakeywords', XOBJ_DTYPE_TXTBOX, '', false); |
|
| 25 | + $this->initVar('metadescription', XOBJ_DTYPE_TXTBOX, '', false); |
|
| 26 | + |
|
| 27 | + // Нет в таблице |
|
| 28 | + $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); |
|
| 29 | + $this->initVar('dobr', XOBJ_DTYPE_INT, 0, false); |
|
| 30 | + } |
|
| 31 | + |
|
| 32 | + public function InstructionInstruction() |
|
| 33 | + { |
|
| 34 | + $this->__construct(); |
|
| 35 | + } |
|
| 36 | + |
|
| 37 | + public function get_new_enreg() |
|
| 38 | + { |
|
| 39 | + $new_enreg = $GLOBALS['xoopsDB']->getInsertId(); |
|
| 40 | + return $new_enreg; |
|
| 41 | + } |
|
| 42 | + |
|
| 43 | + // Получаем форму |
|
| 44 | + public function getForm($action = false) |
|
| 45 | + { |
|
| 46 | + global $xoopsDB, $xoopsModule, $xoopsModuleConfig; |
|
| 47 | + // Если нет $action |
|
| 48 | + if (false === $action) { |
|
| 49 | + $action = xoops_getenv('REQUEST_URI'); |
|
| 50 | + } |
|
| 51 | + // Подключаем формы |
|
| 52 | + include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
| 53 | + |
|
| 54 | + // Название формы |
|
| 55 | + $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDINSTR) : sprintf(_AM_INSTRUCTION_FORMEDITINSTR); |
|
| 56 | + |
|
| 57 | + // Форма |
|
| 58 | + $form = new XoopsThemeForm($title, 'forminstr', $action, 'post', true); |
|
| 59 | + //$form->setExtra('enctype="multipart/form-data"'); |
|
| 60 | + // Название инструкции |
|
| 61 | + $form->addElement(new XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true); |
|
| 62 | + // Категория |
|
| 63 | + $instructioncatHandler = xoops_getModuleHandler('category', 'instruction'); |
|
| 64 | + $criteria = new CriteriaCompo(); |
|
| 65 | + $criteria->setSort('weight ASC, title'); |
|
| 66 | + $criteria->setOrder('ASC'); |
|
| 67 | + $instructioncat_arr = $instructioncatHandler->getall($criteria); |
|
| 68 | + unset($criteria); |
|
| 69 | + // Подключаем трей |
|
| 70 | + include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
| 71 | + $mytree = new XoopsObjectTree($instructioncat_arr, 'cid', 'pid'); |
|
| 72 | + |
|
| 73 | + // $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_CATC, $mytree->makeSelBox('cid', 'title', '--', $this->getVar('cid'), true))); |
|
| 74 | + $moduleDirName = basename(__DIR__); |
|
| 75 | + if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) { |
|
| 76 | + } else { |
|
| 77 | + $moduleHelper = Xmf\Module\Helper::getHelper('system'); |
|
| 78 | + } |
|
| 79 | + $module = $moduleHelper->getModule(); |
|
| 80 | + |
|
| 81 | + if (InstructionUtility::checkVerXoops($module, '2.5.9')) { |
|
| 82 | + $mytree_select = $mytree->makeSelectElement('cid', 'title', '--', $this->getVar('cid'), true, 0, '', _AM_INSTRUCTION_CATC); |
|
| 83 | + $form->addElement($mytree_select); |
|
| 84 | + } else { |
|
| 85 | + $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_CATC, $mytree->makeSelBox('cid', 'title', '--', $this->getVar('cid'), true))); |
|
| 86 | + } |
|
| 87 | + |
|
| 88 | + // Описание |
|
| 89 | + $form->addElement(InstructionUtility::getWysiwygForm(_AM_INSTRUCTION_DESCRIPTIONC, 'description', $this->getVar('description', 'e')), true); |
|
| 90 | + // Статус |
|
| 91 | + $form->addElement(new XoopsFormRadioYN(_AM_INSTRUCTION_ACTIVEC, 'status', $this->getVar('status')), false); |
|
| 92 | + |
|
| 93 | + // Теги |
|
| 94 | + if (is_dir('../../tag') || is_dir('../tag')) { |
|
| 95 | + $dir_tag_ok = true; |
|
| 96 | + } else { |
|
| 97 | + $dir_tag_ok = false; |
|
| 98 | + } |
|
| 99 | + // Если влючена поддержка тегов и есть модуль tag |
|
| 100 | + if (xoops_getModuleOption('usetag', 'instruction') && $dir_tag_ok) { |
|
| 101 | + $itemIdForTag = $this->isNew() ? 0 : $this->getVar('instrid'); |
|
| 102 | + // Подключаем форму тегов |
|
| 103 | + include_once $GLOBALS['xoops']->path('modules/tag/include/formtag.php'); |
|
| 104 | + // Добавляем элемент в форму |
|
| 105 | + $form->addElement(new XoopsFormTag('tag', 60, 255, $itemIdForTag, 0)); |
|
| 106 | + } |
|
| 107 | + |
|
| 108 | + // Мета-теги ключевых слов |
|
| 109 | + $form->addElement(new XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'metakeywords', 50, 255, $this->getVar('metakeywords')), false); |
|
| 110 | + // Мета-теги описания |
|
| 111 | + $form->addElement(new XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'metadescription', 50, 255, $this->getVar('metadescription')), false); |
|
| 112 | + |
|
| 113 | + // Если мы редактируем категорию |
|
| 114 | + if (!$this->isNew()) { |
|
| 115 | + $form->addElement(new XoopsFormHidden('instrid', $this->getVar('instrid'))); |
|
| 116 | + } |
|
| 117 | + // |
|
| 118 | + $form->addElement(new XoopsFormHidden('op', 'saveinstr')); |
|
| 119 | + // Кнопка |
|
| 120 | + $form->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
| 121 | + return $form; |
|
| 122 | + } |
|
| 123 | 123 | } |
| 124 | 124 | |
| 125 | 125 | class InstructionInstructionHandler extends XoopsPersistableObjectHandler |
| 126 | 126 | { |
| 127 | - public function __construct($db) |
|
| 128 | - { |
|
| 129 | - parent::__construct($db, 'instruction_instr', 'InstructionInstruction', 'instrid', 'title'); |
|
| 130 | - } |
|
| 131 | - |
|
| 132 | - // Обновление даты обновления инструкций |
|
| 133 | - public function updateDateupdated($instrid = 0, $time = null) |
|
| 134 | - { |
|
| 135 | - // Если не передали время |
|
| 136 | - $time = null === $time ? time() : (int)$time; |
|
| 137 | - // |
|
| 138 | - $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `instrid` = %u', $this->table, $time, (int)$instrid); |
|
| 139 | - // |
|
| 140 | - return $this->db->query($sql); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - // Обновление числа страниц |
|
| 144 | - public function updatePages($instrid = 0) |
|
| 145 | - { |
|
| 146 | - $inspageHandler = xoops_getModuleHandler('page', 'instruction'); |
|
| 147 | - // Находим число активных страниц |
|
| 148 | - $criteria = new CriteriaCompo(); |
|
| 149 | - $criteria->add(new Criteria('instrid', $instrid, '=')); |
|
| 150 | - $criteria->add(new Criteria('status ', '0', '>')); |
|
| 151 | - // Число страниц |
|
| 152 | - $pages = $inspageHandler->getCount($criteria); |
|
| 153 | - unset($criteria); |
|
| 154 | - |
|
| 155 | - // Сохраняем это число |
|
| 156 | - $sql = sprintf('UPDATE `%s` SET `pages` = %u, `dateupdated` = %u WHERE `instrid` = %u', $this->table, $pages, time(), $instrid); |
|
| 157 | - // |
|
| 158 | - return $this->db->query($sql); |
|
| 159 | - } |
|
| 127 | + public function __construct($db) |
|
| 128 | + { |
|
| 129 | + parent::__construct($db, 'instruction_instr', 'InstructionInstruction', 'instrid', 'title'); |
|
| 130 | + } |
|
| 131 | + |
|
| 132 | + // Обновление даты обновления инструкций |
|
| 133 | + public function updateDateupdated($instrid = 0, $time = null) |
|
| 134 | + { |
|
| 135 | + // Если не передали время |
|
| 136 | + $time = null === $time ? time() : (int)$time; |
|
| 137 | + // |
|
| 138 | + $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `instrid` = %u', $this->table, $time, (int)$instrid); |
|
| 139 | + // |
|
| 140 | + return $this->db->query($sql); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + // Обновление числа страниц |
|
| 144 | + public function updatePages($instrid = 0) |
|
| 145 | + { |
|
| 146 | + $inspageHandler = xoops_getModuleHandler('page', 'instruction'); |
|
| 147 | + // Находим число активных страниц |
|
| 148 | + $criteria = new CriteriaCompo(); |
|
| 149 | + $criteria->add(new Criteria('instrid', $instrid, '=')); |
|
| 150 | + $criteria->add(new Criteria('status ', '0', '>')); |
|
| 151 | + // Число страниц |
|
| 152 | + $pages = $inspageHandler->getCount($criteria); |
|
| 153 | + unset($criteria); |
|
| 154 | + |
|
| 155 | + // Сохраняем это число |
|
| 156 | + $sql = sprintf('UPDATE `%s` SET `pages` = %u, `dateupdated` = %u WHERE `instrid` = %u', $this->table, $pages, time(), $instrid); |
|
| 157 | + // |
|
| 158 | + return $this->db->query($sql); |
|
| 159 | + } |
|
| 160 | 160 | } |
@@ -23,37 +23,37 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class Instruction extends \Xmf\Module\Helper |
| 25 | 25 | { |
| 26 | - public $debugArray = []; |
|
| 26 | + public $debugArray = []; |
|
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * @internal param $debug |
|
| 30 | - */ |
|
| 31 | - protected function __construct() |
|
| 32 | - { |
|
| 33 | - // $this->debug = $debug; |
|
| 34 | - $this->dirname = basename(dirname(__DIR__)); |
|
| 35 | - } |
|
| 28 | + /** |
|
| 29 | + * @internal param $debug |
|
| 30 | + */ |
|
| 31 | + protected function __construct() |
|
| 32 | + { |
|
| 33 | + // $this->debug = $debug; |
|
| 34 | + $this->dirname = basename(dirname(__DIR__)); |
|
| 35 | + } |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * @param bool $debug |
|
| 39 | - * |
|
| 40 | - * @return Newbb |
|
| 41 | - */ |
|
| 42 | - public static function getInstance($debug = false) |
|
| 43 | - { |
|
| 44 | - static $instance; |
|
| 45 | - if (null === $instance) { |
|
| 46 | - $instance = new static($debug); |
|
| 47 | - } |
|
| 37 | + /** |
|
| 38 | + * @param bool $debug |
|
| 39 | + * |
|
| 40 | + * @return Newbb |
|
| 41 | + */ |
|
| 42 | + public static function getInstance($debug = false) |
|
| 43 | + { |
|
| 44 | + static $instance; |
|
| 45 | + if (null === $instance) { |
|
| 46 | + $instance = new static($debug); |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | - return $instance; |
|
| 50 | - } |
|
| 49 | + return $instance; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @return string |
|
| 54 | - */ |
|
| 55 | - public function getDirname() |
|
| 56 | - { |
|
| 57 | - return $this->dirname; |
|
| 58 | - } |
|
| 52 | + /** |
|
| 53 | + * @return string |
|
| 54 | + */ |
|
| 55 | + public function getDirname() |
|
| 56 | + { |
|
| 57 | + return $this->dirname; |
|
| 58 | + } |
|
| 59 | 59 | } |
@@ -73,7 +73,7 @@ discard block |
||
| 73 | 73 | // Находим все страницы данной инструкции |
| 74 | 74 | $criteria->add(new Criteria('instrid', $instrid_page, '=')); |
| 75 | 75 | // Если мы редактируем, то убрать текущую страницу из списка выбора родительской |
| 76 | - if (!$this->isNew()) { |
|
| 76 | + if ( ! $this->isNew()) { |
|
| 77 | 77 | $criteria->add(new Criteria('pageid', $this->getVar('pageid'), '<>')); |
| 78 | 78 | } |
| 79 | 79 | $criteria->setSort('weight'); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | $form->addElement($option_tray); |
| 129 | 129 | |
| 130 | 130 | // Если мы редактируем страницу |
| 131 | - if (!$this->isNew()) { |
|
| 131 | + if ( ! $this->isNew()) { |
|
| 132 | 132 | $form->addElement(new XoopsFormHidden('pageid', $this->getVar('pageid'))); |
| 133 | 133 | } else { |
| 134 | 134 | $form->addElement(new XoopsFormHidden('pageid', 0)); |
@@ -8,222 +8,222 @@ |
||
| 8 | 8 | |
| 9 | 9 | class InstructionPage extends XoopsObject |
| 10 | 10 | { |
| 11 | - // constructor |
|
| 12 | - public function __construct() |
|
| 13 | - { |
|
| 14 | - // $this->XoopsObject(); |
|
| 15 | - $this->initVar('pageid', XOBJ_DTYPE_INT, null, false, 11); |
|
| 16 | - $this->initVar('pid', XOBJ_DTYPE_INT, 0, false, 11); |
|
| 17 | - $this->initVar('instrid', XOBJ_DTYPE_INT, 0, false, 11); |
|
| 18 | - $this->initVar('uid', XOBJ_DTYPE_INT, 0, false, 11); |
|
| 19 | - $this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false, 255); |
|
| 20 | - $this->initVar('status', XOBJ_DTYPE_INT, 1, false, 1); |
|
| 21 | - $this->initVar('type', XOBJ_DTYPE_INT, 1, false, 1); |
|
| 22 | - $this->initVar('hometext', XOBJ_DTYPE_TXTAREA, null, false); |
|
| 23 | - $this->initVar('footnote', XOBJ_DTYPE_TXTAREA, '', false); |
|
| 24 | - $this->initVar('weight', XOBJ_DTYPE_INT, 0, false, 11); |
|
| 25 | - $this->initVar('keywords', XOBJ_DTYPE_TXTBOX, '', false, 255); |
|
| 26 | - $this->initVar('description', XOBJ_DTYPE_TXTBOX, '', false, 255); |
|
| 27 | - $this->initVar('comments', XOBJ_DTYPE_INT, 0, false, 11); |
|
| 28 | - $this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10); |
|
| 29 | - $this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10); |
|
| 30 | - $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false, 1); |
|
| 31 | - $this->initVar('dosmiley', XOBJ_DTYPE_INT, 0, false, 1); |
|
| 32 | - $this->initVar('doxcode', XOBJ_DTYPE_INT, 1, false, 1); |
|
| 33 | - $this->initVar('dobr', XOBJ_DTYPE_INT, 0, false, 1); |
|
| 34 | - } |
|
| 35 | - |
|
| 36 | - public function InstructionPage() |
|
| 37 | - { |
|
| 38 | - $this->__construct(); |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - public function get_new_enreg() |
|
| 42 | - { |
|
| 43 | - $new_enreg = $GLOBALS['xoopsDB']->getInsertId(); |
|
| 44 | - return $new_enreg; |
|
| 45 | - } |
|
| 46 | - |
|
| 47 | - // Получаем форму |
|
| 48 | - public function getForm($action = false, $instrid = 0) |
|
| 49 | - { |
|
| 50 | - // Если нет $action |
|
| 51 | - if (false === $action) { |
|
| 52 | - $action = xoops_getenv('REQUEST_URI'); |
|
| 53 | - } |
|
| 54 | - |
|
| 55 | - // Подключаем формы |
|
| 56 | - include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
| 57 | - // Подключаем типы страниц |
|
| 58 | - $pagetypes = include $GLOBALS['xoops']->path('modules/instruction/include/pagetypes.inc.php'); |
|
| 59 | - |
|
| 60 | - // Название формы |
|
| 61 | - $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDPAGE) : sprintf(_AM_INSTRUCTION_FORMEDITPAGE); |
|
| 62 | - |
|
| 63 | - // Форма |
|
| 64 | - $form = new XoopsThemeForm($title, 'instr_form_page', $action, 'post', true); |
|
| 65 | - // Название |
|
| 66 | - $form->addElement(new XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true); |
|
| 67 | - |
|
| 68 | - // Родительская страница |
|
| 69 | - $inspageHandler = xoops_getModuleHandler('page', 'instruction'); |
|
| 70 | - $criteria = new CriteriaCompo(); |
|
| 71 | - // ID инструкции в которой данная страница |
|
| 72 | - $instrid_page = $this->isNew() ? $instrid : $this->getVar('instrid'); |
|
| 73 | - // Находим все страницы данной инструкции |
|
| 74 | - $criteria->add(new Criteria('instrid', $instrid_page, '=')); |
|
| 75 | - // Если мы редактируем, то убрать текущую страницу из списка выбора родительской |
|
| 76 | - if (!$this->isNew()) { |
|
| 77 | - $criteria->add(new Criteria('pageid', $this->getVar('pageid'), '<>')); |
|
| 78 | - } |
|
| 79 | - $criteria->setSort('weight'); |
|
| 80 | - $criteria->setOrder('ASC'); |
|
| 81 | - $inspage_arr = $inspageHandler->getall($criteria); |
|
| 82 | - unset($criteria); |
|
| 83 | - // Подключаем трей |
|
| 84 | - include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
| 85 | - $mytree = new XoopsObjectTree($inspage_arr, 'pageid', 'pid'); |
|
| 86 | - |
|
| 87 | - // $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_PPAGEC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
| 88 | - $moduleDirName = basename(__DIR__); |
|
| 89 | - if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) { |
|
| 90 | - } else { |
|
| 91 | - $moduleHelper = Xmf\Module\Helper::getHelper('system'); |
|
| 92 | - } |
|
| 93 | - $module = $moduleHelper->getModule(); |
|
| 94 | - |
|
| 95 | - if (InstructionUtility::checkVerXoops($module, '2.5.9')) { |
|
| 96 | - $mytree_select = $mytree->makeSelectElement('pid', 'title', '--', $this->getVar('pid'), true, 0, '', _AM_INSTRUCTION_PPAGEC); |
|
| 97 | - $form->addElement($mytree_select); |
|
| 98 | - } else { |
|
| 99 | - $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_PPAGEC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
| 100 | - } |
|
| 101 | - |
|
| 102 | - // Вес |
|
| 103 | - $form->addElement(new XoopsFormText(_AM_INSTRUCTION_WEIGHTC, 'weight', 5, 5, $this->getVar('weight')), true); |
|
| 104 | - // Основной текст |
|
| 105 | - $form->addElement(InstructionUtility::getWysiwygForm(_AM_INSTRUCTION_HOMETEXTC, 'hometext', $this->getVar('hometext', 'e')), true); |
|
| 106 | - // Сноска |
|
| 107 | - $form_footnote = new XoopsFormTextArea(_AM_INSTRUCTION_FOOTNOTEC, 'footnote', $this->getVar('footnote', 'e')); |
|
| 108 | - $form_footnote->setDescription(_AM_INSTRUCTION_FOOTNOTE_DSC); |
|
| 109 | - $form->addElement($form_footnote, false); |
|
| 110 | - unset($form_footnote); |
|
| 111 | - // Статус |
|
| 112 | - $form->addElement(new XoopsFormRadioYN(_AM_INSTRUCTION_ACTIVEC, 'status', $this->getVar('status')), false); |
|
| 113 | - // Тип страницы |
|
| 114 | - $form_type = new XoopsFormSelect(_AM_INSTR_PAGETYPEC, 'type', $this->getVar('type')); |
|
| 115 | - $form_type->setDescription(_AM_INSTR_PAGETYPEC_DESC); |
|
| 116 | - $form_type->addOptionArray($pagetypes); |
|
| 117 | - $form->addElement($form_type, false); |
|
| 118 | - // Мета-теги ключевых слов |
|
| 119 | - $form->addElement(new XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'keywords', 50, 255, $this->getVar('keywords')), false); |
|
| 120 | - // Мета-теги описания |
|
| 121 | - $form->addElement(new XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'description', 50, 255, $this->getVar('description')), false); |
|
| 122 | - |
|
| 123 | - // Настройки |
|
| 124 | - $option_tray = new XoopsFormElementTray(_OPTIONS, '<br>'); |
|
| 125 | - // HTML |
|
| 126 | - $html_checkbox = new XoopsFormCheckBox('', 'dohtml', $this->getVar('dohtml')); |
|
| 127 | - $html_checkbox->addOption(1, _AM_INSTR_DOHTML); |
|
| 128 | - $option_tray->addElement($html_checkbox); |
|
| 129 | - // Смайлы |
|
| 130 | - $smiley_checkbox = new XoopsFormCheckBox('', 'dosmiley', $this->getVar('dosmiley')); |
|
| 131 | - $smiley_checkbox->addOption(1, _AM_INSTR_DOSMILEY); |
|
| 132 | - $option_tray->addElement($smiley_checkbox); |
|
| 133 | - // ББ коды |
|
| 134 | - $xcode_checkbox = new XoopsFormCheckBox('', 'doxcode', $this->getVar('doxcode')); |
|
| 135 | - $xcode_checkbox->addOption(1, _AM_INSTR_DOXCODE); |
|
| 136 | - $option_tray->addElement($xcode_checkbox); |
|
| 137 | - // |
|
| 138 | - $br_checkbox = new XoopsFormCheckBox('', 'dobr', $this->getVar('dobr')); |
|
| 139 | - $br_checkbox->addOption(1, _AM_INSTR_DOAUTOWRAP); |
|
| 140 | - $option_tray->addElement($br_checkbox); |
|
| 141 | - // |
|
| 142 | - $form->addElement($option_tray); |
|
| 143 | - |
|
| 144 | - // Если мы редактируем страницу |
|
| 145 | - if (!$this->isNew()) { |
|
| 146 | - $form->addElement(new XoopsFormHidden('pageid', $this->getVar('pageid'))); |
|
| 147 | - } else { |
|
| 148 | - $form->addElement(new XoopsFormHidden('pageid', 0)); |
|
| 149 | - } |
|
| 150 | - // ID инструкции |
|
| 151 | - if ($instrid) { |
|
| 152 | - $form->addElement(new XoopsFormHidden('instrid', $instrid)); |
|
| 153 | - } else { |
|
| 154 | - $form->addElement(new XoopsFormHidden('instrid', 0)); |
|
| 155 | - } |
|
| 156 | - // |
|
| 157 | - $form->addElement(new XoopsFormHidden('op', 'savepage')); |
|
| 158 | - // Кнопка |
|
| 159 | - $button_tray = new XoopsFormElementTray('', ''); |
|
| 160 | - $button_tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
| 161 | - $save_btn = new XoopsFormButton('', 'cancel', _AM_INSTR_SAVEFORM); |
|
| 162 | - $save_btn->setExtra('onclick="instrSavePage();"'); |
|
| 163 | - $button_tray->addElement($save_btn); |
|
| 164 | - $form->addElement($button_tray); |
|
| 165 | - |
|
| 166 | - return $form; |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - // |
|
| 170 | - public function getInstrid() |
|
| 171 | - { |
|
| 172 | - // Возвращаем ID инструкции |
|
| 173 | - return $this->getVar('instrid'); |
|
| 174 | - } |
|
| 11 | + // constructor |
|
| 12 | + public function __construct() |
|
| 13 | + { |
|
| 14 | + // $this->XoopsObject(); |
|
| 15 | + $this->initVar('pageid', XOBJ_DTYPE_INT, null, false, 11); |
|
| 16 | + $this->initVar('pid', XOBJ_DTYPE_INT, 0, false, 11); |
|
| 17 | + $this->initVar('instrid', XOBJ_DTYPE_INT, 0, false, 11); |
|
| 18 | + $this->initVar('uid', XOBJ_DTYPE_INT, 0, false, 11); |
|
| 19 | + $this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false, 255); |
|
| 20 | + $this->initVar('status', XOBJ_DTYPE_INT, 1, false, 1); |
|
| 21 | + $this->initVar('type', XOBJ_DTYPE_INT, 1, false, 1); |
|
| 22 | + $this->initVar('hometext', XOBJ_DTYPE_TXTAREA, null, false); |
|
| 23 | + $this->initVar('footnote', XOBJ_DTYPE_TXTAREA, '', false); |
|
| 24 | + $this->initVar('weight', XOBJ_DTYPE_INT, 0, false, 11); |
|
| 25 | + $this->initVar('keywords', XOBJ_DTYPE_TXTBOX, '', false, 255); |
|
| 26 | + $this->initVar('description', XOBJ_DTYPE_TXTBOX, '', false, 255); |
|
| 27 | + $this->initVar('comments', XOBJ_DTYPE_INT, 0, false, 11); |
|
| 28 | + $this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10); |
|
| 29 | + $this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10); |
|
| 30 | + $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false, 1); |
|
| 31 | + $this->initVar('dosmiley', XOBJ_DTYPE_INT, 0, false, 1); |
|
| 32 | + $this->initVar('doxcode', XOBJ_DTYPE_INT, 1, false, 1); |
|
| 33 | + $this->initVar('dobr', XOBJ_DTYPE_INT, 0, false, 1); |
|
| 34 | + } |
|
| 35 | + |
|
| 36 | + public function InstructionPage() |
|
| 37 | + { |
|
| 38 | + $this->__construct(); |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + public function get_new_enreg() |
|
| 42 | + { |
|
| 43 | + $new_enreg = $GLOBALS['xoopsDB']->getInsertId(); |
|
| 44 | + return $new_enreg; |
|
| 45 | + } |
|
| 46 | + |
|
| 47 | + // Получаем форму |
|
| 48 | + public function getForm($action = false, $instrid = 0) |
|
| 49 | + { |
|
| 50 | + // Если нет $action |
|
| 51 | + if (false === $action) { |
|
| 52 | + $action = xoops_getenv('REQUEST_URI'); |
|
| 53 | + } |
|
| 54 | + |
|
| 55 | + // Подключаем формы |
|
| 56 | + include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
| 57 | + // Подключаем типы страниц |
|
| 58 | + $pagetypes = include $GLOBALS['xoops']->path('modules/instruction/include/pagetypes.inc.php'); |
|
| 59 | + |
|
| 60 | + // Название формы |
|
| 61 | + $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDPAGE) : sprintf(_AM_INSTRUCTION_FORMEDITPAGE); |
|
| 62 | + |
|
| 63 | + // Форма |
|
| 64 | + $form = new XoopsThemeForm($title, 'instr_form_page', $action, 'post', true); |
|
| 65 | + // Название |
|
| 66 | + $form->addElement(new XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true); |
|
| 67 | + |
|
| 68 | + // Родительская страница |
|
| 69 | + $inspageHandler = xoops_getModuleHandler('page', 'instruction'); |
|
| 70 | + $criteria = new CriteriaCompo(); |
|
| 71 | + // ID инструкции в которой данная страница |
|
| 72 | + $instrid_page = $this->isNew() ? $instrid : $this->getVar('instrid'); |
|
| 73 | + // Находим все страницы данной инструкции |
|
| 74 | + $criteria->add(new Criteria('instrid', $instrid_page, '=')); |
|
| 75 | + // Если мы редактируем, то убрать текущую страницу из списка выбора родительской |
|
| 76 | + if (!$this->isNew()) { |
|
| 77 | + $criteria->add(new Criteria('pageid', $this->getVar('pageid'), '<>')); |
|
| 78 | + } |
|
| 79 | + $criteria->setSort('weight'); |
|
| 80 | + $criteria->setOrder('ASC'); |
|
| 81 | + $inspage_arr = $inspageHandler->getall($criteria); |
|
| 82 | + unset($criteria); |
|
| 83 | + // Подключаем трей |
|
| 84 | + include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
| 85 | + $mytree = new XoopsObjectTree($inspage_arr, 'pageid', 'pid'); |
|
| 86 | + |
|
| 87 | + // $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_PPAGEC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
| 88 | + $moduleDirName = basename(__DIR__); |
|
| 89 | + if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) { |
|
| 90 | + } else { |
|
| 91 | + $moduleHelper = Xmf\Module\Helper::getHelper('system'); |
|
| 92 | + } |
|
| 93 | + $module = $moduleHelper->getModule(); |
|
| 94 | + |
|
| 95 | + if (InstructionUtility::checkVerXoops($module, '2.5.9')) { |
|
| 96 | + $mytree_select = $mytree->makeSelectElement('pid', 'title', '--', $this->getVar('pid'), true, 0, '', _AM_INSTRUCTION_PPAGEC); |
|
| 97 | + $form->addElement($mytree_select); |
|
| 98 | + } else { |
|
| 99 | + $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_PPAGEC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
| 100 | + } |
|
| 101 | + |
|
| 102 | + // Вес |
|
| 103 | + $form->addElement(new XoopsFormText(_AM_INSTRUCTION_WEIGHTC, 'weight', 5, 5, $this->getVar('weight')), true); |
|
| 104 | + // Основной текст |
|
| 105 | + $form->addElement(InstructionUtility::getWysiwygForm(_AM_INSTRUCTION_HOMETEXTC, 'hometext', $this->getVar('hometext', 'e')), true); |
|
| 106 | + // Сноска |
|
| 107 | + $form_footnote = new XoopsFormTextArea(_AM_INSTRUCTION_FOOTNOTEC, 'footnote', $this->getVar('footnote', 'e')); |
|
| 108 | + $form_footnote->setDescription(_AM_INSTRUCTION_FOOTNOTE_DSC); |
|
| 109 | + $form->addElement($form_footnote, false); |
|
| 110 | + unset($form_footnote); |
|
| 111 | + // Статус |
|
| 112 | + $form->addElement(new XoopsFormRadioYN(_AM_INSTRUCTION_ACTIVEC, 'status', $this->getVar('status')), false); |
|
| 113 | + // Тип страницы |
|
| 114 | + $form_type = new XoopsFormSelect(_AM_INSTR_PAGETYPEC, 'type', $this->getVar('type')); |
|
| 115 | + $form_type->setDescription(_AM_INSTR_PAGETYPEC_DESC); |
|
| 116 | + $form_type->addOptionArray($pagetypes); |
|
| 117 | + $form->addElement($form_type, false); |
|
| 118 | + // Мета-теги ключевых слов |
|
| 119 | + $form->addElement(new XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'keywords', 50, 255, $this->getVar('keywords')), false); |
|
| 120 | + // Мета-теги описания |
|
| 121 | + $form->addElement(new XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'description', 50, 255, $this->getVar('description')), false); |
|
| 122 | + |
|
| 123 | + // Настройки |
|
| 124 | + $option_tray = new XoopsFormElementTray(_OPTIONS, '<br>'); |
|
| 125 | + // HTML |
|
| 126 | + $html_checkbox = new XoopsFormCheckBox('', 'dohtml', $this->getVar('dohtml')); |
|
| 127 | + $html_checkbox->addOption(1, _AM_INSTR_DOHTML); |
|
| 128 | + $option_tray->addElement($html_checkbox); |
|
| 129 | + // Смайлы |
|
| 130 | + $smiley_checkbox = new XoopsFormCheckBox('', 'dosmiley', $this->getVar('dosmiley')); |
|
| 131 | + $smiley_checkbox->addOption(1, _AM_INSTR_DOSMILEY); |
|
| 132 | + $option_tray->addElement($smiley_checkbox); |
|
| 133 | + // ББ коды |
|
| 134 | + $xcode_checkbox = new XoopsFormCheckBox('', 'doxcode', $this->getVar('doxcode')); |
|
| 135 | + $xcode_checkbox->addOption(1, _AM_INSTR_DOXCODE); |
|
| 136 | + $option_tray->addElement($xcode_checkbox); |
|
| 137 | + // |
|
| 138 | + $br_checkbox = new XoopsFormCheckBox('', 'dobr', $this->getVar('dobr')); |
|
| 139 | + $br_checkbox->addOption(1, _AM_INSTR_DOAUTOWRAP); |
|
| 140 | + $option_tray->addElement($br_checkbox); |
|
| 141 | + // |
|
| 142 | + $form->addElement($option_tray); |
|
| 143 | + |
|
| 144 | + // Если мы редактируем страницу |
|
| 145 | + if (!$this->isNew()) { |
|
| 146 | + $form->addElement(new XoopsFormHidden('pageid', $this->getVar('pageid'))); |
|
| 147 | + } else { |
|
| 148 | + $form->addElement(new XoopsFormHidden('pageid', 0)); |
|
| 149 | + } |
|
| 150 | + // ID инструкции |
|
| 151 | + if ($instrid) { |
|
| 152 | + $form->addElement(new XoopsFormHidden('instrid', $instrid)); |
|
| 153 | + } else { |
|
| 154 | + $form->addElement(new XoopsFormHidden('instrid', 0)); |
|
| 155 | + } |
|
| 156 | + // |
|
| 157 | + $form->addElement(new XoopsFormHidden('op', 'savepage')); |
|
| 158 | + // Кнопка |
|
| 159 | + $button_tray = new XoopsFormElementTray('', ''); |
|
| 160 | + $button_tray->addElement(new XoopsFormButton('', 'submit', _SUBMIT, 'submit')); |
|
| 161 | + $save_btn = new XoopsFormButton('', 'cancel', _AM_INSTR_SAVEFORM); |
|
| 162 | + $save_btn->setExtra('onclick="instrSavePage();"'); |
|
| 163 | + $button_tray->addElement($save_btn); |
|
| 164 | + $form->addElement($button_tray); |
|
| 165 | + |
|
| 166 | + return $form; |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + // |
|
| 170 | + public function getInstrid() |
|
| 171 | + { |
|
| 172 | + // Возвращаем ID инструкции |
|
| 173 | + return $this->getVar('instrid'); |
|
| 174 | + } |
|
| 175 | 175 | } |
| 176 | 176 | |
| 177 | 177 | class InstructionPageHandler extends XoopsPersistableObjectHandler |
| 178 | 178 | { |
| 179 | - public function __construct($db) |
|
| 180 | - { |
|
| 181 | - parent::__construct($db, 'instruction_page', 'InstructionPage', 'pageid', 'title'); |
|
| 182 | - } |
|
| 183 | - |
|
| 184 | - /** |
|
| 185 | - * Generate function for update user post |
|
| 186 | - * |
|
| 187 | - * @ Update user post count after send approve content |
|
| 188 | - * @ Update user post count after change status content |
|
| 189 | - * @ Update user post count after delete content |
|
| 190 | - */ |
|
| 191 | - public function updateposts($uid, $status, $action) |
|
| 192 | - { |
|
| 193 | - // |
|
| 194 | - switch ($action) { |
|
| 195 | - // Добавление страницы |
|
| 196 | - case 'add': |
|
| 197 | - if ($uid && $status) { |
|
| 198 | - $user = new xoopsUser($uid); |
|
| 199 | - $memberHandler = xoops_getHandler('member'); |
|
| 200 | - // Добавялем +1 к комментам |
|
| 201 | - $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') + 1); |
|
| 202 | - } |
|
| 203 | - break; |
|
| 204 | - // Удаление страницы |
|
| 205 | - case 'delete': |
|
| 206 | - if ($uid && $status) { |
|
| 207 | - $user = new xoopsUser($uid); |
|
| 208 | - $memberHandler = xoops_getHandler('member'); |
|
| 209 | - // Декримент комментов |
|
| 210 | - //$user->setVar( 'posts', $user->getVar( 'posts' ) - 1 ); |
|
| 211 | - // Сохраняем |
|
| 212 | - $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') - 1); |
|
| 213 | - } |
|
| 214 | - break; |
|
| 215 | - |
|
| 216 | - case 'status': |
|
| 217 | - if ($uid) { |
|
| 218 | - $user = new xoopsUser($uid); |
|
| 219 | - $memberHandler = xoops_getHandler('member'); |
|
| 220 | - if ($status) { |
|
| 221 | - $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') - 1); |
|
| 222 | - } else { |
|
| 223 | - $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') + 1); |
|
| 224 | - } |
|
| 225 | - } |
|
| 226 | - break; |
|
| 227 | - } |
|
| 228 | - } |
|
| 179 | + public function __construct($db) |
|
| 180 | + { |
|
| 181 | + parent::__construct($db, 'instruction_page', 'InstructionPage', 'pageid', 'title'); |
|
| 182 | + } |
|
| 183 | + |
|
| 184 | + /** |
|
| 185 | + * Generate function for update user post |
|
| 186 | + * |
|
| 187 | + * @ Update user post count after send approve content |
|
| 188 | + * @ Update user post count after change status content |
|
| 189 | + * @ Update user post count after delete content |
|
| 190 | + */ |
|
| 191 | + public function updateposts($uid, $status, $action) |
|
| 192 | + { |
|
| 193 | + // |
|
| 194 | + switch ($action) { |
|
| 195 | + // Добавление страницы |
|
| 196 | + case 'add': |
|
| 197 | + if ($uid && $status) { |
|
| 198 | + $user = new xoopsUser($uid); |
|
| 199 | + $memberHandler = xoops_getHandler('member'); |
|
| 200 | + // Добавялем +1 к комментам |
|
| 201 | + $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') + 1); |
|
| 202 | + } |
|
| 203 | + break; |
|
| 204 | + // Удаление страницы |
|
| 205 | + case 'delete': |
|
| 206 | + if ($uid && $status) { |
|
| 207 | + $user = new xoopsUser($uid); |
|
| 208 | + $memberHandler = xoops_getHandler('member'); |
|
| 209 | + // Декримент комментов |
|
| 210 | + //$user->setVar( 'posts', $user->getVar( 'posts' ) - 1 ); |
|
| 211 | + // Сохраняем |
|
| 212 | + $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') - 1); |
|
| 213 | + } |
|
| 214 | + break; |
|
| 215 | + |
|
| 216 | + case 'status': |
|
| 217 | + if ($uid) { |
|
| 218 | + $user = new xoopsUser($uid); |
|
| 219 | + $memberHandler = xoops_getHandler('member'); |
|
| 220 | + if ($status) { |
|
| 221 | + $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') - 1); |
|
| 222 | + } else { |
|
| 223 | + $memberHandler->updateUserByField($user, 'posts', $user->getVar('posts') + 1); |
|
| 224 | + } |
|
| 225 | + } |
|
| 226 | + break; |
|
| 227 | + } |
|
| 228 | + } |
|
| 229 | 229 | } |
@@ -83,7 +83,7 @@ discard block |
||
| 83 | 83 | $instructioncatHandler = xoops_getModuleHandler('category', 'instruction'); |
| 84 | 84 | $criteria = new CriteriaCompo(); |
| 85 | 85 | // Если мы редактируем, то убрать текущую категорию из списка выбора родительской |
| 86 | - if (!$this->isNew()) { |
|
| 86 | + if ( ! $this->isNew()) { |
|
| 87 | 87 | $criteria->add(new Criteria('cid', $this->getVar('cid'), '<>')); |
| 88 | 88 | } |
| 89 | 89 | $criteria->setSort('weight ASC, title'); |
@@ -128,7 +128,7 @@ discard block |
||
| 128 | 128 | // Права на просмотр |
| 129 | 129 | $groups_ids = []; |
| 130 | 130 | // Если мы редактируем |
| 131 | - if (!$this->isNew()) { |
|
| 131 | + if ( ! $this->isNew()) { |
|
| 132 | 132 | $groups_ids = $gpermHandler->getGroupIds('instruction_view', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
| 133 | 133 | $groups_ids = array_values($groups_ids); |
| 134 | 134 | $groups_instr_view = new XoopsFormCheckBox(_AM_INSTRUCTION_PERM_VIEW, 'groups_instr_view', $groups_ids); |
@@ -140,7 +140,7 @@ discard block |
||
| 140 | 140 | |
| 141 | 141 | // Права на отправку |
| 142 | 142 | $groups_ids = []; |
| 143 | - if (!$this->isNew()) { |
|
| 143 | + if ( ! $this->isNew()) { |
|
| 144 | 144 | $groups_ids = $gpermHandler->getGroupIds('instruction_submit', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
| 145 | 145 | $groups_ids = array_values($groups_ids); |
| 146 | 146 | $groups_instr_submit = new XoopsFormCheckBox(_AM_INSTRUCTION_PERM_SUBMIT, 'groups_instr_submit', $groups_ids); |
@@ -152,7 +152,7 @@ discard block |
||
| 152 | 152 | |
| 153 | 153 | // Права на редактирование |
| 154 | 154 | $groups_ids = []; |
| 155 | - if (!$this->isNew()) { |
|
| 155 | + if ( ! $this->isNew()) { |
|
| 156 | 156 | $groups_ids = $gpermHandler->getGroupIds('instruction_edit', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
| 157 | 157 | $groups_ids = array_values($groups_ids); |
| 158 | 158 | $groups_instr_edit = new XoopsFormCheckBox(_AM_INSTRUCTION_PERM_EDIT, 'groups_instr_edit', $groups_ids); |
@@ -166,7 +166,7 @@ discard block |
||
| 166 | 166 | // ========================================================== |
| 167 | 167 | |
| 168 | 168 | // Если мы редактируем категорию |
| 169 | - if (!$this->isNew()) { |
|
| 169 | + if ( ! $this->isNew()) { |
|
| 170 | 170 | $form->addElement(new XoopsFormHidden('cid', $this->getVar('cid'))); |
| 171 | 171 | //$form->addElement( new XoopsFormHidden( 'catmodify', true)); |
| 172 | 172 | } |
@@ -196,9 +196,9 @@ discard block |
||
| 196 | 196 | public function updateDateupdated($cid = 0, $time = null) |
| 197 | 197 | { |
| 198 | 198 | // Если не передали время |
| 199 | - $time = null === $time ? time() : (int)$time; |
|
| 199 | + $time = null === $time ? time() : (int) $time; |
|
| 200 | 200 | // |
| 201 | - $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `cid` = %u', $this->table, $time, (int)$cid); |
|
| 201 | + $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `cid` = %u', $this->table, $time, (int) $cid); |
|
| 202 | 202 | // |
| 203 | 203 | return $this->db->query($sql); |
| 204 | 204 | } |
@@ -11,56 +11,56 @@ discard block |
||
| 11 | 11 | |
| 12 | 12 | class InstructionCategory extends XoopsObject |
| 13 | 13 | { |
| 14 | - // constructor |
|
| 15 | - public function __construct() |
|
| 16 | - { |
|
| 17 | - // $this->XoopsObject(); |
|
| 18 | - $this->initVar('cid', XOBJ_DTYPE_INT, null, false, 5); |
|
| 19 | - $this->initVar('pid', XOBJ_DTYPE_INT, 0, false, 5); |
|
| 20 | - $this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false); |
|
| 21 | - $this->initVar('imgurl', XOBJ_DTYPE_TXTBOX, '', false); |
|
| 22 | - $this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false); |
|
| 23 | - $this->initVar('weight', XOBJ_DTYPE_INT, 0, false, 11); |
|
| 24 | - $this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10); |
|
| 25 | - $this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10); |
|
| 26 | - $this->initVar('metakeywords', XOBJ_DTYPE_TXTBOX, '', false); |
|
| 27 | - $this->initVar('metadescription', XOBJ_DTYPE_TXTBOX, '', false); |
|
| 28 | - } |
|
| 29 | - |
|
| 30 | - public function InstructionCategory() |
|
| 31 | - { |
|
| 32 | - $this->__construct(); |
|
| 33 | - } |
|
| 34 | - |
|
| 35 | - public function get_new_enreg() |
|
| 36 | - { |
|
| 37 | - $new_enreg = $GLOBALS['xoopsDB']->getInsertId(); |
|
| 38 | - return $new_enreg; |
|
| 39 | - } |
|
| 40 | - |
|
| 41 | - // Получаем форму |
|
| 42 | - public function getForm($action = false) |
|
| 43 | - { |
|
| 44 | - //global $xoopsDB, $xoopsModule, $xoopsModuleConfig; |
|
| 45 | - // Если нет $action |
|
| 46 | - if (false === $action) { |
|
| 47 | - $action = xoops_getenv('REQUEST_URI'); |
|
| 48 | - } |
|
| 49 | - // Подключаем формы |
|
| 50 | - include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
| 51 | - |
|
| 52 | - // Название формы |
|
| 53 | - $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDCAT) : sprintf(_AM_INSTRUCTION_FORMEDITCAT); |
|
| 54 | - |
|
| 55 | - // Форма |
|
| 56 | - $form = new XoopsThemeForm($title, 'formcat', $action, 'post', true); |
|
| 57 | - //$form->setExtra('enctype="multipart/form-data"'); |
|
| 58 | - // Название категории |
|
| 59 | - $form->addElement(new XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true); |
|
| 60 | - // Редактор |
|
| 61 | - $form->addElement(new XoopsFormTextArea(_AM_INSTRUCTION_DSCC, 'description', $this->getVar('description', 'e')), true); |
|
| 62 | - //image |
|
| 63 | - /* |
|
| 14 | + // constructor |
|
| 15 | + public function __construct() |
|
| 16 | + { |
|
| 17 | + // $this->XoopsObject(); |
|
| 18 | + $this->initVar('cid', XOBJ_DTYPE_INT, null, false, 5); |
|
| 19 | + $this->initVar('pid', XOBJ_DTYPE_INT, 0, false, 5); |
|
| 20 | + $this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false); |
|
| 21 | + $this->initVar('imgurl', XOBJ_DTYPE_TXTBOX, '', false); |
|
| 22 | + $this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false); |
|
| 23 | + $this->initVar('weight', XOBJ_DTYPE_INT, 0, false, 11); |
|
| 24 | + $this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10); |
|
| 25 | + $this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10); |
|
| 26 | + $this->initVar('metakeywords', XOBJ_DTYPE_TXTBOX, '', false); |
|
| 27 | + $this->initVar('metadescription', XOBJ_DTYPE_TXTBOX, '', false); |
|
| 28 | + } |
|
| 29 | + |
|
| 30 | + public function InstructionCategory() |
|
| 31 | + { |
|
| 32 | + $this->__construct(); |
|
| 33 | + } |
|
| 34 | + |
|
| 35 | + public function get_new_enreg() |
|
| 36 | + { |
|
| 37 | + $new_enreg = $GLOBALS['xoopsDB']->getInsertId(); |
|
| 38 | + return $new_enreg; |
|
| 39 | + } |
|
| 40 | + |
|
| 41 | + // Получаем форму |
|
| 42 | + public function getForm($action = false) |
|
| 43 | + { |
|
| 44 | + //global $xoopsDB, $xoopsModule, $xoopsModuleConfig; |
|
| 45 | + // Если нет $action |
|
| 46 | + if (false === $action) { |
|
| 47 | + $action = xoops_getenv('REQUEST_URI'); |
|
| 48 | + } |
|
| 49 | + // Подключаем формы |
|
| 50 | + include_once $GLOBALS['xoops']->path('class/xoopsformloader.php'); |
|
| 51 | + |
|
| 52 | + // Название формы |
|
| 53 | + $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDCAT) : sprintf(_AM_INSTRUCTION_FORMEDITCAT); |
|
| 54 | + |
|
| 55 | + // Форма |
|
| 56 | + $form = new XoopsThemeForm($title, 'formcat', $action, 'post', true); |
|
| 57 | + //$form->setExtra('enctype="multipart/form-data"'); |
|
| 58 | + // Название категории |
|
| 59 | + $form->addElement(new XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true); |
|
| 60 | + // Редактор |
|
| 61 | + $form->addElement(new XoopsFormTextArea(_AM_INSTRUCTION_DSCC, 'description', $this->getVar('description', 'e')), true); |
|
| 62 | + //image |
|
| 63 | + /* |
|
| 64 | 64 | $downloadscat_img = $this->getVar('imgurl') ? $this->getVar('imgurl') : 'blank.gif'; |
| 65 | 65 | $uploadirectory='/uploads/tdmdownloads/images/cats'; |
| 66 | 66 | $imgtray = new XoopsFormElementTray(_AM_TDMDOWNLOADS_FORMIMG,'<br>'); |
@@ -79,127 +79,127 @@ discard block |
||
| 79 | 79 | $imgtray->addElement($fileseltray); |
| 80 | 80 | $form->addElement($imgtray); |
| 81 | 81 | */ |
| 82 | - // Родительская категория |
|
| 83 | - $instructioncatHandler = xoops_getModuleHandler('category', 'instruction'); |
|
| 84 | - $criteria = new CriteriaCompo(); |
|
| 85 | - // Если мы редактируем, то убрать текущую категорию из списка выбора родительской |
|
| 86 | - if (!$this->isNew()) { |
|
| 87 | - $criteria->add(new Criteria('cid', $this->getVar('cid'), '<>')); |
|
| 88 | - } |
|
| 89 | - $criteria->setSort('weight ASC, title'); |
|
| 90 | - $criteria->setOrder('ASC'); |
|
| 91 | - $instructioncat_arr = $instructioncatHandler->getall($criteria); |
|
| 92 | - unset($criteria); |
|
| 93 | - // Подключаем трей |
|
| 94 | - include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
| 95 | - $mytree = new XoopsObjectTree($instructioncat_arr, 'cid', 'pid'); |
|
| 96 | - |
|
| 97 | - // $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_PCATC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
| 98 | - $moduleDirName = basename(__DIR__); |
|
| 99 | - if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) { |
|
| 100 | - } else { |
|
| 101 | - $moduleHelper = Xmf\Module\Helper::getHelper('system'); |
|
| 102 | - } |
|
| 103 | - $module = $moduleHelper->getModule(); |
|
| 104 | - |
|
| 105 | - if (InstructionUtility::checkVerXoops($module, '2.5.9')) { |
|
| 106 | - $mytree_select = $mytree->makeSelectElement('pid', 'title', '--', $this->getVar('pid'), true, 0, '', _AM_INSTRUCTION_PCATC); |
|
| 107 | - $form->addElement($mytree_select); |
|
| 108 | - } else { |
|
| 109 | - $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_PCATC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
| 110 | - } |
|
| 111 | - |
|
| 112 | - // Вес |
|
| 113 | - $form->addElement(new XoopsFormText(_AM_INSTRUCTION_WEIGHTC, 'weight', 5, 5, $this->getVar('weight')), true); |
|
| 114 | - // Мета-теги ключевых слов |
|
| 115 | - $form->addElement(new XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'metakeywords', 50, 255, $this->getVar('metakeywords')), false); |
|
| 116 | - // Мета-теги описания |
|
| 117 | - $form->addElement(new XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'metadescription', 50, 255, $this->getVar('metadescription')), false); |
|
| 118 | - |
|
| 119 | - // ========================================================== |
|
| 120 | - // ========================================================== |
|
| 121 | - |
|
| 122 | - // Права |
|
| 123 | - $memberHandler = xoops_getHandler('member'); |
|
| 124 | - $group_list = $memberHandler->getGroupList(); |
|
| 125 | - $gpermHandler = xoops_getHandler('groupperm'); |
|
| 126 | - $full_list = array_keys($group_list); |
|
| 127 | - |
|
| 128 | - // Права на просмотр |
|
| 129 | - $groups_ids = []; |
|
| 130 | - // Если мы редактируем |
|
| 131 | - if (!$this->isNew()) { |
|
| 132 | - $groups_ids = $gpermHandler->getGroupIds('instruction_view', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
| 133 | - $groups_ids = array_values($groups_ids); |
|
| 134 | - $groups_instr_view = new XoopsFormCheckBox(_AM_INSTRUCTION_PERM_VIEW, 'groups_instr_view', $groups_ids); |
|
| 135 | - } else { |
|
| 136 | - $groups_instr_view = new XoopsFormCheckBox(_AM_INSTRUCTION_PERM_VIEW, 'groups_instr_view', $full_list); |
|
| 137 | - } |
|
| 138 | - $groups_instr_view->addOptionArray($group_list); |
|
| 139 | - $form->addElement($groups_instr_view); |
|
| 140 | - |
|
| 141 | - // Права на отправку |
|
| 142 | - $groups_ids = []; |
|
| 143 | - if (!$this->isNew()) { |
|
| 144 | - $groups_ids = $gpermHandler->getGroupIds('instruction_submit', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
| 145 | - $groups_ids = array_values($groups_ids); |
|
| 146 | - $groups_instr_submit = new XoopsFormCheckBox(_AM_INSTRUCTION_PERM_SUBMIT, 'groups_instr_submit', $groups_ids); |
|
| 147 | - } else { |
|
| 148 | - $groups_instr_submit = new XoopsFormCheckBox(_AM_INSTRUCTION_PERM_SUBMIT, 'groups_instr_submit', $full_list); |
|
| 149 | - } |
|
| 150 | - $groups_instr_submit->addOptionArray($group_list); |
|
| 151 | - $form->addElement($groups_instr_submit); |
|
| 152 | - |
|
| 153 | - // Права на редактирование |
|
| 154 | - $groups_ids = []; |
|
| 155 | - if (!$this->isNew()) { |
|
| 156 | - $groups_ids = $gpermHandler->getGroupIds('instruction_edit', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
| 157 | - $groups_ids = array_values($groups_ids); |
|
| 158 | - $groups_instr_edit = new XoopsFormCheckBox(_AM_INSTRUCTION_PERM_EDIT, 'groups_instr_edit', $groups_ids); |
|
| 159 | - } else { |
|
| 160 | - $groups_instr_edit = new XoopsFormCheckBox(_AM_INSTRUCTION_PERM_EDIT, 'groups_instr_edit', $full_list); |
|
| 161 | - } |
|
| 162 | - $groups_instr_edit->addOptionArray($group_list); |
|
| 163 | - $form->addElement($groups_instr_edit); |
|
| 164 | - |
|
| 165 | - // ========================================================== |
|
| 166 | - // ========================================================== |
|
| 167 | - |
|
| 168 | - // Если мы редактируем категорию |
|
| 169 | - if (!$this->isNew()) { |
|
| 170 | - $form->addElement(new XoopsFormHidden('cid', $this->getVar('cid'))); |
|
| 171 | - //$form->addElement( new XoopsFormHidden( 'catmodify', true)); |
|
| 172 | - } |
|
| 173 | - // |
|
| 174 | - $form->addElement(new XoopsFormHidden('op', 'savecat')); |
|
| 175 | - // Кнопка |
|
| 176 | - $button_tray = new XoopsFormElementTray('', ''); |
|
| 177 | - $submit_btn = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
| 178 | - $button_tray->addElement($submit_btn); |
|
| 179 | - $cancel_btn = new XoopsFormButton('', 'cancel', _CANCEL, 'cancel'); |
|
| 180 | - $cancel_btn->setExtra('onclick="javascript:history.go(-1);"'); |
|
| 181 | - $button_tray->addElement($cancel_btn); |
|
| 182 | - $form->addElement($button_tray); |
|
| 183 | - |
|
| 184 | - return $form; |
|
| 185 | - } |
|
| 82 | + // Родительская категория |
|
| 83 | + $instructioncatHandler = xoops_getModuleHandler('category', 'instruction'); |
|
| 84 | + $criteria = new CriteriaCompo(); |
|
| 85 | + // Если мы редактируем, то убрать текущую категорию из списка выбора родительской |
|
| 86 | + if (!$this->isNew()) { |
|
| 87 | + $criteria->add(new Criteria('cid', $this->getVar('cid'), '<>')); |
|
| 88 | + } |
|
| 89 | + $criteria->setSort('weight ASC, title'); |
|
| 90 | + $criteria->setOrder('ASC'); |
|
| 91 | + $instructioncat_arr = $instructioncatHandler->getall($criteria); |
|
| 92 | + unset($criteria); |
|
| 93 | + // Подключаем трей |
|
| 94 | + include_once $GLOBALS['xoops']->path('class/tree.php'); |
|
| 95 | + $mytree = new XoopsObjectTree($instructioncat_arr, 'cid', 'pid'); |
|
| 96 | + |
|
| 97 | + // $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_PCATC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
| 98 | + $moduleDirName = basename(__DIR__); |
|
| 99 | + if (false !== ($moduleHelper = Xmf\Module\Helper::getHelper($moduleDirName))) { |
|
| 100 | + } else { |
|
| 101 | + $moduleHelper = Xmf\Module\Helper::getHelper('system'); |
|
| 102 | + } |
|
| 103 | + $module = $moduleHelper->getModule(); |
|
| 104 | + |
|
| 105 | + if (InstructionUtility::checkVerXoops($module, '2.5.9')) { |
|
| 106 | + $mytree_select = $mytree->makeSelectElement('pid', 'title', '--', $this->getVar('pid'), true, 0, '', _AM_INSTRUCTION_PCATC); |
|
| 107 | + $form->addElement($mytree_select); |
|
| 108 | + } else { |
|
| 109 | + $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_PCATC, $mytree->makeSelBox('pid', 'title', '--', $this->getVar('pid'), true))); |
|
| 110 | + } |
|
| 111 | + |
|
| 112 | + // Вес |
|
| 113 | + $form->addElement(new XoopsFormText(_AM_INSTRUCTION_WEIGHTC, 'weight', 5, 5, $this->getVar('weight')), true); |
|
| 114 | + // Мета-теги ключевых слов |
|
| 115 | + $form->addElement(new XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'metakeywords', 50, 255, $this->getVar('metakeywords')), false); |
|
| 116 | + // Мета-теги описания |
|
| 117 | + $form->addElement(new XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'metadescription', 50, 255, $this->getVar('metadescription')), false); |
|
| 118 | + |
|
| 119 | + // ========================================================== |
|
| 120 | + // ========================================================== |
|
| 121 | + |
|
| 122 | + // Права |
|
| 123 | + $memberHandler = xoops_getHandler('member'); |
|
| 124 | + $group_list = $memberHandler->getGroupList(); |
|
| 125 | + $gpermHandler = xoops_getHandler('groupperm'); |
|
| 126 | + $full_list = array_keys($group_list); |
|
| 127 | + |
|
| 128 | + // Права на просмотр |
|
| 129 | + $groups_ids = []; |
|
| 130 | + // Если мы редактируем |
|
| 131 | + if (!$this->isNew()) { |
|
| 132 | + $groups_ids = $gpermHandler->getGroupIds('instruction_view', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
| 133 | + $groups_ids = array_values($groups_ids); |
|
| 134 | + $groups_instr_view = new XoopsFormCheckBox(_AM_INSTRUCTION_PERM_VIEW, 'groups_instr_view', $groups_ids); |
|
| 135 | + } else { |
|
| 136 | + $groups_instr_view = new XoopsFormCheckBox(_AM_INSTRUCTION_PERM_VIEW, 'groups_instr_view', $full_list); |
|
| 137 | + } |
|
| 138 | + $groups_instr_view->addOptionArray($group_list); |
|
| 139 | + $form->addElement($groups_instr_view); |
|
| 140 | + |
|
| 141 | + // Права на отправку |
|
| 142 | + $groups_ids = []; |
|
| 143 | + if (!$this->isNew()) { |
|
| 144 | + $groups_ids = $gpermHandler->getGroupIds('instruction_submit', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
| 145 | + $groups_ids = array_values($groups_ids); |
|
| 146 | + $groups_instr_submit = new XoopsFormCheckBox(_AM_INSTRUCTION_PERM_SUBMIT, 'groups_instr_submit', $groups_ids); |
|
| 147 | + } else { |
|
| 148 | + $groups_instr_submit = new XoopsFormCheckBox(_AM_INSTRUCTION_PERM_SUBMIT, 'groups_instr_submit', $full_list); |
|
| 149 | + } |
|
| 150 | + $groups_instr_submit->addOptionArray($group_list); |
|
| 151 | + $form->addElement($groups_instr_submit); |
|
| 152 | + |
|
| 153 | + // Права на редактирование |
|
| 154 | + $groups_ids = []; |
|
| 155 | + if (!$this->isNew()) { |
|
| 156 | + $groups_ids = $gpermHandler->getGroupIds('instruction_edit', $this->getVar('cid'), $GLOBALS['xoopsModule']->getVar('mid')); |
|
| 157 | + $groups_ids = array_values($groups_ids); |
|
| 158 | + $groups_instr_edit = new XoopsFormCheckBox(_AM_INSTRUCTION_PERM_EDIT, 'groups_instr_edit', $groups_ids); |
|
| 159 | + } else { |
|
| 160 | + $groups_instr_edit = new XoopsFormCheckBox(_AM_INSTRUCTION_PERM_EDIT, 'groups_instr_edit', $full_list); |
|
| 161 | + } |
|
| 162 | + $groups_instr_edit->addOptionArray($group_list); |
|
| 163 | + $form->addElement($groups_instr_edit); |
|
| 164 | + |
|
| 165 | + // ========================================================== |
|
| 166 | + // ========================================================== |
|
| 167 | + |
|
| 168 | + // Если мы редактируем категорию |
|
| 169 | + if (!$this->isNew()) { |
|
| 170 | + $form->addElement(new XoopsFormHidden('cid', $this->getVar('cid'))); |
|
| 171 | + //$form->addElement( new XoopsFormHidden( 'catmodify', true)); |
|
| 172 | + } |
|
| 173 | + // |
|
| 174 | + $form->addElement(new XoopsFormHidden('op', 'savecat')); |
|
| 175 | + // Кнопка |
|
| 176 | + $button_tray = new XoopsFormElementTray('', ''); |
|
| 177 | + $submit_btn = new XoopsFormButton('', 'submit', _SUBMIT, 'submit'); |
|
| 178 | + $button_tray->addElement($submit_btn); |
|
| 179 | + $cancel_btn = new XoopsFormButton('', 'cancel', _CANCEL, 'cancel'); |
|
| 180 | + $cancel_btn->setExtra('onclick="javascript:history.go(-1);"'); |
|
| 181 | + $button_tray->addElement($cancel_btn); |
|
| 182 | + $form->addElement($button_tray); |
|
| 183 | + |
|
| 184 | + return $form; |
|
| 185 | + } |
|
| 186 | 186 | } |
| 187 | 187 | |
| 188 | 188 | class InstructionCategoryHandler extends XoopsPersistableObjectHandler |
| 189 | 189 | { |
| 190 | - public function __construct($db) |
|
| 191 | - { |
|
| 192 | - parent::__construct($db, 'instruction_cat', 'InstructionCategory', 'cid', 'title'); |
|
| 193 | - } |
|
| 194 | - |
|
| 195 | - // Обновление даты обновления категории |
|
| 196 | - public function updateDateupdated($cid = 0, $time = null) |
|
| 197 | - { |
|
| 198 | - // Если не передали время |
|
| 199 | - $time = null === $time ? time() : (int)$time; |
|
| 200 | - // |
|
| 201 | - $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `cid` = %u', $this->table, $time, (int)$cid); |
|
| 202 | - // |
|
| 203 | - return $this->db->query($sql); |
|
| 204 | - } |
|
| 190 | + public function __construct($db) |
|
| 191 | + { |
|
| 192 | + parent::__construct($db, 'instruction_cat', 'InstructionCategory', 'cid', 'title'); |
|
| 193 | + } |
|
| 194 | + |
|
| 195 | + // Обновление даты обновления категории |
|
| 196 | + public function updateDateupdated($cid = 0, $time = null) |
|
| 197 | + { |
|
| 198 | + // Если не передали время |
|
| 199 | + $time = null === $time ? time() : (int)$time; |
|
| 200 | + // |
|
| 201 | + $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `cid` = %u', $this->table, $time, (int)$cid); |
|
| 202 | + // |
|
| 203 | + return $this->db->query($sql); |
|
| 204 | + } |
|
| 205 | 205 | } |
@@ -78,7 +78,7 @@ discard block |
||
| 78 | 78 | $prefix_curr .= $prefix_orig; |
| 79 | 79 | } |
| 80 | 80 | |
| 81 | - if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
| 81 | + if (isset($this->tree[$key]['child']) && ! empty($this->tree[$key]['child'])) { |
|
| 82 | 82 | foreach ($this->tree[$key]['child'] as $childkey) { |
| 83 | 83 | $this->_makePagesAdminOptions($childkey, $ret, $prefix_orig, $objInsinstr, $class, $prefix_curr); |
| 84 | 84 | } |
@@ -172,7 +172,7 @@ discard block |
||
| 172 | 172 | $prefix_curr .= $prefix_orig; |
| 173 | 173 | } |
| 174 | 174 | |
| 175 | - if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
| 175 | + if (isset($this->tree[$key]['child']) && ! empty($this->tree[$key]['child'])) { |
|
| 176 | 176 | foreach ($this->tree[$key]['child'] as $childkey) { |
| 177 | 177 | $this->_makeCatsAdminOptions($childkey, $ret, $prefix_orig, $cidinstrids, $class, $prefix_curr); |
| 178 | 178 | } |
@@ -289,7 +289,7 @@ discard block |
||
| 289 | 289 | } |
| 290 | 290 | |
| 291 | 291 | // Рекурсия |
| 292 | - if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
| 292 | + if (isset($this->tree[$key]['child']) && ! empty($this->tree[$key]['child'])) { |
|
| 293 | 293 | foreach ($this->tree[$key]['child'] as $childkey) { |
| 294 | 294 | $this->_makePagesUserTree($childkey, $ret, $currpageid, $lastpageids, $level); |
| 295 | 295 | } |
@@ -350,7 +350,7 @@ discard block |
||
| 350 | 350 | } |
| 351 | 351 | |
| 352 | 352 | // Рекурсия |
| 353 | - if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
| 353 | + if (isset($this->tree[$key]['child']) && ! empty($this->tree[$key]['child'])) { |
|
| 354 | 354 | foreach ($this->tree[$key]['child'] as $childkey) { |
| 355 | 355 | $this->_makePagesUserCalc($childkey, $currpageid, $prevpages, $nextpages, $lastpageids, $level); |
| 356 | 356 | } |
@@ -16,6 +16,11 @@ discard block |
||
| 16 | 16 | // { |
| 17 | 17 | // } |
| 18 | 18 | |
| 19 | + /** |
|
| 20 | + * @param integer $key |
|
| 21 | + * @param string $ret |
|
| 22 | + * @param string $prefix_orig |
|
| 23 | + */ |
|
| 19 | 24 | public function _makePagesAdminOptions($key, &$ret, $prefix_orig, $objInsinstr, $class = 'odd', $prefix_curr = '') |
| 20 | 25 | { |
| 21 | 26 | if ($key > 0) { |
@@ -119,6 +124,11 @@ discard block |
||
| 119 | 124 | // === Дерево категорий в админке === |
| 120 | 125 | // ================================== |
| 121 | 126 | |
| 127 | + /** |
|
| 128 | + * @param integer $key |
|
| 129 | + * @param string $ret |
|
| 130 | + * @param string $prefix_orig |
|
| 131 | + */ |
|
| 122 | 132 | public function _makeCatsAdminOptions($key, &$ret, $prefix_orig, $cidinstrids = [], &$class = 'odd', $prefix_curr = '') |
| 123 | 133 | { |
| 124 | 134 | if ($key > 0) { |
@@ -204,6 +214,10 @@ discard block |
||
| 204 | 214 | // Список страниц на стороне пользователя |
| 205 | 215 | // ====================================== |
| 206 | 216 | |
| 217 | + /** |
|
| 218 | + * @param integer $key |
|
| 219 | + * @param string $ret |
|
| 220 | + */ |
|
| 207 | 221 | public function _makePagesUserTree($key, &$ret, $currpageid = 0, &$lastpageids = [], $level = 0) |
| 208 | 222 | { |
| 209 | 223 | |
@@ -308,6 +322,10 @@ discard block |
||
| 308 | 322 | |
| 309 | 323 | // Находим предыдущую и следующую страницы. |
| 310 | 324 | // Находим последнии страницы на каждом уровне. |
| 325 | + |
|
| 326 | + /** |
|
| 327 | + * @param integer $key |
|
| 328 | + */ |
|
| 311 | 329 | public function _makePagesUserCalc($key, $currpageid = 0, &$prevpages = [], &$nextpages = [], &$lastpageids = [], $level = 0) |
| 312 | 330 | { |
| 313 | 331 | |
@@ -16,78 +16,78 @@ discard block |
||
| 16 | 16 | // { |
| 17 | 17 | // } |
| 18 | 18 | |
| 19 | - public function _makePagesAdminOptions($key, &$ret, $prefix_orig, $objInsinstr, $class = 'odd', $prefix_curr = '') |
|
| 20 | - { |
|
| 21 | - if ($key > 0) { |
|
| 22 | - |
|
| 23 | - // |
|
| 24 | - $class = ('even' == $class) ? 'odd' : 'even'; |
|
| 25 | - // ID инструкции ( Можно сделать статической ) |
|
| 26 | - $instrid = $objInsinstr->getVar('instrid'); |
|
| 27 | - |
|
| 28 | - // ID страницы |
|
| 29 | - $pageid = $this->tree[$key]['obj']->getVar('pageid'); |
|
| 30 | - // Название страницы |
|
| 31 | - $pagetitle = $this->tree[$key]['obj']->getVar('title'); |
|
| 32 | - // Вес |
|
| 33 | - $pageweight = $this->tree[$key]['obj']->getVar('weight'); |
|
| 34 | - // Статус |
|
| 35 | - $pagestatus = $this->tree[$key]['obj']->getVar('status'); |
|
| 36 | - // Тип страницы |
|
| 37 | - $pagetype = $this->tree[$key]['obj']->getVar('type'); |
|
| 38 | - |
|
| 39 | - // Дочернии страницы |
|
| 40 | - $page_childs = $this->getAllChild($pageid); |
|
| 41 | - // Число дочерних страниц |
|
| 42 | - $num_childs = count($page_childs); |
|
| 43 | - |
|
| 44 | - // Действие - удаление |
|
| 45 | - $act_del = ($num_childs > 0) ? '<img src="../assets/icons/no_delete_mini.png" alt="' . _AM_INSTR_NODELPAGE . '" title="' . _AM_INSTR_NODELPAGE . '" />' : '<a href="instr.php?op=delpage&pageid=' |
|
| 46 | - . $pageid |
|
| 47 | - . '"><img src="../assets/icons/delete_mini.png" alt="' |
|
| 48 | - . _AM_INSTRUCTION_DEL |
|
| 49 | - . '" title="' |
|
| 50 | - . _AM_INSTRUCTION_DEL |
|
| 51 | - . '"></a>'; |
|
| 52 | - // |
|
| 53 | - $page_link = '<a name="pageid_' . $pageid . '" ' . ($pagetype ? 'href="' . XOOPS_URL . '/modules/' . INST_DIRNAME . '/page.php?id=' . $pageid . '#pagetext"' : '') . '>' . $pagetitle . '</a>'; |
|
| 54 | - |
|
| 55 | - $ret .= '<tr class="' . $class . '"> |
|
| 19 | + public function _makePagesAdminOptions($key, &$ret, $prefix_orig, $objInsinstr, $class = 'odd', $prefix_curr = '') |
|
| 20 | + { |
|
| 21 | + if ($key > 0) { |
|
| 22 | + |
|
| 23 | + // |
|
| 24 | + $class = ('even' == $class) ? 'odd' : 'even'; |
|
| 25 | + // ID инструкции ( Можно сделать статической ) |
|
| 26 | + $instrid = $objInsinstr->getVar('instrid'); |
|
| 27 | + |
|
| 28 | + // ID страницы |
|
| 29 | + $pageid = $this->tree[$key]['obj']->getVar('pageid'); |
|
| 30 | + // Название страницы |
|
| 31 | + $pagetitle = $this->tree[$key]['obj']->getVar('title'); |
|
| 32 | + // Вес |
|
| 33 | + $pageweight = $this->tree[$key]['obj']->getVar('weight'); |
|
| 34 | + // Статус |
|
| 35 | + $pagestatus = $this->tree[$key]['obj']->getVar('status'); |
|
| 36 | + // Тип страницы |
|
| 37 | + $pagetype = $this->tree[$key]['obj']->getVar('type'); |
|
| 38 | + |
|
| 39 | + // Дочернии страницы |
|
| 40 | + $page_childs = $this->getAllChild($pageid); |
|
| 41 | + // Число дочерних страниц |
|
| 42 | + $num_childs = count($page_childs); |
|
| 43 | + |
|
| 44 | + // Действие - удаление |
|
| 45 | + $act_del = ($num_childs > 0) ? '<img src="../assets/icons/no_delete_mini.png" alt="' . _AM_INSTR_NODELPAGE . '" title="' . _AM_INSTR_NODELPAGE . '" />' : '<a href="instr.php?op=delpage&pageid=' |
|
| 46 | + . $pageid |
|
| 47 | + . '"><img src="../assets/icons/delete_mini.png" alt="' |
|
| 48 | + . _AM_INSTRUCTION_DEL |
|
| 49 | + . '" title="' |
|
| 50 | + . _AM_INSTRUCTION_DEL |
|
| 51 | + . '"></a>'; |
|
| 52 | + // |
|
| 53 | + $page_link = '<a name="pageid_' . $pageid . '" ' . ($pagetype ? 'href="' . XOOPS_URL . '/modules/' . INST_DIRNAME . '/page.php?id=' . $pageid . '#pagetext"' : '') . '>' . $pagetitle . '</a>'; |
|
| 54 | + |
|
| 55 | + $ret .= '<tr class="' . $class . '"> |
|
| 56 | 56 | <td>' . $prefix_curr . ' ' . $page_link . '</td> |
| 57 | 57 | <td align="center" width="50"> |
| 58 | 58 | <input type="text" name="weights[]" size="2" value="' . $pageweight . '" /> |
| 59 | 59 | <input type="hidden" name="pageids[]" value="' . $pageid . '" /> |
| 60 | 60 | </td> |
| 61 | 61 | <td align="center" width="180">'; |
| 62 | - // Просмотре без кэша |
|
| 63 | - $ret .= ' <a href="' . XOOPS_URL . '/modules/' . INST_DIRNAME . '/page.php?id=' . $pageid . '&nocache=1"><img src="../assets/icons/no_cache.png" alt="' . _AM_INSTR_DISPLAY_NOCACHE . '" title="' . _AM_INSTR_DISPLAY_NOCACHE . '" /></a> '; |
|
| 64 | - // Добавить подстраницу |
|
| 65 | - $ret .= ' <a href="instr.php?op=editpage&instrid=' . $instrid . '&pid=' . $pageid . '"><img src="../assets/icons/add_mini.png" alt="' . _AM_INSTRUCTION_ADDSUBPAGE . '" title="' . _AM_INSTRUCTION_ADDSUBPAGE . '" /></a> '; |
|
| 66 | - |
|
| 67 | - if ($pagestatus) { |
|
| 68 | - $ret .= ' <img src="../assets/icons/lock_mini.png" alt="' . _AM_INSTRUCTION_LOCK . '" title="' . _AM_INSTRUCTION_LOCK . '"> '; |
|
| 69 | - } else { |
|
| 70 | - $ret .= ' <img src="../assets/icons/unlock_mini.png" alt="' . _AM_INSTRUCTION_UNLOCK . '" title="' . _AM_INSTRUCTION_UNLOCK . '"> '; |
|
| 71 | - } |
|
| 72 | - |
|
| 73 | - $ret .= ' <a href="instr.php?op=editpage&pageid=' . $pageid . '"><img src="../assets/icons/edit_mini.png" alt="' . _AM_INSTRUCTION_EDIT . '" title="' . _AM_INSTRUCTION_EDIT . '"></a> ' . $act_del . ' |
|
| 62 | + // Просмотре без кэша |
|
| 63 | + $ret .= ' <a href="' . XOOPS_URL . '/modules/' . INST_DIRNAME . '/page.php?id=' . $pageid . '&nocache=1"><img src="../assets/icons/no_cache.png" alt="' . _AM_INSTR_DISPLAY_NOCACHE . '" title="' . _AM_INSTR_DISPLAY_NOCACHE . '" /></a> '; |
|
| 64 | + // Добавить подстраницу |
|
| 65 | + $ret .= ' <a href="instr.php?op=editpage&instrid=' . $instrid . '&pid=' . $pageid . '"><img src="../assets/icons/add_mini.png" alt="' . _AM_INSTRUCTION_ADDSUBPAGE . '" title="' . _AM_INSTRUCTION_ADDSUBPAGE . '" /></a> '; |
|
| 66 | + |
|
| 67 | + if ($pagestatus) { |
|
| 68 | + $ret .= ' <img src="../assets/icons/lock_mini.png" alt="' . _AM_INSTRUCTION_LOCK . '" title="' . _AM_INSTRUCTION_LOCK . '"> '; |
|
| 69 | + } else { |
|
| 70 | + $ret .= ' <img src="../assets/icons/unlock_mini.png" alt="' . _AM_INSTRUCTION_UNLOCK . '" title="' . _AM_INSTRUCTION_UNLOCK . '"> '; |
|
| 71 | + } |
|
| 72 | + |
|
| 73 | + $ret .= ' <a href="instr.php?op=editpage&pageid=' . $pageid . '"><img src="../assets/icons/edit_mini.png" alt="' . _AM_INSTRUCTION_EDIT . '" title="' . _AM_INSTRUCTION_EDIT . '"></a> ' . $act_del . ' |
|
| 74 | 74 | </td> |
| 75 | 75 | </tr>'; |
| 76 | 76 | |
| 77 | - // Устанавливаем префикс |
|
| 78 | - $prefix_curr .= $prefix_orig; |
|
| 79 | - } |
|
| 77 | + // Устанавливаем префикс |
|
| 78 | + $prefix_curr .= $prefix_orig; |
|
| 79 | + } |
|
| 80 | 80 | |
| 81 | - if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
| 82 | - foreach ($this->tree[$key]['child'] as $childkey) { |
|
| 83 | - $this->_makePagesAdminOptions($childkey, $ret, $prefix_orig, $objInsinstr, $class, $prefix_curr); |
|
| 84 | - } |
|
| 85 | - } |
|
| 86 | - } |
|
| 81 | + if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
| 82 | + foreach ($this->tree[$key]['child'] as $childkey) { |
|
| 83 | + $this->_makePagesAdminOptions($childkey, $ret, $prefix_orig, $objInsinstr, $class, $prefix_curr); |
|
| 84 | + } |
|
| 85 | + } |
|
| 86 | + } |
|
| 87 | 87 | |
| 88 | - public function makePagesAdmin(&$objInsinstr, $prefix = '-', $key = 0) |
|
| 89 | - { |
|
| 90 | - $ret = '<form name="inspages" action="instr.php" method="post"> |
|
| 88 | + public function makePagesAdmin(&$objInsinstr, $prefix = '-', $key = 0) |
|
| 89 | + { |
|
| 90 | + $ret = '<form name="inspages" action="instr.php" method="post"> |
|
| 91 | 91 | <table width="100%" cellspacing="1" class="outer"> |
| 92 | 92 | <tr> |
| 93 | 93 | <th align="center" colspan="3">' . sprintf(_AM_INSTRUCTION_LISTPAGESININSTR, $objInsinstr->getVar('title')) . '</th> |
@@ -98,10 +98,10 @@ discard block |
||
| 98 | 98 | <td class="head" align="center" width="180">' . _AM_INSTRUCTION_ACTION . '</td> |
| 99 | 99 | </tr>'; |
| 100 | 100 | |
| 101 | - // Выводим все страницы |
|
| 102 | - $this->_makePagesAdminOptions($key, $ret, $prefix, $objInsinstr); |
|
| 101 | + // Выводим все страницы |
|
| 102 | + $this->_makePagesAdminOptions($key, $ret, $prefix, $objInsinstr); |
|
| 103 | 103 | |
| 104 | - $ret .= '<tr class="foot"> |
|
| 104 | + $ret .= '<tr class="foot"> |
|
| 105 | 105 | <td><a href="instr.php?op=editpage&instrid=' . $objInsinstr->getVar('instrid') . '"><img src="../assets/icons/add_mini.png" alt="' . _AM_INSTRUCTION_ADDPAGE . '" title="' . _AM_INSTRUCTION_ADDPAGE . '"></a></td> |
| 106 | 106 | <td colspan="2"> |
| 107 | 107 | <input type="hidden" name="instrid" value="' . $objInsinstr->getVar('instrid') . '" /> |
@@ -112,52 +112,52 @@ discard block |
||
| 112 | 112 | </table> |
| 113 | 113 | </form>'; |
| 114 | 114 | |
| 115 | - return $ret; |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - // ================================== |
|
| 119 | - // === Дерево категорий в админке === |
|
| 120 | - // ================================== |
|
| 121 | - |
|
| 122 | - public function _makeCatsAdminOptions($key, &$ret, $prefix_orig, $cidinstrids = [], &$class = 'odd', $prefix_curr = '') |
|
| 123 | - { |
|
| 124 | - if ($key > 0) { |
|
| 125 | - |
|
| 126 | - // |
|
| 127 | - $class = ('even' == $class) ? 'odd' : 'even'; |
|
| 128 | - |
|
| 129 | - // ID категории |
|
| 130 | - $catid = $this->tree[$key]['obj']->getVar('cid'); |
|
| 131 | - // Название категории |
|
| 132 | - $cattitle = $this->tree[$key]['obj']->getVar('title'); |
|
| 133 | - // Вес |
|
| 134 | - $catweight = $this->tree[$key]['obj']->getVar('weight'); |
|
| 135 | - // Статус |
|
| 136 | - $pagestatus = $this->tree[$key]['obj']->getVar('status'); |
|
| 137 | - |
|
| 138 | - // Дочернии категории |
|
| 139 | - $cat_childs = $this->getAllChild($catid); |
|
| 140 | - // Число дочерних категорий |
|
| 141 | - $num_childs = count($cat_childs); |
|
| 142 | - // Число инструкций |
|
| 143 | - $num_instrs = isset($cidinstrids[$catid]) ? $cidinstrids[$catid] : 0; |
|
| 144 | - |
|
| 145 | - // Действие - удаление |
|
| 146 | - $act_del = (($num_instrs > 0) || ($num_childs > 0)) ? '<img src="../assets/icons/no_delete_mini.png" alt="' . _AM_INSTR_NODELCAT . '" title="' . _AM_INSTR_NODELCAT . '" />' : '<a href="cat.php?op=delcat&cid=' |
|
| 147 | - . $catid |
|
| 148 | - . '"><img src="../assets/icons/delete_mini.png" alt="' |
|
| 149 | - . _AM_INSTRUCTION_DEL |
|
| 150 | - . '" title="' |
|
| 151 | - . _AM_INSTRUCTION_DEL |
|
| 152 | - . '" /></a>'; |
|
| 153 | - // Действие - просмотр |
|
| 154 | - $act_view = ($num_instrs > 0) ? '<a href="instr.php?cid=' . $catid . '"><img src="../assets/icons/view_mini.png" alt="' . _AM_INSTR_VIEWINSTR . '" title="' . _AM_INSTR_VIEWINSTR . '" /></a>' : '<img src="../assets/icons/no_view_mini.png" alt="' |
|
| 155 | - . _AM_INSTR_NOVIEWINSTR |
|
| 156 | - . '" title="' |
|
| 157 | - . _AM_INSTR_NOVIEWINSTR |
|
| 158 | - . '" />'; |
|
| 159 | - |
|
| 160 | - $ret .= '<tr class="' . $class . '"> |
|
| 115 | + return $ret; |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + // ================================== |
|
| 119 | + // === Дерево категорий в админке === |
|
| 120 | + // ================================== |
|
| 121 | + |
|
| 122 | + public function _makeCatsAdminOptions($key, &$ret, $prefix_orig, $cidinstrids = [], &$class = 'odd', $prefix_curr = '') |
|
| 123 | + { |
|
| 124 | + if ($key > 0) { |
|
| 125 | + |
|
| 126 | + // |
|
| 127 | + $class = ('even' == $class) ? 'odd' : 'even'; |
|
| 128 | + |
|
| 129 | + // ID категории |
|
| 130 | + $catid = $this->tree[$key]['obj']->getVar('cid'); |
|
| 131 | + // Название категории |
|
| 132 | + $cattitle = $this->tree[$key]['obj']->getVar('title'); |
|
| 133 | + // Вес |
|
| 134 | + $catweight = $this->tree[$key]['obj']->getVar('weight'); |
|
| 135 | + // Статус |
|
| 136 | + $pagestatus = $this->tree[$key]['obj']->getVar('status'); |
|
| 137 | + |
|
| 138 | + // Дочернии категории |
|
| 139 | + $cat_childs = $this->getAllChild($catid); |
|
| 140 | + // Число дочерних категорий |
|
| 141 | + $num_childs = count($cat_childs); |
|
| 142 | + // Число инструкций |
|
| 143 | + $num_instrs = isset($cidinstrids[$catid]) ? $cidinstrids[$catid] : 0; |
|
| 144 | + |
|
| 145 | + // Действие - удаление |
|
| 146 | + $act_del = (($num_instrs > 0) || ($num_childs > 0)) ? '<img src="../assets/icons/no_delete_mini.png" alt="' . _AM_INSTR_NODELCAT . '" title="' . _AM_INSTR_NODELCAT . '" />' : '<a href="cat.php?op=delcat&cid=' |
|
| 147 | + . $catid |
|
| 148 | + . '"><img src="../assets/icons/delete_mini.png" alt="' |
|
| 149 | + . _AM_INSTRUCTION_DEL |
|
| 150 | + . '" title="' |
|
| 151 | + . _AM_INSTRUCTION_DEL |
|
| 152 | + . '" /></a>'; |
|
| 153 | + // Действие - просмотр |
|
| 154 | + $act_view = ($num_instrs > 0) ? '<a href="instr.php?cid=' . $catid . '"><img src="../assets/icons/view_mini.png" alt="' . _AM_INSTR_VIEWINSTR . '" title="' . _AM_INSTR_VIEWINSTR . '" /></a>' : '<img src="../assets/icons/no_view_mini.png" alt="' |
|
| 155 | + . _AM_INSTR_NOVIEWINSTR |
|
| 156 | + . '" title="' |
|
| 157 | + . _AM_INSTR_NOVIEWINSTR |
|
| 158 | + . '" />'; |
|
| 159 | + |
|
| 160 | + $ret .= '<tr class="' . $class . '"> |
|
| 161 | 161 | <td>' . $prefix_curr . ' <a href="' . XOOPS_URL . '/modules/' . INST_DIRNAME . '/index.php?cid=' . $catid . '">' . $cattitle . '</a></td> |
| 162 | 162 | <td align="center" width="50">' . $catweight . '</td> |
| 163 | 163 | <td align="center" width="100">' . $num_instrs . '</td> |
@@ -168,20 +168,20 @@ discard block |
||
| 168 | 168 | </td> |
| 169 | 169 | </tr>'; |
| 170 | 170 | |
| 171 | - // Устанавливаем префикс |
|
| 172 | - $prefix_curr .= $prefix_orig; |
|
| 173 | - } |
|
| 171 | + // Устанавливаем префикс |
|
| 172 | + $prefix_curr .= $prefix_orig; |
|
| 173 | + } |
|
| 174 | 174 | |
| 175 | - if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
| 176 | - foreach ($this->tree[$key]['child'] as $childkey) { |
|
| 177 | - $this->_makeCatsAdminOptions($childkey, $ret, $prefix_orig, $cidinstrids, $class, $prefix_curr); |
|
| 178 | - } |
|
| 179 | - } |
|
| 180 | - } |
|
| 175 | + if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
| 176 | + foreach ($this->tree[$key]['child'] as $childkey) { |
|
| 177 | + $this->_makeCatsAdminOptions($childkey, $ret, $prefix_orig, $cidinstrids, $class, $prefix_curr); |
|
| 178 | + } |
|
| 179 | + } |
|
| 180 | + } |
|
| 181 | 181 | |
| 182 | - public function makeCatsAdmin($prefix = '-', $cidinstrids = [], $key = 0) |
|
| 183 | - { |
|
| 184 | - $ret = '<table width="100%" cellspacing="1" class="outer"> |
|
| 182 | + public function makeCatsAdmin($prefix = '-', $cidinstrids = [], $key = 0) |
|
| 183 | + { |
|
| 184 | + $ret = '<table width="100%" cellspacing="1" class="outer"> |
|
| 185 | 185 | <tr> |
| 186 | 186 | <th align="center" colspan="4">' . _AM_INSTR_LISTALLCATS . '</th> |
| 187 | 187 | </tr> |
@@ -192,193 +192,193 @@ discard block |
||
| 192 | 192 | <td class="head" align="center" width="150">' . _AM_INSTRUCTION_ACTION . '</td> |
| 193 | 193 | </tr>'; |
| 194 | 194 | |
| 195 | - // Выводим все страницы |
|
| 196 | - $this->_makeCatsAdminOptions($key, $ret, $prefix, $cidinstrids); |
|
| 197 | - |
|
| 198 | - $ret .= '</table>'; |
|
| 199 | - |
|
| 200 | - return $ret; |
|
| 201 | - } |
|
| 202 | - |
|
| 203 | - // ====================================== |
|
| 204 | - // Список страниц на стороне пользователя |
|
| 205 | - // ====================================== |
|
| 206 | - |
|
| 207 | - public function _makePagesUserTree($key, &$ret, $currpageid = 0, &$lastpageids = [], $level = 0) |
|
| 208 | - { |
|
| 209 | - |
|
| 210 | - // Сохраняем значение предыдущей страницы |
|
| 211 | - //static $stat_prevpages; |
|
| 212 | - |
|
| 213 | - if ($key > 0) { |
|
| 214 | - |
|
| 215 | - // ID страницы |
|
| 216 | - $pageid = $this->tree[$key]['obj']->getVar('pageid'); |
|
| 217 | - // Название страницы |
|
| 218 | - $pagetitle = $this->tree[$key]['obj']->getVar('title'); |
|
| 219 | - // Тип страницы |
|
| 220 | - $pagetype = $this->tree[$key]['obj']->getVar('type'); |
|
| 221 | - |
|
| 222 | - // Дочернии категории |
|
| 223 | - $page_childs = $this->getAllChild($pageid); |
|
| 224 | - // Число дочерних страниц |
|
| 225 | - $num_childs = count($page_childs); |
|
| 226 | - |
|
| 227 | - // Генерируем класс |
|
| 228 | - // InstrTreeNode InstrTreeIsRoot InstrTreeExpandClosed InstrTreeIsLast |
|
| 229 | - $class = []; |
|
| 230 | - // Данный класс должен быть у любого узла |
|
| 231 | - $class[] = 'InstrTreeNode'; |
|
| 232 | - // Если узел нулевого уровня, добавляем InstrTreeIsRoot |
|
| 233 | - if (0 === $level) { |
|
| 234 | - $class[] = 'InstrTreeIsRoot'; |
|
| 235 | - } |
|
| 236 | - // Тип узла InstrTreeExpandClosed|InstrTreeExpandLeaf |
|
| 237 | - // Если у узла нет потомков - InstrTreeExpandLeaf |
|
| 238 | - if (0 == $num_childs) { |
|
| 239 | - $class[] = 'InstrTreeExpandLeaf'; |
|
| 240 | - // Если у искомого элемента есть потомки - открываем список |
|
| 241 | - } elseif ($currpageid == $pageid) { |
|
| 242 | - $class[] = 'InstrTreeExpandOpen'; |
|
| 243 | - // Если искомый элемент есть в потомках текущего, то ставим класс InstrTreeExpandOpen |
|
| 244 | - } elseif (in_array($currpageid, array_keys($page_childs))) { |
|
| 245 | - $class[] = 'InstrTreeExpandOpen'; |
|
| 246 | - // |
|
| 247 | - } else { |
|
| 248 | - $class[] = 'InstrTreeExpandClosed'; |
|
| 249 | - } |
|
| 250 | - |
|
| 251 | - // Данный класс нужно добавлять последнему узлу в каждом уровне |
|
| 252 | - |
|
| 253 | - if (isset($lastpageids[$level]) && ($pageid == $lastpageids[$level])) { |
|
| 254 | - $class[] = 'InstrTreeIsLast'; |
|
| 255 | - } |
|
| 256 | - |
|
| 257 | - //$class[] = 'InstrTreeIsLast'; |
|
| 258 | - |
|
| 259 | - // Test |
|
| 260 | - //$ret .= '<div id="' . $pageid . '">'; |
|
| 261 | - |
|
| 262 | - // Создаём запись |
|
| 263 | - $ret .= '<li class="' . implode(' ', $class) . '">'; |
|
| 264 | - // |
|
| 265 | - $ret .= '<div class="InstrTreeExpand"></div>'; |
|
| 266 | - // |
|
| 267 | - $ret .= '<div class="InstrTreeContent">'; |
|
| 268 | - |
|
| 269 | - // Если это лист дерева |
|
| 270 | - if (0 == $pagetype) { |
|
| 271 | - $ret .= '<span class="InstrTreeEmptyPage">' . $pagetitle . '</span>'; |
|
| 272 | - // |
|
| 273 | - } elseif ($currpageid == $pageid) { |
|
| 274 | - $ret .= $pagetitle; |
|
| 275 | - // |
|
| 276 | - } else { |
|
| 277 | - $ret .= '<a href="' . XOOPS_URL . '/modules/' . INST_DIRNAME . '/page.php?id=' . $pageid . '#pagetext">' . $pagetitle . '</a>'; |
|
| 278 | - } |
|
| 279 | - |
|
| 280 | - $ret .= '</div>'; |
|
| 281 | - |
|
| 282 | - // Если есть потомки |
|
| 283 | - if ($num_childs > 0) { |
|
| 284 | - $ret .= '<ul class="InstrTreeContainer">'; |
|
| 285 | - } |
|
| 286 | - |
|
| 287 | - // Инкримент уровня |
|
| 288 | - $level++; |
|
| 289 | - } |
|
| 290 | - |
|
| 291 | - // Рекурсия |
|
| 292 | - if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
| 293 | - foreach ($this->tree[$key]['child'] as $childkey) { |
|
| 294 | - $this->_makePagesUserTree($childkey, $ret, $currpageid, $lastpageids, $level); |
|
| 295 | - } |
|
| 296 | - } |
|
| 297 | - |
|
| 298 | - // Test |
|
| 299 | - if ($key > 0) { |
|
| 300 | - // Если есть потомки |
|
| 301 | - if ($num_childs > 0) { |
|
| 302 | - $ret .= '</ul>'; |
|
| 303 | - } |
|
| 304 | - // Конец текущей записи |
|
| 305 | - $ret .= '</li>'; |
|
| 306 | - } |
|
| 307 | - } |
|
| 308 | - |
|
| 309 | - // Находим предыдущую и следующую страницы. |
|
| 310 | - // Находим последнии страницы на каждом уровне. |
|
| 311 | - public function _makePagesUserCalc($key, $currpageid = 0, &$prevpages = [], &$nextpages = [], &$lastpageids = [], $level = 0) |
|
| 312 | - { |
|
| 313 | - |
|
| 314 | - // Сохраняем значение предыдущей страницы |
|
| 315 | - static $stat_prevpages; |
|
| 316 | - |
|
| 317 | - if ($key > 0) { |
|
| 318 | - // ID страницы |
|
| 319 | - $pageid = $this->tree[$key]['obj']->getVar('pageid'); |
|
| 320 | - // Название страницы |
|
| 321 | - $pagetitle = $this->tree[$key]['obj']->getVar('title'); |
|
| 322 | - // Тип страницы |
|
| 323 | - $pagetype = $this->tree[$key]['obj']->getVar('type'); |
|
| 324 | - |
|
| 325 | - // Если мы передали ID текущей страницы, то находить предыдудую и следующую страницы |
|
| 326 | - // Не находить предыдущие и следующие для "Пустой страницы" |
|
| 327 | - if ($currpageid && $pagetype) { |
|
| 328 | - // Если элемент равен текущей странице |
|
| 329 | - if (isset($stat_prevpages) && ($currpageid == $pageid)) { |
|
| 330 | - // Забиваем массив предыдущей страницы |
|
| 331 | - $prevpages['pageid'] = $stat_prevpages['pageid']; |
|
| 332 | - $prevpages['title'] = $stat_prevpages['title']; |
|
| 333 | - |
|
| 334 | - // Если предыдущий равен текущей странице |
|
| 335 | - } elseif (isset($stat_prevpages) && ($currpageid == $stat_prevpages['pageid'])) { |
|
| 336 | - // Забиваем массив следующей страницы |
|
| 337 | - $nextpages['pageid'] = $pageid; |
|
| 338 | - $nextpages['title'] = $pagetitle; |
|
| 339 | - } |
|
| 340 | - // Заносим текущие данные в массив предыдущей страницы |
|
| 341 | - $stat_prevpages['pageid'] = $pageid; |
|
| 342 | - $stat_prevpages['title'] = $pagetitle; |
|
| 343 | - } |
|
| 344 | - |
|
| 345 | - // Заносим текущую страницу в массив "последних страний" |
|
| 346 | - $lastpageids[$level] = $pageid; |
|
| 347 | - |
|
| 348 | - // Инкримент уровня |
|
| 349 | - $level++; |
|
| 350 | - } |
|
| 351 | - |
|
| 352 | - // Рекурсия |
|
| 353 | - if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
| 354 | - foreach ($this->tree[$key]['child'] as $childkey) { |
|
| 355 | - $this->_makePagesUserCalc($childkey, $currpageid, $prevpages, $nextpages, $lastpageids, $level); |
|
| 356 | - } |
|
| 357 | - } |
|
| 358 | - } |
|
| 359 | - |
|
| 360 | - // |
|
| 361 | - |
|
| 362 | - public function makePagesUser($currpageid = 0, &$prevpages = [], &$nextpages = [], $key = 0) |
|
| 363 | - { |
|
| 364 | - |
|
| 365 | - // Массив последней страницы на каждом уровне |
|
| 366 | - // level => pageid |
|
| 367 | - $lastpageids = []; |
|
| 368 | - |
|
| 369 | - // Расчёт |
|
| 370 | - $this->_makePagesUserCalc($key, $currpageid, $prevpages, $nextpages, $lastpageids); |
|
| 371 | - |
|
| 372 | - $ret = '<div onclick="instr_tree_toggle(arguments[0])"> |
|
| 195 | + // Выводим все страницы |
|
| 196 | + $this->_makeCatsAdminOptions($key, $ret, $prefix, $cidinstrids); |
|
| 197 | + |
|
| 198 | + $ret .= '</table>'; |
|
| 199 | + |
|
| 200 | + return $ret; |
|
| 201 | + } |
|
| 202 | + |
|
| 203 | + // ====================================== |
|
| 204 | + // Список страниц на стороне пользователя |
|
| 205 | + // ====================================== |
|
| 206 | + |
|
| 207 | + public function _makePagesUserTree($key, &$ret, $currpageid = 0, &$lastpageids = [], $level = 0) |
|
| 208 | + { |
|
| 209 | + |
|
| 210 | + // Сохраняем значение предыдущей страницы |
|
| 211 | + //static $stat_prevpages; |
|
| 212 | + |
|
| 213 | + if ($key > 0) { |
|
| 214 | + |
|
| 215 | + // ID страницы |
|
| 216 | + $pageid = $this->tree[$key]['obj']->getVar('pageid'); |
|
| 217 | + // Название страницы |
|
| 218 | + $pagetitle = $this->tree[$key]['obj']->getVar('title'); |
|
| 219 | + // Тип страницы |
|
| 220 | + $pagetype = $this->tree[$key]['obj']->getVar('type'); |
|
| 221 | + |
|
| 222 | + // Дочернии категории |
|
| 223 | + $page_childs = $this->getAllChild($pageid); |
|
| 224 | + // Число дочерних страниц |
|
| 225 | + $num_childs = count($page_childs); |
|
| 226 | + |
|
| 227 | + // Генерируем класс |
|
| 228 | + // InstrTreeNode InstrTreeIsRoot InstrTreeExpandClosed InstrTreeIsLast |
|
| 229 | + $class = []; |
|
| 230 | + // Данный класс должен быть у любого узла |
|
| 231 | + $class[] = 'InstrTreeNode'; |
|
| 232 | + // Если узел нулевого уровня, добавляем InstrTreeIsRoot |
|
| 233 | + if (0 === $level) { |
|
| 234 | + $class[] = 'InstrTreeIsRoot'; |
|
| 235 | + } |
|
| 236 | + // Тип узла InstrTreeExpandClosed|InstrTreeExpandLeaf |
|
| 237 | + // Если у узла нет потомков - InstrTreeExpandLeaf |
|
| 238 | + if (0 == $num_childs) { |
|
| 239 | + $class[] = 'InstrTreeExpandLeaf'; |
|
| 240 | + // Если у искомого элемента есть потомки - открываем список |
|
| 241 | + } elseif ($currpageid == $pageid) { |
|
| 242 | + $class[] = 'InstrTreeExpandOpen'; |
|
| 243 | + // Если искомый элемент есть в потомках текущего, то ставим класс InstrTreeExpandOpen |
|
| 244 | + } elseif (in_array($currpageid, array_keys($page_childs))) { |
|
| 245 | + $class[] = 'InstrTreeExpandOpen'; |
|
| 246 | + // |
|
| 247 | + } else { |
|
| 248 | + $class[] = 'InstrTreeExpandClosed'; |
|
| 249 | + } |
|
| 250 | + |
|
| 251 | + // Данный класс нужно добавлять последнему узлу в каждом уровне |
|
| 252 | + |
|
| 253 | + if (isset($lastpageids[$level]) && ($pageid == $lastpageids[$level])) { |
|
| 254 | + $class[] = 'InstrTreeIsLast'; |
|
| 255 | + } |
|
| 256 | + |
|
| 257 | + //$class[] = 'InstrTreeIsLast'; |
|
| 258 | + |
|
| 259 | + // Test |
|
| 260 | + //$ret .= '<div id="' . $pageid . '">'; |
|
| 261 | + |
|
| 262 | + // Создаём запись |
|
| 263 | + $ret .= '<li class="' . implode(' ', $class) . '">'; |
|
| 264 | + // |
|
| 265 | + $ret .= '<div class="InstrTreeExpand"></div>'; |
|
| 266 | + // |
|
| 267 | + $ret .= '<div class="InstrTreeContent">'; |
|
| 268 | + |
|
| 269 | + // Если это лист дерева |
|
| 270 | + if (0 == $pagetype) { |
|
| 271 | + $ret .= '<span class="InstrTreeEmptyPage">' . $pagetitle . '</span>'; |
|
| 272 | + // |
|
| 273 | + } elseif ($currpageid == $pageid) { |
|
| 274 | + $ret .= $pagetitle; |
|
| 275 | + // |
|
| 276 | + } else { |
|
| 277 | + $ret .= '<a href="' . XOOPS_URL . '/modules/' . INST_DIRNAME . '/page.php?id=' . $pageid . '#pagetext">' . $pagetitle . '</a>'; |
|
| 278 | + } |
|
| 279 | + |
|
| 280 | + $ret .= '</div>'; |
|
| 281 | + |
|
| 282 | + // Если есть потомки |
|
| 283 | + if ($num_childs > 0) { |
|
| 284 | + $ret .= '<ul class="InstrTreeContainer">'; |
|
| 285 | + } |
|
| 286 | + |
|
| 287 | + // Инкримент уровня |
|
| 288 | + $level++; |
|
| 289 | + } |
|
| 290 | + |
|
| 291 | + // Рекурсия |
|
| 292 | + if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
| 293 | + foreach ($this->tree[$key]['child'] as $childkey) { |
|
| 294 | + $this->_makePagesUserTree($childkey, $ret, $currpageid, $lastpageids, $level); |
|
| 295 | + } |
|
| 296 | + } |
|
| 297 | + |
|
| 298 | + // Test |
|
| 299 | + if ($key > 0) { |
|
| 300 | + // Если есть потомки |
|
| 301 | + if ($num_childs > 0) { |
|
| 302 | + $ret .= '</ul>'; |
|
| 303 | + } |
|
| 304 | + // Конец текущей записи |
|
| 305 | + $ret .= '</li>'; |
|
| 306 | + } |
|
| 307 | + } |
|
| 308 | + |
|
| 309 | + // Находим предыдущую и следующую страницы. |
|
| 310 | + // Находим последнии страницы на каждом уровне. |
|
| 311 | + public function _makePagesUserCalc($key, $currpageid = 0, &$prevpages = [], &$nextpages = [], &$lastpageids = [], $level = 0) |
|
| 312 | + { |
|
| 313 | + |
|
| 314 | + // Сохраняем значение предыдущей страницы |
|
| 315 | + static $stat_prevpages; |
|
| 316 | + |
|
| 317 | + if ($key > 0) { |
|
| 318 | + // ID страницы |
|
| 319 | + $pageid = $this->tree[$key]['obj']->getVar('pageid'); |
|
| 320 | + // Название страницы |
|
| 321 | + $pagetitle = $this->tree[$key]['obj']->getVar('title'); |
|
| 322 | + // Тип страницы |
|
| 323 | + $pagetype = $this->tree[$key]['obj']->getVar('type'); |
|
| 324 | + |
|
| 325 | + // Если мы передали ID текущей страницы, то находить предыдудую и следующую страницы |
|
| 326 | + // Не находить предыдущие и следующие для "Пустой страницы" |
|
| 327 | + if ($currpageid && $pagetype) { |
|
| 328 | + // Если элемент равен текущей странице |
|
| 329 | + if (isset($stat_prevpages) && ($currpageid == $pageid)) { |
|
| 330 | + // Забиваем массив предыдущей страницы |
|
| 331 | + $prevpages['pageid'] = $stat_prevpages['pageid']; |
|
| 332 | + $prevpages['title'] = $stat_prevpages['title']; |
|
| 333 | + |
|
| 334 | + // Если предыдущий равен текущей странице |
|
| 335 | + } elseif (isset($stat_prevpages) && ($currpageid == $stat_prevpages['pageid'])) { |
|
| 336 | + // Забиваем массив следующей страницы |
|
| 337 | + $nextpages['pageid'] = $pageid; |
|
| 338 | + $nextpages['title'] = $pagetitle; |
|
| 339 | + } |
|
| 340 | + // Заносим текущие данные в массив предыдущей страницы |
|
| 341 | + $stat_prevpages['pageid'] = $pageid; |
|
| 342 | + $stat_prevpages['title'] = $pagetitle; |
|
| 343 | + } |
|
| 344 | + |
|
| 345 | + // Заносим текущую страницу в массив "последних страний" |
|
| 346 | + $lastpageids[$level] = $pageid; |
|
| 347 | + |
|
| 348 | + // Инкримент уровня |
|
| 349 | + $level++; |
|
| 350 | + } |
|
| 351 | + |
|
| 352 | + // Рекурсия |
|
| 353 | + if (isset($this->tree[$key]['child']) && !empty($this->tree[$key]['child'])) { |
|
| 354 | + foreach ($this->tree[$key]['child'] as $childkey) { |
|
| 355 | + $this->_makePagesUserCalc($childkey, $currpageid, $prevpages, $nextpages, $lastpageids, $level); |
|
| 356 | + } |
|
| 357 | + } |
|
| 358 | + } |
|
| 359 | + |
|
| 360 | + // |
|
| 361 | + |
|
| 362 | + public function makePagesUser($currpageid = 0, &$prevpages = [], &$nextpages = [], $key = 0) |
|
| 363 | + { |
|
| 364 | + |
|
| 365 | + // Массив последней страницы на каждом уровне |
|
| 366 | + // level => pageid |
|
| 367 | + $lastpageids = []; |
|
| 368 | + |
|
| 369 | + // Расчёт |
|
| 370 | + $this->_makePagesUserCalc($key, $currpageid, $prevpages, $nextpages, $lastpageids); |
|
| 371 | + |
|
| 372 | + $ret = '<div onclick="instr_tree_toggle(arguments[0])"> |
|
| 373 | 373 | <div>' . _MD_INSTRUCTION_LISTPAGES . '</div> |
| 374 | 374 | <div><ul class="InstrTreeContainer">'; |
| 375 | 375 | |
| 376 | - // Генерируем дерево |
|
| 377 | - $this->_makePagesUserTree($key, $ret, $currpageid, $lastpageids); |
|
| 376 | + // Генерируем дерево |
|
| 377 | + $this->_makePagesUserTree($key, $ret, $currpageid, $lastpageids); |
|
| 378 | 378 | |
| 379 | - $ret .= '</ul> |
|
| 379 | + $ret .= '</ul> |
|
| 380 | 380 | </div>'; |
| 381 | 381 | |
| 382 | - return $ret; |
|
| 383 | - } |
|
| 382 | + return $ret; |
|
| 383 | + } |
|
| 384 | 384 | } |
@@ -21,9 +21,9 @@ discard block |
||
| 21 | 21 | // Стили |
| 22 | 22 | $xoTheme->addStylesheet(XOOPS_URL . '/modules/' . $moduleDirName . '/assets/css/style.css'); |
| 23 | 23 | // |
| 24 | -$cid = isset($_GET['cid']) ? (int)$_GET['cid'] : 0; |
|
| 24 | +$cid = isset($_GET['cid']) ? (int) $_GET['cid'] : 0; |
|
| 25 | 25 | // |
| 26 | -$start = isset($_GET['start']) ? (int)$_GET['start'] : 0; |
|
| 26 | +$start = isset($_GET['start']) ? (int) $_GET['start'] : 0; |
|
| 27 | 27 | // |
| 28 | 28 | $limit = xoops_getModuleOption('perpagemain', 'instruction'); |
| 29 | 29 | // Права на просмотр |
@@ -52,7 +52,7 @@ discard block |
||
| 52 | 52 | // Если есть категория |
| 53 | 53 | if ($cid) { |
| 54 | 54 | // Если нельзя просматривать эту категорию |
| 55 | - if (!in_array($cid, $categories)) { |
|
| 55 | + if ( ! in_array($cid, $categories)) { |
|
| 56 | 56 | redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_CAT); |
| 57 | 57 | } |
| 58 | 58 | $criteria->add(new Criteria('cid', $cid, '=')); |
@@ -51,11 +51,11 @@ discard block |
||
| 51 | 51 | $module = $moduleHelper->getModule(); |
| 52 | 52 | |
| 53 | 53 | if (InstructionUtility::checkVerXoops($module, '2.5.9')) { |
| 54 | - $cat_select = $mytree->makeSelectElement('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'", ''); |
|
| 55 | - $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select->render()); |
|
| 54 | + $cat_select = $mytree->makeSelectElement('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'", ''); |
|
| 55 | + $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select->render()); |
|
| 56 | 56 | } else { |
| 57 | - $cat_select = $mytree->makeSelBox('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'"); |
|
| 58 | - $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select); |
|
| 57 | + $cat_select = $mytree->makeSelBox('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'"); |
|
| 58 | + $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select); |
|
| 59 | 59 | } |
| 60 | 60 | |
| 61 | 61 | // Находим список всех инструкций |
@@ -65,14 +65,14 @@ discard block |
||
| 65 | 65 | $criteria->add(new Criteria('status', '0', '>')); |
| 66 | 66 | // Если есть категория |
| 67 | 67 | if ($cid) { |
| 68 | - // Если нельзя просматривать эту категорию |
|
| 69 | - if (!in_array($cid, $categories)) { |
|
| 70 | - redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_CAT); |
|
| 71 | - } |
|
| 72 | - $criteria->add(new Criteria('cid', $cid, '=')); |
|
| 73 | - // Иначе находим список всех |
|
| 68 | + // Если нельзя просматривать эту категорию |
|
| 69 | + if (!in_array($cid, $categories)) { |
|
| 70 | + redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_CAT); |
|
| 71 | + } |
|
| 72 | + $criteria->add(new Criteria('cid', $cid, '=')); |
|
| 73 | + // Иначе находим список всех |
|
| 74 | 74 | } else { |
| 75 | - $criteria->add(new Criteria('cid', '( ' . implode(', ', $categories) . ' )', 'IN')); |
|
| 75 | + $criteria->add(new Criteria('cid', '( ' . implode(', ', $categories) . ' )', 'IN')); |
|
| 76 | 76 | } |
| 77 | 77 | |
| 78 | 78 | // Число инструкций, удовлетворяющих данному условию |
@@ -89,10 +89,10 @@ discard block |
||
| 89 | 89 | $instr_arr = $insinstrHandler->getall($criteria); |
| 90 | 90 | // Если записей больше чем $limit, то выводим пагинатор |
| 91 | 91 | if ($numrows > $limit) { |
| 92 | - $pagenav = new XoopsPageNav($numrows, $limit, $start, 'start', 'cid=' . $cid); |
|
| 93 | - $pagenav = $pagenav->renderNav(4); |
|
| 92 | + $pagenav = new XoopsPageNav($numrows, $limit, $start, 'start', 'cid=' . $cid); |
|
| 93 | + $pagenav = $pagenav->renderNav(4); |
|
| 94 | 94 | } else { |
| 95 | - $pagenav = ''; |
|
| 95 | + $pagenav = ''; |
|
| 96 | 96 | } |
| 97 | 97 | // Выводим пагинатор в шаблон |
| 98 | 98 | $GLOBALS['xoopsTpl']->assign('insPagenav', $pagenav); |
@@ -103,52 +103,52 @@ discard block |
||
| 103 | 103 | |
| 104 | 104 | // Если есть записи |
| 105 | 105 | if ($numrows > 0) { |
| 106 | - $class = 'odd'; |
|
| 107 | - foreach (array_keys($instr_arr) as $i) { |
|
| 108 | - |
|
| 109 | - // |
|
| 110 | - $class = ('even' == $class) ? 'odd' : 'even'; |
|
| 111 | - // ID |
|
| 112 | - $insinstr_instrid = $instr_arr[$i]->getVar('instrid'); |
|
| 113 | - // Название |
|
| 114 | - $insinstr_title = $instr_arr[$i]->getVar('title'); |
|
| 115 | - // Статус |
|
| 116 | - $insinstr_status = $instr_arr[$i]->getVar('status'); |
|
| 117 | - // Количество страниц |
|
| 118 | - $insinstr_pages = $instr_arr[$i]->getVar('pages'); |
|
| 119 | - // Категория |
|
| 120 | - $insinstr_cid = $instr_arr[$i]->getVar('cid'); |
|
| 121 | - $insinstr_cat = $inscatHandler->get($insinstr_cid); |
|
| 122 | - // Права на добавление |
|
| 123 | - $perm_submit = in_array($insinstr_cid, $cat_submit) ? true : false; |
|
| 124 | - // Права на редактирование |
|
| 125 | - $perm_edit = in_array($insinstr_cid, $cat_edit) ? true : false; |
|
| 126 | - //Мета-теги ключевых слов |
|
| 127 | - $insinstr_metakeywords = $instr_arr[$i]->getVar('metakeywords'); |
|
| 128 | - // Если есть - добавляем в мета-теги страницы |
|
| 129 | - if ($insinstr_metakeywords) { |
|
| 130 | - $index_metakeywords[] = $insinstr_metakeywords; |
|
| 131 | - } |
|
| 132 | - // Мета-теги описания |
|
| 133 | - $insinstr_metadescript = $instr_arr[$i]->getVar('metadescription'); |
|
| 134 | - // Если есть - добавляем в мета-теги страницы |
|
| 135 | - if ($insinstr_metadescript) { |
|
| 136 | - $index_metadescript[] = $insinstr_metadescript; |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - // Выводим в шаблон |
|
| 140 | - $GLOBALS['xoopsTpl']->append('insListInstr', ['instrid' => $insinstr_instrid, 'title' => $insinstr_title, 'status' => $insinstr_status, 'pages' => $insinstr_pages, 'ctitle' => $insinstr_cat->getVar('title'), 'cid' => $insinstr_cid, 'permsubmit' => $perm_submit, 'permedit' => $perm_edit, 'class' => $class]); |
|
| 141 | - } |
|
| 142 | - |
|
| 143 | - // Языковые константы |
|
| 106 | + $class = 'odd'; |
|
| 107 | + foreach (array_keys($instr_arr) as $i) { |
|
| 108 | + |
|
| 109 | + // |
|
| 110 | + $class = ('even' == $class) ? 'odd' : 'even'; |
|
| 111 | + // ID |
|
| 112 | + $insinstr_instrid = $instr_arr[$i]->getVar('instrid'); |
|
| 113 | + // Название |
|
| 114 | + $insinstr_title = $instr_arr[$i]->getVar('title'); |
|
| 115 | + // Статус |
|
| 116 | + $insinstr_status = $instr_arr[$i]->getVar('status'); |
|
| 117 | + // Количество страниц |
|
| 118 | + $insinstr_pages = $instr_arr[$i]->getVar('pages'); |
|
| 119 | + // Категория |
|
| 120 | + $insinstr_cid = $instr_arr[$i]->getVar('cid'); |
|
| 121 | + $insinstr_cat = $inscatHandler->get($insinstr_cid); |
|
| 122 | + // Права на добавление |
|
| 123 | + $perm_submit = in_array($insinstr_cid, $cat_submit) ? true : false; |
|
| 124 | + // Права на редактирование |
|
| 125 | + $perm_edit = in_array($insinstr_cid, $cat_edit) ? true : false; |
|
| 126 | + //Мета-теги ключевых слов |
|
| 127 | + $insinstr_metakeywords = $instr_arr[$i]->getVar('metakeywords'); |
|
| 128 | + // Если есть - добавляем в мета-теги страницы |
|
| 129 | + if ($insinstr_metakeywords) { |
|
| 130 | + $index_metakeywords[] = $insinstr_metakeywords; |
|
| 131 | + } |
|
| 132 | + // Мета-теги описания |
|
| 133 | + $insinstr_metadescript = $instr_arr[$i]->getVar('metadescription'); |
|
| 134 | + // Если есть - добавляем в мета-теги страницы |
|
| 135 | + if ($insinstr_metadescript) { |
|
| 136 | + $index_metadescript[] = $insinstr_metadescript; |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + // Выводим в шаблон |
|
| 140 | + $GLOBALS['xoopsTpl']->append('insListInstr', ['instrid' => $insinstr_instrid, 'title' => $insinstr_title, 'status' => $insinstr_status, 'pages' => $insinstr_pages, 'ctitle' => $insinstr_cat->getVar('title'), 'cid' => $insinstr_cid, 'permsubmit' => $perm_submit, 'permedit' => $perm_edit, 'class' => $class]); |
|
| 141 | + } |
|
| 142 | + |
|
| 143 | + // Языковые константы |
|
| 144 | 144 | } |
| 145 | 145 | |
| 146 | 146 | // Если есть мета-теги |
| 147 | 147 | if (count($index_metakeywords)) { |
| 148 | - $xoTheme->addMeta('meta', 'keywords', implode(', ', $index_metakeywords)); |
|
| 148 | + $xoTheme->addMeta('meta', 'keywords', implode(', ', $index_metakeywords)); |
|
| 149 | 149 | } |
| 150 | 150 | if (count($index_metadescript)) { |
| 151 | - $xoTheme->addMeta('meta', 'description', implode(', ', $index_metadescript)); |
|
| 151 | + $xoTheme->addMeta('meta', 'description', implode(', ', $index_metadescript)); |
|
| 152 | 152 | } |
| 153 | 153 | |
| 154 | 154 | // Подвал |
@@ -7,12 +7,12 @@ |
||
| 7 | 7 | |
| 8 | 8 | $com_itemid = Request::getInt('com_itemid', 0, 'GET'); |
| 9 | 9 | if ($com_itemid > 0) { |
| 10 | - $itemObj = $publisher->getHandler('item')->get($com_itemid); |
|
| 11 | - $com_replytext = _POSTEDBY . ' <strong>' . $itemObj->getLinkedPosterName() . '</strong> ' . _DATE . ' <strong>' . $itemObj->dateSub() . '</strong><br><br>' . $itemObj->summary(); |
|
| 12 | - $bodytext = $itemObj->body(); |
|
| 13 | - if ('' != $bodytext) { |
|
| 14 | - $com_replytext .= '<br><br>' . $bodytext . ''; |
|
| 15 | - } |
|
| 16 | - $com_replytitle = $itemObj->getTitle(); |
|
| 17 | - include_once $GLOBALS['xoops']->path('include/comment_new.php'); |
|
| 10 | + $itemObj = $publisher->getHandler('item')->get($com_itemid); |
|
| 11 | + $com_replytext = _POSTEDBY . ' <strong>' . $itemObj->getLinkedPosterName() . '</strong> ' . _DATE . ' <strong>' . $itemObj->dateSub() . '</strong><br><br>' . $itemObj->summary(); |
|
| 12 | + $bodytext = $itemObj->body(); |
|
| 13 | + if ('' != $bodytext) { |
|
| 14 | + $com_replytext .= '<br><br>' . $bodytext . ''; |
|
| 15 | + } |
|
| 16 | + $com_replytitle = $itemObj->getTitle(); |
|
| 17 | + include_once $GLOBALS['xoops']->path('include/comment_new.php'); |
|
| 18 | 18 | } |