<div class="mod_news_img">
    <h2><?php echo $MOD_NEWS_IMG['SETTINGS']; ?></h2>
    <form name="modify_mode" action="<?php echo WB_URL; ?>/modules/news_img/save_settings.php" method="post">
        <?php echo $FTAN; ?>
        <input type="hidden" name="section_id" value="<?php echo $section_id; ?>" />
    	<input type="hidden" name="page_id" value="<?php echo $page_id; ?>" />
<?php if($settings['mode']=='advanced'): ?>
        <input type="hidden" name="mode" value="default" />
<?php else: ?>
        <input type="hidden" name="mode" value="advanced" />
<?php endif; ?>
        <?php echo $MOD_NEWS_IMG['EXPERT_MODE'] ?>
        <label class="switch">
          <input id="toggle_mode" type="checkbox"<?php if($settings['mode']=='advanced'): ?> checked="checked"<?php endif; ?>/>
          <span class="slider round"></span>
        </label>
    </form>

    <form name="modify" action="<?php echo WB_URL; ?>/modules/news_img/save_settings.php" method="post" style="margin: 0;">
        <?php echo $FTAN; ?>
    	<input type="hidden" name="section_id" value="<?php echo $section_id; ?>" />
    	<input type="hidden" name="page_id" value="<?php echo $page_id; ?>" />
    	<table>
            <thead>
                <tr><th colspan="2"><?php echo $MOD_NEWS_IMG['OVERVIEW_SETTINGS']?></th></tr>
            </thead>
            <tbody>
				<tr>
				<td class="setting_name" colspan="2"><?php echo $MOD_NEWS_IMG['SHOW_SETTINGS_ONLY_ADMINS']; ?>:
				
				<input type="checkbox" name="show_settings_only_admins" VALUE="Y"<?php if($settings['show_settings_only_admins']=='Y'): ?> checked="checked"<?php endif; ?> />
                        <?php echo $TEXT['YES'] ?>
				</td>
				</tr>
        		<tr>
        			<td class="setting_name"><?php echo $MOD_NEWS_IMG['ORDERBY']; ?>:</td>
        			<td class="setting_value">
        				<select name="view_order" style="width: 98%;">
        					<?php
						echo '<option value="0"'.(($settings['view_order'] == 0)?' selected="selected"':'').'>'.$TEXT['CUSTOM'].'</option>';
						echo '<option value="1"'.(($settings['view_order'] == 1)?' selected="selected"':'').'>'.$TEXT['PUBL_START_DATE'].' ('.$MOD_NEWS_IMG['DESCENDING'].' = '.$MOD_NEWS_IMG['NEWEST_FIRST'].')</option>';
						echo '<option value="2"'.(($settings['view_order'] == 2)?' selected="selected"':'').'>'.$TEXT['PUBL_END_DATE'].' ('.$MOD_NEWS_IMG['DESCENDING'].' = '.$MOD_NEWS_IMG['FIRST_EXPIRING_LAST'].')</option>';
						echo '<option value="3"'.(($settings['view_order'] == 3)?' selected="selected"':'').'>'.$TEXT['SUBMITTED'].' ('.$MOD_NEWS_IMG['DESCENDING'].' = '.$MOD_NEWS_IMG['NEWEST_FIRST'].')</option>';
						echo '<option value="4"'.(($settings['view_order'] == 4)?' selected="selected"':'').'>'.$TEXT['SUBMISSION_ID'].' ('.$MOD_NEWS_IMG['DESCENDING'].' = '.$MOD_NEWS_IMG['NEWEST_FIRST'].')</option>';
						echo '<option value="5"'.(($settings['view_order'] == 5)?' selected="selected"':'').'>'.$TEXT['PUBL_END_DATE'].' ('.$MOD_NEWS_IMG['FIRST_EXPIRING_FIRST'].')</option>';
        					?>
        				</select>
        			</td>
        		</tr>
        		<tr>
        			<td class="setting_name"><?php echo $TEXT['POSTS_PER_PAGE']; ?>:</td>
        			<td class="setting_value">
        				<select name="posts_per_page" style="width: 98%;">
        					<option value=""><?php echo $TEXT['UNLIMITED']; ?></option>
        					<?php
        					for($i = 1; $i <= 20; $i++) {
        						if($settings['posts_per_page'] == ($i*5)) { $selected = ' selected="selected"'; } else { $selected = ''; }
        						echo '<option value="'.($i*5).'"'.$selected.'>'.($i*5).'</option>';
        					}
        					?>
        				</select>
        			</td>
        		</tr>
	           	<tr>
        			<td class="setting_name"><?php echo $TEXT['HEADER']; ?>:</td>
        			<td class="setting_value">
        				<textarea name="header" rows="10" cols="1" style="width: 98%; height: 80px;"><?php echo ($settings['header']); ?></textarea>
        			</td>
        		</tr>
        		<tr>
        			<td class="setting_name"><?php echo $TEXT['POST'].' '.$TEXT['LOOP']; ?>:</td>
        			<td class="setting_value">
        				<textarea name="post_loop" rows="10" cols="1" style="width: 98%; height: 60px;"><?php echo ($settings['post_loop']); ?></textarea>
        			</td>
        		</tr>
        		<tr>
        			<td class="setting_name"><?php echo $TEXT['FOOTER']; ?>:</td>
        			<td class="setting_value">
        				<textarea name="footer" rows="10" cols="1" style="width: 98%; height: 80px;"><?php echo str_replace($raw, $friendly, ($settings['footer'])); ?></textarea>
        			</td>
        		</tr>
