Changeset 1080

Show
Ignore:
Timestamp:
08/28/06 00:40:29 (5 years ago)
Author:
benoitg
Message:
  • clickthrough.php, HyperLink?.php: Implement working hyperlink

clickthrough tracking (no reporting yet).

Works for Langstring, FlickrPhotoStream?, Picture,

RssAggregator? and their subclasses.

  • Make HTMLeditor inherit from Langstring. Allowed a massive

reduction of line count and will stop the codebases from needlessly
drifting apart.

  • Do not log content displayed as metadata, and log their

clickthrough as the parent's.

Location:
trunk/wifidog-auth
Files:
2 added
9 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/CHANGELOG

    r1079 r1080  
     12006-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         
    172006-08-27 François Proulx <francois.proulx@gmail.com> 
    28        * Updated French translations 
  • trunk/wifidog-auth/wifidog/classes/Content.php

    r1074 r1080  
    5050require_once ('classes/GenericObject.php'); 
    5151require_once ('classes/Cache.php'); 
    52  
     52require_once ('classes/HyperLink.php'); 
    5353/** 
    5454 * Defines any type of content 
     
    104104     */ 
    105105    private $is_logging_enabled; 
     106     
     107    /** Log as part of this other content */ 
     108    private $log_as_content; 
    106109 
    107110    /** 
     
    136139        // By default content display logging is enabled 
    137140        $this->setLoggingStatus(true); 
     141        $this->log_as_content &= $this; 
    138142    } 
    139143 
     
    10391043            $html .= "<div class='user_ui_title'>\n"; 
    10401044            $title = self :: getObject($this->content_row['title']); 
     1045            $title->setLogAsContent($this); 
    10411046            // If the content logging is disabled, all the children will inherit this property temporarly 
    10421047            if ($this->getLoggingStatus() == false) 
     
    10631068            $html .= "<div class='user_ui_description'>\n"; 
    10641069            $description = self :: getObject($this->content_row['description']); 
     1070            $description->setLogAsContent($this); 
    10651071            // If the content logging is disabled, all the children will inherit this property temporarly 
    10661072            if ($this->getLoggingStatus() == false) 
     
    10751081                $html .= "<b>"._("Project information:")."</b>"; 
    10761082                $project_info = self :: getObject($this->content_row['project_info']); 
     1083                $project_info->setLogAsContent($this); 
    10771084                // If the content logging is disabled, all the children will inherit this property temporarly 
    10781085                if ($this->getLoggingStatus() == false) 
     
    10861093                $html .= "<b>"._("Project sponsor:")."</b>"; 
    10871094                $sponsor_info = self :: getObject($this->content_row['sponsor_info']); 
     1095                $sponsor_info->setLogAsContent($this); 
    10881096                // If the content logging is disabled, all the children will inherit this property temporarly 
    10891097                if ($this->getLoggingStatus() == false) 
     
    11031111    } 
    11041112 
     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 */ 
     1117protected function setLogAsContent(Content $content) 
     1118{ 
     1119   $this->log_as_content = $content; 
     1120} 
     1121 
    11051122    /** Log that this content has just been displayed to the user.  Will only log if the user is logged in */ 
    11061123    private function logContentDisplay() { 
    1107         if ($this->getLoggingStatus() == true) { 
     1124        if ($this->getLoggingStatus() == true && $this->log_as_content->getId()==$this->getId()) { 
    11081125            // DEBUG:: 
    11091126            //echo "Logging ".get_class($this)." :: ".$this->__toString()."<br>"; 
     
    11251142            } 
    11261143        } 
     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; 
    11271152    } 
    11281153 
  • trunk/wifidog-auth/wifidog/classes/Content/FlickrPhotostream/FlickrPhotostream.php

    r1074 r1080  
    876876        $html .= $subclass_user_interface; 
    877877        $html .= "</div>\n"; 
    878  
     878        /* Handle hyperlink clicktrough logging */ 
     879        $html = $this->replaceHyperLinks($html); 
    879880        return parent::getUserUI($html); 
    880881    } 
  • trunk/wifidog-auth/wifidog/classes/Content/HTMLeditor/HTMLeditor.php

    r1070 r1080  
    4747 * Load required classes 
    4848 */ 
    49 require_once('classes/Cache.php'); 
    50 require_once('classes/HtmlSafe.php'); 
    51 require_once('classes/LocaleList.php'); 
     49require_once('classes/Content/Langstring/Langstring.php'); 
    5250 
    5351/** 
     
    5957 * @copyright  2005-2006 Max Horvath, maxspot GmbH 
    6058 */ 
    61 class HTMLeditor extends Content 
     59class HTMLeditor extends Langstring 
    6260{ 
    6361 
     
    10098            $this->_FCKeditorAvailable = true; 
    10199        } 
    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 private 
    110      */ 
    111     private function getString() 
    112     { 
    113         // Init values 
    114         $_retval = null; 
    115         $_row = null; 
    116         $_useCache = false; 
    117         $_cachedData = null; 
    118  
    119         // Create new cache objects 
    120         $_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 user 
    146             $_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 found 
    153                 $_retval = "(Empty string)"; 
    154             } else { 
    155                 // String has been found 
    156                 $_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 added 
    173      * @param string $locale             Locale of string (i.e. 'fr_CA') - can 
    174      *                                   be NULL 
    175      * @param bool   $allow_empty_string Defines if string may be empty 
    176      * 
    177      * @return bool True if string has been added, otherwise false. 
    178      * 
    179      * @access private 
    180      */ 
    181     private function addString($string, $locale, $allow_empty_string = false) 
    182     { 
    183         // Init values 
    184         $_retval = false; 
    185         $_id = 'NULL'; 
    186         $_idSQL = $_id; 
    187  
    188         if ($locale) { 
    189             // Set locale of string 
    190             $_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 database 
    198             $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 private 
    228      */ 
    229     private function UpdateString($string, $locale) 
    230     { 
    231         // Init values 
    232         $_retval = false; 
    233         $_id = 'NULL'; 
    234         $_row = null; 
    235  
    236         if ($locale) { 
    237             // Set locale of string 
    238             $_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 record 
    248             $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; 
    271100    } 
    272101 
     
    394223        // Check FCKeditor support 
    395224        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(); 
    470226        } 
    471227    } 
    472  
    473     /** 
    474      * Retreives the user interface of this object. Anything that overrides 
    475      * this method should call the parent method with it's output at the 
    476      * END of processing. 
    477      * 
    478      * @param string $subclass_admin_interface HTML content of the interface 
    479      *                                         element of a children. 
    480      * 
    481      * @return string The HTML fragment for this interface. 
    482      * 
    483      * @access public 
    484      */ 
    485     public function getUserUI($subclass_user_interface = null) 
    486     { 
    487         // Init values 
    488         $_html = ""; 
    489  
    490         $_html .= "<div class='user_ui_container ".get_class($this)."'>\n"; 
    491         $_html .= "<div class='langstring'>\n"; 
    492  
    493         // Check FCKeditor support 
    494         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 after 
    509      * a set operation. This function is private because calling it from a 
    510      * subclass will call the constructor from the wrong scope. 
    511      * 
    512      * @return void 
    513      * 
    514      * @access private 
    515      */ 
    516     private function refresh() 
    517     { 
    518         $this->__construct($this->id); 
    519     } 
    520  
    521     /** 
    522      * Deletes a HTMLeditor object 
    523      * 
    524      * @param string $errmsg Reference to error message 
    525      * 
    526      * @return bool True if deletion was successful 
    527      * 
    528      * @access public 
    529      * @internal Persistent content will not be deleted 
    530      */ 
    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  
    561228} 
    562229 
  • trunk/wifidog-auth/wifidog/classes/Content/Langstring/Langstring.php

    r1070 r1080  
    105105        // Check if caching has been enabled. 
    106106        if ($_cacheLanguage->isCachingEnabled) { 
    107             if ($_cachedData = $_cacheLanguage->getCachedData()) { 
     107            $_cachedData = $_cacheLanguage->getCachedData(); 
     108            if ($_cachedData) { 
    108109                // Return cached data. 
    109110                $_useCache = true; 
     
    128129 
    129130            if ($row == null) { 
    130                 $retval = "(Langstring vide)"; 
     131                $retval = sprintf(_("(Empty $s)"), get_class($this)); 
    131132            } else { 
    132133                $retval = $row['value']; 
     
    513514        $html .= "</div>\n"; 
    514515        $html .= "</div>\n"; 
    515  
     516        /* Handle hyperlink clicktrough logging */ 
     517        $html = $this->replaceHyperLinks($html); 
    516518        return parent::getUserUI($html); 
    517519    } 
  • trunk/wifidog-auth/wifidog/classes/Content/Picture/Picture.php

    r1074 r1080  
    342342 
    343343        $html .= "</div>\n"; 
    344  
     344        /* Handle hyperlink clicktrough logging */ 
     345        $html = $this->replaceHyperLinks($html); 
    345346        return $html; 
    346347    } 
  • trunk/wifidog-auth/wifidog/classes/Content/RssAggregator/RssAggregator.php

    r1070 r1080  
    11<?php 
     2 
    23 
    34/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */ 
     
    4647 * Load required class 
    4748 */ 
    48 require_once('classes/LocaleList.php'); 
     49require_once ('classes/LocaleList.php'); 
    4950 
    5051/** 
     
    6162 * @copyright  2005-2006 Benoit Grégoire, Technologies Coeus inc. 
    6263 */ 
    63 class RssAggregator extends Content 
    64 { 
     64class RssAggregator extends Content { 
    6565    /** 
    6666     * @var string 
     
    9090     * @access protected 
    9191     */ 
    92     protected function __construct($content_id) 
    93     { 
     92    protected function __construct($content_id) { 
    9493        // Define globals 
    9594        global $db; 
     
    9998        $content_rss_aggregator_rows = null; 
    10099 
    101         parent::__construct($content_id); 
     100        parent :: __construct($content_id); 
    102101        $content_id = $db->escapeString($content_id); 
    103102 
     
    110109            $db->execSqlUniqueRes($sql, $row, false); 
    111110            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); 
    113112            } 
    114113        } 
     
    121120        if ($content_rss_aggregator_rows != null) { 
    122121            $this->content_rss_aggregator_feeds_rows = $content_rss_aggregator_rows; 
    123         } else { 
     122        } 
     123        else { 
    124124            $this->content_rss_aggregator_feeds_rows = array (); 
    125125        } 
    126126 
    127127        if (RSS_SUPPORT) { 
    128             require_once('lib/RssPressReview/RssPressReview.php'); 
     128            require_once ('lib/RssPressReview/RssPressReview.php'); 
    129129 
    130130            $this->press_review = new RssPressReview(WIFIDOG_ABS_FILE_PATH . MAGPIE_REL_PATH, "UTF-8"); 
     
    138138                // Update the stored feed title if it changed. 
    139139                //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 { 
    148149            $html = _("RSS support is disabled"); 
    149150        } 
     
    159160     * @access public 
    160161     */ 
    161     public function getDisplayNumItems() 
    162     { 
     162    public function getDisplayNumItems() { 
    163163        return $this->content_rss_aggregator_row['number_of_display_items']; 
    164164    } 
     
    174174     * @access public 
    175175     */ 
    176     public function setDisplayNumItems($num_items, &$errormsg = null) 
    177     { 
     176    public function setDisplayNumItems($num_items, & $errormsg = null) { 
    178177        // Init values 
    179178        $retval = false; 
     
    190189 
    191190            $retval = true; 
    192         } elseif ($num_items < 1) { 
     191        } 
     192        elseif ($num_items < 1) { 
    193193            $errormsg = _("You must display at least one element"); 
    194194 
    195195            $retval = false; 
    196         } else { 
     196        } 
     197        else { 
    197198            /* 
    198199             * Successfull, but nothing modified 
     
    212213     * @access public 
    213214     */ 
    214     public function getAlgorithmStrength() 
    215     { 
     215    public function getAlgorithmStrength() { 
    216216        return $this->content_rss_aggregator_row['algorithm_strength']; 
    217217    } 
     
    240240     * @access public 
    241241     */ 
    242     public function setAlgorithmStrength($strength, &$errormsg = null) 
    243     { 
     242    public function setAlgorithmStrength($strength, & $errormsg = null) { 
    244243        // Init values 
    245244        $retval = false; 
     
    256255 
    257256            $retval = true; 
    258         } else { 
     257        } 
     258        else { 
    259259            /* 
    260260             * Successfull, but nothing modified 
     
    272272     * @access public 
    273273     */ 
    274     public function getMaxItemAge() 
    275     { 
     274    public function getMaxItemAge() { 
    276275        $retval = $this->content_rss_aggregator_row['max_item_age_seconds']; 
    277276 
     
    298297     * @access public 
    299298     */ 
    300     public function setMaxItemAge($max_item_age, &$errormsg = null) 
    301     { 
     299    public function setMaxItemAge($max_item_age, & $errormsg = null) { 
    302300        // Init values 
    303301        $retval = false; 
     
    322320 
    323321            $retval = true; 
    324         } elseif ($max_item_age <= 0) { 
     322        } 
     323        elseif ($max_item_age <= 0) { 
    325324            $errormsg = _("The maximum age must be a positive integer or null"); 
    326325 
    327326            $retval = false; 
    328         } else { 
     327        } 
     328        else { 
    329329            /* 
    330330             * Successfull, but nothing modified 
     
    345345     * @access public 
    346346     */ 
    347     public function addFeed($url) 
    348     { 
     347    public function addFeed($url) { 
    349348        // Define globals 
    350349        global $db; 
     
    373372     * @access public 
    374373     */ 
    375     public function removeFeed($url) 
    376     { 
     374    public function removeFeed($url) { 
    377375        // Define globals 
    378376        global $db; 
     
    392390    } 
    393391 
    394  
    395392    /** 
    396393     * Shows the administration interface for RssAggregator 
     
    403400     * @access public 
    404401     */ 
    405     public function getAdminUI($subclass_admin_interface = null, $title=null) 
    406     { 
     402    public function getAdminUI($subclass_admin_interface = null, $title = null) { 
    407403        // Define globals 
    408404        global $db; 
     
    414410        $i = 0; 
    415411 
    416  
    417412        $html .= "<ul class='admin_element_list'>\n"; 
    418413        /* 
     
    420415         */ 
    421416        $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"; 
    423418        $html .= "<div class='admin_element_data'>\n"; 
    424419 
    425         $name = "rss_aggregator_".$this->id."_display_num_items"; 
     420        $name = "rss_aggregator_" . $this->id . "_display_num_items"; 
    426421        $value = $this->getDisplayNumItems(); 
    427422        $html .= "<input type='text' size='2' value='$value' name='$name'>\n"; 
     
    436431        $html .= "<div class='admin_element_label'>\n"; 
    437432        $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 feeds 
    440                     will be displayed. 1 is usually as high as you'll want to go:  Assuming that all 
    441                     an homogenous internal distribution (ex:  one feed publishes exactly one entry a day, the 
    442                     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 is 
    444                     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."); 
    445440        $html .= ": </div>\n"; 
    446441        $html .= "<div class='admin_element_data'>\n"; 
    447442 
    448         $name = "rss_aggregator_".$this->id."_algorithm_strength"; 
     443        $name = "rss_aggregator_" . $this->id . "_algorithm_strength"; 
    449444        $value = $this->getAlgorithmStrength(); 
    450445        $html .= "<input type='text' size='2' value='$value' name='$name'>\n"; 
     
    459454        $html .= "<div class='admin_element_label'>\n"; 
    460455        $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."); 
    463458        $html .= ": </div>\n"; 
    464459        $html .= "<div class='admin_element_data'>\n"; 
    465460 
    466         $name = "rss_aggregator_".$this->id."_max_item_age"; 
     461        $name = "rss_aggregator_" . $this->id . "_max_item_age"; 
    467462        $value = $this->getMaxItemAge(); 
    468463        $html .= "<input type='text' size='10' value='$value' name='$name'>\n"; 
     
    476471         */ 
    477472        $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"; 
    479474 
    480475        $html .= "<ul class='admin_element_list'>\n"; 
     
    491486             * Delete feeds 
    492487             */ 
    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") . "'>"; 
    495490            $html .= "</div>\n"; 
    496491            $html .= "</li>\n"; 
     
    501496         */ 
    502497        $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>"; 
    504499 
    505500        $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 count 
    507                 FROM content_rss_aggregator_feeds 
    508                 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_feeds 
    511                 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"; 
    513508 
    514509        $db->execSql($sql, $feed_urls, false); 
     
    516511        foreach ($feed_urls as $feed_row) { 
    517512            $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']; 
    519514            $tab[$i][1] = sprintf(_("%s, used %d times"), $title, $feed_row['count']); 
    520             $i ++; 
     515            $i++; 
    521516        } 
    522517 
     
    526521 
    527522        $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") . "'>"; 
    529524 
    530525        $html .= "</li>\n"; 
     
    534529        $html .= $subclass_admin_interface; 
    535530 
    536         return parent::getAdminUI($html, $title); 
     531        return parent :: getAdminUI($html, $title); 
    537532    } 
    538533 
     
    544539     * @access public 
    545540     */ 
    546     public function processAdminUI() 
    547     { 
     541    public function processAdminUI() { 
    548542        if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) { 
    549             parent::processAdminUI(); 
     543            parent :: processAdminUI(); 
    550544 
    551545            /* 
    552546             * number_of_display_items 
    553547             */ 
    554             $name = "rss_aggregator_".$this->id."_display_num_items"; 
     548            $name = "rss_aggregator_" . $this->id . "_display_num_items"; 
    555549            $this->setDisplayNumItems($_REQUEST[$name]); 
    556550 
     
    558552             * algorithm_strength 
    559553             */ 
    560             $name = "rss_aggregator_".$this->id."_algorithm_strength"; 
     554            $name = "rss_aggregator_" . $this->id . "_algorithm_strength"; 
    561555            $this->setAlgorithmStrength($_REQUEST[$name]); 
    562556 
     
    564558             * max_item_age 
    565559             */ 
    566             $name = "rss_aggregator_".$this->id."_max_item_age"; 
     560            $name = "rss_aggregator_" . $this->id . "_max_item_age"; 
    567561            $this->setMaxItemAge($_REQUEST[$name]); 
    568562 
     
    582576                 * Delete feeds 
    583577                 */ 
    584                 $name = "rss_aggregator_".$this->id."_feed_".md5($feed_row['url'])."_delete"; 
     578                $name = "rss_aggregator_" . $this->id . "_feed_" . md5($feed_row['url']) . "_delete"; 
    585579 
    586580                if (isset ($_REQUEST[$name])) { 
     
    600594     * @access private 
    601595     */ 
    602     private function getFeedAdminUI($feed_row) 
    603     { 
     596    private function getFeedAdminUI($feed_row) { 
    604597        // Init values 
    605598        $html = ''; 
    606599        $html .= "<ul class='admin_element_list'>\n"; 
    607600        $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"; 
    609602 
    610603        $html .= "<div class='admin_element_data'>\n"; 
     
    614607         */ 
    615608        $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>"; 
    620613        } 
    621614 
     
    623616        $html .= "<div class='admin_element_data'>\n"; 
    624617 
    625         $name = "rss_aggregator_".$this->id."_feed_".md5($feed_row['url'])."_url"; 
     618        $name = "rss_aggregator_" . $this->id . "_feed_" . md5($feed_row['url']) . "_url"; 
    626619        $value = $feed_row['url']; 
    627620        $html .= "<input type='text' size='60' value='$value' name='$name'>\n"; 
     
    638631        if ($calculated_pub_interval == true) { 
    639632            $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"; 
    647641            $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"; 
    649643 
    650644            if (!empty ($feed_row['default_publication_interval'])) { 
    651645                $value = $feed_row['default_publication_interval'] / (60 * 60 * 24); 
    652             } else { 
     646            } 
     647            else { 
    653648                $value = ''; 
    654649            } 
     
    664659         */ 
    665660        $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.5 
    668                                                         and default is 1 (no bias).  A bias of 2 will cause the items 
    669                                                         to \"look\" twice as recent to the algorithm. A bias of 0.5 to 
    670                                                         look twice as old. Be carefull, a bias of 2 will statistically 
    671                                                         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"; 
    672667        $html .= "<div class='admin_element_data'>\n"; 
    673668 
    674         $name = "rss_aggregator_".$this->id."_feed_".md5($feed_row['url'])."_bias"; 
     669        $name = "rss_aggregator_" . $this->id . "_feed_" . md5($feed_row['url']) . "_bias"; 
    675670        $value = $feed_row['bias']; 
    676671        $html .= "<input type='text' size='60' value='$value' name='$name'>\n"; 
     
    693688     * @access private 
    694689     */ 
    695     private function processFeedAdminUI($feed_row) 
    696     { 
     690    private function processFeedAdminUI($feed_row) { 
    697691        // Define globals 
    698692        global $db; 
     
    703697         * bias 
    704698         */ 
    705         $name = "rss_aggregator_".$this->id."_feed_".md5($feed_row['url'])."_bias"; 
     699        $name = "rss_aggregator_" . $this->id . "_feed_" . md5($feed_row['url']) . "_bias"; 
    706700        $original_bias = $db->escapeString($feed_row['bias']); 
    707701        $bias = $db->escapeString($_REQUEST[$name]); 
     
    713707            $db->execSqlUpdate("UPDATE content_rss_aggregator_feeds SET bias = '$bias' WHERE content_id = '$this->id' AND url='$original_url'", false); 
    714708            $this->refresh(); 
    715         } elseif (!is_numeric($bias) || $bias <= 0) { 
     709        } 
     710        elseif (!is_numeric($bias) || $bias <= 0) { 
    716711            echo _("The bias must be a positive real number"); 
    717         } else { 
     712        } 
     713        else { 
    718714            /* 
    719715             * Successfull, but nothing modified 
     
    724720         * default_publication_interval 
    725721         */ 
    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"; 
    727723 
    728724        if (isset ($_REQUEST[$name])) { 
     
    740736                $db->execSqlUpdate("UPDATE content_rss_aggregator_feeds SET default_publication_interval = $default_publication_interval WHERE content_id = '$this->id' AND url='$original_url'", false); 
    741737                $this->refresh(); 
    742             } elseif (!is_numeric($bias) || $bias <= 0) { 
     738            } 
     739            elseif (!is_numeric($bias) || $bias <= 0) { 
    743740                echo _("The default publication must must be a positive integer or empty"); 
    744             } else { 
     741            } 
     742            else { 
    745743                /* 
    746744                 * Successfull, but nothing modified 
     
    752750         * URL, we must change it last or we won't find the row again 
    753751         */ 
    754         $name = "rss_aggregator_".$this->id."_feed_".md5($feed_row['url'])."_url"; 
     752        $name = "rss_aggregator_" . $this->id . "_feed_" . md5($feed_row['url']) . "_url"; 
    755753        $url = $db->escapeString($_REQUEST[$name]); 
    756754 
     
    761759            $db->execSqlUpdate("UPDATE content_rss_aggregator_feeds SET url = '$url' WHERE content_id = '$this->id' AND url='$original_url'", false); 
    762760            $this->refresh(); 
    763         } elseif (empty ($url)) { 
     761        } 
     762        elseif (empty ($url)) { 
    764763            echo _("The URL cannot be empty!"); 
    765         } else { 
     764        } 
     765        else { 
    766766            /* 
    767767             * Successfull, but nothing modified 
     
    777777     * @access public 
    778778     */ 
    779     public function getUserUI() 
    780     { 
     779    public function getUserUI() { 
    781780        // Init values 
    782781        $html = ''; 
    783782 
    784         $html .= "<div class='user_ui_data  ".get_class($this)."'>\n"; 
     783        $html .= "<div class='user_ui_data  " . get_class($this) . "'>\n"; 
    785784 
    786785        if (RSS_SUPPORT) { 
     
    788787                $html = $this->press_review->get_rss_html($this->content_rss_aggregator_row['number_of_display_items']); 
    789788            } 
    790  
    791789            catch (Exception $e) { 
    792790                $html = sprintf(_("Could not get RSS feed: %s"), $feed_row['url']); 
    793791            } 
    794         } else { 
     792        /* Handle hyperlink clicktrough logging */ 
     793        $html = $this->replaceHyperLinks($html); 
     794 
     795        } 
     796        else { 
    795797            $html = _("RSS support is disabled"); 
    796798        } 
     
    798800        $html .= "</div>\n"; 
    799801 
    800         return parent::getUserUI($html); 
     802        return parent :: getUserUI($html); 
    801803    } 
    802804 
     
    813815     * @access private 
    814816     */ 
    815     private function refresh() 
    816     { 
     817    private function refresh() { 
    817818        $this->__construct($this->id); 
    818819    } 
     
    826827 * End: 
    827828 */ 
    828  
    829  
  • trunk/wifidog-auth/wifidog/include/schema_validate.php

    r1074 r1080  
    4747 * Define current database schema version 
    4848 */ 
    49 define('REQUIRED_SCHEMA_VERSION', 42); 
     49define('REQUIRED_SCHEMA_VERSION', 43); 
    5050 
    5151/** 
     
    888888        } 
    889889 
     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         
    890903        /* 
    891904        $new_schema_version = 43; 
  • trunk/wifidog-auth/wifidog/lib/RssPressReview/RssPressReview.php

    r1056 r1080  
    3535 
    3636/** 
    37  * @package    WiFiDogAuthServer 
    3837 * @author     Benoit Grégoire <bock@step.polymtl.ca> 
    3938 * @copyright  2005-2006 Benoit Grégoire, Technologies Coeus inc. 
     
    5049 
    5150/** 
    52  * @package    WiFiDogAuthServer 
    5351 * @author     Benoit Grégoire <bock@step.polymtl.ca> 
    5452 * @copyright  2005-2006 Benoit Grégoire, Technologies Coeus inc.