Yii Framework Forum: [EXTENSION] SwfUpload - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

[EXTENSION] SwfUpload All about the swfobject extension Rate Topic: -----

#1 User is offline   prchakal 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 95
  • Joined: 20-January 10

Posted 02 February 2010 - 06:29 PM

Hi,

On this topic you can know all about the swfobject extension.

How to use:
Download and decompress all in 'extensions' dir.

Usage:

<?php $this->widget('ext.swfobject.ESwfObject', array(
          'width'         => '896',
          'height'        => '703',
          'swfFile'       => Yii::app()->baseUrl . '/swf/home.swf',
          'playerVersion' => '9.0.0',
          'params'        => array('menu' => 'false', 'quality' => 'high', 'wmode' => 'transparent'),
          'flashvars'     => array(),
          'attributes'    => array(),
      )); 
?>


So simple :)
0

#2 User is offline   prchakal 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 95
  • Joined: 20-January 10

Posted 05 February 2010 - 11:02 AM

Any admin can change the topic title please?

I type wrong, if SWFOBJECT not SWFUPLOAD .

Ty.
0

#3 User is offline   prchakal 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 95
  • Joined: 20-January 10

Posted 05 February 2010 - 07:41 PM

I make the support for EXTENSION DOWNLOAD command.

You can get with console command:
extension install swfobject

You can see how to use this command, here:
http://www.yiiframew...nent-extension/
0

#4 User is offline   drx 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 15
  • Joined: 23-October 09

Posted 28 June 2010 - 07:20 AM

Nice extension.

Some proposals:

  • Use counter instead of date for id.
  • Use CJavaScript::encode to encode flashvars, params and attributes - it´s much easier and provides javascript parameter / method usage via "js:" (eg. "js:document.URL").


<?php

class ESwfObject extends CWidget
{
  public static $count = 0;

  public $params;
  public $flashvars;
  public $attributes;

  public $swfFile;
  public $width;
  public $height;
  public $playerVersion;

  private $expressInstallFile;
  private $newLineJS;
  private $baseUrl;
  private $clientScript;

  public $randomID;

  /**
   * Init the extension
   */
  public function init()
  {
    $this->randomID  = '_' . self::$count++;
    $this->newLineJS = "\n";

    parent::init();
  }

  /**
   * Publishes the assets
   */
  public function publishAssets()
  {
    $dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'assets';
    $this->baseUrl = Yii::app()->getAssetManager()->publish($dir);
  }

  /**
   * Registers the external javascript files
   */
  public function registerClientScripts()
  {
    // add the scripts
    if ($this->baseUrl === '')
    throw new CException(Yii::t('ESwfObject', 'baseUrl must be set. This is done automatically by calling publishAssets()'));

    $this->clientScript = Yii::app()->getClientScript();
    $this->clientScript->registerScriptFile($this->baseUrl.'/swfobject.js');

    // set install express url
    $this->expressInstallFile = $this->baseUrl.'/expressInstall.swf';
  }

  /**
   * The javascript needed
   */
  protected function createJsCode()
  {

    $js  = '';

    // add the flashvars array
    $js .= 'var flashvars' . $this->randomID . ' = ';
    $js .= CJavaScript::encode($this->flashvars);
    $js .= ';' . $this->newLineJS;

    // add the params array
    $js .= 'var params' . $this->randomID . ' = ';
    $js .= CJavaScript::encode($this->params);
    $js .= ';' . $this->newLineJS;

    // add the attributes array
    $js .= 'var attributes' . $this->randomID . ' = ';
    $js .= CJavaScript::encode($this->attributes);
    $js .= ';' . $this->newLineJS;

    // create the swfobject call
    $js .= $this->newLineJS;
    $js .= 'swfobject.embedSWF("' . $this->swfFile . '", "eswfobject_content' . $this->randomID . '", "' . $this->width . '", "' . $this->height . '", "' . $this->playerVersion . '","' . $this->expressInstallFile . '", flashvars' . $this->randomID . ', params' . $this->randomID . ', attributes' . $this->randomID . ');';

    return $js;
  }

  /**
   * The HTML object to receive the SWF OBJECT content
   */
  public function createHtml(){
    $html = '<div id="eswfobject_content' . $this->randomID . '"></div>';
    return $html;
  }