<?php if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg')): ?>
                <tr>
        			<td class="setting_name"><?php echo $MOD_NEWS_IMG['RESIZE_PREVIEW_IMAGE_TO']; ?>:</td>
        			<td class="setting_value">
                        <label for="resize_width"><?php echo $TEXT['WIDTH'] ?></label>
                            <input type="text" maxlength="4" name="resize_width" id="resize_width" style="width:80px" value="<?php echo $previewwidth ?>" /> x
                        <label for="resize_height"><?php echo $TEXT['HEIGHT'] ?></label>
                            <input type="text" maxlength="4" name="resize_height" id="resize_height" style="width:80px" value="<?php echo $previewheight ?>" /> Pixel<br />
                            <span title="<?php echo $MOD_NEWS_IMG['TEXT_DEFAULTS_CLICK']; ?>"><?php echo $MOD_NEWS_IMG['TEXT_DEFAULTS'] ?>:&nbsp;
<?php
					foreach($SIZES AS $size => $size_name) {
						echo '[<span class="resize_defaults" data-value="'.$size.'">'.$size_name.'</span>] ';
					}
?>
        				  </span>
        			</td>
        		</tr>
<?php endif; ?>
            </tbody>
            <thead>
        		<tr><th colspan="2"><?php echo $MOD_NEWS_IMG['POST_SETTINGS']?></th></tr>
            </thead>
            <tbody>
        		<tr>
        			<td class="setting_name"><?php echo $TEXT['POST_HEADER']; ?>:</td>
        			<td class="setting_value">
        				<textarea name="post_header" rows="10" cols="1" style="width: 98%; height: 60px;"><?php echo str_replace($raw, $friendly, ($settings['post_header'])); ?></textarea>
        			</td>
        		</tr>
                <tr>
        			<td class="setting_name"><?php echo $MOD_NEWS_IMG['POST_CONTENT']; ?>:</td>
        			<td class="setting_value">
        				<textarea name="post_content" rows="10" cols="1" style="width: 98%; height: 60px;"><?php echo str_replace($raw, $friendly, ($settings['post_content'])); ?></textarea>
        			</td>
        		</tr>
        		<tr>
        			<td class="setting_name"><?php echo $TEXT['POST_FOOTER']; ?>:</td>
        			<td class="setting_value">
        				<textarea name="post_footer" rows="10" cols="1" style="width: 98%; height: 60px;"><?php echo str_replace($raw, $friendly, ($settings['post_footer'])); ?></textarea>
        			</td>
        		</tr>
