private static function create()
 {
     // Decide slug from Type selected
     if (self::$_quick_start_options['quick_start_type'] == 'city') {
         $name = 'Cities';
         $slug = 'cities';
     } else {
         if (self::$_quick_start_options['quick_start_type'] == 'zip') {
             $name = 'Zip Codes';
             $slug = 'zip-codes';
         } else {
             if (self::$_quick_start_options['quick_start_type'] == 'subdivision') {
                 $name = 'Subdivisions';
                 $slug = 'subdivisions';
             } else {
                 if (self::$_quick_start_options['quick_start_type'] == 'school_district') {
                     $name = 'School Districts';
                     $slug = 'school-districts';
                 } else {
                     if (self::$_quick_start_options['quick_start_type'] == 'school') {
                         $name = 'Schools';
                         $slug = 'schools';
                     }
                 }
             }
         }
     }
     // Create menu if needed
     if (self::$_quick_start_options['quick_start_parent_menu'] == 'new') {
         $menu_id = self::register_menu($name);
     } else {
         if (!empty(self::$_quick_start_options['quick_start_parent_menu']) && self::$_quick_start_options['quick_start_parent_menu'] != 'none') {
             $menu_id = self::$_quick_start_options['quick_start_parent_menu'];
         } else {
             $menu_id = false;
         }
     }
     // Create parent page if needed
     if (self::$_quick_start_options['quick_start_parent_page'] == 'new') {
         $parent_id = self::register_parent_page($name, $slug);
     } else {
         if (!empty(self::$_quick_start_options['quick_start_parent_page']) && self::$_quick_start_options['quick_start_parent_page'] != 'none') {
             $parent_id = self::$_quick_start_options['quick_start_parent_page'];
         } else {
             $parent_id = false;
         }
     }
     // Create pages for each
     $criteria_values = array_map('trim', explode("\n", self::$_quick_start_options['quick_start_criteria']));
     if (!empty($criteria_values)) {
         self::register_pages($criteria_values, self::$_quick_start_options['quick_start_type'], $menu_id, $parent_id);
     }
     // Remove Criteria to prevent looping creation
     self::$_quick_start_options['quick_start_criteria'] = '';
     DispletRetsIdxOptionsController::update_option('quick_start', self::$_quick_start_options);
 }
예제 #2
0
/**
 * @param: $field: string or array ( area_mls_defined, city, property_type or school_district, status or zip )
 * @return: success: array
 * @return: failure: false
 */
function displetretsidx_get_field_options($field)
{
    $field_option = DispletRetsIdxOptionsController::get_option('fields');
    if (is_array($field)) {
        $fields = array();
        foreach ($field as $slug) {
            if (isset($field_option[$slug])) {
                $fields = array_merge($fields, $field_option[$slug]);
            }
        }
        sort($fields);
        return $fields;
    } elseif (isset($field_option[$field])) {
        return $field_option[$field];
    }
    return false;
}
 public static function set_options()
 {
     self::$_options = self::get_option();
     if (!empty(self::$_options['displet_app_key'])) {
         self::$_field_options = self::get_option('fields');
     }
     self::$_search_form_options = self::get_option('search_forms');
 }
 private static function update_to_2_1_19()
 {
     DispletRetsIdxSettingsController::update_email_templates_at_api(DispletRetsIdxOptionsController::get_option());
     DispletRetsIdxSettingsController::update_field_options(self::$_options);
 }
 public static function update_setting($key, $value)
 {
     $options = DispletRetsIdxOptionsController::get_option();
     $options[$key] = $value;
     DispletRetsIdxOptionsController::update_option('settings', $options);
 }
 private function maybe_set_property_types()
 {
     if ($this->_model['data_from'] !== 'property_showcase' && !$this->_model['is_property_details_page'] && ($this->_model['count'] > 9 || $this->_model['layout'] == 'table') && (!empty($this->_model['property_type_navigation']) || !empty($this->_model['property_type_sorting']))) {
         $property_types = array();
         if (!empty($this->_model['property_type'])) {
             $model_property_types = explode(',', $this->_model['property_type']);
             if (count($model_property_types) > 1) {
                 foreach ($model_property_types as $property_type) {
                     $key = strtolower(trim($property_type));
                     $property_types[$key] = $property_type;
                 }
             }
         } else {
             $displetretsidx_field_option = DispletRetsIdxOptionsController::get_option('fields');
             if (!empty($displetretsidx_field_option['property_type'])) {
                 foreach ($displetretsidx_field_option['property_type'] as $property_type) {
                     $key = strtolower($property_type);
                     $property_types[$key] = $property_type;
                 }
             }
         }
         $filter_used = false;
         if (!empty($this->_options['property_type_include_filter'])) {
             foreach ($this->_options['property_type_include_filter'] as $key => $value) {
                 $new_key = strtolower($key);
                 $filter_property_types[$new_key] = $value;
                 if ($value != 'false') {
                     $filter_used = true;
                 }
             }
         }
         if (!empty($property_types) && !empty($filter_used)) {
             foreach ($property_types as $property_type_key => $value) {
                 if (isset($filter_property_types[$property_type_key]) && $filter_property_types[$property_type_key] == 'false') {
                     unset($property_types[$property_type_key]);
                 }
             }
         }
         $this->_model['property_types'] = $property_types;
         $this->_model['property_type_points'] = array_values($property_types);
     }
 }
    function form($instance)
    {
        $title = isset($instance['title']) ? strip_tags($instance['title']) : 'Search Properties';
        $id = isset($instance['id']) ? intval($instance['id']) : 1;
        $search_forms = DispletRetsIdxOptionsController::get_option('search_forms');
        $registered_quick_search_ids = array(1 => 1);
        if (!empty($search_forms) && is_array($search_forms)) {
            foreach ($search_forms as $key => $search_form) {
                if ($key > 3) {
                    $form_id = $key - 3;
                    $registered_quick_search_ids[$form_id] = $form_id;
                }
            }
        }
        ?>
        <p>
			<label for="<?php 
        echo $this->get_field_id('title');
        ?>
">
				Title:
			</label>
			<input class="widefat" id="<?php 
        echo $this->get_field_id('title');
        ?>
" name="<?php 
        echo $this->get_field_name('title');
        ?>
" type="text" value="<?php 
        echo esc_attr($title);
        ?>
" />
		</p>
        <p>
			<label for="<?php 
        echo $this->get_field_id('id');
        ?>
">
				Form ID:
			</label>
			<select class="widefat" id="<?php 
        echo $this->get_field_id('id');
        ?>
" name="<?php 
        echo $this->get_field_name('id');
        ?>
">
				<?php 
        if (!empty($registered_quick_search_ids)) {
            foreach ($registered_quick_search_ids as $option_id) {
                ?>
					<option value="<?php 
                echo $option_id;
                ?>
" <?php 
                selected($option_id, $id);
                ?>
>
						<?php 
                echo $option_id;
                ?>
					</option>
				<?php 
            }
        }
        ?>
			</select>
		</p>
	<?php 
    }
 public static function update_field_options($options, $update_settings_page = false)
 {
     if (!empty($options['displet_app_key'])) {
         $field_options = array('area_mls_defined' => self::get_field_values('area_mls_defined', $options['displet_app_key']), 'city' => self::get_field_values('city', $options['displet_app_key']), 'property_type' => self::get_field_values('property_type', $options['displet_app_key']), 'school_district' => self::get_field_values('school_district', $options['displet_app_key']), 'state' => self::get_field_values('state', $options['displet_app_key']), 'status' => self::get_field_values('status', $options['displet_app_key']), 'zip' => self::get_field_values('zip', $options['displet_app_key']));
         foreach ($field_options as $field => $value) {
             if (is_array($value)) {
                 foreach ($value as $key => $val) {
                     $value[$val] = $val;
                     unset($value[$key]);
                 }
             } else {
                 $value = array();
             }
             if ($update_settings_page) {
                 self::$_settings_page->update_field($field . '_include_filter', $value);
             }
         }
         DispletRetsIdxOptionsController::update_option('fields', $field_options);
         do_action('displetretsidx_post_field_options_update', $field_options);
     }
 }
예제 #9
0
<?php

include_once dirname(__FILE__) . '/../../../../../wp-load.php';
include_once ABSPATH . 'wp-admin/includes/plugin.php';
global $displetretsidx_option;
$model = array('options' => $displetretsidx_option, 'field_options' => DispletRetsIdxOptionsController::get_option('fields'));
?>
<!DOCTYPE html>
<html>
<head>
	<title>
		Displet RETS/IDX Listing Criteria
	</title>
	<link rel="stylesheet" type="text/css" href="<?php 
