0 Members and 1 Guest are viewing this topic.
<head>{{comment |FIRST line HEAD}}{{comment |Last line HEAD}}</head><body>{{comment |First line BODY}}{{after the list| At begin of BODY}}{{comment | BEFORE LIST}}%files%{{comment | AFTER LIST}}{{comment |Last line BODY}}</body></html>[file=folder=link]item{{count}}[special:begin]{{comment|Normaly at BEGIN OF MACROS.LOG}}[files]{{comment| first line of files}}{{after the list| At begin of files}}%list%{{after the list| At end of files}}
--- > {{comment|Normaly at BEGIN OF MACROS.LOG}} < --- > {{count}} < 0--- > %files% < %files% > %list% < %list% > {{comment| first line of files}} < > {{after the list| At begin of files}} < At begin of files > {{after the list| At end of files}} < At end of files > {{comment |FIRST line HEAD}} < > {{comment |Last line HEAD}} < > {{comment |First line BODY}} < > {{after the list| At begin of BODY}} < At begin of BODY > {{comment | BEFORE LIST}} < > {{comment | AFTER LIST}} < > {{comment |Last line BODY}} <
--- > {{comment|Normaly at BEGIN OF MACROS.LOG}} < > {{comment |FIRST line HEAD}} < > {{comment |Last line HEAD}} < > {{comment |First line BODY}} < > {{after the list| At begin of BODY}} < At begin of BODY > {{comment | BEFORE LIST}} < --- > %files% < %files% > {{comment| first line of files}} < > %list% < %list%--- > {{count}} < 0 > {{after the list| At begin of files}} < At begin of files > {{after the list| At end of files}} < At end of files > {{comment | AFTER LIST}} < > {{comment |Last line BODY}} <
a good order will be > {{after the list| At begin of BODY}} < At begin of BODY... > {{count}} < 0
listing:=TfileListing.create(); try diffTpl:=Ttpl.create; try diffTpl.over:=otpl as Ttpl; if otpl <> filelistTpl then diffTpl.fullText:=optUTF8(diffTpl.over, folder.getRecursiveDiffTplAsStr()); isDMbrowser:= otpl = dmBrowserTpl; fullEncode:=not isDMbrowser; ofsRelUrl:=length(folder.url(fullEncode))+1; hasher:=Thasher.create; try hasher.loadFrom(folder.resource); md.cd:=conn.data; md.tpl:=diffTpl; md.folder:=folder; md.archiveAvailable:=folder.hasRecursive(FA_ARCHIVABLE) and not folder.hasRecursive(FA_DL_FORBIDDEN); table:=NIL; result:=diffTpl['special:begin']; tryApplyMacrosAndSymbols(result, @md, table); // cache these values fileTpl:=xtpl(diffTpl['file'], table); folderTpl:=xtpl(diffTpl['folder'], table); linkTpl:=xtpl(diffTpl['link'], table); hideExt:=folder.hasRecursive(FA_HIDE_EXT); // this may be heavy to calculate, only do it upon request img_file:=pos('~img_file', fileTpl) > 0; // build %list% based on dir[] numberFolders:=0; numberFiles:=0; numberLinks:=0; totalBytes:=0; oneAccessible:=FALSE; fast:=TfastStringAppend.Create(); try for i:=0 to length(listing.dir)-1 do begin application.ProcessMessages(); if conn.state = HCS_DISCONNECTED then break; data.lastActivityTime:=now(); handleItem(listing.dir); end; list:=fast.reset(); finally fast.free end; finally hasher.free end; if conn.state = HCS_DISCONNECTED then exit; // build final page if not oneAccessible then md.archiveAvailable:=FALSE; addArray(table, [ '%upload-link%', if_(uploadAllowed(conn, folder), diffTpl['upload-link']), '%files%', if_(list='', diffTpl['nofiles'], diffTpl['files']), '%list%',list, '%number%', intToStr(numberFiles+numberFolders+numberLinks), '%number-files%', intToStr(numberFiles), '%number-folders%', intToStr(numberFolders), '%number-links%', intToStr(numberlinks), '%total-bytes%', intToStr(totalBytes), '%total-kbytes%', intToStr(totalBytes div KILO), '%total-size%', smartsize(totalBytes) ]); result:=result+diffTpl['']; md.f:=NIL; md.afterTheList:=TRUE; try tryApplyMacrosAndSymbols(result, @md, table) finally md.afterTheList:=FALSE end;//include here something as result:=result+diffTpl['special:end'];tryApplyMacrosAndSymbols(result, @md, table);//then we can define by example {{set|mynumbersitems|{{add|'%number-files%|'%number-links%}}}}//and to end macrosmd.atTheEND:=TRUE;try tryApplyMacrosAndSymbols(result, @md, table)finally md.atTheEND:=FALSE end;// and any where in template {{at the end|{{^mynumbersitems}}}} applySequential(); // ensure this is the last symbol to be translated result:=xtpl(result, [ '\n', CRLF, '%build-time%', floatToStrF((now()-buildTime)*SECONDS, ffFixed, 7,3) ]); finally diffTpl.free end; finally listing.free end;finally folder.unlock() end;end; // getFolderPage
...... begin // most symbols here, are here because they can be heavy to calculate, so we ensure we do // it only upon request. others are for centralization. result:=name; // by default, an unrecognized symbol remains the same (just as the song)if name= '%list%' then beginlisting.fromFolder( folder, conn, recur ); if not recur or (otpl <> filelistTpl) then listing.sort(conn);md.afterTheList:=TRUE; end; if ansiStartsText('%sym-', name) then // legacy: surpassed by {{section}} result:=tpl[substr(name,2,-1)] else if name = '%item-icon%' then itemIcon()....