<?php if($settings['mode']=='advanced'): ?>
                <tr>
        			<td class="setting_name"><?php echo $MOD_NEWS_IMG['USE_SECOND_BLOCK']; ?>:</td>
        			<td class="setting_value">
        				<input type="checkbox" name="use_second_block" VALUE="Y"<?php if($settings['use_second_block']=='Y'): ?> checked="checked"<?php endif; ?> />
                        <?php echo $TEXT['YES'] ?> <i>(<?php echo $MOD_NEWS_IMG['USE_SECOND_BLOCK_HINT'] ?>)</i>
        			</td>
        		</tr>
        		<tr class="nwi_use_second_block"<?php if($settings['use_second_block']!='Y'): ?> style="display:none"<?php endif; ?>>
        			<td class="setting_name"><?php echo $TEXT['BLOCK']; ?> 2:</td>
        			<td class="setting_value">
        				<textarea name="block2" rows="10" cols="1" style="width: 98%; height: 80px;"><?php echo str_replace($raw, $friendly, ($settings['block2'])); ?></textarea>
        			</td>
        		</tr>
<?php endif; ?>
            </tbody>
            <thead>
                <tr><th colspan="2"><?php echo $MOD_NEWS_IMG['GALLERY_SETTINGS']?></th></tr>
            </thead>
            <tbody>
                <tr>
        			<td class="setting_name"><?php echo $MOD_NEWS_IMG['GALLERY'] ?>:</td>
        			<td class="setting_value">
                        <select name="gallery" style="width: 98%;" onfocus="this.setAttribute('PrvSelectedValue',this.value);" onchange="if(confirm('<?php echo $MOD_NEWS_IMG['GALLERY_WARNING']?>')==false){ this.value=this.getAttribute('PrvSelectedValue');return false; }" >
                            <option value="fotorama"<?php if($settings['gallery']=='fotorama'): ?> selected="selected"<?php endif; ?>>Fotorama</option>
                            <option value="masonry"<?php if($settings['gallery']=='masonry'): ?> selected="selected"<?php endif; ?>>Masonry</option>
							<option value="lightcase" <?php if($settings['gallery']=='lightcase'): ?> selected="selected"<?php endif; ?>>Lightcase</option>
        					<option value="none"<?php if($settings['gallery']=='none'): ?> selected="selected"<?php endif; ?>><?php echo $MOD_NEWS_IMG['NONE'] ?></option>
                        </select>
        			</td>
        		</tr>
<?php if($settings['mode']=='advanced'): ?>
        		<tr>
                    <td></td>
                    <td><i><?php echo $MOD_NEWS_IMG['GALLERY_INFO'] ?></i></td>
                </tr>
        		<tr>
        			<td class="setting_name"><?php echo $TEXT['IMAGE'].' '.$TEXT['LOOP']; ?>:</td>
        			<td class="setting_value">
        				<textarea name="image_loop" rows="10" cols="1" style="width: 98%; height: 60px;"><?php echo str_replace($raw, $friendly, ($settings['image_loop'])); ?></textarea>
        			</td>
        		</tr>
                <tr>
        			<td class="setting_name"><?php echo $MOD_NEWS_IMG['IMAGE_MAX_SIZE']; ?>:</td>
        			<td class="setting_value">
                        <input type="text" name="gal_img_max_size" value="<?php echo intval($settings['imgmaxsize'])/1024 ?>" />
        			</td>
        		</tr>
