xml = $xmlstring; $this->bu = $bu; $this->current_style = $this->getDefaultStyle(); } function getType() { preg_match('/(.*)<\/mms:type>/', $this->xml, $m); return $m[1]; } function isProgressing() { // mms:processing preg_match('/(.*)<\/mms:processing>/', $this->xml, $m); return strcmp($m[1], "false"); } function getOriginal() { preg_match('/(.*)<\/mms:original>/', $this->xml, $m); return $m[1]; } function getStyles() { if (!is_null($this->styles)) { return $this->styles; } $r = array(); preg_match_all('//', $this->xml, $m); for($i=0;$i $m[1][$i], 'width' => (int)$m[2][$i], 'style' => $m[3][$i]); } uasort($r, 'mycmp'); $this->styles = $r; return $r; } function getDefaultStyle() { $cw = 0; $cs = 'low'; foreach ($this->getStyles() as $st) { if ($st['width'] < 501 && $st['width'] > $cw) { $cs = $st['style']; } } $found = false; foreach ($this->getStyles() as $st) { if (!strcmp($st['style'], $cs)) { $found = true; break; } } if (!$found) { if (!strcmp($this->getType(), "audio")) { return "mp4"; } } return $cs; } function getOptionsHtml() { global $CONFIG; $c = "
"; foreach ($this->getStyles() as $st) { $c .= ''; $c .= ''; if (strcmp($st['style'], $this->current_style)) { $c .= ''; } $c .= elgg_echo('koolielu:media_'.$st['style']); if (strcmp($st['style'], $this->current_style)) $c .= ''; if (strcmp($st['style'], $this->current_style)) { if ($st['width']>500) { $c .= ''; } } $c .= ''; } $c .= ''; $c .= ''; $c .= ''; $c .= elgg_echo('koolielu:media_original'); $c .= ''; return $c.'
'; } function validateStyle($req_style, $ignsize = false) { foreach ($this->getStyles() as $st) { if (!strcmp($st['style'], $req_style)) { if ($ignsize) return $st['style']; if ($st['width'] < 501) { $this->current_style = $st['style']; return $st['style']; } } } return $this->getDefaultStyle(); } } /* $x = << Gr0283 01 artistic gaia galaxy large image 2011-06-25 10:44:55 UTC 2011-06-25 11:16:10 UTC false http://mms.eenet.ee/media/9a11/52/original/gr0283_01_artistic_gaia_galaxy_large.jpg 52 EOT; $m = new MMSXML($x); print_r($m->getStyles()); */