<?php

/**
 *
 * @copyright  2010-2013 izend.org
 * @version    16
 * @link       http://www.izend.org
 */
?>
<?php extract($errors); ?>
<h3><?php echo htmlspecialchars($site_title ? $site_title : $sitename, ENT_COMPAT, 'UTF-8'); ?></h3>
<form class="compact" action="" method="post">
<input name="clang" type="hidden" value="<?php echo $clang; ?>" />
<p>
<?php echo $inlanguages; ?>
</p>
<p>
<input class="submit submit_add" id="thread_create" name="thread_create" type="submit" value="Add" />
thread
<input id="new_thread_title" name="new_thread_title" type="text" size="40" maxlength="100" value="<?php echo htmlspecialchars($new_thread_title, ENT_COMPAT, 'UTF-8'); ?>" title="Title" title="Titre" onkeypress="return focusonenter(event, 'new_thread_number')"/>
<span class="nowrap">
#
<input id="new_thread_number" name="new_thread_number" type="text" size="2" maxlength="3" value="<?php echo htmlspecialchars($new_thread_number, ENT_COMPAT, 'UTF-8'); ?>" title="Number" onkeypress="return submitonenter(event, 'thread_create')"/>
</span>
<span class="nowrap">
type
<select name="new_thread_type" size="1">
<option value="thread"<?php if ($new_thread_type == 'thread'): ?> selected="selected"<?php endif; ?>>Thread</option>
<?php foreach ($supported_threads as $type): ?>
<?php if ($type == 'folder'): ?>
<option value="folder"<?php if ($new_thread_type == 'folder'): ?> selected="selected"<?php endif; ?>>Folder</option>
<?php elseif ($type == 'story'): ?>
<option value="story"<?php if ($new_thread_type == 'story'): ?> selected="selected"<?php endif; ?>>Article</option>
<?php elseif ($type == 'book'): ?>
<option value="book"<?php if ($new_thread_type == 'book'): ?> selected="selected"<?php endif; ?>>Manual</option>
<?php elseif ($type == 'rss'): ?>
<option value="rss"<?php if ($new_thread_type == 'rss'): ?> selected="selected"<?php endif; ?>>RSS</option>
<?php elseif ($type == 'newsletter'): ?>
<option value="newsletter"<?php if ($new_thread_type == 'newsletter'): ?> selected="selected"<?php endif; ?>>Newsletter</option>
<?php elseif ($type == 'campaign'): ?>
<option value="campaign"<?php if ($new_thread_type == 'campaign'): ?> selected="selected"<?php endif; ?>>Campaign</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
</span>
</p>
<?php if ($thread_list): ?>
<fieldset class="block">
<legend>Catalog</legend>
<table cellpadding="2" cellspacing="0">
<tbody>
<?php
$i=1;
foreach ($thread_list as $tr) {
	extract($tr);	/* pos, thread_id, thread_title, thread_number, thread_url */
	$thread_url .= '?' . 'clang=' . $clang;
?>
<tr>
<td><input name="p[<?php echo $i; ?>]" type="text" size="2" maxlength="3" value="<?php echo $pos; ?>" /></td>
<td><a href="<?php echo $thread_url; ?>" title="<?php echo $thread_id; ?>"><?php echo $thread_title ? htmlspecialchars($thread_title, ENT_COMPAT, 'UTF-8') : $thread_id; ?></a></td>
</tr>
<?php
	$i++;
}
?>
</tbody>
</table>
</fieldset>
<p>
<input class="submit submit submit_sort" id="threadlist_reorder" name="threadlist_reorder" type="submit" value="Sort" />
contents or
<input class="submit submit submit_delete" id="thread_delete" name="thread_delete" type="submit" value="Delete" />
thread
<span class="nowrap">
#
<input id="old_thread_number" name="old_thread_number" type="text" size="2" maxlength="3" value="<?php echo htmlspecialchars($old_thread_number, ENT_COMPAT, 'UTF-8'); ?>" title="Number" onkeypress="return submitonenter(event, 'thread_delete')"/>
</span>
<?php if ($confirm_delete_thread): ?>
<input class="submit submit submit_confirm" id="thread_confirmdelete" name="thread_confirmdelete" type="submit" value="Confirm" />
<?php endif; ?>
</p>
<?php endif; ?>
</form>
<?php
$focus=false;
if ($missing_new_thread_title or $missing_new_thread_name or $bad_new_thread_name) {
	 $focus='#new_thread_title';
}
else if ($bad_new_thread_number) {
	$focus='#new_thread_number';
}
else if ($missing_old_thread_number or $bad_old_thread_number) {
	$focus='#old_thread_number';
}
else if ($confirm_delete_thread) {
	$focus='#old_thread_number';
}
?>
<?php if ($focus): ?>
<?php head('javascript', 'jquery.scrollTo', 'screen'); ?>
<script type="text/javascript">
$(function() {$('<?php echo $focus; ?>').focus(); $.scrollTo('<?php echo $focus; ?>', {offset: -200}); });
</script>
<?php endif; ?>
