<commit_before><?php
declare(ENCODING = 'utf-8');
namespace F3\Fluid\Controller;

/*                                                                        *
 * This script belongs to the FLOW3 package "Fluid".                      *
 *                                                                        *
 * It is free software; you can redistribute it and/or modify it under    *
 * the terms of the GNU Lesser General Public License as published by the *
 * Free Software Foundation, either version 3 of the License, or (at your *
 * option) any later version.                                             *
 *                                                                        *
 * This script is distributed in the hope that it will be useful, but     *
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
 * General Public License for more details.                               *
 *                                                                        *
 * You should have received a copy of the GNU Lesser General Public       *
 * License along with the script.                                         *
 * If not, see http://www.gnu.org/licenses/lgpl.html                      *
 *                                                                        *
 * The TYPO3 project - inspiring people to share!                         *
 *                                                                        */

/**
 * @package Fluid
 * @subpackage Controller
 * @version $Id$
 */

/**
 * Controller which provides a web UI for generating ViewHelper XSD Definitons
 *
 * @package Fluid
 * @subpackage Controller
 * @version $Id$
 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
 */
class StandardController extends \F3\FLOW3\MVC\Controller\ActionController {

	/**
	 * XSD Generator
	 * @var F3\Fluid\Service\XSDGenerator
	 */
	protected $xsdGenerator;

	/**
	 * Inject XSD Generator
	 *
	 * @param \F3\Fluid\Service\XSDGenerator $xsdGenerator XSD Generator
	 * @return void
	 * @author <NAME> <<EMAIL>>
	 * @api
	 */
	public function injectXSDGenerator(\F3\Fluid\Service\XSDGenerator $xsdGenerator) {
		$this->xsdGenerator = $xsdGenerator;
	}

	/**
	 * Inject a TemplateView
	 *
	 * @param \F3\Fluid\View\TemplateView $view The Fluid View Instance
	 * @return void
	 * @author <NAME> <<EMAIL>>
	 */
	public function injectView(\F3\Fluid\View\TemplateView $view) {
		$this->view = $view;
	}

	/**
	 * Index action
	 *
	 * @return string HTML string
	 * @author <NAME> <<EMAIL>>
	 */
	public function indexAction() {
		return $this->view->render();
	}

	/**
	 * Generate the XSD file.
	 *
	 * @param $baseNamespace string
	 * @param $namespacePrefix string
	 * @return string HTML string
	 * @author <NAME> <<EMAIL>>
	 * @todo Still has to be finished
	 */
	public function generateXSDAction($baseNamespace, $namespacePrefix) {
		$xsdFileContents = $this->xsdGenerator->generateXSD($baseNamespace);

		$path = 'Resources/Fluid/XSD/';
		if (!is_dir(FLOW3_PATH_PUBLIC . $path)) {
			\F3\FLOW3\Utility\Files::createDirectoryRecursively(FLOW3_PATH_PUBLIC . $path);
		}

		$filename = $path . str_replace('\\', '_', $baseNamespace) . '.xsd';

		$fp = fopen(FLOW3_PATH_PUBLIC . $filename, 'w');
		fputs($fp, $xsdFileContents);
		fclose($fp);

		return $this->view->assign('xsdPath', $filename)
		                  ->assign('namespaceURI', 'http://typo3.org/ns/fluid/' . str_replace('\\', '/', $baseNamespace))
		                  ->assign('namespacePrefix', $namespacePrefix)
		                  ->render();
	}
}
?><commit_msg>[!!!][~TASK] FLOW3: Renamed the directory "Public" to "Web" and the constant FLOW3_PATH_PUBLIC to FLOW3_PATH_WEB accordingly. [!!!][~TASK] FLOW3: Renamed the folder for packages which are included in the FLOW3 distribution from "Distribution" to "Framework". [~TASK] FLOW3: Improved and refactored the bootstrap script (index.php) Original-Commit-Hash: e832d00e95a1602eaa1a4b9fcbb5dcae747c236d<commit_after><?php
declare(ENCODING = 'utf-8');
namespace F3\Fluid\Controller;

/*                                                                        *
 * This script belongs to the FLOW3 package "Fluid".                      *
 *                                                                        *
 * It is free software; you can redistribute it and/or modify it under    *
 * the terms of the GNU Lesser General Public License as published by the *
 * Free Software Foundation, either version 3 of the License, or (at your *
 * option) any later version.                                             *
 *                                                                        *
 * This script is distributed in the hope that it will be useful, but     *
 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
 * General Public License for more details.                               *
 *                                                                        *
 * You should have received a copy of the GNU Lesser General Public       *
 * License along with the script.                                         *
 * If not, see http://www.gnu.org/licenses/lgpl.html                      *
 *                                                                        *
 * The TYPO3 project - inspiring people to share!                         *
 *                                                                        */

/**
 * @package Fluid
 * @subpackage Controller
 * @version $Id$
 */

/**
 * Controller which provides a web UI for generating ViewHelper XSD Definitons
 *
 * @package Fluid
 * @subpackage Controller
 * @version $Id$
 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
 */
class StandardController extends \F3\FLOW3\MVC\Controller\ActionController {

	/**
	 * XSD Generator
	 * @var F3\Fluid\Service\XSDGenerator
	 */
	protected $xsdGenerator;

	/**
	 * Inject XSD Generator
	 *
	 * @param \F3\Fluid\Service\XSDGenerator $xsdGenerator XSD Generator
	 * @return void
	 * @author <NAME> <<EMAIL>>
	 * @api
	 */
	public function injectXSDGenerator(\F3\Fluid\Service\XSDGenerator $xsdGenerator) {
		$this->xsdGenerator = $xsdGenerator;
	}

	/**
	 * Inject a TemplateView
	 *
	 * @param \F3\Fluid\View\TemplateView $view The Fluid View Instance
	 * @return void
	 * @author <NAME> <<EMAIL>>
	 */
	public function injectView(\F3\Fluid\View\TemplateView $view) {
		$this->view = $view;
	}

	/**
	 * Index action
	 *
	 * @return string HTML string
	 * @author <NAME> <<EMAIL>>
	 */
	public function indexAction() {
		return $this->view->render();
	}

	/**
	 * Generate the XSD file.
	 *
	 * @param $baseNamespace string
	 * @param $namespacePrefix string
	 * @return string HTML string
	 * @author <NAME> <<EMAIL>>
	 * @todo Still has to be finished
	 */
	public function generateXSDAction($baseNamespace, $namespacePrefix) {
		$xsdFileContents = $this->xsdGenerator->generateXSD($baseNamespace);

		$path = 'Resources/Fluid/XSD/';
		if (!is_dir(FLOW3_PATH_WEB . $path)) {
			\F3\FLOW3\Utility\Files::createDirectoryRecursively(FLOW3_PATH_WEB . $path);
		}

		$filename = $path . str_replace('\\', '_', $baseNamespace) . '.xsd';

		$fp = fopen(FLOW3_PATH_WEB . $filename, 'w');
		fputs($fp, $xsdFileContents);
		fclose($fp);

		return $this->view->assign('xsdPath', $filename)
		                  ->assign('namespaceURI', 'http://typo3.org/ns/fluid/' . str_replace('\\', '/', $baseNamespace))
		                  ->assign('namespacePrefix', $namespacePrefix)
		                  ->render();
	}
}
?>
{'fraction_non_alphanumeric': 0.11247259125499806, 'fraction_numerical': 0.008383851412356508, 'mean_word_length': 1.8793167471221686, 'pattern_counts': {'":': 0, '<': 29, '<?xml version=': 0, '>': 51, 'https://': 0, 'lorem ipsum': 0, 'www.': 4, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 42, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4140020', 'n_tokens_mistral': 2205, 'n_tokens_neox': 2032, 'n_words': 601}