diff --git a/include/functions.php b/include/functions.php
index 3e4737ae..1e13fcf1 100644
--- a/include/functions.php
+++ b/include/functions.php
@@ -4622,4 +4622,62 @@ function canDoLogin()
return true;
}
+function displayHotAndClassic()
+{
+ global $showextinfo, $showmovies, $Cache, $lang_functions;
+
+ if (($showextinfo['imdb'] == 'yes' || get_setting('main.enable_pt_gen_system')) && ($showmovies['hot'] == "yes" || $showmovies['classic'] == "yes"))
+ {
+ $imdb = new \Nexus\Imdb\Imdb();
+ $type = array('hot', 'classic');
+ foreach($type as $type_each)
+ {
+ if($showmovies[$type_each] == 'yes' && (!isset($CURUSER) || $CURUSER['show' . $type_each] == 'yes'))
+ {
+ $Cache->new_page($type_each.'_resources', 900, true);
+ if (!$Cache->get_page())
+ {
+ $Cache->add_whole_row();
+
+ $res = sql_query("SELECT * FROM torrents WHERE picktype = " . sqlesc($type_each) . " AND seeders > 0 AND url != '' ORDER BY id DESC LIMIT 30") or sqlerr(__FILE__, __LINE__);
+ if (mysql_num_rows($res) > 0)
+ {
+ $movies_list = "";
+ $count = 0;
+ $allImdb = array();
+ while($array = mysql_fetch_array($res))
+ {
+ $pro_torrent = get_torrent_promotion_append($array['sp_state'],'word');
+ if ($imdb_id = parse_imdb_id($array["url"]))
+ {
+ if (array_search($imdb_id, $allImdb) !== false) { //a torrent with the same IMDb url already exists
+ continue;
+ }
+ $allImdb[]=$imdb_id;
+ $photo_url = $imdb->getMovie($imdb_id)->photo(true);
+ $thumbnail = " ";
+ }
+ else continue;
+ $thumbnail = "" . (addslashes($array['name'] . $pro_torrent)) . " ".(addslashes($array['small_descr'])) ." "). "', 'trail', true, 'delay', 0,'lifetime',5000,'styleClass','niceTitle','maxWidth', 600);\">" . $thumbnail . " ";
+ $movies_list .= $thumbnail;
+ $count++;
+ if ($count >= 9)
+ break;
+ }
+ ?>
+
+
+ end_whole_row();
+ $Cache->cache_page();
+ }
+ echo $Cache->next_row();
+ }
+ }
+ }
+
+}
+
?>
diff --git a/lang/chs/lang_fields.php b/lang/chs/lang_fields.php
index 7edcbcdb..4a024064 100644
--- a/lang/chs/lang_fields.php
+++ b/lang/chs/lang_fields.php
@@ -19,7 +19,7 @@ $lang_fields = [
'js_sure_to_delete_this' => '你确信要删除此项目吗?',
'submit_submit' => '提交',
'field_type_text' => '短文本',
- 'field_type_textara' => '长文本',
+ 'field_type_textarea' => '长文本',
'field_type_radio' => '横向单选',
'field_type_checkbox' => '横向多选',
'field_type_select' => '下拉单选',
diff --git a/nexus/Field/Field.php b/nexus/Field/Field.php
index 4a8357ea..c1ffa1b9 100644
--- a/nexus/Field/Field.php
+++ b/nexus/Field/Field.php
@@ -57,7 +57,7 @@ class Field
global $lang_fields;
$map = [
self::TYPE_TEXT => $lang_fields['field_type_text'],
- self::TYPE_TEXTAREA => $lang_fields['field_type_textara'],
+ self::TYPE_TEXTAREA => $lang_fields['field_type_textarea'],
self::TYPE_RADIO => $lang_fields['field_type_radio'],
self::TYPE_CHECKBOX => $lang_fields['field_type_checkbox'],
self::TYPE_SELECT => $lang_fields['field_type_select'],
@@ -227,7 +227,7 @@ HEAD;
return $result;
}
- public function buildTable(array $header, array $rows)
+ protected function buildTable(array $header, array $rows)
{
$table = '';
foreach ($header as $key => $value) {
@@ -264,19 +264,20 @@ HEAD;
}
- public function renderUploadPage(array $customValues = [])
+ public function renderOnUploadPage($torrentId = 0)
{
- $searchBoxId = get_setting('main.browsecat');
- $searchBox = DB::getOne('searchbox', "id = $searchBoxId");
+ global $browsecatmode;
+ $searchBox = DB::getOne('searchbox', "id = $browsecatmode");
if (empty($searchBox)) {
- throw new \RuntimeException("Invalid search box: $searchBoxId");
+ throw new \RuntimeException("Invalid search box: $browsecatmode");
}
+ $customValues = $this->listTorrentCustomField($torrentId);
$sql = sprintf('select * from torrents_custom_fields where id in (%s)', $searchBox['custom_fields']);
$res = sql_query($sql);
$html = '';
while ($row = mysql_fetch_assoc($res)) {
$name = "custom_fields[{$row['id']}]";
- $currentValue = $customValues[$row['id']] ?? '';
+ $currentValue = $customValues[$row['id']]['custom_field_value'] ?? '';
if ($row['type'] == self::TYPE_TEXT) {
$html .= tr($row['label'], sprintf(' ', $name, $currentValue), 1);
} elseif ($row['type'] == self::TYPE_TEXTAREA) {
@@ -402,43 +403,16 @@ JS;
return $result;
}
- public function renderTorrentDetailPageMixed($torretnId)
+ public function renderOnTorrentDetailsPage($torrentId)
{
global $browsecatmode;
$displayName = get_searchbox_value($browsecatmode, 'custom_fields_display_name');
$displayOrder = get_searchbox_value($browsecatmode, 'custom_fields_display_order');
- $customFields = $this->listTorrentCustomField($torretnId);
+ $customFields = $this->listTorrentCustomField($torrentId);
$mixedRowContent = nl2br($displayOrder);
$rowByRowHtml = '';
foreach ($customFields as $field) {
- $content = '';
- $fieldValue = $field['custom_field_value'];
- $typeInfo = self::$types[$field['type']];
- switch ($field['type']) {
- case self::TYPE_TEXT:
- case self::TYPE_TEXTAREA:
- case self::TYPE_FILE:
- $content .= format_comment($fieldValue);
- break;
- case self::TYPE_IMAGE:
- if (substr($fieldValue, 0, 4) == 'http') {
- $content .= formatImg($fieldValue, true, 700, 0, "attach{$field['id']}");
- } else {
- $content .= format_comment($fieldValue);
- }
- break;
- case self::TYPE_RADIO:
- case self::TYPE_CHECKBOX:
- case self::TYPE_SELECT;
- $fieldContent = [];
- foreach ((array)$fieldValue as $item) {
- $fieldContent[] = $field['options'][$item] ?? '';
- }
- $content .= implode(' ', $fieldContent);
- break;
- default:
- break;
- }
+ $content = $this->formatCustomFieldValue($field);
$mixedRowContent = str_replace("<%{$field['name']}.label%>", $field['label'], $mixedRowContent);
$mixedRowContent = str_replace("<%{$field['name']}.value%>", $content, $mixedRowContent);
if ($field['is_single_row']) {
@@ -453,4 +427,53 @@ JS;
}
+
+ protected function formatCustomFieldValue(array $customFieldWithValue)
+ {
+ $result = '';
+ $fieldValue = $customFieldWithValue['custom_field_value'];
+ switch ($customFieldWithValue['type']) {
+ case self::TYPE_TEXT:
+ case self::TYPE_TEXTAREA:
+ case self::TYPE_FILE:
+ $result .= format_comment($fieldValue);
+ break;
+ case self::TYPE_IMAGE:
+ if (substr($fieldValue, 0, 4) == 'http') {
+ $result .= formatImg($fieldValue, true, 700, 0, "attach{$customFieldWithValue['id']}");
+ } else {
+ $result .= format_comment($fieldValue);
+ }
+ break;
+ case self::TYPE_RADIO:
+ case self::TYPE_CHECKBOX:
+ case self::TYPE_SELECT;
+ $fieldContent = [];
+ foreach ((array)$fieldValue as $item) {
+ $fieldContent[] = $customFieldWithValue['options'][$item] ?? '';
+ }
+ $result .= implode(' ', $fieldContent);
+ break;
+ default:
+ break;
+ }
+ return $result;
+ }
+
+ public function getFieldValue($torrentId, $fieldName = null)
+ {
+ static $result;
+ if (is_null($result)) {
+ $customFields = $this->listTorrentCustomField($torrentId);
+ $result = [];
+ foreach ($customFields as &$field) {
+ $field['custom_field_value_formatted'] = $this->formatCustomFieldValue($field);
+ $result[$field['name']] = $field;
+ }
+ }
+ return is_null($fieldName) ? $result : ($result[$fieldName] ?? '');
+
+ }
+
+
}
\ No newline at end of file
diff --git a/nexus/Imdb/Imdb.php b/nexus/Imdb/Imdb.php
index 81b59b1c..e8c3b211 100644
--- a/nexus/Imdb/Imdb.php
+++ b/nexus/Imdb/Imdb.php
@@ -271,4 +271,16 @@ class Imdb
$result .= '';
return $result;
}
+
+ public function renderHotAndClassic()
+ {
+ global $showextinfo, $showmovies;
+
+ $shouldDisplay = ($showextinfo['imdb'] == 'yes' || get_setting('main.enable_pt_gen_system')) && ($showmovies['hot'] == "yes" || $showmovies['classic'] == "yes");
+ if (!$shouldDisplay) {
+ return '';
+ }
+
+
+ }
}
\ No newline at end of file
diff --git a/public/details.php b/public/details.php
index d46530c9..60a40c3b 100644
--- a/public/details.php
+++ b/public/details.php
@@ -155,7 +155,7 @@ else {
// ---------------- end subtitle block -------------------//
/**************start custom fields****************/
- echo $customField->renderTorrentDetailPageMixed($id);
+ echo $customField->renderOnTorrentDetailsPage($id);
/**************end custom fields****************/
diff --git a/public/edit.php b/public/edit.php
index c362dd25..3760ff69 100644
--- a/public/edit.php
+++ b/public/edit.php
@@ -17,8 +17,6 @@ if (!$row) die();
* @since v1.6
*/
$customField = new \Nexus\Field\Field();
-$customFieldValues = $customField->listTorrentCustomField($id);
-//dd($customFieldValues);
if ($enablespecial == 'yes' && get_user_class() >= $movetorrent_class)
$allowmove = true; //enable moving torrent to other section
@@ -67,7 +65,7 @@ else {
echo $ptGen->renderUploadPageFormInput($row['pt_gen']);
}
- $customField->renderUploadPage($customFieldValues);
+ $customField->renderOnUploadPage($id);
if ($enablenfo_main=='yes')
tr($lang_edit['row_nfo_file'], " ".$lang_edit['radio_keep_current'].
diff --git a/public/index.php b/public/index.php
index 17202f15..c5e61b60 100644
--- a/public/index.php
+++ b/public/index.php
@@ -4,8 +4,6 @@ dbconn(true);
require_once(get_langfile_path());
loggedinorreturn(true);
$userid = $CURUSER["id"];
-if ($showextinfo['imdb'] == 'yes')
- require_once ("imdb/imdb.class.php");
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
if ($showpolls_main == "yes")
@@ -87,60 +85,7 @@ while($Cache->next_row()){
echo $Cache->next_row();
// ------------- end: recent news ------------------//
// ------------- start: hot and classic movies ------------------//
-if ($showextinfo['imdb'] == 'yes' && ($showmovies['hot'] == "yes" || $showmovies['classic'] == "yes"))
-{
- $type = array('hot', 'classic');
- foreach($type as $type_each)
- {
- if($showmovies[$type_each] == 'yes' && (!isset($CURUSER) || $CURUSER['show' . $type_each] == 'yes'))
- {
- $Cache->new_page($type_each.'_resources', 900, true);
- if (!$Cache->get_page())
- {
- $Cache->add_whole_row();
-
- $imdbcfg = new imdb_config();
- $res = sql_query("SELECT * FROM torrents WHERE picktype = " . sqlesc($type_each) . " AND seeders > 0 AND url != '' ORDER BY id DESC LIMIT 30") or sqlerr(__FILE__, __LINE__);
- if (mysql_num_rows($res) > 0)
- {
- $movies_list = "";
- $count = 0;
- $allImdb = array();
- while($array = mysql_fetch_array($res))
- {
- $pro_torrent = get_torrent_promotion_append($array[sp_state],'word');
- if ($imdb_id = parse_imdb_id($array["url"]))
- {
- if (array_search($imdb_id, $allImdb) !== false) { //a torrent with the same IMDb url already exists
- continue;
- }
- $allImdb[]=$imdb_id;
- $photo_url = $imdbcfg->photodir . $imdb_id. $imdbcfg->imageext;
-
- if (file_exists($photo_url))
- $thumbnail = " ";
- else continue;
- }
- else continue;
- $thumbnail = "" . (addslashes($array['name'] . $pro_torrent)) . " ".(addslashes($array['small_descr'])) ." "). "', 'trail', true, 'delay', 0,'lifetime',5000,'styleClass','niceTitle','maxWidth', 600);\">" . $thumbnail . "";
- $movies_list .= $thumbnail;
- $count++;
- if ($count >= 9)
- break;
- }
-?>
-
-
-end_whole_row();
- $Cache->cache_page();
- }
- echo $Cache->next_row();
- }
- }
-}
+displayHotAndClassic();
// ------------- end: hot and classic movies ------------------//
// ------------- start: funbox ------------------//
if ($showfunbox_main == "yes" && (!isset($CURUSER) || $CURUSER['showfb'] == "yes")){
diff --git a/public/torrents.php b/public/torrents.php
index bac22832..25faf15b 100644
--- a/public/torrents.php
+++ b/public/torrents.php
@@ -1,12 +1,9 @@
");
+
+displayHotAndClassic();
+
+
if ($allsec != 1 || $enablespecial != 'yes'){ //do not print searchbox if showing bookmarked torrents from all sections;
?>