echo plugins_url('displetreader-wordpress-plugin/includes/css/displet-rets-idx-admin-styles.css');
?>
"/>
	<script>
		var displetretsidx_admin = {
			first_city: '<?php 
if (!empty($model["field_options"]["city"][0])) {
    echo $model["field_options"]["city"][0];
}
?>
',
			images: {
				close: '<?php 
echo plugins_url("displetreader-wordpress-plugin/includes/css/images/close.png");
?>
',
				close_hover: '<?php 
 public static function set_search_forms($search_forms, $from_update = false)
 {
     if (!empty($search_forms)) {
         if ($from_update && empty(self::$_model)) {
             self::$_model = array();
         }
         self::_set_defaults();
         self::_set_field_options();
         foreach ($search_forms as &$form) {
             if (!empty($form)) {
                 foreach ($form as &$column) {
                     if (!empty($column)) {
                         foreach ($column as &$field) {
                             if (!empty(self::$_model['search_fields'][$field])) {
                                 $new_field = array('label' => !empty(self::$_model['search_fields'][$field]['label']) ? self::$_model['search_fields'][$field]['label'] : self::$_model['search_fields'][$field]['title'], 'field' => $field, 'options' => self::$_model['search_fields'][$field]['options'], 'min' => self::$_model['search_fields'][$field]['range']['min'], 'max' => self::$_model['search_fields'][$field]['range']['max'], 'increment' => self::$_model['search_fields'][$field]['range']['increment']);
                                 if ($from_update) {
                                     if ($field === 'price' || $field === 'price_max' || $field === 'price_min') {
                                         if (!empty(self::$_options['search_values_custom_prices'])) {
                                             $new_field['range'] = array_map(array('DispletRetsIdxUtilities', 'increase_by_three_orders_of_magnitude'), array_map('trim', explode("\n", self::$_options['search_values_custom_prices'])));
                                         }
                                         if (!empty(self::$_options['search_values_min_price'])) {
                                             $new_field['min'] = intval(self::$_options['search_values_min_price']) * 1000;
                                         }
                                         if (!empty(self::$_options['search_values_max_price'])) {
                                             $new_field['max'] = intval(self::$_options['search_values_max_price']) * 1000;
                                         }
                                         if (!empty(self::$_options['search_values_price_increment'])) {
                                             $new_field['increment'] = intval(self::$_options['search_values_price_increment']) * 1000;
                                         }
                                     } else {
                                         if ($field === 'beds' || $field === 'beds_max' || $field === 'beds_baths') {
                                             if (!empty(self::$_options['search_values_beds_min'])) {
                                                 $new_field['min'] = intval(self::$_options['search_values_beds_min']);
                                             }
                                             if (!empty(self::$_options['search_values_beds_max'])) {
                                                 $new_field['max'] = intval(self::$_options['search_values_beds_max']);
                                             }
                                         } else {
                                             if ($field === 'baths' || $field === 'baths_max') {
                                                 if (!empty(self::$_options['search_values_baths_min'])) {
                                                     $new_field['min'] = intval(self::$_options['search_values_baths_min']);
                                                 }
                                                 if (!empty(self::$_options['search_values_baths_max'])) {
                                                     $new_field['max'] = intval(self::$_options['search_values_baths_max']);
                                                 }
                                             } else {
                                                 if ($field === 'square_feet' || $field === 'square_feet_max' || $field === 'square_feet_min') {
                                                     if (!empty(self::$_options['search_values_min_square_feet'])) {
                                                         $new_field['min'] = intval(self::$_options['search_values_min_square_feet']);
                                                     }
                                                     if (!empty(self::$_options['search_values_max_square_feet'])) {
                                                         $new_field['max'] = intval(self::$_options['search_values_max_square_feet']);
                                                     }
                                                     if (!empty(self::$_options['search_values_square_feet_increment'])) {
                                                         $new_field['increment'] = intval(self::$_options['search_values_square_feet_increment']);
                                                     }
                                                 } else {
                                                     if ($field === 'acres_min') {
                                                         if (!empty(self::$_options['search_values_min_acres'])) {
                                                             $new_field['min'] = floatval(self::$_options['search_values_min_acres']);
                                                         }
                                                         if (!empty(self::$_options['search_values_max_acres'])) {
                                                             $new_field['max'] = floatval(self::$_options['search_values_max_acres']);
                                                         }
                                                         if (!empty(self::$_options['search_values_acres_increment'])) {
                                                             $new_field['increment'] = floatval(self::$_options['search_values_acres_increment']);
                                                         }
                                                     } else {
                                                         if ($field === 'property_type' || $field === 'property_type_select') {
                                                             if (!empty(self::$_options['search_values_property_types'])) {
                                                                 $property_types = array_filter(self::$_options['search_values_property_types'], array('DispletRetsIdxUtilities', 'remove_false_as_string'));
                                                                 if (!empty($property_types)) {
                                                                     $new_field['options'] = array_keys($property_types);
                                                                 }
                                                             }
                                                         }
                                                     }
                                                 }
                                             }
                                         }
                                     }
                                 }
                                 $field = $new_field;
                             }
                         }
                     }
                 }
             }
         }
         DispletRetsIdxOptionsController::update_option('search_forms', $search_forms);
     }
 }
 private static function _set_page_choices()
 {
     $pages = get_pages();
     self::$_choices['pages'] = DispletRetsIdxOptionsController::get_associative_array_from_post_objects($pages);
 }