<commit_before><?php
/**
 * @link http://www.yiiframework.com/
 * @copyright Copyright (c) 2008 Yii Software LLC
 * @license http://www.yiiframework.com/license/
 */

namespace yii\debug\panels;

use Yii;
use yii\base\InlineAction;
use yii\bootstrap\Tabs;
use yii\debug\Panel;
use yii\helpers\Html;
use yii\web\Response;

/**
 * Debugger panel that collects and displays request data.
 *
 * @author <NAME> <<EMAIL>>
 * @since 2.0
 */
class RequestPanel extends Panel
{
	public function getName()
	{
		return 'Request';
	}

	public function getSummary()
	{
		$url = $this->getUrl();
		$statusCode = $this->data['statusCode'];
		if ($statusCode === null) {
			$statusCode = 200;
		}
		if ($statusCode >= 200 && $statusCode < 300) {
			$class = 'label-success';
		} elseif ($statusCode >= 100 && $statusCode < 200) {
			$class = 'label-info';
		} else {
			$class = 'label-important';
		}
		$statusText = Html::encode(isset(Response::$httpStatuses[$statusCode]) ? Response::$httpStatuses[$statusCode] : '');

		return <<<EOD
<div class="yii-debug-toolbar-block">
	<a href="$url" title="Status code: $statusCode $statusText">Status <span class="label $class">$statusCode</span></a>
</div>
<div class="yii-debug-toolbar-block">
	<a href="$url">Action <span class="label">{$this->data['action']}</span></a>
</div>
EOD;
	}

	public function getDetail()
	{
		$data = array(
			'Route' => $this->data['route'],
			'Action' => $this->data['action'],
			'Parameters' => $this->data['actionParams'],
		);
		return Tabs::widget(array(
			'items' => array(
				array(
					'label' => 'Parameters',
					'content' => $this->renderData('Routing', $data)
						. $this->renderData('$_GET', $this->data['GET'])
						. $this->renderData('$_POST', $this->data['POST'])
						. $this->renderData('$_FILES', $this->data['POST'])
						. $this->renderData('$_COOKIE', $this->data['COOKIE']),
					'active' => true,
				),
				array(
					'label' => 'Headers',
					'content' => $this->renderData('Request Headers', $this->data['requestHeaders'])
						. $this->renderData('Response Headers', $this->data['responseHeaders']),
				),
				array(
					'label' => 'Session',
					'content' => $this->renderData('$_SESSION', $this->data['SESSION'])
						. $this->renderData('Flashes', $this->data['flashes']),
				),
				array(
					'label' => '$_SERVER',
					'content' => $this->renderData('$_SERVER', $this->data['SERVER']),
				),
			),
		));
	}

	public function save()
	{
		if (function_exists('apache_request_headers')) {
			$requestHeaders = apache_request_headers();
		} elseif (function_exists('http_get_request_headers')) {
			$requestHeaders = http_get_request_headers();<commit_msg>Fix in RequestPanel<commit_after><?php
/**
 * @link http://www.yiiframework.com/
 * @copyright Copyright (c) 2008 Yii Software LLC
 * @license http://www.yiiframework.com/license/
 */

namespace yii\debug\panels;

use Yii;
use yii\base\InlineAction;
use yii\bootstrap\Tabs;
use yii\debug\Panel;
use yii\helpers\Html;
use yii\web\Response;

/**
 * Debugger panel that collects and displays request data.
 *
 * @author <NAME> <<EMAIL>.com>
 * @since 2.0
 */
class RequestPanel extends Panel
{
	public function getName()
	{
		return 'Request';
	}

	public function getSummary()
	{
		$url = $this->getUrl();
		$statusCode = $this->data['statusCode'];
		if ($statusCode === null) {
			$statusCode = 200;
		}
		if ($statusCode >= 200 && $statusCode < 300) {
			$class = 'label-success';
		} elseif ($statusCode >= 100 && $statusCode < 200) {
			$class = 'label-info';
		} else {
			$class = 'label-important';
		}
		$statusText = Html::encode(isset(Response::$httpStatuses[$statusCode]) ? Response::$httpStatuses[$statusCode] : '');

		return <<<EOD
<div class="yii-debug-toolbar-block">
	<a href="$url" title="Status code: $statusCode $statusText">Status <span class="label $class">$statusCode</span></a>
</div>
<div class="yii-debug-toolbar-block">
	<a href="$url">Action <span class="label">{$this->data['action']}</span></a>
</div>
EOD;
	}

	public function getDetail()
	{
		$data = array(
			'Route' => $this->data['route'],
			'Action' => $this->data['action'],
			'Parameters' => $this->data['actionParams'],
		);
		return Tabs::widget(array(
			'items' => array(
				array(
					'label' => 'Parameters',
					'content' => $this->renderData('Routing', $data)
						. $this->renderData('$_GET', $this->data['GET'])
						. $this->renderData('$_POST', $this->data['POST'])
						. $this->renderData('$_FILES', $this->data['FILES'])
						. $this->renderData('$_COOKIE', $this->data['COOKIE']),
					'active' => true,
				),
				array(
					'label' => 'Headers',
					'content' => $this->renderData('Request Headers', $this->data['requestHeaders'])
						. $this->renderData('Response Headers', $this->data['responseHeaders']),
				),
				array(
					'label' => 'Session',
					'content' => $this->renderData('$_SESSION', $this->data['SESSION'])
						. $this->renderData('Flashes', $this->data['flashes']),
				),
				array(
					'label' => '$_SERVER',
					'content' => $this->renderData('$_SERVER', $this->data['SERVER']),
				),
			),
		));
	}

	public function save()
	{
		if (function_exists('apache_request_headers')) {
			$requestHeaders = apache_request_headers();
		} elseif (function_exists('http_get_request_headers')) {
			$requestHeaders = http_get_request_headers();
{'fraction_non_alphanumeric': 0.21077239573592668, 'fraction_numerical': 0.007854871890779876, 'mean_word_length': 4.054820415879017, 'pattern_counts': {'":': 0, '<': 45, '<?xml version=': 0, '>': 113, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6324682', 'n_tokens_mistral': 2123, 'n_tokens_neox': 1817, 'n_words': 337}