TYPO3 CMS  TYPO3_7-6
AbstractStepAction.php
Go to the documentation of this file.
1 <?php
3 
4 /*
5  * This file is part of the TYPO3 CMS project.
6  *
7  * It is free software; you can redistribute it and/or modify it under
8  * the terms of the GNU General Public License, either version 2
9  * of the License, or any later version.
10  *
11  * For the full copyright and license information, please read the
12  * LICENSE.txt file that was distributed with this source code.
13  *
14  * The TYPO3 project - inspiring people to share!
15  */
16 
21 {
25  protected $currentStep = 0;
26 
30  protected $totalSteps = 0;
31 
39  public function setStepsCounter($current, $total)
40  {
41  $this->currentStep = $current;
42  $this->totalSteps = $total;
43  }
44 
50  public function getCurrentStep()
51  {
52  return $this->currentStep;
53  }
54 
60  public function getTotalSteps()
61  {
62  return $this->totalSteps;
63  }
64 
68  protected function assignSteps()
69  {
70  $steps = [];
71  $currentStep = $this->getCurrentStep();
72  $totalSteps = $this->getTotalSteps();
73  for ($i = 1; $i <= $totalSteps; $i++) {
74  $class = '';
75  if ($i == $currentStep) {
76  $class = 'cur';
77  } elseif ($i < $currentStep) {
78  $class = 'prev';
79  }
80  $steps[] = [
81  'number' => $i,
82  'class' => $class,
83  'total' => $totalSteps,
84  'percent' => floor((100 * $i) / $totalSteps)
85  ];
86  }
87  $this->view->assign('steps', $steps);
88  $this->view->assign('currentStep', $steps[$currentStep-1]);
89  }
90 }