Completed
Push — master ( 5fe85d...a4e09c )
by Michael
01:40
created
class/utility.php 2 patches
Unused Use Statements   -1 removed lines patch added patch discarded remove patch
@@ -1,6 +1,5 @@
 block discarded – undo
1 1
 <?php
2 2
 
3
-use Xmf\Request;
4 3
 use Xoopsmodules\instruction\common;
5 4
 
6 5
 require_once __DIR__ . '/common/traitversionchecks.php';
Please login to merge, or discard this patch.
Indentation   +53 added lines, -53 removed lines patch added patch discarded remove patch
@@ -14,63 +14,63 @@
 block discarded – undo
14 14
  */
15 15
 class InstructionUtility
16 16
 {
17
-    use common\VersionChecks; //checkVerXoops, checkVerPhp Traits
17
+	use common\VersionChecks; //checkVerXoops, checkVerPhp Traits
18 18
 
19
-    use common\ServerStats; // getServerStats Trait
19
+	use common\ServerStats; // getServerStats Trait
20 20
 
21
-    use common\FilesManagement; // Files Management Trait
21
+	use common\FilesManagement; // Files Management Trait
22 22
 
23
-    // Права
24
-    public static function getItemIds($permtype = 'instruction_view')
25
-    {
26
-        //global $xoopsUser;
27
-        static $permissions = [];
28
-        // Если есть в статике
29
-        if (is_array($permissions) && array_key_exists($permtype, $permissions)) {
30
-            return $permissions[$permtype];
31
-        }
32
-        // Находим из базы
33
-        $moduleHandler          = xoops_getHandler('module');
34
-        $instrModule            = $moduleHandler->getByDirname('instruction');
35
-        $groups                 = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS;
36
-        $gpermHandler           = xoops_getHandler('groupperm');
37
-        $categories             = $gpermHandler->getItemIds($permtype, $groups, $instrModule->getVar('mid'));
38
-        $permissions[$permtype] = $categories;
39
-        return $categories;
40
-    }
23
+	// Права
24
+	public static function getItemIds($permtype = 'instruction_view')
25
+	{
26
+		//global $xoopsUser;
27
+		static $permissions = [];
28
+		// Если есть в статике
29
+		if (is_array($permissions) && array_key_exists($permtype, $permissions)) {
30
+			return $permissions[$permtype];
31
+		}
32
+		// Находим из базы
33
+		$moduleHandler          = xoops_getHandler('module');
34
+		$instrModule            = $moduleHandler->getByDirname('instruction');
35
+		$groups                 = is_object($GLOBALS['xoopsUser']) ? $GLOBALS['xoopsUser']->getGroups() : XOOPS_GROUP_ANONYMOUS;
36
+		$gpermHandler           = xoops_getHandler('groupperm');
37
+		$categories             = $gpermHandler->getItemIds($permtype, $groups, $instrModule->getVar('mid'));
38
+		$permissions[$permtype] = $categories;
39
+		return $categories;
40
+	}
41 41
 
42
-    // Редактор
43
-    public static function getWysiwygForm($caption, $name, $value = '')
44
-    {
45
-        $editor                   = false;
46
-        $editor_configs           = [];
47
-        $editor_configs['name']   = $name;
48
-        $editor_configs['value']  = $value;
49
-        $editor_configs['rows']   = 35;
50
-        $editor_configs['cols']   = 60;
51
-        $editor_configs['width']  = '100%';
52
-        $editor_configs['height'] = '350px';
53
-        $editor_configs['editor'] = strtolower(xoops_getModuleOption('form_options', 'instruction'));
42
+	// Редактор
43
+	public static function getWysiwygForm($caption, $name, $value = '')
44
+	{
45
+		$editor                   = false;
46
+		$editor_configs           = [];
47
+		$editor_configs['name']   = $name;
48
+		$editor_configs['value']  = $value;
49
+		$editor_configs['rows']   = 35;
50
+		$editor_configs['cols']   = 60;
51
+		$editor_configs['width']  = '100%';
52
+		$editor_configs['height'] = '350px';
53
+		$editor_configs['editor'] = strtolower(xoops_getModuleOption('form_options', 'instruction'));
54 54
 
55
-        $editor = new XoopsFormEditor($caption, $name, $editor_configs);
56
-        return $editor;
57
-    }
55
+		$editor = new XoopsFormEditor($caption, $name, $editor_configs);
56
+		return $editor;
57
+	}
58 58
 
59
-    // Получение значения переменной, переданной через GET или POST запрос
60
-    public static function cleanVars(&$global, $key, $default = '', $type = 'int')
61
-    {
62
-        switch ($type) {
63
-            case 'string':
64
-                $ret = isset($global[$key]) ? $global[$key] : $default;
65
-                break;
66
-            case 'int':
67
-            default:
68
-                $ret = isset($global[$key]) ? (int)$global[$key] : (int)$default;
69
-                break;
70
-        }
71
-        if (false === $ret) {
72
-            return $default;
73
-        }
74
-        return $ret;
75
-    }
59
+	// Получение значения переменной, переданной через GET или POST запрос
60
+	public static function cleanVars(&$global, $key, $default = '', $type = 'int')
61
+	{
62
+		switch ($type) {
63
+			case 'string':
64
+				$ret = isset($global[$key]) ? $global[$key] : $default;
65
+				break;
66
+			case 'int':
67
+			default:
68
+				$ret = isset($global[$key]) ? (int)$global[$key] : (int)$default;
69
+				break;
70
+		}
71
+		if (false === $ret) {
72
+			return $default;
73
+		}
74
+		return $ret;
75
+	}
76 76
 }
