| 1 |  |  | <?php namespace Xoopsmodules\instruction; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | //if (!defined("XOOPS_ROOT_PATH")) { | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  | //	die("XOOPS root path not defined"); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | //} | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | include_once $GLOBALS['xoops']->path('include/common.php'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  |  * Class Instruction | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  |  * @package Xoopsmodules\instruction | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  |  */ | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  | class Instruction extends \XoopsObject | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  |     // constructor | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     public function __construct() | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |         //		$this->XoopsObject(); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |         $this->initVar('instrid', XOBJ_DTYPE_INT, null, false, 11); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |         $this->initVar('cid', XOBJ_DTYPE_INT, 0, false, 5); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |         $this->initVar('uid', XOBJ_DTYPE_INT, 0, false, 11); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 22 |  |  |         $this->initVar('title', XOBJ_DTYPE_TXTBOX, '', false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 23 |  |  |         $this->initVar('status', XOBJ_DTYPE_INT, 0, false, 1); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 24 |  |  |         $this->initVar('pages', XOBJ_DTYPE_INT, 0, false, 11); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 25 |  |  |         $this->initVar('description', XOBJ_DTYPE_TXTAREA, null, false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 26 |  |  |         $this->initVar('datecreated', XOBJ_DTYPE_INT, 0, false, 10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 27 |  |  |         $this->initVar('dateupdated', XOBJ_DTYPE_INT, 0, false, 10); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 28 |  |  |         $this->initVar('metakeywords', XOBJ_DTYPE_TXTBOX, '', false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 29 |  |  |         $this->initVar('metadescription', XOBJ_DTYPE_TXTBOX, '', false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 30 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 31 |  |  |         // Нет в таблице | 
            
                                                                                                            
                            
            
                                    
            
            
                | 32 |  |  |         $this->initVar('dohtml', XOBJ_DTYPE_INT, 1, false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 33 |  |  |         $this->initVar('dobr', XOBJ_DTYPE_INT, 0, false); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 34 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 35 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 36 |  |  |     /** | 
            
                                                                                                            
                            
            
                                    
            
            
                | 37 |  |  |      * @return mixed | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 38 |  |  |      */ | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |     public function getNewInstertId() | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |         $newEnreg = $GLOBALS['xoopsDB']->getInsertId(); | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |         return $newEnreg; | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |     } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 44 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 45 |  |  |     // Получаем форму | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 60 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 61 |  |  |         // Название формы | 
            
                                                                                                            
                            
            
                                    
            
            
                | 62 |  |  |         $title = $this->isNew() ? sprintf(_AM_INSTRUCTION_FORMADDINSTR) : sprintf(_AM_INSTRUCTION_FORMEDITINSTR); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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'); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 83 |  |  |  | 
            
                                                                                                            
                            
            
                                                                    
                                                                                                        
            
            
                | 84 |  | View Code Duplication |         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 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 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 |  |  | } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 126 |  |  |  | 
            
                                                        
            
                                    
            
            
                | 127 |  |  |  | 
            
                        
Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.
The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.
This check looks for comments that seem to be mostly valid code and reports them.