- Timestamp:
- 12/28/05 19:42:26 (7 years ago)
- Files:
-
- 1 modified
Legend:
- Unmodified
- Added
- Removed
-
trunk/wifidog-auth/wifidog/classes/Content/EmbeddedContent/EmbeddedContent.php
r868 r874 38 38 * @subpackage ContentClasses 39 39 * @author Francois Proulx <francois.proulx@gmail.com> 40 * @copyright 2005 Francois Proulx <francois.proulx@gmail.com> - Technologies 41 * Coeus inc. 40 * @copyright 2005 Francois Proulx, Technologies Coeus inc. 42 41 * @version CVS: $Id$ 43 42 * @link http://sourceforge.net/projects/wifidog/ 44 43 */ 45 44 46 require_once BASEPATH.'classes/Content.php';47 48 45 /** 49 46 * A generic embedded content container 47 * 50 48 * This object supports backward compatiblity fallback 51 49 * … … 55 53 * And Macromedia recommendations for backward compatibility 56 54 * http://www.macromedia.com/cfusion/knowledgebase/index.cfm?id=tn_12701 57 * */ 55 * 56 * @package WiFiDogAuthServer 57 * @subpackage ContentClasses 58 * @author Francois Proulx <francois.proulx@gmail.com> 59 * @copyright 2005 Francois Proulx, Technologies Coeus inc. 60 */ 58 61 class EmbeddedContent extends Content 59 62 { 63 /** 64 * Constructor 65 * 66 * @param string $content_id Content Id 67 * 68 * @return void 69 * 70 * @access protected 71 */ 60 72 protected function __construct($content_id) 61 73 { 62 parent :: __construct($content_id);74 // Define globals 63 75 global $db; 76 77 // Init values 78 $row = null; 79 80 parent::__construct($content_id); 81 64 82 $content_id = $db->EscapeString($content_id); 65 83 … … 86 104 } 87 105 106 /** 107 * Returns the attributes of embedded content 108 * 109 * @return string Attributes of the embedded content 110 * 111 * @access private 112 */ 113 private function getAttributes() 114 { 115 return $this->embedded_content_row['attributes']; 116 } 117 118 /** 119 * Sets the attributes of embedded content 120 * 121 * @param string $attributes_str Attributes of the embedded content 122 * 123 * @return void 124 * 125 * @access private 126 */ 127 private function setAttributes($attributes_str) 128 { 129 $attributes_str = $this->mBd->EscapeString($attributes_str); 130 $this->mBd->ExecSqlUpdate("UPDATE embedded_content SET attributes ='".$attributes_str."' WHERE embedded_content_id='".$this->getId()."'", false); 131 $this->refresh(); 132 } 133 134 /** 135 * Returns parameters of embedded content 136 * 137 * @return string Parameters of the embedded content 138 * 139 * @access private 140 */ 141 private function getParameters() 142 { 143 return $this->embedded_content_row['parameters']; 144 } 145 146 /** 147 * Sets the parameters of embedded content 148 * 149 * @param string $paramters_str Parameters of the embedded content 150 * 151 * @return void 152 * 153 * @access private 154 */ 155 private function setParameters($paramters_str) 156 { 157 $paramters_str = $this->mBd->EscapeString($paramters_str); 158 $this->mBd->ExecSqlUpdate("UPDATE embedded_content SET parameters ='".$paramters_str."' WHERE embedded_content_id='".$this->getId()."'", false); 159 $this->refresh(); 160 } 161 162 /** 163 * Shows the administration interface for embedded content. 164 * 165 * @param string $subclass_admin_interface HTML code to be added after the 166 * administration interface 167 * 168 * @return string HTML code for the administration interface 169 * 170 * @access public 171 */ 88 172 public function getAdminUI($subclass_admin_interface = null) 89 173 { … … 95 179 $html .= "<div class='admin_section_title'>"._("Embedded content")." : <br></div>\n"; 96 180 $html .= "<div class='admin_section_data'>\n"; 97 if (empty ($this->embedded_content_row['embedded_file_id'])) 98 {181 182 if (empty ($this->embedded_content_row['embedded_file_id'])) { 99 183 // Mandate File 100 184 $html .= self :: getNewContentUI("embedded_file_{$this->id}_new", "File"); 101 185 $html .= "</div>\n"; 102 } 103 else 104 { 105 $embedded_content_file = self :: getObject($this->embedded_content_row['embedded_file_id']); 186 } else { 187 $embedded_content_file = self::getObject($this->embedded_content_row['embedded_file_id']); 188 106 189 $html .= $embedded_content_file->getAdminUI(); 190 107 191 $html .= "</div>\n"; 108 192 $html .= "<div class='admin_section_tools'>\n"; … … 127 211 $html .= "</div>\n"; 128 212 } 213 129 214 $html .= "</div>\n"; 130 215 … … 133 218 $html .= "<div class='admin_section_title'>"._("Fallback content (Can be another embedded content to create a fallback hierarchy)")." : <br></div>\n"; 134 219 $html .= "<div class='admin_section_data'>\n"; 135 if (empty ($this->embedded_content_row['fallback_content_id'])) 136 { 137 $html .= self :: getNewContentUI("fallback_content_{$this->id}_new"); 138 $html .= "</div>\n"; 139 } 140 else 141 { 142 $fallback_content = self :: getObject($this->embedded_content_row['fallback_content_id']); 220 221 if (empty ($this->embedded_content_row['fallback_content_id'])) { 222 $html .= self::getNewContentUI("fallback_content_{$this->id}_new"); 223 $html .= "</div>\n"; 224 } else { 225 $fallback_content = self::getObject($this->embedded_content_row['fallback_content_id']); 226 143 227 $html .= $fallback_content->getAdminUI(); 228 144 229 $html .= "</div>\n"; 145 230 $html .= "<div class='admin_section_tools'>\n"; … … 148 233 $html .= "</div>\n"; 149 234 } 235 150 236 $html .= "</div>\n"; 151 237 152 238 $html .= $subclass_admin_interface; 153 return parent :: getAdminUI($html); 154 } 155 156 function processAdminUI() 157 { 158 if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) 159 { 160 parent :: processAdminUI(); 161 239 240 return parent::getAdminUI($html); 241 } 242 243 /** 244 * Processes the input of the administration interface for embedded content 245 * 246 * @return void 247 * 248 * @access public 249 */ 250 public function processAdminUI() 251 { 252 if ($this->isOwner(User :: getCurrentUser()) || User :: getCurrentUser()->isSuperAdmin()) { 253 // Define globals 162 254 global $db; 163 if (empty ($this->embedded_content_row['embedded_file_id'])) 164 { 255 256 // Init values 257 $errmsg = null; 258 259 parent::processAdminUI(); 260 261 if (empty ($this->embedded_content_row['embedded_file_id'])) { 165 262 $embedded_content_file = self :: processNewContentUI("embedded_file_{$this->id}_new"); 166 if ($embedded_content_file != null) 167 {263 264 if ($embedded_content_file != null) { 168 265 $embedded_content_file_id = $embedded_content_file->GetId(); 169 266 $db->ExecSqlUpdate("UPDATE embedded_content SET embedded_file_id = '$embedded_content_file_id' WHERE embedded_content_id = '$this->id'", FALSE); 170 } 171 else 172 { 267 } else { 173 268 echo _("You MUST choose a File object or any of its siblings."); 174 269 $embedded_content_file->delete($errmsg); 175 270 } 176 } 177 else 178 { 271 } else { 179 272 $embedded_content_file = self :: getObject($this->embedded_content_row['embedded_file_id']); 180 273 $name = "embeddedcontent_".$this->id."_embedded_file_erase"; 181 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) 182 {274 275 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 183 276 $db->ExecSqlUpdate("UPDATE embedded_content SET embedded_file_id = NULL WHERE embedded_content_id = '$this->id'", FALSE); 184 277 $embedded_content_file->delete($errmsg); 185 } 186 else 187 { 278 } else { 188 279 $embedded_content_file->processAdminUI(); 189 280 … … 196 287 } 197 288 198 if (empty ($this->embedded_content_row['fallback_content_id'])) 199 { 289 if (empty ($this->embedded_content_row['fallback_content_id'])) { 200 290 $fallback_content = self :: processNewContentUI("fallback_content_{$this->id}_new"); 201 if ($fallback_content != null) 202 {291 292 if ($fallback_content != null) { 203 293 $fallback_content_id = $fallback_content->GetId(); 204 294 $db->ExecSqlUpdate("UPDATE embedded_content SET fallback_content_id = '$fallback_content_id' WHERE embedded_content_id = '$this->id'", FALSE); 205 295 } 206 } 207 else 208 { 296 } else { 209 297 $fallback_content = self :: getObject($this->embedded_content_row['fallback_content_id']); 210 298 $name = "fallback_content_".$this->id."_fallback_content_erase"; 211 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) 212 {299 300 if (!empty ($_REQUEST[$name]) && $_REQUEST[$name] == true) { 213 301 $db->ExecSqlUpdate("UPDATE embedded_content SET fallback_content_id = NULL WHERE embedded_content_id = '$this->id'", FALSE); 214 302 $fallback_content->delete($errmsg); 215 } 216 else 217 { 303 } else { 218 304 $fallback_content->processAdminUI(); 219 305 } … … 224 310 } 225 311 226 /** Retreives the user interface of this object. Anything that overrides this method should call the parent method with it's output at the END of processing. 227 * @param $subclass_admin_interface Html content of the interface element of a children 228 * @return The HTML fragment for this interface */ 312 /** 313 * Retreives the user interface of this object. 314 * 315 * @return string The HTML fragment for this interface 316 * 317 * @access public 318 */ 229 319 public function getUserUI() 230 320 { 321 // Init values 231 322 $html = ''; 323 $embedded_content_file = null; 324 $fallback_content = null; 325 232 326 $html .= "<div class='user_ui_container'>\n"; 233 327 $html .= "<div class='user_ui_object_class'>EmbeddedContent (".get_class($this)." instance)</div>\n"; 234 328 235 $embedded_content_file = null;236 $fallback_content = null;237 238 329 /* Get both objects if they exist */ 239 if (!empty ($this->embedded_content_row['embedded_file_id'])) 330 if (!empty ($this->embedded_content_row['embedded_file_id'])) { 240 331 $embedded_content_file = self :: getObject($this->embedded_content_row['embedded_file_id']); 241 if (!empty ($this->embedded_content_row['fallback_content_id'])) 332 } 333 334 if (!empty ($this->embedded_content_row['fallback_content_id'])) { 242 335 $fallback_content = self :: getObject($this->embedded_content_row['fallback_content_id']); 243 244 /* 245 * Example 246 * <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="400" height="316" codebase="http://www.apple.com/qtactivex/qtplugin.cab"> 247 <param name="SRC" value="/sponsors/airborne/400.mov"> 248 249 <param name="QTNEXT1" value="<http://stream.qtv.apple.com/qtv/endorphin/http/hydrogen3_ref.mov> T<myself>"> 250 <param name="AUTOPLAY" value="true"> 251 <param name="CONTROLLER" value="true"> 252 <embed src="/sponsors/airborne/400.mov" qtnext1="<http://stream.qtv.apple.com/qtv/endorphin/http/hydrogen3_ref.mov> T<myself>" width="400" height="316" align="left" autoplay="true" controller="true" pluginspage="http://www.apple.com/quicktime/download/"> 253 </embed> 254 </object> 336 } 337 338 /** 339 * @internal Example: 255 340 * 341 * <samp> 342 * <object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" width="400" height="316" codebase="http://www.apple.com/qtactivex/qtplugin.cab"> 343 * <param name="SRC" value="/sponsors/airborne/400.mov"> 344 * <param name="QTNEXT1" value="<http://stream.qtv.apple.com/qtv/endorphin/http/hydrogen3_ref.mov> T<myself>"> 345 * <param name="AUTOPLAY" value="true"> 346 * <param name="CONTROLLER" value="true"> 347 * <embed src="/sponsors/airborne/400.mov" qtnext1="<http://stream.qtv.apple.com/qtv/endorphin/http/hydrogen3_ref.mov> T<myself>" width="400" height="316" align="left" autoplay="true" controller="true" pluginspage="http://www.apple.com/quicktime/download/"> 348 * </embed> 349 * </object> 350 * </samp> 256 351 */ 257 if ($embedded_content_file != null) 258 { 352 if ($embedded_content_file != null) { 259 353 $url = htmlentities($embedded_content_file->getFileUrl()); 260 354 $mime_type = $embedded_content_file->getMimeType(); … … 263 357 $html .= "<param name='AUTOPLAY' value='0'>\n"; 264 358 $html .= "{$this->getParameters()}\n"; 359 265 360 // Spit fallback content between inside the <object> tag 266 if ($fallback_content != null) 361 if ($fallback_content != null) { 267 362 $html .= $fallback_content->getUserUI(); 363 } 364 268 365 $html .= "<embed autoplay=FALSE src='$url'>\n"; 269 366 $html .= "<nobembed>\n"; … … 274 371 275 372 $html .= "</div>\n"; 276 return parent :: getUserUI($html); 277 } 278 279 public function getAttributes() 280 { 281 return $this->embedded_content_row['attributes']; 282 } 283 284 public function setAttributes($attributes_str) 285 { 286 $attributes_str = $this->mBd->EscapeString($attributes_str); 287 $this->mBd->ExecSqlUpdate("UPDATE embedded_content SET attributes ='".$attributes_str."' WHERE embedded_content_id='".$this->getId()."'", false); 288 $this->refresh(); 289 } 290 291 public function getParameters() 292 { 293 return $this->embedded_content_row['parameters']; 294 } 295 296 public function setParameters($paramters_str) 297 { 298 $paramters_str = $this->mBd->EscapeString($paramters_str); 299 $this->mBd->ExecSqlUpdate("UPDATE embedded_content SET parameters ='".$paramters_str."' WHERE embedded_content_id='".$this->getId()."'", false); 300 $this->refresh(); 301 } 302 303 /** Delete this Content from the database 304 */ 305 public function delete(& $errmsg) 306 { 307 if ($this->isPersistent() == false) 308 { 309 if (!empty ($this->embedded_content_row['embedded_file_id'])) 310 { 373 374 return parent::getUserUI($html); 375 } 376 377 /** 378 * Reloads the object from the database. Should normally be called after 379 * a set operation. This function is private because calling it from a 380 * subclass will call the constructor from the wrong scope. 381 * 382 * @return void 383 * 384 * @access private 385 */ 386 private function refresh() 387 { 388 $this->__construct($this->id); 389 } 390 391 /** 392 * Deletes a embedded content object 393 * 394 * @param string $errmsg Reference to error message 395 * 396 * @return bool True if deletion was successful 397 * 398 * @access public 399 * @internal Persistent content will not be deleted 400 */ 401 public function delete(&$errmsg) 402 { 403 if ($this->isPersistent() == false) { 404 if (!empty ($this->embedded_content_row['embedded_file_id'])) { 311 405 $embedded_content_file = self :: getObject($this->embedded_content_row['embedded_file_id']); 312 406 $embedded_content_file->delete($errmsg); 313 407 } 314 if (!empty ($this->embedded_content_row['fallback_content_id'])) 315 {408 409 if (!empty ($this->embedded_content_row['fallback_content_id'])) { 316 410 $fallback_content = self :: getObject($this->embedded_content_row['fallback_content_id']); 317 411 $fallback_content->delete($errmsg); 318 412 } 319 } 413 } else { 414 $errmsg = _("Content is persistent (you must make it non persistent before you can delete it)"); 415 } 416 320 417 return parent :: delete($errmsg); 321 418 } 322 /** Reloads the object from the database. Should normally be called after a set operation. 323 * This function is private because calling it from a subclass will call the 324 * constructor from the wrong scope */ 325 private function refresh() 326 { 327 $this->__construct($this->id); 328 } 419 329 420 } 330 421
