From: <var...@us...> - 2011-03-07 13:08:08
|
Revision: 7967 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=7967&view=rev Author: vargenau Date: 2011-03-07 13:08:01 +0000 (Mon, 07 Mar 2011) Log Message: ----------- No tabs Modified Paths: -------------- trunk/lib/wikilens/Buddy.php trunk/lib/wikilens/CustomPrefs.php trunk/lib/wikilens/RatingsDb.php trunk/lib/wikilens/RatingsUser.php trunk/lib/wikilens/Utils.php Modified: trunk/lib/wikilens/Buddy.php =================================================================== --- trunk/lib/wikilens/Buddy.php 2011-03-07 10:02:01 UTC (rev 7966) +++ trunk/lib/wikilens/Buddy.php 2011-03-07 13:08:01 UTC (rev 7967) @@ -15,16 +15,8 @@ // serialized string. // If no homepage, fallback to prefs in cookie as in 1.3.3. - -/** -* -*/ require_once (dirname(__FILE__)."/Utils.php"); -/* -class Buddy extends WikiUserNew {} -*/ - function addBuddy($user, $buddy, $dbi) { $START_DELIM = _("Buddies:"); @@ -43,95 +35,95 @@ $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 = ''; + // 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 AND numrating > 5" - . " 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 = $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 AND numrating > 5" + . " 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); + foreach ($buddies_array as $userid) { + $result[] = new RatingsUser($userid); } return $result; } function CoAgreement($dbi, $page, $users, $active_userid){ - //Returns a "yes" 1, "no" -1, or "unsure" 0 for whether - //the group agrees on the page based on their ratings - $cur_page = $page; - - $my_ratings_iter = $dbi->get_rating(0, $active_userid, $page); - $my_ratings_single = $my_ratings_iter->next(); - $cur_rating = $my_ratings_single['ratingvalue']; - - $MIDDLE_RATING = 3; - - if($cur_rating >= $MIDDLE_RATING){ - $agreePos = 1; - } else { - $agreePos = 0; - } - foreach($users as $buddy){ - $buddy_rating_iter = $dbi->get_rating(0, $buddy, $cur_page); - $buddy_rating_array = $buddy_rating_iter->next(); - $buddy_rating = $buddy_rating_array['ratingvalue']; - if($buddy_rating == ""){ - $agree = 1; - }else if($agreePos && $buddy_rating >= $MIDDLE_RATING){ - $agree = 1; - } else if(!$agreePos && $buddy_rating < $MIDDLE_RATING){ - $agree = 1; - } else { - $agree = 0; - break; - } - } - if($agree && $agreePos){ - return 1; - } else if($agree && !$agreePos){ - return -1; - } else { - return 0; - } + //Returns a "yes" 1, "no" -1, or "unsure" 0 for whether + //the group agrees on the page based on their ratings + $cur_page = $page; + + $my_ratings_iter = $dbi->get_rating(0, $active_userid, $page); + $my_ratings_single = $my_ratings_iter->next(); + $cur_rating = $my_ratings_single['ratingvalue']; + + $MIDDLE_RATING = 3; + + if($cur_rating >= $MIDDLE_RATING){ + $agreePos = 1; + } else { + $agreePos = 0; + } + foreach($users as $buddy){ + $buddy_rating_iter = $dbi->get_rating(0, $buddy, $cur_page); + $buddy_rating_array = $buddy_rating_iter->next(); + $buddy_rating = $buddy_rating_array['ratingvalue']; + if($buddy_rating == ""){ + $agree = 1; + }else if($agreePos && $buddy_rating >= $MIDDLE_RATING){ + $agree = 1; + } else if(!$agreePos && $buddy_rating < $MIDDLE_RATING){ + $agree = 1; + } else { + $agree = 0; + break; + } + } + if($agree && $agreePos){ + return 1; + } else if($agree && !$agreePos){ + return -1; + } else { + return 0; + } } function MinMisery($dbi, $page, $users, $active_userid){ //Returns the minimum rating for the page //from all the users. - + $cur_page = $page; - + $my_ratings_iter = $dbi->get_rating(0, $active_userid, $page); $my_ratings_single = $my_ratings_iter->next(); $cur_rating = $my_ratings_single['ratingvalue']; - + $min = $cur_rating; foreach($users as $buddy){ $buddy_rating_iter = $dbi->get_rating(0, $buddy, $cur_page); $buddy_rating_array = $buddy_rating_iter->next(); $buddy_rating = $buddy_rating_array['ratingvalue']; if($buddy_rating != "" && $buddy_rating < $min){ - $min = $buddy_rating; + $min = $buddy_rating; } } return $min; @@ -140,9 +132,9 @@ function AverageRating($dbi, $page, $users, $active_userid){ //Returns the average rating for the page //from all the users. - + $cur_page = $page; - + $my_ratings_iter = $dbi->get_rating(0, $active_userid, $page); $my_ratings_single = $my_ratings_iter->next(); $cur_rating = $my_ratings_single['ratingvalue']; @@ -157,9 +149,9 @@ $buddy_rating_iter = $dbi->get_rating(0, $buddy, $cur_page); $buddy_rating_array = $buddy_rating_iter->next(); $buddy_rating = $buddy_rating_array['ratingvalue']; - if($buddy_rating != ""){ + if($buddy_rating != ""){ $total = $total + $buddy_rating; - $count++; + $count++; } } if($count == 0){ Modified: trunk/lib/wikilens/CustomPrefs.php =================================================================== --- trunk/lib/wikilens/CustomPrefs.php 2011-03-07 10:02:01 UTC (rev 7966) +++ trunk/lib/wikilens/CustomPrefs.php 2011-03-07 13:08:01 UTC (rev 7967) @@ -4,7 +4,7 @@ /** * Custom UserPreferences: * A list of name => _UserPreference class pairs. - * Rationale: Certain themes should be able to extend the predefined list + * Rationale: Certain themes should be able to extend the predefined list * of preferences. Display/editing is done in the theme specific userprefs.tmpl * but storage/sanification/update/... must be extended to the Get/SetPreferences methods. * @@ -29,7 +29,7 @@ var $valid_values = array ( 'itemCos', // Item-based Top-N recommendation algorithm with cosine-based similarity function - 'itemProb', // Item-based Top-N recommendation algorithm with probability-based similarity function. + 'itemProb', // Item-based Top-N recommendation algorithm with probability-based similarity function. // This algorithms tends to outperform the rest. 'userCos', // User-based Top-N recommendation algorithm with cosine-based similarity function. 'bayes'); // Naïve Bayesian Classifier @@ -45,7 +45,7 @@ extends _UserPreference_numeric{}; $WikiTheme->customUserPreferences - (array + (array ( 'recengine' => new _UserPreference_recengine('php'), 'recalgo' => new _UserPreference_recalgo('itemProb'), Modified: trunk/lib/wikilens/RatingsDb.php =================================================================== --- trunk/lib/wikilens/RatingsDb.php 2011-03-07 10:02:01 UTC (rev 7966) +++ trunk/lib/wikilens/RatingsDb.php 2011-03-07 13:08:01 UTC (rev 7967) @@ -4,7 +4,7 @@ /* * @author: Dan Frankowski (wikilens group manager), Reini Urban (as plugin) * - * TODO: + * TODO: * - fix RATING_STORAGE = WIKIPAGE (dba, file) * - fix smart caching * - finish mysuggest.c (external engine with data from mysql) @@ -30,7 +30,7 @@ // but this is problematic. define('RATING_STORAGE', $GLOBALS['request']->_dbi->_backend->isSQL() ? 'SQL' : 'WIKIPAGE'); //define('RATING_STORAGE','WIKIPAGE'); // not fully supported yet - + // leave undefined for internal, slow php engine. //if (!defined('RATING_EXTERNAL')) // define('RATING_EXTERNAL',PHPWIKI_DIR . 'suggest.exe'); @@ -61,39 +61,39 @@ } elseif (isa($this->_backend, 'WikiDB_backend_ADODOB')) { $this->_sqlbackend = &$this->_backend; $this->dbtype = "ADODB"; - } else { - include_once("lib/WikiDB/backend/ADODB.php"); - // It is not possible to decouple a ref from the source again. (4.3.11) - // It replaced the main request backend. So we don't initialize _sqlbackend before. - //$this->_sqlbackend = clone($this->_backend); + } else { + include_once("lib/WikiDB/backend/ADODB.php"); + // It is not possible to decouple a ref from the source again. (4.3.11) + // It replaced the main request backend. So we don't initialize _sqlbackend before. + //$this->_sqlbackend = clone($this->_backend); $this->_sqlbackend = new WikiDB_backend_ADODB($GLOBALS['DBParams']); - $this->dbtype = "ADODB"; + $this->dbtype = "ADODB"; } $this->iter_class = "WikiDB_backend_".$this->dbtype."_generic_iter"; extract($this->_sqlbackend->_table_names); if (empty($rating_tbl)) { - $rating_tbl = (!empty($GLOBALS['DBParams']['prefix']) + $rating_tbl = (!empty($GLOBALS['DBParams']['prefix']) ? $GLOBALS['DBParams']['prefix'] : '') . 'rating'; $this->_sqlbackend->_table_names['rating_tbl'] = $rating_tbl; } } else { - $this->iter_class = "WikiDB_Array_PageIterator"; + $this->iter_class = "WikiDB_Array_PageIterator"; } } - + // this is a singleton. It ensures there is only 1 ratingsDB. function & getTheRatingsDb(){ static $_theRatingsDb; - + if (!isset($_theRatingsDb)){ $_theRatingsDb = new RatingsDb(); - } + } //echo "rating db is $_theRatingsDb"; return $_theRatingsDb; } - + /// ************************************************************************************* // FIXME // from Reini Urban's RateIt plugin @@ -110,7 +110,7 @@ function deleteRating($userid=null, $pagename=null, $dimension=null) { if (is_null($dimension)) $dimension = $this->dimension; - if (is_null($userid)) $userid = $this->userid; + if (is_null($userid)) $userid = $this->userid; if (is_null($pagename)) $pagename = $this->pagename; if (RATING_STORAGE == 'SQL') { $this->sql_delete_rating($userid, $pagename, $dimension); @@ -118,13 +118,13 @@ $this->metadata_set_rating($userid, $pagename, $dimension, -1); } } - + function getRating($userid=null, $pagename=null, $dimension=null) { if (RATING_STORAGE == 'SQL') { $ratings_iter = $this->sql_get_rating($dimension, $userid, $pagename); if ($rating = $ratings_iter->next() and isset($rating['ratingvalue'])) { return $rating['ratingvalue']; - } else + } else return false; } else { return $this->metadata_get_rating($userid, $pagename, $dimension); @@ -133,20 +133,19 @@ function getUsersRated($dimension=null, $orderby = null) { if (is_null($dimension)) $dimension = $this->dimension; - //if (is_null($userid)) $userid = $this->userid; + //if (is_null($userid)) $userid = $this->userid; //if (is_null($pagename)) $pagename = $this->pagename; if (RATING_STORAGE == 'SQL') { $ratings_iter = $this->sql_get_users_rated($dimension, $orderby); if ($rating = $ratings_iter->next() and isset($rating['ratingvalue'])) { return $rating['ratingvalue']; - } else + } else return false; } else { return $this->metadata_get_users_rated($dimension, $orderby); } } - - + /** * Get ratings. * @@ -184,7 +183,7 @@ * If this is null (or left off), the info returned * is for the 'ratee' page (i.e., thing being rated). * - * @return DB iterator with results + * @return DB iterator with results */ function get_rating($dimension=null, $rater=null, $ratee=null, $orderby = null, $pageinfo = "ratee") { @@ -192,7 +191,7 @@ $ratings_iter = $this->sql_get_rating($dimension, $rater, $pagename); if ($rating = $ratings_iter->next() and isset($rating['ratingvalue'])) { return $rating['ratingvalue']; - } else + } else return false; } else { return $this->metadata_get_rating($rater, $pagename, $dimension); @@ -205,12 +204,12 @@ function get_users_rated($dimension=null, $pagename = null, $orderby = null) { if (RATING_STORAGE == 'SQL') { $ratings_iter = $this->sql_get_users_rated($dimension, $pagename, $orderby); - // iter as userid - $users = array(); - while ($rating = $ratings_iter->next()) { - $users[] = $rating['userid']; - } - return $users; + // iter as userid + $users = array(); + while ($rating = $ratings_iter->next()) { + $users[] = $rating['userid']; + } + return $users; } else { return $this->metadata_get_users_rated($dimension, $pagename, $orderby); } @@ -225,9 +224,9 @@ if (RATING_STORAGE == 'SQL') { return $this->sql_get_rating($dimension, $rater, $ratee, $orderby, $pageinfo); } else { - // empty dummy iterator - $pages = array(); - return new WikiDB_Array_PageIterator($pages); + // empty dummy iterator + $pages = array(); + return new WikiDB_Array_PageIterator($pages); } } @@ -275,9 +274,9 @@ $this->metadata_set_rating($userid, $pagename, $dimension, $rating); } } - + //function getUsersRated(){} - + //******************************************************************************* // TODO: // Use wikilens/RatingsUser.php for the php methods. @@ -287,22 +286,22 @@ // http://www-users.cs.umn.edu/~karypis/suggest/ // until we implement a simple recommendation engine. // Note that "suggest" is only free for non-profit organizations. - // I am currently writing a binary CGI mysuggest using suggest, which loads + // I am currently writing a binary CGI mysuggest using suggest, which loads // data from mysql. function getPrediction($userid=null, $pagename=null, $dimension=null) { if (is_null($dimension)) $dimension = $this->dimension; - if (is_null($userid)) $userid = $this->userid; + if (is_null($userid)) $userid = $this->userid; if (is_null($pagename)) $pagename = $this->pagename; if (RATING_STORAGE == 'SQL') { $dbh = &$this->_sqlbackend; if (isset($pagename)) $page = $dbh->_get_pageid($pagename); - else + else return 0; if (isset($userid)) $user = $dbh->_get_pageid($userid); - else + else return 0; } if (defined('RATING_EXTERNAL') and RATING_EXTERNAL) { @@ -325,7 +324,7 @@ */ function php_prediction($userid=null, $pagename=null, $dimension=null) { if (is_null($dimension)) $dimension = $this->dimension; - if (is_null($userid)) $userid = $this->userid; + if (is_null($userid)) $userid = $this->userid; if (is_null($pagename)) $pagename = $this->pagename; if (empty($this->buddies)) { require_once("lib/wikilens/RatingsUser.php"); @@ -335,7 +334,7 @@ } return $user->knn_uu_predict($pagename, $this->buddies, $dimension); } - + function getNumUsers($pagename=null, $dimension=null) { if (is_null($dimension)) $dimension = $this->dimension; if (is_null($pagename)) $pagename = $this->pagename; @@ -349,7 +348,7 @@ $data = $page->get('rating'); if (!empty($data[$dimension])) return count($data[$dimension]); - else + else return 0; } } @@ -359,23 +358,23 @@ if (is_null($pagename)) $pagename = $this->pagename; if (RATING_STORAGE == 'SQL') { $dbi = &$this->_sqlbackend; - if (isset($pagename) || isset($dimension)) { - $where = "WHERE"; - } + if (isset($pagename) || isset($dimension)) { + $where = "WHERE"; + } if (isset($pagename)) { $raterid = $this->_sqlbackend->_get_pageid($pagename, true); $where .= " raterpage=$raterid"; } if (isset($dimension)) { - if (isset($pagename)) $where .= " AND"; + if (isset($pagename)) $where .= " AND"; $where .= " dimension=$dimension"; } //$dbh = &$this->_dbi; extract($dbi->_table_names); $query = "SELECT AVG(ratingvalue) as avg" - . " FROM $rating_tbl r, $page_tbl p " - . $where - . " GROUP BY raterpage"; + . " FROM $rating_tbl r, $page_tbl p " + . $where + . " GROUP BY raterpage"; $result = $dbi->_dbh->query($query); $iter = new $this->iter_class($this, $result); $row = $iter->next(); @@ -387,8 +386,8 @@ if (!empty($data[$dimension])) // hash of userid => rating return array_sum(array_values($data[$dimension])) / count($data[$dimension]); - else - return 0; + else + return 0; } } //******************************************************************************* @@ -431,7 +430,7 @@ * If this is null (or left off), the info returned * is for the 'ratee' page (i.e., thing being rated). * - * @return DB iterator with results + * @return DB iterator with results */ function sql_get_rating($dimension=null, $rater=null, $ratee=null, $orderby=null, $pageinfo = "ratee") { @@ -449,16 +448,16 @@ // all users who rated this page resp if null all pages.. needed? function metadata_get_users_rated($dimension=null, $pagename=null, $orderby=null) { if (is_null($dimension)) $dimension = $this->dimension; - $users = array(); - if (!$pagename) { - // TODO: all pages? - return new WikiDB_Array_PageIterator($users); - } - $page = $this->_dbi->getPage($pagename); - $data = $page->get('rating'); - if (!empty($data[$dimension])) { - //array($userid => (float)$rating); - return new WikiDB_Array_PageIterator(array_keys($data[$dimension])); + $users = array(); + if (!$pagename) { + // TODO: all pages? + return new WikiDB_Array_PageIterator($users); + } + $page = $this->_dbi->getPage($pagename); + $data = $page->get('rating'); + if (!empty($data[$dimension])) { + //array($userid => (float)$rating); + return new WikiDB_Array_PageIterator(array_keys($data[$dimension])); } return new WikiDB_Array_PageIterator($users); } @@ -487,19 +486,19 @@ } if (isset($ratee)) { if(is_array($ratee)){ - $where .= " AND ("; - for($i = 0; $i < count($ratee); $i++){ - $rateeid = $dbi->_get_pageid($ratee[$i], true); - $where .= "rateepage=$rateeid"; - if($i != (count($ratee) - 1)){ - $where .= " OR "; - } - } - $where .= ")"; - } else { - $rateeid = $dbi->_get_pageid($ratee, true); - $where .= " AND rateepage=$rateeid"; - } + $where .= " AND ("; + for($i = 0; $i < count($ratee); $i++){ + $rateeid = $dbi->_get_pageid($ratee[$i], true); + $where .= "rateepage=$rateeid"; + if($i != (count($ratee) - 1)){ + $where .= " OR "; + } + } + $where .= ")"; + } else { + $rateeid = $dbi->_get_pageid($ratee, true); + $where .= " AND rateepage=$rateeid"; + } } $orderbyStr = ""; if (isset($orderby)) { @@ -508,10 +507,10 @@ if (isset($rater) or isset($ratee)) $what = '*'; // same as _get_users_rated_result() else { - $what = 'DISTINCT p.pagename'; - if ($pageinfo == 'rater') - $what = 'DISTINCT p.pagename as userid'; - } + $what = 'DISTINCT p.pagename'; + if ($pageinfo == 'rater') + $what = 'DISTINCT p.pagename as userid'; + } $query = "SELECT $what" . " FROM $rating_tbl r, $page_tbl p " @@ -582,24 +581,24 @@ $insert = "INSERT INTO $rating_tbl (dimension, raterpage, rateepage, ratingvalue, rateeversion)" ." VALUES ('$dimension', $raterid, $rateeid, '$rating', '$rateeversion')"; $dbi->_dbh->query($insert); - + $dbi->unlock(); return true; } function metadata_get_rating($userid, $pagename, $dimension) { - if (!$pagename) return false; + if (!$pagename) return false; $page = $this->_dbi->getPage($pagename); $data = $page->get('rating'); if (!empty($data[$dimension][$userid])) return (float)$data[$dimension][$userid]; - else + else return false; } function metadata_set_rating($userid, $pagename, $dimension, $rating = -1) { - if (!$pagename) return false; - $page = $this->_dbi->getPage($pagename); + if (!$pagename) return false; + $page = $this->_dbi->getPage($pagename); $data = $page->get('rating'); if ($rating == -1) unset($data[$dimension][$userid]); @@ -615,7 +614,7 @@ } /* -class RatingsDB_backend_PearDB +class RatingsDB_backend_PearDB extends WikiDB_backend_PearDB { function get_rating($dimension=null, $rater=null, $ratee=null, $orderby=null, $pageinfo = "ratee") { @@ -623,7 +622,7 @@ $dimension, $rater, $ratee, $orderby, $pageinfo); return new WikiDB_backend_PearDB_generic_iter($this, $result); } - + function get_users_rated($dimension=null, $orderby=null) { $result = $this->_get_users_rated_result( $dimension, $orderby); @@ -655,20 +654,20 @@ $where .= " AND raterpage=$raterid"; } if (isset($ratee)) { - if(is_array($ratee)){ - $where .= " AND ("; - for($i = 0; $i < count($ratee); $i++){ - $rateeid = $this->_get_pageid($ratee[$i], true); - $where .= "rateepage=$rateeid"; - if($i != (count($ratee) - 1)){ - $where .= " OR "; - } - } - $where .= ")"; - } else { - $rateeid = $this->_get_pageid($ratee, true); - $where .= " AND rateepage=$rateeid"; - } + if(is_array($ratee)){ + $where .= " AND ("; + for($i = 0; $i < count($ratee); $i++){ + $rateeid = $this->_get_pageid($ratee[$i], true); + $where .= "rateepage=$rateeid"; + if($i != (count($ratee) - 1)){ + $where .= " OR "; + } + } + $where .= ")"; + } else { + $rateeid = $this->_get_pageid($ratee, true); + $where .= " AND rateepage=$rateeid"; + } } $orderbyStr = ""; @@ -685,7 +684,7 @@ return $result; } - + function _get_users_rated_result($dimension=null, $orderby=null) { $dbh = &$this->_dbh; extract($this->_table_names); @@ -735,7 +734,7 @@ $this->unlock(); return true; } -} +} */ // Local Variables: Modified: trunk/lib/wikilens/RatingsUser.php =================================================================== --- trunk/lib/wikilens/RatingsUser.php 2011-03-07 10:02:01 UTC (rev 7966) +++ trunk/lib/wikilens/RatingsUser.php 2011-03-07 13:08:01 UTC (rev 7967) @@ -77,13 +77,13 @@ return $this->_rdbi; } - // XXX: may want to think about caching ratings in the PHP session + // XXX: may want to think about caching ratings in the PHP session // since a WikiUser is created for *every* access, in which case rate.php // will want to change to use this object instead of direct db access /** * Check whether $user is allowed to view this user's ratings - * + * * @return bool True if $user can view this user's ratings, false otherwise */ function allow_view_ratings($user) @@ -93,7 +93,7 @@ /** * Gets this user's ratings - * + * * @return array Assoc. array [page_name][dimension] = _UserRating object */ function get_ratings() @@ -104,13 +104,13 @@ /** * Gets this user's mean rating across a dimension - * + * * @return float Mean rating */ function mean_rating($dimension = 0) { // use memoized result if available - if (isset($this->_mean_ratings[$dimension])) + if (isset($this->_mean_ratings[$dimension])) { return $this->_mean_ratings[$dimension]; } @@ -147,8 +147,6 @@ $this->_load_ratings(); if (isset($dimension)) { - - if (isset($this->_ratings[$pagename][$dimension])) { return true; @@ -231,7 +229,7 @@ { return $this->_pearson_sims[$user->getId()][$dimension]; } - + $ratings1 = $this->get_ratings(); $mean1 = $this->mean_rating($dimension); // XXX: sanify user input? @@ -278,7 +276,7 @@ // items that the similarity was based on // prevent division-by-zero - if (sqrt($sum11) == 0 || sqrt($sum12) == 0) + if (sqrt($sum11) == 0 || sqrt($sum12) == 0) $sim = array(0, $n); else // Pearson similarity @@ -368,9 +366,9 @@ } $this->_num_ratings++; $this->_ratings[$rating['pagename']][$rating['dimension']] - = new _UserRating($this->_userid, + = new _UserRating($this->_userid, $rating['pagename'], - $rating['dimension'], + $rating['dimension'], $rating['ratingvalue']); } @@ -382,7 +380,7 @@ /** Represent a rating. */ class _UserRating { - function _UserRating ($rater, $ratee, $dimension, $rating) + function _UserRating ($rater, $ratee, $dimension, $rating) { $this->rater = (string)$rater; $this->ratee = (string)$ratee; @@ -390,42 +388,42 @@ $this->rating = (float)$rating; } - function get_rater() + function get_rater() { return $this->rater; } - function get_ratee() + function get_ratee() { return $this->ratee; } - function get_rating() + function get_rating() { return $this->rating; } - function get_dimension() + function get_dimension() { return $this->dimension; } - function set_rater() + function set_rater() { $this->rater = (string)$rater; } - function set_ratee() + function set_ratee() { $this->ratee = (string)$ratee; } - function set_rating() + function set_rating() { $this->rating = (float)$rating; } - function set_dimension() + function set_dimension() { $this->dimension = (int)$dimension; } Modified: trunk/lib/wikilens/Utils.php =================================================================== --- trunk/lib/wikilens/Utils.php 2011-03-07 10:02:01 UTC (rev 7966) +++ trunk/lib/wikilens/Utils.php 2011-03-07 13:08:01 UTC (rev 7967) @@ -20,9 +20,6 @@ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA */ -/** - */ - function addPageTextData($user, $dbi, $new_data, $START_DELIM, $DELIM) { // This is largely lifted from the TranslateText plugin, which performs a // similar set of functions (retrieves a user's homepage, modifies it @@ -64,15 +61,15 @@ if (is_object($fromUser)) $fromUser = $fromUser->getId(); if ($fromUser == "") - return ""; + return ""; $userPage = $dbi->getPage($fromUser); $transformed = $userPage->getCurrentRevision(); $pageArray = $transformed->getContent(); $p = -1; for ($i = 0; $i < count($pageArray); $i++){ - if($pageArray[$i] != ""){ + if($pageArray[$i] != ""){ if(!((strpos($pageArray[$i], $START_DELIM)) === FALSE)){ - $p = $i; + $p = $i; break; } } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2012-10-02 12:17:08
|
Revision: 8379 http://phpwiki.svn.sourceforge.net/phpwiki/?rev=8379&view=rev Author: vargenau Date: 2012-10-02 12:16:57 +0000 (Tue, 02 Oct 2012) Log Message: ----------- Whitespace only Modified Paths: -------------- trunk/lib/wikilens/Buddy.php trunk/lib/wikilens/CustomPrefs.php Modified: trunk/lib/wikilens/Buddy.php =================================================================== --- trunk/lib/wikilens/Buddy.php 2012-10-02 12:12:25 UTC (rev 8378) +++ trunk/lib/wikilens/Buddy.php 2012-10-02 12:16:57 UTC (rev 8379) @@ -1,6 +1,5 @@ -<?php //-*-php-*- +<?php - // It is anticipated that when userid support is added to phpwiki, // this object will hold much more information (e-mail, // home(wiki)page, etc.) about the user. Modified: trunk/lib/wikilens/CustomPrefs.php =================================================================== --- trunk/lib/wikilens/CustomPrefs.php 2012-10-02 12:12:25 UTC (rev 8378) +++ trunk/lib/wikilens/CustomPrefs.php 2012-10-02 12:16:57 UTC (rev 8379) @@ -1,6 +1,5 @@ -<?php // -*-php-*- +<?php - /** * Custom UserPreferences: * A list of name => _UserPreference class pairs. This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2016-07-12 07:20:22
|
Revision: 9876 http://sourceforge.net/p/phpwiki/code/9876 Author: vargenau Date: 2016-07-12 07:20:17 +0000 (Tue, 12 Jul 2016) Log Message: ----------- Use __construct Modified Paths: -------------- trunk/lib/wikilens/RatingsDb.php trunk/lib/wikilens/RatingsUser.php Modified: trunk/lib/wikilens/RatingsDb.php =================================================================== --- trunk/lib/wikilens/RatingsDb.php 2016-07-11 15:54:50 UTC (rev 9875) +++ trunk/lib/wikilens/RatingsDb.php 2016-07-12 07:20:17 UTC (rev 9876) @@ -53,7 +53,7 @@ class RatingsDb extends WikiDB { - function RatingsDb() + function __construct() { global $request; $this->_dbi = &$request->_dbi; Modified: trunk/lib/wikilens/RatingsUser.php =================================================================== --- trunk/lib/wikilens/RatingsUser.php 2016-07-11 15:54:50 UTC (rev 9875) +++ trunk/lib/wikilens/RatingsUser.php 2016-07-12 07:20:17 UTC (rev 9876) @@ -56,7 +56,7 @@ public $_mean_ratings; public $_pearson_sims; - function RatingsUser($userid) + function __construct($userid) { $this->_userid = $userid; $this->_ratings_loaded = false; @@ -360,7 +360,7 @@ /** Represent a rating. */ class _UserRating { - function _UserRating($rater, $ratee, $dimension, $rating) + function __construct($rater, $ratee, $dimension, $rating) { $this->rater = (string)$rater; $this->ratee = (string)$ratee; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2016-10-06 16:55:27
|
Revision: 9938 http://sourceforge.net/p/phpwiki/code/9938 Author: vargenau Date: 2016-10-06 16:55:25 +0000 (Thu, 06 Oct 2016) Log Message: ----------- Add SPDX-License-Identifier Modified Paths: -------------- trunk/lib/wikilens/RatingsUser.php trunk/lib/wikilens/Utils.php Modified: trunk/lib/wikilens/RatingsUser.php =================================================================== --- trunk/lib/wikilens/RatingsUser.php 2016-10-06 16:50:28 UTC (rev 9937) +++ trunk/lib/wikilens/RatingsUser.php 2016-10-06 16:55:25 UTC (rev 9938) @@ -1,7 +1,7 @@ <?php - -/* Copyright (C) 2004 Dan Frankowski - * Copyright (C) 2010 Roger Guignard, Alcatel-Lucent +/** + * Copyright © 2004 Dan Frankowski + * Copyright © 2010 Roger Guignard, Alcatel-Lucent * * This file is part of PhpWiki. * @@ -18,6 +18,9 @@ * You should have received a copy of the GNU General Public License along * with PhpWiki; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * SPDX-License-Identifier: GPL-2.0+ + * */ require_once 'lib/wikilens/RatingsDb.php'; @@ -25,6 +28,7 @@ /** * Get a RatingsUser instance (possibly from a cache). */ + class RatingsUserFactory { static function & getUser($userid) Modified: trunk/lib/wikilens/Utils.php =================================================================== --- trunk/lib/wikilens/Utils.php 2016-10-06 16:50:28 UTC (rev 9937) +++ trunk/lib/wikilens/Utils.php 2016-10-06 16:55:25 UTC (rev 9938) @@ -1,7 +1,6 @@ <?php - -/* - * Copyright 2004 Mike Cassano +/** + * Copyright © 2004 Mike Cassano * * This file is part of PhpWiki. * @@ -18,6 +17,9 @@ * You should have received a copy of the GNU General Public License along * with PhpWiki; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * SPDX-License-Identifier: GPL-2.0+ + * */ function addPageTextData($user, $dbi, $new_data, $START_DELIM, $DELIM) This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2022-03-24 13:48:03
|
Revision: 11013 http://sourceforge.net/p/phpwiki/code/11013 Author: vargenau Date: 2022-03-24 13:48:01 +0000 (Thu, 24 Mar 2022) Log Message: ----------- run php-cs-fixer Modified Paths: -------------- trunk/lib/wikilens/Buddy.php trunk/lib/wikilens/CustomPrefs.php trunk/lib/wikilens/PageListColumns.php trunk/lib/wikilens/RatingsDb.php trunk/lib/wikilens/RatingsUser.php trunk/lib/wikilens/Utils.php Modified: trunk/lib/wikilens/Buddy.php =================================================================== --- trunk/lib/wikilens/Buddy.php 2022-03-24 13:44:55 UTC (rev 11012) +++ trunk/lib/wikilens/Buddy.php 2022-03-24 13:48:01 UTC (rev 11013) @@ -36,7 +36,7 @@ // serialized string. // If no homepage, fallback to prefs in cookie as in 1.3.3. -require_once (dirname(__FILE__) . "/Utils.php"); +require_once(dirname(__FILE__) . "/Utils.php"); function addBuddy($user, $buddy, $dbi) { @@ -78,13 +78,13 @@ } else { // from 10 random raters of this page (non-SQL) } - } $result = array(); - if (is_array($buddies_array)) + if (is_array($buddies_array)) { foreach ($buddies_array as $userid) { $result[] = new RatingsUser($userid); } + } return $result; } Modified: trunk/lib/wikilens/CustomPrefs.php =================================================================== --- trunk/lib/wikilens/CustomPrefs.php 2022-03-24 13:44:55 UTC (rev 11012) +++ trunk/lib/wikilens/CustomPrefs.php 2022-03-24 13:48:01 UTC (rev 11013) @@ -38,10 +38,13 @@ public $valid_values = array('php', 'mysuggest', 'mymovielens', 'mycluto'); public $default_value = 'php'; - function sanify($value) + public function sanify($value) { - if (!in_array($value, $this->valid_values)) return $this->default_value; - else return $value; + if (!in_array($value, $this->valid_values)) { + return $this->default_value; + } else { + return $value; + } } } @@ -48,8 +51,7 @@ class _UserPreference_recalgo // recommendation engine algorithm extends _UserPreference { - public $valid_values = array - ( + public $valid_values = array( 'itemCos', // Item-based Top-N recommendation algorithm with cosine-based similarity function 'itemProb', // Item-based Top-N recommendation algorithm with probability-based similarity function. // This algorithms tends to outperform the rest. @@ -57,10 +59,13 @@ 'bayes'); // Naïve Bayesian Classifier public $default_value = 'itemProb'; - function sanify($value) + public function sanify($value) { - if (!in_array($value, $this->valid_values)) return $this->default_value; - else return $value; + if (!in_array($value, $this->valid_values)) { + return $this->default_value; + } else { + return $value; + } } } @@ -69,9 +74,7 @@ { } -$WikiTheme->customUserPreferences -(array -( +$WikiTheme->customUserPreferences(array( 'recengine' => new _UserPreference_recengine('php'), 'recalgo' => new _UserPreference_recalgo('itemProb'), //recnnbr: typically 15-30 for item-based, 40-80 for user-based algos Modified: trunk/lib/wikilens/PageListColumns.php =================================================================== --- trunk/lib/wikilens/PageListColumns.php 2022-03-24 13:44:55 UTC (rev 11012) +++ trunk/lib/wikilens/PageListColumns.php 2022-03-24 13:48:01 UTC (rev 11013) @@ -46,13 +46,13 @@ */ class _PageList_Column_numbacklinks extends _PageList_Column_custom { - function _getValue($page_handle, $revision_handle) + public function _getValue($page_handle, $revision_handle) { $theIter = $page_handle->getBackLinks(); return $theIter->count(); } - function _getSortableValue($page_handle, $revision_handle) + public function _getSortableValue($page_handle, $revision_handle) { return $this->_getValue($page_handle, $revision_handle); } @@ -60,7 +60,7 @@ class _PageList_Column_coagreement extends _PageList_Column_custom { - function __construct($params) + public function __construct($params) { $this->_pagelist =& $params[3]; _PageList_Column::__construct($params[0], $params[1], $params[2]); @@ -67,7 +67,7 @@ $this->_selectedBuddies = $this->_pagelist->getOption('selectedBuddies'); } - function _getValue($page_handle, $revision_handle) + public function _getValue($page_handle, $revision_handle) { global $request; @@ -93,7 +93,7 @@ class _PageList_Column_minmisery extends _PageList_Column_custom { - function __construct($params) + public function __construct($params) { $this->_pagelist =& $params[3]; _PageList_Column::__construct($params[0], $params[1], $params[2]); @@ -100,7 +100,7 @@ $this->_selectedBuddies = $this->_pagelist->getOption('selectedBuddies'); } - function _getValue($page_handle, $revision_handle) + public function _getValue($page_handle, $revision_handle) { global $request, $WikiTheme; @@ -117,7 +117,7 @@ class _PageList_Column_averagerating extends _PageList_Column_custom { - function __construct($params) + public function __construct($params) { $this->_pagelist =& $params[3]; _PageList_Column::__construct($params[0], $params[1], $params[2]); @@ -124,7 +124,7 @@ $this->_selectedBuddies = $this->_pagelist->getOption('selectedBuddies'); } - function _getValue($page_handle, $revision_handle) + public function _getValue($page_handle, $revision_handle) { global $request, $WikiTheme; @@ -153,7 +153,7 @@ public $_user; public $_dimension; - function __construct($params) + public function __construct($params) { $this->_pagelist =& $params[3]; $this->_user =& $params[4]; //$this->_pagelist->getOption('user'); @@ -164,10 +164,12 @@ } parent::__construct($params[0], $params[1], $params[2]); $this->_dimension = $this->_pagelist->getOption('dimension'); - if (!$this->_dimension) $this->_dimension = 0; + if (!$this->_dimension) { + $this->_dimension = 0; + } } - function format($pagelist, $page_handle, $revision_handle) + public function format($pagelist, $page_handle, $revision_handle) { /** * @var WikiRequest $request @@ -174,8 +176,9 @@ */ global $request; - if (empty($this->_user)) + if (empty($this->_user)) { $this->_user =& RatingsUserFactory::getUser($request->_user->_userid); + } assert(!empty($this->_user)); $rating = $this->_getValue($page_handle, $revision_handle); $mean = $this->_user->mean_rating($this->_dimension); @@ -182,8 +185,9 @@ $td = HTML::td($this->_tdattr); $div = HTML::div(); - if ($rating != '-' && abs($rating - $mean) >= 0.75) + if ($rating != '-' && abs($rating - $mean) >= 0.75) { $div->setAttr('style', 'color: #' . ($rating > $mean ? '009900' : 'ff3333')); + } $div->pushContent($rating); $td->pushContent($div); @@ -191,7 +195,7 @@ return $td; } - function _getValue($page_handle, $revision_handle) + public function _getValue($page_handle, $revision_handle) { $pagename = $page_handle->getName(); @@ -202,7 +206,7 @@ return ($rating ? $rating : "-"); } - function hasNoRatings($pages) + public function hasNoRatings($pages) { $total = 0; $use = & $this->_user; @@ -215,10 +219,9 @@ return true; } return false; - } - function _getSortableValue($page_handle, $revision_handle) + public function _getSortableValue($page_handle, $revision_handle) { return $this->_getValue($page_handle, $revision_handle); } @@ -230,23 +233,35 @@ */ class _PageList_Column_ratingwidget extends _PageList_Column_custom { - function __construct($params) + public function __construct($params) { $this->_pagelist =& $params[3]; _PageList_Column::__construct($params[0], $params[1], $params[2]); $this->_dimension = $this->_pagelist->getOption('dimension'); - if (!$this->_dimension) $this->_dimension = 0; + if (!$this->_dimension) { + $this->_dimension = 0; + } } - function format($pagelist, $page_handle, $revision_handle) + public function format($pagelist, $page_handle, $revision_handle) { $plugin = new WikiPlugin_RateIt(); if (defined('FUSIONFORGE') && FUSIONFORGE) { - $widget = $plugin->RatingWidgetHtml($page_handle->getName(), "", - "BStar", $this->_dimension, "small"); + $widget = $plugin->RatingWidgetHtml( + $page_handle->getName(), + "", + "BStar", + $this->_dimension, + "small" + ); } else { - $widget = $plugin->RatingWidgetHtml($page_handle->getName(), "", - "Star", $this->_dimension, "small"); + $widget = $plugin->RatingWidgetHtml( + $page_handle->getName(), + "", + "Star", + $this->_dimension, + "small" + ); } $td = HTML::td($widget); $td->setAttr('nowrap', 'nowrap'); @@ -253,7 +268,7 @@ return $td; } - function _getValue($page_handle, $revision_handle) + public function _getValue($page_handle, $revision_handle) { global $request; @@ -271,7 +286,7 @@ } } - function _getSortableValue($page_handle, $revision_handle) + public function _getSortableValue($page_handle, $revision_handle) { return $this->_getValue($page_handle, $revision_handle); } @@ -282,7 +297,7 @@ public $_active_ratings_user; public $_users; - function __construct($params) + public function __construct($params) { global $request; $active_user = $request->getUser(); @@ -292,11 +307,13 @@ $this->_pagelist =& $params[3]; parent::__construct($params[0], $params[1], $params[2]); $this->_dimension = $this->_pagelist->getOption('dimension'); - if (!$this->_dimension) $this->_dimension = 0; + if (!$this->_dimension) { + $this->_dimension = 0; + } $this->_users = $this->_pagelist->getOption('users'); } - function format($pagelist, $page_handle, $revision_handle) + public function format($pagelist, $page_handle, $revision_handle) { $pred = $this->_getValue($page_handle, $revision_handle); $mean = $this->_active_ratings_user->mean_rating($this->_dimension); @@ -303,8 +320,9 @@ $td = HTML::td($this->_tdattr); $div = HTML::div(); - if ($pred > 0 && abs($pred - $mean) >= 0.75) + if ($pred > 0 && abs($pred - $mean) >= 0.75) { $div->setAttr('style', 'color: #' . ($pred > $mean ? '009900' : 'ff3333')); + } $div->pushContent($pred); $td->pushContent($div); @@ -312,7 +330,7 @@ return $td; } - function _getValue($page_handle, $revision_handle) + public function _getValue($page_handle, $revision_handle) { $pagename = $page_handle->getName(); @@ -320,7 +338,7 @@ return sprintf("%.1f", min(5, max(0, $pred))); } - function _getSortableValue($page_handle, $revision_handle) + public function _getSortableValue($page_handle, $revision_handle) { return $this->_getValue($page_handle, $revision_handle); } @@ -328,11 +346,10 @@ class _PageList_Column_top3recs extends _PageList_Column_custom { - public $_active_ratings_user; public $_users; - function __construct($params) + public function __construct($params) { global $request; $active_user = $request->getUser(); @@ -349,12 +366,14 @@ if (!empty($params[3])) { $this->_pagelist =& $params[3]; $this->_dimension = $this->_pagelist->getOption('dimension'); - if (!$this->_dimension) $this->_dimension = 0; + if (!$this->_dimension) { + $this->_dimension = 0; + } $this->_users = $this->_pagelist->getOption('users'); } } - function _getValue($page_handle, $revision_handle) + public function _getValue($page_handle, $revision_handle) { $ratings = $this->_active_ratings_user->get_ratings(); $iter = $page_handle->getLinks(); @@ -363,8 +382,11 @@ //filter out already rated if (!$this->_active_ratings_user->get_rating($current->getName(), $this->_dimension)) { $recs[$current->getName()] = - $this->_active_ratings_user->knn_uu_predict($current->getName(), - $this->_users, $this->_dimension); + $this->_active_ratings_user->knn_uu_predict( + $current->getName(), + $this->_users, + $this->_dimension + ); } } arsort($recs); @@ -397,9 +419,7 @@ // register custom PageList type global $WikiTheme; -$WikiTheme->addPageListColumn -(array -( +$WikiTheme->addPageListColumn(array( 'numbacklinks' => array('_PageList_Column_numbacklinks', 'custom:numbacklinks', _("# things"), 'center'), Modified: trunk/lib/wikilens/RatingsDb.php =================================================================== --- trunk/lib/wikilens/RatingsDb.php 2022-03-24 13:44:55 UTC (rev 11012) +++ trunk/lib/wikilens/RatingsDb.php 2022-03-24 13:48:01 UTC (rev 11013) @@ -53,8 +53,9 @@ // For other than SQL backends. dba ratings are allowed but deprecated. // We will probably drop this hack. -if (!defined('RATING_STORAGE')) +if (!defined('RATING_STORAGE')) { define('RATING_STORAGE', $request->_dbi->_backend->isSQL() ? 'SQL' : 'WIKIPAGE'); +} //define('RATING_STORAGE','WIKIPAGE'); // not fully supported yet // leave undefined for internal, slow php engine. @@ -62,20 +63,23 @@ // define('RATING_EXTERNAL',PHPWIKI_DIR . 'suggest.exe'); // Dimensions -if (!defined('EXPLICIT_RATINGS_DIMENSION')) +if (!defined('EXPLICIT_RATINGS_DIMENSION')) { define('EXPLICIT_RATINGS_DIMENSION', 0); -if (!defined('LIST_ITEMS_DIMENSION')) +} +if (!defined('LIST_ITEMS_DIMENSION')) { define('LIST_ITEMS_DIMENSION', 1); -if (!defined('LIST_OWNER_DIMENSION')) +} +if (!defined('LIST_OWNER_DIMENSION')) { define('LIST_OWNER_DIMENSION', 2); -if (!defined('LIST_TYPE_DIMENSION')) +} +if (!defined('LIST_TYPE_DIMENSION')) { define('LIST_TYPE_DIMENSION', 3); +} //TODO: split class into SQL and metadata backends class RatingsDb extends WikiDB { - - function __construct() + public function __construct() { global $request; $this->_dbi = &$request->_dbi; @@ -103,7 +107,7 @@ } // this is a singleton. It ensures there is only 1 ratingsDB. - static function & getTheRatingsDb() + public static function & getTheRatingsDb() { static $_theRatingsDb; @@ -115,10 +119,10 @@ } -/// ************************************************************************************* -// FIXME -// from Reini Urban's RateIt plugin - function addRating($rating, $userid, $pagename, $dimension) + /// ************************************************************************************* + // FIXME + // from Reini Urban's RateIt plugin + public function addRating($rating, $userid, $pagename, $dimension) { if (RATING_STORAGE == 'SQL') { $page = $this->_dbi->getPage($pagename); @@ -130,11 +134,17 @@ } } - function deleteRating($userid = null, $pagename = null, $dimension = null) + public function deleteRating($userid = null, $pagename = null, $dimension = null) { - if (is_null($dimension)) $dimension = $this->dimension; - if (is_null($userid)) $userid = $this->userid; - if (is_null($pagename)) $pagename = $this->pagename; + if (is_null($dimension)) { + $dimension = $this->dimension; + } + if (is_null($userid)) { + $userid = $this->userid; + } + if (is_null($pagename)) { + $pagename = $this->pagename; + } if (RATING_STORAGE == 'SQL') { $this->sql_delete_rating($userid, $pagename, $dimension); } else { @@ -142,22 +152,25 @@ } } - function getRating($userid = null, $pagename = null, $dimension = null) + public function getRating($userid = null, $pagename = null, $dimension = null) { if (RATING_STORAGE == 'SQL') { $ratings_iter = $this->sql_get_rating($dimension, $userid, $pagename); if ($rating = $ratings_iter->next() and isset($rating['ratingvalue'])) { return $rating['ratingvalue']; - } else + } else { return false; + } } else { return $this->metadata_get_rating($userid, $pagename, $dimension); } } - function getUsersRated($dimension = null, $orderby = null) + public function getUsersRated($dimension = null, $orderby = null) { - if (is_null($dimension)) $dimension = $this->dimension; + if (is_null($dimension)) { + $dimension = $this->dimension; + } //if (is_null($userid)) $userid = $this->userid; //if (is_null($pagename)) $pagename = $this->pagename; if (RATING_STORAGE == 'SQL') { @@ -164,8 +177,9 @@ $ratings_iter = $this->sql_get_users_rated($dimension, $orderby); if ($rating = $ratings_iter->next() and isset($rating['ratingvalue'])) { return $rating['ratingvalue']; - } else + } else { return false; + } } else { return $this->metadata_get_users_rated($dimension, $orderby); } @@ -210,15 +224,21 @@ * * @return DB iterator with results */ - function get_rating($dimension = null, $rater = null, $ratee = null, - $orderby = null, $pageinfo = "ratee") + public function get_rating( + $dimension = null, + $rater = null, + $ratee = null, + $orderby = null, + $pageinfo = "ratee" + ) { if (RATING_STORAGE == 'SQL') { $ratings_iter = $this->sql_get_rating($dimension, $rater, $pagename); if ($rating = $ratings_iter->next() and isset($rating['ratingvalue'])) { return $rating['ratingvalue']; - } else + } else { return false; + } } else { return $this->metadata_get_rating($rater, $pagename, $dimension); } @@ -227,7 +247,7 @@ /* UR: What is this for? NOT USED! Maybe the list of users (ratees) who rated on this page. */ - function get_users_rated($dimension = null, $pagename = null, $orderby = null) + public function get_users_rated($dimension = null, $pagename = null, $orderby = null) { if (RATING_STORAGE == 'SQL') { $ratings_iter = $this->sql_get_users_rated($dimension, $pagename, $orderby); @@ -246,8 +266,13 @@ * Like get_rating(), but return a WikiDB_PageIterator * FIXME! */ - function get_rating_page($dimension = null, $rater = null, $ratee = null, - $orderby = null, $pageinfo = "ratee") + public function get_rating_page( + $dimension = null, + $rater = null, + $ratee = null, + $orderby = null, + $pageinfo = "ratee" + ) { if (RATING_STORAGE == 'SQL') { return $this->sql_get_rating($dimension, $rater, $ratee, $orderby, $pageinfo); @@ -303,7 +328,7 @@ //function getUsersRated(){} -//******************************************************************************* + //******************************************************************************* // TODO: // Use wikilens/RatingsUser.php for the php methods. // @@ -314,29 +339,38 @@ // Note that "suggest" is only free for non-profit organizations. // I am currently writing a binary CGI mysuggest using suggest, which loads // data from mysql. - function getPrediction($userid = null, $pagename = null, $dimension = null) + public function getPrediction($userid = null, $pagename = null, $dimension = null) { - if (is_null($dimension)) $dimension = $this->dimension; - if (is_null($userid)) $userid = $this->userid; - if (is_null($pagename)) $pagename = $this->pagename; + if (is_null($dimension)) { + $dimension = $this->dimension; + } + if (is_null($userid)) { + $userid = $this->userid; + } + if (is_null($pagename)) { + $pagename = $this->pagename; + } if (RATING_STORAGE == 'SQL') { $dbh = &$this->_sqlbackend; - if (isset($pagename)) + if (isset($pagename)) { $page = $dbh->_get_pageid($pagename); - else + } else { return 0; - if (isset($userid)) + } + if (isset($userid)) { $user = $dbh->_get_pageid($userid); - else + } else { return 0; + } } if (defined('RATING_EXTERNAL') and RATING_EXTERNAL) { // how call mysuggest.exe? as CGI or natively //$rating = HTML::raw("<!--#include virtual=".RATING_ENGINE." -->"); $args = "-u$user -p$page -malpha"; // --top 10 - if (isset($dimension)) + if (isset($dimension)) { $args .= " -d$dimension"; + } $rating = passthru(RATING_EXTERNAL . " $args"); } else { $rating = $this->php_prediction($userid, $pagename, $dimension); @@ -349,7 +383,7 @@ * Only the SUGGEST_EstimateAlpha part * Take wikilens/RatingsUser.php for the php methods. */ - function php_prediction($userid = null, $pagename = null, $dimension = null) + public function php_prediction($userid = null, $pagename = null, $dimension = null) { /** * @var WikiRequest $request @@ -356,9 +390,15 @@ */ global $request; - if (is_null($dimension)) $dimension = $this->dimension; - if (is_null($userid)) $userid = $this->userid; - if (is_null($pagename)) $pagename = $this->pagename; + if (is_null($dimension)) { + $dimension = $this->dimension; + } + if (is_null($userid)) { + $userid = $this->userid; + } + if (is_null($pagename)) { + $pagename = $this->pagename; + } if (empty($this->buddies)) { require_once 'lib/wikilens/RatingsUser.php'; require_once 'lib/wikilens/Buddy.php'; @@ -368,29 +408,45 @@ return $user->knn_uu_predict($pagename, $this->buddies, $dimension); } - function getNumUsers($pagename = null, $dimension = null) + public function getNumUsers($pagename = null, $dimension = null) { - if (is_null($dimension)) $dimension = $this->dimension; - if (is_null($pagename)) $pagename = $this->pagename; + if (is_null($dimension)) { + $dimension = $this->dimension; + } + if (is_null($pagename)) { + $pagename = $this->pagename; + } if (RATING_STORAGE == 'SQL') { - $ratings_iter = $this->sql_get_rating($dimension, null, $pagename, - null, "ratee"); + $ratings_iter = $this->sql_get_rating( + $dimension, + null, + $pagename, + null, + "ratee" + ); return $ratings_iter->count(); } else { - if (!$pagename) return 0; + if (!$pagename) { + return 0; + } $page = $this->_dbi->getPage($pagename); $data = $page->get('rating'); - if (!empty($data[$dimension])) + if (!empty($data[$dimension])) { return count($data[$dimension]); - else + } else { return 0; + } } } - function getAvg($pagename = null, $dimension = null) + public function getAvg($pagename = null, $dimension = null) { - if (is_null($dimension)) $dimension = $this->dimension; - if (is_null($pagename)) $pagename = $this->pagename; + if (is_null($dimension)) { + $dimension = $this->dimension; + } + if (is_null($pagename)) { + $pagename = $this->pagename; + } if (RATING_STORAGE == 'SQL') { $dbi = &$this->_sqlbackend; if (isset($pagename) || isset($dimension)) { @@ -406,7 +462,9 @@ } } if (isset($dimension)) { - if (isset($pagename)) $where .= " AND"; + if (isset($pagename)) { + $where .= " AND"; + } $where .= " dimension=$dimension"; } extract($dbi->_table_names); @@ -420,19 +478,21 @@ $row = $iter->next(); return is_array($row) ? $row['avg'] : 0; } else { - if (!$pagename) + if (!$pagename) { return 0; + } $page = $this->_dbi->getPage($pagename); $data = $page->get('rating'); - if (!empty($data[$dimension])) + if (!empty($data[$dimension])) { // hash of userid => rating return array_sum(array_values($data[$dimension])) / count($data[$dimension]); - else + } else { return 0; + } } } -//******************************************************************************* + //******************************************************************************* /** * Get ratings. @@ -474,25 +534,36 @@ * * @return DB iterator with results */ - function sql_get_rating($dimension = null, $rater = null, $ratee = null, - $orderby = null, $pageinfo = "ratee") + public function sql_get_rating( + $dimension = null, + $rater = null, + $ratee = null, + $orderby = null, + $pageinfo = "ratee" + ) { - if (is_null($dimension)) $dimension = $this->dimension; + if (is_null($dimension)) { + $dimension = $this->dimension; + } $result = $this->_sql_get_rating_result($dimension, $rater, $ratee, $orderby, $pageinfo); return new $this->iter_class($this, $result); } - function sql_get_users_rated($dimension = null, $pagename = null, $orderby = null) + public function sql_get_users_rated($dimension = null, $pagename = null, $orderby = null) { - if (is_null($dimension)) $dimension = $this->dimension; + if (is_null($dimension)) { + $dimension = $this->dimension; + } $result = $this->_sql_get_rating_result($dimension, null, $pagename, $orderby, "rater"); return new $this->iter_class($this, $result); } // all users who rated this page resp if null all pages.. needed? - function metadata_get_users_rated($dimension = null, $pagename = null, $orderby = null) + public function metadata_get_users_rated($dimension = null, $pagename = null, $orderby = null) { - if (is_null($dimension)) $dimension = $this->dimension; + if (is_null($dimension)) { + $dimension = $this->dimension; + } $users = array(); if (!$pagename) { // TODO: all pages? @@ -510,15 +581,22 @@ /** * @return result ressource, suitable to the iterator */ - private function _sql_get_rating_result($dimension = null, $rater = null, $ratee = null, - $orderby = null, $pageinfo = "ratee") + private function _sql_get_rating_result( + $dimension = null, + $rater = null, + $ratee = null, + $orderby = null, + $pageinfo = "ratee" + ) { // pageinfo must be 'rater' or 'ratee' - if (($pageinfo != "ratee") && ($pageinfo != "rater")) + if (($pageinfo != "ratee") && ($pageinfo != "rater")) { return; + } $dbi = &$this->_sqlbackend; - if (is_null($dbi)) + if (is_null($dbi)) { return; + } //$dbh = &$this->_dbi; extract($dbi->_table_names); $where = "WHERE r." . $pageinfo . "page = p.id"; @@ -549,12 +627,15 @@ if (isset($orderby)) { $orderbyStr = " ORDER BY " . $orderby; } - if (isset($rater) or isset($ratee)) $what = '*'; + if (isset($rater) or isset($ratee)) { + $what = '*'; + } // same as _get_users_rated_result() else { $what = 'DISTINCT p.pagename'; - if ($pageinfo == 'rater') + if ($pageinfo == 'rater') { $what = 'DISTINCT p.pagename as userid'; + } } $query = "SELECT $what" @@ -609,8 +690,9 @@ { $dbi = &$this->_sqlbackend; extract($dbi->_table_names); - if (empty($rating_tbl)) + if (empty($rating_tbl)) { $rating_tbl = $this->_dbi->getParam('prefix') . 'rating'; + } $dbi->lock(); $raterid = $dbi->_get_pageid($rater, true); @@ -628,31 +710,36 @@ return true; } - function metadata_get_rating($userid, $pagename, $dimension) + public function metadata_get_rating($userid, $pagename, $dimension) { - if (!$pagename) return false; + if (!$pagename) { + return false; + } $page = $this->_dbi->getPage($pagename); $data = $page->get('rating'); - if (!empty($data[$dimension][$userid])) + if (!empty($data[$dimension][$userid])) { return (float)$data[$dimension][$userid]; - else + } else { return false; + } } - function metadata_set_rating($userid, $pagename, $dimension, $rating = -1) + public function metadata_set_rating($userid, $pagename, $dimension, $rating = -1) { - if (!$pagename) return; + if (!$pagename) { + return; + } $page = $this->_dbi->getPage($pagename); $data = $page->get('rating'); - if ($rating == -1) + if ($rating == -1) { unset($data[$dimension][$userid]); - else { - if (empty($data[$dimension])) + } else { + if (empty($data[$dimension])) { $data[$dimension] = array($userid => (float)$rating); - else + } else { $data[$dimension][$userid] = (float)$rating; + } } $page->set('rating', $data); } - } Modified: trunk/lib/wikilens/RatingsUser.php =================================================================== --- trunk/lib/wikilens/RatingsUser.php 2022-03-24 13:44:55 UTC (rev 11012) +++ trunk/lib/wikilens/RatingsUser.php 2022-03-24 13:48:01 UTC (rev 11013) @@ -31,7 +31,7 @@ class RatingsUserFactory { - static function & getUser($userid) + public static function & getUser($userid) { //print "getUser($userid) "; global $_ratingsUserCache; @@ -60,7 +60,7 @@ public $_mean_ratings; public $_pearson_sims; - function __construct($userid) + public function __construct($userid) { $this->_userid = $userid; $this->_ratings_loaded = false; @@ -70,18 +70,19 @@ $this->_pearson_sims = array(); } - function getId() + public function getId() { return $this->_userid; } - function & _get_rating_dbi() + public 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)) + if (isset($this->_rdbi)) { return $this->_rdbi; + } $this->_rdbi = RatingsDb::getTheRatingsDb(); return $this->_rdbi; } @@ -95,7 +96,7 @@ * * @return bool True if $user can view this user's ratings, false otherwise */ - function allow_view_ratings($user) + public function allow_view_ratings($user) { return true; } @@ -105,7 +106,7 @@ * * @return array Assoc. array [page_name][dimension] = _UserRating object */ - function get_ratings() + public function get_ratings() { $this->_load_ratings(); return $this->_ratings; @@ -116,7 +117,7 @@ * * @return float Mean rating */ - function mean_rating($dimension = 0) + public function mean_rating($dimension = 0) { // use memoized result if available if (isset($this->_mean_ratings[$dimension])) { @@ -147,7 +148,7 @@ // ephemeral and doesn't particularly care about the ratings count or any // other features that these methods might provide down the road) - function has_rated($pagename, $dimension = null) + public function has_rated($pagename, $dimension = null) { // XXX: does this really want to do a full ratings load? (scalability?) $this->_load_ratings(); @@ -163,12 +164,12 @@ return false; } - function get_rating($pagename, $dimension = 0) + public function get_rating($pagename, $dimension = 0) { // XXX: does this really want to do a full ratings load? (scalability?) - if (RATING_STORAGE == 'SQL') + if (RATING_STORAGE == 'SQL') { $this->_load_ratings(); - else { + } else { $rdbi = $this->_get_rating_dbi(); return $rdbi->metadata_get_rating($this->getId(), $pagename, $dimension); } @@ -179,7 +180,7 @@ return false; } - function set_rating($pagename, $dimension, $rating) + public function set_rating($pagename, $dimension, $rating) { // XXX: does this really want to do a full ratings load? (scalability?) $this->_load_ratings(); @@ -199,7 +200,7 @@ } } - function unset_rating($pagename, $dimension) + public function unset_rating($pagename, $dimension) { // XXX: does this really want to do a full ratings load? (scalability?) $this->_load_ratings(); @@ -215,7 +216,7 @@ } } - function pearson_similarity($user, $dimension = 0) + public function pearson_similarity($user, $dimension = 0) { // use memoized result if available if (isset($this->_pearson_sims[$user->getId()][$dimension])) { @@ -264,11 +265,12 @@ // items that the similarity was based on // prevent division-by-zero - if (sqrt($sum11) == 0 || sqrt($sum12) == 0) + if (sqrt($sum11) == 0 || sqrt($sum12) == 0) { $sim = array(0, $n); - else + } else { // Pearson similarity $sim = array($sum12 / (sqrt($sum11) * sqrt($sum22)), $n); + } // print "sim is " . $sim[0] . "<BR><BR>"; @@ -277,7 +279,7 @@ return $this->_pearson_sims[$user->getId()][$dimension] = $sim; } - function knn_uu_predict($pagename, &$neighbors, $dimension = 0) + public function knn_uu_predict($pagename, &$neighbors, $dimension = 0) { /* print "<PRE>"; @@ -298,8 +300,9 @@ $nbor =& $neighbors[$i]; // ignore self-neighbor - if ($this->getId() == $nbor->getId()) + if ($this->getId() == $nbor->getId()) { continue; + } if ($nbor->has_rated($pagename, $dimension)) { list($sim, $n_items) = $this->pearson_similarity($nbor); @@ -307,8 +310,9 @@ // XXX: no filtering done... small-world = too few neighbors if (1 || ($sim > 0 && abs($sim) >= 0.1)) { // n/50 sig weighting - if ($n_items < 50) + if ($n_items < 50) { $sim *= $n_items / 50; + } /* print "neighbor is " . $nbor->getId() . "<BR>"; print "weighted sim is " . $sim . "<BR>"; @@ -330,7 +334,7 @@ return ($total_sim == 0 ? 0 : ($total / $total_sim + $my_mean)); } - function _load_ratings($force = false) + public function _load_ratings($force = false) { if (!$this->_ratings_loaded || $force) { // print "load " . $this->getId() . "<BR>"; @@ -352,10 +356,12 @@ } $this->_num_ratings++; $this->_ratings[$rating['pagename']][$rating['dimension']] - = new _UserRating($this->_userid, - $rating['pagename'], - $rating['dimension'], - $rating['ratingvalue']); + = new _UserRating( + $this->_userid, + $rating['pagename'], + $rating['dimension'], + $rating['ratingvalue'] + ); } $this->_ratings_loaded = true; @@ -366,7 +372,7 @@ /** Represent a rating. */ class _UserRating { - function __construct($rater, $ratee, $dimension, $rating) + public function __construct($rater, $ratee, $dimension, $rating) { $this->rater = (string)$rater; $this->ratee = (string)$ratee; @@ -374,42 +380,42 @@ $this->rating = (float)$rating; } - function get_rater() + public function get_rater() { return $this->rater; } - function get_ratee() + public function get_ratee() { return $this->ratee; } - function get_rating() + public function get_rating() { return $this->rating; } - function get_dimension() + public function get_dimension() { return $this->dimension; } - function set_rater() + public function set_rater() { $this->rater = (string)$rater; } - function set_ratee() + public function set_ratee() { $this->ratee = (string)$ratee; } - function set_rating() + public function set_rating() { $this->rating = (float)$rating; } - function set_dimension() + public function set_dimension() { $this->dimension = (int)$dimension; } Modified: trunk/lib/wikilens/Utils.php =================================================================== --- trunk/lib/wikilens/Utils.php 2022-03-24 13:44:55 UTC (rev 11012) +++ trunk/lib/wikilens/Utils.php 2022-03-24 13:48:01 UTC (rev 11013) @@ -43,8 +43,11 @@ // add new data to the appropriate line if (preg_match('/^' . preg_quote($START_DELIM, '/') . '/', $text)) { // need multiline modifier to match EOL correctly - $text = preg_replace('/(^' . preg_quote($START_DELIM, '/') . '.*)$/m', - '$1' . $DELIM . $new_data, $text); + $text = preg_replace( + '/(^' . preg_quote($START_DELIM, '/') . '.*)$/m', + '$1' . $DELIM . $new_data, + $text + ); } else { // handle case where the line does not yet exist $text .= "\n" . $START_DELIM . $new_data . "\n"; @@ -56,16 +59,20 @@ function getMembers($groupName, $dbi, $START_DELIM = false, $DELIM = ",") { - if (!$START_DELIM) $START_DELIM = _("Members:"); + if (!$START_DELIM) { + $START_DELIM = _("Members:"); + } return getPageTextData($groupName, $dbi, $START_DELIM, $DELIM); } function getPageTextData($fromUser, $dbi, $START_DELIM, $DELIM) { - if (is_object($fromUser)) + if (is_object($fromUser)) { $fromUser = $fromUser->getId(); - if ($fromUser == "") + } + if ($fromUser == "") { return ""; + } $userPage = $dbi->getPage($fromUser); $transformed = $userPage->getCurrentRevision(); $pageArray = $transformed->getContent(); @@ -72,7 +79,7 @@ $p = -1; for ($i = 0; $i < count($pageArray); $i++) { if ($pageArray[$i] != "") { - if (!((strpos($pageArray[$i], $START_DELIM)) === FALSE)) { + if (!((strpos($pageArray[$i], $START_DELIM)) === false)) { $p = $i; break; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2023-07-14 10:33:07
|
Revision: 11051 http://sourceforge.net/p/phpwiki/code/11051 Author: vargenau Date: 2023-07-14 10:33:04 +0000 (Fri, 14 Jul 2023) Log Message: ----------- lib/wikilens: PHP 7: add types for function arguments and return Modified Paths: -------------- trunk/lib/wikilens/Buddy.php trunk/lib/wikilens/CustomPrefs.php trunk/lib/wikilens/PageListColumns.php trunk/lib/wikilens/RatingsDb.php trunk/lib/wikilens/RatingsUser.php trunk/lib/wikilens/Utils.php Modified: trunk/lib/wikilens/Buddy.php =================================================================== --- trunk/lib/wikilens/Buddy.php 2023-07-14 10:03:49 UTC (rev 11050) +++ trunk/lib/wikilens/Buddy.php 2023-07-14 10:33:04 UTC (rev 11051) @@ -48,7 +48,7 @@ addPageTextData($user, $dbi, $buddy, $START_DELIM, $DELIM); } -function getBuddies($fromUser, $dbi, $thePage = "") +function getBuddies($fromUser, $dbi, $thePage = ""): array { $START_DELIM = $thePage . _("Buddies:"); $DELIM = ","; @@ -88,7 +88,7 @@ return $result; } -function CoAgreement($dbi, $page, $users, $active_userid) +function CoAgreement($dbi, $page, $users, $active_userid): int { //Returns a "yes" 1, "no" -1, or "unsure" 0 for whether //the group agrees on the page based on their ratings Modified: trunk/lib/wikilens/CustomPrefs.php =================================================================== --- trunk/lib/wikilens/CustomPrefs.php 2023-07-14 10:03:49 UTC (rev 11050) +++ trunk/lib/wikilens/CustomPrefs.php 2023-07-14 10:33:04 UTC (rev 11051) @@ -35,7 +35,7 @@ class _UserPreference_recengine // recommendation engine method extends _UserPreference { - public $valid_values = array('php', 'mysuggest', 'mymovielens', 'mycluto'); + public array $valid_values = array('php', 'mysuggest', 'mymovielens', 'mycluto'); public $default_value = 'php'; public function sanify($value) @@ -51,7 +51,7 @@ class _UserPreference_recalgo // recommendation engine algorithm extends _UserPreference { - public $valid_values = array( + public array $valid_values = array( 'itemCos', // Item-based Top-N recommendation algorithm with cosine-based similarity function 'itemProb', // Item-based Top-N recommendation algorithm with probability-based similarity function. // This algorithms tends to outperform the rest. Modified: trunk/lib/wikilens/PageListColumns.php =================================================================== --- trunk/lib/wikilens/PageListColumns.php 2023-07-14 10:03:49 UTC (rev 11050) +++ trunk/lib/wikilens/PageListColumns.php 2023-07-14 10:33:04 UTC (rev 11051) @@ -206,7 +206,7 @@ return ($rating ? $rating : "-"); } - public function hasNoRatings($pages) + public function hasNoRatings($pages): bool { $total = 0; $use = & $this->_user; @@ -346,7 +346,7 @@ class _PageList_Column_top3recs extends _PageList_Column_custom { - public $_active_ratings_user; + public RatingsUser $_active_ratings_user; public $_users; public function __construct($params) Modified: trunk/lib/wikilens/RatingsDb.php =================================================================== --- trunk/lib/wikilens/RatingsDb.php 2023-07-14 10:03:49 UTC (rev 11050) +++ trunk/lib/wikilens/RatingsDb.php 2023-07-14 10:33:04 UTC (rev 11051) @@ -293,7 +293,7 @@ * * @return true upon success */ - public function delete_rating($rater, $ratee, $dimension) + public function delete_rating($rater, $ratee, $dimension): bool { if (RATING_STORAGE == 'SQL') { $this->sql_delete_rating($rater, $ratee, $dimension); @@ -314,7 +314,7 @@ * * @return true upon success */ - public function rate($rater, $ratee, $rateeversion, $dimension, $rating) + public function rate($rater, $ratee, $rateeversion, $dimension, $rating): bool { if (RATING_STORAGE == 'SQL') { $page = $this->_dbi->getPage($pagename); @@ -539,7 +539,7 @@ $rater = null, $ratee = null, $orderby = null, - $pageinfo = "ratee" + string $pageinfo = "ratee" ) { if (is_null($dimension)) { @@ -656,7 +656,7 @@ * * @return true upon success */ - public function sql_delete_rating($rater, $ratee, $dimension) + public function sql_delete_rating($rater, $ratee, $dimension): bool { //$dbh = &$this->_dbi; $dbi = &$this->_sqlbackend; @@ -686,7 +686,7 @@ * * @return true upon success */ - public function sql_rate($rater, $ratee, $rateeversion, $dimension, $rating) + public function sql_rate($rater, $ratee, $rateeversion, $dimension, $rating): bool { $dbi = &$this->_sqlbackend; extract($dbi->_table_names); Modified: trunk/lib/wikilens/RatingsUser.php =================================================================== --- trunk/lib/wikilens/RatingsUser.php 2023-07-14 10:03:49 UTC (rev 11050) +++ trunk/lib/wikilens/RatingsUser.php 2023-07-14 10:33:04 UTC (rev 11051) @@ -54,11 +54,11 @@ class RatingsUser { public $_userid; - public $_ratings_loaded; - public $_ratings; - public $_num_ratings; - public $_mean_ratings; - public $_pearson_sims; + public bool $_ratings_loaded; + public array $_ratings; + public int $_num_ratings; + public array $_mean_ratings; + public array $_pearson_sims; public function __construct($userid) { @@ -96,7 +96,7 @@ * * @return bool True if $user can view this user's ratings, false otherwise */ - public function allow_view_ratings($user) + public function allow_view_ratings($user): bool { return true; } @@ -106,7 +106,7 @@ * * @return array Assoc. array [page_name][dimension] = _UserRating object */ - public function get_ratings() + public function get_ratings(): array { $this->_load_ratings(); return $this->_ratings; @@ -148,7 +148,7 @@ // ephemeral and doesn't particularly care about the ratings count or any // other features that these methods might provide down the road) - public function has_rated($pagename, $dimension = null) + public function has_rated($pagename, $dimension = null): bool { // XXX: does this really want to do a full ratings load? (scalability?) $this->_load_ratings(); @@ -380,22 +380,22 @@ $this->rating = (float)$rating; } - public function get_rater() + public function get_rater(): string { return $this->rater; } - public function get_ratee() + public function get_ratee(): string { return $this->ratee; } - public function get_rating() + public function get_rating(): float { return $this->rating; } - public function get_dimension() + public function get_dimension(): int { return $this->dimension; } Modified: trunk/lib/wikilens/Utils.php =================================================================== --- trunk/lib/wikilens/Utils.php 2023-07-14 10:03:49 UTC (rev 11050) +++ trunk/lib/wikilens/Utils.php 2023-07-14 10:33:04 UTC (rev 11051) @@ -101,7 +101,7 @@ return $retArray; } -function notEmptyName($var) +function notEmptyName($var): bool { return $var != ""; } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |
From: <var...@us...> - 2016-10-06 17:07:24
|
Revision: 9940 http://sourceforge.net/p/phpwiki/code/9940 Author: vargenau Date: 2016-10-06 17:07:22 +0000 (Thu, 06 Oct 2016) Log Message: ----------- Add standard file header Modified Paths: -------------- trunk/lib/wikilens/Buddy.php trunk/lib/wikilens/CustomPrefs.php trunk/lib/wikilens/RatingsDb.php Modified: trunk/lib/wikilens/Buddy.php =================================================================== --- trunk/lib/wikilens/Buddy.php 2016-10-06 17:06:42 UTC (rev 9939) +++ trunk/lib/wikilens/Buddy.php 2016-10-06 17:07:22 UTC (rev 9940) @@ -1,4 +1,26 @@ <?php +/** + * Copyright © 2004-2010 $ThePhpWikiProgrammingTeam + * + * This file is part of PhpWiki. + * + * PhpWiki is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PhpWiki is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with PhpWiki; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * SPDX-License-Identifier: GPL-2.0+ + * + */ // It is anticipated that when userid support is added to phpwiki, // this object will hold much more information (e-mail, Modified: trunk/lib/wikilens/CustomPrefs.php =================================================================== --- trunk/lib/wikilens/CustomPrefs.php 2016-10-06 17:06:42 UTC (rev 9939) +++ trunk/lib/wikilens/CustomPrefs.php 2016-10-06 17:07:22 UTC (rev 9940) @@ -1,4 +1,26 @@ <?php +/** + * Copyright © 2004 Reini Urban + * + * This file is part of PhpWiki. + * + * PhpWiki is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PhpWiki is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with PhpWiki; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * SPDX-License-Identifier: GPL-2.0+ + * + */ /** * Custom UserPreferences: Modified: trunk/lib/wikilens/RatingsDb.php =================================================================== --- trunk/lib/wikilens/RatingsDb.php 2016-10-06 17:06:42 UTC (rev 9939) +++ trunk/lib/wikilens/RatingsDb.php 2016-10-06 17:07:22 UTC (rev 9940) @@ -1,4 +1,27 @@ <?php +/** + * Copyright © 2004,2007 Reini Urban + * Copyright © 2010 $ThePhpWikiProgrammingTeam + * + * This file is part of PhpWiki. + * + * PhpWiki is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * PhpWiki is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with PhpWiki; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + * + * SPDX-License-Identifier: GPL-2.0+ + * + */ /* * @author: Dan Frankowski (wikilens group manager), Reini Urban (as plugin) @@ -9,6 +32,7 @@ * - finish mysuggest.c (external engine with data from mysql) * - add the various show modes (esp. TopN queries in PHP) */ + /* CREATE TABLE rating ( dimension INT(4) NOT NULL, This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |