<?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
 */

$user = sly_Util_User::getCurrentUser();

$moduleSelect = new sly_Form_Select_DropDown('add_module', '', '', array(), 'module'.$pos);
$moduleSelect->addClass('sly-module-select');
$moduleSelect->addValue('', '---------------------------- '.t('add_slice'));

foreach ($modules as $module => $moduleTitle) {
	if (sly_Util_ArticleSlice::canAddModule($user, $module)) {
		$moduleSelect->addValue($module, sly_translate($moduleTitle));
	}
}

if ($moduleSelect->getValueCount() === 1) {
	return;
}

$form = new sly_Form($_router->getPlainUrl(null).'#addslice', 'GET', t('add_slice'));
$form->setCsrfEnabled(false);
$form->addClass('sly-form-add-slice');
$form->addHiddenValue('article_id', $article->getId());
$form->addHiddenValue('clang', $article->getClang());
$form->addHiddenValue('pos', $pos);
$form->addHiddenValue('function', 'add');
$form->addHiddenValue('slot', $slot);

$form->add($moduleSelect);
$form->setSubmitButton(null);
$form->setResetButton(null);
print $form->render();
