* Add block test.

This commit is contained in:
Wangyuting
2023-05-08 17:52:33 +08:00
parent 5d506c2878
commit 0372a1a7ac
42 changed files with 119 additions and 1030 deletions
-43
View File
@@ -370,49 +370,6 @@ class blockModel extends model
return true;
}
/**
* Save a block.
*
* @param int $blockID
* @param string $type
* @param string $module
* @access public
* @return int|false
*/
public function save(int $blockID, string $type, string $module = 'my'): bool|int
{
$block = $blockID ? $this->getByID($blockID) : null;
$data = fixer::input('post')
->setIF($blockID, 'id', $blockID)
->add('account', $this->app->user->account)
->add('module', $module)
->add('order', $block ? $block->order : ($this->getMaxOrderByModule($module) + 1))
->add('hidden', 0)
->setDefault('vision', $this->config->vision)
->setDefault('grid', '4')
->setDefault('params', array())
->stripTags('html', $this->config->allowedTags)
->remove('uid,actionLink,modules,moduleBlock')
->get();
$data->source = $this->post->moduleBlock ? $this->post->modules : '';
$data->block = $this->post->moduleBlock ? $this->post->moduleBlock : $this->post->modules;
if($block) $data->height = $block->height;
if($type == 'html')
{
$uid = $this->post->uid;
$data = $this->loadModel('file')->processImgURL($data, 'html', $uid);
$data->params['html'] = $data->html;
unset($data->html);
unset($_SESSION['album'][$uid]);
}
$data->params = helper::jsonEncode($data->params);
$this->dao->replace(TABLE_BLOCK)->data($data)->exec();
}
/**
* Init block when account use first.
* 用户首次加载时初始化区块数据.