-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
split sidebar in 3 different viewHelpers
- Loading branch information
1 parent
aba5a55
commit 2268036
Showing
9 changed files
with
164 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<?php | ||
|
||
|
||
namespace PServerCMS\View\Helper; | ||
|
||
use Zend\View\Model\ViewModel; | ||
|
||
class LoggedInWidget extends InvokerBase | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function __invoke() | ||
{ | ||
$template = ''; | ||
|
||
if ($this->getAuthService()->hasIdentity()) { | ||
$viewModel = new ViewModel([ | ||
'user' => $this->getAuthService()->getIdentity() | ||
]); | ||
$viewModel->setTemplate('helper/sidebarLoggedInWidget'); | ||
$template = $this->getView()->render($viewModel); | ||
} | ||
|
||
return $template; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?php | ||
|
||
|
||
namespace PServerCMS\View\Helper; | ||
|
||
use Zend\View\Model\ViewModel; | ||
|
||
class ServerInfoWidget extends InvokerBase | ||
{ | ||
/** | ||
* @return string | ||
*/ | ||
public function __invoke() | ||
{ | ||
$viewModel = new ViewModel(array( | ||
'serverInfo' => $this->getServerInfoService()->getServerInfo() | ||
)); | ||
$viewModel->setTemplate('helper/sidebarServerInfoWidget'); | ||
|
||
return $this->getView()->render($viewModel); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
<?php | ||
|
||
|
||
namespace PServerCMS\View\Helper; | ||
|
||
use PServerCMS\Helper\Timer; | ||
use Zend\View\Model\ViewModel; | ||
|
||
class TimerWidget extends InvokerBase | ||
{ | ||
/** @var array */ | ||
protected $timerService; | ||
|
||
/** | ||
* @return string | ||
*/ | ||
public function __invoke() | ||
{ | ||
$viewModel = new ViewModel(array( | ||
'timer' => $this->getTimer(), | ||
)); | ||
$viewModel->setTemplate('helper/sidebarTimerWidget'); | ||
|
||
return $this->getView()->render($viewModel); | ||
} | ||
|
||
/** | ||
* @return array | ||
*/ | ||
protected function getTimer() | ||
{ | ||
if(!$this->timerService){ | ||
$config = $this->getConfig(); | ||
$timerConfig = isset($config['pserver']['timer'])?$config['pserver']['timer']:array(); | ||
|
||
if ($timerConfig) { | ||
foreach($timerConfig as $data){ | ||
$time = 0; | ||
$text = ''; | ||
if(!isset($data['type'])){ | ||
if(isset($data['days'])){ | ||
$time = Timer::getNextTimeDay( $data['days'], $data['hour'], $data['min'] ); | ||
}else{ | ||
$time = Timer::getNextTime( $data['hours'],$data['min'] ); | ||
} | ||
}else{ | ||
$text = $data['time']; | ||
} | ||
$this->timerService[] = array( | ||
'time' => $time, | ||
'text' => $text, | ||
'name' => $data['name'], | ||
'icon' => $data['icon'] | ||
); | ||
} | ||
} | ||
} | ||
|
||
return $this->timerService; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div> | ||
<h3><?= $this->translate('Server Info') ?></h3> | ||
<hr/> | ||
<ul class="list-unstyled"> | ||
<li><b><?= $this->translate('PlayerOnline') ?></b> <?= $this->playerHistory() ?></li> | ||
<?php if((bool)$this->serverInfo): ?> | ||
<?php foreach($this->serverInfo as $curInfo): ?> | ||
<?php /** @var \PServerCMS\Entity\ServerInfo $curInfo */ ?> | ||
<li> | ||
<i class="<?= $this->escapeHtml($curInfo->getIcon()) ?>"></i> | ||
<b><?= $this->escapeHtml($curInfo->getLabel()) ?></b> | ||
<?= $this->escapeHtml($curInfo->getMemo()) ?> | ||
</li> | ||
<?php endforeach ?> | ||
<?php endif ?> | ||
</ul> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,37 +1,3 @@ | ||
<div> | ||
<h3><?= $this->translate('Server Info') ?></h3> | ||
<hr/> | ||
<ul class="list-unstyled"> | ||
<li><b><?= $this->translate('PlayerOnline') ?></b> <?= $this->playerHistory() ?></li> | ||
<?php if((bool)$this->serverInfo): ?> | ||
<?php foreach($this->serverInfo as $curInfo): ?> | ||
<?php /** @var \PServerCMS\Entity\ServerInfo $curInfo */ ?> | ||
<li> | ||
<i class="<?= $this->escapeHtml($curInfo->getIcon()) ?>"></i> | ||
<b><?= $this->escapeHtml($curInfo->getLabel()) ?></b> | ||
<?= $this->escapeHtml($curInfo->getMemo()) ?> | ||
</li> | ||
<?php endforeach ?> | ||
<?php endif ?> | ||
</ul> | ||
</div> | ||
<div class="margin-top-30"> | ||
<h3><?= $this->translate('Servertime') ?></h3> | ||
<hr/> | ||
<ul class="list-unstyled"> | ||
<li><i class="fa fa-clock-o"></i> <?= $this->translate('Timer') ?>: <span id="idTimerClock"><?php echo date('H:i:s') ?></span></li> | ||
<?php $i=0; ?> | ||
<?php if ((bool)$this->timer ): ?> | ||
<?php foreach ($this->timer as $curTimer) : ?> | ||
<li><i class="<?= $this->escapeHtml($curTimer['icon']) ?>"></i> | ||
<?= $curTimer['name'] ?>: | ||
<?php if ($curTimer['time'] > 0) { ?> | ||
<span class="timerCountdown" id="<?php echo 'idTimeCountdown_'.$i++; ?>" data-time="<?= $curTimer['time'] ?>"></span> | ||
<?php } else { ?> | ||
<?= $this->escapeHtml($curTimer['text']) ?> | ||
<?php } ?> | ||
</li> | ||
<?php endforeach ?> | ||
<?php endif ?> | ||
</ul> | ||
</div> | ||
<?= $this->loggedInWidgetPServerCMS() ?> | ||
<?= $this->serverInfoWidgetPServerCMS() ?> | ||
<?= $this->timerWidgetPServerCMS() ?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
<div class="margin-top-30"> | ||
<h3><?= $this->translate('Servertime') ?></h3> | ||
<hr/> | ||
<ul class="list-unstyled"> | ||
<li><i class="fa fa-clock-o"></i> <?= $this->translate('Timer') ?>: <span id="idTimerClock"><?php echo date('H:i:s') ?></span></li> | ||
<?php $i=0; ?> | ||
<?php if ((bool)$this->timer ): ?> | ||
<?php foreach ($this->timer as $curTimer) : ?> | ||
<li><i class="<?= $this->escapeHtml($curTimer['icon']) ?>"></i> | ||
<?= $curTimer['name'] ?>: | ||
<?php if ($curTimer['time'] > 0) { ?> | ||
<span class="timerCountdown" id="<?php echo 'idTimeCountdown_'.$i++; ?>" data-time="<?= $curTimer['time'] ?>"></span> | ||
<?php } else { ?> | ||
<?= $this->escapeHtml($curTimer['text']) ?> | ||
<?php } ?> | ||
</li> | ||
<?php endforeach ?> | ||
<?php endif ?> | ||
</ul> | ||
</div> |