<?php
/**
*
*/

// Disallow direct access.
defined('ABSPATH') or die("Access denied");

// Set buttons text.
if ($this->isNew) {
	$closeButtonText = cssJSToolbox::getText('Close');
	$updateButtonText = cssJSToolbox::getText('Save');
}
else {
	$closeButtonText = cssJSToolbox::getText('Cancel');
	$updateButtonText = cssJSToolbox::getText('Update');
}
// Import dependencies.
cssJSToolbox::import('framework:html:list.php');
// If NEW enable core fields, if edit disable core fields!
$coreFieldsState = $this->isNew ? '' : 'disabled="disabled"';

// Allow view to enqueue scripts and styles.
$this->enququeScripts();
$this->enququeStyles();
$this->suppressPrintScriptsHook();
?>
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
<?php wp_print_head_scripts() ?>
<?php wp_print_styles() ?>
	</head>
	<body>
		<div id="wpwrap">
			<div id="wpcontent">
				<div id="wpbody">
					<div id="wpbody-content">
						<div class="wrap">
							<form id="item-form" class="cjt-form" method="post">
								<div id="form-tabs">
									<ul>
										<li><a href="#main-tab"><?php echo cssJSToolbox::getText('Main') ?></a></li>
										<li><a href="#description-tab"><?php echo cssJSToolbox::getText('Description') ?></a></li>
										<li><a href="#version-tab"><?php echo cssJSToolbox::getText('Version') ?></a></li>
									</ul>
									<div id="main-tab">
										<fieldset>
											<ul>
												<li><label for="name" title="<?php echo cssJSToolbox::getText('Name or title of template  (must be unique and cannot be left blank)') ?>"><?php echo cssJSToolbox::getText('Name') ?><sub>*</sub></label><input type="text" maxlength="80" id="name" name="item[template][name]" value="<?php echo esc_attr($this->item->name) ?>" <?php echo $coreFieldsState ?>></li>
												<li>
													<label for="type" title="<?php echo cssJSToolbox::getText('Set the code language to: CSS, JavaScript, HTML, or PHP  (selection must be made)') ?>"><?php echo cssJSToolbox::getText('Language') ?><sub>*</sub></label>
<?php							echo CJTListField::getInstance('template-types', 'item-form', 'item[template][type]', $this->item->type, 'type', null, null, null, $coreFieldsState, cssJSToolbox::getText('< Select Type >'))->getInput(array('standard' => true, 'result' => 'fullList')) ?>
												</li>
												<li>
													<label for="state" title="<?php echo  cssJSToolbox::getText('Set the template state to: Published, Draft, or Trash  (selection must be made)') ?>"><?php echo cssJSToolbox::getText('Template State') ?><sub>*</sub></label>
<?php							echo CJTListField::getInstance('template-states', 'item-form', 'item[template][state]', $this->item->state, 'state', null, null, null, null, cssJSToolbox::getText('< Select State >'))->getInput(array('standard' => true, 'result' => 'fullList')) ?>
												</li>
												<li>
													<label for="code" title="<?php echo cssJSToolbox::getText('Enter code for the template in the large text ﬁeld and click Save when done') ?>"><?php echo cssJSToolbox::getText('Code') ?></label>
													<div class="ace-wrap">
														<div  id="code" name="item[revision][code]"><?php echo htmlentities($this->item->code, null, 'UTF-8') ?></div>
													</div>
												</li>
											</ul>
										</fieldset>
									</div>
									<div id="description-tab">
										<fieldset>
											<ul>
												<li><label for="description" title="<?php echo cssJSToolbox::getText('Enter a descriptive write-up for the template describing what it is, and how it works, etc ') ?>"><?php echo cssJSToolbox::getText('Description') ?></label><textarea id="description" name="item[template][description]"><?php echo esc_textarea($this->item->description) ?></textarea></li>
												<li><label for="keywords" title="<?php echo cssJSToolbox::getText('Enter strong keywords for the template - each being separated by a comma') ?>"><?php echo cssJSToolbox::getText('Keywords') ?></label><textarea id="keywords" cols="60" rows="5" name="item[template][keywords]"><?php echo esc_textarea($this->item->keywords) ?></textarea></li>
											</ul>
										</fieldset>
									</div>
									<div id="version-tab">
										<fieldset>
											<ul>
												<li><label for="version" title="<?php echo cssJSToolbox::getText('Enter the speciﬁc version for the template  (e.g. 1.0)') ?>"><?php echo cssJSToolbox::getText('Version') ?></label><input type="text" maxlength="15" id="version" name="item[revision][version]" value="<?php echo esc_attr($this->item->version) ?>"></li>
												<li>
													<label for="developmentState" title="<?php echo cssJSToolbox::getText('Set the release state to: Release, Beta, Alpha, Release Candidate, or Revision') ?>"><?php echo cssJSToolbox::getText('State') ?></label>
<?php							echo CJTListField::getInstance('template-development-states', 'item-form', 'item[revision][state]', $this->item->developmentState, 'developmentState', null, null, null, null, cssJSToolbox::getText('< Select State >'))->getInput(array('standard' => true, 'result' => 'fullList')) ?>
												</li>
												<li><label for="changeLog" title="<?php echo cssJSToolbox::getText('Add any notes such as stability issues, bug ﬁxes, or anything that can be useful for future development') ?>"><?php echo cssJSToolbox::getText('Revision note') ?></label><textarea id="changeLog" name="item[revision][changeLog]"><?php echo esc_textarea($this->item->changeLog) ?></textarea></li>
											</ul>
										</fieldset>
									</div>
								</div>
								<input type="button" id="cancel" class="button-secondary" value="<?php echo $closeButtonText ?>">
								<input type="button" id="save" class="button-secondary" value="<?php echo $updateButtonText ?>">
								<input type="hidden" name="item[template][id]" value="<?php echo $this->item->id ?>" />
							</form>
						</div>
					</div>
				</div>
			</div>
		</div>
<?php wp_print_footer_scripts() ?>
	</body>
</html>