2 require_once(
"./Services/Style/System/classes/Less/class.ilSystemStyleLessItem.php");
3 require_once(
"./Services/Style/System/classes/Less/class.ilSystemStyleLessCategory.php");
4 require_once(
"./Services/Style/System/classes/Less/class.ilSystemStyleLessComment.php");
5 require_once(
"./Services/Style/System/classes/Less/class.ilSystemStyleLessVariable.php");
59 $this->less_variables_file = $less_variables_file;
69 $last_variable_comment = null;
70 $last_category_id = null;
71 $last_category_name = null;
73 $regex_category =
'/\/\/==\s(.*)/';
74 $regex_category_by_line =
'/^\/\/[\s]?$/';
75 $regex_category_comment =
'/\/\/##\s(.*)/';
76 $regex_variable =
'/^@(.*)/';
77 $regex_variable_comment =
'/\/\/\*\*\s(.*)/';
78 $regex_variable_name =
'/(?:@)(.*)(?:\:)/';
79 $regex_variable_value =
'/(?::)(.*)(?:;)/';
80 $regex_variable_references =
'/(?:@)([a-zA-Z0-9_-]*)/';
91 $last_line_is_category =
false;
93 while (($line = fgets($handle)) !==
false) {
95 if($last_line_is_category && preg_match($regex_category_by_line, $line,
$out)){
96 $line = fgets($handle);
98 $last_line_is_category =
false;
99 if(preg_match($regex_category, $line,
$out)){
102 $last_category_name =
$out[1];
103 $last_line_is_category =
true;
104 }
else if(preg_match($regex_category_comment, $line,
$out)){
106 $last_category = $this->
getItemById($last_category_id);
107 $last_category->setComment(
$out[1]);
108 }
else if(preg_match($regex_variable_comment, $line,
$out)){
110 $last_variable_comment =
$out[1];
111 }
else if(preg_match($regex_variable, $line,
$out)){
115 preg_match($regex_variable_name,
$out[0], $variable);
118 preg_match($regex_variable_value, $line, $value);
121 $temp_value = $value[0];
122 $references =
array();
123 while(preg_match($regex_variable_references,$temp_value,$reference)){
124 $references[] = $reference[1];
125 $temp_value = str_replace($reference,
"",$temp_value);
130 ltrim ( $value[1] ,
" \t\n\r\0\x0B" ),
131 $last_variable_comment,
134 $last_variable_comment =
"";
162 foreach($this->items as $item){
163 $output .= $item->__toString();
173 $id = array_push($this->items,$item)-1;
176 if(get_class($item)==
"ilSystemStyleLessComment"){
177 $this->comments_ids[] = $id;
178 }
else if(get_class($item)==
"ilSystemStyleLessCategory"){
179 $this->categories_ids[] = $id;
180 }
else if(get_class($item)==
"ilSystemStyleLessVariable"){
181 $this->variables_ids[] = $id;
191 $categories =
array();
193 foreach($this->categories_ids as $category_id){
194 $categories[] = $this->items[$category_id];
206 $variables =
array();
208 foreach($this->variables_ids as $variables_id){
209 if(!$category || $this->items[$variables_id]->getCategoryName() == $category){
210 $variables[] = $this->items[$variables_id];
222 return $this->items[$id];
230 foreach($this->variables_ids as $variables_id){
231 if($this->items[$variables_id]->getName() == $name){
232 return $this->items[$variables_id];
246 foreach($this->variables_ids as $id){
247 foreach($this->items[$id]->getReferences() as $reference){
248 if($variable_name == $reference)
249 $references[] = $this->items[$id]->getName();
260 $references_string =
"";
262 $references_string .=
"$reference; ";
264 return $references_string;
272 return $this->less_variables_file;
280 $this->less_variables_file = $less_variables_file;
getReferencesToVariable($variable_name)
getVariableByName($name="")
__construct($less_variables_file)
KitchenSinkLessFile constructor.
read()
Reads the file from the file system.
write()
Write the complete file back to the file system (including comments and random content) ...
setLessVariablesFile($less_variables_file)
Capsules data of a less category in the variables to less file.
addItem(ilSystemStyleLessItem $item)
getReferencesToVariableAsString($variable_name)
if(!is_dir( $entity_dir)) exit("Fatal Error ([A-Za-z0-9]+)\+" &#(? foreach( $entity_files as $file) $output
Class for advanced editing exception handling in ILIAS.
const FILE_OPENING_FAILED
Create styles array
The data for the language used.
Abstracts content of a less file.
getVariablesPerCategory($category="")
$less_variables_file_path