$set[1]['fetch']['order_direction'] = 'DESC'; $set[1]['fetch']['limit'] = '4'; $set[2]['fetch']['entertain_type'] = $request['entertain_type']; $set[2]['fetch']['order'] = 'random'; $set[2]['fetch']['limit'] = '4'; $set[3]['fetch']['entertain_type'] = $request['entertain_type']; $set[3]['fetch']['order'] = 'comment_count'; $set[3]['fetch']['order_direction'] = 'DESC'; $set[3]['fetch']['limit'] = '4'; $options = $set[rand(0, 3)]; $fetch_result = entertain_fetch($options['fetch']); $items = $fetch_result['items']; // preint_r($items); $list_options['list_style'] = 'thumbnails'; $output .= rounded_corners_top(); $output .= entertain_list($items, $list_options); $output .= rounded_corners_bottom(); //En utvalt item med två kommentarer $output .= rounded_corners_top(); $fetch['entertain_type'] = $request['entertain_type']; $fetch['order'] = 'random'; $fetch['limit'] = '1'; $fetch_result = entertain_fetch($fetch); $items = $fetch_result['items']; $item = array_pop($items); $output .= '<div class="entertain_item_with_comments">' . "\n"; $output .= entertain_thumbnail_draw($item); $comments_options['limit'] = 2; $comments_options['style'] = 'no_margin'; $output .= comments_list($item['id'], 'entertain', $comments_options); $output .= '<br style="clear: both;" />' . "\n";
function entertain_item_draw($item, $options) { global $entertain_types; entertain_item_viewed($item['id'], $item['entertain_type'], $item['view_count']); $output .= '<span class="' . $item['entertain_type'] . '">' . "\n"; $output .= '<div class="entertain_item">' . "\n"; // Item title $output .= '<h1 class="entertain_header">' . $item['title'] . '</h1>' . "\n"; /* The entertainment items are displayed in different ways for different types. Games have full width while movie clips, flash films and images are displayed in 3/4 width, whith a few thumbnails on the side. */ switch ($item['entertain_type']) { case 'software': case 'clip': case 'flash': case 'image': $fetch_result = entertain_fetch(array('released' => true, 'entertain_type' => $item['entertain_type'], 'exclude' => array($item['id']), 'limit' => 3, 'order' => 'random')); $related_items = $fetch_result['items']; $output .= entertain_list($related_items, array('list_style' => 'thumbnails', 'headline' => 'Fler ' . $entertain_types[$item['entertain_type']]['label_plural'])); break; case 'game': break; } // Item rank, counter and release date $output .= '<div class="entertain_statistics">' . "\n"; $output .= '<div class="entertain_rank">' . "\n"; $output .= rank_draw($item['rank_average'], array('size' => 'medium')); $output .= '</div>' . "\n"; // end entertain_rank $output .= '<div class="entertain_view_count">' . "\n"; $output .= cute_number($item['view_count'] + 1) . ' visningar sedan ' . "\n"; $output .= date('Y-m-d', $item['release']); //fix_time($item['release']); $output .= '</div>' . "\n"; // end entertain_date $output .= '</div>' . "\n"; // end entertain_statistics $output .= '<div class="entertain_player" id="entertain_player">' . "\n"; /* Now we shall display the entertainment item itself. This is done in different ways for different types and also different depending on special properties like use_special_code or trailer_id. */ if ($_SESSION['login']['id'] == 87926) { preint_r($item); } //First, we consider a bunch of special cases, that is film trailers, items with their own special html, images and software links if ($item['trailer_id'] > 0) { $output .= '<!-- Play Networks - Embeddable Flash Player -->' . "\n"; $output .= '<div id="playnw" class="playnw">' . "\n"; $output .= '<script src="http://se.player.playnetworks.net/player.php?mid=' . $item['trailer_id'] . '&channel_user_id=4601100020-1&width=474&height=355"></script><br>' . "\n"; $output .= '</div>' . "\n"; $output .= '<!-- Play Networks - Embeddable Flash Player -->' . "\n"; } elseif ($item['use_special_code'] == 1) { $output .= stripslashes($item['html']); } elseif (strlen($item['link']) > 2 && $item['entertain_type'] == 'image') { $server = distribute_server_get(array('item_handle' => $item['handle'], 'type' => $item['entertain_type'])); $address = 'http://' . $server['address'] . '/distribute/' . $item['entertain_type'] . '/' . $item['handle'] . '.' . $item['extension']; $output .= '<a href="' . $item['link'] . '"><img src="' . $address . '" class="entertain_' . $item['entertain_type'] . '" /></a>' . "\n"; } elseif ($item['entertain_type'] == 'software') { $output .= '<button onclick="window.location=\'' . $item['link'] . '\';" class="button_150">Ladda ner</button><br />' . "\n"; $output .= '<p>Alla filer är givetvis gratis att ladda ner och innehåller inga virus!</p>' . "\n"; } else { $server = distribute_server_get(array('item_handle' => $item['handle'], 'type' => $item['entertain_type'])); $address = 'http://' . $server['address'] . '/distribute/' . $item['entertain_type'] . '/' . $item['handle'] . '.' . $item['extension']; switch ($item['extension']) { case 'swf': $wrapper = ''; $output .= '<object type="application/x-shockwave-flash" data="' . $wrapper . $address . '" > <param name="movie" value="' . $wrapper . $address . '" /></object>'; $item['entertain_type'] == 'clip' || $item['entertain_type'] == 'flash' ? event_log_log('jc_ad_after') : ''; break; case 'flv': $player_url = '/entertain/flvplayer.swf'; // On end of J-store campaign, set width to 456 and height to 355 on both places $output .= '<div id="player1"><a href="http://www.macromedia.com/go/getflashplayer">Installera Flash Player</a> för att kunna se den här grejen.</div> <script type="text/javascript"> var s1 = new SWFObject("' . $player_url . '","single","466","336","7"); s1.addParam("allowfullscreen","true"); s1.addVariable("file","' . $address . '"); s1.addVariable("image","' . IMAGE_URL . '/entertain/' . $item['handle'] . '.png"); s1.addVariable("width","466"); s1.addVariable("height","336"); s1.write("player1"); </script>'; break; case 'jpg': case 'png': case 'gif': $server = distribute_server_get(array('item_handle' => $item['handle'], 'type' => $item['entertain_type'])); $address = 'http://' . $server['address'] . '/distribute/' . $item['entertain_type'] . '/' . $item['handle'] . '.' . $item['extension']; $output .= '<img src="' . $address . '" class="entertain_' . $item['entertain_type'] . '" />' . "\n"; } } $output .= '<div class="entertain_item_buttons">' . "\n"; if ($item['entertain_type'] == 'image') { $query = 'SELECT id, handle FROM entertain_items WHERE id < "' . $item['id'] . '"'; $query .= ' AND `release` < ' . time(); $query .= ' AND entertain_type = "' . $item['entertain_type'] . '"'; $query .= ' ORDER BY id DESC'; $query .= ' LIMIT 1'; $result = mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__)); if ($data = mysql_fetch_assoc($result)) { $output .= '<a href="/' . $entertain_types[$item['entertain_type']]['url_handle'] . '/' . $data['handle'] . '.html">'; $output .= '<button id="entertain_previous" class="button_90">'; $output .= 'Föregående'; $output .= '</button></a>' . "\n"; } $query = 'SELECT id, handle FROM entertain_items WHERE id > "' . $item['id'] . '"'; $query .= ' AND `release` < ' . time(); $query .= ' AND entertain_type = "' . $item['entertain_type'] . '"'; $query .= ' ORDER BY id ASC'; $query .= ' LIMIT 1'; $result = mysql_query($query) or die(report_sql_error($query, __FILE__, __LINE__)); if ($data = mysql_fetch_assoc($result)) { $output .= '<a href="/' . $entertain_types[$item['entertain_type']]['url_handle'] . '/' . $data['handle'] . '.html">'; $output .= '<button id="entertain_next" class="button_90">'; $output .= 'Nästa'; $output .= '</button></a>' . "\n"; } } if ($item['extension'] == 'swf') { $output .= '<button id="entertain_fullscreen" onclick="javascript: open_fullscreen_window(\'' . $address . '\');">'; $output .= 'Spela i fullskärm'; $output .= '</button>' . "\n"; } $output .= '</div>' . "\n"; // end entertain_item_buttons $output .= '</div>' . "\n"; // end entertain_player // Description and game controls $output .= '<div class="entertain_description">' . "\n"; if (strlen($item['description']) > 0) { $output .= $item['description'] . "\n"; } if ($item['trailer_id'] > 0) { $output .= '<p>Filmtrailers visas i samarbete med Play Networks</p>' . "\n"; } $output .= '</div>' . "\n"; // end entertain_description if (!is_array($item['controls'])) { $item['controls'] = unserialize(utf8_decode($item['controls'])); $utf8_mupp = true; } if (is_array($item['controls']) && count($item['controls']) > 0) { $output .= '<h2>Kontroller</h2>' . "\n"; $output .= '<table class="entertain_controls">' . "\n"; $num_of_rows = ceil(count($item['controls']) / 2); for ($i = 0; $i < $num_of_rows; $i++) { $output .= '<tr>' . "\n"; if (!$utf8_mupp) { $output .= '<td class="combination">' . $item['controls'][$i]['combination'] . '</td>' . "\n"; $output .= '<td class="description">' . $item['controls'][$i]['description'] . '</td>' . "\n"; } else { $output .= '<td class="combination">' . utf8_encode($item['controls'][$i]['combination']) . '</td>' . "\n"; $output .= '<td class="description">' . utf8_encode($item['controls'][$i]['description']) . '</td>' . "\n"; } $output .= '</tr>' . "\n"; } $output .= '</table>' . "\n"; } if (is_privilegied('entertain_update')) { $output .= '<a class="entertain_edit" href="/' . $entertain_types[$item['entertain_type']]['url_handle'] . '/admin/' . $item['handle'] . '.html">[Redigera]</a>' . "\n"; } if (is_privilegied('entertain_add')) { $output .= 'Personen som laddat upp det här objektet är: <a href="/traffa/profile.php?id=' . $item['uploader'] . '">' . $item['uploader'] . '</a>'; } //todo! connect with javascript // Comments - Users can rank and leave a comment. These are handled by separate libraries but are connected // by javascript so that users submit rank and comment together. $output .= '<div class="entertain_comments">' . "\n"; $output .= '<input type="hidden" id="entertain_item_id" value="' . $item['id'] . '" />' . "\n"; $output .= '<h2 class="rank_input_header">Din poäng</h2>' . "\n"; $output .= '<h2 class="comment_input_header">Din kommentar</h2>' . "\n"; $output .= '<br style="clear: both;" />' . "\n"; if (login_checklogin()) { $query = 'SELECT rank FROM user_ranks WHERE user_id = "' . $_SESSION['login']['id'] . '" AND item_id = "' . $item['id'] . '" AND item_type = "entertain"'; $result = mysql_query($query); if (mysql_num_rows($result) == 1) { $data = mysql_fetch_assoc($result); } } unset($rank_options); $rank_options['previous'] = $data['rank']; $output .= rank_input_draw($item['id'], 'entertain', $rank_options); $output .= comments_input_draw($item['id'], 'entertain'); $output .= '<br style="clear: both;" />' . "\n"; $output .= '</div>' . "\n"; // end entertain_comments $options['comments'] = isset($options['comments']) ? $options['comments'] : 'yes'; if ($options['comments'] == 'yes') { $output .= comments_list($item['id'], 'entertain'); } $output .= '</div>' . "\n"; // end entertainment_item $output .= '</span>' . "\n"; // end $entertain_type return $output; }