public static function saveElements($post, Type $type) { // init vars $elements = array(); // update old elements foreach ($type->getElements() as $identifier => $element) { if (isset($post['elements'][$identifier])) { $data = $post['elements'][$identifier]; // bind data $element->bindConfig($data); // add to element array $elements[$data['ordering']] = $element; } } // add new elements if (isset($post['new_elements'])) { foreach ($post['new_elements'] as $data) { $element = ElementHelper::loadElement($data['type'], $type->getApplication()->getPath() . '/elements'); $element->setType($type); // set identifier (UUID) $data['identifier'] = YUtility::generateUUID(); // bind data $element->bindConfig($data); // add to element array $elements[$data['ordering']] = $element; } } // sort elements ksort($elements); $type->setXML(self::toXML($elements)); $type->clearElements(); return true; }
public function render($params = array()) { // init vars $width = $this->_data->get('width'); $height = $this->_data->get('height'); $autoplay = $this->_data->get('autoplay', false); $autoplay_bool = $autoplay ? 'true' : 'false'; $autoplay_google = $autoplay ? 'autoplay:"true"' : ''; $directory = $this->_config->get('directory'); $formats = $this->_getVideoFormats(); $file = $this->_data->get('file'); $source = $file ? JURI::root() . $directory . '/' . $file : $this->_data->get('url'); $format = $this->getVideoFormat($source); if (isset($formats[$format])) { if (in_array($format, array('flv', 'swf', 'youtube.com', 'video.google.com', 'vimeo.com', 'liveleak.com', 'vids.myspace.com'))) { JHTML::script('swfobject.js', 'administrator/components/com_zoo/elements/video/assets/js/'); $width = $width ? $width : 200; $height = $height ? $height : 200; } if (in_array($format, array('mov', 'mpg', 'mp4'))) { JHTML::script('quicktime.js', 'administrator/components/com_zoo/elements/video/assets/js/'); } // parse source link if (isset($formats[$format]['regex'])) { if (preg_match($formats[$format]['regex'], $source, $matches)) { if (isset($matches[1])) { $source = $matches[1]; } } } // video params $params = array("{SOURCE}", "{ID}", "{WIDTH}", "{HEIGHT}", "{AUTOPLAY}", "{AUTOPLAY-AS-INT}", "{AUTOPLAY-GOOGLE}"); // replacements $replace = array($source, "video-" . YUtility::generateUUID(), $width, $height, $autoplay_bool, $autoplay, $autoplay_google); return JFilterOutput::ampReplace(str_replace($params, $replace, $formats[$format]['html'])); } return JText::_('No video selected.'); }