Ticket #243: GenerateGraphHTML.diff

File GenerateGraphHTML.diff, 5.7 KB (added by vipsoft, 3 years ago)

Replaces patch for core/ViewDataTable/GenerateGraphHTML.php.

  • core/ViewDataTable/GenerateGraphHTML.php

     
    1818 */ 
    1919abstract class Piwik_ViewDataTable_GenerateGraphHTML extends Piwik_ViewDataTable 
    2020{        
    21         protected $width = '100%';  
     21        protected $width = '100%'; 
    2222        protected $height = 250; 
    2323        protected $graphType = 'standard'; 
    24          
     24 
    2525        /** 
    2626         * @see Piwik_ViewDataTable::init() 
    2727         */ 
    2828        function init($currentControllerName, 
    29                                                 $currentControllerAction,  
     29                                                $currentControllerAction, 
    3030                                                $apiMethodToRequestDataTable ) 
    3131        { 
    3232                parent::init($currentControllerName, 
    33                                                 $currentControllerAction,  
     33                                                $currentControllerAction, 
    3434                                                $apiMethodToRequestDataTable ); 
    3535 
    3636                $this->dataTableTemplate = 'CoreHome/templates/graph.tpl'; 
    37                  
     37 
    3838                $this->disableOffsetInformation(); 
    3939                $this->disableExcludeLowPopulation(); 
    4040                $this->disableSearchBox(); 
    41                 $this->parametersToModify = array(  
     41                $this->parametersToModify = array( 
    4242                                                'viewDataTable' => $this->getViewDataTableIdToLoad(), 
    4343                                                // in the case this controller is being executed by another controller 
    4444                                                // eg. when being widgetized in an IFRAME 
     
    4747                                                'action' => $currentControllerAction, 
    4848                ); 
    4949        } 
    50          
     50 
    5151        /** 
    5252         * Sets parameters to modify in the future generated URL 
    5353         * @param array $array array('nameParameter' => $newValue, ...) 
     
    5656        { 
    5757                $this->parametersToModify = array_merge($this->parametersToModify, $array); 
    5858        } 
    59          
     59 
    6060        /** 
    6161         * @see Piwik_ViewDataTable::main() 
    6262         */ 
     
    7070                 
    7171                $this->view = $this->buildView(); 
    7272        } 
    73          
     73 
    7474        protected function buildView() 
    7575        { 
    7676                $view = new Piwik_View($this->dataTableTemplate); 
     
    8989                $view->properties = $this->getViewProperties(); 
    9090                return $view; 
    9191        } 
    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;  
    9792 
     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 
    9898                $libPathInPiwik = 'libs/open-flash-chart/'; 
    9999                $currentPath = Piwik_Url::getCurrentUrlWithoutFileName(); 
    100100                $pathToLibraryOpenChart = $currentPath . $libPathInPiwik; 
    101                  
     101 
    102102                $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 
    106106                $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>'; 
    124115                } 
     116 
    125117                $urlGraph = $pathToLibraryOpenChart."open-flash-chart.swf?data=" . $url; 
    126                  
     118 
    127119                // 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>'; 
    134126                $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"> 
     133swfobject.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>'; 
    138135                } 
    139                  
     136 
    140137                return $return; 
    141138        } 
    142139} 
    143