Please login to merge, or discard this patch.
index.php 1 patch
Indentation   +54 added lines, -54 removed lines patch added patch discarded remove patch
@@ -55,11 +55,11 @@  discard block
 block discarded – undo
55 55
 
56 56
 
57 57
 if (InstructionUtility::checkVerXoops($module1, '2.5.9')) {
58
-    $cat_select = $mytree->makeSelectElement('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'", '');
59
-    $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select->render());
58
+	$cat_select = $mytree->makeSelectElement('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'", '');
59
+	$GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select->render());
60 60
 } else {
61
-    $cat_select = $mytree->makeSelBox('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'");
62
-    $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select);
61
+	$cat_select = $mytree->makeSelBox('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'");
62
+	$GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select);
63 63
 }
64 64
 
65 65
 // Находим список всех инструкций
@@ -69,14 +69,14 @@  discard block
 block discarded – undo
69 69
 $criteria->add(new Criteria('status', '0', '>'));
70 70
 // Если есть категория
71 71
 if ($cid) {
72
-    // Если нельзя просматривать эту категорию
73
-    if (!in_array($cid, $categories)) {
74
-        redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_CAT);
75
-    }
76
-    $criteria->add(new Criteria('cid', $cid, '='));
77
-    // Иначе находим список всех
72
+	// Если нельзя просматривать эту категорию
73
+	if (!in_array($cid, $categories)) {
74
+		redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_CAT);
75
+	}
76
+	$criteria->add(new Criteria('cid', $cid, '='));
77
+	// Иначе находим список всех
78 78
 } else {
79
-    $criteria->add(new Criteria('cid', '( ' . implode(', ', $categories) . ' )', 'IN'));
79
+	$criteria->add(new Criteria('cid', '( ' . implode(', ', $categories) . ' )', 'IN'));
80 80
 }
81 81
 
82 82
 // Число инструкций, удовлетворяющих данному условию
@@ -93,10 +93,10 @@  discard block
 block discarded – undo
93 93
 $instr_arr = $insinstrHandler->getall($criteria);
94 94
 // Если записей больше чем $limit, то выводим пагинатор
95 95
 if ($numrows > $limit) {
96
-    $pagenav = new XoopsPageNav($numrows, $limit, $start, 'start', 'cid=' . $cid);
97
-    $pagenav = $pagenav->renderNav(4);
96
+	$pagenav = new XoopsPageNav($numrows, $limit, $start, 'start', 'cid=' . $cid);
97
+	$pagenav = $pagenav->renderNav(4);
98 98
 } else {
99
-    $pagenav = '';
99
+	$pagenav = '';
100 100
 }
101 101
 // Выводим пагинатор в шаблон
102 102
 $GLOBALS['xoopsTpl']->assign('insPagenav', $pagenav);
@@ -107,52 +107,52 @@  discard block
 block discarded – undo
107 107
 
108 108
 // Если есть записи
109 109
 if ($numrows > 0) {
110
-    $class = 'odd';
111
-    foreach (array_keys($instr_arr) as $i) {
112
-
113
-        //
114
-        $class = ('even' == $class) ? 'odd' : 'even';
115
-        // ID
116
-        $insinstr_instrid = $instr_arr[$i]->getVar('instrid');
117
-        // Название
118
-        $insinstr_title = $instr_arr[$i]->getVar('title');
119
-        // Статус
120
-        $insinstr_status = $instr_arr[$i]->getVar('status');
121
-        // Количество страниц
122
-        $insinstr_pages = $instr_arr[$i]->getVar('pages');
123
-        // Категория
124
-        $insinstr_cid = $instr_arr[$i]->getVar('cid');
125
-        $insinstr_cat = $inscatHandler->get($insinstr_cid);
126
-        // Права на добавление
127
-        $perm_submit = in_array($insinstr_cid, $cat_submit) ? true : false;
128
-        // Права на редактирование
129
-        $perm_edit = in_array($insinstr_cid, $cat_edit) ? true : false;
130
-        //Мета-теги ключевых слов
131
-        $insinstr_metakeywords = $instr_arr[$i]->getVar('metakeywords');
132
-        // Если есть - добавляем в мета-теги страницы
133
-        if ($insinstr_metakeywords) {
134
-            $index_metakeywords[] = $insinstr_metakeywords;
135
-        }
136
-        // Мета-теги описания
137
-        $insinstr_metadescript = $instr_arr[$i]->getVar('metadescription');
138
-        // Если есть - добавляем в мета-теги страницы
139
-        if ($insinstr_metadescript) {
140
-            $index_metadescript[] = $insinstr_metadescript;
141
-        }
142
-
143
-        // Выводим в шаблон
144
-        $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]);
145
-    }
146
-
147
-    // Языковые константы
110
+	$class = 'odd';
111
+	foreach (array_keys($instr_arr) as $i) {
112
+
113
+		//
114
+		$class = ('even' == $class) ? 'odd' : 'even';
115
+		// ID
116
+		$insinstr_instrid = $instr_arr[$i]->getVar('instrid');
117
+		// Название
118
+		$insinstr_title = $instr_arr[$i]->getVar('title');
119
+		// Статус
120
+		$insinstr_status = $instr_arr[$i]->getVar('status');
121
+		// Количество страниц
122
+		$insinstr_pages = $instr_arr[$i]->getVar('pages');
123
+		// Категория
124
+		$insinstr_cid = $instr_arr[$i]->getVar('cid');
125
+		$insinstr_cat = $inscatHandler->get($insinstr_cid);
126
+		// Права на добавление
127
+		$perm_submit = in_array($insinstr_cid, $cat_submit) ? true : false;
128
+		// Права на редактирование
129
+		$perm_edit = in_array($insinstr_cid, $cat_edit) ? true : false;
130
+		//Мета-теги ключевых слов
131
+		$insinstr_metakeywords = $instr_arr[$i]->getVar('metakeywords');
132
+		// Если есть - добавляем в мета-теги страницы
133
+		if ($insinstr_metakeywords) {
134
+			$index_metakeywords[] = $insinstr_metakeywords;
135
+		}
136
+		// Мета-теги описания
137
+		$insinstr_metadescript = $instr_arr[$i]->getVar('metadescription');
138
+		// Если есть - добавляем в мета-теги страницы
139
+		if ($insinstr_metadescript) {
140
+			$index_metadescript[] = $insinstr_metadescript;
141
+		}
142
+
143
+		// Выводим в шаблон
144
+		$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]);
145
+	}
146
+
147
+	// Языковые константы
148 148
 }
149 149
 
150 150
 // Если есть мета-теги
151 151
 if (count($index_metakeywords)) {
152
-    $xoTheme->addMeta('meta', 'keywords', implode(', ', $index_metakeywords));
152
+	$xoTheme->addMeta('meta', 'keywords', implode(', ', $index_metakeywords));
153 153
 }
154 154
 if (count($index_metadescript)) {
155
-    $xoTheme->addMeta('meta', 'description', implode(', ', $index_metadescript));
155
+	$xoTheme->addMeta('meta', 'description', implode(', ', $index_metadescript));
156 156
 }
157 157
 
158 158
 // Подвал
Please login to merge, or discard this patch.
class/common/traitversionchecks.php 1 patch
Indentation   +69 added lines, -69 removed lines patch added patch discarded remove patch
@@ -16,77 +16,77 @@
 block discarded – undo
16 16
  */
17 17
 trait VersionChecks