<?php if(extension_loaded('gd') AND function_exists('imageCreateFromJpeg')): ?>
                <tr>
        			<td class="setting_name"><?php echo $MOD_NEWS_IMG['RESIZE_GALLERY_IMAGES_TO']; ?>:</td>
        			<td class="setting_value">
                        <label for="gal_img_resize_width"><?php echo $TEXT['WIDTH'] ?></label>
                            <input type="text" maxlength="4" name="gal_img_resize_width" id="gal_img_resize_width" style="width:80px" value="<?php echo $settings['imgmaxwidth'] ?>" /> x
                        <label for="gal_img_resize_height"><?php echo $TEXT['HEIGHT'] ?></label>
                            <input type="text" maxlength="4" name="gal_img_resize_height" id="gal_img_resize_height" style="width:80px" value="<?php echo $settings['imgmaxheight'] ?>" /> Pixel
        			</td>
        		</tr>
                <tr>
        			<td class="setting_name"><?php echo $MOD_NEWS_IMG['THUMB_SIZE']; ?>:</td>
        			<td class="setting_value">
                        <label for="thumb_width"><?php echo $TEXT['WIDTH'] ?></label>
                            <input type="text" maxlength="4" name="thumb_width" id="thumb_width" style="width:80px" value="<?php echo $thumbwidth ?>" /> x
                        <label for="thumb_height"><?php echo $TEXT['HEIGHT'] ?></label>
                            <input type="text" maxlength="4" name="thumb_height" id="thumb_height" style="width:80px" value="<?php echo $thumbheight ?>" /> Pixel <br />
                            <span title="<?php echo $MOD_NEWS_IMG['TEXT_DEFAULTS_CLICK']; ?>"><?php echo $MOD_NEWS_IMG['TEXT_DEFAULTS'] ?>:&nbsp;
<?php
					foreach($SIZES AS $size => $size_name) {
						echo '[<span class="resize_defaults_thumb" data-value="'.$size.'">'.$size_name.'</span>] ';
					}
?>
        				  </span>
        			</td>
        		</tr>
                <tr>
                    <td class="setting_name"><?php echo $MOD_NEWS_IMG['CROP']; ?>:</td>
        			<td class="setting_value">
                        <label for="crop_preview"><input type="checkbox" name="crop_preview" id="crop_preview"<?php if($settings['crop_preview']=='Y'):?> checked="checked"<?php endif; ?> title="<?php echo $MOD_NEWS_IMG['TEXT_CROP'] ?>" /> <?php echo $MOD_NEWS_IMG['CROP'] ?></label><br />
                        <i><?php echo $MOD_NEWS_IMG['TEXT_CROP']; ?></i>
                </tr>
<?php else: ?>
                <tr>
                    <td></td>
                    <td><span style="color: #c00 !important"><?php echo $MOD_NEWS_IMG['MISSING_GD'] ?></span></td>
                </tr>
<?php endif; endif; ?>
            </tbody>
<?php if($settings['mode']=='advanced'): ?>
            <thead>
        		<tr><th colspan="2"><?php echo $MOD_NEWS_IMG['ADVANCED_SETTINGS']?></th></tr>
            </thead>
            <tbody>
                <tr>
        			<td class="setting_name"><?php echo $MOD_NEWS_IMG['VIEW']; ?>:</td>
        			<td class="setting_value">
        				<select name="view" style="width: 98%;">
<?php if(is_array($views)): foreach(array_values($views) as $v): ?>
                            <option value="<?php echo $v ?>"<?php if($settings['view']==$v): ?> selected="selected"<?php endif; ?>><?php echo $v ?></option>
<?php endforeach; endif; ?>
        				</select>
        			</td>
        		</tr>
                <tr>
                    <td></td>
                    <td><i><?php echo $MOD_NEWS_IMG['VIEW_INFO'] ?></i></td>
                </tr>
            </tbody>
<?php endif; ?>
	    </table>
    	<table>
    		<tr>
    			<td>
    				<input name="save" type="submit" value="<?php echo $TEXT['SAVE']; ?>" style="width: 100px; margin-top: 5px;" />
    			</td>
    			<td style="text-align:right">
    				<input type="button" value="<?php echo $TEXT['CANCEL']; ?>" onclick="javascript: window.location = '<?php echo ADMIN_URL; ?>/pages/modify.php?page_id=<?php echo $page_id; ?>';" style="width: 100px; margin-top: 5px;" />
    			</td>
    		</tr>
    	</table>
    </form>
</div>
