"", 'section' => "", 'language' => ""); } $this->active = &$_SESSION['cms']['edit']['i18n_setup']['active']; $this->active['language'] = isset ($this->active['language']) ? $this->active['language'] : I18n::DEFAULT_LC; $this->section = !empty ($this->active['section']) ? preg_replace ("/\/.*/", "", $this->active['section']) : ""; $this->status = $this->status (); } //*************************** // GETTER / SETTER //*************************** public function __get ($name) { switch ($name) { case "may_edit_i18n": return User::get ("is_admin") || User::get ("may_edit_i18n"); case "language": return $this->active['language']; case "languages": return I18n::getLanguages (); case "sections": $sections = array (); foreach (I18n::getSections () as $section) { $i18n = new I18n ($section); foreach ($i18n->getAll () as $row) { // Untergruppen suchen if (strstr ($row['name'], "/")) { $head = preg_replace ("/\/.*/", "", $row['name']); if (empty ($sections[$section][$head])) { $sections[$section][$head] = $head; ksort ($sections[$section]); } } else { $sections[$section]["_$section"] = ""; ksort ($sections[$section]); } } } ksort ($sections); return $sections; case "textList": $list = array (); if (!empty ($this->active['language']) && !empty ($this->active['section'])) { $group = preg_replace ("/.*?\/(.*)/", "\\1", $this->active['section']); $i18n = new I18n ($this->section, $this->active['language']); foreach ($i18n->getAll () as $row) { if (!strstr ($row['name'], "$group/")==!$group) { $row['title'] = preg_replace ("/^$group\//", "", $row['name']); $list[] = $row; } } } return $list; default: return $this->$name; } } public function __set ($name, $value) { } private function status () { $status = array (); if (!empty ($this->active['name'])) { $i18n = new I18n ($this->section, $this->active['language']); $status['values'] = $i18n->get ($this->active['name']); $status['values']['ok'] = isset ($status['values']['id']) && ($status['values']['status'] & I18n::STATUS_CHECKED); $status['id'] = isset ($status['values']['id']) && $status['values']['id']; $values = $i18n->getAll ($this->active['name']); $status['values']['defaultValue'] = isset ($values['value']) ? $values['value'] : ""; } else { $status['values'] = array (); $status['id'] = 0; } $status['messages'] = array (); $status['quickbar']['disabledButtons']['save'] = true; if (!History::getFirstUndo ($status['id'], "i18n", false)) { $status['quickbar']['disabledButtons']['undo'] = true; } if (!History::getFirstRedo ($status['id'], "i18n", false)) { $status['quickbar']['disabledButtons']['redo'] = true; } $status['quickbar']['disabledButtons']['new'] = empty ($this->active['language']) || !$this->section; $status['quickbar']['disabledButtons']['delete'] = empty ($this->active['name']); $status['quickbar']['disabledButtons']['deleteall'] = empty ($this->active['name']); $status['statusbar']['value'] = ""; // Elementname, User, letzte Änderung,... if (User::get ("is_admin")) { $status['statusbar']['value'] .= ""; } return $status; } public function value ($name) { if (isset ($this->status['values'][$name])) { return $this->status['values'][$name]; } else { return ""; } } public function select ($active) { $this->active = $active; $this->status = $this->status (); } public function save ($values) { $i18n = new I18n ($this->section, $this->active['language']); $i18n->set ($this->active['name'], isset ($values['value']) ? $values['value'] : $this->value ("value"), (empty ($values['ok']) ? I18n::STATUS_EDITED : I18n::STATUS_CHECKED)); } public function del () { if ($this->active) { $i18n = new I18n ($this->section, $this->active['language']); $i18n->del ($this->active['name']); $this->status = $this->status (); } } public function delAll () { if ($this->active) { $i18n = new I18n ($this->section); $i18n->del ($this->active['name']); $this->active['name'] = ""; $this->status = $this->status (); } } public function add ($name) { if ($this->active['section']) { $prefix = preg_replace ("/.*?\//", "", $this->active['section']); $fullname = ($prefix && $prefix!=$this->active['section']) ? "$prefix/$name" : $name; $i18n = new I18n ($this->section, I18n::DEFAULT_LC); if (!$i18n->get ($fullname)) { $i18n->set ($fullname, $name); } $this->active['name'] = $name; } } public function undo () { if ($undo = History::getFirstUndo ($this->status['id'], "i18n", false)) { History::restore ($undo['id']); $this->status = $this->status (); } } public function redo () { $ids = Setting::getIds ("system"); if ($redo = History::getFirstRedo ($this->status['id'], "i18n", false)) { History::restore ($redo['id']); $this->status = $this->status (); } } public function message ($text) { return I18n::tr ("edit", "i18n_settings/$text", $text); } // Wandelt das gegebene Array/Text in eine Form um, die direkt einer JavaScript Variablen zugewiesen werden kann public function toJavaScript ($value) { if (is_array ($value)) { $values = array (); foreach ($value as $key => $val) { $values[] = "'$key':".$this->toJavaScript ($val); } return "{".implode (",", $values)."}"; } else { $value = Database::escape ($value); return ($value===true) ? "true" : (($value===false) ? "false" : "'$value'"); } } } ?>