diff --git a/Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php b/Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php index ba5929307bad..53c8ce29e7a5 100755 --- a/Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php +++ b/Services/UIComponent/AdvancedSelectionList/classes/class.ilAdvancedSelectionListGUI.php @@ -443,7 +443,7 @@ public function getHTML(bool $a_only_cmd_list_asynch = false) : string $items = $this->getItems(); // do not show list, if no item is in list - if (count($items) == 0 && !$this->getAsynch() && $this->getGroupedList() == null) { + if (count($items) === 0 && !$this->getAsynch() && $this->getGroupedList() === null) { return ""; } @@ -477,11 +477,11 @@ public function getHTML(bool $a_only_cmd_list_asynch = false) : string $tpl->setCurrentBlock("asynch_request"); $tpl->setVariable("IMG_LOADER", ilUtil::getImagePath("loader.svg")); $tpl->parseCurrentBlock(); - } elseif ($this->getGroupedList() != null) { + } elseif ($this->getGroupedList() !== null) { $tpl->setVariable("GROUPED_LIST_HTML", $this->getGroupedList()->getHTML()); } else { foreach ($items as $item) { - $this->css_row = ($this->css_row != "tblrow1_mo") + $this->css_row = ($this->css_row !== "tblrow1_mo") ? "tblrow1_mo" : "tblrow2_mo"; @@ -506,16 +506,14 @@ public function getHTML(bool $a_only_cmd_list_asynch = false) : string } } - if ($this->getOnClickMode() == - self::ON_ITEM_CLICK_HREF || - $this->getItemLinkClass() != "") { + if ($this->getOnClickMode() === self::ON_ITEM_CLICK_HREF || $this->getItemLinkClass() !== "") { if ($item["frame"]) { $tpl->setCurrentBlock("frame"); $tpl->setVariable("TARGET_ITEM", $item["frame"]); $tpl->parseCurrentBlock(); } - if ($this->getItemLinkClass() != "") { + if ($this->getItemLinkClass() !== "") { $tpl->setCurrentBlock("item_link_class"); $tpl->setVariable("ITEM_LINK_CLASS", $this->getItemLinkClass()); $tpl->parseCurrentBlock(); @@ -543,8 +541,7 @@ public function getHTML(bool $a_only_cmd_list_asynch = false) : string } $tpl->setCurrentBlock("item"); - if ($this->getOnClickMode() == - self::ON_ITEM_CLICK_HREF) { + if ($this->getOnClickMode() === self::ON_ITEM_CLICK_HREF) { if ($item["prevent_background_click"]) { $tpl->setVariable("ONCLICK_ITEM", ''); } elseif ($item["onclick"] == "" && $item["frame"] != "") { // see #28730 @@ -558,24 +555,21 @@ public function getHTML(bool $a_only_cmd_list_asynch = false) : string 'onclick="' . "return " . $item["onclick"] . ";" . '"' ); } - } elseif ($this->getOnClickMode() == - self::ON_ITEM_CLICK_FORM_SUBMIT) { + } elseif ($this->getOnClickMode() === self::ON_ITEM_CLICK_FORM_SUBMIT) { $tpl->setVariable( "ONCLICK_ITEM", 'onclick="return il.AdvancedSelectionList.submitForm(\'' . $this->getId() . '\'' . ", '" . $this->form_mode["select_name"] . "','" . $item["value"] . "'," . "'" . $this->on_click_form_id . "','" . $this->form_mode["button_cmd"] . "');\"" ); - } elseif ($this->getOnClickMode() == - self::ON_ITEM_CLICK_FORM_SELECT) { + } elseif ($this->getOnClickMode() === self::ON_ITEM_CLICK_FORM_SELECT) { $tpl->setVariable( "ONCLICK_ITEM", 'onclick="return il.AdvancedSelectionList.selectForm(\'' . $this->getId() . '\'' . ", '" . $this->form_mode["select_name"] . "','" . $item["value"] . "'," . "'" . $item["title"] . "');\"" ); - } elseif ($this->getOnClickMode() == - self::ON_ITEM_CLICK_NOP) { + } elseif ($this->getOnClickMode() === self::ON_ITEM_CLICK_NOP) { $tpl->setVariable( "ONCLICK_ITEM", 'onclick="il.AdvancedSelectionList.clickNop(\'' . $this->getId() . '\'' . @@ -619,7 +613,7 @@ public function getHTML(bool $a_only_cmd_list_asynch = false) : string } // output hidden input, if click mode is form submission - if ($this->getOnClickMode() == self::ON_ITEM_CLICK_FORM_SUBMIT) { + if ($this->getOnClickMode() === self::ON_ITEM_CLICK_FORM_SUBMIT) { $tpl->setCurrentBlock("hidden_input"); $tpl->setVariable("HID", $this->getId()); $tpl->parseCurrentBlock(); @@ -630,7 +624,7 @@ public function getHTML(bool $a_only_cmd_list_asynch = false) : string } // output hidden input and initialize - if ($this->getOnClickMode() == self::ON_ITEM_CLICK_FORM_SELECT) { + if ($this->getOnClickMode() === self::ON_ITEM_CLICK_FORM_SELECT) { $tpl->setCurrentBlock("hidden_input"); $tpl->setVariable("HID", $this->getId()); $tpl->parseCurrentBlock(); @@ -649,7 +643,7 @@ public function getHTML(bool $a_only_cmd_list_asynch = false) : string return $tpl->get("cmd_table"); } - if ($this->getGroupedList() == null) { + if ($this->getGroupedList() === null) { $tpl->setCurrentBlock("dd_content"); if ($this->getPullRight()) { $tpl->setVariable("UL_CLASS", "dropdown-menu pull-right"); @@ -660,7 +654,7 @@ public function getHTML(bool $a_only_cmd_list_asynch = false) : string $tpl->parseCurrentBlock(); } - if ($this->getHeaderIcon() != self::NO_ICON) { + if ($this->getHeaderIcon() !== self::NO_ICON) { $tpl->setCurrentBlock("top_img"); switch ($this->getHeaderIcon()) { case self::ICON_CONFIG: @@ -690,7 +684,7 @@ public function getHTML(bool $a_only_cmd_list_asynch = false) : string $cfg["trigger_event"] = $this->getTriggerEvent(); $cfg["auto_hide"] = $this->getAutoHide(); - if ($this->getSelectCallback() != "") { + if ($this->getSelectCallback() !== "") { $cfg["select_callback"] = $this->getSelectCallback(); } $cfg["anchor_id"] = "ilAdvSelListAnchorElement_" . $this->getId(); @@ -707,8 +701,8 @@ public function getHTML(bool $a_only_cmd_list_asynch = false) : string //echo htmlentities(ilJsonUtil::encode($cfg)); $tpl->setVariable("TXT_SEL_TOP", $this->getListTitle()); - if ($this->getListTitle() == "" || $this->getAriaListTitle() != "") { - $aria_title = ($this->getAriaListTitle() != "") + if ($this->getListTitle() === "" || $this->getAriaListTitle() !== "") { + $aria_title = ($this->getAriaListTitle() !== "") ? $this->getAriaListTitle() : $this->lng->txt("actions"); $tpl->setVariable("TXT_ARIA_TOP", $aria_title); @@ -741,7 +735,7 @@ public function getHTML(bool $a_only_cmd_list_asynch = false) : string } - if ($this->getSelectionHeaderSpanClass() != "") { + if ($this->getSelectionHeaderSpanClass() !== "") { $tpl->setVariable( "CLASS_SEL_TOP_SPAN", $this->getSelectionHeaderSpanClass() diff --git a/Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php b/Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php index 38052cdb6231..d3d0a18ab184 100755 --- a/Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php +++ b/Services/UIComponent/CharSelector/classes/class.ilCharSelectorGUI.php @@ -77,7 +77,7 @@ public static function _isAllowed() : bool // with correct case for checking parent classes $class = false; foreach ($ilCtrl->getCallHistory() as $call) { - if ($call['mode'] == 'execComm') { + if ($call['mode'] === 'execComm') { $class = $call['class']; } } diff --git a/Services/UIComponent/CharSelector/classes/class.ilCharSelectorRadioGroupInputGUI.php b/Services/UIComponent/CharSelector/classes/class.ilCharSelectorRadioGroupInputGUI.php index 12e09054a5bb..9d18445f1396 100644 --- a/Services/UIComponent/CharSelector/classes/class.ilCharSelectorRadioGroupInputGUI.php +++ b/Services/UIComponent/CharSelector/classes/class.ilCharSelectorRadioGroupInputGUI.php @@ -35,9 +35,9 @@ public function checkInput() : bool return false; } - if ($this->int('char_selector_availability') == ilCharSelectorConfig::ENABLED - and trim(implode("", $this->strArray('char_selector_blocks'))) == "" - and trim($this->str('char_selector_custom_items')) == '') { + if ($this->int('char_selector_availability') === ilCharSelectorConfig::ENABLED + && trim(implode("", $this->strArray('char_selector_blocks'))) === "" + && trim($this->str('char_selector_custom_items')) === '') { $this->setAlert($lng->txt("char_selector_msg_blocks_or_custom_needed")); return false; } else { diff --git a/Services/UIComponent/CharSelector/classes/ilCharSelectorConfig.php b/Services/UIComponent/CharSelector/classes/ilCharSelectorConfig.php index db55b479d0a5..78a9b41ccf1f 100644 --- a/Services/UIComponent/CharSelector/classes/ilCharSelectorConfig.php +++ b/Services/UIComponent/CharSelector/classes/ilCharSelectorConfig.php @@ -302,7 +302,7 @@ public static function _getCurrentConfig(ilObjTest $a_test_obj = null) : self $admin_config = new self(self::CONTEXT_ADMIN); $admin_config->setAvailability($ilSetting->get('char_selector_availability')); $admin_config->setDefinition($ilSetting->get('char_selector_definition')); - if ($admin_config->getAvailability() == self::INACTIVE) { + if ($admin_config->getAvailability() === self::INACTIVE) { // a globally inactive selector can't be overwritten by users or tests return $admin_config; } @@ -312,7 +312,7 @@ public static function _getCurrentConfig(ilObjTest $a_test_obj = null) : self $test_config = new self(self::CONTEXT_TEST); $test_config->setAvailability($a_test_obj->getCharSelectorAvailability()); $test_config->setDefinition($a_test_obj->getCharSelectorDefinition()); - if ($test_config->getAvailability() != self::INHERIT) { + if ($test_config->getAvailability() !== self::INHERIT) { // a specific test configuration has precedence over user configuration return $test_config; } @@ -322,7 +322,7 @@ public static function _getCurrentConfig(ilObjTest $a_test_obj = null) : self $user_config = new self(self::CONTEXT_USER); $user_config->setAvailability($ilUser->getPref('char_selector_availability')); $user_config->setDefinition($ilUser->getPref('char_selector_definition')); - if ($user_config->getAvailability() != self::INHERIT) { + if ($user_config->getAvailability() !== self::INHERIT) { // take user specific config return $user_config; } else { @@ -419,16 +419,16 @@ public function setDefinition(string $a_definition = '') : void $this->custom_items = array(); // set the default definition to all unicode blocks - if (trim($a_definition) == '') { + if (trim($a_definition) === '') { $a_definition = "[all]"; } // analyze definition items $items = explode(' ', $a_definition); foreach ($items as $item) { - if (strlen($block_name = $this->extractUnicodeBlock($item))) { + if (($block_name = $this->extractUnicodeBlock($item)) !== '') { $this->added_blocks[] = $block_name; - } elseif ($item != '') { + } elseif ($item !== '') { $this->custom_items[] = trim($item); } } @@ -475,7 +475,7 @@ public function getBlockTitle(string $a_block_name) : string global $lng; $langvar = 'char_selector_unicode_' . $a_block_name; - if ($lng->txt($langvar) != '-' . $langvar . '-') { + if ($lng->txt($langvar) !== '-' . $langvar . '-') { return $lng->txt($langvar); } else { return self::$unicode_blocks[$a_block_name][0]; diff --git a/Services/UIComponent/Explorer/classes/class.ilExplorer.php b/Services/UIComponent/Explorer/classes/class.ilExplorer.php index c18d0f8295cc..ffc8fb76e6f5 100755 --- a/Services/UIComponent/Explorer/classes/class.ilExplorer.php +++ b/Services/UIComponent/Explorer/classes/class.ilExplorer.php @@ -196,7 +196,7 @@ public function setOrderColumn(string $a_column) : void public function setOrderDirection(string $a_direction) : void { - if ($a_direction == "desc") { + if ($a_direction === "desc") { $this->order_direction = $a_direction; } else { $this->order_direction = "asc"; @@ -318,11 +318,7 @@ public function isClickable( // only the type determines, wether an object should be clickable or not // but this method can be overwritten and make $exp->setFilterMode(IL_FM_NEGATIVE);use of the ref id // (this happens e.g. in class ilRepositoryExplorerGUI) - if ($this->is_clickable[$a_type] == "n") { - return false; - } else { - return true; - } + return $this->is_clickable[$a_type] !== "n"; } public function setPostSort(bool $a_sort) : void @@ -408,7 +404,7 @@ public function setOutput( } //echo "
-".$object["child"]."-".$this->forceExpanded($object["child"])."-"; //ask for FILTER - if ($this->filtered == false or $this->checkFilter($object["type"]) == false) { + if ($this->filtered === false || $this->checkFilter($object["type"]) === false) { if ($this->isVisible($object['child'], $object['type'])) { #echo 'CHILD getIndex() '.$object['child'].' parent: '.$this->getRoot(); if ($object["child"] != $this->getRoot()) { @@ -431,7 +427,7 @@ public function setOutput( } // fix explorer (sometimes explorer disappears) - if ($parent_index == 0) { + if ($parent_index === 0) { if (!$this->expand_all && !in_array($object["parent"], $this->expanded)) { $this->expanded[] = $object["parent"]; } @@ -541,9 +537,9 @@ public function getOutput() : string $tpl_tree = new ilTemplate("tpl.tree.html", true, true, "Services/UIComponent/Explorer"); // updater - if (($this->requestStr("ict") != "" || - $this->requestStr("collapseAll") != "" || - $this->requestStr("expandAll") != "") && $this->up_frame != "") { + if (($this->requestStr("ict") !== "" || + $this->requestStr("collapseAll") !== "" || + $this->requestStr("expandAll") !== "") && $this->up_frame !== "") { $tpl_tree->setCurrentBlock("updater"); $tpl_tree->setVariable("UPDATE_FRAME", $this->up_frame); $tpl_tree->setVariable("UPDATE_SCRIPT", $this->up_script); @@ -584,12 +580,12 @@ public function getOutput() : string $this->handleListEndTags($tpl_tree, $cur_depth, -1); $tpl_tree->setVariable("TREE_LEAD", ""); - if ($this->tree_lead != "") { + if ($this->tree_lead !== "") { $tpl_tree->setCurrentBlock("tree_lead"); $tpl_tree->setVariable("TREE_LEAD", $this->tree_lead); $tpl_tree->parseCurrentBlock(); } - if ($this->getId() != "") { + if ($this->getId() !== "") { $tpl_tree->setVariable("TREE_ID", 'id="' . $this->getId() . '_tree"'); } @@ -600,10 +596,10 @@ public function getOutput() : string $mtpl->setVariable("LOCATION_STYLESHEET", ilUtil::getStyleSheetLocation()); $mtpl->setVariable("BODY_CLASS", "il_Explorer"); $mtpl->addBlockFile("CONTENT", "content", "tpl.explorer.html"); - if ($this->getTitle() != "") { + if ($this->getTitle() !== "") { $mtpl->setVariable("TXT_EXPLORER_HEADER", $this->getTitle()); } - if ($this->getId() != "") { + if ($this->getId() !== "") { $mtpl->setVariable("ID", 'id="' . $this->getId() . '"'); } $mtpl->setVariable("IMG_SPACE", ilUtil::getImagePath("spacer.png", false)); @@ -688,7 +684,7 @@ public function formatObject( $pic = false; foreach ((array) $a_option["tab"] as $picture) { - if ($picture == 'plus') { + if ($picture === 'plus') { $tpl->setCurrentBlock("expander"); $tpl->setVariable("EXP_DESC", $lng->txt("collapsed")); $tpl->setVariable("LINK_NAME", $a_node_id); @@ -705,7 +701,7 @@ public function formatObject( $pic = true; } - if ($picture == 'forceexp') { + if ($picture === 'forceexp') { $tpl->setCurrentBlock("expander"); $tpl->setVariable("EXP_DESC", $lng->txt("expanded")); $target = $this->createTarget('+', $a_node_id); @@ -716,7 +712,7 @@ public function formatObject( $pic = true; } - if ($picture == 'minus' && $this->show_minus) { + if ($picture === 'minus' && $this->show_minus) { $tpl->setCurrentBlock("expander"); $tpl->setVariable("EXP_DESC", $lng->txt("expanded")); $tpl->setVariable("LINK_NAME", $a_node_id); @@ -753,7 +749,7 @@ public function formatObject( $tpl->parseCurrentBlock(); } - if (strlen($sel = $this->buildSelect($a_node_id, $a_option['type']))) { + if (($sel = $this->buildSelect($a_node_id, $a_option['type'])) !== '') { $tpl->setCurrentBlock('select'); $tpl->setVariable('OBJ_SEL', $sel); $tpl->parseCurrentBlock(); @@ -768,7 +764,7 @@ public function formatObject( $style_class = $this->getNodeStyleClass($a_node_id, $a_option["type"]); - if ($style_class != "") { + if ($style_class !== "") { $tpl->setVariable("A_CLASS", ' class="' . $style_class . '" '); } @@ -794,7 +790,7 @@ public function formatObject( ) ); $frame_target = $this->buildFrameTarget($a_option["type"], $a_node_id, $a_option["obj_id"]); - if ($frame_target != "") { + if ($frame_target !== "") { $tpl->setVariable("TARGET", " target=\"" . $frame_target . "\""); } } else { // output text only @@ -916,14 +912,14 @@ public function createTarget( // SET expand parameter: // positive if object is expanded // negative if object is compressed - $a_node_id = $a_type == '+' ? $a_node_id : -(int) $a_node_id; + $a_node_id = $a_type === '+' ? $a_node_id : -(int) $a_node_id; $sep = (is_int(strpos($this->expand_target, "?"))) ? "&" : "?"; // in current tree flag - $ict_str = ($a_highlighted_subtree || $this->highlighted == "") + $ict_str = ($a_highlighted_subtree || $this->highlighted === "") ? "&ict=1" : ""; if ($this->getAsynchExpanding()) { @@ -1003,7 +999,7 @@ public function addFilter(string $a_item) : bool if (is_array($this->filter)) { //run through filter foreach ($this->filter as $item) { - if ($item == $a_item) { + if ($item === $a_item) { return false; } } @@ -1024,7 +1020,7 @@ public function delFilter(string $a_item) : bool $tmp = array(); foreach ($this->filter as $item) { - if ($item != $a_item) { + if ($item !== $a_item) { $tmp[] = $item; } else { $deleted = 1; @@ -1036,11 +1032,7 @@ public function delFilter(string $a_item) : bool return false; } - if ($deleted == 1) { - return true; - } else { - return false; - } + return $deleted === 1; } /** @@ -1099,7 +1091,7 @@ public function checkFilter(string $a_item) : bool $ret = false; } - if ($this->getFilterMode() == IL_FM_NEGATIVE) { + if ($this->getFilterMode() === IL_FM_NEGATIVE) { return $ret; } else { return !$ret; @@ -1113,7 +1105,7 @@ public function sortNodes(array $a_nodes, $a_parent_obj_id) : array { $adm_node = null; foreach ($a_nodes as $key => $node) { - if ($node["type"] == "adm") { + if ($node["type"] === "adm") { $match = $key; $adm_node = $node; break; diff --git a/Services/UIComponent/Explorer2/classes/class.ilExplorerBaseGUI.php b/Services/UIComponent/Explorer2/classes/class.ilExplorerBaseGUI.php index 4cdeb64da21d..1d8521982ac5 100644 --- a/Services/UIComponent/Explorer2/classes/class.ilExplorerBaseGUI.php +++ b/Services/UIComponent/Explorer2/classes/class.ilExplorerBaseGUI.php @@ -252,7 +252,7 @@ public function getNodeTarget($a_node) : string */ public function getNodeOnClick($a_node) : string { - if ($this->select_postvar != "") { + if ($this->select_postvar !== "") { return $this->getSelectOnClick($a_node); } return ""; @@ -421,8 +421,8 @@ public function getOfflineMode() : bool */ public function handleCommand() : bool { - if ($this->requested_exp_cmd != "" && - $this->requested_exp_cont == $this->getContainerId()) { + if ($this->requested_exp_cmd !== "" && + $this->requested_exp_cont === $this->getContainerId()) { $cmd = $this->requested_exp_cmd; if (in_array($cmd, array("openNode", "closeNode", "getNodeAsync"))) { $this->$cmd(); @@ -479,7 +479,7 @@ public function getNodeAsync() : string $this->open_nodes[] = $root; } - if ($this->requested_node_id != "") { + if ($this->requested_node_id !== "") { $id = $this->getNodeIdForDomNodeId($this->requested_node_id); $this->setSearchTerm(ilUtil::stripSlashes($this->requested_searchterm)); $this->renderChilds($id, $etpl); @@ -568,7 +568,11 @@ public function getOnLoadCode() : string "html_data" => array() ); - return 'il.Explorer2.init(' . json_encode($config) . ', ' . json_encode($js_tree_config) . ');'; + return ( + 'il.Explorer2.init(' . + json_encode($config, JSON_THROW_ON_ERROR) . ', ' . + json_encode($js_tree_config, JSON_THROW_ON_ERROR) . ');' + ); } protected function getJSTreePlugins() : array @@ -586,11 +590,7 @@ public static function init(ilGlobalTemplateInterface $a_main_tpl = null) : void { global $DIC; - if ($a_main_tpl == null) { - $tpl = $DIC["tpl"]; - } else { - $tpl = $a_main_tpl; - } + $tpl = $a_main_tpl ?? $DIC["tpl"]; iljQueryUtil::initjQuery($tpl); @@ -675,7 +675,7 @@ public function renderNode($a_node, ilTemplate $tpl) : void $this->listItemStart($tpl, $a_node); // select mode? - if ($this->select_postvar != "" && $this->isNodeSelectable($a_node)) { + if ($this->select_postvar !== "" && $this->isNodeSelectable($a_node)) { if ($this->select_multi) { $tpl->setCurrentBlock("cb"); if (in_array($this->getNodeId($a_node), $this->selected_nodes)) { @@ -699,7 +699,7 @@ public function renderNode($a_node, ilTemplate $tpl) : void $tpl->touchBlock("hl"); } $tpl->setCurrentBlock("content"); - if ($this->getNodeIcon($a_node) != "") { + if ($this->getNodeIcon($a_node) !== "") { $tpl->setVariable("ICON", ilUtil::img($this->getNodeIcon($a_node), $this->getNodeIconAlt($a_node)) . " "); } $tpl->setVariable("CONTENT", $this->getNodeContent($a_node)); @@ -707,7 +707,7 @@ public function renderNode($a_node, ilTemplate $tpl) : void $tpl->setVariable("HREF", $this->getNodeHref($a_node)); } $target = $this->getNodeTarget($a_node); - if ($target != "") { + if ($target !== "") { $targetRelatedParams = array( 'target="' . $target . '"' ); @@ -723,7 +723,7 @@ public function renderNode($a_node, ilTemplate $tpl) : void $tpl->setVariable("A_CLASS", 'class="disabled"'); } else { $onclick = $this->getNodeOnClick($a_node); - if ($onclick != "") { + if ($onclick !== "") { $tpl->setVariable("ONCLICK", 'onclick="' . $onclick . '"'); } } @@ -751,7 +751,7 @@ final public function renderChilds($a_node_id, ilTemplate $tpl) : void $childs = $this->getChildsOfNode($a_node_id); $childs = $this->sortChilds($childs, $a_node_id); - if (count($childs) > 0 || ($this->getSearchTerm() != "" && $this->requested_node_id == $this->getDomNodeIdForNodeId($a_node_id))) { + if (count($childs) > 0 || ($this->getSearchTerm() !== "" && $this->requested_node_id === $this->getDomNodeIdForNodeId($a_node_id))) { // collect visible childs $visible_childs = []; @@ -770,15 +770,14 @@ final public function renderChilds($a_node_id, ilTemplate $tpl) : void // search field, if too many childs $any = false; - if ($this->getChildLimit() > 0 && $this->getChildLimit() < $cnt_child - || ($this->getSearchTerm() != "")) { + if (($this->getChildLimit() > 0 && $this->getChildLimit() < $cnt_child) || $this->getSearchTerm() !== "") { if (!$any) { $this->listStart($tpl); $any = true; } $tpl->setCurrentBlock("list_search"); $tpl->setVariable("SEARCH_CONTAINER_ID", $a_node_id); - if ($this->requested_node_id == $this->getDomNodeIdForNodeId($a_node_id)) { + if ($this->requested_node_id === $this->getDomNodeIdForNodeId($a_node_id)) { $tpl->setVariable("SEARCH_VAL", $this->getSearchTerm()); } $tpl->parseCurrentBlock(); diff --git a/Services/UIComponent/Explorer2/classes/class.ilExplorerSelectInputGUI.php b/Services/UIComponent/Explorer2/classes/class.ilExplorerSelectInputGUI.php index 9c89480e12fe..80432566b651 100644 --- a/Services/UIComponent/Explorer2/classes/class.ilExplorerSelectInputGUI.php +++ b/Services/UIComponent/Explorer2/classes/class.ilExplorerSelectInputGUI.php @@ -118,8 +118,8 @@ public function checkInput() : bool // check required if ($this->getRequired()) { - if ((!$this->multi_nodes && trim($this->getInput()) == "") || - ($this->multi_nodes && count($this->getInput()) == 0)) { + if ((!$this->multi_nodes && trim($this->getInput()) === "") || + ($this->multi_nodes && count($this->getInput()) === 0)) { $this->setAlert($lng->txt("msg_input_is_required")); return false; } @@ -151,7 +151,7 @@ public function render(string $a_mode = "property_form") : string $tpl = new ilTemplate("tpl.prop_expl_select.html", true, true, "Services/UIComponent/Explorer2"); - if ($a_mode != "property_form") { + if ($a_mode !== "property_form") { $tpl->touchBlock("tiny_presentation"); } diff --git a/Services/UIComponent/Explorer2/classes/class.ilTreeExplorerGUI.php b/Services/UIComponent/Explorer2/classes/class.ilTreeExplorerGUI.php index 90d61a0029a4..f23e1c5563eb 100644 --- a/Services/UIComponent/Explorer2/classes/class.ilTreeExplorerGUI.php +++ b/Services/UIComponent/Explorer2/classes/class.ilTreeExplorerGUI.php @@ -133,7 +133,7 @@ protected function preloadChilds() : void $this->all_childs[$s["child"]] = $s; } - if ($this->order_field != "") { + if ($this->order_field !== "") { foreach ($this->childs as $k => $childs) { $this->childs[$k] = ilArrayUtil::sortArray( $childs, @@ -145,7 +145,7 @@ protected function preloadChilds() : void } // sort childs and store prev/next reference - if ($this->order_field == "") { + if ($this->order_field === "") { $this->all_childs = ilArrayUtil::sortArray($this->all_childs, "lft", "asc", true, true); $prev = false; @@ -174,14 +174,14 @@ public function getSuccessorNode( $a_node_id, string $a_type = "" ) { - if ($this->order_field != "") { + if ($this->order_field !== "") { die("ilTreeExplorerGUI::getSuccessorNode not implemented for order field " . $this->order_field); } if ($this->preloaded) { $next_id = $a_node_id; - while (($next_id = $this->all_childs[$next_id]["next_node_id"]) && $a_type != "" && - $this->all_childs[$next_id]["type"] != $a_type) { + while (($next_id = $this->all_childs[$next_id]["next_node_id"]) && $a_type !== "" && + $this->all_childs[$next_id]["type"] !== $a_type) { // do nothing } if ($next_id) { @@ -201,7 +201,7 @@ public function getSuccessorNode( */ public function getChildsOfNode($a_parent_node_id) : array { - if ($this->preloaded && $this->getSearchTerm() == "") { + if ($this->preloaded && $this->getSearchTerm() === "") { if (isset($this->childs[$a_parent_node_id]) && is_array($this->childs[$a_parent_node_id])) { return $this->childs[$a_parent_node_id]; } @@ -209,7 +209,7 @@ public function getChildsOfNode($a_parent_node_id) : array } $wl = $this->getTypeWhiteList(); - if (is_array($wl) && count($wl) > 0) { + if (count($wl) > 0) { $childs = $this->tree->getChildsByTypeFilter($a_parent_node_id, $wl, $this->getOrderField()); } else { $childs = $this->tree->getChilds($a_parent_node_id, $this->getOrderField()); @@ -220,7 +220,7 @@ public function getChildsOfNode($a_parent_node_id) : array if (is_array($bl) && count($bl) > 0) { $bl_childs = array(); foreach ($childs as $k => $c) { - if (!in_array($c["type"], $bl) && ($this->matches($c) || $this->requested_node_id != $this->getDomNodeIdForNodeId($a_parent_node_id))) { + if (!in_array($c["type"], $bl, true) && ($this->matches($c) || $this->requested_node_id !== $this->getDomNodeIdForNodeId($a_parent_node_id))) { $bl_childs[$k] = $c; } } @@ -229,7 +229,7 @@ public function getChildsOfNode($a_parent_node_id) : array $final_childs = []; foreach ($childs as $k => $c) { - if ($this->matches($c) || $this->requested_node_id != $this->getDomNodeIdForNodeId($a_parent_node_id)) { + if ($this->matches($c) || $this->requested_node_id !== $this->getDomNodeIdForNodeId($a_parent_node_id)) { $final_childs[$k] = $c; } } @@ -243,11 +243,10 @@ public function getChildsOfNode($a_parent_node_id) : array */ protected function matches($node) : bool { - if ($this->getSearchTerm() == "" || - is_int(stripos($this->getNodeContent($node), $this->getSearchTerm()))) { - return true; - } - return false; + return ( + $this->getSearchTerm() === "" || + is_int(ilStr::striPos($this->getNodeContent($node), $this->getSearchTerm())) + ); } @@ -255,7 +254,7 @@ protected function matches($node) : bool * Get id for node * * @param object|array $a_node - * @return string id + * @return string */ public function getNodeId($a_node) { @@ -290,15 +289,12 @@ public function getRootNode() /** * @param int|string $a_root */ - public function setRootId($a_root) + public function setRootId($a_root) : void { $this->root_id = $a_root; } - /** - * @return int - */ - protected function getRootId() + protected function getRootId() : int { return $this->root_id ?: $this->getTree()->readRootId(); @@ -350,7 +346,7 @@ protected function createNode( $nodeIconPath = $this->getNodeIcon($record); $icon = null; - if (is_string($nodeIconPath) && strlen($nodeIconPath) > 0) { + if ($nodeIconPath !== '') { $icon = $this->ui ->factory() ->symbol() @@ -380,7 +376,7 @@ public function build( $node = $this->createNode($factory, $record); $href = $this->getNodeHref($record); - if (is_string($href) && strlen($href) > 0 && '#' !== $href) { + if ($href !== '' && '#' !== $href) { $node = $node->withLink(new \ILIAS\Data\URI(ILIAS_HTTP_PATH . '/' . $href)); } @@ -391,8 +387,8 @@ public function build( $nodeStateToggleCmdClasses = $this->getNodeStateToggleCmdClasses($record); $cmdClass = end($nodeStateToggleCmdClasses); - if (is_string($cmdClass) && strlen($cmdClass) > 0) { - $node = $node->withAdditionalOnLoadCode(function ($id) use ($record, $nodeStateToggleCmdClasses, $cmdClass) { + if (is_string($cmdClass) && $cmdClass !== '') { + $node = $node->withAdditionalOnLoadCode(function ($id) use ($record, $nodeStateToggleCmdClasses, $cmdClass) : string { $serverNodeId = $this->getNodeId($record); $this->ctrl->setParameterByClass($cmdClass, 'node_id', $serverNodeId); @@ -423,7 +419,7 @@ public function getTreeComponent() : Tree ); $label = $this->getTreeLabel(); - if ($this->getTreeLabel() == "" && $this->getNodeContent($this->getRootNode())) { + if ($this->getTreeLabel() === "" && $this->getNodeContent($this->getRootNode())) { $label = $this->getNodeContent($this->getRootNode()); } diff --git a/Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php b/Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php index 49dadc6f2ef9..9a8804e2d24d 100644 --- a/Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php +++ b/Services/UIComponent/Glyph/classes/class.ilGlyphGUI.php @@ -61,9 +61,9 @@ public static function get( $lng = $DIC->language(); - $text = ($a_text == "") + $text = ($a_text === "") ? $lng->txt(self::$map[$a_glyph]["txt"]) - : (($a_text == self::NO_TEXT) + : (($a_text === self::NO_TEXT) ? "" : $a_text); switch ($a_glyph) { diff --git a/Services/UIComponent/GroupedList/classes/class.ilGroupedListGUI.php b/Services/UIComponent/GroupedList/classes/class.ilGroupedListGUI.php index 1cbafc6586d5..07758ddbae82 100644 --- a/Services/UIComponent/GroupedList/classes/class.ilGroupedListGUI.php +++ b/Services/UIComponent/GroupedList/classes/class.ilGroupedListGUI.php @@ -174,13 +174,13 @@ public function getHTML() : string $tpl->touchBlock("multi_end"); } - if ($tt_calls != "") { + if ($tt_calls !== "") { $tpl->setCurrentBlock("script"); $tpl->setVariable("TT_CALLS", $tt_calls); $tpl->parseCurrentBlock(); } - if ($this->id != "") { + if ($this->id !== "") { $tpl->setCurrentBlock("id"); $tpl->setVariable("ID", $this->id); $tpl->parseCurrentBlock(); diff --git a/Services/UIComponent/Lightbox/classes/class.ilLightboxGUI.php b/Services/UIComponent/Lightbox/classes/class.ilLightboxGUI.php index 9a272e0498ba..5b693531c36f 100644 --- a/Services/UIComponent/Lightbox/classes/class.ilLightboxGUI.php +++ b/Services/UIComponent/Lightbox/classes/class.ilLightboxGUI.php @@ -60,7 +60,7 @@ public function addLightbox(\ilGlobalTemplateInterface $a_tpl = null) : void { $tpl = $this->tpl; - if ($a_tpl == null) { + if ($a_tpl === null) { $a_tpl = $tpl; } @@ -73,7 +73,7 @@ public function getHTML() : string $tpl = new ilTemplate("tpl.lightbox.html", true, true, "Services/UIComponent/Lightbox"); $tpl->setVariable("LIGHTBOX_CONTENT", ""); $tpl->setVariable("ID", $this->getId()); - if ($this->getWidth() != "") { + if ($this->getWidth() !== "") { $tpl->setVariable("WIDTH", "width: " . $this->getWidth() . ";"); } return $tpl->get(); diff --git a/Services/UIComponent/Modal/classes/class.ilModalGUI.php b/Services/UIComponent/Modal/classes/class.ilModalGUI.php index 61decb007c7a..85d25bcd7f2f 100644 --- a/Services/UIComponent/Modal/classes/class.ilModalGUI.php +++ b/Services/UIComponent/Modal/classes/class.ilModalGUI.php @@ -136,11 +136,7 @@ public static function initJS(ilGlobalTemplateInterface $a_main_tpl = null) : vo { global $DIC; - if ($a_main_tpl != null) { - $tpl = $a_main_tpl; - } else { - $tpl = $DIC["tpl"]; - } + $tpl = $a_main_tpl ?? $DIC["tpl"]; $tpl->addJavaScript("./Services/UIComponent/Modal/js/Modal.js"); } diff --git a/Services/UIComponent/NestedList/classes/class.ilNestedList.php b/Services/UIComponent/NestedList/classes/class.ilNestedList.php index 57539689e810..ed677a0f2942 100644 --- a/Services/UIComponent/NestedList/classes/class.ilNestedList.php +++ b/Services/UIComponent/NestedList/classes/class.ilNestedList.php @@ -137,7 +137,7 @@ public function renderNode( public function listItemStart(ilTemplate $tpl) : void { - if ($this->getItemClass() != "") { + if ($this->getItemClass() !== "") { $tpl->setCurrentBlock("list_item_start"); $tpl->setVariable("LI_CLASS", ' class="' . $this->getItemClass() . '" '); $tpl->parseCurrentBlock(); @@ -157,11 +157,11 @@ public function listStart(ilTemplate $tpl, int $depth) : void { //echo "
listStart"; - $class = ($this->getListClass($depth) != "") + $class = ($this->getListClass($depth) !== "") ? $this->getListClass($depth) : $this->getListClass(); //echo "-$class-"; - if ($class != "") { + if ($class !== "") { $tpl->setCurrentBlock("list_start"); $tpl->setVariable("UL_CLASS", ' class="' . $class . '" '); $tpl->parseCurrentBlock(); diff --git a/Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php b/Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php index c805cb06779b..e7bacd9e106c 100644 --- a/Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php +++ b/Services/UIComponent/Overlay/classes/class.ilOverlayGUI.php @@ -112,15 +112,15 @@ public function getOnLoadCode() : string // yui cfg string $yuicfg["visible"] = $this->visible; - if ($this->width != "") { + if ($this->width !== "") { $yuicfg["width"] = $this->width; } - if ($this->height != "") { + if ($this->height !== "") { $yuicfg["height"] = $this->height; } $yuicfg["fixedcenter"] = $this->fixed_center; - if ($this->anchor_el_id != "") { + if ($this->anchor_el_id !== "") { $yuicfg["context"] = array($this->anchor_el_id, $this->anchor_ov_corner, $this->anchor_anch_corner, array("beforeShow", "windowResize")); } diff --git a/Services/UIComponent/Panel/classes/class.ilPanelGUI.php b/Services/UIComponent/Panel/classes/class.ilPanelGUI.php index a990b3b8fc94..b5b657b58fc3 100644 --- a/Services/UIComponent/Panel/classes/class.ilPanelGUI.php +++ b/Services/UIComponent/Panel/classes/class.ilPanelGUI.php @@ -107,7 +107,7 @@ public function getHTML() : string $tpl = new ilTemplate("tpl.panel.html", true, true, "Services/UIComponent/Panel"); $head_outer_div_style = ""; - if ($this->getHeading() != "") { + if ($this->getHeading() !== "") { $tpl->setCurrentBlock("heading"); $tpl->setVariable("HEADING", $this->getHeading()); @@ -129,7 +129,7 @@ public function getHTML() : string $tpl->setVariable("BODY", $this->getBody()); - if ($this->getFooter() != "") { + if ($this->getFooter() !== "") { $tpl->setCurrentBlock("footer"); $tpl->setVariable("FOOTER", $this->getFooter()); diff --git a/Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php b/Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php index 64106473941e..ff49f6613b83 100644 --- a/Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php +++ b/Services/UIComponent/ProgressBar/classes/class.ilProgressBar.php @@ -147,7 +147,7 @@ public function render() : string $tpl->touchBlock("hide_caption_out_bl"); } - if (strlen($this->ajax_url) and $this->ajax_timeout) { + if ($this->ajax_url !== '' && $this->ajax_timeout) { $tpl->setCurrentBlock('async_status'); $tpl->setVariable('ASYNC_STATUS_ID', $this->unique_id); $tpl->setVariable('ICON_OK', ilUtil::getImagePath('icon_ok.svg')); diff --git a/Services/UIComponent/Tabs/classes/class.ilTabsGUI.php b/Services/UIComponent/Tabs/classes/class.ilTabsGUI.php index 143d76a0bc5d..0e59dd4f5730 100755 --- a/Services/UIComponent/Tabs/classes/class.ilTabsGUI.php +++ b/Services/UIComponent/Tabs/classes/class.ilTabsGUI.php @@ -256,9 +256,9 @@ public function addSubTab( public function setTabActive(string $a_id) : void { foreach ($this->target as $key => $target) { - $this->target[$key]['activate'] = $this->target[$key]['id'] == $a_id; + $this->target[$key]['activate'] = $this->target[$key]['id'] === $a_id; } - if ($a_id != "") { + if ($a_id !== "") { $this->manual_activation = true; } else { $this->manual_activation = false; @@ -276,7 +276,7 @@ public function activateTab(string $a_id) : void public function setSubTabActive(string $a_text) : void { for ($i = 0, $iMax = count($this->sub_target); $i < $iMax; $i++) { - $this->sub_target[$i]['activate'] = $this->sub_target[$i]['id'] == $a_text; + $this->sub_target[$i]['activate'] = $this->sub_target[$i]['id'] === $a_text; } $this->subtab_manual_activation = true; } @@ -370,12 +370,12 @@ private function __getHTML( $pre = $pre2 = ""; // back 2 tab - if ($this->back_2_title != "") { + if ($this->back_2_title !== "") { $tpl->setCurrentBlock("back_2_tab"); $tpl->setVariable("BACK_2_ICON", ilGlyphGUI::get(ilGlyphGUI::PREVIOUS, ilGlyphGUI::NO_TEXT)); $tpl->setVariable("BACK_2_TAB_LINK", $this->back_2_target); $tpl->setVariable("BACK_2_TAB_TEXT", $this->back_2_title); - if ($this->back_2_frame != "") { + if ($this->back_2_frame !== "") { $tpl->setVariable("BACK_2_TAB_TARGET", ' target="' . $this->back_2_frame . '" '); } @@ -383,12 +383,12 @@ private function __getHTML( } // back tab - if ($this->back_title != "") { + if ($this->back_title !== "") { $tpl->setCurrentBlock("back_tab"); $tpl->setVariable("BACK_ICON", ilGlyphGUI::get(ilGlyphGUI::PREVIOUS, ilGlyphGUI::NO_TEXT)); $tpl->setVariable("BACK_TAB_LINK", $this->back_target); $tpl->setVariable("BACK_TAB_TEXT", $this->back_title); - if ($this->back_frame != "") { + if ($this->back_frame !== "") { $tpl->setVariable("BACK_TAB_TARGET", ' target="' . $this->back_frame . '" '); } $tpl->parseCurrentBlock(); @@ -400,7 +400,7 @@ private function __getHTML( $i = 0; // do not display one tab only - if ((count($targets) > 1 || $this->force_one_tab) || ($this->back_title != "" && !$a_get_sub_tabs) + if ((count($targets) > 1 || $this->force_one_tab) || ($this->back_title !== "" && !$a_get_sub_tabs) || (count($this->non_tabbed_link) > 0 && !$a_get_sub_tabs)) { foreach ($targets as $target) { $i++; @@ -423,7 +423,7 @@ private function __getHTML( $tabtype = $pre . "tabactive"; } - if ($tabtype == "tabactive" || $tabtype == "subtabactive") { + if ($tabtype === "tabactive" || $tabtype === "subtabactive") { $tpl->setCurrentBlock("sel_text"); $tpl->setVariable("TXT_SELECTED", $lng->txt("stat_selected")); $tpl->parseCurrentBlock(); @@ -444,7 +444,7 @@ private function __getHTML( // tooltip if (!$this->getSetupMode()) { $ttext = $ilHelp->getTabTooltipText($target["id"]); - if ($ttext != "") { + if ($ttext !== "") { ilTooltipGUI::addTooltip( $pre . "tab_" . $target["id"], $ttext, @@ -495,7 +495,7 @@ private function __getHTML( // tooltip if (!$this->getSetupMode()) { $ttext = $ilHelp->getTabTooltipText($link["id"]); - if ($ttext != "") { + if ($ttext !== "") { ilTooltipGUI::addTooltip( "nontab_" . $link["id"], $ttext, diff --git a/Services/UIComponent/TextHighlighter/classes/class.ilTextHighlighterGUI.php b/Services/UIComponent/TextHighlighter/classes/class.ilTextHighlighterGUI.php index dffdd6388a6c..966d9e0efbf6 100644 --- a/Services/UIComponent/TextHighlighter/classes/class.ilTextHighlighterGUI.php +++ b/Services/UIComponent/TextHighlighter/classes/class.ilTextHighlighterGUI.php @@ -36,7 +36,7 @@ public static function highlight( return; } - if ($a_tpl == null) { + if ($a_tpl === null) { $a_tpl = $tpl; } $a_tpl->addJavaScript("./Services/UIComponent/TextHighlighter/js/ilTextHighlighter.js"); diff --git a/Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php b/Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php index bb9c39a4e611..0a776d1b56ab 100644 --- a/Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php +++ b/Services/UIComponent/Toolbar/classes/class.ilToolbarGUI.php @@ -260,7 +260,7 @@ public function getGroupedItems() : array $groups = array(); $group = array(); foreach ($this->items as $item) { - if ($item['type'] == 'separator') { + if ($item['type'] === 'separator') { $groups[] = $group; $group = array(); } else { @@ -309,7 +309,7 @@ public function getHTML() : string } // Hide toggle button if only sticky items are in the toolbar - if (count($this->items) == 0) { + if (count($this->items) === 0) { $tpl->setVariable('HIDE_TOGGLE_CLASS', ' hidden'); } @@ -442,7 +442,7 @@ public function getHTML() : string } // form? - if ($this->getFormAction() != "") { + if ($this->getFormAction() !== "") { // #18947 $GLOBALS["tpl"]->addJavaScript("Services/Form/js/Form.js"); @@ -455,10 +455,10 @@ public function getHTML() : string if ($this->multipart) { $tpl->setVariable("ENC_TYPE", 'enctype="multipart/form-data"'); } - if ($this->form_target != "") { + if ($this->form_target !== "") { $tpl->setVariable("TARGET", ' target="' . $this->form_target . '" '); } - if ($this->form_name != "") { + if ($this->form_name !== "") { $tpl->setVariable("FORMNAME", 'name="' . $this->getFormName() . '"'); } @@ -470,7 +470,7 @@ public function getHTML() : string } // id - if ($this->getId() != "") { + if ($this->getId() !== "") { $tpl->setVariable("ID", ' id="' . $this->getId() . '" '); } diff --git a/Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php b/Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php index 1c33f6995f39..c278f47db3ab 100755 --- a/Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php +++ b/Services/UIComponent/Tooltip/classes/class.ilTooltipGUI.php @@ -64,7 +64,7 @@ public static function getToolTip( // not needed, just make sure the position plugin is included // $addstr.= ", position: {viewport: $('#fixed_content')}"; - if ($a_container != "") { + if ($a_container !== "") { $addstr .= ", container: '" . $a_container . "'"; }