-
Notifications
You must be signed in to change notification settings - Fork 0
/
browse.php
118 lines (98 loc) · 3.13 KB
/
browse.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<?php
include_once 'listings.php';
$libraryBrowse = true;
$useSeasonImage = false;
$pageObj = new ListingsPage('');
$pageObj->backdrop = $backdrop;
overrideIndexStyle($folderType, $collectionType);
$pageObj->dynamicGridPage = $dynamicGridPage;
//get episodes from this season
$params = new UserItemsParams();
if (!$pageObj->dynamicGridPage) {
$params->StartIndex = ($page - 1) * $indexStyle->Limit;
$params->Limit = $indexStyle->Limit;
}
//common options
$recursive = false;
$type = null;
switch ($folderType) {
case ItemType::PLAYLIST:
$recursive = true;
$params->setSortByDefault(null);
break;
case ItemType::BOXSET:
$params->setSortByDefault(null);
break;
default:
if ($collectionType == CollectionType::TVSHOWS) {
$type = ItemType::SERIES;
$recursive = true;
} elseif ($collectionType == CollectionType::MOVIES) {
$type = ItemType::MOVIE;
$recursive = true;
}
}
$params->setFromQueryString();
if ($collectionType === 'search' || empty($params->ParentID)) {
//exclude season and episodes to match JF behavior
$excludeItemTypes = ItemType::SEASON . ',' . ItemType::EPISODE;
$recursive = true;
}
$params->IncludeItemTypes = $type;
$params->ExcludeItemTypes = $excludeItemTypes;
$params->Recursive = $recursive;
$itemsAndCount = getItems($params);
$items = $itemsAndCount->Items;
$pageObj->setNumPagesAndIndexCount($itemsAndCount->TotalRecordCount);
$prettySortBy = [
"SortName" => "Name",
"CommunityRating" => "Community Rating",
"CriticRating" => "Critic Rating",
"DateCreated" => "Date Added",
"DatePlayed" => "Date Played",
"OfficialRating" => "Parental Rating",
"PlayCount" => "Play Count",
"PremiereDate" => "Release Date",
"Runtime" => "Runtime"
];
$prettyFilter = [
"IsFavorite" => "Favorites",
"IsUnplayed" => "Unplayed",
"IsPlayed" => "Played",
"hasSpecialFeature" => "Extras",
"hasSubtitles" => "Subtitles",
"hasTrailer" => "Trailers",
"hasThemeSong" => "Theme Song",
"hasThemeVideo" => "Theme Video"
];
if (empty($name)) {
//build name from parameters
foreach ($filterCategories as $cat) {
if (!empty($params->$cat)) {
!empty($name) && $name .= ", ";
if (strpos($cat, 'has') === 0) {
$key = $cat;
} else {
$key = $params->$cat;
}
$name .= array_key_exists($key, $prettyFilter) ? $prettyFilter[$key] : $params->$cat;
}
}
if ((!empty($params->SortBy) && $params->SortBy != UserItemsParams::SORTNAME) || $params->SortOrder == UserItemsParams::DESC) {
!empty($name) && $name .= ", ";
$name .= 'by ' . $prettySortBy[$params->SortBy];
if ($params->SortOrder == UserItemsParams::DESC) {
$name .= ' ' . $params->SortOrder;
}
}
}
if (!empty($topParentName) && $topParentName != $name) {
$pageObj->title = $topParentName;
if (!empty($name)) {
$pageObj->title .= ' - ';
}
}
$pageObj->title .= $name;
$pageObj->indexStyle = $indexStyle;
$pageObj->items = $items;
$pageObj->render();