The ASP.NET version offer a nice function, it automaticly show all classes in the "custom CSS" drop down list. So here is the equivalent for CLASSIC ASP
The code, will read the "style.css" file and show all classes in the "custom css" drop down list. You will need to download and register the FREE XCSSParser.dll from
http://xstandard.com
Enjoy!
' -- START CODE --
' check if myWebApp/clientFolder/STYLE.CSS exist... if not, CE will load default values
' need to register the FREE XCSSParser.dll (http://xstandard.com/en/documentation/xcss-parser/)
Set fs=Server.CreateObject("Scripting.FileSystemObject")
If fs.FileExists(server.MapPath ("../" & foldername & "/style.css")) = true Then
Dim objCSS, objXML, objDoc, myDoc
Set myDoc = createObject("Msxml.DOMDocument")
myDoc.async = false
myDoc.setProperty "ServerHTTPRequest", true
Set objCSS = Server.CreateObject("XStandard.CSS2XML")
Set objDoc = Server.CreateObject("MSXML2.DOMDocument.3.0")
objDoc.async = False
objCSS.Load strWWWrootPath & foldername & "\style.css"
myDoc.LoadXML(objCSS.XML)
' Check if XML is loaded is loaded... show error & stop
If (myDoc.parseError.errorCode <> 0) then
response.write "Erreur code : " & myDoc.parseError.errorCode
response.write "<br>Raison : " & myDoc.parseError.reason
response.write "<br>Ligne : " & myDoc.parseError.line
response.write "<br>Fichier : " & myDoc.parseError.url
response.end
Else
set myCssStyleSheet = myDoc.getElementsByTagName("rule")
end if
MenuNames = MenuNames & "Aucun style,"
MenuList = MenuList & ","
For Each item In myCssStyleSheet
selector = item.selectSingleNode("selector").text
' here we want only CLASSES (no ID's)
if left(selector,1) = "." then
theSelector = replace(selector,".","")
Set declarations = item.selectNodes("declaration")
If declarations.length > 0 Then
inlineStyle = " "
' put nice desing in drop down list, but not all of them, can you imagine width:500px... NOT !!!
' Dont use inlineStyle if you use version < 6.0
For Each items In declarations
select case items.selectSingleNode("property").text
case "color"
inlineStyle = inlineStyle & items.selectSingleNode("property").text & ":" & items.selectSingleNode("value").text & "; "
case "border"
inlineStyle = inlineStyle & items.selectSingleNode("property").text & ":" & items.selectSingleNode("value").text & "; "
inlineStyle = inlineStyle & "padding:1px ; "
case "background"
inlineStyle = inlineStyle & items.selectSingleNode("property").text & ":" & items.selectSingleNode("value").text & "; "
inlineStyle = inlineStyle & "padding:1px ; "
case "background-color"
inlineStyle = inlineStyle & items.selectSingleNode("property").text & ": " & items.selectSingleNode("value").text & "; "
inlineStyle = inlineStyle & "padding:1px ; "
case "font-weight"
inlineStyle = inlineStyle & items.selectSingleNode("property").text & ":" & items.selectSingleNode("value").text & "; "
case "text-transform"
inlineStyle = inlineStyle & items.selectSingleNode("property").text & ":" & items.selectSingleNode("value").text & "; "
end select
Next
MenuNames = MenuNames & "<span" & inlineStyle & """>" & left(""&theSelector,20) & "</span>,"
else
MenuNames = MenuNames & "" & left(""&theSelector,20) & ","
end if
MenuList = MenuList & "" & theSelector & ","
end if
Next
MenuNames = replace(MenuNames,"url(images","url(../" & foldername & "/images")
MenuNames = replace(MenuNames,"url('images","url('../" & foldername & "/images")
MenuNames = ""&left(MenuNames,len(MenuNames)-1)
MenuList = ""&left(MenuList,len(MenuList)-1)
editor.CssClassStyleDropDownMenuNames = MenuNames
editor.CssClassStyleDropDownMenuList = MenuList
end if
' -- END CODE --