00001 <?php 00002 /********************************************************************************* 00003 * Zurmo is a customer relationship management program developed by 00004 * Zurmo, Inc. Copyright (C) 2017 Zurmo Inc. 00005 * 00006 * Zurmo is free software; you can redistribute it and/or modify it under 00007 * the terms of the GNU Affero General Public License version 3 as published by the 00008 * Free Software Foundation with the addition of the following permission added 00009 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK 00010 * IN WHICH THE COPYRIGHT IS OWNED BY ZURMO, ZURMO DISCLAIMS THE WARRANTY 00011 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS. 00012 * 00013 * Zurmo is distributed in the hope that it will be useful, but WITHOUT 00014 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00015 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more 00016 * details. 00017 * 00018 * You should have received a copy of the GNU Affero General Public License along with 00019 * this program; if not, see http://www.gnu.org/licenses or write to the Free 00020 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 00021 * 02110-1301 USA. 00022 * 00023 * You can contact Zurmo, Inc. with a mailing address at 27 North Wacker Drive 00024 * Suite 370 Chicago, IL 60606. or at email address contact@zurmo.com. 00025 * 00026 * The interactive user interfaces in original and modified versions 00027 * of this program must display Appropriate Legal Notices, as required under 00028 * Section 5 of the GNU Affero General Public License version 3. 00029 * 00030 * In accordance with Section 7(b) of the GNU Affero General Public License version 3, 00031 * these Appropriate Legal Notices must retain the display of the Zurmo 00032 * logo and Zurmo copyright notice. If the display of the logo is not reasonably 00033 * feasible for technical reasons, the Appropriate Legal Notices must display the words 00034 * "Copyright Zurmo Inc. 2017. All rights reserved". 00035 ********************************************************************************/ 00036 00041 abstract class StepsAndProgressBarForWizardView extends MetadataView 00042 { 00043 protected $zeroBasedStepIndex = 0; 00044 00048 abstract protected function getSpanLabels(); 00049 00050 public function __construct($zeroBasedStepIndex = 0) 00051 { 00052 assert('is_int($zeroBasedStepIndex)'); 00053 $this->zeroBasedStepIndex = $zeroBasedStepIndex; 00054 } 00055 00056 public function isUniqueToAPage() 00057 { 00058 return true; 00059 } 00060 00061 protected function renderContent() 00062 { 00063 $width = $this->getSpanPercentWidthFromCount() * ($this->zeroBasedStepIndex + 1); 00064 $content = ZurmoHtml::tag('div', array('class' => 'progress-bar', 00065 'style' => 'width:' . $width . '%; margin-left:0%'), ''); 00066 $content = ZurmoHtml::tag('div', array('class' => 'progress-back'), $content); 00067 $spanContent = $this->getSpanContent(); 00068 return ZurmoHtml::tag('div', array('class' => 'progress'), $content . $spanContent); 00069 } 00070 00071 protected function getSpanContent() 00072 { 00073 $width = $this->getSpanPercentWidthFromCount(); 00074 $content = null; 00075 $first = true; 00076 foreach ($this->getSpanLabels() as $step => $label) 00077 { 00078 $htmlOptions = array(); 00079 $htmlOptions['style'] = 'width:' . $width . '%'; 00080 if ($this->zeroBasedStepIndex === $step) 00081 { 00082 $htmlOptions['class'] = 'current-step'; 00083 } 00084 $content .= ZurmoHtml::tag('span', $htmlOptions, $label); 00085 $first = false; 00086 } 00087 return $content; 00088 } 00089 00090 protected function getSpanPercentWidthFromCount() 00091 { 00092 $width = 100 / count($this->getSpanLabels()); 00093 return $width; 00094 } 00095 } 00096 ?>