function field_default_filters()
        {
            ?>
			<table class="widefat" id="dfrps_search_form_wrapper">
				<tbody>
					<tr>
						<td class="form">
							<?php 
            $sform = new Dfrapi_SearchForm();
            echo $sform->render($this->key . '[dfrps_query]', $this->options['default_filters']['dfrps_query']);
            ?>
						</td>
					</tr>
				</tbody>
			</table>
			<p class="description"><?php 
            _e('Set the default search parameters for creating new Product Sets.', DFRPS_DOMAIN);
            ?>
</p>
			<?php 
        }
Exemple #2
0
/**
 * Creates the proper API request from the $query.
 */
function dfrapi_api_query_to_filters($query, $useSelected = TRUE)
{
    $sform = new Dfrapi_SearchForm();
    return $sform->makeFilters($query, $useSelected);
}
Exemple #3
0
        function search_form()
        {
            ?>
	
		<div id="dfrps_search_form_wrapper" class="stuffbox">
			<div class="instructions" style="display: none;">
				<a href="#" id="dfrps_search_instructions_toggle"><?php 
            _e('search help...', DFRPS_DOMAIN);
            ?>
</a>
				<div style="display:none" id="dfrps_search_instructions">
					<div id="dfrps_search_instructions_wrapper">
						<h2><?php 
            _e('Search Help', DFRPS_DOMAIN);
            ?>
</h2>
						<h3><?php 
            _e('Filters', DFRPS_DOMAIN);
            ?>
</h3>
						<p><?php 
            _e('Use filters to search and filter lists of products. ', DFRPS_DOMAIN);
            ?>
</p> 
						<table class="widefat" cellspacing="0">
							<tbody>
								<tr class="alternate">
									<td class="row-title"><?php 
            _e('Any field', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Filter products based on "Text" fields.  Generally "Text" fields are: product name, product description, brand, etc...', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr>
									<td class="row-title"><?php 
            _e('Product name', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Filter products based on the product name.', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr class="alternate">
									<td class="row-title"><?php 
            _e('Brand', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Filter products based on the product\'s brand name. Not every product has a brand name.', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr>
									<td class="row-title"><?php 
            _e('Description', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Filter products based on the product description field.', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr class="alternate">
									<td class="row-title"><?php 
            _e('Tags', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Filter products based on the product tags.', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr>
									<td class="row-title"><?php 
            _e('Product type', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Filter products based on type: product or coupon. Note that in order to use this filter, you should have already selected merchants that provide this type of products. For example, if you choose "coupon" but you have not selected any Merchants, your search will return an error.', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr class="alternate">
									<td class="row-title"><?php 
            _e('Currency', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Filter products based on their currency code. Not every product has a currency code.', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr>
									<td class="row-title"><?php 
            _e('Price', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Filter products based on their price.', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr class="alternate">
									<td class="row-title"><?php 
            _e('Sale Price', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Filter products based on their sale price.', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr>
									<td class="row-title"><?php 
            _e('Network', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Filter products based on the affiliate network they are from.', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr class="alternate">
									<td class="row-title"><?php 
            _e('Merchant', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Filter products based on the merchant they are from.', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr>
									<td class="row-title"><?php 
            _e('On Sale', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Filter products by whether or not they are on sale.', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr class="alternate">
									<td class="row-title"><?php 
            _e('Discount', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Filter products by the percent of discount. For example, if you only want products that are on sale and the discount is greater than 20%, choose the "greater than" operator and type "20".', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr>
									<td class="row-title"><?php 
            _e('Has Image', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Filter products by whether or not they have an image. Note that if a merchant provides an image URL in their data feed but that image URL is broken, the product will still be returned in your search results.', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr class="alternate">
									<td class="row-title"><?php 
            _e('Last updated', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Filter products by the last time they were updated in our database. You can use about any English textual datetime description. For examples, see PHP\'s ', DFRPS_DOMAIN);
            ?>
<a href="http://php.net/strtotime" target="_blank">strtotime()</a> <?php 
            _e('function.', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr>
									<td class="row-title"><?php 
            _e('Limit', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Return a limited number of products. Note that the maximum number of products that will be returned is 10,000 products.', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr class="alternate">
									<td class="row-title"><?php 
            _e('Sort By', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Sort the search results by various parameters.', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr>
									<td class="row-title"><?php 
            _e('Exclude Duplicates', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc">
										<?php 
            _e('Exclude products that have duplicate fields. Possible values are: ', DFRPS_DOMAIN);
            ?>
										<br />
										<tt>name, brand, currency, price, saleprice, source_id, merchant_id, onsale, image, thumbnail</tt>
										<br /><br />
										<strong><?php 
            _e('Examples:', DFRPS_DOMAIN);
            ?>
</strong>
										<br />
										<tt>name image</tt> - <?php 
            _e('Exclude products with the same name AND the same image URL.', DFRPS_DOMAIN);
            ?>
<br />
										<tt>name|image</tt> - <?php 
            _e('Exclude products with the same name OR the same image URL.', DFRPS_DOMAIN);
            ?>
<br />
										<tt>merchant_id name|image</tt> - <?php 
            _e('Exclude products which have the same merchant AND their name OR image URL are the same.', DFRPS_DOMAIN);
            ?>
									</td>
								</tr>
							</tbody>
						</table>
						<h3><?php 
            _e('Filter Operators', DFRPS_DOMAIN);
            ?>
</h3>
						<p><?php 
            _e('Use these filter operators to modify your search filters. ', DFRPS_DOMAIN);
            ?>
</p> 
						<table class="widefat" cellspacing="0">
							<thead>
								<tr>
									<th><?php 
            _e('Filter Operators', DFRPS_DOMAIN);
            ?>
</th>
									<th><?php 
            _e('Description', DFRPS_DOMAIN);
            ?>
</th>
									<th><?php 
            _e('Character Operators', DFRPS_DOMAIN);
            ?>
</th>
								</tr>
							</thead>
							<tbody>
								<tr class="alternate">
									<td class="row-title"><?php 
            _e('contains', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Return products which have the keyword(s).', DFRPS_DOMAIN);
            ?>
</td>
									<td class="operators">
										<tt>= |</tt>
									</td>
								</tr>
								<tr>
									<td class="row-title"><?php 
            _e("doesn't contain", DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Return products which do not have the keyword(s).', DFRPS_DOMAIN);
            ?>
</td>
									<td class="operators">
										<tt>= |</tt>
									</td>
								</tr>
								<tr class="alternate">
									<td class="row-title"><?php 
            _e('starts with', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Return products which keyword(s) start with a specific word.', DFRPS_DOMAIN);
            ?>
</td>
									<td class="operators">
										<tt>= |</tt>
									</td>
								</tr>
								<tr>
									<td class="row-title"><?php 
            _e('ends with', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Return products which keyword(s) end with a specific word.', DFRPS_DOMAIN);
            ?>
</td>
									<td class="operators">
										<tt>= |</tt>
									</td>
								</tr>
								<tr class="alternate">
									<td class="row-title"><?php 
            _e('matches', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Allows use of all available operators.', DFRPS_DOMAIN);
            ?>
</td>
									<td class="operators">
										<tt>= | ^ $ "&hellip;"</tt>
									</td>
								</tr>
								<tr>
									<td class="row-title"><?php 
            _e('is', DFRPS_DOMAIN);
            ?>
</td>
									<td class="desc"><?php 
            _e('Return products that match an exact word (stemming is still in effect).', DFRPS_DOMAIN);
            ?>
</td>
									<td class="operators">
										<tt>= |</tt>
									</td>
								</tr>
							</tbody>
						</table>
						
						<h3><?php 
            _e('Character Operators', DFRPS_DOMAIN);
            ?>
</h3>
						<p><?php 
            _e('Use these filter operators to further modify your filter operators. ', DFRPS_DOMAIN);
            ?>
</p> 
						<table class="widefat" cellspacing="0">
							<thead>
								<tr>
									<th><?php 
            _e('Character', DFRPS_DOMAIN);
            ?>
</th>
									<th><?php 
            _e('Description', DFRPS_DOMAIN);
            ?>
</th>
								</tr>
							</thead>
							<tbody>
								<tr class="alternate">
									<td class="operators"><tt>=</tt></td>
									<td class="desc"><?php 
            _e('Perform an exact word search.', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr>
									<td class="operators"><tt>|</tt></td>
									<td class="desc"><?php 
            _e('Perform a search with an OR operator with the pipe symbol.', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr class="alternate">
									<td class="operators"><tt>^</tt></td>
									<td class="desc"><?php 
            _e('Perform a search that begin with a specific word.', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr>
									<td class="operators"><tt>$</tt></td>
									<td class="desc"><?php 
            _e('Perform a search that ends with a specific word.', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
								<tr class="alternate">
									<td class="operators"><tt>"&hellip;"</tt></td>
									<td class="desc"><?php 
            _e('Perform a phrasal search by surrounding a phrase in double quotes.', DFRPS_DOMAIN);
            ?>
</td>
								</tr>
							</tbody>
						</table>
					</div>
				</div>
			</div>
			<div style="margin-bottom: 10px;"> </div>
			<?php 
            $sform = new Dfrapi_SearchForm();
            echo $sform->render('_dfrps_cpt_query', $this->get_search_form_defaults(get_the_ID()));
            ?>
			<div class="actions">
				<span class="dfrps_raw_query"><a href="#" id="dfrps_view_raw_query"><?php 
            _e('view api request', DFRPS_DOMAIN);
            ?>
</a></span>
				<input name="search" type="submit" class="button" id="dfrps_cpt_search" value="<?php 
            echo __('Search', DFRPS_DOMAIN);
            ?>
" />
				<div id="dfrps_save_update_search_actions">
					<?php 
            $saved_query = get_post_meta(get_the_ID(), '_dfrps_cpt_query', true);
            $add_update_button_text = $saved_query ? __('Update Saved Search', DFRPS_DOMAIN) : __('Add as Saved Search', DFRPS_DOMAIN);
            ?>
					<input type="submit" class="button button-primary" id="dfrps_cpt_save_search" value="<?php 
            echo $add_update_button_text;
            ?>
" />
				</div>
			</div>
		</div>
		<div id="div_dfrps_tab_search_results"></div>
		<?php 
        }
 function ajax_search_form()
 {
     $sform = new Dfrapi_SearchForm();
     echo $sform->ajaxHandler();
     die;
 }