168 lines
2.9 KiB
PHP
168 lines
2.9 KiB
PHP
<?php
|
|
|
|
namespace KupShop\AdminBundle\Admin;
|
|
|
|
abstract class WindowTab
|
|
{
|
|
use \DatabaseCommunication;
|
|
/**
|
|
* Title of tab.
|
|
*
|
|
* @var string*/
|
|
protected $title;
|
|
|
|
/** @var string */
|
|
protected $className;
|
|
|
|
/**
|
|
* Route to tab template.
|
|
*
|
|
* @var string */
|
|
protected $template;
|
|
|
|
/** @var \Window */
|
|
protected $window;
|
|
|
|
/**
|
|
* @var int
|
|
*/
|
|
protected $ID;
|
|
|
|
public static function getTypes()
|
|
{
|
|
return [];
|
|
}
|
|
|
|
public static function isAllowed()
|
|
{
|
|
return true;
|
|
}
|
|
|
|
public function isVisible()
|
|
{
|
|
if ($this->isOnlyForWpjAdmin() && !isSuperuser()) {
|
|
return false;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
public function isOnlyForWpjAdmin()
|
|
{
|
|
return false;
|
|
}
|
|
|
|
/**
|
|
* @return $this
|
|
*/
|
|
public function setWindow(\Window $window)
|
|
{
|
|
$this->window = $window;
|
|
|
|
return $this;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getTitle()
|
|
{
|
|
return $this->title;
|
|
}
|
|
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function getLabel()
|
|
{
|
|
return translate($this->title, lcfirst($this->getClassName()));
|
|
}
|
|
|
|
public function getTemplate(): string
|
|
{
|
|
return $this->template;
|
|
}
|
|
|
|
public function getClassName()
|
|
{
|
|
if ($this->className) {
|
|
return $this->className;
|
|
}
|
|
|
|
return $this->className = (new \ReflectionClass($this))->getShortName();
|
|
}
|
|
|
|
public function getVars($smarty_tpl_vars)
|
|
{
|
|
return $smarty_tpl_vars;
|
|
}
|
|
|
|
public function handleUpdate()
|
|
{
|
|
}
|
|
|
|
public function handle()
|
|
{
|
|
$acn = $this->getAction();
|
|
if ($acn) {
|
|
$action = 'handle'.ucfirst($acn);
|
|
if (method_exists($this, $action)) {
|
|
call_user_func([$this, $action]);
|
|
}
|
|
}
|
|
}
|
|
|
|
protected function getAction()
|
|
{
|
|
return getVal('acn');
|
|
}
|
|
|
|
protected function getWindow(): \Window
|
|
{
|
|
return $this->window;
|
|
}
|
|
|
|
protected function getData()
|
|
{
|
|
$data = getVal($this->getClassName(), null, []);
|
|
|
|
return $data;
|
|
}
|
|
|
|
/**
|
|
* @return int $ID
|
|
*/
|
|
public function getID()
|
|
{
|
|
return $this->ID;
|
|
}
|
|
|
|
/**
|
|
* @param int $ID
|
|
*/
|
|
public function setID($ID)
|
|
{
|
|
$this->ID = $ID;
|
|
}
|
|
|
|
public function addHTMLError($error)
|
|
{
|
|
$this->window->addHTMLError($error);
|
|
}
|
|
|
|
protected function isDuplicate()
|
|
{
|
|
return getVal('Duplicate');
|
|
}
|
|
|
|
protected function returnOK($ErrStr = null, $parentRefresh = false, $params = [])
|
|
{
|
|
$this->getWindow()->returnOK($ErrStr, $parentRefresh, $params);
|
|
}
|
|
|
|
protected function returnError($ErrStr, $parentRefresh = '', $ID = null)
|
|
{
|
|
$this->getWindow()->returnError($ErrStr, $parentRefresh, $ID);
|
|
}
|
|
}
|