Returns a string representation of the script output (javascript) from this request object

@return string
499929
public function getScript()
    {
        /*
         * JQuery variables sometimes depend on the context where they are used, eg. when their value depends on $(this).
         * When a confirmation question is added, the Jaxon calls are made in a different context,
         * making those variables invalid.
         * To avoid issues related to these context changes, the JQuery selectors values are first saved into
         * local variables, which are then used in Jaxon function calls.
         */
        $sVars = ''; // Javascript code defining all the variables values.
        $nVarId = 1; // Position of the variables, starting from 1.
        // This array will avoid declaring multiple variables with the same value.
        // The array key is the variable value, while the array value is the variable name.
        $aVariables = []; // Array of local variables.
        foreach($this->aParameters as &$xParameter)
        {
            $sParameterStr = $xParameter->getScript();
            if($xParameter instanceof \Jaxon\Response\Plugin\JQuery\Dom\Element)
            {
                if(!array_key_exists($sParameterStr, $aVariables))
                {
                    // The value is not yet defined. A new variable is created.
                    $sVarName = "jxnVar$nVarId";
                    $aVariables[$sParameterStr] = $sVarName;
                    $sVars .= "$sVarName=$xParameter;";
                    $nVarId++;
                }
                else
                {
                    // The value is already defined. The corresponding variable is assigned.
                    $sVarName = $aVariables[$sParameterStr];
                }
                $xParameter = new Parameter(Jaxon::JS_VALUE, $sVarName);
            }
        }

        $sPhrase = '';
        if(count($this->aMessageArgs) > 0)
        {
            $sPhrase = array_shift($this->aMessageArgs); // The first array entry is the question.
            // $sPhrase = "'" . addslashes($sPhrase) . "'"; // Wrap the phrase with single quotes
            if(count($this->aMessageArgs) > 0)
            {
                $nParamId = 1;
                foreach($this->aMessageArgs as &$xParameter)
                {
                    $sParameterStr = $xParameter->getScript();
                    if($xParameter instanceof \Jaxon\Response\Plugin\JQuery\Dom\Element)
                    {
                        if(!array_key_exists($sParameterStr, $aVariables))
                        {
                            // The value is not yet defined. A new variable is created.
                            $sVarName = "jxnVar$nVarId";
                            $aVariables[$sParameterStr] = $sVarName;
                            $sVars .= "$sVarName=$xParameter;";
                            $nVarId++;
                        }
                        else
                        {
                            // The value is already defined. The corresponding variable is assigned.
                            $sVarName = $aVariables[$sParameterStr];
                        }
                        $xParameter = new Parameter(Jaxon::JS_VALUE, $sVarName);
                    }
                    $xParameter = "'$nParamId':" . $xParameter->getScript();
                    $nParamId++;
                }
                $sPhrase .= '.supplant({' . implode(',', $this->aMessageArgs) . '})';
            }
        }

        $sScript = parent::getScript();
        $xDialog = jaxon()->dialog();
        if($this->sCondition == '__confirm__')
        {
            $sScript = $xDialog->confirm($sPhrase, $sScript, '');
        }
        elseif($this->sCondition !== null)
        {
            $sScript = 'if(' . $this->sCondition . '){' . $sScript . ';}';
            if(($sPhrase))
            {
                $xDialog->getAlert()->setReturn(true);
                $sScript .= 'else{' . $xDialog->warning($sPhrase) . ';}';
            }
        }
        return $sVars . $sScript;
    }
1353306
public function render() {
        $string = '';
        foreach (static::$_scripts as $script) {
            $method = '_render' . ucfirst($script['type']);
            $string .= $this->{$method}($script['value'], $script['attrs']);
        }
        return $string;
    }
1109595
public function asJavascript()
    {
        return implode("\n    ", array_map(function ($push) {
            return '_paq.push([' . implode(', ', array_map(function ($item) {
                    if ($item instanceof RawExpression) {
                        return $item->value;
                    }

                    // JSON encoding is used to escape data injected into javascript
                    return json_encode($item);
                }, $push)) . ']);';
        }, $this->pushs));
    }
357921
protected function getInlineJavaScript()
    {
        static $shown = false;

        if (!$shown) {
            $javascript = $this->getInlineJavaScriptTranslations();
            $shown = true;
        } else {
            $javascript = '';
        }

        $dismissable_messages =
            '[' . implode(', ', $this->dismissable_messages) . ']';

        $javascript .= sprintf(
            "var %s_obj = new %s('%s', %s);",
            $this->id,
            $this->getJavaScriptClass(),
            $this->id,
            $dismissable_messages
        );

        return $javascript;
    }
537028
public function getScript()
    {
        $sJsCode = '';
        switch($this->sType)
        {
        case Jaxon::FORM_VALUES:
            $sJsCode = $this->getJsCall('getFormValues', $this->xValue);
            break;
        case Jaxon::INPUT_VALUE:
            $sJsCode = $this->getJsCall('$', $this->xValue) . '.value';
            break;
        case Jaxon::CHECKED_VALUE:
            $sJsCode = $this->getJsCall('$', $this->xValue) . '.checked';
            break;
        case Jaxon::ELEMENT_INNERHTML:
            $sJsCode = $this->getJsCall('$', $this->xValue) . '.innerHTML';
            break;
        case Jaxon::QUOTED_VALUE:
            $sJsCode = $this->getQuotedValue(addslashes($this->xValue));
            break;
        case Jaxon::BOOL_VALUE:
            $sJsCode = ($this->xValue) ? 'true' : 'false';
            break;
        case Jaxon::PAGE_NUMBER:
            $sJsCode = (string)$this->xValue;
            break;
        case Jaxon::NUMERIC_VALUE:
            $sJsCode = (string)$this->xValue;
            break;
        case Jaxon::JS_VALUE:
            if(is_array($this->xValue) || is_object($this->xValue))
            {
                // Unable to use double quotes here because they cannot be handled on client side.
                // So we are using simple quotes even if the Json standard recommends double quotes.
                $sJsCode = str_replace(['"'], ["'"], json_encode($this->xValue, JSON_HEX_APOS | JSON_HEX_QUOT));
            }
            else
            {
                $sJsCode = (string)$this->xValue;
            }
            break;
        }
        return $sJsCode;
    }
274262
public function toString()
    {
        $status = sprintf('HTTP/%s %d %s', $this->getVersion(), $this->getStatusCode(), $this->getStatusMessage());

        $str  = trim($status) . "\r\n";
        $str .= $this->getHeaders();
        $str .= "\r\n";
        $str .= $this->getContent();
        return $str;
    }
736322
public function generateScripts()
    {
        $result = '';

        $rawScript     = [];
        $this->scripts = array_unique($this->scripts, SORT_REGULAR);
        foreach ($this->scripts as $scriptInfo) {
            if (!$scriptInfo[2]) {
                $result.= '<script src="'.$scriptInfo[0].'" type="'.$scriptInfo[1].'"></script>';
            } else {
                $rawScript[$scriptInfo[1]] = isset($rawScript[$scriptInfo[1]]) ? $rawScript[$scriptInfo[1]] .= $scriptInfo[0]
                        : $scriptInfo[0];
            }
        }
        foreach ($rawScript as $type => $script) {
            $result.= '<script type="'.$type.'">'.$script.'</script>';
        }

        return $result;
    }
316487
private function getTraceOutput()
    {
        if (! $this->addTraceToOutput()) {
            return '';
        }
        $inspector = $this->getInspector();
        $frames = $inspector->getFrames();

        $response = "\nStack trace:";

        $line = 1;
        foreach ($frames as $frame) {
            /** @var Frame $frame */
            $class = $frame->getClass();

            $template = "\n%3d. %s->%s() %s:%d%s";
            if (! $class) {
                // Remove method arrow (->) from output.
                $template = "\n%3d. %s%s() %s:%d%s";
            }

            $response .= sprintf(
                $template,
                $line,
                $class,
                $frame->getFunction(),
                $frame->getFile(),
                $frame->getLine(),
                $this->getFrameArgsOutput($frame, $line)
            );

            $line++;
        }

        return $response;
    }
1191342
public function toString()
    {
        if (!$this->getCommand()->getExecuted() && !$this->execute()) {
            return false;
        }
        return file_get_contents($this->getTmpFile()->getFileName());
    }
783111
public function input() {
		$output = '<script type="text/html" data-template="' . esc_attr( $this->name() ) . '">';
		if ( ! empty( $this->struct['template'] ) && file_exists( $this->struct['template'] ) ) {
			ob_start();
			include $this->struct['template'];
			$output .= ob_get_clean();
		}
		$output .= '</script>';
		echo $output;

		return $output;
	}
1335199
protected function getScript()
    {
        if (null === $this->getScriptName()) {
            $request = $this->frontController->getRequest();
            $this->setScriptName($request->getControllerName() . DIRECTORY_SEPARATOR . $request->getActionName());
        }

        return $this->getScriptName() . '.' . $this->getViewSuffix();
    }
917267
public function getJsCode()
    {
        $html = '';
        foreach ($this->js as $js) {
            $html .= sprintf('<script src="%s"></script>', $js);
        }
        foreach ($this->entry as $entry) {
            $html .= sprintf('<script>System.import(\'%s\')</script>', $entry);
        }
        return $html;
    }
623558
protected function getScriptText()
    {
        $login = Builder::escapeText($this->login);

        if ($this->control) {
            // Control event
            $controlId = Builder::escapeText($this->control->getId());
            return "
if (Event.Control.ControlId == {$controlId}) {
	ShowProfile({$login});
}";
        }

        // Other events
        return "
ShowProfile({$login});";
    }
571315
private function _getScript()
    {
        $aVars = $this->getOptionVars();
        $sYesScript = 'jaxon.ajax.response.process(command.response)';
        $sNoScript = 'jaxon.confirm.skip(command);jaxon.ajax.response.process(command.response)';
        $sConfirmScript = jaxon()->dialog()->confirm('msg', $sYesScript, $sNoScript);
        $aVars['sConfirmScript'] = $this->render('jaxon::plugins/confirm.js', ['sConfirmScript' => $sConfirmScript]);

        return $this->render('jaxon::plugins/config.js', $aVars) . "\n" . $this->sJsReady . "\n";
    }
389488
public function asString()
    {
        $display = function ($lines, $length, $loop = 0) use (&$display) {
            $output = '';
            foreach ($lines as $line) {
                $line = is_a($line, 'Deflection\Element\AbstractElement') ? $line->getElement() : $line;
                if (is_array($line)) {
                    $output .= $display($line, $length, $loop+1);
                } else {
                    $size = mb_strlen($line)+($length*$loop);
                    $output .= str_pad($line, $size, ' ', STR_PAD_LEFT)."\n";
                }
            }
            return $output;
        };
        return !$this->class ?: "<?php\n".$display($this->class->getElement(), $this->tab);
    }
402081
protected function getScriptText()
    {
        $actionName = Builder::escapeText($this->actionName);
        $key        = null;
        $value      = null;
        if ($this->keyName !== null) {
            $key   = "KeyName";
            $value = $this->keyName;
        } else if ($this->keyCode !== null) {
            $key   = "KeyCode";
            $value = $this->keyCode;
        } else if ($this->charPressed !== null) {
            $key   = "CharPressed";
            $value = $this->charPressed;
        }
        $value = Builder::escapeText($value);
        return "
if (Event.{$key} == {$value}) {
	TriggerPageAction({$actionName});
}";
    }
1266982
public function getHtmlOutput() {
    try {
      $profileId = $this->getFirstProfileId();
      if (isset($profileId)) {
        $results = $this->queryCoreReportingApi($profileId);
        return $this->getFormattedResults($results);
      }

    } catch (Google_ServiceException $e) {
      // Error from the API.
      $this->error = $e->getMessage();

    } catch (demoException $e) {
      // Error running this demo.
      $this->error = $e->getMessage();
    }
    return '';
  }