| 4 |
|
|
| 5 |
uses |
uses |
| 6 |
Messages, SysUtils, Classes, Contnrs, ComCtrls, {HttpApp,} YofUtils, |
Messages, SysUtils, Classes, Contnrs, ComCtrls, {HttpApp,} YofUtils, |
| 7 |
GikoSystem{, XMLIntf, XMLDoc}, GikoXMLDoc; |
GikoSystem{, XMLIntf, XMLDoc}, GikoXMLDoc, BoardGroup; |
| 8 |
{SAX, SAXHelpers, SAXComps, SAXKW;} |
{SAX, SAXHelpers, SAXComps, SAXKW;} |
| 9 |
|
|
| 10 |
type |
type |
| 13 |
|
|
| 14 |
TFavoriteBoardItem = class |
TFavoriteBoardItem = class |
| 15 |
private |
private |
| 16 |
FBBSID: string; |
FItem : TBoard; |
| 17 |
FBoardName: string; |
FTitle : string; |
| 18 |
public |
public |
| 19 |
property BBSID: string read FBBSID write FBBSID; |
property Item : TBoard read FItem write FItem; |
| 20 |
property BoardName: string read FBoardName write FBoardName; |
property Title : string read FTitle write FTitle; |
| 21 |
end; |
end; |
| 22 |
|
|
| 23 |
TFavoriteThreadItem = class |
TFavoriteThreadItem = class |
| 24 |
private |
private |
| 25 |
FBBSID: string; |
FItem : TThreadItem; |
| 26 |
FThreadID: string; |
FTitle : string; |
|
FThreadName: string; |
|
| 27 |
public |
public |
| 28 |
property BBSID: string read FBBSID write FBBSID; |
property Item : TThreadItem read FItem write FItem; |
| 29 |
property ThreadID: string read FThreadID write FThreadID; |
property Title : string read FTitle write FTitle; |
|
property ThreadName: string read FThreadName write FThreadName; |
|
| 30 |
end; |
end; |
| 31 |
|
|
| 32 |
TFavoriteDM = class(TDataModule) |
TFavoriteDM = class(TDataModule) |
| 62 |
|
|
| 63 |
implementation |
implementation |
| 64 |
|
|
| 65 |
|
uses ExternalBoardManager, ExternalBoardPlugInMain; |
| 66 |
|
|
| 67 |
const |
const |
| 68 |
FAVORITE_ROOT_NAME = 'お気に入り'; |
FAVORITE_ROOT_NAME = 'お気に入り'; |
| 69 |
FAVORITE_FILE_NAME = 'Favorite.xml'; |
FAVORITE_FILE_NAME = 'Favorite.xml'; |
| 164 |
procedure TFavoriteDM.ReadNode(Node: IXMLNode); |
procedure TFavoriteDM.ReadNode(Node: IXMLNode); |
| 165 |
var |
var |
| 166 |
i: Integer; |
i: Integer; |
| 167 |
|
j, jBound : Integer; |
| 168 |
|
|
| 169 |
ParentNode: TTreeNode; |
ParentNode: TTreeNode; |
| 170 |
CurrentNode: TTreeNode; |
CurrentNode: TTreeNode; |
| 171 |
FavFolder: TFavoriteFolder; |
FavFolder: TFavoriteFolder; |
| 172 |
FavBoard: TFavoriteBoardItem; |
FavBoard: TFavoriteBoardItem; |
| 173 |
FavThread: TFavoriteThreadItem; |
FavThread: TFavoriteThreadItem; |
| 174 |
|
board : TBoard; |
| 175 |
|
url : string; |
| 176 |
begin |
begin |
| 177 |
if Node.NodeName = 'folder' then begin |
if Node.NodeName = 'folder' then begin |
| 178 |
ParentNode := FStack.Peek; |
ParentNode := FStack.Peek; |
| 181 |
CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavFolder); |
CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavFolder); |
| 182 |
CurrentNode.ImageIndex := 14; |
CurrentNode.ImageIndex := 14; |
| 183 |
CurrentNode.SelectedIndex := 14; |
CurrentNode.SelectedIndex := 14; |
| 184 |
|
CurrentNode.Expanded := Node.Attributes[ 'expanded' ] = 'true'; |
| 185 |
FStack.Push(CurrentNode); |
FStack.Push(CurrentNode); |
| 186 |
end; |
end; |
| 187 |
for i := 0 to Node.ChildNodes.Count - 1 do begin |
for i := 0 to Node.ChildNodes.Count - 1 do begin |
| 193 |
ParentNode := FStack.Peek; |
ParentNode := FStack.Peek; |
| 194 |
if TObject(ParentNode.Data) is TFavoriteFolder then begin |
if TObject(ParentNode.Data) is TFavoriteFolder then begin |
| 195 |
if Node.Attributes['favtype'] = 'board' then begin |
if Node.Attributes['favtype'] = 'board' then begin |
| 196 |
FavBoard := TFavoriteBoardItem.Create; |
FavBoard := TFavoriteBoardItem.Create; |
| 197 |
FavBoard.BBSID := Node.Attributes['bbs']; |
FavBoard.Item := BBSsFindBoardFromURL( Node.Attributes[ 'url' ] ); |
| 198 |
FavBoard.BoardName := Node.Attributes['boardname']; |
// 旧式のお気に入りとの互換性のため |
| 199 |
|
if FavBoard.Item = nil then begin |
| 200 |
|
if Node.Attributes[ 'url' ] = '' then begin |
| 201 |
|
FavBoard.Item := BBSsFindBoardFromBBSID( Node.Attributes[ 'bbs' ] ); |
| 202 |
|
if FavBoard.Item = nil then begin |
| 203 |
|
FavBoard.Free; |
| 204 |
|
Exit; |
| 205 |
|
end; |
| 206 |
|
end else begin |
| 207 |
|
// ※作っても、追加するカテゴリが無いので激しく保留 |
| 208 |
|
//FavBoard.Item := TBoard.Create( nil, Node.Attributes[ 'url' ] ); |
| 209 |
|
end; |
| 210 |
|
end; |
| 211 |
|
FavBoard.Title := Node.Attributes['title']; |
| 212 |
CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavBoard); |
CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavBoard); |
| 213 |
CurrentNode.ImageIndex := 15; |
CurrentNode.ImageIndex := 15; |
| 214 |
CurrentNode.SelectedIndex := 15; |
CurrentNode.SelectedIndex := 15; |
| 215 |
end else if Node.Attributes['favtype'] = 'thread' then begin |
end else if Node.Attributes['favtype'] = 'thread' then begin |
| 216 |
FavThread := TFavoriteThreadItem.Create; |
url := Node.Attributes[ 'url' ]; |
| 217 |
FavThread.BBSID := Node.Attributes['bbs']; |
FavThread := TFavoriteThreadItem.Create; |
| 218 |
FavThread.ThreadID := Node.Attributes['thread']; |
FavThread.Item := BBSsFindThreadFromURL( url ); |
| 219 |
FavThread.ThreadName := Node.Attributes['threadname']; |
// 旧式のお気に入りとの互換性のため |
| 220 |
|
if FavThread.Item = nil then begin |
| 221 |
|
if Node.Attributes[ 'url' ] = '' then begin |
| 222 |
|
board := BBSsFindBoardFromBBSID( Node.Attributes[ 'bbs' ] ); |
| 223 |
|
if board = nil then begin |
| 224 |
|
FavThread.Free; |
| 225 |
|
Exit; |
| 226 |
|
end; |
| 227 |
|
if not board.IsThreadDatRead then |
| 228 |
|
GikoSys.ReadSubjectFile( board ); |
| 229 |
|
FavThread.Item := board.Find( Node.Attributes[ 'thread' ] ); |
| 230 |
|
if FavThread.Item = nil then begin |
| 231 |
|
FavThread.Item := TThreadItem.Create( |
| 232 |
|
board.BoardPlugIn, |
| 233 |
|
GikoSys.Get2chBoard2ThreadURL( board, ChangeFileExt( Node.Attributes[ 'thread' ], '' ) ) ); |
| 234 |
|
board.Add( FavThread.Item ) |
| 235 |
|
end; |
| 236 |
|
end else begin |
| 237 |
|
board := BBSsFindBoardFromURL( GikoSys.Get2chThreadURL2BoardURL( url ) ); |
| 238 |
|
if board <> nil then begin |
| 239 |
|
//===== プラグイン |
| 240 |
|
try |
| 241 |
|
jBound := Length( BoardPlugIns ) - 1; |
| 242 |
|
for j := 0 to jBound do begin |
| 243 |
|
if Assigned( Pointer( BoardPlugIns[ j ].Module ) ) then begin |
| 244 |
|
if BoardPlugIns[ j ].AcceptURL( url ) = atThread then begin |
| 245 |
|
FavThread.Item := TThreadItem.Create( BoardPlugIns[ j ], url ); |
| 246 |
|
|
| 247 |
|
Break; |
| 248 |
|
end; |
| 249 |
|
end; |
| 250 |
|
end; |
| 251 |
|
except |
| 252 |
|
// exception が発生した場合は内部処理に任せたいのでここでは何もしない |
| 253 |
|
end; |
| 254 |
|
|
| 255 |
|
//===== 内部 |
| 256 |
|
if FavThread.Item = nil then |
| 257 |
|
FavThread.Item := TThreadItem.Create( nil, url ); |
| 258 |
|
|
| 259 |
|
board.Add( FavThread.Item ); |
| 260 |
|
end; |
| 261 |
|
end; |
| 262 |
|
end; |
| 263 |
|
FavThread.Title := Node.Attributes['title']; |
| 264 |
CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavThread); |
CurrentNode := FTreeView.Items.AddChildObject(ParentNode, Node.Attributes['title'], FavThread); |
| 265 |
CurrentNode.ImageIndex := 16; |
CurrentNode.ImageIndex := 16; |
| 266 |
CurrentNode.SelectedIndex := 16; |
CurrentNode.SelectedIndex := 16; |
| 351 |
begin |
begin |
| 352 |
for i := 0 to Node.Count - 1 do begin |
for i := 0 to Node.Count - 1 do begin |
| 353 |
if TObject(Node.Item[i].Data) is TFavoriteFolder then begin |
if TObject(Node.Item[i].Data) is TFavoriteFolder then begin |
| 354 |
s := Format('<folder title="%s">', [HtmlEncode(Node.Item[i].Text)]); |
if Node.Item[ i ].Expanded then |
| 355 |
|
s := Format('<folder title="%s" expanded="true">', [HtmlEncode(Node.Item[i].Text)]) |
| 356 |
|
else |
| 357 |
|
s := Format('<folder title="%s" expanded="false">', [HtmlEncode(Node.Item[i].Text)]); |
| 358 |
SaveList.Add(s); |
SaveList.Add(s); |
| 359 |
AddSaveString(Node.Item[i], SaveList); |
AddSaveString(Node.Item[i], SaveList); |
| 360 |
SaveList.Add('</folder>'); |
SaveList.Add('</folder>'); |
| 361 |
end else if TObject(Node.Item[i].Data) is TFavoriteBoardItem then begin |
end else if TObject(Node.Item[i].Data) is TFavoriteBoardItem then begin |
| 362 |
FavBoard := TFavoriteBoardItem(Node.Item[i].Data); |
FavBoard := TFavoriteBoardItem(Node.Item[i].Data); |
| 363 |
s := Format('<favitem type="2ch" favtype="board" bbs="%s" title="%s" boardname="%s"/>', |
s := Format('<favitem type="2ch" favtype="board" url="%s" title="%s"/>', |
| 364 |
[FavBoard.BBSID, HtmlEncode(Node.Item[i].Text), HtmlEncode(FavBoard.BoardName)]); |
[HtmlEncode( FavBoard.Item.URL ), HtmlEncode(FavBoard.Title)]); |
| 365 |
SaveList.Add(s); |
SaveList.Add(s); |
| 366 |
end else if TObject(Node.Item[i].Data) is TFavoriteThreadItem then begin |
end else if TObject(Node.Item[i].Data) is TFavoriteThreadItem then begin |
| 367 |
FavThread := TFavoriteThreadItem(Node.Item[i].Data); |
FavThread := TFavoriteThreadItem(Node.Item[i].Data); |
| 368 |
s := Format('<favitem type="2ch" favtype="thread" bbs="%s" thread="%s" title="%s" threadname="%s"/>', |
s := Format('<favitem type="2ch" favtype="thread" url="%s" title="%s"/>', |
| 369 |
[FavThread.BBSID, FavThread.ThreadID, HtmlEncode(Node.Item[i].Text), HtmlEncode(FavThread.ThreadName)]); |
[HtmlEncode( FavThread.Item.URL ), HtmlEncode(FavThread.Title)]); |
| 370 |
SaveList.Add(s); |
SaveList.Add(s); |
| 371 |
end; |
end; |
| 372 |
end; |
end; |