<?php include W3TC_DIR . '/inc/options/common/header.phtml'; ?>

<form action="admin.php">
    <p>
        Page caching via
        <strong><?php echo w3_get_engine_name($this->_config->get_string('pgcache.engine')); ?></strong>
        is currently <span class="w3tc-<?php if ($pgcache_enabled): ?>enabled">enabled<?php else: ?>disabled">disabled<?php endif; ?></span>.
    </p>
    <p>
		To rebuild the page cache use the 
        <input type="submit" name="flush_pgcache" value="empty cache"<?php if (! $pgcache_enabled): ?> disabled="disabled"<?php endif; ?> class="button" />
		operation.
        <input type="hidden" name="page" value="<?php echo $this->_page; ?>" />
    </p>
</form>

<form action="admin.php?page=<?php echo $this->_page; ?>" method="post">
	<fieldset>
		<legend>General</legend>

        <table class="form-table">
        	<tr>
        		<th>
        			<input type="hidden" name="pgcache.reject.logged" value="0" />
        			<label><input type="checkbox" name="pgcache.reject.logged" value="1"<?php checked($this->_config->get_boolean('pgcache.reject.logged'), true); ?> /> Don't cache pages for logged in users</label><br />
    				<span class="description">Users that have signed in to WordPress (e.g. administrators) will never view cached pages if enabled.</span>
        		</th>
        	</tr>
        	<tr>
        		<th>
        			<input type="hidden" name="pgcache.cache.home" value="0" />
        			<label><input type="checkbox" name="pgcache.cache.home" value="1"<?php checked($this->_config->get_boolean('pgcache.cache.home'), true); ?> /> Cache home page</label><br />
    				<span class="description">For many blogs this is your most visited page, it is recommended that you cache it.</span>
        		</th>
        	</tr>
        	<tr>
        		<th>
        			<input type="hidden" name="pgcache.cache.feed" value="0" />
        			<label><input type="checkbox" name="pgcache.cache.feed" value="1"<?php checked($this->_config->get_boolean('pgcache.cache.feed'), true); ?> /> Cache feeds: site, categories, tags, comments</label><br />
    				<span class="description">Even if using a feed proxy service (like <a href="http://en.wikipedia.org/wiki/FeedBurner" target="_blank">FeedBurner</a>), enabling this option is still recommended.</span>
        		</th>
        	</tr>
        	<tr>
        		<th>
        			<input type="hidden" name="pgcache.cache.query" value="0"<?php if ($this->_config->get_string('pgcache.engine') == 'file_pgcache'): ?> disabled="disabled"<?php endif; ?> />
        			<label><input type="checkbox" name="pgcache.cache.query" value="1"<?php checked($this->_config->get_boolean('pgcache.cache.query'), true); ?><?php if ($this->_config->get_string('pgcache.engine') == 'file_pgcache'): ?> disabled="disabled"<?php endif; ?> /> Cache <acronym title="Uniform Resource Identifier">URI</acronym>s with query string variables</label><br />
    				<span class="description">Search result (and similar) pages will be cached if enabled.</span>
        		</th>
        	</tr>
        	<tr>
        		<th>
        			<input type="hidden" name="pgcache.cache.404" value="0" />
        			<label><input type="checkbox" name="pgcache.cache.404" value="1"<?php checked($this->_config->get_boolean('pgcache.cache.404'), true); ?> /> Cache 404 (not found) pages</label><br />
    				<span class="description">Reduce server load by caching 404 pages. The "Do not process 404 errors for static objects with WordPress" Browser Cache option is recommended.</span>
        		</th>
        	</tr>
        </table>

        <p class="submit">
        	<input type="submit" name="options_save" class="button-primary" value="Save changes" />
        </p>
	</fieldset>

	<fieldset>
		<legend>Advanced</legend>

        <table class="form-table">
        	<?php if ($this->_config->get_string('pgcache.engine') == 'memcached'): ?>
        	<tr>
        		<th><label for="memcached_servers">Memcached hostname:port / <acronym title="Internet Protocol">IP</acronym>:port:</label></th>
        		<td>
        			<input id="memcached_servers" type="text" name="pgcache.memcached.servers" value="<?php echo htmlspecialchars(implode(',', $this->_config->get_array('pgcache.memcached.servers'))); ?>" size="100" />
        			<input id="memcached_test" class="button" type="button" value="Test" />
        			<span id="memcached_test_status" class="w3tc-status w3tc-process"></span>
        			<br /><span class="description">Multiple servers may be used and seperated by a comma; e.g. 192.168.1.100:11211, domain.com:22122</span>
        		</td>
        	</tr>
        	<?php endif; ?>
        	<tr>
        		<th><label for="pgcache_file_gc">Garbage collection interval:</label></th>
        		<td>
        			<input id="pgcache_file_gc" type="text" name="pgcache.file.gc" value="<?php echo $this->_config->get_integer('pgcache.file.gc'); ?>" size="8"<?php if ($this->_config->get_string('pgcache.engine') != 'file' && $this->_config->get_string('pgcache.engine') != 'file_pgcache'): ?> disabled="disabled"<?php endif; ?> /> seconds
        			<br /><span class="description">If caching to disk, specify how frequently expired cache data is removed. For busy sites, a lower value is best.</span>
    			</td>
        	</tr>
        	<tr>
        		<th valign="top"><label for="pgcache_reject_ua">Rejected User Agents:</label></th>
        		<td>
        			<textarea id="pgcache_reject_ua" name="pgcache.reject.ua" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('pgcache.reject.ua'))); ?></textarea><br />
        			<span class="description">Never send cache pages for these user agents.</span>
        		</td>
        	</tr>
        	<tr>
        		<th valign="top"><label for="pgcache_reject_cookie">Rejected Cookies:</label></th>
        		<td>
        			<textarea id="pgcache_reject_cookie" name="pgcache.reject.cookie" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('pgcache.reject.cookie'))); ?></textarea><br />
        			<span class="description">Never cache pages that use the specified cookies.</span>
        		</td>
        	</tr>
        	<tr>
        		<th valign="top"><label for="pgcache_reject_uri">Never cache the following pages:</label></th>
        		<td>
        			<textarea id="pgcache_reject_uri" name="pgcache.reject.uri" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('pgcache.reject.uri'))); ?></textarea><br />
        			<span class="description">Always ignore the specified pages / directories.</span>
        		</td>
        	</tr>
        	<tr>
        		<th valign="top"><label for="pgcache_accept_files">Cache exception list:</label></th>
        		<td>
        			<textarea id="pgcache_accept_files" name="pgcache.accept.files" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('pgcache.accept.files'))); ?></textarea><br />
        			<span class="description">Cache the specified pages / directories even if listed in the "never cache the following pages" field.</span>
        		</td>
        	</tr>
        	<tr>
        		<th valign="top"><label for="pgcache_cache_headers">Specify page headers:</label></th>
        		<td>
        			<textarea id="pgcache_cache_headers" name="pgcache.cache.headers" cols="40" rows="5"<?php if (! W3TC_PHP5 || $this->_config->get_string('pgcache.engine') == 'file_pgcache'): ?> disabled="disabled"<?php endif; ?>><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('pgcache.cache.headers'))); ?></textarea><br />
        			<span class="description">Specify additional page headers to cache.</span>
        		</td>
        	</tr>
        </table>

        <p class="submit">
        	<input type="submit" name="options_save" class="button-primary" value="Save changes" />
        </p>
	</fieldset>
	
    <fieldset>
    	<legend>Cache Preload</legend>

        <table class="form-table">
        	<tr>
        		<th colspan="2">
            		<input type="hidden" name="pgcache.prime.enabled" value="0" />
            		<label><input type="checkbox" name="pgcache.prime.enabled" value="1"<?php checked($this->_config->get_boolean('pgcache.prime.enabled'), true); ?> /> Automatically prime the page cache</label><br />
        		</th>
        	</tr>
        	<tr>
        		<th><label for="pgcache_prime_interval">Update interval:</label></th>
        		<td>
        			<input id="pgcache_prime_interval" type="text" name="pgcache.prime.interval" value="<?php echo $this->_config->get_integer('pgcache.prime.interval'); ?>" size="8" /> seconds<br />
        			<span class="description">The number of seconds to wait before creating another set of cached pages.</span>
    			</td>
        	</tr>
        	<tr>
        		<th><label for="pgcache_prime_limit">Pages per interval:</label></th>
        		<td>
        			<input id="pgcache_prime_limit" type="text" name="pgcache.prime.limit" value="<?php echo $this->_config->get_integer('pgcache.prime.limit'); ?>" size="8" /><br />
        			<span class="description">Limit the number of pages to create per batch. Fewer pages may be better for under-powered servers.</span>
    			</td>
        	</tr>
        	<tr>
        		<th><label for="pgcache_prime_sitemap">Sitemap <acronym title="Uniform Resource Indicator">URL</acronym>:</label></th>
        		<td>
        			<input id="pgcache_prime_sitemap" type="text" name="pgcache.prime.sitemap" value="<?php echo $this->_config->get_string('pgcache.prime.sitemap'); ?>" size="100" /><br />
        			<span class="description">A <a href="http://www.xml-sitemaps.com/validate-xml-sitemap.html" target="_blank">compliant</a> sitemap can be used to specify the pages to maintain in the primed cache. Pages will be cached according to the priorities specified in the <acronym title="Extensible Markup Language">XML</acronym> file. <a href="http://wordpress.org/extend/plugins/google-sitemap-generator/" target="_blank">Google <acronym title="Extensible Markup Language">XML</acronym> Sitemaps</a> is recommended for use with this feature.</span>
    			</td>
        	</tr>
        	
        </table>

        <p class="submit">
        	<input type="submit" name="options_save" class="button-primary" value="Save changes" />
        </p>
	</fieldset>

    <fieldset>
    	<legend>Varnish</legend>
    	
        <table class="form-table">
        	<tr>
        		<th colspan="2">
            		<input type="hidden" name="pgcache.varnish.enabled" value="0" />
            		<label><input type="checkbox" name="pgcache.varnish.enabled" value="1"<?php checked($this->_config->get_boolean('pgcache.varnish.enabled'), true); ?> /> Enable varnish cache purging</label><br />
        		</th>
        	</tr>
         	<tr>
         		<th valign="top"><label for="pgcache_varnish_servers">Varnish servers:</label></th>
         		<td>
        			<textarea id="pgcache_varnish_servers" name="pgcache.varnish.servers" cols="40" rows="5"><?php echo htmlspecialchars(implode("\r\n", $this->_config->get_array('pgcache.varnish.servers'))); ?></textarea><br />
        			<span class="description">Specify the IP addresses of your varnish instances above. Your <acronym title="Varnish Configuration Language">VCL</acronym>'s <acronym title="Access Control List">ACL</acronym> must allow this request.</span>
        		</td>
        	</tr>
        </table>

        <p class="submit">
        	<input type="submit" name="options_save" class="button-primary" value="Save changes" />
        </p>
	</fieldset>

	<fieldset>
		<legend>Note(s):</legend>

        <table class="form-table">
        	<tr>
        		<th valign="top" colspan="2">
					<ul>
						<li>Enable <acronym title="Hypertext Transfer Protocol">HTTP</acronym> compression in the "<acronym title="Hypertext Markup Language">HTML</acronym>" section on <a href="admin.php?page=w3tc_browsercache">Browser Cache</a> Settings tab.</li>
						<li>The <acronym title="Time to Live">TTL</acronym> of page cache files is set via the "Expires header lifetime" field in the "<acronym title="Hypertext Markup Language">HTML</acronym>" section on <a href="admin.php?page=w3tc_browsercache">Browser Cache</a> Settings tab.</li>
					</ul>
        		</th>
        	</tr>
        </table>
	</fieldset>
	
</form>

<?php include W3TC_DIR . '/inc/options/common/footer.phtml'; ?>