I'm not sure if i should post this thread here, but anyway. As we use the editor in an application (which we use often for the maintenance od different sites), it's a great deal of work to constantly edit the fckstyles.xml file.
So i wrote a function, which takes a stylesheet as parameter and parses this file, so you will get a valid fckstyles.xml file. Here's the code, i hope it helps anyone.
<?php // this file will convert a css file to the fckstyles xml layout // the only requirement is that the style in the stylesheet start with // a dot(.), the element name it is intented for and a underscore, eg: .img_image_on_left{} // as a parameter, a valid stylesheet is taken (/usr/home/somehost/stylesheet.css) or // (http://www.somehost.com/styles.css) // // in this file, the name of the style is modified, the ".elementname_" is stripped and after // that, underscores are replaced for readability; // // there's an array of allowed tags, only elements wth that tagname will be displayed in the // xml file (and thus style combo) function echo_styles($strStylesheet){ // define an array of valid tags $arrTags = array("span","img", "table", "tr", "td", "input", "select", "textarea", "hr", "object"); // open the stylesheet for reading if($fp = fopen($strStylesheet, "r")){ $contents = ''; while(!feof($fp)) { $contents .= fread($fp, 8192); } // read the content in an array //$stylesheet_content = split("\n", $contents); $stylesheet_content = split("}",$contents); $theXML = ''; for($i=0;$i<count($stylesheet_content);$i++){ $style = $stylesheet_content[$i]; $style_name = trim(substr($style,0,strpos($style,"{"))); if(substr($style_name,0,1) == "."){ $style_name = substr($style_name,1); // for each element, display an xml tag $theElement = substr($style_name, 0, strpos($style_name,"_")); if(in_array(strtolower($theElement), $arrTags)){ $new_style_name = str_replace("_", " ", substr($style_name, strpos($style_name,"_")+1, strlen($style_name)-strpos($style_name,"_"))); $theXML .= "<Style name=\"$new_style_name\" element=\"$theElement\">\n"; $theXML .= " <Attribute name=\"class\" value=\"$style_name\" />\n"; $theXML .= "</Style>\n"; } } else { if(trim(substr($style,0,7)) == "@import"){ $theStyleSheets = split("@", $style); for($i=0;$i<count($theStyleSheets);$i++){ $theStyleSheet = substr($theStyleSheets[$i], 7, strlen($theStyleSheets[$i])); $theStyleSheet = str_replace("'","", $theStyleSheet); $theStyleSheet = str_replace(";","", $theStyleSheet); $number_dirs_back = count(split("../", $theStyleSheet)); $theStyleSheet = str_replace("../","", $theStyleSheet); for($k=0;$k<$number_dirs_back;$k++){ $thePath = substr($site_path,0,strrpos($site_path, "/")); $thePath = trim(substr($thePath,0,strrpos($thePath, "/"))); } echo_styles(trim($thePath."/".$theStyleSheet)); } } } } } return $theXML; } // send the XML header to the broser, so it knows it's XML header("Content-type: text/xml"); header("Pragma: public"); header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); // echo the XML tag first and the root node echo "<?xml version=\"1.0\" encoding=\"utf-8\" ?>\n";