// 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));
$Form->set_placeholder('add_filter_label', __('Add Filter', CCTM_TXTDOMAIN));
$Form->set_placeholder('save_criteria_label', __('Save Criteria', CCTM_TXTDOMAIN));
$Form->set_placeholder('cancel_label', __('Cancel', CCTM_TXTDOMAIN));
print $Form->generate(CCTM::$search_by, $existing_values);
exit;
/*EOF*/
$args['offset'] = 0;
// assume 0, unless we got a page number
// 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'];
}
// Get the results
$results = $Q->get_posts($args);
$search_form_tpl = CCTM::load_tpl(array('post_selector/search_forms/_post_content_widget.tpl'));
$Form->set_tpl($search_form_tpl);
$Form->set_name_prefix('');
// blank out the prefixes
$Form->set_id_prefix('');
$search_by = array('search_term', 'yearmonth');
// Pass these to hidden fields so jQuery can read them
$Form->set_placeholder('post_type', $args['post_type']);
$Form->set_placeholder('post_id_field', $post_id_field);
$Form->set_placeholder('target_id', $target_id);
$d['search_form'] = $Form->generate($search_by, $args);
$item_tpl = '';
$wrapper_tpl = '';
$item_tpl = CCTM::load_tpl(array('post_selector/items/_widget.tpl'));
$wrapper_tpl = CCTM::load_tpl(array('post_selector/wrappers/_default.tpl'));
// Placeholders for the wrapper tpl
$hash = array();
$hash['post_title'] = __('Title', CCTM_TXTDOMAIN);
$hash['post_date'] = __('Date', CCTM_TXTDOMAIN);
$hash['post_status'] = __('Status', CCTM_TXTDOMAIN);
$hash['post_parent'] = __('Parent', CCTM_TXTDOMAIN);
$hash['post_type'] = __('Post Type', CCTM_TXTDOMAIN);
$hash['fieldname'] = '';
if (isset($_POST['search_parameters'])) {
    $search_parameters_str = $_POST['search_parameters'];
}
//print '<pre>'.$search_parameters_str. '</pre>'; return;
$existing_values = array();
parse_str($search_parameters_str, $existing_values);
//print '<pre>'.print_r($existing_values, true) . '</pre>';
require_once CCTM_PATH . '/includes/SummarizePosts.php';
require_once CCTM_PATH . '/includes/GetPostsQuery.php';
require_once CCTM_PATH . '/includes/GetPostsForm.php';
$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/' . $fieldname . '.php';
// e.g. my_field.php
$possible_configs[] = '/config/search_parameters/_' . $type . '.php';
// e.g. _image.php
$possible_configs[] = '/config/search_parameters/_default.php';
if (!CCTM::load_file($possible_configs)) {
    print '<p>' . sprintf(__('Search parameter configuration file not found. Check config/search_parameters/ for a valid configuration file for the %s field or the %s field-type.', CCTM_TXTDOMAIN), "<code>{$fieldname}</code>", "<code>{$type}</code>") . '</p>';
}
$Form->set_placeholder('description', __('This form will determine which posts will be selectable when users create or edit a post that uses this field. WARNING: supplying incorrect or overly restrictive criteria will result in an empty list!', CCTM_TXTDOMAIN));
$Form->set_placeholder('save', __('Save', CCTM_TXTDOMAIN));
$Form->set_placeholder('cancel', __('Cancel', CCTM_TXTDOMAIN));
$form_tpl = CCTM::load_tpl('post_selector/search_forms/_modal.tpl');
$Form->set_name_prefix('');
$Form->set_id_prefix('');
$Form->set_tpl($form_tpl);
print $Form->generate(CCTM::$search_by, $existing_values);
/*EOF*/
------------------------------------------------------------------------------*/
require_once CCTM_PATH . '/includes/SummarizePosts.php';
require_once CCTM_PATH . '/includes/GetPostsQuery.php';
require_once CCTM_PATH . '/includes/GetPostsForm.php';
$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/_summarize_posts.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/search.tpl');
$Form->set_name_prefix('');
$Form->set_id_prefix('');
$Form->set_placeholder('cctm_url', CCTM_URL);
$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']);
}
$Form->set_placeholder('custom_fields', $custom_field_options);
// I18n for the search form
$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));
$Form->set_placeholder('add_filter_label', __('Add Filter', CCTM_TXTDOMAIN));
$Form->set_placeholder('generate_shortcode_label', __('Generate Shortcode', CCTM_TXTDOMAIN));
$Form->set_placeholder('cancel_label', __('Cancel', CCTM_TXTDOMAIN));
print $Form->generate(CCTM::$search_by);