Esempio n. 1
0
function getBuddies($fromUser, $dbi, $thePage = "")
{
    $START_DELIM = $thePage . _("Buddies:");
    $DELIM = ",";
    $buddies_array = getPageTextData($fromUser, $dbi, $START_DELIM, $DELIM);
    if (count($buddies_array) == 0 and $thePage !== "") {
        $buddies_array = getPageTextData($fromUser, $dbi, _("Buddies:"), $DELIM);
    }
    if (empty($buddies_array)) {
        // 1. calculate buddies automatically from the 10 top raters with the most numratings (min. 5 ratings).
        //    of all pages (only SQL)
        // or 2. from 10 random raters of this page (non-SQL)
        // or 3. from all members of your group (department) if <= 20
        $rdbi = RatingsDb::getTheRatingsDb();
        $dimension = '';
        if (RATING_STORAGE == 'SQL') {
            //$result = $this->_sql_get_rating_result($dimension, null, null, 'numrating', "rater");
            $dbh =& $rdbi->_sqlbackend;
            extract($dbh->_table_names);
            $query = "SELECT raterpage, COUNT(rateepage) as numrating" . " FROM {$rating_tbl} r, {$page_tbl} p " . " WHERE ratingvalue > 0" . " GROUP BY raterpage" . " ORDER BY numrating" . " LIMIT 10";
            $result = $dbh->_dbh->query($query);
        } else {
            // from 10 random raters of this page (non-SQL)
        }
    }
    $result = array();
    if (is_array($buddies_array)) {
        foreach ($buddies_array as $userid) {
            $result[] = new RatingsUser($userid);
        }
    }
    return $result;
}
Esempio n. 2
0
 function &_get_rating_dbi()
 {
     // This is a hack, because otherwise this object doesn't know about a
     // DBI at all.  Perhaps all this ratings stuff should live somewhere
     // else that's less of a base class.
     if (isset($this->_rdbi)) {
         return $this->_rdbi;
     }
     $this->_rdbi = RatingsDb::getTheRatingsDb();
     return $this->_rdbi;
 }
