Changeset 559

Show
Ignore:
Timestamp:
04/20/05 13:08:14 (8 years ago)
Author:
fproulx
Message:

2005-04-20 Fran�ois Proulx <francois.proulx@…>

  • Completed Flickr support ( explicit exceptions catching )
  • Most of File object is done
  • Fixed bug in generic_object_admin.php
  • changed stylesheet class tags for Flickr
Location:
trunk/wifidog-auth
Files:
6 modified

Legend:

Unmodified
Added
Removed
  • trunk/wifidog-auth/ChangeLog

    r555 r559  
     12005-04-20 François Proulx <francois.proulx@gmail.com> 
     2        * Completed Flickr support ( explicit exceptions catching ) 
     3        * Most of File object is done 
     4        * Fixed bug in generic_object_admin.php 
     5        * changed stylesheet class tags for Flickr 
     6         
    172005-04-18 François Proulx <francois.proulx@gmail.com> 
    28        * Added Flickr content support 
  • trunk/wifidog-auth/wifidog/admin/generic_object_admin.php

    r555 r559  
    6969if ($_REQUEST['action'] == 'save') 
    7070{ 
    71  
    7271        $html .= $object->processAdminUI(); 
     72    $object = call_user_func(array ($class, 'getObject'), $_REQUEST['object_id']); 
    7373        $_REQUEST['action'] = 'edit'; 
    7474} 
  • trunk/wifidog-auth/wifidog/admin/index.php

    r553 r559  
    3030 
    3131$smarty->display("templates/header.html"); 
    32 $html = ''; 
    33 $html .= "<ul>\n"; 
    34 $html .= "<li><a href='user_log.php'>"._("User logs")."</a></li>\n"; 
    35 $html .= "<li><a href='online_users.php'>"._("Online Users")."</a></li>\n"; 
    36 $html .= "<li><a href='user_stats.php'>"._("Cumulative user statistics")."</a></li>\n"; 
    37 $html .= "<li><a href='hotspot_log.php'>"._("Hotspot logs")."</a></li>\n"; 
    38 $html .= "<li><a href='import_user_database.php'>"._("Import NoCat user database")."</a></li>\n"; 
    39 $html .= "<li><a href='hotspot.php'>"._("Hotspot creation and configuration")."</a> - Beta</li>\n"; 
    40 $html .= "<li><a href='owner_sendfiles.php'>"._("Hotspot owner administration")."</a> - Beta</li>\n"; 
    41  
    42 /* Node admin */ 
    43 $html .= "<div class='admin_section_container'>\n"; 
    44 $html .= '<form action="'.GENERIC_OBJECT_ADMIN_ABS_HREF.'" method="get">'; 
    45 $html .= "<div class='admin_section_title'>"._("Node administration:")." </div>\n"; 
    46  
    47 $html .= "<div class='admin_section_data'>\n"; 
    48 $html .= "<input type='hidden' name='action' value='edit'>\n"; 
    49 $html .= "<input type='hidden' name='object_class' value='Node'>\n"; 
    5032 
    5133$current_user = User :: getCurrentUser(); 
    52 if ($current_user->isSuperAdmin()) 
     34if(!$current_user) 
    5335{ 
    54         $sql_additional_where = ''; 
     36    $html = _('You must be logged in to access the administration panel.'); 
    5537} 
    5638else 
    5739{ 
    58         $sql_additional_where = "AND node_id IN (SELECT node_id from node_owners WHERE user_id='".$current_user->getId()."')"; 
     40    $html = ''; 
     41    $html .= "<ul>\n"; 
     42    $html .= "<li><a href='user_log.php'>"._("User logs")."</a></li>\n"; 
     43    $html .= "<li><a href='online_users.php'>"._("Online Users")."</a></li>\n"; 
     44    $html .= "<li><a href='user_stats.php'>"._("Cumulative user statistics")."</a></li>\n"; 
     45    $html .= "<li><a href='hotspot_log.php'>"._("Hotspot logs")."</a></li>\n"; 
     46    $html .= "<li><a href='import_user_database.php'>"._("Import NoCat user database")."</a></li>\n"; 
     47    $html .= "<li><a href='hotspot.php'>"._("Hotspot creation and configuration")."</a> - Beta</li>\n"; 
     48    $html .= "<li><a href='owner_sendfiles.php'>"._("Hotspot owner administration")."</a> - Beta</li>\n"; 
     49     
     50    /* Node admin */ 
     51    $html .= "<div class='admin_section_container'>\n"; 
     52    $html .= '<form action="'.GENERIC_OBJECT_ADMIN_ABS_HREF.'" method="get">'; 
     53    $html .= "<div class='admin_section_title'>"._("Node administration:")." </div>\n"; 
     54     
     55    $html .= "<div class='admin_section_data'>\n"; 
     56    $html .= "<input type='hidden' name='action' value='edit'>\n"; 
     57    $html .= "<input type='hidden' name='object_class' value='Node'>\n"; 
     58     
     59    if ($current_user->isSuperAdmin()) 
     60    { 
     61        $sql_additional_where = ''; 
     62    } 
     63    else 
     64    { 
     65        $sql_additional_where = "AND node_id IN (SELECT node_id from node_owners WHERE user_id='".$current_user->getId()."')"; 
     66    } 
     67    $html .= Node :: getSelectNodeUI('object_id', $sql_additional_where); 
     68    $html .= "</div>\n"; 
     69    $html .= "<div class='admin_section_tools'>\n"; 
     70     
     71    $html .= "<input type=submit name='edit_submit' value='"._("Edit")."'>\n"; 
     72    $html .= "</div>\n"; 
     73    $html .= '</form>'; 
     74    $html .= "</div>\n"; 
     75     
     76    /* Network admin */ 
     77    $html .= "<div class='admin_section_container'>\n"; 
     78    $html .= '<form action="'.GENERIC_OBJECT_ADMIN_ABS_HREF.'" method="post">'; 
     79    $html .= "<div class='admin_section_title'>"._("Network administration:")." </div>\n"; 
     80     
     81    $html .= "<div class='admin_section_data'>\n"; 
     82    $html .= "<input type='hidden' name='action' value='edit'>\n"; 
     83    $html .= "<input type='hidden' name='object_class' value='Network'>\n"; 
     84    $html .= Network :: getSelectNetworkUI('object_id'); 
     85    $html .= "</div>\n"; 
     86    $html .= "<div class='admin_section_tools'>\n"; 
     87     
     88    $html .= "<input type=submit name='edit_submit' value='"._("Edit")."'>\n"; 
     89    $html .= "</div>\n"; 
     90    $html .= '</form>'; 
     91    $html .= "</div>\n"; 
     92     
     93    $html .= "<li><a href='content_admin.php'>"._("Content manager")."</a></li>\n"; 
     94    $html .= "</ul>\n"; 
    5995} 
    60 $html .= Node :: getSelectNodeUI('object_id', $sql_additional_where); 
    61 $html .= "</div>\n"; 
    62 $html .= "<div class='admin_section_tools'>\n"; 
    63  
    64 $html .= "<input type=submit name='edit_submit' value='"._("Edit")."'>\n"; 
    65 $html .= "</div>\n"; 
    66 $html .= '</form>'; 
    67 $html .= "</div>\n"; 
    68  
    69 /* Network admin */ 
    70 $html .= "<div class='admin_section_container'>\n"; 
    71 $html .= '<form action="'.GENERIC_OBJECT_ADMIN_ABS_HREF.'" method="post">'; 
    72 $html .= "<div class='admin_section_title'>"._("Network administration:")." </div>\n"; 
    73  
    74 $html .= "<div class='admin_section_data'>\n"; 
    75 $html .= "<input type='hidden' name='action' value='edit'>\n"; 
    76 $html .= "<input type='hidden' name='object_class' value='Network'>\n"; 
    77 $html .= Network :: getSelectNetworkUI('object_id'); 
    78 $html .= "</div>\n"; 
    79 $html .= "<div class='admin_section_tools'>\n"; 
    80  
    81 $html .= "<input type=submit name='edit_submit' value='"._("Edit")."'>\n"; 
    82 $html .= "</div>\n"; 
    83 $html .= '</form>'; 
    84 $html .= "</div>\n"; 
    85  
    86 $html .= "<li><a href='content_admin.php'>"._("Content manager")."</a></li>\n"; 
    87 $html .= "</ul>\n"; 
    8896 
    8997echo $html; 
  • trunk/wifidog-auth/wifidog/classes/Content/File.php

    r556 r559  
    3434class File extends Content 
    3535{ 
     36    /* File size units */ 
     37    const UNIT_BYTES = 1; 
     38    const UNIT_KILOBYTES = 1024; 
     39    const UNIT_MEGABYTES = 1048576; 
     40    const UNIT_GIGABYTES = 1073741824; 
     41     
    3642        /**Constructeur 
    3743        @param $content_id Content id 
     
    4551 
    4652                $content_id = $db->EscapeString($content_id); 
    47                 $sql = "SELECT files_id, filename, mime_type FROM files WHERE files_id='$content_id'"; 
     53                $sql = "SELECT files_id, filename, mime_type, url, octet_length(binary_data) AS size FROM files WHERE files_id='$content_id'"; 
    4854                $db->ExecSqlUniqueRes($sql, $row, false); 
    4955                if ($row == null) 
     
    5359                        $db->ExecSqlUpdate($sql, false); 
    5460 
    55                         $sql = "SELECT files_id, filename, mime_type FROM files WHERE files_id='$content_id'"; 
     61                        $sql = "SELECT files_id, filename, mime_type, url, octet_length(binary_data) AS size FROM files WHERE files_id='$content_id'"; 
    5662                        $db->ExecSqlUniqueRes($sql, $row, false); 
    5763                        if ($row == null) 
     
    129135                $this->refresh(); 
    130136        } 
     137     
     138    function getFileSize($unit = self::UNIT_BYTES) 
     139    { 
     140        switch($unit) 
     141        { 
     142            case self::UNIT_KILOBYTES; 
     143            case self::UNIT_MEGABYTES: 
     144            case self::UNIT_GIGABYTES: 
     145            case self::UNIT_BYTES: 
     146                return round($this->files_row['size'] / $unit, 2); 
     147            default: 
     148                return $this->files_row['size']; 
     149                break; 
     150        } 
     151    } 
     152     
     153    function getFileUrl() 
     154    { 
     155        //TODO: build local url + file generator 
     156        if(!isLocalFile()) 
     157            return $this->files_row['url']; 
     158        else 
     159            return "http://"; 
     160    } 
     161     
     162    function setURL($url) 
     163    { 
     164        $url = $this->mBd->EscapeString($url); 
     165        $this->mBd->execSqlUpdate("UPDATE files SET url = '$url' WHERE files_id='".$this->getId()."'", false); 
     166        $this->refresh(); 
     167    } 
     168     
     169    function isLocalFile() 
     170    { 
     171        return !empty($this->files_row['url']); 
     172    } 
    131173 
    132174        /**Affiche l'interface d'administration de l'objet */ 
     
    137179         
    138180                $html .= "<div class='admin_section_container'>\n"; 
    139         $html .= "<div class='admin_section_title'>"._("Upload a new file (This will replace any existing file)")." : </div>\n"; 
     181        $html .= "<div class='admin_section_title'>"; 
     182        $html .= "<input type='radio' name='file_by_upload".$this->getId()."' value='true' ".(!$this->isLocalFile()?"CHECKED":"").">"; 
     183        $html .= _("Upload a new file (This will replace any existing file)")." : </div>\n"; 
    140184        $html .= "<div class='admin_section_data'>\n"; 
    141185        $html .= '<input type="hidden" name="MAX_FILE_SIZE" value="1073741824" />'; 
     
    145189         
    146190        $html .= "<div class='admin_section_container'>\n"; 
     191        $html .= "<div class='admin_section_title'>"; 
     192        $html .= "<input type='radio' name='file_by_url".$this->getId()."' value='true' ".($this->isLocalFile()?"CHECKED":"").">"; 
     193        $html .= _("Remote file via URL")." : </div>\n"; 
     194        $html .= "<div class='admin_section_data'>\n"; 
     195        $html .= "<input name='file_url".$this->getId()."' type='text' size='50'/>"; 
     196        $html .= "</div>\n"; 
     197        $html .= "</div>\n"; 
     198         
     199        $html .= "<div class='admin_section_container'>\n"; 
    147200        $html .= "<div class='admin_section_title'>"._("Filename")." : </div>\n"; 
    148201        $html .= "<div class='admin_section_data'>\n"; 
     
    158211        $html .= "</div>\n"; 
    159212         
     213        if($this->isLocalFile()) 
     214        { 
     215            $html .= "<div class='admin_section_container'>\n"; 
     216            $html .= "<div class='admin_section_title'>"._("File size")." : </div>\n"; 
     217            $html .= "<div class='admin_section_data'>\n"; 
     218            $html .= $this->getFileSize(self::UNIT_KILOBYTES)." "._("KB"); 
     219            $html .= "</div>\n"; 
     220            $html .= "</div>\n"; 
     221        } 
     222        else 
     223        { 
     224            //TODO: implement user defined size 
     225        } 
     226         
    160227                return parent :: getAdminUI($html); 
    161228        } 
     
    166233         
    167234        // If no file was uploaded, update filename and mime type 
    168         if(!$this->setBinaryDataFromPostVar("file_file_upload".$this->getId())) 
    169         { 
    170             $this->setMimeType($_REQUEST["file_mime_type".$this->getId()]); 
    171             $this->setFilename($_REQUEST["file_file_name".$this->getId()]); 
    172         } 
     235        if(!empty($_REQUEST["file_by_upload".$this->getId()])) 
     236        { 
     237            $this->setBinaryDataFromPostVar("file_file_upload".$this->getId()); 
     238        } 
     239        else 
     240            if(!empty($_REQUEST["file_url".$this->getId()])) 
     241            { 
     242                $this->setURL($_REQUEST["file_url".$this->getId()]); 
     243            } 
     244        $this->setMimeType($_REQUEST["file_mime_type".$this->getId()]); 
     245        $this->setFilename($_REQUEST["file_file_name".$this->getId()]); 
    173246        } 
    174247 
     
    179252         * @param $subclass_admin_interface Html content of the interface element of a children 
    180253         * @return The HTML fragment for this interface */ 
    181         public function getUserUI($subclass_user_interface = null) 
     254        public function getUserUI() 
    182255        { 
    183256                $html = ''; 
    184257                $html .= "<div class='user_ui_container'>\n"; 
    185258                $html .= "<div class='user_ui_object_class'>Langstring (".get_class($this)." instance)</div>\n"; 
    186                 $html .= $this->getString(); 
    187                 $html .= $subclass_user_interface; 
     259                $html .= "<a href='".$this->getFileUrl()."'>"._("Download this file")." (".$this->getFileSize(UNIT_KILOBYTES)." "._("KB").")</a>"; 
    188260                $html .= "</div>\n"; 
    189261                return parent :: getUserUI($html); 
  • trunk/wifidog-auth/wifidog/classes/Content/FlickrPhotostream.php

    r555 r559  
    555555                    if(is_object($photo)) 
    556556                    { 
    557                         $html .= '<div class="FlickrPhotoBlock">'."\n"; 
    558                         $html .= '<div class="FlickrTitle"><h3>'.$photo->getTitle().'</h3></div>'."\n"; 
    559                         $html .= '<div class="FlickrPhoto"><a href="'.$photo->buildUrl().'"><img src="'.$photo->buildImgUrl().'"></a></div>'."\n"; 
    560                         $tags = $photo->getTags(); 
    561                         if(!empty($tags)) 
     557                        $html .= '<div class="flickr_photo_block">'."\n"; 
     558                        if($this->shouldDisplayTitle()) 
     559                            $html .= '<div class="flickr_title"><h3>'.$photo->getTitle().'</h3></div>'."\n"; 
     560                        $html .= '<div class="flickr_photo"><a href="'.$photo->buildUrl().'"><img src="'.$photo->buildImgUrl().'"></a></div>'."\n"; 
     561                        if($this->shouldDisplayTags()) 
    562562                        { 
    563                             $html .= '<div class="FlickrTags">'."\n"; 
    564                             $html .= '<h3>'._("Tags")."</h3>\n"; 
    565                             $html .= '<ul>'."\n"; 
    566                             foreach($tags as $tag) 
     563                            $tags = $photo->getTags(); 
     564                            if(!empty($tags)) 
    567565                            { 
    568                                 $url_encoded_tag = urlencode($tag); 
    569                                 $html .= '<li><a href="http://www.flickr.com/photos/tags/'.$url_encoded_tag.'/">'.$tag.'</a></li>'."\n"; 
     566                                $html .= '<div class="flickr_tags">'."\n"; 
     567                                $html .= '<h3>'._("Tags")."</h3>\n"; 
     568                                $html .= '<ul>'."\n"; 
     569                                foreach($tags as $tag) 
     570                                { 
     571                                    $url_encoded_tag = urlencode($tag); 
     572                                    $html .= '<li><a href="http://www.flickr.com/photos/tags/'.$url_encoded_tag.'/">'.$tag.'</a></li>'."\n"; 
     573                                } 
     574                                $html .= '</ul>'."\n"; 
     575                                $html .= '</div>'."\n"; 
    570576                            } 
    571                             $html .= '</ul>'."\n"; 
    572                             $html .= '</div>'."\n"; 
    573577                        } 
    574                         $description = $photo->getDescription(); 
    575                         if(!empty($description)) 
    576                             $html .= '<div class="FlickrDescription">'.$description.'</div>'."\n"; 
     578                        if($this->shouldDisplayDescription()) 
     579                        { 
     580                            $description = $photo->getDescription(); 
     581                            if(!empty($description)) 
     582                                $html .= '<div class="flickr_description">'.$description.'</div>'."\n"; 
     583                        } 
    577584                        $html .= '</div>'."\n"; 
    578585                    } 
    579586                } 
    580587                        } 
     588            catch (Phlickr_ConnectionException $e) 
     589            { 
     590                $html .= _("Unable to connect to Flickr API."); 
     591            } 
     592            catch (Phlickr_MethodFailureException $e) 
     593            { 
     594                $html .= _("Some of the request parameters provided to Flickr API are invalid."); 
     595            } 
     596            catch (Phlickr_XmlParseException $e) 
     597            { 
     598                $html .= _("Unable to parse Flickr's response."); 
     599            } 
    581600                        catch (Phlickr_Exception $e) 
    582601                        { 
    583                                 $html .= _("Could not complete succesfully the request to Flickr API."); 
     602                                $html .= _("Could not get content from Flickr : ").$e; 
    584603                        } 
    585604 
  • trunk/wifidog-auth/wifidog/local_content/default/stylesheet.css

    r555 r559  
    228228max-width: 100px; 
    229229} 
    230 .FlickrPhotoBlock { 
     230.flickr_photo_block { 
    231231    margin:20px auto 20px auto; 
    232232    width:400px; 
    233233} 
    234 .FlickrPhotoBlock:hover > * { 
     234.flickr_photo_block:hover > * { 
    235235    visibility: visible; 
    236236} 
    237 .FlickrTitle { 
     237.flickr_title { 
    238238    visibility: hidden; 
    239239    width: 200px; 
    240240    background: #696969; 
    241241} 
    242 .FlickrTitle h3 { 
     242.flickr_title h3 { 
    243243    color: white; 
    244244    padding: 5px; 
    245245    margin: 0; 
    246246} 
    247 .FlickrPhoto { 
     247.flickr_photo { 
    248248    float:left; 
    249249} 
     
    251251    border: 10px solid black; 
    252252} 
    253 .FlickrTags { 
     253.flickr_tags { 
    254254    visibility: hidden; 
    255255    background-color: #696969; 
     
    257257    margin-left: 260px; 
    258258} 
    259 .FlickrTags h3 { 
     259.flickr_tags h3 { 
    260260    padding-left: 5px; 
    261261    margin: 0; 
    262262} 
    263 .FlickrTags ul { 
     263.flickr_tags ul { 
    264264    margin-left: 20px; 
    265265    margin-top: 0px; 
    266266    padding: 0px; 
    267267} 
    268 .FlickrTags li { 
     268.flickr_tags li { 
    269269    list-style: none; 
    270270    list-style-image: none; 
    271271} 
    272 .FlickrTags li a { 
     272.flickr_tags li a { 
    273273    color: white; 
    274274    font-size: normal; 
    275275    text-decoration: none; 
    276276} 
    277 .FlickrTags li a:hover { 
     277.flickr_tags li a:hover { 
    278278    text-decoration: underline; 
    279279} 
    280 .FlickrDescription { 
     280.flickr_description { 
    281281    visibility: hidden; 
    282282    width: 180px;