$value) { $variable = lcfirst(str_replace(' ', '', ucwords(str_replace('-', ' ', strtolower($key))))); $this->{$variable} = self::prepareData($value); } } } /** * Prepares the data for output * * @param mixed $value * @return mixed */ protected function prepareData($value) { if (is_string($value)) { return stripslashes(trim(str_replace('\n', "\n", $value))); } else if (is_array($value)) { return array_map('self::prepareData', $value); } return $value; } /** * Return Event data excluding anything blank * within an HTML template * * @param string $html HTML template to use * @return string */ public function printData($html = '

%s: %s

') { $data = array( 'SUMMARY' => $this->summary, 'DTSTART' => $this->dtstart, 'DTEND' => $this->dtend, 'DTSTART_TZ' => $this->dtstart_tz, 'DTEND_TZ' => $this->dtend_tz, 'DURATION' => $this->duration, 'DTSTAMP' => $this->dtstamp, 'UID' => $this->uid, 'CREATED' => $this->created, 'LAST-MODIFIED' => $this->lastmodified, 'DESCRIPTION' => $this->description, 'LOCATION' => $this->location, 'SEQUENCE' => $this->sequence, 'STATUS' => $this->status, 'TRANSP' => $this->transp, 'ORGANISER' => $this->organizer, 'ATTENDEE(S)' => $this->attendee, ); $data = array_map('trim', $data); // Trim all values $data = array_filter($data); // Remove any blank values $output = ''; foreach ($data as $key => $value) { $output .= sprintf($html, $key, $value); } return $output; } }