". __("Manage Locations", SLPLUS_PREFIX).""; // Save all values except a few for subsequent form processing // $hidden=''; foreach($_REQUEST as $key=>$val) { if ($key!="q" && $key!="o" && $key!="d" && $key!="start" && $key!="act" && $key!='sl_tags' && $key!='sl_id') { $hidden.="\n"; } } // Header Text // print "

". __('Store Locator Plus - Manage Locations', SLPLUS_PREFIX). "

"; //------------------------- // Navbar Section //------------------------- print '
'; print get_string_from_phpexec(SLPLUS_COREDIR.'/templates/navbar.php'); print '
'; // Check Google API Key // Not present : show message // $slak=$slplus_plugin->driver_args['api_key']; if (!$slak) { print ''; _e('Google API Key needs to be set to activate this feature.', SLPLUS_PREFIX); print ''; // Got key - show forms and listing // } else { // Initialize Variables // initialize_variables(); // If delete link is clicked if (isset($_GET['delete']) && ($_GET['delete']!='')) { $wpdb->query("DELETE FROM ".$wpdb->prefix."store_locator ". "WHERE sl_id='".$_GET['delete']."'"); } // Edit, any form // if ($_POST && (isset($_GET['edit']) && $_GET['edit']) && (!isset($_POST['act']) || (isset($_POST['act']) && ($_POST['act']!="delete"))) ) { $field_value_str = ''; foreach ($_POST as $key=>$value) { if (ereg("\-$_GET[edit]", $key)) { $field_value_str.="sl_".ereg_replace("\-$_GET[edit]", "", $key)."='". trim(comma($value))."', "; // strip off number at the end $key=ereg_replace("\-$_GET[edit]", "", $key); $_POST["$key"]=$value; } } $field_value_str=substr($field_value_str, 0, strlen($field_value_str)-2); $edit=$_GET['edit']; extract($_POST); $the_address="$address $address2, $city, $state $zip"; $old_address=$wpdb->get_results("SELECT * FROM ". $wpdb->prefix."store_locator WHERE sl_id=$_GET[edit]", ARRAY_A); $wpdb->query("UPDATE ".$wpdb->prefix."store_locator SET $field_value_str " . "WHERE sl_id=$_GET[edit]"); if (!isset($old_address['sl_address'])) { $old_address['sl_address'] = ''; } if (!isset($old_address['sl_address2'])){ $old_address['sl_address2'] = ''; } if (!isset($old_address['sl_city'])) { $old_address['sl_city'] = ''; } if (!isset($old_address['sl_state'])) { $old_address['sl_state'] = ''; } if (!isset($old_address['sl_zip'])) { $old_address['sl_zip'] = ''; } if ($the_address!= "$old_address[sl_address] $old_address[sl_address2], $old_address[sl_city], " . "$old_address[sl_state] $old_address[sl_zip]" || ($old_address['sl_latitude']=="" || $old_address['sl_longitutde']=="") ) { do_geocoding($the_address,$_GET['edit']); } print ""; } // ACTION HANDLER //If post action is set // if (isset($_REQUEST['act'])) { // Delete Action if ($_REQUEST['act']=="delete") { if ($_POST) {extract($_POST);} if (isset($sl_id)) { if (is_array($sl_id)==1) { $id_string=""; foreach ($sl_id as $value) { $id_string.="$value,"; } $id_string=substr($id_string, 0, strlen($id_string)-1); } else { $id_string=$sl_id; } if ($id_string != '') { $wpdb->query("DELETE FROM ".$wpdb->prefix."store_locator WHERE sl_id IN ($id_string)"); } } // Tagging Action } elseif (eregi("tag", $_REQUEST['act'])) { //adding or removing tags for specified a locations if ($_POST) {extract($_POST);} if (isset($sl_id)) { if (is_array($sl_id)) { $id_string=''; foreach ($sl_id as $value) { $id_string.="$value,"; } $id_string=substr($id_string, 0, strlen($id_string)-1); } else { $id_string=$sl_id; } // If we have some store IDs // if ($id_string != '') { //adding tags if ($act=="add_tag") { $wpdb->query("UPDATE ".$wpdb->prefix."store_locator SET sl_tags=CONCAT(sl_tags, '".strtolower($sl_tags).", ') WHERE sl_id IN ($id_string)"); //removing tags } elseif ($act=="remove_tag") { if (empty($sl_tags)) { //if no tag is specified, all tags will be removed from selected locations $wpdb->query("UPDATE ".$wpdb->prefix."store_locator SET sl_tags='' WHERE sl_id IN ($id_string)"); } else { $wpdb->query("UPDATE ".$wpdb->prefix."store_locator SET sl_tags=REPLACE(sl_tags, '$sl_tags,', '') WHERE sl_id IN ($id_string)"); } } } } // Locations Per Page Action } elseif ($_REQUEST['act']=="locationsPerPage") { //If bulk delete is used update_option('sl_admin_locations_per_page', $_REQUEST['sl_admin_locations_per_page']); extract($_REQUEST); // Change View Action // } elseif ($_REQUEST['act']=='changeview') { if (get_option('sl_location_table_view') == 'Expanded') { update_option('sl_location_table_view', 'Normal'); } else { update_option('sl_location_table_view', 'Expanded'); } // Recode The Address // } elseif ($_REQUEST['act']=='recode') { if (isset($_REQUEST['sl_id'])) { if (!is_array($_REQUEST['sl_id'])) { $theLocations = array($_REQUEST['sl_id']); } else { $theLocations = $_REQUEST['sl_id']; } // Process SL_ID Array // foreach ($theLocations as $thisLocation) { $address=$wpdb->get_row("SELECT * FROM ".$wpdb->prefix."store_locator WHERE sl_id=$thisLocation", ARRAY_A); if (!isset($address['sl_address'])) { $address['sl_address'] = ''; print 'BLANK
'; } if (!isset($address['sl_address2'])){ $address['sl_address2'] = ''; } if (!isset($address['sl_city'])) { $address['sl_city'] = ''; } if (!isset($address['sl_state'])) { $address['sl_state'] = ''; } if (!isset($address['sl_zip'])) { $address['sl_zip'] = ''; } do_geocoding("$address[sl_address] $address[sl_address2], $address[sl_city], $address[sl_state] $address[sl_zip]",$thisLocation); } } } } // Changing Updater // if (isset($_GET['changeUpdater']) && ($_GET['changeUpdater']==1)) { if (get_option('sl_location_updater_type')=="Tagging") { update_option('sl_location_updater_type', 'Multiple Fields'); $updaterTypeText="Multiple Fields"; } else { update_option('sl_location_updater_type', 'Tagging'); $updaterTypeText="Tagging"; } $_SERVER['REQUEST_URI']=ereg_replace("&changeUpdater=1", "", $_SERVER['REQUEST_URI']); print ""; } //------------------------- // Actionbar Section //------------------------- print '
'; print get_string_from_phpexec(SLPLUS_COREDIR.'/templates/managelocations_actionbar.php'); print '
'; set_query_defaults(); /* Uncoded items */ if (isset($_REQUEST['act'])) { if ($_REQUEST['act'] == 'show_uncoded') { if ($where == '') { $where = 'WHERE '; } $where .= ' sl_latitude IS NULL or sl_longitude IS NULL'; } } //for search links $numMembers=$wpdb->get_results( "SELECT sl_id FROM " . $wpdb->prefix . "store_locator $where"); $numMembers2=count($numMembers); $start=(isset($_GET['start'])&&(trim($_GET['start'])!=''))?$_GET['start']:0; //edit this to determine how many locations to view per page of 'Manage Locations' page $num_per_page=$sl_admin_locations_per_page; if ($numMembers2!=0) {include(SLPLUS_COREDIR.'search-links.php');} $opt = isset($_GET['o']) ? $_GET['o'] : ''; $dir = isset($_GET['d']) ? $_GET['d'] : ''; print "
"; if (get_option('sl_location_table_view')!="Normal") { print "". "". "". "". "". ""; } print ""; if ($locales=$wpdb->get_results("SELECT * FROM " . $wpdb->prefix . "store_locator $where ORDER BY $o $d LIMIT $start,$num_per_page", ARRAY_A)) { $bgcol = '#eee'; foreach ($locales as $value) { $locID = $value['sl_id']; $bgcol=($bgcol=="#eee")?"#fff":"#eee"; $bgcol=($value['sl_latitude']=="" || $value['sl_longitude']=="")? "salmon" : $bgcol; $value=array_map("trim",$value); // EDIT MODE // if (isset($_GET['edit']) && ($locID==$_GET['edit'])) { print ""; $colspan=(get_option('sl_location_table_view')!="Normal")? 16 : 11; print ""; // DISPLAY MODE // } else { $value['sl_url']=(!url_test($value['sl_url']) && trim($value['sl_url'])!="")? "http://".$value['sl_url'] : $value['sl_url'] ; $value['sl_url']=($value['sl_url']!="")? "".__("View", SLPLUS_PREFIX)."" : "" ; $value['sl_email']=($value['sl_email']!="")? "".__("Email", SLPLUS_PREFIX)."" : "" ; $value['sl_image']=($value['sl_image']!="")? "".__("View", SLPLUS_PREFIX)."" : "" ; $value['sl_description']=($value['sl_description']!="")? "". __("View", SLPLUS_PREFIX)."" : "" ; print ""; if (get_option('sl_location_table_view')!="Normal") { print ""; } print ""; } } } else { $notice=( isset($_GET['q']) && ($_GET['q']!="") )? __("No Locations Showing for this Search of ", SLPLUS_PREFIX). "\"$_GET[q]\". $view_link" : __("No Locations Currently in Database", SLPLUS_PREFIX); print ""; } print "
".__("Actions", SLPLUS_PREFIX)." ".__("ID", SLPLUS_PREFIX)." ".__("Name", SLPLUS_PREFIX)." ".__("Street", SLPLUS_PREFIX)." ".__("Street2", SLPLUS_PREFIX)." ".__("City", SLPLUS_PREFIX)." ".__("State", SLPLUS_PREFIX)." ".__("Zip", SLPLUS_PREFIX)." ".__("Tags", SLPLUS_PREFIX)."".__("Description", SLPLUS_PREFIX)."".__("URL", SLPLUS_PREFIX)."".__("Email", SLPLUS_PREFIX)."".__("Hours", SLPLUS_PREFIX)."".__("Phone", SLPLUS_PREFIX)."".__("Image", SLPLUS_PREFIX)."(Lat, Lon)
"; execute_and_output_template('edit_location_address.php'); print "
".__("Additional Information", SLPLUS_PREFIX)."
 ".__("Description", SLPLUS_PREFIX)."
 ".__("Tags (seperate with commas)", SLPLUS_PREFIX)."
 ".__("URL", SLPLUS_PREFIX)."
 ".__("Email", SLPLUS_PREFIX)."
 ".__("Hours", SLPLUS_PREFIX)."
 ".__("Phone", SLPLUS_PREFIX)."
 ".__("Image URL (shown with location)", SLPLUS_PREFIX)."

