(array []*DocumentTree, parentId int, selectedId int, selectedParentId int, buf *bytes.Buffer)
| 117 | } |
| 118 | |
| 119 | func getDocumentTree(array []*DocumentTree, parentId int, selectedId int, selectedParentId int, buf *bytes.Buffer) { |
| 120 | buf.WriteString("<ul>") |
| 121 | |
| 122 | for _, item := range array { |
| 123 | pid := 0 |
| 124 | |
| 125 | if p, ok := item.ParentId.(int); ok { |
| 126 | pid = p |
| 127 | } |
| 128 | if pid == parentId { |
| 129 | |
| 130 | selected := "" |
| 131 | if item.DocumentId == selectedId { |
| 132 | selected = ` class="jstree-clicked"` |
| 133 | } |
| 134 | selectedLi := "" |
| 135 | if item.DocumentId == selectedParentId { |
| 136 | selectedLi = ` class="jstree-open"` |
| 137 | } |
| 138 | buf.WriteString("<li id=\"") |
| 139 | buf.WriteString(strconv.Itoa(item.DocumentId)) |
| 140 | buf.WriteString("\"") |
| 141 | buf.WriteString(selectedLi) |
| 142 | buf.WriteString("><a href=\"") |
| 143 | if item.Identify != "" { |
| 144 | uri := beego.URLFor("DocumentController.Read", ":key", item.BookIdentify, ":id", item.Identify) |
| 145 | buf.WriteString(uri) |
| 146 | } else { |
| 147 | uri := beego.URLFor("DocumentController.Read", ":key", item.BookIdentify, ":id", item.DocumentId) |
| 148 | buf.WriteString(uri) |
| 149 | } |
| 150 | buf.WriteString("\" title=\"") |
| 151 | buf.WriteString(template.HTMLEscapeString(item.DocumentName) + "\"") |
| 152 | buf.WriteString(selected + ">") |
| 153 | buf.WriteString(template.HTMLEscapeString(item.DocumentName) + "</a>") |
| 154 | |
| 155 | for _, sub := range array { |
| 156 | if p, ok := sub.ParentId.(int); ok && p == item.DocumentId { |
| 157 | getDocumentTree(array, p, selectedId, selectedParentId, buf) |
| 158 | break |
| 159 | } |
| 160 | } |
| 161 | buf.WriteString("</li>") |
| 162 | } |
| 163 | } |
| 164 | buf.WriteString("</ul>") |
| 165 | } |
no outgoing calls
no test coverage detected