本文整理汇总了PHP中block::update_block方法的典型用法代码示例。如果您正苦于以下问题:PHP block::update_block方法的具体用法?PHP block::update_block怎么用?PHP block::update_block使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类block
的用法示例。
在下文中一共展示了block::update_block方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: cellUpdate
/**
* 编辑单元
*
* @param array $data 单元信息
* @return array 编辑过后的单元的详细信息
*/
public function cellUpdate($data)
{
if (!$data) {
return false;
}
if (is_array($data) && count($data) > 0) {
if (!class_exists('cell')) {
include_once CUR_CONF_PATH . 'lib/cell.class.php';
}
$this->obj = new cell();
$return = array();
foreach ($data as $k => $v) {
$oriCellInfo = $this->obj->detail(" AND id = " . $v['id']);
$info = array();
$condition = " AND site_id = " . intval($v['site_id']) . " AND page_id = " . intval($v['page_id']) . " AND page_data_id = " . intval($v['page_data_id']) . " AND content_type = " . intval($v['content_type']) . " AND template_sign = '" . $v['template_sign'] . "' AND template_style = '" . $v['template_style'] . "' AND cell_name='" . $v['cell_name'] . "' AND original_id != 0 AND del=0";
$q = $this->obj->detail($condition);
$param = array();
if (is_array($v['input_param']) && count($v['input_param']) > 0) {
foreach ($v['input_param'] as $kk => $vv) {
$vv['value'] = str_replace("<", '<', $vv['value']);
if ($vv['sign'] == 'count') {
$dataCountNum = $vv['value'];
}
if ($vv['value'] !== $vv['default_value']) {
$param['input_param'][$vv['sign']] = $vv['value'];
}
}
}
if (is_array($v['mode_param']) && count($v['mode_param']) > 0) {
foreach ($v['mode_param'] as $kk => $vv) {
$vv['value'] = str_replace("<", '<', $vv['value']);
if ($vv['value'] !== $vv['default_value']) {
$param['mode_param'][$vv['sign']] = $vv['value'];
}
}
}
if (is_array($v['css_param']) && count($v['css_param']) > 0) {
foreach ($v['css_param'] as $kk => $vv) {
if ($vv['value'] !== $vv['default_value']) {
$param['css_param'][$vv['sign']] = $vv['value'];
}
}
}
if (is_array($v['js_param']) && count($v['js_param']) > 0) {
foreach ($v['js_param'] as $kk => $vv) {
if ($vv['value'] !== $vv['default_value']) {
$param['js_param'][$vv['sign']] = $vv['value'];
}
}
}
empty($this->arPageInfo) && ($this->arPageInfo = common::getPageBySign('special', 'id'));
$blSpecial = $v['page_id'] == $this->arPageInfo['id'] ? 1 : 0;
//取专题的页面,如果是专题单元时不自动选择css
$v['css_id'] == 0 && $v['cell_mode'] && !$blSpecial && ($v['css_id'] = common::get_mode_default_css($v['cell_mode']));
$v['css_id'] == -1 && ($v['css_id'] = 0);
$info = array('css_id' => $v['css_id'], 'cell_type' => $v['cell_type'], 'cell_mode' => $v['cell_mode'], 'param_asso' => addslashes(serialize($param)), 'is_header' => $v['is_header'], 'header_text' => $v['header_text'], 'is_more' => $v['is_more'], 'more_href' => $v['more_href']);
$info['cell_type'] != 3 && ($info['static_html'] = $v['static_html'] = '');
isset($v['data_source']) && ($info['data_source'] = $v['data_source']);
if ($info['cell_mode']) {
//区块样式处理
$modeDetail = $info['cell_mode'] ? common::modeDetail($info['cell_mode'], 'title') : array();
$info['using_block'] = $v['using_block'] = substr($modeDetail['title'], 0, 3) == 'qk_' ? 1 : 0;
if ($info['using_block']) {
$postFields = array('site_id' => intval($v['site_id']), 'page_id' => intval($v['page_id']), 'page_data_id' => intval($v['page_data_id']), 'content_type' => intval($v['content_type']), 'client_type' => $this->intClientType, 'datasource_id' => intval($info['data_source']), 'datasource_argument' => $param['input_param'], 'name' => $v['id'] . '_' . $v['cell_name'], 'expand_name' => $this->arPageColumnInfo['name'] ? $this->arPageColumnInfo['name'] : $this->arPageSiteInfo['site_name'], 'line_num' => $dataCountNum);
}
include_once ROOT_PATH . 'lib/class/block.class.php';
$objBlock = new block();
}
if ($oriCellInfo['using_block'] && !$info['using_block']) {
$objBlock->delete_block($oriCellInfo['block_id']);
$info['block_id'] = $v['block_id'] = 0;
}
if ($q || $this->blPreset && $this->blPreset != 'false' || $v['layout_id']) {
$info['update_time'] = TIMENOW;
if ($info['using_block']) {
$response = $v['block_id'] ? $objBlock->update_block($postFields, $v['block_id']) : $objBlock->insert_block($postFields);
!$v['block_id'] && ($info['block_id'] = $v['block_id'] = $response['id']);
}
if ($v['layout_id']) {
$condition = " id = " . $v['id'];
$this->db->update_data($info, 'layout_cell', $condition);
} else {
$this->obj->update($info, $v['id']);
}
} else {
$info['block_id'] = $response['id'];
$info['original_id'] = $v['id'];
//原单元id
$info['create_time'] = TIMENOW;
$info['update_time'] = TIMENOW;
$info['sign'] = uniqid();
$info['cell_name'] = $v['cell_name'];
$info['template_style'] = $v['template_style'];
$info['sort_id'] = intval($v['sort_id']);
//.........这里部分代码省略.........