<?php

/**
 *
 * @copyright  2010-2015 izend.org
 * @version    20
 * @link       http://www.izend.org
 */
?>
<?php if($content_types or $node_contents): ?>
<?php extract($errors); ?>
<form action="" method="post">
<input name="clang" type="hidden" value="<?php echo $clang; ?>" />
<p>
<?php if ($content_types) :?>
<input class="submit submit_add" id="content_create" name="content_create" type="submit" value="Ajouter" />
un type
<?php
$selected=$new_content_type ? $new_content_type : $content_types[0];
?>
<select id="content_new_type" name="content_new_type" size="1">
<?php foreach ($content_types as $type): ?>
<?php if ($type == 'text'): ?>
<option value="text" <?php echo $selected == 'text' ? 'selected="selected"' : ''; ?>>Texte</option>
<?php elseif ($type == 'infile'): ?>
<option value="infile" <?php echo $selected == 'infile' ? 'selected="selected"' : ''; ?>>Insertion</option>
<?php elseif ($type == 'download'): ?>
<option value="download" <?php echo $selected == 'download' ? 'selected="selected"' : ''; ?>>Téléchargement</option>
<?php elseif ($type == 'file'): ?>
<option value="file" <?php echo $selected == 'file' ? 'selected="selected"' : ''; ?>>Fichier</option>
<?php elseif ($type == 'youtube'): ?>
<option value="youtube" <?php echo $selected == 'youtube' ? 'selected="youtube"' : ''; ?>>YouTube</option>
<?php elseif ($type == 'longtail'): ?>
<option value="longtail" <?php echo $selected == 'longtail' ? 'selected="selected"' : ''; ?>>LongTail</option>
<?php elseif ($type == 'sms'): ?>
<option value="sms" <?php echo $selected == 'sms' ? 'selected="selected"' : ''; ?>>SMS</option>
<?php endif; ?>
<?php endforeach; ?>
</select>
<span class="nowrap">
#
<input id="content_new_number" name="content_new_number" type="text" size="2" maxlength="3" value="<?php echo htmlspecialchars($new_content_number, ENT_COMPAT, 'UTF-8'); ?>" title="Numéro"/>
</span>
<?php endif; ?>
<?php if ($node_contents): ?>
<?php if ($content_types) :?>
ou
<?php endif; ?>
<input class="submit submit_delete" id="content_delete" name="content_delete" type="submit" value="Supprimer" />
le
<span class="nowrap">
#
<input id="content_old_number" name="content_old_number" type="text" size="2" maxlength="3" value="<?php echo htmlspecialchars($old_content_number, ENT_COMPAT, 'UTF-8'); ?>" title="Numéro"/>
</span>
<?php endif; ?>
<span id="nodecontent_hidy" class="hidy">+</span>
</p>
<?php if ($node_contents): ?>
<div id="nodecontent">
<?php
$i=1;
foreach ($node_contents as $c) {
	$content_text_text='';
	$content_text_eval=false;
	$content_infile_path=false;
	$content_download_name=$content_download_path=false;
	$content_file_path=$content_file_format=$content_file_lineno=false;
	$content_file_start=$content_file_end=0;
	$content_youtube_id=false;
	$content_youtube_width=$content_youtube_height=0;
	$content_youtube_miniature=$content_youtube_title=false;
	$content_youtube_autoplay=$content_youtube_controls=$content_youtube_fs=$content_youtube_rel=false;
	$content_longtail_file=$content_longtail_image=false;
	$content_longtail_width=$content_longtail_height=0;
	$content_longtail_skin=false;
	$content_longtail_controlbar='none';
	$content_longtail_icons=false;
	$content_longtail_duration=0;
	$content_longtail_autostart=$content_longtail_repeat=false;
	$content_sms_text='';
	extract($c);	/* content_id content_number content_ignored content_type ... */
?>
<p class="<?php echo $content_ignored ? 'ignored' : (($i % 2) ? 'odd' : 'even'); ?>">
<input name="content_id[<?php echo $i; ?>]" type="hidden" value="<?php echo $content_id; ?>"/>
<input name="content_p[<?php echo $i; ?>]" type="text" size="2" maxlength="3" value="<?php echo htmlspecialchars($content_pos, ENT_COMPAT, 'UTF-8'); ?>"/>
<input id="content_ignored[<?php echo $i; ?>]" name="content_ignored[<?php echo $i; ?>]" type="checkbox"<?php if ($content_ignored): ?> checked="checked"<?php endif; ?> /><label for="content_ignored[<?php echo $i; ?>]"><span class="btn_edit btn_ignored">ignoré</span></label>
<?php switch ($content_type): ?>
<?php case 'text': ?>
<label>Texte&nbsp;:</label>
<?php break; ?>
<?php case 'infile': ?>
<label>Insertion&nbsp;:</label>
<?php break; ?>
<?php case 'download': ?>
<label>Téléchargement&nbsp;:</label>
<?php break; ?>
<?php case 'file': ?>
<label>Fichier&nbsp;:</label>
<?php break; ?>
<?php case 'youtube': ?>
<label>YouTube&nbsp;:</label>
<?php break; ?>
<?php case 'longtail': ?>
<label>LongTail&nbsp;:</label>
<?php break; ?>
<?php case 'sms': ?>
<label>SMS&nbsp;:</label>
<?php break; ?>
<?php endswitch; ?>
</p>
<?php switch ($content_type): ?>
<?php case 'text': ?>
<div class="tagbar">
<span class="btn_edit btn_p" title="p" onclick="addtag('content_text_text_<?php echo $i; ?>', '&lt;p&gt;','&lt;/p&gt;')">&lt;p&gt;</span>
<span class="btn_edit btn_b" title="b" onclick="addtag('content_text_text_<?php echo $i; ?>', '&lt;b&gt;','&lt;/b&gt;')">&lt;b&gt;</span>
<span class="btn_edit btn_i" title="i" onclick="addtag('content_text_text_<?php echo $i; ?>', '&lt;i&gt;','&lt;/i&gt;')">&lt;i&gt;</span>
<span class="btn_edit btn_u" title="u" onclick="addtag('content_text_text_<?php echo $i; ?>', '&lt;u&gt;','&lt;/u&gt;')">&lt;u&gt;</span>
<span class="btn_edit btn_s" title="s" onclick="addtag('content_text_text_<?php echo $i; ?>', '&lt;s&gt;','&lt;/s&gt;')">&lt;s&gt;</span>
<span class="btn_edit btn_h4" title="h4" onclick="addtag('content_text_text_<?php echo $i; ?>', '&lt;h4&gt;','&lt;/h4&gt;')">&lt;h4&gt;</span>
<span class="btn_edit btn_h5" title="h5" onclick="addtag('content_text_text_<?php echo $i; ?>', '&lt;h5&gt;','&lt;/h5&gt;')">&lt;h5&gt;</span>
<span class="btn_edit btn_h6" title="h6" onclick="addtag('content_text_text_<?php echo $i; ?>', '&lt;h6&gt;','&lt;/h6&gt;')">&lt;h6&gt;</span>
<span class="btn_edit btn_br" title="br" onclick="addtag('content_text_text_<?php echo $i; ?>', '','&lt;br /&gt;\n')">&lt;br /&gt;</span>
<span class="btn_edit btn_ol" title="ol" onclick="addtag('content_text_text_<?php echo $i; ?>', '','&lt;ol&gt;\n&lt;li&gt;&lt;/li&gt;\n&lt;/ol&gt;\n')">&lt;ol&gt;</span>
<span class="btn_edit btn_ul" title="ul" onclick="addtag('content_text_text_<?php echo $i; ?>', '','&lt;ul&gt;\n&lt;li&gt;&lt;/li&gt;\n&lt;/ul&gt;\n')">&lt;ul&gt;</span>
<span class="btn_edit btn_table" title="table" onclick="addtag('content_text_text_<?php echo $i; ?>', '','&lt;table&gt;\n&lt;tbody&gt;\n&lt;tr&gt;\n&lt;td&gt;&lt;/td&gt;\n&lt;/tr&gt;\n&lt;/tbody&gt;\n&lt;/table&gt;\n')">&lt;table&gt;</span>
<span class="btn_edit btn_code" title="code" onclick="addtag('content_text_text_<?php echo $i; ?>', '&lt;code&gt;','&lt;/code&gt;')">&lt;code&gt;</span>
<span class="btn_edit btn_precode" title="pre code" onclick="addtag('content_text_text_<?php echo $i; ?>', '&lt;pre&gt;&lt;code&gt;','&lt;/code&gt;&lt;/pre&gt;')">&lt;pre&gt;&lt;code&gt;</span>
<span class="btn_edit btn_blockquote" title="blockquote" onclick="addtag('content_text_text_<?php echo $i; ?>', '&lt;blockquote&gt;','&lt;/blockquote&gt;')">&lt;blockquote&gt;</span>
<span class="btn_edit btn_img" title="img" onclick="addtag('content_text_text_<?php echo $i; ?>', '&lt;img src=\x22','\x22 alt=\x22\x22 title=\x22\x22 /&gt;')">&lt;img&gt;</span>
<span class="btn_edit btn_a" title="a" onclick="addtag('content_text_text_<?php echo $i; ?>', '&lt;a href=\x22#\x22&gt;','&lt;/a&gt;')">&lt;a&gt;</span>
<span class="btn_edit btn_entquote" title="entquote" onclick="entquote('content_text_text_<?php echo $i; ?>')">entquote</span>
<span class="btn_edit btn_striptags" title="striptags" onclick="striptags('content_text_text_<?php echo $i; ?>')">striptags</span>
<span class="tagmore">
<input id="content_text_eval[<?php echo $i; ?>]" name="content_text_eval[<?php echo $i; ?>]" type="checkbox"<?php if ($content_text_eval): ?> checked="checked"<?php endif; ?> /><label for="content_text_eval[<?php echo $i; ?>]"><span class="btn_edit btn_seval" title="seval">PHP</span></label>
</span>
</div>
<textarea id="content_text_text_<?php echo $i; ?>" name="content_text_text[<?php echo $i; ?>]" cols="100" rows="8"><?php echo htmlspecialchars($content_text_text, ENT_COMPAT, 'UTF-8'); ?></textarea>
<br/><span class="grippie btn_edit btn_grippie">===</span>
<?php break; ?>
<?php case 'infile': ?>
<p>
<input name="content_infile_path[<?php echo $i; ?>]" type="text" size="40" maxlength="200" value="<?php echo htmlspecialchars($content_infile_path, ENT_COMPAT, 'UTF-8'); ?>" title="Fichier" />
</p>
<?php break; ?>
<?php case 'download': ?>
<p>
<input name="content_download_name[<?php echo $i; ?>]" type="text" size="20" maxlength="50" value="<?php echo htmlspecialchars($content_download_name, ENT_COMPAT, 'UTF-8'); ?>" title="Nom" />
<input name="content_download_path[<?php echo $i; ?>]" type="text" size="40" maxlength="200" value="<?php echo htmlspecialchars($content_download_path, ENT_COMPAT, 'UTF-8'); ?>" title="Fichier" />
</p>
<?php break; ?>
<?php case 'file': ?>
<p>
<input name="content_file_path[<?php echo $i; ?>]" type="text" size="40" maxlength="200" value="<?php echo htmlspecialchars($content_file_path, ENT_COMPAT, 'UTF-8'); ?>" title="Fichier" />
<input name="content_file_start[<?php echo $i; ?>]" type="text" size="5" maxlength="5" value="<?php echo htmlspecialchars($content_file_start, ENT_COMPAT, 'UTF-8'); ?>" title="Début" />
<input name="content_file_end[<?php echo $i; ?>]" type="text" size="5" maxlength="5" value="<?php echo htmlspecialchars($content_file_end, ENT_COMPAT, 'UTF-8'); ?>" title="Fin" />
<input name="content_file_format[<?php echo $i; ?>]" type="text" size="10" maxlength="20" value="<?php echo htmlspecialchars($content_file_format, ENT_COMPAT, 'UTF-8'); ?>" title="Format" />
<input id="content_file_lineno[<?php echo $i; ?>]" name="content_file_lineno[<?php echo $i; ?>]" type="checkbox"<?php if ($content_file_lineno): ?> checked="checked"<?php endif; ?> /><label for="content_file_lineno[<?php echo $i; ?>]"><span class="btn_edit btn_number" title="Numéroter">numéroter</span></label>
</p>
<?php break; ?>
<?php case 'youtube': ?>
<p>
<input name="content_youtube_id[<?php echo $i; ?>]" type="text" size="11" maxlength="20" value="<?php echo htmlspecialchars($content_youtube_id, ENT_COMPAT, 'UTF-8'); ?>" title="Id" />
<input name="content_youtube_width[<?php echo $i; ?>]" type="text" size="5" maxlength="5" value="<?php echo htmlspecialchars($content_youtube_width, ENT_COMPAT, 'UTF-8'); ?>" title="Largeur" />
x
<input name="content_youtube_height[<?php echo $i; ?>]" type="text" size="5" maxlength="5" value="<?php echo htmlspecialchars($content_youtube_height, ENT_COMPAT, 'UTF-8'); ?>" title="Hauteur" />
<input id="content_youtube_autoplay[<?php echo $i; ?>]" name="content_youtube_autoplay[<?php echo $i; ?>]" type="checkbox"<?php if ($content_youtube_autoplay): ?> checked="checked"<?php endif; ?> /><label for="content_youtube_autoplay[<?php echo $i; ?>]"><span class="btn_edit btn_autoplay" title="Auto">auto</span></label>
<select name="content_youtube_theme[<?php echo $i; ?>]" title="Thème">
<?php foreach (array('dark' => 'sombre', 'light' => 'clair') as $tm => $ts): ?>
<option value="<?php echo $tm; ?>"<?php if ($content_youtube_theme == $tm) : ?> selected="selected"<?php endif; ?>><?php echo $ts; ?></option>
<?php endforeach; ?>
</select>
<input id="content_youtube_controls[<?php echo $i; ?>]" name="content_youtube_controls[<?php echo $i; ?>]" type="checkbox"<?php if ($content_youtube_controls): ?> checked="checked"<?php endif; ?> /><label for="content_youtube_controls[<?php echo $i; ?>]"><span class="btn_edit btn_controls" title="Contrôles">contrôles</span></label>
<input id="content_youtube_fs[<?php echo $i; ?>]" name="content_youtube_fs[<?php echo $i; ?>]" type="checkbox"<?php if ($content_youtube_fs): ?> checked="checked"<?php endif; ?> /><label for="content_youtube_fs[<?php echo $i; ?>]"><span class="btn_edit btn_fs" title="Plein écran">fs</span></label>
<input id="content_youtube_rel[<?php echo $i; ?>]" name="content_youtube_rel[<?php echo $i; ?>]" type="checkbox"<?php if ($content_youtube_rel): ?> checked="checked"<?php endif; ?> /><label for="content_youtube_rel[<?php echo $i; ?>]"><span class="btn_edit btn_rel" title="Liens">liens</span></label>
</p>
<p>
<input name="content_youtube_miniature[<?php echo $i; ?>]" type="text" size="40" maxlength="200" value="<?php echo htmlspecialchars($content_youtube_miniature, ENT_COMPAT, 'UTF-8'); ?>" title="Miniature" />
<input name="content_youtube_title[<?php echo $i; ?>]" type="text" size="40" maxlength="200" value="<?php echo htmlspecialchars($content_youtube_title, ENT_COMPAT, 'UTF-8'); ?>" title="Titre" />
</p>
<?php break; ?>
<?php case 'longtail': ?>
<p>
<input name="content_longtail_file[<?php echo $i; ?>]" type="text" size="40" maxlength="200" value="<?php echo htmlspecialchars($content_longtail_file, ENT_COMPAT, 'UTF-8'); ?>" title="Fichier" />
<input name="content_longtail_width[<?php echo $i; ?>]" type="text" size="5" maxlength="5" value="<?php echo htmlspecialchars($content_longtail_width, ENT_COMPAT, 'UTF-8'); ?>" title="Largeur" />
x
<input name="content_longtail_height[<?php echo $i; ?>]" type="text" size="5" maxlength="5" value="<?php echo htmlspecialchars($content_longtail_height, ENT_COMPAT, 'UTF-8'); ?>" title="Hauteur" />
<span class="btn_edit btn_time">Durée :</span>
<input name="content_longtail_duration[<?php echo $i; ?>]" type="text" size="5" maxlength="5" value="<?php echo htmlspecialchars($content_longtail_duration, ENT_COMPAT, 'UTF-8'); ?>" title="Durée" />
<input id="content_longtail_autostart[<?php echo $i; ?>]" name="content_longtail_autostart[<?php echo $i; ?>]" type="checkbox"<?php if ($content_longtail_autostart): ?> checked="checked"<?php endif; ?> /><label for="content_longtail_autostart[<?php echo $i; ?>]"><span class="btn_edit btn_autostart" title="Auto">auto</span></label><input id="content_longtail_repeat[<?php echo $i; ?>]" name="content_longtail_repeat[<?php echo $i; ?>]" type="checkbox"<?php if ($content_longtail_repeat): ?> checked="checked"<?php endif; ?> /><label for="content_longtail_repeat[<?php echo $i; ?>]"><span class="btn_edit btn_repeat" title="Boucle">boucle</span></label>
</p>
<p>
<input name="content_longtail_image[<?php echo $i; ?>]" type="text" size="40" maxlength="200" value="<?php echo htmlspecialchars($content_longtail_image, ENT_COMPAT, 'UTF-8'); ?>" title="Image" />
<input id="content_longtail_icons[<?php echo $i; ?>]" name="content_longtail_icons[<?php echo $i; ?>]" type="checkbox"<?php if ($content_longtail_icons): ?> checked="checked"<?php endif; ?> /><label for="content_longtail_icons[<?php echo $i; ?>]"><span class="btn_edit btn_playicon" title="Icônes">icônes</span></label>
</p>
<p>
<input name="content_longtail_skin[<?php echo $i; ?>]" type="text" size="40" maxlength="200" value="<?php echo htmlspecialchars($content_longtail_skin, ENT_COMPAT, 'UTF-8'); ?>" title="Habillage" />
<select name="content_longtail_controlbar[<?php echo $i; ?>]" title="Barre de contrôle">
<?php foreach (array('none' => 'aucune', 'over' => 'au dessus', 'top' => 'en haut', 'bottom' => 'en bas') as $cb => $tr): ?>
<option value="<?php echo $cb; ?>"<?php if ($content_longtail_controlbar == $cb) : ?> selected="selected"<?php endif; ?>><?php echo $tr; ?></option>
<?php endforeach; ?>
</select>
</p>
<?php break; ?>
<?php case 'sms': ?>
<p>
<textarea id="content_sms_text_<?php echo $i; ?>" name="content_sms_text[<?php echo $i; ?>]" cols="80" rows="5"><?php echo htmlspecialchars($content_sms_text, ENT_COMPAT, 'UTF-8'); ?></textarea>
<br/><span class="grippie btn_edit btn_grippie">===</span>
</p>
<?php break; ?>
<?php endswitch; ?>
<?php
	$i++;
}
?>
<p>
<input class="submit submit_modify" id="content_modify" name="content_modify" type="submit" value="Modifier" />
le contenu
</p>
</div>
<?php endif; ?>
</form>
<?php head('javascript', 'jquery.cookie'); ?>
<script type="text/javascript">
if ($.cookie('hidenodecontent') == 1) {
	$('#nodecontent').hide();
}
$('#nodecontent_hidy').click(function() {
	$('#nodecontent').toggle();
	$.cookie('hidenodecontent', $('#nodecontent').is(':hidden') ? 1 : 0, { path: '/' });
});
</script>
<?php
$focus=false;
if ($bad_new_content_number) {
	 $focus='#content_new_number';
}
else if ($missing_old_content_number or $bad_old_content_number) {
	 $focus='#content_old_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; ?>
<script type="text/javascript">
$(document).ready(function() {
	$('.grippie').each(function() {
		var grippie = $(this);
		var textarea = grippie.prev().prev();
		var offset;

		grippie.mousedown(startDrag);

	    function startDrag(e) {
	      offset = textarea.height() - e.pageY;
	      textarea.css('opacity', 0.25);
	      $(document).mousemove(performDrag).mouseup(endDrag);
	      return false;
	    }

	    function performDrag(e) {
	      textarea.height(Math.max(32, offset + e.pageY) + 'px');
	      return false;
	    }

	    function endDrag(e) {
	      $(document).unbind('mousemove', performDrag).unbind('mouseup', endDrag);
	      textarea.css('opacity', 1);
	    }
	});
});
</script>
<?php endif; ?>