  /**
   * Run the widget
   */
  public function run()
  {
    $this->publishAssets();
    $this->registerClientScripts();

    $js = $this->createJsCode();
    $this->clientScript->registerScript('js_eswfobject' . $this->randomID, $js, CClientScript::POS_HEAD);

    echo( $this->createHtml() );

    parent::run();
  }
}


Happy coding
drx
0

#5 User is offline   daonhack 

  • Junior Member
  • Pip
  • Yii
  • Group: Members
  • Posts: 34
  • Joined: 02-June 09

Posted 16 July 2010 - 10:09 PM

View Postprchakal, on 02 February 2010 - 06:29 PM, said:

Hi,

On this topic you can know all about the swfobject extension.

How to use:
Download and decompress all in 'extensions' dir.

Usage:

<?php $this->widget('ext.swfobject.ESwfObject', array(
          'width'         => '896',
          'height'        => '703',
          'swfFile'       => Yii::app()->baseUrl . '/swf/home.swf',
          'playerVersion' => '9.0.0',
          'params'        => array('menu' => 'false', 'quality' => 'high', 'wmode' => 'transparent'),
          'flashvars'     => array(),
          'attributes'    => array(),
      )); 
?>


So simple :)


I have problem when adding more than one flash file into different content id.
For example:
<?php $this->widget('ext.swfobject.ESwfObject', array(
          'width'         => '896',
          'height'        => '703',
          'swfFile'       => Yii::app()->baseUrl . '/swf/home.swf',
          'playerVersion' => '9.0.0',
          'params'        => array('menu' => 'false', 'quality' => 'high', 'wmode' => 'transparent'),
          'flashvars'     => array(),
          'attributes'    => array(),
      )); 
?>

then
<?php $this->widget('ext.swfobject.ESwfObject', array(
          'width'         => '896',
          'height'        => '703',
          'swfFile'       => Yii::app()->baseUrl . '/swf/footer.swf',
          'playerVersion' => '9.0.0',
          'params'        => array('menu' => 'false', 'quality' => 'high', 'wmode' => 'transparent'),
          'flashvars'     => array(),
          'attributes'    => array(),
      )); 
?>


This script override home.swf and just display footer.swf.
Any suggestion in this case? Thanks.

Nevermind, Problem solved when used count :)
0

#6 User is offline   Q-Zma 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 8
  • Joined: 17-August 09
  • Location:Ukraine, Kharkiv

Posted 20 March 2011 - 08:48 AM

how I can to set alternate content? why not use beginWidget/endWidget schema for alternate content?
0

#7 User is offline   Ivan Wilhelm 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 7
  • Joined: 30-November 10
  • Location:Blumenau - SC - Brasil

Posted 06 October 2011 - 03:47 PM

View Postdaonhack, on 16 July 2010 - 10:09 PM, said:

I have problem when adding more than one flash file into different content id.
For example:
<?php $this->widget('ext.swfobject.ESwfObject', array(
          'width'     	=> '896',
          'height'        => '703',
          'swfFile'   	=> Yii::app()->baseUrl . '/swf/home.swf',
          'playerVersion' => '9.0.0',
          'params'        => array('menu' => 'false', 'quality' => 'high', 'wmode' => 'transparent'),
          'flashvars' 	=> array(),
          'attributes'    => array(),
      )); 
?>

then
<?php $this->widget('ext.swfobject.ESwfObject', array(
          'width'     	=> '896',
          'height'        => '703',
          'swfFile'   	=> Yii::app()->baseUrl . '/swf/footer.swf',
          'playerVersion' => '9.0.0',
          'params'        => array('menu' => 'false', 'quality' => 'high', 'wmode' => 'transparent'),
          'flashvars' 	=> array(),
          'attributes'    => array(),
      )); 
?>


This script override home.swf and just display footer.swf.
Any suggestion in this case? Thanks.

Nevermind, Problem solved when used count :)



i have created a $myId attribute and alter init metod to:


    /**
     * Init the extension
     */
    public function init() {
      $this->randomID = '_' . $this->myId . date('YdmHis');
      $this->newLineJS = "\n";

      parent::init();
    }




--Ivan Wilhelm
ivan.whm@me.com
47-8849-4224
@ivanwhm

"Para se ter sucesso, é necessário amar de verdade o que se faz. Caso contrário, levando em conta apenas o lado racional, você simplesmente desiste. É o que acontece com a maioria das pessoas." Steve Jobs
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users