PMA\libraries\Scripts::getDisplay PHP Method

getDisplay() public method

Renders all the JavaScript file inclusions, code and events
public getDisplay ( ) : string
return string
    public function getDisplay()
    {
        $retval = '';
        if (count($this->_files) > 0) {
            $retval .= $this->_includeFiles($this->_files);
        }
        $code = 'AJAX.scriptHandler';
        foreach ($this->_files as $file) {
            $code .= sprintf('.add("%s",%d)', Sanitize::escapeJsString($file['filename']), $file['has_onload'] ? 1 : 0);
        }
        $code .= ';';
        $this->addCode($code);
        $code = '$(function() {';
        foreach ($this->_files as $file) {
            if ($file['has_onload']) {
                $code .= 'AJAX.fireOnload("';
                $code .= Sanitize::escapeJsString($file['filename']);
                $code .= '");';
            }
        }
        $code .= '});';
        $this->addCode($code);
        $retval .= '<script data-cfasync="false" type="text/javascript">';
        $retval .= "// <![CDATA[\n";
        $retval .= $this->_code;
        $retval .= '// ]]>';
        $retval .= '</script>';
        return $retval;
    }

Usage Example

Example #1
0
 /**
  * Renders the footer
  *
  * @return string
  */
 public function getDisplay()
 {
     $retval = '';
     $this->_setHistory();
     if ($this->_isEnabled) {
         if (!$this->_isAjax) {
             $retval .= "</div>";
         }
         if (!$this->_isAjax && !$this->_isMinimal) {
             if (PMA_getenv('SCRIPT_NAME') && empty($_POST) && empty($GLOBALS['checked_special']) && !$this->_isAjax) {
                 $url = $this->getSelfUrl();
                 $header = Response::getInstance()->getHeader();
                 $scripts = $header->getScripts()->getFiles();
                 $menuHash = $header->getMenu()->getHash();
                 // prime the client-side cache
                 $this->_scripts->addCode(sprintf('if (! (history && history.pushState)) ' . 'PMA_MicroHistory.primer = {' . ' url: "%s",' . ' scripts: %s,' . ' menuHash: "%s"' . '};', Sanitize::escapeJsString($url), json_encode($scripts), Sanitize::escapeJsString($menuHash)));
             }
             if (PMA_getenv('SCRIPT_NAME') && !$this->_isAjax) {
                 $url = $this->getSelfUrl();
                 $retval .= $this->_getSelfLink($url);
             }
             $this->_scripts->addCode('var debugSQLInfo = ' . $this->getDebugMessage() . ';');
             $retval .= '<div class="clearfloat" id="pma_errors">';
             $retval .= $this->getErrorMessages();
             $retval .= '</div>';
             $retval .= $this->_scripts->getDisplay();
             if ($GLOBALS['cfg']['DBG']['demo']) {
                 $retval .= '<div id="pma_demo">';
                 $retval .= $this->_getDemoMessage();
                 $retval .= '</div>';
             }
             // Include possible custom footers
             if (file_exists(CUSTOM_FOOTER_FILE)) {
                 $retval .= '<div id="pma_footer">';
                 ob_start();
                 include CUSTOM_FOOTER_FILE;
                 $retval .= ob_get_contents();
                 ob_end_clean();
                 $retval .= '</div>';
             }
         }
         if (!$this->_isAjax) {
             $retval .= "</body></html>";
         }
     }
     return $retval;
 }
All Usage Examples Of PMA\libraries\Scripts::getDisplay