Esempio n. 3
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     extract($this->getArgs($argstr, $request));
     // XXX: fix to reflect multi-user ratings?
     $caption = _("Displaying %d ratings:");
     $active_user = $request->getUser();
     $active_userid = $active_user->_userid;
     // check for request to display a category's ratings
     if (isset($category) && is_string($category) && strlen($category)) {
         $pageids = array();
         $category_page = $dbi->getPage($category);
         $iter = $category_page->getLinks();
         while ($item = $iter->next()) {
             array_push($pageids, $item->getName());
         }
         // XXX: is there a way to retrieve the preferred plural
         // representation of a category name?
         // XXX: should the category text be a link?  can it be one easily?
         $caption = sprintf(_("Showing all %ss (%%d):"), $category);
     } elseif (!isset($pageids) || !is_array($pageids)) {
         // XXX: need support for sorted ratings
         // bug: pages excluded from the PageList via the "exclude" argument
         // count toward the limit!
         $pageids = array();
         $active_user_ratings_user =& RatingsUserFactory::getUser($active_user->getId());
         $current_user_ratings = $active_user_ratings_user->get_ratings();
         if ($userPage) {
             //we're on a user's homepage, get *their* ratings
             $this_page_user =& RatingsUserFactory::getUser($userPage);
             $caption = _("Here are {$userPage}" . "'s %d page ratings:");
             $ratings = $this_page_user->get_ratings();
         } else {
             $caption = _("Here are your %d page ratings:");
             $ratings = $current_user_ratings;
         }
         $i = 0;
         foreach ($ratings as $pagename => $page_ratings) {
             // limit is currently only honored for "own" ratings
             if ($limit > 0 && $i >= $limit) {
                 break;
             }
             if (isset($page_ratings[$dimension])) {
                 array_push($pageids, $pagename);
                 $i++;
             }
         }
         // $caption = _("Here are your %d page ratings:");
         //make $ratings the user's ratings again if it had been treated as the current page
         // name's ratings
         $ratings = $current_user_ratings;
     }
     // if userids is null or empty, fill it with just the active user
     if (!isset($userids) || !is_array($userids) || !count($userids)) {
         // TKL: moved getBuddies call inside if statement because it was
         // causing the userids[] parameter to be ignored
         if (is_string($active_userid) && strlen($active_userid) && $active_user->isSignedIn() && !$userPage) {
             if (isset($category_page)) {
                 $userids = getBuddies($active_userid, $dbi, $category_page->getName());
             } else {
                 $userids = getBuddies($active_userid, $dbi);
             }
         } elseif ($userPage) {
             //we're on a user page, show that user's ratings as the only column
             $userids = array();
             array_push($userids, $userPage);
         } else {
             $userids = array();
             // XXX: this wipes out the category caption...
             // $caption = _("You must be logged in to view ratings.");
         }
     }
     // find out which users we should show ratings for
     // users allowed in the prediction calculation
     $allowed_users = array();
     // users actually allowed to be shown to the user
     $allowed_users_toshow = array();
     foreach ($userids as $userid) {
         $user =& RatingsUserFactory::getUser($userid);
         if ($user->allow_view_ratings($active_user)) {
             array_push($allowed_users_toshow, $user);
         }
         // all users should be allowed in calculation
         array_push($allowed_users, $user);
         // This line ensures $user is not a reference type after this loop
         // If it is a reference type, that can produce very unexpected behavior!
         unset($user);
     }
     // if no buddies, use allusers in prediction calculation
     if (count($userids) == 0 || $userPage) {
         $allowed_users = array();
         //$people_iter = $dbi->get_users_rated();
         $people_dbi = RatingsDb::getTheRatingsDb();
         $people_iter = $people_dbi->sql_get_users_rated();
         while ($people_array = $people_iter->next()) {
             $userid = $people_array['pagename'];
             $user =& RatingsUserFactory::getUser($userid);
             array_push($allowed_users, $user);
         }
     }
     $columns = $info ? explode(",", $info) : array();
     // build our table...
     $pagelist = new PageList($columns, $exclude, array('dimension' => $dimension, 'users' => $allowed_users_toshow));
     // augment columns
     //$preds = new _PageList_Column_prediction('prediction', _("Pred"), 'right', $dimension, $allowed_users);
     $preds = array('_PageList_column_prediction', 'custom:prediction', _("Pred"), 'right', ' ', $allowed_users);
     $pagelist->addColumnObject($preds);
     //$widget = new _PageList_Column_ratingwidget('ratingwidget', _("Rate"), 'left', $dimension);
     $widget = array('_PageList_column_ratingwidget', 'custom:ratingwidget', _("Rate"), 'center');
     $pagelist->addColumnObject($widget);
     $noRatingUsers = array();
     if (!$nobuds) {
         foreach ($allowed_users_toshow as $idx => $user) {
             // For proper caching behavior, get a ref, don't user $user
             $u =& $allowed_users_toshow[$idx];
             //$col = new _PageList_Column_ratingvalue('ratingvalue', $u->getId(), 'right', $dimension, $u);
             $col = array('_PageList_Column_ratingvalue', 'custom:ratingvalue', $u->getId(), 'right', ' ', $u);
             $pagelist->addColumnObject($col);
             unset($u);
         }
     }
     // add rows -- each row represents an item (page)
     foreach ($pageids as $pagename) {
         // addPage can deal with cases where it is passed a string
         $pagelist->addPage($pagename);
     }
     if (!$noheader) {
         $pagelist->setCaption(_($caption));
     }
     return $pagelist;
 }
