mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-24 12:07:23 +08:00
fix custom field rendering
This commit is contained in:
@@ -216,10 +216,6 @@ function formatAdUrl($adid, $url, $content, $newWindow=true)
|
|||||||
return formatUrl("adredir.php?id=".$adid."&url=".rawurlencode($url), $newWindow, $content);
|
return formatUrl("adredir.php?id=".$adid."&url=".rawurlencode($url), $newWindow, $content);
|
||||||
}
|
}
|
||||||
function formatUrl($url, $newWindow = false, $text = '', $linkClass = '') {
|
function formatUrl($url, $newWindow = false, $text = '', $linkClass = '') {
|
||||||
//Exclude youtube, because [youtube] bbcode
|
|
||||||
if (str_contains($url, 'youtube')) {
|
|
||||||
return $url;
|
|
||||||
}
|
|
||||||
if (!$text) {
|
if (!$text) {
|
||||||
$text = $url;
|
$text = $url;
|
||||||
}
|
}
|
||||||
|
|||||||
+12
-12
@@ -267,9 +267,9 @@ HEAD;
|
|||||||
$name = "custom_fields[{$row['id']}]";
|
$name = "custom_fields[{$row['id']}]";
|
||||||
$currentValue = $customValues[$row['id']]['custom_field_value'] ?? '';
|
$currentValue = $customValues[$row['id']]['custom_field_value'] ?? '';
|
||||||
if ($row['type'] == self::TYPE_TEXT) {
|
if ($row['type'] == self::TYPE_TEXT) {
|
||||||
$html .= tr($row['label'], sprintf('<input type="text" name="%s" value="%s" style="width: 650px"/>', $name, $currentValue), 1);
|
$html .= tr($row['label'], sprintf('<input type="text" name="%s" value="%s" style="width: %s"/>', $name, $currentValue, '99%'), 1);
|
||||||
} elseif ($row['type'] == self::TYPE_TEXTAREA) {
|
} elseif ($row['type'] == self::TYPE_TEXTAREA) {
|
||||||
$html .= tr($row['label'], sprintf('<textarea name="%s" rows="4" style="width: 650px">%s</textarea>', $name, $currentValue), 1);
|
$html .= tr($row['label'], sprintf('<textarea name="%s" rows="4" style="width: %s">%s</textarea>', $name, '99%', $currentValue), 1);
|
||||||
} elseif ($row['type'] == self::TYPE_RADIO || $row['type'] == self::TYPE_CHECKBOX) {
|
} elseif ($row['type'] == self::TYPE_RADIO || $row['type'] == self::TYPE_CHECKBOX) {
|
||||||
if ($row['type'] == self::TYPE_CHECKBOX) {
|
if ($row['type'] == self::TYPE_CHECKBOX) {
|
||||||
$name .= '[]';
|
$name .= '[]';
|
||||||
@@ -320,7 +320,7 @@ HEAD;
|
|||||||
$imgId = "attach" . $row['id'];
|
$imgId = "attach" . $row['id'];
|
||||||
$previewBoxId = "preview_$callbackFunc";
|
$previewBoxId = "preview_$callbackFunc";
|
||||||
$y = '<iframe id="' . $iframeId . '" src="' . getSchemeAndHttpHost() . '/attachment.php?callback_func=' . $callbackFunc . '" width="100%" height="24" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>';
|
$y = '<iframe id="' . $iframeId . '" src="' . getSchemeAndHttpHost() . '/attachment.php?callback_func=' . $callbackFunc . '" width="100%" height="24" frameborder="0" scrolling="no" marginheight="0" marginwidth="0"></iframe>';
|
||||||
$y .= sprintf('<input id="%s" type="text" name="%s" value="%s" style="width: 650px;margin: 10px 0">', $inputId, $name, $currentValue);
|
$y .= sprintf('<input id="%s" type="text" name="%s" value="%s" style="width: %s;margin: 10px 0">', $inputId, $name, $currentValue, '99%');
|
||||||
$y .= '<div id="' . $previewBoxId . '">';
|
$y .= '<div id="' . $previewBoxId . '">';
|
||||||
if (!empty($currentValue)) {
|
if (!empty($currentValue)) {
|
||||||
if (substr($currentValue, 0, 4) == 'http') {
|
if (substr($currentValue, 0, 4) == 'http') {
|
||||||
@@ -406,16 +406,16 @@ JS;
|
|||||||
{
|
{
|
||||||
global $browsecatmode;
|
global $browsecatmode;
|
||||||
$displayName = get_searchbox_value($browsecatmode, 'custom_fields_display_name');
|
$displayName = get_searchbox_value($browsecatmode, 'custom_fields_display_name');
|
||||||
$display = get_searchbox_value($browsecatmode, 'custom_fields_display');
|
|
||||||
$customFields = $this->listTorrentCustomField($torrentId);
|
$customFields = $this->listTorrentCustomField($torrentId);
|
||||||
$mixedRowContent = nl2br($display);
|
$mixedRowContent = get_searchbox_value($browsecatmode, 'custom_fields_display');
|
||||||
$rowByRowHtml = '';
|
$rowByRowHtml = '';
|
||||||
foreach ($customFields as $field) {
|
foreach ($customFields as $field) {
|
||||||
$content = $this->formatCustomFieldValue($field);
|
$contentNotFormatted = $this->formatCustomFieldValue($field, false);
|
||||||
$mixedRowContent = str_replace("<%{$field['name']}.label%>", $field['label'], $mixedRowContent);
|
$mixedRowContent = str_replace("<%{$field['name']}.label%>", $field['label'], $mixedRowContent);
|
||||||
$mixedRowContent = str_replace("<%{$field['name']}.value%>", $content, $mixedRowContent);
|
$mixedRowContent = str_replace("<%{$field['name']}.value%>", $contentNotFormatted, $mixedRowContent);
|
||||||
if ($field['is_single_row']) {
|
if ($field['is_single_row']) {
|
||||||
$rowByRowHtml .= tr($field['label'], $content, 1);
|
$contentFormatted = $this->formatCustomFieldValue($field, true);
|
||||||
|
$rowByRowHtml .= tr($field['label'], $contentFormatted, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
$result = $rowByRowHtml;
|
$result = $rowByRowHtml;
|
||||||
@@ -427,20 +427,20 @@ JS;
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
protected function formatCustomFieldValue(array $customFieldWithValue)
|
protected function formatCustomFieldValue(array $customFieldWithValue, $doFormatComment = false): string
|
||||||
{
|
{
|
||||||
$result = '';
|
$result = '';
|
||||||
$fieldValue = $customFieldWithValue['custom_field_value'];
|
$fieldValue = $customFieldWithValue['custom_field_value'];
|
||||||
switch ($customFieldWithValue['type']) {
|
switch ($customFieldWithValue['type']) {
|
||||||
case self::TYPE_TEXT:
|
case self::TYPE_TEXT:
|
||||||
case self::TYPE_TEXTAREA:
|
case self::TYPE_TEXTAREA:
|
||||||
$result .= format_comment($fieldValue);
|
$result .= $doFormatComment ? format_comment($fieldValue) : $fieldValue;
|
||||||
break;
|
break;
|
||||||
case self::TYPE_IMAGE:
|
case self::TYPE_IMAGE:
|
||||||
if (substr($fieldValue, 0, 4) == 'http') {
|
if (substr($fieldValue, 0, 4) == 'http') {
|
||||||
$result .= formatImg($fieldValue, true, 700, 0, "attach{$customFieldWithValue['id']}");
|
$result .= $doFormatComment ? formatImg($fieldValue, true, 700, 0, "attach{$customFieldWithValue['id']}") : $fieldValue;
|
||||||
} else {
|
} else {
|
||||||
$result .= format_comment($fieldValue);
|
$result .= $doFormatComment ? format_comment($fieldValue) : $fieldValue;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case self::TYPE_RADIO:
|
case self::TYPE_RADIO:
|
||||||
|
|||||||
Reference in New Issue
Block a user