$search_parameters_str = $_POST['search_parameters'];
}
$existing_values = array();
parse_str($search_parameters_str, $existing_values);
$Form = new GetPostsForm();
// What options should be displayed on the form that defines the search?
// Load up the config...
$possible_configs = array();
$possible_configs[] = '/config/search_parameters/_widget.php';
if (!CCTM::load_file($possible_configs)) {
    print '<p>' . __('Search parameter configuration file not found.', CCTM_TXTDOMAIN) . '</p>';
}
$form_tpl = CCTM::load_tpl('summarize_posts/widget.tpl');
$Form->set_name_prefix('');
$Form->set_id_prefix('');
$Form->set_tpl($form_tpl);
$custom_fields = CCTM::get_custom_field_defs();
$custom_field_options = '';
foreach ($custom_fields as $cf) {
    $custom_field_options .= sprintf('<option value="%s:%s">%s</option>', $cf['name'], $cf['label'], $cf['label']);
}
if (!isset($existing_values['limit']) || $existing_values['limit'] == 0) {
    $existing_values['limit'] = 5;
}
$Form->set_placeholder('custom_fields', $custom_field_options);
$Form->set_placeholder('cctm_url', CCTM_URL);
$Form->set_placeholder('storage_field', $storage_field);
// I18n for the widget
$Form->set_placeholder('widget_desc', __('Dynamically list posts according to the criteria below.', CCTM_TXTDOMAIN));
$Form->set_placeholder('post_title_label', __('Post Title', CCTM_TXTDOMAIN));
$Form->set_placeholder('author_id_label', __('Author ID', CCTM_TXTDOMAIN));
// Calculate offset based on page number
if (is_numeric($d['page_number']) && $d['page_number'] > 1) {
    $args['offset'] = ($d['page_number'] - 1) * CCTM::$post_selector['limit'];
}
//print '<pre>'.print_r($args,true).'</pre>'; exit;
// Set pagination tpls
$tpls = array('firstTpl' => '<span class="linklike" onclick="javascript:change_page(1);">&laquo; First</span> &nbsp;', 'lastTpl' => '&nbsp;<span class="linklike" onclick="javascript:change_page([+page_number+]);" >Last &raquo;</span>', 'prevTpl' => '<span class="linklike" onclick="javascript:change_page([+page_number+]);">&lsaquo; Prev.</span>&nbsp;', 'nextTpl' => '&nbsp;<span class="linklike" onclick="javascript:change_page([+page_number+]);">Next &rsaquo;</span>', 'currentPageTpl' => '&nbsp;<span class="post_selector_pagination_active_page">[+page_number+]</span>&nbsp;', 'pageTpl' => '&nbsp;<span class="linklike" title="[+page_number+]" onclick="javascript:change_page([+page_number+]);">[+page_number+]</span>&nbsp;', 'outerTpl' => '<div id="pagination">[+content+] &nbsp; &nbsp;
		Page [+current_page+] of [+page_count+]<br/>
	</div>');
$Q->set_tpls($tpls);
// Get the results
//print '<pre>'.print_r(CCTM::$search_by, true) . '</pre>';
$results = $Q->get_posts($args);
//print '<pre>'.$Q->debug().'</pre>';
$search_form_tpl = CCTM::load_tpl(array('post_selector/search_forms/' . $fieldname . '.tpl', 'post_selector/search_forms/_' . $def['type'] . '.tpl', 'post_selector/search_forms/_default.tpl'));
$Form->set_tpl($search_form_tpl);
$Form->set_name_prefix('');
// blank out the prefixes
$Form->set_id_prefix('');
$d['search_form'] = $Form->generate(CCTM::$search_by, $args);
$item_tpl = '';
$wrapper_tpl = '';
// Multi Field (contains an array of values.
if (isset($def['is_repeatable']) && $def['is_repeatable'] == 1) {
    $item_tpl = CCTM::load_tpl(array('post_selector/items/' . $fieldname . '.tpl', 'post_selector/items/_' . $def['type'] . '_multi.tpl', 'post_selector/items/_relation_multi.tpl'));
    $wrapper_tpl = CCTM::load_tpl(array('post_selector/wrappers/' . $fieldname . '.tpl', 'post_selector/wrappers/_' . $def['type'] . '_multi.tpl', 'post_selector/wrappers/_relation_multi.tpl'));
} else {
    $item_tpl = CCTM::load_tpl(array('post_selector/items/' . $fieldname . '.tpl', 'post_selector/items/_' . $def['type'] . '.tpl', 'post_selector/items/_default.tpl'));
    $wrapper_tpl = CCTM::load_tpl(array('post_selector/wrappers/' . $fieldname . '.tpl', 'post_selector/wrappers/_' . $def['type'] . '.tpl', 'post_selector/wrappers/_default.tpl'));
}
// Placeholders for the wrapper tpl
    function testSearchBy3()
    {
        $Q = new GetPostsForm();
        $Q->set_nonce_field('');
        // override nonce
        $Q->set_css('', false);
        // blank out CSS
        $Q->set_tpl('[+post_type.options+]');
        $actual = $Q->generate(array('post_type'));
        //print $Q->placeholders['post_type.options']; exit;
        //print $actual; exit;
        //print '<pre>'; print_r($Q->placeholders); print '</pre>';exit;
        $expected = '<option value="" >Select post-type</option>
			<option value="attachment" >attachment</option>
			<option value="house" >house</option>
			<option value="movie" >movie</option>
			<option value="page" >page</option>
			<option value="people" >people</option>
			<option value="post" >post</option>
			<option value="room" >room</option>
			<option value="snake" >snake</option>
			<option value="test" >test</option>';
        $this->assertTrue(in_html($expected, $actual));
    }