Ticket #243: GenerateGraphHTML.diff
| File GenerateGraphHTML.diff, 5.7 KB (added by vipsoft, 3 years ago) |
|---|
-
core/ViewDataTable/GenerateGraphHTML.php
18 18 */ 19 19 abstract class Piwik_ViewDataTable_GenerateGraphHTML extends Piwik_ViewDataTable 20 20 { 21 protected $width = '100%'; 21 protected $width = '100%'; 22 22 protected $height = 250; 23 23 protected $graphType = 'standard'; 24 24 25 25 /** 26 26 * @see Piwik_ViewDataTable::init() 27 27 */ 28 28 function init($currentControllerName, 29 $currentControllerAction, 29 $currentControllerAction, 30 30 $apiMethodToRequestDataTable ) 31 31 { 32 32 parent::init($currentControllerName, 33 $currentControllerAction, 33 $currentControllerAction, 34 34 $apiMethodToRequestDataTable ); 35 35 36 36 $this->dataTableTemplate = 'CoreHome/templates/graph.tpl'; 37 37 38 38 $this->disableOffsetInformation(); 39 39 $this->disableExcludeLowPopulation(); 40 40 $this->disableSearchBox(); 41 $this->parametersToModify = array( 41 $this->parametersToModify = array( 42 42 'viewDataTable' => $this->getViewDataTableIdToLoad(), 43 43 // in the case this controller is being executed by another controller 44 44 // eg. when being widgetized in an IFRAME … … 47 47 'action' => $currentControllerAction, 48 48 ); 49 49 } 50 50 51 51 /** 52 52 * Sets parameters to modify in the future generated URL 53 53 * @param array $array array('nameParameter' => $newValue, ...) … … 56 56 { 57 57 $this->parametersToModify = array_merge($this->parametersToModify, $array); 58 58 } 59 59 60 60 /** 61 61 * @see Piwik_ViewDataTable::main() 62 62 */ … … 70 70 71 71 $this->view = $this->buildView(); 72 72 } 73 73 74 74 protected function buildView() 75 75 { 76 76 $view = new Piwik_View($this->dataTableTemplate); … … 89 89 $view->properties = $this->getViewProperties(); 90 90 return $view; 91 91 } 92 93 protected function getFlashInvocationCode( $url = 'libs/open-flash-chart/data-files/nodata.txt', $use_swfobject = true )94 {95 $width = $this->width;96 $height = $this->height;97 92 93 protected function getFlashInvocationCode( $url = 'libs/open-flash-chart/data-files/nodata.txt', $use_swfobject = true ) 94 { 95 $width = $this->width; 96 $height = $this->height; 97 98 98 $libPathInPiwik = 'libs/open-flash-chart/'; 99 99 $currentPath = Piwik_Url::getCurrentUrlWithoutFileName(); 100 100 $pathToLibraryOpenChart = $currentPath . $libPathInPiwik; 101 101 102 102 $url = Piwik_Url::getCurrentUrlWithoutQueryString() . $url; 103 // escape the & and stuff:104 $url = urlencode($url);105 103 // escape the & and stuff: 104 $url = urlencode($url); 105 106 106 $obj_id = $this->uniqueIdViewDataTable . "Chart"; 107 $div_name = $this->uniqueIdViewDataTable . "FlashContent"; 108 109 $return = ''; 110 if( $use_swfobject ) 111 { 112 // Using library for auto-enabling Flash object on IE, disabled-Javascript proof 113 $return .= ' 114 <div id="'. $div_name .'"></div> 115 <script type="text/javascript"> 116 var so = new SWFObject("'.$pathToLibraryOpenChart.'open-flash-chart.swf", "'.$obj_id.'_swf", "'. $width . '", "' . $height . '", "9", "#FFFFFF"); 117 so.addVariable("data", "'. $url . '"); 118 so.addParam("allowScriptAccess", "sameDomain"); 119 so.addParam("wmode", "transparent"); 120 so.write("'. $div_name .'"); 121 </script> 122 <noscript> 123 '; 107 $div_name = $this->uniqueIdViewDataTable . "FlashContent"; 108 109 $return = ''; 110 if( $use_swfobject ) 111 { 112 // Using library for auto-enabling Flash object on IE, disabled-Javascript proof 113 $return .= ' 114 <div id="'. $div_name .'"><div id="'. $obj_id .'_swf"><noscript>'; 124 115 } 116 125 117 $urlGraph = $pathToLibraryOpenChart."open-flash-chart.swf?data=" . $url; 126 118 127 119 // when the object/embed is changed, see also widgetize.js; it may require a logic update 128 $this->graphCodeEmbed .= "<div><object classid='clsid:d27cdb6e-ae6d-11cf-96b8-444553540000' codebase='http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0' width='" . $width . "' height='" . $height . "' id='". $obj_id ."' >".129 "<param name='movie' value='".$urlGraph."' />". 130 "<param name='wmode' value='transparent' />". 131 "<param name='allowScriptAccess' value='sameDomain' /> ". 132 "<embed src='$urlGraph' allowScriptAccess='sameDomain' quality='high' bgcolor='#FFFFFF' width='". $width ."' height='". $height ."' name='open-flash-chart' type='application/x-shockwave-flash' id='". $obj_id ."' />". 133 "</object></div>";120 $this->graphCodeEmbed .= '<div><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" width="' . $width . '" height="' . $height . '" id="'. $obj_id .'" > 121 <param name="movie" value="'.$urlGraph.'" /> 122 <param name="wmode" value="opaque" /> 123 <param name="allowScriptAccess" value="sameDomain" /> 124 <embed src="'.$urlGraph.'" wmode="opaque" allowScriptAccess="sameDomain" quality="high" bgcolor="#FFFFFF" width="'. $width .'" height="'. $height .'" name="open-flash-chart" type="application/x-shockwave-flash" id="'. $obj_id .'" /> 125 </object></div>'; 134 126 $return .= $this->graphCodeEmbed; 135 136 if ( $use_swfobject ) { 137 $return .= '</noscript>'; 127 128 if( $use_swfobject ) 129 { 130 $return .= ' 131 </noscript></div></div> 132 <script type="text/javascript"> 133 swfobject.embedSWF("'.$pathToLibraryOpenChart.'open-flash-chart.swf", "'. $obj_id .'_swf", "'. $width . '", "' . $height . '", "9.0.0", false, {"data":"'.$url.'"}, {"allowScriptAccess":"sameDomain","wmode":"opaque"}, {"bgcolor":"#FFFFFF"}); 134 </script>'; 138 135 } 139 136 140 137 return $return; 141 138 } 142 139 } 143
