<div class="wrap">
    <div id="icon-options-general" class="icon32"><br /></div>
    <h2><?php echo __('Settings › WP-AutoSharePost', WP_AUTOSHAREPOST_DOMAIN) ?></h2>
    
    <?php if (isset($this->successMessage)): ?>
        <?php echo $this->wasp->viewHelperMessage($this->successMessage, NULL, CheckdomainWordpressBase::MESSAGE_UPDATED); ?>
    <?php endif; ?>
    
    <form method="post" target="_self" action="">
    
        <h3><?php echo __('General Settings', WP_AUTOSHAREPOST_DOMAIN) ?></h3>
        
        <table class="form-table">
            <tbody>
                <tr valign="top">
                    <th scope="row">
                        <label for=""><?php echo __('Enable WP-AutoSharePost', WP_AUTOSHAREPOST_DOMAIN) ?></label>
                    </th>
                    <td>
                        <input type="checkbox" value="1" name="autosharepost[enabled]"<?php echo ($this->autoEnabled == '1') ? ' checked="checked"' : '' ?> />
                    </td>
                </tr>
                <tr valign="top">
                    <th scope="row">
                        <label for="wasp-allowed-post-types"><?php echo __('Allowed Post Types', WP_AUTOSHAREPOST_DOMAIN) ?></label>
                    </th>
                    <td>
                    	<?php foreach(get_post_types(array('public' => TRUE)) as $key => $type): ?>
                    	    <label>
                    		    <input type="checkbox" name="autosharepost[post_types][<?php echo $key ?>]" value="<?php echo $type ?>" <?php echo (in_array($type, $this->postTypes)) ? 'checked="checked"' : '' ?> />
                    		    <?php echo $type; ?>
                    		</label>
                    	<?php endforeach; ?>
                    </td>
                </tr>
                <tr valign="top">
                    <th scope="row">
                        <label for="wasp-picture"><?php echo __('Picture to share', WP_AUTOSHAREPOST_DOMAIN) ?></label>
                    </th>
                    <td>
                        <select id="wasp-picture" name="autosharepost[picture]">
                        	<option value="none" <?php echo ($this->picture == 'none') ? 'selected="selected"' : '' ?>><?php echo __('None', WP_AUTOSHAREPOST_DOMAIN) ?></option>
                        	<option value="thumbnail" <?php echo ($this->picture == 'thumbnail') ? 'selected="selected"' : '' ?>><?php echo __('Thumbnail', WP_AUTOSHAREPOST_DOMAIN) ?></option>
                        	<option value="attachment" <?php echo ($this->picture == 'attachment') ? 'selected="selected"' : '' ?>><?php echo __('Attachment', WP_AUTOSHAREPOST_DOMAIN) ?></option>
                        </select>
                        <p>
                        	<?php echo __('If you want to submit status messages and attach a picture to them select the type of the picture here.', WP_AUTOSHAREPOST_DOMAIN) ?>
                        </p>
                    </td>
                </tr>
                <tr valign="top">
                    <th scope="row">
                        <label for="wasp-picture-size"><?php echo __('Size of the picture', WP_AUTOSHAREPOST_DOMAIN) ?></label>
                    </th>
                    <td>
                        <select id="wasp-picture-size" name="autosharepost[picture_size]">
                        	<?php foreach(get_intermediate_image_sizes() as $key => $size): ?>
                        		<option value="<?php echo $size ?>" <?php echo ($this->pictureSize == $size) ? 'selected="selected"' : '' ?>><?php echo $size; ?></option>
                        	<?php endforeach; ?>
                        </select>
                    </td>
                </tr>
            </tbody>
        </table>
        
        <h3><?php echo __('Facebook Settings', WP_AUTOSHAREPOST_DOMAIN) ?></h3>
        
        <?php if (isset($this->facebookError)): ?>
            <?php echo $this->wasp->viewHelperMessage($this->facebookError, __('Facebook Error', WP_AUTOSHAREPOST_DOMAIN)); ?>
        <?php endif; ?>
        
        <table class="form-table">
            <tbody>
                <tr valign="top">
                    <th scope="row">
                        <label for="wasp-fb-app-name"><?php echo __('User/App/Page Name', WP_AUTOSHAREPOST_DOMAIN) ?></label>
                    </th>
                    <td>
                        <input id="wasp-fb-app-name" type="text" class="regular-text code" value="<?php echo $this->facebookAppName ?>" name="autosharepost[facebook][app_name]" readonly="readonly" />
                    </td>
                </tr>
                <tr valign="top">
                    <th scope="row">
                        <label for="wasp-fb-app-id"><?php echo __('App ID', WP_AUTOSHAREPOST_DOMAIN) ?></label>
                    </th>
                    <td>
                        <input id="wasp-fb-app-id" type="text" class="regular-text code" value="<?php echo $this->facebookAppId ?>" name="autosharepost[facebook][app_id]" />
                    </td>
                </tr>
                <tr valign="top">
                    <th scope="row">
                        <label for="wasp-fb-app-secret"><?php echo __('App Secret', WP_AUTOSHAREPOST_DOMAIN) ?></label>
                    </th>
                    <td>
                        <input id="wasp-fb-app-secret" type="text" class="regular-text code" value="<?php echo $this->facebookAppSecret ?>" name="autosharepost[facebook][app_secret]" />
                    </td>
                </tr>
                <tr valign="top">
                    <th scope="row">
                        <label for="wasp-fb-page-id"><?php echo __('Page ID', WP_AUTOSHAREPOST_DOMAIN) ?></label>
                    </th>
                    <td>
                        <input id="wasp-fb-page-id" type="text" class="regular-text code" value="<?php echo $this->facebookPageId ?>" name="autosharepost[facebook][page_id]" />
                        <br />
                        <?php echo __('<strong>Optional</strong> Only if you want to manage a page'); ?>
                    </td>
                </tr>
                <tr valign="top">
                    <th scope="row">
                        <label for="wasp-fb-token"><?php echo __('Token', WP_AUTOSHAREPOST_DOMAIN) ?></label>
                    </th>
                    <td>
                        <input id="wasp-fb-token" type="text" class="large-text code" value="<?php echo $this->facebookAccessToken ?>" name="autosharepost[facebook][access_token]" readonly="readonly" />
                        <?php if (isset($this->facebookLogin)): ?>
	                        <br />
	                        <a href="<?php echo $this->facebookLogin; ?>"><?php echo __('Request Facebook Access-Token', WP_AUTOSHAREPOST_DOMAIN) ?></a>
	                    <?php else: ?>
	                    	<strong><?php echo __('Set AppID and AppSecret before requesting an access token', WP_AUTOSHAREPOST_DOMAIN) ?></strong>
                        <?php endif; ?>
                    </td>
                </tr>
                <tr valign="top">
                    <th scope="row">
                        <label for="wasp-fb-posting-type"><?php echo __('Posting Type', WP_AUTOSHAREPOST_DOMAIN) ?></label>
                    </th>
                    <td>
                        <select id="wasp-fb-posting-type" name="autosharepost[facebook][type]">
                        	<?php foreach (WordpressAutoSharePostAdmin::$facebookPostTypes as $type): ?>
	                        	<option value="<?php echo $type; ?>" <?php echo ($this->facebookPostingType == $type) ? 'selected="selected"' : '' ?>><?php echo __($type, WP_AUTOSHAREPOST_DOMAIN) ?></option>
                        	<?php endforeach; ?>
                        </select>
                        <p>
                        	<?php echo __('Specify whether to post a link or a status message on facebook.', WP_AUTOSHAREPOST_DOMAIN) ?>
                        </p>
                    </td>
                </tr>
                <tr valign="top">
                	<th scope="row">
                		<label for="wasp-fb-default-text"><?php echo __('Default message', WP_AUTOSHAREPOST_DOMAIN); ?></label>
                	</th>
                	<td>
                		<textarea id="wasp-fb-default-text" name="autosharepost[facebook][default]" rows="3" cols="80"><?php echo $this->facebookDefaultText; ?></textarea>
                	</td>
                </tr>
                <tr valign="top">
                    <th scope="row">
                        <label for="wasp-picture-album"><?php echo __('Create new album for every picture', WP_AUTOSHAREPOST_DOMAIN) ?></label>
                    </th>
                    <td>
                        <input type="checkbox" id="wasp-picture-album" name="autosharepost[facebook][album]" value="1" <?php echo ($this->facebookAlbum == '1') ? 'checked="checked"' : '' ?> />
                    </td>
                </tr>
                <tr valign="top">
                    <th scope="row">
                        <label for="wasp-fb-description-words"><?php echo __('Wordcount for description', WP_AUTOSHAREPOST_DOMAIN) ?></label>
                    </th>
                    <td>
                        <input id="wasp-fb-description-words" type="text" name="autosharepost[facebook][description]" value="<?php echo $this->facebookDescriptionWords ?>" />
                        <p>
                        	<?php echo __('This defines the maximum wordcount for the description text of facebook status messages', WP_AUTOSHAREPOST_DOMAIN) ?>
                        </p>
                    </td>
                </tr>
                <tr valign="top">
                    <th scope="row">
                        <label for="wasp-fb-disable-bitly"><?php echo __('Disable Bit.ly URL Shortening', WP_AUTOSHAREPOST_DOMAIN) ?></label>
                    </th>
                    <td>
                        <input id="wasp-fb-disable-bitly" type="checkbox" name="autosharepost[facebook][disable_bitly]" value="1" <?php echo ($this->facebookBitlyDisabled == '1') ? 'checked="checked"' : '' ?> />
                    </td>
                </tr>
            </tbody>
        </table>
        
        
        <h3><?php echo __('Twitter Settings', WP_AUTOSHAREPOST_DOMAIN) ?></h3>
        
        <table class="form-table">
            <tbody>
                <tr valign="top">
                    <th scope="row">
                        <label for="wasp-twitter-consumer-key"><?php echo __('Consumer Key', WP_AUTOSHAREPOST_DOMAIN) ?></label>
                    </th>
                    <td>
                        <input id="wasp-twitter-consumer-key" class="regular-text code" type="text" name="autosharepost[twitter][consumer_key]" value="<?php echo $this->twitterConsumerKey ?>" />
                    </td>
                </tr>
                <tr valign="top">
                    <th scope="row">
                        <label for="wasp-twitter-consumer-secret"><?php echo __('Consumer Secret', WP_AUTOSHAREPOST_DOMAIN) ?></label>
                    </th>
                    <td>
                        <input id="wasp-twitter-consumer-secret" class="regular-text code" type="text" name="autosharepost[twitter][consumer_secret]" value="<?php echo $this->twitterConsumerSecret ?>" />
                    </td>
                </tr>
                <tr valign="top">
                    <th scope="row">
                        <label for="wasp-twitter-oauth-token"><?php echo __('OAuth Token', WP_AUTOSHAREPOST_DOMAIN) ?></label>
                    </th>
                    <td>
                        <input id="wasp-twitter-oauth-token" class="regular-text code" type="text" name="autosharepost[twitter][oauth_token]" value="<?php echo $this->twitterOAuthToken ?>" />
                    </td>
                </tr>
                <tr valign="top">
                    <th scope="row">
                        <label for="wasp-twitter-oauth-secret"><?php echo __('OAuth Secret', WP_AUTOSHAREPOST_DOMAIN) ?></label>
                    </th>
                    <td>
                        <input id="wasp-twitter-oauth-secret" class="regular-text code" type="text" name="autosharepost[twitter][oauth_secret]" value="<?php echo $this->twitterOAuthSecret ?>" />
                    </td>
                </tr>
                <tr valign="top">
                    <th scope="row">
                        <label for="wasp-twitter-url-seperator"><?php echo __('Seperator between Text and URL', WP_AUTOSHAREPOST_DOMAIN) ?></label>
                    </th>
                    <td>
                        <select id="wasp-twitter-url-seperator" class="regular-text code" name="autosharepost[twitter][url_seperator]">
                            <option value=" "<?php echo ($this->twitterUrlSeperator == ' ') ? ' selected="selected"' : '' ?>><?php echo __('Whitespace', WP_AUTOSHAREPOST_DOMAIN); ?></option>
                            <option value="user-defined"<?php echo ($this->twitterUrlSeperator != ' ' && !empty($this->twitterUrlSeperator)) ? ' selected="selected"' : '' ?>><?php echo __('As defined:', WP_AUTOSHAREPOST_DOMAIN); ?></option>
                        </select>
                        <input id="wasp-twitter-url-seperator-text" type="text" value="<?php echo ($this->twitterUrlSeperator != ' ') ? $this->twitterUrlSeperator : '' ?>" name="autosharepost[twitter][url_seperator_text]" placeholder="<?php echo __('Put your seperator here', WP_AUTOSHAREPOST_DOMAIN) ?>" />
                        <p>
                        	<?php echo __('The seperator which is used to seperate the URL from the text in a Twitter tweet.', WP_AUTOSHAREPOST_DOMAIN); ?>
                        </p>
                    </td>
                </tr>
                <tr valign="top">
                	<th scope="row">
                		<label for="wasp-twitter-default-text"><?php echo __('Default message', WP_AUTOSHAREPOST_DOMAIN); ?></label>
                	</th>
                	<td>
                		<textarea id="wasp-twitter-default-text" name="autosharepost[twitter][default]" rows="3" cols="80"><?php echo $this->twitterDefaultText; ?></textarea>
                	</td>
                </tr>
            </tbody>
        </table>
        
        <h3><?php echo __('Bit.ly Url Shortening', WP_AUTOSHAREPOST_DOMAIN) ?></h3>
        <p>
        	<?php echo __('Bit.ly is a URL shortening service. This is used to shorten the URL to your Blogpost so that the URL does not consume too many characters from the twitter message itself.', WP_AUTOSHAREPOST_DOMAIN) ?>
        </p>
        <table class="form-table">
            <tbody>
                <tr valign="top">
                    <th scope="row">
                        <label for="wasp-bitly-login"><?php echo __('Login', WP_AUTOSHAREPOST_DOMAIN) ?></label>
                    </th>
                    <td>
                        <input id="wasp-bitly-login" type="text" value="<?php echo $this->bitlyLogin ?>" class="regular-text code" name="autosharepost[bitly][login]" />
                    </td>
                </tr>
                <tr valign="top">
                    <th scope="row">
                        <label for="wasp-bitly-api"><?php echo __('API Key', WP_AUTOSHAREPOST_DOMAIN) ?></label>
                    </th>
                    <td>
                        <input id="wasp-bitly-api"type="text" value="<?php echo $this->bitlyApiKey ?>" class="regular-text code" name="autosharepost[bitly][api_key]" />
                    </td>
                </tr>
            </tbody>
        </table>
        
        <p class="submit">
            <input type="submit" name="submit" id="submit" class="button-primary" value="<?php echo __('Save Changes') ?>" />
        </p>
    </form>
</div>