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;
70 $last_variable_comment = null;
71 $last_category_id = null;
72 $last_category_name = null;
74 $regex_category =
'/\/\/==\s(.*)/';
75 $regex_category_by_line =
'/^\/\/[\s]?$/';
76 $regex_category_comment =
'/\/\/##\s(.*)/';
77 $regex_variable =
'/^@(.*)/';
78 $regex_variable_comment =
'/\/\/\*\*\s(.*)/';
79 $regex_variable_name =
'/(?:@)(.*)(?:\:)/';
80 $regex_variable_value =
'/(?::)(.*)(?:;)/';
81 $regex_variable_references =
'/(?:@)([a-zA-Z0-9_-]*)/';
92 $last_line_is_category =
false;
94 while (($line = fgets($handle)) !==
false) {
96 if ($last_line_is_category && preg_match($regex_category_by_line, $line,
$out)) {
97 $line = fgets($handle);
99 $last_line_is_category =
false;
100 if (preg_match($regex_category, $line,
$out)) {
103 $last_category_name =
$out[1];
104 $last_line_is_category =
true;
105 } elseif (preg_match($regex_category_comment, $line,
$out)) {
107 $last_category = $this->
getItemById($last_category_id);
108 $last_category->setComment(
$out[1]);
109 } elseif (preg_match($regex_variable_comment, $line,
$out)) {
111 $last_variable_comment =
$out[1];
112 } elseif (preg_match($regex_variable, $line,
$out)) {
116 preg_match($regex_variable_name,
$out[0], $variable);
119 preg_match($regex_variable_value, $line, $value);
122 $temp_value = $value[0];
123 $references =
array();
124 while (preg_match($regex_variable_references, $temp_value, $reference)) {
125 $references[] = $reference[1];
126 $temp_value = str_replace($reference,
"", $temp_value);
131 ltrim($value[1],
" \t\n\r\0\x0B"),
132 $last_variable_comment,
136 $last_variable_comment =
"";
165 foreach ($this->items as $item) {
166 $output .= $item->__toString();
177 $id = array_push($this->items, $item)-1;
180 if (get_class($item)==
"ilSystemStyleLessComment") {
181 $this->comments_ids[] =
$id;
182 } elseif (get_class($item)==
"ilSystemStyleLessCategory") {
183 $this->categories_ids[] =
$id;
184 } elseif (get_class($item)==
"ilSystemStyleLessVariable") {
185 $this->variables_ids[] =
$id;
196 $categories =
array();
198 foreach ($this->categories_ids as $category_id) {
199 $categories[] = $this->items[$category_id];
211 $variables =
array();
213 foreach ($this->variables_ids as $variables_id) {
214 if (!$category || $this->items[$variables_id]->getCategoryName() == $category) {
215 $variables[] = $this->items[$variables_id];
228 return $this->items[
$id];
237 foreach ($this->variables_ids as $variables_id) {
238 if ($this->items[$variables_id]->getName() ==
$name) {
239 return $this->items[$variables_id];
253 foreach ($this->variables_ids as
$id) {
254 foreach ($this->items[$id]->getReferences() as $reference) {
255 if ($variable_name == $reference) {
256 $references[] = $this->items[
$id]->getName();
269 $references_string =
"";
271 $references_string .=
"$reference; ";
273 return $references_string;
281 return $this->less_variables_file;
289 $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)
if(!array_key_exists('StateId', $_REQUEST)) $id
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