group = &$_SESSION['cms']['edit'][0]['group']; $this->values = &$_SESSION['cms']['edit'][0]; $this->status = $this->status (); } //*************************** // GETTER / SETTER //*************************** public function __get ($name) { switch ($name) { case "may_set_online": return Ticket::getEditRight () & Base::MODE_ONLINE; case "may_edit": return Ticket::getEditRight () & Base::MODE_EDIT; case "groupList": if (isset ($_REQUEST['listonline'])) { return $this->status['values']; } else { $list = array (); foreach ($this->status['values'] as $key => $row) { if ($row['status'] == "delete" || $row['status'] == "archive" || $row['status'] == "cut") { $list[$key] = $row; } } } return $list; case "status": $status = $this->status; foreach ($status['values'] as $key => $row) { $status['values'][$row['id']] = $row['status']; foreach ($row['elements'] as $name => $element) { $status['names'][$name] = $name; } } return $status; default: return $this->$name; } } public function __set ($name, $value) { } public function status () { $status = array (); $status['values'] = $this->values (); $status['messages'] = array (); $status['quickbar']['disabledButtons']['offline'] = true; $status['quickbar']['disabledButtons']['archive'] = true; $status['quickbar']['disabledButtons']['delete'] = true; $status['statusbar']['value'] = ""; // Elementname, User, letzte Änderung,... if (User::get ("is_admin")) { $status['statusbar']['value'] .= ""; } return $status; } private function values () { $values = Group::getChildList ($this->group['parent_id'], $this->group['name'], true); foreach ($values as $key => $row) { $values[$key]['status'] = ($row['parent_group_id'] != $this->group['parent_id']) ? "cut" : (($row['status'] & Base::STATUS_ERASED) ? "delete" : (($row['status'] & Base::STATUS_ARCHIVED) ? "archive" : (($row['status'] & Base::STATUS_ONLINE) ? "online" :"offline"))); $values[$key]['online'] = Group::getOnlineGroupStatus ($row['id']) & Base::STATUS_ONLINE; $group = new Group (array ('id' => $row['id'])); foreach ($this->group['element_names'] as $name) { if ($name) { $value = $group[$name]; $type = Status::get ($this->values['site_number'], $this->values['group_number'], $name); if ($type=="image") { if (preg_match ("/type=video\/mp4|\.mp4/", $value)) { $type = "mp4"; } } else { // Tags entfernen / umwandeln $value = preg_replace_callback ("/<(.*?)>/", array ($this, "replace"), $value); // Text kürzen for ($i=0, $j=0, $k=0; $j<200 && $i") { break; } } } if (substr ($value, $i, 1) == " ") { $k = $i; } } $value = ($j >= 200) ? (substr ($value, 0, $k) . " ...") : $value; } } else { // keine Elemente vorhanden (bzw. Element ohne Name?) $name = '—'; $value = ""; $type = ""; } $values[$key]['elements'][$name]['value'] = $value; $values[$key]['elements'][$name]['type'] = $type; } } return $values; } private function replace ($tag) { $name = preg_replace ("<([\/a-zA-Z]+).*>", "\\1", $tag[1]); switch ($name) { case "h": return ""; case "/h": return " – "; case "/p": case "/li": case "br": return " "; case "img": return preg_replace ("/.*src=[\'\"]([^\'\"]*).*/", "", $tag[1]); } return ""; } public function del ($id) { $group = new Group (array ('id' => $id)); $group->del (); $this->status = $this->status (); } public function archive ($id) { $group = new Group (array ('id' => $id)); $group->archive (); $this->status = $this->status (); } public function offline ($id) { $group = new Group (array ('id' => $id)); if ($group->parent_id == $this->group['parent_id']) { $group->offline (); } else { $group->move (0, $this->group['parent_id'], $this->group['name']); } $this->status = $this->status (); } public function message ($text) { return I18n::tr ("edit", "show_archive/$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'"); } } } ?>