". " ". " " . " ". " $locID $value[sl_store] $value[sl_address] $value[sl_address2] $value[sl_city] $value[sl_state] $value[sl_zip] $value[sl_tags]$value[sl_description] $value[sl_url] $value[sl_email] $value[sl_hours] $value[sl_phone] $value[sl_image](".$value['sl_latitude'].", ".$value['sl_longitude'].")
$notice | ". __("Add Locations", SLPLUS_PREFIX)."

"; if ($numMembers2!=0) {include(SLPLUS_COREDIR.'/search-links.php');} print ""; } print "
"; /*-----------------------------------------------------------*/ function url_test($url) { return (strtolower(substr($url,0,7))=="http://"); } /*---------------------------------*/ function set_query_defaults() { global $where, $o, $d; $qry = isset($_REQUEST['q']) ? $_REQUEST['q'] : ''; $where=($qry!='')? " WHERE ". "sl_store LIKE '%$qry%' OR ". "sl_address LIKE '%$qry%' OR ". "sl_address2 LIKE '%$qry%' OR ". "sl_city LIKE '%$qry%' OR ". "sl_state LIKE '%$qry%' OR ". "sl_zip LIKE '%$qry%' OR ". "sl_tags LIKE '%$qry%' " : '' ; $o= (isset($_GET['o']) && (trim($_GET['o']) != '')) ? $_GET['o'] : "sl_store"; $d= (isset($_GET['d']) && (trim($_GET['d'])=='DESC')) ? "DESC" : "ASC"; }