Esempio n. 4
0
 /**
  * HTML widget display
  *
  * This needs to be put in the <body> section of the page.
  *
  * @param pagename    Name of the page to rate
  * @param version     Version of the page to rate (may be "" for current)
  * @param imgPrefix   Prefix of the names of the images that display the rating
  *                    You can have two widgets for the same page displayed at
  *                    once iff the imgPrefix-s are different.
  * @param dimension   Id of the dimension to rate
  * @param small       Makes a smaller ratings widget if non-false
  *
  * Limitations: Currently this can only print the current users ratings.
  *              And only the widget, but no value (for buddies) also.
  */
 function RatingWidgetHtml($pagename, $version, $imgPrefix, $dimension, $small = false)
 {
     global $WikiTheme, $request;
     $imgId = MangleXmlIdentifier($pagename) . $imgPrefix;
     $actionImgName = $imgId . 'RateItAction';
     $dbi =& $GLOBALS['request']->_dbi;
     $version = $dbi->_backend->get_latest_version($pagename);
     //$rdbi =& $this->_rdbi;
     $rdbi = RatingsDb::getTheRatingsDb();
     // check if the imgPrefix icons exist.
     if (!$WikiTheme->_findData("images/RateIt" . $imgPrefix . "Nk0.png", true)) {
         $imgPrefix = '';
     }
     // Protect against 's, though not \r or \n
     $reImgPrefix = $this->_javascript_quote_string($imgPrefix);
     $reActionImgName = $this->_javascript_quote_string($actionImgName);
     $rePagename = $this->_javascript_quote_string($pagename);
     //$dimension = $args['pagename'] . "rat";
     $html = HTML::span(array("id" => $imgId));
     for ($i = 0; $i < 2; $i++) {
         $nk[$i] = $WikiTheme->_findData("images/RateIt" . $imgPrefix . "Nk" . $i . ".png");
         $none[$i] = $WikiTheme->_findData("images/RateIt" . $imgPrefix . "Rk" . $i . ".png");
     }
     $user = $request->getUser();
     $userid = $user->getId();
     //if (!isset($args['rating']))
     $rating = $rdbi->getRating($userid, $pagename, $dimension);
     if (!$rating) {
         $pred = $rdbi->getPrediction($userid, $pagename, $dimension);
     }
     for ($i = 1; $i <= 10; $i++) {
         $a1 = HTML::a(array('href' => 'javascript:click(\'' . $reActionImgName . '\',\'' . $rePagename . '\',\'' . $version . '\',\'' . $reImgPrefix . '\',\'' . $dimension . '\',' . $i / 2 . ')'));
         $img_attr = array();
         $img_attr['src'] = $nk[$i % 2];
         //if (!$rating and !$pred)
         //  $img_attr['src'] = $none[$i%2];
         $img_attr['name'] = $imgPrefix . $i;
         $img_attr['alt'] = $img_attr['name'];
         $img_attr['border'] = 0;
         $a1->pushContent(HTML::img($img_attr));
         $a1->addToolTip(_("Rate the topic of this page"));
         $html->pushContent($a1);
         //This adds a space between the rating smilies:
         // if (($i%2) == 0) $html->pushContent(' ');
     }
     $html->pushContent(HTML::Raw('&nbsp;'));
     $a0 = HTML::a(array('href' => 'javascript:click(\'' . $reActionImgName . '\',\'' . $rePagename . '\',\'' . $version . '\',\'' . $reImgPrefix . '\',\'' . $dimension . '\',\'X\')'));
     $msg = _("Cancel rating");
     $a0->pushContent(HTML::img(array('src' => $WikiTheme->getImageUrl("RateIt" . $imgPrefix . "Cancel"), 'name' => $imgPrefix . 'Cancel', 'alt' => $msg)));
     $a0->addToolTip($msg);
     $html->pushContent($a0);
     /*} elseif ($pred) {
           $msg = _("No opinion");
           $html->pushContent(HTML::img(array('src' => $WikiTheme->getImageUrl("RateItCancelN"),
                                              'name'=> $imgPrefix.'Cancel',
                                              'alt' => $msg)));
           //$a0->addToolTip($msg);
           //$html->pushContent($a0);
       }*/
     $img_attr = array();
     $img_attr['src'] = $WikiTheme->_findData("images/RateItAction.png");
     $img_attr['name'] = $actionImgName;
     $img_attr['alt'] = $img_attr['name'];
     //$img_attr['class'] = 'k' . $i;
     $img_attr['border'] = 0;
     $html->pushContent(HTML::img($img_attr));
     // Display the current rating if there is one
     if ($rating) {
         $html->pushContent(JavaScript('displayRating(\'' . $reImgPrefix . '\',' . $rating . ',0)'));
     } elseif ($pred) {
         $html->pushContent(JavaScript('displayRating(\'' . $reImgPrefix . '\',' . $pred . ',1)'));
     } else {
         $html->pushContent(JavaScript('displayRating(\'' . $reImgPrefix . '\',0,0)'));
     }
     return $html;
 }
