当前位置: 首页>>代码示例>>PHP>>正文


PHP MediaHelper::embedAsObject方法代码示例

本文整理汇总了PHP中MediaHelper::embedAsObject方法的典型用法代码示例。如果您正苦于以下问题:PHP MediaHelper::embedAsObject方法的具体用法?PHP MediaHelper::embedAsObject怎么用?PHP MediaHelper::embedAsObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MediaHelper的用法示例。


在下文中一共展示了MediaHelper::embedAsObject方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: testEmbedAsObject

    public function testEmbedAsObject()
    {
        $result = $this->Media->embedAsObject('http://example.com/img/image-png');
        $this->assertFalse($result);
        $result = $this->Media->embedAsObject('img/image-png', array('url' => 'http://example.com'));
        $expected = '<a href="http://example.com"><img src="/media/static/img/image-png.png"  height="54" width="70"/></a>';
        $this->assertEqual($result, $expected);
        $result = $this->Media->embedAsObject('img/image-png', array('checked' => true, 'disabled' => true, 'noresize' => true, 'required' => true));
        $expected = '<object type="image/png" data="/media/static/img/image-png.png" checked="checked" disabled="disabled" noresize="noresize" required="required"><param name="src" value="/media/static/img/image-png.png"/></object>';
        $this->assertEqual($result, $expected);
        $result = $this->Media->embedAsObject('img/special-image-&-png');
        $expected = '<object type="image/png" data="http://fo&amp;o:bar@example.com/media/special%5Bfolder%5D/img/special-image-%26-png.png"><param name="src" value="http://fo&amp;o:bar@example.com/media/special%5Bfolder%5D/img/special-image-%26-png.png"/></object>';
        $this->assertEqual($result, $expected);
        $result = $this->Media->embedAsObject('img/image-png', array('id' => 'my-image', 'class' => 'image', 'data-custom' => 42));
        $expected = '<object type="image/png" data="/media/static/img/image-png.png" id="my-image" class="image" data-custom="42"><param name="src" value="/media/static/img/image-png.png"/></object>';
        $this->assertEqual($result, $expected);
        $this->Data->getFile(array('video-wmv.wmv' => $this->Data->settings['static'] . 'vid/video-wmv.wmv'));
        $result = $this->Media->embedAsObject('vid/video-wmv');
        $expected = '<object type="video/x-ms-wmv" data="/media/static/vid/video-wmv.wmv" classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6"><param name="src" value="/media/static/vid/video-wmv.wmv"/>
<param name="controller" value="true"/>
<param name="pluginspage" value="http://www.microsoft.com/Windows/MediaPlayer/"/></object>';
        $this->assertEqual($result, $expected);
        $this->Data->getFile(array('video-rm.rm' => $this->Data->settings['static'] . 'vid/video-rm.rm'));
        $result = $this->Media->embedAsObject('vid/video-rm');
        $expected = '<object type="application/vnd.rn-realmedia" data="/media/static/vid/video-rm.rm" classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA"><param name="src" value="/media/static/vid/video-rm.rm"/>
<param name="controls" value="ControlPanel"/>
<param name="console" value="video5268463f37ca4"/>
<param name="nologo" value="true"/>
<param name="nojava" value="true"/>
<param name="center" value="true"/>
<param name="pluginspage" value="http://www.real.com/player/"/></object>';
        $pattern = str_replace('video5268463f37ca4', 'video.{13}', preg_quote($expected, '/'));
        $this->assertRegExp('/^' . $pattern . '$/', $result);
        $this->Data->getFile(array('video-mov.mov' => $this->Data->settings['static'] . 'vid/video-mov.mov'));
        $result = $this->Media->embedAsObject('vid/video-mov');
        $expected = '<object type="video/quicktime" data="/media/static/vid/video-mov.mov" classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab"><param name="src" value="/media/static/vid/video-mov.mov"/>
<param name="controller" value="true"/>
<param name="pluginspage" value="http://www.apple.com/quicktime/download/"/></object>';
        $this->assertEqual($result, $expected);
        $this->Data->getFile(array('video-mpg.mpg' => $this->Data->settings['static'] . 'vid/video-mpg.mpg'));
        $result = $this->Media->embedAsObject('vid/video-mpg');
        $expected = '<object type="video/mpeg" data="/media/static/vid/video-mpg.mpg"><param name="src" value="/media/static/vid/video-mpg.mpg"/></object>';
        $this->assertEqual($result, $expected);
        $this->Data->getFile(array('video-swf.swf' => $this->Data->settings['static'] . 'vid/video-swf.swf'));
        $result = $this->Media->embedAsObject('vid/video-swf');
        $expected = '<object type="application/x-shockwave-flash" data="/media/static/vid/video-swf.swf" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab"><param name="movie" value="/media/static/vid/video-swf.swf"/>
<param name="wmode" value="transparent"/>
<param name="FlashVars" value="playerMode=embedded"/>
<param name="quality" value="best"/>
<param name="scale" value="noScale"/>
<param name="salign" value="TL"/>
<param name="pluginspage" value="http://www.adobe.com/go/getflashplayer"/></object>';
        $this->assertEqual($result, $expected);
        $this->Data->getFile(array('application-pdf.pdf' => $this->Data->settings['static'] . 'doc/application-pdf.pdf'));
        $result = $this->Media->embedAsObject('doc/application-pdf');
        $expected = '<object type="application/pdf" data="/media/static/doc/application-pdf.pdf"><param name="src" value="/media/static/doc/application-pdf.pdf"/>
<param name="toolbar" value="true"/>
<param name="scrollbar" value="true"/>
<param name="navpanes" value="true"/></object>';
        $this->assertEqual($result, $expected);
        $this->Data->getFile(array('audio-mp3.mp3' => $this->Data->settings['static'] . 'aud/audio-mp3.mp3'));
        $result = $this->Media->embedAsObject('aud/audio-mp3');
        $expected = '<object type="audio/mpeg" data="/media/static/aud/audio-mp3.mp3"><param name="src" value="/media/static/aud/audio-mp3.mp3"/></object>';
        $this->assertEqual($result, $expected);
        $result = $this->Media->embedAsObject('img/image-png');
        $expected = '<object type="image/png" data="/media/static/img/image-png.png"><param name="src" value="/media/static/img/image-png.png"/></object>';
        $this->assertEqual($result, $expected);
        $result = $this->Media->embedAsObject('non-existent');
        $expected = '';
        $this->assertEqual($result, $expected);
    }
开发者ID:miznokruge,项目名称:base-cake,代码行数:71,代码来源:MediaHelperTest.php


注:本文中的MediaHelper::embedAsObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。