[备忘]一个树形类(修正了子节点ID小于父节点ID时的BUG)(1 位领导批示)

这个树形类还是相当好用..
不过今天在使用时数据中出现了子节点id(71)小于父节点id(104).导致部分子节点没被存储入数组
修改了一下..应该没有问题了..

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
<?php
class Tree
{
    var $data = array();
    var $child = array(-1=>array());
    var $layer = array(-1=>-1);
    var $parent = array();
    var $num = array();
 
    function setNode($id, $parent, $value,$num=0)
    {
        $parent = $parent ? $parent : 0;
 
        $this->data[$id]		= $value;
        $this->num[$id]      = $num;
        if (!isset($this->child[$id])) $this->child[$id] = array();
        $this->child[$parent][] = $id;
        $this->parent[$id]		= $parent;
 
        if (!isset($this->layer[$parent]) && $parent == 0)
        {
           $this->layer[$id] = 0;
        }
        else
        {
            $this->layer[$id] = $this->layer[$parent] + 1;
        }
    }
 
 
    function getList(&$tree, $root= 0)
    {
        foreach ($this->child[$root] as $key=>$id)
        {
            $tree[] = $id;
            if($this->child[$id]) $this->getList($tree, $id);
        }
    }
 
    function getValue($id)
    {
		if($this->layer[$id]==0)
		{
			return $this->data[$id];
		}
		else
		{
			return $leftmar.$this->data[$id];
		}
    }
 
    function getNum($id)
    {
		return $this->num[$id];
    }
 
    function getbitValue($id)
    {
		return $this->data[$id];
    }
 
    function getLayer($id, $space = false)
    {
        return $space ? str_repeat($space, $this->layer[$id]) : $this->layer[$id];
    }
 
    function getParent($id)
    {
        return $this->parent[$id];
    }
 
    function getParents($id)
    {
        while ($this->parent[$id] != -1)
        {
            $id = $parent[$this->layer[$id]] = $this->parent[$id];
        }
 
        ksort($parent);
        reset($parent);
 
        return $parent;
    }
 
    function getChild($id)
    {
        return $this->child[$id];
    }
 
    function getChilds($id = 0)
    {
        $child = array($id);
        $this->getList($child, $id);
 
        return $child;
    }
 
    function printData()
    {
        return $this->layer;
    }
}
?>
Tags : , ,

qqdang的首页缩略图在IE6中的BUG解决,爽!(0 位领导批示)

qqdang首页缩略图在IE6下一直显示不正常,今天做到现在终于搞定了,庆祝一下.思考一下,总结如下:

一.DEDECMS的缩略图功能很烂,如时你不填写imgwidth与imgheight,它默认就是120px.并在页面中显示宽度与高度.

二.在对CSS中,我以前用到了width:530px;height:auto;显然IE6对在页面中与CSS中的定义优先权上有矛盾,所以在IE六下图片才会变形严重.

三.我的解决方法就是去除了CMS程序中输出image时显示width与height,让图片显示自适应.不过可能带来的后果是以后的图片就不能直接设置高与宽度了

总结一下,这次首页的bug修改,实际不过用了两个小时,如果不是卡卡热心帮助,我可能会忽视这个问题,碰到问题回避的坏毛病,一定要克服=。=

最后拍照留念^_^

qqdang.jpg

可恶的IE6双倍浮动BUG及解决办法(7 位领导批示)

制作页面时常会碰到IE6双倍浮动BUG,以前我的解决方法就是多写一行CSS HACK

如:

margin-left:12px;
-margin-left:6px;

这种方法虽然有效,但在讲究完美的coder来说使用CSS HACK是不能接受的

真正的解决方法:

加上display:inline

是的,没有看错,就是这么简单,被IE双倍浮动BUG困扰的朋友试一下吧

困难终于实践

随机显示的10篇日志

评论最多的10篇日志

浏览最多的10篇日志