* Optimize block control.

This commit is contained in:
Wangyuting
2023-05-05 09:38:59 +08:00
parent bc761dcd6d
commit e6849ef172
4 changed files with 13 additions and 14 deletions
+3
View File
@@ -7,3 +7,6 @@ ALTER TABLE `zt_todo` CHANGE `idvalue` `objectID` mediumint(8) unsigned default
UPDATE `zt_block` SET `dashboard` = `module`;
UPDATE `zt_block` SET `module` = IF(`source` != '', `source`, `code`);
DROP INDEX account_vision_module_type_order ON `zt_block`;
ALTER TABLE `zt_block` DROP COLUMN `source`;
ALTER TABLE `zt_block` DROP COLUMN `type`;
+7 -6
View File
@@ -259,13 +259,14 @@ class block extends control
* Print block.
* 输出区块
*
* @param int $id
* @param int $blockID
* @access public
* @return void|false
*/
public function printBlock($id)
public function printBlock($blockID)
{
$block = $this->block->getByID((int)$id);
$blockID = (int)$blockID;
$block = $this->block->getByID($blockID);
if(empty($block)) return false;
@@ -280,7 +281,7 @@ class block extends control
break;
case 'guide':
$html = $this->fetch('block', 'guide', "blockID=$block->id");
$html = $this->fetch('block', 'guide', "blockID=$blockID");
break;
case 'assigntome':
@@ -288,7 +289,7 @@ class block extends control
break;
case 'welcome':
$html = $this->fetch('block', 'welcome', "blockID=$block->id");
$html = $this->fetch('block', 'welcome', "blockID=$blockID");
break;
case 'contribute':
@@ -296,7 +297,7 @@ class block extends control
break;
default:
$html = $this->blockZen->generateDefaultBlockBySource($id, $block);
$html = $this->blockZen->generateDefaultBlockBySource($block);
break;
}
echo $html;
+1 -4
View File
@@ -28,10 +28,7 @@ dtable
set::width('100%'),
set::height('auto'),
set::cols(array_values($config->block->dtable->project->fieldList)),
set::data(array_values($projects)),
set::footPager(usePager()),
set::footer(array('flex', 'pager'))
set::data(array_values($projects))
);
render();
+2 -4
View File
@@ -265,20 +265,18 @@ class blockZen extends block
* 根据来源生成默认区块
* Generate default block by source.
*
* @param int $id
* @param object $block
* @return string
*/
protected function generateDefaultBlockBySource(int $id, object $block): string
protected function generateDefaultBlockBySource(object $block): string
{
$this->get->set('mode', 'getblockdata');
$this->get->set('blockTitle', $block->title);
$this->get->set('module', $block->module);
$this->get->set('source', $block->source);
$this->get->set('blockid', $block->code);
$this->get->set('param', base64_encode(json_encode($block->params)));
return $this->fetch('block', 'main', "module={$block->source}&id=$id");
return $this->fetch('block', 'main', "module={$block->module}&id={$block->id}");
}
/**