| Conditions | 15 |
| Paths | 160 |
| Total Lines | 137 |
| Code Lines | 83 |
| 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 |
||
| 221 | function get_content(&$arguments,$properties) |
||
| 222 | { |
||
| 223 | $GLOBALS['egw_info']['flags']['currentapp'] = 'calendar'; |
||
| 224 | Api\Translation::add_app('calendar'); |
||
| 225 | |||
| 226 | //error_log(array2string($arguments)); |
||
| 227 | if (empty($arguments['date'])) |
||
| 228 | { |
||
| 229 | $arguments['date'] = date('Ymd'); |
||
| 230 | } |
||
| 231 | |||
| 232 | if (isset($_GET['date'])) $arguments['date'] = $_GET['date']; |
||
| 233 | if (empty($arguments['cat_id'])) $arguments['cat_id'] = ''; |
||
| 234 | if(isset($arguments['resources']) && in_array('r0', $arguments['resources'])) |
||
| 235 | { |
||
| 236 | foreach($arguments['resources'] as $index => $value) |
||
| 237 | { |
||
| 238 | if($value == 'r0') |
||
| 239 | { |
||
| 240 | unset($arguments['resources'][$index]); |
||
| 241 | } |
||
| 242 | } |
||
| 243 | } |
||
| 244 | |||
| 245 | $params = $arguments; |
||
| 246 | if (isset($params['resources']) && count($params['resources'])) |
||
| 247 | { |
||
| 248 | $params['owner'] = array_merge((array)$params['owner'], (array)$params['resources']); |
||
| 249 | unset($params['resources']); |
||
| 250 | } |
||
| 251 | |||
| 252 | $html = '<style type="text/css">'."\n"; |
||
| 253 | $html .= '@import url('.$GLOBALS['egw_info']['server']['webserver_url'].self::CALENDAR_CSS.");\n"; |
||
| 254 | $html .= '@import url('.$GLOBALS['egw_info']['server']['webserver_url'].self::ETEMPLATE_CSS.");\n"; |
||
| 255 | $html .= '@import url('.$GLOBALS['egw_info']['server']['webserver_url'].Api\Categories::css(Api\Categories::GLOBAL_APPNAME).");\n"; |
||
| 256 | $html .= '@import url('.$GLOBALS['egw_info']['server']['webserver_url'].Api\Categories::css('calendar').");\n"; |
||
| 257 | $html .= '.popupMainDiv #calendar-view {position: static; min-height: 250px; height: 99% !important;} |
||
| 258 | </style>'."\n"; |
||
| 259 | $html .= Api\Html::image('sitemgr', 'left', lang('Previous'), 'onclick=\'app.calendar.toolbar_action({id:"previous",data:{state:{view:"weekN"}}});\'') |
||
| 260 | . Api\Html::image('sitemgr', 'right', lang('Next'), 'style="float: right;" onclick=\'app.calendar.toolbar_action({id:"next",data:{state:{view:"weekN"}}});\''); |
||
| 261 | |||
| 262 | if (is_array($params['owner'])) |
||
| 263 | { |
||
| 264 | // Buffer, and add anything that gets cleared to the content |
||
| 265 | ob_start(function($buffer) use(&$html) { |
||
| 266 | $html .= $buffer; |
||
| 267 | return ''; |
||
| 268 | }); |
||
| 269 | Framework::$header_done = true; |
||
| 270 | $ui = new calendar_uiviews(); |
||
| 271 | $ui->owner = $params['owner']; |
||
| 272 | |||
| 273 | $tmpl = new Etemplate('calendar.view'); |
||
| 274 | |||
| 275 | $start = new Api\DateTime($arguments['date']); |
||
| 276 | $start->setWeekstart(); |
||
| 277 | $ui->first = $start->format('ts'); |
||
| 278 | $ui->last = strtotime("+{$params['numWeeks']} weeks",$ui->first) - 1; |
||
| 279 | |||
| 280 | // Calendar uses user preferences for number of weeks, so set it |
||
| 281 | if((int)$params['numWeeks'] != (int)$ui->cal_prefs['multiple_weeks']) |
||
| 282 | { |
||
| 283 | $anon_user = $GLOBALS['egw']->accounts->name2id($GLOBALS['Common_BO']->sites->current_site['anonymous_user'],'account_lid','u'); |
||
| 284 | $pref = new Api\Preferences($anon_user); |
||
| 285 | $pref->add('calendar','multiple_weeks',(int)$params['numWeeks']); |
||
| 286 | $pref->save_repository(); |
||
| 287 | } |
||
| 288 | |||
| 289 | $navHeader = lang('Week').' '.$ui->week_number($ui->first).' - '.$ui->week_number($this->last).': '. |
||
| 290 | $ui->bo->long_date($ui->first,$ui->last); |
||
| 291 | |||
| 292 | $granularity = ($ui->cal_prefs['interval'] ? (int)$ui->cal_prefs['interval'] : 30); |
||
| 293 | |||
| 294 | $content = array('view' => array()); |
||
| 295 | |||
| 296 | $sel_options = array(); |
||
| 297 | |||
| 298 | $ui->search_params['query'] = $params['search']; |
||
| 299 | $ui->search_params['cat_id'] = $params['cat_id']; |
||
| 300 | |||
| 301 | // Loop through, using Api\DateTime to handle DST |
||
| 302 | $week = 0; |
||
| 303 | $week_start = new EGroupware\Api\DateTime($ui->first); |
||
| 304 | $week_start->setTime(0,0,0); |
||
| 305 | $week_end = new Api\DateTime($week_start); |
||
| 306 | $week_end->add(new DateInterval('P6DT23H59M59S')); |
||
| 307 | $last = new EGroupware\Api\DateTime($ui->last); |
||
| 308 | |||
| 309 | for ($week_start; $week_start < $last; $week_start->add('1 week'), $week_end->add('1 week')) |
||
| 310 | { |
||
| 311 | $search_params = $ui->search_params; |
||
| 312 | |||
| 313 | $search_params['start'] = $week_start->format('ts'); |
||
| 314 | $search_params['end'] = $week_end->format('ts'); |
||
| 315 | |||
| 316 | $content['view'][] = (array)$ui->tagWholeDayOnTop($ui->bo->search($search_params)) + |
||
| 317 | array( |
||
| 318 | 'id' => $week_start->format('Ymd') |
||
| 319 | ); |
||
| 320 | $tmpl->setElementAttribute("view[$week]",'onchange',false); |
||
| 321 | $tmpl->setElementAttribute("view[$week]",'granularity',$granularity); |
||
| 322 | $tmpl->setElementAttribute("view[$week]",'height','250px'); |
||
| 323 | $week++; |
||
| 324 | } |
||
| 325 | |||
| 326 | |||
| 327 | // Make sure all used owners are there, faking |
||
| 328 | // calendar_owner_etemplate_widget::beforeSendToClient() since the |
||
| 329 | // rest of the calendar app is probably missing. |
||
| 330 | foreach($params['owner'] as $owner) |
||
| 331 | { |
||
| 332 | $sel_options['owner'][] = Array( |
||
| 333 | 'id' => $owner, |
||
| 334 | 'value' => $owner, |
||
| 335 | 'label' => calendar_owner_etemplate_widget::get_owner_label($owner) |
||
| 336 | ); |
||
| 337 | } |
||
| 338 | $tmpl->exec(__METHOD__, $content,$sel_options, array('__ALL__' => true),array(),2); |
||
| 339 | $html .= ob_get_contents(); |
||
| 340 | |||
| 341 | $html .= '<script>' |
||
| 342 | . ' window.egw_LAB.wait(function() {jQuery(function() {' |
||
| 343 | . 'app.calendar.set_state(' . json_encode(array( |
||
| 344 | 'owner' => $params['owner'], |
||
| 345 | 'date' => $start->format(EGroupware\Api\DateTime::ET2) |
||
| 346 | )).'); ' |
||
| 347 | . '});});' |
||
| 348 | . '</script>'; |
||
| 349 | |||
| 350 | ob_end_clean(); |
||
| 351 | } |
||
| 352 | else |
||
| 353 | { |
||
| 354 | $html .= '<div class="message" align="center">'.lang('No owner selected').'</div>'; |
||
| 355 | } |
||
| 356 | |||
| 357 | return $html; |
||
| 358 | } |
||
| 360 |
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