예제 #1
0
파일: mode.php 프로젝트: h3len/Project
    function detail()
    {
        $sql = 'SELECT *
				FROM ' . DB_PREFIX . 'cell_mode WHERE id = ' . intval($this->input['id']);
        $r = $this->db->query_first($sql);
        $argument = unserialize($r['argument']);
        if (is_array($argument['type'])) {
            foreach ($argument['type'] as $k => $v) {
                if ($v == 'select') {
                    $argument['other_value'][$k] = hg_string_to_array($argument['other_value'][$k]);
                    if (is_array($argument['other_value'][$k])) {
                        foreach ($argument['other_value'][$k] as $ke => $va) {
                            if (isset($ke) && isset($va)) {
                                $other_value[$ke] = $va;
                            }
                        }
                    }
                    $argument['other_value'][$k] = $other_value;
                }
                unset($other_value);
            }
        }
        if ($argument['sign']) {
            $sign_str = implode(',', $argument['sign']);
            $argument['sign_name'] = $this->obj->get_code_para_name('html', $sign_str);
            $argument['sign_info'] = $this->obj->get_para_name('html', $sign_str);
        }
        $r['argument'] = $argument;
        $css = $js = array();
        $sqll = "SELECT * FROM " . DB_PREFIX . "cell_mode_code WHERE mode_id = " . intval($this->input['id']) . " AND del =0";
        $sll = $this->db->query($sqll);
        $css_sign = array();
        while ($rowl = $this->db->fetch_array($sll)) {
            if ($rowl['type'] == 'js') {
                $js_argument = unserialize($rowl['para']);
                $jskey = array('js_name', 'js_sign', 'js_flag', 'js_default_value', 'js_other_value', 'js_type');
                $js_arg = hg_format_array($js_argument, $jskey);
                if (is_array($js_arg['js_type'])) {
                    foreach ($js_arg['js_type'] as $k => $v) {
                        if ($v == 'select') {
                            $js_arg['js_other_value'][$k] = hg_string_to_array($js_arg['js_other_value'][$k]);
                            if (is_array($js_arg['js_other_value'][$k])) {
                                foreach ($js_arg['js_other_value'][$k] as $ke => $va) {
                                    if (isset($ke) && isset($va)) {
                                        $jsother_value[$ke] = $va;
                                    }
                                }
                            }
                            $js_arg['js_other_value'][$k] = $jsother_value;
                        }
                        unset($jsother_value);
                    }
                }
                if ($js_arg['js_sign']) {
                    $js_sign_str = implode(',', $js_arg['js_sign']);
                    $js_arg['js_sign_name'] = $this->obj->get_code_para_name('js', $js_sign_str);
                    $js_arg['js_sign_info'] = $this->obj->get_para_name('js', $js_sign_str);
                }
                $js['js_argument'] = $js_arg;
                $js['code'] = $rowl['code'];
                $js['js_title'] = $rowl['title'];
            }
            if ($rowl['type'] == 'css') {
                $css_argument = unserialize($rowl['para']);
                $csskey = array('css_name', 'css_sign', 'css_flag', 'css_default_value', 'css_other_value', 'css_type');
                $css_ar = hg_format_array($css_argument, $csskey);
                if (is_array($css_ar['css_type'])) {
                    foreach ($css_ar['css_type'] as $k => $v) {
                        if ($v == 'select') {
                            $css_ar['css_other_value'][$k] = hg_string_to_array($css_ar['css_other_value'][$k]);
                            if (is_array($css_ar['css_other_value'][$k])) {
                                foreach ($css_ar['css_other_value'][$k] as $ke => $va) {
                                    if (isset($ke) && isset($va)) {
                                        $cssother_value[$ke] = $va;
                                    }
                                }
                            }
                            $css_ar['css_other_value'][$k] = $cssother_value;
                        }
                        unset($cssother_value);
                    }
                }
                if ($css_ar['css_sign']) {
                    $css_sign_str = implode(',', $css_ar['css_sign']);
                    $css_ar['css_sign_name'] = $this->obj->get_code_para_name('css', $css_sign_str);
                    $css_sign = array_merge($css_sign, $css_ar['css_sign']);
                    //$css_ar['css_sign_info'] = $this->obj->get_para_name('css',$css_sign_str);
                }
                $css[$rowl['id']]['css_argument'] = $css_ar;
                $css[$rowl['id']]['code'] = $rowl['code'];
                $css[$rowl['id']]['css_title'] = $rowl['title'];
                $css[$rowl['id']]['css_indexpic'] = $rowl['indexpic'];
                $css[$rowl['id']]['default_css'] = $rowl['default_css'];
            }
        }
        $sql_ = "SELECT * FROM " . DB_PREFIX . "out_variable  WHERE mod_id =2 AND depath =3  AND expand_id =  " . $this->input['id'];
        $q = $this->db->query($sql_);
        while ($re = $this->db->fetch_array($q)) {
            $out_arment['name'][] = $re['name'];
            $out_arment['value'][] = $re['value'];
            $out_arment['flag'][] = $re['flag'];
        }
        $sqll = "SELECT id FROM " . DB_PREFIX . "out_variable  WHERE mod_id =2 AND depath =2  AND expand_id =  " . $this->input['id'];
        $fi = $this->db->query_first($sqll);
        $fid = $fi['id'];
        if (!$fid) {
            $datafid = $this->obj->create_out_para('data', '0', $this->input['id']);
            $fid = $this->obj->create_out_para('0', $datafid, $this->input['id']);
        }
        $r['fid'] = $fid;
        $pregfind = array('<<!--', '-->', '>', '<', '"', '!', ''', "\n", '$', '');
        $pregreplace = array('<!--', '-->', '>', '<', '"', '!', "'", "\n", '$', "\r");
        $r['content'] = str_replace($pregfind, $pregreplace, $r['content']);
        $r['content'] = htmlspecialchars($r['content']);
        $r['out_arment'] = $out_arment;
        $r['css'] = $css;
        $r['js'] = $js;
        $csign_str = implode(',', $css_sign);
        $r['css_sign'] = $this->obj->get_para_name('css', $csign_str);
        if ($r['default_param']) {
            $r['default_param'] = unserialize($r['default_param']);
        }
        /*if($r['indexpic'])
               {
               	$indexpic = unserialize($r['indexpic']);
               	$url = $indexpic['host'].$indexpic['dir'].$indexpic['filepath'].$indexpic['filename'];
               	$pic = file_get_contents($url);
        		if($pic)
        		{
        			$dir = CUR_CONF_PATH.'data/template/pic/';
        			hg_mkdir($dir);
        			file_put_contents($dir.$indexpic['filename'],$pic);
        		}
        		$index_pic  = array(
        				'host'			=>	$this->settings['template_image_url']."/",
        				'dir'			=>	'pic/',
        				'filepath'		=>	'',
        				'filename'		=>	$indexpic['filename'],
        		);
        		$r['indexpic'] = serialize($index_pic);
               }*/
        $ret[] = $r;
        $ret['mode_node'] = $this->obj->get_mode_node(' AND mod_id=2 AND expand_id=' . $this->input['id'] . ' AND fid=0 ORDER BY order_id ', '');
        $ret['mode_id'] = $this->input['id'];
        $this->addItem($ret);
        $this->output();
    }
예제 #2
0
파일: common.php 프로젝트: h3len/Project
 public function get_mode_info($id, $cell_id = '', $css_id = '', $js_id = '', $param = array())
 {
     $ret = array();
     $sql = "SELECT * FROM " . DB_PREFIX . "cell_mode WHERE id = " . $id;
     $mode_info = $this->db->query_first($sql);
     $mode_info['default_param'] = $mode_info['default_param'] ? unserialize($mode_info['default_param']) : array();
     $sql = "SELECT * FROM " . DB_PREFIX . "cell_mode_variable  WHERE cell_mode_id=" . $id;
     $info = $this->db->query($sql);
     $mode_param = $data_param = array();
     while ($row = $this->db->fetch_array($info)) {
         if ($row['type'] == 'select') {
             $row['other_value'] = hg_string_to_array($row['other_value']);
         }
         ###合并参数
         $row['name'] = $row['name'] ? $row['name'] : $row['sign'];
         $row['value'] = isset($param['mode_param'][$row['sign']]) ? $param['mode_param'][$row['sign']] : $row['default_value'];
         $mode_param[$row['id']] = $row;
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "cell_mode_code WHERE mode_id = " . $id . " AND type='js' AND del = 0 ";
     $mode_js_info = $this->db->query_first($sql);
     if ($mode_js_info) {
         $mode_js_info['para'] = unserialize($mode_js_info['para']);
         if (is_array($mode_js_info['para']) && count($mode_js_info['para']) > 0) {
             $relation = array();
             foreach ($mode_js_info['para'] as $k => $v) {
                 $v['js_other_value'] = hg_string_to_array($v['js_other_value']);
                 ###合并参数
                 $v['js_value'] = isset($param['js_param'][$v['js_sign']]) ? $param['js_param'][$v['js_sign']] : $v['js_default_value'];
                 ### 重新复制 使返回值名称统一
                 $variables[$v['js_sign']] = array('name' => $v['js_name'] ? $v['js_name'] : $v['js_sign'], 'sign' => $v['js_sign'], 'type' => $v['js_type'], 'other_value' => $v['js_other_value'], 'default_value' => $v['js_default_value'], 'value' => $v['js_value']);
                 $relation[$v['js_sign']] = $v['js_value'];
             }
             $ret['js_param'] = $variables;
         }
         $mode_js_info['code'] = html_entity_decode($mode_js_info['code'], ENT_QUOTES);
         if ($mode_js_info['code']) {
             if (!class_exists('Parse')) {
                 include_once CUR_CONF_PATH . 'lib/parse.class.php';
             }
             $parse = new Parse();
             $parse->parse_cssjs($mode_js_info['code'], $relation);
             $ret['js'] = $parse->built_cssjs($cell_id . '_' . $id . '_js' . '.php', true);
         }
     }
     $sql = "SELECT * FROM " . DB_PREFIX . "out_variable WHERE mod_id = 2  AND flag = 0 AND expand_id = " . $id;
     $q = $this->db->query($sql);
     while ($row = $this->db->fetch_array($q)) {
         $row['fuction_value'] = unserialize($row['fuction_value']);
         $row['fuction_value'] = $row['fuction_value'] ? $row['fuction_value'] : array();
         $row['fuction_value'] = implode("','", $row['fuction_value']);
         $row['fuction_value'] = "'" . $row['fuction_value'] . "'";
         $data_param[$row['id']] = $row;
     }
     ###css处理   js处理 命名空间替换、参数替换、格式化参数格式确保参数格式统一
     if ($css_id) {
         $sql = "SELECT * FROM " . DB_PREFIX . "cell_mode_code WHERE id = " . intval($css_id) . " AND del = 0 ";
         $q = $this->db->query($sql);
         while ($row = $this->db->fetch_array($q)) {
             $prefix = $row['type'];
             $relation = $variables = array();
             $row['para'] = unserialize($row['para']);
             if (is_array($row['para']) && count($row['para']) > 0) {
                 foreach ($row['para'] as $k => $v) {
                     $v[$prefix . '_other_value'] = hg_string_to_array($v[$prefix . '_other_value']);
                     ###合并参数
                     $v[$prefix . '_value'] = isset($param[$prefix . '_param'][$v[$prefix . '_sign']]) ? $param[$prefix . '_param'][$v[$prefix . '_sign']] : $v[$prefix . '_default_value'];
                     ### 重新复制 使返回值名称统一
                     $variables[$v[$prefix . '_sign']] = array('name' => $v[$prefix . '_name'] ? $v[$prefix . '_name'] : $v[$prefix . '_sign'], 'sign' => $v[$prefix . '_sign'], 'type' => $v[$prefix . '_type'], 'other_value' => $v[$prefix . '_other_value'], 'default_value' => $v[$prefix . '_default_value'], 'value' => $v[$prefix . '_value']);
                     $relation[$v[$prefix . '_sign']] = $v[$prefix . '_value'];
                 }
             }
             $ret[$prefix . '_code'] = html_entity_decode($row['code']);
             $ret[$prefix . '_param'] = $variables;
             if ($ret[$prefix . '_code']) {
                 if (!class_exists('Parse')) {
                     include_once CUR_CONF_PATH . 'lib/parse.class.php';
                 }
                 $parse = new Parse();
                 $parse->parse_cssjs($ret[$prefix . '_code'], $relation);
                 $ret[$prefix] = $parse->built_cssjs($cell_id . '_' . $id . '_' . $prefix . '.php', true);
             }
         }
     }
     ###css,js处理处理结束
     ##取样式的css列表
     $sql = "SELECT * FROM " . DB_PREFIX . "cell_mode_code WHERE mode_id = " . $id . " AND (cell_id = " . $cell_id . " OR cell_id = 0 ) AND type='css' AND del = 0 ";
     $q = $this->db->query($sql);
     $ret['css_list'] = array();
     while ($row = $this->db->fetch_array($q)) {
         $prefix = $row['type'];
         $row['para'] = unserialize($row['para']);
         if (is_array($row['para']) && count($row['para']) > 0) {
             $tmp = array();
             foreach ($row['para'] as $k => $v) {
                 $v[$prefix . '_other_value'] = hg_string_to_array($v[$prefix . '_other_value']);
                 $tmp[$v[$prefix . '_sign']] = array('name' => $v[$prefix . '_name'] ? $v[$prefix . '_name'] : $v[$prefix . '_sign'], 'sign' => $v[$prefix . '_sign'], 'type' => $v[$prefix . '_type'], 'other_value' => $v[$prefix . '_other_value'], 'default_value' => $v[$prefix . '_default_value'], 'value' => $v[$prefix . '_default_value']);
             }
             $row['para'] = $tmp;
         }
         //			$ret[$prefix . '_list'][$row['id']] = $row;
         $ret[$prefix . '_list'][] = $row;
     }
     $ret['mode_info'] = $mode_info;
     $ret['mode_param'] = $mode_param;
     $ret['data_param'] = $data_param;
     return $ret;
 }