Esempio n. 5
0
 /**
  * HTML widget display
  *
  * This needs to be put in the <body> section of the page.
  *
  * @param pagename    Name of the page to rate
  * @param version     Version of the page to rate (may be "" for current)
  * @param imgPrefix   Prefix of the names of the images that display the rating
  *                    You can have two widgets for the same page displayed at
  *                    once iff the imgPrefix-s are different.
  * @param dimension   Id of the dimension to rate
  * @param small       Makes a smaller ratings widget if non-false
  *
  * Limitations: Currently this can only print the current users ratings.
  *              And only the widget, but no value (for buddies) also.
  */
 function RatingWidgetHtml($pagename, $version, $imgPrefix, $dimension, $small = false)
 {
     global $WikiTheme, $request;
     $dbi =& $request->_dbi;
     $version = $dbi->_backend->get_latest_version($pagename);
     $pageid = sprintf("%u", crc32($pagename));
     // MangleXmlIdentifier($pagename)
     $imgId = 'RateIt' . $pageid;
     $actionImgName = 'RateIt' . $pageid . 'Action';
     //$rdbi =& $this->_rdbi;
     $rdbi = RatingsDb::getTheRatingsDb();
     // check if the imgPrefix icons exist.
     if (!$WikiTheme->_findData("images/RateIt" . $imgPrefix . "Nk0.png", true)) {
         $imgPrefix = '';
     }
     // Protect against \'s, though not \r or \n
     $reImgPrefix = $this->_javascript_quote_string($imgPrefix);
     $reImgId = $this->_javascript_quote_string($imgId);
     $reActionImgName = $this->_javascript_quote_string($actionImgName);
     $rePagename = $this->_javascript_quote_string($pagename);
     //$dimension = $args['pagename'] . "rat";
     $html = HTML::span(array("class" => "rateit-widget", "id" => $imgId));
     for ($i = 0; $i < 2; $i++) {
         $ok[$i] = $WikiTheme->_findData("images/RateIt" . $imgPrefix . "Ok" . $i . ".png");
         // empty
         $nk[$i] = $WikiTheme->_findData("images/RateIt" . $imgPrefix . "Nk" . $i . ".png");
         // rated
         $rk[$i] = $WikiTheme->_findData("images/RateIt" . $imgPrefix . "Rk" . $i . ".png");
         // pred
     }
     if (empty($this->userid)) {
         $user = $request->getUser();
         $this->userid = $user->getId();
     }
     if (empty($this->rating)) {
         $this->rating = $rdbi->getRating($this->userid, $pagename, $dimension);
         if (!$this->rating and empty($this->pred)) {
             $this->pred = $rdbi->getPrediction($this->userid, $pagename, $dimension);
         }
     }
     for ($i = 1; $i <= 10; $i++) {
         $j = $i / 2;
         $a1 = HTML::a(array('href' => "javascript:clickRating('{$reImgPrefix}','{$rePagename}','{$version}'," . "'{$reImgId}','{$dimension}',{$j})"));
         $img_attr = array();
         $img_attr['src'] = $nk[$i % 2];
         if ($this->rating) {
             $img_attr['src'] = $ok[$i % 2];
             $img_attr['onmouseover'] = "displayRating('{$reImgId}','{$reImgPrefix}',{$j},0,1)";
             $img_attr['onmouseout'] = "displayRating('{$reImgId}','{$reImgPrefix}',{$this->rating},0,1)";
         } else {
             if (!$this->rating and $this->pred) {
                 $img_attr['src'] = $rk[$i % 2];
                 $img_attr['onmouseover'] = "displayRating('{$reImgId}','{$reImgPrefix}',{$j},1,1)";
                 $img_attr['onmouseout'] = "displayRating('{$reImgId}','{$reImgPrefix}',{$this->pred},1,1)";
             } else {
                 $img_attr['onmouseover'] = "displayRating('{$reImgId}','{$reImgPrefix}',{$j},0,1)";
                 $img_attr['onmouseout'] = "displayRating('{$reImgId}','{$reImgPrefix}',0,0,1)";
             }
         }
         //$imgName = 'RateIt'.$reImgId.$i;
         $img_attr['id'] = $imgId . $i;
         $img_attr['alt'] = $img_attr['id'];
         $a1->pushContent(HTML::img($img_attr));
         //$a1->addToolTip(_("Rate the topic of this page"));
         $html->pushContent($a1);
         //This adds a space between the rating smilies:
         //if (($i%2) == 0) $html->pushContent("\n");
     }
     $html->pushContent(HTML::Raw("&nbsp;"));
     $a0 = HTML::a(array('href' => "javascript:clickRating('{$reImgPrefix}','{$rePagename}','{$version}'," . "'{$reImgId}','{$dimension}','X')"));
     $msg = _("Cancel your rating");
     $imgprops = array('src' => $WikiTheme->getImageUrl("RateIt" . $imgPrefix . "Cancel"), 'id' => $imgId . $imgPrefix . 'Cancel', 'alt' => $msg, 'title' => $msg);
     if (!$this->rating) {
         $imgprops['style'] = 'display:none';
     }
     $a0->pushContent(HTML::img($imgprops));
     $a0->addToolTip($msg);
     $html->pushContent($a0);
     /*} elseif ($pred) {
           $msg = _("No opinion");
           $html->pushContent(HTML::img(array('src' => $WikiTheme->getImageUrl("RateItCancelN"),
                                              'id'  => $imgPrefix.'Cancel',
                                              'alt' => $msg)));
           //$a0->addToolTip($msg);
           //$html->pushContent($a0);
       }*/
     $img_attr = array();
     $img_attr['src'] = $WikiTheme->_findData("images/spacer.png");
     $img_attr['id'] = $actionImgName;
     $img_attr['alt'] = $img_attr['id'];
     $img_attr['height'] = 15;
     $img_attr['width'] = 20;
     $html->pushContent(HTML::img($img_attr));
     // Display your current rating if there is one, or the current prediction
     // or the empty widget.
     $pred = empty($this->pred) ? 0 : $this->pred;
     $js = '';
     if (!empty($this->avg)) {
         $js .= "avg['{$reImgId}']={$this->avg}; numusers['{$reImgId}']={$this->numusers};\n";
     }
     if ($this->rating) {
         $js .= "rating['{$reImgId}']={$this->rating}; prediction['{$reImgId}']={$pred};\n";
         $html->pushContent(JavaScript($js . "displayRating('{$reImgId}','{$reImgPrefix}',{$this->rating},0,1);"));
     } elseif (!empty($this->pred)) {
         $js .= "rating['{$reImgId}']=0; prediction['{$reImgId}']={$this->pred};\n";
         $html->pushContent(JavaScript($js . "displayRating('{$reImgId}','{$reImgPrefix}',{$this->pred},1,1);"));
     } else {
         $js .= "rating['{$reImgId}']=0; prediction['{$reImgId}']=0;\n";
         $html->pushContent(JavaScript($js . "displayRating('{$reImgId}','{$reImgPrefix}',0,0,1);"));
     }
     return $html;
 }
Esempio n. 6
0
 function run($dbi, $argstr, &$request, $basepage)
 {
     extract($this->getArgs($argstr, $request));
     if ($pageTextLabel == null && $category != null && $group == null) {
         $group = $category;
     }
     if ($category == null || $pageTextLabel == null) {
         return HTML::div(array('class' => "error"), "PreferencesApp Error: You must declare at least parameters category and pageTextLabel.");
     }
     $dbi = $request->getDbh();
     $rdbi = RatingsDb::getTheRatingsDb();
     $CATEGORY = $category;
     $PAGE_TEXT_LABEL = $pageTextLabel;
     $NEUTRAL_RATING = (int) $neutralRating;
     $active_user = $request->getUser();
     $active_userid = $active_user->_userid;
     $html = HTML();
     $html->pushContent("");
     //Load participating Users
     $users_array = array();
     if ($group != null) {
         $users_array = getMembers($group, $rdbi);
     } else {
         $people_iter = $rdbi->sql_get_users_rated();
         while ($people_array = $people_iter->next()) {
             $users_array[] = $people_array['pagename'];
         }
     }
     $people = array();
     foreach ($users_array as $person_indv) {
         if ($declareBudget == "true") {
             $get_array = getPageTextData($person_indv, $dbi, $PAGE_TEXT_LABEL, "cans");
             if (count($get_array) == 1) {
                 $cans_text = $get_array[0];
                 if (is_numeric($cans_text) && $cans_text >= 0) {
                     $canBudget[$person_indv] = $cans_text;
                     //Load the persons budget
                 } else {
                     $canBudget[$person_indv] = 0;
                 }
                 $people[] = $person_indv;
             }
         } else {
             $canBudget[$person_indv] = $lockedBudget;
             $people[] = $person_indv;
         }
     }
     if (count($people) < 1) {
         return fmt("Nobody has used %s on their homepage", $PAGE_TEXT_LABEL);
     }
     //Get all pages from Category
     $pageids = array();
     $category_page = $dbi->getPage($CATEGORY);
     $iter = $category_page->getLinks();
     while ($item = $iter->next()) {
         array_push($pageids, $item->getName());
     }
     $ratingTotals = array();
     foreach ($people as $person) {
         $ratings_iter = $rdbi->sql_get_rating(0, $person, $pageids);
         $ratingTotals[$person] = 0;
         while ($ratings_array = $ratings_iter->next()) {
             $can_rating = $ratings_array['ratingvalue'];
             if ($can_rating >= $NEUTRAL_RATING) {
                 $ratingTotals[$person] += $can_rating;
             }
         }
     }
     //Generate numbers
     $canTotals = array();
     $peopleTotals = array();
     foreach ($pageids as $soda) {
         $canTotals[$soda] = 0;
     }
     foreach ($people as $person) {
         foreach ($pageids as $soda) {
             $peopleTotals[$person][$soda] = 0;
         }
     }
     foreach ($people as $person) {
         foreach ($pageids as $page) {
             $can_rating_iter = $rdbi->sql_get_rating(0, $person, $page);
             $can_rating_array = $can_rating_iter->next();
             $can_rating = $can_rating_array['ratingvalue'];
             if ($can_rating >= $NEUTRAL_RATING) {
                 $calc = $can_rating / $ratingTotals[$person] * $canBudget[$person];
                 if ($roundCalc == "true") {
                     $adjustedCans = round($calc);
                 } else {
                     $adjustedCans = round($calc, 2);
                 }
                 $peopleTotals[$person][$page] = $adjustedCans;
                 $canTotals[$page] = $canTotals[$page] + $adjustedCans;
             }
         }
     }
     $outputArray = array();
     foreach ($people as $person) {
         foreach ($pageids as $page) {
             $outputArray[$person][$page] = 0;
         }
     }
     $table = HTML::table(array('cellpadding' => '5', 'cellspacing' => '1', 'border' => '0'));
     $tr = HTML::tr();
     $td = HTML::td(array('bgcolor' => '#FFFFFF'));
     $td->pushContent(" ");
     $tr->pushContent($td);
     foreach ($people as $person) {
         $td = HTML::td(array('bgcolor' => '#FFFFFF'));
         $td->pushContent(HTML::a(array('href' => WikiURL($person), 'class' => 'wiki'), SplitPagename($person)));
         //$td->pushContent(WikiLink(" $person "));
         $tr->pushContent($td);
     }
     $td = HTML::td(array('bgcolor' => '#FFFFFF'));
     $td->pushContent(_("Total Units"));
     $tr->pushContent($td);
     $td = HTML::td(array('bgcolor' => '#FFFFFF'));
     $td->pushContent(_("Total Voters"));
     $tr->pushContent($td);
     $table->pushContent($tr);
     for ($i = 0; $i < count($pageids); $i++) {
         $total_cans = 0;
         for ($j = 0; $j < count($people); $j++) {
             $td = HTML::td(array('align' => 'right'));
             $cans_per_soda = $peopleTotals[$people[$j]][$pageids[$i]];
             $total_cans = $total_cans + $cans_per_soda;
             $outputArray[$people[$j]][$pageids[$i]] = $cans_per_soda;
         }
     }
     foreach ($people as $person) {
         $min_soda = "";
         $min_cans = 9999999;
         //9 million, serving as "infinity"
         $total_cans = 0;
         foreach ($pageids as $page) {
             $cur_soda_cans = $outputArray[$person][$page];
             if ($cur_soda_cans < $min_cans && $cur_soda_cans > 0) {
                 $min_cans = $cur_soda_cans;
                 $min_soda = $page;
             }
             $total_cans = $total_cans + $cur_soda_cans;
         }
         if ($total_cans != $canBudget[$person] && $total_cans > 0) {
             $diff = $canBudget[$person] - $total_cans;
             $outputArray[$person][$min_soda] = $outputArray[$person][$min_soda] + $diff;
         }
     }
     for ($i = 0; $i < count($pageids); $i++) {
         $tr = HTML::tr();
         $td = HTML::td(array('align' => 'left', 'bgcolor' => '#f7f7f7'));
         $td->pushContent(HTML::a(array('href' => WikiURL($pageids[$i]), 'class' => 'wiki'), SplitPagename($pageids[$i])));
         $tr->pushContent($td);
         $total_cans = 0;
         $total_voters = 0;
         for ($j = 0; $j < count($people); $j++) {
             $td = HTML::td(array('align' => 'right', 'bgcolor' => '#f7f7f7'));
             $output = $outputArray[$people[$j]][$pageids[$i]];
             $total_cans = $total_cans + $output;
             if ($output == "") {
                 $output = "-";
             } else {
                 $total_voters++;
             }
             $td->pushContent($output);
             $tr->pushContent($td);
         }
         if ($total_cans == "") {
             $total_cans = "-";
         }
         if ($total_voters == "") {
             $total_voters = "-";
         }
         $td = HTML::td(array('align' => 'right'));
         $td->pushContent($total_cans);
         $tr->pushContent($td);
         $td = HTML::td(array('align' => 'right'));
         $td->pushContent($total_voters);
         $tr->pushContent($td);
         $table->pushContent($tr);
     }
     $tr = HTML::tr();
     $td = HTML::td(array('align' => 'left'));
     $td->pushContent(HTML::strong(_("Total Budget")));
     $tr->pushContent($td);
     $cans_total = 0;
     $total_voters = 0;
     for ($i = 0; $i < count($people); $i++) {
         $td = HTML::td(array('align' => 'right'));
         $cans_for_soda = 0;
         foreach ($pageids as $page) {
             $cans_for_soda = $cans_for_soda + $outputArray[$people[$i]][$page];
         }
         $cans = $cans_for_soda;
         $cans_total = $cans_total + $cans;
         if ($cans == "") {
             $cans = "-";
         } else {
             $total_voters++;
         }
         $td->pushContent(HTML::strong($cans));
         $tr->pushContent($td);
     }
     $td = HTML::td(array('align' => 'right'));
     $td->pushContent(HTML::strong($cans_total));
     $tr->pushContent($td);
     $td = HTML::td(array('align' => 'right'));
     $td->pushContent(HTML::strong($total_voters));
     $tr->pushContent($td);
     $table->pushContent($tr);
     $table2 = HTML::table(array('bgcolor' => '#dedfdf'));
     $table2->pushContent(HTML::tr(HTML::td($table)));
     $html->pushContent($table2);
     return $html;
 }