function _compo2_rate_rate($params, $uid = "") { if (!$uid) { $uid = intval($_REQUEST["uid"]); } $ce = compo2_entry_load($params["cid"], $uid); echo "<p>"; echo "<a href='?action=default'>Back to Rate Entries</a>"; if (current_user_can('edit_others_posts')) { echo " | <strong><a href='?action=edit&uid=" . $ce["uid"] . "&admin=1'>ADMIN EDIT</a></strong>"; } if (get_current_user_id() === $uid) { echo " | <strong><a href='?action=edit'>Edit Entry</a></strong>"; } echo "</p>"; if ($params["uid"] == $uid) { _compo2_preview_show($params, $uid, true); return; } $ce = compo2_entry_load($params["cid"], $uid); if (!$ce["is_judged"]) { _compo2_preview_show($params, $uid, true); return; } $div = $ce["etype"]; $settings = unserialize($ce["settings"]); _compo2_preview_show($params, $uid, false); if (!$ce["id"]) { return; } $ve = array_pop(compo2_query("select * from c2_rate where cid = ? and to_uid = ? and from_uid = ?", array($params["cid"], $ce["uid"], $params["uid"]))); $canvote = false; if ($params["uid"] != $uid) { if (!isset($params["{$div}_judged"]) || $params["{$div}_judged"] !== "0") { echo "<h3>Rate this {$params['{$div}_title']} Entry</h3>"; echo "<p><i>If you can't run this Entry, please leave a comment saying so and explaining why. Do not score unrunnable entries.</i></p>"; $myurl = get_bloginfo("url") . "/wp-content/plugins/compo2"; echo "<script type='text/javascript' src='{$myurl}/starry/prototype.lite.js'></script>"; echo "<script type='text/javascript' src='{$myurl}/starry/stars.js'></script>"; echo "<link rel='stylesheet' href='{$myurl}/starry/stars.css' type='text/css' />"; echo "<form method=post action='?action=submit&uid={$uid}'>"; echo "<p>"; if (isset($params["{$div}_cats"])) { echo "<table>"; $data = unserialize($ve["data"]); foreach ($params["{$div}_cats"] as $k) { if (!isset($settings['OPTOUT'][$div][$k])) { echo "<tr><th>" . htmlentities($k); echo "<td>"; $v = intval($data[$k]); echo "<script>new Starry('data[{$k}]',{name:'data[{$k}]',sprite:'{$myurl}/starry/newstars.gif',width:20,height:20,startAt:{$v}});</script>"; // compo2_select("data[$k]",array(""=>"n/a","5"=>"5 - Best","4"=>"4","3"=>"3","2"=>"2","1"=>"1 - Worst"),$v); } $canvote = true; } echo "</table>"; } else { echo "<i>This division does not have any voting categories. Please leave comments for the author.</i>"; } echo "</p>"; echo "<a name='vote'></a><h2>Comments (non-anonymous)</h2>"; $ve["comments"] = ""; echo "<textarea name='comments' rows=4 cols=60>" . htmlentities($ve["comments"]) . "</textarea>"; echo "<p><input type='submit' value='Submit'></p>"; echo "</form>"; echo "<br/>"; } } _compo2_preview_comments($params, $uid, $form = !$canvote); //true); _compo2_show_comments($params["cid"], $ce["uid"]); // NOTE: Legacy comment system if ($canvote) { echo "<h2>NOTE: Use the comment box <a href='#vote'>OVER HERE</a>. Thanks!</h2>"; // echo "<h2>Comments (non-anonymous)</h2>"; // $ve["comments"]=""; // echo "<textarea name='comments2' rows=4 cols=60>".htmlentities($ve["comments"])."</textarea>"; // echo "<p><input type='submit' value='Submit'></p>"; } }
function _compo2_preview_show($params, $uid, $comments = true) { $ce = compo2_entry_load($params["cid"], $uid); echo "<p>"; echo "<a href='?action=preview'>Back to Browse Entries</a>"; if (isset($params["uid"]) && $params["uid"]) { if (current_user_can('edit_others_posts')) { // $ce = compo2_entry_load($params["cid"],intval($_REQUEST["uid"])); echo " | <strong><a href='?action=edit&uid=" . $ce["uid"] . "&admin=1'>ADMIN EDIT</a></strong>"; } if (intval($params["uid"]) === intval($uid)) { // If the entry exists // if ($ce["id"]) { echo " | <a href='?action=edit'>Edit Entry</a>"; } } } echo "</p>"; if (!$ce["id"]) { echo "<p>Sorry, this person does not have an Entry.</p>"; return; } $shots = unserialize($ce["shots"]); $settings = unserialize($ce["settings"]); $is_nsfw = $settings["NSFL"]; $baseurl = get_bloginfo("url") . "/wp-content"; $has_embed = isset($settings["EMBED"]["url"]) && $settings["EMBED"]["url"] !== ""; if ($has_embed) { $url = $settings["EMBED"]["url"]; $width = $settings["EMBED"]["width"]; $height = $settings["EMBED"]["height"]; $imagefile = array_values($shots)[0]; $shot_url = c2_thumb($imagefile, 900, 500, false, true); $play_code = "<div id='embed' onclick='c2_play_game();' style='width:{$width}px;height:{$height}px'><img class='embed-icon' src='{$shot_url}'><div class='embed-overlay'></div><img class='embed-icon' src='/compo/wp-content/plugins/compo2/art/play.png' /></div>"; ?> <script> function c2_toggle_fullscreen() { var elem = document.getElementById('embed'); if (elem.requestFullscreen) { elem.requestFullscreen(); } else if (elem.msRequestFullscreen) { elem.msRequestFullscreen(); } else if (elem.mozRequestFullScreen) { elem.mozRequestFullScreen(); } else if (elem.webkitRequestFullscreen) { elem.webkitRequestFullscreen(); } } function c2_play_game() { var elm = document.getElementById('embed-frame'); elm.innerHTML = "<?php echo "<iframe id='embed' src='{$url}' width='{$width}' height='{$height}' frameborder='0' allowfullscreen></iframe>"; ?> "; } function c2_exit_game() { var elm = document.getElementById('embed-frame'); elm.innerHTML = "<?php echo $play_code; ?> "; //"<div id='embed' onclick='c2_play_game();'><?php echo "<img id='embed' src='{$shot_url}'>"; ?> </div>"; } </script> <style> #embed { margin:10px auto; display:block; position:relative; text-align:center; } :-webkit-full-screen #embed { width: 100%; height: 100%; } #embed:-ms-fullscreen { position:absolute; left:0px; top:0px; width: 100%; height: 100%; } .embed-overlay { position:absolute; background:url('/compo/wp-content/plugins/compo2/art/TiledBars.png'); left:0; top:0; width:100%; height:100%; } .embed-icon { position:absolute; left:50%; top:50%; -ms-transform: translate(-50%,-50); -webkit-transform: translate(-50%,-50%); transform: translate(-50%,-50%); } .embed-controls { text-align:center; } .embed-controls img { cursor:pointer; opacity:0.3; } .embed-controls img:hover { opacity:1.0; } </style> <?php echo "<div id='embed-view'>"; echo "<div id='embed-frame'>"; echo $play_code; echo "</div>"; echo "<div class='embed-controls'>"; if ($settings["EMBED"]["fullscreen"]) { echo "<img src='{$baseurl}/plugins/compo2/art/Maximize.png' onclick='c2_toggle_fullscreen();'>"; } echo "<img src='{$baseurl}/plugins/compo2/art/Power.png' onclick='if (confirm(\"Are you sure you want to Shutdown the game? All progress will be lost!\")) { c2_exit_game(); }'>"; echo "</div>"; echo "</div>"; } echo "\n\t\t<style>\n\t\t\t#shotview {\n\t\t\t\ttext-align:center;\n\t\t\t\tmargin-bottom:10px;\n\t\t\t}\n\t\t\t#shotview img {\n\t\t\t\tmax-width:900px;\n\t\t\t}\n\t\t</style>\n\t"; // Screenshot Viewer // echo "<div id='shotview' class='" . ($has_embed ? "hidden" : "") . "'>"; $imagefile = array_values($shots)[0]; $link = $baseurl . '/compo2/' . $imagefile; $preview = c2_thumb($imagefile, 900, 500, false, true); echo "<a id='shotview_link' href='{$link}' target='_blank'><img id='shotview_img' src='{$preview}'></a>"; echo "</div>"; // Game Name and Developer // echo "<div style='overflow:auto;'>"; echo "<div style='float:right;'>"; $user = unserialize($ce["get_user"]); echo get_avatar($user['user_email'], '56'); echo "</div>"; echo "<h2 style='font-size:28px'>" . htmlentities($ce["title"]) . "</h2>"; echo "by <a href=\"../author/{$user['user_nicename']}/\" target='_blank'><strong>{$user['display_name']}</strong></a>"; $div = $ce["etype"]; echo " - <i>{$params["{$div}_title"]} Entry</i>"; echo "</div>"; ?> <style> .shot-nav { text-align:center; width:940px; left:-20px; position:relative; margin-top:10px; } .shot-nav .sn-item { display:inline-block; opacity:0.4; padding:3px; position:relative; } .shot-nav .sn-item:hover { opacity:1.0; } .shot-nav .sn-item .sn-img { border-radius:7px; cursor:pointer; } .shot-nav .sn-item .sn-overlay { border-radius:7px; position:absolute; background:url('/compo/wp-content/plugins/compo2/art/TiledBars.png'); left:0; top:0; width:100%; height:100%; } .shot-nav .sn-item .sn-icon { position:absolute; left:50%; top:50%; -ms-transform: translate(-50%,-50); -webkit-transform: translate(-50%,-50%); transform: translate(-50%,-50%); } .shot-nav .sn-selected { opacity:0.8; border:3px solid #000; background:#000; border-radius:10px; padding:0; } .links { margin:0; } .links ul { list-style:none; margin:0; } .links ul li:before { content:''; } #compo-nsfw { cursor:pointer; background:#900; border-radius:10px; padding:20px; color:#FF0; text-align:center; } #compo-nsfw h2 { text-align:center; font-size:40px; color:#F80; } </style> <script> function c2_addclass( el, className ) { if ( el ) { if (el.classList) el.classList.add(className); else el.className += ' ' + className; } } function c2_removeclass( el, className ) { if ( el ) { if (el.classList) el.classList.remove(className); else el.className = el.className.replace(new RegExp('(^|\\b)' + className.split(' ').join('|') + '(\\b|$)', 'gi'), ' '); } } // Global Variable // window.c2_ShotIndex = 0; function c2_show_embed() { c2_removeclass( document.getElementById('embed-view'), 'hidden'); } function c2_hide_embed() { c2_addclass( document.getElementById('embed-view'), 'hidden'); } function c2_show_image( _img, _link ) { c2_removeclass( document.getElementById('shotview'), 'hidden'); document.getElementById('shotview_img').setAttribute('src', _img); document.getElementById('shotview_link').setAttribute('href', _link); } function c2_hide_image() { c2_addclass( document.getElementById('shotview'), 'hidden'); } function c2_highlight_nav( id ) { c2_removeclass( document.getElementById('shot-nav-'+window.c2_ShotIndex), 'sn-selected'); c2_addclass( document.getElementById('shot-nav-'+id), 'sn-selected'); window.c2_ShotIndex = id; } function c2_select_embed( id ) { c2_hide_image(); c2_highlight_nav(id); c2_show_embed(); } function c2_select_image( id, _img, _link ) { c2_hide_embed(); c2_highlight_nav(id); c2_show_image( _img, _link ); } </script> <?php //echo "NSFW Test:".(($is_nsfw=='1')?"YES":"nope"); //<script>window.compo_game_nsfw = true;</script> if ($is_nsfw == '1') { echo "<script>window.compo_game_nsfw = true;</script>"; } // Screenshots // echo "<div class='shot-nav'><span>"; $idx = 0; if ($has_embed) { $imagefile = array_values($shots)[0]; $link = $baseurl . '/compo2"/' . $imagefile; $thumb = c2_thumb($imagefile, 180, 140); $selected = $idx === 0 ? "sn-selected" : ""; // echo "<div class='sn-item {$selected}' id='shot-nav-{$idx}'><a href='' target='_blank'><img src='{$thumb}' width='180' height='140'></a></div>"; echo "<div class='sn-item {$selected}' id='shot-nav-{$idx}' onclick='c2_select_embed({$idx});'>\n\t\t\t<img class='sn-img' src='{$thumb}' width='180' height='140'>\n\t\t\t<div class='sn-overlay'></div>\n\t\t\t<img class='sn-icon' id='embed-mode' src='/compo/wp-content/plugins/compo2/art/play-sm.png' />\n\t\t</div>"; $idx++; } foreach ($shots as $imagefile) { if ($idx === 5) { break; } $link = $baseurl . '/compo2/' . $imagefile; $thumb = c2_thumb($imagefile, 180, 140); $preview = c2_thumb($imagefile, 900, 500, false, true); $selected = $idx === 0 ? "sn-selected" : ""; // echo "<div class='sn-item {$selected}' id='shot-nav-{$idx}'><a href='{$link}' target='_blank'><img src='{$thumb}' width='180' height='140'></a></div>"; echo "<div class='sn-item {$selected}' id='shot-nav-{$idx}'><img class='sn-img' src='{$thumb}' width='180' height='140' onclick='c2_select_image({$idx},\"{$preview}\",\"{$link}\");'></div>"; $idx++; } echo "</span></div>"; // Description // echo "<p>" . str_replace("\n", "<br/>", htmlentities($ce["notes"])) . "</p>"; // Links and Downloads // echo "<h2>Downloads and Links</h2>"; echo "<div class='links'>"; _compo2_preview_show_links($ce); echo "</div>"; echo "<br />"; echo '<meta name="twitter:card" content="summary" />'; echo '<meta name="twitter:site" content="@ludumdare" />'; $twitter = get_the_author_meta('twitter', (string) $uid); //get_the_author_meta('twitter', $user["ID"]); if ($twitter != null && $twitter != '') { echo '<meta name="twitter:creator" content="@' . $twitter . '" />'; } echo '<meta name="twitter:title" content="' . substr(htmlentities($ce["title"]), 0, 70) . '" />'; echo '<meta name="twitter:description" content="' . substr(htmlentities($ce["notes"]), 0, 200) . '" />'; if ($firstshot != null && $firstshot != '') { echo '<meta name="twitter:image" content="' . get_bloginfo("url") . '/wp-content/compo2/' . htmlentities($firstshot) . '" />'; } echo '<script>'; echo 'var Elm = document.getElementsByTagName("title")[0];'; echo 'Elm.innerHTML = "' . htmlentities($ce["title"]) . ' by ' . $user["display_name"] . ' | " + Elm.innerHTML;'; echo '</script>'; // Rating Results // if ($params["state"] == "results" || $params["state"] == "admin") { if (!isset($params["{$div}_judged"]) || $params["{$div}_judged"] !== "0") { _compo2_results_ratings($params, $uid); } } // Comments ?? // if ($comments) { _compo2_preview_comments($params, $uid, true); } }