Skip to content
Snippets Groups Projects
Commit 95d79f13 authored by David Siegfried's avatar David Siegfried
Browse files

prevent php-warnings, closes #4124

Closes #4124

Merge request studip/studip!2969
parent 4e9e4166
No related branches found
No related tags found
No related merge requests found
...@@ -66,8 +66,8 @@ class Admin_ExternController extends AuthenticatedController ...@@ -66,8 +66,8 @@ class Admin_ExternController extends AuthenticatedController
ExternPageConfig::findEachBySQL( ExternPageConfig::findEachBySQL(
function ($c) use (&$configs, &$count_not_migrated) { function ($c) use (&$configs, &$count_not_migrated) {
$configs[$c->type][] = $c; $configs[$c->type][] = $c;
if (isset($c->conf['not_fixed_after_migration'])) { if (isset($c->conf['not_fixed_after_migration'])) {
$count_not_migrated++; $count_not_migrated++;
} }
}, },
"range_id = ?", [$this->range] "range_id = ?", [$this->range]
...@@ -165,7 +165,7 @@ class Admin_ExternController extends AuthenticatedController ...@@ -165,7 +165,7 @@ class Admin_ExternController extends AuthenticatedController
if ($this->page->page_config->isNew()) { if ($this->page->page_config->isNew()) {
PageLayout::postSuccess(sprintf( PageLayout::postSuccess(sprintf(
_('Eine neue externe Seite "%$1s" vom Typ %$2s wurde angelegt.'), _('Eine neue externe Seite "%$1s" vom Typ %$2s wurde angelegt.'),
htmlReady($this->page->name), htmlReady($this->page->name),
htmlReady($this->page->type) htmlReady($this->page->type)
)); ));
} else { } else {
...@@ -259,7 +259,11 @@ class Admin_ExternController extends AuthenticatedController ...@@ -259,7 +259,11 @@ class Admin_ExternController extends AuthenticatedController
*/ */
public function info_action(string $config_id) public function info_action(string $config_id)
{ {
$this->page = ExternPage::get(ExternPageConfig::find($config_id)); $config = ExternPageConfig::find($config_id);
if (!$config) {
throw new Exception('ExternPageConfig object not found!');
}
$this->page = ExternPage::get($config);
if ($this->page->author) { if ($this->page->author) {
$this->author = '<a href="' $this->author = '<a href="'
. URLHelper::getLink('dispatch.php/profile', ['username' => $this->page->author->username]) . URLHelper::getLink('dispatch.php/profile', ['username' => $this->page->author->username])
...@@ -364,7 +368,7 @@ class Admin_ExternController extends AuthenticatedController ...@@ -364,7 +368,7 @@ class Admin_ExternController extends AuthenticatedController
$config->author_id = $config->editor_id = $GLOBALS['user']->id; $config->author_id = $config->editor_id = $GLOBALS['user']->id;
$config->store(); $config->store();
PageLayout::postSuccess( PageLayout::postSuccess(
sprintf(_('Die Konfiguration "%s" wurde erfolgreich importiert.'), sprintf(_('Die Konfiguration "%s" wurde erfolgreich importiert.'),
htmlReady($config->name) htmlReady($config->name)
)); ));
} }
......
...@@ -85,7 +85,7 @@ ...@@ -85,7 +85,7 @@
<select class="nested-select" name="semclass[]" multiple> <select class="nested-select" name="semclass[]" multiple>
<? foreach ($GLOBALS['SEM_CLASS'] as $key => $sem_class) : ?> <? foreach ($GLOBALS['SEM_CLASS'] as $key => $sem_class) : ?>
<? if ($sem_class['show_browse']) : ?> <? if ($sem_class['show_browse']) : ?>
<option value="<?= $key ?>"<?= in_array($key, $page->semclass) ? ' selected' : '' ?>> <option value="<?= $key ?>"<?= in_array($key, $page->semclass ?? []) ? ' selected' : '' ?>>
<?= htmlReady($sem_class['name']) ?> <?= htmlReady($sem_class['name']) ?>
</option> </option>
<? endif ?> <? endif ?>
......
...@@ -22,7 +22,7 @@ else : ?> ...@@ -22,7 +22,7 @@ else : ?>
</h1> </h1>
</header> </header>
<? foreach ($config_types as $type_id => $config_type): ?> <? foreach ($config_types as $type_id => $config_type): ?>
<? if ($configs[$type_id]) : ?> <? if (!empty($configs[$type_id])) : ?>
<article id="<?= $type_id ?>" <? if (Request::option('open_type') === $type_id) echo 'class="open"'; ?>> <article id="<?= $type_id ?>" <? if (Request::option('open_type') === $type_id) echo 'class="open"'; ?>>
<header> <header>
<h1> <h1>
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
<div style="font-size: smaller;"> <div style="font-size: smaller;">
(<?= _('Ohne Angabe wird der Name aus den importierten Daten genommen.') ?>) (<?= _('Ohne Angabe wird der Name aus den importierten Daten genommen.') ?>)
</div> </div>
<input type="text" name="config_name" value="<?= htmlReady($config_name) ?>"> <input type="text" name="config_name" value="<?= htmlReady($config_name ?? '') ?>">
</label> </label>
<label> <label>
<?= _('Konfigurationsdatei') ?> <?= _('Konfigurationsdatei') ?>
......
...@@ -37,7 +37,7 @@ trait StudipTreeNodeCachableTrait ...@@ -37,7 +37,7 @@ trait StudipTreeNodeCachableTrait
return $config; return $config;
} }
protected function getDescendantIds(): array public function getDescendantIds(): array
{ {
$cache = self::getDescendantsCacheArray(); $cache = self::getDescendantsCacheArray();
......
...@@ -138,7 +138,7 @@ abstract class ExternPage ...@@ -138,7 +138,7 @@ abstract class ExternPage
$extract[] = array_values(array_filter(array_map('trim', explode(' ', $one)))); $extract[] = array_values(array_filter(array_map('trim', explode(' ', $one))));
} }
foreach ($extract as $one) { foreach ($extract as $one) {
$return[$one[0]] = $one[1]; $return[$one[0]] = $one[1] ?? null;
} }
return $return; return $return;
} }
...@@ -236,7 +236,7 @@ abstract class ExternPage ...@@ -236,7 +236,7 @@ abstract class ExternPage
$allowed_params = $this->getAllowedRequestParams(true); $allowed_params = $this->getAllowedRequestParams(true);
$config_fields = $this->getConfigFields(true); $config_fields = $this->getConfigFields(true);
foreach ($allowed_params as $param_name) { foreach ($allowed_params as $param_name) {
$method = $config_fields[$param_name] ?: 'get'; $method = $config_fields[$param_name] ?? 'get';
$param_value = Request::$method($param_name); $param_value = Request::$method($param_name);
if ($param_value) { if ($param_value) {
$this->setValue($param_name, $param_value); $this->setValue($param_name, $param_value);
...@@ -342,6 +342,7 @@ abstract class ExternPage ...@@ -342,6 +342,7 @@ abstract class ExternPage
): string { ): string {
if (count($scopes) > 0) { if (count($scopes) > 0) {
$study_areas = StudipStudyArea::findMany($scopes); $study_areas = StudipStudyArea::findMany($scopes);
$scopes = []; $scopes = [];
if ($with_kids) { if ($with_kids) {
foreach ($study_areas as $study_area) { foreach ($study_areas as $study_area) {
......
...@@ -162,7 +162,7 @@ class ExternPageTimetable extends ExternPage ...@@ -162,7 +162,7 @@ class ExternPageTimetable extends ExternPage
$time = new DateTime(); $time = new DateTime();
switch ($this->date_offset) { switch ($this->date_offset) {
case 'start_date': case 'start_date':
$time = DateTime::createFromFormat('d.m.Y', $this->date); $time = $this->date ? DateTime::createFromFormat('d.m.Y', $this->date) : $time;
break; break;
case 'current_semester': case 'current_semester':
$semester = Semester::findCurrent(); $semester = Semester::findCurrent();
...@@ -228,6 +228,7 @@ class ExternPageTimetable extends ExternPage ...@@ -228,6 +228,7 @@ class ExternPageTimetable extends ExternPage
protected function getContent() protected function getContent()
{ {
$count = 0; $count = 0;
$date_content = [];
foreach ($this->getDates() as $date) { foreach ($this->getDates() as $date) {
$day = new DateTime(); $day = new DateTime();
$day->setTimestamp($date->date)->setTime(0, 0); $day->setTimestamp($date->date)->setTime(0, 0);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment