<commit_before><?php
/*
 * This file is part of the Mouf core package.
 *
 * (c) 2012 <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE.txt
 * file that was distributed with this source code.
 */
namespace Mouf\Actions;

use Mouf\Mvc\Splash\Controllers\Controller;


/**
 * The controller that performs the installation by running the MultiStepActionService in a loop.
 * 
 * @author david
 * @Component
 */
class InstallController extends Controller {
	
	/**
	 * @Property
	 * @Compulsory
	 * @var MultiStepActionService
	 */
	public $multiStepActionService;
	
	/**
	 * @Property
	 * @Compulsory
	 * @var TemplateInterface
	 */
	public $template;
	
	/**
	 * The content block the template will be writting into.
	 *
	 * @Property
	 * @Compulsory
	 * @var HtmlBlock
	 */
	public $contentBlock;
	
	/**
	 * 
	 * @var array<MoufActionDescriptor>
	 */
	protected $actionsList;
	
	/**
	 * True if finished.
	 * @var bool
	 */
	protected $done;
	
	/**
	 * The exception thrown while running the action, if any.
	 * @var unknown_type
	 */
	protected $exception;
	
	protected $selfedit;
	
	/**
	 * Displays the page that runs the actions of the MultiStepActionService.
	 * 
	 * @Action
	 * @Logged
	 * @param string $selfedit 
	 */
	public function defaultAction($selfedit = "false") {
		$this->selfedit = $selfedit;
		if ($selfedit == "true") {
			$this->multiStepActionService->actionsStoreFile = "moufRunningActions.php";
		} else {
			$this->multiStepActionService->actionsStoreFile = "../../../moufRunningActions.php";
		}
		$this->actionsList = $this->multiStepActionService->getActionsList();
		$this->contentBlock->addFile(__DIR__."/../../views/install/install.php", $this);
		$this->template->toHtml();
	}
	
	/**
	 * Ajax action that installs the next step.
	 * 
	 * @Action
	 * @Logged
	 */
	public function nextstep($selfedit = "false") {
		// FIXME: we should take into account the $selfEdit variable!!!!
		// TODO: first, we should receive the selfedit variable!!!!
		
		if ($selfedit == "true") {
			$this->multiStepActionService->actionsStoreFile = "moufRunningActions.php";
		} else {
			$this->multiStepActionService->actionsStoreFile = "../../../moufRunningActions.php";
		}
		
		$this->done = false;
		$actionResult =  null;
		$html = "";
		if ($this->multiStepActionService->hasRemainingAction()) {
			try {
				$actionResult = $this->multiStepActionService->executeNextAction();
			} catch (Exception $e) {
				$this->exception = $e;
			}
			if (!$this->multiStepActionService->hasRemainingAction()) {
				$this->done = true;
			}
		} else {
			$this->done = true;
		}
		
		$redirect = null;
		if ($actionResult && $actionResult->getStatus() == "redirect") {
			$redirect = ROOT_URL.$actionResult->getRedirectUrl();
		}
		
		if ($this->done) {
			$this->multiStepActionService->purgeActions();<commit_msg>Fixing ROOT_URL<commit_after><?php
/*
 * This file is part of the Mouf core package.
 *
 * (c) 2012 <NAME> <<EMAIL>>
 *
 * For the full copyright and license information, please view the LICENSE.txt
 * file that was distributed with this source code.
 */
namespace Mouf\Actions;

use Mouf\Mvc\Splash\Controllers\Controller;


/**
 * The controller that performs the installation by running the MultiStepActionService in a loop.
 * 
 * @author david
 * @Component
 */
class InstallController extends Controller {
	
	/**
	 * @Property
	 * @Compulsory
	 * @var MultiStepActionService
	 */
	public $multiStepActionService;
	
	/**
	 * @Property
	 * @Compulsory
	 * @var TemplateInterface
	 */
	public $template;
	
	/**
	 * The content block the template will be writting into.
	 *
	 * @Property
	 * @Compulsory
	 * @var HtmlBlock
	 */
	public $contentBlock;
	
	/**
	 * 
	 * @var array<MoufActionDescriptor>
	 */
	protected $actionsList;
	
	/**
	 * True if finished.
	 * @var bool
	 */
	protected $done;
	
	/**
	 * The exception thrown while running the action, if any.
	 * @var unknown_type
	 */
	protected $exception;
	
	protected $selfedit;
	
	/**
	 * Displays the page that runs the actions of the MultiStepActionService.
	 * 
	 * @Action
	 * @Logged
	 * @param string $selfedit 
	 */
	public function defaultAction($selfedit = "false") {
		$this->selfedit = $selfedit;
		if ($selfedit == "true") {
			$this->multiStepActionService->actionsStoreFile = "moufRunningActions.php";
		} else {
			$this->multiStepActionService->actionsStoreFile = "../../../moufRunningActions.php";
		}
		$this->actionsList = $this->multiStepActionService->getActionsList();
		$this->contentBlock->addFile(__DIR__."/../../views/install/install.php", $this);
		$this->template->toHtml();
	}
	
	/**
	 * Ajax action that installs the next step.
	 * 
	 * @Action
	 * @Logged
	 */
	public function nextstep($selfedit = "false") {
		// FIXME: we should take into account the $selfEdit variable!!!!
		// TODO: first, we should receive the selfedit variable!!!!
		
		if ($selfedit == "true") {
			$this->multiStepActionService->actionsStoreFile = "moufRunningActions.php";
		} else {
			$this->multiStepActionService->actionsStoreFile = "../../../moufRunningActions.php";
		}
		
		$this->done = false;
		$actionResult =  null;
		$html = "";
		if ($this->multiStepActionService->hasRemainingAction()) {
			try {
				$actionResult = $this->multiStepActionService->executeNextAction();
			} catch (Exception $e) {
				$this->exception = $e;
			}
			if (!$this->multiStepActionService->hasRemainingAction()) {
				$this->done = true;
			}
		} else {
			$this->done = true;
		}
		
		$redirect = null;
		if ($actionResult && $actionResult->getStatus() == "redirect") {
			if ($selfedit == 'true') {
				$redirect = ROOT_URL.$actionResult->getRedirectUrl();
			} else {
				$redirect = ROOT_URL."../../../".$actionResult->getRedirectUrl();
			}
		}
		
		if ($this->done) {
			$this->multiStepActionService->purgeActions();
{'fraction_non_alphanumeric': 0.1512145056448854, 'fraction_numerical': 0.0013684570646595963, 'mean_word_length': 3.356929955290611, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 74, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, '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': '3942827', 'n_tokens_mistral': 2040, 'n_tokens_neox': 1779, 'n_words': 436}