<?php
if (!isset($path)) $path = NULL;
if (!isset($group_key)) $group_key = NULL;
if (!isset($group_start)) $group_start = '';
if (!isset($group_end)) $group_end = '';
if (!isset($row_start)) $row_start = '';
if (!isset($row_end)) $row_end = '';
if (!isset($row_limit)) $row_limit = 0;
if (!isset($row_count) OR !$row_count) $row_count = 1;

print "
<div class='form-row'>
	<label for='path' class='form-label'>".LABEL_PATH."</label>
	<div class='form-cols'>
		<div class='form-col form-full'>
			<div class='form-controls'>
				<input type='text' class='field' id='path' name='path' value='".$path."' placeholder='template/article.php'>
			</div><!-- /.form-controls -->
		</div><!-- /.form-col -->
	</div><!-- /.form-cols -->
</div><!-- /.form-row -->";

if ($path) {
	print "
<div class='form-row'>
	<label for='template_source_textarea' class='form-label textarea'>".LABEL_TEMPLATE_FILE."</label>
	<div class='form-cols'>
		<div class='form-col form-full'>
			<div class='form-controls big'>
				<input type='hidden' name='template_source_path' value='".$path."'>

				<ul class='textarea-panel' data-id='template_source' data-default='code'>
					<li class='show_default-editor current' data-id='template_source' data-type='plain'>
						<i class='material-icons md-24'>edit</i>".LABEL_DEFAULT_EDITOR."
					</li>
					<li class='show_code-editor' data-id='template_source' data-type='plain'>
						<i class='material-icons md-24'>code</i>".LABEL_CODE_EDITOR."
					</li>
				</ul>

				<ul class='chips' data-id='template_source_textarea'>
					<!-- <li data-value='[IMAGE=1]'><span>[IMAGE]</span></li>
					<li data-value='[FILE=1]'><span>[FILE]</span></li>
					<li data-value='[LINK=1]'><span>[LINK]</span></li> -->
				</ul>";

	if ($template_source_error) {
		print "
				<div class='alert error'>
					<strong>".LABEL_ERROR."</strong>
					".$template_source_error."
				</div>";
	}

	print "
				<textarea name='template_source' class='field big' id='template_source_textarea' data-mode='php' data-autocomplete='true'>".$template_source."</textarea>
				<div id='template_source' class='code-editor'></div>
			</div><!-- /.form-controls -->
		</div><!-- /.form-col -->
	</div><!-- /.form-cols -->
</div><!-- /.form-row -->

<hr/>
<div class='form-row'>
	<label for='group_key' class='form-label'>".LABEL_GROUP_KEY."</label>
	<div class='form-cols'>
		<div class='form-col form-full'>
			<div class='form-controls'>
				<input type='text' class='field' id='group_key' name='group_key' value='".$group_key."'>
			</div><!-- /.form-controls -->
		</div><!-- /.form-col -->
	</div><!-- /.form-cols -->
</div><!-- /.form-row -->

<div class='form-row'>
	<label for='group_start_textarea' class='form-label textarea'>".LABEL_GROUP_START."</label>
	<div class='form-cols'>
		<div class='form-col form-full'>
			<div class='form-controls'>
				<ul class='textarea-panel' data-id='group_start' data-default='code'>
					<li class='show_default-editor current' data-id='group_start' data-type='plain'>
						<i class='material-icons md-24'>edit</i>".LABEL_DEFAULT_EDITOR."
					</li>
					<li class='show_code-editor' data-id='group_start' data-type='plain'>
						<i class='material-icons md-24'>code</i>".LABEL_CODE_EDITOR."
					</li>
				</ul>

				<textarea name='group_start' class='field small' id='group_start_textarea' data-mode='html' data-autocomplete='true'>".$group_start."</textarea>
				<div id='group_start' class='code-editor'></div>
			</div><!-- /.form-controls -->
		</div><!-- /.form-col -->
	</div><!-- /.form-cols -->
</div><!-- /.form-row -->

<div class='form-row'>
	<label for='group_end_textarea' class='form-label textarea'>".LABEL_GROUP_END."</label>
	<div class='form-cols'>
		<div class='form-col form-full'>
			<div class='form-controls'>
				<ul class='textarea-panel' data-id='group_end' data-default='code'>
					<li class='show_default-editor current' data-id='group_end' data-type='plain'>
						<i class='material-icons md-24'>edit</i>".LABEL_DEFAULT_EDITOR."
					</li>
					<li class='show_code-editor' data-id='group_end' data-type='plain'>
						<i class='material-icons md-24'>code</i>".LABEL_CODE_EDITOR."
					</li>
				</ul>

				<textarea name='group_end' class='field small' id='group_end_textarea' data-mode='html' data-autocomplete='true'>".$group_end."</textarea>
				<div id='group_end' class='code-editor'></div>
			</div><!-- /.form-controls -->
		</div><!-- /.form-col -->
	</div><!-- /.form-cols -->
</div><!-- /.form-row -->

<hr />

<div class='form-row'>
	<label for='row_limit' class='form-label'>".LABEL_ROW_LIMIT."</label>
	<div class='form-cols'>
		<div class='form-col form-small'>
			<div class='form-controls'>
				<input type='number' class='field' id='row_limit' name='row_limit' value='".$row_limit."' min='0'>
			</div><!-- /.form-controls -->
		</div><!-- /.form-col -->
	</div><!-- /.form-cols -->
</div><!-- /.form-row -->

<div class='form-row'>
	<label for='row_count' class='form-label'>".LABEL_ROW_COUNT."</label>
	<div class='form-cols'>
		<div class='form-col form-small'>
			<div class='form-controls'>
				<input type='number' class='field' id='row_count' name='row_count' value='".$row_count."' min='1'>
			</div><!-- /.form-controls -->
		</div><!-- /.form-col -->
	</div><!-- /.form-cols -->
</div><!-- /.form-row -->

<div class='form-row'>
	<label for='row_start_textarea' class='form-label textarea'>".LABEL_ROW_START."</label>
	<div class='form-cols'>
		<div class='form-col form-full'>
			<div class='form-controls'>
				<ul class='textarea-panel' data-id='row_start' data-default='code'>
					<li class='show_default-editor current' data-id='row_start' data-type='plain'>
						<i class='material-icons md-24'>edit</i>".LABEL_DEFAULT_EDITOR."
					</li>
					<li class='show_code-editor' data-id='row_start' data-type='plain'>
						<i class='material-icons md-24'>code</i>".LABEL_CODE_EDITOR."
					</li>
				</ul>

				<textarea name='row_start' class='field small' id='row_start_textarea' data-mode='html' data-autocomplete='true'>".$row_start."</textarea>
				<div id='row_start' class='code-editor'></div>
			</div><!-- /.form-controls -->
		</div><!-- /.form-col -->
	</div><!-- /.form-cols -->
</div><!-- /.form-row -->

<div class='form-row'>
	<label for='row_end_textarea' class='form-label textarea'>".LABEL_ROW_END."</label>
	<div class='form-cols'>
		<div class='form-col form-full'>
			<div class='form-controls'>
				<ul class='textarea-panel' data-id='row_end' data-default='code'>
					<li class='show_default-editor current' data-id='row_end' data-type='plain'>
						<i class='material-icons md-24'>edit</i>".LABEL_DEFAULT_EDITOR."
					</li>
					<li class='show_code-editor' data-id='row_end' data-type='plain'>
						<i class='material-icons md-24'>code</i>".LABEL_CODE_EDITOR."
					</li>
				</ul>

				<textarea name='row_end' class='field small' id='row_end_textarea' data-mode='html' data-autocomplete='true'>".$row_end."</textarea>
				<div id='row_end' class='code-editor'></div>
			</div><!-- /.form-controls -->
		</div><!-- /.form-col -->
	</div><!-- /.form-cols -->
</div><!-- /.form-row -->";
}

print "
<hr/>";