| Conditions | 13 |
| Paths | 288 |
| Total Lines | 205 |
| Code Lines | 113 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 0 | ||
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
| 1 | <?php |
||
| 37 | function bExtcalMinicalShow($options) |
||
| 38 | { |
||
| 39 | global $xoopsUser; |
||
| 40 | |||
| 41 | extcal_getDefautminicalOption($options); |
||
| 42 | |||
| 43 | // // require_once dirname(__DIR__) . '/class/Config.php'; |
||
| 44 | |||
| 45 | require_once _EXTCAL_PEAR_CALENDAR_ROOT . '/Util/Textual.php'; |
||
| 46 | require_once _EXTCAL_PEAR_CALENDAR_ROOT . '/Month/Weeks.php'; |
||
| 47 | require_once _EXTCAL_PEAR_CALENDAR_ROOT . '/Day.php'; |
||
| 48 | // require_once CALENDAR_ROOT . 'Month/Weeks.php'; |
||
| 49 | // require_once CALENDAR_ROOT . 'Day.php'; |
||
| 50 | |||
| 51 | $helper = Helper::getInstance(); |
||
| 52 | |||
| 53 | // Retriving Image for block if enabled |
||
| 54 | if (isset($options[0]) && 1 == $options[0]) { |
||
| 55 | $imageHandler = xoops_getHandler('image'); |
||
| 56 | $criteria = new \Criteria('imgcat_id', $options[1]); |
||
| 57 | $criteria->setSort('RAND()'); |
||
| 58 | $criteria->setLimit($options[6]); |
||
| 59 | $images = $imageHandler->getObjects($criteria); |
||
| 60 | $slideShowParam = [ |
||
| 61 | 'images' => $images, |
||
| 62 | 'frameHeight' => $options[3], |
||
| 63 | 'frameWidth' => $options[2], |
||
| 64 | 'transTime' => $options[4], |
||
| 65 | 'pauseTime' => $options[5], |
||
| 66 | ]; |
||
| 67 | if (count($images) > 0) { |
||
| 68 | _makeXMLSlideshowConf($slideShowParam); |
||
| 69 | $imageParam = ['displayImage' => true]; |
||
| 70 | } else { |
||
| 71 | $imageParam = ['displayImage' => false]; |
||
| 72 | } |
||
| 73 | } else { |
||
| 74 | $imageParam = ['displayImage' => false]; |
||
| 75 | } |
||
| 76 | $imageParam['frameHeight'] = $options[3]; |
||
| 77 | $imageParam['frameWidth'] = $options[2]; |
||
| 78 | |||
| 79 | $categoryHandler = $helper->getHandler(_EXTCAL_CLN_CAT); |
||
| 80 | |||
| 81 | $cats = $categoryHandler->getAllCatById($xoopsUser); |
||
| 82 | // $t = print_r($cats,true); |
||
| 83 | // echo "zzz<pre>{$t}</pre>"; |
||
| 84 | |||
| 85 | $eventHandler = $helper->getHandler(_EXTCAL_CLN_EVENT); |
||
| 86 | $timeHandler = Time::getHandler(); |
||
| 87 | |||
| 88 | // Retriving month and year value according to block options |
||
| 89 | //modif JJD |
||
| 90 | $offset = $helper->getConfig('offsetMinical'); |
||
| 91 | $monthToShow = mktime(0, 0, 0, date('m') + $offset, date('d'), date('Y')); |
||
| 92 | $month = date('n', $monthToShow); |
||
| 93 | $year = date('Y', $monthToShow); |
||
| 94 | |||
| 95 | //---------------------------------------------------- |
||
| 96 | $month += $options[7]; //ajout ou retrait du nombre de mois de décalage |
||
| 97 | if ($month < 1) { |
||
| 98 | $month = 12; |
||
| 99 | --$year; |
||
| 100 | } elseif ($month > 12) { |
||
| 101 | $month = 1; |
||
| 102 | ++$year; |
||
| 103 | } |
||
| 104 | //---------------------------------------------------- |
||
| 105 | |||
| 106 | // Saving display link preference |
||
| 107 | $displayLink = $options[8]; |
||
| 108 | |||
| 109 | // Delete options to keep only categorie data |
||
| 110 | $tCatSelected = explode(',', $options[9]); |
||
| 111 | |||
| 112 | /***************************************************************/ |
||
| 113 | // Retriving events and formatting them |
||
| 114 | //$events = $eventHandler->objectToArray($eventHandler->getEventCalendarMonth($month, $year, $tCatSelected)); |
||
| 115 | if (true) { |
||
| 116 | $criteres = [ |
||
| 117 | 'periode' => _EXTCAL_EVENTS_MONTH, |
||
| 118 | 'month' => $month, |
||
| 119 | 'year' => $year, |
||
| 120 | 'category' => $tCatSelected, |
||
| 121 | 'externalKeys' => 'cat_id', |
||
| 122 | ]; |
||
| 123 | $events = $eventHandler->getEventsOnPeriode($criteres); |
||
| 124 | } else { |
||
| 125 | $events = []; |
||
| 126 | } |
||
| 127 | //Utility::echoArray($events, 'minical'); |
||
| 128 | /***************************************************************/ |
||
| 129 | //$eventHandler->formatEventDate($events, "l dS \of F Y h:i A"); |
||
| 130 | |||
| 131 | // Calculating timestamp for the begin and the end of the month |
||
| 132 | $startMonth = mktime(0, 0, 0, $month, 1, $year); |
||
| 133 | $endMonth = mktime(23, 59, 59, $month + 1, 0, $year); |
||
| 134 | |||
| 135 | /* |
||
| 136 | * Adding all event occuring during this month to an array indexed by day number |
||
| 137 | */ |
||
| 138 | $eventsArray = []; |
||
| 139 | foreach ($events as $event) { |
||
| 140 | //echo "id->{$event['event_id']}<br>"; |
||
| 141 | bExtcalMinicalAddEventToArray($event, $eventsArray, $timeHandler, $startMonth, $endMonth, $cats); |
||
| 142 | // if (!$event['event_isrecur']) { |
||
| 143 | // bExtcalMinicalAddEventToArray($event, $eventsArray, $timeHandler, $startMonth, $endMonth, $cats); |
||
| 144 | // } else { |
||
| 145 | // |
||
| 146 | // $recurEvents = $eventHandler->getRecurEventToDisplay($event, $startMonth, $endMonth); |
||
| 147 | // foreach ($recurEvents as $recurEvent) |
||
| 148 | // { |
||
| 149 | // bExtcalMinicalAddEventToArray($recurEvent, $eventsArray, $timeHandler, $startMonth, $endMonth, $cats); |
||
| 150 | // } |
||
| 151 | // } |
||
| 152 | } |
||
| 153 | //Utility::echoArray($eventsArray); |
||
| 154 | |||
| 155 | /* |
||
| 156 | * Making an array to create tabbed output on the template |
||
| 157 | */ |
||
| 158 | // Flag current day |
||
| 159 | $selectedDays = [ |
||
| 160 | new Calendar_Day( |
||
| 161 | date('Y', xoops_getUserTimestamp(time(), $timeHandler->getUserTimeZone($GLOBALS['xoopsUser']))), |
||
| 162 | date('n', xoops_getUserTimestamp(time(), $timeHandler->getUserTimeZone($GLOBALS['xoopsUser']))), |
||
| 163 | date('j', xoops_getUserTimestamp(time(), $timeHandler->getUserTimeZone($GLOBALS['xoopsUser']))) |
||
| 164 | ), |
||
| 165 | ]; |
||
| 166 | |||
| 167 | // Build calendar object |
||
| 168 | $monthCalObj = new Calendar_Month_Weeks($year, $month, $helper->getConfig('week_start_day')); |
||
| 169 | $monthCalObj->build(); |
||
| 170 | |||
| 171 | $tableRows = []; |
||
| 172 | $rowId = 0; |
||
| 173 | $cellId = 0; |
||
| 174 | while (false !== ($weekCalObj = $monthCalObj->fetch())) { |
||
| 175 | $weekCalObj->build($selectedDays); |
||
| 176 | $tableRows[$rowId]['weekInfo'] = [ |
||
| 177 | 'week' => $weekCalObj->thisWeek('n_in_year'), |
||
| 178 | 'day' => $weekCalObj->thisDay(), |
||
| 179 | 'month' => $monthCalObj->thisMonth(), |
||
| 180 | 'year' => $monthCalObj->thisYear(), |
||
| 181 | ]; |
||
| 182 | while (false !== ($dayCalObj = $weekCalObj->fetch())) { |
||
| 183 | $tableRows[$rowId]['week'][$cellId] = [ |
||
| 184 | 'isEmpty' => $dayCalObj->isEmpty(), |
||
| 185 | 'number' => $dayCalObj->thisDay(), |
||
| 186 | 'isSelected' => $dayCalObj->isSelected(), |
||
| 187 | ]; |
||
| 188 | $day = $dayCalObj->thisDay(); |
||
| 189 | if (isset($eventsArray[$day]) && !$dayCalObj->isEmpty()) { |
||
| 190 | $tableRows[$rowId]['week'][$cellId]['haveEvents'] = true; |
||
| 191 | $tableRows[$rowId]['week'][$cellId]['color'] = $eventsArray[$day]['color']; |
||
| 192 | } else { |
||
| 193 | $tableRows[$rowId]['week'][$cellId]['haveEvents'] = false; |
||
| 194 | } |
||
| 195 | ++$cellId; |
||
| 196 | } |
||
| 197 | $cellId = 0; |
||
| 198 | ++$rowId; |
||
| 199 | } |
||
| 200 | |||
| 201 | // Retriving weekdayNames |
||
| 202 | //$loc_de = setlocale (LC_ALL, 'Fr'); |
||
| 203 | |||
| 204 | $weekdayNames = Calendar_Util_Textual::weekdayNames('one'); |
||
| 205 | //$weekdayNames=array('D','L','M','M','J','V','S'); |
||
| 206 | |||
| 207 | // echo "<hr>L'identifiant de l'allemand sur ce système est '$loc_de'"; |
||
| 208 | // echoArray($weekdayNames,true); |
||
| 209 | |||
| 210 | for ($i = 0; $i < $helper->getConfig('week_start_day'); ++$i) { |
||
| 211 | $weekdayName = array_shift($weekdayNames); |
||
| 212 | $weekdayNames[] = $weekdayName; |
||
| 213 | } |
||
| 214 | |||
| 215 | // Making navig data |
||
| 216 | $navig = [ |
||
| 217 | 'page' => $helper->getConfig('start_page'), |
||
| 218 | 'uri' => 'year=' . $monthCalObj->thisYear() . '&month=' . $monthCalObj->thisMonth(), |
||
| 219 | 'name' => $timeHandler->getFormatedDate($helper->getConfig('nav_date_month'), $monthCalObj->getTimestamp()), |
||
| 220 | ]; |
||
| 221 | |||
| 222 | $horloge = []; |
||
| 223 | $horloge['display'] = ('' != trim($options[11])); |
||
| 224 | $horloge['fullName'] = XOOPS_URL . _EXTCAL_PATH_HORLOGES . $options[11]; |
||
| 225 | $horloge['width'] = $options[12] . 'px'; |
||
| 226 | $horloge['height'] = $options[13] . 'px'; |
||
| 227 | |||
| 228 | $ret = [ |
||
| 229 | 'imageParam' => $imageParam, |
||
| 230 | 'displayLink' => $displayLink, |
||
| 231 | 'submitText' => _MB_EXTCAL_SUBMIT_LINK_TEXT, |
||
| 232 | 'tableRows' => $tableRows, |
||
| 233 | 'weekdayNames' => $weekdayNames, |
||
| 234 | 'navig' => $navig, |
||
| 235 | 'horloge' => $horloge, |
||
| 236 | 'bgColor' => $options[10], |
||
| 237 | ]; |
||
| 238 | |||
| 239 | // $t = print_r($horloge,true); |
||
| 240 | // echo "<pre>{$t}</pre>"; |
||
| 241 | return $ret; |
||
| 242 | } |
||
| 591 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths