set_type($path);
}
protected function analyze() {
if(file_exists($this->path.'/'.$this->filename)) {
$xml = file_get_contents($this->path.'/'.$this->filename);
static::$xml_indexation = _parser_text_no_function_($xml,"INDEXATION");
static::$xml_indexation['FIELD'] = $this->apply_sort(static::$xml_indexation['FIELD']);
}
}
protected function get_display_header_list() {
global $msg, $charset;
$display = "
".htmlentities($msg['misc_file_code'], ENT_QUOTES, $charset)." |
".htmlentities($msg['misc_file_label'], ENT_QUOTES, $charset)." |
".htmlentities($msg['misc_file_visible'], ENT_QUOTES, $charset)." |
";
return $display;
}
protected function get_display_content_list() {
global $msg, $charset;
$display = "";
foreach (static::$xml_indexation['FIELD'] as $field) {
$display .= "
".$field['ID']."
".$this->get_informations_hidden($field['ID'])."
|
".htmlentities($msg[$field['NAME']], ENT_QUOTES, $charset)." |
".$this->get_visible_checkbox($field['ID'])." |
";
}
return $display;
}
public function get_display_list() {
$display = "";
$display .= $this->get_display_header_list();
if(count(static::$xml_indexation['FIELD'])) {
$display .= $this->get_display_content_list();
}
$display .= "
";
return $display;
}
public function set_type($type) {
$this->type = substr($type, strrpos($type, '/')+1);
}
public function get_default_template() {
$is_subst = strpos($this->filename, '_subst.xml');
if(file_exists($this->path.'/'.$this->filename)) {
$contents = file_get_contents($this->path.'/'.$this->filename);
return utf8_encode($contents);
} elseif($is_subst) {
$contents = file_get_contents($this->path.'/'.str_replace('_subst.xml', '.xml', $this->filename));
return utf8_encode($contents);
}
}
protected function field_exists($field_id, $substitution_fields) {
foreach ($substitution_fields as $key=>$field) {
if($field['ID'] == $field_id) {
return $key;
}
}
return false;
}
protected function apply_sort($substitution_fields) {
if(!count($this->data)) {
return $substitution_fields;
}
$sorted_substitution = array();
foreach ($this->data as $field_id=>$field) {
$field_exists = $this->field_exists($field_id, $substitution_fields);
if($field_exists !== false) {
$sorted_substitution[] = $substitution_fields[$field_exists];
unset($substitution_fields[$field_exists]);
}
}
$sorted_substitution = array_merge($sorted_substitution, $substitution_fields);
return $sorted_substitution;
}
public function apply_substitution($fields) {
if(count($this->data)) {
$substitution = array();
foreach ($fields as $field) {
if(!isset($this->data[$field['ID']]['visible']) || $this->data[$field['ID']]['visible']) {
$substitution[] = $field;
}
}
//Ordonnancement
$substitution = $this->apply_sort($substitution);
} else {
$substitution = $fields;
}
return $substitution;
}
}