BcBaserHelper::swf PHP Method

swf() public method

Flashを表示する
public swf ( string $path, string $id, integer $width, integer $height, array $options = [] ) : string
$path string Flashのパス
$id string 任意のID(divにも埋め込まれる)
$width integer 横幅
$height integer 高さ
$options array オプション(初期値 : array()) - `version` : Flashのバージョン(初期値 : 7) - `script` : Flashを読み込むJavascriptのパス(初期値 : admin/swfobject-2.2) - `noflash` : Flashがインストールされてない場合に表示する文字列
return string Flash表示タグ
    public function swf($path, $id, $width, $height, $options = array())
    {
        $options = array_merge(array('version' => 7, 'script' => 'admin/swfobject-2.2', 'noflash' => ' '), $options);
        $version = $options['version'];
        $script = $options['script'];
        $noflash = $options['noflash'];
        if (!preg_match('/\\.swf$/', $path)) {
            $path .= '.swf';
        }
        if (is_array($path)) {
            $path = $this->getUrl($path);
        } elseif (strpos($path, '://') === false) {
            if ($path[0] !== '/') {
                $path = Configure::read('App.imageBaseUrl') . $path;
            }
            $path = $this->webroot($path);
        }
        $out = $this->js($script, true) . "\n";
        $out = <<<END_FLASH
<div id="{$id}">{$noflash}</div>
<script type="text/javascript">
\tswfobject.embedSWF("{$path}", "{$id}", "{$width}", "{$height}", "{$version}");
</script>
END_FLASH;
        echo $out;
    }