aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
Diffstat (limited to 'lib')
-rw-r--r--lib/admissionrules/coursememberadmission/templates/info.php2
-rw-r--r--lib/classes/Icon.php52
-rw-r--r--lib/classes/forms/Link.php2
-rw-r--r--lib/classes/globalsearch/GlobalSearchCourses.php6
-rw-r--r--lib/classes/globalsearch/GlobalSearchStudygroups.php6
-rw-r--r--lib/classes/sidebar/CourseManagementSelectWidget.php2
-rw-r--r--lib/classes/sidebar/LinkElement.php4
-rw-r--r--lib/ilias_interface/IliasModule.php2
-rw-r--r--lib/models/OERReview.php10
-rw-r--r--lib/models/resources/ResourcePropertyDefinition.php2
-rw-r--r--lib/navigation/Navigation.php2
-rw-r--r--lib/statusgruppe.inc.php2
12 files changed, 53 insertions, 39 deletions
diff --git a/lib/admissionrules/coursememberadmission/templates/info.php b/lib/admissionrules/coursememberadmission/templates/info.php
index 8616aad..9c844e3 100644
--- a/lib/admissionrules/coursememberadmission/templates/info.php
+++ b/lib/admissionrules/coursememberadmission/templates/info.php
@@ -14,7 +14,7 @@
<li>
<strong><?= htmlReady($course->getFullName('number-name-semester')) ?></strong>
<a href="<?= URLHelper::getLink('dispatch.php/course/details/index/' . $course->id) ?>" data-dialog>
- <?= Icon::create('info-circle')->asSvg([
+ <?= Icon::create('info-circle')->asImg([
'title' => _('Veranstaltungsdetails aufrufen')
]) ?>
</a>
diff --git a/lib/classes/Icon.php b/lib/classes/Icon.php
index 509664e..8306181 100644
--- a/lib/classes/Icon.php
+++ b/lib/classes/Icon.php
@@ -198,7 +198,7 @@ class Icon implements JsonSerializable
*/
public function __toString()
{
- return $this->asSvg();
+ return $this->asImg();
}
public function jsonSerialize(): mixed
@@ -207,35 +207,49 @@ class Icon implements JsonSerializable
}
/**
- * Renders the icon inside an img html tag.
+ * Renders the icon inside as an svg image.
*
* @param int $size Optional; Defines the dimension in px of the rendered icon; FALSE prevents any
* width or height attributes
* @param Array $view_attributes Optional; Additional attributes to pass
* into the rendered output
* @return String containing the html representation for the icon.
+ *
+ * @deprecated will be removed in Stud.IP 7.0. Use `asImg` instead.
*/
- public function asImg($size = null, $view_attributes = [])
+ public function asSvg($size = self::SIZE_DEFAULT, $view_attributes = []): string
{
- if (is_array($size)) {
- [$view_attributes, $size] = [$size, null];
- }
- return sprintf(
- '<img %s>',
- arrayToHtmlAttributes(
- $this->prepareHTMLAttributes($size, $view_attributes)
- )
- );
+ return $this->asImg(...func_get_args());
}
- public function asSvg($size = self::SIZE_DEFAULT, $view_attributes = []): string
- {
- if (self::isStatic($this->shape)) {
- return $this->asImg($size, $view_attributes);
+ /**
+ * Renders the icon as an HTML image.
+ *
+ * @param int $size Optional; Defines the dimension in px of the rendered icon; FALSE prevents any
+ * width or height attributes
+ * @param Array $view_attributes Optional; Additional attributes to pass
+ * into the rendered output
+ * @param bool $force_img_tag Optional; If true, the icon will always be rendered as an img tag.
+ * @return String containing the html representation for the icon.
+ */
+ public function asImg(
+ $size = self::SIZE_DEFAULT,
+ $view_attributes = [],
+ bool $force_img_tag = false
+ ): string {
+ if (is_array($size)) {
+ [$view_attributes, $size] = [$size, self::SIZE_DEFAULT];
}
- if (is_array($size)) {
- [$view_attributes, $size] = [$size, $size['size'] ?? self::SIZE_DEFAULT];
+ $size ??= self::SIZE_DEFAULT;
+
+ if ($force_img_tag || self::isStatic($this->shape)) {
+ return sprintf(
+ '<img %s>',
+ arrayToHtmlAttributes(
+ $this->prepareHTMLAttributes($size, $view_attributes)
+ )
+ );
}
$cacheKey = md5(json_encode([
@@ -305,7 +319,7 @@ class Icon implements JsonSerializable
$text = isset($view_attributes['text']) ? htmlReady($view_attributes['text']) : '';
- $svgContent = $this->asSvg($size, $view_attributes);
+ $svgContent = $this->asImg($size, $view_attributes);
if ($without_label) {
return sprintf(
diff --git a/lib/classes/forms/Link.php b/lib/classes/forms/Link.php
index e198c71..8aa182c 100644
--- a/lib/classes/forms/Link.php
+++ b/lib/classes/forms/Link.php
@@ -159,7 +159,7 @@ class Link extends Part
'<div class="formpart"><a href="%1$s" %2$s>%3$s %4$s</a></div>',
\URLHelper::getLink($this->url, [], true),
arrayToHtmlAttributes($this->attributes),
- $this->icon ? $this->icon->asSvg(['class' => 'text-bottom']) : '',
+ $this->icon ? $this->icon->asImg(['class' => 'text-bottom']) : '',
htmlReady($this->label)
);
}
diff --git a/lib/classes/globalsearch/GlobalSearchCourses.php b/lib/classes/globalsearch/GlobalSearchCourses.php
index a02e691..939203c 100644
--- a/lib/classes/globalsearch/GlobalSearchCourses.php
+++ b/lib/classes/globalsearch/GlobalSearchCourses.php
@@ -185,21 +185,21 @@ class GlobalSearchCourses extends GlobalSearchModule implements GlobalSearchFull
'decline-circle',
Icon::ROLE_STATUS_YELLOW,
tooltip2(_('Eingeschränkter Zugang'))
- )->asSvg();
+ )->asImg();
break;
case 2:
$admission_state = Icon::create(
'decline-circle',
Icon::ROLE_STATUS_RED,
tooltip2(_('Kein Zugang'))
- )->asSvg();
+ )->asImg();
break;
default:
$admission_state = Icon::create(
'check-circle',
Icon::ROLE_STATUS_GREEN,
tooltip2(_('Uneingeschränkter Zugang'))
- )->asSvg();
+ )->asImg();
}
}
diff --git a/lib/classes/globalsearch/GlobalSearchStudygroups.php b/lib/classes/globalsearch/GlobalSearchStudygroups.php
index 74bc11f..a9f1398 100644
--- a/lib/classes/globalsearch/GlobalSearchStudygroups.php
+++ b/lib/classes/globalsearch/GlobalSearchStudygroups.php
@@ -188,21 +188,21 @@ class GlobalSearchStudygroups extends GlobalSearchModule implements GlobalSearch
'decline-circle',
Icon::ROLE_STATUS_YELLOW,
tooltip2(_('Eingeschränkter Zugang'))
- )->asSvg();
+ )->asImg();
break;
case 2:
$admission_state = Icon::create(
'decline-circle',
Icon::ROLE_STATUS_RED,
tooltip2(_('Kein Zugang'))
- )->asSvg();
+ )->asImg();
break;
default:
$admission_state = Icon::create(
'check-circle',
Icon::ROLE_STATUS_GREEN,
tooltip2(_('Uneingeschränkter Zugang'))
- )->asSvg();
+ )->asImg();
}
}
diff --git a/lib/classes/sidebar/CourseManagementSelectWidget.php b/lib/classes/sidebar/CourseManagementSelectWidget.php
index 8f10eaa..3ce9d80 100644
--- a/lib/classes/sidebar/CourseManagementSelectWidget.php
+++ b/lib/classes/sidebar/CourseManagementSelectWidget.php
@@ -19,7 +19,7 @@ class CourseManagementSelectWidget extends SelectWidget
'<a href="%s" title="%s" data-dialog="size=auto">%s</a>',
URLHelper::getURL('dispatch.php/course/management/order_settings', ['cid' => $this->course->id, 'from' => Request::url()]),
_('Sortiereinstellungen'),
- Icon::create('settings')->asSvg(['title' => _('Sortiereinstellungen')])
+ Icon::create('settings')->asImg(['title' => _('Sortiereinstellungen')])
);
$this->setExtra($extra);
$this->class = 'nested-select';
diff --git a/lib/classes/sidebar/LinkElement.php b/lib/classes/sidebar/LinkElement.php
index 4b87337..b6742c0 100644
--- a/lib/classes/sidebar/LinkElement.php
+++ b/lib/classes/sidebar/LinkElement.php
@@ -241,7 +241,7 @@ class LinkElement extends WidgetElement implements ArrayAccess
'<%1$s %2$s>%3$s%4$s</%1$s>',
$tag,
arrayToHtmlAttributes($attributes),
- $icon->asSvg(),
+ $icon->asImg(),
htmlReady($this->label)
);
}
@@ -257,7 +257,7 @@ class LinkElement extends WidgetElement implements ArrayAccess
'<button formaction="%s" %s>%s %s</button>',
htmlReady($this->url),
arrayToHtmlAttributes((array) $this->attributes),
- $icon?->asSvg() ?? '',
+ $icon?->asImg() ?? '',
htmlReady($this->label)
);
}
diff --git a/lib/ilias_interface/IliasModule.php b/lib/ilias_interface/IliasModule.php
index f792c5d..84336ab 100644
--- a/lib/ilias_interface/IliasModule.php
+++ b/lib/ilias_interface/IliasModule.php
@@ -374,6 +374,6 @@ class IliasModule
if (!$this->icon_file) {
$this->icon_file = 'learnmodule';
}
- return Icon::create($this->icon_file, 'inactive', [])->asSvg();
+ return Icon::create($this->icon_file, 'inactive', [])->asImg();
}
}
diff --git a/lib/models/OERReview.php b/lib/models/OERReview.php
index 69a672f..e5b9fd4 100644
--- a/lib/models/OERReview.php
+++ b/lib/models/OERReview.php
@@ -204,15 +204,15 @@ class OERReview extends BlubberThread
$data['thread_posting']['html'] .= "<div>";
$rating = round($this['metadata']['rating'], 1);
$v = $rating >= 0.75 ? "" : ($rating >= 0.25 ? "-halffull" : "-empty");
- $data['thread_posting']['html'] .= Icon::create("star{$v}", 'info')->asSvg(25);
+ $data['thread_posting']['html'] .= Icon::create("star{$v}", 'info')->asImg(25);
$v = $rating >= 1.75 ? "" : ($rating >= 1.25 ? "-halffull" : "-empty");
- $data['thread_posting']['html'] .= Icon::create("star{$v}", 'info')->asSvg(25);
+ $data['thread_posting']['html'] .= Icon::create("star{$v}", 'info')->asImg(25);
$v = $rating >= 2.75 ? "" : ($rating >= 2.25 ? "-halffull" : "-empty");
- $data['thread_posting']['html'] .= Icon::create("star{$v}", 'info')->asSvg(25);
+ $data['thread_posting']['html'] .= Icon::create("star{$v}", 'info')->asImg(25);
$v = $rating >= 3.75 ? "" : ($rating >= 3.25 ? "-halffull" : "-empty");
- $data['thread_posting']['html'] .= Icon::create("star{$v}", 'info')->asSvg(25);
+ $data['thread_posting']['html'] .= Icon::create("star{$v}", 'info')->asImg(25);
$v = $rating >= 4.75 ? "" : ($rating >= 4.25 ? "-halffull" : "-empty");
- $data['thread_posting']['html'] .= Icon::create("star{$v}", 'info')->asSvg(25);
+ $data['thread_posting']['html'] .= Icon::create("star{$v}", 'info')->asImg(25);
$data['thread_posting']['html'] .= "</div>";
return $data;
diff --git a/lib/models/resources/ResourcePropertyDefinition.php b/lib/models/resources/ResourcePropertyDefinition.php
index 1e2333d..f878975 100644
--- a/lib/models/resources/ResourcePropertyDefinition.php
+++ b/lib/models/resources/ResourcePropertyDefinition.php
@@ -254,7 +254,7 @@ class ResourcePropertyDefinition extends SimpleORMap
),
$this->__toString(),
$search->render(),
- Icon::create('refresh')->asSvg(
+ Icon::create('refresh')->asImg(
[
'class' => 'delete-assigned-user-icon enter-accessible',
'data-input-name' => $input_name,
diff --git a/lib/navigation/Navigation.php b/lib/navigation/Navigation.php
index 6f4de69..9f26ab6 100644
--- a/lib/navigation/Navigation.php
+++ b/lib/navigation/Navigation.php
@@ -202,7 +202,7 @@ class Navigation implements IteratorAggregate
public function getImageTag()
{
if ($image = $this->getImage()) {
- return $image->asSvg($this->getLinkAttributes());
+ return $image->asImg($this->getLinkAttributes());
} else {
return '';
}
diff --git a/lib/statusgruppe.inc.php b/lib/statusgruppe.inc.php
index 993ae08..a9c382c 100644
--- a/lib/statusgruppe.inc.php
+++ b/lib/statusgruppe.inc.php
@@ -161,7 +161,7 @@ function get_role_data_recursive($roles, $user_or_id, $default_entries, $level =
if ($role['user_there'] && $role['visible']) {
$out .= '<tr><td>'
- . Icon::create('arr_1right', Icon::ROLE_INFO)->asSvg(Icon::SIZE_INLINE, [])
+ . Icon::create('arr_1right', Icon::ROLE_INFO)->asImg(Icon::SIZE_INLINE, [])
. '</td><td colspan="2"><b>'. htmlReady($new_pred) .'</b></td></tr>';
$entries = DataFieldEntry::getDataFieldEntries([$user->id, $role_id]);