コード例 #1
0
ファイル: magic.php プロジェクト: h3len/Project
 public function cellPreview()
 {
     $intCellId = intval($this->input['intCellId']);
     $arData = $this->input['arData'];
     if (!$intCellId) {
         $this->errorOutput('NO CELLID');
     }
     if (!class_exists('cell')) {
         include CUR_CONF_PATH . 'lib/cell.class.php';
     }
     $objCell = new cell();
     $arCellInfo = $objCell->detail(' AND id = ' . $intCellId);
     if (!class_exists('Magic')) {
         include CUR_CONF_PATH . 'lib/magic.class.php';
     }
     $objMagic = new Magic();
     $arCellInfo = $objMagic->cellProcess($arCellInfo, 'false', $arData);
     $this->addItem($arCellInfo);
     $this->output();
 }
コード例 #2
0
ファイル: magic.class.php プロジェクト: h3len/Project
 /**
  * 处理单元、生成单元的html
  * 
  * @param array $info 单元详细信息
  * @param boolean $force 是否强制生成单元缓存
  * @param array $arData 数据、有此参数时用该数据生成单元hmtl 用于单元预览
  * @param array 处理过后的单元详细信息
  */
 public function cellProcess($info, $force = false, $arData = array())
 {
     if (!$info['cell_mode']) {
         //return array();
     }
     /**********专题栏目链接处理***************************/
     if (strpos($info['more_href'], 'COLURL') !== false) {
         $intColumnId = intval(str_replace('COLURL', '', $info['more_href']));
         if (!class_exists('special')) {
             include ROOT_PATH . 'lib/class/special.class.php';
         }
         $objSpecial = new special();
         $info['more_href'] = $objSpecial->get_special_col_url($intColumnId);
     }
     /**********专题栏目链接处理***************************/
     $mode_info = common::get_mode_info(intval($info['cell_mode']), $info['id'], intval($info['css_id']), intval($info['js_id']), $info['param_asso']);
     $blBuiltCell = $this->blBuiltCell && $this->blBuiltCell !== 'false' ? 1 : 0;
     if ($info['cell_type'] == 3 && $blBuiltCell) {
         $html = $info['static_html'];
     } else {
         $content = $mode_info['mode_info']['content'];
         $content = str_replace(' ', ' ', $content);
         $ret_data = array();
         if (!$info['data_source']) {
             $map = common::get_mode_map($mode_info);
             if ($blBuiltCell) {
                 $ret_data = !empty($arData) ? $arData : $mode_info['mode_info']['default_param'];
             }
             $ret_data = $info['using_block'] ? common::getBlockData($info['block_id']) : $ret_data;
         } else {
             $data_source = common::get_datasource_info($info['data_source'], $info['param_asso']);
             if ($info['using_block'] && $blBuiltCell) {
                 $ret_data = !empty($arData) ? $arData : common::getBlockData($info['block_id']);
             } else {
                 $map = common::get_cell_map($mode_info, $data_source, $info['param_asso']);
                 if ($blBuiltCell) {
                     $ret_data = common::get_content_by_datasource($info['data_source'], $map['data_input_variable']);
                     if (isset($ret_data['total'])) {
                         $intTotal = $ret_data['total'];
                         $ret_data = $ret_data['data'];
                     }
                     if (!$info['layout_id']) {
                         //替换已经编辑过的单元数据
                         if (!class_exists('cell')) {
                             include CUR_CONF_PATH . 'lib/cell.class.php';
                         }
                         $objCell = new cell();
                         $arCellData = $objCell->getCellData($info['id']);
                         if (is_array($ret_data) && count($ret_data) > 0) {
                             foreach ($ret_data as $k => $v) {
                                 !empty($arCellData[$v['id']]) && ($arCellData[$v['id']]['id'] = $arCellData[$v['id']]['content_id']);
                                 $ret_data[$k] = !empty($arCellData[$v['id']]) ? $arCellData[$v['id']] : $v;
                                 if (!empty($arData)) {
                                     if ($v['id'] == $arData['content_id']) {
                                         //arData 预览提交的数据
                                         $arData['id'] = $arData['content_id'];
                                         $ret_data[$k] = $arData;
                                     }
                                 }
                             }
                         }
                     }
                     if (isset($intTotal)) {
                         $ret_data = array('total' => $intTotal, 'data' => $ret_data);
                     }
                 }
             }
         }
         $cache_file = $info['layout_id'] ? $info['id'] . '_' . $info['layout_id'] . '.php' : $info['id'] . '.php';
         $cache_filepath = MODE_CACHE_DIR . substr(md5($cache_file), 0, 2) . '/';
         include_once CUR_CONF_PATH . 'lib/parse.class.php';
         $parse = new Parse();
         $parse->parse_template(stripcslashes($content), $info['id'], $mode_info['mode_info'], $map['relation_map'], $map['mode_variable_map'], $map['variable_function_relation']);
         if ($blBuiltCell) {
             if (MAGIC_DEBUG) {
                 $path = CUR_CONF_PATH . 'cache/log/data/';
                 hg_mkdir($path);
                 hg_file_write($path . $info['id'] . '.txt', var_export($map['data_input_variable'], 1) . var_export($ret_data, 1));
             }
             $html = $parse->built_cell_html($ret_data, $cache_file, $mode_info['mode_info'], $this->arNeedPageInfo, $this->arPageSiteInfo, $this->arPageColumnInfo, $this->arPageClientInfo, $this->arPageSpecialInfo, $this->arPageSpecialColumnInfo, $map['data_input_variable'], $force, $cache_filepath);
             if ($info['is_header']) {
                 $find = array('{$header_text}', '{$more_href}', '{$more_text}');
                 $replace = array($info['header_text'], $info['is_more'] ? $info['more_href'] : '#', $info['is_more'] ? '更多>>' : '');
                 $header = str_replace($find, $replace, $this->settings['header_dom']['cell']);
                 $html = $header . $html;
             }
             // if (empty($ret_data)) {
             // $html = '<span>暂无数据</span>' . $html;
             // }
         } else {
             $parse->built_mode_cache($cache_file, $cache_filepath);
         }
     }
     $ret = array();
     $ret = array_merge($info, $mode_info);
     $ret['mode_detail'] = $ret['mode_info'];
     //生成时用
     unset($ret['mode_info']);
     !$ret['using_block'] && $ret['data_source'] && ($ret['can_edit'] = 1);
     //有数据源且不是区块单元时单元数据可编辑
     $ret['rended_html'] = $html;
     $ret['input_param'] = $data_source['input_param'];
     $ret['site_id'] = $this->intSiteId;
     $ret['page_id'] = $this->intPageId;
     $ret['page_data_id'] = $this->intPageDataId;
     $ret['content_type'] = $this->intContentType;
     if ($blBuiltCell) {
         $strNsPre = $ret['layout_id'] ? 'layout_cell' : 'cell';
         $ret['css'] = str_replace('<MATEURL>', ICON_URL, preg_replace('/<NS([0-9a-zA-Z]*)>/', '.' . $strNsPre . '_' . $ret['id'] . '_\\1', $ret['css']));
         $ret['js'] = str_replace('<MATEURL>', ICON_URL, preg_replace('/<NS([0-9a-zA-Z]*)>/', '.' . $strNsPre . '_' . $ret['id'] . '_\\1', $ret['js']));
         $ret['rended_html'] = str_replace('<MATEURL>', ICON_URL, preg_replace('/<NS([0-9a-zA-Z]*)>/', $strNsPre . '_' . $ret['id'] . '_\\1', $ret['rended_html']));
         $ret['css'] = preg_replace('/<NNS([0-9a-zA-Z]*)>/', $strNsPre . '_' . $ret['id'] . '_\\1', $ret['css']);
         $ret['js'] = preg_replace('/<NNS([0-9a-zA-Z]*)>/', $strNsPre . '_' . $ret['id'] . '_\\1', $ret['js']);
         $ret['rended_html'] = preg_replace('/<NNS([0-9a-zA-Z]*)>/', $strNsPre . '_' . $ret['id'] . '_\\1', $ret['rended_html']);
         if ($this->input['data'] == 1 || $this->input['return_data'] == 1) {
             if (is_array($ret_data) && count($ret_data) > 0) {
                 foreach ($ret_data as $k => $v) {
                     $ret['data'][] = array('id' => $v['id'], 'title' => $v['title'], 'brief' => $v['brief'], 'indexpic' => $v['indexpic'], 'content_url' => $v['content_url']);
                 }
             }
         }
     }
     return $ret;
 }
コード例 #3
0
ファイル: publishsys.php プロジェクト: h3len/Project
 public function get_cell_data()
 {
     $cell_id = intval($this->input['cell_id']);
     if (!$cell_id) {
         $this->errorOutput('NO_CELL_ID');
     }
     include_once CUR_CONF_PATH . 'lib/cell.class.php';
     $cell = new cell();
     $data = $cell->getCellData($cell_id);
     $this->addItem($data);
     $this->output();
 }
コード例 #4
0
ファイル: magic_update.php プロジェクト: h3len/Project
 public function cellDataUpdate()
 {
     $intCellId = intval($this->input['intCellId']);
     $intContentId = $this->input['intContentId'];
     if (!$intCellId || !$intContentId) {
         $this->errorOutput('NO ID');
     }
     if (!empty($this->input['arIndexPic'])) {
         $this->input['arIndexPic'] = array('host' => $this->input['arIndexPic']['host'], 'dir' => $this->input['arIndexPic']['dir'], 'filepath' => $this->input['arIndexPic']['filepath'], 'filename' => $this->input['arIndexPic']['filename']);
     }
     $arData = array('title' => $this->input['strTitle'], 'brief' => $this->input['strBrief'], 'content_url' => $this->input['strContentUrl'], 'indexpic' => $this->input['arIndexPic'] ? serialize($this->input['arIndexPic']) : '');
     if (!class_exists('cell')) {
         include CUR_CONF_PATH . 'lib/cell.class.php';
     }
     $objCell = new cell();
     $arContent = $objCell->detail(' AND cell_id = ' . $intCellId . ' AND content_id = ' . $intContentId, 'cell_data');
     if (empty($arContent)) {
         $arData['cell_id'] = $intCellId;
         $arData['content_id'] = $intContentId;
         $this->db->insert_data($arData, 'cell_data');
     } else {
         $this->db->update_data($arData, 'cell_data', 'cell_id = ' . $intCellId . ' AND content_id = ' . $intContentId);
     }
     $arCellInfo = $objCell->detail(' AND id = ' . $intCellId);
     //删除单元内容缓存
     $objCell->delete_cell_data_cache($intCellId);
     //重新处理该单元信息
     if (!class_exists('Magic')) {
         include CUR_CONF_PATH . 'lib/magic.class.php';
     }
     $objMagic = new Magic();
     $arCellInfo = $objMagic->cellProcess($arCellInfo, true);
     $this->addItem($arCellInfo);
     $this->output();
 }