<?php
/*
 * Copyright (c) 2013, webvariants GbR, http://www.webvariants.de
 *
 * This file is released under the terms of the MIT license. You can find the
 * complete text in the attached LICENSE file or online at:
 *
 * http://www.opensource.org/licenses/mit-license.php
 */

abstract class _WV_Datatype_Base_MediaWidget extends _WV_Datatype_Base {
	protected function initFormElement(sly_Form $form, sly_Form_Widget_MediaBase $widget, WV_IProperty $property) {
		$params = $this->deserializeParams($property->getParams());
		$cats   = sly_makeArray($params['categories']);
		$types  = sly_makeArray($params['types']);

		if (!empty($cats)) {
			$widget->filterByCategories($cats, $params['recursive']);
		}

		if (!empty($types)) {
			$widget->filterByFiletypes($types);
		}

		WV_Datatype::setHelpTextOnElement($form, $widget, $property);
		$widget->setMultilingual($property->isMultilingual());
	}
}
