first commit
This commit is contained in:
107
admin/artauthors.php
Normal file
107
admin/artauthors.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
use KupShop\AdminBundle\AdminBlocksTrait;
|
||||
use KupShop\AdminBundle\Util\BlocksHistory;
|
||||
use KupShop\ContentBundle\Util\BlocksTrait;
|
||||
use KupShop\KupShopBundle\Util\Compat\ServiceContainer;
|
||||
|
||||
class Artauthors extends Window
|
||||
{
|
||||
use BlocksTrait;
|
||||
use AdminBlocksTrait;
|
||||
|
||||
protected $tableName = 'articles_authors';
|
||||
protected $show_on_web = 'articlesAuthor';
|
||||
|
||||
private BlocksHistory $blocksHistory;
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->defaults = ['date_reg' => date('d-m-Y H:i'),
|
||||
'active' => 'Y',
|
||||
'sex' => 'M',
|
||||
'top_branch' => '0',
|
||||
];
|
||||
$this->blocksHistory = ServiceContainer::getService(BlocksHistory::class);
|
||||
}
|
||||
|
||||
public function getData()
|
||||
{
|
||||
$data = parent::getData();
|
||||
|
||||
if (!empty($data['date_reg'])) {
|
||||
$data['date_reg'] = $this->prepareDate($data['date_reg']);
|
||||
}
|
||||
|
||||
if (!empty($data['date_borned'])) {
|
||||
$data['date_borned'] = $this->prepareDate($data['date_borned']);
|
||||
}
|
||||
|
||||
return $data;
|
||||
}
|
||||
|
||||
public function get_vars()
|
||||
{
|
||||
$vars = parent::get_vars();
|
||||
$pageVars = getVal('body', $vars);
|
||||
if (!empty($pageVars['data']['photo'])) {
|
||||
$pageVars['data']['photo'] = @getImage($this->getID(), $pageVars['data']['photo'], '../articles_authors/', 'articles_authors', dateUpdate: strtotime($pageVars['data']['date_update']));
|
||||
}
|
||||
|
||||
$vars['body'] = $pageVars;
|
||||
|
||||
if (isset($pageVars['data']['id_block'])) {
|
||||
$vars['body']['data']['blocks'] = $this->getBlocks($pageVars['data']['id_block']);
|
||||
$vars['body']['data']['blocks_history'] = $this->blocksHistory->getBlocksHistory($pageVars['data']['id_block']);
|
||||
}
|
||||
|
||||
return $vars;
|
||||
}
|
||||
|
||||
public function handleUpdate()
|
||||
{
|
||||
$SQL = parent::handleUpdate();
|
||||
|
||||
$ID = $this->getID();
|
||||
|
||||
if (!empty($_FILES['picture']['name'])) {
|
||||
$img = new Photos('articles_authors');
|
||||
$img->newImage($ID);
|
||||
$img->uploadImage($_FILES['picture'], strtolower(substr(strrchr($_FILES['picture']['name'], '.'), 0)));
|
||||
|
||||
if ($img->checkFileType()) {
|
||||
$img->insertImageIntoDB();
|
||||
} else {
|
||||
$this->returnError(getTextString('producers', 'errorBadPhoto'));
|
||||
}
|
||||
|
||||
unset($img);
|
||||
}
|
||||
|
||||
if ($this->getAction() == 'edit') {
|
||||
// historii je treba ulozit jeste pred ulozenim bloku
|
||||
$this->blocksHistory->saveBlocksHistory(getVal('blocks', $this->getData(), []));
|
||||
}
|
||||
|
||||
$this->saveBlocks($this->getData(), $ID, 'articles_authors');
|
||||
|
||||
return $SQL;
|
||||
}
|
||||
|
||||
public function handleErasephoto()
|
||||
{
|
||||
$ID = getVal('ID');
|
||||
// sqlQuery("DELETE FROM ".getTableName("photos")." WHERE id='$IDsec'");
|
||||
|
||||
// ########################################################################
|
||||
$img = new Photos('articles_authors');
|
||||
$img->newImage($ID);
|
||||
$img->deletePhoto();
|
||||
unset($img);
|
||||
// ########################################################################
|
||||
|
||||
$this->returnOK('Fotografie byla smazána');
|
||||
}
|
||||
}
|
||||
|
||||
return Artauthors::class;
|
||||
Reference in New Issue
Block a user