I am trying to load XML / SWF diagrams with Yii and have some problems. As far as I can tell, the problem is that Yii loads the script tags in the header.
This is what the source source looks like from the header created by my working test.php script (minus Yii).
<HTML>
<script language="javascript">
/*<![CDATA[*/
AC_FL_RunContent = 0;
DetectFlashVer = 0;
var requiredMajorVersion = 10;
var requiredMinorVersion = 0;
var requiredRevision = 45;
/*]]>*/
</script>
<script src="AC_RunActiveContent.js" language="javascript"></script>
<BODY bgcolor="#FFFFFF">
Now I'm trying to get Yii to do the same using this code.
<?php
Yii::app()->clientScript->registerScript('AC_FL_RunContent', 'AC_FL_RunContent = 0;', CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScript('DetectFlashVer', 'DetectFlashVer = 0;', CClientScript::POS_HEAD);
Yii::app()->getClientScript()->registerScriptFile($chartUrl.'/AC_RunActiveContent.js');
Yii::app()->clientScript->registerScript('DetectFlashVer',
'
var requiredMajorVersion = 10;
var requiredMinorVersion = 0;
var requiredRevision = 45;
', CClientScript::POS_HEAD);
?>
And this is what I get
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="language" content="en" />
<link rel="stylesheet" type="text/css" href="/css/main.css" />
<link rel="stylesheet" type="text/css" href="/css/form.css" />
<link rel="stylesheet" type="text/css" href="/css/components.css" />
<link rel="stylesheet" type="text/css" href="/css/pages.css" />
<script type="text/javascript" src="/assets/e5f807c3/AC_RunActiveContent.js"></script>
<script type="text/javascript">
/<![CDATA[/
AC_FL_RunContent = 0;
DetectFlashVer = 0;
var requiredMajorVersion = 10;
var requiredMinorVersion = 0;
var requiredRevision = 45;
/]]>/
</script>
</head>
<body>
The problem is placing the line that loads AC_RunActiveContent.js. When I move it above other variables in my script test, it interrupts the script test. Is there a way to get Yii to write the commands in the order I want them?
UPDATE 8/23 / 10- RESOLVED !!!
Gray Teardrop . , , , .
-, XML/SWF, protected/vendors/Maani
show.php(, )
<?php
$chartPath=Yii::getPathOfAlias('application.vendors.Maani.*');
$chartUrl=Yii::app()->getAssetManager()->publish($chartPath);
Yii::app()->clientScript->registerScript('AC_FL_RunContent', 'AC_FL_RunContent = 0;', CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScript('DetectFlashVer', 'DetectFlashVer = 0;', CClientScript::POS_HEAD);
Yii::app()->clientScript->registerScript('Morestuff',
'
var requiredMajorVersion = 10;
var requiredMinorVersion = 0;
var requiredRevision = 45;
', CClientScript::POS_HEAD);
Yii::app()->getClientScript()->registerScriptFile($chartUrl.'/AC_RunActiveContent.js',CClientScript::POS_BEGIN);
?>
<?php $chart = "<chart><chart_type>bar</chart_type><chart_border color='FF0000' /></chart>"; ?>
<script language="JavaScript" type="text/javascript">
/<![CDATA[/
if (AC_FL_RunContent == 0 || DetectFlashVer == 0) {
alert("This page requires AC_RunActiveContent.js.");
} else {
var hasRightVersion = DetectFlashVer(requiredMajorVersion, requiredMinorVersion, requiredRevision);
if(hasRightVersion) {
AC_FL_RunContent(
'codebase', 'http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=10,0,45,2',
'width', '400',
'height', '250',
'scale', 'noscale',
'salign', 'TL',
'bgcolor', '#777788',
'wmode', 'opaque',
'movie', 'charts',
'src', '<?php echo $chartUrl; ?>/charts',
'FlashVars', "library_path=<?php echo $chartUrl; ?>/charts_library&xml_data=<?php echo $chart; ?>",
'id', 'my_chart',
'name', 'my_chart',
'menu', 'true',
'allowFullScreen', 'true',
'allowScriptAccess','sameDomain',
'quality', 'high',
'align', 'middle',
'pluginspage', 'http://www.macromedia.com/go/getflashplayer',
'play', 'true',
'devicefont', 'false'
);
} else {
var alternateContent = 'This content requires the Adobe Flash Player. '
+ '<u><a href=http://www.macromedia.com/go/getflash/>Get Flash</a></u>.';
document.write(alternateContent);
}
}
/]]>/
, src FlashVars.