Source of file SWFVariation.php
Size: 2,762 Bytes - Last Modified: 2021-12-23T10:33:31+00:00
/var/www/docs.ssmods.com/process/src/code/variation/SWFVariation.php
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374 | <?php class SWFVariation extends PersonalisationVariation { public static $db = array( "EmbedSWF" => "HTMLText", "SWFWidth" => "Int", "SWFHeight" => "Int" ); public static $has_one = array( "SWFFile" => "File", "FallBackImage" => "Image" ); public function getCMSFields() { $fields = parent::getCMSFields(); // $internalSWF = new UploadField("SWFFileID", "Choose swf from assets" ); // $internalSWF->getValidator()->setAllowedExtensions(array('swf')); $internalSWF = new ReadonlyField('SwfVariation', 'SWF Variation From Assets', 'Links to swfs in files and assets can be added after you have saved for the first time'); // $internalSWF = new TreeDropdownField("SWFFileID", "Choose swf from assets", "File", "ID", "Title"); $fields->push($internalSWF); $externalSWF = new HtmlEditorField("EmbedSWF", "Link to External SWF"); $fields->push($externalSWF); $fallBackImage = new ReadonlyField('Variation', 'Fall Back Image', ' Fall Back Images can be added after you have saved for the first time'); $fields->push($fallBackImage); return $fields; } public function helperText() { return "lets you use Flash (SWF) file as the output, with an optional fallback image for devices that don't support Flash."; } public function render(ContextProvider $context, Controller $controller = null) { $swfdetails = new ArrayList(); if ($this->SWFFileID && $swf = File::get_by_id("File", $this->SWFFileID)) { $swfURL = $swf->getURL(); } else { $swfURL = $this->EmbedSWF; } if ($this->FallBackImageID && $fallBack = File::get_by_id("Image", $this->FallBackImageID)) { $fallBackImage = $fallBack->getURL(); } else { $fallBackImage = null; } $html = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" width=" ' . $this->SWFWidth . ' " height=" ' . $this->SWFHeight . '"> ' . '<param name="movie" value="' . $swfURL . '" /> ' . ' <param name="wmode" value="transparent"> ' . ' <!--[if !IE]>--> ' . ' <object type="application/x-shockwave-flash" data="' .$swfURL . '" width=" ' . $this->SWFWidth . ' " height="' . $this->SWFHeight . '"> ' . ' <param name="wmode" value="transparent"> ' . ' <!--<![endif]--> '; if (!is_null($fallBackImage)) { $html .= ' <img src="' . $fallBackImage . '" alt="$AlternativeText" /> ' ; } $html .= ' <!--[if !IE]>--> ' . ' </object> ' . ' <!--<![endif]--> ' . ' </object>'; return $html; } } |