Changeset 696

Show
Ignore:
Timestamp:
08/21/05 22:26:12 (8 years ago)
Author:
fproulx
Message:

2005-08-21 Francois Proulx <francois.proulx@…>

  • Added reference to new street address fields in mapping page and on status template
  • Fix bug on line 756 of RssPressReview? , added check for empty var.
  • Flickr support is broken, added bug to sf.net tracker
Location:
trunk/wifidog-auth
Files:
5 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/ChangeLog

    r695 r696  
     12005-08-21 Francois Proulx <francois.proulx@gmail.com> 
     2        * Added reference to new street address fields in mapping page and on status template 
     3        * Fix bug on line 756 of RssPressReview , added check for empty var. 
     4        * Flickr support is broken, added  bug to sf.net tracker 
     5         
    162005-08-21 Francois Proulx <francois.proulx@gmail.com> 
    27        * Node admin UI should now be completed. 
  • trunk/wifidog-auth/wifidog/classes/Content/FlickrPhotostream.php

    r624 r696  
    11<?php 
    2  
    32/********************************************************************\ 
    43 * This program is free software; you can redistribute it and/or    * 
     
    5958                const SIZE_MEDIUM_500x375 = ''; 
    6059                const SIZE_ORIGINAL = 'o'; 
    61                  
     60 
    6261                const GRID_X = 3; 
    6362                const GRID_Y = 3; 
     
    110109                private function writeCacheToDatabase($force_overwrite = false) 
    111110                { 
    112                         //echo "<h2>DEBUG :: Writing cache to database</h2>"; 
    113                         $api = $this->getFlickrApi(); 
     111                                //echo "<h2>DEBUG :: Writing cache to database</h2>"; 
     112        $api = $this->getFlickrApi(); 
    114113                        if ($api) 
    115114                        { 
    116                 $new_cache = serialize($api->getCache()); 
    117                 $old_cache = $this->mBd->UnescapeBinaryString($this->flickr_photostream_row['requests_cache']); 
     115                                $new_cache = serialize($api->getCache()); 
     116                                $old_cache = $this->mBd->UnescapeBinaryString($this->flickr_photostream_row['requests_cache']); 
    118117                                $age = is_null($this->flickr_photostream_row['cache_age']) ? self :: MAX_CACHE_AGE : $this->flickr_photostream_row['cache_age']; 
    119118                                if ($force_overwrite === true || ($age >= self :: MAX_CACHE_AGE) || ($new_cache !== $old_cache)) 
     
    502501                                catch (Phlickr_MethodFailureException $e) 
    503502                                { 
    504                                         $html .= _("Some of the request parameters provided to Flickr API are invalid.");; 
     503                                        $html .= _("Some of the request parameters provided to Flickr API are invalid."); 
    505504                                } 
    506505                                catch (Phlickr_XmlParseException $e) 
     
    607606                                if ($force_data_refresh === false) 
    608607                                        $this->loadCacheFromDatabase(); 
    609                                  
     608 
    610609                                try 
    611610                                { 
     
    637636                                        } 
    638637 
    639                                         if (is_array($photos) && !empty($photos)) 
     638                                        if (is_array($photos) && !empty ($photos)) 
    640639                                        { 
    641640                                                $size = $this->getPreferredSize(); 
    642641                                                if (empty ($size)) 
    643642                                                        $size = null; 
    644                                                          
     643 
    645644                                                // Preload authors ( this will be cached ) 
    646645                                                foreach ($photos as $cache_authors) 
    647646                                                        $author = new Phlickr_User($api, $cache_authors->getOwnerId()); 
    648                                                                          
     647 
    649648                                                // If there's enough photo show a grid 
    650                                                 if(count($photos) >= self::GRID_X * self::GRID_Y) 
     649                                                if (count($photos) >= self :: GRID_X * self :: GRID_Y) 
    651650                                                { 
    652                                                         $grid_photos_idx = array(); 
     651                                                        $grid_photos_idx = array (); 
    653652                                                        $html .= "<table>\n"; 
    654                                                         for($i=0;$i<self::GRID_X;$i++) 
     653                                                        for ($i = 0; $i < self :: GRID_X; $i ++) 
    655654                                                        { 
    656655                                                                $html .= "<tr>\n"; 
    657                                                                 for($j=0;$j<self::GRID_Y;$j++) 
     656                                                                for ($j = 0; $j < self :: GRID_Y; $j ++) 
    658657                                                                { 
    659658                                                                        // Get random values for each grid positions (assert no double) 
    660659                                                                        $idx = mt_rand(0, count($photos) - 1); 
    661                                                                         while(in_array($idx, $grid_photos_idx)) 
     660                                                                        while (in_array($idx, $grid_photos_idx)) 
    662661                                                                                $idx = mt_rand(0, count($photos) - 1); 
    663662                                                                        $grid_photos_idx[] = $idx; 
     
    670669                                                                } 
    671670                                                                $html .= "</tr>\n"; 
    672                                                         }                
     671                                                        } 
    673672                                                        $html .= "</table>\n"; 
    674673                                                } 
     
    688687                                                                        } 
    689688                                                                } 
    690                                                                  
     689 
    691690                                                                $html .= '<div class="flickr_photo"><a href="'.$photo->buildUrl().'"><img src="'.$photo->buildImgUrl($size).'"></a></div>'."\n"; 
    692                                                                  
     691 
    693692                                                                if ($this->shouldDisplayTags()) 
    694693                                                                { 
     
    714713                                                                                $html .= '<div class="flickr_description">'.$description.'</div>'."\n"; 
    715714                                                                } 
    716          
     715 
    717716                                                                foreach ($photos as $cache_authors) 
    718717                                                                        $author = new Phlickr_User($api, $cache_authors->getOwnerId()); 
    719          
     718 
    720719                                                                $author = new Phlickr_User($api, $photo->getOwnerId()); 
    721720                                                                $html .= '<div class="flickr_description"><a href="'.$author->buildUrl().'">'.$author->getName().'</a></div>'."\n"; 
     
    736735                                { 
    737736                                        $html .= _("Some of the request parameters provided to Flickr API are invalid."); 
    738                     $html .= "<br>".$e->getMessage(); 
     737                                        $html .= "<br>".$e->getMessage(); 
    739738                                } 
    740739                                catch (Phlickr_XmlParseException $e) 
  • trunk/wifidog-auth/wifidog/js/gmaps_hotspots_status_map.js

    r695 r696  
    153153        if(desc.length == 1) 
    154154                html += "<i>" + desc[0].firstChild.nodeValue + "</i><br/>";*/ 
    155                  
     155         
     156        var civicNumber = hotspot_element.getElementsByTagName("civicNumber"); 
     157        if(civicNumber == 1) 
     158                html += "<i>" + civicNumber[0].firstChild.nodeValue + ",&nbsp;</i>"; 
     159                         
    156160        var streetAddress = hotspot_element.getElementsByTagName("streetAddress"); 
    157161        if(streetAddress.length == 1) 
    158                 html += "<i>" + streetAddress[0].firstChild.nodeValue + "</i><br/>"; 
     162                html += "<i>" + streetAddress[0].firstChild.nodeValue + ",&nbsp;</i><br/>"; 
     163                 
     164        var city = hotspot_element.getElementsByTagName("city"); 
     165        if(city.length == 1) 
     166                html += "<i>" + city[0].firstChild.nodeValue + ",&nbsp;</i>"; 
     167         
     168        var province = hotspot_element.getElementsByTagName("province"); 
     169        if(province.length == 1) 
     170                html += "<i>" + province[0].firstChild.nodeValue + ",&nbsp;</i>"; 
     171                 
     172        var postalCode = hotspot_element.getElementsByTagName("postalCode"); 
     173        if(postalCode.length == 1) 
     174                html += "<i>" + postalCode[0].firstChild.nodeValue + ",&nbsp;</i>"; 
     175         
     176        var country = hotspot_element.getElementsByTagName("country"); 
     177        if(country.length == 1) 
     178                html += "<i>" + country[0].firstChild.nodeValue + "</i><br/>"; 
    159179                 
    160180        var phone = hotspot_element.getElementsByTagName("contactPhoneNumber"); 
  • trunk/wifidog-auth/wifidog/lib/RssPressReview/RssPressReview.php

    r694 r696  
    11<?php 
    2  
    3  
    42/********************************************************************\ 
    53 * This program is free software; you can redistribute it and/or    * 
     
    3230        var $magpie_dir = ''; 
    3331        var $rss_sources; /**< 
    34                                         $rss_sources is an array of arrays, each of which must contain: 
    35                                         );*/ 
     32                                                        $rss_sources is an array of arrays, each of which must contain: 
     33                                                        );*/ 
    3634 
    3735        var $algorithm_strength_modifier = 0.75; 
     
    232230                        //echo "RssPressReview::addSourceFeed($url, $estimated_publication_interval)<br>\n"; 
    233231        $retval = false; 
    234         if(empty($estimated_publication_interval)) 
    235         { 
    236                 $estimated_publication_interval = DEFAULT_PUBLICATION_INTERVAL; 
    237         } 
     232                if (empty ($estimated_publication_interval)) 
     233                { 
     234                        $estimated_publication_interval = DEFAULT_PUBLICATION_INTERVAL; 
     235                } 
    238236                if (!empty ($url)) 
    239237                { 
     
    275273                return $retval; 
    276274        } 
    277          
     275 
    278276        /** Return the title of the feed, if the feed contains title information. 
    279277         * @param $url  
     
    282280        { 
    283281                $retval = false; 
    284                 if (isset ($this->rss_sources[$url])&& isset ($this->rss_sources[$url]['magpie_array']->channel['title'])) 
     282                if (isset ($this->rss_sources[$url]) && isset ($this->rss_sources[$url]['magpie_array']->channel['title'])) 
    285283                { 
    286284                        $retval = $this->rss_sources[$url]['magpie_array']->channel['title']; 
     
    397395                        echo "RssPressReview::get_rss_info($number_of_items_to_display)<br>\n"; 
    398396 
    399                 /* Calculate the average publication interval for all feeds */ 
    400                 $all_feed_publication_interval_total = null; 
    401                 reset($this->rss_sources); 
    402                 foreach ($this->rss_sources as $rss_source) 
    403                 { 
    404                         $all_feed_publication_interval_total += $rss_source['rpr_computed_publication_interval']; 
    405                 } 
    406                 $all_feed_publication_interval = $all_feed_publication_interval_total / count($this->rss_sources); 
    407  
    408                 /*Calculate the adjusted dates and create the date list array. */ 
    409                 $item_date_array = array (); 
    410                 $item_date_array_index = 0; 
    411  
    412                 foreach ($this->rss_sources as $rss_sources_key => $rss_source) 
    413                 { 
    414                         foreach ($rss_source['magpie_array']->items as $item_key => $item) 
    415                         { 
    416                                 /* Calculate the adjusted date */ 
    417                                 $feed_publication_interval = $rss_source['rpr_computed_publication_interval']; 
    418                                 $source_bias = $rss_source['source_bias']; 
    419                                 $distance_to_today = abs(time() - $item['rpr_computed_phpdate']); 
    420                                 /* With no strength modifier, a feed with a publication twice as long will get a 2x bonus on the distance to today */ 
    421                                 $original_adjust_factor = $all_feed_publication_interval / $feed_publication_interval; 
    422                                 if ($original_adjust_factor < 1) 
     397                if (!empty ($this->rss_sources)) 
     398                { 
     399                        /* Calculate the average publication interval for all feeds */ 
     400                        $all_feed_publication_interval_total = null; 
     401                        reset($this->rss_sources); 
     402                        foreach ($this->rss_sources as $rss_source) 
     403                        { 
     404                                $all_feed_publication_interval_total += $rss_source['rpr_computed_publication_interval']; 
     405                        } 
     406                        $all_feed_publication_interval = $all_feed_publication_interval_total / count($this->rss_sources); 
     407 
     408                        /*Calculate the adjusted dates and create the date list array. */ 
     409                        $item_date_array = array (); 
     410                        $item_date_array_index = 0; 
     411 
     412                        foreach ($this->rss_sources as $rss_sources_key => $rss_source) 
     413                        { 
     414                                foreach ($rss_source['magpie_array']->items as $item_key => $item) 
    423415                                { 
    424                                         $algorithm_strength_modifier = 1 / $this->algorithm_strength_modifier; 
     416                                        /* Calculate the adjusted date */ 
     417                                        $feed_publication_interval = $rss_source['rpr_computed_publication_interval']; 
     418                                        $source_bias = $rss_source['source_bias']; 
     419                                        $distance_to_today = abs(time() - $item['rpr_computed_phpdate']); 
     420                                        /* With no strength modifier, a feed with a publication twice as long will get a 2x bonus on the distance to today */ 
     421                                        $original_adjust_factor = $all_feed_publication_interval / $feed_publication_interval; 
     422                                        if ($original_adjust_factor < 1) 
     423                                        { 
     424                                                $algorithm_strength_modifier = 1 / $this->algorithm_strength_modifier; 
     425                                        } 
     426 
     427                                        /*Algorithm strength modifier doit modifier la difference de lécart du ratio  
     428                                         $all_feed_publication_interval / $feed_publication_interval avec 1/1.*/ 
     429                                        $adjust_factor = 1 - (1 - $original_adjust_factor) * $this->algorithm_strength_modifier; 
     430 
     431                                        $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_adjusted_date'] = time() - ($distance_to_today * $adjust_factor) / $source_bias; 
     432 
     433                                        /* Memorize each date, and publication intervals so we can determine the "oldest" item to publish 
     434                                         * Only consider items whose date is not farther from today than max_item_age */ 
     435                                        if ($this->max_item_age == null || abs(time() - $item['rpr_computed_phpdate']) < $this->max_item_age) 
     436                                        { 
     437                                                $item_date_array[$item_date_array_index]['rpr_adjusted_date'] = $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_adjusted_date']; 
     438                                                $item_date_array[$item_date_array_index]['rpr_computed_phpdate'] = $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_computed_phpdate']; 
     439                                                $item_date_array[$item_date_array_index]['rss_sources_key'] = $rss_sources_key; 
     440                                                $item_date_array_index ++; 
     441                                        } 
     442 
     443                                        if (isset ($this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_realphpdate'])) 
     444                                        { 
     445                                                /* Check if the item is newer than the last visit */ 
     446                                                if ($last_visit != null && $item['rpr_realphpdate'] > $last_visit) 
     447                                                { 
     448                                                        $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_is_new'] = true; 
     449                                                } 
     450 
     451                                                /* Check if the item has been published today */ 
     452                                                $item_getdate = getdate($this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_realphpdate']); 
     453                                                $today_getdate = getdate(); 
     454                                                if ($item_getdate['year'] == $today_getdate['year'] && $item_getdate['yday'] == $today_getdate['yday']) 
     455                                                { 
     456                                                        $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_is_today'] = true; 
     457                                                } 
     458                                                else 
     459                                                { 
     460                                                        $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_is_today'] = false; 
     461                                                } 
     462                                        } 
     463                                        $content = null; 
     464                                        if (!empty ($item['atom_content'])) 
     465                                        { 
     466                                                $content = $item['atom_content']; 
     467                                        } 
     468                                        else 
     469                                                if (!empty ($item['content']['encoded'])) 
     470                                                { 
     471                                                        $content = $item['content']['encoded']; 
     472                                                } 
     473                                                else 
     474                                                        if (!empty ($item['summary'])) 
     475                                                        { 
     476                                                                $content = $item['summary']; 
     477                                                        } 
     478                                        $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_content'] = $content; 
     479 
     480                                        $summary = null; 
     481                                        if (!empty ($item['summary'])) 
     482                                        { 
     483                                                $summary = $item['summary']; 
     484                                        } 
     485                                        else 
     486                                        { 
     487                                                $summary = $content; 
     488                                        } 
     489                                        $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_summary'] = $summary; 
     490 
    425491                                } 
    426492 
    427                                 /*Algorithm strength modifier doit modifier la difference de lécart du ratio  
    428                                  $all_feed_publication_interval / $feed_publication_interval avec 1/1.*/ 
    429                                 $adjust_factor = 1 - (1 - $original_adjust_factor) * $this->algorithm_strength_modifier; 
    430  
    431                                 $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_adjusted_date'] = time() - ($distance_to_today * $adjust_factor) / $source_bias; 
    432  
    433                                 /* Memorize each date, and publication intervals so we can determine the "oldest" item to publish 
    434                                  * Only consider items whose date is not farther from today than max_item_age */ 
    435                                 if ($this->max_item_age == null || abs(time() - $item['rpr_computed_phpdate']) < $this->max_item_age) 
     493                                //echo "<p>$i items, average_publication_interval (days) = ". $this->rss_sources[$rss_sources_key]['average_publication_interval']/(3600 * 24) . "</p>\n"; 
     494                        } // End foreach rss feeds 
     495 
     496                        /* Sort the item date array by adjusted date. */ 
     497                        usort($item_date_array, array ("RssPressReview", "_cmp_rpr_adjusted_date")); 
     498 
     499                        /*echo "<pre>"; 
     500                        print_r($item_date_array); 
     501                        echo "</pre>";*/ 
     502                        /* Find the "oldest" adjusted date to display */ 
     503                        if (count($item_date_array) < $number_of_items_to_display) 
     504                        { 
     505                                $number_of_items_to_display = count($item_date_array); 
     506                        } 
     507                        $min_rpr_adjusted_date_to_display = $item_date_array[$number_of_items_to_display -1]['rpr_adjusted_date']; 
     508 
     509                        if ($debug) 
     510                                echo "min_rpr_adjusted_date_to_display: $min_rpr_adjusted_date_to_display<br>\n"; 
     511                        /************** Now we actually display the feeds **************/ 
     512                        reset($this->rss_sources); 
     513                        $rss_info_tmp = null; 
     514                        foreach ($this->rss_sources as $rss_sources_key => $rss_source) 
     515                        { 
     516                                if (!$rss_source['magpie_array']) 
    436517                                { 
    437                                         $item_date_array[$item_date_array_index]['rpr_adjusted_date'] = $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_adjusted_date']; 
    438                                         $item_date_array[$item_date_array_index]['rpr_computed_phpdate'] = $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_computed_phpdate']; 
    439                                         $item_date_array[$item_date_array_index]['rss_sources_key'] = $rss_sources_key; 
    440                                         $item_date_array_index ++; 
    441                                 } 
    442  
    443                                 if (isset ($this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_realphpdate'])) 
    444                                 { 
    445                                         /* Check if the item is newer than the last visit */ 
    446                                         if ($last_visit != null && $item['rpr_realphpdate'] > $last_visit) 
    447                                         { 
    448                                                 $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_is_new'] = true; 
    449                                         } 
    450  
    451                                         /* Check if the item has been published today */ 
    452                                         $item_getdate = getdate($this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_realphpdate']); 
    453                                         $today_getdate = getdate(); 
    454                                         if ($item_getdate['year'] == $today_getdate['year'] && $item_getdate['yday'] == $today_getdate['yday']) 
    455                                         { 
    456                                                 $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_is_today'] = true; 
    457                                         } 
    458                                         else 
    459                                         { 
    460                                                 $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_is_today'] = false; 
    461                                         } 
    462                                 } 
    463                                 $content = null; 
    464                                 if(!empty($item['atom_content'])) 
    465                                 { 
    466                                         $content = $item['atom_content']; 
    467                                 } 
    468                                 else if(!empty($item['content']['encoded'])) 
    469                                 { 
    470                                         $content = $item['content']['encoded']; 
    471                                 } 
    472                                 else if(!empty($item['summary'])) 
    473                                 {        
    474                                 $content = $item['summary']; 
    475                                 } 
    476                                 $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_content'] = $content; 
    477                                  
    478                                 $summary = null; 
    479                                 if(!empty($item['summary'])) 
    480                                 {        
    481                                 $summary = $item['summary']; 
     518                                        echo _('get_rss_info(): Feed missing'); 
     519                                        return false; 
    482520                                } 
    483521                                else 
    484522                                { 
    485                                         $summary = $content; 
     523                                        unset ($rss_info_tmp); 
     524                                        $rss_info_tmp['channel'] = $this->rss_sources[$rss_sources_key]['magpie_array']->channel; 
     525 
     526                                        $i = 0; 
     527                                        /* Sort the items by date, so we get the most recent first */ 
     528                                        if (!uasort($this->rss_sources[$rss_sources_key]['magpie_array']->items, array ("RssPressReview", "_cmp_date_item"))) 
     529                                        { 
     530                                                echo _('get_rss_info(): uasort() failed!'); 
     531                                                return false; 
     532                                        } 
     533 
     534                                        $rss_info_tmp['items'] = array (); 
     535                                        foreach ($this->rss_sources[$rss_sources_key]['magpie_array']->items as $item_key => $item) 
     536                                        { 
     537                                                if ($debug) 
     538                                                        echo "Is item with rpr_adjusted_date: ".$item['rpr_adjusted_date']." after the minimum date: $min_rpr_adjusted_date_to_display?<br>\n"; 
     539 
     540                                                if ($item['rpr_adjusted_date'] >= $min_rpr_adjusted_date_to_display) 
     541                                                { 
     542                                                        if ($debug) 
     543                                                                echo "YES!<br>\n"; 
     544                                                        if (!empty ($item['dc']['creator'])) 
     545                                                        { 
     546                                                                $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_author'] = trim($item['dc']['creator']); 
     547                                                        } 
     548                                                        elseif (!empty ($item['author'])) 
     549                                                        { 
     550                                                                $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_author'] = trim($item['author']); 
     551                                                        } 
     552                                                        elseif (!empty ($item['author_name'])) 
     553                                                        { 
     554                                                                $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_author'] = trim($item['author_name']); 
     555                                                        } 
     556                                                        else 
     557                                                        { 
     558                                                                $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_author'] = ''; 
     559                                                        } 
     560 
     561                                                        $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_id'] = "summary_".mt_rand(1, 10000); 
     562                                                        array_push($rss_info_tmp['items'], $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]); 
     563                                                } 
     564                                                $i ++; 
     565                                        } // End foreach items 
     566 
     567                                        if ($debug) 
     568                                                echo count($rss_info_tmp['items'])." items (out of ".count($rss->items).") are after the minimum date in feed $rss_sources_key<br>\n"; 
     569 
     570                                        $rss_info[$rss_sources_key] = $rss_info_tmp; 
    486571                                } 
    487                                 $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_summary'] = $summary; 
    488                                  
    489                         } 
    490  
    491                         //echo "<p>$i items, average_publication_interval (days) = ". $this->rss_sources[$rss_sources_key]['average_publication_interval']/(3600 * 24) . "</p>\n"; 
    492                 } // End foreach rss feeds 
    493  
    494                 /* Sort the item date array by adjusted date. */ 
    495                 usort($item_date_array, array ("RssPressReview", "_cmp_rpr_adjusted_date")); 
    496  
    497                 /*echo "<pre>"; 
    498                 print_r($item_date_array); 
    499                 echo "</pre>";*/ 
    500                 /* Find the "oldest" adjusted date to display */ 
    501                 if (count($item_date_array) < $number_of_items_to_display) 
    502                 { 
    503                         $number_of_items_to_display = count($item_date_array); 
    504                 } 
    505                 $min_rpr_adjusted_date_to_display = $item_date_array[$number_of_items_to_display -1]['rpr_adjusted_date']; 
    506  
    507                 if ($debug) 
    508                         echo "min_rpr_adjusted_date_to_display: $min_rpr_adjusted_date_to_display<br>\n"; 
    509                 /************** Now we actually display the feeds **************/ 
    510                 reset($this->rss_sources); 
    511                 $rss_info_tmp = null; 
    512                 foreach ($this->rss_sources as $rss_sources_key => $rss_source) 
    513                 { 
    514                         if (!$rss_source['magpie_array']) 
    515                         { 
    516                                 echo _('get_rss_info(): Feed missing'); 
    517                                 return false; 
    518                         } 
    519                         else 
    520                         { 
    521                                 unset ($rss_info_tmp); 
    522                                 $rss_info_tmp['channel'] = $this->rss_sources[$rss_sources_key]['magpie_array']->channel; 
    523  
    524                                 $i = 0; 
    525                                 /* Sort the items by date, so we get the most recent first */ 
    526                                 if (!uasort($this->rss_sources[$rss_sources_key]['magpie_array']->items, array ("RssPressReview", "_cmp_date_item"))) 
    527                                 { 
    528                                         echo _('get_rss_info(): uasort() failed!'); 
    529                                         return false; 
    530                                 } 
    531  
    532                                 $rss_info_tmp['items'] = array (); 
    533                                 foreach ($this->rss_sources[$rss_sources_key]['magpie_array']->items as $item_key => $item) 
    534                                 { 
    535                                         if ($debug) 
    536                                                 echo "Is item with rpr_adjusted_date: ".$item['rpr_adjusted_date']." after the minimum date: $min_rpr_adjusted_date_to_display?<br>\n"; 
    537  
    538                                         if ($item['rpr_adjusted_date'] >= $min_rpr_adjusted_date_to_display) 
    539                                         { 
    540                                                 if ($debug) 
    541                                                         echo "YES!<br>\n"; 
    542                                                 if (!empty ($item['dc']['creator'])) 
    543                                                 { 
    544                                                         $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_author'] = trim($item['dc']['creator']); 
    545                                                 } 
    546                                                 elseif (!empty ($item['author'])) 
    547                                                 { 
    548                                                         $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_author'] = trim($item['author']); 
    549                                                 } 
    550                                                 elseif (!empty ($item['author_name'])) 
    551                                                 { 
    552                                                         $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_author'] = trim($item['author_name']); 
    553                                                 } 
    554                                                 else 
    555                                                 { 
    556                                                         $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_author'] = ''; 
    557                                                 } 
    558  
    559                                                 $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]['rpr_id'] = "summary_".mt_rand(1, 10000); 
    560                                                 array_push($rss_info_tmp['items'], $this->rss_sources[$rss_sources_key]['magpie_array']->items[$item_key]); 
    561                                         } 
    562                                         $i ++; 
    563                                 } // End foreach items 
    564  
    565                                 if ($debug) 
    566                                         echo count($rss_info_tmp['items'])." items (out of ".count($rss->items).") are after the minimum date in feed $rss_sources_key<br>\n"; 
    567  
    568                                 $rss_info[$rss_sources_key] = $rss_info_tmp; 
    569                         } 
    570                 } // End foreach rss feeds 
    571                 /*echo "\n<pre>\n"; 
    572                 print_r($rss_info); 
    573                 echo "\n</pre>\n"; 
    574                 */ 
    575                 return $rss_info; 
    576  
     572                        } // End foreach rss feeds 
     573                        /*echo "\n<pre>\n"; 
     574                        print_r($rss_info); 
     575                        echo "\n</pre>\n"; 
     576                        */ 
     577                        return $rss_info; 
     578                } 
     579                else 
     580                        return null; 
    577581        } 
    578582 
     
    585589                        $done_header = true; 
    586590                        return ' 
    587                                                                                                                                                                          
    588 <script language="JavaScript" type="text/javascript"> 
    589 function MM_findObj(n, d) { //v4.0 
    590 var p,i,x; 
    591 if(!d) d=document;  
    592 if((p=n.indexOf("?"))>0&&parent.frames.length) { 
    593 d=parent.frames[n.substring(p+1)].document;  
    594 n=n.substring(0,p); 
    595 } 
    596 if(!(x=d[n])&&d.all) x=d.all[n];  
    597 for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; 
    598 for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); 
    599 if(!x && document.getElementById) x=document.getElementById(n); return x; 
    600 } 
    601                                                                                                                                                                                          
    602 function changestyle(couche, style) { 
    603 if (!(layer = MM_findObj(couche))) return; 
    604 if(layer.className != "rpr_popup_inner_div_expanded") 
    605 { 
    606 layer.style.visibility = style; 
    607 } 
    608 } 
    609                                                                                                                                                                                          
    610 function changeclass(objet, myClass) 
    611 {  
    612 objet.className = myClass; 
    613 } 
    614  
    615 function toggleItemVisibility(item_id) 
    616 { 
    617 if (!(layer = MM_findObj(item_id))) return; 
    618 if(layer.className != "rpr_popup_inner_div_expanded") 
    619 { 
    620 layer.style.visibility = "visible"; 
    621 layer.className = "rpr_popup_inner_div_expanded"; 
    622 } 
    623 else 
    624 { 
    625 layer.style.visibility = "hidden"; 
    626 layer.className = "rpr_popup_inner_div"; 
    627 } 
    628 } 
    629 </script> 
    630  
    631 <style type="text/css"> 
    632  
    633 /*h2 {color: green}*/ 
    634 .rpr_header {margin: 0em 0em 0em 0em; 
    635 padding: 0em 0em 0em 0em;} 
    636 .rpr_title { font-weight: bold;  
    637              font-size: 90%} 
    638 .rpr_title_date { font-weight: lighter; } 
    639  
    640 .rpr_item_list { 
    641 padding: 0em 1em 0em 1em; 
    642 margin: 0em 1em 0em 1em;} 
    643 .rpr_item { list-style-type: none;  
    644 } 
    645 .rpr_item_title { 
    646 margin: 0em 0em 0em 0em; 
    647 padding: 0em 0em 0em 0em;} 
    648  
    649  
    650 .rpr_item_link { } 
    651 .rpr_expand_switch { font-weight: bolder; 
    652 text-decoration: none; 
    653 /*border: 1px solid black*/ } 
    654 /*.rpr_expand_switch:before { content: "+"; }*/ 
    655  
    656 .rpr_popup_inner_div {  
    657 z-index: 1000; 
    658 display: inline; 
    659 padding: 0.5em; 
    660 border: 2px outset #324C48; 
    661 background-color: #f9f9f9; 
    662 visibility: hidden; 
    663 position: absolute; 
    664 left: 4em; 
    665 top: 1.5em; 
    666 width: 350px; 
    667 -moz-opacity: 0.95; filter: alpha(opacity=95); 
    668 } 
    669  
    670 .rpr_popup_inner_div_expanded { 
    671 margin:  0.5em 1em 0em 1em; 
    672 padding: 0.5em; 
    673 border: 2px outset #324C48; 
    674 background-color: #f9f9f9; 
    675 }  
    676 .rpr_popup_outer_div {  
    677 z-index: 1000; 
    678  position: relative; 
    679  display: inline; 
    680 } 
    681  
    682  
    683 </style> 
    684  
    685 '; 
    686  
     591                                                                                                                                                                                                                         
     592                                                <script language="JavaScript" type="text/javascript"> 
     593                                                function MM_findObj(n, d) { //v4.0 
     594                                                var p,i,x; 
     595                                                if(!d) d=document;  
     596                                                if((p=n.indexOf("?"))>0&&parent.frames.length) { 
     597                                                d=parent.frames[n.substring(p+1)].document;  
     598                                                n=n.substring(0,p); 
     599                                                } 
     600                                                if(!(x=d[n])&&d.all) x=d.all[n];  
     601                                                for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n]; 
     602                                                for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document); 
     603                                                if(!x && document.getElementById) x=document.getElementById(n); return x; 
     604                                                } 
     605                                                                                                                                                                                                                                         
     606                                                function changestyle(couche, style) { 
     607                                                if (!(layer = MM_findObj(couche))) return; 
     608                                                if(layer.className != "rpr_popup_inner_div_expanded") 
     609                                                { 
     610                                                layer.style.visibility = style; 
     611                                                } 
     612                                                } 
     613                                                                                                                                                                                                                                         
     614                                                function changeclass(objet, myClass) 
     615                                                {  
     616                                                objet.className = myClass; 
     617                                                } 
     618                                                 
     619                                                function toggleItemVisibility(item_id) 
     620                                                { 
     621                                                if (!(layer = MM_findObj(item_id))) return; 
     622                                                if(layer.className != "rpr_popup_inner_div_expanded") 
     623                                                { 
     624                                                layer.style.visibility = "visible"; 
     625                                                layer.className = "rpr_popup_inner_div_expanded"; 
     626                                                } 
     627                                                else 
     628                                                { 
     629                                                layer.style.visibility = "hidden"; 
     630                                                layer.className = "rpr_popup_inner_div"; 
     631                                                } 
     632                                                } 
     633                                                </script> 
     634                                                 
     635                                                <style type="text/css"> 
     636                                                 
     637                                                /*h2 {color: green}*/ 
     638                                                .rpr_header {margin: 0em 0em 0em 0em; 
     639                                                padding: 0em 0em 0em 0em;} 
     640                                                .rpr_title { font-weight: bold;  
     641                                                             font-size: 90%} 
     642                                                .rpr_title_date { font-weight: lighter; } 
     643                                                 
     644                                                .rpr_item_list { 
     645                                                padding: 0em 1em 0em 1em; 
     646                                                margin: 0em 1em 0em 1em;} 
     647                                                .rpr_item { list-style-type: none;  
     648                                                } 
     649                                                .rpr_item_title { 
     650                                                margin: 0em 0em 0em 0em; 
     651                                                padding: 0em 0em 0em 0em;} 
     652                                                 
     653                                                 
     654                                                .rpr_item_link { } 
     655                                                .rpr_expand_switch { font-weight: bolder; 
     656                                                text-decoration: none; 
     657                                                /*border: 1px solid black*/ } 
     658                                                /*.rpr_expand_switch:before { content: "+"; }*/ 
     659                                                 
     660                                                .rpr_popup_inner_div {  
     661                                                z-index: 1000; 
     662                                                display: inline; 
     663                                                padding: 0.5em; 
     664                                                border: 2px outset #324C48; 
     665                                                background-color: #f9f9f9; 
     666                                                visibility: hidden; 
     667                                                position: absolute; 
     668                                                left: 4em; 
     669                                                top: 1.5em; 
     670                                                width: 350px; 
     671                                                -moz-opacity: 0.95; filter: alpha(opacity=95); 
     672                                                } 
     673                                                 
     674                                                .rpr_popup_inner_div_expanded { 
     675                                                margin:  0.5em 1em 0em 1em; 
     676                                                padding: 0.5em; 
     677                                                border: 2px outset #324C48; 
     678                                                background-color: #f9f9f9; 
     679                                                }  
     680                                                .rpr_popup_outer_div {  
     681                                                z-index: 1000; 
     682                                                 position: relative; 
     683                                                 display: inline; 
     684                                                } 
     685                                                 
     686                                                 
     687                                                </style> 
     688                                                 
     689                                                '; 
    687690 
    688691                } 
     
    694697        function get_rss_html($number_of_items_to_display = 20, $last_visit = null, $show_empty_sources = true) 
    695698        { 
    696                 $rss_result = $this->get_rss_info($number_of_items_to_display, $last_visit); 
    697  
    698699                $html = ''; 
    699                 foreach ($rss_result as $feed_id => $feed) 
    700                 { 
    701                         if (count($feed['items']) > 0 || $show_empty_sources == true) 
    702                         { 
    703                                 $feed_html = ''; 
    704                                 $dhtml_id = "feed_".md5($feed_id); 
    705                                 $feed_html .= "<p class='rpr_header'>"._('Source: '); 
    706                                 $feed_html .= "<span class='rpr_title' onMouseOver=\"changestyle('$dhtml_id','visible');\" onMouseOut=\"changestyle('$dhtml_id','hidden');\">\n"; 
    707                                 if (!empty ($feed['link'])) 
     700                if (($rss_result = $this->get_rss_info($number_of_items_to_display, $last_visit)) !== null) 
     701                { 
     702                        foreach ($rss_result as $feed_id => $feed) 
     703                        { 
     704                                if (count($feed['items']) > 0 || $show_empty_sources == true) 
    708705                                { 
    709                                         $feed_html .= "<a class='y' href='".$feed['link']."'>".$feed['channel']['title']."</a>"; 
     706                                        $feed_html = ''; 
     707                                        $dhtml_id = "feed_".md5($feed_id); 
     708                                        $feed_html .= "<p class='rpr_header'>"._('Source: '); 
     709                                        $feed_html .= "<span class='rpr_title' onMouseOver=\"changestyle('$dhtml_id','visible');\" onMouseOut=\"changestyle('$dhtml_id','hidden');\">\n"; 
     710                                        if (!empty ($feed['link'])) 
     711                                        { 
     712                                                $feed_html .= "<a class='y' href='".$feed['link']."'>".$feed['channel']['title']."</a>"; 
     713                                        } 
     714                                        else 
     715                                        { 
     716                                                $feed_html .= $feed['channel']['title']; 
     717                                        } 
     718                                        $feed_html .= "</span>\n"; 
     719                                        $feed_html .= "</p>\n"; 
     720 
     721                                        $feed_html .= "<div class='rpr_popup_outer_div'>\n"; 
     722                                        $feed_html .= "<div id='$dhtml_id' class='rpr_popup_inner_div'>\n"; 
     723                                        $feed_html .= "<p class='rpr_text'>{$feed['channel']['title']}  </p>\n"; 
     724                                        if (!empty ($feed['channel']['description'])) 
     725                                        { 
     726                                                $description = strip_tags($feed['channel']['description'], "<p><a><img><b><i>"); 
     727                                                $feed_html .= "<p class='rpr_text'>{$description}</p>\n"; 
     728                                        } 
     729                                        $feed_html .= "<p class='rpr_text'>{$feed_id}</p>\n"; 
     730                                        $feed_html .= "</div></div>\n"; 
     731 
     732                                        $feed_html .= "<ul class='rpr_item_list'>\n"; 
     733 
     734                                        foreach ($feed['items'] as $item) 
     735                                        { 
     736                                                if ($item['rpr_is_today']) 
     737                                                { 
     738                                                        $display_date = _("Today"); 
     739                                                } 
     740                                                else 
     741                                                        if ($item['rpr_realphpdate'] != -1) 
     742                                                        { 
     743                                                                setlocale(LC_TIME, "fr_CA"); 
     744                                                                $display_date = strftime("%x", $item['rpr_realphpdate']); 
     745                                                        } 
     746                                                        else 
     747                                                        { 
     748                                                                $display_date = ''; 
     749                                                                //$display_date = "Estimated: ".strftime("%x", $item['rpr_computed_phpdate']); 
     750                                                        } 
     751 
     752                                                $dhtml_id = "summary_".mt_rand(1, 10000); 
     753                                                $feed_html .= "<li class='rpr_item'>\n"; 
     754                                                $feed_html .= "<p class='rpr_item_title'>\n"; 
     755                                                $item['rpr_is_today'] ? $switch_content = '-' : $switch_content = '+'; 
     756 
     757                                                $feed_html .= "<a class='rpr_expand_switch' href='#dummy' onClick=\"toggleItemVisibility('$dhtml_id'); if(this.innerHTML=='+'){this.innerHTML='-';}else{this.innerHTML='+';}\">$switch_content</a> "; 
     758                                                $feed_html .= "<span class='rpr_title_date'>$display_date</span>"; 
     759                                                $feed_html .= "<span class='rpr_title' onMouseOver=\"changestyle('$dhtml_id','visible');\" onMouseOut=\"changestyle('$dhtml_id','hidden');\">\n"; 
     760                                                if (!empty ($item['link'])) 
     761                                                { 
     762                                                        $feed_html .= "<a class='rpr_item_link' href='{$item['link']}'>{$item['title']}</a>"; 
     763                                                } 
     764                                                else 
     765                                                { 
     766                                                        $feed_html .= "{$item['title']}"; 
     767                                                } 
     768                                                $feed_html .= "</span></p>\n"; 
     769                                                $feed_html .= "<div class='rpr_popup_outer_div'>\n"; 
     770                                                $item['rpr_is_today'] ? $class = 'rpr_popup_inner_div_expanded' : $class = 'rpr_popup_inner_div'; 
     771                                                $feed_html .= "<div class='$class' id='$dhtml_id'>\n"; 
     772                                                $feed_html .= "<p class='rpr_text'>{$item['rpr_author']} ({$feed['channel']['title']}) $display_date</p>\n"; 
     773                                                $summary = strip_tags($item['rpr_content'], "<br><p><a><img><b><i>"); 
     774                                                $feed_html .= "<p class='rpr_text'>{$summary}</p></div>\n"; 
     775                                                $feed_html .= "</div>\n"; 
     776                                                $feed_html .= "</li>\n"; 
     777                                        } 
     778                                        $feed_html .= "</ul>\n"; 
     779 
     780                                        $html .= $feed_html; 
    710781                                } 
    711                                 else 
    712                                 { 
    713                                         $feed_html .= $feed['channel']['title']; 
    714                                 } 
    715                                 $feed_html .= "</span>\n"; 
    716                                 $feed_html .= "</p>\n"; 
    717  
    718                                 $feed_html .= "<div class='rpr_popup_outer_div'>\n"; 
    719                                 $feed_html .= "<div id='$dhtml_id' class='rpr_popup_inner_div'>\n"; 
    720                                 $feed_html .= "<p class='rpr_text'>{$feed['channel']['title']}  </p>\n"; 
    721                                 if(!empty($feed['channel']['description'])) 
    722                                 { 
    723                                 $description = strip_tags($feed['channel']['description'], "<p><a><img><b><i>"); 
    724                                 $feed_html .= "<p class='rpr_text'>{$description}</p>\n"; 
    725                                 } 
    726                                 $feed_html .= "<p class='rpr_text'>{$feed_id}</p>\n"; 
    727                                 $feed_html .= "</div></div>\n"; 
    728  
    729                                 $feed_html .= "<ul class='rpr_item_list'>\n"; 
    730  
    731                                 foreach ($feed['items'] as $item) 
    732                                 { 
    733                                         if ($item['rpr_is_today']) 
    734                                         { 
    735                                                 $display_date = _("Today"); 
    736                                         } 
    737                                         else if ($item['rpr_realphpdate'] != -1) 
    738                                         { 
    739                                                 setlocale(LC_TIME, "fr_CA"); 
    740                                                 $display_date = strftime("%x", $item['rpr_realphpdate']); 
    741                                         } 
    742                                         else 
    743                                         { 
    744                                                 $display_date = ''; 
    745                                                 //$display_date = "Estimated: ".strftime("%x", $item['rpr_computed_phpdate']); 
    746                                         } 
    747  
    748                                         $dhtml_id = "summary_".mt_rand(1, 10000); 
    749                                         $feed_html .= "<li class='rpr_item'>\n"; 
    750                                         $feed_html .= "<p class='rpr_item_title'>\n"; 
    751                                         $item['rpr_is_today'] ? $switch_content = '-':$switch_content = '+'; 
    752                                          
    753                                         $feed_html .= "<a class='rpr_expand_switch' href='#dummy' onClick=\"toggleItemVisibility('$dhtml_id'); if(this.innerHTML=='+'){this.innerHTML='-';}else{this.innerHTML='+';}\">$switch_content</a> "; 
    754                                         $feed_html .= "<span class='rpr_title_date'>$display_date</span>"; 
    755                                         $feed_html .= "<span class='rpr_title' onMouseOver=\"changestyle('$dhtml_id','visible');\" onMouseOut=\"changestyle('$dhtml_id','hidden');\">\n"; 
    756                                         if ($item['link']) 
    757                                         { 
    758                                                 $feed_html .= "<a class='rpr_item_link' href='{$item['link']}'>{$item['title']}</a>"; 
    759                                         } 
    760                                         else 
    761                                         { 
    762                                                 $feed_html .= "{$item['title']}"; 
    763                                         } 
    764                                         $feed_html .= "</span></p>\n"; 
    765                                         $feed_html .= "<div class='rpr_popup_outer_div'>\n"; 
    766                                         $item['rpr_is_today'] ? $class = 'rpr_popup_inner_div_expanded':$class = 'rpr_popup_inner_div'; 
    767                                         $feed_html .= "<div class='$class' id='$dhtml_id'>\n"; 
    768                                         $feed_html .= "<p class='rpr_text'>{$item['rpr_author']} ({$feed['channel']['title']}) $display_date</p>\n"; 
    769                                         $summary = strip_tags($item['rpr_content'], "<br><p><a><img><b><i>"); 
    770                                         $feed_html .= "<p class='rpr_text'>{$summary}</p></div>\n"; 
    771                                         $feed_html .= "</div>\n"; 
    772                                         $feed_html .= "</li>\n"; 
    773                                 } 
    774                                 $feed_html .= "</ul>\n"; 
    775  
    776                                 $html .= $feed_html; 
    777782                        } 
    778783                } 
     
    781786} 
    782787?> 
    783  
    784  
    785  
    786  
    787  
    788  
    789  
  • trunk/wifidog-auth/wifidog/templates/hotspot_status.html

    r566 r696  
    5353 
    5454    <td> 
    55     {if $nodes[node].street_address}{$nodes[node].street_address}{/if} 
     55    {if $nodes[node].civic_number}{$nodes[node].civic_number}, {/if} 
     56    {if $nodes[node].street_name}{$nodes[node].street_name}, {/if} 
     57    {if $nodes[node].city}{$nodes[node].city}, {/if} 
     58    {if $nodes[node].province}{$nodes[node].province}, {/if} 
     59    {if $nodes[node].postal_code}{$nodes[node].postal_code}, {/if} 
     60    {if $nodes[node].country}{$nodes[node].country}{/if}         
    5661    {if $nodes[node].map_url} - <a href='{$nodes[node].map_url}' target='_new'>Map</a>{/if} 
    5762    {if $nodes[node].mass_transit_info}<br />{$nodes[node].mass_transit_info}{/if}