Changeset 1080
- Timestamp:
- 08/28/06 00:40:29 (5 years ago)
- Location:
- trunk/wifidog-auth
- Files:
-
- 2 added
- 9 modified
-
CHANGELOG (modified) (1 diff)
-
wifidog/classes/Content.php (modified) (9 diffs)
-
wifidog/classes/Content/FlickrPhotostream/FlickrPhotostream.php (modified) (1 diff)
-
wifidog/classes/Content/HTMLeditor/HTMLeditor.php (modified) (4 diffs)
-
wifidog/classes/Content/Langstring/Langstring.php (modified) (3 diffs)
-
wifidog/classes/Content/Picture/Picture.php (modified) (1 diff)
-
wifidog/classes/Content/RssAggregator/RssAggregator.php (modified) (52 diffs)
-
wifidog/classes/HyperLink.php (added)
-
wifidog/clickthrough.php (added)
-
wifidog/include/schema_validate.php (modified) (2 diffs)
-
wifidog/lib/RssPressReview/RssPressReview.php (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog-auth/CHANGELOG
r1079 r1080 1 2006-08-27 Benoit Grégoire <bock@step.polymtl.ca> 2 * clickthrough.php, HyperLink.php: Implement working hyperlink clickthrough tracking (no reporting yet). 3 Works for Langstring, FlickrPhotoStream, Picture, RssAggregator and their subclasses. 4 * Make HTMLeditor inherit from Langstring. Allowed a massive reduction of line count and will stop the codebases from needlessly drifting apart. 5 * Do not log content displayed as metadata, and log their clickthrough as the parent's. 6 1 7 2006-08-27 François Proulx <francois.proulx@gmail.com> 2 8 * Updated French translations -
trunk/wifidog-auth/wifidog/classes/Content.php
r1074 r1080 50 50 require_once ('classes/GenericObject.php'); 51 51 require_once ('classes/Cache.php'); 52 52 require_once ('classes/HyperLink.php'); 53 53 /** 54 54 * Defines any type of content … … 104 104 */ 105 105 private $is_logging_enabled; 106 107 /** Log as part of this other content */ 108 private $log_as_content; 106 109 107 110 /** … … 136 139 // By default content display logging is enabled 137 140 $this->setLoggingStatus(true); 141 $this->log_as_content &= $this; 138 142 } 139 143 … … 1039 1043 $html .= "<div class='user_ui_title'>\n"; 1040 1044 $title = self :: getObject($this->content_row['title']); 1045 $title->setLogAsContent($this); 1041 1046 // If the content logging is disabled, all the children will inherit this property temporarly 1042 1047 if ($this->getLoggingStatus() == false) … … 1063 1068 $html .= "<div class='user_ui_description'>\n"; 1064 1069 $description = self :: getObject($this->content_row['description']); 1070 $description->setLogAsContent($this); 1065 1071 // If the content logging is disabled, all the children will inherit this property temporarly 1066 1072 if ($this->getLoggingStatus() == false) … … 1075 1081 $html .= "<b>"._("Project information:")."</b>"; 1076 1082 $project_info = self :: getObject($this->content_row['project_info']); 1083 $project_info->setLogAsContent($this); 1077 1084 // If the content logging is disabled, all the children will inherit this property temporarly 1078 1085 if ($this->getLoggingStatus() == false) … … 1086 1093 $html .= "<b>"._("Project sponsor:")."</b>"; 1087 1094 $sponsor_info = self :: getObject($this->content_row['sponsor_info']); 1095 $sponsor_info->setLogAsContent($this); 1088 1096 // If the content logging is disabled, all the children will inherit this property temporarly 1089 1097 if ($this->getLoggingStatus() == false) … … 1103 1111 } 1104 1112 1113 1114 /** Allow logging as part of another content (usually the parent for metadata). 1115 * Redirects clickthrough logging to the parent's content id, and does not log 1116 * display */ 1117 protected function setLogAsContent(Content $content) 1118 { 1119 $this->log_as_content = $content; 1120 } 1121 1105 1122 /** Log that this content has just been displayed to the user. Will only log if the user is logged in */ 1106 1123 private function logContentDisplay() { 1107 if ($this->getLoggingStatus() == true ) {1124 if ($this->getLoggingStatus() == true && $this->log_as_content->getId()==$this->getId()) { 1108 1125 // DEBUG:: 1109 1126 //echo "Logging ".get_class($this)." :: ".$this->__toString()."<br>"; … … 1125 1142 } 1126 1143 } 1144 } 1145 /** Handle replacements of hyperlinks for clickthrough tracking (if appropriate) */ 1146 protected function replaceHyperLinks(&$html) { 1147 /* Handle hyperlink clicktrough logging */ 1148 if ($this->getLoggingStatus() == true) { 1149 $html = HyperLink :: replaceHyperLinks($html, $this->log_as_content); 1150 } 1151 return $html; 1127 1152 } 1128 1153 -
trunk/wifidog-auth/wifidog/classes/Content/FlickrPhotostream/FlickrPhotostream.php
r1074 r1080 876 876 $html .= $subclass_user_interface; 877 877 $html .= "</div>\n"; 878 878 /* Handle hyperlink clicktrough logging */ 879 $html = $this->replaceHyperLinks($html); 879 880 return parent::getUserUI($html); 880 881 } -
trunk/wifidog-auth/wifidog/classes/Content/HTMLeditor/HTMLeditor.php
r1070 r1080 47 47 * Load required classes 48 48 */ 49 require_once('classes/Cache.php'); 50 require_once('classes/HtmlSafe.php'); 51 require_once('classes/LocaleList.php'); 49 require_once('classes/Content/Langstring/Langstring.php'); 52 50 53 51 /** … … 59 57 * @copyright 2005-2006 Max Horvath, maxspot GmbH 60 58 */ 61 class HTMLeditor extends Content59 class HTMLeditor extends Langstring 62 60 { 63 61 … … 100 98 $this->_FCKeditorAvailable = true; 101 99 } 102 }103 104 /**105 * Return string in the language requested by the user.106 *107 * @return string UTF-8 string of content.108 *109 * @access private110 */111 private function getString()112 {113 // Init values114 $_retval = null;115 $_row = null;116 $_useCache = false;117 $_cachedData = null;118 119 // Create new cache objects120 $_cacheLanguage = new Cache('langstrings_' . $this->id . '_substring_' . substr(Locale::getCurrentLocale()->getId(), 0, 2) . '_string', $this->id);121 $_cache = new Cache('langstrings_' . $this->id . '_substring__string', $this->id);122 123 // Check if caching has been enabled.124 if ($_cacheLanguage->isCachingEnabled) {125 $_cachedData = $_cacheLanguage->getCachedData();126 127 if ($_cachedData) {128 // Return cached data.129 $_useCache = true;130 $_retval = $_cachedData;131 } else {132 // Language specific cached data has not been found.133 // Try to get language independent cached data.134 $_cachedData = $_cache->getCachedData();135 136 if ($_cachedData) {137 // Return cached data.138 $_useCache = true;139 $_retval = $_cachedData;140 }141 }142 }143 144 if (!$_useCache) {145 // Get string in the prefered language of the user146 $_sql = "SELECT value, locales_id, \n";147 $_sql .= Locale::getSqlCaseStringSelect(Locale::getCurrentLocale()->getId());148 $_sql .= " as score FROM content_langstring_entries WHERE content_langstring_entries.langstrings_id = '{$this->id}' AND value!='' ORDER BY score LIMIT 1";149 $this->mBd->execSqlUniqueRes($_sql, $_row, false);150 151 if ($_row == null) {152 // String has not been found153 $_retval = "(Empty string)";154 } else {155 // String has been found156 $_retval = $_row['value'];157 158 // Check if caching has been enabled.159 if ($_cache->isCachingEnabled) {160 // Save data into cache, because it wasn't saved into cache before.161 $_cache->saveCachedData($_retval);162 }163 }164 }165 166 return $_retval;167 }168 169 /**170 * Adds the string associated with the locale.171 *172 * @param string $string String to be added173 * @param string $locale Locale of string (i.e. 'fr_CA') - can174 * be NULL175 * @param bool $allow_empty_string Defines if string may be empty176 *177 * @return bool True if string has been added, otherwise false.178 *179 * @access private180 */181 private function addString($string, $locale, $allow_empty_string = false)182 {183 // Init values184 $_retval = false;185 $_id = 'NULL';186 $_idSQL = $_id;187 188 if ($locale) {189 // Set locale of string190 $_language = new Locale($locale);191 192 $_id = $_language->GetId();193 $_idSQL = "'" . $_id . "'";194 }195 196 if ($allow_empty_string || ($string != null && $string != '')) {197 // Save string in database198 $string = $this->mBd->escapeString($string);199 $this->mBd->execSqlUpdate("INSERT INTO content_langstring_entries (langstring_entries_id, langstrings_id, locales_id, value) VALUES ('" . get_guid() . "', '$this->id', $_idSQL , '$string')", FALSE);200 201 // Create new cache object.202 $_cache = new Cache('langstrings_' . $this->id . '_substring_' . $_id . '_string', $this->id);203 204 // Check if caching has been enabled.205 if ($_cache->isCachingEnabled) {206 // Remove old cached data.207 $_cache->eraseCachedData();208 209 // Save data into cache.210 $_cache->saveCachedData($string);211 }212 213 $_retval = true;214 }215 216 return $_retval;217 }218 219 /**220 * Updates the string associated with the locale.221 *222 * @param string $string String to be updated.223 * @param string $locale Locale of string (i.e. 'fr_CA') - can be NULL.224 *225 * @return bool True if string has been updated, otherwise false.226 *227 * @access private228 */229 private function UpdateString($string, $locale)230 {231 // Init values232 $_retval = false;233 $_id = 'NULL';234 $_row = null;235 236 if ($locale) {237 // Set locale of string238 $_language = new Locale($locale);239 240 $_id = $_language->GetId();241 $_idSQL = "'" . $_id . "'";242 }243 244 if ($string != null && $string != '') {245 $string = $this->mBd->escapeString($string);246 247 // If the update returns 0 (no update), try inserting the record248 $this->mBd->execSqlUniqueRes("SELECT * FROM content_langstring_entries WHERE locales_id = $_idSQL AND langstrings_id = '$this->id'", $_row, false);249 250 if ($_row != null) {251 $this->mBd->execSqlUpdate("UPDATE content_langstring_entries SET value = '$string' WHERE langstrings_id = '$this->id' AND locales_id = $_idSQL", false);252 253 // Create new cache object.254 $_cache = new Cache('langstrings_' . $this->id . '_substring_' . $_id . '_string', $this->id);255 256 // Check if caching has been enabled.257 if ($_cache->isCachingEnabled) {258 // Remove old cached data.259 $_cache->eraseCachedData();260 261 // Save data into cache.262 $_cache->saveCachedData($string);263 }264 } else {265 $this->addString($string, $locale);266 }267 268 $_retval = true;269 }270 return $_retval;271 100 } 272 101 … … 394 223 // Check FCKeditor support 395 224 if ($this->_FCKeditorAvailable) { 396 // Init values 397 $_result = null; 398 399 if ($this->isOwner(User::getCurrentUser()) || User::getCurrentUser()->isSuperAdmin()) { 400 parent::processAdminUI(); 401 402 $_form_select = new FormSelectGenerator(); 403 404 $_sql = "SELECT * FROM content_langstring_entries WHERE content_langstring_entries.langstrings_id = '$this->id'"; 405 $this->mBd->execSql($_sql, $_result, FALSE); 406 407 if ($_result != null) { 408 while (list($_key, $_value) = each($_result)) { 409 $_language = $_form_select->getResult("langstrings_" . $this->id . "_substring_" . $_value["langstring_entries_id"] . "_language", 'Langstring::AfficherInterfaceAdmin'); 410 411 if (empty ($_language)) { 412 $_language = ''; 413 $_languageSQL = 'NULL'; 414 } else { 415 $_languageSQL = "'" . $_language . "'"; 416 } 417 418 if (!empty ($_REQUEST["langstrings_" . $this->id . "_substring_" . $_value["langstring_entries_id"] . "_erase"]) && $_REQUEST["langstrings_" . $this->id . "_substring_" . $_value["langstring_entries_id"] . "_erase"] == true) { 419 $this->mBd->execSqlUpdate("DELETE FROM content_langstring_entries WHERE langstrings_id = '$this->id' AND langstring_entries_id='" . $_value["langstring_entries_id"] . "'", FALSE); 420 421 // Create new cache object. 422 $_cache = new Cache('langstrings_' . $this->id . '_substring_' . $_language . '_string', $this->id); 423 424 // Check if caching has been enabled. 425 if ($_cache->isCachingEnabled) { 426 // Remove old cached data. 427 $_cache->eraseCachedData(); 428 } 429 } else { 430 // Strip HTML tags! 431 $string = $_REQUEST["langstrings_" . $this->id . "_substring_" . $_value["langstring_entries_id"] . "_string"]; 432 $string = $this->mBd->escapeString(strip_tags($string, self::ALLOWED_HTML_TAGS)); 433 434 // If PEAR::HTML_Safe is available strips down all potentially dangerous content 435 $_HtmlSafe = new HtmlSafe(); 436 437 if ($_HtmlSafe->isHtmlSafeEnabled) { 438 $string = $_HtmlSafe->parseHtml($string); 439 } 440 441 $this->mBd->execSqlUpdate("UPDATE content_langstring_entries SET locales_id = " . $_languageSQL . " , value = '$string' WHERE langstrings_id = '$this->id' AND langstring_entries_id='" . $_value["langstring_entries_id"] . "'", FALSE); 442 443 // Create new cache object. 444 $_cache = new Cache('langstrings_' . $this->id . '_substring_' . $_language . '_string', $this->id); 445 446 // Check if caching has been enabled. 447 if ($_cache->isCachingEnabled) { 448 // Remove old cached data. 449 $_cache->eraseCachedData(); 450 451 // Save data into cache. 452 $_cache->saveCachedData($string); 453 } 454 } 455 } 456 } 457 458 $_new_substring_name = "langstrings_" . $this->id . "_substring_new_string"; 459 $_new_substring_submit_name = "langstrings_" . $this->id . "_add_new_entry"; 460 if ((isset ($_REQUEST[$_new_substring_submit_name]) && $_REQUEST[$_new_substring_submit_name] == true) || !empty ($_REQUEST[$_new_substring_name])) { 461 $_language = $_form_select->getResult("langstrings_" . $this->id . "_substring_new_language", 'Langstring::AfficherInterfaceAdmin'); 462 463 if (empty($_language)) { 464 $_language = null; 465 } 466 467 $this->addString($_REQUEST[$_new_substring_name], $_language, true); 468 } 469 } 225 return parent::processAdminUI(); 470 226 } 471 227 } 472 473 /**474 * Retreives the user interface of this object. Anything that overrides475 * this method should call the parent method with it's output at the476 * END of processing.477 *478 * @param string $subclass_admin_interface HTML content of the interface479 * element of a children.480 *481 * @return string The HTML fragment for this interface.482 *483 * @access public484 */485 public function getUserUI($subclass_user_interface = null)486 {487 // Init values488 $_html = "";489 490 $_html .= "<div class='user_ui_container ".get_class($this)."'>\n";491 $_html .= "<div class='langstring'>\n";492 493 // Check FCKeditor support494 if ($this->_FCKeditorAvailable) {495 $_html .= $this->getString();496 } else {497 $_html .= _("FCKeditor is not installed");498 }499 500 $_html .= $subclass_user_interface;501 $_html .= "</div>\n";502 $_html .= "</div>\n";503 504 return parent::getUserUI($_html);505 }506 507 /**508 * Reloads the object from the database. Should normally be called after509 * a set operation. This function is private because calling it from a510 * subclass will call the constructor from the wrong scope.511 *512 * @return void513 *514 * @access private515 */516 private function refresh()517 {518 $this->__construct($this->id);519 }520 521 /**522 * Deletes a HTMLeditor object523 *524 * @param string $errmsg Reference to error message525 *526 * @return bool True if deletion was successful527 *528 * @access public529 * @internal Persistent content will not be deleted530 */531 public function delete(& $errmsg) {532 // Init values.533 $_retval = false;534 535 if ($this->isPersistent()) {536 $errmsg = _("Content is persistent (you must make it non persistent before you can delete it)");537 } else {538 global $db;539 540 if ($this->isOwner(User::getCurrentUser()) || User::getCurrentUser()->isSuperAdmin()) {541 $_sql = "DELETE FROM content WHERE content_id='$this->id'";542 $db->execSqlUpdate($_sql, false);543 $_retval = true;544 545 // Create new cache object.546 $_cache = new Cache('all', $this->id);547 548 // Check if caching has been enabled.549 if ($_cache->isCachingEnabled) {550 // Remove old cached data.551 $_cache->eraseCachedGroupData();552 }553 } else {554 $errmsg = _("Access denied (not owner of content)");555 }556 }557 558 return $_retval;559 }560 561 228 } 562 229 -
trunk/wifidog-auth/wifidog/classes/Content/Langstring/Langstring.php
r1070 r1080 105 105 // Check if caching has been enabled. 106 106 if ($_cacheLanguage->isCachingEnabled) { 107 if ($_cachedData = $_cacheLanguage->getCachedData()) { 107 $_cachedData = $_cacheLanguage->getCachedData(); 108 if ($_cachedData) { 108 109 // Return cached data. 109 110 $_useCache = true; … … 128 129 129 130 if ($row == null) { 130 $retval = "(Langstring vide)";131 $retval = sprintf(_("(Empty $s)"), get_class($this)); 131 132 } else { 132 133 $retval = $row['value']; … … 513 514 $html .= "</div>\n"; 514 515 $html .= "</div>\n"; 515 516 /* Handle hyperlink clicktrough logging */ 517 $html = $this->replaceHyperLinks($html); 516 518 return parent::getUserUI($html); 517 519 } -
trunk/wifidog-auth/wifidog/classes/Content/Picture/Picture.php
r1074 r1080 342 342 343 343 $html .= "</div>\n"; 344 344 /* Handle hyperlink clicktrough logging */ 345 $html = $this->replaceHyperLinks($html); 345 346 return $html; 346 347 } -
trunk/wifidog-auth/wifidog/classes/Content/RssAggregator/RssAggregator.php
r1070 r1080 1 1 <?php 2 2 3 3 4 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ … … 46 47 * Load required class 47 48 */ 48 require_once ('classes/LocaleList.php');49 require_once ('classes/LocaleList.php'); 49 50 50 51 /** … … 61 62 * @copyright 2005-2006 Benoit Grégoire, Technologies Coeus inc. 62 63 */ 63 class RssAggregator extends Content 64 { 64 class RssAggregator extends Content { 65 65 /** 66 66 * @var string … … 90 90 * @access protected 91 91 */ 92 protected function __construct($content_id) 93 { 92 protected function __construct($content_id) { 94 93 // Define globals 95 94 global $db; … … 99 98 $content_rss_aggregator_rows = null; 100 99 101 parent ::__construct($content_id);100 parent :: __construct($content_id); 102 101 $content_id = $db->escapeString($content_id); 103 102 … … 110 109 $db->execSqlUniqueRes($sql, $row, false); 111 110 if ($row == null) { 112 throw new Exception(_("The RssAggregator content with the following id could not be found in the database: ") .$content_id);111 throw new Exception(_("The RssAggregator content with the following id could not be found in the database: ") . $content_id); 113 112 } 114 113 } … … 121 120 if ($content_rss_aggregator_rows != null) { 122 121 $this->content_rss_aggregator_feeds_rows = $content_rss_aggregator_rows; 123 } else { 122 } 123 else { 124 124 $this->content_rss_aggregator_feeds_rows = array (); 125 125 } 126 126 127 127 if (RSS_SUPPORT) { 128 require_once ('lib/RssPressReview/RssPressReview.php');128 require_once ('lib/RssPressReview/RssPressReview.php'); 129 129 130 130 $this->press_review = new RssPressReview(WIFIDOG_ABS_FILE_PATH . MAGPIE_REL_PATH, "UTF-8"); … … 138 138 // Update the stored feed title if it changed. 139 139 //This allows the system to know every feed's title without continuously looking them up 140 if(!empty($title) && $title!=$feed_row['title']) { 141 $title = $db->escapeString($title); 142 $url = $db->escapeString($feed_row['url']); 143 $db->execSqlUpdate("UPDATE content_rss_aggregator_feeds SET title = '$title' WHERE url='$url'", false); 144 $this->refresh(); 145 } 146 } 147 } else { 140 if (!empty ($title) && $title != $feed_row['title']) { 141 $title = $db->escapeString($title); 142 $url = $db->escapeString($feed_row['url']); 143 $db->execSqlUpdate("UPDATE content_rss_aggregator_feeds SET title = '$title' WHERE url='$url'", false); 144 $this->refresh(); 145 } 146 } 147 } 148 else { 148 149 $html = _("RSS support is disabled"); 149 150 } … … 159 160 * @access public 160 161 */ 161 public function getDisplayNumItems() 162 { 162 public function getDisplayNumItems() { 163 163 return $this->content_rss_aggregator_row['number_of_display_items']; 164 164 } … … 174 174 * @access public 175 175 */ 176 public function setDisplayNumItems($num_items, &$errormsg = null) 177 { 176 public function setDisplayNumItems($num_items, & $errormsg = null) { 178 177 // Init values 179 178 $retval = false; … … 190 189 191 190 $retval = true; 192 } elseif ($num_items < 1) { 191 } 192 elseif ($num_items < 1) { 193 193 $errormsg = _("You must display at least one element"); 194 194 195 195 $retval = false; 196 } else { 196 } 197 else { 197 198 /* 198 199 * Successfull, but nothing modified … … 212 213 * @access public 213 214 */ 214 public function getAlgorithmStrength() 215 { 215 public function getAlgorithmStrength() { 216 216 return $this->content_rss_aggregator_row['algorithm_strength']; 217 217 } … … 240 240 * @access public 241 241 */ 242 public function setAlgorithmStrength($strength, &$errormsg = null) 243 { 242 public function setAlgorithmStrength($strength, & $errormsg = null) { 244 243 // Init values 245 244 $retval = false; … … 256 255 257 256 $retval = true; 258 } else { 257 } 258 else { 259 259 /* 260 260 * Successfull, but nothing modified … … 272 272 * @access public 273 273 */ 274 public function getMaxItemAge() 275 { 274 public function getMaxItemAge() { 276 275 $retval = $this->content_rss_aggregator_row['max_item_age_seconds']; 277 276 … … 298 297 * @access public 299 298 */ 300 public function setMaxItemAge($max_item_age, &$errormsg = null) 301 { 299 public function setMaxItemAge($max_item_age, & $errormsg = null) { 302 300 // Init values 303 301 $retval = false; … … 322 320 323 321 $retval = true; 324 } elseif ($max_item_age <= 0) { 322 } 323 elseif ($max_item_age <= 0) { 325 324 $errormsg = _("The maximum age must be a positive integer or null"); 326 325 327 326 $retval = false; 328 } else { 327 } 328 else { 329 329 /* 330 330 * Successfull, but nothing modified … … 345 345 * @access public 346 346 */ 347 public function addFeed($url) 348 { 347 public function addFeed($url) { 349 348 // Define globals 350 349 global $db; … … 373 372 * @access public 374 373 */ 375 public function removeFeed($url) 376 { 374 public function removeFeed($url) { 377 375 // Define globals 378 376 global $db; … … 392 390 } 393 391 394 395 392 /** 396 393 * Shows the administration interface for RssAggregator … … 403 400 * @access public 404 401 */ 405 public function getAdminUI($subclass_admin_interface = null, $title=null) 406 { 402 public function getAdminUI($subclass_admin_interface = null, $title = null) { 407 403 // Define globals 408 404 global $db; … … 414 410 $i = 0; 415 411 416 417 412 $html .= "<ul class='admin_element_list'>\n"; 418 413 /* … … 420 415 */ 421 416 $html .= "<li class='admin_element_item_container'>\n"; 422 $html .= "<div class='admin_element_label'>" ._("Total number of items to display (from all feeds)").": </div>\n";417 $html .= "<div class='admin_element_label'>" . _("Total number of items to display (from all feeds)") . ": </div>\n"; 423 418 $html .= "<div class='admin_element_data'>\n"; 424 419 425 $name = "rss_aggregator_" .$this->id."_display_num_items";420 $name = "rss_aggregator_" . $this->id . "_display_num_items"; 426 421 $value = $this->getDisplayNumItems(); 427 422 $html .= "<input type='text' size='2' value='$value' name='$name'>\n"; … … 436 431 $html .= "<div class='admin_element_label'>\n"; 437 432 $html .= _("How much bonus feeds that do not publish as often get over feed that publish more often. 438 The default is 0.75, with a typical range between 0 and 1.439 At 0, you have a classic RSS aggregator, meaning the n most recent entries picked from all feeds440 will be displayed. 1 is usually as high as you'll want to go: Assuming that all441 an homogenous internal distribution (ex: one feed publishes exactly one entry a day, the442 second once every two days, and the third once every three days), and you ask for 15 entries,443 there will be 5 of each. While that may not sound usefull, it still is, as the feed's distribution is444 usually not homogenous.");433 The default is 0.75, with a typical range between 0 and 1. 434 At 0, you have a classic RSS aggregator, meaning the n most recent entries picked from all feeds 435 will be displayed. 1 is usually as high as you'll want to go: Assuming that all 436 an homogenous internal distribution (ex: one feed publishes exactly one entry a day, the 437 second once every two days, and the third once every three days), and you ask for 15 entries, 438 there will be 5 of each. While that may not sound usefull, it still is, as the feed's distribution is 439 usually not homogenous."); 445 440 $html .= ": </div>\n"; 446 441 $html .= "<div class='admin_element_data'>\n"; 447 442 448 $name = "rss_aggregator_" .$this->id."_algorithm_strength";443 $name = "rss_aggregator_" . $this->id . "_algorithm_strength"; 449 444 $value = $this->getAlgorithmStrength(); 450 445 $html .= "<input type='text' size='2' value='$value' name='$name'>\n"; … … 459 454 $html .= "<div class='admin_element_label'>\n"; 460 455 $html .= _("Set the oldest entries (in seconds) you are willing to see. Any entries older than this will not 461 be considered at all for display, even if it means that the configured number of items to be displayed isn't reached.462 It's only usefull if all your feed publish very rarely, and you don't want very old entries to show up.");456 be considered at all for display, even if it means that the configured number of items to be displayed isn't reached. 457 It's only usefull if all your feed publish very rarely, and you don't want very old entries to show up."); 463 458 $html .= ": </div>\n"; 464 459 $html .= "<div class='admin_element_data'>\n"; 465 460 466 $name = "rss_aggregator_" .$this->id."_max_item_age";461 $name = "rss_aggregator_" . $this->id . "_max_item_age"; 467 462 $value = $this->getMaxItemAge(); 468 463 $html .= "<input type='text' size='10' value='$value' name='$name'>\n"; … … 476 471 */ 477 472 $html .= "<li class='admin_element_item_container'>\n"; 478 $html .= "<div class='admin_element_label'>" ._("Feeds:")."</div>\n";473 $html .= "<div class='admin_element_label'>" . _("Feeds:") . "</div>\n"; 479 474 480 475 $html .= "<ul class='admin_element_list'>\n"; … … 491 486 * Delete feeds 492 487 */ 493 $name = "rss_aggregator_" .$this->id."_feed_".md5($feed_row['url'])."_delete";494 $html .= "<input type='submit' name='$name' value='" ._("Delete")."'>";488 $name = "rss_aggregator_" . $this->id . "_feed_" . md5($feed_row['url']) . "_delete"; 489 $html .= "<input type='submit' name='$name' value='" . _("Delete") . "'>"; 495 490 $html .= "</div>\n"; 496 491 $html .= "</li>\n"; … … 501 496 */ 502 497 $html .= "<li class='admin_element_item_container'>\n"; 503 $html .= "<b>" ._("Add a new feed or pick one from the other feeds in the system (most_popular_first)")."</b><br>";498 $html .= "<b>" . _("Add a new feed or pick one from the other feeds in the system (most_popular_first)") . "</b><br>"; 504 499 505 500 $sql = "SELECT count, content_rss_aggregator_feeds.url, title FROM content_rss_aggregator_feeds 506 JOIN (SELECT url, count(content_rss_aggregator_feeds.url) as count507 FROM content_rss_aggregator_feeds508 WHERE content_rss_aggregator_feeds.url NOT IN (SELECT url FROM content_rss_aggregator_feeds WHERE content_id='{$this->id}')509 GROUP BY content_rss_aggregator_feeds.content_id, content_rss_aggregator_feeds.url)510 AS available_feeds511 ON (available_feeds.url=content_rss_aggregator_feeds.url)512 ORDER by count DESC";501 JOIN (SELECT url, count(content_rss_aggregator_feeds.url) as count 502 FROM content_rss_aggregator_feeds 503 WHERE content_rss_aggregator_feeds.url NOT IN (SELECT url FROM content_rss_aggregator_feeds WHERE content_id='{$this->id}') 504 GROUP BY content_rss_aggregator_feeds.content_id, content_rss_aggregator_feeds.url) 505 AS available_feeds 506 ON (available_feeds.url=content_rss_aggregator_feeds.url) 507 ORDER by count DESC"; 513 508 514 509 $db->execSql($sql, $feed_urls, false); … … 516 511 foreach ($feed_urls as $feed_row) { 517 512 $tab[$i][0] = $feed_row['url']; 518 empty ($feed_row['title']) ? $title = $feed_row['url'] : $title = $feed_row['title'];513 empty ($feed_row['title']) ? $title = $feed_row['url'] : $title = $feed_row['title']; 519 514 $tab[$i][1] = sprintf(_("%s, used %d times"), $title, $feed_row['count']); 520 $i ++;515 $i++; 521 516 } 522 517 … … 526 521 527 522 $name = "rss_aggregator_{$this->id}_feed_add_button"; 528 $html .= "<input type='submit' name='$name' value='" ._("Add")."'>";523 $html .= "<input type='submit' name='$name' value='" . _("Add") . "'>"; 529 524 530 525 $html .= "</li>\n"; … … 534 529 $html .= $subclass_admin_interface; 535 530 536 return parent ::getAdminUI($html, $title);531 return parent :: getAdminUI($html, $title); 537 532 } 538 533 … … 544 539 * @access public 545 540 */ 546 public function processAdminUI() 547 { 541 public function processAdminUI() { 548 542 if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) { 549 parent ::processAdminUI();543 parent :: processAdminUI(); 550 544 551 545 /* 552 546 * number_of_display_items 553 547 */ 554 $name = "rss_aggregator_" .$this->id."_display_num_items";548 $name = "rss_aggregator_" . $this->id . "_display_num_items"; 555 549 $this->setDisplayNumItems($_REQUEST[$name]); 556 550 … … 558 552 * algorithm_strength 559 553 */ 560 $name = "rss_aggregator_" .$this->id."_algorithm_strength";554 $name = "rss_aggregator_" . $this->id . "_algorithm_strength"; 561 555 $this->setAlgorithmStrength($_REQUEST[$name]); 562 556 … … 564 558 * max_item_age 565 559 */ 566 $name = "rss_aggregator_" .$this->id."_max_item_age";560 $name = "rss_aggregator_" . $this->id . "_max_item_age"; 567 561 $this->setMaxItemAge($_REQUEST[$name]); 568 562 … … 582 576 * Delete feeds 583 577 */ 584 $name = "rss_aggregator_" .$this->id."_feed_".md5($feed_row['url'])."_delete";578 $name = "rss_aggregator_" . $this->id . "_feed_" . md5($feed_row['url']) . "_delete"; 585 579 586 580 if (isset ($_REQUEST[$name])) { … … 600 594 * @access private 601 595 */ 602 private function getFeedAdminUI($feed_row) 603 { 596 private function getFeedAdminUI($feed_row) { 604 597 // Init values 605 598 $html = ''; 606 599 $html .= "<ul class='admin_element_list'>\n"; 607 600 $html .= "<li class='admin_element_item_container'>\n"; 608 $html .= "<div class='admin_element_label'>" .$feed_row['title']."</div>\n";601 $html .= "<div class='admin_element_label'>" . $feed_row['title'] . "</div>\n"; 609 602 610 603 $html .= "<div class='admin_element_data'>\n"; … … 614 607 */ 615 608 $html .= "<li class='admin_element_item_container'>\n"; 616 $html .= "<div class='admin_element_label'>" ._("URL").": \n";617 618 if (!$this->press_review->isFeedAvailable($feed_row['url'])) {619 $html .= "<br/><span class='warningmsg'>" ._("WARNING: Either the feed couldn't be retrieved, or it couldn't be parsed. Please double check the URL.")."</span>";609 $html .= "<div class='admin_element_label'>" . _("URL") . ": \n"; 610 611 if (!$this->press_review->isFeedAvailable($feed_row['url'])) { 612 $html .= "<br/><span class='warningmsg'>" . _("WARNING: Either the feed couldn't be retrieved, or it couldn't be parsed. Please double check the URL.") . "</span>"; 620 613 } 621 614 … … 623 616 $html .= "<div class='admin_element_data'>\n"; 624 617 625 $name = "rss_aggregator_" .$this->id."_feed_".md5($feed_row['url'])."_url";618 $name = "rss_aggregator_" . $this->id . "_feed_" . md5($feed_row['url']) . "_url"; 626 619 $value = $feed_row['url']; 627 620 $html .= "<input type='text' size='60' value='$value' name='$name'>\n"; … … 638 631 if ($calculated_pub_interval == true) { 639 632 $html .= sprintf(_("The feed publishes an item every %.2f day(s)"), $calculated_pub_interval / (60 * 60 * 24)); 640 } else { 641 $html .= "<div class='admin_element_label'><span class='warningmsg'>"._("WARNING: This feed does not include the publication dates. 642 The system needs to be able to compute approximate publication 643 date for each entry, so the entry can be weighted against the 644 others. In order for the aggregator to do a good job, you need 645 to estimate fublication frequency of the items, in days. 646 If unset, defaults to one day.").": </span></div>\n"; 633 } 634 else { 635 $html .= "<div class='admin_element_label'><span class='warningmsg'>" . _("WARNING: This feed does not include the publication dates. 636 The system needs to be able to compute approximate publication 637 date for each entry, so the entry can be weighted against the 638 others. In order for the aggregator to do a good job, you need 639 to estimate fublication frequency of the items, in days. 640 If unset, defaults to one day.") . ": </span></div>\n"; 647 641 $html .= "<div class='admin_element_data'>\n"; 648 $name = "rss_aggregator_" .$this->id."_feed_".md5($feed_row['url'])."_default_publication_interval";642 $name = "rss_aggregator_" . $this->id . "_feed_" . md5($feed_row['url']) . "_default_publication_interval"; 649 643 650 644 if (!empty ($feed_row['default_publication_interval'])) { 651 645 $value = $feed_row['default_publication_interval'] / (60 * 60 * 24); 652 } else { 646 } 647 else { 653 648 $value = ''; 654 649 } … … 664 659 */ 665 660 $html .= "<li class='admin_element_item_container'>\n"; 666 $html .= "<div class='admin_element_label'>" ._("The bias to be given to the source by the selection algorithm.667 Bias must be > 0 , typical values would be between 0.75 and 1.5668 and default is 1 (no bias). A bias of 2 will cause the items669 to \"look\" twice as recent to the algorithm. A bias of 0.5 to670 look twice as old. Be carefull, a bias of 2 will statistically671 because the feed to have MORE than twice as many items displayed.").": </div>\n";661 $html .= "<div class='admin_element_label'>" . _("The bias to be given to the source by the selection algorithm. 662 Bias must be > 0 , typical values would be between 0.75 and 1.5 663 and default is 1 (no bias). A bias of 2 will cause the items 664 to \"look\" twice as recent to the algorithm. A bias of 0.5 to 665 look twice as old. Be carefull, a bias of 2 will statistically 666 cause the feed to have MORE than twice as many items displayed.") . ": </div>\n"; 672 667 $html .= "<div class='admin_element_data'>\n"; 673 668 674 $name = "rss_aggregator_" .$this->id."_feed_".md5($feed_row['url'])."_bias";669 $name = "rss_aggregator_" . $this->id . "_feed_" . md5($feed_row['url']) . "_bias"; 675 670 $value = $feed_row['bias']; 676 671 $html .= "<input type='text' size='60' value='$value' name='$name'>\n"; … … 693 688 * @access private 694 689 */ 695 private function processFeedAdminUI($feed_row) 696 { 690 private function processFeedAdminUI($feed_row) { 697 691 // Define globals 698 692 global $db; … … 703 697 * bias 704 698 */ 705 $name = "rss_aggregator_" .$this->id."_feed_".md5($feed_row['url'])."_bias";699 $name = "rss_aggregator_" . $this->id . "_feed_" . md5($feed_row['url']) . "_bias"; 706 700 $original_bias = $db->escapeString($feed_row['bias']); 707 701 $bias = $db->escapeString($_REQUEST[$name]); … … 713 707 $db->execSqlUpdate("UPDATE content_rss_aggregator_feeds SET bias = '$bias' WHERE content_id = '$this->id' AND url='$original_url'", false); 714 708 $this->refresh(); 715 } elseif (!is_numeric($bias) || $bias <= 0) { 709 } 710 elseif (!is_numeric($bias) || $bias <= 0) { 716 711 echo _("The bias must be a positive real number"); 717 } else { 712 } 713 else { 718 714 /* 719 715 * Successfull, but nothing modified … … 724 720 * default_publication_interval 725 721 */ 726 $name = "rss_aggregator_" .$this->id."_feed_".md5($feed_row['url'])."_default_publication_interval";722 $name = "rss_aggregator_" . $this->id . "_feed_" . md5($feed_row['url']) . "_default_publication_interval"; 727 723 728 724 if (isset ($_REQUEST[$name])) { … … 740 736 $db->execSqlUpdate("UPDATE content_rss_aggregator_feeds SET default_publication_interval = $default_publication_interval WHERE content_id = '$this->id' AND url='$original_url'", false); 741 737 $this->refresh(); 742 } elseif (!is_numeric($bias) || $bias <= 0) { 738 } 739 elseif (!is_numeric($bias) || $bias <= 0) { 743 740 echo _("The default publication must must be a positive integer or empty"); 744 } else { 741 } 742 else { 745 743 /* 746 744 * Successfull, but nothing modified … … 752 750 * URL, we must change it last or we won't find the row again 753 751 */ 754 $name = "rss_aggregator_" .$this->id."_feed_".md5($feed_row['url'])."_url";752 $name = "rss_aggregator_" . $this->id . "_feed_" . md5($feed_row['url']) . "_url"; 755 753 $url = $db->escapeString($_REQUEST[$name]); 756 754 … … 761 759 $db->execSqlUpdate("UPDATE content_rss_aggregator_feeds SET url = '$url' WHERE content_id = '$this->id' AND url='$original_url'", false); 762 760 $this->refresh(); 763 } elseif (empty ($url)) { 761 } 762 elseif (empty ($url)) { 764 763 echo _("The URL cannot be empty!"); 765 } else { 764 } 765 else { 766 766 /* 767 767 * Successfull, but nothing modified … … 777 777 * @access public 778 778 */ 779 public function getUserUI() 780 { 779 public function getUserUI() { 781 780 // Init values 782 781 $html = ''; 783 782 784 $html .= "<div class='user_ui_data " .get_class($this)."'>\n";783 $html .= "<div class='user_ui_data " . get_class($this) . "'>\n"; 785 784 786 785 if (RSS_SUPPORT) { … … 788 787 $html = $this->press_review->get_rss_html($this->content_rss_aggregator_row['number_of_display_items']); 789 788 } 790 791 789 catch (Exception $e) { 792 790 $html = sprintf(_("Could not get RSS feed: %s"), $feed_row['url']); 793 791 } 794 } else { 792 /* Handle hyperlink clicktrough logging */ 793 $html = $this->replaceHyperLinks($html); 794 795 } 796 else { 795 797 $html = _("RSS support is disabled"); 796 798 } … … 798 800 $html .= "</div>\n"; 799 801 800 return parent ::getUserUI($html);802 return parent :: getUserUI($html); 801 803 } 802 804 … … 813 815 * @access private 814 816 */ 815 private function refresh() 816 { 817 private function refresh() { 817 818 $this->__construct($this->id); 818 819 } … … 826 827 * End: 827 828 */ 828 829 -
trunk/wifidog-auth/wifidog/include/schema_validate.php
r1074 r1080 47 47 * Define current database schema version 48 48 */ 49 define('REQUIRED_SCHEMA_VERSION', 4 2);49 define('REQUIRED_SCHEMA_VERSION', 43); 50 50 51 51 /** … … 888 888 } 889 889 890 $new_schema_version = 43; 891 if ($schema_version < $new_schema_version) { 892 printUpdateVersion($new_schema_version); 893 $sql .= "\n\nUPDATE schema_info SET value='$new_schema_version' WHERE tag='schema_version';\n"; 894 $sql .= "CREATE TABLE content_clickthrough_log ( \n"; 895 $sql .= " user_id text REFERENCES users (user_id) ON UPDATE CASCADE ON DELETE CASCADE,\n"; 896 $sql .= " content_id text NOT NULL REFERENCES content ON UPDATE CASCADE ON DELETE CASCADE,\n"; 897 $sql .= " clickthrough_timestamp timestamp NOT NULL DEFAULT now(),\n"; 898 $sql .= " node_id text NOT NULL REFERENCES nodes ON UPDATE CASCADE ON DELETE CASCADE,\n"; 899 $sql .= " destination_url text NOT NULL CHECK (destination_url<>'')\n"; 900 $sql .= ");\n"; 901 } 902 890 903 /* 891 904 $new_schema_version = 43; -
trunk/wifidog-auth/wifidog/lib/RssPressReview/RssPressReview.php
r1056 r1080 35 35 36 36 /** 37 * @package WiFiDogAuthServer38 37 * @author Benoit Grégoire <bock@step.polymtl.ca> 39 38 * @copyright 2005-2006 Benoit Grégoire, Technologies Coeus inc. … … 50 49 51 50 /** 52 * @package WiFiDogAuthServer53 51 * @author Benoit Grégoire <bock@step.polymtl.ca> 54 52 * @copyright 2005-2006 Benoit Grégoire, Technologies Coeus inc.
