Changeset 559
- Timestamp:
- 04/20/05 13:08:14 (8 years ago)
- Location:
- trunk/wifidog-auth
- Files:
-
- 6 modified
-
ChangeLog (modified) (1 diff)
-
wifidog/admin/generic_object_admin.php (modified) (1 diff)
-
wifidog/admin/index.php (modified) (1 diff)
-
wifidog/classes/Content/File.php (modified) (9 diffs)
-
wifidog/classes/Content/FlickrPhotostream.php (modified) (1 diff)
-
wifidog/local_content/default/stylesheet.css (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog-auth/ChangeLog
r555 r559 1 2005-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 1 7 2005-04-18 François Proulx <francois.proulx@gmail.com> 2 8 * Added Flickr content support -
trunk/wifidog-auth/wifidog/admin/generic_object_admin.php
r555 r559 69 69 if ($_REQUEST['action'] == 'save') 70 70 { 71 72 71 $html .= $object->processAdminUI(); 72 $object = call_user_func(array ($class, 'getObject'), $_REQUEST['object_id']); 73 73 $_REQUEST['action'] = 'edit'; 74 74 } -
trunk/wifidog-auth/wifidog/admin/index.php
r553 r559 30 30 31 31 $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";50 32 51 33 $current_user = User :: getCurrentUser(); 52 if ($current_user->isSuperAdmin())34 if(!$current_user) 53 35 { 54 $sql_additional_where = '';36 $html = _('You must be logged in to access the administration panel.'); 55 37 } 56 38 else 57 39 { 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"; 59 95 } 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";88 96 89 97 echo $html; -
trunk/wifidog-auth/wifidog/classes/Content/File.php
r556 r559 34 34 class File extends Content 35 35 { 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 36 42 /**Constructeur 37 43 @param $content_id Content id … … 45 51 46 52 $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'"; 48 54 $db->ExecSqlUniqueRes($sql, $row, false); 49 55 if ($row == null) … … 53 59 $db->ExecSqlUpdate($sql, false); 54 60 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'"; 56 62 $db->ExecSqlUniqueRes($sql, $row, false); 57 63 if ($row == null) … … 129 135 $this->refresh(); 130 136 } 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 } 131 173 132 174 /**Affiche l'interface d'administration de l'objet */ … … 137 179 138 180 $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"; 140 184 $html .= "<div class='admin_section_data'>\n"; 141 185 $html .= '<input type="hidden" name="MAX_FILE_SIZE" value="1073741824" />'; … … 145 189 146 190 $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"; 147 200 $html .= "<div class='admin_section_title'>"._("Filename")." : </div>\n"; 148 201 $html .= "<div class='admin_section_data'>\n"; … … 158 211 $html .= "</div>\n"; 159 212 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 160 227 return parent :: getAdminUI($html); 161 228 } … … 166 233 167 234 // 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()]); 173 246 } 174 247 … … 179 252 * @param $subclass_admin_interface Html content of the interface element of a children 180 253 * @return The HTML fragment for this interface */ 181 public function getUserUI( $subclass_user_interface = null)254 public function getUserUI() 182 255 { 183 256 $html = ''; 184 257 $html .= "<div class='user_ui_container'>\n"; 185 258 $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>"; 188 260 $html .= "</div>\n"; 189 261 return parent :: getUserUI($html); -
trunk/wifidog-auth/wifidog/classes/Content/FlickrPhotostream.php
r555 r559 555 555 if(is_object($photo)) 556 556 { 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()) 562 562 { 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)) 567 565 { 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"; 570 576 } 571 $html .= '</ul>'."\n";572 $html .= '</div>'."\n";573 577 } 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 } 577 584 $html .= '</div>'."\n"; 578 585 } 579 586 } 580 587 } 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 } 581 600 catch (Phlickr_Exception $e) 582 601 { 583 $html .= _("Could not complete succesfully the request to Flickr API.");602 $html .= _("Could not get content from Flickr : ").$e; 584 603 } 585 604 -
trunk/wifidog-auth/wifidog/local_content/default/stylesheet.css
r555 r559 228 228 max-width: 100px; 229 229 } 230 . FlickrPhotoBlock {230 .flickr_photo_block { 231 231 margin:20px auto 20px auto; 232 232 width:400px; 233 233 } 234 . FlickrPhotoBlock:hover > * {234 .flickr_photo_block:hover > * { 235 235 visibility: visible; 236 236 } 237 . FlickrTitle {237 .flickr_title { 238 238 visibility: hidden; 239 239 width: 200px; 240 240 background: #696969; 241 241 } 242 . FlickrTitle h3 {242 .flickr_title h3 { 243 243 color: white; 244 244 padding: 5px; 245 245 margin: 0; 246 246 } 247 . FlickrPhoto {247 .flickr_photo { 248 248 float:left; 249 249 } … … 251 251 border: 10px solid black; 252 252 } 253 . FlickrTags {253 .flickr_tags { 254 254 visibility: hidden; 255 255 background-color: #696969; … … 257 257 margin-left: 260px; 258 258 } 259 . FlickrTags h3 {259 .flickr_tags h3 { 260 260 padding-left: 5px; 261 261 margin: 0; 262 262 } 263 . FlickrTags ul {263 .flickr_tags ul { 264 264 margin-left: 20px; 265 265 margin-top: 0px; 266 266 padding: 0px; 267 267 } 268 . FlickrTags li {268 .flickr_tags li { 269 269 list-style: none; 270 270 list-style-image: none; 271 271 } 272 . FlickrTags li a {272 .flickr_tags li a { 273 273 color: white; 274 274 font-size: normal; 275 275 text-decoration: none; 276 276 } 277 . FlickrTags li a:hover {277 .flickr_tags li a:hover { 278 278 text-decoration: underline; 279 279 } 280 . FlickrDescription {280 .flickr_description { 281 281 visibility: hidden; 282 282 width: 180px;