18 18
 {
19
-    /**
20
-     *
21
-     * Verifies XOOPS version meets minimum requirements for this module
22
-     * @static
23
-     * @param \XoopsModule|null $module
24
-     *
25
-     * @param null|string $requiredVer
26
-     * @return bool true if meets requirements, false if not
27
-     */
28
-    public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null)
29
-    {
30
-        $moduleDirName = basename(dirname(dirname(__DIR__)));
31
-        if (null === $module) {
32
-            $module = XoopsModule::getByDirname($moduleDirName);
33
-        }
34
-        xoops_loadLanguage('admin', $moduleDirName);
35
-        //check for minimum XOOPS version
36
-        $currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string
37
-        $currArray  = explode('.', $currentVer);
38
-        if (null === $requiredVer) {
39
-            $requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string
40
-        }
41
-        $reqArray = explode('.', $requiredVer);
42
-        $success  = true;
43
-        foreach ($reqArray as $k => $v) {
44
-            if (isset($currArray[$k])) {
45
-                if ($currArray[$k] > $v) {
46
-                    break;
47
-                } elseif ($currArray[$k] == $v) {
48
-                    continue;
49
-                } else {
50
-                    $success = false;
51
-                    break;
52
-                }
53
-            } else {
54
-                if ((int)$v > 0) { // handles versions like x.x.x.0_RC2
55
-                    $success = false;
56
-                    break;
57
-                }
58
-            }
59
-        }
19
+	/**
20
+	 *
21
+	 * Verifies XOOPS version meets minimum requirements for this module
22
+	 * @static
23
+	 * @param \XoopsModule|null $module
24
+	 *
25
+	 * @param null|string $requiredVer
26
+	 * @return bool true if meets requirements, false if not
27
+	 */
28
+	public static function checkVerXoops(\XoopsModule $module = null, $requiredVer = null)
29
+	{
30
+		$moduleDirName = basename(dirname(dirname(__DIR__)));
31
+		if (null === $module) {
32
+			$module = XoopsModule::getByDirname($moduleDirName);
33
+		}
34
+		xoops_loadLanguage('admin', $moduleDirName);
35
+		//check for minimum XOOPS version
36
+		$currentVer = substr(XOOPS_VERSION, 6); // get the numeric part of string
37
+		$currArray  = explode('.', $currentVer);
38
+		if (null === $requiredVer) {
39
+			$requiredVer = '' . $module->getInfo('min_xoops'); //making sure it's a string
40
+		}
41
+		$reqArray = explode('.', $requiredVer);
42
+		$success  = true;
43
+		foreach ($reqArray as $k => $v) {
44
+			if (isset($currArray[$k])) {
45
+				if ($currArray[$k] > $v) {
46
+					break;
47
+				} elseif ($currArray[$k] == $v) {
48
+					continue;
49
+				} else {
50
+					$success = false;
51
+					break;
52
+				}
53
+			} else {
54
+				if ((int)$v > 0) { // handles versions like x.x.x.0_RC2
55
+					$success = false;
56
+					break;
57
+				}
58
+			}
59
+		}
60 60
 
61
-        if (false === $success) {
62
-            $module->setErrors(sprintf(_AM_WFL_ERROR_BAD_XOOPS, $requiredVer, $currentVer));
63
-        }
61
+		if (false === $success) {
62
+			$module->setErrors(sprintf(_AM_WFL_ERROR_BAD_XOOPS, $requiredVer, $currentVer));
63
+		}
64 64
 
65
-        return $success;
66
-    }
65
+		return $success;
66
+	}
67 67
 
68
-    /**
69
-     *
70
-     * Verifies PHP version meets minimum requirements for this module
71
-     * @static
72
-     * @param \XoopsModule $module
73
-     *
74
-     * @return bool true if meets requirements, false if not
75
-     */
76
-    public static function checkVerPhp(\XoopsModule $module)
77
-    {
78
-        xoops_loadLanguage('admin', $module->dirname());
79
-        // check for minimum PHP version
80
-        $success = true;
81
-        $verNum  = PHP_VERSION;
82
-        $reqVer  = $module->getInfo('min_php');
83
-        if (false !== $reqVer && '' !== $reqVer) {
84
-            if (version_compare($verNum, $reqVer, '<')) {
85
-                $module->setErrors(sprintf(_AM_WFL_ERROR_BAD_PHP, $reqVer, $verNum));
86
-                $success = false;
87
-            }
88
-        }
68
+	/**
69
+	 *
70
+	 * Verifies PHP version meets minimum requirements for this module
71
+	 * @static
72
+	 * @param \XoopsModule $module
73
+	 *
74
+	 * @return bool true if meets requirements, false if not
75
+	 */
76
+	public static function checkVerPhp(\XoopsModule $module)
77
+	{
78
+		xoops_loadLanguage('admin', $module->dirname());
79
+		// check for minimum PHP version
80
+		$success = true;
81
+		$verNum  = PHP_VERSION;
82
+		$reqVer  = $module->getInfo('min_php');
83
+		if (false !== $reqVer && '' !== $reqVer) {
84
+			if (version_compare($verNum, $reqVer, '<')) {
85
+				$module->setErrors(sprintf(_AM_WFL_ERROR_BAD_PHP, $reqVer, $verNum));
86
+				$success = false;
87
+			}
88
+		}
89 89
 
90
-        return $success;
91
-    }
90
+		return $success;
91
+	}
92 92
 }
Please login to merge, or discard this patch.
class/common/breadcrumb.php 1 patch
Indentation   +39 added lines, -39 removed lines patch added patch discarded remove patch
@@ -32,48 +32,48 @@
 block discarded – undo
32 32
  */
33 33
 class Breadcrumb
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
 }
Please login to merge, or discard this patch.