* @link http://wp-dreams.com, http://codecanyon.net/user/anago/portfolio * @copyright Copyright (c) 2014, Ernest Marcinko */ class wpdreamsBP_XProfileFields extends wpdreamsType { private $selected; private $types; function getType() { $profile_fields = $this->getProfileFields(); $pf_array = array(); foreach ($profile_fields as $pf) $pf_array[$pf->id] = $pf; parent::getType(); $this->processData(); $this->types = $profile_fields; echo "
" . $this->label . ""; echo '
' . __('Available profile fields', 'ajax-search-pro') . '
    '; if ($this->types != null && is_array($this->types)) { foreach ($this->types as $k => $v) { if ($this->selected == null || !in_array($v->id, $this->selected)) { echo '
  • ' . $v->name . '
  • '; } } } echo "
"; echo '
' . __('Drag here the fields you want to search!', 'ajax-search-pro') . '
    '; if ($this->selected != null && is_array($this->selected)) { foreach ($this->selected as $k => $v) { if ( isset($pf_array[$v]) ) { echo '
  • ' . $pf_array[$v]->name . '
  • '; } } } echo "
"; echo " "; echo " "; echo "
"; } function getProfileFields() { global $wpdb; $table_name = $wpdb->base_prefix . "bp_xprofile_fields"; if( $wpdb->get_var("SHOW TABLES LIKE '$table_name'") == $table_name ) return $wpdb->get_results( "SELECT * FROM $table_name LIMIT 200" ); else return array(); } function processData() { $this->data = str_replace("\n", "", $this->data); if ($this->data != "") $this->selected = explode("|", $this->data); else $this->selected = null; } final function getData() { return $this->data; } final function getSelected() { return $this->selected; } } }