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
ExternPageConfig::findEachBySQL(
function ($c) use (&$configs, &$count_not_migrated) {
$configs[$c->type][] = $c;
if (isset($c->conf['not_fixed_after_migration'])) {
$count_not_migrated++;
if (isset($c->conf['not_fixed_after_migration'])) {
$count_not_migrated++;
}
},
"range_id = ?", [$this->range]
......@@ -165,7 +165,7 @@ class Admin_ExternController extends AuthenticatedController
if ($this->page->page_config->isNew()) {
PageLayout::postSuccess(sprintf(
_('Eine neue externe Seite "%$1s" vom Typ %$2s wurde angelegt.'),
htmlReady($this->page->name),
htmlReady($this->page->name),
htmlReady($this->page->type)
));
} else {
......@@ -259,7 +259,11 @@ class Admin_ExternController extends AuthenticatedController
*/
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) {
$this->author = '<a href="'
. URLHelper::getLink('dispatch.php/profile', ['username' => $this->page->author->username])
......@@ -364,7 +368,7 @@ class Admin_ExternController extends AuthenticatedController
$config->author_id = $config->editor_id = $GLOBALS['user']->id;
$config->store();
PageLayout::postSuccess(
sprintf(_('Die Konfiguration "%s" wurde erfolgreich importiert.'),
sprintf(_('Die Konfiguration "%s" wurde erfolgreich importiert.'),
htmlReady($config->name)
));
}
......
......@@ -85,7 +85,7 @@
<select class="nested-select" name="semclass[]" multiple>
<? foreach ($GLOBALS['SEM_CLASS'] as $key => $sem_class) : ?>
<? 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']) ?>
</option>
<? endif ?>
......
......@@ -22,7 +22,7 @@ else : ?>
</h1>
</header>
<? 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"'; ?>>
<header>
<h1>
......
......@@ -16,7 +16,7 @@
<div style="font-size: smaller;">
(<?= _('Ohne Angabe wird der Name aus den importierten Daten genommen.') ?>)
</div>
<input type="text" name="config_name" value="<?= htmlReady($config_name) ?>">
<input type="text" name="config_name" value="<?= htmlReady($config_name ?? '') ?>">
</label>
<label>
<?= _('Konfigurationsdatei') ?>
......
......@@ -37,7 +37,7 @@ trait StudipTreeNodeCachableTrait
return $config;
}
protected function getDescendantIds(): array
public function getDescendantIds(): array
{
$cache = self::getDescendantsCacheArray();
......
......@@ -138,7 +138,7 @@ abstract class ExternPage
$extract[] = array_values(array_filter(array_map('trim', explode(' ', $one))));
}
foreach ($extract as $one) {
$return[$one[0]] = $one[1];
$return[$one[0]] = $one[1] ?? null;
}
return $return;
}
......@@ -236,7 +236,7 @@ abstract class ExternPage
$allowed_params = $this->getAllowedRequestParams(true);
$config_fields = $this->getConfigFields(true);
foreach ($allowed_params as $param_name) {
$method = $config_fields[$param_name] ?: 'get';
$method = $config_fields[$param_name] ?? 'get';
$param_value = Request::$method($param_name);
if ($param_value) {
$this->setValue($param_name, $param_value);
......@@ -342,6 +342,7 @@ abstract class ExternPage
): string {
if (count($scopes) > 0) {
$study_areas = StudipStudyArea::findMany($scopes);
$scopes = [];
if ($with_kids) {
foreach ($study_areas as $study_area) {
......
......@@ -162,7 +162,7 @@ class ExternPageTimetable extends ExternPage
$time = new DateTime();
switch ($this->date_offset) {
case 'start_date':
$time = DateTime::createFromFormat('d.m.Y', $this->date);
$time = $this->date ? DateTime::createFromFormat('d.m.Y', $this->date) : $time;
break;
case 'current_semester':
$semester = Semester::findCurrent();
......@@ -228,6 +228,7 @@ class ExternPageTimetable extends ExternPage
protected function getContent()
{
$count = 0;
$date_content = [];
foreach ($this->getDates() as $date) {
$day = new DateTime();
$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