Completed
Push — master ( f5725e...47133a )
by Michael
02:14
created
class/CategoryHandler.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -34,9 +34,9 @@
 block discarded – undo
34 34
     public function updateDateupdated($cid = 0, $time = null)
35 35
     {
36 36
         // Если не передали время
37
-        $time = null === $time ? time() : (int)$time;
37
+        $time = null === $time ? time() : (int) $time;
38 38
         //
39
-        $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `cid` = %u', $this->table, $time, (int)$cid);
39
+        $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `cid` = %u', $this->table, $time, (int) $cid);
40 40
         //
41 41
         return $this->db->query($sql);
42 42
     }
Please login to merge, or discard this patch.
Indentation   +22 added lines, -22 removed lines patch added patch discarded remove patch
@@ -14,28 +14,28 @@
 block discarded – undo
14 14
  */
15 15
 class CategoryHandler extends \XoopsPersistableObjectHandler
16 16
 {
17
-    /**
18
-     * @param null|mixed $db
19
-     */
20
-    public function __construct(\XoopsDatabase $db = null)
21
-    {
22
-        parent::__construct($db, 'instruction_cat', Category::class, 'cid', 'title');
23
-    }
17
+	/**
18
+	 * @param null|mixed $db
19
+	 */
20
+	public function __construct(\XoopsDatabase $db = null)
21
+	{
22
+		parent::__construct($db, 'instruction_cat', Category::class, 'cid', 'title');
23
+	}
24 24
 
25
-    // Обновление даты обновления категории
25
+	// Обновление даты обновления категории
26 26
 
27
-    /**
28
-     * @param int      $cid
29
-     * @param null|int $time
30
-     * @return mixed
31
-     */
32
-    public function updateDateupdated($cid = 0, $time = null)
33
-    {
34
-        // Если не передали время
35
-        $time = null === $time ? time() : (int)$time;
36
-        //
37
-        $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `cid` = %u', $this->table, $time, (int)$cid);
38
-        //
39
-        return $this->db->query($sql);
40
-    }
27
+	/**
28
+	 * @param int      $cid
29
+	 * @param null|int $time
30
+	 * @return mixed
31
+	 */
32
+	public function updateDateupdated($cid = 0, $time = null)
33
+	{
34
+		// Если не передали время
35
+		$time = null === $time ? time() : (int)$time;
36
+		//
37
+		$sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `cid` = %u', $this->table, $time, (int)$cid);
38
+		//
39
+		return $this->db->query($sql);
40
+	}
41 41
 }
Please login to merge, or discard this patch.
class/Instruction.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -118,7 +118,7 @@
 block discarded – undo
118 118
         $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'metadescription', 50, 255, $this->getVar('metadescription')), false);
119 119
 
120 120
         // Если мы редактируем категорию
121
-        if (!$this->isNew()) {
121
+        if ( ! $this->isNew()) {
122 122
             $form->addElement(new \XoopsFormHidden('instrid', $this->getVar('instrid')));
123 123
         }
124 124
         //
Please login to merge, or discard this patch.
Indentation   +98 added lines, -98 removed lines patch added patch discarded remove patch
@@ -12,114 +12,114 @@
 block discarded – undo
12 12
  */
13 13
 class Instruction extends \XoopsObject
14 14
 {
15
-    // constructor
16
-    public function __construct()
17
-    {
18
-        //		$this->XoopsObject();
19
-        $this->initVar('instrid', XOBJ_DTYPE_INT, null, false, 11);
20
-        $this->initVar('cid', XOBJ_DTYPE_INT, 0, false, 5);
21
-        $this->initVar('uid', XOBJ_DTYPE_INT, 0, false, 11);
22
-        $this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false);
23
-        $this->initVar('status', XOBJ_DTYPE_INT, 0, false, 1);
24
-        $this->initVar('pages', XOBJ_DTYPE_INT, 0, false, 11);
25
-        $this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false);
26
-        $this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10);
27
-        $this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10);
28
-        $this->initVar('metakeywords', XOBJ_DTYPE_TXTBOX, '', false);
29
-        $this->initVar('metadescription', XOBJ_DTYPE_TXTBOX, '', false);
15
+	// constructor
16
+	public function __construct()
17
+	{
18
+		//		$this->XoopsObject();
19
+		$this->initVar('instrid', XOBJ_DTYPE_INT, null, false, 11);
20
+		$this->initVar('cid', XOBJ_DTYPE_INT, 0, false, 5);
21
+		$this->initVar('uid', XOBJ_DTYPE_INT, 0, false, 11);
22
+		$this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false);
23
+		$this->initVar('status', XOBJ_DTYPE_INT, 0, false, 1);
24
+		$this->initVar('pages', XOBJ_DTYPE_INT, 0, false, 11);
25
+		$this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false);
26
+		$this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10);
27
+		$this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10);
28
+		$this->initVar('metakeywords', XOBJ_DTYPE_TXTBOX, '', false);
29
+		$this->initVar('metadescription', XOBJ_DTYPE_TXTBOX, '', false);
30 30
 
31
-        // Нет в таблице
32
-        $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false);
33
-        $this->initVar('dobr', XOBJ_DTYPE_INT, 0, false);
34
-    }
31
+		// Нет в таблице
32
+		$this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false);
33
+		$this->initVar('dobr', XOBJ_DTYPE_INT, 0, false);
34
+	}
35 35
 
36
-    /**
37
-     * @return mixed
38
-     */
39
-    public function getNewInstertId()
40
-    {
41
-        $newEnreg = $GLOBALS['xoopsDB']->getInsertId();
42
-        return $newEnreg;
43
-    }
36
+	/**
37
+	 * @return mixed
38
+	 */
39
+	public function getNewInstertId()
40
+	{
41
+		$newEnreg = $GLOBALS['xoopsDB']->getInsertId();
42
+		return $newEnreg;
43
+	}
44 44
 
45
-    // Получаем форму
45
+	// Получаем форму
46 46
 
47
-    /**
48
-     * @param bool|null|string $action
49
-     * @return \XoopsThemeForm
50
-     */
51
-    public function getForm($action = false)
52
-    {
53
-        global $xoopsDB, $xoopsModule, $xoopsModuleConfig;
54
-        // Если нет $action
55
-        if (false === $action) {
56
-            $action = xoops_getenv('REQUEST_URI');
57
-        }
58
-        // Подключаем формы
59
-        include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
47
+	/**
48
+	 * @param bool|null|string $action
49
+	 * @return \XoopsThemeForm
50
+	 */
51
+	public function getForm($action = false)
52
+	{
53
+		global $xoopsDB, $xoopsModule, $xoopsModuleConfig;
54
+		// Если нет $action
55
+		if (false === $action) {
56
+			$action = xoops_getenv('REQUEST_URI');
57
+		}
58
+		// Подключаем формы
59
+		include_once $GLOBALS['xoops']->path('class/xoopsformloader.php');
60 60
 
61
-        // Название формы
62
-        $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDINSTR) : sprintf(_AM_INSTRUCTION_FORMEDITINSTR);
61
+		// Название формы
62
+		$title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDINSTR) : sprintf(_AM_INSTRUCTION_FORMEDITINSTR);
63 63
 
64
-        // Форма
65
-        $form = new \XoopsThemeForm($title, 'forminstr', $action, 'post', true);
66
-        //$form->setExtra('enctype="multipart/form-data"');
67
-        // Название инструкции
68
-        $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true);
69
-        // Категория
70
-        $categoryHandler = new CategoryHandler;
71
-        $criteria        = new \CriteriaCompo();
72
-        $criteria->setSort('weight ASC, title');
73
-        $criteria->setOrder('ASC');
74
-        $instructioncat_arr = $categoryHandler->getall($criteria);
75
-        unset($criteria);
76
-        // Подключаем трей
77
-        include_once $GLOBALS['xoops']->path('class/tree.php');
78
-        $mytree = new \XoopsObjectTree($instructioncat_arr, 'cid', 'pid');
64
+		// Форма
65
+		$form = new \XoopsThemeForm($title, 'forminstr', $action, 'post', true);
66
+		//$form->setExtra('enctype="multipart/form-data"');
67
+		// Название инструкции
68
+		$form->addElement(new \XoopsFormText(_AM_INSTRUCTION_TITLEC, 'title', 50, 255, $this->getVar('title')), true);
69
+		// Категория
70
+		$categoryHandler = new CategoryHandler;
71
+		$criteria        = new \CriteriaCompo();
72
+		$criteria->setSort('weight ASC, title');
73
+		$criteria->setOrder('ASC');
74
+		$instructioncat_arr = $categoryHandler->getall($criteria);
75
+		unset($criteria);
76
+		// Подключаем трей
77
+		include_once $GLOBALS['xoops']->path('class/tree.php');
78
+		$mytree = new \XoopsObjectTree($instructioncat_arr, 'cid', 'pid');
79 79
 
80
-        // $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_CATC, $mytree->makeSelBox('cid', 'title', '--', $this->getVar('cid'), true)));
81
-        $helper = Helper::getInstance();
82
-        $module = $helper->getModule();
80
+		// $form->addElement(new XoopsFormLabel(_AM_INSTRUCTION_CATC, $mytree->makeSelBox('cid', 'title', '--', $this->getVar('cid'), true)));
81
+		$helper = Helper::getInstance();
82
+		$module = $helper->getModule();
83 83
 
84
-        if (Utility::checkVerXoops($module, '2.5.9')) {
85
-            $mytree_select = $mytree->makeSelectElement('cid', 'title', '--', $this->getVar('cid'), true, 0, '', _AM_INSTRUCTION_CATC);
86
-            $form->addElement($mytree_select);
87
-        } else {
88
-            $form->addElement(new \XoopsFormLabel(_AM_INSTRUCTION_CATC, $mytree->makeSelBox('cid', 'title', '--', $this->getVar('cid'), true)));
89
-        }
84
+		if (Utility::checkVerXoops($module, '2.5.9')) {
85
+			$mytree_select = $mytree->makeSelectElement('cid', 'title', '--', $this->getVar('cid'), true, 0, '', _AM_INSTRUCTION_CATC);
86
+			$form->addElement($mytree_select);
87
+		} else {
88
+			$form->addElement(new \XoopsFormLabel(_AM_INSTRUCTION_CATC, $mytree->makeSelBox('cid', 'title', '--', $this->getVar('cid'), true)));
89
+		}
90 90
 
91
-        // Описание
92
-        $form->addElement(Utility::getWysiwygForm(_AM_INSTRUCTION_DESCRIPTIONC, 'description', $this->getVar('description', 'e')), true);
93
-        // Статус
94
-        $form->addElement(new \XoopsFormRadioYN(_AM_INSTRUCTION_ACTIVEC, 'status', $this->getVar('status')), false);
91
+		// Описание
92
+		$form->addElement(Utility::getWysiwygForm(_AM_INSTRUCTION_DESCRIPTIONC, 'description', $this->getVar('description', 'e')), true);
93
+		// Статус
94
+		$form->addElement(new \XoopsFormRadioYN(_AM_INSTRUCTION_ACTIVEC, 'status', $this->getVar('status')), false);
95 95
 
96
-        // Теги
97
-        $dir_tag_ok = false;
98
-        if (is_dir('../../tag') || is_dir('../tag')) {
99
-            $dir_tag_ok = true;
100
-        }
101
-        // Если влючена поддержка тегов и есть модуль tag
102
-        if (xoops_getModuleOption('usetag', 'instruction') && $dir_tag_ok) {
103
-            $itemIdForTag = $this->isNew() ? 0 : $this->getVar('instrid');
104
-            // Подключаем форму тегов
105
-            include_once $GLOBALS['xoops']->path('modules/tag/include/formtag.php');
106
-            // Добавляем элемент в форму
107
-            $form->addElement(new \XoopsFormTag('tag', 60, 255, $itemIdForTag, 0));
108
-        }
96
+		// Теги
97
+		$dir_tag_ok = false;
98
+		if (is_dir('../../tag') || is_dir('../tag')) {
99
+			$dir_tag_ok = true;
100
+		}
101
+		// Если влючена поддержка тегов и есть модуль tag
102
+		if (xoops_getModuleOption('usetag', 'instruction') && $dir_tag_ok) {
103
+			$itemIdForTag = $this->isNew() ? 0 : $this->getVar('instrid');
104
+			// Подключаем форму тегов
105
+			include_once $GLOBALS['xoops']->path('modules/tag/include/formtag.php');
106
+			// Добавляем элемент в форму
107
+			$form->addElement(new \XoopsFormTag('tag', 60, 255, $itemIdForTag, 0));
108
+		}
109 109
 
110
-        // Мета-теги ключевых слов
111
-        $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'metakeywords', 50, 255, $this->getVar('metakeywords')), false);
112
-        // Мета-теги описания
113
-        $form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'metadescription', 50, 255, $this->getVar('metadescription')), false);
110
+		// Мета-теги ключевых слов
111
+		$form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METAKEYWORDSC, 'metakeywords', 50, 255, $this->getVar('metakeywords')), false);
112
+		// Мета-теги описания
113
+		$form->addElement(new \XoopsFormText(_AM_INSTRUCTION_METADESCRIPTIONC, 'metadescription', 50, 255, $this->getVar('metadescription')), false);
114 114
 
115
-        // Если мы редактируем категорию
116
-        if (!$this->isNew()) {
117
-            $form->addElement(new \XoopsFormHidden('instrid', $this->getVar('instrid')));
118
-        }
119
-        //
120
-        $form->addElement(new \XoopsFormHidden('op', 'saveinstr'));
121
-        // Кнопка
122
-        $form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
123
-        return $form;
124
-    }
115
+		// Если мы редактируем категорию
116
+		if (!$this->isNew()) {
117
+			$form->addElement(new \XoopsFormHidden('instrid', $this->getVar('instrid')));
118
+		}
119
+		//
120
+		$form->addElement(new \XoopsFormHidden('op', 'saveinstr'));
121
+		// Кнопка
122
+		$form->addElement(new \XoopsFormButton('', 'submit', _SUBMIT, 'submit'));
123
+		return $form;
124
+	}
125 125
 }
Please login to merge, or discard this patch.
class/InstructionHandler.php 2 patches
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -32,9 +32,9 @@
 block discarded – undo
32 32
     public function updateDateupdated($instrid = 0, $time = null)
33 33
     {
34 34
         // Если не передали время
35
-        $time = null === $time ? time() : (int)$time;
35
+        $time = null === $time ? time() : (int) $time;
36 36
         //
37
-        $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `instrid` = %u', $this->table, $time, (int)$instrid);
37
+        $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `instrid` = %u', $this->table, $time, (int) $instrid);
38 38
         //
39 39
         return $this->db->query($sql);
40 40
     }
Please login to merge, or discard this patch.
Indentation   +43 added lines, -43 removed lines patch added patch discarded remove patch
@@ -14,52 +14,52 @@
 block discarded – undo
14 14
  */
15 15
 class InstructionHandler extends \XoopsPersistableObjectHandler
16 16
 {
17
-    /**
18
-     * @param null|mixed $db
19
-     */
20
-    public function __construct(\XoopsDatabase $db = null)
21
-    {
22
-        parent::__construct($db, 'instruction_instr', Instruction::class, 'instrid', 'title');
23
-    }
17
+	/**
18
+	 * @param null|mixed $db
19
+	 */
20
+	public function __construct(\XoopsDatabase $db = null)
21
+	{
22
+		parent::__construct($db, 'instruction_instr', Instruction::class, 'instrid', 'title');
23
+	}
24 24
 
25
-    // Обновление даты обновления инструкций
25
+	// Обновление даты обновления инструкций
26 26
 
27
-    /**
28
-     * @param int      $instrid
29
-     * @param bool|int $time
30
-     * @return mixed
31
-     */
32
-    public function updateDateupdated($instrid = 0, $time = null)
33
-    {
34
-        // Если не передали время
35
-        $time = null === $time ? time() : (int)$time;
36
-        //
37
-        $sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `instrid` = %u', $this->table, $time, (int)$instrid);
38
-        //
39
-        return $this->db->query($sql);
40
-    }
27
+	/**
28
+	 * @param int      $instrid
29
+	 * @param bool|int $time
30
+	 * @return mixed
31
+	 */
32
+	public function updateDateupdated($instrid = 0, $time = null)
33
+	{
34
+		// Если не передали время
35
+		$time = null === $time ? time() : (int)$time;
36
+		//
37
+		$sql = sprintf('UPDATE `%s` SET `dateupdated` = %u WHERE `instrid` = %u', $this->table, $time, (int)$instrid);
38
+		//
39
+		return $this->db->query($sql);
40
+	}
41 41
 
42
-    // Обновление числа страниц
42
+	// Обновление числа страниц
43 43
 
44
-    /**
45
-     * @param int $instrid
46
-     * @return mixed
47
-     */
48
-    public function updatePages($instrid = 0)
49
-    {
50
-        //        $pageHandler = xoops_getModuleHandler('page', 'instruction');
51
-        $pageHandler = new PageHandler;
52
-        // Находим число активных страниц
53
-        $criteria = new \CriteriaCompo();
54
-        $criteria->add(new \Criteria('instrid', $instrid, '='));
55
-        $criteria->add(new \Criteria('status ', '0', '>'));
56
-        // Число страниц
57
-        $pages = $pageHandler->getCount($criteria);
58
-        unset($criteria);
44
+	/**
45
+	 * @param int $instrid
46
+	 * @return mixed
47
+	 */
48
+	public function updatePages($instrid = 0)
49
+	{
50
+		//        $pageHandler = xoops_getModuleHandler('page', 'instruction');
51
+		$pageHandler = new PageHandler;
52
+		// Находим число активных страниц
53
+		$criteria = new \CriteriaCompo();
54
+		$criteria->add(new \Criteria('instrid', $instrid, '='));
55
+		$criteria->add(new \Criteria('status ', '0', '>'));
56
+		// Число страниц
57
+		$pages = $pageHandler->getCount($criteria);
58
+		unset($criteria);
59 59
 
60
-        // Сохраняем это число
61
-        $sql = sprintf('UPDATE `%s` SET `pages` = %u, `dateupdated` = %u WHERE `instrid` = %u', $this->table, $pages, time(), $instrid);
62
-        //
63
-        return $this->db->query($sql);
64
-    }
60
+		// Сохраняем это число
61
+		$sql = sprintf('UPDATE `%s` SET `pages` = %u, `dateupdated` = %u WHERE `instrid` = %u', $this->table, $pages, time(), $instrid);
62
+		//
63
+		return $this->db->query($sql);
64
+	}
65 65
 }
Please login to merge, or discard this patch.
include/comment_functions.php 1 patch
Indentation   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -9,9 +9,9 @@  discard block
 block discarded – undo
9 9
  */
10 10
 function instruction_com_update($pageid, $total_num)
11 11
 {
12
-    $db  = XoopsDatabaseFactory::getDatabaseConnection();
13
-    $sql = 'UPDATE ' . $db->prefix('instruction_page') . ' SET comments = ' . $total_num . ' WHERE pageid  = ' . $pageid;
14
-    $db->query($sql);
12
+	$db  = XoopsDatabaseFactory::getDatabaseConnection();
13
+	$sql = 'UPDATE ' . $db->prefix('instruction_page') . ' SET comments = ' . $total_num . ' WHERE pageid  = ' . $pageid;
14
+	$db->query($sql);
15 15
 }
16 16
 
17 17
 /**
@@ -19,5 +19,5 @@  discard block
 block discarded – undo
19 19
  */
20 20
 function instruction_com_approve(&$comment)
21 21
 {
22
-    // notification mail here
22
+	// notification mail here
23 23
 }
Please login to merge, or discard this patch.
include/common.php 2 patches
Indentation   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -70,8 +70,8 @@
 block discarded – undo
70 70
 $debug = false;
71 71
 
72 72
 if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof \XoopsTpl)) {
73
-    require_once $GLOBALS['xoops']->path('class/template.php');
74
-    $xoopsTpl = new \XoopsTpl();
73
+	require_once $GLOBALS['xoops']->path('class/template.php');
74
+	$xoopsTpl = new \XoopsTpl();
75 75
 }
76 76
 
77 77
 $moduleDirName = basename(dirname(__DIR__));
Please login to merge, or discard this patch.
Spacing   +6 added lines, -6 removed lines patch added patch discarded remove patch
@@ -46,11 +46,11 @@  discard block
 block discarded – undo
46 46
 //require_once INSTRUCTION_ROOT_PATH . '/class/CategoryHandler.php';
47 47
 //require_once INSTRUCTION_ROOT_PATH . '/class/PageHandler.php';
48 48
 
49
-require_once __DIR__  . '/../class/Helper.php';
50
-require_once __DIR__  . '/../class/Utility.php';
51
-require_once __DIR__  . '/../class/InstructionHandler.php';
52
-require_once __DIR__  . '/../class/CategoryHandler.php';
53
-require_once __DIR__  . '/../class/PageHandler.php';
49
+require_once __DIR__ . '/../class/Helper.php';
50
+require_once __DIR__ . '/../class/Utility.php';
51
+require_once __DIR__ . '/../class/InstructionHandler.php';
52
+require_once __DIR__ . '/../class/CategoryHandler.php';
53
+require_once __DIR__ . '/../class/PageHandler.php';
54 54
 
55 55
 //xoops_load('constants', INSTRUCTION_DIRNAME);
56 56
 //xoops_load('utility', INSTRUCTION_DIRNAME);
@@ -85,7 +85,7 @@  discard block
 block discarded – undo
85 85
 
86 86
 $debug = false;
87 87
 
88
-if (!isset($GLOBALS['xoopsTpl']) || !($GLOBALS['xoopsTpl'] instanceof \XoopsTpl)) {
88
+if ( ! isset($GLOBALS['xoopsTpl']) || ! ($GLOBALS['xoopsTpl'] instanceof \XoopsTpl)) {
89 89
     require_once $GLOBALS['xoops']->path('class/template.php');
90 90
     $xoopsTpl = new \XoopsTpl();
91 91
 }
Please login to merge, or discard this patch.
index.php 2 patches
Spacing   +1 added lines, -1 removed lines patch added patch discarded remove patch
@@ -63,7 +63,7 @@
 block discarded – undo
63 63
 // Если есть категория
64 64
 if ($cid) {
65 65
     // Если нельзя просматривать эту категорию
66
-    if (!in_array($cid, $categories)) {
66
+    if ( ! in_array($cid, $categories)) {
67 67
         redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_CAT);
68 68
     }
69 69
     $criteria->add(new \Criteria('cid', $cid, '='));
Please login to merge, or discard this patch.
Indentation   +56 added lines, -56 removed lines patch added patch discarded remove patch
@@ -48,11 +48,11 @@  discard block
 block discarded – undo
48 48
 $module = $helper->getModule();
49 49
 
50 50
 if (Xoopsmodules\instruction\Utility::checkVerXoops($module, '2.5.9')) {
51
-    $cat_select = $mytree->makeSelectElement('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'", '');
52
-    $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select->render());
51
+	$cat_select = $mytree->makeSelectElement('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'", '');
52
+	$GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select->render());
53 53
 } else {
54
-    $cat_select = $mytree->makeSelBox('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'");
55
-    $GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select);
54
+	$cat_select = $mytree->makeSelBox('cid', 'title', '--', $cid, true, 0, "onChange='javascript: document.insformselcat.submit()'");
55
+	$GLOBALS['xoopsTpl']->assign('insFormSelCat', $cat_select);
56 56
 }
57 57
 
58 58
 // Находим список всех инструкций
@@ -62,14 +62,14 @@  discard block
 block discarded – undo
62 62
 $criteria->add(new \Criteria('status', '0', '>'));
63 63
 // Если есть категория
64 64
 if ($cid) {
65
-    // Если нельзя просматривать эту категорию
66
-    if (!in_array($cid, $categories)) {
67
-        redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_CAT);
68
-    }
69
-    $criteria->add(new \Criteria('cid', $cid, '='));
70
-    // Иначе находим список всех
65
+	// Если нельзя просматривать эту категорию
66
+	if (!in_array($cid, $categories)) {
67
+		redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_CAT);
68
+	}
69
+	$criteria->add(new \Criteria('cid', $cid, '='));
70
+	// Иначе находим список всех
71 71
 } else {
72
-    $criteria->add(new \Criteria('cid', '( ' . implode(', ', $categories) . ' )', 'IN'));
72
+	$criteria->add(new \Criteria('cid', '( ' . implode(', ', $categories) . ' )', 'IN'));
73 73
 }
74 74
 
75 75
 // Число инструкций, удовлетворяющих данному условию
@@ -86,10 +86,10 @@  discard block
 block discarded – undo
86 86
 $instr_arr = $instructionHandler->getall($criteria);
87 87
 // Если записей больше чем $limit, то выводим пагинатор
88 88
 if ($numrows > $limit) {
89
-    $pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', 'cid=' . $cid);
90
-    $pagenav = $pagenav->renderNav(4);
89
+	$pagenav = new \XoopsPageNav($numrows, $limit, $start, 'start', 'cid=' . $cid);
90
+	$pagenav = $pagenav->renderNav(4);
91 91
 } else {
92
-    $pagenav = '';
92
+	$pagenav = '';
93 93
 }
94 94
 // Выводим пагинатор в шаблон
95 95
 $GLOBALS['xoopsTpl']->assign('insPagenav', $pagenav);
@@ -100,54 +100,54 @@  discard block
 block discarded – undo
100 100
 
101 101
 // Если есть записи
102 102
 if ($numrows > 0) {
103
-    $class = 'odd';
104
-    foreach (array_keys($instr_arr) as $i) {
105
-
106
-        //
107
-        $class = ('even' === $class) ? 'odd' : 'even';
108
-        // ID
109
-        $insinstr_instrid = $instr_arr[$i]->getVar('instrid');
110
-        // Название
111
-        $insinstr_title = $instr_arr[$i]->getVar('title');
112
-        // Статус
113
-        $insinstr_status = $instr_arr[$i]->getVar('status');
114
-        // Количество страниц
115
-        $insinstr_pages = $instr_arr[$i]->getVar('pages');
116
-        // Категория
117
-        $insinstr_cid = $instr_arr[$i]->getVar('cid');
118
-        $insinstr_cat = $categoryHandler->get($insinstr_cid);
119
-        // Права на добавление
120
-        $perm_submit = in_array($insinstr_cid, $cat_submit) ? true : false;
121
-        // Права на редактирование
122
-        $perm_edit = in_array($insinstr_cid, $cat_edit) ? true : false;
123
-        //Мета-теги ключевых слов
124
-        $insinstr_metakeywords = $instr_arr[$i]->getVar('metakeywords');
125
-        // Если есть - добавляем в мета-теги страницы
126
-        if ($insinstr_metakeywords) {
127
-            $index_metakeywords[] = $insinstr_metakeywords;
128
-        }
129
-        // Мета-теги описания
130
-        $insinstr_metadescript = $instr_arr[$i]->getVar('metadescription');
131
-        // Если есть - добавляем в мета-теги страницы
132
-        if ($insinstr_metadescript) {
133
-            $index_metadescript[] = $insinstr_metadescript;
134
-        }
135
-
136
-        // Выводим в шаблон
137
-        $GLOBALS['xoopsTpl']->append('insListInstr',
138
-                                     ['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]
139
-        );
140
-    }
141
-
142
-    // Языковые константы
103
+	$class = 'odd';
104
+	foreach (array_keys($instr_arr) as $i) {
105
+
106
+		//
107
+		$class = ('even' === $class) ? 'odd' : 'even';
108
+		// ID
109
+		$insinstr_instrid = $instr_arr[$i]->getVar('instrid');
110
+		// Название
111
+		$insinstr_title = $instr_arr[$i]->getVar('title');
112
+		// Статус
113
+		$insinstr_status = $instr_arr[$i]->getVar('status');
114
+		// Количество страниц
115
+		$insinstr_pages = $instr_arr[$i]->getVar('pages');
116
+		// Категория
117
+		$insinstr_cid = $instr_arr[$i]->getVar('cid');
118
+		$insinstr_cat = $categoryHandler->get($insinstr_cid);
119
+		// Права на добавление
120
+		$perm_submit = in_array($insinstr_cid, $cat_submit) ? true : false;
121
+		// Права на редактирование
122
+		$perm_edit = in_array($insinstr_cid, $cat_edit) ? true : false;
123
+		//Мета-теги ключевых слов
124
+		$insinstr_metakeywords = $instr_arr[$i]->getVar('metakeywords');
125
+		// Если есть - добавляем в мета-теги страницы
126
+		if ($insinstr_metakeywords) {
127
+			$index_metakeywords[] = $insinstr_metakeywords;
128
+		}
129
+		// Мета-теги описания
130
+		$insinstr_metadescript = $instr_arr[$i]->getVar('metadescription');
131
+		// Если есть - добавляем в мета-теги страницы
132
+		if ($insinstr_metadescript) {
133
+			$index_metadescript[] = $insinstr_metadescript;
134
+		}
135
+
136
+		// Выводим в шаблон
137
+		$GLOBALS['xoopsTpl']->append('insListInstr',
138
+									 ['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]
139
+		);
140
+	}
141
+
142
+	// Языковые константы
143 143
 }
144 144
 
145 145
 // Если есть мета-теги
146 146
 if (count($index_metakeywords)) {
147
-    $xoTheme->addMeta('meta', 'keywords', implode(', ', $index_metakeywords));
147
+	$xoTheme->addMeta('meta', 'keywords', implode(', ', $index_metakeywords));
148 148
 }
149 149
 if (count($index_metadescript)) {
150
-    $xoTheme->addMeta('meta', 'description', implode(', ', $index_metadescript));
150
+	$xoTheme->addMeta('meta', 'description', implode(', ', $index_metadescript));
151 151
 }
152 152
 
153 153
 // Подвал
Please login to merge, or discard this patch.
submit.php 2 patches
Indentation   +191 added lines, -191 removed lines patch added patch discarded remove patch
@@ -35,195 +35,195 @@
 block discarded – undo
35 35
 
36 36
 switch ($op) {
37 37
 
38
-    case 'editpage':
39
-
40
-        // Задание тайтла
41
-        $xoopsOption['xoops_pagetitle'] = '';
42
-        // Шаблон
43
-        $GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_editpage.tpl';
44
-        // Заголовок
45
-        include_once $GLOBALS['xoops']->path('header.php');
46
-
47
-        // Если мы редактируем страницу
48
-        if ($pageid) {
49
-            // Получаем объект страницы
50
-            $objInspage = $pageHandler->get($pageid);
51
-            // ID инструкции
52
-            $instrid = $objInspage->getVar('instrid');
53
-            // Объект инструкции
54
-            $objInsinstr = $instructionHandler->get($instrid);
55
-            // Можно ли редактировать инструкцию в данной категории
56
-            if (!in_array($objInsinstr->getVar('cid'), $cat_edit)) {
57
-                redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_EDITPAGE);
58
-            }
59
-            // Создание новой страницы
60
-        } elseif ($instrid) {
61
-
62
-            // Если нельзя добавлять не в одну категорию
63
-            //if( ! count( $cat_submit ) ) redirect_header( 'index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMIT_PAGE );
64
-            // Создаём объект страницы
65
-            $objInspage = $pageHandler->create();
66
-            // Объект инструкции
67
-            $objInsinstr = $instructionHandler->get($instrid);
68
-            // Можно ли добавлять инструкции в данной категории
69
-            if (!in_array($objInsinstr->getVar('cid'), $cat_submit)) {
70
-                redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMITPAGE);
71
-            }
72
-        } else {
73
-            redirect_header('index.php', 3, _MD_INSTRUCTION_BADREQUEST);
74
-        }
75
-
76
-        // Информация об инструкции
77
-
78
-        // Массив данных об инструкции
79
-        $instrs = [];
80
-        // ID инструкции
81
-        $instrs['instrid'] = $objInsinstr->getVar('instrid');
82
-        // Название страницы
83
-        $instrs['title'] = $objInsinstr->getVar('title');
84
-        // Описание
85
-        $instrs['description'] = $objInsinstr->getVar('description');
86
-
87
-        // Выводим в шаблон
88
-        $GLOBALS['xoopsTpl']->assign('insInstr', $instrs);
89
-
90
-        //
91
-
92
-        $form = $objInspage->getForm('submit.php', $instrid);
93
-        // Форма
94
-        $GLOBALS['xoopsTpl']->assign('insFormPage', $form->render());
95
-
96
-        // Подвал
97
-        include_once $GLOBALS['xoops']->path('footer.php');
98
-
99
-        break;
100
-    // Сохранение страницы
101
-    case 'savepage':
102
-
103
-        // Проверка
104
-        if (!$GLOBALS['xoopsSecurity']->check()) {
105
-            redirect_header('index.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
106
-        }
107
-
108
-        $err         = false;
109
-        $message_err = '';
110
-
111
-        // Если мы редактируем
112
-        if ($pageid) {
113
-            $objInspage = $pageHandler->get($pageid);
114
-            // Объект инструкции
115
-            $objInsinstr = $instructionHandler->get($objInspage->getVar('instrid'));
116
-            // Можно ли редактировать инструкцию в данной категории
117
-            if (!in_array($objInsinstr->getVar('cid'), $cat_edit)) {
118
-                redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_EDITPAGE);
119
-            }
120
-        } elseif ($instrid) {
121
-            $objInspage = $pageHandler->create();
122
-            // Объект инструкции
123
-            $objInsinstr = $instructionHandler->get($instrid);
124
-            // Можно ли добавлять инструкции в данной категории
125
-            if (!in_array($objInsinstr->getVar('cid'), $cat_submit)) {
126
-                redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMITPAGE);
127
-            }
128
-
129
-            // Если мы создаём страницу необходимо указать к какой инструкции
130
-            $objInspage->setVar('instrid', $instrid);
131
-            // Указываем дату создания
132
-            $objInspage->setVar('datecreated', $time);
133
-            // Указываем пользователя
134
-            $objInspage->setVar('uid', $uid);
135
-        } else {
136
-            redirect_header('index.php', 3, _MD_INSTRUCTION_BADREQUEST);
137
-        }
138
-
139
-        // Родительская страница
140
-        $objInspage->setVar('pid', $pid);
141
-        // Дата обновления
142
-        $objInspage->setVar('dateupdated', $time);
143
-        //
144
-        $objInspage->setVar('title', Request::getString('title', '', 'POST'));
145
-        $objInspage->setVar('weight', $weight);
146
-        $objInspage->setVar('hometext', Request::getText('hometext', '', 'POST'));
147
-        // Сноска
148
-        $objInspage->setVar('footnote', Request::getText('footnote', '', 'POST'));
149
-        $objInspage->setVar('status', Request::getInt('status', 0, 'POST'));
150
-        $objInspage->setVar('keywords', Request::getString('keywords', '', 'POST'));
151
-        $objInspage->setVar('description', Request::getText('description', '', 'POST'));
152
-
153
-        // Проверка категорий
154
-        if (!$pageid && !$instrid) {
155
-            $err         = true;
156
-            $message_err .= _MD_INSTRUCTION_ERR_INSTR . '<br>';
157
-        }
158
-        // Проверка веса
159
-        if (0 == $weight) {
160
-            $err         = true;
161
-            $message_err .= _MD_INSTRUCTION_ERR_WEIGHT . '<br>';
162
-        }
163
-        // Проверка родительской страницы
164
-        if ($pageid && ($pageid == $pid)) {
165
-            $err         = true;
166
-            $message_err .= _MD_INSTRUCTION_ERR_PPAGE . '<br>';
167
-        }
168
-        // Если были ошибки
169
-        if (true === $err) {
170
-            // Задание тайтла
171
-            $xoopsOption['xoops_pagetitle'] = '';
172
-            // Шаблон
173
-            $GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_savepage.tpl';
174
-            // Заголовок
175
-            include_once $GLOBALS['xoops']->path('header.php');
176
-            // Сообщение об ошибке
177
-            $message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>';
178
-            // Выводим ошибки в шаблон
179
-            $GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err);
180
-            // Если небыло ошибок
181
-        } else {
182
-            // Вставляем данные в БД
183
-            if ($pageHandler->insert($objInspage)) {
184
-                // Если мы редактируем
185
-                if ($pageid) {
186
-                    // Обновление даты
187
-                    $sql = sprintf('UPDATE %s SET `dateupdated` = %u WHERE `instrid` = %u', $GLOBALS['xoopsDB']->prefix($moduleDirName . '_instr'), $time, $instrid);
188
-                    $GLOBALS['xoopsDB']->query($sql);
189
-                    // Запись в лог
190
-                    xoops_loadLanguage('main', 'userslog');
191
-                    //userslog_insert( $objInsinstr->getVar('title') . ': ' . $objInspage->getVar('title'), _MD_USERSLOG_MODIFY_PAGE );
192
-                    //
193
-                    redirect_header('index.php', 3, _MD_INSTRUCTION_PAGEMODIFY);
194
-                    // Если мы добавляем
195
-                } else {
196
-                    // Инкримент комментов
197
-                    $pageHandler->updateposts($uid, Request::getInt('status', 0, 'POST'), 'add');
198
-                    // Инкремент страниц и обновление даты
199
-                    $sql = sprintf('UPDATE %s SET `pages` = `pages` + 1, `dateupdated` = %u WHERE `instrid` = %u', $GLOBALS['xoopsDB']->prefix($moduleDirName . '_instr'), $time, $instrid);
200
-                    $GLOBALS['xoopsDB']->query($sql);
201
-                    // Запись в лог
202
-                    xoops_loadLanguage('main', 'userslog');
203
-                    //userslog_insert( $objInsinstr->getVar('title') . ': ' . $objInspage->getVar('title'), _MD_USERSLOG_SUBMIT_PAGE );
204
-                    //
205
-                    redirect_header('index.php', 3, _MD_INSTRUCTION_PAGEADDED);
206
-                }
207
-            }
208
-
209
-            // Задание тайтла
210
-            $xoopsOption['xoops_pagetitle'] = '';
211
-            // Шаблон
212
-            $GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_savepage.tpl';
213
-            // Заголовок
214
-            include_once $GLOBALS['xoops']->path('header.php');
215
-
216
-            // Выводим ошибки в шаблон
217
-            $GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInspage->getHtmlErrors());
218
-        }
219
-        // Получаем форму
220
-        $form = $objInspage->getForm('submit.php', $instrid);
221
-
222
-        // Форма
223
-        $GLOBALS['xoopsTpl']->assign('insFormPage', $form->render());
224
-
225
-        // Подвал
226
-        include_once $GLOBALS['xoops']->path('footer.php');
227
-
228
-        break;
38
+	case 'editpage':
39
+
40
+		// Задание тайтла
41
+		$xoopsOption['xoops_pagetitle'] = '';
42
+		// Шаблон
43
+		$GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_editpage.tpl';
44
+		// Заголовок
45
+		include_once $GLOBALS['xoops']->path('header.php');
46
+
47
+		// Если мы редактируем страницу
48
+		if ($pageid) {
49
+			// Получаем объект страницы
50
+			$objInspage = $pageHandler->get($pageid);
51
+			// ID инструкции
52
+			$instrid = $objInspage->getVar('instrid');
53
+			// Объект инструкции
54
+			$objInsinstr = $instructionHandler->get($instrid);
55
+			// Можно ли редактировать инструкцию в данной категории
56
+			if (!in_array($objInsinstr->getVar('cid'), $cat_edit)) {
57
+				redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_EDITPAGE);
58
+			}
59
+			// Создание новой страницы
60
+		} elseif ($instrid) {
61
+
62
+			// Если нельзя добавлять не в одну категорию
63
+			//if( ! count( $cat_submit ) ) redirect_header( 'index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMIT_PAGE );
64
+			// Создаём объект страницы
65
+			$objInspage = $pageHandler->create();
66
+			// Объект инструкции
67
+			$objInsinstr = $instructionHandler->get($instrid);
68
+			// Можно ли добавлять инструкции в данной категории
69
+			if (!in_array($objInsinstr->getVar('cid'), $cat_submit)) {
70
+				redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMITPAGE);
71
+			}
72
+		} else {
73
+			redirect_header('index.php', 3, _MD_INSTRUCTION_BADREQUEST);
74
+		}
75
+
76
+		// Информация об инструкции
77
+
78
+		// Массив данных об инструкции
79
+		$instrs = [];
80
+		// ID инструкции
81
+		$instrs['instrid'] = $objInsinstr->getVar('instrid');
82
+		// Название страницы
83
+		$instrs['title'] = $objInsinstr->getVar('title');
84
+		// Описание
85
+		$instrs['description'] = $objInsinstr->getVar('description');
86
+
87
+		// Выводим в шаблон
88
+		$GLOBALS['xoopsTpl']->assign('insInstr', $instrs);
89
+
90
+		//
91
+
92
+		$form = $objInspage->getForm('submit.php', $instrid);
93
+		// Форма
94
+		$GLOBALS['xoopsTpl']->assign('insFormPage', $form->render());
95
+
96
+		// Подвал
97
+		include_once $GLOBALS['xoops']->path('footer.php');
98
+
99
+		break;
100
+	// Сохранение страницы
101
+	case 'savepage':
102
+
103
+		// Проверка
104
+		if (!$GLOBALS['xoopsSecurity']->check()) {
105
+			redirect_header('index.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
106
+		}
107
+
108
+		$err         = false;
109
+		$message_err = '';
110
+
111
+		// Если мы редактируем
112
+		if ($pageid) {
113
+			$objInspage = $pageHandler->get($pageid);
114
+			// Объект инструкции
115
+			$objInsinstr = $instructionHandler->get($objInspage->getVar('instrid'));
116
+			// Можно ли редактировать инструкцию в данной категории
117
+			if (!in_array($objInsinstr->getVar('cid'), $cat_edit)) {
118
+				redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_EDITPAGE);
119
+			}
120
+		} elseif ($instrid) {
121
+			$objInspage = $pageHandler->create();
122
+			// Объект инструкции
123
+			$objInsinstr = $instructionHandler->get($instrid);
124
+			// Можно ли добавлять инструкции в данной категории
125
+			if (!in_array($objInsinstr->getVar('cid'), $cat_submit)) {
126
+				redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMITPAGE);
127
+			}
128
+
129
+			// Если мы создаём страницу необходимо указать к какой инструкции
130
+			$objInspage->setVar('instrid', $instrid);
131
+			// Указываем дату создания
132
+			$objInspage->setVar('datecreated', $time);
133
+			// Указываем пользователя
134
+			$objInspage->setVar('uid', $uid);
135
+		} else {
136
+			redirect_header('index.php', 3, _MD_INSTRUCTION_BADREQUEST);
137
+		}
138
+
139
+		// Родительская страница
140
+		$objInspage->setVar('pid', $pid);
141
+		// Дата обновления
142
+		$objInspage->setVar('dateupdated', $time);
143
+		//
144
+		$objInspage->setVar('title', Request::getString('title', '', 'POST'));
145
+		$objInspage->setVar('weight', $weight);
146
+		$objInspage->setVar('hometext', Request::getText('hometext', '', 'POST'));
147
+		// Сноска
148
+		$objInspage->setVar('footnote', Request::getText('footnote', '', 'POST'));
149
+		$objInspage->setVar('status', Request::getInt('status', 0, 'POST'));
150
+		$objInspage->setVar('keywords', Request::getString('keywords', '', 'POST'));
151
+		$objInspage->setVar('description', Request::getText('description', '', 'POST'));
152
+
153
+		// Проверка категорий
154
+		if (!$pageid && !$instrid) {
155
+			$err         = true;
156
+			$message_err .= _MD_INSTRUCTION_ERR_INSTR . '<br>';
157
+		}
158
+		// Проверка веса
159
+		if (0 == $weight) {
160
+			$err         = true;
161
+			$message_err .= _MD_INSTRUCTION_ERR_WEIGHT . '<br>';
162
+		}
163
+		// Проверка родительской страницы
164
+		if ($pageid && ($pageid == $pid)) {
165
+			$err         = true;
166
+			$message_err .= _MD_INSTRUCTION_ERR_PPAGE . '<br>';
167
+		}
168
+		// Если были ошибки
169
+		if (true === $err) {
170
+			// Задание тайтла
171
+			$xoopsOption['xoops_pagetitle'] = '';
172
+			// Шаблон
173
+			$GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_savepage.tpl';
174
+			// Заголовок
175
+			include_once $GLOBALS['xoops']->path('header.php');
176
+			// Сообщение об ошибке
177
+			$message_err = '<div class="errorMsg" style="text-align: left;">' . $message_err . '</div>';
178
+			// Выводим ошибки в шаблон
179
+			$GLOBALS['xoopsTpl']->assign('insErrorMsg', $message_err);
180
+			// Если небыло ошибок
181
+		} else {
182
+			// Вставляем данные в БД
183
+			if ($pageHandler->insert($objInspage)) {
184
+				// Если мы редактируем
185
+				if ($pageid) {
186
+					// Обновление даты
187
+					$sql = sprintf('UPDATE %s SET `dateupdated` = %u WHERE `instrid` = %u', $GLOBALS['xoopsDB']->prefix($moduleDirName . '_instr'), $time, $instrid);
188
+					$GLOBALS['xoopsDB']->query($sql);
189
+					// Запись в лог
190
+					xoops_loadLanguage('main', 'userslog');
191
+					//userslog_insert( $objInsinstr->getVar('title') . ': ' . $objInspage->getVar('title'), _MD_USERSLOG_MODIFY_PAGE );
192
+					//
193
+					redirect_header('index.php', 3, _MD_INSTRUCTION_PAGEMODIFY);
194
+					// Если мы добавляем
195
+				} else {
196
+					// Инкримент комментов
197
+					$pageHandler->updateposts($uid, Request::getInt('status', 0, 'POST'), 'add');
198
+					// Инкремент страниц и обновление даты
199
+					$sql = sprintf('UPDATE %s SET `pages` = `pages` + 1, `dateupdated` = %u WHERE `instrid` = %u', $GLOBALS['xoopsDB']->prefix($moduleDirName . '_instr'), $time, $instrid);
200
+					$GLOBALS['xoopsDB']->query($sql);
201
+					// Запись в лог
202
+					xoops_loadLanguage('main', 'userslog');
203
+					//userslog_insert( $objInsinstr->getVar('title') . ': ' . $objInspage->getVar('title'), _MD_USERSLOG_SUBMIT_PAGE );
204
+					//
205
+					redirect_header('index.php', 3, _MD_INSTRUCTION_PAGEADDED);
206
+				}
207
+			}
208
+
209
+			// Задание тайтла
210
+			$xoopsOption['xoops_pagetitle'] = '';
211
+			// Шаблон
212
+			$GLOBALS['xoopsOption']['template_main'] = $moduleDirName . '_savepage.tpl';
213
+			// Заголовок
214
+			include_once $GLOBALS['xoops']->path('header.php');
215
+
216
+			// Выводим ошибки в шаблон
217
+			$GLOBALS['xoopsTpl']->assign('insErrorMsg', $objInspage->getHtmlErrors());
218
+		}
219
+		// Получаем форму
220
+		$form = $objInspage->getForm('submit.php', $instrid);
221
+
222
+		// Форма
223
+		$GLOBALS['xoopsTpl']->assign('insFormPage', $form->render());
224
+
225
+		// Подвал
226
+		include_once $GLOBALS['xoops']->path('footer.php');
227
+
228
+		break;
229 229
 }
Please login to merge, or discard this patch.
Spacing   +9 added lines, -9 removed lines patch added patch discarded remove patch
@@ -53,7 +53,7 @@  discard block
 block discarded – undo
53 53
             // Объект инструкции
54 54
             $objInsinstr = $instructionHandler->get($instrid);
55 55
             // Можно ли редактировать инструкцию в данной категории
56
-            if (!in_array($objInsinstr->getVar('cid'), $cat_edit)) {
56
+            if ( ! in_array($objInsinstr->getVar('cid'), $cat_edit)) {
57 57
                 redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_EDITPAGE);
58 58
             }
59 59
             // Создание новой страницы
@@ -66,7 +66,7 @@  discard block
 block discarded – undo
66 66
             // Объект инструкции
67 67
             $objInsinstr = $instructionHandler->get($instrid);
68 68
             // Можно ли добавлять инструкции в данной категории
69
-            if (!in_array($objInsinstr->getVar('cid'), $cat_submit)) {
69
+            if ( ! in_array($objInsinstr->getVar('cid'), $cat_submit)) {
70 70
                 redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMITPAGE);
71 71
             }
72 72
         } else {
@@ -101,7 +101,7 @@  discard block
 block discarded – undo
101 101
     case 'savepage':
102 102
 
103 103
         // Проверка
104
-        if (!$GLOBALS['xoopsSecurity']->check()) {
104
+        if ( ! $GLOBALS['xoopsSecurity']->check()) {
105 105
             redirect_header('index.php', 3, implode(',', $GLOBALS['xoopsSecurity']->getErrors()));
106 106
         }
107 107
 
@@ -114,7 +114,7 @@  discard block
 block discarded – undo
114 114
             // Объект инструкции
115 115
             $objInsinstr = $instructionHandler->get($objInspage->getVar('instrid'));
116 116
             // Можно ли редактировать инструкцию в данной категории
117
-            if (!in_array($objInsinstr->getVar('cid'), $cat_edit)) {
117
+            if ( ! in_array($objInsinstr->getVar('cid'), $cat_edit)) {
118 118
                 redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_EDITPAGE);
119 119
             }
120 120
         } elseif ($instrid) {
@@ -122,7 +122,7 @@  discard block
 block discarded – undo
122 122
             // Объект инструкции
123 123
             $objInsinstr = $instructionHandler->get($instrid);
124 124
             // Можно ли добавлять инструкции в данной категории
125
-            if (!in_array($objInsinstr->getVar('cid'), $cat_submit)) {
125
+            if ( ! in_array($objInsinstr->getVar('cid'), $cat_submit)) {
126 126
                 redirect_header('index.php', 3, _MD_INSTRUCTION_NOPERM_SUBMITPAGE);
127 127
             }
128 128
 
@@ -151,18 +151,18 @@  discard block
 block discarded – undo
151 151
         $objInspage->setVar('description', Request::getText('description', '', 'POST'));
152 152
 
153 153
         // Проверка категорий
154
-        if (!$pageid && !$instrid) {
155
-            $err         = true;
154
+        if ( ! $pageid && ! $instrid) {
155
+            $err = true;
156 156
             $message_err .= _MD_INSTRUCTION_ERR_INSTR . '<br>';
157 157
         }
158 158
         // Проверка веса
159 159
         if (0 == $weight) {
160
-            $err         = true;
160
+            $err = true;
161 161
             $message_err .= _MD_INSTRUCTION_ERR_WEIGHT . '<br>';
162 162
         }
163 163
         // Проверка родительской страницы
164 164
         if ($pageid && ($pageid == $pid)) {
165
-            $err         = true;
165
+            $err = true;
166 166
             $message_err .= _MD_INSTRUCTION_ERR_PPAGE . '<br>';
167 167
         }
168 168
         // Если были ошибки
Please login to merge, or discard this patch.
class/common/ServerStats.php 2 patches
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -17,60 +17,60 @@
 block discarded – undo
17 17
  */
18 18
 trait ServerStats
19 19
 {
20
-    /**
21
-     * serverStats()
22
-     *
23
-     * @return string
24
-     */
25
-    public static function getServerStats()
26
-    {
27
-        //mb    $wfdownloads = WfdownloadsWfdownloads::getInstance();
28
-        $moduleDirName      = basename(dirname(dirname(__DIR__)));
29
-        $moduleDirNameUpper = strtoupper($moduleDirName);
30
-        xoops_loadLanguage('common', $moduleDirName);
31
-        $html = '';
32
-        //        $sql   = 'SELECT metavalue';
33
-        //        $sql   .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_meta');
34
-        //        $sql   .= " WHERE metakey='version' LIMIT 1";
35
-        //        $query = $GLOBALS['xoopsDB']->query($sql);
36
-        //        list($meta) = $GLOBALS['xoopsDB']->fetchRow($query);
37
-        $html .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "</legend>\n";
38
-        $html .= "<div style='padding: 8px;'>\n";
39
-        //        $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "</div>\n";
40
-        //        $html .= "<br>\n";
41
-        //        $html .= "<br>\n";
42
-        $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "</div>\n";
43
-        $html .= "<ul>\n";
44
-        //
45
-        $gdlib = function_exists('gd_info') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>';
46
-        $html  .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib;
47
-        if (function_exists('gd_info')) {
48
-            if (true === ($gdlib = gd_info())) {
49
-                $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>';
50
-            }
51
-        }
52
-        //
53
-        //    $safemode = ini_get('safe_mode') ? constant('CO_' . $moduleDirNameUpper . '_ON') . constant('CO_' . $moduleDirNameUpper . '_SAFEMODEPROBLEMS : constant('CO_' . $moduleDirNameUpper . '_OFF');
54
-        //    $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SAFEMODESTATUS . $safemode;
55
-        //
56
-        //    $registerglobals = (!ini_get('register_globals')) ? "<span style=\"color: green;\">" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>' : "<span style=\"color: red;\">" . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>';
57
-        //    $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals;
58
-        //
59
-        $downloads = ini_get('file_uploads') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>';
60
-        $html      .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads;
61
-        //
62
-        $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . ini_get('upload_max_filesize') . "</span></b>\n";
63
-        $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . ini_get('post_max_size') . "</span></b>\n";
64
-        $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . ini_get('memory_limit') . "</span></b>\n";
65
-        $html .= "</ul>\n";
66
-        $html .= "<ul>\n";
67
-        $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' <b>' . XOOPS_ROOT_PATH . "</b>\n";
68
-        $html .= "</ul>\n";
69
-        $html .= "<br>\n";
70
-        $html .= constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n";
71
-        $html .= '</div>';
72
-        $html .= '</fieldset><br>';
20
+	/**
21
+	 * serverStats()
22
+	 *
23
+	 * @return string
24
+	 */
25
+	public static function getServerStats()
26
+	{
27
+		//mb    $wfdownloads = WfdownloadsWfdownloads::getInstance();
28
+		$moduleDirName      = basename(dirname(dirname(__DIR__)));
29
+		$moduleDirNameUpper = strtoupper($moduleDirName);
30
+		xoops_loadLanguage('common', $moduleDirName);
31
+		$html = '';
32
+		//        $sql   = 'SELECT metavalue';
33
+		//        $sql   .= ' FROM ' . $GLOBALS['xoopsDB']->prefix('wfdownloads_meta');
34
+		//        $sql   .= " WHERE metakey='version' LIMIT 1";
35
+		//        $query = $GLOBALS['xoopsDB']->query($sql);
36
+		//        list($meta) = $GLOBALS['xoopsDB']->fetchRow($query);
37
+		$html .= "<fieldset><legend style='font-weight: bold; color: #900;'>" . constant('CO_' . $moduleDirNameUpper . '_IMAGEINFO') . "</legend>\n";
38
+		$html .= "<div style='padding: 8px;'>\n";
39
+		//        $html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_METAVERSION') . $meta . "</div>\n";
40
+		//        $html .= "<br>\n";
41
+		//        $html .= "<br>\n";
42
+		$html .= '<div>' . constant('CO_' . $moduleDirNameUpper . '_SPHPINI') . "</div>\n";
43
+		$html .= "<ul>\n";
44
+		//
45
+		$gdlib = function_exists('gd_info') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>';
46
+		$html  .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib;
47
+		if (function_exists('gd_info')) {
48
+			if (true === ($gdlib = gd_info())) {
49
+				$html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>';
50
+			}
51
+		}
52
+		//
53
+		//    $safemode = ini_get('safe_mode') ? constant('CO_' . $moduleDirNameUpper . '_ON') . constant('CO_' . $moduleDirNameUpper . '_SAFEMODEPROBLEMS : constant('CO_' . $moduleDirNameUpper . '_OFF');
54
+		//    $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SAFEMODESTATUS . $safemode;
55
+		//
56
+		//    $registerglobals = (!ini_get('register_globals')) ? "<span style=\"color: green;\">" . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>' : "<span style=\"color: red;\">" . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>';
57
+		//    $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals;
58
+		//
59
+		$downloads = ini_get('file_uploads') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>';
60
+		$html      .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads;
61
+		//
62
+		$html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . ini_get('upload_max_filesize') . "</span></b>\n";
63
+		$html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . ini_get('post_max_size') . "</span></b>\n";
64
+		$html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MEMORYLIMIT') . ' <b><span style="color: blue;">' . ini_get('memory_limit') . "</span></b>\n";
65
+		$html .= "</ul>\n";
66
+		$html .= "<ul>\n";
67
+		$html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERPATH') . ' <b>' . XOOPS_ROOT_PATH . "</b>\n";
68
+		$html .= "</ul>\n";
69
+		$html .= "<br>\n";
70
+		$html .= constant('CO_' . $moduleDirNameUpper . '_UPLOADPATHDSC') . "\n";
71
+		$html .= '</div>';
72
+		$html .= '</fieldset><br>';
73 73
 
74
-        return $html;
75
-    }
74
+		return $html;
75
+	}
76 76
 }
Please login to merge, or discard this patch.
Spacing   +2 added lines, -2 removed lines patch added patch discarded remove patch
@@ -43,7 +43,7 @@  discard block
 block discarded – undo
43 43
         $html .= "<ul>\n";
44 44
         //
45 45
         $gdlib = function_exists('gd_info') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_GDON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_GDOFF') . '</span>';
46
-        $html  .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib;
46
+        $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBSTATUS') . $gdlib;
47 47
         if (function_exists('gd_info')) {
48 48
             if (true === ($gdlib = gd_info())) {
49 49
                 $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_GDLIBVERSION') . '<b>' . $gdlib['GD Version'] . '</b>';
@@ -57,7 +57,7 @@  discard block
 block discarded – undo
57 57
         //    $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_REGISTERGLOBALS . $registerglobals;
58 58
         //
59 59
         $downloads = ini_get('file_uploads') ? '<span style="color: green;">' . constant('CO_' . $moduleDirNameUpper . '_ON') . '</span>' : '<span style="color: red;">' . constant('CO_' . $moduleDirNameUpper . '_OFF') . '</span>';
60
-        $html      .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads;
60
+        $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_SERVERUPLOADSTATUS') . $downloads;
61 61
         //
62 62
         $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXUPLOADSIZE') . ' <b><span style="color: blue;">' . ini_get('upload_max_filesize') . "</span></b>\n";
63 63
         $html .= '<li>' . constant('CO_' . $moduleDirNameUpper . '_MAXPOSTSIZE') . ' <b><span style="color: blue;">' . ini_get('post_max_size') . "</span></b>\n";
Please login to merge, or discard this patch.
class/common/FilesManagement.php 2 patches
Spacing   +20 added lines, -20 removed lines patch added patch discarded remove patch
@@ -28,8 +28,8 @@  discard block
 block discarded – undo
28 28
     public static function createFolder($folder)
29 29
     {
30 30
         try {
31
-            if (!file_exists($folder)) {
32
-                if (!mkdir($folder) && !is_dir($folder)) {
31
+            if ( ! file_exists($folder)) {
32
+                if ( ! mkdir($folder) && ! is_dir($folder)) {
33 33
                     throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder));
34 34
                 }
35 35
 
@@ -59,7 +59,7 @@  discard block
 block discarded – undo
59 59
     public static function recurseCopy($src, $dst)
60 60
     {
61 61
         $dir = opendir($src);
62
-        if (!mkdir($dst) && !is_dir($dst)) {
62
+        if ( ! mkdir($dst) && ! is_dir($dst)) {
63 63
             throw new \RuntimeException('The directory ' . $dst . ' could not be created.');
64 64
         }
65 65
         while (false !== ($file = readdir($dir))) {
@@ -88,7 +88,7 @@  discard block
 block discarded – undo
88 88
     public static function deleteDirectory($src)
89 89
     {
90 90
         // Only continue if user is a 'global' Admin
91
-        if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
91
+        if ( ! ($GLOBALS['xoopsUser'] instanceof \XoopsUser) || ! $GLOBALS['xoopsUser']->isAdmin()) {
92 92
             return false;
93 93
         }
94 94
 
@@ -102,12 +102,12 @@  discard block
 block discarded – undo
102 102
                 $fileInfo = new \SplFileInfo("{$src}/{$v}");
103 103
                 if ($fileInfo->isDir()) {
104 104
                     // recursively handle subdirectories
105
-                    if (!$success = self::deleteDirectory($fileInfo->getRealPath())) {
105
+                    if ( ! $success = self::deleteDirectory($fileInfo->getRealPath())) {
106 106
                         break;
107 107
                     }
108 108
                 } else {
109 109
                     // delete the file
110
-                    if (!($success = unlink($fileInfo->getRealPath()))) {
110
+                    if ( ! ($success = unlink($fileInfo->getRealPath()))) {
111 111
                         break;
112 112
                     }
113 113
                 }
@@ -136,12 +136,12 @@  discard block
 block discarded – undo
136 136
     public static function rrmdir($src)
137 137
     {
138 138
         // Only continue if user is a 'global' Admin
139
-        if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
139
+        if ( ! ($GLOBALS['xoopsUser'] instanceof \XoopsUser) || ! $GLOBALS['xoopsUser']->isAdmin()) {
140 140
             return false;
141 141
         }
142 142
 
143 143
         // If source is not a directory stop processing
144
-        if (!is_dir($src)) {
144
+        if ( ! is_dir($src)) {
145 145
             return false;
146 146
         }
147 147
 
@@ -153,15 +153,15 @@  discard block
 block discarded – undo
153 153
             if ($fObj->isFile()) {
154 154
                 $filename = $fObj->getPathname();
155 155
                 $fObj     = null; // clear this iterator object to close the file
156
-                if (!unlink($filename)) {
156
+                if ( ! unlink($filename)) {
157 157
                     return false; // couldn't delete the file
158 158
                 }
159
-            } elseif (!$fObj->isDot() && $fObj->isDir()) {
159
+            } elseif ( ! $fObj->isDot() && $fObj->isDir()) {
160 160
                 // Try recursively on directory
161 161
                 self::rrmdir($fObj->getPathname());
162 162
             }
163 163
         }
164
-        $iterator = null;   // clear iterator Obj to close file/directory
164
+        $iterator = null; // clear iterator Obj to close file/directory
165 165
         return rmdir($src); // remove the directory & return results
166 166
     }
167 167
 
@@ -176,17 +176,17 @@  discard block
 block discarded – undo
176 176
     public static function rmove($src, $dest)
177 177
     {
178 178
         // Only continue if user is a 'global' Admin
179
-        if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
179
+        if ( ! ($GLOBALS['xoopsUser'] instanceof \XoopsUser) || ! $GLOBALS['xoopsUser']->isAdmin()) {
180 180
             return false;
181 181
         }
182 182
 
183 183
         // If source is not a directory stop processing
184
-        if (!is_dir($src)) {
184
+        if ( ! is_dir($src)) {
185 185
             return false;
186 186
         }
187 187
 
188 188
         // If the destination directory does not exist and could not be created stop processing
189
-        if (!is_dir($dest) && !mkdir($dest, 0755)) {
189
+        if ( ! is_dir($dest) && ! mkdir($dest, 0755)) {
190 190
             return false;
191 191
         }
192 192
 
@@ -195,13 +195,13 @@  discard block
 block discarded – undo
195 195
         foreach ($iterator as $fObj) {
196 196
             if ($fObj->isFile()) {
197 197
                 rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
198
-            } elseif (!$fObj->isDot() && $fObj->isDir()) {
198
+            } elseif ( ! $fObj->isDot() && $fObj->isDir()) {
199 199
                 // Try recursively on directory
200 200
                 self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
201 201
                 //                rmdir($fObj->getPath()); // now delete the directory
202 202
             }
203 203
         }
204
-        $iterator = null;   // clear iterator Obj to close file/directory
204
+        $iterator = null; // clear iterator Obj to close file/directory
205 205
         return rmdir($src); // remove the directory & return results
206 206
     }
207 207
 
@@ -219,17 +219,17 @@  discard block
 block discarded – undo
219 219
     public static function rcopy($src, $dest)
220 220
     {
221 221
         // Only continue if user is a 'global' Admin
222
-        if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
222
+        if ( ! ($GLOBALS['xoopsUser'] instanceof \XoopsUser) || ! $GLOBALS['xoopsUser']->isAdmin()) {
223 223
             return false;
224 224
         }
225 225
 
226 226
         // If source is not a directory stop processing
227
-        if (!is_dir($src)) {
227
+        if ( ! is_dir($src)) {
228 228
             return false;
229 229
         }
230 230
 
231 231
         // If the destination directory does not exist and could not be created stop processing
232
-        if (!is_dir($dest) && !mkdir($dest, 0755)) {
232
+        if ( ! is_dir($dest) && ! mkdir($dest, 0755)) {
233 233
             return false;
234 234
         }
235 235
 
@@ -238,7 +238,7 @@  discard block
 block discarded – undo
238 238
         foreach ($iterator as $fObj) {
239 239
             if ($fObj->isFile()) {
240 240
                 copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
241
-            } elseif (!$fObj->isDot() && $fObj->isDir()) {
241
+            } elseif ( ! $fObj->isDot() && $fObj->isDir()) {
242 242
                 self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
243 243
             }
244 244
         }
Please login to merge, or discard this patch.
Indentation   +226 added lines, -226 removed lines patch added patch discarded remove patch
@@ -17,230 +17,230 @@
 block discarded – undo
17 17
  */
18 18
 trait FilesManagement
19 19
 {
20
-    /**
21
-     * Function responsible for checking if a directory exists, we can also write in and create an index.html file
22
-     *
23
-     * @param string $folder The full path of the directory to check
24
-     *
25
-     * @return void
26
-     * @throws \RuntimeException
27
-     */
28
-    public static function createFolder($folder)
29
-    {
30
-        try {
31
-            if (!file_exists($folder)) {
32
-                if (!mkdir($folder) && !is_dir($folder)) {
33
-                    throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder));
34
-                }
35
-
36
-                file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>');
37
-            }
38
-        } catch (\Exception $e) {
39
-            echo 'Caught exception: ', $e->getMessage(), "\n", '<br>';
40
-        }
41
-    }
42
-
43
-    /**
44
-     * @param $file
45
-     * @param $folder
46
-     * @return bool
47
-     */
48
-    public static function copyFile($file, $folder)
49
-    {
50
-        return copy($file, $folder);
51
-    }
52
-
53
-    /**
54
-     * @param $src
55
-     * @param $dst
56
-     * @throws \RuntimeException
57
-     */
58
-    public static function recurseCopy($src, $dst)
59
-    {
60
-        $dir = opendir($src);
61
-        if (!mkdir($dst) && !is_dir($dst)) {
62
-            throw new \RuntimeException('The directory ' . $dst . ' could not be created.');
63
-        }
64
-        while (false !== ($file = readdir($dir))) {
65
-            if (('.' !== $file) && ('..' !== $file)) {
66
-                if (is_dir($src . '/' . $file)) {
67
-                    self::recurseCopy($src . '/' . $file, $dst . '/' . $file);
68
-                } else {
69
-                    copy($src . '/' . $file, $dst . '/' . $file);
70
-                }
71
-            }
72
-        }
73
-        closedir($dir);
74
-    }
75
-
76
-    /**
77
-     *
78
-     * Remove files and (sub)directories
79
-     *
80
-     * @param string $src source directory to delete
81
-     *
82
-     * @uses \Xmf\Module\Helper::getHelper()
83
-     * @uses \Xmf\Module\Helper::isUserAdmin()
84
-     *
85
-     * @return bool true on success
86
-     */
87
-    public static function deleteDirectory($src)
88
-    {
89
-        // Only continue if user is a 'global' Admin
90
-        if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
91
-            return false;
92
-        }
93
-
94
-        $success = true;
95
-        // remove old files
96
-        $dirInfo = new \SplFileInfo($src);
97
-        // validate is a directory
98
-        if ($dirInfo->isDir()) {
99
-            $fileList = array_diff(scandir($src, SCANDIR_SORT_NONE), ['..', '.']);
100
-            foreach ($fileList as $k => $v) {
101
-                $fileInfo = new \SplFileInfo("{$src}/{$v}");
102
-                if ($fileInfo->isDir()) {
103
-                    // recursively handle subdirectories
104
-                    if (!$success = self::deleteDirectory($fileInfo->getRealPath())) {
105
-                        break;
106
-                    }
107
-                } else {
108
-                    // delete the file
109
-                    if (!($success = unlink($fileInfo->getRealPath()))) {
110
-                        break;
111
-                    }
112
-                }
113
-            }
114
-            // now delete this (sub)directory if all the files are gone
115
-            if ($success) {
116
-                $success = rmdir($dirInfo->getRealPath());
117
-            }
118
-        } else {
119
-            // input is not a valid directory
120
-            $success = false;
121
-        }
122
-        return $success;
123
-    }
124
-
125
-    /**
126
-     *
127
-     * Recursively remove directory
128
-     *
129
-     * @todo currently won't remove directories with hidden files, should it?
130
-     *
131
-     * @param string $src directory to remove (delete)
132
-     *
133
-     * @return bool true on success
134
-     */
135
-    public static function rrmdir($src)
136
-    {
137
-        // Only continue if user is a 'global' Admin
138
-        if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
139
-            return false;
140
-        }
141
-
142
-        // If source is not a directory stop processing
143
-        if (!is_dir($src)) {
144
-            return false;
145
-        }
146
-
147
-        $success = true;
148
-
149
-        // Open the source directory to read in files
150
-        $iterator = new \DirectoryIterator($src);
151
-        foreach ($iterator as $fObj) {
152
-            if ($fObj->isFile()) {
153
-                $filename = $fObj->getPathname();
154
-                $fObj     = null; // clear this iterator object to close the file
155
-                if (!unlink($filename)) {
156
-                    return false; // couldn't delete the file
157
-                }
158
-            } elseif (!$fObj->isDot() && $fObj->isDir()) {
159
-                // Try recursively on directory
160
-                self::rrmdir($fObj->getPathname());
161
-            }
162
-        }
163
-        $iterator = null;   // clear iterator Obj to close file/directory
164
-        return rmdir($src); // remove the directory & return results
165
-    }
166
-
167
-    /**
168
-     * Recursively move files from one directory to another
169
-     *
170
-     * @param string $src  - Source of files being moved
171
-     * @param string $dest - Destination of files being moved
172
-     *
173
-     * @return bool true on success
174
-     */
175
-    public static function rmove($src, $dest)
176
-    {
177
-        // Only continue if user is a 'global' Admin
178
-        if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
179
-            return false;
180
-        }
181
-
182
-        // If source is not a directory stop processing
183
-        if (!is_dir($src)) {
184
-            return false;
185
-        }
186
-
187
-        // If the destination directory does not exist and could not be created stop processing
188
-        if (!is_dir($dest) && !mkdir($dest, 0755)) {
189
-            return false;
190
-        }
191
-
192
-        // Open the source directory to read in files
193
-        $iterator = new \DirectoryIterator($src);
194
-        foreach ($iterator as $fObj) {
195
-            if ($fObj->isFile()) {
196
-                rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
197
-            } elseif (!$fObj->isDot() && $fObj->isDir()) {
198
-                // Try recursively on directory
199
-                self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
200
-                //                rmdir($fObj->getPath()); // now delete the directory
201
-            }
202
-        }
203
-        $iterator = null;   // clear iterator Obj to close file/directory
204
-        return rmdir($src); // remove the directory & return results
205
-    }
206
-
207
-    /**
208
-     * Recursively copy directories and files from one directory to another
209
-     *
210
-     * @param string $src  - Source of files being moved
211
-     * @param string $dest - Destination of files being moved
212
-     *
213
-     * @uses \Xmf\Module\Helper::getHelper()
214
-     * @uses \Xmf\Module\Helper::isUserAdmin()
215
-     *
216
-     * @return bool true on success
217
-     */
218
-    public static function rcopy($src, $dest)
219
-    {
220
-        // Only continue if user is a 'global' Admin
221
-        if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
222
-            return false;
223
-        }
224
-
225
-        // If source is not a directory stop processing
226
-        if (!is_dir($src)) {
227
-            return false;
228
-        }
229
-
230
-        // If the destination directory does not exist and could not be created stop processing
231
-        if (!is_dir($dest) && !mkdir($dest, 0755)) {
232
-            return false;
233
-        }
234
-
235
-        // Open the source directory to read in files
236
-        $iterator = new \DirectoryIterator($src);
237
-        foreach ($iterator as $fObj) {
238
-            if ($fObj->isFile()) {
239
-                copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
240
-            } elseif (!$fObj->isDot() && $fObj->isDir()) {
241
-                self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
242
-            }
243
-        }
244
-        return true;
245
-    }
20
+	/**
21
+	 * Function responsible for checking if a directory exists, we can also write in and create an index.html file
22
+	 *
23
+	 * @param string $folder The full path of the directory to check
24
+	 *
25
+	 * @return void
26
+	 * @throws \RuntimeException
27
+	 */
28
+	public static function createFolder($folder)
29
+	{
30
+		try {
31
+			if (!file_exists($folder)) {
32
+				if (!mkdir($folder) && !is_dir($folder)) {
33
+					throw new \RuntimeException(sprintf('Unable to create the %s directory', $folder));
34
+				}
35
+
36
+				file_put_contents($folder . '/index.html', '<script>history.go(-1);</script>');
37
+			}
38
+		} catch (\Exception $e) {
39
+			echo 'Caught exception: ', $e->getMessage(), "\n", '<br>';
40
+		}
41
+	}
42
+
43
+	/**
44
+	 * @param $file
45
+	 * @param $folder
46
+	 * @return bool
47
+	 */
48
+	public static function copyFile($file, $folder)
49
+	{
50
+		return copy($file, $folder);
51
+	}
52
+
53
+	/**
54
+	 * @param $src
55
+	 * @param $dst
56
+	 * @throws \RuntimeException
57
+	 */
58
+	public static function recurseCopy($src, $dst)
59
+	{
60
+		$dir = opendir($src);
61
+		if (!mkdir($dst) && !is_dir($dst)) {
62
+			throw new \RuntimeException('The directory ' . $dst . ' could not be created.');
63
+		}
64
+		while (false !== ($file = readdir($dir))) {
65
+			if (('.' !== $file) && ('..' !== $file)) {
66
+				if (is_dir($src . '/' . $file)) {
67
+					self::recurseCopy($src . '/' . $file, $dst . '/' . $file);
68
+				} else {
69
+					copy($src . '/' . $file, $dst . '/' . $file);
70
+				}
71
+			}
72
+		}
73
+		closedir($dir);
74
+	}
75
+
76
+	/**
77
+	 *
78
+	 * Remove files and (sub)directories
79
+	 *
80
+	 * @param string $src source directory to delete
81
+	 *
82
+	 * @uses \Xmf\Module\Helper::getHelper()
83
+	 * @uses \Xmf\Module\Helper::isUserAdmin()
84
+	 *
85
+	 * @return bool true on success
86
+	 */
87
+	public static function deleteDirectory($src)
88
+	{
89
+		// Only continue if user is a 'global' Admin
90
+		if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
91
+			return false;
92
+		}
93
+
94
+		$success = true;
95
+		// remove old files
96
+		$dirInfo = new \SplFileInfo($src);
97
+		// validate is a directory
98
+		if ($dirInfo->isDir()) {
99
+			$fileList = array_diff(scandir($src, SCANDIR_SORT_NONE), ['..', '.']);
100
+			foreach ($fileList as $k => $v) {
101
+				$fileInfo = new \SplFileInfo("{$src}/{$v}");
102
+				if ($fileInfo->isDir()) {
103
+					// recursively handle subdirectories
104
+					if (!$success = self::deleteDirectory($fileInfo->getRealPath())) {
105
+						break;
106
+					}
107
+				} else {
108
+					// delete the file
109
+					if (!($success = unlink($fileInfo->getRealPath()))) {
110
+						break;
111
+					}
112
+				}
113
+			}
114
+			// now delete this (sub)directory if all the files are gone
115
+			if ($success) {
116
+				$success = rmdir($dirInfo->getRealPath());
117
+			}
118
+		} else {
119
+			// input is not a valid directory
120
+			$success = false;
121
+		}
122
+		return $success;
123
+	}
124
+
125
+	/**
126
+	 *
127
+	 * Recursively remove directory
128
+	 *
129
+	 * @todo currently won't remove directories with hidden files, should it?
130
+	 *
131
+	 * @param string $src directory to remove (delete)
132
+	 *
133
+	 * @return bool true on success
134
+	 */
135
+	public static function rrmdir($src)
136
+	{
137
+		// Only continue if user is a 'global' Admin
138
+		if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
139
+			return false;
140
+		}
141
+
142
+		// If source is not a directory stop processing
143
+		if (!is_dir($src)) {
144
+			return false;
145
+		}
146
+
147
+		$success = true;
148
+
149
+		// Open the source directory to read in files
150
+		$iterator = new \DirectoryIterator($src);
151
+		foreach ($iterator as $fObj) {
152
+			if ($fObj->isFile()) {
153
+				$filename = $fObj->getPathname();
154
+				$fObj     = null; // clear this iterator object to close the file
155
+				if (!unlink($filename)) {
156
+					return false; // couldn't delete the file
157
+				}
158
+			} elseif (!$fObj->isDot() && $fObj->isDir()) {
159
+				// Try recursively on directory
160
+				self::rrmdir($fObj->getPathname());
161
+			}
162
+		}
163
+		$iterator = null;   // clear iterator Obj to close file/directory
164
+		return rmdir($src); // remove the directory & return results
165
+	}
166
+
167
+	/**
168
+	 * Recursively move files from one directory to another
169
+	 *
170
+	 * @param string $src  - Source of files being moved
171
+	 * @param string $dest - Destination of files being moved
172
+	 *
173
+	 * @return bool true on success
174
+	 */
175
+	public static function rmove($src, $dest)
176
+	{
177
+		// Only continue if user is a 'global' Admin
178
+		if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
179
+			return false;
180
+		}
181
+
182
+		// If source is not a directory stop processing
183
+		if (!is_dir($src)) {
184
+			return false;
185
+		}
186
+
187
+		// If the destination directory does not exist and could not be created stop processing
188
+		if (!is_dir($dest) && !mkdir($dest, 0755)) {
189
+			return false;
190
+		}
191
+
192
+		// Open the source directory to read in files
193
+		$iterator = new \DirectoryIterator($src);
194
+		foreach ($iterator as $fObj) {
195
+			if ($fObj->isFile()) {
196
+				rename($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
197
+			} elseif (!$fObj->isDot() && $fObj->isDir()) {
198
+				// Try recursively on directory
199
+				self::rmove($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
200
+				//                rmdir($fObj->getPath()); // now delete the directory
201
+			}
202
+		}
203
+		$iterator = null;   // clear iterator Obj to close file/directory
204
+		return rmdir($src); // remove the directory & return results
205
+	}
206
+
207
+	/**
208
+	 * Recursively copy directories and files from one directory to another
209
+	 *
210
+	 * @param string $src  - Source of files being moved
211
+	 * @param string $dest - Destination of files being moved
212
+	 *
213
+	 * @uses \Xmf\Module\Helper::getHelper()
214
+	 * @uses \Xmf\Module\Helper::isUserAdmin()
215
+	 *
216
+	 * @return bool true on success
217
+	 */
218
+	public static function rcopy($src, $dest)
219
+	{
220
+		// Only continue if user is a 'global' Admin
221
+		if (!($GLOBALS['xoopsUser'] instanceof \XoopsUser) || !$GLOBALS['xoopsUser']->isAdmin()) {
222
+			return false;
223
+		}
224
+
225
+		// If source is not a directory stop processing
226
+		if (!is_dir($src)) {
227
+			return false;
228
+		}
229
+
230
+		// If the destination directory does not exist and could not be created stop processing
231
+		if (!is_dir($dest) && !mkdir($dest, 0755)) {
232
+			return false;
233
+		}
234
+
235
+		// Open the source directory to read in files
236
+		$iterator = new \DirectoryIterator($src);
237
+		foreach ($iterator as $fObj) {
238
+			if ($fObj->isFile()) {
239
+				copy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
240
+			} elseif (!$fObj->isDot() && $fObj->isDir()) {
241
+				self::rcopy($fObj->getPathname(), "{$dest}/" . $fObj->getFilename());
242
+			}
243
+		}
244
+		return true;
245
+	}
246 246
 }
Please login to merge, or discard this patch.