Example #1
0
function _compo2_results_show($params, $uid)
{
    echo "<p><a href='?action=default'>Back to Results</a></p>";
    _compo2_preview_show($params, $uid);
    _compo2_show_comments($params["cid"], $uid);
}
Example #2
0
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>";
    }
}
Example #3
0
function _compo2_preview($params, $_link = "?action=preview")
{
    if (isset($_REQUEST["uid"])) {
        _compo2_preview_show($params, intval($_REQUEST["uid"]));
        _compo2_show_comments($params["cid"], intval($_REQUEST["uid"]));
        return;
    }
    $cats = array("" => "All Entries");
    foreach ($params["divs"] as $div) {
        $cats[$div] = "{$params["{$div}_title"]} Entries";
    }
    if (isset($params["uid"])) {
        $ce = compo2_entry_load($params["cid"], $params["uid"]);
        if (isset($ce["id"])) {
            echo "<p><a href='?action=edit'>Edit Entry</a> | <a href='?action=preview&uid={$ce["uid"]}'>View Entry</a></p>";
        }
    }
    $etype = $_REQUEST["etype"];
    @($q = $_REQUEST["q"]);
    $limit = 24;
    $start = 0;
    if (isset($_REQUEST["start"])) {
        $start = intval($_REQUEST["start"]);
    }
    $start = intval($start);
    $limit = intval($limit);
    if (($cres = compo2_cache_read($params["cid"], $ckey = "_compo2_preview:{$etype}:{$q}:{$start}", 5 * 60)) !== false) {
        echo $cres;
        return;
    }
    ob_start();
    if (!strlen($q)) {
        $cnte = array_pop(compo2_query("select count(*) _cnt from c2_entry where etype like ? and cid = ? " . (!($params["state"] == "admin") ? " and active=1" : ""), array("%{$etype}%", $params["cid"])));
    } else {
        $cnte = array_pop(compo2_query("select count(*) _cnt from c2_entry where (title like ? OR notes like ? OR links like ? OR get_user like ?) and  etype like ? and cid = ? " . (!($params["state"] == "admin") ? " and active=1" : ""), array("%{$q}%", "%{$q}%", "%{$q}%", "%{$q}%", "%{$etype}%", $params["cid"])));
    }
    $cnt = $cnte["_cnt"];
    $sh = date("Y-m-d") . "|";
    // shuffle the entries every day .. seems a good compromise between having a user's search order get messed up if they are going through a bunch of entries, and having the same entries on the 1st page all the time.
    if (!strlen($q)) {
        $r = compo2_query("select *, md5(concat(?,id)) sh from c2_entry where etype like ? and cid = ? " . (!($params["state"] == "admin") ? " and active=1" : "") . " order by sh limit {$start},{$limit}", array($sh, "%{$etype}%", $params["cid"]));
    } else {
        $r = compo2_query("select *, md5(concat(?,id)) sh from c2_entry where (title like ? OR notes like ? OR links like ? OR get_user like ?) and etype like ? and cid = ? " . (!($params["state"] == "admin") ? " and active=1" : "") . " order by sh limit {$start},{$limit}", array($sh, "%{$q}%", "%{$q}%", "%{$q}%", "%{$q}%", "%{$etype}%", $params["cid"]));
    }
    usort($r, "_compo2_preview_sort");
    echo "<h2>" . htmlentities($cats[$etype]) . " ({$cnt})</h2>";
    if (isset($params[$etype . "_desc"])) {
        echo "<div>";
        echo $params[$etype . "_desc"];
        echo "</div>";
    }
    ob_start();
    echo "<p>";
    $pre = "";
    if (count($params["divs"]) > 1) {
        foreach ($cats as $kk => $vv) {
            echo "{$pre}<a href='?action=preview&etype={$kk}'>{$vv}</a>";
            $pre = " | ";
        }
    }
    echo "</p>";
    $links = ob_get_contents();
    ob_end_clean();
    echo $links;
    echo "<form style='text-align:left;margin:0px;'>";
    echo "<input type='hidden' name='action' value='preview'>";
    echo "<input type='text' name='q' value='" . htmlentities($q) . "'>";
    echo " <input type='submit' value='Search'>";
    echo "</form>";
    if (!$cnt) {
        echo "<p>No entries found.</p>";
    } else {
        ob_start();
        echo "<p>";
        if ($start > 0) {
            $i = max(0, $start - $limit);
            echo "<a href='?action=preview&q=" . urlencode($q) . "&etype=" . urlencode($etype) . "&start={$i}'>Previous</a> ";
        }
        echo " [ ";
        $n = 1;
        for ($i = 0; $i < $cnt; $i += $limit) {
            if ($i == $start) {
                echo "<b>{$n}</b> ";
            } else {
                echo "<a href='?action=preview&q=" . urlencode($q) . "&etype=" . urlencode($etype) . "&start={$i}'>{$n}</a> ";
            }
            $n += 1;
        }
        echo " ] ";
        if ($start < $cnt - $limit) {
            $i = $start + $limit;
            echo "<a href='?action=preview&q=" . urlencode($q) . "&etype=" . urlencode($etype) . "&start={$i}'>Next</a> ";
        }
        echo "</p>";
        $paging = ob_get_contents();
        ob_end_clean();
        echo $paging;
        $cols = 6;
        $n = 0;
        $row = 0;
        echo "<table class='preview'>";
        foreach ($r as $e) {
            if ($n % $cols == 0) {
                echo "<tr>";
                $row += 1;
            }
            $n += 1;
            $klass = "class='alt-" . (1 + $row % 2) . "'";
            echo "<td valign=bottom align=center {$klass}>";
            $link = "{$_link}&uid={$e["uid"]}";
            echo "<div><a href='{$link}'>";
            $shots = unserialize($e["shots"]);
            echo "<img src='" . compo2_thumb($shots["shot0"], 120, 90) . "'>";
            echo "<div class='title'><i>" . htmlentities($e["title"]) . "</i></div>";
            $ue = unserialize($e["get_user"]);
            echo $ue["display_name"];
            echo "</a></div>";
            if ($e["disabled"]) {
                echo "<div><i>disabled</i></div>";
            } else {
                if (!$e["active"]) {
                    echo "<div><i>inactive</i></div>";
                }
            }
        }
        echo "</table>";
        echo $paging;
    }
    echo $links;
    $cres = ob_get_contents();
    ob_end_clean();
    compo2_cache_write($params["cid"], $ckey, $cres);
    echo $cres;
}