{namespace n=Tx_News_ViewHelpers}

<f:layout name="Backend/Default" />

<f:section name="categoryTree">
	<ul class="list-unstyled">
		<f:for each="{categories}" as="category">
			<li>
				<f:form.checkbox id="category-{category.item.uid}" property="selectedCategories" value="{category.item.uid}" />
				<label for="category-{category.item.uid}" title="{category.item.uid}">{category.item.title}</label>

				<f:if condition="{category.children}">
					<f:render section="categoryTree" arguments="{categories: category.children}" />
				</f:if>
			</li>
		</f:for>
	</ul>
</f:section>

<f:section name="content">
	<h1>
		<f:translate key="LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:administration.title" />
	</h1>
	<f:if condition="{page} == 0">
		<div class="alert alert-info">
			<div class="message-body">
				<f:translate key="LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:administration.nopageselected" />
			</div>
		</div>
	</f:if>
	<f:flashMessages class="tx-extbase-flash-message" />

	<f:form name="demand" object="{demand}" method="get" >
		<input type="hidden" name="M" value="web_NewsTxNewsM2">
		<input type="hidden" name="moduleToken" value="{moduleToken}">
		<input type="hidden" name="id" value="{page}">

		<h2>
			<f:translate key="LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:module.headline" />
		</h2>
		<div class="settings">
			<div class="row">
				<div class="col-sm-4 form-horizontal">
					<div class="form-group">
						<label for="recursive" class="col-sm-4 control-label">
							<f:translate key="LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:module.recursive" />
						</label>

						<div class="col-sm-8">
							<f:form.select property="recursive" options="{0:0,1:1,2:2,3:3,4:4,5:5}" id="recursive" class="form-control" />
						</div>
					</div>
					<div class="form-group">
						<label for="timeRestriction" class="col-sm-4 control-label">
							<f:translate key="LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:module.timeRestriction" />
						</label>

						<div class="col-sm-8">
							<f:form.textfield property="timeRestriction" id="timeRestriction" class="form-control" />
						</div>
					</div>
					<div class="form-group">
						<label for="timeRestrictionHigh" class="col-sm-4 control-label">
							<f:translate key="LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:module.timeRestrictionHigh" />
						</label>

						<div class="col-sm-8">
							<f:form.textfield property="timeRestrictionHigh" id="timeRestrictionHigh" class="form-control" />
						</div>
					</div>
					<div class="form-group">
						<label for="topNewsRestriction" class="col-sm-4 control-label">
							<f:translate key="LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.topNewsRestriction" />
						</label>

						<div class="col-sm-8">
							<f:form.select property="topNewsRestriction" class="form-control" options="{
						0:'',
						1:'{f:translate(key: \'LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.topNewsRestriction.1\')}',
						2:'{f:translate(key: \'LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.topNewsRestriction.2\')}'
					}" id="topNewsRestriction" />
						</div>
					</div>

					<div class="form-group">
						<label for="sortingField" class="col-sm-4 control-label">
							<f:translate key="LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderBy" />
						</label>

						<div class="col-sm-4">
							<f:form.select class="form-control" property="sortingField" options="{
					title:'{f:translate(key: \'LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderBy.title\')}',
					datetime:'{f:translate(key: \'LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderBy.datetime\')}',
					tstamp:'{f:translate(key: \'LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderBy.tstamp\')}',
					archive:'{f:translate(key: \'LLL:EXT:news/Resources/Private/Language/locallang_db.xlf:tx_news_domain_model_news.archive\')}',
					author:'{f:translate(key: \'LLL:EXT:cms/locallang_tca.xlf:pages.author_formlabel\')}'
				}" id="sortingField" />
						</div>
						<div class="col-sm-4">
							<f:form.select class="form-control" property="sortingDirection" options="{
					asc:'{f:translate(key: \'LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderDirection.asc\')}',
					desc:'{f:translate(key: \'LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderDirection.desc\')}'
				}" id="sortingDirection" />
						</div>
					</div>

					<div class="form-group">
						<div class="col-sm-offset-4 col-sm-8">
							<f:form.submit value="{f:translate(key:'LLL:EXT:lang/locallang_common.xlf:search')}" class="btn btn-default" />
						</div>
					</div>
				</div>
				<div class="col-sm-8">
					<div class="category-tree">
						<div class="tree-wrapper">
							<f:render section="categoryTree" arguments="{categories: categories}" />
						</div>

						<f:if condition="{categories}">
							<div class="form-group">
								<label for="categoryConjunction" class="col-sm-6 control-label">
									<f:translate key="LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.categoryConjunction" />
								</label>

								<div class="col-sm-6">
									<f:form.select class="form-control" property="categoryConjunction" options="{AND:'AND', OR:'OR', notor:'notor', notand:'notand'}" id="categoryConjunction" />
								</div>
							</div>
						</f:if>
					</div>
				</div>
			</div>

		</div>
	</f:form>

	<f:if condition="{news}">
		<f:then>
			<div class="result">
				<f:if condition="{settings.list.paginate.itemsPerPage} == 0">
					<div class="alert alert-warning">
						<f:translate key="LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:administration.nolimit" arguments="{0:'settings.list.paginate.itemsPerPage'}" />
					</div>
				</f:if>
				<f:be.widget.paginate objects="{news}" as="paginatedNews" configuration="{itemsPerPage: settings.list.paginate.itemsPerPage}">
					<table class="table table-hover">
						<thead>
						<tr class="t3-row-header">
							<th>
								<f:translate key="LLL:EXT:cms/locallang_ttc.xlf:header_formlabel" />
								<div class="btn-group">
									<n:be.buttons.icon class="btn" uri="#" onclick="{n:be.multiEditLink(items:paginatedNews,columns:'title')}" icon="actions-document-open" />
								</div>
							</th>
							<th class="nowrap">
								<f:translate key="LLL:EXT:news/Resources/Private/Language/locallang_db.xlf:tx_news_domain_model_news.istopnews" />
								<div class="btn-group">
									<n:be.buttons.icon class="btn" uri="#" onclick="{n:be.multiEditLink(items:paginatedNews,columns:'istopnews')}" icon="actions-document-open" />
								</div>
							</th>
							<th class="nowrap date">
								<f:translate key="LLL:EXT:news/Resources/Private/Language/locallang_db.xlf:tx_news_domain_model_news.datetime" />
								<div class="btn-group">
									<n:be.buttons.icon class="btn" uri="#" onclick="{n:be.multiEditLink(items:paginatedNews,columns:'datetime')}" icon="actions-document-open" />
								</div>
							</th>
							<th class="nowrap date">
								<f:translate key="LLL:EXT:news/Resources/Private/Language/locallang_db.xlf:tx_news_domain_model_news.archive" />
								<div class="btn-group">
									<n:be.buttons.icon class="btn" uri="#" onclick="{n:be.multiEditLink(items:paginatedNews,columns:'archive')}" icon="actions-document-open" />
								</div>
							</th>
							<th class="nowrap">
								<f:translate key="LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:flexforms_general.orderBy.tstamp" />
							</th>
							<th class="nowrap nosort"></th>
						</tr>
						</thead>
						<tbody>
						<f:for each="{paginatedNews}" as="newsItem">
							<f:render partial="Administration/ListItem" arguments="{newsItem: newsItem, dateformat:dateformat}" />
						</f:for>
						</tbody>
						<tfoot>
							<tr>
								<td colspan="6">
									<f:translate key="LLL:EXT:news/Resources/Private/Language/locallang_be.xlf:module.newsCount" arguments="{0:'{f:count(subject:news)}'}" />
								</td>
							</tr>
						</tfoot>
					</table>
				</f:be.widget.paginate>
			</div>
		</f:then>
		<f:else>
			<div class="alert alert-notice">
				<f:translate key="list_nonewsfound" />
			</div>
		</f:else>
	</f:if>
</f:section>